agentlans commited on
Commit
47f904e
1 Parent(s): ce42c82

Upload 8 files

Browse files
README.md CHANGED
@@ -1,3 +1,99 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - agentlans/twitter-sentiment-meta-analysis
5
+ language:
6
+ - en
7
+ base_model:
8
+ - microsoft/deberta-v3-xsmall
9
+ - microsoft/deberta-v3-base
10
+ pipeline_tag: text-classification
11
+ ---
12
+ # DeBERTa-v3 Twitter Sentiment Models
13
+
14
+ This page contains one of two DeBERTa-v3 models (xsmall and base) fine-tuned for Twitter sentiment regression.
15
+
16
+ ## Model Details
17
+
18
+ - **Model Architecture**: DeBERTa-v3
19
+ - **Variants**:
20
+ - xsmall (22M parameters)
21
+ - base (86M parameters)
22
+ - **Task**: Sentiment regression
23
+ - **Language**: English
24
+ - **License**: Apache 2.0
25
+
26
+ ## Intended Use
27
+
28
+ These models are designed for fine-grained sentiment analysis of English tweets. They output a **continuous sentiment score** rather than discrete categories.
29
+ - negative score means negative sentiment
30
+ - zero score means neutral sentiment
31
+ - positive score means positive sentiment
32
+ - the absolute value of the score represents how strong that sentiment is
33
+
34
+ ## Training Data
35
+
36
+ The models were fine-tuned on a dataset of English tweets collected between September 2009 and January 2010. The sentiment scores were derived from a meta-analysis of 10 different sentiment classifiers using principal component analysis. Find the dataset at [agentlans/twitter-sentiment-meta-analysis](https://huggingface.co/datasets/agentlans/twitter-sentiment-meta-analysis).
37
+
38
+ ## How to use
39
+
40
+ ```python
41
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
42
+ import torch
43
+
44
+ model_name="agentlans/deberta-v3-base-tweet-sentiment"
45
+
46
+ # Put model on GPU or else CPU
47
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
48
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
49
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
50
+ model = model.to(device)
51
+
52
+ def sentiment(text):
53
+ """Processes the text using the model and returns its logits.
54
+ In this case, it's interpreted as the sentiment score for that text."""
55
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True).to(device)
56
+ with torch.no_grad():
57
+ logits = model(**inputs).logits.squeeze().cpu()
58
+ return logits.tolist()
59
+
60
+ # Example usage
61
+ text = [x.strip() for x in """
62
+ I absolutely despise this product and regret ever purchasing it.
63
+ The service at that restaurant was terrible and ruined our entire evening.
64
+ I'm feeling a bit under the weather today, but it's not too bad.
65
+ The weather is quite average today, neither good nor bad.
66
+ The movie was okay, I didn't love it but I didn't hate it either.
67
+ I'm looking forward to the weekend, it should be nice to relax.
68
+ This new coffee shop has a really pleasant atmosphere and friendly staff.
69
+ I'm thrilled with my new job and the opportunities it presents!
70
+ The concert last night was absolutely incredible, easily the best I've ever seen.
71
+ I'm overjoyed and grateful for all the love and support from my friends and family.
72
+ """.strip().split("\n")]
73
+
74
+ for x, s in zip(text, sentiment(text)):
75
+ print(f"Text: {x}\nSentiment: {round(s, 2)}\n")
76
+ ```
77
+
78
+ Output:
79
+ ```text
80
+
81
+ ```
82
+
83
+ ## Performance
84
+
85
+ Evaluation set RMSE:
86
+ - xsmall: 0.2560
87
+ - base: 0.1938
88
+
89
+ ## Limitations
90
+
91
+ - English language only
92
+ - Trained specifically on tweets, may or may not generalize well to other text types
93
+ - Lack of broader context beyond individual tweets
94
+ - May struggle with detecting sarcasm or nuanced sentiment
95
+
96
+ ## Ethical Considerations
97
+
98
+ - Potential biases in the training data related to the time period and Twitter user demographics
99
+ - Risk of misuse for large-scale sentiment monitoring without consent
added_tokens.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "[MASK]": 128000
3
+ }
config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "microsoft/deberta-v3-base",
3
+ "architectures": [
4
+ "DebertaV2ForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "hidden_act": "gelu",
8
+ "hidden_dropout_prob": 0.1,
9
+ "hidden_size": 768,
10
+ "id2label": {
11
+ "0": "LABEL_0"
12
+ },
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 3072,
15
+ "label2id": {
16
+ "LABEL_0": 0
17
+ },
18
+ "layer_norm_eps": 1e-07,
19
+ "max_position_embeddings": 512,
20
+ "max_relative_positions": -1,
21
+ "model_type": "deberta-v2",
22
+ "norm_rel_ebd": "layer_norm",
23
+ "num_attention_heads": 12,
24
+ "num_hidden_layers": 12,
25
+ "pad_token_id": 0,
26
+ "pooler_dropout": 0,
27
+ "pooler_hidden_act": "gelu",
28
+ "pooler_hidden_size": 768,
29
+ "pos_att_type": [
30
+ "p2c",
31
+ "c2p"
32
+ ],
33
+ "position_biased_input": false,
34
+ "position_buckets": 256,
35
+ "relative_attention": true,
36
+ "share_att_key": true,
37
+ "torch_dtype": "float32",
38
+ "transformers_version": "4.45.1",
39
+ "type_vocab_size": 0,
40
+ "vocab_size": 128100
41
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5b7123eaa1dd5d6fe67bd63d00506646ff0a621436c9984fde716693f6951353
3
+ size 737716196
special_tokens_map.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "[CLS]",
3
+ "cls_token": "[CLS]",
4
+ "eos_token": "[SEP]",
5
+ "mask_token": "[MASK]",
6
+ "pad_token": "[PAD]",
7
+ "sep_token": "[SEP]",
8
+ "unk_token": {
9
+ "content": "[UNK]",
10
+ "lstrip": false,
11
+ "normalized": true,
12
+ "rstrip": false,
13
+ "single_word": false
14
+ }
15
+ }
spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c679fbf93643d19aab7ee10c0b99e460bdbc02fedf34b92b05af343b4af586fd
3
+ size 2464616
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "[CLS]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "[SEP]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "[UNK]",
29
+ "lstrip": false,
30
+ "normalized": true,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "128000": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "bos_token": "[CLS]",
45
+ "clean_up_tokenization_spaces": false,
46
+ "cls_token": "[CLS]",
47
+ "do_lower_case": false,
48
+ "eos_token": "[SEP]",
49
+ "mask_token": "[MASK]",
50
+ "model_max_length": 1000000000000000019884624838656,
51
+ "pad_token": "[PAD]",
52
+ "sep_token": "[SEP]",
53
+ "sp_model_kwargs": {},
54
+ "split_by_punct": false,
55
+ "tokenizer_class": "DebertaV2Tokenizer",
56
+ "unk_token": "[UNK]",
57
+ "vocab_type": "spm"
58
+ }