|
|
--- |
|
|
license: apache-2.0 |
|
|
base_model: bartpho |
|
|
tags: |
|
|
- vietnamese |
|
|
- aspect-based-sentiment-analysis |
|
|
- VLSP-ABSA |
|
|
datasets: |
|
|
- visolex/VLSP2018-ABSA-Restaurant |
|
|
metrics: |
|
|
- accuracy |
|
|
- macro-f1 |
|
|
model-index: |
|
|
- name: bartpho-absa-restaurant |
|
|
results: |
|
|
- task: |
|
|
type: text-classification |
|
|
name: Aspect-based Sentiment Analysis |
|
|
dataset: |
|
|
name: VLSP2018-ABSA-Restaurant |
|
|
type: VLSP-ABSA |
|
|
metrics: |
|
|
- type: accuracy |
|
|
value: 0.8336 |
|
|
- type: macro-f1 |
|
|
value: 0.2228 |
|
|
- type: macro_precision |
|
|
value: 0.2930 |
|
|
- type: macro_recall |
|
|
value: 0.1798 |
|
|
--- |
|
|
|
|
|
# bartpho-absa-restaurant: Aspect-based Sentiment Analysis for Vietnamese Reviews |
|
|
|
|
|
This model is a fine-tuned version of [bartpho](https://huggingface.co/bartpho) |
|
|
on the **VLSP2018-ABSA-Restaurant** dataset for aspect-based sentiment analysis in Vietnamese reviews. |
|
|
|
|
|
## Model Details |
|
|
|
|
|
* **Base Model**: bartpho |
|
|
* **Description**: BartPho for Vietnamese ABSA |
|
|
* **Dataset**: VLSP2018-ABSA-Restaurant |
|
|
* **Fine-tuning Framework**: HuggingFace Transformers |
|
|
* **Task**: Aspect-based Sentiment Classification (3 classes) |
|
|
|
|
|
### Hyperparameters |
|
|
|
|
|
* Batch size: `32` |
|
|
* Learning rate: `3e-5` |
|
|
* Epochs: `100` |
|
|
* Max sequence length: `256` |
|
|
* Weight decay: `0.01` |
|
|
* Warmup steps: `500` |
|
|
* Optimizer: AdamW |
|
|
|
|
|
## Dataset |
|
|
|
|
|
Model was trained on **VLSP2018 ABSA Restaurant dataset** for aspect-based sentiment analysis. |
|
|
|
|
|
### Sentiment Labels: |
|
|
|
|
|
* **0 - Negative** (Tiêu cực): Negative opinions |
|
|
* **1 - Neutral** (Trung lập): Neutral, objective opinions |
|
|
* **2 - Positive** (Tích cực): Positive opinions |
|
|
|
|
|
### Aspect Categories: |
|
|
|
|
|
Model được train để phân tích sentiment cho các aspects sau: |
|
|
|
|
|
- **AMBIENCE#GENERAL** |
|
|
- **DRINKS#PRICES** |
|
|
- **DRINKS#QUALITY** |
|
|
- **DRINKS#STYLE&OPTIONS** |
|
|
- **FOOD#PRICES** |
|
|
- **FOOD#QUALITY** |
|
|
- **FOOD#STYLE&OPTIONS** |
|
|
- **LOCATION#GENERAL** |
|
|
- **RESTAURANT#GENERAL** |
|
|
- **RESTAURANT#MISCELLANEOUS** |
|
|
- **RESTAURANT#PRICES** |
|
|
- **SERVICE#GENERAL** |
|
|
|
|
|
## Evaluation Results |
|
|
|
|
|
The model was evaluated on test set with the following metrics: |
|
|
|
|
|
* **Accuracy**: `0.8336` |
|
|
* **Macro-F1**: `0.2228` |
|
|
* **Weighted-F1**: `0.4893` |
|
|
* **Macro-Precision**: `0.2930` |
|
|
* **Macro-Recall**: `0.1798` |
|
|
|
|
|
## Usage Example |
|
|
|
|
|
```python |
|
|
import torch |
|
|
from transformers import AutoTokenizer, AutoModel |
|
|
|
|
|
# Load model and tokenizer |
|
|
repo = "visolex/bartpho-absa-restaurant" |
|
|
tokenizer = AutoTokenizer.from_pretrained(repo, trust_remote_code=True) |
|
|
model = AutoModel.from_pretrained(repo, trust_remote_code=True) |
|
|
model.eval() |
|
|
|
|
|
# Aspect labels for VLSP2018-ABSA-Restaurant |
|
|
aspect_labels = [ |
|
|
"AMBIENCE#GENERAL", |
|
|
"DRINKS#PRICES", |
|
|
"DRINKS#QUALITY", |
|
|
"DRINKS#STYLE&OPTIONS", |
|
|
"FOOD#PRICES", |
|
|
"FOOD#QUALITY", |
|
|
"FOOD#STYLE&OPTIONS", |
|
|
"LOCATION#GENERAL", |
|
|
"RESTAURANT#GENERAL", |
|
|
"RESTAURANT#MISCELLANEOUS", |
|
|
"RESTAURANT#PRICES", |
|
|
"SERVICE#GENERAL" |
|
|
] |
|
|
|
|
|
# Sentiment labels |
|
|
sentiment_labels = ["POSITIVE", "NEGATIVE", "NEUTRAL"] |
|
|
|
|
|
# Example review text |
|
|
text = "Nhà hàng có không gian đẹp, đồ ăn ngon nhưng giá hơi đắt." |
|
|
|
|
|
# Tokenize |
|
|
inputs = tokenizer( |
|
|
text, |
|
|
return_tensors="pt", |
|
|
padding=True, |
|
|
truncation=True, |
|
|
max_length=256 |
|
|
) |
|
|
inputs.pop("token_type_ids", None) |
|
|
|
|
|
# Predict |
|
|
with torch.no_grad(): |
|
|
outputs = model(**inputs) |
|
|
|
|
|
# Get logits: shape [1, num_aspects, num_sentiments + 1] |
|
|
logits = outputs.logits.squeeze(0) # [num_aspects, num_sentiments + 1] |
|
|
probs = torch.softmax(logits, dim=-1) |
|
|
|
|
|
# Predict for each aspect |
|
|
none_id = probs.size(-1) - 1 # Index of "none" class |
|
|
results = [] |
|
|
|
|
|
for i, aspect in enumerate(aspect_labels): |
|
|
prob_i = probs[i] |
|
|
pred_id = int(prob_i.argmax().item()) |
|
|
|
|
|
if pred_id != none_id and pred_id < len(sentiment_labels): |
|
|
score = prob_i[pred_id].item() |
|
|
if score >= 0.5: # threshold |
|
|
results.append((aspect, sentiment_labels[pred_id].lower())) |
|
|
|
|
|
print(f"Text: {text}") |
|
|
print(f"Predicted aspects: {results}") |
|
|
# Output example: [('aspects', 'positive'), ('aspects', 'positive'), ('aspects', 'negative')] |
|
|
``` |
|
|
|
|
|
## Citation |
|
|
|
|
|
If you use this model, please cite: |
|
|
|
|
|
```bibtex |
|
|
@misc{visolex_absa_bartpho_absa_restaurant, |
|
|
title={BartPho for Vietnamese ABSA for Vietnamese Aspect-based Sentiment Analysis}, |
|
|
author={ViSoLex Team}, |
|
|
year={2025}, |
|
|
url={https://huggingface.co/visolex/bartpho-absa-restaurant} |
|
|
} |
|
|
``` |
|
|
|
|
|
## License |
|
|
|
|
|
This model is released under the Apache-2.0 license. |
|
|
|
|
|
## Acknowledgments |
|
|
|
|
|
* Base model: [bartpho](https://huggingface.co/bartpho) |
|
|
* Dataset: VLSP2018-ABSA-Restaurant |
|
|
* ViSoLex Toolkit |
|
|
|
|
|
--- |
|
|
|