Deep dive · module 75 of 100
RAG: improving chunking and retrieval
Understand how to split documents so that AI finds the correct pieces.
After this lesson
You can explain what chunking is and why the size of pieces matters.
In view · How it connects
From document to relevant passage
Divide a document into text segments with sufficient coherence.
Let the retrieval layer select appropriate segments.
Check whether the found passage contains the answer and the necessary context.
Part 1 of 3 · Splitting into pieces
Your preference for less movement is on. Choose each part yourself.
What is chunking?
Splitting documents into smaller pieces so they are more searchable.
Chunk size
Too large: too much noise. Too small: context is lost. Test what works for your documents.
Retrieval
The system searches for the most relevant chunks for a question. The quality depends on the splitting and the search method.
New practice example
From explanation to a usable result.
A document becomes more searchable if every passage retains sufficient meaning and provenance.
Fictional practice situationFictitious procedure: a step is in one paragraph, but the exception is only in the next. You divide the document into searchable passages.
View a possible solution
This is how it can be done
Preserve header, document version and sufficient surrounding context. Test with a question about the exception or whether the correct information is retrieved together.
Why this works
A single relevant sentence may be insufficient for a reliable answer. Choose passage boundaries using real test questions.
Make it slightly more difficult
Create one question whose answer requires two adjacent passages and check what your search step returns.
Extra practice, at your own pace. You do not need to submit anything. This does not count towards an automatic assessment.
Read more: Google Cloud: background for RAG. The situation above is a fictional lesson example of your own.
Your workplace · learning by doing
Make something. See what changes.

Checking the AI connection… You can already view the written example.

Present your assignment to Ende.
Read the answer, change one thing, and compare.
Previously held
New version
You remain in control
What do you want to improve in your next attempt?
On this device only. AI answers remain only in this page memory. This is self-review, not a grade.
Why this approach works
A single relevant sentence may be insufficient for a reliable answer. Choose passage boundaries using real test questions.
A step further
Create one question whose answer requires two adjacent passages and check what your search step returns.
Try & discover · no obligation
Search in a small document bank
Compare small and larger text pieces. Do you also find the exception in the answer?
Found text pieces (maximum three)
- Openingsuren2 keywords found
o'clock. Note the exception: on Friday, the closing is at sixteen o'clock.
- Openingsuren1 keywords found
The fictitious workshop is open Monday to Friday from nine to eighteen
Compare with the full original documents
Openingsuren
The fictitious workshop is open Monday to Friday from nine to eighteen o'clock. Note the exception: on Friday, the closing is at sixteen o'clock. On Saturday and Sunday, the workshop is closed.
Bezoekers
Visitors report to the reception. An appointment is required for a tour. An appointment for a visit does not change the opening hours.
Materiaal
Tools remain in the workshop. Return borrowed equipment on the agreed day. For questions about materials, speak to the manager.
Find the exception yourself: the workshop closes at sixteen o'clock on Friday. Is that information fully present in a found piece? Try 12 words with 4 words overlap.
This example ranks by exact keywords. Real embeddings and vector databases compare numerical representations; these are not performed here. A match is not proof that the entire question has been answered.
This trial works locally with fictitious data and does not count towards your lesson completion. It starts anew with a new lesson or reload.
A prompt to get you started
Briefly explain what chunking is and why the size of the pieces affects the quality of answers.
Apply it
A manual is split into pieces. A condition and its corresponding exception always end up in different pieces.
Which approach best fits this situation?
- Test boundaries per topic and sufficient overlap; check retrieval on real questions.
- Reduce all pieces to individual sentences without context.
- Only choose a fixed page limit and test nothing.
With JavaScript, you can check your approach and receive immediate feedback.
Test your insight
What is the risk of chunks that are too large?
- The system finds too much irrelevant information.
- It always works better.
- Chunks must not be large.
Extra practice
Describe how you would split a long document for use in a RAG system.
Splitting a manual by chapter or by topic, not by page.

