antypasd commited on
Commit
6f77ecf
1 Parent(s): e03cf7b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +49 -30
README.md CHANGED
@@ -1,46 +1,65 @@
1
- ---
2
- tags:
3
- - generated_from_keras_callback
4
- model-index:
5
- - name: tf version
6
- results: []
7
- ---
8
 
9
- <!-- This model card has been generated automatically according to the information Keras had access to. You should
10
- probably proofread and complete it, then remove this comment. -->
11
 
12
- # tf version
 
13
 
14
- This model is a fine-tuned version of [antypasd/tweet-topic-19-multi](https://huggingface.co/antypasd/tweet-topic-19-multi) on an unknown dataset.
15
- It achieves the following results on the evaluation set:
16
 
17
 
18
- ## Model description
 
 
 
 
 
19
 
20
- More information needed
21
 
22
- ## Intended uses & limitations
23
 
24
- More information needed
 
 
 
 
25
 
26
- ## Training and evaluation data
 
 
27
 
28
- More information needed
 
 
29
 
30
- ## Training procedure
 
 
31
 
32
- ### Training hyperparameters
 
 
33
 
34
- The following hyperparameters were used during training:
35
- - optimizer: None
36
- - training_precision: float32
 
 
 
 
 
 
37
 
38
- ### Training results
 
 
 
39
 
 
 
40
 
41
-
42
- ### Framework versions
43
-
44
- - Transformers 4.19.2
45
- - TensorFlow 2.8.2
46
- - Tokenizers 0.12.1
 
1
+ # tweet-topic-19-multi
 
 
 
 
 
 
2
 
3
+ This is a roBERTa-base model trained on ~90m tweets until the end of 2019 (see [here](https://huggingface.co/cardiffnlp/twitter-roberta-base-2019-90m)), 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).
7
+ - Git Repo: [TimeLMs official repository](https://github.com/cardiffnlp/timelms).
8
 
9
+ <b>Labels</b>:
 
10
 
11
 
12
+ | <span style="font-weight:normal">0: arts_&_culture</span> | <span style="font-weight:normal">5: fashion_&_style</span> | <span style="font-weight:normal">10: learning_&_educational</span> | <span style="font-weight:normal">15: science_&_technology</span> |
13
+ |-----------------------------|---------------------|----------------------------|--------------------------|
14
+ | 1: business_&_entrepreneurs | 6: film_tv_&_video | 11: music | 16: sports |
15
+ | 2: celebrity_&_pop_culture | 7: fitness_&_health | 12: news_&_social_concern | 17: travel_&_adventure |
16
+ | 3: diaries_&_daily_life | 8: food_&_dining | 13: other_hobbies | 18: youth_&_student_life |
17
+ | 4: family | 9: gaming | 14: relationships | |
18
 
 
19
 
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
27
 
28
+
29
+ MODEL = f"antypasd/tweet-topic-19-multi"
30
+ tokenizer = AutoTokenizer.from_pretrained(MODEL)
31
 
32
+ # PT
33
+ model = AutoModelForSequenceClassification.from_pretrained(MODEL)
34
+ class_mapping = model.config.id2label
35
 
36
+ text = "It is great to see athletes promoting awareness for climate change."
37
+ tokens = tokenizer(text, return_tensors='pt')
38
+ output = model(**tokens)
39
 
40
+ scores = output[0][0].detach().numpy()
41
+ scores = expit(scores)
42
+ predictions = (scores >= 0.5) * 1
43
 
44
+ # TF
45
+ #tf_model = TFAutoModelForSequenceClassification.from_pretrained('antypasd/tweet-topic-19-multi')
46
+ #class_mapping = model.config.id2label
47
+ #text = "It is great to see athletes promoting awareness for climate change."
48
+ #tokens = tokenizer(text, return_tensors='tf')
49
+ #output = tf_model(**tokens)
50
+ #scores = output[0][0]
51
+ #scores = expit(scores)
52
+ #predictions = (scores >= 0.5) * 1
53
 
54
+ # Map to classes
55
+ for i in range(len(predictions)):
56
+ if predictions[i]:
57
+ print(class_mapping[i])
58
 
59
+ ```
60
+ Output:
61
 
62
+ ```
63
+ news_&_social_concern
64
+ sports
65
+ ```