YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Sexism Detection Models for EXIST2025
This repository provides two fine-tuned transformer models for the EXIST2025 sexism detection challenge:
- Intention Multiclass Detection (
sexism-intention-xlm-roberta)
Both models are based on xlm-roberta-large and are ready for direct use with Hugging Face Transformers.
How to Use
2. Intention Multiclass Detection
Task: Classify the intention of a sexist tweet as one of: DIRECT, REPORTED, JUDGEMENTAL, NO.
Load and use:
from transformers import AutoTokenizer
from model_class import SoftMultiClassifier # See below for class definition
import torch
import numpy as np
model_path = "LuisaLuligo/sexism-intention-xlm-roberta"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = SoftMultiClassifier(model_name=model_path, num_labels=4)
model.eval()
text = "Example tweet here"
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding="max_length", max_length=128)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=-1).cpu().numpy()[0]
idx2label = {0: "DIRECT", 1: "REPORTED", 2: "JUDGEMENTAL", 3: "NO"}
pred_label = idx2label[int(np.argmax(probs))]
print(f"Prediction: {pred_label} (probs: {probs})")
Model Classes
You must use the following classes for inference:
import torch
import torch.nn as nn
from transformers import AutoModel, AutoConfig
from transformers.modeling_outputs import SequenceClassifierOutput
class SoftMultiClassifier(nn.Module):
def __init__(self, model_name="xlm-roberta-large", num_labels=4, dropout=0.3):
super().__init__()
self.config = AutoConfig.from_pretrained(model_name, num_labels=num_labels)
self.encoder = AutoModel.from_pretrained(model_name)
self.dropout = nn.Dropout(dropout)
self.classifier = nn.Linear(self.config.hidden_size, num_labels)
self.to(torch.device("cuda" if torch.cuda.is_available() else "cpu"))
def forward(self, input_ids, attention_mask=None, **kwargs):
output = self.encoder(input_ids=input_ids, attention_mask=attention_mask)
pooled = self.dropout(output.last_hidden_state[:, 0])
logits = self.classifier(pooled)
return SequenceClassifierOutput(loss=None, logits=logits)
Model Card: sexism-intention-xlm-roberta
Architecture: xlm-roberta-large
Task: Multiclass classification (DIRECT, REPORTED, JUDGEMENTAL, NO)
Languages: Spanish and English
Training Data: Tweets annotated by 6 experts, soft labels used
Loss: CrossEntropyLoss with class weights
Frozen Layers: Embeddings + first 4 encoder layers
Metrics: Macro F1, accuracy
Intended Use: Classifies the intention behind sexist tweets
Limitations: Class imbalance may affect rare classes; requires similar preprocessing for new data.
Citation
If you use these models, please cite the EXIST2025 challenge and