policyfx-nli
Fine-tuned version of
tasksource/ModernBERT-base-nli for natural language inference on Congressional Research Service (CRS) policy reports.
Intended Use
Classifies whether a policy passage entails, contradicts, or is neutral with respect to a stakeholder impact statement.
Input Format
1premise = "The program provides monthly cash payments of $500 to eligible low-income families."
2hypothesis = "low-income families: Low-income families receive monthly cash payments of $500 through the program."
The hypothesis follows the format {stakeholder}: {effect statement}. Both premise and hypothesis are truncated to 2048 tokens.
Usage
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3from scipy.special import softmax
4
5model_id = "JoshuaAshkinaze/policyfx-nli"
6tokenizer = AutoTokenizer.from_pretrained(model_id)
7model = AutoModelForSequenceClassification.from_pretrained(model_id)
8model.eval()
9
10LABEL_NAMES = ["contradiction", "entailment", "neutral"]
11
12premise = "The bill will raise taxes."
13hypothesis = "Taxpayers: Individual taxpayers will have less disposable income."
14
15inputs = tokenizer(premise, hypothesis, return_tensors="pt",
16 truncation=True, max_length=2048)
17with torch.no_grad():
18 logits = model(**inputs).logits.numpy()
19
20probs = softmax(logits, axis=-1)[0]
21pred = {label: round(float(p), 4) for label, p in zip(LABEL_NAMES, probs)}
22print(pred)
Note on label order: config.id2label is set to {0: "contradiction", 1: "entailment", 2: "neutral"}. Do not remap from the base model's label config.
Training
Data: ~61,600 (premise, stakeholder-effect hypothesis, label) triples generated from ~3,000 CRS reports, covering topics from housing and healthcare to defense and immigration. Train/val/test split is report-level to prevent leakage.
Hard example filtering: The base NLI model scored all examples; only those with P(true_label) < 0.80 were retained (~30,000 examples). This removes trivially easy examples and focuses training on genuine domain difficulty.
Spurious correlation check: A TF-IDF classifier trained on hypotheses alone achieves macro-F1 = 0.34 (≈ chance), confirming that labels are not recoverable from surface form.
Hyperparameters (best config, retrained on train+val):
| Parameter | Value |
|---|
| Base model | tasksource/ModernBERT-base-nli |
| Learning rate | 2e-5 |
| Epochs | 1 |
| Batch size | 16 |
| Max length | 2048 |
| Optimizer | AdamW (fused) |
| Precision | bfloat16 + tf32 |
| Parameters | 149,607,171 |
Evaluation
Evaluated on a held-out test set of 2,874 balanced examples (958 per class).
| Metric | Score |
|---|
| Macro-F1 | 0.9652 |
| ROC-AUC (OvR) | 0.9964 |
| Brier Score | 0.0549 |
| ECE | 0.0163 |
Per-class F1:
| Label | Precision | Recall | F1 |
|---|
| Contradiction | 0.946 | 0.953 | 0.950 |
| Entailment | 0.954 | 0.944 | 0.949 |
| Neutral | 0.996 | 0.999 | 0.997 |
Limitations
- Domain specificity: Fine-tuned on CRS policy text with a specific hypothesis format (
{stakeholder}: {effect}). Performance on general NLI benchmarks (SNLI, MNLI, ANLI) is lower than the zero-shot base model — this is an expected cost of domain adaptation.
- Hypothesis format: The stakeholder-prefixed hypothesis format. Take note. Inputs that deviate significantly from this format may produce unreliable probabilities.
- English only.
Citation
1@misc{ashkinaze2026crs,
2 author = {Ashkinaze, Joshua},
3 title = {ModernBERT-NLI fine-tuned on Congressional Research Service policy reports},
4 year = {2026},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/jashkina/modernbert-nli-crs}
7}