This project is a Retrieval-Augmented Generation (RAG) system designed to answer Bangla and English questions from a Bangla literature book (HSC26 Bangla 1st Paper PDF). The system retrieves the most relevant document chunks and generates grounded answers using an LLM.
| Category | Tool/Library |
|---|---|
| Text Extraction | PyMuPDF, Tesseract (for Bangla OCR) |
| Chunking | langchain.text_splitter |
| Embedding | intfloat/multilingual-e5-base (via sentence-transformers) |
| Vector Store | FAISS |
| LLM | LLaMA3 via Ollama OR Mistral/GPT-4 |
| Retrieval Logic | numpy, scikit-learn for hybrid search |
| Interface | Command Line (CLI), optional REST API |
Install dependencies:
pip install faiss-cpu sentence-transformers scikit-learn ollama numpy
Install Ollama (for LLaMA/Mistral): https://ollama.com/download
Run the following steps in order:
python src/chunk_text.py
python src/embed_store.py
python src/retrieve_with_llama3.py # or retrieve_with_mistral.py or retrieve_with_gpt.py
Make sure your FAISS index and model are ready.
Start the FastAPI server:
uvicorn main:app --reload
http://localhost:8000/docs
You can now test the /query endpoint with Bangla or English questions.
| Query (Bangla) | Expected Answer |
|---|---|
| অনুপমের ভাষায় সুপুরুষ কাকে বলা হয়েছে? | শব্তুনাথ |
| কাকে অনুপমের ভাগ্য দেবতা বলে উল্লেখ করা হয়েছে? | মামাকে |
| বিয়ের সময় কল্যাণীর প্রকৃত বয়স কত ছিল? | ১৫ বছর |
Used PyMuPDF and Tesseract for Bangla OCR. PyMuPDF was selected for its accurate layout preservation. Challenges included line breaks, noise, and MCQ formatting, which were cleaned manually.
Character-based chunking (via RecursiveCharacterTextSplitter, chunk size = 500, overlap = 50). It ensures semantically coherent chunks while avoiding long sequences.
intfloat/multilingual-e5-base. Chosen for its multilingual understanding and compatibility with FAISS. It captures semantic similarity better for Bangla queries than MiniLM.
Used a hybrid of:
This balances contextual understanding with lexical matching for better retrieval.
"query: ..." prefix for semantic alignmentYes, but minor errors occur when chunks lack structure or are misaligned. Improvements include:
Not implemented yet. Would include:
POST /query
{
"question": "অনুপমের ভাষায় সুপুরুষ কাকে বলা হয়েছে?"
}
Implemented:
src/
│
├── chunk_text.py # Loads and chunks PDF
├── embed_store.py # Embeds and stores vectors in FAISS
├── retrieve_with_llama3.py # Main CLI using Ollama + LLaMA
├── retrieve_with_mistral.py # Alternate model
├── retrieve_with_gpt.py # (Optional) GPT API
├── utils/ # Contains text cleaning, OCR tools
embeddings/
outputs/
To quit CLI:
exit
quit
q
🎯 Good luck! Make sure to push your code to a GitHub Public Repo and attach this
README.md.
11 commits
Python
100.0%
This project is a Retrieval-Augmented Generation (RAG) system designed to answer Bangla and English questions from a Bangla literature book (HSC26 Bangla 1st Paper PDF). The system retrieves the most relevant document chunks and generates grounded answers using an LLM.
| Category | Tool/Library |
|---|---|
| Text Extraction | PyMuPDF, Tesseract (for Bangla OCR) |
| Chunking | langchain.text_splitter |
| Embedding | intfloat/multilingual-e5-base (via sentence-transformers) |
| Vector Store | FAISS |
| LLM | LLaMA3 via Ollama OR Mistral/GPT-4 |
| Retrieval Logic | numpy, scikit-learn for hybrid search |
| Interface | Command Line (CLI), optional REST API |
Install dependencies:
pip install faiss-cpu sentence-transformers scikit-learn ollama numpy
Install Ollama (for LLaMA/Mistral): https://ollama.com/download
Run the following steps in order:
python src/chunk_text.py
python src/embed_store.py
python src/retrieve_with_llama3.py # or retrieve_with_mistral.py or retrieve_with_gpt.py
Make sure your FAISS index and model are ready.
Start the FastAPI server:
uvicorn main:app --reload
http://localhost:8000/docs
You can now test the /query endpoint with Bangla or English questions.
| Query (Bangla) | Expected Answer |
|---|---|
| অনুপমের ভাষায় সুপুরুষ কাকে বলা হয়েছে? | শব্তুনাথ |
| কাকে অনুপমের ভাগ্য দেবতা বলে উল্লেখ করা হয়েছে? | মামাকে |
| বিয়ের সময় কল্যাণীর প্রকৃত বয়স কত ছিল? | ১৫ বছর |
Used PyMuPDF and Tesseract for Bangla OCR. PyMuPDF was selected for its accurate layout preservation. Challenges included line breaks, noise, and MCQ formatting, which were cleaned manually.
Character-based chunking (via RecursiveCharacterTextSplitter, chunk size = 500, overlap = 50). It ensures semantically coherent chunks while avoiding long sequences.
intfloat/multilingual-e5-base. Chosen for its multilingual understanding and compatibility with FAISS. It captures semantic similarity better for Bangla queries than MiniLM.
Used a hybrid of:
This balances contextual understanding with lexical matching for better retrieval.
"query: ..." prefix for semantic alignmentYes, but minor errors occur when chunks lack structure or are misaligned. Improvements include:
Not implemented yet. Would include:
POST /query
{
"question": "অনুপমের ভাষায় সুপুরুষ কাকে বলা হয়েছে?"
}
Implemented:
src/
│
├── chunk_text.py # Loads and chunks PDF
├── embed_store.py # Embeds and stores vectors in FAISS
├── retrieve_with_llama3.py # Main CLI using Ollama + LLaMA
├── retrieve_with_mistral.py # Alternate model
├── retrieve_with_gpt.py # (Optional) GPT API
├── utils/ # Contains text cleaning, OCR tools
embeddings/
outputs/
To quit CLI:
exit
quit
q
🎯 Good luck! Make sure to push your code to a GitHub Public Repo and attach this
README.md.
11 commits
Python
100.0%