Views
No views yet
🇻🇳 Đâ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, ... |
1from peft import PeftModel
2from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
3
4REPO_ID = "kienthinh/phobert-sentiment-vn-finance-v0"
5
6base = AutoModelForSequenceClassification.from_pretrained(
7 "vinai/phobert-base-v2", num_labels=3
8)
9model = PeftModel.from_pretrained(base, REPO_ID)
10tokenizer = AutoTokenizer.from_pretrained(REPO_ID)
11
12clf = pipeline("text-classification", model=model, tokenizer=tokenizer)
13
14samples = [
15 "ACB công bố lợi nhuận quý 3 tăng mạnh, vượt kỳ vọng thị trường.",
16 "Cổ phiếu HPG bị bán tháo do tin tiêu cực ngành thép.",
17 "VN-Index đóng cửa ở mức 1.250 điểm.",
18]
19for r, t in zip(clf(samples), samples):
20 print(f"{r['label']:10s} ({r['score']:.2f}) ← {t}")
21
22Output (mapping: LABEL_0 = Negative, LABEL_1 = Neutral, LABEL_2 = Positive):
23LABEL_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.
24LABEL_0 (0.79) ← Cổ phiếu HPG bị bán tháo do tin tiêu cực ngành thép.
25LABEL_0 (0.40) ← VN-Index đóng cửa ở mức 1.250 điểm.
26
27Training Data
28
29- 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,
30 PNJ, ...), macro events, and market index movements.
31- Class balance: 20 Positive / 20 Negative / 20 Neutral (perfectly balanced before stratified split).
32- Split: 70% train / 15% validation / 15% test, stratified.
33- Domain: Vietnamese financial news headlines (informal, short-form).
34
35⚠️ Limitation: 60 sentences is far below production scale. Expect overfitting on phrases that appear in training and weak generalization to unseen patterns.
36
37Training Procedure
38
39Base Model
40
41- vinai/phobert-base-v2 (135M parameters)
42
43LoRA Configuration
44
45┌──────────────────┬──────────────────────────┐
46│ Param │ Value │
47├──────────────────┼──────────────────────────┤
48│ r (rank) │ 8 │
49├──────────────────┼──────────────────────────┤
50│ lora_alpha │ 16 │
51├──────────────────┼──────────────────────────┤
52│ lora_dropout │ 0.1 │
53├──────────────────┼──────────────────────────┤
54│ target_modules │ ["query", "value"] │
55├──────────────────┼──────────────────────────┤
56│ Trainable params │ 887,811 (0.65% of total) │
57└──────────────────┴──────────────────────────┘
58
59Hyperparameters
60
61┌─────────────────────────┬────────────────────┐
62│ Param │ Value │
63├─────────────────────────┼────────────────────┤
64│ Epochs │ 20 │
65├─────────────────────────┼────────────────────┤
66│ Batch size (train/eval) │ 8 / 8 │
67├─────────────────────────┼────────────────────┤
68│ Learning rate │ 5e-4 │
69├─────────────────────────┼────────────────────┤
70│ Warmup ratio │ 0.1 │
71├─────────────────────────┼────────────────────┤
72│ Weight decay │ 0.01 │
73├─────────────────────────┼────────────────────┤
74│ Precision │ bf16 │
75├─────────────────────────┼────────────────────┤
76│ Optimizer │ AdamW (HF default) │
77├─────────────────────────┼────────────────────┤
78│ Best model selector │ F1 (weighted) │
79└─────────────────────────┴────────────────────┘
80
81Compute
82
83- Hardware: NVIDIA A100 (Google Colab Pro)
84- Training time: < 1 minute (tiny dataset)
85- Carbon footprint: negligible
86
87Evaluation
88
89Evaluated on the held-out validation split (9 sentences, stratified across 3 classes).
90
91┌──────────────────────┬────────┐
92│ Metric │ Score │
93├──────────────────────┼────────┤
94│ Accuracy │ 0.8889 │
95├──────────────────────┼────────┤
96│ Precision (weighted) │ 0.9167 │
97├──────────────────────┼────────┤
98│ Recall (weighted) │ 0.8889 │
99├──────────────────────┼────────┤
100│ F1 (weighted) │ 0.8857 │
101├──────────────────────┼────────┤
102│ Eval loss │ 0.6396 │
103└──────────────────────┴────────┘
104
105Sample Inference (5 unseen sentences)
106
107┌─────────────────────────────────────────────────────────────────────┬───────────┬────────────┬────────────────────────┐
108│ Sentence │ Predicted │ Confidence │ Correct? │
109├─────────────────────────────────────────────────────────────────────┼───────────┼────────────┼────────────────────────┤
110│ 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 │ ✅ │
111├─────────────────────────────────────────────────────────────────────┼───────────┼────────────┼────────────────────────┤
112│ Thị trường chứng khoán giảm điểm phiên thứ ba liên tiếp. │ Negative │ 0.79 │ ✅ │
113├─────────────────────────────────────────────────────────────────────┼───────────┼────────────┼────────────────────────┤
114│ VN-Index đóng cửa ở mức 1.250 điểm. │ Negative │ 0.40 │ ❌ (should be Neutral) │
115├─────────────────────────────────────────────────────────────────────┼───────────┼────────────┼────────────────────────┤
116│ Cổ phiếu HPG bị bán tháo do tin tiêu cực ngành thép. │ Negative │ 0.79 │ ✅ │
117├─────────────────────────────────────────────────────────────────────┼───────────┼────────────┼────────────────────────┤
118│ 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 │ ✅ │
119└─────────────────────────────────────────────────────────────────────┴───────────┴────────────┴────────────────────────┘
120
1214 / 5 correct. The misclassified neutral example shows confidence 0.40 — close to the random uniform baseline (0.33), indicating model uncertainty. In
122production, a confidence threshold (e.g. 0.5) is recommended to flag low-confidence predictions for human review.
123
124Bias, Risks & Limitations
125
1261. Tiny training set (60 examples) — generalization beyond seen lexical patterns is limited. The model may bias toward Negative when encountering generic
127"VN-Index ..." phrasing because half of the negative training examples mention indices.
1282. No word segmentation — PhoBERT is normally fed VnCoreNLP-segmented text. This v0 uses raw whitespace tokenization, which is suboptimal.
1293. Domain narrow — trained only on stock market / listed companies. May fail on other financial sub-domains (banking ops, crypto, real estate financing).
1304. Hand-labeled by single annotator — labels reflect one person's judgment; no inter-annotator agreement check.
1315. Not investment advice — outputs must NOT be used as a basis for trading decisions.
132
133Recommended Use
134
135- ✅ Educational / research demos of LoRA + PhoBERT pipeline
136- ✅ Starting point for further fine-tuning with larger datasets
137- ❌ Production financial sentiment scoring
138- ❌ Automated trading signals
139
140Roadmap
141
142- 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.
143- v2 (planned): Multi-aspect sentiment (per-ticker mention) + integration into a real-time news pipeline.
144
145Citation
146
147If you use this model, please cite the base PhoBERT paper:
148
149@inproceedings{phobert,
150 title = {{PhoBERT: Pre-trained language models for Vietnamese}},
151 author = {Dat Quoc Nguyen and Anh Tuan Nguyen},
152 booktitle = {Findings of EMNLP},
153 year = {2020}
154}
155
156Author
157
158- Trained by: Kien — Applied Mathematics @ HCMUS
159- Context: Day 2 of a 14-day sprint preparing for an AI Engineer application at ACBS (Asia Commercial Bank Securities).
160
161License
162
163Apache 2.0 (inherits from PhoBERT-base-v2).
164
165---