Run this model with HF Jobs
Run Moinaknaskar/indian-contract-clause-classifier on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/Moinaknaskar/indian-contract-clause-classifier. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Moinaknaskar/indian-contract-clause-classifier on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use Moinaknaskar/indian-contract-clause-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Moinaknaskar/indian-contract-clause-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Moinaknaskar/indian-contract-clause-classifier")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("Moinaknaskar/indian-contract-clause-classifier") model = AutoModelForSequenceClassification.from_pretrained("Moinaknaskar/indian-contract-clause-classifier", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Indian contract clause classifier (InLegalBERT)
Given one clause from a contract, this model says which of 14 clause types it is: governing_law, dispute_resolution, indemnity, limitation_of_liability, force_majeure, confidentiality, termination, assignment, intellectual_property, payment_and_taxes, notices, representations_warranties, insurance, boilerplate.
It is InLegalBERT (BERT-base pre-trained on Indian court judgments), fine-tuned on US contract provisions from LEDGAR plus clauses taken from public Indian government model contracts. It is tested on Indian contracts of types it never saw in training.
On the held-out Indian contracts it reaches macro-F1 0.782 and accuracy 0.841. A TF-IDF + logistic regression baseline trained on the same data does about as well (see Results), so this model is not a clear improvement over a simple keyword model on this test set.
All training data is public. No private, client or customer contracts were used at any stage.
Code and full evaluation: github.com/MoinakNaskar/indian-contract-clause-classifier
Labels and source links for the Indian clauses: Moinaknaskar/indian-contract-clauses (metadata only; the clause text is rebuilt from the publishers' PDFs).
Why this exists
Most contract-clause datasets (CUAD, LEDGAR) are US filings with the SEC. Indian contracts read differently: arbitration under the Arbitration and Conciliation Act, 1996, courts at a named Indian city, stamp duty, GST, "Political" and "Non-Political" force majeure events, and long government concession templates. This project asks a simple question with an honest test: how well does a clause classifier trained mostly on US contracts transfer to Indian ones, and how much does a small amount of Indian data and Indian legal pre-training help?
Key findings
- Models trained on US contracts transfer poorly to Indian ones. Trained on LEDGAR only, InLegalBERT scores macro-F1 0.972 on US test clauses but 0.676 on Indian test clauses (TF-IDF: 0.962 vs 0.641). Part of this gap is built in:
force_majeureandlimitation_of_liabilitydo not exist in LEDGAR, so a US-only model cannot get them right. - A few hundred Indian clauses close much of the gap. Adding 515 Indian training clauses raises Indian macro-F1 by 0.107 for InLegalBERT and 0.169 for TF-IDF, and accuracy by 0.138 and 0.164. InLegalBERT's calibration error on Indian clauses falls from 0.201 to 0.111, and US performance does not suffer (LEDGAR macro-F1 0.972 โ 0.969).
- Fine-tuned InLegalBERT does not beat the TF-IDF baseline on Indian clauses. With the same training data it scores macro-F1 0.782 (0.685โ0.831) against 0.810 (0.695โ0.853) for TF-IDF + logistic regression; the intervals overlap heavily. Indian government contracts reuse template wording, so word overlap is a strong signal, and with 195 test clauses (several types have fewer than 10) the test cannot separate the two. Whether Indian legal pre-training helps compared with bert-base or LEGAL-BERT was not tested.
- Weak spots.
limitation_of_liabilitygets F1 0.000 (3 test clauses, no LEDGAR examples) andnoticeshas precision 0.400. The most common mistake is an Event of Default clause predicted as force majeure (6 cases): these clauses open with "unless any such event occurs as a result of a Force Majeure Event", and they come from re-issued PPA templates whose variants differ enough to pass the near-duplicate filter, so one template mistake is counted several times. - Some errors are label errors. Indian labels come from clause headings. Two manual checks of 50 clauses each, made after tightening the heading rules, put label noise at about 5% (a check before the fixes found about 16%). Reading 20 of the 31 test errors by hand: 10 were model errors, 6 were label errors (for example billing reconciliation labelled as dispute resolution because of a "Disputed Bill" heading), 2 had text from a neighbouring clause spilled in by PDF extraction, and 2 were genuinely ambiguous.
- Calibration does not transfer either. The temperature fitted on US validation data (T = 1.17) moves InLegalBERT's Indian calibration error only from 0.124 to 0.111, so its probabilities on Indian clauses are still somewhat over-confident.
Results
The Indian test set is built from contract families that are completely absent from training: power purchase agreements, a hospital O&M agreement, a highway consultancy agreement, a solid-waste concession and a water-supply concession. Test clauses that were near-duplicates of any training clause (TF-IDF cosine โฅ 0.85) were removed (66 removed), and so were near-duplicates inside the test set, because several test documents are re-issues of one template (62 removed). 95% confidence intervals are from 1,000 bootstrap resamples of the test set.
| Model | Training data | Indian test macro-F1 (95% CI) | Indian test accuracy | LEDGAR test macro-F1 | ECE on Indian test |
|---|---|---|---|---|---|
| TF-IDF + logistic regression | ledgar_only | 0.641 (0.529โ0.688) | 0.713 | 0.962 | 0.128 |
| TF-IDF + logistic regression | ledgar+india | 0.810 (0.695โ0.853) | 0.877 | 0.961 | 0.099 |
| law-ai/InLegalBERT | ledgar_only | 0.676 (0.569โ0.716) | 0.703 | 0.972 | 0.201 |
| law-ai/InLegalBERT | ledgar+india | 0.782 (0.685โ0.831) | 0.841 | 0.969 | 0.111 |
ECE is expected calibration error after temperature scaling (T = 1.168 for the final model), fitted on LEDGAR validation data only so the Indian test set is never touched. Macro-F1 averages over the clause types present in the Indian test set; intellectual_property has no Indian test clauses, so it is not measured there.
Final model, per clause type (Indian test set)
| Clause type | Precision | Recall | F1 | Test clauses |
|---|---|---|---|---|
| governing_law | 0.800 | 1.000 | 0.889 | 4 |
| dispute_resolution | 0.800 | 0.615 | 0.696 | 13 |
| indemnity | 0.875 | 0.700 | 0.778 | 10 |
| limitation_of_liability | 0.000 | 0.000 | 0.000 | 3 |
| force_majeure | 0.759 | 1.000 | 0.863 | 22 |
| confidentiality | 0.667 | 1.000 | 0.800 | 2 |
| termination | 0.865 | 0.744 | 0.800 | 43 |
| assignment | 0.818 | 1.000 | 0.900 | 9 |
| payment_and_taxes | 0.897 | 0.852 | 0.874 | 61 |
| notices | 0.400 | 1.000 | 0.571 | 4 |
| representations_warranties | 1.000 | 1.000 | 1.000 | 5 |
| insurance | 1.000 | 1.000 | 1.000 | 13 |
| boilerplate | 1.000 | 1.000 | 1.000 | 6 |
Where it goes wrong
terminationpredicted asforce_majeure: 6 clausespayment_and_taxespredicted astermination: 5 clausesterminationpredicted asnotices: 4 clausesdispute_resolutionpredicted aspayment_and_taxes: 3 clausesindemnitypredicted asnotices: 2 clauseslimitation_of_liabilitypredicted aspayment_and_taxes: 2 clauses
Data
| Part | Source | Size |
|---|---|---|
| US provisions | LEDGAR via LexGLUE (CC BY 4.0), 31 of its 100 labels mapped onto ours, capped at 800 per label | 9273 clauses |
| Indian train | NITI Aayog, Ministry of Shipping and Ministry of Road Transport & Highways model concession / EPC agreements | 515 clauses |
| Indian test | SECI standard PPAs, Goa and Maharashtra KUSUM-A PPAs, an Odisha health department O&M agreement, the SBM-Urban solid-waste concession, the Shimla water-supply concession and an NHIDCL consultancy agreement | 195 clauses |
Indian clauses are labelled automatically from their own headings (for example 29.1 Force Majeure), falling back to the Article title (for example sub-clauses under ARTICLE 39 DISPUTE RESOLUTION). The heading and clause number are then removed from the text, so the model has to read the clause itself. Heading-based labels are noisy, so treat the Indian numbers as an estimate rather than a gold-standard benchmark.
force_majeure and limitation_of_liability do not exist in LEDGAR, so the model learns them from Indian data only. The ledgar_only rows show what happens without it.
Two planned test documents were dropped because they could not be downloaded: the Ministry of Power medium-term model PPA (its link now returns 404) and the World Bank-hosted India solar PPA (the site refuses scripted downloads).
Source documents (clause counts are before deduplication):
| Document | Split | Clauses |
|---|---|---|
| niti_epc_civil_works | train | 69 |
| niti_ebus_om_2020 | train | 82 |
| niti_ebus_mca_2023 | train | 82 |
| niti_ropeway_mca | train | 80 |
| niti_dbfot | train | 13 |
| niti_medical_college_mca | train | 83 |
| shipping_mca_2021 | train | 52 |
| morth_ham_mca_2020 | train | 59 |
| morth_bot_toll_mca | train | 79 |
| mmlp_mca | train | 96 |
| seci_ppa_solar_ists_xi | test | 40 |
| seci_ppa_rtc_v | test | 39 |
| seci_ppa_fdre_viii | test | 39 |
| seci_ppa_hpd_t8 | test | 39 |
| goa_kusum_a_ppa | test | 26 |
| msedcl_kusum_a_ppa | test | 34 |
| odisha_health_om | test | 38 |
| sbm_solid_waste_mca | test | 56 |
| shimla_water_ca | test | 58 |
| nhidcl_dca | test | 56 |
Use
from transformers import pipeline
clf = pipeline("text-classification", model="Moinaknaskar/indian-contract-clause-classifier", top_k=3)
clf("Any Dispute which is not resolved amicably by conciliation shall be finally decided by "
"reference to arbitration by a Board of Arbitrators appointed under the Rules of Arbitration "
"of the Indian Council of Arbitration.")
Calibrated probabilities
pipeline returns a plain softmax over the logits, which is not calibrated. The calibration temperature is stored in the config as calibration_temperature; divide the logits by it before the softmax:
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
path = "Moinaknaskar/indian-contract-clause-classifier"
tok = AutoTokenizer.from_pretrained(path); model = AutoModelForSequenceClassification.from_pretrained(path)
probs = torch.softmax(model(**tok(text, return_tensors="pt", truncation=True)).logits / model.config.calibration_temperature, -1)
The temperature was fitted on US (LEDGAR) data and only partly fixes calibration on Indian clauses (see Key findings).
Limits
- 14 types only, and there is no "other" class. Every input gets one of the 14 labels, so filter by confidence (the probabilities are calibrated) or segment documents first.
- Indian training data comes from government infrastructure templates. Private commercial contracts (SaaS, employment, NDAs) may look different, and performance there is not measured.
- Labels on Indian data come from headings, not from a lawyer. Manual checks of 100 clauses put label noise at about 5%, and 6 of 20 test errors read by hand were label errors.
limitation_of_liabilityandintellectual_propertyhave very few Indian examples; do not rely on the model for them.- One training run with one seed; the confidence intervals cover test-set sampling only, not training variance.
- Input is truncated to 256 tokens.
- Not legal advice. A clause type is not a judgement about whether a clause is fair, enforceable or risky.
Training
AdamW, learning rate 3e-5, batch 16, 2 epochs, linear warm-up 6%, max length 256, Indian training clauses repeated 3x to balance against LEDGAR, seed 13. Each run took about 45 minutes on an Apple M2 laptop (PyTorch MPS). Code, data-building scripts and evaluation: https://github.com/MoinakNaskar/indian-contract-clause-classifier
Citation
Base model: Paul, Mandal, Goyal, Ghosh. Pre-trained Language Models for the Legal Domain: A Case Study on Indian Law. ICAIL 2023. LEDGAR: Tuggener et al., LREC 2020. LexGLUE: Chalkidis et al., ACL 2022.
- Downloads last month
- 30
Model tree for Moinaknaskar/indian-contract-clause-classifier
Base model
law-ai/InLegalBERT