An AI-powered Legal Question-Answering system that uses Retrieval-Augmented Generation (RAG) to provide accurate responses from a legal document database. It combines LangChain, vector embeddings, and OpenAIβs GPT models to ensure reliable legal answers.
- β Ask Legal Questions β Get answers based on actual legal documents.
- β Retrieval-Augmented Generation (RAG) β Combines document context with GPT for accuracy.
- β LangChain Integration β Handles document loading, chunking, and chaining.
- β Embedding + Vector Store β Converts documents into vectors for semantic search.
- β Simple Streamlit UI β Easy-to-use web interface.
- β OpenAI GPT β Powered by GPT-3.5/4 for final response generation.
legal-qa-rag-bot/
βββ .gitignore
βββ LICENSE
βββ README.md
βββ requirements.txt
βββ app.py # Streamlit app UI
βββ qa_chain.py # LangChain question-answering logic
βββ vector_store.py # Vector DB (FAISS) logic
βββ data/
β βββ legal_docs/ # Upload your PDF/DOCX legal files here
βββ .env # API keys (DO NOT COMMIT)
- Python 3.11+
- LangChain
- FAISS (Facebook AI Similarity Search)
- OpenAI GPT-3.5/4
- Streamlit for UI
- python-dotenv
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Set up
.env
file:
Create a .env
file in the root with this line:
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- Add Legal Documents:
Place your .pdf
or .docx
files inside the data/legal_docs/
folder.
- Run the app:
streamlit run app.py
- Never commit
.env
or API keys. - Add this to your
.gitignore
file:
.env
- Clean up large or unnecessary files before pushing.
- Ask natural language legal questions.
- Answers will be based only on your uploaded documents.
- Everything happens locally except OpenAI API calls.
- π Authentication for private deployments
- π Admin dashboard for monitoring usage
- π¬ Chat history + feedback collection
- π Multi-language support
- π§ Plug into government APIs or court data
This project is licensed under the MIT License.
Pull requests are welcome. For major changes, open an issue first to discuss the improvements you'd like to make.
Place your demo images or gifs in a `screenshots/` folder and reference like:

git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/YOUR_USERNAME/legal-qa-rag-bot.git
git push -u origin main