--- language: vi license: cc-by-nc-sa-4.0 library_name: transformers pipeline_tag: text-classification base_model: vinai/phobert-base-v2 tags: - esg - greenwashing - phobert - vietnamese - commitment-detection - text-classification metrics: - f1 --- # Commitment classifier (PhoBERT-v2) — ESG washing / Cheap-Talk Index Phân loại nhị phân **commitment**: câu có phải *cam kết / hành động* ESG không — một thành phần của chỉ số **Cheap-Talk Index (CTI)** đo greenwashing trong báo cáo ngân hàng tiếng Việt. - **Kiến trúc:** `AutoModelForSequenceClassification` (PhoBERT-base-v2, **single-head**, 2 lớp). Khác bản multi-head `esgwash` -> model này load thẳng bằng `transformers`. - **Nhãn:** `1` = cam kết/hành động; `0` = không phải cam kết. - **Train:** translate-train — gold EN `climatebert/climate_commitments_actions` dịch sang tiếng Việt + augment `action_500`. Ngưỡng quyết định **0.5** (đã cân lệch lớp bằng class-weights `sqrt_inverse`). ## Kết quả (test = bản dịch, 5-seed mean ± std, ngưỡng 0.5) | Metric | Giá trị | Sàn TF-IDF+LR | |---|---|---| | macro-F1 | **0.789 ± 0.008** | 0.739 | | F1 lớp dương (commitment) | 0.729 ± 0.010 | — | | micro-F1 | 0.806 ± 0.009 | — | Đặc tính lỗi (seed 42): lớp dương **precision 0.64 / recall 0.84** -> bắt gần đủ cam kết (recall cao), nhưng lẫn cam kết "giả" (precision thấp). > ⚠️ **Caveat:** test là **bản dịch (miền climate/doanh nghiệp chung)**, CHƯA verify trên báo cáo > ngân hàng VN thật. Dùng cho CTI nên kiểm trên human-eval tiếng Việt trước khi tin tuyệt đối. ## Inference ```python from transformers import AutoTokenizer, AutoModelForSequenceClassification import torch from underthesea import word_tokenize # PhoBERT cần text đã tách từ repo = "dqa2412/esg-washing-optimized" tok = AutoTokenizer.from_pretrained(repo) model = AutoModelForSequenceClassification.from_pretrained(repo).eval() text = "Ngân hàng cam kết giảm 30% phát thải vào năm 2030." seg = word_tokenize(text, format="text") # BẮT BUỘC: model train trên text đã tách từ inp = tok(seg, return_tensors="pt", truncation=True, max_length=256) with torch.no_grad(): p1 = model(**inp).logits.softmax(-1)[0, 1].item() print("P(commitment) =", round(p1, 3), "->", "commitment" if p1 >= 0.5 else "non-commitment") ``` ## Tái lập (tune + train) Repo kèm code + data (`data/vi_gold/commitment/`, cột `sentence`, `label`): ```bash pip install -r requirements.txt # 1) Tune (Optuna TPE + MedianPruner, 10 trials) -> best_params_commitment.json python -m src.training.tune_hyperparams --config config/train_commitment.yml --task commitment --trials 10 # 2) Train cuối (5-seed mean±std @ 0.5) -> outputs/models/commitment/{final, metrics_summary.json} python -m src.training.train_model --config config/train_commitment.yml --task commitment ``` Chạy từ thư mục gốc repo này (code tự `sys.path.insert` để import `src.training.*`). ## Files - `model.safetensors`, `config.json`, tokenizer PhoBERT — model đã train (seed 42). - `best_params_commitment.json` — siêu tham số tốt nhất (Optuna). - `metrics_summary.json`, `test_predictions.parquet` — eval 5-seed + dự đoán test. - `src/training/*` — code tune+train (single-head, dual-use `main()`). - `config/train_commitment.yml` — config chỉ task commitment. - `data/vi_gold/commitment/{train,val,test}.parquet` — gold translate-train. ## Nguồn dữ liệu & license Train data = `climatebert/climate_commitments_actions` (EN) dịch sang tiếng Việt + augment `action_500`. Kế thừa **CC BY-NC-SA 4.0** (phi thương mại). Vui lòng trích dẫn ClimateBERT (Bingler et al.).