Skip to content

Repository files navigation

LexHelix — Judicial AI Platform Logo

⚖️ LexHelix

End-to-End Judicial Problem Solving & Legal-LLM Intelligence Platform

From Statutory Problem Statement to Verified Grounded Legal Remedy


Hugging Face Model Open In Colab GitHub Stars License: MIT


Python 3.10+ FastAPI Meta Llama 3.2 GSAP 3 GGUF Quantized PRs Welcome


Live DemoHugging Face WeightsColab NotebookArchitectureAPI DocsStar Us ⭐


📌 Executive Summary

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.


⚡ The LexHelix Advantage: Why We're Different

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 $\rightarrow$ Pleadings $\rightarrow$ Evidence $\rightarrow$ Judgment Tracker
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

🌟 Core Pillars & Feature Suite

  ┌────────────────────────────────────────────────────────────────────────┐
  │                         ⚖️ 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   │
  └───────────────────┴────────────────────┴───────────────────────────────┘

1. 🧠 Grounded Statutory RAG Assistant (/api/rag)

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

2. 📄 Judicial Document OCR Room (/api/ocr)

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

3. 📝 NLP Judgment Summarizer (/api/summarize)

  • Condenses voluminous judgments, orders, and case files into structured executive summaries with key legal ratios and statutory arguments.

4. ⌛ Chronological Case Timeline & Stage Engine (/api/cases)

  • Automatically parses dates, actions, and milestones to map litigation progress across Filing, Pleadings, Evidence, Arguments, and Disposal stages.

5. 🎬 Physics-Driven GSAP Cinematic Monochrome UI

  • 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 #000000 void canvas with crisp white typography (#ffffff) and frosted glass panels.

🤗 Hugging Face Model Hub & Weights

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 / MIT

⚡ 1-Click Fine-Tuning in Google Colab

Train or fine-tune your own LexHelix model on a free T4 GPU in under 15 minutes:

Open In Colab

  • Automated dataset preparation from Indian court QA pairs.
  • 2x faster QLoRA training with 70% less VRAM using Unsloth.
  • Instant 16-bit to Q4_K_M GGUF conversion & automated Hugging Face upload.

🏗️ System Architecture

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
Loading

🚀 Quick Start (Run in 60 Seconds)

1. Clone the Repository

git clone https://github.com/P-mohith230/LexHelix.git
cd LexHelix

2. Install Dependencies

pip install -r requirements.txt

3. Configure Environment (Optional)

# 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 >> .env

4. Launch the Server

python server.py

On Windows, you can simply double-click start_lexhelix.bat.

5. Access the Applications

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

📡 REST API Documentation

1. Legal RAG Query (POST /api/rag)

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)"
}

2. Document OCR (POST /api/ocr)

curl -X POST "http://localhost:8000/api/ocr" \
     -F "file=@/path/to/court_brief.png"

3. Judgment Summarizer (POST /api/summarize)

curl -X POST "http://localhost:8000/api/summarize" \
     -H "Content-Type: application/json" \
     -d '{"text": "Lengthy judgment text...", "num_sentences": 5}'

📊 Benchmark & Evaluation Results

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

📁 Repository Directory Map

LexHelix/
├── 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

🗺️ Roadmap & Future Horizons

  • 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

🤝 Contributing

We welcome contributions from AI researchers, legal scholars, developers, and designers!

  1. Fork the Repo (https://github.com/P-mohith230/LexHelix)
  2. Create a Feature Branch (git checkout -b feature/NewRemedyFeature)
  3. Commit Your Changes (git commit -m 'feat: Add NewRemedyFeature')
  4. Push to the Branch (git push origin feature/NewRemedyFeature)
  5. Open a Pull Request

🌟 Star History

If you love this project, please consider giving it a star ⭐!

Star History Chart


Star on GitHub


Built with ❤️ for Open-Source Legal AI & Transparent Judicial Problem Solving.

About

⚖️ End-to-End Judicial Problem Solving Platform powered by a fine-tuned Legal Llama 3.2 (GGUF), statutory RAG over Indian Law (IPC, CrPC, IT Act, Constitution), document OCR, judgment summarizer, and a physics-driven GSAP monochrome interface.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages