This project converts PDF documents to plain text for use with the NVIDIA's AgentIQ toolkit, OCR support with Tesseract, and automated cleaning pipelines. The processed texts are then indexed and retrieved within a Retrieval-Augmented Generation (RAG) system that powers a legal assistant capable of answering questions grounded in real legal case documents.
NVIDIA_Hackathon/
├── AIQToolkit/ # External toolkit (cloned from GitHub and modififed for this project)
├── data/
│ ├── input/ # Original PDFs, organized in folders (Capsulas, Jornadas, Jurisprudencia)
│ └── output/ # Cleaned .txt files ready for retrieval
├── utilities/
│ ├── convert_pdfs.py # Extracts text from PDFs (uses OCR if needed)
│ ├── clean_existing_output.py # Cleans headers, footers, and blank lines from .txt files
│ └── validate_clean_output.py # Validates that output files are clean (no headers/footers, no blank lines)
├── run_pipeline.bat # Batch file to automate conversion, cleaning, and validation
├── move_files.sh # File to copy the files into the toolkit
└── README.md # This file
- Before you begin using AgentIQ, ensure that you meet the following software prerequisites.
-
Install Git
-
Install Git Large File Storage (LFS)
-
Install uv
- Clone the AIQToolkit repository. To do so, open the terminal inside the nvidia-hackathon project and run
git clone https://github.com/NVIDIA/AIQToolkit.git
cd AIQToolkit- Initialize, fetch, and update submodules in the Git repository.
git submodule update --init --recursive- Fetch the data sets by downloading the LFS files.
git lfs install
git lfs fetch
git lfs pull- Create a Python environment.
uv venv --seed .venv
source .venv/bin/activate- Install the AgentIQ library along with all of the optional dependencies.
uv sync --all-groups --all-extrasTo run the RAG (Retrieval-Augmented Generation) system—whether you're posing a query, running an evaluation, or modifying the data ingestion files—follow the following instructions. This instructions assume that you are already in the AIQToolkit folder.
-
Install the necessary libraries:
uv pip install -e examples/simple_rag
-
Move the new scripts inside the simple_rag example project. This file also removes the .git from the AIQToolkit folder.
../move_files.sh
-
Start the docker compose [Skip this step if you already have Milvus running]
docker compose -f examples/simple_rag/deploy/docker-compose.yaml up -d
-
Export your NVIDIA API key:
export NVIDIA_API_KEY=<YOUR API KEY HERE>
-
Next, execute the
bootstrap_milvus.shscript as illustrated below.scripts/bootstrap_milvus.sh
-
Run the workflow.
aiq run --config_file examples/simple_rag/configs/milvus_rag_config.yml --input "¿Qué criterios utiliza el Tribunal Supremo y las Audiencias Provinciales para diferenciar entre un discurso amparado por la libertad de expresión y un discurso que constituye delito de odio según el artículo 510 del Código Penal?" -
Evaluate the responses.
aiq eval --config_file=examples/simple_rag/configs/eval_config.yml
In order to do so, you have to select in the examples/simple_rag/configs/eval_config.yml file, inside eval/ general/dataset/file_path you have to select the json containing the answer you want to evaluate. In my case, I have created a data folder inside the simple_rag folder in which I have placed 5 different jsons with 5 different questions to evaluate. The results of the evaluation will appear in a temporal folder inside the AIQToolkit folder.
To run the entire process of converting the PDFs to .txt files (PDF extraction, cleaning, validation) with one command:
python run_pipeline.batThis will:
- Extract text from PDFs (convert_pdfs.py)
- Clean blank lines (clean_existing_output.py)
- Validate the output files are ready for retrieval (validate_clean_output.py)
- Convert PDFs to TXT:
python utilities/convert_pdfs.py- Clean .txt outputs:
python utilities/clean_existing_output.py- Validate cleaned outputs:
python utilities/validate_clean_output.pyThis project uses Tesseract and pdf2image to handle scanned PDFs.
- Install Tesseract for Windows
- Add it to your PATH (e.g.
C:\Program Files\Tesseract-OCR\) - Install Poppler from:
https://github.com/oschwartz10612/poppler-windows/releases - Add
C:\poppler\Library\binto your PATH
This project properly ignores:
- AIQToolkit
For any questions, contact the project team.