Legal-Bot is a Streamlit-based application designed to democratize access to the Indian Penal Code (IPC). It empowers users to quickly find simple, accurate explanations of IPC sections through an intuitive conversational interface.
- Complexity of Law: IPC sections are written in dense legal language, making them hard to understand for non-lawyers.
- Accessibility Issues: Citizens often lack affordable, reliable access to legal experts for basic queries.
- Fragmented Resources: People must search across multiple sources (books, websites, forums), wasting time and risking misinformation.
Legal-Bot bridges this gap by providing a simple, conversational way to understand IPC sections.
Legal-Bot uses a Retrieval-Augmented Generation (RAG) pipeline to combine fast document retrieval with LLM-powered explanations:
- Retrieval (Precision): FAISS + Sentence-Transformers quickly find the most relevant IPC sections.
- Generation (Clarity): Llama 3.1 (via Ollama) rewrites complex legal text into plain language.
- Local Privacy: Runs entirely on your machine — no cloud dependency, ensuring confidentiality.
- User-Centric Design: Streamlit UI makes interaction intuitive, lowering the barrier to legal knowledge.
Why it matters:
Legal-Bot empowers citizens, students, and professionals to understand their rights and responsibilities without needing a lawyer for every query. It’s a step toward accessible justice.
graph TD
A[User Query] --> B[Sentence-Transformers Embeddings]
B --> C[FAISS Vector Search]
C -->|Relevant IPC Sections| D{RAG Pipeline}
subgraph Intelligence
D --> E[Llama 3.1 via Ollama]
E --> F[Plain-Language Legal Explanation]
end
F --> G[Streamlit Chat UI]
G --> H[User]
subgraph Data Layer
I[legal_data.jsonl] --> C
C --> J[ipc_faiss.index + ipc_metadata.json]
end
- Intelligent IPC Explanations: Converts complex IPC sections into simple language.
- RAG Pipeline: Combines retrieval + generation for contextual accuracy.
- Local LLM Integration: Runs Llama 3.1 locally via Ollama.
- FAISS Vector Search: Lightning-fast retrieval.
- Streamlit UI: Clean, user-friendly interface.
- Dynamic Data Handling: Auto-generates FAISS index + metadata.
- Comprehensive Logging: Configurable via
logging_config.yaml.
git clone https://github.com/arjunrd07/Legal-Bot.git
cd Legal-Botollama run llama3.1(Downloads the model and starts an interactive session. Exit with /bye once complete.)
- Download
install.bat(Windows) from the latest GitHub Release. - Double-click to run.
- Script handles Ollama setup, model download, venv creation, dependency installation, and app launch.
pip install uv
python3 -m venv venv
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windows
uv pip install -r requirements.txt
streamlit run app.pyApp runs at http://localhost:8501.
- Open the app in your browser.
- Enter queries like:
"What is IPC section 302?""Explain crimes against children under IPC.""What are the punishments for theft?"
- Legal-Bot retrieves relevant IPC sections and generates simplified explanations.
- Python 3.8+
- Streamlit
- Sentence-Transformers
- FAISS-CPU
- PyTorch
- Ollama Python Library
- Utilities:
langchain,pydantic, etc.
Legal-Bot makes legal knowledge accessible by simplifying IPC sections into conversational explanations.
It reduces the barrier to understanding complex laws, empowering students, professionals, and citizens alike.
- Expanded Coverage: Beyond IPC to other Indian laws.
- Advanced Querying: Multi-section reasoning with cross-references.
- Enhanced Privacy: Fully offline inference with Ollama.
- Dockerized Deployment: Seamless containerized setup for production.