Retrieval quality depends on choices made before any model answers: how documents are cut into chunks, and how chunks are embedded. Here you use a real sentence-embedding model, all-MiniLM-L6-v2, running in the lesson's runner through the fastembed library.
Two common chunking choices:
- By section: one chunk per heading. Keeps context together, but a long section that covers many things gets one blurred embedding.
- Fixed size: chunks of about 200 characters. Each is about one thing, but loses its heading.
Your task
- Implement both chunking functions.
- Run them: the script embeds the chunks and reports, for 12 paraphrased questions, how often the single best chunk comes from the right section.
- Decide which you would ship for this handbook. On submit your code also runs on a second handbook.