llm

package
v0.1.29 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Magic constant for `ggml` files (unversioned).
	FILE_MAGIC_GGML = 0x67676d6c
	// Magic constant for `ggml` files (versioned, ggmf).
	FILE_MAGIC_GGMF = 0x67676d66
	// Magic constant for `ggml` files (versioned, ggjt).
	FILE_MAGIC_GGJT = 0x67676a74
	// Magic constant for `ggla` files (LoRA adapter).
	FILE_MAGIC_GGLA = 0x67676C61
	// Magic constant for `gguf` files (versioned, gguf)
	FILE_MAGIC_GGUF_LE = 0x46554747
	FILE_MAGIC_GGUF_BE = 0x47475546
)
View Source
const (
	GGUFTokenNormal uint32
	GGUFTokenUnknown
	GGUFTokenControl
	GGUFTokenUserDefined
	GGUFTokenUnused
	GGUFTokenByte
)
View Source
const (
	GGUFTypeUint8 uint32 = iota
	GGUFTypeInt8
	GGUFTypeUint16
	GGUFTypeInt16
	GGUFTypeUint32
	GGUFTypeInt32
	GGUFTypeFloat32
	GGUFTypeBool
	GGUFTypeString
	GGUFTypeArray
	GGUFTypeUint64
	GGUFTypeInt64
	GGUFTypeFloat64
)

Variables

View Source
var ErrUnsupportedFormat = errors.New("unsupported model format")

Functions

func Init added in v0.1.18

func Init() error

Give any native cgo implementations an opportunity to initialize

Types

type ContainerGGLA added in v0.1.29

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

func (*ContainerGGLA) Decode added in v0.1.29

func (c *ContainerGGLA) Decode(rso *readSeekOffset) (model, error)

func (*ContainerGGLA) Name added in v0.1.29

func (c *ContainerGGLA) Name() string

type ContainerGGUF added in v0.1.29

type ContainerGGUF struct {
	ByteOrder binary.ByteOrder

	Version uint32

	V1 struct {
		NumTensor uint32
		NumKV     uint32
	}

	V2 struct {
		NumTensor uint64
		NumKV     uint64
	}

	V3 struct {
		NumTensor uint64
		NumKV     uint64
	}
}

func (*ContainerGGUF) Decode added in v0.1.29

func (c *ContainerGGUF) Decode(rso *readSeekOffset) (model, error)

func (*ContainerGGUF) Name added in v0.1.29

func (c *ContainerGGUF) Name() string

type DetokenizeRequest added in v0.0.18

type DetokenizeRequest struct {
	Tokens []int `json:"tokens"`
}

type DetokenizeResponse added in v0.0.18

type DetokenizeResponse struct {
	Content string `json:"content"`
}

type EmbeddingRequest added in v0.0.18

type EmbeddingRequest struct {
	Content string `json:"content"`
}

type EmbeddingResponse added in v0.0.18

type EmbeddingResponse struct {
	Embedding []float64 `json:"embedding"`
}

type GGML

type GGML struct {
	Size int64
	// contains filtered or unexported fields
}

func DecodeGGML

func DecodeGGML(r io.ReadSeeker) (*GGML, error)

type GGUFModel added in v0.1.29

type GGUFModel struct {
	*ContainerGGUF

	KV
	Tensors []Tensor
	// contains filtered or unexported fields
}

func NewGGUFModel added in v0.1.29

func NewGGUFModel(container *ContainerGGUF) *GGUFModel

func (*GGUFModel) Decode added in v0.1.29

func (llm *GGUFModel) Decode(rso *readSeekOffset) error

func (*GGUFModel) Encode added in v0.1.29

func (llm *GGUFModel) Encode(f *os.File) error

func (*GGUFModel) FileType added in v0.1.29

func (llm *GGUFModel) FileType() string

func (*GGUFModel) ModelFamily added in v0.1.29

func (llm *GGUFModel) ModelFamily() string

func (*GGUFModel) ModelType added in v0.1.29

func (llm *GGUFModel) ModelType() string

func (*GGUFModel) NumCtx added in v0.1.29

func (llm *GGUFModel) NumCtx() uint32

