分块 · 一刀切在哪里Chunking · Where Should the Boundary Fall?
document → overlapping indexable passages
分块(Chunking)按长度、结构或语义把文档切成可索引、可检索的片段。块大小同时决定召回粒度、上下文完整性和成本。Chunking splits a document into indexable, retrievable passages by length, structure, or meaning. Chunk size jointly controls recall granularity, context completeness, and cost.
01 · 一条规则被切成两半01 · One rule, cut in half
“标准版 30 天退货,但须未拆封”若刚好跨过切割线,检索到半句够用吗?If “Standard: 30-day return, only when unopened” crosses a boundary, is half the sentence enough?
▯|▯
02分块切割台:块长与重叠一起调Chunk Cutter: Tune Length and Overlap Together
分块配方chunk recipe
索引块数Indexed chunks
4
块chunks
证据完整度Evidence completeness
100%
最佳块best chunk
索引成本Index cost
32
tokens
03分块配方的四个后果Four Consequences of a Chunk Recipe
粒度 · 完整 · 成本granularity · context · cost
LENGTH
块长决定视野Length sets the view
小块定位细,却容易割断一句完整规则。Small chunks localize precisely but can sever a complete rule.
OVERLAP
重叠保护边界Overlap protects boundaries
重复少量 token,让跨边界证据在相邻块里重现。Repeat a few tokens so boundary-spanning evidence reappears in a neighboring chunk.
COUNT
步长决定块数Stride sets chunk count
步长 = 块长 − 重叠;步长越小,块越多。Stride equals length minus overlap; a smaller stride creates more chunks.
COST
重复增加成本Duplication adds cost
重叠提高完整机会,也增加嵌入、存储和检索 token。Overlap improves completeness odds while adding embedding, storage, and retrieval tokens.
04最小机制:块长与步长共同排布边界Minimal Mechanism: Length and Stride Place Boundaries
stride = L − O
n = ⌈(N − L) / (L − O)⌉ + 1
N 是文档 token 数,L 是块长,O 是重叠。主交互中块数与成本都由这三个量直接算出。N is document length, L chunk length, and O overlap. The interaction computes chunk count and cost directly from these values.
选择 L 与 OChoose L and O得到步长derive stride
铺开切割线Place boundaries形成索引块form index chunks
测完整与成本Measure context and cost不是只看块数not chunk count alone
05边界实验:小块且零重叠Boundary Test: Tiny Chunks with Zero Overlap
主动制造失败Create a failure
让切割线穿过关键规则Cut through the decisive rule
块长 4、重叠 0 会把“30 天”和“未拆封”分到不同块。任一命中都只得到半条规则。Length four with zero overlap separates “30 days” from “unopened.” Either hit retrieves only half the rule.
尚未执行。当前至少一个块包含完整规则。Not run yet. At least one current chunk contains the full rule.
✗ 块越小,检索一定越准。Smaller chunks always improve retrieval. → ✓ 粒度变细也可能割断必要上下文。Finer granularity can sever required context.
✗ 重叠越大越保险。More overlap is always safer. → ✓ 它也复制 token,增加索引与上下文成本。It duplicates tokens and raises indexing and context cost.
✗ 固定字数适合所有文档。One fixed length fits every document. → ✓ 结构与语义边界也应参与分块。Structural and semantic boundaries should inform chunking.
06 · 一句话带走06 · One line to keep
分块用块长与重叠在召回粒度、证据完整性和 token 成本之间取舍;边界切在哪里会决定检索能否拿到完整事实。Chunking trades off recall granularity, evidence completeness, and token cost through length and overlap; boundary placement decides whether retrieval can recover a complete fact.