Skip to content
Ho Dinh Tri
Work

Applied AI

ViGuard: Detecting Vietnamese Scam Messages

A team project that sorts Vietnamese SMS into safe, advertising and scam. I fine-tuned PhoBERT and ViSoBERT and tested them against TF-IDF baselines on leakage-safe splits.

At a glance

test macro-F1 (PhoBERT)
~0.96
provisional: labels are machine-proposed, not yet human-verified
macro-F1, ViSoBERT vs PhoBERT
0.933 → 0.963
same 270-message test set, 5 folds × 3 seeds
PhoBERT vs TF-IDF baseline
p = 0.79
McNemar test: no significant difference (0.963 vs 0.956)

Engineering write-up

A fine-tuned PhoBERT scored 0.963 macro-F1 on our test set. A character TF-IDF model with logistic regression, trained in about fifteen seconds on a CPU, scored 0.956. The gap was not statistically significant, and that result shaped everything else about the project.

TL;DR#

ViGuard sorts Vietnamese text messages into safe, advertising and scam. It was a team project of three for the Machine Learning course at HCMUS. I fine-tuned PhoBERT and ViSoBERT, built the training and evaluation package, and compared both transformers with TF-IDF baselines. The numbers are provisional: the labels are machine-proposed and still waiting for human review.

The problem#

Scam texts in Vietnamese hide inside a much larger flood of advertising. Both kinds push a link or a phone number, and both are written to get a click. A filter that only separates "spam" from "not spam" either blocks shop promotions people want or lets scams through.

The hard boundary is advertising versus scam, and it is easy to fake progress on it. Scammers reuse templates, so a model that has seen one variant in training can score well on another variant in the test set without learning anything general.

Key decisions#

Near-duplicates never cross the split. Messages whose character TF-IDF cosine similarity is 0.8 or more form a group, and a group always lands on one side. The split manifest records zero groups split across train and test, and the code asserts it. Without this, a model could look good just by recognising a template.

One fixed test set, plus repeated cross-validation. 270 messages (20%) are held out for good. On the remaining 1,080, every model runs 5 group-aware folds with 3 seeds. When human-verified labels arrive, the same test IDs will be reused, so old and new results stay comparable.

Uncertainty before rankings. Every test score comes with a bootstrap 95% confidence interval, and each model is compared with the strongest baseline using a McNemar test on the same messages.

Two transformers for two kinds of Vietnamese. PhoBERT (phobert-base-v2) needs word-segmented input. ViSoBERT was trained on social media text, so I expected it to handle teencode, missing diacritics and obfuscated words better.

Training setup#

Both models were fine-tuned on Kaggle T4 GPUs with the same recipe: learning rate 2e-5, batch size 16, up to 10 epochs, early stopping on a group-aware inner validation split, mixed precision. Placeholders from anonymisation ([URL], [MONEY]) go through one shared text-preparation function, so the baselines and the transformers see exactly the same input.

Only one run in fifteen per model reached the tenth epoch before early stopping, so longer training was unlikely to change the picture.

Results#

On 1,350 messages, test set of 270:

Model Test macro-F1 (95% CI) Scam recall McNemar vs TF-IDF LR
PhoBERT 0.963 (0.940-0.985) 0.943 p = 0.79
TF-IDF characters + logistic regression 0.956 (0.930-0.978) 0.977
TF-IDF characters + words + linear SVM 0.952 (0.925-0.974) 0.989 p = 1.00
ViSoBERT 0.933 (0.904-0.960) 0.920 p = 0.146

The confusion matrices tell the models apart better than the averages do. PhoBERT raised fewer false alarms on safe messages, but it let five scams through as safe. The TF-IDF models did the opposite: more safe messages flagged as scam, fewer scams missed. For a scam filter, that trade matters more than a 0.007 difference in F1.

ViSoBERT came last and was the least stable across folds, despite my expectation. It was also weakest on messages written without diacritics. The files don't show a clear cause yet.

Why the baseline was so hard to beat#

The labels were proposed by rules and an LLM. A character n-gram model can learn to reproduce that kind of labeller very closely, which leaves little room above it. With machine-made labels, these scores measure agreement with the labeller, not real-world scam detection.

Limits and next steps#

  • Labels first. The next step is human-verified labels on the same 270 test messages, then rerunning every model with the same split.
  • Small test set. The confidence intervals overlap, so no ranking here is final.
  • Slices. The obfuscated-text slice (32 messages) has no advertising examples, so its per-class scores are not meaningful yet.
All work