Documentation
¶
Overview ¶
Package embed provides BGE-small-en-v1.5 text embedding via ONNX Runtime. Vectors are L2-normalized so dot product == cosine similarity.
Index ¶
Constants ¶
const ( // EmbeddingDim is the output dimension of BGE-small-en-v1.5. EmbeddingDim = 384 // BGEQueryPrefix is prepended to queries (not documents) for asymmetric // retrieval per the BGE-small-en-v1.5 paper recommendation. // Docs: https://huggingface.co/BAAI/bge-small-en-v1.5 BGEQueryPrefix = "Represent this sentence for searching relevant passages: " )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Embedder ¶
type Embedder struct {
// contains filtered or unexported fields
}
Embedder wraps an ONNX session and a HuggingFace tokenizer.
func New ¶
New loads the ONNX model and tokenizer from modelDir. ortLibPath is the path to onnxruntime.so; pass "" to use the system default. numThreads controls intra-op parallelism; 0 = use min(4, NumCPU). modelDir must contain: model.onnx, tokenizer.json
func (*Embedder) BenchmarkSingle ¶
func (e *Embedder) BenchmarkSingle(text string) (tokenize, inference, total time.Duration, err error)
BenchmarkSingle embeds a single short text and returns phase timings for the sift bench command. Returns (tokenizeMs, inferenceMs, totalMs, error).
func (*Embedder) Embed ¶
Embed embeds a batch of document texts (no instruction prefix). Use this for indexing document chunks.
func (*Embedder) EmbedQuery ¶
EmbedQuery embeds a single query string with the BGE instruction prefix. Always use this for search queries — never for document chunks. The prefix "Represent this sentence for searching relevant passages: " is recommended by the BGE authors for asymmetric retrieval tasks.