AI MOOC
✦ Grow togetherInvite 3 friends, earn 1 month of membership · Up to 12 monthsInvite friends →

Library / My reading notes

Chunk and index understandable evidence

Understand chunking failures and the limits of the retrieval baseline.

Back to the RAG course plan: Build a searchable, cited RAG knowledge base

Chapter 3 / 8 · Read and take notes

Understand chunking failures and the limits of the retrieval baseline.

Understand the method

Chunking balances context size with complete meaning. If a cap and its invoice condition are split, retrieving only the cap hides the constraint from generation. A shorter chunk is not necessarily a better source.

Each lab rule is already a coherent chunk. For longer documents, start with headings and paragraphs and then respect the actual model context budget. Overlap reduces some boundary loss but creates duplication and does not guarantee complete rules.

Carry parent source, heading path and version. References such as “these staff” may be meaningless alone. Enrich a chunk with the needed heading or retrieve adjacent context. Do not expect the model to reconstruct discarded constraints.

The program uses overlapping Chinese bigrams and Latin words as an inspectable baseline. It scores shared terms between question and chunk. It has no embeddings or synonym understanding. Its transparent failures provide a baseline for later semantic search.

Vector retrieval encodes questions and sources for similarity search. Keyword methods help exact names and IDs. Compare or combine approaches. Neither similarity nor the lab overlap score is a correctness probability; calibrate any threshold with your own cases.

Try rephrasing a computer failure using different wording and observe whether P4 remains. Save the output before adding query synonyms, enriching titles or adopting embeddings. Change one factor at a time to isolate its effect.

  1. 1Complete rule
  2. 2Context
  3. 3Baseline
  4. 4Misses

Included material

import re
def terms(text):
    result = set(re.findall(r"[a-z0-9]+", text.lower()))
    for run in re.findall(r"[\u4e00-\u9fff]+", text):
        result.update(run[i:i+2] for i in range(max(1, len(run)-1)))
    return result

query_terms = terms("Python RAG")
document_terms = terms("RAG with Python")
score = len(query_terms & document_terms) / max(1, len(query_terms))
print(score)

Work through the steps

  1. Write the bigrams for the supplied lodging phrase and compare with code.
  2. Compare complete P1 with a copy missing the invoice condition.
  3. Record one observed retrieval result for a paraphrase before changing anything.

Worked example

Bad split: one chunk contains only the cap; another the invoice condition. Better: preserve the complete P1 rule. If retrieved evidence lacks the invoice constraint, repair chunking before prompting.

Your exercise

Write a five-sentence procedure and two chunking strategies. Give one question whose evidence changes with the split. Use original non-sensitive text.

Check before delivery

  • Explain that this program has no vector search.
  • Record specific lost conditions in the comparison.
Finish the exercise, then view the reference

Identify the cross-boundary requirement, missing evidence and repaired chunk. If both splits support the answer, choose a question that actually exposes the boundary.

An original course with teaching exercises. Reading records, practice outcomes and independent certification are distinct.

References and further reading

The lessons are original. The following sources are provided under their respective permissions.

Article / guide

Prompt Engineering Guide

DAIR.AI · en/zh

MIT

License checked. This entry links to the original; the book text is not mirrored.

License checked: 2026-10-16 · Pinned 57673726
Article / guide

RAG and Vector Databases

Microsoft · en/zh

MIT

License checked. This entry links to the original; the book text is not mirrored.

License checked: 2026-10-16 · Pinned d45da912
Whitepaper / report

NIST AI 600-1: Generative AI Profile

NIST / Autio et al. · en

NIST Technical Series reprint policy

Original PDF provided under the institution’s reprint policy.

License checked: 2026-10-16
Article / guide

Ollama Chat API

Ollama · en

Official documentation link; no full-text reproduction

Original link only; full text is not mirrored.

License checked: 2026-10-20