Downloads · 30 days
0
lovingTK5/phobert-sentiment-vn-finance
phobert-sentiment-vn-finance is a machine learning model from lovingTK5. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
--- license: apache-2.0 language: - vi tags: - text-classification - sentiment-analysis - vietnamese - finance - stock-market - phobert - lora - peft basemodel: vinai/phobert-base-v2 pipelinetag: text-classification l…
Downloads · 30 days
0
Access
Public
Updated Apr 29, 2026
Repo size
3.6 MB
Likes
0
Public
Click a slice to open those files.
.safetensors3.6 MB · 63%
From the Hugging Face model README
license: apache-2.0 language:
A LoRA-adapted PhoBERT-base-v2 fine-tuned for 3-class sentiment classification on Vietnamese financial news (stock market, listed companies, macro news).
This is a proof-of-concept (v0) trained on a tiny hand-labeled dataset of 60 sentences as part of a 14-day learning sprint. A v1 with a 500-sentence augmented dataset is planned.
🇻🇳 Đây là phiên bản v0 (warm-up), fine-tune PhoBERT-base-v2 bằng LoRA trên 60 câu tin tài chính tiếng Việt tự gán nhãn để học flow PEFT. Phiên bản v1 với 500 câu augment qua LLM sẽ được release sau.
| ID | Label | Mô tả |
|---|---|---|
| 0 | Negative (tiêu cực) | Tin xấu: giảm điểm, lỗ, bán tháo, nợ xấu, hủy niêm yết, ... |
| 1 | Neutral (trung lập) | Thông báo trung tính: lịch ĐHCĐ, BCTC công bố, tỷ giá ổn định, ... |
| 2 | Positive (tích cực) | Tin tốt: lợi nhuận tăng, ký hợp đồng lớn, cổ tức, khối ngoại mua ròng, ... |
from peft import PeftModel
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
REPO_ID = "kienthinh/phobert-sentiment-vn-finance-v0"
base = AutoModelForSequenceClassification.from_pretrained(
"vinai/phobert-base-v2", num_labels=3
)
model = PeftModel.from_pretrained(base, REPO_ID)
tokenizer = AutoTokenizer.from_pretrained(REPO_ID)
clf = pipeline("text-classification", model=model, tokenizer=tokenizer)
samples = [
"ACB công bố lợi nhuận quý 3 tăng mạnh, vượt kỳ vọng thị trường.",
"Cổ phiếu HPG bị bán tháo do tin tiêu cực ngành thép.",
"VN-Index đóng cửa ở mức 1.250 điểm.",
]
for r, t in zip(clf(samples), samples):
print(f"{r['label']:10s} ({r['score']:.2f}) ← {t}")
Output (mapping: LABEL_0 = Negative, LABEL_1 = Neutral, LABEL_2 = Positive):
LABEL_2 (0.53) ← ACB công bố lợi nhuận quý 3 tăng mạnh, vượt kỳ vọng thị trường.
LABEL_0 (0.79) ← Cổ phiếu HPG bị bán tháo do tin tiêu cực ngành thép.
LABEL_0 (0.40) ← VN-Index đóng cửa ở mức 1.250 điểm.
Training Data
- Source: 60 sentences hand-labeled by the author covering Vietnamese stock market topics: listed companies (ACB, VCB, FPT, HPG, VNM, MBB, MSN, NVL, MWG, GAS,
PNJ, ...), macro events, and market index movements.
- Class balance: 20 Positive / 20 Negative / 20 Neutral (perfectly balanced before stratified split).
- Split: 70% train / 15% validation / 15% test, stratified.
- Domain: Vietnamese financial news headlines (informal, short-form).
⚠️ Limitation: 60 sentences is far below production scale. Expect overfitting on phrases that appear in training and weak generalization to unseen patterns.
Training Procedure
Base Model
- vinai/phobert-base-v2 (135M parameters)
LoRA Configuration
┌──────────────────┬──────────────────────────┐
│ Param │ Value │
├──────────────────┼──────────────────────────┤
│ r (rank) │ 8 │
├──────────────────┼──────────────────────────┤
│ lora_alpha │ 16 │
├──────────────────┼──────────────────────────┤
│ lora_dropout │ 0.1 │
├──────────────────┼──────────────────────────┤
│ target_modules │ ["query", "value"] │
├──────────────────┼──────────────────────────┤
│ Trainable params │ 887,811 (0.65% of total) │
└──────────────────┴──────────────────────────┘
Hyperparameters
┌─────────────────────────┬────────────────────┐
│ Param │ Value │
├─────────────────────────┼────────────────────┤
│ Epochs │ 20 │
├─────────────────────────┼────────────────────┤
│ Batch size (train/eval) │ 8 / 8 │
├─────────────────────────┼────────────────────┤
│ Learning rate │ 5e-4 │
├─────────────────────────┼────────────────────┤
│ Warmup ratio │ 0.1 │
├─────────────────────────┼────────────────────┤
│ Weight decay │ 0.01 │
├─────────────────────────┼────────────────────┤
│ Precision │ bf16 │
├─────────────────────────┼────────────────────┤
│ Optimizer │ AdamW (HF default) │
├─────────────────────────┼────────────────────┤
│ Best model selector │ F1 (weighted) │
└─────────────────────────┴────────────────────┘
Compute
- Hardware: NVIDIA A100 (Google Colab Pro)
- Training time: < 1 minute (tiny dataset)
- Carbon footprint: negligible
Evaluation
Evaluated on the held-out validation split (9 sentences, stratified across 3 classes).
┌──────────────────────┬────────┐
│ Metric │ Score │
├──────────────────────┼────────┤
│ Accuracy │ 0.8889 │
├──────────────────────┼────────┤
│ Precision (weighted) │ 0.9167 │
├──────────────────────┼────────┤
│ Recall (weighted) │ 0.8889 │
├──────────────────────┼────────┤
│ F1 (weighted) │ 0.8857 │
├──────────────────────┼────────┤
│ Eval loss │ 0.6396 │
└──────────────────────┴────────┘
Sample Inference (5 unseen sentences)
┌─────────────────────────────────────────────────────────────────────┬───────────┬────────────┬────────────────────────┐
│ Sentence │ Predicted │ Confidence │ Correct? │
├─────────────────────────────────────────────────────────────────────┼───────────┼────────────┼────────────────────────┤
│ ACB công bố lợi nhuận quý 3 tăng mạnh, vượt kỳ vọng thị trường. │ Positive │ 0.53 │ ✅ │
├─────────────────────────────────────────────────────────────────────┼───────────┼────────────┼────────────────────────┤
│ Thị trường chứng khoán giảm điểm phiên thứ ba liên tiếp. │ Negative │ 0.79 │ ✅ │
├─────────────────────────────────────────────────────────────────────┼───────────┼────────────┼────────────────────────┤
│ VN-Index đóng cửa ở mức 1.250 điểm. │ Negative │ 0.40 │ ❌ (should be Neutral) │
├─────────────────────────────────────────────────────────────────────┼───────────┼────────────┼────────────────────────┤
│ Cổ phiếu HPG bị bán tháo do tin tiêu cực ngành thép. │ Negative │ 0.79 │ ✅ │
├─────────────────────────────────────────────────────────────────────┼───────────┼────────────┼────────────────────────┤
│ FPT ký hợp đồng lớn với khách hàng Mỹ, triển vọng dài hạn tích cực. │ Positive │ 0.54 │ ✅ │
└─────────────────────────────────────────────────────────────────────┴───────────┴────────────┴────────────────────────┘
4 / 5 correct. The misclassified neutral example shows confidence 0.40 — close to the random uniform baseline (0.33), indicating model uncertainty. In
production, a confidence threshold (e.g. 0.5) is recommended to flag low-confidence predictions for human review.
Bias, Risks & Limitations
1. Tiny training set (60 examples) — generalization beyond seen lexical patterns is limited. The model may bias toward Negative when encountering generic
"VN-Index ..." phrasing because half of the negative training examples mention indices.
2. No word segmentation — PhoBERT is normally fed VnCoreNLP-segmented text. This v0 uses raw whitespace tokenization, which is suboptimal.
3. Domain narrow — trained only on stock market / listed companies. May fail on other financial sub-domains (banking ops, crypto, real estate financing).
4. Hand-labeled by single annotator — labels reflect one person's judgment; no inter-annotator agreement check.
5. Not investment advice — outputs must NOT be used as a basis for trading decisions.
Recommended Use
- ✅ Educational / research demos of LoRA + PhoBERT pipeline
- ✅ Starting point for further fine-tuning with larger datasets
- ❌ Production financial sentiment scoring
- ❌ Automated trading signals
Roadmap
- v1 (planned): Train on 500 LLM-augmented Vietnamese financial sentences with VnCoreNLP word segmentation. Target F1 ≥ 0.85 on a separate held-out test set.
- v2 (planned): Multi-aspect sentiment (per-ticker mention) + integration into a real-time news pipeline.
Citation
If you use this model, please cite the base PhoBERT paper:
@inproceedings{phobert,
title = {{PhoBERT: Pre-trained language models for Vietnamese}},
author = {Dat Quoc Nguyen and Anh Tuan Nguyen},
booktitle = {Findings of EMNLP},
year = {2020}
}
Author
- Trained by: Kien — Applied Mathematics @ HCMUS
- Context: Day 2 of a 14-day sprint preparing for an AI Engineer application at ACBS (Asia Commercial Bank Securities).
License
Apache 2.0 (inherits from PhoBERT-base-v2).
---