func (*GGUFModel) NumEmbed added in v0.1.29

func (llm *GGUFModel) NumEmbed() uint32

func (*GGUFModel) NumGQA added in v0.1.29

func (llm *GGUFModel) NumGQA() uint32

func (*GGUFModel) NumHead added in v0.1.29

func (llm *GGUFModel) NumHead() uint32

func (*GGUFModel) NumHeadKv added in v0.1.29

func (llm *GGUFModel) NumHeadKv() uint32

func (*GGUFModel) NumKV added in v0.1.29

func (llm *GGUFModel) NumKV() uint64

func (*GGUFModel) NumLayers added in v0.1.29

func (llm *GGUFModel) NumLayers() uint32

func (*GGUFModel) NumTensor added in v0.1.29

func (llm *GGUFModel) NumTensor() uint64

type ImageData added in v0.1.15

type ImageData struct {
	Data []byte `json:"data"`
	ID   int    `json:"id"`
}

type KV added in v0.1.29

type KV map[string]any

type LLM

type LLM interface {
	Predict(context.Context, PredictOpts, func(PredictResult)) error
	Embedding(context.Context, string) ([]float64, error)
	Encode(context.Context, string) ([]int, error)
	Decode(context.Context, []int) (string, error)
	Close()
}

func New

func New(model string, adapters, projectors []string, opts api.Options) (LLM, error)

type ModelGGLA added in v0.1.29

type ModelGGLA struct {
	*ContainerGGLA
	// contains filtered or unexported fields
}

func (*ModelGGLA) FileType added in v0.1.29

func (*ModelGGLA) FileType() string

func (*ModelGGLA) KV added in v0.1.29

func (m *ModelGGLA) KV() KV

func (*ModelGGLA) ModelFamily added in v0.1.29

func (*ModelGGLA) ModelFamily() string

func (*ModelGGLA) ModelType added in v0.1.29

func (*ModelGGLA) ModelType() string

func (*ModelGGLA) NumCtx added in v0.1.29

func (*ModelGGLA) NumCtx() uint32

func (*ModelGGLA) NumEmbed added in v0.1.29

func (*ModelGGLA) NumEmbed() uint32

func (*ModelGGLA) NumGQA added in v0.1.29

func (*ModelGGLA) NumGQA() uint32

func (*ModelGGLA) NumHead added in v0.1.29

func (*ModelGGLA) NumHead() uint32

func (*ModelGGLA) NumHeadKv added in v0.1.29

func (*ModelGGLA) NumHeadKv() uint32

func (*ModelGGLA) NumLayers added in v0.1.29

func (*ModelGGLA) NumLayers() uint32

func (*ModelGGLA) Tensor added in v0.1.29

func (m *ModelGGLA) Tensor() []Tensor

type PredictOpts added in v0.1.14

type PredictOpts struct {
	Prompt  string
	Format  string
	Images  []ImageData
	Options api.Options
}

type PredictResult added in v0.1.14

type PredictResult struct {
	Content            string
	Done               bool
	PromptEvalCount    int
	PromptEvalDuration time.Duration
	EvalCount          int
	EvalDuration       time.Duration
}

type Tensor added in v0.1.29

type Tensor struct {
	Name   string
	Kind   uint32
	Offset uint64

	// shape is the number of elements in each dimension
	Shape []uint64

	FileName      string
	OffsetPadding uint64
	FileOffsets   []uint64
}

func (Tensor) BlockSize added in v0.1.29

func (t Tensor) BlockSize() uint64

func (Tensor) Parameters added in v0.1.29

func (t Tensor) Parameters() uint64

func (Tensor) Repack added in v0.1.29

func (t Tensor) Repack(data []uint16, heads int) ([]uint16, error)

func (Tensor) Size added in v0.1.29

func (t Tensor) Size() uint64

func (Tensor) TypeSize added in v0.1.29

func (t Tensor) TypeSize() uint64

type TokenizeRequest added in v0.0.18

type TokenizeRequest struct {
	Content string `json:"content"`
}

type TokenizeResponse added in v0.0.18

type TokenizeResponse struct {
	Tokens []int `json:"tokens"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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