Zenaique

Describe what the 'query:' and 'passage:' prefixes do for models like E5 and BGE

Flashcard·Easy·4.0 · 0·~30s·Asked atElevenlabsJump TradingMphasis·Relevant atElasticHugging FaceNeo4jQdrant
Attempt it
TL;DR

The prefixes are part of the training contract, they tell the encoder to project queries and passages into matched but distinct sub-regions of the embedding space; forgetting them silently drops recall.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine a sommelier who studied under two strict instructors. One taught them how to taste short, sharp questions like a customer at the bar. The other taught them how to taste long, descriptive passages like a wine label. The sommelier was always told before each tasting which mode to switch into. Now picture you walk up and hand them a sip without saying which mode. They guess, and they often guess wrong, and the pairings they recommend at the end of the night no longer line up. The little phrase like query colon or passage colon is that whispered hint. Skip it and the recommendations quietly fall apart, with no error message, no warning, only worse matches.

Key concepts

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

The 'query: ' / 'passage: ' prefix pattern is the single most common silent bug in 2026 production RAG. Teams onboard a new embedding model, copy a tutorial that omits the prefix, and lose 5 to 15 percent of retrieval recall they never measure. The reason this question matters more than its appearance suggests is that the failure mode is invisible: no error, no warning, no log line, just a quiet drop in retrieval quality that surfaces only as 'somehow our RAG feels worse than it should.'

This deep dive covers why the prefixes exist (encoding query-passage asymmetry), how training enforces the contract, what silently breaks at inference time, how to detect the bug, and the 2026 landscape of which models require explicit prefixes vs which hide them.

Mental model: prefixes are not preprocessing. They are part of the input contract the model was trained on. Skip them and the contract is broken.

Why the asymmetry exists in the first place

Queries and passages are structurally different

Queries in retrieval systems are typically short (5 to 15 tokens), intent-bearing, often interrogative or imperative. Passages are longer (50 to 500 tokens), declarative, content-bearing. A user types 'what is mean pooling' as a query and expects to retrieve a passage that explains mean pooling at length.

A symmetric embedder wastes capacity

A single encoder forced to map both queries and passages into the same uniform geometric space has to reconcile the two shapes. Short queries and long passages might land in different regions of the space just from length, regardless of semantic match. The contrastive loss has to fight that, which wastes representational capacity.

Asymmetric prefixes solve this

Introducing distinct prefixes ('query: ' vs 'passage: ') signals the model which side the input represents. During contrastive training the model learns to project queries into one sub-region and passages into another, and the loss aligns matched pairs across the sub-regions. The capacity that would have been wasted on shape-reconciliation is now used for semantic alignment.

The empirical payoff

Asymmetric prefix models like multilingual-e5-large typically outperform same-size symmetric models by 5 to 10 percent on retrieval benchmarks at equal parameter count. The prefix pattern is now standard for open-weight embedders that target retrieval specifically.

How training enforces the contract
What silently breaks at inference
The 2026 model landscape and how to follow contracts correctly
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • multilingual-e5-large from Microsoft requires 'query: ' and 'passage: ' prefixes for asymmetric retrieval.
  • BGE-large-en-v1.5 from BAAI requires task-specific instructions like 'Represent this sentence for searching relevant passages: ' on the query side.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow do you verify the right prefix to use for a given model?
A

Read the model card on Hugging Face. The required prefix is usually documented in the 'Usage' section. For e5-family, it is 'query: ' and 'passage: '. For BGE, it is task-specific instructions. Never guess.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Treating the prefix as optional preprocessing. It is part of the training contract, omitting it produces silent recall degradation with no error.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • What an instruction prefix is and where it sits in the input

  • Why prefixes are part of the training contract, not preprocessing

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Why is cosine similarity preferred over Euclidean distance for text embeddings?
Flashcard·Easy