Skip to main content

Module embeddings

Module embeddings 

Source
Expand description

Vector embedding support for semantic recall in the Punch memory system.

Provides a BuiltInEmbedder (TF-IDF based, no external deps), an OpenAiEmbedder (calls the OpenAI embeddings API), and an EmbeddingStore backed by SQLite for persistence and similarity search.

Structs§

BuiltInEmbedder
A TF-IDF vectorizer that works entirely offline with no external dependencies. Call BuiltInEmbedder::fit with a corpus to build the vocabulary, then use Embedder::embed to compute vectors.
Embedding
A vector embedding with its source text and metadata.
EmbeddingConfig
Configuration for the embedding engine.
EmbeddingStore
Persistent store for embeddings, backed by SQLite.
OpenAiEmbedder
An embedder that calls the OpenAI embeddings API.

Enums§

EmbeddingProvider
Which backend to use for computing embeddings.

Traits§

Embedder
Trait for computing vector embeddings from text.

Functions§

bytes_to_vec
Deserialize little-endian bytes back to a Vec<f32>.
cosine_similarity
Compute the cosine similarity between two vectors.
top_k_similar
Return the top-k most similar embeddings to query_vec, sorted by descending similarity.
vec_to_bytes
Serialize a Vec<f32> to little-endian bytes.