gauneg commited on
Commit
0791a75
1 Parent(s): 724e84b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +121 -32
README.md CHANGED
@@ -44,24 +44,67 @@ model = PeftModel.from_pretrained(base_model, 'gauneg/roberta-large-absa-ate-sen
44
  ```
45
 
46
  This model can be utilized in the following two methods:
47
- 1. Making token level inference
48
- 2. Using pipelines for end to end inference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
  ## Making token level inference
51
 
52
  ```python
53
  # after loading base model and the adapter as shown in the previous snippet
54
 
 
55
  text_input = "Been here a few times and food has always been good but service really suffers when it gets crowded."
56
- tok_inputs = tokenizer(text_input, return_tensors="pt").to(device)
 
57
 
58
  y_pred = model(**tok_inputs) # predicting the logits
59
 
60
- y_pred_fin = y_pred.logits.argmax(dim=-1)[0] # selecting the most favoured labels for each token from the logits
 
 
 
 
 
61
 
62
- decoded_pred = [id2labels[logx.item()] for logx in y_pred_fin]
63
 
64
- tok_levl_pred = list(zip(tokenizer.convert_ids_to_tokens(tok_inputs['input_ids'][0]), decoded_pred))[1:-1]
 
 
 
65
  ```
66
 
67
  RESULTS in `tok_levl_pred` variable:
@@ -89,32 +132,78 @@ RESULTS in `tok_levl_pred` variable:
89
  ('.', 'O')]
90
  ```
91
 
92
- ## Using end-to-end token classification pipeline
93
-
94
- ```python
95
- # after loading base model and the adapter as shown in the previous snippet
96
- from transformers import pipeline
97
 
98
- ate_senti_pipeline = pipeline(task='ner',
99
- aggregation_strategy='simple',
100
- model=model,
101
- tokenizer=tokenizer)
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
- text_input = "Been here a few times and food has always been good but service really suffers when it gets crowded."
105
- ate_senti_pipeline(text_input)
106
-
107
- ```
108
- OUTPUT
109
- ```bash
110
- [{'entity_group': 'pos',
111
- 'score': 0.92310727,
112
- 'word': ' food',
113
- 'start': 26,
114
- 'end': 30},
115
- {'entity_group': 'neg',
116
- 'score': 0.90695626,
117
- 'word': ' service',
118
- 'start': 56,
119
- 'end': 63}]
120
- ```
 
44
  ```
45
 
46
  This model can be utilized in the following two methods:
47
+
48
+ 1. Using pipelines for end to end inference
49
+ 2. Making token level inference
50
+
51
+
52
+ ## Using end-to-end token classification pipeline
53
+
54
+ ```python
55
+ # after loading base model and the adapter as shown in the previous snippet
56
+ from transformers import pipeline
57
+
58
+ ate_senti_pipeline = pipeline(task='ner',
59
+ aggregation_strategy='simple',
60
+ model=model,
61
+ tokenizer=tokenizer)
62
+
63
+
64
+ text_input = "Been here a few times and food has always been good but service really suffers when it gets crowded."
65
+ ate_senti_pipeline(text_input)
66
+
67
+ ```
68
+ OUTPUT
69
+ ```bash
70
+ [{'entity_group': 'pos',
71
+ 'score': 0.92310727,
72
+ 'word': ' food',
73
+ 'start': 26,
74
+ 'end': 30},
75
+ {'entity_group': 'neg',
76
+ 'score': 0.90695626,
77
+ 'word': ' service',
78
+ 'start': 56,
79
+ 'end': 63}]
80
+ ```
81
+
82
+ # OR
83
 
84
  ## Making token level inference
85
 
86
  ```python
87
  # after loading base model and the adapter as shown in the previous snippet
88
 
89
+ # making one prediction at a time (should be padded/batched and truncated for efficiency)
90
  text_input = "Been here a few times and food has always been good but service really suffers when it gets crowded."
91
+ tok_inputs = tokenizer(text_input, return_tensors="pt")
92
+
93
 
94
  y_pred = model(**tok_inputs) # predicting the logits
95
 
96
+ # since first and the last tokens are excluded (<s> and </s>) labels predicted against them
97
+ # should be removed before decoding predicted labels
98
+ y_pred_fin = y_pred.logits.argmax(dim=-1)[0][1:-1] # selecting the most favoured labels for each token from the logits
99
+
100
+
101
+ decoded_pred = [id2lab[logx.item()] for logx in y_pred_fin]
102
 
 
103
 
104
+ ## displaying the input tokens with predictions and skipping <s> and </s> tokens at the beginning and the end respectively
105
+ decoded_toks = tok_inputs['input_ids'][0][1:-1]
106
+ tok_levl_pred = list(zip(tokenizer.convert_ids_to_tokens(decoded_toks), decoded_pred))
107
+
108
  ```
109
 
110
  RESULTS in `tok_levl_pred` variable:
 
132
  ('.', 'O')]
133
  ```
134
 
 
 
 
 
 
135
 
 
 
 
 
136
 
137
+ # Evaluation on Benchmark Test Datasets
138
+
139
+ The first evaluation is for token-extraction task without considering the polarity of the extracted tokens. The tokens expected to be extracted are aspect term tokens
140
+ on which the sentiments have been expressed. (scores are expressed as micro-averages of B-I-O labels)
141
+
142
+ # ATE (Aspect Term Extraction Only)
143
+ | Test Dataset | Base Model | Fine-tuned Model | Precision | Recall | F1 Score |
144
+ | ------------ | ---------- | ---------------- | --------- | ------ | -------- |
145
+ |hotel reviews (SemEval 2015)|microsoft/deberta-v3-base|[gauneg/deberta-v3-base-absa-ate-sentiment](https://huggingface.co/gauneg/deberta-v3-base-absa-ate-sentiment)|71.16|73.92|71.6|
146
+ |hotel reviews (SemEval 2015)|FacebookAI/roberta-base|[gauneg/roberta-base-absa-ate-sentiment](https://huggingface.co/gauneg/roberta-base-absa-ate-sentiment)|70.92|72.28|71.07|
147
+ |hotel reviews (SemEval 2015)|microsoft/deberta-v3-large|[gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter)|64.05|79.69|70.0|
148
+ |hotel reviews (SemEval 2015)|FacebookAI/roberta-large|(this) [gauneg/roberta-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/roberta-large-absa-ate-sentiment-lora-adapter)|66.29|72.78|68.92|
149
+ | ------------ | ---------- | ---------------- | --------- | ------ | -------- |
150
+ |laptop reviews (SemEval 2014)|microsoft/deberta-v3-large|[gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter)|70.58|61.52|64.21|
151
+ |laptop reviews (SemEval 2014)|FacebookAI/roberta-large|(this) [gauneg/roberta-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/roberta-large-absa-ate-sentiment-lora-adapter)|66.38|50.62|54.31|
152
+ |laptop reviews (SemEval 2014)|microsoft/deberta-v3-base|[gauneg/deberta-v3-base-absa-ate-sentiment](https://huggingface.co/gauneg/deberta-v3-base-absa-ate-sentiment)|70.82|48.97|52.08|
153
+ |laptop reviews (SemEval 2014)|FacebookAI/roberta-base|[gauneg/roberta-base-absa-ate-sentiment](https://huggingface.co/gauneg/roberta-base-absa-ate-sentiment)|73.61|46.38|49.87|
154
+ | ------------ | ---------- | ---------------- | --------- | ------ | -------- |
155
+ |MAMS-ATE (2019)|microsoft/deberta-v3-base|[gauneg/deberta-v3-base-absa-ate-sentiment](https://huggingface.co/gauneg/deberta-v3-base-absa-ate-sentiment)|81.07|79.66|80.35|
156
+ |MAMS-ATE (2019)|FacebookAI/roberta-base|[gauneg/roberta-base-absa-ate-sentiment](https://huggingface.co/gauneg/roberta-base-absa-ate-sentiment)|79.91|78.95|79.39|
157
+ |MAMS-ATE (2019)|microsoft/deberta-v3-large|[gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter)|74.46|84.5|78.75|
158
+ |MAMS-ATE (2019)|FacebookAI/roberta-large|(this)[gauneg/roberta-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/roberta-large-absa-ate-sentiment-lora-adapter)|77.8|79.81|78.75|
159
+ | ------------ | ---------- | ---------------- | --------- | ------ | -------- |
160
+ |restaurant reviews (SemEval 2014)|microsoft/deberta-v3-large|[gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter)|88.59|87.0|87.45|
161
+ |restaurant reviews (SemEval 2014)|FacebookAI/roberta-large|(this) [gauneg/roberta-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/roberta-large-absa-ate-sentiment-lora-adapter)|92.26|82.95|86.57|
162
+ |restaurant reviews (SemEval 2014)|FacebookAI/roberta-base|[gauneg/roberta-base-absa-ate-sentiment](https://huggingface.co/gauneg/roberta-base-absa-ate-sentiment)|93.07|81.95|86.32|
163
+ |restaurant reviews (SemEval 2014)|microsoft/deberta-v3-base|[gauneg/deberta-v3-base-absa-ate-sentiment](https://huggingface.co/gauneg/deberta-v3-base-absa-ate-sentiment)|92.94|81.71|86.01|
164
+ | ------------ | ---------- | ---------------- | --------- | ------ | -------- |
165
+ |restaurant reviews (SemEval 2015)|microsoft/deberta-v3-base|[gauneg/deberta-v3-base-absa-ate-sentiment](https://huggingface.co/gauneg/deberta-v3-base-absa-ate-sentiment)|72.91|75.4|72.74|
166
+ |restaurant reviews (SemEval 2015)|FacebookAI/roberta-large|(this) [gauneg/roberta-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/roberta-large-absa-ate-sentiment-lora-adapter)|70.54|77.48|72.63|
167
+ |restaurant reviews (SemEval 2015)|microsoft/deberta-v3-large|[gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter)|68.32|79.84|72.28|
168
+ |restaurant reviews (SemEval 2015)|FacebookAI/roberta-base|[gauneg/roberta-base-absa-ate-sentiment](https://huggingface.co/gauneg/roberta-base-absa-ate-sentiment)|71.94|74.75|71.84|
169
+ | ------------ | ---------- | ---------------- | --------- | ------ | -------- |
170
+ |restaurant reviews (SemEval 2016)|FacebookAI/roberta-large|(this) [gauneg/roberta-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/roberta-large-absa-ate-sentiment-lora-adapter)|70.22|75.83|71.84|
171
+ |restaurant reviews (SemEval 2016)|microsoft/deberta-v3-base|[gauneg/deberta-v3-base-absa-ate-sentiment](https://huggingface.co/gauneg/deberta-v3-base-absa-ate-sentiment)|71.54|73.38|71.2|
172
+ |restaurant reviews (SemEval 2016)|FacebookAI/roberta-base|[gauneg/roberta-base-absa-ate-sentiment](https://huggingface.co/gauneg/roberta-base-absa-ate-sentiment)|71.35|72.78|70.85|
173
+ |restaurant reviews (SemEval 2016)|microsoft/deberta-v3-large|[gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter)|66.68|77.97|70.79|
174
+
175
+ # Aspect Sentiment Evaluation
176
+ This evaluation considers token-extraction task with polarity of the extracted tokens. The tokens expected to be extracted are aspect term tokens
177
+ on which the sentiments have been expressed along with the polarity of the sentiments. (scores are expressed as macro-averages)
178
+ | Test Dataset | Base Model | Fine-tuned Model | Precision | Recall | F1 Score |
179
+ | ------------ | ---------- | ---------------- | --------- | ------ | -------- |
180
+ |hotel reviews (SemEval 2015)|microsoft/deberta-v3-large|[gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter)|51.92|65.55|54.94|
181
+ |hotel reviews (SemEval 2015)|FacebookAI/roberta-base|[gauneg/roberta-base-absa-ate-sentiment](https://huggingface.co/gauneg/roberta-base-absa-ate-sentiment)|54.62|53.65|54.08|
182
+ |hotel reviews (SemEval 2015)|microsoft/deberta-v3-base|[gauneg/deberta-v3-base-absa-ate-sentiment](https://huggingface.co/gauneg/deberta-v3-base-absa-ate-sentiment)|55.43|56.53|54.03|
183
+ |hotel reviews (SemEval 2015)|FacebookAI/roberta-large|(this) [gauneg/roberta-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/roberta-large-absa-ate-sentiment-lora-adapter)|52.88|55.19|53.85|
184
+ | ------------ | ---------- | ---------------- | --------- | ------ | -------- |
185
+ |laptop reviews (SemEval 2014)|microsoft/deberta-v3-large|[gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter)|44.25|41.55|42.81|
186
+ |laptop reviews (SemEval 2014)|microsoft/deberta-v3-base|[gauneg/deberta-v3-base-absa-ate-sentiment](https://huggingface.co/gauneg/deberta-v3-base-absa-ate-sentiment)|46.15|33.23|37.09|
187
+ |laptop reviews (SemEval 2014)|FacebookAI/roberta-large|(this) [gauneg/roberta-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/roberta-large-absa-ate-sentiment-lora-adapter)|41.7|34.38|36.93|
188
+ |laptop reviews (SemEval 2014)|FacebookAI/roberta-base|[gauneg/roberta-base-absa-ate-sentiment](https://huggingface.co/gauneg/roberta-base-absa-ate-sentiment)|44.98|31.87|35.67|
189
+ | ------------ | ---------- | ---------------- | --------- | ------ | -------- |
190
+ |MAMS-ATE (2019)|FacebookAI/roberta-base|(this) [gauneg/roberta-base-absa-ate-sentiment](https://huggingface.co/gauneg/roberta-base-absa-ate-sentiment)|72.06|72.98|72.49|
191
+ |MAMS-ATE (2019)|microsoft/deberta-v3-base|[gauneg/deberta-v3-base-absa-ate-sentiment](https://huggingface.co/gauneg/deberta-v3-base-absa-ate-sentiment)|72.97|71.63|72.26|
192
+ |MAMS-ATE (2019)|FacebookAI/roberta-large|(this) [gauneg/roberta-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/roberta-large-absa-ate-sentiment-lora-adapter)|69.34|73.3|71.07|
193
+ |MAMS-ATE (2019)|microsoft/deberta-v3-large|[gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter)|65.74|75.11|69.77|
194
+ | ------------ | ---------- | ---------------- | --------- | ------ | -------- |
195
+ |restaurant reviews (SemEval 2014)|FacebookAI/roberta-large|(this) [gauneg/roberta-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/roberta-large-absa-ate-sentiment-lora-adapter)|61.15|58.46|59.74|
196
+ |restaurant reviews (SemEval 2014)|FacebookAI/roberta-base|[gauneg/roberta-base-absa-ate-sentiment](https://huggingface.co/gauneg/roberta-base-absa-ate-sentiment)|60.13|56.81|58.13|
197
+ |restaurant reviews (SemEval 2014)|microsoft/deberta-v3-large|[gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter)|56.79|59.3|57.93|
198
+ |restaurant reviews (SemEval 2014)|microsoft/deberta-v3-base|[gauneg/deberta-v3-base-absa-ate-sentiment](https://huggingface.co/gauneg/deberta-v3-base-absa-ate-sentiment)|58.99|54.76|56.45|
199
+ | ------------ | ---------- | ---------------- | --------- | ------ | -------- |
200
+ |restaurant reviews (SemEval 2015)|FacebookAI/roberta-large|(this) [gauneg/roberta-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/roberta-large-absa-ate-sentiment-lora-adapter)|53.89|55.7|54.11|
201
+ |restaurant reviews (SemEval 2015)|FacebookAI/roberta-base|[gauneg/roberta-base-absa-ate-sentiment](https://huggingface.co/gauneg/roberta-base-absa-ate-sentiment)|54.36|55.38|53.6|
202
+ |restaurant reviews (SemEval 2015)|microsoft/deberta-v3-large|[gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter)|51.67|56.58|53.29|
203
+ |restaurant reviews (SemEval 2015)|microsoft/deberta-v3-base|[gauneg/deberta-v3-base-absa-ate-sentiment](https://huggingface.co/gauneg/deberta-v3-base-absa-ate-sentiment)|54.55|53.68|53.12|
204
+ | ------------ | ---------- | ---------------- | --------- | ------ | -------- |
205
+ |restaurant reviews (SemEval 2016)|FacebookAI/roberta-large|(this) [gauneg/roberta-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/roberta-large-absa-ate-sentiment-lora-adapter)|53.7|60.49|55.05|
206
+ |restaurant reviews (SemEval 2016)|FacebookAI/roberta-base|[gauneg/roberta-base-absa-ate-sentiment](https://huggingface.co/gauneg/roberta-base-absa-ate-sentiment)|52.31|54.58|52.33|
207
+ |restaurant reviews (SemEval 2016)|microsoft/deberta-v3-base|[gauneg/deberta-v3-base-absa-ate-sentiment](https://huggingface.co/gauneg/deberta-v3-base-absa-ate-sentiment)|52.07|54.58|52.15|
208
+ |restaurant reviews (SemEval 2016)|microsoft/deberta-v3-large|[gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter](https://huggingface.co/gauneg/deberta-v3-large-absa-ate-sentiment-lora-adapter)|49.07|56.5|51.25|
209