NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content
Senior2 views

What algorithm would you use to make fact retrieval across chunks robust when a fact may be split across a chunk boundary?

Practice

Asked at

AI answer

Don’t search each chunk in isolation: a boundary can split a match. A reliable approach is to keep the original offsets and search the combined text, or join adjacent chunks with an overlap. If the maximum length of the fact being searched for is known, the overlap should be at least that length minus one character. If it’s unknown, check the window at the boundary between adjacent chunks or use a sliding window. For semantic search, also retrieve the neighboring chunk and verify the fact in context.