Documentation
¶
Overview ¶
Package embed provides deterministic, dependency-free embedding helpers for demos, tests, and reliquary.Quickstart.
The hashing embedder maps text to normalized vectors with the signed feature hashing trick. It is useful for examples and local tests, but it is not a replacement for a production embedding model.
Package embed provides a deterministic, dependency-free embedding.Embedder for demos, tests, and reliquary.Quickstart. It maps text to vectors with the signed feature-hashing trick, so callers obtain meaningful (non-trivial cosine) vectors without an ONNX runtime or API key.
It is a stand-in for a real embedding model, not a replacement: quality is suitable for examples and tests only, never production retrieval.
Index ¶
Examples ¶
Constants ¶
const DefaultHashingDim = 256
DefaultHashingDim is used when callers pass a non-positive dimension. It is intentionally small and deterministic for demos and tests, not production retrieval quality.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Hashing ¶
Hashing is a deterministic hashing-trick embedder implementing embedding.Embedder.
func NewHashing ¶
NewHashing returns a Hashing embedder producing L2-normalized vectors of the given width. Non-positive dimensions use DefaultHashingDim.
func (*Hashing) Embed ¶
Embed satisfies embedding.Embedder.
Example ¶
package main
import (
"context"
"fmt"
"github.com/dotcommander/reliquary/embed"
"github.com/dotcommander/reliquary/embedding"
)
func main() {
embedder := embed.NewHashing(8)
result, err := embedder.Embed(context.Background(), embedding.Request{Inputs: []string{"hello world"}})
fmt.Println(len(result.Vectors), len(result.Vectors[0]), err == nil)
}
Output: 1 8 true