An open API service indexing awesome lists of open source software.

https://github.com/numikel/processtorag

ProcessToRag is a simple Python script that merges PDF files into grouped chunks β€” perfect for preparing documents for Retrieval-Augmented Generation (RAG) models or archiving purposes.
https://github.com/numikel/processtorag

Last synced: 3 months ago
JSON representation

ProcessToRag is a simple Python script that merges PDF files into grouped chunks β€” perfect for preparing documents for Retrieval-Augmented Generation (RAG) models or archiving purposes.

Awesome Lists containing this project

README

          

# 🧠 ProcessToRag

**ProcessToRag** is a modular Python tool for processing and preparing PDF documents for downstream tasks such as Retrieval-Augmented Generation (RAG), document classification, archiving or knowledge extraction.
It supports PDF merging, content extraction, paragraph segmentation and optional translation to English using the [NLLB-200](https://huggingface.co/facebook/nllb-200-distilled-600M) model.

## πŸš€ Features

- βœ… Automatically detects `.pdf` files in a given folder
- βœ… Merge mode: groups PDFs into chunks of defined size
- βœ… Mid-processing mode: extracts, cleans and splits text into paragraphs
- βœ… Optional translation to English (multi-language β†’ English) via NLLB
- βœ… Logging of processing steps and errors
- βœ… Ready for integration with RAG pipelines or ML workflows

## πŸ›  Requirements

Install dependencies (Python β‰₯ 3.9 recommended):

```bash
pip install -r requirements.txt
```

Ensure PyTorch is installed correctly – if using GPU, follow the installation instructions for your environment:
➑️ https://pytorch.org/get-started/locally/

## ▢️ How to Use
Run the script manually:

```bash
python process_to_rag.py
```

You can configure:
1) input_folder: where your PDF files are located
2) process_type: "merge" or "mid"
3) translation: True to enable translation to English
4) merge_file_count: number of files per merged PDF
5) logging: saves logs to process_to_rag_logs.txt

You can modify these directly in __main__ or extend with CLI (argparse support planned).

## πŸ“Œ Examples
Merge 25 PDF files into chunks of 10:
```python
ProcessToRag(input_folder="path/to/pdfs", process_type="merge", merge_file_count=10)
```

Extract and translate content from PDFs:
```python
ProcessToRag(input_folder="path/to/pdfs", process_type="mid", translation=True)
```

## πŸ“ Project Structure
```pgsql
PROCESSSTORAG/
β”œβ”€β”€ process_to_rag.py # Main script (PDF handling, extraction, logging)
β”œβ”€β”€ translation_tool/
β”‚ └── translation_tool.py # Translation wrapper for NLLB-200
β”œβ”€β”€ requirements.txt # Project dependencies
β”œβ”€β”€ README.md # Project documentation
β”œβ”€β”€ LICENSE # MIT license
β”œβ”€β”€ .gitignore # Git ignore rules
```

## πŸ—‚ Output
Extracted paragraphs are saved as .txt files in texts/ inside the output_folder.
Logs are written to process_to_rag_logs.txt.

## πŸ“Œ To-do
1) Add CLI support via argparse
2) Add full token-based chunking and embedding preparation
3) Support .docx and other formats
4) Add unit tests and CI pipeline

## πŸ‘€ Author
Made with ❀️ by MichaΕ‚ KamiΕ„ski

## 🧾 License
This project is licensed under the MIT License.
You are free to use, modify, and distribute it as you wish.