Downloads · 30 days
30
14% of all-time downloads
maxwlnd/socialgroup_stance_classification_nli
socialgroup_stance_classification_nli is a zero-shot classification model from maxwlnd. Use it when you need labels you did not train the model on. It is set up for transformers. The card lists the license as mit.
A DeBERTa-v3-base NLI model fine-tuned to classify the author's stance toward a social group in a political text as positive, negative, or neutral.
Downloads · 30 days
30
14% of all-time downloads
All-time downloads
212
Public
Parameters
184M
2.2 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors738 MB · 99%
From the Hugging Face model README
A DeBERTa-v3-base NLI model fine-tuned to classify the author's stance toward a social group in a political text as positive, negative, or neutral.
This model is part of the group-appeal-detector package, which also provides group mention detection and mention clustering.
MoritzLaurer/deberta-v3-base-zeroshot-v2.0positive, negative, neutralFor each detected group mention, three hypotheses are formulated — one per stance class. The model chooses the class with the largest entailment probability as the predicted stance.
Cross-validated performance (95% confidence intervals based on the estimated standard error across folds in brackets):
| Metric | Negative | Neutral | Positive | Macro-Avg. |
|---|---|---|---|---|
| F1 | 0.76 [0.72, 0.80] | 0.80 [0.78, 0.81] | 0.89 [0.89, 0.89] | 0.81 [0.80, 0.83] |
| Precision | 0.85 [0.77, 0.94] | 0.81 [0.79, 0.84] | 0.87 [0.86, 0.88] | 0.85 [0.82, 0.87] |
| Recall | 0.70 [0.62, 0.77] | 0.78 [0.76, 0.80] | 0.91 [0.89, 0.92] | 0.79 [0.77, 0.82] |
group-appeal-detector package (recommended)pip install group-appeal-detector
from group_appeal_detector import GroupAppealDetector
detector = GroupAppealDetector(device="cpu")
sentence = "We must protect the rights of farmers."
target_group = "farmers"
result = detector.classify_stance(sentence, target_group)
print(result["predicted_stance"], result["stance_probs"])
For batch processing:
pairs = [
("We must protect the rights of farmers.", "farmers"),
("We do a lot for elderly people.", "elderly people"),
]
results_df = detector.classify_stance_batch(pairs, batch_size=8, as_df=True)
from transformers import pipeline
pipe = pipeline(
"zero-shot-classification",
model="maxwlnd/socialgroup_stance_classification_nli",
)
sentence = "We must protect the rights of farmers."
target_group = "farmers"
hypotheses = [
f"The text is positive towards {target_group}.",
f"The text is negative towards {target_group}.",
f"The text is neutral, or contains no stance, towards {target_group}.",
]
result = pipe(sentence, candidate_labels=hypotheses)
print(result["labels"][0], result["scores"][0])
This model is one of three models in the group appeal detection pipeline:
| Model | Task |
|---|---|
maxwlnd/roberta_group_mention_detector | Detect social group mentions |
maxwlnd/socialgroup_stance_classification_nli | Classify stance toward a group as positive, negative, or neutral (this model) |
maxwlnd/cl_mention_embedding | Embed mentions for clustering into qualitative categories |
The definition of a social group appeal used for annotating the training data is inspired by Lena Maria Huber and Alona O. Dolinsky and Will Horne, Alona O. Dolinsky and Lena Maria Huber.
A group appeal is an intentional act by a political actor that associates them with a social group in a supportive or critical manner. This model classifies whether the author's expressed stance toward the mentioned group is positive, negative, or neutral.
MIT