Update README.md
Browse files
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# tweet-topic-21-multi
|
| 2 |
|
| 3 |
-
This is a roBERTa-base model trained on ~124M tweets from January 2018 to December 2021 (see [here](https://huggingface.co/cardiffnlp/twitter-roberta-base-2021-124m)), and finetuned for
|
| 4 |
The original roBERTa-base model can be found [here](https://huggingface.co/cardiffnlp/twitter-roberta-base-2021-124m) and the original reference paper is [TweetEval](https://github.com/cardiffnlp/tweeteval). This model is suitable for English.
|
| 5 |
|
| 6 |
- Reference Paper: [TimeLMs paper](https://arxiv.org/abs/2202.03829).
|
|
@@ -20,7 +20,7 @@ The original roBERTa-base model can be found [here](https://huggingface.co/cardi
|
|
| 20 |
## Full classification example
|
| 21 |
|
| 22 |
```python
|
| 23 |
-
from transformers import AutoModelForSequenceClassification
|
| 24 |
from transformers import AutoTokenizer
|
| 25 |
import numpy as np
|
| 26 |
from scipy.special import expit
|
|
@@ -41,6 +41,17 @@ scores = output[0][0].detach().numpy()
|
|
| 41 |
scores = expit(scores)
|
| 42 |
predictions = (scores >= 0.5) * 1
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
# Map to classes
|
| 45 |
for i in range(len(predictions)):
|
| 46 |
if predictions[i]:
|
|
|
|
| 1 |
# tweet-topic-21-multi
|
| 2 |
|
| 3 |
+
This is a roBERTa-base model trained on ~124M tweets from January 2018 to December 2021 (see [here](https://huggingface.co/cardiffnlp/twitter-roberta-base-2021-124m)), and finetuned for multi-label topic classification on a corpus of 11,267 tweets.
|
| 4 |
The original roBERTa-base model can be found [here](https://huggingface.co/cardiffnlp/twitter-roberta-base-2021-124m) and the original reference paper is [TweetEval](https://github.com/cardiffnlp/tweeteval). This model is suitable for English.
|
| 5 |
|
| 6 |
- Reference Paper: [TimeLMs paper](https://arxiv.org/abs/2202.03829).
|
|
|
|
| 20 |
## Full classification example
|
| 21 |
|
| 22 |
```python
|
| 23 |
+
from transformers import AutoModelForSequenceClassification, TFAutoModelForSequenceClassification
|
| 24 |
from transformers import AutoTokenizer
|
| 25 |
import numpy as np
|
| 26 |
from scipy.special import expit
|
|
|
|
| 41 |
scores = expit(scores)
|
| 42 |
predictions = (scores >= 0.5) * 1
|
| 43 |
|
| 44 |
+
|
| 45 |
+
# TF
|
| 46 |
+
#tf_model = TFAutoModelForSequenceClassification.from_pretrained(MODEL)
|
| 47 |
+
#class_mapping = model.config.id2label
|
| 48 |
+
#text = "It is great to see athletes promoting awareness for climate change."
|
| 49 |
+
#tokens = tokenizer(text, return_tensors='tf')
|
| 50 |
+
#output = tf_model(**tokens)
|
| 51 |
+
#scores = output[0][0]
|
| 52 |
+
#scores = expit(scores)
|
| 53 |
+
#predictions = (scores >= 0.5) * 1
|
| 54 |
+
|
| 55 |
# Map to classes
|
| 56 |
for i in range(len(predictions)):
|
| 57 |
if predictions[i]:
|