Retrieval-augmented generation · core
Parsing, chunking and the ingestion pipeline
RAG quality starts at ingestion: parse the file well, cut it into chunks that make sense alone, attach metadata, embed, and index. A change in the source file can quietly break answers.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Ingestion: parse the file (a text parser for digital PDFs, OCR or a vision model for scans, tables kept as tables), clean it, split into chunks with metadata, embed each chunk, and store vectors and text. Often also a keyword index.
- Chunks too small lose context (it refers to the previous chunk, or a rule is cut off from its exception). Chunks too big blur several topics, lower precision and cost more prompt tokens.
- A fair baseline is fixed-size chunks by tokens with 10 to 20 percent overlap. Structure-aware chunking by headings, sections and list items usually wins for manuals and policies.
- Semantic chunking costs more and is not automatically better.
- Put context into each chunk: prepend the document title and section path before embedding, so a chunk makes sense alone.
- Parent-child: embed small chunks for precise matching but send the whole parent section to the model. Keep a table with its header row in one chunk.
- Metadata on every chunk: document id, page, section, date, version, language and who may see it.
- When a new version of a file gives worse answers, suspect parsing first: a new layout (two columns, steps as images, scanned pages) can give jumbled or empty text. Roll back to the previous index version, then fix the parser.
- Choose k by measuring recall@k on a test set. More chunks cost more and the model uses the middle of a long context less well.
The red pen
Common traps: mistake → fix
Mistake: Smaller chunks are always more precise
Fix: too small loses context and the rule is separated from its exception.
Mistake: If the file looks fine to a person, the parser read it well
Fix: check the extracted text; layout changes break parsers.
Mistake: One chunk size fits every document
Fix: choose by document structure and test it.
Easy to hard
Questions interviewers ask, easy to hard
- Walk me through RAG for a 200-page PDF, from upload to answer.
- How do you choose a chunking strategy for an HR policy manual?
- What metadata do you store with each chunk and why?
- A re-uploaded manual made answers worse. What do you do?
- How do you choose k?
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.