Skip to main content

RAG Ingestion

A lightweight document ingestion component for Retrieval-Augmented Generation (RAG) pipelines.

RAG Ingestion handles the initial document-processing stage of a RAG workflow: loading supported files, extracting their content, tracking token usage, cleaning extracted text, and splitting documents into chunks.

The package is designed to work with LangChain Document objects and can be used as a standalone component or as part of a larger RAG pipeline.

Features

  • Load multiple documents from file paths
  • Support for PDF, DOCX, and XLSX files
  • Extract content into LangChain Document objects
  • Token counting with tiktoken
  • Optional maximum token budget
  • Optional strict error handling
  • Basic text cleaning while preserving document metadata
  • Configurable LangChain text splitter
  • Configurable chunk size and chunk overlap
  • Compatible with custom tokenizers and text splitters

Supported File Types

File type Loader
.pdf PyPDFLoader
.docx Docx2txtLoader
.xlsx UnstructuredExcelLoader

Installation

pip install rag-ingestion

Basic Usage

from rag_ingestion import RAGIngection

ingestion = RAGIngection()

result = ingestion.load([
    "document.pdf",
    "document.docx",
    "spreadsheet.xlsx",
])

documents = result["documents"]

chunks = ingestion.chunk(documents)

The load() method returns:

{
    "documents": [...],
    "total_tokens": ...,
    "files_processed": ...
}

Configuration

The ingestion component can be configured with optional parameters:

ingestion = RAGIngection(
    tokenizer=custom_tokenizer,
    max_tokens=4000,
    strict=True,
    chunk_size=1000,
    chunk_overlap=200,
    clean=True,
)

Tokenizer

A custom tokenizer can be supplied when required.

If no tokenizer is provided, the package uses the default cl100k_base encoding from tiktoken.

Token Budget

max_tokens can be used to limit the total number of extracted tokens processed by the loader.

ingestion = RAGIngection(max_tokens=4000)

If no limit is provided, token processing is unlimited.

Strict Mode

By default, unsupported or failed files are skipped.

To raise an exception instead:

ingestion = RAGIngection(strict=True)

Chunking

Documents can be split using the default recursive character text splitter:

chunks = ingestion.chunk(documents)

Chunking can be configured with:

ingestion = RAGIngection(
    chunk_size=1000,
    chunk_overlap=200,
)

A custom LangChain text splitter can also be supplied.

Pipeline

The basic processing flow is:

Files
  ↓
Load & Extract
  ↓
Token Counting
  ↓
Text Cleaning
  ↓
Chunking
  ↓
LangChain Documents

The resulting chunks can then be passed to a retrieval system, vector store, hybrid retriever, or another downstream RAG component.

Dependencies

This package uses components from the LangChain ecosystem together with document loaders and tokenization utilities.

The package dependencies are defined in pyproject.toml.

Status

This is the initial version of the RAG ingestion component, developed as a modular building block for a larger RAG system.

The package is intentionally focused on document ingestion and preprocessing rather than retrieval or generation.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Release files for rag-ingestion 0.1.0

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

Source distribution (sdist)

Source distribution for rag-ingestion 0.1.0
File Size Uploaded
rag_ingestion-0.1.0.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rag-ingestion 0.1.0
File Interpreter ABI Platform
rag_ingestion-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.3 kB

Release files / rag_ingestion-0.1.0.tar.gz

Download URL rag_ingestion-0.1.0.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0a3ed20267b1b2759a3899cb815072a253564a78c2e65ef129633125fcdaa400
BLAKE2b-256 checksum
How to use checksums
611377a5ad1ab9e9925fe79528f0f1d51753c9af18e465510f29dbc2c6b74d78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 24, 2026.

Transparency log

Release files / rag_ingestion-0.1.0-py3-none-any.whl

Download URL rag_ingestion-0.1.0-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07645dd61bd4f4139039bf6f79642a5682b24c1e115b08ce01fb028c14a237c0
BLAKE2b-256 checksum
How to use checksums
9fe04e23f693e48c859dfddf124655928891a28b64a825e348047a530d1b0504
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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