RAG & Retrieval·Question 15 of 100Basic

Many embedding models tell you to prefix queries and documents differently, or to pass a task instruction. Why, and what goes wrong if you ignore it?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Because retrieval is asymmetric, and these models learned it with the markers present. A query is short, question-shaped and underspecified; a passage is long and declarative. A model trained contrastively with a side marker uses it to decide how to encode the text, so the marker is part of the model, not a formatting nicety.

Full worked answer

Because retrieval is asymmetric, and these models learned it with the markers present. A query is short, question-shaped and underspecified; a passage is long and declarative. A model trained contrastively with a side marker uses it to decide how to encode the text, so the marker is part of the model, not a formatting nicety.

Conventions differ by family. E5-style models expect query: and passage: prefixes. Instruction-tuned embedders such as Qwen3-Embedding put a task description on the query side only, in an Instruct: line before the query. Hosted APIs usually expose it as an input-type or task-type parameter set to query or document, and some have no switch at all. Read the model card every time, because the rules do not transfer between families.

If you ignore it, nothing errors. Results still look plausible, just measurably worse, and every published number for that model assumed the convention, so you are no longer running the model you evaluated. Short keyword queries tend to suffer most: without the query marker they get encoded like tiny documents and match titles and fragments rather than answering passages.

The bugs I see in practice:

  • Index and query disagree. Someone swaps the embedding wrapper and the document prefix silently disappears at ingest, or the query prefix at serve time.
  • Wrong convention for symmetric tasks. Deduplication and clustering compare documents with documents, and the model card usually prescribes one marker for both sides.
  • Treating the instruction as free text. If it sits on the document side, changing it means re-embedding the corpus.

Two habits prevent this. Store the prefix or instruction next to the embedding model version in chunk metadata, and add a test that embeds a fixed query and passage and asserts the similarity matches a recorded value. Then use the upside: a query-side instruction is a tuning knob you can A/B on the golden set without touching the index.

What a good answer covers

  • Because retrieval is asymmetric, and these models learned it with the markers present
  • A query is short, question-shaped and underspecified; a passage is long and declarative
  • A model trained contrastively with a side marker uses it to decide how to encode the text, so the marker…
  • E5-style models expect query: and passage: prefixes
  • Instruction-tuned embedders such as Qwen3-Embedding put a task description on the query side only, in an…

Key terms: Index and query disagree · Wrong convention for symmetric tasks

Interviewer follow-ups to expect

  1. How would you detect, from production data alone, that the index was built without the document prefix?

  2. If the instruction lives only on the query side, what can you tune without reindexing, and how would you test it?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep