luisespinosa commited on
Commit
115a167
•
1 Parent(s): 8bddc41

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +12 -2
README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Twitter-roBERTa-base
2
 
3
- This is a roBERTa-base model trained on ~58M tweets and finetuned for the hate detection task at Semeval 2019.
4
  For full description: [_TweetEval_ benchmark (Findings of EMNLP 2020)](https://arxiv.org/pdf/2010.12421.pdf).
5
  To evaluate this and other models on Twitter-specific data, please refer to the [Tweeteval official repository](https://github.com/cardiffnlp/tweeteval).
6
 
@@ -15,6 +15,15 @@ from scipy.special import softmax
15
  import csv
16
  import urllib.request
17
 
 
 
 
 
 
 
 
 
 
18
  # Tasks:
19
  # emoji, emotion, hate, irony, offensive, sentiment
20
  # stance/abortion, stance/atheism, stance/climate, stance/feminist, stance/hillary
@@ -37,6 +46,7 @@ model = AutoModelForSequenceClassification.from_pretrained(MODEL)
37
  model.save_pretrained(MODEL)
38
 
39
  text = "Good night 😊"
 
40
  encoded_input = tokenizer(text, return_tensors='pt')
41
  output = model(**encoded_input)
42
  scores = output[0][0].detach().numpy()
1
+ # Twitter-roBERTa-base for Hate Speech Detection
2
 
3
+ This is a roBERTa-base model trained on ~58M tweets and finetuned for the Hate Speech Detection task at Semeval 2019.
4
  For full description: [_TweetEval_ benchmark (Findings of EMNLP 2020)](https://arxiv.org/pdf/2010.12421.pdf).
5
  To evaluate this and other models on Twitter-specific data, please refer to the [Tweeteval official repository](https://github.com/cardiffnlp/tweeteval).
6
 
15
  import csv
16
  import urllib.request
17
 
18
+ # Preprocess text (username and link placeholders)
19
+ def preprocess(text):
20
+ new_text = []
21
+ for t in text.split(" "):
22
+ t = '@user' if t.startswith('@') and len(t) > 1 else t
23
+ t = 'http' if t.startswith('http') else t
24
+ new_text.append(t)
25
+ return " ".join(new_text)
26
+
27
  # Tasks:
28
  # emoji, emotion, hate, irony, offensive, sentiment
29
  # stance/abortion, stance/atheism, stance/climate, stance/feminist, stance/hillary
46
  model.save_pretrained(MODEL)
47
 
48
  text = "Good night 😊"
49
+ text = preprocess(text)
50
  encoded_input = tokenizer(text, return_tensors='pt')
51
  output = model(**encoded_input)
52
  scores = output[0][0].detach().numpy()