blazechunk
the fastest semantic text chunking library — now reads PDFs, Word, PowerPoint and Excel
blazechunk splits text at semantic boundaries and does it stupid fast: a SIMD-accelerated
Rust core with a small, uniform Python API. It ships nine chunkers — a zero-copy byte Chunker
plus RecursiveChunker, SentenceChunker, TokenChunker, TableChunker, CodeChunker, and the
embedding-based SemanticChunker, SDPMChunker and LateChunker — and every high-level chunker
offers matching synchronous and asynchronous methods.
New in 0.15: DocumentChunker reads PDF, Word, PowerPoint, Excel, OpenDocument, RTF, EPUB
and CSV files directly, and produces chunks that know which heading they came from.
📖 Full documentation: https://blazechunk-documentation.vercel.app/
📦 installation
pip install blazechunk
pip install "blazechunk[anydoc]" # + PDF / Word / PowerPoint / Excel / EPUB / CSV
🚀 usage
High-level chunkers (sync + async)
Every chunker exposes the same four methods, so once you know one you know them all:
chunk / chunk_async and chunk_batch / chunk_batch_async.
from blazechunk import TokenChunker
chunker = TokenChunker(chunk_size=512, chunk_overlap=64)
# synchronous
chunks = chunker.chunk("... a long document ...")
for c in chunks:
print(c.text, c.start_index, c.end_index, c.token_count)
# many documents at once
batches = chunker.chunk_batch(["doc one ...", "doc two ..."])
import asyncio
from blazechunk import RecursiveChunker
async def main() -> None:
chunker = RecursiveChunker(chunk_size=2048)
# await a single document — the work runs off the event loop
chunks = await chunker.chunk_async("... a long document ...")
# await many documents concurrently, with optional back-pressure
batches = await chunker.chunk_batch_async(
["doc one ...", "doc two ..."], max_concurrency=8
)
asyncio.run(main())
Other chunkers follow the same shape:
from blazechunk import SentenceChunker, TableChunker, CodeChunker
SentenceChunker(chunk_size=2048, chunk_overlap=128).chunk(prose)
TableChunker(chunk_size=3).chunk(markdown_or_html_table) # header repeated per chunk
CodeChunker(chunk_size=2048, language="python").chunk(source_code)
Low-level byte chunker (zero-copy)
The Chunker primitive and the chunk() helper yield zero-copy memoryview slices for
maximum throughput:
from blazechunk import chunk, chunk_async
# synchronous generator of zero-copy memoryviews
for view in chunk(b"Hello. World. Test.", size=10, delimiters=b"."):
print(bytes(view))
# async variant returns owned bytes
chunks = await chunk_async(b"Hello. World.", size=10, delimiters=b".")
📄 documents (PDF, Word, PowerPoint, Excel, …)
Every RAG pipeline starts with a file, not a string. DocumentChunker takes the file.
pip install "blazechunk[anydoc]"
from blazechunk.loaders import DocumentChunker
result = DocumentChunker().chunk("report.pdf")
for c in result.chunks:
print(c.heading_path, c.kind, c.text[:60])
# ('Methods', 'Sample Preparation') prose 'We sampled two hundred sites across …'
Conversion is handled by anydoc — a pure-Rust converter from Firecrawl with no ML and no network calls.
| Format | Extensions |
|---|---|
.pdf |
|
| Word | .doc, .docx, .docm |
| PowerPoint | .ppt, .pptx, .pptm, .pps, .ppsx, .pot |
| Excel | .xls, .xlsx, .xlsm, .xlsb |
| OpenDocument | .odt, .ods, .odp |
| RTF / EPUB / CSV | .rtf, .epub, .csv |
| Markdown / text | .md, .txt — no extra required |
Why not just convert and chunk?
Converting a file to Markdown and handing the string to a text chunker throws the structure away on the way in. The chunker then guesses it back from punctuation, and splits tables mid-row and functions mid-body because it has no idea they are there.
DocumentChunker segments the document first, then routes each piece to a chunker that suits
it — table rows to TableChunker, fenced code to CodeChunker, prose to whichever chunker you
picked:
from blazechunk import RecursiveChunker, TableChunker, CodeChunker
from blazechunk.loaders import DocumentChunker
loader = DocumentChunker(
chunker=RecursiveChunker(chunk_size=2048), # prose
table_chunker=TableChunker(chunk_size=3), # rows stay whole, header repeated
code_chunker=CodeChunker(chunk_size=2048), # fences stay intact
respect_headings=True, # never merge across a heading
min_chunk_size=256, # merge undersized neighbours
)
result = loader.chunk("handbook.docx")
result = loader.chunk(pdf_bytes, format="pdf") # bytes work too
Async and batch mirror the rest of the library:
result = await loader.chunk_async("report.pdf")
results = await loader.chunk_batch_async(paths, max_concurrency=8)
# skip the files that cannot be read instead of stopping the run
results = loader.chunk_batch(paths, on_error="skip")
heading_path is the point
Each chunk carries the chain of headings above it, which is what turns an anonymous fragment into something a retriever can place — and what a reranker can use directly:
for c in result.chunks:
store.add(
text=c.text,
metadata={
"section": " > ".join(c.heading_path), # "Methods > Sample Preparation"
"kind": c.kind, # prose | table | code | list | quote
"format": c.source_format, # pdf, docx, …
},
)
Offsets and provenance
md_start / md_end are byte offsets into result.markdown — the converted Markdown, which
is returned alongside the chunks — and not into the original file. They are named md_* rather
than start/end precisely so they are not mistaken for offsets into your input.
data = result.markdown_bytes
assert data[c.md_start:c.md_end].decode() == c.text # for every chunk with c.is_exact
anydoc exposes no mapping back to source bytes, so a page number for a PDF chunk is not something this can honestly provide. If you need page-level attribution for audit or compliance, this path does not give you it, and no approximation is shipped in its place.
Two guarantees hold, and are enforced by the test suite over thousands of generated documents:
- Exact reconstruction — a chunk with
is_exactis byte-for-byte the slice its offsets name. The only chunks where this is false are the second and later chunks of a split table, which repeat the header row so each one reads on its own. - Full coverage — the chunks' spans tile the document in order, without overlap, and everything they leave out is whitespace. Nothing is silently dropped.
Scanned PDFs
anydoc reads the text layer of a PDF; it does not do OCR. A scanned or image-only PDF opens fine in any reader but has no text to extract, so it raises a named error rather than a puzzling "unsupported format":
from blazechunk.loaders import DocumentChunker, ScannedDocumentError, DocumentError
try:
result = DocumentChunker().chunk("scan.pdf")
except ScannedDocumentError:
... # run OCR upstream, then pass the text back in
except DocumentError:
... # malformed, encrypted, unsupported — catches every load failure
Run OCR first (or use Firecrawl Parse, the hosted API that adds OCR models), then feed the result
back through chunk_markdown to keep the same structural routing:
result = DocumentChunker().chunk_markdown(text_from_ocr)
🔌 integrations
blazechunk plugs into popular RAG frameworks — install the matching extra.
pip install "blazechunk[langchain]" # LangChain
pip install "blazechunk[agno]" # Agno
# LangChain
from blazechunk import TokenChunker
from blazechunk.integrations.langchain import BlazechunkTextSplitter
splitter = BlazechunkTextSplitter(TokenChunker(chunk_size=512, chunk_overlap=64))
docs = splitter.create_documents([text])
# Agno
from blazechunk.integrations.agno import BlazechunkChunking
strategy = BlazechunkChunking(TokenChunker(chunk_size=512, chunk_overlap=64))
🙏 acknowledgements
blazechunk is a fork of the excellent chonkie-inc/chunk project, and builds on its SIMD chunking core. Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Release files for blazechunk 0.15.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| blazechunk-0.15.0.tar.gz | 162.4 kB | Details |
Built distributions (wheels)
Total release size: 9.5 MB
Release files / blazechunk-0.15.0.tar.gz
| Download URL | blazechunk-0.15.0.tar.gz |
|---|---|
| Size | 162.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4be517b49adb630883d0b971adff4402c3525c6249b60ec0752d88ba3ff8958c
|
|
BLAKE2b-256 checksum How to use checksums |
b4abc7eb1159b7f847140b7f99b2c2c86c2bd47b6decc1624c168c8d2abf8615
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp313-cp313-win_amd64.whl
| Download URL | blazechunk-0.15.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 354.8 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
062160c7cf834b7843baebf8128100e70e6037ea35de865c4d462c232d244c86
|
|
BLAKE2b-256 checksum How to use checksums |
b16f5982d038b673b8c89d94d67bd7ebf3fafd4fa43db18cd80d40f7fcdb1cb3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp313-cp313-manylinux_2_28_aarch64.whl
| Download URL | blazechunk-0.15.0-cp313-cp313-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 502.9 kB |
| Tags | CPython 3.13 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
599c17290966c12f5b2b2ac8a4b723e17324147d011add457900d392e4a09330
|
|
BLAKE2b-256 checksum How to use checksums |
9e70b4eb953d732704df43ee103282c141b1d210afbb49121f2cc7f1f8780ba5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | blazechunk-0.15.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 517.2 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
81a4d338196fb919a6f29216aec52ef5259a70cf9866d1592a944839dfd0ca9e
|
|
BLAKE2b-256 checksum How to use checksums |
475283cb3a5b0cd3aaaaa4be91779f6fb957089a1790f350c238b37eed99402d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | blazechunk-0.15.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 462.4 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3e0d38c363b6336fb05a5d5503dfe5efc9ffe26515ec09e4010f3f12809cf41a
|
|
BLAKE2b-256 checksum How to use checksums |
ff20c1ad91fcbd3591255215b51cfbffc8b3b19da39c97f9404a5dd21b29de4a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp313-cp313-macosx_10_12_x86_64.whl
| Download URL | blazechunk-0.15.0-cp313-cp313-macosx_10_12_x86_64.whl |
|---|---|
| Size | 476.9 kB |
| Tags | CPython 3.13 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
cb6faf59e50910e970f4db451874a6311256ed98c94606014851bbdf0582ecfe
|
|
BLAKE2b-256 checksum How to use checksums |
1d9f0ee885e136072bdb8ac3c24ec05c57dcd4254428b8620a3fc9481cc5cc78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp312-cp312-win_amd64.whl
| Download URL | blazechunk-0.15.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 355.3 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
29b38f54faca338d87a041abf654cc4d2ba62a23ec7db34d5e555d9e470bebc3
|
|
BLAKE2b-256 checksum How to use checksums |
3d9184f4d568879471fcf79b5f4b0694ca45b1ef65c13bc9a5be987b1d666a1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp312-cp312-manylinux_2_28_aarch64.whl
| Download URL | blazechunk-0.15.0-cp312-cp312-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 503.1 kB |
| Tags | CPython 3.12 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
a1c90664a265c55483c3856d082e08af0474a98efd1d2b572409414f272f638a
|
|
BLAKE2b-256 checksum How to use checksums |
3c6bf31052cf889aa2a2dfc2d2afb2f591c7c13b417c1b1cec2092b59ff932a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | blazechunk-0.15.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 517.2 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
9c91ce8c300da77aa5c198f3450187b7171b7de68c46c8ab97833d83e0db48b6
|
|
BLAKE2b-256 checksum How to use checksums |
d0baaae2ce2a151549e5ddd34643577186c19aa42c080c1dd9501f39a0661fca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | blazechunk-0.15.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 462.6 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
42759162ca47810fb00ff0b626535167e8b6379130d3ef1234251bbe87aabe68
|
|
BLAKE2b-256 checksum How to use checksums |
380dc315436af1940c6a2e4b62e436e316cae142150a33e345a9b29246f5d3be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp312-cp312-macosx_10_12_x86_64.whl
| Download URL | blazechunk-0.15.0-cp312-cp312-macosx_10_12_x86_64.whl |
|---|---|
| Size | 477.0 kB |
| Tags | CPython 3.12 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
2b96ca435bd16468d03ef9a8248b58d30573684b532ef8f3687af54dbd65bc41
|
|
BLAKE2b-256 checksum How to use checksums |
f817ed35ef4d668f76aaee9b6edb78530054817dbfe1f46e406333a5da45c2aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp311-cp311-win_amd64.whl
| Download URL | blazechunk-0.15.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 357.5 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a872428e81eb3043e80eea28a8686453915652e732d8c208fd7455215399347a
|
|
BLAKE2b-256 checksum How to use checksums |
9996f8d816c599d612bc9b87cc35317df8be10d53d189af130acb6870a1b60bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp311-cp311-manylinux_2_28_aarch64.whl
| Download URL | blazechunk-0.15.0-cp311-cp311-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 508.9 kB |
| Tags | CPython 3.11 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
0a2b26083c91d06f0f931d6ba8790ab760632f43ed076b65d25fd8edd3d326d8
|
|
BLAKE2b-256 checksum How to use checksums |
fd10757f04d01a493468a74eb0bcaed4b50c204f1464e32b9ae25cac75bbe8e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | blazechunk-0.15.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 521.1 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
c35b3b6a1c7ebd509bcdb27f09078e92fe4aca4d276942ce45125108285bed7b
|
|
BLAKE2b-256 checksum How to use checksums |
f591d24b8f5664358c94a2d8632944bdb7148862feb397d45803b74858cd6603
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | blazechunk-0.15.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 466.1 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ae12c8a5ca340397b6a8474296aab982288a423f96c0381becca024c361376da
|
|
BLAKE2b-256 checksum How to use checksums |
c560d3b360201b22005800b1412914de5c8e7cfb65e3456fbc861b465dd88258
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp311-cp311-macosx_10_12_x86_64.whl
| Download URL | blazechunk-0.15.0-cp311-cp311-macosx_10_12_x86_64.whl |
|---|---|
| Size | 479.5 kB |
| Tags | CPython 3.11 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
48b696c2993e995d67730a824a2a739129800f26a339cfff10c61c0657ed1756
|
|
BLAKE2b-256 checksum How to use checksums |
1c182ee4e55e017449db2c08949a0f5b68bc1cba6f87e8b54f8a6fd2ee58dd0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp310-cp310-win_amd64.whl
| Download URL | blazechunk-0.15.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 357.2 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
96f9ffe507c1e3d213bccd643847605af75f5b420436d580d99902c7439afd37
|
|
BLAKE2b-256 checksum How to use checksums |
d5ed73b74be277f978a7c76678590921f545bc89b8ac63ab586cc76d09145712
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp310-cp310-manylinux_2_28_aarch64.whl
| Download URL | blazechunk-0.15.0-cp310-cp310-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 508.5 kB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
e0050f250d34a3ba803da00b2d124143ab6be0b933ac4c1d518a9316df20ae2a
|
|
BLAKE2b-256 checksum How to use checksums |
2e6162b8fba51dd5d6d4ae2753e6904a32dadb154ae908daf96897e882a2b005
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | blazechunk-0.15.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 521.2 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
a8f4fd8829c7e422932962ef1439ea2c48245b48e707e33f33a20eb9eb300f04
|
|
BLAKE2b-256 checksum How to use checksums |
963e5a97ef733b029f79512af8584540c2c238a434ffa66642b0706fd5a432d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | blazechunk-0.15.0-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 465.9 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b5bd02d0dba5c341e8e3a86dbfee94554da054c8bceb59f147ea60fcc02fa341
|
|
BLAKE2b-256 checksum How to use checksums |
473b3f193dc9e4971ec5927ef52a30b4370e6bff0ca1a89ce6bb42f5a39510d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / blazechunk-0.15.0-cp310-cp310-macosx_10_12_x86_64.whl
| Download URL | blazechunk-0.15.0-cp310-cp310-macosx_10_12_x86_64.whl |
|---|---|
| Size | 479.3 kB |
| Tags | CPython 3.10 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
c5afea07faf022eaa8c4677a672eea0349fc69a60cfad93e334cee335995bce3
|
|
BLAKE2b-256 checksum How to use checksums |
ccad956fa4e5152dc76c44aa345d3729e810d67c040355941338e37f40e76974
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|