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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# R-ViHSD — ViSoBERT + TF-IDF/LinearSVM Stacking
|
| 2 |
+
|
| 3 |
+
A Vietnamese hate-speech and text-noise classification pipeline combining:
|
| 4 |
+
|
| 5 |
+
- **ViSoBERT** for semantic representation.
|
| 6 |
+
- **TF-IDF character + word n-grams** for robust lexical features.
|
| 7 |
+
- **LinearSVC** models for hate-speech and noise classification.
|
| 8 |
+
- **Logistic Regression stacking** for the final hate-speech prediction.
|
| 9 |
+
|
| 10 |
+
The pipeline is trained using **Out-of-Fold (OOF) stacking** to reduce data leakage. After OOF training, the final base models are retrained on the full labeled dataset for inference on new data.
|
| 11 |
+
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
## 1. Task Definition
|
| 15 |
+
|
| 16 |
+
For each Vietnamese text sample, the system predicts two outputs.
|
| 17 |
+
|
| 18 |
+
### Hate-Speech Label
|
| 19 |
+
|
| 20 |
+
```text
|
| 21 |
+
CLEAN
|
| 22 |
+
OFFENSIVE
|
| 23 |
+
HATE
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
### Noise Type
|
| 27 |
+
|
| 28 |
+
```text
|
| 29 |
+
ORIGINAL
|
| 30 |
+
NO_DIACRITICS
|
| 31 |
+
TEENCODE
|
| 32 |
+
CHAR_REPEAT
|
| 33 |
+
PUNCT_NOISE
|
| 34 |
+
OBFUSCATION
|
| 35 |
+
MIXED
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
The minimum inference input format is:
|
| 39 |
+
|
| 40 |
+
```csv
|
| 41 |
+
id,text
|
| 42 |
+
0001,"sample text"
|
| 43 |
+
0002,"another sample"
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
The `id` column is preserved in the output but is not used as a model feature.
|
| 47 |
+
|
| 48 |
+
---
|
| 49 |
+
|
| 50 |
+
## 2. Overall Architecture
|
| 51 |
+
|
| 52 |
+
```text
|
| 53 |
+
┌─────────────────────────┐
|
| 54 |
+
│ TEXT │
|
| 55 |
+
└────────────┬────────────┘
|
| 56 |
+
│
|
| 57 |
+
┌──────────────────────┼──────────────────────┐
|
| 58 |
+
│ │ │
|
| 59 |
+
▼ ▼ ▼
|
| 60 |
+
┌────────────────┐ ┌──────────────────┐ ┌─────────────────┐
|
| 61 |
+
│ ViSoBERT │ │ TF-IDF char+word│ │ Surface Features│
|
| 62 |
+
└───────┬────────┘ └────────┬─────────┘ └────────┬────────┘
|
| 63 |
+
│ │ │
|
| 64 |
+
3 class probabilities ┌─────┴─────┐ │
|
| 65 |
+
│ │ │
|
| 66 |
+
▼ ▼ │
|
| 67 |
+
Hate LinearSVC Noise LinearSVC │
|
| 68 |
+
│ │ │
|
| 69 |
+
3 decision 7 decision │
|
| 70 |
+
scores scores │
|
| 71 |
+
│ │ │
|
| 72 |
+
│ softmax │
|
| 73 |
+
│ │ │
|
| 74 |
+
└─────┬─────┘ │
|
| 75 |
+
│ │
|
| 76 |
+
┌──────────────────────┴──────────────────────┘
|
| 77 |
+
│
|
| 78 |
+
▼
|
| 79 |
+
┌──────────────────────┐
|
| 80 |
+
│ 18 Stacking Features │
|
| 81 |
+
└──────────┬───────────┘
|
| 82 |
+
│
|
| 83 |
+
▼
|
| 84 |
+
┌──────────────────────┐
|
| 85 |
+
│ Logistic Regression │
|
| 86 |
+
│ Meta-Model │
|
| 87 |
+
└──────────┬───────────┘
|
| 88 |
+
│
|
| 89 |
+
▼
|
| 90 |
+
CLEAN / OFFENSIVE / HATE
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
The final `noise_type` prediction does not pass through the meta-model. It is obtained directly from:
|
| 94 |
+
|
| 95 |
+
```text
|
| 96 |
+
TF-IDF → Noise LinearSVC → argmax
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
---
|
| 100 |
+
|
| 101 |
+
## 3. Saved Model Structure
|
| 102 |
+
|
| 103 |
+
After training, the main working directory is expected to contain:
|
| 104 |
+
|
| 105 |
+
```text
|
| 106 |
+
rvihsd_stacking_work/
|
| 107 |
+
│
|
| 108 |
+
├── visobert_full/
|
| 109 |
+
│ ├── config.json
|
| 110 |
+
│ ├── model.safetensors / pytorch_model.bin
|
| 111 |
+
│ ├── tokenizer_config.json
|
| 112 |
+
│ ├── tokenizer.json
|
| 113 |
+
│ └── ...
|
| 114 |
+
│
|
| 115 |
+
├── full_vectorizer.joblib
|
| 116 |
+
├── full_hate_svm.joblib
|
| 117 |
+
├── full_noise_svm.joblib
|
| 118 |
+
├── meta_model.joblib
|
| 119 |
+
│
|
| 120 |
+
├── visobert_oof.npy
|
| 121 |
+
├── svm_oof.npy
|
| 122 |
+
├── noise_oof_scores.npy
|
| 123 |
+
├── visobert_fold*_pred.npy
|
| 124 |
+
│
|
| 125 |
+
└── submissions/
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
### Required Files for Inference
|
| 129 |
+
|
| 130 |
+
Only the following files are required for inference:
|
| 131 |
+
|
| 132 |
+
```text
|
| 133 |
+
visobert_full/
|
| 134 |
+
full_vectorizer.joblib
|
| 135 |
+
full_hate_svm.joblib
|
| 136 |
+
full_noise_svm.joblib
|
| 137 |
+
meta_model.joblib
|
| 138 |
+
```
|
| 139 |
+
|
| 140 |
+
OOF files are used during training and evaluation but are not required for deployment.
|
| 141 |
+
|
| 142 |
+
---
|
| 143 |
+
|
| 144 |
+
## 4. ViSoBERT Model
|
| 145 |
+
|
| 146 |
+
Backbone:
|
| 147 |
+
|
| 148 |
+
```text
|
| 149 |
+
uitnlp/visobert
|
| 150 |
+
```
|
| 151 |
+
|
| 152 |
+
ViSoBERT is fine-tuned for three-class hate-speech classification:
|
| 153 |
+
|
| 154 |
+
```text
|
| 155 |
+
0 → CLEAN
|
| 156 |
+
1 → OFFENSIVE
|
| 157 |
+
2 → HATE
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
+
Main training configuration:
|
| 161 |
+
|
| 162 |
+
| Parameter | Value |
|
| 163 |
+
|---|---:|
|
| 164 |
+
| Backbone | `uitnlp/visobert` |
|
| 165 |
+
| Max sequence length | `128` |
|
| 166 |
+
| Epochs | `3` |
|
| 167 |
+
| Learning rate | `2e-5` |
|
| 168 |
+
| Weight decay | `0.01` |
|
| 169 |
+
| Warmup ratio | `0.08` |
|
| 170 |
+
| Label smoothing | `0.05` |
|
| 171 |
+
| Train batch size | `128` |
|
| 172 |
+
| Evaluation batch size | `64` |
|
| 173 |
+
| Gradient accumulation | `2` |
|
| 174 |
+
| Seed | `42` |
|
| 175 |
+
|
| 176 |
+
During training, ViSoBERT uses weighted cross-entropy with sqrt-balanced class weights to reduce the effect of class imbalance.
|
| 177 |
+
|
| 178 |
+
The model produces three probabilities:
|
| 179 |
+
|
| 180 |
+
```text
|
| 181 |
+
P(CLEAN)
|
| 182 |
+
P(OFFENSIVE)
|
| 183 |
+
P(HATE)
|
| 184 |
+
```
|
| 185 |
+
|
| 186 |
+
These three values are passed to the stacking meta-model.
|
| 187 |
+
|
| 188 |
+
---
|
| 189 |
+
|
| 190 |
+
## 5. TF-IDF Features
|
| 191 |
+
|
| 192 |
+
The pipeline combines two TF-IDF vectorizers.
|
| 193 |
+
|
| 194 |
+
### Character TF-IDF
|
| 195 |
+
|
| 196 |
+
```python
|
| 197 |
+
analyzer="char"
|
| 198 |
+
ngram_range=(3, 5)
|
| 199 |
+
max_features=150_000
|
| 200 |
+
min_df=2
|
| 201 |
+
sublinear_tf=True
|
| 202 |
+
```
|
| 203 |
+
|
| 204 |
+
### Word TF-IDF
|
| 205 |
+
|
| 206 |
+
```python
|
| 207 |
+
analyzer="word"
|
| 208 |
+
ngram_range=(1, 2)
|
| 209 |
+
max_features=80_000
|
| 210 |
+
min_df=2
|
| 211 |
+
sublinear_tf=True
|
| 212 |
+
```
|
| 213 |
+
|
| 214 |
+
The two sparse matrices are concatenated:
|
| 215 |
+
|
| 216 |
+
```text
|
| 217 |
+
Character TF-IDF + Word TF-IDF
|
| 218 |
+
│
|
| 219 |
+
▼
|
| 220 |
+
Sparse Feature Matrix
|
| 221 |
+
```
|
| 222 |
+
|
| 223 |
+
Character n-grams are particularly useful for noisy social-media text, including:
|
| 224 |
+
|
| 225 |
+
- teencode,
|
| 226 |
+
- misspellings,
|
| 227 |
+
- missing Vietnamese diacritics,
|
| 228 |
+
- repeated characters,
|
| 229 |
+
- obfuscation,
|
| 230 |
+
- punctuation noise.
|
| 231 |
+
|
| 232 |
+
---
|
| 233 |
+
|
| 234 |
+
## 6. LinearSVC Models
|
| 235 |
+
|
| 236 |
+
Two independent LinearSVC models are used.
|
| 237 |
+
|
| 238 |
+
### Hate-Speech SVM
|
| 239 |
+
|
| 240 |
+
Classes:
|
| 241 |
+
|
| 242 |
+
```text
|
| 243 |
+
CLEAN
|
| 244 |
+
OFFENSIVE
|
| 245 |
+
HATE
|
| 246 |
+
```
|
| 247 |
+
|
| 248 |
+
Configuration:
|
| 249 |
+
|
| 250 |
+
```python
|
| 251 |
+
LinearSVC(
|
| 252 |
+
C=2.0,
|
| 253 |
+
class_weight="balanced",
|
| 254 |
+
random_state=42
|
| 255 |
+
)
|
| 256 |
+
```
|
| 257 |
+
|
| 258 |
+
The stacking model uses the three `decision_function` scores, not calibrated probabilities.
|
| 259 |
+
|
| 260 |
+
### Noise SVM
|
| 261 |
+
|
| 262 |
+
Classes:
|
| 263 |
+
|
| 264 |
+
```text
|
| 265 |
+
ORIGINAL
|
| 266 |
+
NO_DIACRITICS
|
| 267 |
+
TEENCODE
|
| 268 |
+
CHAR_REPEAT
|
| 269 |
+
PUNCT_NOISE
|
| 270 |
+
OBFUSCATION
|
| 271 |
+
MIXED
|
| 272 |
+
```
|
| 273 |
+
|
| 274 |
+
Configuration:
|
| 275 |
+
|
| 276 |
+
```python
|
| 277 |
+
LinearSVC(
|
| 278 |
+
C=2.0,
|
| 279 |
+
class_weight="balanced",
|
| 280 |
+
random_state=42
|
| 281 |
+
)
|
| 282 |
+
```
|
| 283 |
+
|
| 284 |
+
For stacking, the seven decision scores are transformed using:
|
| 285 |
+
|
| 286 |
+
```python
|
| 287 |
+
softmax(noise_score, axis=1)
|
| 288 |
+
```
|
| 289 |
+
|
| 290 |
+
These values are only used as stacking features and should not be interpreted as calibrated probabilities.
|
| 291 |
+
|
| 292 |
+
---
|
| 293 |
+
|
| 294 |
+
## 7. Surface Features
|
| 295 |
+
|
| 296 |
+
The pipeline also extracts five handcrafted features:
|
| 297 |
+
|
| 298 |
+
```text
|
| 299 |
+
1. log(1 + text length)
|
| 300 |
+
2. punctuation ratio
|
| 301 |
+
3. Vietnamese-diacritic ratio
|
| 302 |
+
4. repeated-character score
|
| 303 |
+
5. obfuscation score
|
| 304 |
+
```
|
| 305 |
+
|
| 306 |
+
The final meta-model input consists of:
|
| 307 |
+
|
| 308 |
+
```text
|
| 309 |
+
ViSoBERT probabilities 3
|
| 310 |
+
Hate SVM decision scores 3
|
| 311 |
+
Noise SVM softmax scores 7
|
| 312 |
+
Surface features 5
|
| 313 |
+
-------------------------------
|
| 314 |
+
Total 18
|
| 315 |
+
```
|
| 316 |
+
|
| 317 |
+
The feature order must remain exactly the same during inference.
|
| 318 |
+
|
| 319 |
+
---
|
| 320 |
+
|
| 321 |
+
## 8. Meta-Model
|
| 322 |
+
|
| 323 |
+
The final hate-speech meta-model is:
|
| 324 |
+
|
| 325 |
+
```text
|
| 326 |
+
StandardScaler
|
| 327 |
+
↓
|
| 328 |
+
LogisticRegression
|
| 329 |
+
```
|
| 330 |
+
|
| 331 |
+
Configuration:
|
| 332 |
+
|
| 333 |
+
```python
|
| 334 |
+
Pipeline([
|
| 335 |
+
("scale", StandardScaler()),
|
| 336 |
+
("lr", LogisticRegression(
|
| 337 |
+
C=1.0,
|
| 338 |
+
max_iter=3000,
|
| 339 |
+
class_weight="balanced",
|
| 340 |
+
random_state=42
|
| 341 |
+
))
|
| 342 |
+
])
|
| 343 |
+
```
|
| 344 |
+
|
| 345 |
+
Input:
|
| 346 |
+
|
| 347 |
+
```text
|
| 348 |
+
18 features
|
| 349 |
+
```
|
| 350 |
+
|
| 351 |
+
Output:
|
| 352 |
+
|
| 353 |
+
```text
|
| 354 |
+
CLEAN / OFFENSIVE / HATE
|
| 355 |
+
```
|
| 356 |
+
|
| 357 |
+
The model is saved as:
|
| 358 |
+
|
| 359 |
+
```text
|
| 360 |
+
meta_model.joblib
|
| 361 |
+
```
|
| 362 |
+
|
| 363 |
+
---
|
| 364 |
+
|
| 365 |
+
## 9. Out-of-Fold Stacking
|
| 366 |
+
|
| 367 |
+
The meta-model should not be trained on predictions produced by base models that have already seen the same samples.
|
| 368 |
+
|
| 369 |
+
The training pipeline therefore uses:
|
| 370 |
+
|
| 371 |
+
```python
|
| 372 |
+
StratifiedGroupKFold(
|
| 373 |
+
n_splits=5,
|
| 374 |
+
shuffle=True,
|
| 375 |
+
random_state=42
|
| 376 |
+
)
|
| 377 |
+
```
|
| 378 |
+
|
| 379 |
+
Workflow:
|
| 380 |
+
|
| 381 |
+
```text
|
| 382 |
+
Fold 1 → train base models on other folds → predict Fold 1
|
| 383 |
+
Fold 2 → train base models on other folds → predict Fold 2
|
| 384 |
+
...
|
| 385 |
+
Fold 5 → train base models on other folds → predict Fold 5
|
| 386 |
+
```
|
| 387 |
+
|
| 388 |
+
These predictions form the Out-of-Fold feature matrix.
|
| 389 |
+
|
| 390 |
+
The meta-model is then trained on:
|
| 391 |
+
|
| 392 |
+
```text
|
| 393 |
+
ViSoBERT OOF predictions
|
| 394 |
+
+
|
| 395 |
+
Hate SVM OOF scores
|
| 396 |
+
+
|
| 397 |
+
Noise SVM OOF scores
|
| 398 |
+
+
|
| 399 |
+
Surface features
|
| 400 |
+
↓
|
| 401 |
+
Logistic Regression Meta-Model
|
| 402 |
+
```
|
| 403 |
+
|
| 404 |
+
Grouping based on normalized text can also be used to reduce duplicate or augmentation leakage across folds.
|
| 405 |
+
|
| 406 |
+
---
|
| 407 |
+
|
| 408 |
+
## 10. Final Training
|
| 409 |
+
|
| 410 |
+
After OOF features are generated and the meta-model is trained:
|
| 411 |
+
|
| 412 |
+
1. The TF-IDF vectorizer is fitted again on all labeled data.
|
| 413 |
+
2. The hate-speech LinearSVC is trained on all labeled data.
|
| 414 |
+
3. The noise LinearSVC is trained on all labeled data.
|
| 415 |
+
4. ViSoBERT is fine-tuned on all labeled data.
|
| 416 |
+
5. All final models are saved for inference.
|
| 417 |
+
|
| 418 |
+
If:
|
| 419 |
+
|
| 420 |
+
```python
|
| 421 |
+
USE_VALIDATION_FOR_FINAL_TRAIN = True
|
| 422 |
+
```
|
| 423 |
+
|
| 424 |
+
the final models use:
|
| 425 |
+
|
| 426 |
+
```text
|
| 427 |
+
training_set + validation_set
|
| 428 |
+
```
|
| 429 |
+
|
| 430 |
+
---
|
| 431 |
+
|
| 432 |
+
## 11. Environment Requirements
|
| 433 |
+
|
| 434 |
+
Recommended installation:
|
| 435 |
+
|
| 436 |
+
```bash
|
| 437 |
+
pip install -U \
|
| 438 |
+
"transformers>=4.46" \
|
| 439 |
+
"accelerate>=1.0" \
|
| 440 |
+
"scikit-learn>=1.4" \
|
| 441 |
+
sentencepiece \
|
| 442 |
+
joblib \
|
| 443 |
+
scipy \
|
| 444 |
+
pandas \
|
| 445 |
+
numpy \
|
| 446 |
+
torch
|
| 447 |
+
```
|
| 448 |
+
|
| 449 |
+
Main dependencies:
|
| 450 |
+
|
| 451 |
+
```text
|
| 452 |
+
Python
|
| 453 |
+
PyTorch
|
| 454 |
+
Transformers
|
| 455 |
+
scikit-learn
|
| 456 |
+
SciPy
|
| 457 |
+
NumPy
|
| 458 |
+
Pandas
|
| 459 |
+
Joblib
|
| 460 |
+
SentencePiece
|
| 461 |
+
```
|
| 462 |
+
|
| 463 |
+
CUDA GPU support is recommended for ViSoBERT inference but is not required.
|
| 464 |
+
|
| 465 |
+
---
|
| 466 |
+
|
| 467 |
+
## 12. Loading the Models
|
| 468 |
+
|
| 469 |
+
Example:
|
| 470 |
+
|
| 471 |
+
```python
|
| 472 |
+
from pathlib import Path
|
| 473 |
+
import joblib
|
| 474 |
+
|
| 475 |
+
from transformers import (
|
| 476 |
+
AutoTokenizer,
|
| 477 |
+
AutoModelForSequenceClassification,
|
| 478 |
+
)
|
| 479 |
+
|
| 480 |
+
WORK_DIR = Path(
|
| 481 |
+
"/content/drive/MyDrive/rvihsd_stacking_work"
|
| 482 |
+
)
|
| 483 |
+
|
| 484 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 485 |
+
WORK_DIR / "visobert_full"
|
| 486 |
+
)
|
| 487 |
+
|
| 488 |
+
visobert = AutoModelForSequenceClassification.from_pretrained(
|
| 489 |
+
WORK_DIR / "visobert_full"
|
| 490 |
+
)
|
| 491 |
+
|
| 492 |
+
vectorizer = joblib.load(
|
| 493 |
+
WORK_DIR / "full_vectorizer.joblib"
|
| 494 |
+
)
|
| 495 |
+
|
| 496 |
+
hate_svm = joblib.load(
|
| 497 |
+
WORK_DIR / "full_hate_svm.joblib"
|
| 498 |
+
)
|
| 499 |
+
|
| 500 |
+
noise_svm = joblib.load(
|
| 501 |
+
WORK_DIR / "full_noise_svm.joblib"
|
| 502 |
+
)
|
| 503 |
+
|
| 504 |
+
meta_model = joblib.load(
|
| 505 |
+
WORK_DIR / "meta_model.joblib"
|
| 506 |
+
)
|
| 507 |
+
```
|
| 508 |
+
|
| 509 |
+
> `full_vectorizer.joblib` contains a custom `DualTfidf` class. The inference environment must define a compatible `DualTfidf` class before loading the file with `joblib`.
|
| 510 |
+
|
| 511 |
+
---
|
| 512 |
+
|
| 513 |
+
## 13. Inference Flow
|
| 514 |
+
|
| 515 |
+
For each new text sample:
|
| 516 |
+
|
| 517 |
+
```text
|
| 518 |
+
text
|
| 519 |
+
│
|
| 520 |
+
├── ViSoBERT
|
| 521 |
+
│ └── 3 class probabilities
|
| 522 |
+
│
|
| 523 |
+
├── TF-IDF
|
| 524 |
+
│ ├── Hate LinearSVC
|
| 525 |
+
│ │ └── 3 decision scores
|
| 526 |
+
│ │
|
| 527 |
+
│ └── Noise LinearSVC
|
| 528 |
+
│ ├── 7 decision scores
|
| 529 |
+
│ └── softmax → 7 stacking features
|
| 530 |
+
│
|
| 531 |
+
└── Surface features
|
| 532 |
+
└── 5 features
|
| 533 |
+
```
|
| 534 |
+
|
| 535 |
+
The final stacking input is:
|
| 536 |
+
|
| 537 |
+
```python
|
| 538 |
+
meta_X = np.hstack([
|
| 539 |
+
visobert_prob, # 3
|
| 540 |
+
hate_svm_score, # 3
|
| 541 |
+
noise_soft, # 7
|
| 542 |
+
surface_features, # 5
|
| 543 |
+
])
|
| 544 |
+
```
|
| 545 |
+
|
| 546 |
+
The feature dimension must satisfy:
|
| 547 |
+
|
| 548 |
+
```python
|
| 549 |
+
assert meta_X.shape[1] == 18
|
| 550 |
+
```
|
| 551 |
+
|
| 552 |
+
Final hate-speech prediction:
|
| 553 |
+
|
| 554 |
+
```python
|
| 555 |
+
hate_pred = meta_model.predict(meta_X)
|
| 556 |
+
```
|
| 557 |
+
|
| 558 |
+
Final noise prediction:
|
| 559 |
+
|
| 560 |
+
```python
|
| 561 |
+
noise_pred = noise_score.argmax(axis=1)
|
| 562 |
+
```
|
| 563 |
+
|
| 564 |
+
---
|
| 565 |
+
|
| 566 |
+
## 14. Input Format
|
| 567 |
+
|
| 568 |
+
A new CSV file should contain at least:
|
| 569 |
+
|
| 570 |
+
```csv
|
| 571 |
+
id,text
|
| 572 |
+
1,"first sentence"
|
| 573 |
+
2,"second sentence"
|
| 574 |
+
3,"third sentence"
|
| 575 |
+
```
|
| 576 |
+
|
| 577 |
+
Additional columns may exist, but inference should only depend on:
|
| 578 |
+
|
| 579 |
+
```text
|
| 580 |
+
id
|
| 581 |
+
text
|
| 582 |
+
```
|
| 583 |
+
|
| 584 |
+
This prevents accidental use of labels or unrelated metadata.
|
| 585 |
+
|
| 586 |
+
---
|
| 587 |
+
|
| 588 |
+
## 15. Output Format
|
| 589 |
+
|
| 590 |
+
Recommended output:
|
| 591 |
+
|
| 592 |
+
```csv
|
| 593 |
+
id,pred_label,pred_noise_type
|
| 594 |
+
1,CLEAN,ORIGINAL
|
| 595 |
+
2,OFFENSIVE,TEENCODE
|
| 596 |
+
3,HATE,NO_DIACRITICS
|
| 597 |
+
```
|
| 598 |
+
|
| 599 |
+
Columns:
|
| 600 |
+
|
| 601 |
+
| Column | Description |
|
| 602 |
+
|---|---|
|
| 603 |
+
| `id` | Original sample ID |
|
| 604 |
+
| `pred_label` | `CLEAN`, `OFFENSIVE`, or `HATE` |
|
| 605 |
+
| `pred_noise_type` | One of the seven supported noise classes |
|
| 606 |
+
|
| 607 |
+
---
|
| 608 |
+
|
| 609 |
+
## 16. Label Mapping
|
| 610 |
+
|
| 611 |
+
### Hate-Speech Labels
|
| 612 |
+
|
| 613 |
+
```python
|
| 614 |
+
LABELS = [
|
| 615 |
+
"CLEAN",
|
| 616 |
+
"OFFENSIVE",
|
| 617 |
+
"HATE",
|
| 618 |
+
]
|
| 619 |
+
```
|
| 620 |
+
|
| 621 |
+
Mapping:
|
| 622 |
+
|
| 623 |
+
```text
|
| 624 |
+
0 → CLEAN
|
| 625 |
+
1 → OFFENSIVE
|
| 626 |
+
2 → HATE
|
| 627 |
+
```
|
| 628 |
+
|
| 629 |
+
### Noise Labels
|
| 630 |
+
|
| 631 |
+
```python
|
| 632 |
+
NOISE_LABELS = [
|
| 633 |
+
"ORIGINAL",
|
| 634 |
+
"NO_DIACRITICS",
|
| 635 |
+
"TEENCODE",
|
| 636 |
+
"CHAR_REPEAT",
|
| 637 |
+
"PUNCT_NOISE",
|
| 638 |
+
"OBFUSCATION",
|
| 639 |
+
"MIXED",
|
| 640 |
+
]
|
| 641 |
+
```
|
| 642 |
+
|
| 643 |
+
Mapping:
|
| 644 |
+
|
| 645 |
+
```text
|
| 646 |
+
0 → ORIGINAL
|
| 647 |
+
1 → NO_DIACRITICS
|
| 648 |
+
2 → TEENCODE
|
| 649 |
+
3 → CHAR_REPEAT
|
| 650 |
+
4 → PUNCT_NOISE
|
| 651 |
+
5 → OBFUSCATION
|
| 652 |
+
6 → MIXED
|
| 653 |
+
```
|
| 654 |
+
|
| 655 |
+
Do not change the class order when using the already-trained models.
|
| 656 |
+
|
| 657 |
+
---
|
| 658 |
+
|
| 659 |
+
## 17. Recommended Inference Checks
|
| 660 |
+
|
| 661 |
+
Useful safety checks:
|
| 662 |
+
|
| 663 |
+
```python
|
| 664 |
+
assert len(output) == len(test_df)
|
| 665 |
+
assert output["id"].is_unique
|
| 666 |
+
|
| 667 |
+
assert set(
|
| 668 |
+
output["pred_label"]
|
| 669 |
+
).issubset(LABELS)
|
| 670 |
+
|
| 671 |
+
assert set(
|
| 672 |
+
output["pred_noise_type"]
|
| 673 |
+
).issubset(NOISE_LABELS)
|
| 674 |
+
|
| 675 |
+
assert meta_X.shape[1] == 18
|
| 676 |
+
```
|
| 677 |
+
|
| 678 |
+
If the stacking matrix does not contain exactly 18 features, the inference feature construction no longer matches training.
|
| 679 |
+
|
| 680 |
+
---
|
| 681 |
+
|
| 682 |
+
## 18. Components That Must Stay Consistent
|
| 683 |
+
|
| 684 |
+
When using the existing trained models, keep the following unchanged:
|
| 685 |
+
|
| 686 |
+
- hate-speech label order,
|
| 687 |
+
- noise label order,
|
| 688 |
+
- `MAX_LENGTH = 128`,
|
| 689 |
+
- tokenizer saved in `visobert_full`,
|
| 690 |
+
- `meta_surface_features` implementation,
|
| 691 |
+
- `DualTfidf` implementation,
|
| 692 |
+
- 18-feature stacking order,
|
| 693 |
+
- noise-score softmax transformation before the meta-model.
|
| 694 |
+
|
| 695 |
+
The stacking order must remain:
|
| 696 |
+
|
| 697 |
+
```text
|
| 698 |
+
[ViSoBERT: 3]
|
| 699 |
+
+
|
| 700 |
+
[Hate SVM: 3]
|
| 701 |
+
+
|
| 702 |
+
[Noise SVM: 7]
|
| 703 |
+
+
|
| 704 |
+
[Surface Features: 5]
|
| 705 |
+
```
|
| 706 |
+
|
| 707 |
+
---
|
| 708 |
+
|
| 709 |
+
## 19. Do New Test Sets Require Retraining?
|
| 710 |
+
|
| 711 |
+
**No.**
|
| 712 |
+
|
| 713 |
+
If the following trained artifacts are available:
|
| 714 |
+
|
| 715 |
+
```text
|
| 716 |
+
visobert_full/
|
| 717 |
+
full_vectorizer.joblib
|
| 718 |
+
full_hate_svm.joblib
|
| 719 |
+
full_noise_svm.joblib
|
| 720 |
+
meta_model.joblib
|
| 721 |
+
```
|
| 722 |
+
|
| 723 |
+
a new dataset only requires:
|
| 724 |
+
|
| 725 |
+
```text
|
| 726 |
+
LOAD MODELS
|
| 727 |
+
↓
|
| 728 |
+
LOAD NEW CSV
|
| 729 |
+
↓
|
| 730 |
+
TF-IDF + SVM INFERENCE
|
| 731 |
+
↓
|
| 732 |
+
ViSoBERT INFERENCE
|
| 733 |
+
↓
|
| 734 |
+
SURFACE FEATURE EXTRACTION
|
| 735 |
+
↓
|
| 736 |
+
STACKING
|
| 737 |
+
↓
|
| 738 |
+
SAVE PREDICTIONS
|
| 739 |
+
```
|
| 740 |
+
|
| 741 |
+
There is no need to rerun:
|
| 742 |
+
|
| 743 |
+
```text
|
| 744 |
+
5-fold OOF training
|
| 745 |
+
TF-IDF fitting
|
| 746 |
+
SVM training
|
| 747 |
+
ViSoBERT fine-tuning
|
| 748 |
+
Meta-model training
|
| 749 |
+
```
|
| 750 |
+
|
| 751 |
+
---
|
| 752 |
+
|
| 753 |
+
## 20. Training Cache
|
| 754 |
+
|
| 755 |
+
The notebook may use:
|
| 756 |
+
|
| 757 |
+
```python
|
| 758 |
+
REUSE_CACHE = True
|
| 759 |
+
```
|
| 760 |
+
|
| 761 |
+
Typical cache files include:
|
| 762 |
+
|
| 763 |
+
```text
|
| 764 |
+
svm_oof.npy
|
| 765 |
+
noise_oof_scores.npy
|
| 766 |
+
visobert_oof.npy
|
| 767 |
+
visobert_fold*_pred.npy
|
| 768 |
+
```
|
| 769 |
+
|
| 770 |
+
These files are useful for resuming training or reusing OOF predictions.
|
| 771 |
+
|
| 772 |
+
They are not required for deployment.
|
| 773 |
+
|
| 774 |
+
---
|
| 775 |
+
|
| 776 |
+
## 21. Main Training Hyperparameters
|
| 777 |
+
|
| 778 |
+
```python
|
| 779 |
+
N_FOLDS = 5
|
| 780 |
+
SEED = 42
|
| 781 |
+
|
| 782 |
+
MODEL_NAME = "uitnlp/visobert"
|
| 783 |
+
MAX_LENGTH = 128
|
| 784 |
+
EPOCHS = 3
|
| 785 |
+
|
| 786 |
+
TRAIN_BATCH_SIZE = 128
|
| 787 |
+
EVAL_BATCH_SIZE = 64
|
| 788 |
+
GRAD_ACCUM_STEPS = 2
|
| 789 |
+
|
| 790 |
+
LEARNING_RATE = 2e-5
|
| 791 |
+
WEIGHT_DECAY = 0.01
|
| 792 |
+
WARMUP_RATIO = 0.08
|
| 793 |
+
LABEL_SMOOTHING = 0.05
|
| 794 |
+
|
| 795 |
+
CHAR_NGRAM = (3, 5)
|
| 796 |
+
WORD_NGRAM = (1, 2)
|
| 797 |
+
|
| 798 |
+
CHAR_MAX_FEATURES = 150_000
|
| 799 |
+
WORD_MAX_FEATURES = 80_000
|
| 800 |
+
|
| 801 |
+
MIN_DF = 2
|
| 802 |
+
|
| 803 |
+
SVM_C_HATE = 2.0
|
| 804 |
+
SVM_C_NOISE = 2.0
|
| 805 |
+
|
| 806 |
+
META_C = 1.0
|
| 807 |
+
```
|
| 808 |
+
|
| 809 |
+
---
|
| 810 |
+
|
| 811 |
+
## 22. Evaluation Metric
|
| 812 |
+
|
| 813 |
+
Both tasks are evaluated using Macro-F1.
|
| 814 |
+
|
| 815 |
+
Hate-speech classification:
|
| 816 |
+
|
| 817 |
+
```python
|
| 818 |
+
f1_score(
|
| 819 |
+
y_hate,
|
| 820 |
+
hate_pred,
|
| 821 |
+
average="macro"
|
| 822 |
+
)
|
| 823 |
+
```
|
| 824 |
+
|
| 825 |
+
Noise classification:
|
| 826 |
+
|
| 827 |
+
```python
|
| 828 |
+
f1_score(
|
| 829 |
+
y_noise,
|
| 830 |
+
noise_pred,
|
| 831 |
+
average="macro"
|
| 832 |
+
)
|
| 833 |
+
```
|
| 834 |
+
|
| 835 |
+
The notebook may also compute a combined score:
|
| 836 |
+
|
| 837 |
+
```text
|
| 838 |
+
0.85 × Hate Macro-F1
|
| 839 |
+
+
|
| 840 |
+
0.15 × Noise Macro-F1
|
| 841 |
+
```
|
| 842 |
+
|
| 843 |
+
This README intentionally does not report a fixed F1 score because the actual metric depends on the specific training run and cached predictions.
|
| 844 |
+
|
| 845 |
+
---
|
| 846 |
+
|
| 847 |
+
## 23. Minimal Deployment Package
|
| 848 |
+
|
| 849 |
+
For deployment on another machine, the project can be organized as:
|
| 850 |
+
|
| 851 |
+
```text
|
| 852 |
+
model/
|
| 853 |
+
├── visobert_full/
|
| 854 |
+
├── full_vectorizer.joblib
|
| 855 |
+
├── full_hate_svm.joblib
|
| 856 |
+
├── full_noise_svm.joblib
|
| 857 |
+
├── meta_model.joblib
|
| 858 |
+
├── inference.py
|
| 859 |
+
└── README.md
|
| 860 |
+
```
|
| 861 |
+
|
| 862 |
+
A command-line inference interface may look like:
|
| 863 |
+
|
| 864 |
+
```bash
|
| 865 |
+
python inference.py \
|
| 866 |
+
--input new_test.csv \
|
| 867 |
+
--output predictions.csv \
|
| 868 |
+
--model-dir model
|
| 869 |
+
```
|
| 870 |
+
|
| 871 |
+
---
|
| 872 |
+
|
| 873 |
+
## 24. Notes
|
| 874 |
+
|
| 875 |
+
- The meta-model predicts only the hate-speech label.
|
| 876 |
+
- The noise label is produced directly by the noise LinearSVC.
|
| 877 |
+
- `LinearSVC.decision_function()` values are not probabilities.
|
| 878 |
+
- The softmax applied to noise scores is used as a stacking transformation rather than probability calibration.
|
| 879 |
+
- Model compatibility depends on preserving the preprocessing and feature-ordering logic used during training.
|
| 880 |
+
- When transferring `joblib` artifacts between environments, compatible versions of Python and scikit-learn are recommended.
|
| 881 |
+
|
| 882 |
+
---
|
| 883 |
+
|
| 884 |
+
## 25. Summary
|
| 885 |
+
|
| 886 |
+
The final inference system is:
|
| 887 |
+
|
| 888 |
+
```text
|
| 889 |
+
ViSoBERT
|
| 890 |
+
+
|
| 891 |
+
TF-IDF Character/Word Features
|
| 892 |
+
+
|
| 893 |
+
Hate LinearSVC
|
| 894 |
+
+
|
| 895 |
+
Noise LinearSVC
|
| 896 |
+
+
|
| 897 |
+
Surface Features
|
| 898 |
+
↓
|
| 899 |
+
Logistic Regression Stacking
|
| 900 |
+
↓
|
| 901 |
+
Final Hate-Speech Prediction
|
| 902 |
+
|
| 903 |
+
Noise LinearSVC
|
| 904 |
+
↓
|
| 905 |
+
Final Noise-Type Prediction
|
| 906 |
+
```
|
| 907 |
+
|
| 908 |
+
This architecture combines transformer-based semantic information with sparse lexical features that are robust to noisy Vietnamese social-media text.
|