Skip to main content
Embeddings are how RAG turns text into something a computer can compare. A vector store remembers them and answers similarity queries. Cognis has both pieces behind clean traits, with multiple implementations of each — pick the one that fits your scale and operational footprint.

What an embedder does

Two methods because production embedders often treat documents and queries differently — you can prepend role markers, tune normalization, or call a smaller model for queries.

Pick an embedder

Feature: cognis-rag/openai.

Wrappers

You’ll usually wrap your real embedder once or twice:

Pick a vector store

All implement VectorStore:

Quick example — in-memory

SearchResult carries { id, text, score, metadata }. Score is provider-specific (cosine similarity for most). Vector stores support metadata filters when their backend does:
Filter is a small DSL — eq, ne, in, not_in, plus and/or combinators. The store translates it to its native query language.

How it works

  • Embedders are stateless. They turn text into floats. Wrappers add memory, batching, routing.
  • Vector stores own state. That’s why they take &mut self for mutations. Wrap with Arc<RwLock<…>> to share between tasks (the indexing pipeline does this).
  • Embeddings are not interchangeable. A query embedded with model A can’t be searched against vectors stored with model B. Always re-index when you change embedders.
  • Dimension mismatches are caught at runtime. dimensions() lets you cross-check before persistence layouts go wrong.

See also

Retrievers

Turn a vector store into a query interface.

Indexing pipeline

Keep stores in sync with sources.

Reference → cognis-rag

Full method signatures and feature flags.