Collective Action Participation Detection Model - RoBERTa
This model detects expressions of participation in collective action from text. For details on the framework and useful code snippets, see the paper "Extracting Participation in Collective Action from Social Media", Pera and Aiello (2025).
- A predicted value of 0 indicates expressed participation in collective action.
- A predicted value of 1 indicates the lack of such an expression.
Usage Example
To use the model, follow the example below:
from transformers import AutoModelForSequenceClassification, AutoTokenizer
# Set device to CPU or GPU
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Load model and tokenizer
model_name = "ariannap22/collectiveaction_roberta_simplified_synthetic_weights"
model = AutoModelForSequenceClassification.from_pretrained(model_name).to(device)
tokenizer = AutoTokenizer.from_pretrained(model_name)
# Define the text you want to predict
texts = [
"We need to stand together for our rights!",
"I volunteer at the local food bank.",
"This is just a casual discussion."
]
# Tokenize the input text
inputs = tokenizer(
texts,
padding=True, # Pad to the longest sequence in the batch
truncation=True, # Truncate sequences longer than the model's max length
max_length=512, # Adjust max length as needed
return_tensors="pt" # Return PyTorch tensors
).to(device)
# Perform prediction
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits # Raw model outputs before softmax
# Convert logits to probabilities (optional)
probs = torch.nn.functional.softmax(logits, dim=-1)
# Get predicted class indices
predicted_class_indices = torch.argmax(probs, dim=-1)
# Print results
for text, idx, prob in zip(texts, predicted_class_indices, probs):
print(f"Text: {text}")
print(f"Predicted Class Index: {idx.item()}")
print(f"Probabilities: {prob.tolist()}")
print("---")
- Downloads last month
- 46
Inference Providers
NEW
This model is not currently available via any of the supported third-party Inference Providers, and
HF Inference API was unable to determine this model's library.
Model tree for ariannap22/collectiveaction_roberta_simplified_synthetic_weights
Base model
FacebookAI/roberta-base