convert

package
v0.1.32 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSafeTensors

func GetSafeTensors(dirpath string, params *Params) ([]llm.Tensor, error)

func GetTensorName

func GetTensorName(n string) (string, error)

func ReadSafeTensors

func ReadSafeTensors(fn string, offset uint64, params *Params) ([]llm.Tensor, uint64, error)

Types

type ByteOrder added in v0.1.32

type ByteOrder interface {
	binary.ByteOrder
	binary.AppendByteOrder
}

type GemmaModel added in v0.1.32

type GemmaModel struct {
	ModelData
}

func (*GemmaModel) GetTensors added in v0.1.32

func (m *GemmaModel) GetTensors() error

func (*GemmaModel) LoadVocab added in v0.1.32

func (m *GemmaModel) LoadVocab() error

func (*GemmaModel) WriteGGUF added in v0.1.32

func (m *GemmaModel) WriteGGUF() (string, error)

type MetaData

type MetaData struct {
	Type    string `mapstructure:"dtype"`
	Shape   []int  `mapstructure:"shape"`
	Offsets []int  `mapstructure:"data_offsets"`
}

type MistralModel added in v0.1.32

type MistralModel struct {
	ModelData
}

func (*MistralModel) GetTensors added in v0.1.32

func (m *MistralModel) GetTensors() error

func (*MistralModel) LoadVocab added in v0.1.32

func (m *MistralModel) LoadVocab() error

func (*MistralModel) WriteGGUF added in v0.1.32

func (m *MistralModel) WriteGGUF() (string, error)

type ModelArch added in v0.1.32

type ModelArch interface {
	GetTensors() error
	LoadVocab() error
	WriteGGUF() (string, error)
}

func GetModelArchFromParams added in v0.1.32

func GetModelArchFromParams(name, dirPath string, params *Params) (ModelArch, error)

type ModelData added in v0.1.32

type ModelData struct {
	Path    string
	Name    string
	Params  *Params
	Vocab   *Vocab
	Tensors []llm.Tensor
}

type Params

type Params struct {
	Architectures    []string `json:"architectures"`
	VocabSize        int      `json:"vocab_size"`
	HiddenSize       int      `json:"hidden_size"`       // n_embd
	HiddenLayers     int      `json:"num_hidden_layers"` // n_layer
	ContextSize      int      `json:"max_position_embeddings"`
	IntermediateSize int      `json:"intermediate_size"`
	AttentionHeads   int      `json:"num_attention_heads"` // n_head
	KeyValHeads      int      `json:"num_key_value_heads"`
	NormEPS          float64  `json:"rms_norm_eps"`
	BoSTokenID       int      `json:"bos_token_id"`
	EoSTokenID       int      `json:"eos_token_id"`
	HeadDimension    int      `json:"head_dim"`
	PaddingTokenID   int      `json:"pad_token_id"`

	ByteOrder
}

func GetParams

func GetParams(dirpath string) (*Params, error)

type Vocab

type Vocab struct {
	Tokens []string
	Scores []float32
	Types  []int32
}

Details on gguf's tokenizer can be found at: https://github.com/ggerganov/ggml/blob/master/docs/gguf.md#tokenizer

func LoadSentencePieceTokens added in v0.1.32

func LoadSentencePieceTokens(dirpath string, vocabSize int) (*Vocab, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL