This project uses Python to turn the Finance Bill 2025 into a searchable Q&A system. It combines OCR, text cleaning, BM25 search, and a multilingual model (English & Swahili) to create a Retrieval-Augmented Generation (RAG) tool.
```markdown
# Finance Bill 2025 Multilingual Question-Answering
This project is a Python-based notebook that extracts text from the **Finance Bill 2025 PDF**, preprocesses it, and uses **BM25 retrieval** plus a **multilingual Question-Answering model** to answer questions in **English and Swahili**. It’s essentially a Retrieval-Augmented Generation (RAG) system built around the Finance Bill.
---
## Features
- **OCR Extraction:** Uses Tesseract OCR and `pdf2image` to extract text from scanned PDFs.
- **Text Preprocessing:** Splits large text into clean paragraphs for easy retrieval.
- **BM25 Retrieval:** Finds the most relevant paragraphs using the `rank-bm25` algorithm.
- **Multilingual QA Model:** Uses a fine-tuned XLM-RoBERTa model to answer questions in both English and Swahili.
- **RAG Pipeline:** Combines retrieval + generation into a simple question-answering system.
---
## Project Structure
```
project-folder/
│
├── Finance\_Bill\_2025.ipynb # Main notebook with all code
├── finance\_bill\_text.txt # Extracted text saved locally
└── README.md # This file
````
---
## Installation
1. **Clone the repository**
```bash
git clone
github.com
cd finance-bill-2025
````
2. **Install dependencies**
```bash
pip install --upgrade pip
pip install torch transformers rank-bm25 PyPDF2 googletrans==4.0.0-rc1
pip install pytesseract pdf2image pillow sentencepiece tiktoken
```
3. **Set up Tesseract**
* Install Tesseract OCR on your machine.
* Update the `pytesseract.pytesseract.tesseract_cmd` path in the notebook to where Tesseract is installed on your system.
---
## Usage
1. Run the notebook cells step by step.
2. Upload or point to the Finance Bill 2025 PDF.
3. The system extracts text, preprocesses it, and builds a multilingual retriever + generator.
4. Ask questions in **English or Swahili** using the RAG pipeline.
Example:
```python
query_en = "What are the main tax p …