Text Classification
Transformers
Safetensors
English
longformer
legal
document-classification
multi-class-classification
msme
dispute-resolution
indian-legal
Instructions to use abhinavdread/msme-legal-dispute-classifier-longformer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use abhinavdread/msme-legal-dispute-classifier-longformer with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="abhinavdread/msme-legal-dispute-classifier-longformer")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("abhinavdread/msme-legal-dispute-classifier-longformer") model = AutoModelForSequenceClassification.from_pretrained("abhinavdread/msme-legal-dispute-classifier-longformer", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,108 +1,125 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
-
|
| 10 |
-
-
|
| 11 |
-
-
|
| 12 |
-
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
- **
|
| 52 |
-
- **
|
| 53 |
-
- **
|
| 54 |
-
- **
|
| 55 |
-
|
| 56 |
-
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
-
|
| 76 |
-
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
tags:
|
| 5 |
+
- text-classification
|
| 6 |
+
- legal
|
| 7 |
+
- longformer
|
| 8 |
+
- document-classification
|
| 9 |
+
- multi-class-classification
|
| 10 |
+
- msme
|
| 11 |
+
- dispute-resolution
|
| 12 |
+
- indian-legal
|
| 13 |
+
pipeline_tag: text-classification
|
| 14 |
+
library_name: transformers
|
| 15 |
+
model_name: MSME Legal Dispute Classifier (Longformer, 6-Class)
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# MSME Legal Dispute Classifier (Longformer, 6-Class)
|
| 19 |
+
|
| 20 |
+
## Model Overview
|
| 21 |
+
This model is a multi-class legal document classifier designed to categorize MSME-related dispute cases into six statutory dispute categories. It is fine-tuned from `allenai/longformer-base-4096` and optimized for long-form legal documents up to 1200 tokens. The system is intended for automated dispute categorization, legal triage, and decision-support applications in MSME dispute resolution workflows.
|
| 22 |
+
|
| 23 |
+
## Problem Statement
|
| 24 |
+
MSME dispute cases often involve lengthy legal narratives including:
|
| 25 |
+
|
| 26 |
+
- Statement of claim
|
| 27 |
+
- Buyer response
|
| 28 |
+
- Case summary
|
| 29 |
+
- Contractual and payment details
|
| 30 |
+
|
| 31 |
+
Manual classification is time-consuming and error-prone. This model automates dispute categorization into predefined legal classes.
|
| 32 |
+
|
| 33 |
+
## Classification Labels
|
| 34 |
+
The model predicts one of the following six categories:
|
| 35 |
+
|
| 36 |
+
| Label ID | Category |
|
| 37 |
+
|----------|--------------------------------|
|
| 38 |
+
| 0 | Delayed payment (no dispute) |
|
| 39 |
+
| 1 | Quality dispute |
|
| 40 |
+
| 2 | No formal contract |
|
| 41 |
+
| 3 | Partial payment dispute |
|
| 42 |
+
| 4 | Government procurement delay |
|
| 43 |
+
| 5 | Service-related dispute |
|
| 44 |
+
|
| 45 |
+
Label mapping is included in `label_mapping.json`.
|
| 46 |
+
|
| 47 |
+
## Model Architecture
|
| 48 |
+
- **Base Model**: Longformer
|
| 49 |
+
- **Checkpoint**: `allenai/longformer-base-4096`
|
| 50 |
+
- **Max Sequence Length**: 1200 tokens
|
| 51 |
+
- **Hidden Size**: 768
|
| 52 |
+
- **Number of Layers**: 12
|
| 53 |
+
- **Attention Type**: Local attention (CLS token classification)
|
| 54 |
+
- **Classification Head**: Linear layer (6 outputs)
|
| 55 |
+
|
| 56 |
+
Longformer was selected due to the long-document nature of legal dispute texts.
|
| 57 |
+
|
| 58 |
+
## Dataset Information
|
| 59 |
+
- Final Dataset Size (after cleaning): 2152 samples
|
| 60 |
+
- Duplicates removed
|
| 61 |
+
- Label conflicts resolved
|
| 62 |
+
- Stratified 80–20 train/test split
|
| 63 |
+
- 5-fold stratified cross-validation
|
| 64 |
+
|
| 65 |
+
Class imbalance handled using weighted cross-entropy loss.
|
| 66 |
+
|
| 67 |
+
## Training Configuration
|
| 68 |
+
- Optimizer: AdamW
|
| 69 |
+
- Learning Rate: 2e-5
|
| 70 |
+
- Batch Size: 2
|
| 71 |
+
- Gradient Accumulation Steps: 4
|
| 72 |
+
- Effective Batch Size: 8
|
| 73 |
+
- Epochs: 3
|
| 74 |
+
- Warmup Steps: 200
|
| 75 |
+
- Mixed Precision (FP16): Enabled
|
| 76 |
+
- Loss Function: Weighted Cross Entropy
|
| 77 |
+
|
| 78 |
+
## Evaluation Results (Held-Out Test Set)
|
| 79 |
+
|
| 80 |
+
Test Set Size: 431 samples
|
| 81 |
+
|
| 82 |
+
| Metric | Score |
|
| 83 |
+
|-------------------------|-------|
|
| 84 |
+
| Accuracy | 0.77 |
|
| 85 |
+
| Macro Precision | 0.76 |
|
| 86 |
+
| Macro Recall | 0.74 |
|
| 87 |
+
| Macro F1 Score | 0.75 |
|
| 88 |
+
| Macro AUC-ROC (OvR) | 0.948 |
|
| 89 |
+
|
| 90 |
+
These results indicate strong class separability and balanced performance across all categories.
|
| 91 |
+
|
| 92 |
+
## Intended Use
|
| 93 |
+
This model is suitable for:
|
| 94 |
+
|
| 95 |
+
- Automated legal dispute classification
|
| 96 |
+
- MSME case triage systems
|
| 97 |
+
- Online Dispute Resolution (ODR) platforms
|
| 98 |
+
- Legal analytics systems
|
| 99 |
+
- Case routing and prioritization tools
|
| 100 |
+
|
| 101 |
+
## Limitations
|
| 102 |
+
- Performance may degrade for documents significantly exceeding 1200 tokens.
|
| 103 |
+
- Domain-specific to MSME dispute scenarios.
|
| 104 |
+
- Not designed for general legal classification tasks.
|
| 105 |
+
- Should not be used as a substitute for legal judgment.
|
| 106 |
+
|
| 107 |
+
## Ethical Considerations
|
| 108 |
+
This model is intended as a decision-support tool. Human oversight is recommended for legal decision-making applications. It does not provide legal advice.
|
| 109 |
+
|
| 110 |
+
## Usage Example
|
| 111 |
+
|
| 112 |
+
```python
|
| 113 |
+
from transformers import LongformerForSequenceClassification, AutoTokenizer
|
| 114 |
+
import torch
|
| 115 |
+
|
| 116 |
+
model = LongformerForSequenceClassification.from_pretrained("YOUR_USERNAME/msme-legal-dispute-classifier-longformer")
|
| 117 |
+
tokenizer = AutoTokenizer.from_pretrained("YOUR_USERNAME/msme-legal-dispute-classifier-longformer")
|
| 118 |
+
|
| 119 |
+
text = "The buyer failed to release payment within the agreed 45-day period."
|
| 120 |
+
|
| 121 |
+
inputs = tokenizer(text, truncation=True, max_length=1200, return_tensors="pt")
|
| 122 |
+
outputs = model(**inputs)
|
| 123 |
+
|
| 124 |
+
predicted_class = torch.argmax(outputs.logits, dim=1)
|
| 125 |
+
print("Predicted Label:", predicted_class.item())
|