Skip to content

Chunk Quality v3.3: Chunkability score + per-chunk flags - #11

Closed
willscott-v2 wants to merge 1 commit into
feature/chunk-quality-v3.2from
feature/chunk-quality-v3.3
Closed

willscott-v2 wants to merge 1 commit into
feature/chunk-quality-v3.2from
feature/chunk-quality-v3.3

Conversation

@willscott-v2

Copy link
Copy Markdown
Collaborator

Stacked on #10 (v3.2) — merge that first, then retarget this to main.

Why

v3.2 made the Chunks view readable; this answers "now what?". Every page gets a 0–100 Chunkability score and per-chunk fix flags — the actionable layer. Everything is deterministic (regex, word counts, stoplists, Jaccard shingles, Flesch-Kincaid): the same page always scores the same, so you can edit and re-run to watch the delta. Zero AI calls.

API (api/chunk.js)

analyzeChunks() attaches flags[] + chunk_score to each big chunk and returns top-level chunkability {score, grade, top_fixes}.

Flag Severity Detects
dangling-reference high (30) section opens with Our/We/This/… — meaningless retrieved alone
near-duplicate high (30) 5-gram Jaccard ≥ 0.6 between chunks (overlap prefixes excluded)
no-entity-anchor warn (25) no page-entity term (title/og:site_name/JSON-LD org/H1, incl. initialisms — "RAG" anchors "Retrieval-augmented generation")
thin-section warn (20) under min(size minimum, 100) words of real content
oversized-section warn (20) over the size max with no subheading
generic-heading warn (20) "Overview", "Why Choose Us", … (~40-entry stoplist)
answer-buried warn (15) first sentence shares no content words with the heading
readability info (0) Flesch-Kincaid grade > 12

Scoring: each chunk starts at 100 and loses its flags' weights; the page score is the average — proportional to page size by construction, and explainable per chunk.

Extraction fix (root cause, surfaced by the near-duplicate flag)

Containers wrapping nested <section>s were swallowed wholesale into the parent chunk — Wikipedia's "Improvements" chunk contained the entire "Encoder" subsection, which the flag caught as a 61% duplicate. stopCondition now treats a container holding the next heading as the section boundary, and heading-bearing containers that never became chunks (nav/aside blocks) are skipped instead of inlined. This was the long-deferred "nested-content extraction" backlog item.

UI

  • Color-banded score card at the top of the Chunks view: score, grade, top 3 fixes with "up to +N pts" each
  • Red/amber/info flag chips on every chunk card (hover for the specific issue + fix); green "✓ No flags" when clean
  • "Show only flagged chunks" filter toggle
  • Legend bullets documenting the score model and chip colors

Calibration (5 real pages)

Page Score Story
Wikipedia RAG article 79 C control page scores highest, as it should
libertyseniorliving.com 73 C decent structure, thin in places
seasidefl.com 68 D looks clean — but all 9 sections are under 100 words
searchinfluence.com 65 D thin + heading/first-sentence mismatch
Hayes Barton Place assisted-living 51 F the page that started all this: every chunk thin, half open with pronouns

Tuning fixes applied along the way: absolute 100-word thin floor (the size-scaled minimum flagged every Wikipedia section), initialism anchors, ≥2-content-word requirement for answer-buried, and the per-chunk-average scoring model (flat deductions punished many-chunk pages).

Next: Phase 3 (v3.4) — BM25 retrieval simulator, query coverage matrix, markdown optimization-report export.

🤖 Generated with Claude Code

The Chunks view showed structure but passed no judgment — "then what?"
had no answer. This adds the diagnosis layer, all deterministic (regex,
word counts, stoplists, Jaccard shingles, Flesch-Kincaid) — zero AI.

API: analyzeChunks() attaches flags[] and chunk_score to each big chunk
and returns chunkability {score, grade, top_fixes}. Flags:
- dangling-reference: opens with a pronoun (Our/We/This/...)
- near-duplicate: 5-gram Jaccard >= 0.6 between de-overlapped chunks
- no-entity-anchor: no page-entity term (title/site/JSON-LD org/H1 stems
  + initialisms, so "RAG" anchors "Retrieval-augmented generation")
- thin-section (< min(target.min, 100) words), oversized-section,
  generic-heading (~40 stoplist), answer-buried (heading vs first
  sentence, >= 2 heading content words), readability (FK > 12, info)

Scoring: each chunk starts at 100 and loses its flags' weights; the page
score is the average — proportional to page size by construction.

Extraction fix the near-duplicate flag surfaced: containers wrapping
nested sections were swallowed wholesale into the parent chunk
(Wikipedia "Improvements" contained all of "Encoder"). stopCondition
now treats a container holding the next heading as the boundary, and
heading-bearing containers that never became chunks are skipped.

UI: color-banded score card with top 3 fixes (+N pts each), red/amber/
info flag chips per chunk with fix tooltips, "show only flagged" toggle.

Tuned on 5 real pages: Wikipedia RAG 79/C (highest, as the control
should be) ... Hayes Barton Place 51/F (the page that started all this).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
getchunks Ready Ready Preview, Comment Jul 25, 2026 8:54pm

Request Review

This branch was successfully deployed

1 active deployment
Preview — d2e0f86b Deployed Jul 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant