boundary-chunker
Boundary-aware semantic chunking for RAG pipelines. Wraps a ModernBERT model fine-tuned to answer one question per sentence: does a topic boundary follow this one?
Model weights: 0xKitkat/semantic-chunker-modernbert-base
Install
pip install "boundary-chunker[onnx]" # CPU, no torch (~40MB of deps)
pip install "boundary-chunker[torch]" # GPU
torch is not a hard dependency on purpose — a chunker belongs inside someone
else's ingestion pipeline, and "requires CUDA" is the usual reason a component
gets skipped.
Use
from boundary_chunker import SemanticChunker
chunker = SemanticChunker(backend="onnx") # weights download on first use
for c in chunker.split(document):
print(c.n_tokens, c.boundary_score, c.text)
From the command line:
boundary-chunk --backend onnx --file report.txt
cat report.txt | boundary-chunk --backend onnx --json
Or through transformers, with nothing installed from here:
from transformers import pipeline
chunk = pipeline("semantic-chunking",
model="0xKitkat/semantic-chunker-modernbert-base",
trust_remote_code=True)
chunk(document)
Knobs that matter
threshold |
boundary confidence required to split. Higher → fewer, longer chunks. |
max_chunk_tokens |
hard cap. Over-long chunks split at the model's least confident interior boundary, not at an arbitrary offset. |
min_chunk_tokens |
merge chunks below this into a neighbour. Corpus-dependent — see below. |
Does this actually help?
Sometimes. It wins clearly on boundary detection (0.82 vs 0.50 F1 against the closest existing model), but on retrieval it is roughly a wash against plain fixed-size splitting, and it loses on corpora whose documents are already shorter than the embedder's window. Splitting a 150-token document in half makes retrieval worse no matter how correct the boundary is.
Use it for long documents whose topic genuinely shifts — transcripts, reports, manuals. Measure on your own corpus before adopting it; the model card carries the full per-corpus numbers, including the losses.
Apache-2.0.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file boundary_chunker-0.1.0.tar.gz.
File metadata
- Download URL: boundary_chunker-0.1.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f58e0f91196b781738558f975f81ad81a32aeda9013c7198608a48338bccd743
|
|
| MD5 |
5fa62d8363d64abb8db3df5c998d91b0
|
|
| BLAKE2b-256 |
6fb567fa736d6b002bd2229556f11f8174e4606e88d59b7b797e4c4ac073c8e0
|
File details
Details for the file boundary_chunker-0.1.0-py3-none-any.whl.
File metadata
- Download URL: boundary_chunker-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f56c6c0617f2c40161c95eca6b7096ff171120f6c5c3d487bbda3c7abe91051
|
|
| MD5 |
1cbbd72cbee6990aaee39cb502054e2a
|
|
| BLAKE2b-256 |
cd0873eb6c4acc124d0b9eb18540859951edb4ca80a2d036c157e42ec90744bd
|