Skip to main content

chunking4rag

For implementing a good RAG framework, we need 3 steps:

  1. Data Ingestion/ Parsing
  2. Chunking
  3. Embedding/ Vectorization

Data Ingestion is a important steps where we extract data from a document. Aa document can be available in various formats like text, pdf, excel, csv or even Images. The data_extraction folder contains classes to extract data from different types of documents.

Chunking is the process of breaking up a document into smaller chunks. The chunking methods are implemented in the chunkingmethods folder.

The strategies discussed in this repo are:

  1. Fixed length chunking

  2. Keyword chunking

  3. Adaptive chunking

  4. Sliding window

  5. Paragraph chunking

  6. Sentence chunking

Embedding is the process of converting text into vectors. The embedding methods are implemented in the embeddingmethods folder.

To use the library

The library is quite simple to use. Below example uses sentence chunking by extraction from text data

from data_extraction.document_parser import DocumentParser
from chunkingmethods.sentence_chunking import SentenceChunking
from chunkingdatamodel.chunking_model import ChunkingInput


text_content = "<html><body><p>Sample text content. This is a test. It has multiple sentences. It also has some punctuation.</p></body></html>"


text_document = DocumentParser(doc_type={"kind":"HTMLDocument"}).doc_type
content = text_document.get_content(text_content).pages[0].textual_content
data = ChunkingInput(text=content)

sentence_chunking = SentenceChunking(data)
chunks = sentence_chunking.chunk()
print(chunks)

# for pdf document data extraction use the following
pdf_document = DocumentParser(doc_type={"kind":"PDFDocument"}).doc_type
with open("test.pdf", "rb") as f:
    extracted_content = pdf_document.get_content(f.read()).pages[0].textual_content
print(extracted_content)

To install this library

Run the following command

pip install chunking4rag

To start with contribution to the project

  1. Clone the repository using git

  2. Create a virtual environment using uv

uv create chunking4rag
  1. Activate the virtual environment
source .venv/bin/activate
  1. Install the dependencies by running
uv install -r requirements.txt
  1. Run tests to make sure everything is working fine
python chuking_tests.py

Metadata

Release files for chunking4rag 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chunking4rag 0.0.5
File Size Uploaded Provenance
chunking4rag-0.0.5.tar.gz 12.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for chunking4rag 0.0.5
File Interpreter ABI Platform
chunking4rag-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 29.0 kB

Release files / chunking4rag-0.0.5.tar.gz

Download URL chunking4rag-0.0.5.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bf527221cc1d473fc331e4d7e0d969a5851d4061c0db7cab03c02782391ba5f6
BLAKE2b-256 checksum
How to use checksums
73c66b7ee8c00a30134dfa33181f9627556a3d670aa1aa67877bf98de8f393af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 12, 2025.

Transparency log

Release files / chunking4rag-0.0.5-py3-none-any.whl

Download URL chunking4rag-0.0.5-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca7c43257ac39ea54467fb8f19dde7afe0a505c8eebc44b71e4fc107bce1d38d
BLAKE2b-256 checksum
How to use checksums
2bf8bbbcb5b5f9d03b8637ba49f8a1484fd618b1f265d1092e48704828d5f7e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 12, 2025.

Transparency log

Security for chunking4rag 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for chunking4rag-0.0.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 12, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page