A simple, efficient text chunking library for RAG applications
Project description
🦛 Chonkie
so i found myself making another RAG bot (for the 2342148th time) and meanwhile, explaining to my juniors about why we should use chunking in our RAG bots, only to realise that i would have to write chunking all over again unless i use the bloated software library X or the extremely feature-less library Y. WHY CAN I NOT HAVE GOOD THINGS IN LIFE, UGH?
Can't i just install, import and run chunking and not have to worry about dependencies, bloat, speed or other factors?
Well, with chonkie you can! (chonkie boi is a gud boi)
✅ All the CHONKs you'd ever need
✅ Easy to use: Install, Import, CHONK
✅ No bloat, just CHONK
✅ Cute CHONK mascoot
✅ Moto Moto's favorite python library
What're you waiting for, just CHONK it!
Table of Contents
Why do we need Chunking?
Here are some arguments for why one would like to chunk their texts for a RAG scenario:
- Most RAG pipelines are bottlenecked by context length as of today. While we expect future LLMs to exceed 1Mill token lenghts, even then, it's not only LLMs inside the pipeline, but other aspects too, namely, bi-encoder retriever, cross-encoder reranker and even models for particular aspects like answer relevancy models and answer attribution models, that could lead to the context length bottleneck.
- Even with infinite context, there's no free lunch on the context side - the minimum it takes to understand a string is o(n) and we would never be able to make models more efficient on scaling context. So, if we have smaller context, our search and generation pipeline would be more efficient (in response latency)
- Research suggests that a lot of random, noisy context can actually lead to higher hallucination in the model responses. However, if we ensure that each chunk that get's passed onto the model is only relevant, the model would end up with better responses.
Quick CHONK!
Installation
To install chonkie, simply run:
pip install chonkie
Chonkie follows the rule to have minimal defualt installs, read the DOCS to know the installation for your required chunker, or simply install all
if you don't want to think about it (not recommended).
pip install chonkie[all]
Usage
Here's a basic example to get you started:
from chonkie import TokenChunker
# Initialize the chunker
chunker = TokenChunker()
# Chunk some text
chunks = chunker("Your text here")
print(chunks)
More example usages given inside the DOCS
Citation
If you use Chonkie in your research, please cite it as follows:
@misc{chonkie2024,
author = {Minhas, Bhavnick},
title = {Chonkie: A Lightweight Chunking Library for RAG Bots},
year = {2024},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/bhavnick/chonkie}},
}
Project details
Release history Release notifications | RSS feed
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
Hashes for chonkie-0.0.1a6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66e13c3e436f2c5859ee58fb970912eea876d06cc9c29c06a00ed95ab4cc9c41 |
|
MD5 | f0c839941cbc23112d00b0834db28d0f |
|
BLAKE2b-256 | e0a6f4764387c9e0e22f65af8f2f90435af3d6da9baa55a3bd2c7be2b604ada3 |