โš–๏ธ 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:

  • REJECT (0)
  • ACCEPT (1)

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:

Input Legal Document
          โ†“
PDF/Text Extraction
          โ†“
Tokenization
          โ†“
Chunk Generation (512 tokens)
          โ†“
InLegalBERT Prediction
          โ†“
Chunk Aggregation
          โ†“
Final Outcome
(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

0 โ†’ REJECT
1 โ†’ ACCEPT

Model mapping:

id2label = {
    0: "REJECT",
    1: "ACCEPT"
}

๐Ÿš€ Usage

Install dependencies:

pip install transformers torch

Load model:

from transformers import pipeline

classifier = pipeline(
    "text-classification",
    model="vikas-maurya/justifi-inlegalbert-outcome-predictor"
)

text = """
Legal case description text here
"""

result = classifier(text)

print(result)

Example output:

[
 {
   'label':'ACCEPT',
   'score':0.74
 }
]

๐Ÿ”ฌ 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:

{
    "prediction":"ACCEPT",
    "confidence":0.64,
    "num_chunks":7
}

โš  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:

@misc{justifi_inlegalbert,
title={JustiFi: InLegalBERT Legal Outcome Predictor},
author={Vikas Maurya},
year={2026}
}

Downloads last month
41
Safetensors
Model size
0.1B params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for vikas-maurya/justifi-inlegalbert-outcome-predictor

Finetuned
(18)
this model

Space using vikas-maurya/justifi-inlegalbert-outcome-predictor 1