Documentation
¶
Overview ¶
Package embed provides the local-embedding arm of the hybrid funnel: an Ollama-backed Embedder plus the f32 vector codec and similarity helper. Hot-path package: stdlib only. The Embedder interface is structurally identical to gopheragent's tools.Embedder so a future upstream Ollama embedder can replace ollama.go without touching consumers (plan §upstream).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeVec ¶
DecodeVec deserializes an EncodeVec blob. Returns nil for malformed input (length not a multiple of 4) — a stale/corrupt row degrades to "no vector", never an error on the hot path.
func Dot ¶
Dot returns the dot product — cosine similarity for Normalized vectors. Mismatched or empty vectors score 0 (treated as "no signal").
Types ¶
type Ollama ¶
type Ollama struct {
Endpoint string // e.g. http://localhost:11434
Model string // e.g. nomic-embed-text
// KeepAlive is passed through to Ollama as the model's residency window,
// refreshed on every call. Ollama unloads an idle model after ~5min by
// default, and the cold reload costs seconds — far past the hot path's
// 100ms embed budget, so the retrieve breaker trips and the whole cosine
// arm drops out for its cooldown. Keeping the model resident is what makes
// hybrid retrieval actually available between prompts. "" omits the field
// (server default).
KeepAlive string
Client *http.Client
}
Ollama calls the local /api/embed endpoint. Vectors come back Normalized so Dot is cosine. The zero timeout on the shared client is deliberate: callers bound each call with ctx (100ms on the hot path, seconds for indexing).