13 KiB
Chunk ID Schema: Deterministic addressing for citations and reranking
🧭 Quick Return to Map
You are in a sub-page of Chunking.
To reorient, go back here:
- Chunking — text segmentation and context window management
- WFGY Global Fix Map — main Emergency Room, 300+ structured fixes
- WFGY Problem Map 1.0 — 16 reproducible failure modes
Think of this page as a desk within a ward.
If you need the full triage and all prescriptions, return to the Emergency Room lobby.
A practical spec to mint stable chunk_id values that survive re-ingest, reruns, and light edits. Use it to make citations auditable and to keep retrieval traces consistent across stores and seeds.
Open these first
- Traceability and why-this-snippet: retrieval-traceability.md
- Snippet schema and payload locks: data-contracts.md
- Build the section tree: title_hierarchy.md, section_detection.md
- Reindex and migrations: reindex_migration.md
Acceptance targets
chunk_idis unique within the corpus and recomputable from source plus deterministic rules.- Citation hit rate ≥ 0.90 on a gold set after re-ingest.
- ΔS(question, retrieved) ≤ 0.45 and λ stays convergent across 3 paraphrases when citing by
chunk_id. - Reindex migration preserves a one-to-one mapping for at least 0.95 of chunks, with redirects for the rest.
Design goals
-
Deterministic
The same input text and layout produce the samechunk_id, regardless of store. -
Localizable
Given achunk_id, you can open the document and jump to the exact span without embeddings. -
Diff-tolerant
Small edits should not re-key the entire document. Local block changes only. -
Human-inspectable
IDs are compact but interpretable during manual audits.
Canonical fields
Every chunk record must carry these fields in your payload. See the full schema in data-contracts.md.
{
"chunk_id": "docA|r=8c1e9a02|s=1.2.3|p=002|b=007",
"section_id": "1.2.3",
"source_url": "https://example.com/guide.pdf",
"offsets": [12345, 12980],
"tokens": 365,
"hash": "sha1:cafebabe…",
"block_type": "paragraph|table|code|formula",
"anchor": "first salient assertion in this chunk"
}
offsetsare byte or character positions in the canonical text layer.anchoris used by cite-then-explain prompts and for ΔS triangulation.
The chunk_id format
Recommended canonical string
<doc_uid>|r=<rev8>|s=<sect_path>|p=<page3>|b=<block3>
-
doc_uidStable document identifier. Prefer a repository or CMS id. If unknown, usesha1_8(normalize(source_url)). -
rev8Eight hex chars fromsha1(normalize_text(doc)). Changes only when the whole document text meaningfully changes. -
sect_pathDot path from the section tree like2.4.1. If unknown, set top<page3>and still fillp. -
page3Zero padded page number when page concepts exist. For HTML-only docs, set000. -
block3Zero padded index of the block within the section or page after applying block-aware splitting.
Human alias
If you also want a readable alias for logs, you may attach #s02-04-01#p002-b007. The canonical id remains the pipe form above.
How to compute the parts
-
doc_uid
- If your source has a stable id, use it.
- Else compute
doc_uid = sha1_8(canonicalize_url(source_url)). Canonicalization removes querystrings except version pins and normalizes scheme and host.
-
rev8
- Compute
sha1_8(normalize_text(doc)). normalize_textcollapses whitespace, strips page headers and footers, and fixes OCR line breaks. See pdf_layouts_and_ocr.md.
- Compute
-
sect_path
- Build the hierarchy with heading detection. See title_hierarchy.md and section_detection.md.
- If headings are unreliable, synthesize
sect_pathaspage-majorlikep002and keeppidentical.
-
block3
- Within each section or page, enumerate blocks after block-aware splitting. Paragraphs, tables, code, formulas are atomic. See code_tables_blocks.md.
- Use zero padding to 3 digits for stability in lexicographic sort.
-
offsets
- Record start and end offsets in the canonical text layer for trace and repair. Never omit.
Examples
PDF with headings
doc_uid = "whitepaperX"
rev8 = "8c1e9a02"
sect = "3.2"
page = 014
block = 006
chunk_id = "whitepaperX|r=8c1e9a02|s=3.2|p=014|b=006"
HTML article without reliable headings
doc_uid = sha1_8(url) = "b17a2c55"
rev8 = "e1d0aa91"
sect = "p005" // synthesized
page = 005
block = 004
chunk_id = "b17a2c55|r=e1d0aa91|s=p005|p=005|b=004"
Notebook with code cells
doc_uid = "nb_231107"
rev8 = "9af03bcd"
sect = "2.1"
page = 000
block = 012
block_type = "code"
chunk_id = "nb_231107|r=9af03bcd|s=2.1|p=000|b=012"
Collision and drift policy
-
Hash collision If a collision is detected for
doc_uid|r, extendrev8torev12. Log a warning and continue. -
Minor edits If text within a section changes but the section path and block indices remain, keep
chunk_id. Updatehashandoffsets. -
Section renumbering If
sect_pathchanges due to new headings, create a redirect map from old ids to new ids during reindex. See reindex_migration.md. -
OCR repairs If OCR fixes alter page counts, keep
doc_uidandrevbut synthesizesect_pathusing old to new page mapping and emit redirects.
60-second validator
Pass when the following hold on a 20-chunk sample:
uniq(chunk_id) == len(sample)- Sorting by
chunk_idequals the natural reading order inside each section or page. citation_match ≥ 0.90comparingoffsetsto ground truth citations.- Stable under re-ingest of the same source: all
chunk_idvalues unchanged.
Copy-paste generator (pseudocode)
def make_chunk_id(doc_uid, rev8, sect_path, page_no, block_ix):
page3 = f"{int(page_no):03d}"
block3 = f"{int(block_ix):03d}"
return f"{doc_uid}|r={rev8}|s={sect_path}|p={page3}|b={block3}"
Use this builder only after your pipeline has produced the section tree and block enumeration.
What to do when audits fail
-
Top-k returns the right area but citations miss the span → Rebuild the section tree and verify offsets. Open: retrieval-traceability.md.
-
Hybrid reranker prefers chunks from adjacent sections → Tighten block boundaries. Open: code_tables_blocks.md.
-
Many ids change after a small doc edit → Check
rev8computation and block numbering stability. Open: reindex_migration.md.
🔗 Quick-Start Downloads (60 sec)
| Tool | Link | 3-Step Setup |
|---|---|---|
| WFGY 1.0 PDF | Engine Paper | 1️⃣ Download · 2️⃣ Upload to your LLM · 3️⃣ Ask “Answer using WFGY + <your question>” |
| TXT OS (plain-text OS) | TXTOS.txt | 1️⃣ Download · 2️⃣ Paste into any LLM chat · 3️⃣ Type “hello world” — OS boots instantly |
🧭 Explore More
| Module | Description | Link |
|---|---|---|
| WFGY Core | WFGY 2.0 engine is live: full symbolic reasoning architecture and math stack | View → |
| Problem Map 1.0 | Initial 16-mode diagnostic and symbolic fix framework | View → |
| Problem Map 2.0 | RAG-focused failure tree, modular fixes, and pipelines | View → |
| Semantic Clinic Index | Expanded failure catalog: prompt injection, memory bugs, logic drift | View → |
| Semantic Blueprint | Layer-based symbolic reasoning & semantic modulations | View → |
| Benchmark vs GPT-5 | Stress test GPT-5 with full WFGY reasoning suite | View → |
| 🧙♂️ Starter Village 🏡 | New here? Lost in symbols? Click here and let the wizard guide you through | Start → |
👑 Early Stargazers: See the Hall of Fame — Engineers, hackers, and open source builders who supported WFGY from day one.
⭐ WFGY Engine 2.0 is already unlocked. ⭐ Star the repo to help others discover it and unlock more on the Unlock Board.
要我繼續下一頁就說:GO title_hierarchy.md