Choose a local embedding model by whether the correct source passage appears in the first five results for your real questions. Start with a small baseline and one longer-context candidate, keeping chunks identical and testing how well each candidate retrieves your terminology.
Pick candidates with explicit input limits
Embeddings turn text into vectors that you compare during search. The embedding model is a separate choice from the model that writes the answer. Give retrieval its own acceptance test before changing the generator so you can assess source selection independently.
| Open model | Dense dimensions | Documented input handling | Starting use |
|---|---|---|---|
sentence-transformers/all-MiniLM-L6-v2 |
384 | Default truncation beyond 256 word pieces | A compact baseline for short passages |
BAAI/bge-m3 |
1,024 | 8,192-token sequence length | Compare on longer or multilingual material |
Qwen/Qwen3-Embedding-0.6B |
32 to 1,024 supported output dimensions | 32K-token context | Compare instruction-aware retrieval |
These model-card facts were checked on 2026-11-22. Count input with each model's tokenizer. Measure the exact text after adding headings and any model-specific instruction. If your framework truncates input, a vector can be created successfully while the paragraph containing the answer is omitted.
Start with MiniLM when a short-passage baseline is enough to expose the retrieval problem. Try BGE-M3 or Qwen when you need a broader comparison. Rank the candidates using your languages, document structure and queries.
Encode queries the way the model expects
Qwen's model card demonstrates a query instruction using prompt_name="query", while documents are encoded without that query prompt. BGE-M3's card says query instructions are not required. Applying one model's prefix convention to every candidate makes the comparison unfair.
Here is a minimal Qwen retrieval experiment following the model-card API shape. This example requires Transformers 4.51.0 or later and Sentence Transformers 3.0.0 or later because it uses model.similarity(). Downloading the model requires connectivity on the first run.
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("Qwen/Qwen3-Embedding-0.6B", device="cpu")
passages = [
"Paid time off: full-time staff receive 20 days each year.",
"Expenses: submit meal receipts within 30 days.",
"Access: request a replacement building badge from reception.",
]
query = model.encode(["What is the annual leave allowance?"], prompt_name="query")
documents = model.encode(passages)
scores = model.similarity(query, documents)[0]
for index in scores.argsort(descending=True).tolist():
print(float(scores[index]), passages[index])
The explicit CPU choice provides a simple correctness baseline on either macOS or Linux. Replace the three passages with your own fixed fixtures before timing anything. Keep raw scores for debugging, but do not treat a similarity score as the probability that the passage answers the question.
For an exact identifier such as an invoice code, add a lexical-search baseline to the evaluation. Semantic matching is useful for paraphrases such as “leave allowance” and “paid time off”; an identifier differing by one character may need exact matching. Score both kinds of query separately.
Budget the index and version the vector space
For float32 dense vectors, raw storage is chunk count × dimensions × four bytes. At 100,000 chunks, MiniLM's 384-dimensional vectors take 100,000 × 384 × 4 = 153,600,000 bytes, or 153.6 MB in decimal units. At 1,024 dimensions the same calculation gives 409,600,000 bytes, or 409.6 MB.
Those figures exclude search-index structures, stored text, identifiers and metadata. They also exclude embedding-model weights and runtime memory. A smaller vector can reduce index storage without making the embedding model itself proportionally smaller.
Version the model revision, tokenizer, query instruction, document formatting, output dimensions, normalization and similarity metric together. Treat each model as a separate vector space even when both emit 1,024 values. Re-embed documents before sending queries from a new model into the replacement index.
Build the new index alongside the old one. Run the evaluation queries against both, then switch the application to the winning version as a single configuration change. Keep the old version briefly for rollback. Mixing old document vectors with new query vectors can produce plausible-looking rankings that are meaningless for your intended comparison.
Separate retrieval failures from permission failures. Filter documents to what the user is allowed to read before presenting results. A shared vector index needs the same source-access rules as the underlying document collection.
Try it on your workload
Write 20 queries with expected passage IDs: ten paraphrases, five exact identifiers and five questions in the languages your users actually write. Include “leave allowance” for a passage headed “paid time off.” Use the same document chunks and metadata for every candidate.
For each query, retrieve five passages and mark whether the required source appears. If 16 of 20 queries find their single required passage, hit rate at five is 16 / 20 = 80%. For questions needing several passages, score evidence coverage separately so one retrieved paragraph does not count as a complete success.
Record indexing time, query time, peak memory, vector storage and truncation count. Review the misses by category: vocabulary mismatch, missing exception, near-identical code or unsupported language. Inspect the actual tokenized input when a source's opening text ranks well but its later facts never appear.
After choosing a candidate, rerun the questions on a held-out set of documents. Keep embedding settings fixed while testing chunk sizes; changing model and segmentation simultaneously makes improvements hard to explain.
How to decide
- Keep the smallest candidate that meets your retrieval and resource targets.
- Change input length or segmentation when required text is being truncated.
- Rebuild and version the index whenever the embedding space changes.
Evaluate retrieval with ten answer agents for about six cents
Ten answer agents working in parallel to evaluate 200 retrieval results on google/gemma-4-31b-it cost about six cents in tokens on TrustedRouter. On 2026-11-22, the live catalog listed approximately $0.106 per million input and $0.359 per million output tokens. Assign 20 answers to each agent, using 2,000 input and 300 output tokens per answer. Totals are 10 × 20 × 2,000 = 400,000 input and 10 × 20 × 300 = 60,000 output. Cost = 0.4 × $0.106 + 0.06 × $0.359 = $0.06394, about six cents.
On one local GPU, those agents share throughput, and requests beyond its parallel capacity wait in line; through a per-token API, independent answers can run at the same time for the same token bill as sequential execution. Keep embeddings local and budget them separately; this calculation covers answer generation. Hold the generator fixed so the comparison reveals changes in retrieval quality.
Prices change; check current models, API setup and agent setup. Review private API options and send only approved passages. Keep both embeddings and generation local when document policy requires all text to remain on the device.
Sources
- MiniLM model card: dimensions and truncation
- BGE-M3 model card: dimensions, length and query handling
- Qwen3 Embedding model card: dimensions, context and query instructions
- Sentence Transformers 3.0.0: introduction of similarity methods
- Sentence Transformers: model loading, encoding and similarity APIs
- TrustedRouter live model catalog