Views
No views yet
| Label | Description |
|---|---|
| WOMEN | Against women |
| LGBTI | Against LGBTI |
| RACISM | Racist |
| CLASS | Classist |
| POLITICS | Because of politics |
| DISABLED | Against disabled |
| APPEARANCE | Against people because their appearance |
| CRIMINAL | Against criminals |
CALLS, which represents whether a comment is a call to violent action or not.TEXT [SEP] CONTEXT[SEP] is the special token used to separate the comment from the context.Comment: Hay que matarlos a todos!!! Nos infectaron con su virus!
Context: China prohibió la venta de perros y gatos para consumo humanoHay que matarlos a todos!!! Nos infectaron con su virus! [SEP] China prohibió la venta de perros y gatos para consumo humanohuggingface pipeline does not support multi-label classification, so this model cannot be tested directly in the side widget.1
2import torch
3from transformers import AutoTokenizer, AutoModelForSequenceClassification
4
5model_name = "piubamas/beto-contextualized-hate-speech"
6# Load tokenizer and model
7tokenizer = AutoTokenizer.from_pretrained(model_name)
8model = AutoModelForSequenceClassification.from_pretrained(model_name)
9
10id2label = [model.config.id2label[k] for k in range(len(model.config.id2label))]
11
12def predict(*args):
13 encoding = tokenizer.encode_plus(*args)
14
15 inputs = {
16 k:torch.LongTensor(encoding[k]).reshape(1, -1) for k in {"input_ids", "attention_mask", "token_type_ids"}
17 }
18
19 output = model.forward(
20 **inputs
21 )
22
23 chars = list(zip(id2label, list(output.logits[0].detach().cpu().numpy() > 0)))
24
25 return [char for char, pred in chars if pred]
26
27context = "China prohíbe la cría de perros para consumo humano")
28text = "Chinos hdrmp hay que matarlos a todos"
29
30prediction = predict(text, context)1@article{perez2023assessing,
2 title={Assessing the impact of contextual information in hate speech detection},
3 author={P{\'e}rez, Juan Manuel and Luque, Franco M and Zayat, Demian and Kondratzky, Mart{\'\i}n and Moro, Agust{\'\i}n and Serrati, Pablo Santiago and Zajac, Joaqu{\'\i}n and Miguel, Paula and Debandi, Natalia and Gravano, Agust{\'\i}n and others},
4 journal={IEEE Access},
5 volume={11},
6 pages={30575--30590},
7 year={2023},
8 publisher={IEEE}
9}