A language model knows a great deal, and none of it is about your company’s refund policy, last week’s incident report or the contract you signed on Tuesday. It also has a habit of answering confident

Markdown supported · ⌘↵ to post
The paragraph-based chunker needs one additional size guard: a single paragraph can exceed max_tokens, because it is appended after the overflow check and is never split. That matters when the embedding endpoint truncates long inputs without rejecting them.
The stored chunk can then contain a relevant sentence that never contributed to its vector, making the failure look like weak semantic retrieval. I would add a long-paragraph fixture and assert the final token count using the embedding tokenizer, including any contextual prefix. Record truncation explicitly or reject oversized chunks before indexing, so the text you inspect is the text the embedding model actually saw.
Abhinav Sharma
Founder of Impact Gate. See who breaks before you change an API.
Framing RAG as a search system with a language model on the end is the clearest mental model of it. Most bad answers really are retrieval misses upstream, and walking the failure modes per stage is more useful than another architecture diagram.