Skip to main content

An efficient chunking library that integrates traditional and advanced methods, with real-time evaluation of chunking results.

Project description

Chunk-Fcatory Logo

✨Chunk-Factory ✨

PyPI MIT License Documentation GitHub stars

Chunk-Factory is a fast, efficient text chunking library with real-time evaluation.

InstroductionInstallationUsageSupported MethodsTODOReferencesCitation

Instroduction

Chunk-Factory is a Python library that offers various text chunking methods, including both traditional approaches and state-of-the-art techniques. It not only provides efficient text chunking but also offers real-time evaluation metrics, allowing immediate assessment of chunking results. These features are crucial for retrieval-augmented tasks, helping to optimize context extraction and utilization in the retrieval process.

With Chunk-Factory, users can easily chunk text and evaluate its effectiveness, making it suitable for a wide range of natural language processing applications, particularly in scenarios that require fine-grained retrieval and document segmentation.

Note: Every time I do RAG, I have to chop up semantically coherent text into chunks and then have no clue whether it’s good or not. I can only guess based on the retrieval results, but can’t tell if it’s the retriever’s fault or the chunking’s fault. This library is here to solve that problem by evaluating the quality of the chunking first. Hopefully, it can help some people out of their misery—so annoying!

Installation

To install Chunk-Factory, simply run:

pip install chunk-factory

Usage

Here's a basic example to get you started:

from chunk_factory import Chunker

text = 'Chunk-Factory is a Python library that offers various text chunking methods, including both traditional approaches and state-of-the-art techniques. It not only provides efficient text chunking but also offers real-time evaluation metrics, allowing immediate assessment of chunking results. These features are crucial for retrieval-augmented tasks, helping to optimize context extraction and utilization in the retrieval process.'
language = 'en'

ck = Chunker(text,language)
text_chunks = ck.basechunk(chunk_size=20,chunk_overlap=5)
for i,chunk in enumerate(text_chunks):
    print(f'Number {i+1}: ', chunk)

Supported Methods

Chunk-Factory provides several chunkers to help you efficiently split your text for RAG tasks or other natural language processing tasks (such as information extraction). Here's a quick overview of the available chunkers:

  • BaseChunker: Splits text based on words or tokens.

  • DensexChunker: Splits text into propositions.

  • LumberChunker: Splits text based on semantics using LLM.

  • MspChunker: Splits text based on label probabilities from a small model to determine chunking.

  • PPLChunker: Splits text based on perplexity.

TODO

  • Add traditional text chunking methods

    • Add recursive chunking method

    • Add semantic chunking method

  • Add retrieval evaluation methods

References

  • MoC: Mixtures of Text Chunking Learners for Retrieval-Augmented Generation System [Paper]
  • Dense X Retrieval: What Retrieval Granularity Should We Use? [Paper]
  • LumberChunker: Long-Form Narrative Document Segmentation [Paper]
  • Meta-chunking: Learning efficient text segmentation via logical perception [Paper]

Citation

If you use Chunk-Factory in your research, please cite it as follows:

@misc{chunkfactory2025,
  author = {Jie H},
  title = {Chunk-Factory: A toolkit with a variety of text chunking methods},
  year = {2025},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {url{https://github.com/hjandlm/Chunk-Factory}},
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chunk_factory-0.1.0.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chunk_factory-0.1.0-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

Details for the file chunk_factory-0.1.0.tar.gz.

File metadata

  • Download URL: chunk_factory-0.1.0.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for chunk_factory-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f4ca42a2f1ec5e3168f4195db02db2421e25d1dd0ece977d2187ca41501bab91
MD5 8e1406f07a4f41a80d60237d4e6e36d9
BLAKE2b-256 51b698e45be64a8fd6ab11d7d6e1ad3fc1b3fd2400832ba9c17ef8e5b11910f4

See more details on using hashes here.

File details

Details for the file chunk_factory-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: chunk_factory-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 27.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for chunk_factory-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 230696430a50281c14ec2c6e876568013766e70188e9444cb147fd0b5c8db84d
MD5 b4a042d1af2c691a70562e2ecf1bd343
BLAKE2b-256 c1428bc8290d95ae263f7f9a4452daa1c2b1c6091a9c63893487a4ac4c9aa4ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page