This project is a Retrieval-Augmented Generation (RAG) system built to search and understand Nepali legal documents.
It combines traditional keyword search (BM25), semantic vector search (FAISS), and cross-encoder reranking to provide the most relevant results, and can generate answers using Gemini API.
- Hybrid Search: Combines BM25 (Elasticsearch) and FAISS semantic similarity.
- Cross-Encoder Reranker: Reorders retrieved documents using a transformer-based reranker for higher accuracy.
- Multilingual Support: Handles both English and Nepali texts with multilingual models.
- RAG Integration: Generates answers using the retrieved context and Gemini LLM.
- Streamlit UI: Has a streamlit UI for the user
│ ├── dataset/ | ├── edited/ │ ├── indexes/ | | ├── faiss/ │ ├── processed/ │ ├── embeddings/ │ └── raw_pdfs/ ├── notebooks/ ├── scripts/ ├── requirements.txt ├── .gitignore └── README.md
- User Query: The user inputs a question or keyword (either in English or Nepali).
- Document Retrieval: Both BM25 and FAISS independently retrieve top chunks from all law documents.
- Reranking: The cross-encoder model assigns relevance scores and ranks them accordingly.
- Context Formation: The top results are combined to form a structured context.
- Answer Generation: The RAG model (using Gemini API) generates a natural-language answer based on the retrieved context.
- Display: The Streamlit interface shows both the generated answer and the supporting references (chapter, section, law name).
- The system supports both Nepali and English queries and documents.
- A multilingual sentence transformer is used for embeddings to ensure cross-language semantic understanding.
- Each document in the dataset includes:
doc_id(unique per law or language version)chunk_idchaptersectiontext
- All documents (both languages) are stored under a single Elasticsearch index and included in the same FAISS index.
1. Elasticsearch
2. Python(3.10+)
git clone https://github.com/fuseai-fellowship/Law-search-Engine-Nepali.git
cd Law-search-Engine-Nepali
python -m venv env
source env/bin/activate
pip install -r requirements.txt
ELASTIC_PASSWORD=your_elasticsearch_password
GEMINI_API_KEY=google_studio_api_key
To setup elasticsearch indexing please visit our notebooks section
docker start elasticsearch_container
cd scripts/
streamlit run app.py
The app will be available at: 👉 http://localhost:8501
- Add context summarization for long documents
- Include Nepali Question Answering (QA) model fine-tuned on legal datasets
- Integrate document upload and indexing directly from UI
- Enhance search visualization and ranking transparency



