Downloads · 30 days
12
33% of all-time downloads
hamdallah/budgeted-exit-modernbert-base-civil-comments
budgeted-exit-modernbert-base-civil-comments is a text classification model from hamdallah. Use it when you need a label for a piece of text. The card lists the license as apache-2.0.
Stop computing when the decision is settled. This is a full fine-tune of the 150M-parameter encoder ModernBERT-base with a trained classification head at seven exit layers and a frozen, risk-calibrated exit policy. It…
Downloads · 30 days
12
33% of all-time downloads
All-time downloads
36
Public
Parameters
153M
613 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors613 MB · 100%
From the Hugging Face model README
Stop computing when the decision is settled. This is a full fine-tune of the 150M-parameter encoder ModernBERT-base with a trained classification head at seven exit layers and a frozen, risk-calibrated exit policy. It answers four moderation questions about a comment (threat, identity attack, insult, obscene language), composes them with a rule, and leaves the network early when the rule's outcome can no longer change within an explicit error budget.
On a locked, pre-registered test it keeps decision quality within 0.35 points of the full model while running 5.88 of 22 layers on average, and a runtime that really stops is 2.64x faster in measured throughput.
Research release. Trained and evaluated on one dataset (Civil Comments) and one seed. Read the limitations before using it.
Rule: threat or identity_attack or (insult and obscene) (about 1.2% positive). Official Civil Comments test split, 96,862 comments,
read once after the policy, weights, code and test file were hashed. Pass rule fixed in advance: the 95% interval of the change in
balanced accuracy must exclude a 1-point loss.
| System | Balanced accuracy | Change vs full depth [95% CI] | Mean depth | Throughput (A100, 16k dev texts) |
|---|---|---|---|---|
| Full depth | 93.66% | - | 22 | 2,764 texts/s |
| Static truncation at layer 16 | 93.86% | +0.20 [-0.18, +0.60] | 16 | 3,674 texts/s (1.33x) |
| Frozen exit policy (this release) | 93.31% | -0.35 [-0.65, -0.06] | 5.88 | 7,294 texts/s (2.64x) |
Balanced accuracy of each exit on the validation split, if every comment stopped there:
| Exit layer | 4 | 7 | 10 | 13 | 16 | 19 | 22 |
|---|---|---|---|---|---|---|---|
| Balanced accuracy | 91.45% | 92.32% | 92.27% | 92.79% | 93.35% | 93.38% | 93.48% |
The policy changed 1.65% of the full model's positive decisions (budget 2%) and 0.90% of its negative decisions (budget 1%). The loss of 0.35 points is small but statistically detectable; it comes from a higher false-positive rate (7.0% to 7.7%) at unchanged recall.
frozen_policy.json as plain numbers.model.safetensors: the full fine-tuned encoder and the seven exit heads, 153.2M parameters.config.json: base model, exit layers, questionsfrozen_policy.json: the exact policy evaluated on the locked test (Platt parameters, isotonic maps, dials, cut-offs)The loading and runtime code lives in the project repository: github.com/hamdallah90/decision-aware-inference (folder budgeted_exit/).
git clone https://github.com/hamdallah90/decision-aware-inference.git && cd decision-aware-inference
pip install -r requirements.txt && cd budgeted_exit
from huggingface_hub import snapshot_download
from hub import load # budgeted_exit/hub.py
from runtime_exits import Runtime # budgeted_exit/runtime_exits.py
folder = snapshot_download("hamdallah/budgeted-exit-modernbert-base-civil-comments")
model, encode, _ = load(folder) # logits = model(ids, mask) -> [batch, exits, 4 questions]
runtime = Runtime(tag=None, folder=folder)
decisions, exit_layers = runtime.dynamic(encode(["your comment here"]))
Full fine-tuning, mean-pooled readout, on 55,271 Civil Comments training rows (an enriched sample with extra rare positives), binary cross-entropy summed over all exits, two epochs, one seed. Calibration used a separate uniform sample of 99,140 training rows.
transformers 5.17.Apache-2.0, following the base model. Dataset: Civil Comments (CC0-1.0).