Downloads · 30 days
22
9% of all-time downloads
phngahn/phobert-aspect-based-sentiment
phobert-aspect-based-sentiment is a text classification model from phngahn. Use it when you need a label for a piece of text. The card lists the license as mit.
Mô hình phân tích cảm xúc theo khía cạnh (Aspect-Based Sentiment Analysis - ABSA) cho tiếng Việt, được xây dựng dựa trên PhoBERT. Mô hình dự đoán cực tính cảm xúc (tiêu cực / trung lập / tích cực) cho 4 khía cạnh đồng…
Downloads · 30 days
22
9% of all-time downloads
All-time downloads
237
Public
Parameters
135M
2.7 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors540 MB · 99%
From the Hugging Face model README
Mô hình phân tích cảm xúc theo khía cạnh (Aspect-Based Sentiment Analysis - ABSA) cho tiếng Việt, được xây dựng dựa trên PhoBERT. Mô hình dự đoán cực tính cảm xúc (tiêu cực / trung lập / tích cực) cho 4 khía cạnh đồng thời trong một lần forward pass:
Mô hình được thiết kế đặc biệt cho phân tích đánh giá nhà hàng và ẩm thực tiếng Việt.
Mô hình trả về tensor với shape: (batch_size, 4, 3)
Trong đó:
4 tương ứng với số lượng khía cạnh3 tương ứng với số lớp cảm xúc cho mỗi khía cạnhThứ tự các khía cạnh trong output tensor:
["food", "price", "space", "service"]
Sentiment Labels:
| ID | Label | Mô tả |
|---|---|---|
| 0 | negative | Tiêu cực |
| 1 | neutral | Trung lập |
| 2 | positive | Tích cực |
pip install torch transformers
⚠️ Important: Mô hình này sử dụng custom architecture, do đó bạn phải enable
trust_remote_code=Truekhi load.
import torch
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained(
"phngahn/phobert-aspect-based-sentiment"
)
model = AutoModel.from_pretrained(
"phngahn/phobert-aspect-based-sentiment",
trust_remote_code=True
)
text = "Món ăn ngon nhưng phục vụ chậm và giá hơi cao"
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs)
print(logits.shape) # torch.Size([1, 4, 3])
aspect_names = ["food", "price", "space", "service"]
sentiment_labels = ["negative", "neutral", "positive"]
def predict(text):
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs)[0]
preds = logits.argmax(dim=1)
return {
aspect: sentiment_labels[p.item()]
for aspect, p in zip(aspect_names, preds)
}
# Example
result = predict("Món ăn ngon nhưng giá cao, phục vụ chậm")
print(result)
Output:
{
"food": "positive",
"price": "negative",
"space": "neutral",
"service": "negative"
}
token_type_idsAutoModel và Trainer của Hugging Face✅ Phân tích đánh giá nhà hàng tiếng Việt
✅ Phân tích cảm xúc theo khía cạnh
✅ Nghiên cứu học thuật và dự án sinh viên
⚠️ Chỉ được huấn luyện trên dữ liệu nhà hàng/ẩm thực
⚠️ Hiệu suất có thể giảm trên các domain khác
⚠️ Mô hình luôn dự đoán cả 4 khía cạnh (giả định tất cả khía cạnh đều xuất hiện)
Nếu bạn sử dụng mô hình này trong công trình học thuật, vui lòng trích dẫn PhoBERT:
@article{phobert,
title = {{PhoBERT: Pre-trained language models for Vietnamese}},
author = {Dat Quoc Nguyen and Anh Tuan Nguyen},
journal = {Findings of EMNLP},
year = {2020}
}
Mô hình này tuân theo license của base model vinai/phobert-base.