Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Split documents into overlapping token chunks for RAG pipelines and LLM context windows. Zero dependencies.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | -31% | 0% |
| case-02 | ✗→✓ | ▲ Improved | -36% | 0% |
| case-03 | ✗→✓ | ▲ Improved | -49% | 0% |
| case-04 | ✗→✓ | ▲ Improved | -64% | 0% |
| case-05 | ✗→✓ | ▲ Improved | -52% | 0% |
> 中文 — document-chunker 官方中文版本。
将文档切分为重叠的 Token 块。针对 RAG 管道和 LLM 上下文窗口进行了优化。 零依赖 — 仅使用 Python 标准库 + re。
pythonfrom document_chunker import DocumentChunker chunker = DocumentChunker(chunk_size=400, overlap=80) chunks = chunker.chunk_text("Long text...") for chunk in chunks: print(f"Chunk {chunk['chunk_id']}: {chunk['tokens']} tokens")
pythonchunks = chunker.chunk_document("document.md", source="My Project")
pythonfrom document_chunker import chunk_corpus chunks = chunk_corpus(["doc1.md", "doc2.txt"], source="Corpus")
bashpython document_chunker.py document.md # Single file python document_chunker.py ./docs/ # Entire directory
| 参数 | 默认值 | 说明 | |-----------|---------|-------------| | chunk_size | 400 | 每个块的最大 Token 数 | | overlap | 80 | 块之间的重叠 Token 数 |
.txt, .md, .py, .sh
Other measured skills in the registry, with their headline benchmark lift.