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 → verifyReference 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
| Stage | File / function | Responsibility |
|---|---|---|
| 1. HTTP entry | routes/qa.pyask_question() | Receives `QuestionRequest` and passes it to the QA service. |
| 2. Orchestration | qa_service.pyanswer_question_internal() | Checks the input, resolves services and configuration, and coordinates the request. |
| 3. Retrieval | search.py | Searches Qdrant chunks, Qdrant summaries, Meilisearch, and LightRAG. |
| 4. Context | utils.pybuild_context() | Splits the budget across channels and keeps the items that reach the model. |
| 5. Citations | utils.pysources_from_items() | Builds the source list from evidence that survived context assembly. |
| 6. Prompt | utils.pybuild_prompt() | Tells the model to use the context, cite sources, and refuse unsupported answers. |
| 7. Generation | qa_service.pycompletion.generate() | Generates the final answer from the question and assembled context. |
| 8. Response | models.pyAnswerResponse | 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