Why this build, here
HR staff and workers in Zambia ask the same questions about leave, notice and gratuity, and the answer is in a long PDF. Retrieval-augmented generation (RAG) is how you make a model answer from a document instead of from memory, and citations are how a reader checks it.
The build, step by step
Read the document like a machine will
Extract the Act’s text and look at it. Where do sections start? Are there tables or footnotes? Keep the section number with every piece of text, because that is your citation.
Chunk by section, not by character count
Split on the Act’s own sections and sub-sections. Only split further when a section is too long, and keep the section number and title on every chunk.
Embed and store
Create embeddings for each chunk and store them in a vector database (Qdrant, Chroma or pgvector). Retrieve the top five chunks for a question and print them before you ever call the model.
Answer only from what was retrieved
Tell the model to answer only from the chunks, cite section numbers, and reply “the Act does not say” when the chunks do not cover it. Return the answer and citations as structured output.
Check every citation
After generation, confirm every cited section was actually in the retrieved chunks. Drop the answer if a citation was made up.
Finished when
- Every answer cites sections, and every cited section was retrieved
- Questions the Act does not cover get a plain refusal
- Ten questions with the expected sections are written down as your first test set
Read and run
Interview practice
Questions on this topic from AI Engineering Interview Questions, company-wise, with the companies it lists. Write your answer the way you would say it; Jev scores it and DeepSeek tells you what to add.