CodeQuest101Advanced RAGChapter Studio
Advanced RAG

8 chapters · Learn by building

RAG basics

Chapter 05 / 08

Ask the index a clearer question.

Compare rewriting, decomposition, and hypothetical search text without mistaking them for evidence.

The idea, in plain words

Change the search input

A user's question may be vague, use different terms, or ask for two separate facts. Rewriting can clarify wording; decomposition can search for each part separately.

HyDE uses hypothetical answer-like text as a search input. Our rewrites and hypothetical passages are authored examples. They are not verified facts and cannot be cited as source evidence.

1

Keep the original user question visible.

2

Choose an example rewrite, subquestions, or hypothetical search passage.

3

Retrieve with the selected search text and combine duplicate results by source identifier.

4

Inspect the actual documents before answering the original question.

Decision inspector

Follow the evidence.

D3Refund records

A confirmation email is sent when the refund is issued.

Refund settlement policy · D3-s3

The best search input is sometimes more explicit than the original wording, especially when one question contains several information needs.

Math & code

Multiple result lists can be fused by passage ID; reranking still uses the original question.

search_texts = rewrite | decompose | hypothetical_text
candidates = fuse(retrieve(text) for text in search_texts)
answer_question = original_question
Developer’s reasoning

A rewrite can change intent, omit a negation, or invent an entity. Hypothetical search text is a retrieval aid, never an authoritative answer.

Sources & model provenance

sentence-transformers/all-MiniLM-L6-v2 · 384D · mean pooling + L2 normalization.

cross-encoder/ms-marco-MiniLM-L6-v2 · recorded raw logits.

Rewrites, subquestions, HyDE text, and answer claims are authored teaching examples.

Encoder revision onnx-sha256:4f148ba8ae9c2c7fbee4af2b132db8d06c6a6545b47fc83bbb98c3d22b8393e6

Reranker revision 233902d25c440f23af6f7d6e94d2946bac0bee0a

Corpus SHA256 d1c21da297e88785f9a6ac434e0a58f3e10975052a48419ba511145d461f704e

Current sources only; archived documents D9 are excluded before retrieval.

Query strategies · Change the search input