Skip to main content
Two namespaces that work together. embeddings turns text into vectors you can compare. rerank takes a query and a list of candidates and reorders them by relevance.

Embedding text

Vectors come back in input order, so index i of the result matches index i of the input. Batch rather than looping: one call with fifty strings is far cheaper than fifty calls.

Comparison helpers

Electron is the only SDK with these on the namespace:
Both accept an Embedding or a raw Float32Array. Elsewhere you write these yourself, or use helpers on the vector type.

Options

Leave normalize on unless you have a reason. With it off, similarity scores are not comparable across texts of different lengths.

Reranking

Reranking is a different model from embedding. An embedding model encodes each text once and compares vectors, which is fast and approximate. A reranker reads the query and the candidate together, which is slower and much more accurate. The usual shape is both: retrieve widely with embeddings, then rerank the top handful.

Indexing a folder

A desktop app can embed a real corpus rather than a handful of pasted strings:
Batch in chunks rather than passing thousands of documents at once, and persist the vectors so a relaunch does not re-embed everything.

Where this fits

Most people reach for these through RAG, which does retrieval, reranking, and generation in one session. Use the namespaces directly for semantic search with no generation, deduplication, or classification by nearest neighbour.

Models

Embedding and reranking models are small, often tens of megabytes rather than gigabytes, so keeping both resident alongside a language model is reasonable on a desktop.