Skip to main content

Module embed

Module embed 

Source

Structs§

HnswResult
Query result from HNSW search.
Model2VecEmbedder
Neural-quality embedder using Model2Vec (distilled sentence transformer).
TrigramEmbedder
Lightweight, zero-dependency embedder using character n-gram hashing.

Traits§

EmbedProvider
Embedding engine trait. Implementations can use ONNX, API calls, etc.

Functions§

best_embedder
Create the best available embedder: Model2Vec if possible, fallback to trigram.
build_hnsw_index
Build an HNSW index from embeddings and save to disk. Returns the number of vectors indexed.
code_embedder
Singleton lazy-init code embedder (Arc-based, shared across threads).
cosine_similarity
Dot-product similarity — equivalent to cosine when vectors are L2-normalized.
doc_embedder
Singleton lazy-init doc embedder (Arc-based, shared across threads).
embedding_count
Count the number of embeddings in the binary file at root/.infigraph/embeddings.bin.
init_embedder
Factory: select Model2Vec if available, otherwise fall back to TrigramEmbedder.
invalidate_embeddings_cache
Invalidate the embeddings cache (call after save_embeddings or update_embeddings).
invalidate_hnsw_cache
Invalidate the HNSW cache.
load_embeddings
Load symbol embeddings from a binary file.
load_embeddings_cached
Load embeddings with process-lifetime caching. Returns cached data if the file hasn’t been modified since last load. Falls back to load_embeddings on any cache miss.
path_to_context
Extract meaningful context from a file path by filtering out common directory names.
rich_symbol_text
Build a rich text representation of a symbol for embedding, including file context.
rich_symbol_text_full
Extended rich text representation with parameter and return type info.
save_embeddings
Save symbol embeddings to a binary file. Format: [count:u32] then for each entry: [id_len:u32][id_bytes][dim:u32][f32 * dim]
search_hnsw
Search the HNSW index, returning top-k results by inner product similarity. Returns None if no valid index exists (caller should fall back to brute-force).
symbol_text
Build a text representation of a symbol for embedding.
update_embeddings
Incrementally update embeddings for changed files.