S6-13 · 基础 S6-13 · Foundation

分块 · 一刀切在哪里 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 与 O Choose 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.