convert

package
v0.0.0-...-e65ccaf Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertAdapter

func ConvertAdapter(fsys fs.FS, ws io.WriteSeeker, baseKV ggml.KV) error

func ConvertModel

func ConvertModel(fsys fs.FS, ws io.WriteSeeker) error

Convert writes an Ollama compatible model to the provided io.WriteSeeker based on configurations and files it finds in the input path. Supported input model formats include safetensors. Supported input tokenizers files include tokenizer.json (preferred) and tokenizer.model.

func NewZipReader

func NewZipReader(r *zip.Reader, p string, limit int64) fs.FS

Types

type AdapterConverter

type AdapterConverter interface {
	// KV maps parameters to LLM key-values
	KV(ggml.KV) ggml.KV
	// Tensors maps input tensors to LLM tensors. Adapter specific modifications can be done here.
	Tensors([]Tensor) []ggml.Tensor
	// Replacements returns a list of string pairs to replace in tensor names.
	// See [strings.Replacer](https://pkg.go.dev/strings#Replacer) for details
	Replacements() []string
	// contains filtered or unexported methods
}

type AdapterParameters

type AdapterParameters struct {
	Alpha          uint32 `json:"lora_alpha"`
	LoraLayers     uint32 `json:"lora_layers"`
	LoraParameters struct {
		Rank  uint32  `json:"rank"`
		Alpha float32 `json:"alpha"`
		Scale float32 `json:"scale"`
	} `json:"lora_parameters"`
}

func (AdapterParameters) KV

func (p AdapterParameters) KV() ggml.KV

type ModelConverter

type ModelConverter interface {
	// KV maps parameters to LLM key-values
	KV(*Tokenizer) ggml.KV
	// Tensors maps input tensors to LLM tensors. Model specific modifications can be done here.
	Tensors([]Tensor) []ggml.Tensor
	// Replacements returns a list of string pairs to replace in tensor names.
	// See [strings.Replacer](https://pkg.go.dev/strings#Replacer) for details
	Replacements() []string
	// contains filtered or unexported methods
}

type ModelParameters

type ModelParameters struct {
	Architectures []string `json:"architectures"`
	VocabSize     uint32   `json:"vocab_size"`
}

func (ModelParameters) KV

type SpecialVocabulary

type SpecialVocabulary struct {
	Type     string
	ID       int
	Content  string
	AddToken bool
}

func (SpecialVocabulary) Key

func (sv SpecialVocabulary) Key() string

type Tensor

type Tensor interface {
	Name() string
	Shape() []uint64
	Kind() uint32
	SetRepacker(repacker)
	WriteTo(io.Writer) (int64, error)
}

type Tokenizer

type Tokenizer struct {
	*Vocabulary
	SpecialVocabulary []*SpecialVocabulary
	Merges            []string

	Pre      string
	Template string
}

type Vocabulary

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

type ZipReader

type ZipReader struct {
	// contains filtered or unexported fields
}

func (*ZipReader) Open

func (z *ZipReader) Open(name string) (fs.File, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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