Skip to content

Swastik0407/LexQuery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LexQuery — Indian Legal Intelligence System

Ask questions across IPC sections, Supreme Court judgments, and contracts — powered by RAG, LLaMA3, and ChromaDB.


Problem

Legal research in India is slow, expensive, and inaccessible. Finding the right IPC section, understanding a court judgment, or spotting risky contract clauses requires hours of manual reading. LexQuery makes it conversational.


What It Does

  • IPC Q&A — "What is the punishment for culpable homicide?" → cited answer from IPC_1860
  • Judgment summarization — "Summarize the Maneka Gandhi judgment" → plain-English answer with source
  • Contract analysis — "What does the indemnity clause say?" → answer grounded in the uploaded contract
  • Filtered queries — search only IPC, only judgments, or only contracts

Tech Stack

Component Tool
PDF extraction pdfplumber
Chunking LangChain RecursiveCharacterTextSplitter
Embeddings HuggingFace all-MiniLM-L6-v2
Vector store ChromaDB
LLM Groq LLaMA3-8b
Orchestration LangChain

Project Structure

lexquery/
├── data/
│   ├── ipc/             # IPC_1860.pdf
│   ├── judgments/       # landmark SC judgment PDFs
│   └── contracts/       # sample contract PDFs
├── src/
│   ├── ingest.py        # load → clean → chunk → embed → store
│   ├── retriever.py     # query ChromaDB with optional filters
│   └── chain.py         # Groq LLaMA3 QA chain
├── main.py              # CLI entry point
├── config.yaml          # all settings
├── .env.example         # API key template
└── requirements.txt

Setup

# 1. Clone
git clone https://github.com/yourusername/lexquery.git
cd lexquery

# 2. Install dependencies
pip install -r requirements.txt

# 3. Set up API keys
cp .env.example .env
# Add your GROQ_API_KEY and HF_TOKEN to .env

# 4. Add PDFs to data/ folders (see Data Sources below)

# 5. Ingest
python main.py --ingest

Usage

# Query across all documents
python main.py --query "What is the punishment for murder under IPC?"

# Filter by document type
python main.py --query "What does Section 420 say?" --doc_type ipc
python main.py --query "Summarize the Maneka Gandhi judgment" --doc_type judgment
python main.py --query "What are the indemnity terms?" --doc_type contract

Data Sources

All data is publicly available and free to download:

Type Source URL
IPC 1860 India Code (Govt. of India) https://indiacode.nic.in
SC Judgments Indian Kanoon https://indiankanoon.org
SC Judgments Supreme Court of India https://sci.gov.in
Sample Contracts TLDR Legal https://tldrlegal.com

Configuration

All settings are in config.yaml — no hardcoded values in code:

embedding:
  model: "sentence-transformers/all-MiniLM-L6-v2"
llm:
  model: "llama3-8b-8192"
chunking:
  chunk_size: 800
  chunk_overlap: 100
retrieval:
  top_k: 5

Author

Swastik — CS Engineering Student, building toward AI Engineering.

About

LexQuery is a RAG-based Legal Intelligence System that allows users to query Indian legal documents (IPC, judgments, contracts) and receive grounded, citation-backed answers using LLMs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages