- Gen AI Hackathon 2025
- Team: Binary Force
1. Overview
The Contract Analysis & Risk Assessment Platform is an AI-driven system designed to help users understand, evaluate, and manage legal contracts efficiently.
The platform automatically analyzes contracts uploaded in PDF, DOCX, orXT formats, explains complex legal clauses in plain language, assesses legal and business risks, and provides actionable negotiation insights.
A key differentiator of this project is its dual-model architecture, which supports both:
- Cloud-based analysis using OpenAI’s GPT models
- Offline, privacy-preserving analysis using a fine-tuned LLaMA-3 model
This ensures flexibility across environments with different privacy, cost, and connectivity requirements.
2. Problem Statement
Legal contracts are often:
- Lengthy and complex
- Written in dense legal language
- Difficult for non-legal professionals to interpret
- Time-consuming and expensive to review manually
Organizations, startups, freelancers, and individuals frequently need to:
- Identify risky clauses quickly
- Understand obligations and liabilities
- Decide what needs negotiation
- Ensure contracts are reasonably complete
This platform addresses these challenges by combining Natural Language Processing (NLP), Large Language Models (LLMs), and rule-based legal heuristics.
3. Solution Architecture
The system follows a modular, explainable pipeline:
User Upload
↓
Text Extraction (PDF / DOCX / TXT)
↓
Preprocessing & Clause Segmentation
↓
Dual Model Inference
├── GPT-based Analyzer (Online)
└── Fine-tuned LLaMA-3 Analyzer (Offline)
↓
Risk Scoring (LLM + Rules)
↓
Summary, Dashboard & Reports
This separation ensures:
• Model independence
• Easy extensibility
• Clear auditability of decisions4. Dual Model Strategy
4.1 GPT-Based Model (Online Mode)
Purpose: To provide high-accuracy, multilingual, reasoning-intensive analysis using state-of-the-art cloud LLMs.
Models Supported:
- GPT-4o
- GPT-4o-mini
Key Capabilities:
- Deep clause interpretation
- Plain-English explanations
- Risk classification (Low / Medium / High)
- Affected-party identification
- Negotiation recommendations
- English and Hindi output
- Contract-level summaries
Use Cases:
- Complex commercial contracts
- Multilingual requirements
- Rapid prototyping
- Demonstrations and hackathons
Trade-offs:
- Requires internet access
- Token-based usage cost
- External API dependency
4.2 Fine-Tuned LLaMA-3 Model (Offline Mode)
Purpose: To enable fully offline contract analysis for environments with strict privacy, security, or connectivity constraints.
Model Details:
- Based on LLaMA-3
- Fine-tuned on:
- Legal clauses
- Contract obligations
- Risk patterns
- Business liabilities
Key Capabilities:
- Clause-level risk detection
- Plain-language explanations
- Domain-specific reasoning
- Deterministic, repeatable outputs
- No external data transmission
Use Cases:
- Enterprises with data confidentiality requirements
- Government or legal institutions
- Air-gapped or secure systems
- Cost-sensitive deployments
Trade-offs:
- Slightly lower reasoning depth compared to GPT-4o
- Limited multilingual support (extensible)
5. Core Features
5.1 Contract Ingestion
- Supports PDF, DOCX, and TXT formats
- Robust text extraction
- Handles long and multi-section documents
5.2 Clause Segmentation
- Intelligent clause detection
- Preserves clause numbering
- Filters out meaningless fragments
- Ensures clean input for AI models
5.3 Clause-Level Analysis
For each clause:
- Plain-language explanation
- Risk level classification
- Identification of affected party
- Reasoning behind the risk
- Suggested safer alternatives (when applicable)
5.4 Contract-Level Insights
- Overall contract risk
- Completeness score
- Detection of ambiguous or conflicting clauses
- Identification of key business risks
- Negotiation recommendations
5.5 Multilingual Support
- English
- Hindi
- Side-by-side bilingual display (GPT mode)
5.6 Reporting & Export
- JSON export for programmatic use
- Professionally formatted PDF report
- Clause-by-clause breakdown in reports
5.7 Privacy & Security
- No contract storage
- No logging of uploaded documents
- Offline mode ensures zero data leakage
6. Technology Stack
Layer Technology
Frontend Streamlit
AI Models GPT-4o / GPT-4o-mini, LLaMA-3
NLP spaCy
Backend Python 3.11
Document Parsing pdfplumber, python-docx
Reporting ReportLab
Architecture Modular, model-agnostic7. Project Structure
Contract-bot/
│
├── app.py --> Streamlit user interface
├── assets/ --> UI assets (logos, images)
│
├── analyzer/
│ ├── extractor.py --> Text extraction logic
│ ├── preprocessor.py --> Cleaning & clause segmentation
│ ├── llm_model.py --> GPT-based analysis engine
│ ├── llama_model.py --> Offline LLaMA-3 inference
│ ├── risk_rules.py --> Rule-based risk scoring
│ └── report.py --> Data models & schemas
│
├── models/
│ └── llama3_finetuned/ --> Fine-tuned offline model
│
├── requirements.txt
└── README.md8. Installation & Setup
Environment Setup
python3.11 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python -m spacy download en_core_web_sm9. Running the Application
GPT-Based Mode (Online)
export OPENAI_API_KEY="your_api_key"
streamlit run app.pySelect GPT model from the sidebar.
Offline LLaMA-3 Mode 1. Place the fine-tuned model in:
models/llama3_finetuned/
2. Select Offline Mode in the application
3. Run:
streamlit run app.pyNo internet or API key required.
10. Use Cases
- Contract review for startups and SMBs
- Freelancers reviewing client agreements
- Vendor and service agreements
- Employment contracts
- NDA and partnership agreements
- Secure enterprise contract analysis
11. Limitations & Disclaimer
This tool provides AI-assisted legal insights for informational purposes only. It does not replace qualified legal advice.
Users should consult a licensed legal professional before making final decisions.
12. Hackathon Information
Event: Gen AI Hackathon 2025 Organizers: GUVI × HCL Team: Binary Force
13. Future Scope
- OCR support for scanned contracts
- Clause category tagging (IP, Termination, Liability, etc.)
- Jurisdiction-specific compliance checks
- Numeric risk scoring
- Redlined clause rewriting
- Additional Indian language support
- Mobile and edge-device deployment