Documentation
¶
Overview ¶
Package embeddings provides an in-process text embedding engine backed by the nomic-embed-text-v1.5 model whose weights are compiled into the baifo binary. It has no cgo and no heavyweight dependencies: the model is a small (~137M parameter) BERT-style encoder run in pure Go.
The public surface is intentionally tiny: New() loads the embedded model once, and Embed/EmbedBatch turn text into 768-dimensional float32 vectors suitable for cosine-similarity search.
Index ¶
Constants ¶
const Dimension = 768
Dimension is the size of every embedding vector this engine produces.
const MaxTokens = 2048
MaxTokens caps the sequence length fed to the model. nomic-embed-text supports up to 8192 via RoPE; we default to a sane 2048 to bound the O(n^2) attention cost, which is plenty for memory facts and snippets.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine turns text into embedding vectors using the compiled-in nomic-embed-text model. It is safe for concurrent use: forward() allocates its own scratch buffers per call and the weights are read-only after construction.
func New ¶
New builds (or returns the cached) Engine from the embedded weights. The model is loaded lazily and only once per process.
func (*Engine) EmbedBatch ¶
EmbedBatch embeds several texts. Inputs are processed sequentially; the returned slice is index-aligned with texts.