Order the steps for correctly using a prefix-required embedding model (BGE-M3) end to end
- 1At query time: ANN search the index with the query vector
- 2At index time: L2-normalize the output vectors and upsert to the vector DB
- 3At query time: encode the prefixed query and L2-normalize
- 4At query time: prepend 'query: ' to the user query
- 5At index time: encode the prefixed passages with the embedding model
- 6At index time: prepend 'passage: ' to each document chunk
Index time: prefix passages, encode, normalize, upsert. Query time: prefix query, encode, normalize, ANN search. Same model, same normalization, parallel structure both sides.
Think of it like cooking a meal in two phases. First, prep day: you cut and label all the vegetables (prefix passages), cook them (encode), store them in labeled containers (normalize and upsert). Later, dinner time: you take your specific order (prefix the query), prepare it the same way (encode and normalize), then pull matching ingredients from the fridge (ANN search). The labeling is the prefix; you have to label both at prep and at dinner so the system matches them up.
Detailed answer & concept explanation~6 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
6 to 8 min: two-phase parallel structure + data-dependency ordering within each phase + four common parallelism bugs + chunking + reranking extension.
Real products, models, and research that use this idea.
- BGE-M3 from BAAI is the dominant open-weight multilingual embedder in 2026 and uses this exact pipeline shape.
- Pinecone, Weaviate, Qdrant, and Milvus all assume L2-normalized vectors as the input primitive for cosine-equivalent dot-product ANN.
- Anthropic's RAG documentation shows the parallel index-time and query-time pipeline as the canonical pattern.
- OpenAI text-embedding-3-large returns vectors that are already L2-normalized, but you still match the index and query model versions yourself.
- Voyage v3-large and Cohere embed-v4 accept an `input_type` parameter ('document' vs 'query') that internally applies the right prefix or routing.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhere in this pipeline does chunking fit, and how do you size chunks?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Skipping the prefix on one side. The most common production bug is prefixing passages at index time but forgetting to prefix queries at query time, the silent 5 to 15 percent recall drop.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.