SHEN YIFull-Stack & AI

Paris • Singapore • Shanghai

RAG Formation · Reference

One question through the RAG system

A standalone cheat sheet for learning and testing RAG quality on this site.

$ reference --status
▸ course RAG Formation
▸ mode standalone reference
▸ status Complete
● learn → test → verify

Reference sheet

One question through the RAG system

The guided RAG Formation course content is complete; this reference is available for self-directed practice.

Core path

HTTP request → route → service → retrieve → assemble → cite → generate → response

Call map

StageFile / functionResponsibility
1. HTTP entryroutes/qa.py
ask_question()
Receives `QuestionRequest` and passes it to the QA service.
2. Orchestrationqa_service.py
answer_question_internal()
Checks the input, resolves services and configuration, and coordinates the request.
3. Retrievalsearch.pySearches Qdrant chunks, Qdrant summaries, Meilisearch, and LightRAG.
4. Contextutils.py
build_context()
Splits the budget across channels and keeps the items that reach the model.
5. Citationsutils.py
sources_from_items()
Builds the source list from evidence that survived context assembly.
6. Promptutils.py
build_prompt()
Tells the model to use the context, cite sources, and refuse unsupported answers.
7. Generationqa_service.py
completion.generate()
Generates the final answer from the question and assembled context.
8. Responsemodels.py
AnswerResponse
Sends back the answer, sources, and diagnostic stats.

What to inspect when debugging

  • Before generation: check `/api/v1/search` and `context_items_included`.
  • At citation time: compare `sources` with the items that actually made it into the context.
  • After generation: compare the answer with both the evidence and the expected answer.
  • For latency: inspect all four retrieval calls—especially LightRAG—and the final completion call.

Continue learning: Open the matching standalone lesson · Course roadmap