LexAI is a high-performance legal document analysis platform that leverages State-of-the-Art (SOTA) LLMs and Retrieval-Augmented Generation (RAG) to transform how legal professionals interact with complex contracts. Built with a focus on precision, security, and automation.
| Feature | Description | Technology |
|---|---|---|
| π Map-Reduce Summarization | Process 10,000+ word documents into structured executive summaries | LangChain LCEL, Parallel Processing |
| π¬ RAG-Powered Q&A | Hallucination-free chat grounded in your documents | FAISS, LLaMA 3.1, Sentence-Transformers |
| Multi-dimensional risk scoring (Compliance, Financial, Operational) | NLTK VADER, Keyword Frequency Analysis | |
| π Side-by-Side Comparison | Semantic & line-level document diffing for contract versions | Custom Diff Algorithm, Embeddings |
| π Compliance Classifier | Automated regulatory domain identification (GDPR, HIPAA, IP, etc.) | Multi-label Classification |
| π Report Generation | Professional PDF reports with findings & recommendations | FPDF, Jinja2 Templates |
graph LR
A[PDF Upload] --> B[PyMuPDF Extraction]
B --> C[Recursive Chunking]
C --> D[FAISS Vector Index]
D --> E[LangChain LCEL Pipeline]
E --> F[Groq LLaMA 3.1 8B/70B]
F --> G[Structured Output]
style A fill:#e3f2fd
style D fill:#f3e5f5
style E fill:#e8f5e9
style F fill:#fff3e0
style G fill:#e0f2f1
| Category | Technologies |
|---|---|
| LLM Engine | Groq (LLaMA 3.1 8B/70B) - Sub-second inference |
| Frameworks | LangChain (LCEL), Streamlit |
| Vector Database | FAISS (local, no external dependencies) |
| Embeddings | Sentence-Transformers (all-MiniLM-L6-v2) |
| NLP Utilities | NLTK, PyMuPDF, Scikit-learn |
| Document Processing | FPDF (PDF generation), python-docx |
βββββββββββββββ ββββββββββββββββ βββββββββββββββ ββββββββββββββββ
β Upload βββββΆβ Extraction βββββΆβ Chunking & βββββΆβ FAISS Index β
β (PDF) β β (PyMuPDF) β β Embedding β β (Vector DB) β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ ββββββββ¬ββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββ ββββββββββββββββ βββββββββββββββ ββββββββββββββββ
β Output ββββββ Synthesis ββββββ Retrieval ββββββ Query β
β (Report) β β (LLM Chain) β β + RAG β β (User) β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ ββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LEXAI ANALYSIS PIPELINE β
βββββββββββββββ¬ββββββββββββββ¬ββββββββββββββ¬ββββββββββββββββββββββββ€
β Summarizer β Q&A RAG β Risk Score β Compliance Classifierβ
β (Map-Reduce)β (FAISS+LLM)β (VADER+NLP) β (Multi-label) β
βββββββββββββββ΄ββββββββββββββ΄ββββββββββββββ΄ββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββ
β Comparison Engine β
β (Semantic + Line) β
βββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββ
β Report Generator β
β (PDF/MD) β
βββββββββββββββββββββ
- Python 3.11+
- Groq API Key (free at console.groq.com)
git clone https://github.com/Vansh-Sharmaa/LexAI.git
cd LexAI
pip install -r requirements.txtcp .env.example .envGROQ_API_KEY=your_groq_api_key_here
STREAMLIT_SERVER_PORT=8501Streamlit App:
streamlit run app.pyCLI Analysis:
python main.py --pdf contract.pdf --analyze alldocker build -t lexai .
docker run -p 8501:8501 -e GROQ_API_KEY=your_key lexaiLexAI/
βββ .github/workflows/ci.yml # CI/CD Pipeline
βββ app.py # Streamlit Web App
βββ rag.py # RAG Pipeline (FAISS + LLM)
βββ summarization.py # Map-Reduce Summarization
βββ risk_analysis.py # Risk Scoring (VADER + Keywords)
βββ compliance.py # Compliance Classification
βββ comparison.py # Document Comparison Engine
βββ document_processing.py # PDF Parsing & Chunking
βββ report_generation.py # PDF/Markdown Report Generation
βββ utils.py # Shared Utilities
βββ requirements.txt # Dependencies
βββ .env.example # Environment Template
βββ LexAI_Logo.png # Brand Assets
βββ mermaid-diagram.png # Architecture Diagram
βββ README.md
Input: 50-page acquisition agreement
Output:
β’ 2-page executive summary
β’ 15 risk flags (5 High, 7 Medium, 3 Low)
β’ GDPR/CCPA compliance gaps identified
β’ Side-by-side vs. previous version
Input: Policy documents + regulations
Output:
β’ Compliance scorecard per regulation
β’ Missing clauses checklist
β’ Remediation recommendations
Query: "What are the termination clauses in this contract?"
Output: Grounded answer with exact clause citations
# Unit tests
pytest tests/ -v
# With coverage
pytest --cov=. --cov-report=html| Metric | Value |
|---|---|
| Summarization (10k words) | ~12 seconds |
| RAG Query Latency | ~800ms |
| Risk Analysis | ~3 seconds |
| Comparison (2 docs) | ~5 seconds |
| End-to-End Report | ~25 seconds |
Benchmarks on Groq LLaMA 3.1 70B, 16GB RAM
- No data persistence - Documents processed in-memory only
- Local vector storage - FAISS index never leaves your machine
- API keys via env - No hardcoded secrets
- Groq privacy - No training on your data (per Groq policy)
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'feat: add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
MIT License - see LICENSE for details.
Vansh Sharma - AI/ML Engineer | NLP | GenAI | LLMs
- LangChain - LLM orchestration
- Groq - Ultra-fast LLM inference
- FAISS - Vector similarity search
- Sentence-Transformers - Embeddings
- Streamlit - Web app framework
- NLTK - NLP utilities
β Star this repo if you find it useful! β