AnnyNguyen commited on
Commit
65896fc
·
verified ·
1 Parent(s): 2d22f7b

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +186 -0
README.md ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: roberta-base-gru
4
+ tags:
5
+ - vietnamese
6
+ - aspect-based-sentiment-analysis
7
+ - VLSP-ABSA
8
+ datasets:
9
+ - visolex/VLSP2018-ABSA-Restaurant
10
+ metrics:
11
+ - accuracy
12
+ - macro-f1
13
+ model-index:
14
+ - name: roberta-gru-absa-restaurant
15
+ results:
16
+ - task:
17
+ type: text-classification
18
+ name: Aspect-based Sentiment Analysis
19
+ dataset:
20
+ name: VLSP2018-ABSA-Restaurant
21
+ type: VLSP-ABSA
22
+ metrics:
23
+ - type: accuracy
24
+ value: 0.8504
25
+ - type: macro-f1
26
+ value: 0.4915
27
+ - type: macro_precision
28
+ value: 0.6774
29
+ - type: macro_recall
30
+ value: 0.4149
31
+ ---
32
+
33
+ # roberta-gru-absa-restaurant: Aspect-based Sentiment Analysis for Vietnamese Reviews
34
+
35
+ This model is a fine-tuned version of [roberta-base-gru](https://huggingface.co/roberta-base-gru)
36
+ on the **VLSP2018-ABSA-Restaurant** dataset for aspect-based sentiment analysis in Vietnamese reviews.
37
+
38
+ ## Model Details
39
+
40
+ * **Base Model**: roberta-base-gru
41
+ * **Description**: RoBERTa-GRU hybrid model fine-tuned
42
+ * **Dataset**: VLSP2018-ABSA-Restaurant
43
+ * **Fine-tuning Framework**: HuggingFace Transformers
44
+ * **Task**: Aspect-based Sentiment Classification (3 classes)
45
+
46
+ ### Hyperparameters
47
+
48
+ * Batch size: `32`
49
+ * Learning rate: `3e-5`
50
+ * Epochs: `100`
51
+ * Max sequence length: `256`
52
+ * Weight decay: `0.01`
53
+ * Warmup steps: `500`
54
+ * Optimizer: AdamW
55
+
56
+ ## Dataset
57
+
58
+ Model was trained on **VLSP2018 ABSA Restaurant dataset** for aspect-based sentiment analysis.
59
+
60
+ ### Sentiment Labels:
61
+
62
+ * **0 - Negative** (Tiêu cực): Negative opinions
63
+ * **1 - Neutral** (Trung lập): Neutral, objective opinions
64
+ * **2 - Positive** (Tích cực): Positive opinions
65
+
66
+ ### Aspect Categories:
67
+
68
+ Model được train để phân tích sentiment cho các aspects sau:
69
+
70
+ - **AMBIENCE#GENERAL**
71
+ - **DRINKS#PRICES**
72
+ - **DRINKS#QUALITY**
73
+ - **DRINKS#STYLE&OPTIONS**
74
+ - **FOOD#PRICES**
75
+ - **FOOD#QUALITY**
76
+ - **FOOD#STYLE&OPTIONS**
77
+ - **LOCATION#GENERAL**
78
+ - **RESTAURANT#GENERAL**
79
+ - **RESTAURANT#MISCELLANEOUS**
80
+ - **RESTAURANT#PRICES**
81
+ - **SERVICE#GENERAL**
82
+
83
+ ## Evaluation Results
84
+
85
+ The model was evaluated on test set with the following metrics:
86
+
87
+ * **Accuracy**: `0.8504`
88
+ * **Macro-F1**: `0.4915`
89
+ * **Weighted-F1**: `0.7004`
90
+ * **Macro-Precision**: `0.6774`
91
+ * **Macro-Recall**: `0.4149`
92
+
93
+ ## Usage Example
94
+
95
+ ```python
96
+ import torch
97
+ from transformers import AutoTokenizer, AutoModel
98
+
99
+ # Load model and tokenizer
100
+ repo = "visolex/roberta-gru-absa-restaurant"
101
+ tokenizer = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
102
+ model = AutoModel.from_pretrained(repo, trust_remote_code=True)
103
+ model.eval()
104
+
105
+ # Aspect labels for VLSP2018-ABSA-Restaurant
106
+ aspect_labels = [
107
+ "AMBIENCE#GENERAL",
108
+ "DRINKS#PRICES",
109
+ "DRINKS#QUALITY",
110
+ "DRINKS#STYLE&OPTIONS",
111
+ "FOOD#PRICES",
112
+ "FOOD#QUALITY",
113
+ "FOOD#STYLE&OPTIONS",
114
+ "LOCATION#GENERAL",
115
+ "RESTAURANT#GENERAL",
116
+ "RESTAURANT#MISCELLANEOUS",
117
+ "RESTAURANT#PRICES",
118
+ "SERVICE#GENERAL"
119
+ ]
120
+
121
+ # Sentiment labels
122
+ sentiment_labels = ["POSITIVE", "NEGATIVE", "NEUTRAL"]
123
+
124
+ # Example review text
125
+ text = "Nhà hàng có không gian đẹp, đồ ăn ngon nhưng giá hơi đắt."
126
+
127
+ # Tokenize
128
+ inputs = tokenizer(
129
+ text,
130
+ return_tensors="pt",
131
+ padding=True,
132
+ truncation=True,
133
+ max_length=256
134
+ )
135
+ inputs.pop("token_type_ids", None)
136
+
137
+ # Predict
138
+ with torch.no_grad():
139
+ outputs = model(**inputs)
140
+
141
+ # Get logits: shape [1, num_aspects, num_sentiments + 1]
142
+ logits = outputs.logits.squeeze(0) # [num_aspects, num_sentiments + 1]
143
+ probs = torch.softmax(logits, dim=-1)
144
+
145
+ # Predict for each aspect
146
+ none_id = probs.size(-1) - 1 # Index of "none" class
147
+ results = []
148
+
149
+ for i, aspect in enumerate(aspect_labels):
150
+ prob_i = probs[i]
151
+ pred_id = int(prob_i.argmax().item())
152
+
153
+ if pred_id != none_id and pred_id < len(sentiment_labels):
154
+ score = prob_i[pred_id].item()
155
+ if score >= 0.5: # threshold
156
+ results.append((aspect, sentiment_labels[pred_id].lower()))
157
+
158
+ print(f"Text: {text}")
159
+ print(f"Predicted aspects: {results}")
160
+ # Output example: [('aspects', 'positive'), ('aspects', 'positive'), ('aspects', 'negative')]
161
+ ```
162
+
163
+ ## Citation
164
+
165
+ If you use this model, please cite:
166
+
167
+ ```bibtex
168
+ @misc{visolex_absa_roberta_gru_absa_restaurant,
169
+ title={RoBERTa-GRU hybrid model fine-tuned for Vietnamese Aspect-based Sentiment Analysis},
170
+ author={ViSoLex Team},
171
+ year={2025},
172
+ url={https://huggingface.co/visolex/roberta-gru-absa-restaurant}
173
+ }
174
+ ```
175
+
176
+ ## License
177
+
178
+ This model is released under the Apache-2.0 license.
179
+
180
+ ## Acknowledgments
181
+
182
+ * Base model: [roberta-base-gru](https://huggingface.co/roberta-base-gru)
183
+ * Dataset: VLSP2018-ABSA-Restaurant
184
+ * ViSoLex Toolkit
185
+
186
+ ---