⚖️ JustiFi – InLegalBERT Legal Outcome Predictor
Fine-tuned InLegalBERT model for legal outcome prediction on Indian legal documents.
This model predicts whether a legal case is:
The system is designed for long legal documents and uses chunk-based processing to overcome the 512-token limitation of BERT models.
📌 Project Overview
Legal documents are often lengthy and contain complex legal language. Traditional machine learning methods struggle to capture contextual relationships in such texts.
This project fine-tunes InLegalBERT , a legal-domain transformer model, to perform legal outcome prediction using Indian legal datasets.
The workflow includes:
1 Input Legal Document
2 ↓
3 PDF/Text Extraction
4 ↓
5 Tokenization
6 ↓
7 Chunk Generation (512 tokens)
8 ↓
9 InLegalBERT Prediction
10 ↓
11 Chunk Aggregation
12 ↓
13 Final Outcome
14 (REJECT / ACCEPT)
🧠 Model Information
Property Value Base Model InLegalBERT Architecture BertForSequenceClassification Task Binary Classification Classes REJECT / ACCEPT Max Tokens 512 Prediction Method Chunk Aggregation Domain Legal NLP
📊 Model Performance
Evaluation was performed using chunk-based document prediction.
Metric Score Accuracy 0.70 Precision 0.71 Recall 0.71 F1 Score 0.71
⚙️ Features
✅ Legal outcome prediction
✅ Fine-tuned InLegalBERT model
✅ Long document support
✅ Chunk-based inference
✅ PDF processing pipeline
✅ FastAPI deployment support
✅ Confidence scoring
📂 Labels
Model mapping:
1 id2label = {
2 0 : "REJECT" ,
3 1 : "ACCEPT"
4 }
🚀 Usage
Install dependencies:
pip install transformers torch
Load model:
1 from transformers import pipeline
2
3 classifier = pipeline (
4 "text-classification" ,
5 model = "vikas-maurya/justifi-inlegalbert-outcome-predictor"
6 )
7
8 text = """
9 Legal case description text here
10 """
11
12 result = classifier ( text )
13
14 print ( result )
Example output:
1 [
2 {
3 'label' : 'ACCEPT' ,
4 'score' : 0.74
5 }
6 ]
🔬 Training Configuration
Parameter Value Learning Rate 2e-5 Batch Size 4 Gradient Accumulation 4 Optimizer AdamW Loss Function Cross Entropy Mixed Precision FP16 Training Steps ~4500
📈 Evaluation Methods
The project includes:
Accuracy vs Epoch
Precision–Recall Curve
Confusion Matrix
Confidence Distribution
Response Time Analysis
🏗 Deployment
The model was integrated into:
FastAPI backend
PDF upload pipeline
Chunk-based prediction system
Output format:
1 {
2 "prediction" : "ACCEPT" ,
3 "confidence" : 0.64 ,
4 "num_chunks" : 7
5 }
⚠ Limitations
Trained on Indian legal documents only
Limited generalization to other jurisdictions
Long documents require chunk aggregation
Similar case retrieval not included in current version
🔮 Future Improvements
Legal summarization
Explainability module
Similar case retrieval
Legal chatbot
Multilingual support
Outcome reasoning
👨💻 Author
Vikas Maurya
Final Year Computer Engineering Student
Focus Areas:
NLP
Legal AI
Deep Learning
Transformer Models
Generative AI
Project:
JustiFi – AI Powered Legal Intelligence System
📜 Citation
If using this model in academic work:
1 @misc{justifi_inlegalbert,
2 title={JustiFi: InLegalBERT Legal Outcome Predictor},
3 author={Vikas Maurya},
4 year={2026}
5 }