ALETHEX NLI — DeBERTa-v3-Small (Lightweight)
Fast, lightweight contradiction detection — 172MB ONNX, runs in any browser
92.8% accuracy · 92.8% Macro F1 · MCC 0.892 · 22M parameters
Overview
This is a fine-tuned version of cross-encoder/nli-deberta-v3-small (22M parameters) for Natural Language Inference (NLI) optimized to detect contradictions between statements made across a conversation.
It is the lightweight variant of the ALETHEX NLI model family. At only 172MB quantized, it loads significantly faster than the large model while achieving the same 92.8% accuracy — ideal for mobile browsers, low-bandwidth connections, or scenarios where first-load time matters.
Model Details
| Property |
Value |
| Base model |
cross-encoder/nli-deberta-v3-small |
| Architecture |
DeBERTa-v2 (small) |
| Parameters |
~22M |
| Hidden size |
384 |
| Task |
3-way NLI (contradiction / entailment / neutral) |
| Training hardware |
NVIDIA RTX 4050 Laptop GPU (6.4GB VRAM) |
| Precision |
FP16 |
| Training time |
~8 hours |
| Epochs |
3 |
| Batch size |
32 |
| Optimizer |
AdamW (8-bit, bitsandbytes) |
| Learning rate |
1e-5 with linear warmup (10%) |
| Weight decay |
0.01 |
Performance
Overall Metrics
| Metric |
Score |
| Accuracy |
92.80% |
| Macro F1 |
92.81% |
| MCC |
0.892 |
| Eval Loss |
0.2516 |
Training Progression
| Epoch |
Accuracy |
Macro F1 |
MCC |
| 1 |
91.94% |
91.94% |
0.879 |
| 2 |
92.51% |
92.52% |
0.887 |
| 3 |
92.80% |
92.81% |
0.892 |
Labels
| ID |
Label |
Description |
0 |
contradiction |
The hypothesis contradicts the premise |
1 |
entailment |
The hypothesis follows from the premise |
2 |
neutral |
The hypothesis is unrelated to the premise |
Training Data
| Dataset |
Pairs |
Description |
| MultiNLI |
~393K |
Cross-genre NLI |
| SNLI |
~549K |
Caption-based NLI |
| Temporal NLI |
~variable |
Temporal contradictions |
| Total |
~1M+ |
Unified, no synthetic data |
Files
| File |
Size |
Description |
model_quantized.onnx |
~172 MB |
INT8 quantized ONNX — recommended |
model.onnx |
~568 MB |
Full FP32 ONNX |
tokenizer.json |
<1 MB |
Fast tokenizer |
config.json |
<1 KB |
Model config |
Usage
Transformers.js — In-Browser
import { pipeline } from "@xenova/transformers";
const clf = await pipeline(
"zero-shot-classification",
"codewithyug/alethex-nli-deberta-v3-small",
{ quantized: true }
);
const result = await clf(
"I live in New York.",
["contradiction", "same meaning", "unrelated"]
);
console.log(result.labels[0]);
console.log(result.scores[0]);
Python — HuggingFace Transformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_id = "codewithyug/alethex-nli-deberta-v3-small"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)
model.eval()
def check_contradiction(premise: str, hypothesis: str) -> dict:
inputs = tokenizer(premise, hypothesis, return_tensors="pt",
truncation=True, max_length=512)
with torch.no_grad():
logits = model(**inputs).logits
probs = torch.softmax(logits, dim=-1)[0]
return {model.config.id2label[i]: round(probs[i].item(), 4) for i in range(3)}
print(check_contradiction("I live in New York.", "I moved to London last year."))
Python — Pipeline API
from transformers import pipeline
clf = pipeline("text-classification", model="codewithyug/alethex-nli-deberta-v3-small")
result = clf([{"text": "I live in New York.", "text_pair": "I moved to London."}])
print(result)
Python — ONNX Runtime
import onnxruntime as ort
from transformers import AutoTokenizer
import numpy as np
tokenizer = AutoTokenizer.from_pretrained("codewithyug/alethex-nli-deberta-v3-small")
session = ort.InferenceSession("model_quantized.onnx")
def infer(premise, hypothesis):
enc = tokenizer(premise, hypothesis, return_tensors="np",
padding="max_length", max_length=128, truncation=True)
logits = session.run(["logits"], dict(enc))[0]
probs = np.exp(logits) / np.exp(logits).sum(axis=-1, keepdims=True)
return {"contradiction": float(probs[0][0]), "entailment": float(probs[0][1]), "neutral": float(probs[0][2])}
Small vs Large — Which Should I Use?
|
Small (this model) |
Large |
| Parameters |
22M |
400M |
| ONNX size |
172MB |
641MB |
| First load |
~1 min |
~3-5 min |
| Accuracy |
92.8% |
92.8% |
| Best for |
Mobile, low-bandwidth, fast startup |
Desktop, subtle contradictions |
Example Detections
| Earlier statement |
Later statement |
Label |
Confidence |
| "I live in New York." |
"I moved to London last year." |
contradiction |
0.95 |
| "I'm vegetarian." |
"I had steak for dinner." |
contradiction |
0.92 |
| "I work at Google." |
"My job at Microsoft keeps me busy." |
contradiction |
0.89 |
| "I'm 25 years old." |
"I turn 30 next week." |
contradiction |
0.86 |
Limitations
- English only
- Max 128 tokens per input pair (truncated)
- Not a fact-checker — detects logical contradiction between spans only
- Figurative language / sarcasm may produce false positives
Citation
@misc{alethex2026,
title = {ALETHEX NLI: Fine-tuned DeBERTa-v3-Small for Temporal Belief Contradiction Detection},
author = {codewithyug},
year = {2026},
url = {https://huggingface.co/codewithyug/alethex-nli-deberta-v3-small}
}
License
Apache 2.0 — free for commercial and research use.