llm

package
v0.1.28 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 24 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
)

Variables

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

Functions

func Init added in v0.1.18

func Init(workdir string) error

Give any native cgo implementations an opportunity to initialize

Types

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 ImageData added in v0.1.15

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

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(workDir, model string, adapters, projectors []string, opts api.Options) (LLM, error)

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 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