Instructions to use TomMoeras/contragand-qwen3.5-4b-closed with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use TomMoeras/contragand-qwen3.5-4b-closed 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-closed") - Notebooks
- Google Colab
- Kaggle
ContraGAND detector — closed task (FT-CONTRA)
LoRA adapter for Qwen/Qwen3.5-4B that classifies the gender of a given
referent in an English sentence as masculine, feminine, or ambiguous
(no textual cue). This is the FT-CONTRA (D-A) condition from the EMNLP 2026
paper ContraGAND: Auditing and Repairing Gender Ambiguity Failures in LLMs
with Neurosymbolic Contrastive Data Augmentation: fine-tuned on the full
2/2/2 contrastive ContraGAND training split (11,706 examples: each ambiguous
source sentence paired with a masculine and a feminine minimal variant).
Closed-task accuracy on the human-audited ContraGAND test set (1,395 examples): 0.992 (macro-F1 0.992) — above the 31B teacher's 0.984.
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-closed")
system = """You classify the gender of a named REFERENT in an English sentence.
Output one of three labels:
- masculine — the referent is unambiguously male
- feminine — the referent is unambiguously female
- ambiguous — the sentence contains no signal that reveals the referent's gender
Respond with ONLY a JSON object:
{"gender": "masculine|feminine|ambiguous", "confidence": N, "reasoning": "..."}
confidence is an integer 1-5 (5 = certain).
reasoning is one short sentence citing the textual evidence (the pronoun, the title, the gendered noun, etc.)."""
user = "Sentence: The librarian, Mrs. Thompson, shelved the returned books.\nReferent: librarian"
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=200. The response is a single JSON object.
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. See the paper's Limitations and Ethical considerations.
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
- -