CoolFace
Modelpublic

Agreemind/contractnli-legalbert-nda-weighted

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes27downloads
Model Card

contractnli-legalbert-nda-weighted

Legal-BERT fine-tuned on ContractNLI with weighted CE — highest accuracy

Task

Document-level NLI for Non-Disclosure Agreements (NDAs)

Given an NDA contract and a hypothesis about a standard provision, classify as:

  • —Entailment: The provision is present in the contract
  • —Contradiction: The provision is explicitly excluded
  • —NotMentioned: The contract does not address this provision

Performance

MetricScore
Micro-F187.3%
Macro-F179.3%
Parameters110M
LossWeighted Cross-Entropy

Comparison

ModelMicro-F1Macro-F1ParamsNotes
Rule-based baseline20.9%16.0%—Keyword matching
BERT-base (paper)~83%—110MContractNLI paper reference
contractnli-legalbert-nda-weighted87.3%79.3%110Mhighest accuracy ← this model
contractnli-legalbert-nda-standard86.7%77.0%110M
contractnli-bert-nda-standard86.9%76.7%110Mpaper reproduction
contractnli-bert-nda-weighted86.3%77.9%110M
contractnli-distilbert-nda86.0%76.2%66Mfastest inference, recommended for production

17 NDA Provisions Checked

IDProvision
nda-1Explicit identification
nda-2Non-inclusion of non-technical information
nda-3Inclusion of verbally conveyed information
nda-4Limited use
nda-5Sharing with employees
nda-7Sharing with third-parties
nda-8Notice on compelled disclosure
nda-10Confidentiality of Agreement
nda-11No reverse engineering
nda-12Permissible development of similar information
nda-13Permissible acquirement of similar information
nda-15No licensing
nda-16Return of confidential information
nda-17Permissible copy
nda-18No solicitation
nda-19Survival of obligations
nda-20Permissible post-agreement possession

Usage

python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

model_name = "Agreemind/contractnli-legalbert-nda-weighted"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)

hypothesis = "All Confidential Information shall be expressly identified by the Disclosing Party."
premise = "Section 2.1: Any information disclosed must be marked as Confidential..."

inputs = tokenizer(hypothesis, premise, return_tensors="pt", truncation=True, max_length=512)
with torch.no_grad():
    logits = model(**inputs).logits
    probs = torch.softmax(logits, dim=-1)
    pred = ["Entailment", "Contradiction", "NotMentioned"][probs.argmax()]
    print(f"Prediction: {pred} (confidence: {probs.max():.3f})")

Training Details

  • —Dataset: ContractNLI (607 NDAs, 17 hypotheses)
  • —Train/Dev/Test: 423/61/123 documents → 33,974/5,131/9,373 span-level examples
  • —Base model: nlpaueb/legal-bert-base-uncased
  • —Loss: Weighted Cross-Entropy
  • —Learning rate: 3e-5 (aligned with ContractNLI paper)
  • —Epochs: 5 with early stopping (patience=3)
  • —Batch size: 8
  • —Max sequence length: 512

Citation

bibtex
@inproceedings{koreeda-manning-2021-contractnli,
    title = "ContractNLI: A Dataset for Document-level Natural Language Inference for Contracts",
    author = "Koreeda, Yuta and Manning, Christopher",
    booktitle = "Findings of EMNLP 2021",
    year = "2021",
}

License

MIT