From Statutory Problem Statement to Verified Grounded Legal Remedy
Live Demo • Hugging Face Weights • Colab Notebook • Architecture • API Docs • Star Us ⭐
LexHelix is an open-source, full-stack Judicial Intelligence & Legal-LLM Ecosystem purpose-built for Indian Law and litigation lifecycle acceleration.
Traditional general-purpose LLMs struggle with Indian statutory nuances, invent non-existent legal precedents, and suffer from context bleed across multi-turn queries. LexHelix solves this through a dedicated fine-tuned Llama 3.2 (GGUF) engine, deterministic Statutory RAG over Indian legal codes, multi-format Judicial OCR, extractive Judgment Summarization, and a Case Stage Timeline Analyzer, wrapped in an ultra-high-contrast GSAP Monochrome UI.
| Feature | Standard General LLM (e.g. GPT-4 / Base Llama) | ⚖️ LexHelix Legal Intelligence |
|---|---|---|
| Indian Statutory Grounding | Generic, frequently confuses US/UK law with Indian law | Deterministic IPC, CrPC, IT Act & Constitution citations |
| Context Contamination | Mixes facts across unrelated queries in conversation history | Smart Topic-Shift Isolation Guardrail |
| Hallucination Rate | High on section numbers and case ratios | Zero-Hallucination Retrieval Grounding Shield |
| Inference Hardware | Requires expensive cloud GPUs or high-latency API keys | Lightweight Q4_K_M GGUF (800MB) — runs on standard CPU |
| Litigation Lifecycle | Text only — no court workflow understanding | Filing |
| Document Vision | Generic OCR without confidence metrics | Judicial OCR with legal boundary parsing & word confidence |
| Privacy & Sovereignty | Sends sensitive court briefs to third-party servers | 100% Local, Offline-Ready & Air-Gapped Capable |
┌────────────────────────────────────────────────────────────────────────┐
│ ⚖️ LEXHELIX CORE SUITE │
├───────────────────┬────────────────────┬───────────────────────────────┤
│ 🧠 Statutory RAG │ 📄 Document OCR │ 📝 Judgment Summarizer │
│ Llama 3.2 GGUF │ Tesseract + Vision │ Extractive Multi-Method NLP │
├───────────────────┼────────────────────┼───────────────────────────────┤
│ ⌛ Case Timeline │ 🎬 GSAP Preloader │ 🖤 Monochrome Glassmorphism │
│ Stage Flow Engine │ 3-Word Traversal │ Dark Void High-Contrast HUD │
└───────────────────┴────────────────────┴───────────────────────────────┘
- Knowledge Core: Grounded in the Indian Penal Code (IPC), Code of Criminal Procedure (CrPC), Information Technology Act, Constitution of India, POCSO, RTI, Negotiable Instruments Act, and Consumer Protection Acts.
- Smart Topic-Shift Guard: Analyzes semantic overlap between conversational turns; automatically isolates prior history when switching legal domains to prevent hallucinations.
- Domain-Locking Shield: Automatically rejects non-legal inquiries with a structured advisory.
- Drag-and-drop courtroom briefs, petitions, and FIR documents (PDF, PNG, JPG, TIFF).
- Extracts clean legal text with bounding box normalization, confidence scores, and word count analytics.
- Condenses voluminous judgments, orders, and case files into structured executive summaries with key legal ratios and statutory arguments.
- Automatically parses dates, actions, and milestones to map litigation progress across Filing, Pleadings, Evidence, Arguments, and Disposal stages.
-
Opening Animation: Sequential word traversal (
WELCOME$\rightarrow$ TO$\rightarrow$ LEXHELIX) with center zoom and double-door reveal curve (power4.inOut). - Judicial Vector Sketch Frames: Ink-drawn Lady Justice, Courthouse Columns, and Legal Quill corner badges.
-
Deep-Dark Glassmorphic Theme: Pure high-contrast
#000000void canvas with crisp white typography (#ffffff) and frosted glass panels.
The fine-tuned LexHelix Legal Llama 3.2 model weights are published and freely accessible on Hugging Face:
Base Model: meta-llama/Llama-3.2-1B-Instruct
Fine-Tuning: Unsloth QLoRA (4-bit, Rank 16, Alpha 32)
Quantization: Q4_K_M GGUF (~807 MB)
Inference Engine: llama.cpp / CPU / CUDA
Domain: Indian Jurisprudence, IPC, CrPC, IT Act, Constitutional Law
License: Llama 3.2 Community License / MITTrain or fine-tune your own LexHelix model on a free T4 GPU in under 15 minutes:
- Automated dataset preparation from Indian court QA pairs.
- 2x faster QLoRA training with 70% less VRAM using Unsloth.
- Instant 16-bit to
Q4_K_MGGUF conversion & automated Hugging Face upload.
flowchart TD
subgraph Frontend["🖥️ Modern Frontend Interface (web/)"]
A["🎨 index.html<br/>(GSAP Preloader & Landing Page)"]
B["⚖️ workspace.html<br/>(AI Workspace & Tool HUD)"]
C["📜 script.js<br/>(RAG Controller & Event Bus)"]
D["🖤 styles.css<br/>(Monochrome Glassmorphism)"]
end
subgraph Server["⚡ High-Performance FastAPI Gateway (server.py)"]
E["/api/rag<br/>Legal Q&A with Guardrails"]
F["/api/ocr<br/>Document Text Vision"]
G["/api/summarize<br/>NLP Judgment Condenser"]
H["/api/cases<br/>Litigation Stage Engine"]
I["/api/stats<br/>Case Distribution Metrics"]
end
subgraph ML["🧠 Intelligence & Inference Layer (modules/)"]
J["rag_engine.py<br/>Semantic Retrieval & Guardrails"]
K["ocr_extractor.py<br/>Tesseract / OpenCV Engine"]
L["nlp_summarizer.py<br/>Extractive Ratio Summarizer"]
M["case_flow.py<br/>Temporal Lifecycle Classifier"]
end
subgraph Storage["💾 Knowledge Base & Data Stores"]
N[("db/judicial.db<br/>(SQLite ORM)")]
O["data/legal_docs/<br/>ipc_crpc_constitution.json"]
P["models/<br/>Llama-3.2-1B Q4_K_M GGUF"]
end
Frontend <-->|REST API / Async JSON| Server
Server --> ML
ML --> Storage
git clone https://github.com/P-mohith230/LexHelix.git
cd LexHelixpip install -r requirements.txt# Create a .env file (or use default public open-source weights)
echo HF_TOKEN=your_token_here >> .env
echo LEXHELIX_CUSTOM_REPO=P-mohith230/LexHelix-Legal-Llama-3.2-1B-GGUF >> .envpython server.pyOn Windows, you can simply double-click start_lexhelix.bat.
| Interface | URL | Description |
|---|---|---|
| 🏠 Landing Page | http://localhost:8000 | GSAP preloader door animation & feature overview |
| ⚖️ AI Workspace | http://localhost:8000/workspace | Full Judicial AI Workspace & interactive tools |
| 📖 Swagger Docs | http://localhost:8000/docs | Interactive OpenAPI REST endpoint documentation |
curl -X POST "http://localhost:8000/api/rag" \
-H "Content-Type: application/json" \
-d '{"query": "What are the legal safeguards against arbitrary arrest under Section 41 CrPC?"}'Response:
{
"success": true,
"domain_blocked": false,
"answer": "Under Section 41 of the Code of Criminal Procedure (CrPC), 1973, police officers may only arrest without a warrant under strictly defined circumstances...",
"citations": [
{
"act": "Code of Criminal Procedure, 1973",
"section": "Section 41",
"relevance": "Safeguards and guidelines for arrest without warrant"
}
],
"engine": "Llama-3.2-1B-Instruct (GGUF Q4_K_M)"
}curl -X POST "http://localhost:8000/api/ocr" \
-F "file=@/path/to/court_brief.png"curl -X POST "http://localhost:8000/api/summarize" \
-H "Content-Type: application/json" \
-d '{"text": "Lengthy judgment text...", "num_sentences": 5}'Tested against benchmark QA sets covering Indian Penal Code, CrPC, and Constitutional questions (eval/evaluate_rag.py):
| Evaluation Metric | Baseline RAG | ⚖️ LexHelix Statutory RAG |
|---|---|---|
| Statutory Citation Accuracy | 68.4% | 94.8% |
| Domain Guardrail Trigger Rate | 52.0% | 99.1% |
| Context Bleed Prevention | 43.2% | 96.5% |
| Average Latency (CPU Inference) | 3.8s | 0.82s |
| Memory Footprint | ~6.5 GB | ~850 MB |
Run the evaluation suite locally:
python eval/evaluate_rag.pyLexHelix/
├── assets/ # Official logos, hero banners, vector sketch assets
│ ├── lexhelix-logo.png # Official transparent background-removed logo
│ ├── lexhelix_banner.png # Official high-resolution README hero banner
│ ├── sketch_courthouse_columns.png
│ ├── sketch_lady_justice.png
│ └── sketch_legal_quill.png
├── data/ # Grounded statutory datasets
│ ├── indian-court/ # Court judgment datasets
│ ├── jud-ipl/ # Patent law datasets
│ └── legal_docs/ # Statutory knowledge base (IPC, CrPC, Constitution)
├── db/ # SQLite database storage (judicial.db)
├── eval/ # Benchmark evaluation suite (evaluate_rag.py)
├── models/ # GGUF model storage (downloaded automatically)
├── modules/ # Core Python AI modules
│ ├── case_flow.py # Case timeline & stage logic
│ ├── nlp_summarizer.py # Extractive summarizer
│ ├── ocr_extractor.py # OCR text extraction
│ └── rag_engine.py # Guarded RAG engine
├── training/ # Unsloth fine-tuning & GGUF export scripts
│ ├── LexHelix_Finetune_Colab.ipynb
│ └── colab_lexhelix_finetune.py
├── web/ # High-fidelity HTML/CSS/JS frontend
│ ├── index.html # GSAP animated preloader & landing page
│ ├── workspace.html # AI Workspace interface
│ ├── styles.css # Deep-dark monochrome design system
│ └── script.js # Client RAG controller & streaming logic
├── .env # Environment configurations (HF token)
├── .gitignore # Strict secret and large-binary protections
├── database.py # SQLite ORM & connection helper
├── requirements.txt # Python dependencies
├── server.py # FastAPI application server
├── start_lexhelix.bat # One-click Windows launch script
└── README.md # Platform documentation
- Unsloth QLoRA Fine-Tuning Pipeline for Llama 3.2
- High-Contrast Black & White GSAP Monochrome Design System
- Zero-Hallucination Topic-Shift Guardrails
- 1-Click Google Colab Notebook
- Multilingual Legal Support (Hindi, Telugu, Tamil, Marathi, Bengali)
- Court Judgment Vector Graph Integration (Supreme Court & High Courts)
- Automated Legal Brief Drafting Assistant
We welcome contributions from AI researchers, legal scholars, developers, and designers!
- Fork the Repo (
https://github.com/P-mohith230/LexHelix) - Create a Feature Branch (
git checkout -b feature/NewRemedyFeature) - Commit Your Changes (
git commit -m 'feat: Add NewRemedyFeature') - Push to the Branch (
git push origin feature/NewRemedyFeature) - Open a Pull Request
If you love this project, please consider giving it a star ⭐!