r/Rag • u/spydersy • 36m ago
Tools & Resources A Python package for a visual report of your RAG chunking, fully offline and framework-agnostic
While building a RAG pipeline over a set of internal technical docs, I kept running into the same question: what did my chunker actually do to my documents?
Bad chunking fails silently. A table gets split from its header, a code block is cut in half, a paragraph falls between two chunks, a chunk is longer than the embedding model's limit and gets truncated. Retrieval metrics don't point you to any of this; you just get worse answers. My "workflow" was printing a few chunks to the terminal and scrolling.
So I built chunkscope, an open-source Python package that turns the output of any chunker into a single offline HTML report.
What it shows
- Every chunk highlighted in place in the source document, with overlaps and gaps (text that ended up in no chunk)
- A chunk map of each document and the size distribution, in characters or in tokens of your embedding model
- 17 checks: chunks over the token limit, split tables and code blocks, mid-word and mid-sentence cuts, heading-only chunks, duplicates…
- Side-by-side comparison of several chunking strategies or sizes
- Optional retrieval overlay: pass the scores for a query and see which chunks ranked where, in context
How it works
pip install chunkscope
import chunkscope
chunks = splitter.split_documents(docs) # whatever you already use
chunkscope.report(chunks, source=text) # writes and opens the reportIt works with LangChain, LlamaIndex, Haystack, Chonkie, Docling and Unstructured output, or plain strings and dicts, without importing any of them. No dependencies.
The report is one HTML file with no network access (blocked by a Content-Security-Policy), no CDN and no telemetry, so it's safe to use on confidential documents. There is also a CLI with --fail-on error if you want chunking checks in CI.
Live example report and docs: https://belarif.com/chunkscope
GitHub: https://github.com/spydersy/chunkscope
PyPi: https://pypi.org/project/chunkscope
Honest limitations
It's an alpha (0.2) and my first published package.
- It shows the extracted text your chunker received, not the original PDF page.
- Docling and Unstructured support is based on their documented output and not yet tested on real PDFs.
- The checks are most useful on Markdown-like technical docs.
- I haven't tried it on very large corpora yet.
What I'd love feedback on
- How do you inspect your chunking today?
- Would checks in CI be useful to you, or is this something you only look at while tuning?
- What breaks when you run it on your data?
Issues and brutal feedback welcome.