Instructions to use TomMoeras/contragand-qwen3.5-4b-open with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use TomMoeras/contragand-qwen3.5-4b-open with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-4B") model = PeftModel.from_pretrained(base_model, "TomMoeras/contragand-qwen3.5-4b-open") - Notebooks
- Google Colab
- Kaggle
ContraGAND detector — open task (FT-MULTI)
LoRA adapter for Qwen/Qwen3.5-4B that reads an English sentence,
identifies every role, occupation, or relational referent, and labels
each as masculine, feminine, or ambiguous (no textual cue). This is the
FT-MULTI (D-MULTI) condition from the EMNLP 2026 paper ContraGAND: Auditing
and Repairing Gender Ambiguity Failures in LLMs with Neurosymbolic
Contrastive Data Augmentation: knowledge distillation from Gemma-4-31B-it's
multi-referent open-task enumerations over the ContraGAND training split
(11,684 records, ~2 referents per sentence), with the annotated referent's
label corrected to gold.
Open-task accuracy on the human-audited ContraGAND test set (1,395 examples): 0.976 (macro-F1 0.979) — above the 31B teacher's zero-shot 0.952 at one-eighth the parameters, versus 0.242 for the base model in-context.
Usage
The adapter expects the exact prompt format it was trained on:
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("Qwen/Qwen3.5-4B")
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-4B", torch_dtype="bfloat16")
model = PeftModel.from_pretrained(model, "TomMoeras/contragand-qwen3.5-4b-open")
system = """You read an English sentence, identify every role, occupation, or relational REFERENT in it (e.g. doctor, teacher, brother, neighbor, captain), and classify each one's gender.
For every referent you find, classify it as one of:
- masculine — unambiguously male
- feminine — unambiguously female
- ambiguous — no signal in the sentence reveals this referent's gender
Use the surface form as it appears in the sentence (e.g. "doctor", not "the doctor"). List the referents in the order they appear.
Respond with ONLY a JSON object:
{"referents": [{"referent": "...", "gender": "masculine|feminine|ambiguous", "confidence": N, "reasoning": "..."}]}
confidence is an integer 1-5 (5 = certain).
reasoning is one short sentence per referent citing the textual evidence."""
user = "Sentence: The librarian, Mrs. Thompson, shelved the returned books."
prompt = tok.apply_chat_template(
[{"role": "system", "content": system}, {"role": "user", "content": user}],
tokenize=False, add_generation_prompt=True, enable_thinking=False)
Greedy decoding, max_new_tokens=384. The response is a single JSON object
with one entry per identified referent.
Training
QLoRA (nf4), r=64, alpha=128, dropout 0.05 on all linear projections; lr 2e-5 cosine, 5 epochs with early stopping on eval loss; sequence length 1024; trained with axolotl on 4x A100-80GB. Full configs, data builders, and per-row evaluation results: https://github.com/TomMoeras/ContraGAND
Intended use and limitations
Research artifact for gender-ambiguity detection. Labels are restricted to {masculine, feminine, ambiguous} and cannot represent non-binary or singular-they referents. English only. Silver supervision can inherit rare teacher coreference mis-bindings (see the paper's Limitations).
Dataset
Trained on the ContraGAND corpus: https://huggingface.co/datasets/TomMoeras/ContraGAND
Demo
Interactive demo (open + closed task): https://huggingface.co/spaces/TomMoeras/contragand-demo
Citation
Moerman, Gkovedarou, and Hackenbuchner. ContraGAND: Auditing and Repairing Gender Ambiguity Failures in LLMs with Neurosymbolic Contrastive Data Augmentation. EMNLP 2026 (Main Conference).
- Downloads last month
- 35