Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Legal-Bot:

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.


🧩 Problem Statement: "The Legal Knowledge Gap"

  • 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.


💡 Our Approach & Importance

Legal-Bot uses a Retrieval-Augmented Generation (RAG) pipeline to combine fast document retrieval with LLM-powered explanations:

  1. Retrieval (Precision): FAISS + Sentence-Transformers quickly find the most relevant IPC sections.
  2. Generation (Clarity): Llama 3.1 (via Ollama) rewrites complex legal text into plain language.
  3. Local Privacy: Runs entirely on your machine — no cloud dependency, ensuring confidentiality.
  4. 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.


🏗️ System Architecture

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
Loading

✨ Features

  • 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.

🚀 Getting Started

1. Clone the Repository

git clone https://github.com/arjunrd07/Legal-Bot.git
cd Legal-Bot

2. Set Up Ollama & Llama 3.1

ollama run llama3.1

(Downloads the model and starts an interactive session. Exit with /bye once complete.)


⚡ Running the Application

Option A: Automated Setup (Recommended)

  • 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.

Option B: Manual Setup

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.py

App runs at http://localhost:8501.


🖥️ Usage

  • 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.

📦 Dependencies

  • Python 3.8+
  • Streamlit
  • Sentence-Transformers
  • FAISS-CPU
  • PyTorch
  • Ollama Python Library
  • Utilities: langchain, pydantic, etc.

🎯 Impact

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.


🔮 Future Roadmap

  • 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.

About

Legal-Bot simplifies IPC law with RAG pipeline, FAISS search, and local Llama 3.1 for clear, private legal explanations.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages