Instructions to use joshswift/phobihsd-proposed with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use joshswift/phobihsd-proposed with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="joshswift/phobihsd-proposed")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("joshswift/phobihsd-proposed", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload PhoBiHSD pretrained checkpoint
Browse files- README.md +50 -0
- model_comparison.yaml +59 -0
- phobihsd_proposed.meta.json +14 -0
- phobihsd_proposed.pt +3 -0
README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
tags:
|
| 5 |
+
- vietnamese
|
| 6 |
+
- hate-speech-detection
|
| 7 |
+
- phobert
|
| 8 |
+
- bilstm
|
| 9 |
+
- text-classification
|
| 10 |
+
pipeline_tag: text-classification
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# joshswift/phobihsd-proposed
|
| 14 |
+
|
| 15 |
+
PhoBiHSD proposed checkpoint (PhoBERT-BiLSTM) for Vietnamese hate speech detection on ViHSD.
|
| 16 |
+
|
| 17 |
+
## Files
|
| 18 |
+
- `phobihsd_proposed.pt`: PyTorch checkpoint (`state_dict` + optional thresholds).
|
| 19 |
+
- `phobihsd_proposed.meta.json`: model metadata.
|
| 20 |
+
- `model_comparison.yaml`: training/inference config used by this repository.
|
| 21 |
+
|
| 22 |
+
## Label Mapping
|
| 23 |
+
- `0`: Clean
|
| 24 |
+
- `1`: Offensive
|
| 25 |
+
- `2`: Hate
|
| 26 |
+
|
| 27 |
+
## Metadata (from checkpoint sidecar)
|
| 28 |
+
```json
|
| 29 |
+
{
|
| 30 |
+
"model_name": "vinai/phobert-base-v2",
|
| 31 |
+
"head_type": "cls_mlp",
|
| 32 |
+
"hidden_dim": 256,
|
| 33 |
+
"dropout": 0.5,
|
| 34 |
+
"freeze_encoder": false,
|
| 35 |
+
"max_len": 100,
|
| 36 |
+
"thresholds": [
|
| 37 |
+
0.4,
|
| 38 |
+
0.4,
|
| 39 |
+
0.6
|
| 40 |
+
],
|
| 41 |
+
"seed": 4
|
| 42 |
+
}
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
## Inference (from this repo)
|
| 46 |
+
```bash
|
| 47 |
+
export PHOBIHSD_PROPOSED_CKPT=phobihsd_proposed.pt
|
| 48 |
+
export PHOBIHSD_CONFIG=config/experiments/model_comparison.yaml
|
| 49 |
+
python -m app.gradio_app
|
| 50 |
+
```
|
model_comparison.yaml
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
seed: 4
|
| 2 |
+
|
| 3 |
+
dataset:
|
| 4 |
+
train_csv: data/raw/train.csv
|
| 5 |
+
dev_csv: data/raw/dev.csv
|
| 6 |
+
test_csv: data/raw/test.csv
|
| 7 |
+
|
| 8 |
+
preprocess:
|
| 9 |
+
lowercase: false
|
| 10 |
+
|
| 11 |
+
classical:
|
| 12 |
+
max_features: 20000
|
| 13 |
+
|
| 14 |
+
bilstm:
|
| 15 |
+
max_len: 100
|
| 16 |
+
min_freq: 2
|
| 17 |
+
emb_dim: 128
|
| 18 |
+
hidden_dim: 128
|
| 19 |
+
batch_size: 256
|
| 20 |
+
epochs: 50
|
| 21 |
+
lr: 0.001
|
| 22 |
+
dropout: 0.5
|
| 23 |
+
optimizer: adam
|
| 24 |
+
|
| 25 |
+
phobert:
|
| 26 |
+
model_name: vinai/phobert-base-v2
|
| 27 |
+
text_source: raw_text
|
| 28 |
+
max_len: 100
|
| 29 |
+
batch_size: 16
|
| 30 |
+
eval_batch_size: 32
|
| 31 |
+
epochs: 4
|
| 32 |
+
lr: 2.0e-5
|
| 33 |
+
weight_decay: 0.01
|
| 34 |
+
|
| 35 |
+
phobert_bilstm:
|
| 36 |
+
text_source: raw_text
|
| 37 |
+
freeze_encoder: false
|
| 38 |
+
head_type: cls_mlp
|
| 39 |
+
max_len: 100
|
| 40 |
+
hidden_dim: 256
|
| 41 |
+
dropout: 0.5
|
| 42 |
+
batch_size: 16
|
| 43 |
+
epochs: 4
|
| 44 |
+
encoder_lr: 1.0e-5
|
| 45 |
+
head_lr: 3.0e-5
|
| 46 |
+
llrd: 0.9
|
| 47 |
+
warmup_ratio: 0.1
|
| 48 |
+
weight_decay: 0.01
|
| 49 |
+
grad_clip: 1.0
|
| 50 |
+
loss_type: class_weight
|
| 51 |
+
early_stopping_patience: 2
|
| 52 |
+
threshold_grid: [0.4, 0.45, 0.5, 0.55, 0.6]
|
| 53 |
+
|
| 54 |
+
outputs:
|
| 55 |
+
model_table_csv: results/tables/table_4_5_proposed_main.csv
|
| 56 |
+
metrics_json: results/metrics/model_comparison_table_4_5.json
|
| 57 |
+
log_txt: results/logs/table_4_5_model_comparison.log
|
| 58 |
+
registry_csv: experiments/registry.csv
|
| 59 |
+
proposed_checkpoint_pt: results/checkpoints/phobihsd_proposed.pt
|
phobihsd_proposed.meta.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_name": "vinai/phobert-base-v2",
|
| 3 |
+
"head_type": "cls_mlp",
|
| 4 |
+
"hidden_dim": 256,
|
| 5 |
+
"dropout": 0.5,
|
| 6 |
+
"freeze_encoder": false,
|
| 7 |
+
"max_len": 100,
|
| 8 |
+
"thresholds": [
|
| 9 |
+
0.4,
|
| 10 |
+
0.4,
|
| 11 |
+
0.6
|
| 12 |
+
],
|
| 13 |
+
"seed": 4
|
| 14 |
+
}
|
phobihsd_proposed.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:539e44ee8811c44fc755ea9cccc666d22fe79df8308173355fa99bf1cde2f392
|
| 3 |
+
size 540869362
|