Update README.md

This commit is contained in:
Cardiff NLP 2020-11-12 19:21:55 +00:00
parent aa7cb4cab2
commit 8eacbc59c0
1 changed files with 11 additions and 1 deletions

View File

@ -1,4 +1,4 @@
# Twitter-roBERTa-base
# Twitter-roBERTa-base for Sentiment Analysis
This is a roBERTa-base model trained on ~58M tweets and finetuned for the Sentiment Analysis task at Semeval 2018.
For full description: [_TweetEval_ benchmark (Findings of EMNLP 2020)](https://arxiv.org/pdf/2010.12421.pdf).
@ -6,6 +6,15 @@ To evaluate this and other models on Twitter-specific data, please refer to the
## Example of classification
# Preprocess text (username and link placeholders)
def preprocess(text):
new_text = []
for t in text.split(" "):
t = '@user' if t.startswith('@') and len(t) > 1 else t
t = 'http' if t.startswith('http') else t
new_text.append(t)
return " ".join(new_text)
```python
from transformers import AutoModelForSequenceClassification
from transformers import TFAutoModelForSequenceClassification
@ -37,6 +46,7 @@ model = AutoModelForSequenceClassification.from_pretrained(MODEL)
model.save_pretrained(MODEL)
text = "Good night 😊"
text = preprocess(text)
encoded_input = tokenizer(text, return_tensors='pt')
output = model(**encoded_input)
scores = output[0][0].detach().numpy()