Zum Inhalt springen
ModelAufgelistetExtern
Herunterladen

Gus Net Bert

Token-level social-bias detector built on bert-base-uncased. Given a sentence, it tags each token with one of four bias categories following a 7-label BIO scheme, so a downstream system can highlight which words...

ArtOtherBasismodellbert-base-uncasedVersionRevision 8e75db8CBewertung

Modellquelle

Art
Other
Dateigröße
415 MB
Basismodell
bert-base-uncased
Version
vRevision 8e75db8
Aktualisiert
26. Sept. 2026
Downloads
384
Quelle
Hugging Face

Quellenbeschreibung

GUS-Net (BERT)

Token-level social-bias detector built on bert-base-uncased. Given a sentence, it tags each token with one of four bias categories following a 7-label BIO scheme, so a downstream system can highlight which words carry bias, not just whether a sentence is biased.

This is the flagship / default checkpoint of the Attention Atlas project (a master's thesis on interpretable bias detection through transformer attention). This published checkpoint is the sparsity-regularised training run.

Label scheme

The model outputs 7 BIO labels. STEREO, GEN and UNFAIR are the three bias categories; O is "no bias".

IndexLabelCategory
0Onone
1B-STEREOStereotype (span start)
2I-STEREOStereotype (span inside)
3B-GENGeneralisation (span start)
4I-GENGeneralisation (span inside)
5B-UNFAIRUnfair language (span start)
6I-UNFAIRUnfair language (span inside)
  • GEN — a blanket generalisation about a group.
  • UNFAIR — unfair / disparaging language toward a group.
  • STEREO — a stereotype attributed to a group.

Important: multi-label + per-label thresholds

Outputs are per-token sigmoid probabilities (multi-label), not a softmax. Predictions are obtained by thresholding each label. The F1-optimised thresholds for this checkpoint (order [O, B-STEREO, I-STEREO, B-GEN, I-GEN, B-UNFAIR, I-UNFAIR]) are:

[0.4265, 0.4071, 0.3938, 0.3462, 0.3669, 0.3184, 0.3630]

Using a flat 0.5 threshold will under-detect bias — use the values above.

Usage

import torch
from transformers import BertTokenizerFast, BertForTokenClassification

model_id = "pinthoz/gus-net-bert"
tok = BertTokenizerFast.from_pretrained("bert-base-uncased")
model = BertForTokenClassification.from_pretrained(model_id).eval()

CATEGORY_INDICES = {"STEREO": [1, 2], "GEN": [3, 4], "UNFAIR": [5, 6]}
THRESHOLDS = [0.4265, 0.4071, 0.3938, 0.3462, 0.3669, 0.3184, 0.3630]

text = "Women are naturally worse at driving."
enc = tok(text, return_tensors="pt")
with torch.no_grad():
    probs = torch.sigmoid(model(input_ids=enc["input_ids"],
                                attention_mask=enc["attention_mask"]).logits)[0]

tokens = tok.convert_ids_to_tokens(enc["input_ids"][0])
for i, tokn in enumerate(tokens):
    if tokn in ("[CLS]", "[SEP]", "[PAD]"):
        continue
    fired = {cat: float(probs[i, idxs].max())
             for cat, idxs in CATEGORY_INDICES.items()
             if any(probs[i, j] > THRESHOLDS[j] for j in idxs)}
    if fired:
        print(f"{tokn:15s} -> {fired}")

Training data

Fine-tuned on the GUS-Net dataset — a token-level social-bias corpus annotated for Generalisations, Unfairness and Stereotypes, from which this model's 7-label scheme is derived (ethical-spectacle/gus-dataset-v1).

Difference from the original GUS-Net dataset and models: in the raw corpus punctuation is mostly fused to the preceding word rather than tokenised separately, so a comma or full stop falling inside a labelled span inherits that span's categories — the sentence-final mark carries a bias label in 1,942 of the 3,739 sentences, and an in-span comma in 270. The data used here splits each mark into a token of its own and labels it non-bias O, repairing the BIO sequence where the split interrupts a span, since punctuation is not a social-bias carrier. On a held-out sample this checkpoint labels the sentence-final mark as bias in 0 of 741 sentences (0.0 %), matching the cleaned gold.

Evaluation

StereoSet (intersentence split, 2123 examples)

MetricScore
LMS (language-modeling score, higher is better)71.81
SS (stereotype score, 50 = ideal)53.09
ICAT (bias-adjusted quality)67.38

Per-category SS: gender 58.68 · race 50.10 · religion 46.15 · profession 55.62.

Token classification (GUS-Net held-out test set)

Held-out partition (747 sentences) of the stratified cross-validation fold this checkpoint was trained against — StratifiedKFold(n_splits=5, shuffle=True, random_state=42) over the cleaned corpus (see Training data), fold 4 — scored with the per-label thresholds above. Each category aggregates its B-/I- labels; the micro average covers the three bias categories and excludes the majority O class. Label alignment mirrors training (secondary subtokens masked).

CategoryPrecisionRecallF1
O (non-bias)0.8870.9360.911
GEN0.8120.6820.741
UNFAIR0.4130.4970.451
STEREO0.7590.7080.733
Micro-avg0.7270.6760.701

UNFAIR is the weakest category on this checkpoint: treat unfair-language spans as candidates to review, not as detections.

The sparsity penalty costs recall. Measured against an otherwise identical run without the penalty, on the same corpus and the same fold, this checkpoint holds similar precision (0.727 vs 0.726) but recalls less (0.676 vs 0.829), for ~7 points of micro-F1. That is the intended trade: LAMBDA_SPARSE concentrates attention mass on fewer tokens, yielding tighter, more conservative spans.

Attention calibration (Attention Atlas)

Empirical noise floors for reading this checkpoint's attention, derived from a permutation null over 5,439 sentences. They answer "is this head's behaviour distinguishable from chance?", and are what the dashboard uses to avoid over-reading attention. Useful if you build your own attention analysis on these weights; not needed for plain token classification.

Quantityα=0.05 (p95)α=0.01 (p99)
BAR (Bias Attention Ratio)2.054.48
BSR (Bias Self-Reinforcement)2.997.62
Ablation representation-impact0.01490.0261

Top-K head-ablation elbow: 8 heads. A head only counts as bias-specialised above the BAR floor, and its ablation only counts as causal above the impact floor. Note these floors are a property of the specific weights, not of the architecture, so they must be re-derived if the checkpoint is retrained.

Limitations & intended use

  • Research / auditing tool, not a content-moderation oracle. Predictions reflect a specific operationalisation of bias (clear generalisations, unfairness and stereotypes about a group); subtle, implicit or context-dependent bias may be missed.
  • English only.
  • Labels are not error-free; treat spans as evidence to review, not ground truth.
  • Do not use for automated decisions about individuals.

Citation

If you use these models, please cite the GUS-Net dataset and benchmark:

@article{powers2024gusnet,
  title   = {GUS-Net: Social Bias Classification in Text with Generalizations, Unfairness, and Stereotypes},
  author  = {Powers, Maximus and Raza, Shaina and Chang, Alex and Riaz, Rehana and Mavani, Umang and Jonala, Harshitha Reddy and Tiwari, Ansh and Wei, Hua},
  journal = {arXiv preprint arXiv:2410.08388},
  year    = {2024}
}

License

Weights released under Apache-2.0 (matching the bert-base-uncased base model). The Attention Atlas code is MIT-licensed.

Quellen

1 Quelle
Hugging FacePrimärVersion 8e75db8b0796f6998ee7d33e1c5406e40516e8ee
huggingface.co/pinthoz/gus-net-bert/tree/8e75db8b0796f6998ee7d33e1c5406e40516e8ee

Verifiziert 7. Aug.

Modellartefakte

2 Artefakte

model.safetensors

safetensors · 415 MB · SHA-256 8506d51dc808…e50a · Hugging Face

Herunterladen

pytorch_model.bin

bin · 415 MB · SHA-256 e840d3479416…4863 · Hugging Face

Herunterladen

Quellenauszüge

3 Auszüge

--- license: apache-2.0 language: - en library_name: transformers pipeline_tag: token-classification base_model: bert-base-uncased tags: - bias-detection - social-bias - token-classification - gus-net - fairness - interpretability datasets: - ethical-spectacle/gus-dataset-v1 metrics: - f1 --- # GUS-Net (BERT) Token-level **social-bias detector** built on `bert-base-uncased`. Given a sentence, it tags each token with one of four bias categories following a 7-label BIO scheme, so a downstream system can highlight *which words* carry bias, not just whether a sentence is biased. This is the flagship / default checkpoint of the **Attention Atlas** project (a master's thesis on interpretable bias detection through transformer attention). This published checkpoint is the **sparsity-regularised** training run. - **Base model:** `bert-base-uncased` - **Task:** multi-label token classification (per-token sigmoid, thresholded) - **Language:** English - **Related models:** [`pinthoz/gus-net-bert-large`](https://huggingface.co/pinthoz/gus-net-bert-large), [`pinthoz/gus-net-gpt2`](https://huggingface.co/pinthoz/gus-net-gpt2), [`pinthoz/gus-net-gpt2-medium`](https://huggingface.co/pinthoz/gus-net-gpt2-medium) ## Label scheme The model outputs 7 BIO labels. `STEREO`, `GEN` and `UNFAIR` are the three bias categories; `O` is "no bias". | Index | Label | Category | |-------|-----------|-----------------------------------| | 0 | O | none | | 1 | B-STEREO | Stereotype (span start) | | 2 | I-STEREO | Stereotype (span inside) | | 3 | B-GEN | Generalisation (span start) | | 4 | I-GEN | Generalisation (span inside) | | 5 | B-UNFAIR | Unfair language (span start) | | 6 | I-UNFAIR | Unfair language (span inside) | - **GEN** — a blanket generalisation about a group. - **UNFAIR** — unfair / disparaging language toward a group. - **STEREO** — a stereotype attributed to a group. ## Important: multi-label + per-label thresholds Outputs are **per-token sigmoid probabilities** (multi-label), not a softmax. Predictions are obtained by thresholding each label. The F1-optimised thresholds for this checkpoint (order `[O, B-STEREO, I-STEREO, B-GEN, I-GEN, B-UNFAIR, I-UNFAIR]`) are: ``` [0.4265, 0.4071, 0.3938, 0.3462, 0.3669, 0.3184, 0.3630] ``` Using a flat 0.5 threshold will under-detect bias — use the values above. ## Usage ```...

--- license: apache-2.0 language: - en library_name: transformers pipeline_tag: token-classification base_model: bert-base-uncased tags: - bias-detection - social-bias - token-classification - gus-net - fairness - interpretability datasets: - ethical-spectacle/gus-dataset-v1 metrics: - f1 --- # GUS-Net (BERT) Token-level **social-bias detector** built on `bert-base-uncased`. Given a sentence, it tags each token with one of four bias categories following a 7-label BIO scheme, so a downstream system can highlight *which words* carry bias, not just whether a sentence is biased. This is the flagship / default checkpoint of the **Attention Atlas** project (a master's thesis on interpretable bias detection through transformer attention). This published checkpoint is the **sparsity-regularised** training run. - **Base model:** `bert-base-uncased` - **Task:** multi-label token classification (per-token sigmoid, thresholded) - **Language:** English - **Related models:** [`pinthoz/gus-net-bert-large`](https://huggingface.co/pinthoz/gus-net-bert-large), [`pinthoz/gus-net-gpt2`](https://huggingface.co/pinthoz/gus-net-gpt2), [`pinthoz/gus-net-gpt2-medium`](https://huggingface.co/pinthoz/gus-net-gpt2-medium) ## Label scheme The model outputs 7 BIO labels. `STEREO`, `GEN` and `UNFAIR` are the three bias categories; `O` is "no bias". | Index | Label | Category | |-------|-----------|-----------------------------------| | 0 | O | none | | 1 | B-STEREO | Stereotype (span start) | | 2 | I-STEREO | Stereotype (span inside) | | 3 | B-GEN | Generalisation (span start) | | 4 | I-GEN | Generalisation (span inside) | | 5 | B-UNFAIR | Unfair language (span start) | | 6 | I-UNFAIR | Unfair language (span inside) | - **GEN** — a blanket generalisation about a group. - **UNFAIR** — unfair / disparaging language toward a group. - **STEREO** — a stereotype attributed to a group. ## Important: multi-label + per-label thresholds Outputs are **per-token sigmoid probabilities** (multi-label), not a softmax. Predictions are obtained by thresholding each label. The F1-optimised thresholds for this checkpoint (order `[O, B-STEREO, I-STEREO, B-GEN, I-GEN, B-UNFAIR, I-UNFAIR]`) are: ``` [0.476, 0.375, 0.3475, 0.3251, 0.3975, 0.342, 0.3309] ``` Using a flat 0.5 threshold will under-detect bias — use the values above. ## Usage ```python import torch from transformers import...

Source context: 384 downloads · 1 likes · Pipeline token-classification · Library transformers · Repo pinthoz/gus-net-bert