Documentation
¶
Overview ¶
Package embedder provides text embedding using Hugging Face transformers via hugot. It uses ONNX models for efficient, native Go embeddings without external processes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("embedder is closed")
var ErrLocalModelMissing = errors.New("local embedding model missing")
ErrLocalModelMissing means no model.onnx exists under the explicit directory.
Functions ¶
This section is empty.
Types ¶
type Embedder ¶
type Embedder struct {
// contains filtered or unexported fields
}
Embedder generates text embeddings using hugot (Hugging Face ONNX runtime).
func New ¶
New creates a new Embedder. It downloads (if needed) and loads the model. If modelsDir is empty, it uses the bundled model in ./models/onnx/.
func NewLocal ¶
NewLocal loads only from modelsDir/model.onnx or modelsDir/onnx/model.onnx. It never probes the process working directory or downloads a model.
func (*Embedder) CreateEmbedding ¶
CreateEmbedding generates a float32 vector for given text.
func (*Embedder) CreateEmbeddings ¶
CreateEmbeddings batch-embeds multiple texts in a single forward pass. It processes texts in chunks of 64 (recommended by hugot) and handles shape mismatches by falling back to single embeddings when needed.
type Identity ¶
type Identity struct {
Model string `json:"model"`
Dimension int `json:"dimension"`
Metric string `json:"metric"`
Normalize bool `json:"normalize"`
Provider string `json:"provider"`
Version string `json:"version"`
CapturedAt time.Time `json:"captured_at"`
}
Identity represents the exact characteristics of the embedding model used, to ensure vectors can be matched correctly in the database.