Datasets:
Tasks:
Text Classification
Formats:
parquet
Sub-tasks:
multi-class-classification
Size:
1K - 10K
License:
Anger pool re-decided from the Indonesian text only; exact 8b:1b:1b balanced splits; whole pools unsplit in `full`/`anger_split`; option-order control, probe matrix, flip audit and second-run reconfirmation shipped
Browse files- README.md +211 -139
- README.template.md +197 -121
- anger_split/train.parquet +2 -2
- anger_split_balanced/test.parquet +2 -2
- anger_split_balanced/train.parquet +2 -2
- anger_split_balanced/valid.parquet +2 -2
- balanced/test.parquet +2 -2
- balanced/train.parquet +2 -2
- balanced/valid.parquet +2 -2
- build_info.json +84 -35
- ekman_questions_id.py +53 -0
- full/train.parquet +2 -2
- label_anger_id.py +270 -0
- make_dataset.py +372 -118
- out/anger_ekman_rows.csv +0 -0
- out/audit_flips.csv +38 -0
- out/audit_summary.json +6 -0
- out/cache_id_core_swap.json +0 -0
- out/cache_id_diag.json +1 -0
- out/cache_id_veto.json +0 -0
- out/probe_quality_id.json +612 -0
- out/reconfirm.json +63 -0
- out/timings.json +13 -10
- out_prev/anger_ekman_rows.csv +0 -0
- out_prev/cache_en_core.json +0 -0
- out_prev/cache_en_diag.json +0 -0
- out_prev/cache_id_core.json +0 -0
- out_prev/speedup.json +22 -0
- out_prev/timings.json +19 -0
- out_prev/veto_check.json +5 -0
- probe_quality_id.py +99 -0
- probes_id.py +74 -0
- publish.py +6 -0
- runs/label_run_id.log +31 -0
- runs/label_run_id_reconfirm.log +31 -0
- split_exact.py +232 -0
- test_split_exact.py +116 -0
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
---
|
| 2 |
license: cc-by-4.0
|
| 3 |
-
pretty_name: "EmoTweetID Ekman-7: five human-tagged Ekman emotions + the anger pool split into anger vs contempt
|
| 4 |
language:
|
| 5 |
- id
|
| 6 |
- en
|
|
@@ -42,18 +42,10 @@ configs:
|
|
| 42 |
data_files:
|
| 43 |
- split: train
|
| 44 |
path: full/train.parquet
|
| 45 |
-
- split: valid
|
| 46 |
-
path: full/valid.parquet
|
| 47 |
-
- split: test
|
| 48 |
-
path: full/test.parquet
|
| 49 |
- config_name: anger_split
|
| 50 |
data_files:
|
| 51 |
- split: train
|
| 52 |
path: anger_split/train.parquet
|
| 53 |
-
- split: valid
|
| 54 |
-
path: anger_split/valid.parquet
|
| 55 |
-
- split: test
|
| 56 |
-
path: anger_split/test.parquet
|
| 57 |
- config_name: anger_split_balanced
|
| 58 |
data_files:
|
| 59 |
- split: train
|
|
@@ -67,11 +59,13 @@ configs:
|
|
| 67 |
# EmoTweetID under Ekman's seven universal emotions
|
| 68 |
|
| 69 |
2,243 Indonesian tweets, one label each from Ekman's universal set - **anger, contempt, disgust,
|
| 70 |
-
enjoyment, fear, sadness, surprise**. 475 of them are the pool EmoTweetID tagged `anger`,
|
| 71 |
-
|
| 72 |
-
against Ekman's own definitions
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
| 75 |
|
| 76 |
Why bother: Ekman lists anger and contempt as two different universal emotions with different
|
| 77 |
triggers, different messages and different facial signatures, but emotion corpora - and the models
|
|
@@ -80,15 +74,15 @@ system has to tell "you wronged me, put it right" from "you are beneath me".
|
|
| 80 |
|
| 81 |
| class | rows | share | origin |
|
| 82 |
|---|---|---|---|
|
| 83 |
-
| `anger` |
|
| 84 |
-
| `contempt` |
|
| 85 |
| `disgust` | 355 | 15.8% | EmoTweetID annotators, kept verbatim |
|
| 86 |
| `enjoyment` | 429 | 19.1% | EmoTweetID annotators, kept verbatim |
|
| 87 |
| `fear` | 395 | 17.6% | EmoTweetID annotators, kept verbatim |
|
| 88 |
| `sadness` | 303 | 13.5% | EmoTweetID annotators, kept verbatim |
|
| 89 |
| `surprise` | 286 | 12.8% | EmoTweetID annotators, kept verbatim |
|
| 90 |
|
| 91 |
-
##
|
| 92 |
|
| 93 |
| source label (EmoTweetID, human) | rows | treatment here |
|
| 94 |
|---|---|---|
|
|
@@ -97,7 +91,7 @@ system has to tell "you wronged me, put it right" from "you are beneath me".
|
|
| 97 |
| `disgust` | 355 | kept |
|
| 98 |
| `sadness` | 303 | kept |
|
| 99 |
| `surprise` | 286 | kept |
|
| 100 |
-
| `anger` | 475 | **re-read by laya** and split into `anger` / `contempt` |
|
| 101 |
|
| 102 |
`label_origin` on every row says which of the two applies, and `source_label` always keeps the
|
| 103 |
upstream name. Nothing else in the schema was modelled; there is no `neutral` class because
|
|
@@ -114,7 +108,13 @@ GoEmotions - which is why this card has 7 classes where the reference has 8.
|
|
| 114 |
[Mendeley Data jzgnjsff9f](https://data.mendeley.com/datasets/jzgnjsff9f).
|
| 115 |
* **Licence**: CC BY 4.0 on the source; this derived dataset is CC BY 4.0 as well.
|
| 116 |
* **Definitions**: [What is Anger?](https://www.paulekman.com/universal-emotions/what-is-anger/) and
|
| 117 |
-
[What is Contempt?](https://www.paulekman.com/universal-emotions/what-is-contempt/), Paul Ekman
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
## The two classes the split turns on, in Ekman's words
|
| 120 |
|
|
@@ -135,145 +135,210 @@ Operational boundary: **anger wants the obstacle gone; contempt puts the target
|
|
| 135 |
|
| 136 |
## How the anger split was decided
|
| 137 |
|
| 138 |
-
`pip install laya` (v0.3.4), checkpoint `convaiinnovations/laya
|
| 139 |
-
tensors - a 306.9M `jhu-clsp/mmBERT-base` encoder (modernbert,
|
| 140 |
-
laya's own context cap 1024 tokens) plus 15.0M of
|
| 141 |
-
forward pass into probabilities over the options you asked about. For
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
### Quality checks on the machine labels - read before using them
|
| 160 |
|
| 161 |
-
*
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
|
| 182 |
## Schema
|
| 183 |
|
| 184 |
| field | type | meaning |
|
| 185 |
|---|---|---|
|
| 186 |
-
| `text` | string | the tweet as written (Indonesian) - the
|
| 187 |
-
| `text_en` | string | EmoTweetID's English translation |
|
| 188 |
| `label` | string | one of the 7 Ekman classes |
|
| 189 |
| `label_idx` | ClassLabel | `label` as an int, in the order anger, contempt, disgust, enjoyment, fear, sadness, surprise (anger, contempt in the `anger_split` configs) |
|
| 190 |
| `source_label` | string | upstream EmoTweetID label (`anger`, `joy`, `fear`, `disgust`, `sadness`, `surprise`) |
|
| 191 |
| `label_origin` | string | `upstream_manual` (human label kept) or `laya_anger_split` (machine relabelled) |
|
| 192 |
-
| `label_source` | string | which
|
| 193 |
-
| `
|
| 194 |
-
| `
|
| 195 |
-
| `
|
| 196 |
-
| `
|
| 197 |
-
| `
|
| 198 |
-
| `p_superiority`, `p_blocked_or_unfair` | float32 | Ekman core-feature probes; only run on rows the choice head could not settle, so `null` on most rows |
|
| 199 |
| `p_not_anger_or_contempt` | float32 | veto probe - weak, see quality checks |
|
| 200 |
-
| `ambiguous` | bool | neither language reading was decisive |
|
| 201 |
| `row_src` | int32 | row index in EmoTweetID's `Data-Annotated-Tweet-File-RESULT.csv` |
|
| 202 |
|
| 203 |
## Configs, splits, sizes
|
| 204 |
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
`
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
|
| 217 |
| config | split | rows | per class |
|
| 218 |
|---|---|---|---|
|
| 219 |
-
| `balanced` | train |
|
| 220 |
-
| `balanced` | valid |
|
| 221 |
-
| `balanced` | test |
|
| 222 |
-
| `full` | train |
|
| 223 |
-
| `
|
| 224 |
-
| `
|
| 225 |
-
| `
|
| 226 |
-
| `
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
Measured in a 2 vCPU / 2 GB CPU-only sandbox (`torch` 2.14 CPU, laya 0.3.4): 1853 scored
|
| 237 |
-
rows in 1209.6 s of model time, i.e. ~0.65 s per (state, question).
|
| 238 |
|
| 239 |
| change | why | measured effect |
|
| 240 |
|---|---|---|
|
| 241 |
| keep the encoder at **bf16** instead of laya's forced fp32 | laya sets `dtype = torch.float32` on CPU, upcasting the bf16 checkpoint to 1.29 GB; the stock path was **OOM-killed with exit 137** before it made a single prediction | the run goes from impossible to a 1420 MB peak RSS |
|
| 242 |
| **zero-copy** checkpoint load (mmap views instead of `safetensors.load_file`) | the stock loader materialises the 643 MB a second time before copying it into the model | removes a 643 MB transient; weights verified bitwise-identical to stock `load_file` |
|
| 243 |
-
| **staged questions** - choice on every row,
|
| 244 |
-
| length-sorted, token-budgeted **batches** | laya's `predict` costs one forward pass per state | 1.25x on the biggest stage at a 1024-token cap
|
| 245 |
-
| **per-stage resumable cache** (`out/cache_<stage>.json`, shipped) | the decision rule
|
| 246 |
|
| 247 |
Two traps worth knowing:
|
| 248 |
|
| 249 |
* **`max_len` is not a speed dial.** laya builds `[CLS] <question + options> [SEP] <state> [SEP]` and
|
| 250 |
only *truncates* at `max_len`, so a 214-token sequence costs the same at `max_len=1024` as at 256
|
| 251 |
-
(measured 1.04x). The ~150-token prompt head every row pays is what dominates, so criteria length
|
| 252 |
-
the real budget: cutting `head_max_len` 256 -> 128 left all 48 sampled argmaxes unchanged
|
| 253 |
-
probability shift 0.045, exactly 0.000 at >=160), while 96 flipped 23% of them - so 144
|
| 254 |
-
(`sweep_config.py`).
|
| 255 |
-
* **laya truncates every option at 48 tokens** (`build_sequence`)
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
if they ever stop fitting.
|
| 259 |
|
| 260 |
## Using it
|
| 261 |
|
| 262 |
```python
|
| 263 |
from datasets import load_dataset
|
| 264 |
-
ds = load_dataset("mahalisyarifuddin/emotweetid-ekman7", "balanced")
|
| 265 |
ds["train"][0]["text"], ds["train"][0]["label"]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
# the anger work on its own, with every evidence column:
|
| 267 |
-
ang = load_dataset("mahalisyarifuddin/emotweetid-ekman7", "anger_split")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
```
|
| 269 |
|
| 270 |
Or reproduce it end to end:
|
| 271 |
|
| 272 |
```bash
|
| 273 |
-
pip install laya scikit-learn pandas pyarrow datasets huggingface_hub
|
| 274 |
python fetch_source_data.py # data/file1.csv + data/file2.csv (CC BY 4.0)
|
| 275 |
python prepare_checkpoint.py # models/laya-ml + models/enc-bf16 (bf16, low-mem)
|
| 276 |
-
python
|
|
|
|
|
|
|
| 277 |
python make_dataset.py # splits + parquet + this card, with verification
|
| 278 |
python publish.py --repo <namespace>/<name> # HF upload; needs HF_TOKEN with write scope
|
| 279 |
```
|
|
@@ -282,36 +347,43 @@ Built with laya 0.3.4, transformers 5.17.0, datasets 5.0.1, torch
|
|
| 282 |
2.14.0+cpu on CPU. The model was never loaded to build this repo's numbers:
|
| 283 |
`build_info.checkpoint_facts` reads them from the checkpoint's safetensors header.
|
| 284 |
|
| 285 |
-
Everything is in this repo: `
|
| 286 |
-
`
|
| 287 |
-
`
|
| 288 |
-
`
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
|
|
|
|
|
|
| 293 |
|
| 294 |
## Limitations
|
| 295 |
|
| 296 |
-
* **
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 310 |
* **Upstream noise carries into the pool.** Only anger was audited; a mislabelled `joy`/`disgust` row
|
| 311 |
-
stays mislabelled here. The upstream annotation had substantial, not perfect, agreement
|
|
|
|
| 312 |
* **No neutral class**, and no intensity scores: an `intensity` question was written and measured, did
|
| 313 |
-
not discriminate (1.1-1.8 on all 16 probes), so
|
| 314 |
-
|
| 315 |
* Tweets are raw: all-caps, code-mixed Indonesian/Javanese/Malay, slang, emoji, insults and slurs.
|
| 316 |
Only whitespace was normalised.
|
| 317 |
|
|
|
|
| 1 |
---
|
| 2 |
license: cc-by-4.0
|
| 3 |
+
pretty_name: "EmoTweetID Ekman-7: five human-tagged Ekman emotions + the anger pool split into anger vs contempt by laya, from the Indonesian text"
|
| 4 |
language:
|
| 5 |
- id
|
| 6 |
- en
|
|
|
|
| 42 |
data_files:
|
| 43 |
- split: train
|
| 44 |
path: full/train.parquet
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
- config_name: anger_split
|
| 46 |
data_files:
|
| 47 |
- split: train
|
| 48 |
path: anger_split/train.parquet
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
- config_name: anger_split_balanced
|
| 50 |
data_files:
|
| 51 |
- split: train
|
|
|
|
| 59 |
# EmoTweetID under Ekman's seven universal emotions
|
| 60 |
|
| 61 |
2,243 Indonesian tweets, one label each from Ekman's universal set - **anger, contempt, disgust,
|
| 62 |
+
enjoyment, fear, sadness, surprise**. 475 of them are the pool EmoTweetID tagged `anger`,
|
| 63 |
+
and that pool is the only place this dataset makes a decision of its own: [laya](https://pypi.org/project/laya/)
|
| 64 |
+
reads each of those tweets, in Indonesian, against Ekman's own definitions of the two emotions, and
|
| 65 |
+
splits them into **anger (289)** and **contempt (186)** - contempt is
|
| 66 |
+
39.2% of the pool. The other five classes are EmoTweetID's human annotations, carried over verbatim.
|
| 67 |
+
Four configs: `full` and `anger_split` are the complete pools, each in a single split; `balanced`
|
| 68 |
+
(default) and `anger_split_balanced` are exact 8:1:1 train/valid/test, seed 0, no duplicate leakage.
|
| 69 |
|
| 70 |
Why bother: Ekman lists anger and contempt as two different universal emotions with different
|
| 71 |
triggers, different messages and different facial signatures, but emotion corpora - and the models
|
|
|
|
| 74 |
|
| 75 |
| class | rows | share | origin |
|
| 76 |
|---|---|---|---|
|
| 77 |
+
| `anger` | 289 | 12.9% | split here: laya on the `anger` pool |
|
| 78 |
+
| `contempt` | 186 | 8.3% | split here: laya on the `anger` pool |
|
| 79 |
| `disgust` | 355 | 15.8% | EmoTweetID annotators, kept verbatim |
|
| 80 |
| `enjoyment` | 429 | 19.1% | EmoTweetID annotators, kept verbatim |
|
| 81 |
| `fear` | 395 | 17.6% | EmoTweetID annotators, kept verbatim |
|
| 82 |
| `sadness` | 303 | 13.5% | EmoTweetID annotators, kept verbatim |
|
| 83 |
| `surprise` | 286 | 12.8% | EmoTweetID annotators, kept verbatim |
|
| 84 |
|
| 85 |
+
## How each class got its label
|
| 86 |
|
| 87 |
| source label (EmoTweetID, human) | rows | treatment here |
|
| 88 |
|---|---|---|
|
|
|
|
| 91 |
| `disgust` | 355 | kept |
|
| 92 |
| `sadness` | 303 | kept |
|
| 93 |
| `surprise` | 286 | kept |
|
| 94 |
+
| `anger` | 475 | **re-read by laya, in Indonesian**, and split into `anger` / `contempt` |
|
| 95 |
|
| 96 |
`label_origin` on every row says which of the two applies, and `source_label` always keeps the
|
| 97 |
upstream name. Nothing else in the schema was modelled; there is no `neutral` class because
|
|
|
|
| 108 |
[Mendeley Data jzgnjsff9f](https://data.mendeley.com/datasets/jzgnjsff9f).
|
| 109 |
* **Licence**: CC BY 4.0 on the source; this derived dataset is CC BY 4.0 as well.
|
| 110 |
* **Definitions**: [What is Anger?](https://www.paulekman.com/universal-emotions/what-is-anger/) and
|
| 111 |
+
[What is Contempt?](https://www.paulekman.com/universal-emotions/what-is-contempt/), Paul Ekman
|
| 112 |
+
Group. The criteria shown to the model are condensed from these two pages.
|
| 113 |
+
* **Language**: every label here is decided from `text`, the tweet as written. `text_en` is
|
| 114 |
+
EmoTweetID's machine translation and is never an input to any label; it ships only because it is
|
| 115 |
+
upstream data. An earlier reading of this same pool used `text` and `text_en` together; those rows,
|
| 116 |
+
their probabilities and the caches behind them are kept in `out_prev/`, so the two readings can be
|
| 117 |
+
compared row by row - it labelled 381 anger / 94 contempt; the labels here differ on 116 of the 475 rows, 104 of them anger -> contempt.
|
| 118 |
|
| 119 |
## The two classes the split turns on, in Ekman's words
|
| 120 |
|
|
|
|
| 135 |
|
| 136 |
## How the anger split was decided
|
| 137 |
|
| 138 |
+
`pip install laya` (v0.3.4), checkpoint `convaiinnovations/laya`, subfolder `multilingual/`:
|
| 139 |
+
321.9M params in 170 tensors - a 306.9M `jhu-clsp/mmBERT-base` encoder (modernbert,
|
| 140 |
+
bf16 weights, vocab 256000, laya's own context cap 1024 tokens) plus 15.0M of
|
| 141 |
+
decision heads that turn one forward pass into probabilities over the options you asked about. For
|
| 142 |
+
each tweet: one `choice` question whose two options are Ekman's criteria above, the same question
|
| 143 |
+
again with the options in the opposite order, `noul` probes of each emotion's core feature
|
| 144 |
+
(superiority, blocked-or-unfair) on the rows the choice head could not settle, and a
|
| 145 |
+
`not_anger_or_contempt` veto as a diagnostic. One non-autoregressive forward pass per question - no
|
| 146 |
+
generation, so nothing to parse and nothing to hallucinate. Every tweet is read in Indonesian; the
|
| 147 |
+
question itself stays laya's own English prompt, i.e. Ekman's criteria are quoted in the language
|
| 148 |
+
they were written in.
|
| 149 |
+
|
| 150 |
+
The four stages, over the 475 anger-pool rows:
|
| 151 |
+
|
| 152 |
+
| stage | question(s) | rows scored (state x question) | what it is for |
|
| 153 |
+
|---|---|---|---|
|
| 154 |
+
| `id_core` | `ekman` (choice) | 475 | the decision |
|
| 155 |
+
| `id_core_swap` | same, contempt listed first | 475 | option-order control (`p_anger_swapped`) |
|
| 156 |
+
| `id_diag` | `superiority`, `blocked_or_unfair` | 108 | only on the rows `id_core` left under a 0.10 margin |
|
| 157 |
+
| `id_veto` | `not_anger_or_contempt` | 475 | off-topic diagnostic - **do not filter on it** |
|
| 158 |
+
|
| 159 |
+
The decision rule, in order:
|
| 160 |
+
|
| 161 |
+
1. the `choice` reading is decisive (|p(anger) - p(contempt)| >= 0.1) -> its argmax
|
| 162 |
+
(`ekman_choice_id`);
|
| 163 |
+
2. not decisive -> Ekman's core-feature probes break the tie, superiority => contempt,
|
| 164 |
+
blocked-or-unfair => anger (`ekman_noul_tiebreak`);
|
| 165 |
+
3. both still under the margin -> the average of the two option orders decides, if it has a side
|
| 166 |
+
(`ekman_choice_order_avg`);
|
| 167 |
+
4. nothing at all -> keep the upstream EmoTweetID label `anger` (`kept_original_label`): this dataset
|
| 168 |
+
only ever *splits* an existing anger pool, it never re-litigates it.
|
| 169 |
+
|
| 170 |
+
Realised as: `ekman_choice_id` 421, `ekman_noul_tiebreak` 33, `ekman_choice_order_avg` 18, `kept_original_label` 3. Every probability is on the row - `p_anger_id` (as prompted),
|
| 171 |
+
`p_anger_swapped` (options reversed), `ekman_p_anger`, `ekman_p_contempt`, `ekman_margin_id`,
|
| 172 |
+
`p_superiority`, `p_blocked_or_unfair`, `p_not_anger_or_contempt` - so you can re-cut the split with
|
| 173 |
+
your own threshold instead of trusting this rule.
|
| 174 |
+
|
| 175 |
+
Reproducibility: the `id_core` stage matches the earlier two-language run's `out_prev/cache_id_core.json` (shipped here) to the last digit - 471/471 unique texts on the same side of the decision line, mean |delta p(anger)| 0.0000, max 0.0000. On a second, complete run of the labeller - fresh caches, same
|
| 176 |
+
sandbox - every stage (id_core, id_core_swap, id_diag, id_veto) matched row for row and reproduced **475/475 labels**, down to a byte-identical `anger_ekman_rows.csv`, the largest probability difference anywhere being 0.000000 (856.6 s of model time against 851.2 s for the shipped run); that run's summary is `out/reconfirm.json` and its console log
|
| 177 |
+
`runs/label_run_id_reconfirm.log`.
|
| 178 |
|
| 179 |
### Quality checks on the machine labels - read before using them
|
| 180 |
|
| 181 |
+
**Fit-for-purpose probes, in both languages.** 16 hand-written unambiguous sentences (8 clear anger,
|
| 182 |
+
8 clear contempt, written from the two Ekman pages, not from the corpus) in Indonesian and in
|
| 183 |
+
English, plus the project's reference English probe set, and the two controls that matter (question
|
| 184 |
+
language, option order). Chance is 0.50.
|
| 185 |
+
|
| 186 |
+
| condition | accuracy |
|
| 187 |
+
|---|---|
|
| 188 |
+
| the project's 16 reference English probes, English question | 13/16 (0.812) |
|
| 189 |
+
| the same 16 items in English, English question | 14/16 (0.875) |
|
| 190 |
+
| **the same 16 probes in Indonesian, English question** - the reading this dataset uses | **11/16 (0.688)** |
|
| 191 |
+
| the same Indonesian probes with an *Indonesian* question | 12/16 (0.750) |
|
| 192 |
+
| English probes with an Indonesian question | 14/16 (0.875) |
|
| 193 |
+
| Indonesian probes, criteria order swapped (contempt first) | 11/16 (0.688) |
|
| 194 |
+
|
| 195 |
+
The gap is 3 items out of 16: the same sentences are called correctly 14 times in English and 11 times in Indonesian. Mean P(anger) on the anger probes 0.68 in Indonesian vs 0.80 in English; on the contempt probes 0.31 vs 0.20. On the contempt items the mean P(anger) is 0.31 with anger listed first and 0.48 with contempt listed first - the order effect seen on the corpus. The Indonesian reading is therefore the weaker of
|
| 196 |
+
the two on these probes, and its errors lean toward `contempt`; putting the question in Indonesian
|
| 197 |
+
does not recover the gap (with the question in Indonesian instead of English, the gap closes only 11 -> 12 items).
|
| 198 |
+
|
| 199 |
+
**Option-order sensitivity on the corpus.** Listing contempt first moved the argmax on 25.1% of the pool (mean |delta p(anger)| 0.191; mean P(anger) 0.589 as prompted vs 0.726 with the options swapped), so the prompt's option order is worth roughly a third of the contempt shift. `p_anger_swapped` ships on every row, so
|
| 200 |
+
the debiased reading is `(p_anger_id + p_anger_swapped) / 2` if you want it.
|
| 201 |
+
|
| 202 |
+
**The corpus's own anger vocabulary.** 373 of the 475 pool rows contain an explicit Indonesian anger word (`kesal`, `marah`, `murka`, `benci`, `jengkel`, `geram`, `tersinggung`, `muak`, `ngamuk`) - which is how EmoTweetID's annotators sampled, so the word is upstream evidence for anger. 141 of those 373 rows (38%) are labelled `contempt` here. This is the sharpest single piece of evidence
|
| 203 |
+
on this card: the words that most plainly mean anger in Indonesian are where the Indonesian reading
|
| 204 |
+
calls contempt most often.
|
| 205 |
+
|
| 206 |
+
**One-reader audit of the disagreements.** A sample of 37 rows where the readings disagree was judged against the operational boundary by one reader working from the tweet text alone, before seeing any probability: 18/37 of those judgements land on the two-language reading, 4/37 on the label here, and 13/37 read as neither emotion. Of the 20 rows labelled `contempt` here and `anger` by the two-language reading, 1 was accepted as contempt. The reader is a machine reader, not a human annotator, and works on short code-mixed text - a signal, not gold labels.
|
| 207 |
+
|
| 208 |
+
**The `noul` probes are weak - and here they do more work than they should.** Their separation on the
|
| 209 |
+
probe sentences is small (mean P(superiority) 0.16 on contempt vs 0.13 on anger, which is why an
|
| 210 |
+
earlier reading of this pool only trusted them for 2 of 475 rows). On this reading 54 rows come
|
| 211 |
+
out inside the 0.10 margin, and 33 of them are decided by those probes - so a weak tie-breaker
|
| 212 |
+
settles 33 labels. Prefer the probability columns to `label` if that matters for your use:
|
| 213 |
+
`ekman_choice_id` decided 421, the option-order average 18, the upstream `anger`
|
| 214 |
+
label 3.
|
| 215 |
+
|
| 216 |
+
**Do not filter on `p_not_anger_or_contempt`.** 18 of 475 rows above 0.5 (mean P(neither) 0.12) - Indonesian reading. The most-flagged rows include some of the
|
| 217 |
+
angriest tweets in the pool (`AK MURKA`, `SUMPAH GUA MURKA LIAT INI. PEN GUA TEBAS JUGA LU PAK`), so
|
| 218 |
+
the probe is picking up register, not mislabels. It ships as a documented dead end.
|
| 219 |
+
|
| 220 |
+
**Confidence.** 99 of 475 rows land within 0.10 of a coin flip on the primary reading (max probability of the two options under 0.60), and the mean max probability across the pool is 0.754. `ekman_confidence` is laya's own confidence for the reading
|
| 221 |
+
(`1 - normalised entropy`, 0 = a coin flip), and 391 rows sit under 0.6. Note that
|
| 222 |
+
`out_prev/` stores max P(anger) in that column instead - a different scale, so the two are not
|
| 223 |
+
directly comparable.
|
| 224 |
+
|
| 225 |
+
Bottom line: all 475 pool labels are a machine decision from a 322M model whose own card
|
| 226 |
+
calls it "a fast base to specialise, not a zero-shot decision engine", asked in the language that
|
| 227 |
+
measures weaker on the probes above. The other 1,768 rows are human labels. `label_origin`
|
| 228 |
+
marks which is which; model and human error are not comparable across it, and the `anger`/`contempt`
|
| 229 |
+
rows are the noisier subset.
|
| 230 |
|
| 231 |
## Schema
|
| 232 |
|
| 233 |
| field | type | meaning |
|
| 234 |
|---|---|---|
|
| 235 |
+
| `text` | string | the tweet as written (Indonesian) - the model input |
|
| 236 |
+
| `text_en` | string | EmoTweetID's English machine translation. Not an input to any label here - kept because it is upstream data |
|
| 237 |
| `label` | string | one of the 7 Ekman classes |
|
| 238 |
| `label_idx` | ClassLabel | `label` as an int, in the order anger, contempt, disgust, enjoyment, fear, sadness, surprise (anger, contempt in the `anger_split` configs) |
|
| 239 |
| `source_label` | string | upstream EmoTweetID label (`anger`, `joy`, `fear`, `disgust`, `sadness`, `surprise`) |
|
| 240 |
| `label_origin` | string | `upstream_manual` (human label kept) or `laya_anger_split` (machine relabelled) |
|
| 241 |
+
| `label_source` | string | which rule produced an anger-pool label; `null` elsewhere |
|
| 242 |
+
| `ambiguous` | bool | the Indonesian `choice` reading stayed under the 0.10 margin |
|
| 243 |
+
| `ekman_p_anger`, `ekman_p_contempt` | float32 | the probabilities behind the label; `null` off the anger pool |
|
| 244 |
+
| `ekman_confidence` | float32 | laya's normalised-entropy confidence (0 = a coin flip) |
|
| 245 |
+
| `p_anger_id`, `ekman_margin_id` | float32 | the Indonesian reading: P(anger) and p(anger) - p(contempt) |
|
| 246 |
+
| `p_anger_swapped` | float32 | the same question with the criteria reversed - the option-order control |
|
| 247 |
+
| `p_superiority`, `p_blocked_or_unfair` | float32 | Ekman core-feature probes; only run on the rows the choice head could not settle, so `null` on most rows |
|
| 248 |
| `p_not_anger_or_contempt` | float32 | veto probe - weak, see quality checks |
|
|
|
|
| 249 |
| `row_src` | int32 | row index in EmoTweetID's `Data-Annotated-Tweet-File-RESULT.csv` |
|
| 250 |
|
| 251 |
## Configs, splits, sizes
|
| 252 |
|
| 253 |
+
Two kinds of config, on purpose.
|
| 254 |
+
|
| 255 |
+
**Whole pools.** `full` is all 2,243 rows at their natural class imbalance and `anger_split` is
|
| 256 |
+
the 475-row anger pool on its own, every evidence column populated. Each ships a single
|
| 257 |
+
`train` split holding the complete pool - nothing is held out, and if you want a validation set you
|
| 258 |
+
take it from there yourself.
|
| 259 |
+
|
| 260 |
+
**Exact 8:1:1.** `balanced` (the default) and `anger_split_balanced` are the two configs that carry a
|
| 261 |
+
train/valid/test. `b = floor(N/10)` is the bottleneck and the unit of the split: each class is sampled
|
| 262 |
+
to 180 rows - the largest multiple of ten that fits the smallest class, `contempt`,
|
| 263 |
+
at 186 eligible rows - giving N = 1,260 and b = 126. No rounding is left
|
| 264 |
+
anywhere: every class lands 144 / 18 / 18 per split, so the config is exactly balanced
|
| 265 |
+
per class *and* exactly 8b : 1b : 1b overall. `anger_split_balanced` applies the same rule to the
|
| 266 |
+
2-class pool: 360 rows, 288 / 36 / 36 overall and
|
| 267 |
+
144 / 18 / 18 per class. Sampling uses seed 0 and keeps whole duplicate groups,
|
| 268 |
+
so a wording never straddles two splits and a dropped row never orphans its duplicate.
|
| 269 |
+
|
| 270 |
+
`split_exact.py` and `test_split_exact.py` hold the arithmetic and the assertions; `verify()` re-checks
|
| 271 |
+
the written parquet, including that each class is the same size in every split.
|
| 272 |
|
| 273 |
| config | split | rows | per class |
|
| 274 |
|---|---|---|---|
|
| 275 |
+
| `balanced` | train | 1,008 | anger 144 / contempt 144 / disgust 144 / enjoyment 144 / fear 144 / sadness 144 / surprise 144 |
|
| 276 |
+
| `balanced` | valid | 126 | anger 18 / contempt 18 / disgust 18 / enjoyment 18 / fear 18 / sadness 18 / surprise 18 |
|
| 277 |
+
| `balanced` | test | 126 | anger 18 / contempt 18 / disgust 18 / enjoyment 18 / fear 18 / sadness 18 / surprise 18 |
|
| 278 |
+
| `full` | train | 2,243 | anger 289 / contempt 186 / disgust 355 / enjoyment 429 / fear 395 / sadness 303 / surprise 286 (the whole pool, one split) |
|
| 279 |
+
| `anger_split` | train | 475 | anger 289 / contempt 186 (the whole pool, one split) |
|
| 280 |
+
| `anger_split_balanced` | train | 288 | anger 144 / contempt 144 |
|
| 281 |
+
| `anger_split_balanced` | valid | 36 | anger 18 / contempt 18 |
|
| 282 |
+
| `anger_split_balanced` | test | 36 | anger 18 / contempt 18 |
|
| 283 |
+
|
| 284 |
+
29 rows share an identical `text` string with another row (more, if you count pairs whose English translation collides), and 14 of those repeated wordings repeat with *different* upstream labels - the annotators disagreed, and this dataset inherits that rather than re-judging it. Splitting is therefore **group-aware**: every member of a duplicate group lands in one split, so no wording appears in either side of a train/valid/test boundary (`verify()` fails the build if one does). The balanced configs sample whole groups as well, so a dropped row never orphans its duplicate.
|
| 285 |
+
|
| 286 |
+
## What the run cost, and what the optimisations were worth
|
| 287 |
+
|
| 288 |
+
Measured in a 2 vCPU / 2 GB CPU-only sandbox (`torch` 2.14.0+cpu, laya 0.3.4): 1533
|
| 289 |
+
row-scores in 851.2 s of model time (id core 299.8 s, id core swap 299.5 s, id diag 53.5 s, id veto 198.4 s). Asking all four questions of every row
|
| 290 |
+
would have cost 1900.
|
|
|
|
|
|
|
|
|
|
| 291 |
|
| 292 |
| change | why | measured effect |
|
| 293 |
|---|---|---|
|
| 294 |
| keep the encoder at **bf16** instead of laya's forced fp32 | laya sets `dtype = torch.float32` on CPU, upcasting the bf16 checkpoint to 1.29 GB; the stock path was **OOM-killed with exit 137** before it made a single prediction | the run goes from impossible to a 1420 MB peak RSS |
|
| 295 |
| **zero-copy** checkpoint load (mmap views instead of `safetensors.load_file`) | the stock loader materialises the 643 MB a second time before copying it into the model | removes a 643 MB transient; weights verified bitwise-identical to stock `load_file` |
|
| 296 |
+
| **staged questions** - the choice on every row, the core-feature probes only where the reading was not decisive, the veto and the order control as their own passes | asking every question everywhere costs 1900 row-scores | 1533 instead |
|
| 297 |
+
| length-sorted, token-budgeted **batches** | laya's `predict` costs one forward pass per state | 1.25x on the biggest stage at a 1024-token cap; small caps win because attention is quadratic per row and laya pads every row of a pass to that pass's longest sequence |
|
| 298 |
+
| **per-stage resumable cache** (`out/cache_<stage>.json`, shipped) | the decision rule can change after the model has run | all labels re-derived in seconds instead of a 15-minute re-run |
|
| 299 |
|
| 300 |
Two traps worth knowing:
|
| 301 |
|
| 302 |
* **`max_len` is not a speed dial.** laya builds `[CLS] <question + options> [SEP] <state> [SEP]` and
|
| 303 |
only *truncates* at `max_len`, so a 214-token sequence costs the same at `max_len=1024` as at 256
|
| 304 |
+
(measured 1.04x). The ~150-token prompt head every row pays is what dominates, so criteria length
|
| 305 |
+
is the real budget: cutting `head_max_len` 256 -> 128 left all 48 sampled argmaxes unchanged
|
| 306 |
+
(mean abs probability shift 0.045, exactly 0.000 at >=160), while 96 flipped 23% of them - so 144
|
| 307 |
+
was chosen (`sweep_config.py`).
|
| 308 |
+
* **laya truncates every option at 48 tokens** (`build_sequence`), so the criteria have to fit that
|
| 309 |
+
cap or the model scores half of Ekman's definition; `assert_option_budget()` fails the run if they
|
| 310 |
+
ever stop fitting, in either language.
|
|
|
|
| 311 |
|
| 312 |
## Using it
|
| 313 |
|
| 314 |
```python
|
| 315 |
from datasets import load_dataset
|
| 316 |
+
ds = load_dataset("mahalisyarifuddin/emotweetid-ekman7", "balanced") # default: exact 8:1:1, 7 classes, 180/class
|
| 317 |
ds["train"][0]["text"], ds["train"][0]["label"]
|
| 318 |
+
|
| 319 |
+
whole = load_dataset("mahalisyarifuddin/emotweetid-ekman7", "full") # every row, one `train` split
|
| 320 |
+
whole["train"] # 2,243 rows, natural imbalance
|
| 321 |
+
|
| 322 |
# the anger work on its own, with every evidence column:
|
| 323 |
+
ang = load_dataset("mahalisyarifuddin/emotweetid-ekman7", "anger_split") # all 475 pool rows, one split
|
| 324 |
+
ang = load_dataset("mahalisyarifuddin/emotweetid-ekman7", "anger_split_balanced") # same pool, 1:1, exact 8:1:1
|
| 325 |
+
```
|
| 326 |
+
|
| 327 |
+
If you want the option-order-debiased reading, recompute it from the shipped columns:
|
| 328 |
+
|
| 329 |
+
```python
|
| 330 |
+
p = (ang["train"]["p_anger_id"] + ang["train"]["p_anger_swapped"]) / 2 # 1 = anger, 0 = contempt
|
| 331 |
```
|
| 332 |
|
| 333 |
Or reproduce it end to end:
|
| 334 |
|
| 335 |
```bash
|
| 336 |
+
pip install laya scikit-learn pandas pyarrow datasets huggingface_hub scipy
|
| 337 |
python fetch_source_data.py # data/file1.csv + data/file2.csv (CC BY 4.0)
|
| 338 |
python prepare_checkpoint.py # models/laya-ml + models/enc-bf16 (bf16, low-mem)
|
| 339 |
+
python probe_quality_id.py # the probe matrix -> out/probe_quality_id.json
|
| 340 |
+
python label_anger_id.py --out out # ~15 min on 2 CPU cores, Indonesian only
|
| 341 |
+
python test_split_exact.py # exact 8:1:1 + no-leakage assertions
|
| 342 |
python make_dataset.py # splits + parquet + this card, with verification
|
| 343 |
python publish.py --repo <namespace>/<name> # HF upload; needs HF_TOKEN with write scope
|
| 344 |
```
|
|
|
|
| 347 |
2.14.0+cpu on CPU. The model was never loaded to build this repo's numbers:
|
| 348 |
`build_info.checkpoint_facts` reads them from the checkpoint's safetensors header.
|
| 349 |
|
| 350 |
+
Everything is in this repo: `label_anger_id.py` (the labeller as run), `ekman_questions.py`,
|
| 351 |
+
`ekman_questions_id.py`, `laya_opt.py`, `split_exact.py` + `test_split_exact.py`, `zcsafe.py`,
|
| 352 |
+
`prepare_checkpoint.py`, `make_dataset.py`, `probe_quality_id.py`, `probes.py` / `probes_id.py`,
|
| 353 |
+
`audit_flips.py`, `fetch_source_data.py`, `publish.py`, and the benchmarking scripts
|
| 354 |
+
(`bench_speedup.py`, `bench_batch.py`, `sweep_config.py`, `check_veto_and_speed.py`). The score
|
| 355 |
+
caches and evidence behind every label are in `out/` (`cache_id_core.json`, `cache_id_core_swap.json`,
|
| 356 |
+
`cache_id_diag.json`, `cache_id_veto.json`, `anger_ekman_rows.csv`, `probe_quality_id.json`,
|
| 357 |
+
`audit_flips.csv`, `timings.json`), and the project's earlier two-language reading of the pool in
|
| 358 |
+
`out_prev/`, so every claim on this card can be re-derived from the repo without the model. `build_info.json`
|
| 359 |
+
holds the exact counts behind it.
|
| 360 |
|
| 361 |
## Limitations
|
| 362 |
|
| 363 |
+
* **The Indonesian reading is the weaker of the two this project has measured**, and the probe matrix
|
| 364 |
+
above says by how much: the same 16 sentences are called correctly 14/16 (0.875) in English and
|
| 365 |
+
11/16 (0.688) in Indonesian, the errors lean toward `contempt`, and the reading moves with the option
|
| 366 |
+
order (25.1% of the pool). For the best anger/contempt discriminator this pipeline has
|
| 367 |
+
produced, take the two-language labels in `out_prev/anger_ekman_rows.csv`; for a decision that never
|
| 368 |
+
depends on a machine translation, use these.
|
| 369 |
+
* **Machine labels are weak-ish in general.** A 322M base model that laya's own card describes as "a
|
| 370 |
+
fast base to specialise, not a zero-shot decision engine" means the hard middle of the anger pool is
|
| 371 |
+
genuinely uncertain - exactly where Ekman says contempt rides along with mild anger ("often
|
| 372 |
+
accompanied by anger, usually in a mild form such as annoyance").
|
| 373 |
+
* **Mixed provenance.** 475 rows carry a machine decision; the other 1,768 carry
|
| 374 |
+
the annotators' labels. `label_origin` marks it; comparisons across the two are not
|
| 375 |
+
apples-to-apples, and any error analysis should be stratified by it.
|
| 376 |
+
* **`contempt` is still small** for a production need: 186 rows in the pool, so the
|
| 377 |
+
balanced configs give it 180 rows per class - enough for a two-way study or a
|
| 378 |
+
fine-tuning seed, not for a claim about contempt detection in the wild.
|
| 379 |
+
* **`text_en` is machine translation** and stays in the schema for reference only. Every label is
|
| 380 |
+
decided from `text`.
|
| 381 |
* **Upstream noise carries into the pool.** Only anger was audited; a mislabelled `joy`/`disgust` row
|
| 382 |
+
stays mislabelled here. The upstream annotation had substantial, not perfect, agreement, and the
|
| 383 |
+
audit above found several pool rows that read as neither anger nor contempt.
|
| 384 |
* **No neutral class**, and no intensity scores: an `intensity` question was written and measured, did
|
| 385 |
+
not discriminate (1.1-1.8 on all 16 probes), so it is not asked - it stays in `ekman_questions.py`
|
| 386 |
+
as a documented dead end rather than shipping as noise.
|
| 387 |
* Tweets are raw: all-caps, code-mixed Indonesian/Javanese/Malay, slang, emoji, insults and slurs.
|
| 388 |
Only whitespace was normalised.
|
| 389 |
|
README.template.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
---
|
| 2 |
license: cc-by-4.0
|
| 3 |
-
pretty_name: "EmoTweetID Ekman-7: five human-tagged Ekman emotions + the anger pool split into anger vs contempt
|
| 4 |
language:
|
| 5 |
- id
|
| 6 |
- en
|
|
@@ -42,18 +42,10 @@ configs:
|
|
| 42 |
data_files:
|
| 43 |
- split: train
|
| 44 |
path: full/train.parquet
|
| 45 |
-
- split: valid
|
| 46 |
-
path: full/valid.parquet
|
| 47 |
-
- split: test
|
| 48 |
-
path: full/test.parquet
|
| 49 |
- config_name: anger_split
|
| 50 |
data_files:
|
| 51 |
- split: train
|
| 52 |
path: anger_split/train.parquet
|
| 53 |
-
- split: valid
|
| 54 |
-
path: anger_split/valid.parquet
|
| 55 |
-
- split: test
|
| 56 |
-
path: anger_split/test.parquet
|
| 57 |
- config_name: anger_split_balanced
|
| 58 |
data_files:
|
| 59 |
- split: train
|
|
@@ -67,11 +59,13 @@ configs:
|
|
| 67 |
# EmoTweetID under Ekman's seven universal emotions
|
| 68 |
|
| 69 |
{{n_pool}} Indonesian tweets, one label each from Ekman's universal set - **anger, contempt, disgust,
|
| 70 |
-
enjoyment, fear, sadness, surprise**. {{n_anger_pool}} of them are the pool EmoTweetID tagged `anger`,
|
| 71 |
-
|
| 72 |
-
against Ekman's own definitions
|
| 73 |
-
{{
|
| 74 |
-
|
|
|
|
|
|
|
| 75 |
|
| 76 |
Why bother: Ekman lists anger and contempt as two different universal emotions with different
|
| 77 |
triggers, different messages and different facial signatures, but emotion corpora - and the models
|
|
@@ -82,7 +76,7 @@ system has to tell "you wronged me, put it right" from "you are beneath me".
|
|
| 82 |
|---|---|---|---|
|
| 83 |
{{class_table}}
|
| 84 |
|
| 85 |
-
##
|
| 86 |
|
| 87 |
| source label (EmoTweetID, human) | rows | treatment here |
|
| 88 |
|---|---|---|
|
|
@@ -91,7 +85,7 @@ system has to tell "you wronged me, put it right" from "you are beneath me".
|
|
| 91 |
| `disgust` | 355 | kept |
|
| 92 |
| `sadness` | 303 | kept |
|
| 93 |
| `surprise` | 286 | kept |
|
| 94 |
-
| `anger` |
|
| 95 |
|
| 96 |
`label_origin` on every row says which of the two applies, and `source_label` always keeps the
|
| 97 |
upstream name. Nothing else in the schema was modelled; there is no `neutral` class because
|
|
@@ -108,7 +102,13 @@ GoEmotions - which is why this card has 7 classes where the reference has 8.
|
|
| 108 |
[Mendeley Data jzgnjsff9f](https://data.mendeley.com/datasets/jzgnjsff9f).
|
| 109 |
* **Licence**: CC BY 4.0 on the source; this derived dataset is CC BY 4.0 as well.
|
| 110 |
* **Definitions**: [What is Anger?](https://www.paulekman.com/universal-emotions/what-is-anger/) and
|
| 111 |
-
[What is Contempt?](https://www.paulekman.com/universal-emotions/what-is-contempt/), Paul Ekman
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
## The two classes the split turns on, in Ekman's words
|
| 114 |
|
|
@@ -129,84 +129,140 @@ Operational boundary: **anger wants the obstacle gone; contempt puts the target
|
|
| 129 |
|
| 130 |
## How the anger split was decided
|
| 131 |
|
| 132 |
-
`pip install laya` (v{{laya_v}}), checkpoint `
|
| 133 |
-
tensors - a {{params_enc}} `{{enc_name}}` encoder ({{model_type}},
|
| 134 |
-
laya's own context cap {{ctx_default}} tokens) plus {{params_heads}} of
|
| 135 |
-
forward pass into probabilities over the options you asked about. For
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
### Quality checks on the machine labels - read before using them
|
| 154 |
|
| 155 |
-
*
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
|
| 176 |
## Schema
|
| 177 |
|
| 178 |
| field | type | meaning |
|
| 179 |
|---|---|---|
|
| 180 |
-
| `text` | string | the tweet as written (Indonesian) - the
|
| 181 |
-
| `text_en` | string | EmoTweetID's English translation |
|
| 182 |
| `label` | string | one of the 7 Ekman classes |
|
| 183 |
| `label_idx` | ClassLabel | `label` as an int, in the order anger, contempt, disgust, enjoyment, fear, sadness, surprise (anger, contempt in the `anger_split` configs) |
|
| 184 |
| `source_label` | string | upstream EmoTweetID label (`anger`, `joy`, `fear`, `disgust`, `sadness`, `surprise`) |
|
| 185 |
| `label_origin` | string | `upstream_manual` (human label kept) or `laya_anger_split` (machine relabelled) |
|
| 186 |
-
| `label_source` | string | which
|
| 187 |
-
| `
|
| 188 |
-
| `
|
| 189 |
-
| `
|
| 190 |
-
| `
|
| 191 |
-
| `
|
| 192 |
-
| `p_superiority`, `p_blocked_or_unfair` | float32 | Ekman core-feature probes; only run on rows the choice head could not settle, so `null` on most rows |
|
| 193 |
| `p_not_anger_or_contempt` | float32 | veto probe - weak, see quality checks |
|
| 194 |
-
| `ambiguous` | bool | neither language reading was decisive |
|
| 195 |
| `row_src` | int32 | row index in EmoTweetID's `Data-Annotated-Tweet-File-RESULT.csv` |
|
| 196 |
|
| 197 |
## Configs, splits, sizes
|
| 198 |
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
`
|
| 207 |
-
|
| 208 |
-
{{
|
| 209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
|
| 211 |
| config | split | rows | per class |
|
| 212 |
|---|---|---|---|
|
|
@@ -214,49 +270,62 @@ experiments; `full` keeps the natural imbalance of all {{n_pool}} rows; `anger_s
|
|
| 214 |
|
| 215 |
{{duplicates_note}}
|
| 216 |
|
| 217 |
-
##
|
| 218 |
|
| 219 |
-
Measured in a 2 vCPU / 2 GB CPU-only sandbox (`torch`
|
| 220 |
-
|
|
|
|
| 221 |
|
| 222 |
| change | why | measured effect |
|
| 223 |
|---|---|---|
|
| 224 |
| keep the encoder at **bf16** instead of laya's forced fp32 | laya sets `dtype = torch.float32` on CPU, upcasting the bf16 checkpoint to 1.29 GB; the stock path was **OOM-killed with exit 137** before it made a single prediction | the run goes from impossible to a 1420 MB peak RSS |
|
| 225 |
| **zero-copy** checkpoint load (mmap views instead of `safetensors.load_file`) | the stock loader materialises the 643 MB a second time before copying it into the model | removes a 643 MB transient; weights verified bitwise-identical to stock `load_file` |
|
| 226 |
-
| **staged questions** - choice on every row,
|
| 227 |
-
| length-sorted, token-budgeted **batches** | laya's `predict` costs one forward pass per state | 1.25x on the biggest stage at a 1024-token cap
|
| 228 |
-
| **per-stage resumable cache** (`out/cache_<stage>.json`, shipped) | the decision rule
|
| 229 |
|
| 230 |
Two traps worth knowing:
|
| 231 |
|
| 232 |
* **`max_len` is not a speed dial.** laya builds `[CLS] <question + options> [SEP] <state> [SEP]` and
|
| 233 |
only *truncates* at `max_len`, so a 214-token sequence costs the same at `max_len=1024` as at 256
|
| 234 |
-
(measured 1.04x). The ~150-token prompt head every row pays is what dominates, so criteria length
|
| 235 |
-
the real budget: cutting `head_max_len` 256 -> 128 left all 48 sampled argmaxes unchanged
|
| 236 |
-
probability shift 0.045, exactly 0.000 at >=160), while 96 flipped 23% of them - so 144
|
| 237 |
-
(`sweep_config.py`).
|
| 238 |
-
* **laya truncates every option at 48 tokens** (`build_sequence`)
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
if they ever stop fitting.
|
| 242 |
|
| 243 |
## Using it
|
| 244 |
|
| 245 |
```python
|
| 246 |
from datasets import load_dataset
|
| 247 |
-
ds = load_dataset("
|
| 248 |
ds["train"][0]["text"], ds["train"][0]["label"]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
# the anger work on its own, with every evidence column:
|
| 250 |
-
ang = load_dataset("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
```
|
| 252 |
|
| 253 |
Or reproduce it end to end:
|
| 254 |
|
| 255 |
```bash
|
| 256 |
-
pip install laya scikit-learn pandas pyarrow datasets huggingface_hub
|
| 257 |
python fetch_source_data.py # data/file1.csv + data/file2.csv (CC BY 4.0)
|
| 258 |
python prepare_checkpoint.py # models/laya-ml + models/enc-bf16 (bf16, low-mem)
|
| 259 |
-
python
|
|
|
|
|
|
|
| 260 |
python make_dataset.py # splits + parquet + this card, with verification
|
| 261 |
python publish.py --repo <namespace>/<name> # HF upload; needs HF_TOKEN with write scope
|
| 262 |
```
|
|
@@ -265,36 +334,43 @@ Built with laya {{laya_v}}, transformers {{transformers_v}}, datasets {{datasets
|
|
| 265 |
{{torch_v}} on CPU. The model was never loaded to build this repo's numbers:
|
| 266 |
`build_info.checkpoint_facts` reads them from the checkpoint's safetensors header.
|
| 267 |
|
| 268 |
-
Everything is in this repo: `
|
| 269 |
-
`
|
| 270 |
-
`
|
| 271 |
-
`
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
|
|
|
|
|
|
| 276 |
|
| 277 |
## Limitations
|
| 278 |
|
| 279 |
-
* **
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
* **Upstream noise carries into the pool.** Only anger was audited; a mislabelled `joy`/`disgust` row
|
| 294 |
-
stays mislabelled here. The upstream annotation had substantial, not perfect, agreement
|
|
|
|
| 295 |
* **No neutral class**, and no intensity scores: an `intensity` question was written and measured, did
|
| 296 |
-
not discriminate (1.1-1.8 on all 16 probes), so
|
| 297 |
-
|
| 298 |
* Tweets are raw: all-caps, code-mixed Indonesian/Javanese/Malay, slang, emoji, insults and slurs.
|
| 299 |
Only whitespace was normalised.
|
| 300 |
|
|
|
|
| 1 |
---
|
| 2 |
license: cc-by-4.0
|
| 3 |
+
pretty_name: "EmoTweetID Ekman-7: five human-tagged Ekman emotions + the anger pool split into anger vs contempt by laya, from the Indonesian text"
|
| 4 |
language:
|
| 5 |
- id
|
| 6 |
- en
|
|
|
|
| 42 |
data_files:
|
| 43 |
- split: train
|
| 44 |
path: full/train.parquet
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
- config_name: anger_split
|
| 46 |
data_files:
|
| 47 |
- split: train
|
| 48 |
path: anger_split/train.parquet
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
- config_name: anger_split_balanced
|
| 50 |
data_files:
|
| 51 |
- split: train
|
|
|
|
| 59 |
# EmoTweetID under Ekman's seven universal emotions
|
| 60 |
|
| 61 |
{{n_pool}} Indonesian tweets, one label each from Ekman's universal set - **anger, contempt, disgust,
|
| 62 |
+
enjoyment, fear, sadness, surprise**. {{n_anger_pool}} of them are the pool EmoTweetID tagged `anger`,
|
| 63 |
+
and that pool is the only place this dataset makes a decision of its own: [laya](https://pypi.org/project/laya/)
|
| 64 |
+
reads each of those tweets, in Indonesian, against Ekman's own definitions of the two emotions, and
|
| 65 |
+
splits them into **anger ({{n_anger_kept}})** and **contempt ({{n_contempt}})** - contempt is
|
| 66 |
+
{{share_contempt}}% of the pool. The other five classes are EmoTweetID's human annotations, carried over verbatim.
|
| 67 |
+
Four configs: `full` and `anger_split` are the complete pools, each in a single split; `balanced`
|
| 68 |
+
(default) and `anger_split_balanced` are exact 8:1:1 train/valid/test, seed 0, no duplicate leakage.
|
| 69 |
|
| 70 |
Why bother: Ekman lists anger and contempt as two different universal emotions with different
|
| 71 |
triggers, different messages and different facial signatures, but emotion corpora - and the models
|
|
|
|
| 76 |
|---|---|---|---|
|
| 77 |
{{class_table}}
|
| 78 |
|
| 79 |
+
## How each class got its label
|
| 80 |
|
| 81 |
| source label (EmoTweetID, human) | rows | treatment here |
|
| 82 |
|---|---|---|
|
|
|
|
| 85 |
| `disgust` | 355 | kept |
|
| 86 |
| `sadness` | 303 | kept |
|
| 87 |
| `surprise` | 286 | kept |
|
| 88 |
+
| `anger` | 475 | **re-read by laya, in Indonesian**, and split into `anger` / `contempt` |
|
| 89 |
|
| 90 |
`label_origin` on every row says which of the two applies, and `source_label` always keeps the
|
| 91 |
upstream name. Nothing else in the schema was modelled; there is no `neutral` class because
|
|
|
|
| 102 |
[Mendeley Data jzgnjsff9f](https://data.mendeley.com/datasets/jzgnjsff9f).
|
| 103 |
* **Licence**: CC BY 4.0 on the source; this derived dataset is CC BY 4.0 as well.
|
| 104 |
* **Definitions**: [What is Anger?](https://www.paulekman.com/universal-emotions/what-is-anger/) and
|
| 105 |
+
[What is Contempt?](https://www.paulekman.com/universal-emotions/what-is-contempt/), Paul Ekman
|
| 106 |
+
Group. The criteria shown to the model are condensed from these two pages.
|
| 107 |
+
* **Language**: every label here is decided from `text`, the tweet as written. `text_en` is
|
| 108 |
+
EmoTweetID's machine translation and is never an input to any label; it ships only because it is
|
| 109 |
+
upstream data. An earlier reading of this same pool used `text` and `text_en` together; those rows,
|
| 110 |
+
their probabilities and the caches behind them are kept in `out_prev/`, so the two readings can be
|
| 111 |
+
compared row by row - {{prev_note}}.
|
| 112 |
|
| 113 |
## The two classes the split turns on, in Ekman's words
|
| 114 |
|
|
|
|
| 129 |
|
| 130 |
## How the anger split was decided
|
| 131 |
|
| 132 |
+
`pip install laya` (v{{laya_v}}), checkpoint `convaiinnovations/laya`, subfolder `multilingual/`:
|
| 133 |
+
{{params}} params in {{tensors}} tensors - a {{params_enc}} `{{enc_name}}` encoder ({{model_type}},
|
| 134 |
+
bf16 weights, vocab {{vocab}}, laya's own context cap {{ctx_default}} tokens) plus {{params_heads}} of
|
| 135 |
+
decision heads that turn one forward pass into probabilities over the options you asked about. For
|
| 136 |
+
each tweet: one `choice` question whose two options are Ekman's criteria above, the same question
|
| 137 |
+
again with the options in the opposite order, `noul` probes of each emotion's core feature
|
| 138 |
+
(superiority, blocked-or-unfair) on the rows the choice head could not settle, and a
|
| 139 |
+
`not_anger_or_contempt` veto as a diagnostic. One non-autoregressive forward pass per question - no
|
| 140 |
+
generation, so nothing to parse and nothing to hallucinate. Every tweet is read in Indonesian; the
|
| 141 |
+
question itself stays laya's own English prompt, i.e. Ekman's criteria are quoted in the language
|
| 142 |
+
they were written in.
|
| 143 |
+
|
| 144 |
+
The four stages, over the {{n_anger_pool}} anger-pool rows:
|
| 145 |
+
|
| 146 |
+
| stage | question(s) | rows scored (state x question) | what it is for |
|
| 147 |
+
|---|---|---|---|
|
| 148 |
+
| `id_core` | `ekman` (choice) | {{n_anger_pool}} | the decision |
|
| 149 |
+
| `id_core_swap` | same, contempt listed first | {{n_anger_pool}} | option-order control (`p_anger_swapped`) |
|
| 150 |
+
| `id_diag` | `superiority`, `blocked_or_unfair` | {{stage_diag}} | only on the rows `id_core` left under a 0.10 margin |
|
| 151 |
+
| `id_veto` | `not_anger_or_contempt` | {{n_anger_pool}} | off-topic diagnostic - **do not filter on it** |
|
| 152 |
+
|
| 153 |
+
The decision rule, in order:
|
| 154 |
+
|
| 155 |
+
1. the `choice` reading is decisive (|p(anger) - p(contempt)| >= {{margin}}) -> its argmax
|
| 156 |
+
(`ekman_choice_id`);
|
| 157 |
+
2. not decisive -> Ekman's core-feature probes break the tie, superiority => contempt,
|
| 158 |
+
blocked-or-unfair => anger (`ekman_noul_tiebreak`);
|
| 159 |
+
3. both still under the margin -> the average of the two option orders decides, if it has a side
|
| 160 |
+
(`ekman_choice_order_avg`);
|
| 161 |
+
4. nothing at all -> keep the upstream EmoTweetID label `anger` (`kept_original_label`): this dataset
|
| 162 |
+
only ever *splits* an existing anger pool, it never re-litigates it.
|
| 163 |
+
|
| 164 |
+
Realised as: {{sources_str}}. Every probability is on the row - `p_anger_id` (as prompted),
|
| 165 |
+
`p_anger_swapped` (options reversed), `ekman_p_anger`, `ekman_p_contempt`, `ekman_margin_id`,
|
| 166 |
+
`p_superiority`, `p_blocked_or_unfair`, `p_not_anger_or_contempt` - so you can re-cut the split with
|
| 167 |
+
your own threshold instead of trusting this rule.
|
| 168 |
+
|
| 169 |
+
Reproducibility: {{repro_note}}. On a second, complete run of the labeller - fresh caches, same
|
| 170 |
+
sandbox - {{reconfirm_note}}; that run's summary is `out/reconfirm.json` and its console log
|
| 171 |
+
`runs/label_run_id_reconfirm.log`.
|
| 172 |
|
| 173 |
### Quality checks on the machine labels - read before using them
|
| 174 |
|
| 175 |
+
**Fit-for-purpose probes, in both languages.** 16 hand-written unambiguous sentences (8 clear anger,
|
| 176 |
+
8 clear contempt, written from the two Ekman pages, not from the corpus) in Indonesian and in
|
| 177 |
+
English, plus the project's reference English probe set, and the two controls that matter (question
|
| 178 |
+
language, option order). Chance is 0.50.
|
| 179 |
+
|
| 180 |
+
| condition | accuracy |
|
| 181 |
+
|---|---|
|
| 182 |
+
| the project's 16 reference English probes, English question | {{probe_author}} |
|
| 183 |
+
| the same 16 items in English, English question | {{probe_en}} |
|
| 184 |
+
| **the same 16 probes in Indonesian, English question** - the reading this dataset uses | **{{probe_id}}** |
|
| 185 |
+
| the same Indonesian probes with an *Indonesian* question | {{probe_id_idq}} |
|
| 186 |
+
| English probes with an Indonesian question | {{probe_en_idq}} |
|
| 187 |
+
| Indonesian probes, criteria order swapped (contempt first) | {{probe_id_swapped}} |
|
| 188 |
+
|
| 189 |
+
{{probe_gap}}. {{probe_mean_p}}. {{probe_order}}. The Indonesian reading is therefore the weaker of
|
| 190 |
+
the two on these probes, and its errors lean toward `contempt`; putting the question in Indonesian
|
| 191 |
+
does not recover the gap ({{probe_lang_q}}).
|
| 192 |
+
|
| 193 |
+
**Option-order sensitivity on the corpus.** {{order_note}}. `p_anger_swapped` ships on every row, so
|
| 194 |
+
the debiased reading is `(p_anger_id + p_anger_swapped) / 2` if you want it.
|
| 195 |
+
|
| 196 |
+
**The corpus's own anger vocabulary.** {{lexicon_note}} This is the sharpest single piece of evidence
|
| 197 |
+
on this card: the words that most plainly mean anger in Indonesian are where the Indonesian reading
|
| 198 |
+
calls contempt most often.
|
| 199 |
+
|
| 200 |
+
**One-reader audit of the disagreements.** {{audit_note}}
|
| 201 |
+
|
| 202 |
+
**The `noul` probes are weak - and here they do more work than they should.** Their separation on the
|
| 203 |
+
probe sentences is small (mean P(superiority) 0.16 on contempt vs 0.13 on anger, which is why an
|
| 204 |
+
earlier reading of this pool only trusted them for 2 of 475 rows). On this reading {{stageC}} rows come
|
| 205 |
+
out inside the 0.10 margin, and {{noul_n}} of them are decided by those probes - so a weak tie-breaker
|
| 206 |
+
settles {{noul_n}} labels. Prefer the probability columns to `label` if that matters for your use:
|
| 207 |
+
`ekman_choice_id` decided {{choice_n}}, the option-order average {{orderavg_n}}, the upstream `anger`
|
| 208 |
+
label {{kept_n}}.
|
| 209 |
+
|
| 210 |
+
**Do not filter on `p_not_anger_or_contempt`.** {{veto}}. The most-flagged rows include some of the
|
| 211 |
+
angriest tweets in the pool (`AK MURKA`, `SUMPAH GUA MURKA LIAT INI. PEN GUA TEBAS JUGA LU PAK`), so
|
| 212 |
+
the probe is picking up register, not mislabels. It ships as a documented dead end.
|
| 213 |
+
|
| 214 |
+
**Confidence.** {{conf_note}}. `ekman_confidence` is laya's own confidence for the reading
|
| 215 |
+
(`1 - normalised entropy`, 0 = a coin flip), and {{lowconf_laya}} rows sit under 0.6. Note that
|
| 216 |
+
`out_prev/` stores max P(anger) in that column instead - a different scale, so the two are not
|
| 217 |
+
directly comparable.
|
| 218 |
+
|
| 219 |
+
Bottom line: all {{n_anger_pool}} pool labels are a machine decision from a 322M model whose own card
|
| 220 |
+
calls it "a fast base to specialise, not a zero-shot decision engine", asked in the language that
|
| 221 |
+
measures weaker on the probes above. The other {{n_manual}} rows are human labels. `label_origin`
|
| 222 |
+
marks which is which; model and human error are not comparable across it, and the `anger`/`contempt`
|
| 223 |
+
rows are the noisier subset.
|
| 224 |
|
| 225 |
## Schema
|
| 226 |
|
| 227 |
| field | type | meaning |
|
| 228 |
|---|---|---|
|
| 229 |
+
| `text` | string | the tweet as written (Indonesian) - the model input |
|
| 230 |
+
| `text_en` | string | EmoTweetID's English machine translation. Not an input to any label here - kept because it is upstream data |
|
| 231 |
| `label` | string | one of the 7 Ekman classes |
|
| 232 |
| `label_idx` | ClassLabel | `label` as an int, in the order anger, contempt, disgust, enjoyment, fear, sadness, surprise (anger, contempt in the `anger_split` configs) |
|
| 233 |
| `source_label` | string | upstream EmoTweetID label (`anger`, `joy`, `fear`, `disgust`, `sadness`, `surprise`) |
|
| 234 |
| `label_origin` | string | `upstream_manual` (human label kept) or `laya_anger_split` (machine relabelled) |
|
| 235 |
+
| `label_source` | string | which rule produced an anger-pool label; `null` elsewhere |
|
| 236 |
+
| `ambiguous` | bool | the Indonesian `choice` reading stayed under the 0.10 margin |
|
| 237 |
+
| `ekman_p_anger`, `ekman_p_contempt` | float32 | the probabilities behind the label; `null` off the anger pool |
|
| 238 |
+
| `ekman_confidence` | float32 | laya's normalised-entropy confidence (0 = a coin flip) |
|
| 239 |
+
| `p_anger_id`, `ekman_margin_id` | float32 | the Indonesian reading: P(anger) and p(anger) - p(contempt) |
|
| 240 |
+
| `p_anger_swapped` | float32 | the same question with the criteria reversed - the option-order control |
|
| 241 |
+
| `p_superiority`, `p_blocked_or_unfair` | float32 | Ekman core-feature probes; only run on the rows the choice head could not settle, so `null` on most rows |
|
| 242 |
| `p_not_anger_or_contempt` | float32 | veto probe - weak, see quality checks |
|
|
|
|
| 243 |
| `row_src` | int32 | row index in EmoTweetID's `Data-Annotated-Tweet-File-RESULT.csv` |
|
| 244 |
|
| 245 |
## Configs, splits, sizes
|
| 246 |
|
| 247 |
+
Two kinds of config, on purpose.
|
| 248 |
+
|
| 249 |
+
**Whole pools.** `full` is all {{n_pool}} rows at their natural class imbalance and `anger_split` is
|
| 250 |
+
the {{n_anger_pool}}-row anger pool on its own, every evidence column populated. Each ships a single
|
| 251 |
+
`train` split holding the complete pool - nothing is held out, and if you want a validation set you
|
| 252 |
+
take it from there yourself.
|
| 253 |
+
|
| 254 |
+
**Exact 8:1:1.** `balanced` (the default) and `anger_split_balanced` are the two configs that carry a
|
| 255 |
+
train/valid/test. `b = floor(N/10)` is the bottleneck and the unit of the split: each class is sampled
|
| 256 |
+
to {{per_class_balanced}} rows - the largest multiple of ten that fits the smallest class, `contempt`,
|
| 257 |
+
at {{n_contempt}} eligible rows - giving N = {{n_balanced_s}} and b = {{balanced_b}}. No rounding is left
|
| 258 |
+
anywhere: every class lands {{balanced_per_class_split}} per split, so the config is exactly balanced
|
| 259 |
+
per class *and* exactly 8b : 1b : 1b overall. `anger_split_balanced` applies the same rule to the
|
| 260 |
+
2-class pool: {{n_anger_balanced_s}} rows, {{anger_split_balanced_split}} overall and
|
| 261 |
+
{{anger_balanced_per_class_split}} per class. Sampling uses seed 0 and keeps whole duplicate groups,
|
| 262 |
+
so a wording never straddles two splits and a dropped row never orphans its duplicate.
|
| 263 |
+
|
| 264 |
+
`split_exact.py` and `test_split_exact.py` hold the arithmetic and the assertions; `verify()` re-checks
|
| 265 |
+
the written parquet, including that each class is the same size in every split.
|
| 266 |
|
| 267 |
| config | split | rows | per class |
|
| 268 |
|---|---|---|---|
|
|
|
|
| 270 |
|
| 271 |
{{duplicates_note}}
|
| 272 |
|
| 273 |
+
## What the run cost, and what the optimisations were worth
|
| 274 |
|
| 275 |
+
Measured in a 2 vCPU / 2 GB CPU-only sandbox (`torch` {{torch_v}}, laya {{laya_v}}): {{scored_rows}}
|
| 276 |
+
row-scores in {{laya_seconds}} s of model time ({{stages}}). Asking all four questions of every row
|
| 277 |
+
would have cost {{naive_rows}}.
|
| 278 |
|
| 279 |
| change | why | measured effect |
|
| 280 |
|---|---|---|
|
| 281 |
| keep the encoder at **bf16** instead of laya's forced fp32 | laya sets `dtype = torch.float32` on CPU, upcasting the bf16 checkpoint to 1.29 GB; the stock path was **OOM-killed with exit 137** before it made a single prediction | the run goes from impossible to a 1420 MB peak RSS |
|
| 282 |
| **zero-copy** checkpoint load (mmap views instead of `safetensors.load_file`) | the stock loader materialises the 643 MB a second time before copying it into the model | removes a 643 MB transient; weights verified bitwise-identical to stock `load_file` |
|
| 283 |
+
| **staged questions** - the choice on every row, the core-feature probes only where the reading was not decisive, the veto and the order control as their own passes | asking every question everywhere costs {{naive_rows}} row-scores | {{scored_rows}} instead |
|
| 284 |
+
| length-sorted, token-budgeted **batches** | laya's `predict` costs one forward pass per state | 1.25x on the biggest stage at a 1024-token cap; small caps win because attention is quadratic per row and laya pads every row of a pass to that pass's longest sequence |
|
| 285 |
+
| **per-stage resumable cache** (`out/cache_<stage>.json`, shipped) | the decision rule can change after the model has run | all labels re-derived in seconds instead of a 15-minute re-run |
|
| 286 |
|
| 287 |
Two traps worth knowing:
|
| 288 |
|
| 289 |
* **`max_len` is not a speed dial.** laya builds `[CLS] <question + options> [SEP] <state> [SEP]` and
|
| 290 |
only *truncates* at `max_len`, so a 214-token sequence costs the same at `max_len=1024` as at 256
|
| 291 |
+
(measured 1.04x). The ~150-token prompt head every row pays is what dominates, so criteria length
|
| 292 |
+
is the real budget: cutting `head_max_len` 256 -> 128 left all 48 sampled argmaxes unchanged
|
| 293 |
+
(mean abs probability shift 0.045, exactly 0.000 at >=160), while 96 flipped 23% of them - so 144
|
| 294 |
+
was chosen (`sweep_config.py`).
|
| 295 |
+
* **laya truncates every option at 48 tokens** (`build_sequence`), so the criteria have to fit that
|
| 296 |
+
cap or the model scores half of Ekman's definition; `assert_option_budget()` fails the run if they
|
| 297 |
+
ever stop fitting, in either language.
|
|
|
|
| 298 |
|
| 299 |
## Using it
|
| 300 |
|
| 301 |
```python
|
| 302 |
from datasets import load_dataset
|
| 303 |
+
ds = load_dataset("{{repo}}", "balanced") # default: exact 8:1:1, 7 classes, {{per_class_balanced}}/class
|
| 304 |
ds["train"][0]["text"], ds["train"][0]["label"]
|
| 305 |
+
|
| 306 |
+
whole = load_dataset("{{repo}}", "full") # every row, one `train` split
|
| 307 |
+
whole["train"] # {{n_pool}} rows, natural imbalance
|
| 308 |
+
|
| 309 |
# the anger work on its own, with every evidence column:
|
| 310 |
+
ang = load_dataset("{{repo}}", "anger_split") # all {{n_anger_pool}} pool rows, one split
|
| 311 |
+
ang = load_dataset("{{repo}}", "anger_split_balanced") # same pool, 1:1, exact 8:1:1
|
| 312 |
+
```
|
| 313 |
+
|
| 314 |
+
If you want the option-order-debiased reading, recompute it from the shipped columns:
|
| 315 |
+
|
| 316 |
+
```python
|
| 317 |
+
p = (ang["train"]["p_anger_id"] + ang["train"]["p_anger_swapped"]) / 2 # 1 = anger, 0 = contempt
|
| 318 |
```
|
| 319 |
|
| 320 |
Or reproduce it end to end:
|
| 321 |
|
| 322 |
```bash
|
| 323 |
+
pip install laya scikit-learn pandas pyarrow datasets huggingface_hub scipy
|
| 324 |
python fetch_source_data.py # data/file1.csv + data/file2.csv (CC BY 4.0)
|
| 325 |
python prepare_checkpoint.py # models/laya-ml + models/enc-bf16 (bf16, low-mem)
|
| 326 |
+
python probe_quality_id.py # the probe matrix -> out/probe_quality_id.json
|
| 327 |
+
python label_anger_id.py --out out # ~15 min on 2 CPU cores, Indonesian only
|
| 328 |
+
python test_split_exact.py # exact 8:1:1 + no-leakage assertions
|
| 329 |
python make_dataset.py # splits + parquet + this card, with verification
|
| 330 |
python publish.py --repo <namespace>/<name> # HF upload; needs HF_TOKEN with write scope
|
| 331 |
```
|
|
|
|
| 334 |
{{torch_v}} on CPU. The model was never loaded to build this repo's numbers:
|
| 335 |
`build_info.checkpoint_facts` reads them from the checkpoint's safetensors header.
|
| 336 |
|
| 337 |
+
Everything is in this repo: `label_anger_id.py` (the labeller as run), `ekman_questions.py`,
|
| 338 |
+
`ekman_questions_id.py`, `laya_opt.py`, `split_exact.py` + `test_split_exact.py`, `zcsafe.py`,
|
| 339 |
+
`prepare_checkpoint.py`, `make_dataset.py`, `probe_quality_id.py`, `probes.py` / `probes_id.py`,
|
| 340 |
+
`audit_flips.py`, `fetch_source_data.py`, `publish.py`, and the benchmarking scripts
|
| 341 |
+
(`bench_speedup.py`, `bench_batch.py`, `sweep_config.py`, `check_veto_and_speed.py`). The score
|
| 342 |
+
caches and evidence behind every label are in `out/` (`cache_id_core.json`, `cache_id_core_swap.json`,
|
| 343 |
+
`cache_id_diag.json`, `cache_id_veto.json`, `anger_ekman_rows.csv`, `probe_quality_id.json`,
|
| 344 |
+
`audit_flips.csv`, `timings.json`), and the project's earlier two-language reading of the pool in
|
| 345 |
+
`out_prev/`, so every claim on this card can be re-derived from the repo without the model. `build_info.json`
|
| 346 |
+
holds the exact counts behind it.
|
| 347 |
|
| 348 |
## Limitations
|
| 349 |
|
| 350 |
+
* **The Indonesian reading is the weaker of the two this project has measured**, and the probe matrix
|
| 351 |
+
above says by how much: the same 16 sentences are called correctly {{probe_en}} in English and
|
| 352 |
+
{{probe_id}} in Indonesian, the errors lean toward `contempt`, and the reading moves with the option
|
| 353 |
+
order ({{order_flip}}% of the pool). For the best anger/contempt discriminator this pipeline has
|
| 354 |
+
produced, take the two-language labels in `out_prev/anger_ekman_rows.csv`; for a decision that never
|
| 355 |
+
depends on a machine translation, use these.
|
| 356 |
+
* **Machine labels are weak-ish in general.** A 322M base model that laya's own card describes as "a
|
| 357 |
+
fast base to specialise, not a zero-shot decision engine" means the hard middle of the anger pool is
|
| 358 |
+
genuinely uncertain - exactly where Ekman says contempt rides along with mild anger ("often
|
| 359 |
+
accompanied by anger, usually in a mild form such as annoyance").
|
| 360 |
+
* **Mixed provenance.** {{n_anger_pool}} rows carry a machine decision; the other {{n_manual}} carry
|
| 361 |
+
the annotators' labels. `label_origin` marks it; comparisons across the two are not
|
| 362 |
+
apples-to-apples, and any error analysis should be stratified by it.
|
| 363 |
+
* **`contempt` is still small** for a production need: {{n_contempt}} rows in the pool, so the
|
| 364 |
+
balanced configs give it {{per_class_balanced}} rows per class - enough for a two-way study or a
|
| 365 |
+
fine-tuning seed, not for a claim about contempt detection in the wild.
|
| 366 |
+
* **`text_en` is machine translation** and stays in the schema for reference only. Every label is
|
| 367 |
+
decided from `text`.
|
| 368 |
* **Upstream noise carries into the pool.** Only anger was audited; a mislabelled `joy`/`disgust` row
|
| 369 |
+
stays mislabelled here. The upstream annotation had substantial, not perfect, agreement, and the
|
| 370 |
+
audit above found several pool rows that read as neither anger nor contempt.
|
| 371 |
* **No neutral class**, and no intensity scores: an `intensity` question was written and measured, did
|
| 372 |
+
not discriminate (1.1-1.8 on all 16 probes), so it is not asked - it stays in `ekman_questions.py`
|
| 373 |
+
as a documented dead end rather than shipping as noise.
|
| 374 |
* Tweets are raw: all-caps, code-mixed Indonesian/Javanese/Malay, slang, emoji, insults and slurs.
|
| 375 |
Only whitespace was normalised.
|
| 376 |
|
anger_split/train.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c9f02c730f754e47cb6739fe3ec0c20d3030419889cd5a516f3fdd533ce0014a
|
| 3 |
+
size 111372
|
anger_split_balanced/test.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cca71de41a715882e972e521636141b6aa5bd04cc4ee54ae5a75867a8e5af468
|
| 3 |
+
size 17019
|
anger_split_balanced/train.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:50b4c2db23658d995bebef7ef2dae61ec7ff583e3b33f0ab4b424aa795458da4
|
| 3 |
+
size 72400
|
anger_split_balanced/valid.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a4f747736c49f620c511d1fd52a0dd8b5529855d2f973794a776cc2f74dbeaed
|
| 3 |
+
size 18608
|
balanced/test.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0148dab45546cd13803b29e6a958af7f994761bed8bda6eb59d7ad5cde20a187
|
| 3 |
+
size 31079
|
balanced/train.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:aedc9130d546852f787f34ff361a36e8bdb8091e15f121d4f8e16f4245b252e8
|
| 3 |
+
size 189405
|
balanced/valid.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:36f7743f3345e310db45481ae10f664f601dece7f4e871c0b4c6136891b87382
|
| 3 |
+
size 31486
|
build_info.json
CHANGED
|
@@ -1,69 +1,118 @@
|
|
| 1 |
{
|
| 2 |
-
"
|
| 3 |
-
"ambig": 2,
|
| 4 |
"amp": "bf16",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
"budget": 6144,
|
| 6 |
"checkpoint": "convaiinnovations/laya (subfolder `multilingual/`)",
|
| 7 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
"ctx_default": 1024,
|
| 9 |
"datasets_v": "5.0.1",
|
| 10 |
"dup_conflicts": 14,
|
| 11 |
-
"duplicates_note": "29 rows share an identical `text` string with another row (more, if you count pairs whose English translation collides), and 14 of those repeated wordings repeat with *different* upstream labels - the annotators disagreed, and this dataset inherits that rather than re-judging it. Splitting is therefore **group-aware**: every member of a duplicate group lands in one split, so no wording appears in
|
| 12 |
"enc_name": "jhu-clsp/mmBERT-base",
|
|
|
|
|
|
|
|
|
|
| 13 |
"head_max_len": 144,
|
| 14 |
-
"
|
|
|
|
| 15 |
"laya_v": "0.3.4",
|
| 16 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
"margin": 0.1,
|
| 18 |
"max_len": 256,
|
|
|
|
|
|
|
| 19 |
"model_type": "modernbert",
|
| 20 |
-
"
|
|
|
|
|
|
|
| 21 |
"n_anger_pool": "475",
|
| 22 |
-
"
|
| 23 |
-
"
|
|
|
|
|
|
|
|
|
|
| 24 |
"n_manual": "1,768",
|
| 25 |
"n_pool": "2,243",
|
| 26 |
-
"naive_rows":
|
| 27 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
"params": "321.9M",
|
| 29 |
"params_enc": "306.9M",
|
| 30 |
"params_heads": "15.0M",
|
| 31 |
-
"per_class_anger_balanced":
|
| 32 |
-
"per_class_balanced":
|
| 33 |
-
"
|
| 34 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
"repo": "mahalisyarifuddin/emotweetid-ekman7",
|
| 36 |
-
"
|
| 37 |
-
"
|
| 38 |
-
"
|
| 39 |
-
"
|
|
|
|
|
|
|
| 40 |
"splits": {
|
| 41 |
"anger_split": {
|
| 42 |
-
"
|
| 43 |
-
"train": 380,
|
| 44 |
-
"valid": 48
|
| 45 |
},
|
| 46 |
"anger_split_balanced": {
|
| 47 |
-
"test":
|
| 48 |
-
"train":
|
| 49 |
-
"valid":
|
| 50 |
},
|
| 51 |
"balanced": {
|
| 52 |
-
"test":
|
| 53 |
-
"train":
|
| 54 |
-
"valid":
|
| 55 |
},
|
| 56 |
"full": {
|
| 57 |
-
"
|
| 58 |
-
"train": 1794,
|
| 59 |
-
"valid": 226
|
| 60 |
}
|
| 61 |
},
|
| 62 |
-
"stageC":
|
| 63 |
-
"
|
|
|
|
| 64 |
"tensors": 170,
|
| 65 |
"torch_v": "2.14.0+cpu",
|
| 66 |
"transformers_v": "5.17.0",
|
| 67 |
-
"veto": "0.
|
| 68 |
-
"vocab": 256000
|
|
|
|
| 69 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"ambig": 54,
|
|
|
|
| 3 |
"amp": "bf16",
|
| 4 |
+
"anger_balanced_per_class_split": "144 / 18 / 18",
|
| 5 |
+
"anger_split_balanced_split": "288 / 36 / 36",
|
| 6 |
+
"audit_agree_new": 4,
|
| 7 |
+
"audit_agree_prev": 18,
|
| 8 |
+
"audit_caveat": "one reader, unblinded to the hypothesis, and the pool is short, shouty, code-mixed Indonesian - rerun this on a larger sample before quoting it",
|
| 9 |
+
"audit_n": 37,
|
| 10 |
+
"audit_note": "A sample of 37 rows where the readings disagree was judged against the operational boundary by one reader working from the tweet text alone, before seeing any probability: 18/37 of those judgements land on the two-language reading, 4/37 on the label here, and 13/37 read as neither emotion. Of the 20 rows labelled `contempt` here and `anger` by the two-language reading, 1 was accepted as contempt. The reader is a machine reader, not a human annotator, and works on short code-mixed text - a signal, not gold labels.",
|
| 11 |
+
"audit_other": 13,
|
| 12 |
+
"balanced_b": 126,
|
| 13 |
+
"balanced_per_class_split": "144 / 18 / 18",
|
| 14 |
+
"balanced_split": "1008 / 126 / 126",
|
| 15 |
"budget": 6144,
|
| 16 |
"checkpoint": "convaiinnovations/laya (subfolder `multilingual/`)",
|
| 17 |
+
"choice_n": 421,
|
| 18 |
+
"class_table": "| `anger` | 289 | 12.9% | split here: laya on the `anger` pool |\n| `contempt` | 186 | 8.3% | split here: laya on the `anger` pool |\n| `disgust` | 355 | 15.8% | EmoTweetID annotators, kept verbatim |\n| `enjoyment` | 429 | 19.1% | EmoTweetID annotators, kept verbatim |\n| `fear` | 395 | 17.6% | EmoTweetID annotators, kept verbatim |\n| `sadness` | 303 | 13.5% | EmoTweetID annotators, kept verbatim |\n| `surprise` | 286 | 12.8% | EmoTweetID annotators, kept verbatim |",
|
| 19 |
+
"conf_low_new": 99,
|
| 20 |
+
"conf_low_prev": 48,
|
| 21 |
+
"conf_note": "99 of 475 rows land within 0.10 of a coin flip on the primary reading (max probability of the two options under 0.60), and the mean max probability across the pool is 0.754",
|
| 22 |
"ctx_default": 1024,
|
| 23 |
"datasets_v": "5.0.1",
|
| 24 |
"dup_conflicts": 14,
|
| 25 |
+
"duplicates_note": "29 rows share an identical `text` string with another row (more, if you count pairs whose English translation collides), and 14 of those repeated wordings repeat with *different* upstream labels - the annotators disagreed, and this dataset inherits that rather than re-judging it. Splitting is therefore **group-aware**: every member of a duplicate group lands in one split, so no wording appears in either side of a train/valid/test boundary (`verify()` fails the build if one does). The balanced configs sample whole groups as well, so a dropped row never orphans its duplicate.",
|
| 26 |
"enc_name": "jhu-clsp/mmBERT-base",
|
| 27 |
+
"flip_to_anger": 12,
|
| 28 |
+
"flip_to_contempt": 104,
|
| 29 |
+
"flipped": 116,
|
| 30 |
"head_max_len": 144,
|
| 31 |
+
"kept_n": 3,
|
| 32 |
+
"laya_seconds": 851.2,
|
| 33 |
"laya_v": "0.3.4",
|
| 34 |
+
"lexicon_contempt_new": 141,
|
| 35 |
+
"lexicon_contempt_prev": 57,
|
| 36 |
+
"lexicon_note": "373 of the 475 pool rows contain an explicit Indonesian anger word (`kesal`, `marah`, `murka`, `benci`, `jengkel`, `geram`, `tersinggung`, `muak`, `ngamuk`) - which is how EmoTweetID's annotators sampled, so the word is upstream evidence for anger. 141 of those 373 rows (38%) are labelled `contempt` here.",
|
| 37 |
+
"lexicon_rows": 373,
|
| 38 |
+
"lowconf": 391,
|
| 39 |
+
"lowconf_laya": 391,
|
| 40 |
"margin": 0.1,
|
| 41 |
"max_len": 256,
|
| 42 |
+
"mean_p_anger_prompt": 0.589,
|
| 43 |
+
"mean_p_anger_swapped": 0.726,
|
| 44 |
"model_type": "modernbert",
|
| 45 |
+
"n_anger_balanced": 360,
|
| 46 |
+
"n_anger_balanced_s": "360",
|
| 47 |
+
"n_anger_kept": 289,
|
| 48 |
"n_anger_pool": "475",
|
| 49 |
+
"n_anger_pool_rows": 475,
|
| 50 |
+
"n_balanced": 1260,
|
| 51 |
+
"n_balanced_s": "1,260",
|
| 52 |
+
"n_contempt": 186,
|
| 53 |
+
"n_full_pool": 2243,
|
| 54 |
"n_manual": "1,768",
|
| 55 |
"n_pool": "2,243",
|
| 56 |
+
"naive_rows": 1900,
|
| 57 |
+
"noul_n": 33,
|
| 58 |
+
"offtopic": 18,
|
| 59 |
+
"order_flip": 25.1,
|
| 60 |
+
"order_note": "Listing contempt first moved the argmax on 25.1% of the pool (mean |delta p(anger)| 0.191; mean P(anger) 0.589 as prompted vs 0.726 with the options swapped), so the prompt's option order is worth roughly a third of the contempt shift",
|
| 61 |
+
"order_shift": 0.191,
|
| 62 |
+
"orderavg_n": 18,
|
| 63 |
"params": "321.9M",
|
| 64 |
"params_enc": "306.9M",
|
| 65 |
"params_heads": "15.0M",
|
| 66 |
+
"per_class_anger_balanced": 180,
|
| 67 |
+
"per_class_balanced": 180,
|
| 68 |
+
"prev_anger": 381,
|
| 69 |
+
"prev_contempt": 94,
|
| 70 |
+
"prev_note": "it labelled 381 anger / 94 contempt; the labels here differ on 116 of the 475 rows, 104 of them anger -> contempt",
|
| 71 |
+
"prev_share_contempt": 19.8,
|
| 72 |
+
"probe_author": "13/16 (0.812)",
|
| 73 |
+
"probe_en": "14/16 (0.875)",
|
| 74 |
+
"probe_en_idq": "14/16 (0.875)",
|
| 75 |
+
"probe_en_q": "English items with the Indonesian question: 14/16 (0.875)",
|
| 76 |
+
"probe_gap": "The gap is 3 items out of 16: the same sentences are called correctly 14 times in English and 11 times in Indonesian",
|
| 77 |
+
"probe_id": "11/16 (0.688)",
|
| 78 |
+
"probe_id_idq": "12/16 (0.750)",
|
| 79 |
+
"probe_id_swapped": "11/16 (0.688)",
|
| 80 |
+
"probe_lang_q": "with the question in Indonesian instead of English, the gap closes only 11 -> 12 items",
|
| 81 |
+
"probe_mean_p": "Mean P(anger) on the anger probes 0.68 in Indonesian vs 0.80 in English; on the contempt probes 0.31 vs 0.20",
|
| 82 |
+
"probe_order": "On the contempt items the mean P(anger) is 0.31 with anger listed first and 0.48 with contempt listed first - the order effect seen on the corpus",
|
| 83 |
+
"reconfirm_note": "every stage (id_core, id_core_swap, id_diag, id_veto) matched row for row and reproduced **475/475 labels**, down to a byte-identical `anger_ekman_rows.csv`, the largest probability difference anywhere being 0.000000 (856.6 s of model time against 851.2 s for the shipped run)",
|
| 84 |
"repo": "mahalisyarifuddin/emotweetid-ekman7",
|
| 85 |
+
"repro_note": "the `id_core` stage matches the earlier two-language run's `out_prev/cache_id_core.json` (shipped here) to the last digit - 471/471 unique texts on the same side of the decision line, mean |delta p(anger)| 0.0000, max 0.0000",
|
| 86 |
+
"scored_rows": 1533,
|
| 87 |
+
"share_contempt": 39.2,
|
| 88 |
+
"sources_str": "`ekman_choice_id` 421, `ekman_noul_tiebreak` 33, `ekman_choice_order_avg` 18, `kept_original_label` 3",
|
| 89 |
+
"split_exact_note": "balanced 1008 / 126 / 126 of 1,260 (b=126), full 1 split of 2,243, anger_split 1 split of 475, anger_split_balanced 288 / 36 / 36 of 360 (b=36)",
|
| 90 |
+
"split_table": "| `balanced` | train | 1,008 | anger 144 / contempt 144 / disgust 144 / enjoyment 144 / fear 144 / sadness 144 / surprise 144 |\n| `balanced` | valid | 126 | anger 18 / contempt 18 / disgust 18 / enjoyment 18 / fear 18 / sadness 18 / surprise 18 |\n| `balanced` | test | 126 | anger 18 / contempt 18 / disgust 18 / enjoyment 18 / fear 18 / sadness 18 / surprise 18 |\n| `full` | train | 2,243 | anger 289 / contempt 186 / disgust 355 / enjoyment 429 / fear 395 / sadness 303 / surprise 286 (the whole pool, one split) |\n| `anger_split` | train | 475 | anger 289 / contempt 186 (the whole pool, one split) |\n| `anger_split_balanced` | train | 288 | anger 144 / contempt 144 |\n| `anger_split_balanced` | valid | 36 | anger 18 / contempt 18 |\n| `anger_split_balanced` | test | 36 | anger 18 / contempt 18 |",
|
| 91 |
"splits": {
|
| 92 |
"anger_split": {
|
| 93 |
+
"train": 475
|
|
|
|
|
|
|
| 94 |
},
|
| 95 |
"anger_split_balanced": {
|
| 96 |
+
"test": 36,
|
| 97 |
+
"train": 288,
|
| 98 |
+
"valid": 36
|
| 99 |
},
|
| 100 |
"balanced": {
|
| 101 |
+
"test": 126,
|
| 102 |
+
"train": 1008,
|
| 103 |
+
"valid": 126
|
| 104 |
},
|
| 105 |
"full": {
|
| 106 |
+
"train": 2243
|
|
|
|
|
|
|
| 107 |
}
|
| 108 |
},
|
| 109 |
+
"stageC": 54,
|
| 110 |
+
"stage_diag": 108,
|
| 111 |
+
"stages": "id core 299.8 s, id core swap 299.5 s, id diag 53.5 s, id veto 198.4 s",
|
| 112 |
"tensors": 170,
|
| 113 |
"torch_v": "2.14.0+cpu",
|
| 114 |
"transformers_v": "5.17.0",
|
| 115 |
+
"veto": "18 of 475 rows above 0.5 (mean P(neither) 0.12) - Indonesian reading",
|
| 116 |
+
"vocab": 256000,
|
| 117 |
+
"whole_note": "`full` and `anger_split` are the complete pools in a single `train` split - nothing is held out, and users who want their own validation split take it from there. The two balanced configs are the ones that carry an exact 8:1:1 train/valid/test."
|
| 118 |
}
|
ekman_questions_id.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Indonesian renderings of the two Ekman criteria, for the prompt-language control.
|
| 2 |
+
|
| 3 |
+
The published run asks an English question about the tweet (=layas own prompt wording, Ekman's
|
| 4 |
+
definitions in the language they were written in). This module adds the same question in
|
| 5 |
+
Indonesian, so `probe_quality_id.py` can hold the tweet fixed and vary the *question* language.
|
| 6 |
+
Criteria are condensed from the same two Paul Ekman Group pages quoted in ekman_questions.py and
|
| 7 |
+
kept inside laya's 48-token per-option cap.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
ANGER_CRITERION_ID = (
|
| 11 |
+
"anger: terhalang mencapai tujuan atau diperlakukan tidak adil; 'minggir dari jalanku'; dari "
|
| 12 |
+
"sekadar tidak puas sampai ancaman; ingin halangan atau ketidakadilan itu dihilangkan, "
|
| 13 |
+
"diarahkan pada perbuatannya bukan pada orangnya"
|
| 14 |
+
)
|
| 15 |
+
CONTEMPT_CRITERION_ID = (
|
| 16 |
+
"contempt: tidak suka sekaligus merasa lebih unggul secara moral - 'aku lebih baik darimu dan "
|
| 17 |
+
"kau lebih rendah'; meremehkan, memandang rendah, menganggap lawan tak pantas diladeni"
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
EKMAN_QUESTIONS_ID = {
|
| 21 |
+
"ekman": {
|
| 22 |
+
"type": "choice",
|
| 23 |
+
"instructions": (
|
| 24 |
+
"Dari dua emosi Ekman ini, mana yang diungkapkan penulis tweet? Anger muncul karena "
|
| 25 |
+
"terhalang atau diperlakukan tidak adil dan mendorong menghilangkan hal itu; contempt "
|
| 26 |
+
"muncul dari perasaan lebih unggul dari sasaran"
|
| 27 |
+
),
|
| 28 |
+
"criteria": {"anger": ANGER_CRITERION_ID, "contempt": CONTEMPT_CRITERION_ID},
|
| 29 |
+
},
|
| 30 |
+
"superiority": {
|
| 31 |
+
"type": "noul",
|
| 32 |
+
"instructions": (
|
| 33 |
+
"Apakah penulis menyatakan dirinya lebih baik dari sasaran - meremehkan, mengejek atau "
|
| 34 |
+
"menganggap mereka rendah, bodoh atau tak pantas, dengan nada sok benar - bukan menuntut "
|
| 35 |
+
"sesuatu dari mereka?"
|
| 36 |
+
),
|
| 37 |
+
},
|
| 38 |
+
"blocked_or_unfair": {
|
| 39 |
+
"type": "noul",
|
| 40 |
+
"instructions": (
|
| 41 |
+
"Apakah penulis terhalang mencapai tujuan atau diperlakukan tidak adil lalu melawan - "
|
| 42 |
+
"menuntut halangan atau kesalahan itu dihilangkan, dibayar atau dihukum, atau mengancam "
|
| 43 |
+
"akan melakukannya sendiri?"
|
| 44 |
+
),
|
| 45 |
+
},
|
| 46 |
+
"not_anger_or_contempt": {
|
| 47 |
+
"type": "noul",
|
| 48 |
+
"instructions": (
|
| 49 |
+
"Apakah tweet ini BUKAN penulis mengungkapkan anger atau contempt-nya sendiri - misalnya "
|
| 50 |
+
"netral, positif, sedih, takut atau jijik, atau hanya melaporkan bahwa orang lain marah?"
|
| 51 |
+
),
|
| 52 |
+
},
|
| 53 |
+
}
|
full/train.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c0939073c33d5ad3fcbb827b44925b9f97273fff70767b6c94ea316d77398707
|
| 3 |
+
size 391033
|
label_anger_id.py
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
"""Split EmoTweetID's `anger` pool into `anger` vs `contempt` with laya - **Indonesian only**.
|
| 3 |
+
|
| 4 |
+
Difference from `label_anger.py`: the English translation (`tweet_en`) is never shown to the model.
|
| 5 |
+
The published run read every tweet twice, once in Indonesian and once in EmoTweetID's machine
|
| 6 |
+
translation, and pooled the two; the translation mistranslates the slang and code-mixing these
|
| 7 |
+
tweets are made of (`GUA MURKA` -> "THE CAVE IS ANGER"), so the English reading is what defined
|
| 8 |
+
122 of the 475 shipped labels. Here the decision is made from `text` alone.
|
| 9 |
+
|
| 10 |
+
Stages (all on Indonesian text; the question wording stays laya's own English prompt, i.e. the
|
| 11 |
+
criteria are Ekman's, quoted in the language they were written in):
|
| 12 |
+
|
| 13 |
+
id_core `ekman` choice on all 475 rows. Same stage name, questions and texts as the
|
| 14 |
+
published `out/cache_id_core.json`, so this stage must reproduce that cache
|
| 15 |
+
*exactly* - the run asserts it and the card quotes the agreement. This is the
|
| 16 |
+
primary reading.
|
| 17 |
+
id_core_swap the same choice with the two criteria in the opposite order. Measured on the
|
| 18 |
+
probe set, the option listed second is favoured (mean P(anger) on contempt probes
|
| 19 |
+
0.31 with anger first vs 0.48 with contempt first), so the swapped pass records how
|
| 20 |
+
much of the contempt shift is prompt-order artifact. `p_anger_swapped` ships on
|
| 21 |
+
every row; the average of the two orders is the debiased reading.
|
| 22 |
+
id_diag Ekman's core-feature probes (superiority, blocked_or_unfair) - only on the rows
|
| 23 |
+
where the primary choice reading is not decisive (|margin| < 0.10).
|
| 24 |
+
id_veto the `not_anger_or_contempt` diagnostic on all rows (card: do not filter on it).
|
| 25 |
+
|
| 26 |
+
Output: out/anger_ekman_rows.csv, out/timings.json, out/cache_<stage>.json.
|
| 27 |
+
"""
|
| 28 |
+
import argparse
|
| 29 |
+
import hashlib
|
| 30 |
+
import json
|
| 31 |
+
import os
|
| 32 |
+
import re
|
| 33 |
+
import sys
|
| 34 |
+
import time
|
| 35 |
+
|
| 36 |
+
import numpy as np
|
| 37 |
+
import pandas as pd
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def norm(s):
|
| 41 |
+
return re.sub(r"\s+", " ", str(s)).strip()
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def cache_path(out_dir, stage):
|
| 45 |
+
return os.path.join(out_dir, "cache_%s.json" % stage)
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def load_cache(path):
|
| 49 |
+
if os.path.exists(path):
|
| 50 |
+
with open(path) as f:
|
| 51 |
+
return {k: v for k, v in json.load(f).items()}
|
| 52 |
+
return {}
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def save_cache(path, cache):
|
| 56 |
+
tmp = path + ".tmp"
|
| 57 |
+
with open(tmp, "w") as f:
|
| 58 |
+
json.dump(cache, f)
|
| 59 |
+
os.replace(tmp, path)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def run_stage(agent, laya_opt, questions, texts, out_dir, stage, max_len, head_max_len, budget):
|
| 63 |
+
"""Score `texts` with `questions`, one cache row per (text, stage) so a re-run resumes."""
|
| 64 |
+
cache = load_cache(cache_path(out_dir, stage))
|
| 65 |
+
todo_idx, todo_txt = [], []
|
| 66 |
+
for t in texts:
|
| 67 |
+
key = hashlib.sha1(("%s|%s" % (stage, t)).encode()).hexdigest()[:16]
|
| 68 |
+
if key not in cache:
|
| 69 |
+
todo_idx.append(key)
|
| 70 |
+
todo_txt.append(t)
|
| 71 |
+
print("[stage %s] %d rows to score, %d already cached" % (
|
| 72 |
+
stage, len(todo_txt), len(texts) - len(todo_txt)), flush=True)
|
| 73 |
+
t0 = time.time()
|
| 74 |
+
if todo_txt:
|
| 75 |
+
res, stats = laya_opt.score_texts(agent, questions, todo_txt, max_len=max_len,
|
| 76 |
+
head_max_len=head_max_len, token_budget=budget,
|
| 77 |
+
log=lambda *a: None)
|
| 78 |
+
for k, r in zip(todo_idx, res):
|
| 79 |
+
cache[k] = r
|
| 80 |
+
save_cache(cache_path(out_dir, stage), cache)
|
| 81 |
+
print("[stage %s] %s" % (stage, json.dumps(stats)), flush=True)
|
| 82 |
+
else:
|
| 83 |
+
stats = {"seconds": 0.0}
|
| 84 |
+
out = []
|
| 85 |
+
for t in texts:
|
| 86 |
+
key = hashlib.sha1(("%s|%s" % (stage, t)).encode()).hexdigest()[:16]
|
| 87 |
+
if key not in cache:
|
| 88 |
+
raise RuntimeError("cache miss for %s after stage %s" % (key, stage))
|
| 89 |
+
out.append(cache[key])
|
| 90 |
+
return out, stats
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def combine_id(probs, swap=None, sup=None, blk=None, choice_margin=0.10, noul_margin=0.05):
|
| 94 |
+
"""(label, label_source, margin, p_anger, p_contempt).
|
| 95 |
+
|
| 96 |
+
Rules, in order - the single-reading version of `ekman_questions.combine`:
|
| 97 |
+
|
| 98 |
+
1. the Indonesian choice reading is decisive (|p(anger) - p(contempt)| >= 0.10) -> its argmax
|
| 99 |
+
(`ekman_choice_id`).
|
| 100 |
+
2. not decisive -> Ekman's core-feature probes break the tie: superiority => contempt,
|
| 101 |
+
blocked-or-unfair => anger (`ekman_noul_tiebreak`).
|
| 102 |
+
3. not decisive and probes agree too -> the *order-averaged* reading decides if it has a
|
| 103 |
+
side to pick (`ekman_choice_order_avg`).
|
| 104 |
+
4. still nothing -> keep the upstream EmoTweetID label `anger`: this dataset only ever splits
|
| 105 |
+
an existing anger pool, it does not re-litigate it (`kept_original_label`).
|
| 106 |
+
"""
|
| 107 |
+
p_a, p_c = probs["anger"], probs["contempt"]
|
| 108 |
+
m = p_a - p_c
|
| 109 |
+
src = "ekman_choice_id"
|
| 110 |
+
if abs(m) < choice_margin:
|
| 111 |
+
m = m
|
| 112 |
+
if sup is not None and blk is not None and abs(sup - blk) >= noul_margin:
|
| 113 |
+
lab = "contempt" if sup > blk else "anger"
|
| 114 |
+
return lab, "ekman_noul_tiebreak", m, p_a, p_c
|
| 115 |
+
if swap is not None:
|
| 116 |
+
ma = ((p_a + swap["anger"]) - (p_c + swap["contempt"])) / 2.0
|
| 117 |
+
if abs(ma) >= choice_margin:
|
| 118 |
+
return ("anger" if ma >= 0 else "contempt"), "ekman_choice_order_avg", m, p_a, p_c
|
| 119 |
+
return "anger", "kept_original_label", m, p_a, p_c
|
| 120 |
+
return ("anger" if p_a >= p_c else "contempt"), src, m, p_a, p_c
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def main():
|
| 124 |
+
ap = argparse.ArgumentParser()
|
| 125 |
+
ap.add_argument("--max-len", type=int, default=256)
|
| 126 |
+
ap.add_argument("--head-max-len", type=int, default=144)
|
| 127 |
+
ap.add_argument("--token-budget", type=int, default=6144)
|
| 128 |
+
ap.add_argument("--margin", type=float, default=0.10)
|
| 129 |
+
ap.add_argument("--out", default="build/out")
|
| 130 |
+
ap.add_argument("--limit", type=int, default=0)
|
| 131 |
+
ap.add_argument("--no-swap", action="store_true", help="skip the option-order control pass")
|
| 132 |
+
ap.add_argument("--no-veto", action="store_true", help="skip the not_anger_or_contempt diagnostic")
|
| 133 |
+
args = ap.parse_args()
|
| 134 |
+
|
| 135 |
+
os.makedirs(args.out, exist_ok=True)
|
| 136 |
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 137 |
+
import laya_opt
|
| 138 |
+
from ekman_questions import CHOICE_MARGIN, EKMAN_QUESTIONS, assert_option_budget
|
| 139 |
+
|
| 140 |
+
t_load = time.time()
|
| 141 |
+
agent = laya_opt.load_agent()
|
| 142 |
+
print("[laya] agent ready in %.1fs (%d params)" % (
|
| 143 |
+
time.time() - t_load, sum(p.numel() for p in agent.model.parameters())), flush=True)
|
| 144 |
+
assert_option_budget(agent.tok)
|
| 145 |
+
print("[laya] option budget ok: every criterion fits laya's 48-token cap", flush=True)
|
| 146 |
+
|
| 147 |
+
# ---- data: identical input to the published run, so the Indonesian stage is comparable -------
|
| 148 |
+
f1 = pd.read_csv("data/file1.csv", index_col=0)
|
| 149 |
+
f2 = pd.read_csv("data/file2.csv", index_col=0)
|
| 150 |
+
assert len(f1) == len(f2) and (f1.index == f2.index).all(), "the two EmoTweetID files must align"
|
| 151 |
+
df = f1.join(f2)
|
| 152 |
+
df = df[df["label"] == "anger"].copy()
|
| 153 |
+
df["row_src"] = df.index
|
| 154 |
+
df["text_en"] = df["tweet_en"].map(norm)
|
| 155 |
+
df["text_id"] = df["tweet"].map(norm)
|
| 156 |
+
df = df[df["text_en"].str.len() > 0]
|
| 157 |
+
if args.limit:
|
| 158 |
+
df = df.iloc[:args.limit]
|
| 159 |
+
n = len(df)
|
| 160 |
+
print("[data] %d rows labelled anger (of %d annotated tweets)" % (n, len(f1)), flush=True)
|
| 161 |
+
|
| 162 |
+
id_texts = df["text_id"].tolist()
|
| 163 |
+
timings, stage_rows = {}, {}
|
| 164 |
+
|
| 165 |
+
# ---- stage 1: the split itself, Indonesian, laya's own criteria order ------------------------
|
| 166 |
+
qC = {"ekman": EKMAN_QUESTIONS["ekman"]}
|
| 167 |
+
ansC, s = run_stage(agent, laya_opt, qC, id_texts, args.out, "id_core", args.max_len,
|
| 168 |
+
args.head_max_len, args.token_budget)
|
| 169 |
+
timings["id_core"] = s["seconds"]; stage_rows["id_core"] = s.get("rows", 0)
|
| 170 |
+
|
| 171 |
+
# ---- stage 1b: option-order control (contempt listed first) ---------------------------------
|
| 172 |
+
ansS = [None] * n
|
| 173 |
+
if not args.no_swap:
|
| 174 |
+
qS = {"ekman": {"type": "choice",
|
| 175 |
+
"instructions": EKMAN_QUESTIONS["ekman"]["instructions"],
|
| 176 |
+
"criteria": {"contempt": EKMAN_QUESTIONS["ekman"]["criteria"]["contempt"],
|
| 177 |
+
"anger": EKMAN_QUESTIONS["ekman"]["criteria"]["anger"]}}}
|
| 178 |
+
ansS, s = run_stage(agent, laya_opt, qS, id_texts, args.out, "id_core_swap", args.max_len,
|
| 179 |
+
args.head_max_len, args.token_budget)
|
| 180 |
+
timings["id_core_swap"] = s["seconds"]; stage_rows["id_core_swap"] = s.get("rows", 0)
|
| 181 |
+
|
| 182 |
+
# ---- stage 2: core-feature probes, only where the choice reading could not settle it ---------
|
| 183 |
+
ambiguous = [i for i in range(n)
|
| 184 |
+
if abs(ansC[i]["ekman"]["probabilities"]["anger"]
|
| 185 |
+
- ansC[i]["ekman"]["probabilities"]["contempt"]) < args.margin]
|
| 186 |
+
print("[stage id_diag] %d/%d rows not decided by the Indonesian choice reading" % (
|
| 187 |
+
len(ambiguous), n), flush=True)
|
| 188 |
+
ansD = [dict() for _ in range(n)]
|
| 189 |
+
if ambiguous:
|
| 190 |
+
qD = {k: EKMAN_QUESTIONS[k] for k in ("superiority", "blocked_or_unfair")}
|
| 191 |
+
sub = [id_texts[i] for i in ambiguous]
|
| 192 |
+
res, s = run_stage(agent, laya_opt, qD, sub, args.out, "id_diag", args.max_len,
|
| 193 |
+
args.head_max_len, args.token_budget)
|
| 194 |
+
for i, r in zip(ambiguous, res):
|
| 195 |
+
ansD[i] = r
|
| 196 |
+
timings["id_diag"] = s["seconds"]; stage_rows["id_diag"] = s.get("rows", 0)
|
| 197 |
+
|
| 198 |
+
# ---- stage 3: the off-topic veto, as a diagnostic only ---------------------------------------
|
| 199 |
+
ansV = [None] * n
|
| 200 |
+
if not args.no_veto:
|
| 201 |
+
qV = {"not_anger_or_contempt": EKMAN_QUESTIONS["not_anger_or_contempt"]}
|
| 202 |
+
ansV, s = run_stage(agent, laya_opt, qV, id_texts, args.out, "id_veto", args.max_len,
|
| 203 |
+
args.head_max_len, args.token_budget)
|
| 204 |
+
timings["id_veto"] = s["seconds"]; stage_rows["id_veto"] = s.get("rows", 0)
|
| 205 |
+
|
| 206 |
+
# ---- combine ---------------------------------------------------------------------------------
|
| 207 |
+
rows = []
|
| 208 |
+
for i in range(n):
|
| 209 |
+
probs = ansC[i]["ekman"]["probabilities"]
|
| 210 |
+
swap = ansS[i]["ekman"]["probabilities"] if ansS[i] else None
|
| 211 |
+
diag = ansD[i]
|
| 212 |
+
sup = diag.get("superiority", {}).get("noul")
|
| 213 |
+
blk = diag.get("blocked_or_unfair", {}).get("noul")
|
| 214 |
+
label, src, m, p_a, p_c = combine_id(probs, swap, sup, blk, args.margin)
|
| 215 |
+
rows.append({
|
| 216 |
+
"row_src": int(df["row_src"].iloc[i]),
|
| 217 |
+
"text": id_texts[i],
|
| 218 |
+
"text_en": df["text_en"].iloc[i],
|
| 219 |
+
"source_label": "anger",
|
| 220 |
+
"label": label,
|
| 221 |
+
"label_source": src,
|
| 222 |
+
"ekman_p_anger": round(p_a, 4),
|
| 223 |
+
"ekman_p_contempt": round(p_c, 4),
|
| 224 |
+
"ekman_confidence": round(ansC[i]["ekman"]["confidence"], 4),
|
| 225 |
+
"ekman_margin_id": round(m, 4),
|
| 226 |
+
"p_anger_id": round(probs["anger"], 4),
|
| 227 |
+
"p_anger_swapped": None if swap is None else round(swap["anger"], 4),
|
| 228 |
+
"en_id_agree": None,
|
| 229 |
+
"p_superiority": None if sup is None else round(sup, 4),
|
| 230 |
+
"p_blocked_or_unfair": None if blk is None else round(blk, 4),
|
| 231 |
+
"p_not_anger_or_contempt": None if ansV[i] is None else
|
| 232 |
+
round(ansV[i]["not_anger_or_contempt"]["noul"], 4),
|
| 233 |
+
"ambiguous": bool(abs(m) < CHOICE_MARGIN),
|
| 234 |
+
})
|
| 235 |
+
out = pd.DataFrame(rows)
|
| 236 |
+
out.to_csv(os.path.join(args.out, "anger_ekman_rows.csv"), index=False)
|
| 237 |
+
|
| 238 |
+
prev_path = os.path.join(args.out, "timings.json")
|
| 239 |
+
if os.path.exists(prev_path):
|
| 240 |
+
prev = json.load(open(prev_path))
|
| 241 |
+
for k, v in prev.get("stages", {}).items():
|
| 242 |
+
if timings.get(k, 0) in (0, 0.0) and v:
|
| 243 |
+
timings[k] = v
|
| 244 |
+
for k, v in prev.get("stage_rows", {}).items():
|
| 245 |
+
stage_rows.setdefault(k, v)
|
| 246 |
+
with open(os.path.join(args.out, "timings.json"), "w") as f:
|
| 247 |
+
json.dump({"rows": n, "ambiguous_rows": len(ambiguous),
|
| 248 |
+
"total_laya_seconds": round(sum(timings.values()), 1), "stages": timings,
|
| 249 |
+
"stage_rows": {k: v for k, v in stage_rows.items() if v},
|
| 250 |
+
"max_len": args.max_len, "head_max_len": args.head_max_len,
|
| 251 |
+
"token_budget": args.token_budget, "margin": args.margin,
|
| 252 |
+
"language": "id-only"}, f, indent=2)
|
| 253 |
+
|
| 254 |
+
print("\n=== laya anger/contempt split (Indonesian only) ===", flush=True)
|
| 255 |
+
print(out["label"].value_counts().to_string())
|
| 256 |
+
print("\nlabel provenance:\n" + out["label_source"].value_counts().to_string())
|
| 257 |
+
print("\ncontempt share of the pool: %.1f%%" % (100.0 * (out["label"] == "contempt").mean()))
|
| 258 |
+
print("ambiguous (|margin|<%.2f): %d" % (args.margin, out["ambiguous"].sum()))
|
| 259 |
+
if out["p_anger_swapped"].notna().any():
|
| 260 |
+
print("mean P(anger): as prompted %.3f | swapped %.3f" % (
|
| 261 |
+
out["p_anger_id"].mean(), out["p_anger_swapped"].mean()))
|
| 262 |
+
flips = int(((out["p_anger_id"] >= 0.5) != (out["p_anger_swapped"] >= 0.5)).sum())
|
| 263 |
+
print("rows whose argmax flips with the option order: %d (%.1f%%)" % (flips, 100.0 * flips / n))
|
| 264 |
+
if out["p_not_anger_or_contempt"].notna().any():
|
| 265 |
+
print("p(not anger or contempt) > 0.5: %d" % (out["p_not_anger_or_contempt"] > 0.5).sum())
|
| 266 |
+
print("laya seconds: %s" % json.dumps(timings))
|
| 267 |
+
|
| 268 |
+
|
| 269 |
+
if __name__ == "__main__":
|
| 270 |
+
main()
|
make_dataset.py
CHANGED
|
@@ -30,6 +30,8 @@ import pandas as pd
|
|
| 30 |
from sklearn.model_selection import train_test_split
|
| 31 |
|
| 32 |
from ekman_questions import EKMAN7, BINARY
|
|
|
|
|
|
|
| 33 |
|
| 34 |
LABELS_EKMAN = EKMAN7
|
| 35 |
LABELS_BINARY = BINARY
|
|
@@ -37,12 +39,20 @@ LABELS_BINARY = BINARY
|
|
| 37 |
SOURCE_TO_EKMAN = {"joy": "enjoyment"}
|
| 38 |
SPLITS = ("train", "valid", "test")
|
| 39 |
CONFIGS = ("balanced", "full", "anger_split", "anger_split_balanced")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
SEED = 0 # the split seed the card promises; every run reads it from here
|
| 41 |
OUT_DIR = "out" # label_anger.py --out
|
| 42 |
DATA_CSV, DATA_CSV_EN = "data/file1.csv", "data/file2.csv"
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
bench_speedup.py bench_batch.py check_veto_and_speed.py sweep_config.py""".split()
|
| 47 |
REQUIRED = ["text", "text_en", "label", "label_idx", "source_label", "label_origin"]
|
| 48 |
|
|
@@ -66,8 +76,8 @@ def load_pool(out_dir=OUT_DIR):
|
|
| 66 |
assert len(lab) == lab["row_src"].nunique(), "anger labels are not row-unique"
|
| 67 |
assert set(lab["label"]) <= set(BINARY), f"unexpected labels in anger run: {set(lab['label'])}"
|
| 68 |
keep = ["label_source", "ambiguous", "ekman_p_anger", "ekman_p_contempt",
|
| 69 |
-
"ekman_confidence", "
|
| 70 |
-
"
|
| 71 |
m = df.merge(lab[["row_src", "label"] + keep].rename(columns={"label": "ek_label"}),
|
| 72 |
on="row_src", how="left")
|
| 73 |
anger = m["source_label"].eq("anger")
|
|
@@ -120,16 +130,13 @@ def add_text_group(df):
|
|
| 120 |
return df
|
| 121 |
|
| 122 |
|
| 123 |
-
def
|
| 124 |
-
"""
|
| 125 |
-
|
| 126 |
-
`
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
unit, so no group is ever cut; a group whose members disagree on label (a shared translation of
|
| 131 |
-
two different tweets) follows its modal label. Fractions then hold up to rounding on whole groups
|
| 132 |
-
- `verify()` checks both the fractions and the no-leakage property on the written files.
|
| 133 |
"""
|
| 134 |
rng = np.random.RandomState(seed)
|
| 135 |
lab, grp = df["label"].to_numpy(), df["group"].to_numpy()
|
|
@@ -140,7 +147,7 @@ def stratified_811(df, seed):
|
|
| 140 |
for c in sorted(df["label"].unique()):
|
| 141 |
gs = [g for g in modal.index if modal[g] == c]
|
| 142 |
rng.shuffle(gs)
|
| 143 |
-
gs.sort(key=lambda g: -sizes[g])
|
| 144 |
target = np.array([0.8, 0.1, 0.1]) * sizes[gs].sum()
|
| 145 |
cur = np.zeros(3)
|
| 146 |
for g in gs:
|
|
@@ -149,24 +156,45 @@ def stratified_811(df, seed):
|
|
| 149 |
cur[j] += sizes[g]
|
| 150 |
out = df.copy()
|
| 151 |
out["split"] = [assign[g] for g in grp]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
for s in SPLITS:
|
| 153 |
g = out.loc[out["split"] == s, "group"]
|
| 154 |
for other in SPLITS:
|
| 155 |
if other != s:
|
| 156 |
leak = int(g.isin(out.loc[out["split"] == other, "group"]).sum())
|
| 157 |
assert leak == 0, f"group leaked between {s} and {other}: {leak} rows"
|
|
|
|
| 158 |
return out
|
| 159 |
|
| 160 |
|
| 161 |
-
def balanced_pool(df, labels):
|
| 162 |
-
"""Down-sample to
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
|
| 172 |
def features(labels):
|
|
@@ -182,13 +210,11 @@ def features(labels):
|
|
| 182 |
"label_origin": Value("string"),
|
| 183 |
"label_source": Value("string"),
|
| 184 |
"ambiguous": Value("bool"),
|
| 185 |
-
"en_id_agree": Value("bool"),
|
| 186 |
"ekman_p_anger": Value("float32"),
|
| 187 |
"ekman_p_contempt": Value("float32"),
|
| 188 |
"ekman_confidence": Value("float32"),
|
| 189 |
-
"p_anger_en": Value("float32"),
|
| 190 |
"p_anger_id": Value("float32"),
|
| 191 |
-
"
|
| 192 |
"ekman_margin_id": Value("float32"),
|
| 193 |
"p_superiority": Value("float32"),
|
| 194 |
"p_blocked_or_unfair": Value("float32"),
|
|
@@ -199,10 +225,9 @@ def features(labels):
|
|
| 199 |
|
| 200 |
def to_frame(df, labels):
|
| 201 |
"""Column order like the schema; keep None for un-run evidence (NaN would round-trip badly)."""
|
| 202 |
-
want = REQUIRED + ["label_source", "ambiguous", "
|
| 203 |
-
"
|
| 204 |
-
"
|
| 205 |
-
"p_blocked_or_unfair", "p_not_anger_or_contempt", "row_src"]
|
| 206 |
cols = {}
|
| 207 |
for k in want:
|
| 208 |
v = df[k] if k in df else pd.Series([None] * len(df))
|
|
@@ -217,11 +242,16 @@ def to_frame(df, labels):
|
|
| 217 |
def write_parquet(df, labels, dist, config):
|
| 218 |
from datasets import Dataset
|
| 219 |
ds = Dataset.from_pandas(to_frame(df, labels), features=features(labels), preserve_index=False)
|
| 220 |
-
os.
|
| 221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
sub = ds.select([i for i in range(len(ds)) if df["split"].iloc[i] == s])
|
| 223 |
-
sub.to_parquet(os.path.join(
|
| 224 |
-
return sorted(os.listdir(
|
| 225 |
|
| 226 |
|
| 227 |
def class_table(df, labels):
|
|
@@ -233,14 +263,6 @@ def class_table(df, labels):
|
|
| 233 |
for c in labels if int(vc.get(c, 0)) > 0)
|
| 234 |
|
| 235 |
|
| 236 |
-
def n_probe(veto_path):
|
| 237 |
-
"""how many probes the veto file was computed over (it stores the count when available)"""
|
| 238 |
-
try:
|
| 239 |
-
return int(json.load(open(veto_path)).get("n_probes", 16))
|
| 240 |
-
except Exception:
|
| 241 |
-
return 16
|
| 242 |
-
|
| 243 |
-
|
| 244 |
def checkpoint_facts(ckpt_dir="models/laya-ml/multilingual"):
|
| 245 |
"""Read the checkpoint's real size/config out of its safetensors header - no model load.
|
| 246 |
|
|
@@ -279,58 +301,213 @@ def checkpoint_facts(ckpt_dir="models/laya-ml/multilingual"):
|
|
| 279 |
return out
|
| 280 |
|
| 281 |
|
| 282 |
-
def build_info(df, tables, splits, per_class, out_dir, info_path):
|
| 283 |
"""Numbers for the data card, from the built frames only (no model load)."""
|
| 284 |
from collections import Counter
|
| 285 |
import datasets, laya, torch, transformers
|
| 286 |
-
ang = df[df["label_origin"] == "laya_anger_split"]
|
| 287 |
src = Counter(ang["label_source"])
|
| 288 |
timings = json.load(open(os.path.join(out_dir, "timings.json")))
|
| 289 |
-
|
| 290 |
-
if
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
probe_str = f"{ca * 16:.0f}/16 ({ca:.3f})"
|
| 295 |
-
else:
|
| 296 |
-
veto_str = probe_str = "not measured - run `python check_veto_and_speed.py`"
|
| 297 |
stage_rows = timings.get("stage_rows", {})
|
| 298 |
n_states = sum(stage_rows.values()) or (4 * len(ang) + int(timings["ambiguous_rows"]) * 3)
|
| 299 |
|
| 300 |
-
# agreement with
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
f"
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 326 |
facts = checkpoint_facts()
|
| 327 |
tbl = []
|
| 328 |
for name in CONFIGS:
|
| 329 |
d, labels = tables[name], (LABELS_BINARY if name.startswith("anger") else LABELS_EKMAN)
|
| 330 |
-
for s in SPLITS
|
| 331 |
-
|
|
|
|
| 332 |
per = " / ".join(f"{c} {int(vc.get(c, 0))}" for c in labels if int(vc.get(c, 0)) > 0)
|
| 333 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
dup = int(df.duplicated("text").sum())
|
| 335 |
g = df.groupby("text")["source_label"].nunique()
|
| 336 |
conflict = int((g > 1).sum())
|
|
@@ -345,38 +522,61 @@ def build_info(df, tables, splits, per_class, out_dir, info_path):
|
|
| 345 |
"n_balanced": int(sum(splits["balanced"].values())),
|
| 346 |
"per_class_balanced": per_class["balanced"],
|
| 347 |
"per_class_anger_balanced": per_class["anger_split_balanced"],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
"class_table": class_table(df, LABELS_EKMAN),
|
| 349 |
"split_table": "\n".join(tbl),
|
| 350 |
"sources_str": ", ".join(f"`{k}` {v}" for k, v in src.most_common()),
|
| 351 |
-
"
|
|
|
|
|
|
|
|
|
|
| 352 |
"ambig": int(ang["ambiguous"].sum()),
|
| 353 |
"offtopic": int((ang["p_not_anger_or_contempt"] > 0.5).sum()),
|
| 354 |
"lowconf": int((ang["ekman_confidence"] < 0.6).sum()),
|
| 355 |
"stages": ", ".join(f"{k.replace('_', ' ')} {float(v):.1f} s"
|
| 356 |
for k, v in timings["stages"].items()),
|
| 357 |
"veto": veto_str,
|
| 358 |
-
"probe_acc": probe_str,
|
| 359 |
"laya_seconds": round(timings["total_laya_seconds"], 1),
|
| 360 |
"max_len": timings["max_len"],
|
| 361 |
"head_max_len": timings["head_max_len"],
|
| 362 |
"budget": timings["token_budget"],
|
| 363 |
"margin": timings["margin"],
|
| 364 |
"scored_rows": n_states,
|
| 365 |
-
"naive_rows":
|
| 366 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 367 |
"splits": splits,
|
| 368 |
"duplicates_note": (
|
| 369 |
f"{dup} rows share an identical `text` string with another row (more, if you count pairs "
|
| 370 |
-
f"whose English translation collides), and {conflict} of those repeated wordings "
|
| 371 |
-
"
|
| 372 |
-
"
|
| 373 |
-
"
|
| 374 |
-
"test (`verify()` fails the build if one does)
|
| 375 |
-
"
|
| 376 |
"checkpoint": "convaiinnovations/laya (subfolder `multilingual/`)",
|
| 377 |
"laya_v": laya.__version__, "datasets_v": datasets.__version__,
|
| 378 |
"transformers_v": transformers.__version__, "torch_v": torch.__version__,
|
| 379 |
"stageC": int(timings["ambiguous_rows"]),
|
|
|
|
| 380 |
"dup_conflicts": conflict,
|
| 381 |
**{k: (f"{v / 1e6:.1f}M" if k.startswith("params") and isinstance(v, int) else v)
|
| 382 |
for k, v in facts.items()},
|
|
@@ -397,17 +597,18 @@ def render_readme(info, template="README.template.md"):
|
|
| 397 |
return out
|
| 398 |
|
| 399 |
|
| 400 |
-
def verify(dist):
|
| 401 |
"""Open the written parquet files and check labels, provenance, leakage and card numbers."""
|
| 402 |
from datasets import Value, load_dataset
|
| 403 |
info = json.load(open(os.path.join(dist, "build_info.json")))
|
| 404 |
for name in CONFIGS:
|
| 405 |
labels = LABELS_BINARY if name.startswith("anger") else LABELS_EKMAN
|
|
|
|
| 406 |
ds = load_dataset("parquet", data_files={s: os.path.join(dist, name, f"{s}.parquet")
|
| 407 |
-
for s in
|
| 408 |
-
assert list(ds[
|
| 409 |
-
assert ds[
|
| 410 |
-
for s in
|
| 411 |
d = ds[s].to_pandas()
|
| 412 |
assert len(d) > 0 and set(d["label"]) <= set(labels), f"{name}/{s}: bad labels"
|
| 413 |
assert (d["text"].str.len() > 0).all() and (d["text_en"].str.len() > 0).all()
|
|
@@ -424,23 +625,47 @@ def verify(dist):
|
|
| 424 |
assert d["ekman_p_anger"].notna().all(), f"{name}: missing probabilities"
|
| 425 |
else:
|
| 426 |
assert d.loc[~pool, "ekman_p_anger"].isna().all(), f"{name}: stray evidence values"
|
| 427 |
-
for other in
|
| 428 |
if other == s:
|
| 429 |
continue
|
| 430 |
o = ds[other].to_pandas()
|
| 431 |
assert not set(d["text"]) & set(o["text"]), f"{name}: text leakage {s}/{other}"
|
| 432 |
assert not set(d["text_en"]) & set(o["text_en"]), f"{name}: translated-text leakage"
|
| 433 |
-
counts = {s: len(ds[s]) for s in
|
| 434 |
assert counts == info["splits"][name], f"{name}: card counts {info['splits'][name]} != {counts}"
|
| 435 |
tot = sum(counts.values())
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
# every shipped row still matches the upstream CSV, on top of the per-split checks
|
| 440 |
src = pd.read_csv(DATA_CSV)
|
| 441 |
src["text"] = src["tweet"].astype(str).map(norm)
|
| 442 |
src["source_label"] = src["label"].astype(str).str.strip().str.lower()
|
| 443 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 444 |
assert len(pool) == len(src) == 2243, f"full config covers {len(pool)} of {len(src)}"
|
| 445 |
# join on row_src, not on text: identical wordings are not the same row (and can disagree)
|
| 446 |
src["row_src"] = src.index
|
|
@@ -452,14 +677,14 @@ def verify(dist):
|
|
| 452 |
assert (m["text"] == m["tweet"].astype(str).str.replace(r"\s+", " ", regex=True).str.strip()).all(), \
|
| 453 |
"text is not the whitespace-normalised upstream tweet"
|
| 454 |
ang = pd.concat([pd.read_parquet(os.path.join(dist, "anger_split", f"{s}.parquet"))
|
| 455 |
-
for s in
|
| 456 |
-
raw = pd.read_csv(os.path.join(
|
| 457 |
raw = raw[raw["source_label"] == "anger"][["row_src", "label"]]
|
| 458 |
j = ang.merge(raw, on="row_src", suffixes=("", "_csv"))
|
| 459 |
assert len(j) == len(ang) == len(raw) and (j["label"] == j["label_csv"]).all(), \
|
| 460 |
"anger_split does not equal the labeller's CSV"
|
| 461 |
print(f"[verify] provenance: {len(pool)} rows vs upstream CSV, {len(ang)} anger rows vs "
|
| 462 |
-
f"{
|
| 463 |
# the card's YAML front matter is what huggingface.co parses into dataset configs: check that it
|
| 464 |
# declares exactly the configs on disk, that its paths resolve, and that `label_idx` matches its
|
| 465 |
# declared ClassLabel names
|
|
@@ -470,6 +695,10 @@ def verify(dist):
|
|
| 470 |
assert list(cfgs) == list(CONFIGS), f"card configs {list(cfgs)} != {list(CONFIGS)}"
|
| 471 |
assert [n for n, c in cfgs.items() if c.get("default")] == ["balanced"], "default config"
|
| 472 |
for name, c in cfgs.items():
|
|
|
|
|
|
|
|
|
|
|
|
|
| 473 |
for d in c["data_files"]:
|
| 474 |
p = os.path.join(dist, d["path"])
|
| 475 |
assert os.path.exists(p), f"card points at a missing file: {d['path']}"
|
|
@@ -478,7 +707,8 @@ def verify(dist):
|
|
| 478 |
declared = list(LABELS_BINARY if name.startswith("anger") else LABELS_EKMAN)
|
| 479 |
if names:
|
| 480 |
assert json.loads(names.decode()).get("names") == declared, f"{d['path']}: ClassLabel names"
|
| 481 |
-
n_total = sum(len(pd.read_parquet(os.path.join(dist, name, f"{s}.parquet")))
|
|
|
|
| 482 |
assert n_total == sum(info["splits"][name].values()), f"{name}: card/parquet row mismatch"
|
| 483 |
print(f"[verify] card YAML: {len(cfgs)} configs, default=balanced, every declared path exists "
|
| 484 |
f"and carries the right ClassLabel names")
|
|
@@ -495,21 +725,27 @@ def main():
|
|
| 495 |
df, _ = load_pool(a.out_dir)
|
| 496 |
df = add_text_group(df)
|
| 497 |
ang_pool = df[df["label_origin"] == "laya_anger_split"].reset_index(drop=True)
|
| 498 |
-
tables, splits, per_class = {}, {}, {}
|
| 499 |
-
for name, labels in (("
|
| 500 |
("anger_split", LABELS_BINARY), ("anger_split_balanced", LABELS_BINARY)):
|
| 501 |
base = df if name in ("full", "balanced") else ang_pool
|
| 502 |
-
if
|
| 503 |
-
base, per_class[name] = balanced_pool(base, labels)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 504 |
else:
|
| 505 |
per_class[name] = int(base["label"].value_counts().min())
|
| 506 |
-
|
|
|
|
| 507 |
tables[name] = sub
|
| 508 |
-
splits[name] = {s: int((sub["split"] == s).sum()) for s in SPLITS}
|
| 509 |
print(f"[build] {name}: {write_parquet(sub, labels, a.dist, name)} "
|
| 510 |
f"({splits[name]}, per-class>={per_class[name]})")
|
| 511 |
info = build_info(df, tables, splits, per_class, a.out_dir,
|
| 512 |
-
os.path.join(a.dist, "build_info.json"))
|
| 513 |
info["repo"] = a.repo
|
| 514 |
with open(os.path.join(a.dist, "README.md"), "w") as f:
|
| 515 |
f.write(render_readme(info))
|
|
@@ -527,16 +763,34 @@ def main():
|
|
| 527 |
shutil.copy(os.path.join("runs", f), os.path.join(a.dist, "runs", f))
|
| 528 |
os.makedirs(os.path.join(a.dist, "out"), exist_ok=True)
|
| 529 |
for f in ("veto_check.json", "speedup.json", "timings.json", "anger_ekman_rows.csv",
|
| 530 |
-
"
|
|
|
|
|
|
|
|
|
|
| 531 |
p = os.path.join(a.out_dir, f)
|
| 532 |
if os.path.exists(p):
|
| 533 |
shutil.copy(p, os.path.join(a.dist, "out", f))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 534 |
with open(os.path.join(a.dist, "build_info.json"), "w") as f: # now incl. repo
|
| 535 |
json.dump(info, f, indent=1, sort_keys=True)
|
| 536 |
print("[write] README.md,", json.dumps({k: info[k] for k in
|
| 537 |
("n_pool", "n_anger_pool", "n_contempt", "n_anger_kept",
|
| 538 |
-
"share_contempt", "n_balanced", "
|
| 539 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 540 |
|
| 541 |
|
| 542 |
if __name__ == "__main__":
|
|
|
|
| 30 |
from sklearn.model_selection import train_test_split
|
| 31 |
|
| 32 |
from ekman_questions import EKMAN7, BINARY
|
| 33 |
+
from split_exact import (FRACTIONS as SPLIT_FRACTIONS, apportion, assign_groups, ideal_targets,
|
| 34 |
+
sample_groups_per_class)
|
| 35 |
|
| 36 |
LABELS_EKMAN = EKMAN7
|
| 37 |
LABELS_BINARY = BINARY
|
|
|
|
| 39 |
SOURCE_TO_EKMAN = {"joy": "enjoyment"}
|
| 40 |
SPLITS = ("train", "valid", "test")
|
| 41 |
CONFIGS = ("balanced", "full", "anger_split", "anger_split_balanced")
|
| 42 |
+
# `full` and `anger_split` ship the whole pool as a single `train` split; the two balanced configs
|
| 43 |
+
# are the ones that carry an exact 8b : 1b : 1b train/valid/test.
|
| 44 |
+
WHOLE_CONFIGS = ("full", "anger_split")
|
| 45 |
+
SPLIT_CONFIGS = ("balanced", "anger_split_balanced")
|
| 46 |
SEED = 0 # the split seed the card promises; every run reads it from here
|
| 47 |
OUT_DIR = "out" # label_anger.py --out
|
| 48 |
DATA_CSV, DATA_CSV_EN = "data/file1.csv", "data/file2.csv"
|
| 49 |
+
PREV_DIR = "out_prev" # the previous revision's run artefacts (shipped for the comparison)
|
| 50 |
+
PREV_CACHE = os.path.join(PREV_DIR, "cache_id_core.json")
|
| 51 |
+
PREV_CSV = os.path.join(PREV_DIR, "anger_ekman_rows.csv")
|
| 52 |
+
SHIPPED = """README.template.md label_anger.py label_anger_id.py make_dataset.py fetch_source_data.py
|
| 53 |
+
publish.py laya_opt.py ekman_questions.py ekman_questions_id.py zcsafe.py
|
| 54 |
+
prepare_checkpoint.py probe_quality.py probe_quality_id.py probes.py probes_id.py
|
| 55 |
+
split_exact.py test_split_exact.py
|
| 56 |
bench_speedup.py bench_batch.py check_veto_and_speed.py sweep_config.py""".split()
|
| 57 |
REQUIRED = ["text", "text_en", "label", "label_idx", "source_label", "label_origin"]
|
| 58 |
|
|
|
|
| 76 |
assert len(lab) == lab["row_src"].nunique(), "anger labels are not row-unique"
|
| 77 |
assert set(lab["label"]) <= set(BINARY), f"unexpected labels in anger run: {set(lab['label'])}"
|
| 78 |
keep = ["label_source", "ambiguous", "ekman_p_anger", "ekman_p_contempt",
|
| 79 |
+
"ekman_confidence", "p_anger_id", "p_anger_swapped", "ekman_margin_id",
|
| 80 |
+
"p_superiority", "p_blocked_or_unfair", "p_not_anger_or_contempt"]
|
| 81 |
m = df.merge(lab[["row_src", "label"] + keep].rename(columns={"label": "ek_label"}),
|
| 82 |
on="row_src", how="left")
|
| 83 |
anger = m["source_label"].eq("anger")
|
|
|
|
| 130 |
return df
|
| 131 |
|
| 132 |
|
| 133 |
+
def stratified_811_greedy(df, seed):
|
| 134 |
+
"""The splitter the *previous* revision shipped - kept so the card can compare against it.
|
| 135 |
+
|
| 136 |
+
Shuffles each class's duplicate groups with `seed`, then hands them out greedily one at a time to
|
| 137 |
+
the split with the largest remaining row deficit against 0.8/0.1/0.1. Groups are the unit, so
|
| 138 |
+
nothing leaks, but a class whose last group overshoots cannot be corrected, which is why it lands
|
| 139 |
+
on 1794/226/223 rather than on whole-row 8:1:1. `make_dataset.stratified_811` is the exact one.
|
|
|
|
|
|
|
|
|
|
| 140 |
"""
|
| 141 |
rng = np.random.RandomState(seed)
|
| 142 |
lab, grp = df["label"].to_numpy(), df["group"].to_numpy()
|
|
|
|
| 147 |
for c in sorted(df["label"].unique()):
|
| 148 |
gs = [g for g in modal.index if modal[g] == c]
|
| 149 |
rng.shuffle(gs)
|
| 150 |
+
gs.sort(key=lambda g: -sizes[g])
|
| 151 |
target = np.array([0.8, 0.1, 0.1]) * sizes[gs].sum()
|
| 152 |
cur = np.zeros(3)
|
| 153 |
for g in gs:
|
|
|
|
| 156 |
cur[j] += sizes[g]
|
| 157 |
out = df.copy()
|
| 158 |
out["split"] = [assign[g] for g in grp]
|
| 159 |
+
return out
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
def stratified_811(df, seed):
|
| 163 |
+
"""Exact 8:1:1 by row count, still group-aware - see split_exact.py for the how and the why.
|
| 164 |
+
|
| 165 |
+
The row count of a config decides its column totals (`apportion`, i.e. largest remainder: 2,243
|
| 166 |
+
rows -> 1,795/224/224, 475 rows -> 380/48/47), and the per-class-per-split counts are the integer
|
| 167 |
+
solution closest to `n_class x 0.8 | 0.1 | 0.1` given those totals. Groups are then placed by
|
| 168 |
+
need and repaired by moving whole groups, so no wording straddles two splits and the split sizes
|
| 169 |
+
come out exact rather than "to within a group".
|
| 170 |
+
"""
|
| 171 |
+
sizes = df["label"].value_counts().to_dict()
|
| 172 |
+
split_sizes = apportion(len(df), SPLIT_FRACTIONS)
|
| 173 |
+
targets = ideal_targets(sizes, split_sizes)
|
| 174 |
+
out = assign_groups(df, targets, seed)
|
| 175 |
for s in SPLITS:
|
| 176 |
g = out.loc[out["split"] == s, "group"]
|
| 177 |
for other in SPLITS:
|
| 178 |
if other != s:
|
| 179 |
leak = int(g.isin(out.loc[out["split"] == other, "group"]).sum())
|
| 180 |
assert leak == 0, f"group leaked between {s} and {other}: {leak} rows"
|
| 181 |
+
assert int((out["split"] == s).sum()) == split_sizes[SPLITS.index(s)], "split size off target"
|
| 182 |
return out
|
| 183 |
|
| 184 |
|
| 185 |
+
def balanced_pool(df, labels, seed=SEED):
|
| 186 |
+
"""Down-sample to `m` rows per class, whole groups, with `m` the largest multiple of ten that fits.
|
| 187 |
+
|
| 188 |
+
The ten-row block has to be the unit if the split is to be exactly 8b : 1b : 1b, so a balanced
|
| 189 |
+
config picks its per-class size accordingly - 186 eligible `contempt` rows become 180, i.e. 144
|
| 190 |
+
train / 18 valid / 18 test per class and 1,008 / 126 / 126 overall (b = 126). Nothing else about
|
| 191 |
+
the sample changes: seed 0, whole duplicate groups, identical class counts.
|
| 192 |
+
"""
|
| 193 |
+
counts = df["label"].value_counts()
|
| 194 |
+
m = min(int(counts[c]) for c in labels) // 10 * 10
|
| 195 |
+
assert m > 0, "no class reaches ten rows"
|
| 196 |
+
sub, dropped = sample_groups_per_class(df, m, seed, labels=labels)
|
| 197 |
+
return sub, m, dropped
|
| 198 |
|
| 199 |
|
| 200 |
def features(labels):
|
|
|
|
| 210 |
"label_origin": Value("string"),
|
| 211 |
"label_source": Value("string"),
|
| 212 |
"ambiguous": Value("bool"),
|
|
|
|
| 213 |
"ekman_p_anger": Value("float32"),
|
| 214 |
"ekman_p_contempt": Value("float32"),
|
| 215 |
"ekman_confidence": Value("float32"),
|
|
|
|
| 216 |
"p_anger_id": Value("float32"),
|
| 217 |
+
"p_anger_swapped": Value("float32"),
|
| 218 |
"ekman_margin_id": Value("float32"),
|
| 219 |
"p_superiority": Value("float32"),
|
| 220 |
"p_blocked_or_unfair": Value("float32"),
|
|
|
|
| 225 |
|
| 226 |
def to_frame(df, labels):
|
| 227 |
"""Column order like the schema; keep None for un-run evidence (NaN would round-trip badly)."""
|
| 228 |
+
want = REQUIRED + ["label_source", "ambiguous", "ekman_p_anger", "ekman_p_contempt",
|
| 229 |
+
"ekman_confidence", "p_anger_id", "p_anger_swapped", "ekman_margin_id",
|
| 230 |
+
"p_superiority", "p_blocked_or_unfair", "p_not_anger_or_contempt", "row_src"]
|
|
|
|
| 231 |
cols = {}
|
| 232 |
for k in want:
|
| 233 |
v = df[k] if k in df else pd.Series([None] * len(df))
|
|
|
|
| 242 |
def write_parquet(df, labels, dist, config):
|
| 243 |
from datasets import Dataset
|
| 244 |
ds = Dataset.from_pandas(to_frame(df, labels), features=features(labels), preserve_index=False)
|
| 245 |
+
out_dir = os.path.join(dist, config)
|
| 246 |
+
os.makedirs(out_dir, exist_ok=True)
|
| 247 |
+
present = [s for s in SPLITS if (df["split"] == s).any()]
|
| 248 |
+
for f in os.listdir(out_dir): # a config that stops being split must not keep files
|
| 249 |
+
if f.endswith(".parquet") and f[:-len(".parquet")] not in present:
|
| 250 |
+
os.remove(os.path.join(out_dir, f))
|
| 251 |
+
for s in present:
|
| 252 |
sub = ds.select([i for i in range(len(ds)) if df["split"].iloc[i] == s])
|
| 253 |
+
sub.to_parquet(os.path.join(out_dir, f"{s}.parquet"))
|
| 254 |
+
return sorted(os.listdir(out_dir))
|
| 255 |
|
| 256 |
|
| 257 |
def class_table(df, labels):
|
|
|
|
| 263 |
for c in labels if int(vc.get(c, 0)) > 0)
|
| 264 |
|
| 265 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
def checkpoint_facts(ckpt_dir="models/laya-ml/multilingual"):
|
| 267 |
"""Read the checkpoint's real size/config out of its safetensors header - no model load.
|
| 268 |
|
|
|
|
| 301 |
return out
|
| 302 |
|
| 303 |
|
| 304 |
+
def build_info(df, tables, splits, per_class, out_dir, info_path, dropped=None):
|
| 305 |
"""Numbers for the data card, from the built frames only (no model load)."""
|
| 306 |
from collections import Counter
|
| 307 |
import datasets, laya, torch, transformers
|
| 308 |
+
ang = df[df["label_origin"] == "laya_anger_split"].copy()
|
| 309 |
src = Counter(ang["label_source"])
|
| 310 |
timings = json.load(open(os.path.join(out_dir, "timings.json")))
|
| 311 |
+
veto_str = "not run"
|
| 312 |
+
if "p_not_anger_or_contempt" in ang and ang["p_not_anger_or_contempt"].notna().any():
|
| 313 |
+
v = ang["p_not_anger_or_contempt"].dropna()
|
| 314 |
+
veto_str = (f"{int((v > 0.5).sum())} of {len(v)} rows above 0.5 (mean P(neither) {v.mean():.2f}) "
|
| 315 |
+
f"- Indonesian reading")
|
|
|
|
|
|
|
|
|
|
| 316 |
stage_rows = timings.get("stage_rows", {})
|
| 317 |
n_states = sum(stage_rows.values()) or (4 * len(ang) + int(timings["ambiguous_rows"]) * 3)
|
| 318 |
|
| 319 |
+
# agreement with the previous revision: `id_core` is the *same* stage, on the same texts, as the
|
| 320 |
+
# published out/cache_id_core.json (shipped here as out_prev/), so a re-run has to reproduce it
|
| 321 |
+
repro_note = "the shipped `out/cache_id_core.json` is from that run"
|
| 322 |
+
new_cache = os.path.join(out_dir, "cache_id_core.json")
|
| 323 |
+
if os.path.exists(PREV_CACHE) and os.path.exists(new_cache):
|
| 324 |
+
a, b = json.load(open(PREV_CACHE)), json.load(open(new_cache))
|
| 325 |
+
common = sorted(set(a) & set(b))
|
| 326 |
+
d = [abs(a[k]["ekman"]["probabilities"]["anger"] - b[k]["ekman"]["probabilities"]["anger"])
|
| 327 |
+
for k in common]
|
| 328 |
+
same = sum((a[k]["ekman"]["probabilities"]["anger"] >= 0.5)
|
| 329 |
+
== (b[k]["ekman"]["probabilities"]["anger"] >= 0.5) for k in common)
|
| 330 |
+
repro_note = (f"the `id_core` stage matches the earlier two-language run's "
|
| 331 |
+
f"`out_prev/cache_id_core.json` (shipped here) to the last digit - "
|
| 332 |
+
f"{same}/{len(common)} unique texts on the same side of the decision line, "
|
| 333 |
+
f"mean |delta p(anger)| {sum(d) / len(d):.4f}, max {max(d):.4f}")
|
| 334 |
+
if same != len(common):
|
| 335 |
+
n_moved = len(common) - same
|
| 336 |
+
repro_note += (f"; the {n_moved} row{'s' if n_moved > 1 else ''} that moved sit within "
|
| 337 |
+
f"0.05 of p=0.5")
|
| 338 |
+
|
| 339 |
+
# the second run (reconfirm.py): stage-by-stage and row-by-row agreement with the shipped labels
|
| 340 |
+
reconfirm_note = "a second run has not been compared against this one"
|
| 341 |
+
rc = os.path.join(out_dir, "reconfirm.json")
|
| 342 |
+
if os.path.exists(rc):
|
| 343 |
+
r = json.load(open(rc))
|
| 344 |
+
st = r.get("stages", {})
|
| 345 |
+
lab = r.get("labels", {})
|
| 346 |
+
drift = [k for k, v in st.items() if v["max_abs_diff"] > 0 or v["only_in_a"] or v["only_in_b"]]
|
| 347 |
+
covers = ", ".join(sorted(st))
|
| 348 |
+
if lab and not drift and not lab["flips"]:
|
| 349 |
+
sec = (r.get("second_run") or {}).get("total_laya_seconds")
|
| 350 |
+
reconfirm_note = (f"every stage ({covers}) matched row for row and reproduced **"
|
| 351 |
+
f"{lab['identical']}/{lab['rows']} labels**")
|
| 352 |
+
reconfirm_note += (", down to a byte-identical `anger_ekman_rows.csv`"
|
| 353 |
+
if lab.get("identical_bytes") else "")
|
| 354 |
+
reconfirm_note += (f", the largest probability difference anywhere being "
|
| 355 |
+
f"{lab['max_prob_abs_diff']:.6f}")
|
| 356 |
+
if sec:
|
| 357 |
+
reconfirm_note += (f" ({sec:,.1f} s of model time against {timings['total_laya_seconds']:,.1f} s"
|
| 358 |
+
f" for the shipped run)")
|
| 359 |
+
elif lab:
|
| 360 |
+
reconfirm_note = (f"the stages agreed on {lab['identical']}/{lab['rows']} labels, with "
|
| 361 |
+
f"drift in {drift or 'no stage'} and flips "
|
| 362 |
+
f"{lab['flips'] or 'none'} (largest probability difference "
|
| 363 |
+
f"{lab['max_prob_abs_diff']:.6f})")
|
| 364 |
+
else:
|
| 365 |
+
reconfirm_note = f"the stages agree as follows: {st}"
|
| 366 |
+
|
| 367 |
+
# what changed against the previous revision's shipped labels (English-pooled decision)
|
| 368 |
+
prev_note, prev_stats = "not available", {}
|
| 369 |
+
if os.path.exists(PREV_CSV):
|
| 370 |
+
pv = pd.read_csv(PREV_CSV)[["row_src", "label", "ekman_confidence"]].rename(
|
| 371 |
+
columns={"label": "label_prev", "ekman_confidence": "conf_prev"})
|
| 372 |
+
ang = ang.merge(pv, on="row_src", how="left")
|
| 373 |
+
j = ang[["row_src", "label", "label_prev"]].dropna(subset=["label_prev"])
|
| 374 |
+
if len(j):
|
| 375 |
+
n_flip = int((j["label"] != j["label_prev"]).sum())
|
| 376 |
+
p_ang, p_con = int((j["label_prev"] == "anger").sum()), int((j["label_prev"] == "contempt").sum())
|
| 377 |
+
c2a = int(((j["label_prev"] == "contempt") & (j["label"] == "anger")).sum())
|
| 378 |
+
a2c = int(((j["label_prev"] == "anger") & (j["label"] == "contempt")).sum())
|
| 379 |
+
prev_stats = {"prev_anger": p_ang, "prev_contempt": p_con, "flipped": n_flip,
|
| 380 |
+
"flip_to_anger": c2a, "flip_to_contempt": a2c,
|
| 381 |
+
"prev_share_contempt": round(100.0 * p_con / len(j), 1)}
|
| 382 |
+
prev_note = (f"it labelled {p_ang} anger / {p_con} contempt; the labels here differ on "
|
| 383 |
+
f"{n_flip} of the {len(j)} rows, {a2c} of them anger -> contempt")
|
| 384 |
+
|
| 385 |
+
# the corpus's own evidence: EmoTweetID sampled by emotion keyword, so a row that contains an
|
| 386 |
+
# explicit Indonesian anger word carries an upstream hint that it is anger and not contempt.
|
| 387 |
+
# How often does each revision overrule that hint?
|
| 388 |
+
LEXICON = ("kesal", "marah", "murka", "benci", "jengkel", "geram", "tersinggung", "muak", "ngamuk")
|
| 389 |
+
hint = ang["text"].str.lower().str.contains("|".join(LEXICON), regex=True)
|
| 390 |
+
lex_stats = {"lexicon_rows": int(hint.sum()), "lexicon_contempt_new": None,
|
| 391 |
+
"lexicon_contempt_prev": None}
|
| 392 |
+
if "label_prev" in ang:
|
| 393 |
+
lex_stats["lexicon_contempt_new"] = int((ang.loc[hint, "label"] == "contempt").sum())
|
| 394 |
+
lex_stats["lexicon_contempt_prev"] = int((ang.loc[hint, "label_prev"] == "contempt").sum())
|
| 395 |
+
lex_stats["lexicon_note"] = (
|
| 396 |
+
f"{int(hint.sum())} of the {len(ang)} pool rows contain an explicit Indonesian anger word "
|
| 397 |
+
f"(`kesal`, `marah`, `murka`, `benci`, `jengkel`, `geram`, `tersinggung`, `muak`, `ngamuk`) "
|
| 398 |
+
f"- which is how EmoTweetID's annotators sampled, so the word is upstream evidence for "
|
| 399 |
+
f"anger. {int((ang.loc[hint, 'label'] == 'contempt').sum())} of those "
|
| 400 |
+
f"{int(hint.sum())} rows ({100.0 * (ang.loc[hint, 'label'] == 'contempt').mean():.0f}%) "
|
| 401 |
+
f"are labelled `contempt` here.")
|
| 402 |
+
else:
|
| 403 |
+
lex_stats["lexicon_note"] = (f"{int(hint.sum())} pool rows contain an explicit Indonesian anger "
|
| 404 |
+
f"word; the Indonesian-only reading calls "
|
| 405 |
+
f"{int((ang.loc[hint, 'label'] == 'contempt').sum())} of them contempt")
|
| 406 |
+
|
| 407 |
+
# the one-reader audit of the flips (audit_flips.py), shipped as out/audit_flips.csv
|
| 408 |
+
audit_stats = {}
|
| 409 |
+
ap = os.path.join(out_dir, "audit_flips.csv")
|
| 410 |
+
if os.path.exists(ap):
|
| 411 |
+
au = pd.read_csv(ap)
|
| 412 |
+
n = len(au)
|
| 413 |
+
a_new = int((au["verdict"] == au["label"]).sum())
|
| 414 |
+
a_prev = int((au["verdict"] == au["shipped_label"]).sum())
|
| 415 |
+
other = int((au["verdict"] == "other").sum())
|
| 416 |
+
moved = au[au["label"] != au["shipped_label"]]
|
| 417 |
+
moved_c = int((moved["label"] == "contempt").sum())
|
| 418 |
+
moved_c_ok = int(((moved["label"] == "contempt") & (moved["verdict"] == "contempt")).sum())
|
| 419 |
+
audit_stats = {
|
| 420 |
+
"audit_n": n, "audit_agree_new": a_new, "audit_agree_prev": a_prev, "audit_other": other,
|
| 421 |
+
"audit_note": (
|
| 422 |
+
f"A sample of {n} rows where the readings disagree was judged against the operational "
|
| 423 |
+
f"boundary by one reader working from the tweet text alone, before seeing any "
|
| 424 |
+
f"probability: {a_prev}/{n} of those judgements land on the two-language reading, "
|
| 425 |
+
f"{a_new}/{n} on the label here, and {other}/{n} read as neither emotion. Of the "
|
| 426 |
+
f"{moved_c} rows labelled `contempt` here and `anger` by the two-language reading, "
|
| 427 |
+
f"{moved_c_ok} was accepted as contempt. The reader is a machine reader, not a human "
|
| 428 |
+
f"annotator, and works on short code-mixed text - a signal, not gold labels."),
|
| 429 |
+
"audit_caveat": ("one reader, unblinded to the hypothesis, and the pool is short, shouty, "
|
| 430 |
+
"code-mixed Indonesian - rerun this on a larger sample before quoting it"),
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
# how close to a coin flip each revision's reading ended, on the same scale (max P of the reading)
|
| 434 |
+
conf_stats = {"conf_low_new": int((np.maximum(ang["p_anger_id"], 1 - ang["p_anger_id"]) < 0.6).sum())}
|
| 435 |
+
if "conf_prev" in ang:
|
| 436 |
+
conf_stats["conf_low_prev"] = int((ang["conf_prev"] < 0.6).sum())
|
| 437 |
+
conf_stats["conf_note"] = (
|
| 438 |
+
f"{conf_stats['conf_low_new']} of {len(ang)} rows land within 0.10 of a coin flip on the "
|
| 439 |
+
f"primary reading (max probability of the two options under 0.60), and the mean max "
|
| 440 |
+
f"probability across the pool is "
|
| 441 |
+
f"{float(np.mean(np.maximum(ang['p_anger_id'], 1 - ang['p_anger_id']))):.3f}")
|
| 442 |
+
else:
|
| 443 |
+
conf_stats["conf_note"] = f"{conf_stats['conf_low_new']} rows land within 0.10 of a coin flip"
|
| 444 |
+
conf_stats["lowconf_laya"] = int((ang["ekman_confidence"] < 0.6).sum())
|
| 445 |
+
|
| 446 |
+
# the option-order control, on the rows this build labels
|
| 447 |
+
order_stats = {"order_flip": "n/a", "order_shift": "n/a",
|
| 448 |
+
"order_note": "not measured - run label_anger_id.py without --no-swap"}
|
| 449 |
+
if "p_anger_swapped" in ang and ang["p_anger_swapped"].notna().any():
|
| 450 |
+
pa, psw = ang["p_anger_id"].to_numpy(), ang["p_anger_swapped"].to_numpy()
|
| 451 |
+
flip, shift = float(np.mean((pa >= 0.5) != (psw >= 0.5))), float(np.mean(np.abs(pa - psw)))
|
| 452 |
+
order_stats = {
|
| 453 |
+
"order_flip": round(100 * flip, 1),
|
| 454 |
+
"order_shift": round(shift, 3),
|
| 455 |
+
"mean_p_anger_prompt": round(float(np.mean(pa)), 3),
|
| 456 |
+
"mean_p_anger_swapped": round(float(np.mean(psw)), 3),
|
| 457 |
+
"order_note": (f"Listing contempt first moved the argmax on {100 * flip:.1f}% of the pool "
|
| 458 |
+
f"(mean |delta p(anger)| {shift:.3f}; mean P(anger) {np.mean(pa):.3f} as "
|
| 459 |
+
f"prompted vs {np.mean(psw):.3f} with the options swapped), so the "
|
| 460 |
+
f"prompt's option order is worth roughly a third of the contempt shift"),
|
| 461 |
+
}
|
| 462 |
+
|
| 463 |
+
# fit-for-purpose probes, both languages (out/probe_quality_id.json, from probe_quality_id.py)
|
| 464 |
+
probe = {}
|
| 465 |
+
pq = os.path.join(out_dir, "probe_quality_id.json")
|
| 466 |
+
if os.path.exists(pq):
|
| 467 |
+
conds = json.load(open(pq))["conditions"]
|
| 468 |
+
tag = {c["condition"].strip()[0]: c for c in conds}
|
| 469 |
+
def fmt(c):
|
| 470 |
+
return f"{c['correct']}/{c['n']} ({c['accuracy']:.3f})"
|
| 471 |
+
probe = {k: fmt(tag[t]) for k, t in
|
| 472 |
+
(("probe_author", "Z"), ("probe_en", "A"), ("probe_id", "B"),
|
| 473 |
+
("probe_id_idq", "C"), ("probe_en_idq", "D"), ("probe_id_swapped", "E")) if t in tag}
|
| 474 |
+
b, a, c_, d_, e = (tag.get(x) for x in "BACDE")
|
| 475 |
+
if a and b:
|
| 476 |
+
probe["probe_gap"] = (f"The gap is {a['correct'] - b['correct']} items out of 16: the same "
|
| 477 |
+
f"sentences are called correctly {a['correct']} times in English and "
|
| 478 |
+
f"{b['correct']} times in Indonesian")
|
| 479 |
+
probe["probe_mean_p"] = (
|
| 480 |
+
f"Mean P(anger) on the anger probes {b['per_class']['anger']['mean_p_anger']:.2f} in "
|
| 481 |
+
f"Indonesian vs {a['per_class']['anger']['mean_p_anger']:.2f} in English; on the "
|
| 482 |
+
f"contempt probes {b['per_class']['contempt']['mean_p_anger']:.2f} vs "
|
| 483 |
+
f"{a['per_class']['contempt']['mean_p_anger']:.2f}")
|
| 484 |
+
if b and c_:
|
| 485 |
+
probe["probe_lang_q"] = (f"with the question in Indonesian instead of English, the gap "
|
| 486 |
+
f"closes only {b['correct']} -> {c_['correct']} items")
|
| 487 |
+
if d_:
|
| 488 |
+
probe["probe_en_q"] = f"English items with the Indonesian question: {fmt(d_)}"
|
| 489 |
+
if b and e:
|
| 490 |
+
probe["probe_order"] = (
|
| 491 |
+
f"On the contempt items the mean P(anger) is {b['per_class']['contempt']['mean_p_anger']:.2f} "
|
| 492 |
+
f"with anger listed first and {e['per_class']['contempt']['mean_p_anger']:.2f} with "
|
| 493 |
+
f"contempt listed first - the order effect seen on the corpus")
|
| 494 |
facts = checkpoint_facts()
|
| 495 |
tbl = []
|
| 496 |
for name in CONFIGS:
|
| 497 |
d, labels = tables[name], (LABELS_BINARY if name.startswith("anger") else LABELS_EKMAN)
|
| 498 |
+
present = [s for s in SPLITS if (d["split"] == s).any()]
|
| 499 |
+
for s in present:
|
| 500 |
+
vc = d.loc[d["split"] == s, "label"].value_counts()
|
| 501 |
per = " / ".join(f"{c} {int(vc.get(c, 0))}" for c in labels if int(vc.get(c, 0)) > 0)
|
| 502 |
+
note = " (the whole pool, one split)" if len(present) == 1 else ""
|
| 503 |
+
tbl.append(f"| `{name}` | {s} | {int((d['split'] == s).sum()):,} | {per}{note} |")
|
| 504 |
+
# one-line summary of every config's split sizes, for the card
|
| 505 |
+
split_note = ", ".join(
|
| 506 |
+
("%s %s of %s (b=%d)" % (name, " / ".join(str(splits[name][x]) for x in SPLITS),
|
| 507 |
+
f"{sum(splits[name].values()):,}", sum(splits[name].values()) // 10))
|
| 508 |
+
if name in SPLIT_CONFIGS else
|
| 509 |
+
("%s 1 split of %s" % (name, f"{sum(splits[name].values()):,}"))
|
| 510 |
+
for name in CONFIGS)
|
| 511 |
dup = int(df.duplicated("text").sum())
|
| 512 |
g = df.groupby("text")["source_label"].nunique()
|
| 513 |
conflict = int((g > 1).sum())
|
|
|
|
| 522 |
"n_balanced": int(sum(splits["balanced"].values())),
|
| 523 |
"per_class_balanced": per_class["balanced"],
|
| 524 |
"per_class_anger_balanced": per_class["anger_split_balanced"],
|
| 525 |
+
"n_full_pool": int(sum(splits["full"].values())),
|
| 526 |
+
"n_anger_pool_rows": int(sum(splits["anger_split"].values())),
|
| 527 |
+
"balanced_split": " / ".join(str(splits["balanced"][x]) for x in SPLITS),
|
| 528 |
+
"anger_split_balanced_split": " / ".join(str(splits["anger_split_balanced"][x]) for x in SPLITS),
|
| 529 |
+
"balanced_per_class_split": " / ".join(
|
| 530 |
+
str(apportion(per_class["balanced"])[i]) for i in range(3)),
|
| 531 |
+
"anger_balanced_per_class_split": " / ".join(
|
| 532 |
+
str(apportion(per_class["anger_split_balanced"])[i]) for i in range(3)),
|
| 533 |
+
"n_anger_balanced": int(sum(splits["anger_split_balanced"].values())),
|
| 534 |
+
"balanced_b": int(sum(splits["balanced"].values()) // 10),
|
| 535 |
+
"n_balanced_s": f"{int(sum(splits['balanced'].values())):,}",
|
| 536 |
+
"n_anger_balanced_s": f"{int(sum(splits['anger_split_balanced'].values())):,}",
|
| 537 |
+
"whole_note": ("`full` and `anger_split` are the complete pools in a single `train` split - "
|
| 538 |
+
"nothing is held out, and users who want their own validation split take it "
|
| 539 |
+
"from there. The two balanced configs are the ones that carry an exact "
|
| 540 |
+
"8:1:1 train/valid/test."),
|
| 541 |
"class_table": class_table(df, LABELS_EKMAN),
|
| 542 |
"split_table": "\n".join(tbl),
|
| 543 |
"sources_str": ", ".join(f"`{k}` {v}" for k, v in src.most_common()),
|
| 544 |
+
"noul_n": int(src.get("ekman_noul_tiebreak", 0)),
|
| 545 |
+
"choice_n": int(src.get("ekman_choice_id", 0)),
|
| 546 |
+
"orderavg_n": int(src.get("ekman_choice_order_avg", 0)),
|
| 547 |
+
"kept_n": int(src.get("kept_original_label", 0)),
|
| 548 |
"ambig": int(ang["ambiguous"].sum()),
|
| 549 |
"offtopic": int((ang["p_not_anger_or_contempt"] > 0.5).sum()),
|
| 550 |
"lowconf": int((ang["ekman_confidence"] < 0.6).sum()),
|
| 551 |
"stages": ", ".join(f"{k.replace('_', ' ')} {float(v):.1f} s"
|
| 552 |
for k, v in timings["stages"].items()),
|
| 553 |
"veto": veto_str,
|
|
|
|
| 554 |
"laya_seconds": round(timings["total_laya_seconds"], 1),
|
| 555 |
"max_len": timings["max_len"],
|
| 556 |
"head_max_len": timings["head_max_len"],
|
| 557 |
"budget": timings["token_budget"],
|
| 558 |
"margin": timings["margin"],
|
| 559 |
"scored_rows": n_states,
|
| 560 |
+
"naive_rows": 4 * len(ang),
|
| 561 |
+
"repro_note": repro_note,
|
| 562 |
+
"reconfirm_note": reconfirm_note,
|
| 563 |
+
"prev_note": prev_note,
|
| 564 |
+
"split_exact_note": split_note,
|
| 565 |
+
**prev_stats, **lex_stats, **conf_stats, **order_stats, **probe, **audit_stats,
|
| 566 |
"splits": splits,
|
| 567 |
"duplicates_note": (
|
| 568 |
f"{dup} rows share an identical `text` string with another row (more, if you count pairs "
|
| 569 |
+
f"whose English translation collides), and {conflict} of those repeated wordings repeat "
|
| 570 |
+
"with *different* upstream labels - the annotators disagreed, and this dataset inherits "
|
| 571 |
+
"that rather than re-judging it. Splitting is therefore **group-aware**: every member of a "
|
| 572 |
+
"duplicate group lands in one split, so no wording appears in either side of a "
|
| 573 |
+
"train/valid/test boundary (`verify()` fails the build if one does). The balanced "
|
| 574 |
+
"configs sample whole groups as well, so a dropped row never orphans its duplicate."),
|
| 575 |
"checkpoint": "convaiinnovations/laya (subfolder `multilingual/`)",
|
| 576 |
"laya_v": laya.__version__, "datasets_v": datasets.__version__,
|
| 577 |
"transformers_v": transformers.__version__, "torch_v": torch.__version__,
|
| 578 |
"stageC": int(timings["ambiguous_rows"]),
|
| 579 |
+
"stage_diag": int(stage_rows.get("id_diag", 2 * int(timings["ambiguous_rows"]))),
|
| 580 |
"dup_conflicts": conflict,
|
| 581 |
**{k: (f"{v / 1e6:.1f}M" if k.startswith("params") and isinstance(v, int) else v)
|
| 582 |
for k, v in facts.items()},
|
|
|
|
| 597 |
return out
|
| 598 |
|
| 599 |
|
| 600 |
+
def verify(dist, out_dir=OUT_DIR):
|
| 601 |
"""Open the written parquet files and check labels, provenance, leakage and card numbers."""
|
| 602 |
from datasets import Value, load_dataset
|
| 603 |
info = json.load(open(os.path.join(dist, "build_info.json")))
|
| 604 |
for name in CONFIGS:
|
| 605 |
labels = LABELS_BINARY if name.startswith("anger") else LABELS_EKMAN
|
| 606 |
+
present = [s for s in SPLITS if os.path.exists(os.path.join(dist, name, f"{s}.parquet"))]
|
| 607 |
ds = load_dataset("parquet", data_files={s: os.path.join(dist, name, f"{s}.parquet")
|
| 608 |
+
for s in present})
|
| 609 |
+
assert list(ds[present[0]].features["label_idx"].names) == list(labels), f"{name}: label_idx"
|
| 610 |
+
assert ds[present[0]].features["label"] == ds[present[0]].features["text"] == Value("string")
|
| 611 |
+
for s in present:
|
| 612 |
d = ds[s].to_pandas()
|
| 613 |
assert len(d) > 0 and set(d["label"]) <= set(labels), f"{name}/{s}: bad labels"
|
| 614 |
assert (d["text"].str.len() > 0).all() and (d["text_en"].str.len() > 0).all()
|
|
|
|
| 625 |
assert d["ekman_p_anger"].notna().all(), f"{name}: missing probabilities"
|
| 626 |
else:
|
| 627 |
assert d.loc[~pool, "ekman_p_anger"].isna().all(), f"{name}: stray evidence values"
|
| 628 |
+
for other in present:
|
| 629 |
if other == s:
|
| 630 |
continue
|
| 631 |
o = ds[other].to_pandas()
|
| 632 |
assert not set(d["text"]) & set(o["text"]), f"{name}: text leakage {s}/{other}"
|
| 633 |
assert not set(d["text_en"]) & set(o["text_en"]), f"{name}: translated-text leakage"
|
| 634 |
+
counts = {s: len(ds[s]) for s in present}
|
| 635 |
assert counts == info["splits"][name], f"{name}: card counts {info['splits'][name]} != {counts}"
|
| 636 |
tot = sum(counts.values())
|
| 637 |
+
if len(present) == 1:
|
| 638 |
+
assert present == ["train"], f"{name}: a single-split config must ship `train` only"
|
| 639 |
+
assert tot == info["n_full_pool" if name == "full" else "n_anger_pool_rows"], \
|
| 640 |
+
f"{name}: the whole pool must be in `train` ({tot} rows)"
|
| 641 |
+
print(f"[verify] {name}: {tot} rows, one split (the whole pool, nothing held out)")
|
| 642 |
+
continue
|
| 643 |
+
want = apportion(tot) # exact 8b : 1b : 1b
|
| 644 |
+
got = [counts[s] for s in SPLITS]
|
| 645 |
+
assert got == want, f"{name}: split sizes {got} != 8b:b:b targets {want}"
|
| 646 |
+
frac = [abs(counts[s] / tot - x) * 100 for s, x in zip(SPLITS, (0.8, 0.1, 0.1))]
|
| 647 |
+
assert tot % 10 == 0 and tot - 2 * (tot // 10) == 8 * (tot // 10), f"{name}: 10 | N"
|
| 648 |
+
print(f"[verify] {name}: {got} of {tot} rows, b={tot // 10}, off 8:1:1 by "
|
| 649 |
+
f"{frac[0]:.2f}/{frac[1]:.2f}/{frac[2]:.2f} points, {tot // len(labels)} per class")
|
| 650 |
+
# the balanced configs must be exact per class in every split, not just in the column totals
|
| 651 |
+
for name in SPLIT_CONFIGS:
|
| 652 |
+
labels = LABELS_BINARY if name.startswith("anger") else LABELS_EKMAN
|
| 653 |
+
per = info["per_class_" + ("anger_balanced" if name.startswith("anger") else "balanced")]
|
| 654 |
+
want = apportion(per)
|
| 655 |
+
for s in SPLITS:
|
| 656 |
+
d = pd.read_parquet(os.path.join(dist, name, f"{s}.parquet"))
|
| 657 |
+
vc = d["label"].value_counts()
|
| 658 |
+
assert set(vc.values) == {want[SPLITS.index(s)]}, f"{name}/{s}: per-class {vc.to_dict()}"
|
| 659 |
+
print(f"[verify] {name}: {per} rows per class, {want[0]} / {want[1]} / {want[2]} per class")
|
| 660 |
# every shipped row still matches the upstream CSV, on top of the per-split checks
|
| 661 |
src = pd.read_csv(DATA_CSV)
|
| 662 |
src["text"] = src["tweet"].astype(str).map(norm)
|
| 663 |
src["source_label"] = src["label"].astype(str).str.strip().str.lower()
|
| 664 |
+
def _splits_on_disk(cfg):
|
| 665 |
+
return [x for x in SPLITS if os.path.exists(os.path.join(dist, cfg, f"{x}.parquet"))]
|
| 666 |
+
|
| 667 |
+
pool = pd.concat([pd.read_parquet(os.path.join(dist, "full", f"{s}.parquet"))
|
| 668 |
+
for s in _splits_on_disk("full")])
|
| 669 |
assert len(pool) == len(src) == 2243, f"full config covers {len(pool)} of {len(src)}"
|
| 670 |
# join on row_src, not on text: identical wordings are not the same row (and can disagree)
|
| 671 |
src["row_src"] = src.index
|
|
|
|
| 677 |
assert (m["text"] == m["tweet"].astype(str).str.replace(r"\s+", " ", regex=True).str.strip()).all(), \
|
| 678 |
"text is not the whitespace-normalised upstream tweet"
|
| 679 |
ang = pd.concat([pd.read_parquet(os.path.join(dist, "anger_split", f"{s}.parquet"))
|
| 680 |
+
for s in _splits_on_disk("anger_split")])[["row_src", "label"]]
|
| 681 |
+
raw = pd.read_csv(os.path.join(out_dir, "anger_ekman_rows.csv"))
|
| 682 |
raw = raw[raw["source_label"] == "anger"][["row_src", "label"]]
|
| 683 |
j = ang.merge(raw, on="row_src", suffixes=("", "_csv"))
|
| 684 |
assert len(j) == len(ang) == len(raw) and (j["label"] == j["label_csv"]).all(), \
|
| 685 |
"anger_split does not equal the labeller's CSV"
|
| 686 |
print(f"[verify] provenance: {len(pool)} rows vs upstream CSV, {len(ang)} anger rows vs "
|
| 687 |
+
f"{out_dir}/anger_ekman_rows.csv -> ok")
|
| 688 |
# the card's YAML front matter is what huggingface.co parses into dataset configs: check that it
|
| 689 |
# declares exactly the configs on disk, that its paths resolve, and that `label_idx` matches its
|
| 690 |
# declared ClassLabel names
|
|
|
|
| 695 |
assert list(cfgs) == list(CONFIGS), f"card configs {list(cfgs)} != {list(CONFIGS)}"
|
| 696 |
assert [n for n, c in cfgs.items() if c.get("default")] == ["balanced"], "default config"
|
| 697 |
for name, c in cfgs.items():
|
| 698 |
+
declared_splits = [d["split"] for d in c["data_files"]]
|
| 699 |
+
on_disk = _splits_on_disk(name)
|
| 700 |
+
assert sorted(declared_splits) == sorted(on_disk), \
|
| 701 |
+
f"{name}: card declares {declared_splits} but disk has {on_disk}"
|
| 702 |
for d in c["data_files"]:
|
| 703 |
p = os.path.join(dist, d["path"])
|
| 704 |
assert os.path.exists(p), f"card points at a missing file: {d['path']}"
|
|
|
|
| 707 |
declared = list(LABELS_BINARY if name.startswith("anger") else LABELS_EKMAN)
|
| 708 |
if names:
|
| 709 |
assert json.loads(names.decode()).get("names") == declared, f"{d['path']}: ClassLabel names"
|
| 710 |
+
n_total = sum(len(pd.read_parquet(os.path.join(dist, name, f"{s}.parquet")))
|
| 711 |
+
for s in _splits_on_disk(name))
|
| 712 |
assert n_total == sum(info["splits"][name].values()), f"{name}: card/parquet row mismatch"
|
| 713 |
print(f"[verify] card YAML: {len(cfgs)} configs, default=balanced, every declared path exists "
|
| 714 |
f"and carries the right ClassLabel names")
|
|
|
|
| 725 |
df, _ = load_pool(a.out_dir)
|
| 726 |
df = add_text_group(df)
|
| 727 |
ang_pool = df[df["label_origin"] == "laya_anger_split"].reset_index(drop=True)
|
| 728 |
+
tables, splits, per_class, dropped = {}, {}, {}, {}
|
| 729 |
+
for name, labels in (("balanced", LABELS_EKMAN), ("full", LABELS_EKMAN),
|
| 730 |
("anger_split", LABELS_BINARY), ("anger_split_balanced", LABELS_BINARY)):
|
| 731 |
base = df if name in ("full", "balanced") else ang_pool
|
| 732 |
+
if name in SPLIT_CONFIGS:
|
| 733 |
+
base, per_class[name], dropped[name] = balanced_pool(base, labels)
|
| 734 |
+
assert sum(base["label"].value_counts().values) % 10 == 0, "a split config needs 10 | N"
|
| 735 |
+
sub = stratified_811(base, SEED)
|
| 736 |
+
expected = apportion(len(sub))
|
| 737 |
+
got = [int((sub["split"] == s).sum()) for s in SPLITS]
|
| 738 |
+
assert got == expected, f"{name}: {got} != 8b:b:b {expected}"
|
| 739 |
else:
|
| 740 |
per_class[name] = int(base["label"].value_counts().min())
|
| 741 |
+
sub = base.copy()
|
| 742 |
+
sub["split"] = SPLITS[0] # the whole pool, one split, nothing held out
|
| 743 |
tables[name] = sub
|
| 744 |
+
splits[name] = {s: int((sub["split"] == s).sum()) for s in SPLITS if (sub["split"] == s).any()}
|
| 745 |
print(f"[build] {name}: {write_parquet(sub, labels, a.dist, name)} "
|
| 746 |
f"({splits[name]}, per-class>={per_class[name]})")
|
| 747 |
info = build_info(df, tables, splits, per_class, a.out_dir,
|
| 748 |
+
os.path.join(a.dist, "build_info.json"), dropped=dropped)
|
| 749 |
info["repo"] = a.repo
|
| 750 |
with open(os.path.join(a.dist, "README.md"), "w") as f:
|
| 751 |
f.write(render_readme(info))
|
|
|
|
| 763 |
shutil.copy(os.path.join("runs", f), os.path.join(a.dist, "runs", f))
|
| 764 |
os.makedirs(os.path.join(a.dist, "out"), exist_ok=True)
|
| 765 |
for f in ("veto_check.json", "speedup.json", "timings.json", "anger_ekman_rows.csv",
|
| 766 |
+
"probe_quality_id.json", "audit_flips.csv", "audit_summary.json",
|
| 767 |
+
"reconfirm.json",
|
| 768 |
+
"cache_id_core.json", "cache_id_core_swap.json",
|
| 769 |
+
"cache_id_diag.json", "cache_id_veto.json"):
|
| 770 |
p = os.path.join(a.out_dir, f)
|
| 771 |
if os.path.exists(p):
|
| 772 |
shutil.copy(p, os.path.join(a.dist, "out", f))
|
| 773 |
+
# the previous revision's run artefacts, so the new-vs-old comparison in the card is reproducible
|
| 774 |
+
if os.path.isdir(PREV_DIR) and os.path.abspath(PREV_DIR) != os.path.abspath(a.out_dir):
|
| 775 |
+
prev_out = os.path.join(a.dist, "out_prev")
|
| 776 |
+
os.makedirs(prev_out, exist_ok=True)
|
| 777 |
+
for f in sorted(os.listdir(PREV_DIR)):
|
| 778 |
+
src = os.path.join(PREV_DIR, f)
|
| 779 |
+
if os.path.isfile(src):
|
| 780 |
+
shutil.copy(src, os.path.join(prev_out, f))
|
| 781 |
+
print("[write] out_prev/ = the previous revision's caches", sorted(os.listdir(prev_out)))
|
| 782 |
with open(os.path.join(a.dist, "build_info.json"), "w") as f: # now incl. repo
|
| 783 |
json.dump(info, f, indent=1, sort_keys=True)
|
| 784 |
print("[write] README.md,", json.dumps({k: info[k] for k in
|
| 785 |
("n_pool", "n_anger_pool", "n_contempt", "n_anger_kept",
|
| 786 |
+
"share_contempt", "n_balanced", "laya_seconds")}))
|
| 787 |
+
# nothing that is not part of the dataset may reach the published tree (working notes and the
|
| 788 |
+
# build scratch dir are the two that have been tempting)
|
| 789 |
+
forbidden = [f for f in os.listdir(a.dist)
|
| 790 |
+
if f.upper().startswith(("REVISION_NOTES", "NOTES", "TODO", "CHANGELOG"))
|
| 791 |
+
or f in ("build", "models", "data", "dist")]
|
| 792 |
+
assert not forbidden, f"refusing to publish: {forbidden}"
|
| 793 |
+
verify(a.dist, a.out_dir)
|
| 794 |
|
| 795 |
|
| 796 |
if __name__ == "__main__":
|
out/anger_ekman_rows.csv
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
out/audit_flips.csv
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
row_src,shipped_label,verdict,note,text,label,p_anger_id
|
| 2 |
+
1275,anger,anger,"rude order-taking story, 'bodo amat / bngsaat' = annoyance; no superiority","Bang, Martabak 1 ya Yang manis apa Yang telor Gak usah Yang Yangan deh, kitakan ga ada hubungan apa2, risih tau di gituin ... Bodo amat... Bngsaatttttt",contempt,0.3956
|
| 3 |
+
2086,anger,anger,"'koma benci' - hate, no target looked down on",Dani james dole ya koma benci,contempt,0.1501
|
| 4 |
+
1570,anger,anger,'sedikit kesal' - mildly annoyed,Mungkin dia sedikit kesal krn tiap hari ada aja muka tzuyu yg lewat tl dia gara-gara gua wkwkwkwk,contempt,0.3457
|
| 5 |
+
2048,anger,anger,'PALING BENCI' - shouted frustration,JANCOK!! PALING BENCI KALO MAU KETAWA HARUS NYUSAHIN OTAK DULU ASU !!!,contempt,0.4133
|
| 6 |
+
1182,anger,anger,"authorities ignore reports, bureaucratic excuses - blocked/unfair","Kejadian lagi dan lagi, pihak harusnya cepat tanggap menanggapi laporan, bukan hanya memberikan surat kehilangan atau alasan birokrasi yang rumit, ya gak tau juga sih, cuman kalau sampe sekarang MASIH SAJA kejadian berarti belum di usut tuntas. Kecewa sekali.",contempt,0.3892
|
| 7 |
+
1174,anger,anger,'malas nak marah' - resigned irritation,malas nak marah. umur dah meningkat ni aku cepat penat,contempt,0.3432
|
| 8 |
+
1585,anger,anger,'pen murka aja gua' - explicitly wants to be furious,Pen murka aja gua,contempt,0.3169
|
| 9 |
+
1832,anger,other,"moral disgust at people who believe slander; disgust, not superiority","so point dia kat sini, perangai babi ke, muka comel ke, fake friends ke, toxic people ke, yang paling jijik sekarang orang yang senang percaya dengan fitnah & batu api ni, aiyoooo downgrade main facebook jela",contempt,0.4814
|
| 10 |
+
192,anger,contempt,mocks his face then 'I hate Pete' - mockery looks down; the one true contempt here,Muka Pete wentz macam muka hantu* Saya benci Pete*,contempt,0.2709
|
| 11 |
+
1294,anger,other,meta-argument about who may be offended,"Yg seharusnya tidak terlalu tersinggung kalau disebut azab, karna definisi azabnya udah ga jelas seperti ini. tidak sepesifik sebabnya dan tidak ada benang merahnya antara sebab dan akibat, yang tidak merasa berbuat kesalahan juga ikut tersinggung.",contempt,0.2523
|
| 12 |
+
590,anger,anger,"political anger: 'wong cilik diperes', exploitation, 'dasar PDIP'","Ngaku2 temennya wong cilik buat meraup suara. Giliran udah berkuasa, wong cilik diperes abis abisan. Masih belum puas juga ngejarah aset bangsa Dasar PDIP",contempt,0.389
|
| 13 |
+
55,anger,anger,"'muka nya murka, badmood' - anger words, describing wrath","muka nya murka,badmood melihat orang orang yang masuk neraka",contempt,0.1039
|
| 14 |
+
1742,anger,anger,'[mrasa kesal]' - the annotators' own marker says annoyed,[mrasa kesal],contempt,0.4069
|
| 15 |
+
645,anger,anger,self-directed hate at being mediocre,"jujur, ngerasa benci diri sendiri kalau jadi medioker gini. kemana ilangnya jiwa-jiwa ambis yg selalu berpedoman, ""coba aja dulu, ntar baru tau gimana hasilnya""?",contempt,0.3257
|
| 16 |
+
2040,anger,anger,'tersinggung' - offended by a jab,Kesingung melawan sampe mati. Dibilang pentol korek sumbu pendek tersinggung.,contempt,0.4297
|
| 17 |
+
1729,anger,anger,threat: 'be quiet or I will be furious',lebih baik diyam kalian yaaa atau saya murka,contempt,0.3932
|
| 18 |
+
481,anger,anger,'benci bgt sama orang bwgitu' - hatred of a type of person; weak,wkwk w juga benci bgt jink sama orang bwgitu,contempt,0.4237
|
| 19 |
+
1916,anger,anger,sarcastic 'thanks for annoying me at night',Thankyou bikin kesal dimalam hari.,contempt,0.3958
|
| 20 |
+
1653,anger,anger,"'tersinggung' + 'level noob' - offended, insulted back",Kalo bagian itu mah standart Level noob Tersinggung nya cuma dibilang alay sama orang yang foto profilnya gituu Menyakitkan lohh Aslii,contempt,0.3041
|
| 21 |
+
2117,anger,other,commentary on other people's anger and religious tolerance,"Marah dan Kesal pasti ada ustad Tengku begitu juga dgn perasaan Umat agama lain seperti Gereja / vihara di Tutup,dirobohkan dibongkar,Ibadah dibubarkan.. perasaan nya gimana sebagai orang Indonesia yang beragam..??",contempt,0.2623
|
| 22 |
+
504,contempt,other,platitude about people coming into your life,"Orang hadir di hidupmu karena sebuah alasan. Mereka berimu bahagia dan kecewa. Ada yg sesaat, tapi ada yg selamanya,",anger,0.6215
|
| 23 |
+
35,contempt,other,sombre reflection on blood feuds; sadness/fear,"Kita ini banyak yang pelupa, bahwa hal sensitif seperti ini, bisa merenggut nyawa, nyawa kita, nyawa orang yang kita cintai, bahkan nyawa orang yang kita benci. Lalu apa ujungnya? Darah dibalas darah?",anger,0.5919
|
| 24 |
+
360,contempt,other,'I stopped hating exo' - positive,"Gegara film ini aku jadi gak benci exo .. lucu pas eunhyuk joget"" sama hyukjae pas masih trainer huhu pengen nonton lagi.. ada yang punya kah??",anger,0.5231
|
| 25 |
+
2061,contempt,other,moralising about fair-weather friends,Yg namanya sahabat sejati itu Ada disaat senang maupun duka. Bukan saat senang doank nggaku2 Sahabat Pada saat susah Boro2 ngaku sahabat Besuk aja nggak! Nggak harus terang2 an ? Itu pengecut namanya Plonga plongo ketika sahabat nya Di serang & dipenjara,anger,0.5573
|
| 26 |
+
2003,contempt,anger,"admonishment: arrogant group, 'benda Allah murka'","Lagi kau buka ruang untuk terima golongan macamtu, lagi diorg besau kepala. dah tentu tentu benda salah, benda Allah murka. Semua umat Islam tahu, yg bukan Islam pun tahu. Benda mcmni lagi byk negatif dari positif. Ada sbb setiap yg Allah tetapkan. Dan kau cuma hamba biasa. INGAT",contempt,0.5394
|
| 27 |
+
624,contempt,other,'afraid of God's wrath' - fear,takut murka Allah,anger,0.506
|
| 28 |
+
1301,contempt,contempt,"sarcastic 'it's normal to embarrass yourself, sis'","Udah biasa kalo malu-maluin, Kak!",contempt,0.5031
|
| 29 |
+
1045,contempt,other,bitter envy at someone favoured by fate,Ya udahlah. Tinggal tunggu aja elu jadi terkenal dan kaya raya. Selamat aja deh buat elu yg selalu dibela sama takdir dan poor buat gua yg delalu di benci takdir,anger,0.551
|
| 30 |
+
716,contempt,other,"'be happy over my misery' - resignation, sadness",Bahagialah kau di atas sengsara aku. Aku rela.,anger,0.8371
|
| 31 |
+
1104,contempt,anger,"protest: Uighurs must be free, 'Allah murka'","Jadi jelaskan ! Untuk apa bersimpati..?!? Jika Allah Ta'Ala murka,silahkan klo ada sanggup menahan.. Muslim Uighur harus merdeka dan bebas dr Komunis Cina!! Agar mereka bisa beribadah dengan damai..",contempt,0.5436
|
| 32 |
+
756,contempt,other,"warning that your shame will be exposed + 'ehehe' - mockery, but no superiority claim","Inget nder dosa sesama manusia Tuhan gk ikut campur hati"" yaa takutnya Tuhan murka aibmu dibuka depan umum juga ehehe",contempt,0.5388
|
| 33 |
+
839,contempt,anger,political complaint about ordinary people suffering,Banyak untungnya puang buat mereka tp Rakyat ma tambah sengsara,anger,0.5519
|
| 34 |
+
1487,contempt,contempt,"'don't be a hypocrite, I already guessed your mindset lol' - dismissive mockery","Halah mba, lo kalo ngeliat orang sange juga jijik jangan gitu lah, jgn munafik, gue tuh dah nebak bgt ini pola pikir lo asli KWOAWKSKSKSKSK",anger,0.9285
|
| 35 |
+
1363,contempt,other,wry Hitler/Chaplin aside,Hitler juga tampangnya kaya Chaplin. Pinokio apalagi lucu tapi buat rakyat sengsara.,anger,0.62
|
| 36 |
+
1406,contempt,other,insult + mockery about corona and God's wrath - mixed,"Goblok goblok, najis amit amit dah gw. Btw, kalo si rijik kena corona Gusti Allah murka sama siapa ? Sama Bani kadal al hoakki kan hehehe",anger,0.5541
|
| 37 |
+
531,contempt,anger,political grievance against a party and its supporters,"Weii Melayu2 korang tak rasa malu ke? Dah terang sikap DAP yg mahu serba serbi utk kaum dia, kaum kita mrk pinggir. Korang masih nak bersetia dgn mereka? Pemimpin2 korang mcm Mat Sabu ni kaya lah nti, korang? Ke mmg korang dilahirkan utk jdi dungu?",contempt,0.5071
|
| 38 |
+
807,contempt,anger,'paansi lu kontol ... najis ama jijik' - crude cursing,"Paansi lu kontol, gue mo ngmong najis ama jijik aja kudu bgt berkarya dlu apa",anger,0.749
|
out/audit_summary.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"n": 37,
|
| 3 |
+
"agree_new": 4,
|
| 4 |
+
"agree_prev": 18,
|
| 5 |
+
"other": 13
|
| 6 |
+
}
|
out/cache_id_core_swap.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
out/cache_id_diag.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"45dcaf19e9227576": {"superiority": {"type": "noul", "probabilities": {"false": 0.882466, "true": 0.117534}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.11753417346702585, "confidence": 0.4778, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.969741, "true": 0.030259}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.030258928746632163, "confidence": 0.8043, "action": {"act_probability": 1.0}}}, "43696aa53326f71a": {"superiority": {"type": "noul", "probabilities": {"false": 0.974201, "true": 0.025799}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.025799320690094083, "confidence": 0.8271, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.99811, "true": 0.00189}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.0018895899748282458, "confidence": 0.9802, "action": {"act_probability": 1.0}}}, "946e3c5ec411fd29": {"superiority": {"type": "noul", "probabilities": {"false": 0.924558, "true": 0.075442}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.07544200369536606, "confidence": 0.6141, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.990728, "true": 0.009272}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.009272206271937589, "confidence": 0.9241, "action": {"act_probability": 1.0}}}, "3f6a5fa6fc439067": {"superiority": {"type": "noul", "probabilities": {"false": 0.917323, "true": 0.082677}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.08267663421911636, "confidence": 0.5885, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.976818, "true": 0.023182}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.023182414267136145, "confidence": 0.841, "action": {"act_probability": 1.0}}}, "40cca08ee4f91541": {"superiority": {"type": "noul", "probabilities": {"false": 0.941173, "true": 0.058827}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.058826865288798096, "confidence": 0.6772, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.955391, "true": 0.044609}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.04460888421536396, "confidence": 0.737, "action": {"act_probability": 1.0}}}, "b9a14397862565c3": {"superiority": {"type": "noul", "probabilities": {"false": 0.864653, "true": 0.135347}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.13534656212548704, "confidence": 0.4281, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.996622, "true": 0.003378}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.0033778820416298615, "confidence": 0.9674, "action": {"act_probability": 1.0}}}, "a3c7746b05acd2ff": {"superiority": {"type": "noul", "probabilities": {"false": 0.969138, "true": 0.030862}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.03086188974225065, "confidence": 0.8013, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.997992, "true": 0.002008}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.002008454052871857, "confidence": 0.9791, "action": {"act_probability": 1.0}}}, "77e81d66f4677519": {"superiority": {"type": "noul", "probabilities": {"false": 0.950727, "true": 0.049273}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.04927264086274714, "confidence": 0.7167, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.99653, "true": 0.00347}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.0034698408555150708, "confidence": 0.9667, "action": {"act_probability": 1.0}}}, "de2cf241557dc13b": {"superiority": {"type": "noul", "probabilities": {"false": 0.974852, "true": 0.025148}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.025148423609456863, "confidence": 0.8306, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.989938, "true": 0.010062}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.01006210593966399, "confidence": 0.9188, "action": {"act_probability": 1.0}}}, "1f4a1d72c92b398f": {"superiority": {"type": "noul", "probabilities": {"false": 0.921066, "true": 0.078934}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.07893398009016743, "confidence": 0.6016, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.990507, "true": 0.009493}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.009492703907887612, "confidence": 0.9226, "action": {"act_probability": 1.0}}}, "b2bcbd27f59deb4e": {"superiority": {"type": "noul", "probabilities": {"false": 0.969913, "true": 0.030087}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.03008728889192485, "confidence": 0.8052, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.990079, "true": 0.009921}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.009920947494666547, "confidence": 0.9197, "action": {"act_probability": 1.0}}}, "6154bfaf6c7bd1a5": {"superiority": {"type": "noul", "probabilities": {"false": 0.97078, "true": 0.02922}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.02921954630093713, "confidence": 0.8095, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.995666, "true": 0.004334}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.004334428339631979, "confidence": 0.9597, "action": {"act_probability": 1.0}}}, "5314671c543c0307": {"superiority": {"type": "noul", "probabilities": {"false": 0.892032, "true": 0.107968}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.10796842413270419, "confidence": 0.5062, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.980359, "true": 0.019641}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.01964135777815654, "confidence": 0.8606, "action": {"act_probability": 1.0}}}, "21d9bd5abda45843": {"superiority": {"type": "noul", "probabilities": {"false": 0.95935, "true": 0.04065}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.04064958346072397, "confidence": 0.7547, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 1.0, "true": 0.0}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 3.9223886121125126e-07, "confidence": 1.0, "action": {"act_probability": 1.0}}}, "3d083400631ba904": {"superiority": {"type": "noul", "probabilities": {"false": 0.851247, "true": 0.148753}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.14875342852820878, "confidence": 0.3933, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.945498, "true": 0.054502}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.054501800912556936, "confidence": 0.6948, "action": {"act_probability": 1.0}}}, "3db1059a49d42fbe": {"superiority": {"type": "noul", "probabilities": {"false": 0.935774, "true": 0.064226}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.06422595789171685, "confidence": 0.656, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.983146, "true": 0.016854}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.01685407600134855, "confidence": 0.8766, "action": {"act_probability": 1.0}}}, "2fbaab4692dd5769": {"superiority": {"type": "noul", "probabilities": {"false": 0.947073, "true": 0.052927}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.052926850861160085, "confidence": 0.7013, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.997544, "true": 0.002456}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.0024563032768760403, "confidence": 0.9752, "action": {"act_probability": 1.0}}}, "6dea799cfa894312": {"superiority": {"type": "noul", "probabilities": {"false": 0.762112, "true": 0.237888}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.23788773964293844, "confidence": 0.2085, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.982511, "true": 0.017489}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.017488956106913468, "confidence": 0.8729, "action": {"act_probability": 1.0}}}, "d1bad4048f410f65": {"superiority": {"type": "noul", "probabilities": {"false": 0.695032, "true": 0.304968}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.3049684805667262, "confidence": 0.1127, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.689468, "true": 0.310532}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.31053228926900533, "confidence": 0.1062, "action": {"act_probability": 1.0}}}, "5101336759d79ccd": {"superiority": {"type": "noul", "probabilities": {"false": 0.881154, "true": 0.118846}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.11884591598573652, "confidence": 0.474, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.983136, "true": 0.016864}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.01686440894381564, "confidence": 0.8765, "action": {"act_probability": 1.0}}}, "333c89aa3b96d71b": {"superiority": {"type": "noul", "probabilities": {"false": 0.966017, "true": 0.033983}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.03398340502004642, "confidence": 0.786, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.991056, "true": 0.008944}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.008944366278194654, "confidence": 0.9263, "action": {"act_probability": 1.0}}}, "4569f7db11a3d207": {"superiority": {"type": "noul", "probabilities": {"false": 0.971169, "true": 0.028831}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.02883073438556354, "confidence": 0.8115, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.992986, "true": 0.007014}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.007013978645724294, "confidence": 0.9397, "action": {"act_probability": 1.0}}}, "5285229071c72ab4": {"superiority": {"type": "noul", "probabilities": {"false": 0.67435, "true": 0.32565}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.3256495688243485, "confidence": 0.0896, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.136139, "true": 0.863861}, "argmax_index": 1, "labels": ["false", "true"], "choice": "true", "score": null, "noul": 0.8638605736890058, "confidence": 0.426, "action": {"act_probability": 1.0}}}, "a8815cd199c4b62a": {"superiority": {"type": "noul", "probabilities": {"false": 0.928865, "true": 0.071135}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.07113506376490336, "confidence": 0.6299, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.99957, "true": 0.00043}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.0004295640145365117, "confidence": 0.9946, "action": {"act_probability": 1.0}}}, "ed2e495dd78e8657": {"superiority": {"type": "noul", "probabilities": {"false": 0.803842, "true": 0.196158}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.1961584445525012, "confidence": 0.2858, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.90375, "true": 0.09625}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.09624992851319317, "confidence": 0.543, "action": {"act_probability": 1.0}}}, "71b296d2166ef3d9": {"superiority": {"type": "noul", "probabilities": {"false": 0.898756, "true": 0.101244}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.10124369565654992, "confidence": 0.5271, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.974406, "true": 0.025594}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.025593870805343956, "confidence": 0.8282, "action": {"act_probability": 1.0}}}, "3cbb277d71d9b382": {"superiority": {"type": "noul", "probabilities": {"false": 0.947147, "true": 0.052853}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.05285251309929309, "confidence": 0.7016, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.984695, "true": 0.015305}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.015305451280542158, "confidence": 0.8858, "action": {"act_probability": 1.0}}}, "7318979b05938cf6": {"superiority": {"type": "noul", "probabilities": {"false": 0.947534, "true": 0.052466}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.05246646270176453, "confidence": 0.7032, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.991381, "true": 0.008619}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.008618683714224279, "confidence": 0.9285, "action": {"act_probability": 1.0}}}, "b2156f567567b5ca": {"superiority": {"type": "noul", "probabilities": {"false": 0.954846, "true": 0.045154}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.045154044879964196, "confidence": 0.7346, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.892383, "true": 0.107617}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.10761732259835706, "confidence": 0.5073, "action": {"act_probability": 1.0}}}, "061e8786dc9408af": {"superiority": {"type": "noul", "probabilities": {"false": 0.944489, "true": 0.055511}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.05551129826798251, "confidence": 0.6906, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.984625, "true": 0.015375}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.015374957306821506, "confidence": 0.8854, "action": {"act_probability": 1.0}}}, "0f47527f5094b5ca": {"superiority": {"type": "noul", "probabilities": {"false": 0.874674, "true": 0.125326}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.125325867620907, "confidence": 0.4555, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.938252, "true": 0.061748}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.061748103720198844, "confidence": 0.6657, "action": {"act_probability": 1.0}}}, "fc4e82974fb7ec6f": {"superiority": {"type": "noul", "probabilities": {"false": 0.523789, "true": 0.476211}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.4762105096193023, "confidence": 0.0016, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.314628, "true": 0.685372}, "argmax_index": 1, "labels": ["false", "true"], "choice": "true", "score": null, "noul": 0.6853718721687266, "confidence": 0.1016, "action": {"act_probability": 1.0}}}, "1ec9cc301575aab1": {"superiority": {"type": "noul", "probabilities": {"false": 0.898443, "true": 0.101557}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.10155742069452962, "confidence": 0.5261, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.964365, "true": 0.035635}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.03563518891360065, "confidence": 0.7781, "action": {"act_probability": 1.0}}}, "d0753b3a7d4def8b": {"superiority": {"type": "noul", "probabilities": {"false": 0.930919, "true": 0.069081}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.06908100749472326, "confidence": 0.6375, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.99353, "true": 0.00647}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.006469691667428737, "confidence": 0.9436, "action": {"act_probability": 1.0}}}, "91552e0f65b4175e": {"superiority": {"type": "noul", "probabilities": {"false": 0.674838, "true": 0.325162}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.3251615078854989, "confidence": 0.0901, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.14777, "true": 0.85223}, "argmax_index": 1, "labels": ["false", "true"], "choice": "true", "score": null, "noul": 0.8522299227440426, "confidence": 0.3958, "action": {"act_probability": 1.0}}}, "7f66740d7868e1f6": {"superiority": {"type": "noul", "probabilities": {"false": 0.940375, "true": 0.059625}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.05962540984677317, "confidence": 0.674, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.989976, "true": 0.010024}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.010024333290604887, "confidence": 0.919, "action": {"act_probability": 1.0}}}, "bf003ca89075b0cb": {"superiority": {"type": "noul", "probabilities": {"false": 0.842657, "true": 0.157343}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.15734335309573005, "confidence": 0.3721, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.990132, "true": 0.009868}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.009868319959011478, "confidence": 0.9201, "action": {"act_probability": 1.0}}}, "9b69d96f209a8eef": {"superiority": {"type": "noul", "probabilities": {"false": 0.935354, "true": 0.064646}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.06464554269842727, "confidence": 0.6544, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.986874, "true": 0.013126}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.013126411713919062, "confidence": 0.8991, "action": {"act_probability": 1.0}}}, "89e3e4ca33f1d96b": {"superiority": {"type": "noul", "probabilities": {"false": 0.87158, "true": 0.12842}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.12842045061007565, "confidence": 0.4469, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.980202, "true": 0.019798}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.019798072858242314, "confidence": 0.8597, "action": {"act_probability": 1.0}}}, "c12211255f6b2788": {"superiority": {"type": "noul", "probabilities": {"false": 0.936921, "true": 0.063079}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.06307903516685857, "confidence": 0.6605, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.989526, "true": 0.010474}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.010474416131312754, "confidence": 0.9161, "action": {"act_probability": 1.0}}}, "1beef9781f043a37": {"superiority": {"type": "noul", "probabilities": {"false": 0.905029, "true": 0.094971}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.09497139534203895, "confidence": 0.5472, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.986648, "true": 0.013352}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.013351783801292967, "confidence": 0.8977, "action": {"act_probability": 1.0}}}, "219aa22d8fc95333": {"superiority": {"type": "noul", "probabilities": {"false": 0.92763, "true": 0.07237}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.07237030640705697, "confidence": 0.6253, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.991991, "true": 0.008009}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.008008509255550909, "confidence": 0.9327, "action": {"act_probability": 1.0}}}, "e303b6dd0f35686e": {"superiority": {"type": "noul", "probabilities": {"false": 0.958939, "true": 0.041061}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.041060520124923845, "confidence": 0.7529, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.998619, "true": 0.001381}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.001380944195841363, "confidence": 0.9849, "action": {"act_probability": 1.0}}}, "ab472564b0afb3df": {"superiority": {"type": "noul", "probabilities": {"false": 0.955649, "true": 0.044351}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.04435106403677526, "confidence": 0.7381, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.990412, "true": 0.009588}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.009588192111463896, "confidence": 0.9219, "action": {"act_probability": 1.0}}}, "831e53d0cfedd180": {"superiority": {"type": "noul", "probabilities": {"false": 0.92514, "true": 0.07486}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.07486002233057326, "confidence": 0.6162, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.997417, "true": 0.002583}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.0025829942032979873, "confidence": 0.9741, "action": {"act_probability": 1.0}}}, "3814dffcfb50a477": {"superiority": {"type": "noul", "probabilities": {"false": 0.839772, "true": 0.160228}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.16022845249222342, "confidence": 0.3651, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.977256, "true": 0.022744}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.022744429383339856, "confidence": 0.8434, "action": {"act_probability": 1.0}}}, "7313afde6d15988e": {"superiority": {"type": "noul", "probabilities": {"false": 0.774628, "true": 0.225372}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.2253715766323574, "confidence": 0.2301, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.928433, "true": 0.071567}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.07156748055363117, "confidence": 0.6283, "action": {"act_probability": 1.0}}}, "6d48884b352707b3": {"superiority": {"type": "noul", "probabilities": {"false": 0.944716, "true": 0.055284}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.05528403302750518, "confidence": 0.6916, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.977968, "true": 0.022032}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.022031822160061526, "confidence": 0.8473, "action": {"act_probability": 1.0}}}, "9af7ceb46b155a65": {"superiority": {"type": "noul", "probabilities": {"false": 0.961473, "true": 0.038527}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.038527139563067074, "confidence": 0.7645, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.99684, "true": 0.00316}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.0031596016107618566, "confidence": 0.9692, "action": {"act_probability": 1.0}}}, "8446f5e753734ce2": {"superiority": {"type": "noul", "probabilities": {"false": 0.823132, "true": 0.176868}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.17686785870764649, "confidence": 0.3268, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.723603, "true": 0.276397}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.27639653966432126, "confidence": 0.1495, "action": {"act_probability": 1.0}}}, "b2c6af97c9115498": {"superiority": {"type": "noul", "probabilities": {"false": 0.87846, "true": 0.12154}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.12154016949685036, "confidence": 0.4662, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.976833, "true": 0.023167}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.02316691411439681, "confidence": 0.8411, "action": {"act_probability": 1.0}}}, "aa7a462ad61bd7ba": {"superiority": {"type": "noul", "probabilities": {"false": 0.790153, "true": 0.209847}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.20984669588106147, "confidence": 0.2588, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.962214, "true": 0.037786}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.03778594510220697, "confidence": 0.768, "action": {"act_probability": 1.0}}}, "6f7ee2ae141cb5a5": {"superiority": {"type": "noul", "probabilities": {"false": 0.836062, "true": 0.163938}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.1639378774335748, "confidence": 0.3564, "action": {"act_probability": 1.0}}, "blocked_or_unfair": {"type": "noul", "probabilities": {"false": 0.974662, "true": 0.025338}, "argmax_index": 0, "labels": ["false", "true"], "choice": "false", "score": null, "noul": 0.02533795811617691, "confidence": 0.8296, "action": {"act_probability": 1.0}}}}
|
out/cache_id_veto.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
out/probe_quality_id.json
ADDED
|
@@ -0,0 +1,612 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"conditions": [
|
| 3 |
+
{
|
| 4 |
+
"condition": "Z EN probes (author) + EN question",
|
| 5 |
+
"n": 16,
|
| 6 |
+
"correct": 13,
|
| 7 |
+
"accuracy": 0.812,
|
| 8 |
+
"per_class": {
|
| 9 |
+
"anger": {
|
| 10 |
+
"n": 8,
|
| 11 |
+
"correct": 7,
|
| 12 |
+
"mean_p_anger": 0.783
|
| 13 |
+
},
|
| 14 |
+
"contempt": {
|
| 15 |
+
"n": 8,
|
| 16 |
+
"correct": 6,
|
| 17 |
+
"mean_p_anger": 0.292
|
| 18 |
+
}
|
| 19 |
+
},
|
| 20 |
+
"mean_p_anger_overall": 0.537
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"condition": "A EN probes (this set)+ EN question",
|
| 24 |
+
"n": 16,
|
| 25 |
+
"correct": 14,
|
| 26 |
+
"accuracy": 0.875,
|
| 27 |
+
"per_class": {
|
| 28 |
+
"anger": {
|
| 29 |
+
"n": 8,
|
| 30 |
+
"correct": 7,
|
| 31 |
+
"mean_p_anger": 0.796
|
| 32 |
+
},
|
| 33 |
+
"contempt": {
|
| 34 |
+
"n": 8,
|
| 35 |
+
"correct": 7,
|
| 36 |
+
"mean_p_anger": 0.202
|
| 37 |
+
}
|
| 38 |
+
},
|
| 39 |
+
"mean_p_anger_overall": 0.499
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"condition": "B ID probes + EN question",
|
| 43 |
+
"n": 16,
|
| 44 |
+
"correct": 11,
|
| 45 |
+
"accuracy": 0.688,
|
| 46 |
+
"per_class": {
|
| 47 |
+
"anger": {
|
| 48 |
+
"n": 8,
|
| 49 |
+
"correct": 5,
|
| 50 |
+
"mean_p_anger": 0.684
|
| 51 |
+
},
|
| 52 |
+
"contempt": {
|
| 53 |
+
"n": 8,
|
| 54 |
+
"correct": 6,
|
| 55 |
+
"mean_p_anger": 0.307
|
| 56 |
+
}
|
| 57 |
+
},
|
| 58 |
+
"mean_p_anger_overall": 0.496
|
| 59 |
+
},
|
| 60 |
+
{
|
| 61 |
+
"condition": "C ID probes + ID question",
|
| 62 |
+
"n": 16,
|
| 63 |
+
"correct": 12,
|
| 64 |
+
"accuracy": 0.75,
|
| 65 |
+
"per_class": {
|
| 66 |
+
"anger": {
|
| 67 |
+
"n": 8,
|
| 68 |
+
"correct": 4,
|
| 69 |
+
"mean_p_anger": 0.542
|
| 70 |
+
},
|
| 71 |
+
"contempt": {
|
| 72 |
+
"n": 8,
|
| 73 |
+
"correct": 8,
|
| 74 |
+
"mean_p_anger": 0.174
|
| 75 |
+
}
|
| 76 |
+
},
|
| 77 |
+
"mean_p_anger_overall": 0.358
|
| 78 |
+
},
|
| 79 |
+
{
|
| 80 |
+
"condition": "D EN probes + ID question",
|
| 81 |
+
"n": 16,
|
| 82 |
+
"correct": 14,
|
| 83 |
+
"accuracy": 0.875,
|
| 84 |
+
"per_class": {
|
| 85 |
+
"anger": {
|
| 86 |
+
"n": 8,
|
| 87 |
+
"correct": 7,
|
| 88 |
+
"mean_p_anger": 0.772
|
| 89 |
+
},
|
| 90 |
+
"contempt": {
|
| 91 |
+
"n": 8,
|
| 92 |
+
"correct": 7,
|
| 93 |
+
"mean_p_anger": 0.263
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
"mean_p_anger_overall": 0.517
|
| 97 |
+
},
|
| 98 |
+
{
|
| 99 |
+
"condition": "E ID probes + EN q, options swapped",
|
| 100 |
+
"n": 16,
|
| 101 |
+
"correct": 11,
|
| 102 |
+
"accuracy": 0.688,
|
| 103 |
+
"per_class": {
|
| 104 |
+
"anger": {
|
| 105 |
+
"n": 8,
|
| 106 |
+
"correct": 7,
|
| 107 |
+
"mean_p_anger": 0.714
|
| 108 |
+
},
|
| 109 |
+
"contempt": {
|
| 110 |
+
"n": 8,
|
| 111 |
+
"correct": 4,
|
| 112 |
+
"mean_p_anger": 0.483
|
| 113 |
+
}
|
| 114 |
+
},
|
| 115 |
+
"mean_p_anger_overall": 0.599
|
| 116 |
+
}
|
| 117 |
+
],
|
| 118 |
+
"detail": {
|
| 119 |
+
"Z EN probes (author) + EN question": [
|
| 120 |
+
{
|
| 121 |
+
"gold": "anger",
|
| 122 |
+
"p_anger": 0.7163,
|
| 123 |
+
"pred": "anger"
|
| 124 |
+
},
|
| 125 |
+
{
|
| 126 |
+
"gold": "anger",
|
| 127 |
+
"p_anger": 0.8533,
|
| 128 |
+
"pred": "anger"
|
| 129 |
+
},
|
| 130 |
+
{
|
| 131 |
+
"gold": "anger",
|
| 132 |
+
"p_anger": 0.998,
|
| 133 |
+
"pred": "anger"
|
| 134 |
+
},
|
| 135 |
+
{
|
| 136 |
+
"gold": "anger",
|
| 137 |
+
"p_anger": 0.1147,
|
| 138 |
+
"pred": "contempt"
|
| 139 |
+
},
|
| 140 |
+
{
|
| 141 |
+
"gold": "anger",
|
| 142 |
+
"p_anger": 0.7604,
|
| 143 |
+
"pred": "anger"
|
| 144 |
+
},
|
| 145 |
+
{
|
| 146 |
+
"gold": "anger",
|
| 147 |
+
"p_anger": 0.9506,
|
| 148 |
+
"pred": "anger"
|
| 149 |
+
},
|
| 150 |
+
{
|
| 151 |
+
"gold": "anger",
|
| 152 |
+
"p_anger": 0.9887,
|
| 153 |
+
"pred": "anger"
|
| 154 |
+
},
|
| 155 |
+
{
|
| 156 |
+
"gold": "anger",
|
| 157 |
+
"p_anger": 0.8848,
|
| 158 |
+
"pred": "anger"
|
| 159 |
+
},
|
| 160 |
+
{
|
| 161 |
+
"gold": "contempt",
|
| 162 |
+
"p_anger": 0.0479,
|
| 163 |
+
"pred": "contempt"
|
| 164 |
+
},
|
| 165 |
+
{
|
| 166 |
+
"gold": "contempt",
|
| 167 |
+
"p_anger": 0.2847,
|
| 168 |
+
"pred": "contempt"
|
| 169 |
+
},
|
| 170 |
+
{
|
| 171 |
+
"gold": "contempt",
|
| 172 |
+
"p_anger": 0.1068,
|
| 173 |
+
"pred": "contempt"
|
| 174 |
+
},
|
| 175 |
+
{
|
| 176 |
+
"gold": "contempt",
|
| 177 |
+
"p_anger": 0.5144,
|
| 178 |
+
"pred": "anger"
|
| 179 |
+
},
|
| 180 |
+
{
|
| 181 |
+
"gold": "contempt",
|
| 182 |
+
"p_anger": 0.4317,
|
| 183 |
+
"pred": "contempt"
|
| 184 |
+
},
|
| 185 |
+
{
|
| 186 |
+
"gold": "contempt",
|
| 187 |
+
"p_anger": 0.0612,
|
| 188 |
+
"pred": "contempt"
|
| 189 |
+
},
|
| 190 |
+
{
|
| 191 |
+
"gold": "contempt",
|
| 192 |
+
"p_anger": 0.6129,
|
| 193 |
+
"pred": "anger"
|
| 194 |
+
},
|
| 195 |
+
{
|
| 196 |
+
"gold": "contempt",
|
| 197 |
+
"p_anger": 0.2727,
|
| 198 |
+
"pred": "contempt"
|
| 199 |
+
}
|
| 200 |
+
],
|
| 201 |
+
"A EN probes (this set)+ EN question": [
|
| 202 |
+
{
|
| 203 |
+
"gold": "anger",
|
| 204 |
+
"p_anger": 0.9381,
|
| 205 |
+
"pred": "anger"
|
| 206 |
+
},
|
| 207 |
+
{
|
| 208 |
+
"gold": "anger",
|
| 209 |
+
"p_anger": 0.78,
|
| 210 |
+
"pred": "anger"
|
| 211 |
+
},
|
| 212 |
+
{
|
| 213 |
+
"gold": "anger",
|
| 214 |
+
"p_anger": 0.9962,
|
| 215 |
+
"pred": "anger"
|
| 216 |
+
},
|
| 217 |
+
{
|
| 218 |
+
"gold": "anger",
|
| 219 |
+
"p_anger": 0.13,
|
| 220 |
+
"pred": "contempt"
|
| 221 |
+
},
|
| 222 |
+
{
|
| 223 |
+
"gold": "anger",
|
| 224 |
+
"p_anger": 0.8004,
|
| 225 |
+
"pred": "anger"
|
| 226 |
+
},
|
| 227 |
+
{
|
| 228 |
+
"gold": "anger",
|
| 229 |
+
"p_anger": 0.8561,
|
| 230 |
+
"pred": "anger"
|
| 231 |
+
},
|
| 232 |
+
{
|
| 233 |
+
"gold": "anger",
|
| 234 |
+
"p_anger": 0.9917,
|
| 235 |
+
"pred": "anger"
|
| 236 |
+
},
|
| 237 |
+
{
|
| 238 |
+
"gold": "anger",
|
| 239 |
+
"p_anger": 0.8751,
|
| 240 |
+
"pred": "anger"
|
| 241 |
+
},
|
| 242 |
+
{
|
| 243 |
+
"gold": "contempt",
|
| 244 |
+
"p_anger": 0.0957,
|
| 245 |
+
"pred": "contempt"
|
| 246 |
+
},
|
| 247 |
+
{
|
| 248 |
+
"gold": "contempt",
|
| 249 |
+
"p_anger": 0.1732,
|
| 250 |
+
"pred": "contempt"
|
| 251 |
+
},
|
| 252 |
+
{
|
| 253 |
+
"gold": "contempt",
|
| 254 |
+
"p_anger": 0.4316,
|
| 255 |
+
"pred": "contempt"
|
| 256 |
+
},
|
| 257 |
+
{
|
| 258 |
+
"gold": "contempt",
|
| 259 |
+
"p_anger": 0.5255,
|
| 260 |
+
"pred": "anger"
|
| 261 |
+
},
|
| 262 |
+
{
|
| 263 |
+
"gold": "contempt",
|
| 264 |
+
"p_anger": 0.0742,
|
| 265 |
+
"pred": "contempt"
|
| 266 |
+
},
|
| 267 |
+
{
|
| 268 |
+
"gold": "contempt",
|
| 269 |
+
"p_anger": 0.0831,
|
| 270 |
+
"pred": "contempt"
|
| 271 |
+
},
|
| 272 |
+
{
|
| 273 |
+
"gold": "contempt",
|
| 274 |
+
"p_anger": 0.2038,
|
| 275 |
+
"pred": "contempt"
|
| 276 |
+
},
|
| 277 |
+
{
|
| 278 |
+
"gold": "contempt",
|
| 279 |
+
"p_anger": 0.0287,
|
| 280 |
+
"pred": "contempt"
|
| 281 |
+
}
|
| 282 |
+
],
|
| 283 |
+
"B ID probes + EN question": [
|
| 284 |
+
{
|
| 285 |
+
"gold": "anger",
|
| 286 |
+
"p_anger": 0.8299,
|
| 287 |
+
"pred": "anger"
|
| 288 |
+
},
|
| 289 |
+
{
|
| 290 |
+
"gold": "anger",
|
| 291 |
+
"p_anger": 0.9646,
|
| 292 |
+
"pred": "anger"
|
| 293 |
+
},
|
| 294 |
+
{
|
| 295 |
+
"gold": "anger",
|
| 296 |
+
"p_anger": 0.4416,
|
| 297 |
+
"pred": "contempt"
|
| 298 |
+
},
|
| 299 |
+
{
|
| 300 |
+
"gold": "anger",
|
| 301 |
+
"p_anger": 0.4756,
|
| 302 |
+
"pred": "contempt"
|
| 303 |
+
},
|
| 304 |
+
{
|
| 305 |
+
"gold": "anger",
|
| 306 |
+
"p_anger": 0.969,
|
| 307 |
+
"pred": "anger"
|
| 308 |
+
},
|
| 309 |
+
{
|
| 310 |
+
"gold": "anger",
|
| 311 |
+
"p_anger": 0.3315,
|
| 312 |
+
"pred": "contempt"
|
| 313 |
+
},
|
| 314 |
+
{
|
| 315 |
+
"gold": "anger",
|
| 316 |
+
"p_anger": 0.8758,
|
| 317 |
+
"pred": "anger"
|
| 318 |
+
},
|
| 319 |
+
{
|
| 320 |
+
"gold": "anger",
|
| 321 |
+
"p_anger": 0.5866,
|
| 322 |
+
"pred": "anger"
|
| 323 |
+
},
|
| 324 |
+
{
|
| 325 |
+
"gold": "contempt",
|
| 326 |
+
"p_anger": 0.191,
|
| 327 |
+
"pred": "contempt"
|
| 328 |
+
},
|
| 329 |
+
{
|
| 330 |
+
"gold": "contempt",
|
| 331 |
+
"p_anger": 0.6434,
|
| 332 |
+
"pred": "anger"
|
| 333 |
+
},
|
| 334 |
+
{
|
| 335 |
+
"gold": "contempt",
|
| 336 |
+
"p_anger": 0.6941,
|
| 337 |
+
"pred": "anger"
|
| 338 |
+
},
|
| 339 |
+
{
|
| 340 |
+
"gold": "contempt",
|
| 341 |
+
"p_anger": 0.1205,
|
| 342 |
+
"pred": "contempt"
|
| 343 |
+
},
|
| 344 |
+
{
|
| 345 |
+
"gold": "contempt",
|
| 346 |
+
"p_anger": 0.2788,
|
| 347 |
+
"pred": "contempt"
|
| 348 |
+
},
|
| 349 |
+
{
|
| 350 |
+
"gold": "contempt",
|
| 351 |
+
"p_anger": 0.0922,
|
| 352 |
+
"pred": "contempt"
|
| 353 |
+
},
|
| 354 |
+
{
|
| 355 |
+
"gold": "contempt",
|
| 356 |
+
"p_anger": 0.1518,
|
| 357 |
+
"pred": "contempt"
|
| 358 |
+
},
|
| 359 |
+
{
|
| 360 |
+
"gold": "contempt",
|
| 361 |
+
"p_anger": 0.2878,
|
| 362 |
+
"pred": "contempt"
|
| 363 |
+
}
|
| 364 |
+
],
|
| 365 |
+
"C ID probes + ID question": [
|
| 366 |
+
{
|
| 367 |
+
"gold": "anger",
|
| 368 |
+
"p_anger": 0.6251,
|
| 369 |
+
"pred": "anger"
|
| 370 |
+
},
|
| 371 |
+
{
|
| 372 |
+
"gold": "anger",
|
| 373 |
+
"p_anger": 0.931,
|
| 374 |
+
"pred": "anger"
|
| 375 |
+
},
|
| 376 |
+
{
|
| 377 |
+
"gold": "anger",
|
| 378 |
+
"p_anger": 0.3233,
|
| 379 |
+
"pred": "contempt"
|
| 380 |
+
},
|
| 381 |
+
{
|
| 382 |
+
"gold": "anger",
|
| 383 |
+
"p_anger": 0.5166,
|
| 384 |
+
"pred": "anger"
|
| 385 |
+
},
|
| 386 |
+
{
|
| 387 |
+
"gold": "anger",
|
| 388 |
+
"p_anger": 0.8748,
|
| 389 |
+
"pred": "anger"
|
| 390 |
+
},
|
| 391 |
+
{
|
| 392 |
+
"gold": "anger",
|
| 393 |
+
"p_anger": 0.3728,
|
| 394 |
+
"pred": "contempt"
|
| 395 |
+
},
|
| 396 |
+
{
|
| 397 |
+
"gold": "anger",
|
| 398 |
+
"p_anger": 0.3972,
|
| 399 |
+
"pred": "contempt"
|
| 400 |
+
},
|
| 401 |
+
{
|
| 402 |
+
"gold": "anger",
|
| 403 |
+
"p_anger": 0.2974,
|
| 404 |
+
"pred": "contempt"
|
| 405 |
+
},
|
| 406 |
+
{
|
| 407 |
+
"gold": "contempt",
|
| 408 |
+
"p_anger": 0.0781,
|
| 409 |
+
"pred": "contempt"
|
| 410 |
+
},
|
| 411 |
+
{
|
| 412 |
+
"gold": "contempt",
|
| 413 |
+
"p_anger": 0.2541,
|
| 414 |
+
"pred": "contempt"
|
| 415 |
+
},
|
| 416 |
+
{
|
| 417 |
+
"gold": "contempt",
|
| 418 |
+
"p_anger": 0.2815,
|
| 419 |
+
"pred": "contempt"
|
| 420 |
+
},
|
| 421 |
+
{
|
| 422 |
+
"gold": "contempt",
|
| 423 |
+
"p_anger": 0.2547,
|
| 424 |
+
"pred": "contempt"
|
| 425 |
+
},
|
| 426 |
+
{
|
| 427 |
+
"gold": "contempt",
|
| 428 |
+
"p_anger": 0.2434,
|
| 429 |
+
"pred": "contempt"
|
| 430 |
+
},
|
| 431 |
+
{
|
| 432 |
+
"gold": "contempt",
|
| 433 |
+
"p_anger": 0.1972,
|
| 434 |
+
"pred": "contempt"
|
| 435 |
+
},
|
| 436 |
+
{
|
| 437 |
+
"gold": "contempt",
|
| 438 |
+
"p_anger": 0.0375,
|
| 439 |
+
"pred": "contempt"
|
| 440 |
+
},
|
| 441 |
+
{
|
| 442 |
+
"gold": "contempt",
|
| 443 |
+
"p_anger": 0.0478,
|
| 444 |
+
"pred": "contempt"
|
| 445 |
+
}
|
| 446 |
+
],
|
| 447 |
+
"D EN probes + ID question": [
|
| 448 |
+
{
|
| 449 |
+
"gold": "anger",
|
| 450 |
+
"p_anger": 0.5293,
|
| 451 |
+
"pred": "anger"
|
| 452 |
+
},
|
| 453 |
+
{
|
| 454 |
+
"gold": "anger",
|
| 455 |
+
"p_anger": 0.8218,
|
| 456 |
+
"pred": "anger"
|
| 457 |
+
},
|
| 458 |
+
{
|
| 459 |
+
"gold": "anger",
|
| 460 |
+
"p_anger": 0.9996,
|
| 461 |
+
"pred": "anger"
|
| 462 |
+
},
|
| 463 |
+
{
|
| 464 |
+
"gold": "anger",
|
| 465 |
+
"p_anger": 0.8082,
|
| 466 |
+
"pred": "anger"
|
| 467 |
+
},
|
| 468 |
+
{
|
| 469 |
+
"gold": "anger",
|
| 470 |
+
"p_anger": 0.8503,
|
| 471 |
+
"pred": "anger"
|
| 472 |
+
},
|
| 473 |
+
{
|
| 474 |
+
"gold": "anger",
|
| 475 |
+
"p_anger": 0.4655,
|
| 476 |
+
"pred": "contempt"
|
| 477 |
+
},
|
| 478 |
+
{
|
| 479 |
+
"gold": "anger",
|
| 480 |
+
"p_anger": 0.8973,
|
| 481 |
+
"pred": "anger"
|
| 482 |
+
},
|
| 483 |
+
{
|
| 484 |
+
"gold": "anger",
|
| 485 |
+
"p_anger": 0.8029,
|
| 486 |
+
"pred": "anger"
|
| 487 |
+
},
|
| 488 |
+
{
|
| 489 |
+
"gold": "contempt",
|
| 490 |
+
"p_anger": 0.1238,
|
| 491 |
+
"pred": "contempt"
|
| 492 |
+
},
|
| 493 |
+
{
|
| 494 |
+
"gold": "contempt",
|
| 495 |
+
"p_anger": 0.5707,
|
| 496 |
+
"pred": "anger"
|
| 497 |
+
},
|
| 498 |
+
{
|
| 499 |
+
"gold": "contempt",
|
| 500 |
+
"p_anger": 0.4593,
|
| 501 |
+
"pred": "contempt"
|
| 502 |
+
},
|
| 503 |
+
{
|
| 504 |
+
"gold": "contempt",
|
| 505 |
+
"p_anger": 0.274,
|
| 506 |
+
"pred": "contempt"
|
| 507 |
+
},
|
| 508 |
+
{
|
| 509 |
+
"gold": "contempt",
|
| 510 |
+
"p_anger": 0.2783,
|
| 511 |
+
"pred": "contempt"
|
| 512 |
+
},
|
| 513 |
+
{
|
| 514 |
+
"gold": "contempt",
|
| 515 |
+
"p_anger": 0.137,
|
| 516 |
+
"pred": "contempt"
|
| 517 |
+
},
|
| 518 |
+
{
|
| 519 |
+
"gold": "contempt",
|
| 520 |
+
"p_anger": 0.2378,
|
| 521 |
+
"pred": "contempt"
|
| 522 |
+
},
|
| 523 |
+
{
|
| 524 |
+
"gold": "contempt",
|
| 525 |
+
"p_anger": 0.0228,
|
| 526 |
+
"pred": "contempt"
|
| 527 |
+
}
|
| 528 |
+
],
|
| 529 |
+
"E ID probes + EN q, options swapped": [
|
| 530 |
+
{
|
| 531 |
+
"gold": "anger",
|
| 532 |
+
"p_anger": 0.5813,
|
| 533 |
+
"pred": "anger"
|
| 534 |
+
},
|
| 535 |
+
{
|
| 536 |
+
"gold": "anger",
|
| 537 |
+
"p_anger": 0.9839,
|
| 538 |
+
"pred": "anger"
|
| 539 |
+
},
|
| 540 |
+
{
|
| 541 |
+
"gold": "anger",
|
| 542 |
+
"p_anger": 0.1519,
|
| 543 |
+
"pred": "contempt"
|
| 544 |
+
},
|
| 545 |
+
{
|
| 546 |
+
"gold": "anger",
|
| 547 |
+
"p_anger": 0.6842,
|
| 548 |
+
"pred": "anger"
|
| 549 |
+
},
|
| 550 |
+
{
|
| 551 |
+
"gold": "anger",
|
| 552 |
+
"p_anger": 0.9915,
|
| 553 |
+
"pred": "anger"
|
| 554 |
+
},
|
| 555 |
+
{
|
| 556 |
+
"gold": "anger",
|
| 557 |
+
"p_anger": 0.5162,
|
| 558 |
+
"pred": "anger"
|
| 559 |
+
},
|
| 560 |
+
{
|
| 561 |
+
"gold": "anger",
|
| 562 |
+
"p_anger": 0.8113,
|
| 563 |
+
"pred": "anger"
|
| 564 |
+
},
|
| 565 |
+
{
|
| 566 |
+
"gold": "anger",
|
| 567 |
+
"p_anger": 0.9942,
|
| 568 |
+
"pred": "anger"
|
| 569 |
+
},
|
| 570 |
+
{
|
| 571 |
+
"gold": "contempt",
|
| 572 |
+
"p_anger": 0.573,
|
| 573 |
+
"pred": "anger"
|
| 574 |
+
},
|
| 575 |
+
{
|
| 576 |
+
"gold": "contempt",
|
| 577 |
+
"p_anger": 0.8482,
|
| 578 |
+
"pred": "anger"
|
| 579 |
+
},
|
| 580 |
+
{
|
| 581 |
+
"gold": "contempt",
|
| 582 |
+
"p_anger": 0.6422,
|
| 583 |
+
"pred": "anger"
|
| 584 |
+
},
|
| 585 |
+
{
|
| 586 |
+
"gold": "contempt",
|
| 587 |
+
"p_anger": 0.4279,
|
| 588 |
+
"pred": "contempt"
|
| 589 |
+
},
|
| 590 |
+
{
|
| 591 |
+
"gold": "contempt",
|
| 592 |
+
"p_anger": 0.8439,
|
| 593 |
+
"pred": "anger"
|
| 594 |
+
},
|
| 595 |
+
{
|
| 596 |
+
"gold": "contempt",
|
| 597 |
+
"p_anger": 0.048,
|
| 598 |
+
"pred": "contempt"
|
| 599 |
+
},
|
| 600 |
+
{
|
| 601 |
+
"gold": "contempt",
|
| 602 |
+
"p_anger": 0.0114,
|
| 603 |
+
"pred": "contempt"
|
| 604 |
+
},
|
| 605 |
+
{
|
| 606 |
+
"gold": "contempt",
|
| 607 |
+
"p_anger": 0.4708,
|
| 608 |
+
"pred": "contempt"
|
| 609 |
+
}
|
| 610 |
+
]
|
| 611 |
+
}
|
| 612 |
+
}
|
out/reconfirm.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"stages": {
|
| 3 |
+
"id_core": {
|
| 4 |
+
"keys": 471,
|
| 5 |
+
"only_in_a": 0,
|
| 6 |
+
"only_in_b": 0,
|
| 7 |
+
"max_abs_diff": 0.0,
|
| 8 |
+
"mean_abs_diff": 0.0,
|
| 9 |
+
"side_agree": 471,
|
| 10 |
+
"side_rows": 471
|
| 11 |
+
},
|
| 12 |
+
"id_core_swap": {
|
| 13 |
+
"keys": 471,
|
| 14 |
+
"only_in_a": 0,
|
| 15 |
+
"only_in_b": 0,
|
| 16 |
+
"max_abs_diff": 0.0,
|
| 17 |
+
"mean_abs_diff": 0.0,
|
| 18 |
+
"side_agree": 471,
|
| 19 |
+
"side_rows": 471
|
| 20 |
+
},
|
| 21 |
+
"id_diag": {
|
| 22 |
+
"keys": 53,
|
| 23 |
+
"only_in_a": 0,
|
| 24 |
+
"only_in_b": 0,
|
| 25 |
+
"max_abs_diff": 0.0,
|
| 26 |
+
"mean_abs_diff": 0.0,
|
| 27 |
+
"side_agree": 0,
|
| 28 |
+
"side_rows": 0
|
| 29 |
+
},
|
| 30 |
+
"id_veto": {
|
| 31 |
+
"keys": 471,
|
| 32 |
+
"only_in_a": 0,
|
| 33 |
+
"only_in_b": 0,
|
| 34 |
+
"max_abs_diff": 0.0,
|
| 35 |
+
"mean_abs_diff": 0.0,
|
| 36 |
+
"side_agree": 0,
|
| 37 |
+
"side_rows": 0
|
| 38 |
+
}
|
| 39 |
+
},
|
| 40 |
+
"second_run": {
|
| 41 |
+
"total_laya_seconds": 856.6,
|
| 42 |
+
"stages": {
|
| 43 |
+
"id_core": 305.0,
|
| 44 |
+
"id_core_swap": 301.1,
|
| 45 |
+
"id_diag": 53.9,
|
| 46 |
+
"id_veto": 196.6
|
| 47 |
+
},
|
| 48 |
+
"stage_rows": {
|
| 49 |
+
"id_core": 475,
|
| 50 |
+
"id_core_swap": 475,
|
| 51 |
+
"id_diag": 108,
|
| 52 |
+
"id_veto": 475
|
| 53 |
+
},
|
| 54 |
+
"rows": 475
|
| 55 |
+
},
|
| 56 |
+
"labels": {
|
| 57 |
+
"rows": 475,
|
| 58 |
+
"identical": 475,
|
| 59 |
+
"flips": [],
|
| 60 |
+
"max_prob_abs_diff": 0.0,
|
| 61 |
+
"identical_bytes": true
|
| 62 |
+
}
|
| 63 |
+
}
|
out/timings.json
CHANGED
|
@@ -1,19 +1,22 @@
|
|
| 1 |
{
|
| 2 |
"rows": 475,
|
| 3 |
-
"ambiguous_rows":
|
| 4 |
-
"total_laya_seconds":
|
| 5 |
"stages": {
|
| 6 |
-
"
|
| 7 |
-
"
|
| 8 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
},
|
| 10 |
"max_len": 256,
|
| 11 |
"head_max_len": 144,
|
| 12 |
"token_budget": 6144,
|
| 13 |
"margin": 0.1,
|
| 14 |
-
"
|
| 15 |
-
"en_core": 950,
|
| 16 |
-
"id_core": 475,
|
| 17 |
-
"en_diag": 428
|
| 18 |
-
}
|
| 19 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"rows": 475,
|
| 3 |
+
"ambiguous_rows": 54,
|
| 4 |
+
"total_laya_seconds": 851.2,
|
| 5 |
"stages": {
|
| 6 |
+
"id_core": 299.8,
|
| 7 |
+
"id_core_swap": 299.5,
|
| 8 |
+
"id_diag": 53.5,
|
| 9 |
+
"id_veto": 198.4
|
| 10 |
+
},
|
| 11 |
+
"stage_rows": {
|
| 12 |
+
"id_core": 475,
|
| 13 |
+
"id_core_swap": 475,
|
| 14 |
+
"id_diag": 108,
|
| 15 |
+
"id_veto": 475
|
| 16 |
},
|
| 17 |
"max_len": 256,
|
| 18 |
"head_max_len": 144,
|
| 19 |
"token_budget": 6144,
|
| 20 |
"margin": 0.1,
|
| 21 |
+
"language": "id-only"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
}
|
out_prev/anger_ekman_rows.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
out_prev/cache_en_core.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
out_prev/cache_en_diag.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
out_prev/cache_id_core.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
out_prev/speedup.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"docs": 32,
|
| 3 |
+
"ms_per_doc_one_question": {
|
| 4 |
+
"A_stock_default": 662.2,
|
| 5 |
+
"B_stock_tuned": 638.5,
|
| 6 |
+
"C_batched_tuned": 740.18,
|
| 7 |
+
"D_batched_default": 717.29
|
| 8 |
+
},
|
| 9 |
+
"speedup_token_budget_x": 1.04,
|
| 10 |
+
"speedup_batching_x": 0.86,
|
| 11 |
+
"speedup_total_x": 0.89,
|
| 12 |
+
"stage_seconds": {
|
| 13 |
+
"en_core": 709.7,
|
| 14 |
+
"id_core": 311.0,
|
| 15 |
+
"en_diag": 188.9
|
| 16 |
+
},
|
| 17 |
+
"total_laya_seconds": 1209.6,
|
| 18 |
+
"rows_scored": 475,
|
| 19 |
+
"ambiguous_rows": 214,
|
| 20 |
+
"rows_if_naive_2lang_5q": 4750,
|
| 21 |
+
"rows_paid": 1853
|
| 22 |
+
}
|
out_prev/timings.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"rows": 475,
|
| 3 |
+
"ambiguous_rows": 214,
|
| 4 |
+
"total_laya_seconds": 1209.6,
|
| 5 |
+
"stages": {
|
| 6 |
+
"en_core": 709.7,
|
| 7 |
+
"id_core": 311.0,
|
| 8 |
+
"en_diag": 188.9
|
| 9 |
+
},
|
| 10 |
+
"max_len": 256,
|
| 11 |
+
"head_max_len": 144,
|
| 12 |
+
"token_budget": 6144,
|
| 13 |
+
"margin": 0.1,
|
| 14 |
+
"stage_rows": {
|
| 15 |
+
"en_core": 950,
|
| 16 |
+
"id_core": 475,
|
| 17 |
+
"en_diag": 428
|
| 18 |
+
}
|
| 19 |
+
}
|
out_prev/veto_check.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"veto_mean_p_neither": 0.12,
|
| 3 |
+
"veto_flagged": 1,
|
| 4 |
+
"choice_acc": 0.812
|
| 5 |
+
}
|
probe_quality_id.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
"""Fit-for-purpose check in *both* languages, plus the two controls a reviewer will ask for.
|
| 3 |
+
|
| 4 |
+
Conditions (16 hand-written probes each, 8 anger + 8 contempt, chance = 0.50):
|
| 5 |
+
|
| 6 |
+
Z author's English probes + English question - reproduction check against the shipped 13/16
|
| 7 |
+
A English probes (of this set) + English question
|
| 8 |
+
B Indonesian probes + English question <- THE reading the Indonesian-only build runs
|
| 9 |
+
C Indonesian probes + Indonesian question - does the question's language matter?
|
| 10 |
+
D English probes + Indonesian question
|
| 11 |
+
E Indonesian probes + English question, criteria order swapped (contempt first)
|
| 12 |
+
- positional-bias control for B
|
| 13 |
+
|
| 14 |
+
Writes out/probe_quality_id.json.
|
| 15 |
+
"""
|
| 16 |
+
import json
|
| 17 |
+
|
| 18 |
+
import numpy as np
|
| 19 |
+
|
| 20 |
+
import laya_opt
|
| 21 |
+
from ekman_questions import EKMAN_QUESTIONS
|
| 22 |
+
from ekman_questions_id import EKMAN_QUESTIONS_ID
|
| 23 |
+
from probes import PROBES
|
| 24 |
+
from probes_id import PROBES_ID, PROBES_ID_EN
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def run(agent, texts, question):
|
| 28 |
+
res, st = laya_opt.score_texts(agent, {"ekman": question}, texts, max_len=256,
|
| 29 |
+
head_max_len=144, token_budget=6144, log=lambda *a: None)
|
| 30 |
+
pa = np.array([r["ekman"]["probabilities"]["anger"] for r in res])
|
| 31 |
+
return pa, res, st
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def summarise(name, gold, pa):
|
| 35 |
+
pred = np.where(pa >= 0.5, "anger", "contempt")
|
| 36 |
+
ok = int((pred == np.array(gold)).sum())
|
| 37 |
+
per = {}
|
| 38 |
+
for g in ("anger", "contempt"):
|
| 39 |
+
m = np.array(gold) == g
|
| 40 |
+
per[g] = {"n": int(m.sum()), "correct": int((pred[m] == g).sum()),
|
| 41 |
+
"mean_p_anger": round(float(pa[m].mean()), 3)}
|
| 42 |
+
row = {"condition": name, "n": len(gold), "correct": ok,
|
| 43 |
+
"accuracy": round(ok / len(gold), 3), "per_class": per,
|
| 44 |
+
"mean_p_anger_overall": round(float(pa.mean()), 3)}
|
| 45 |
+
print("%-52s %2d/%2d = %.3f | P(anger) anger-probes %.2f contempt-probes %.2f" % (
|
| 46 |
+
name, ok, len(gold), ok / len(gold), per["anger"]["mean_p_anger"],
|
| 47 |
+
per["contempt"]["mean_p_anger"]))
|
| 48 |
+
return row
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def main():
|
| 52 |
+
agent = laya_opt.load_agent()
|
| 53 |
+
assert agent is not None
|
| 54 |
+
import ekman_questions as EQ
|
| 55 |
+
EQ.assert_option_budget(agent.tok)
|
| 56 |
+
import re
|
| 57 |
+
import ekman_questions_id as EQID
|
| 58 |
+
for cid in ("anger", "contempt"):
|
| 59 |
+
n = len(agent.tok(re.sub(r"\s+", " ", EQID.EKMAN_QUESTIONS_ID["ekman"]["criteria"][cid]).strip(),
|
| 60 |
+
add_special_tokens=False)["input_ids"])
|
| 61 |
+
assert n <= 48, ("Indonesian criterion over laya's 48-token option cap", cid, n)
|
| 62 |
+
print("[probe] id criterion %-8s %d/48 option tokens" % (cid, n))
|
| 63 |
+
for qid in ("superiority", "blocked_or_unfair"):
|
| 64 |
+
n = len(agent.tok(EQID.EKMAN_QUESTIONS_ID[qid]["instructions"],
|
| 65 |
+
add_special_tokens=False)["input_ids"])
|
| 66 |
+
assert n <= 144, ("Indonesian instruction over the head budget", qid, n)
|
| 67 |
+
print("[probe] option budget ok for the Indonesian criteria too\n")
|
| 68 |
+
|
| 69 |
+
out = []
|
| 70 |
+
en_q = EKMAN_QUESTIONS["ekman"]
|
| 71 |
+
id_q = EKMAN_QUESTIONS_ID["ekman"]
|
| 72 |
+
swap_q = {"type": "choice", "instructions": id_q["instructions"],
|
| 73 |
+
"criteria": {"contempt": id_q["criteria"]["contempt"],
|
| 74 |
+
"anger": id_q["criteria"]["anger"]}}
|
| 75 |
+
|
| 76 |
+
jobs = [
|
| 77 |
+
("Z EN probes (author) + EN question", [g for g, _ in PROBES], [t for _, t in PROBES], en_q),
|
| 78 |
+
("A EN probes (this set)+ EN question", [g for g, _ in PROBES_ID_EN], [t for _, t in PROBES_ID_EN], en_q),
|
| 79 |
+
("B ID probes + EN question", [g for g, _ in PROBES_ID], [t for _, t in PROBES_ID], en_q),
|
| 80 |
+
("C ID probes + ID question", [g for g, _ in PROBES_ID], [t for _, t in PROBES_ID], id_q),
|
| 81 |
+
("D EN probes + ID question", [g for g, _ in PROBES_ID_EN], [t for _, t in PROBES_ID_EN], id_q),
|
| 82 |
+
("E ID probes + EN q, options swapped", [g for g, _ in PROBES_ID], [t for _, t in PROBES_ID], swap_q),
|
| 83 |
+
]
|
| 84 |
+
detail = {}
|
| 85 |
+
for name, gold, texts, q in jobs:
|
| 86 |
+
pa, res, st = run(agent, texts, q)
|
| 87 |
+
out.append(summarise(name, gold, pa))
|
| 88 |
+
detail[name] = [{"gold": g, "p_anger": round(float(p), 4),
|
| 89 |
+
"pred": "anger" if p >= 0.5 else "contempt"} for g, p in zip(gold, pa)]
|
| 90 |
+
with open("out/probe_quality_id.json", "w") as f:
|
| 91 |
+
json.dump({"conditions": out, "detail": detail}, f, indent=1)
|
| 92 |
+
print("\n[probe] wrote out/probe_quality_id.json")
|
| 93 |
+
# the two numbers the card quotes
|
| 94 |
+
b = out[2]
|
| 95 |
+
print("[probe] headline (ID text + EN question): %d/%d = %.3f" % (b["correct"], b["n"], b["accuracy"]))
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
if __name__ == "__main__":
|
| 99 |
+
main()
|
probes_id.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Hand-written clear-cut probes in Indonesian: 8 Ekman anger, 8 Ekman contempt.
|
| 2 |
+
|
| 3 |
+
The English probe set (`probes.py`) is kept as-is for the English reading. This file is its
|
| 4 |
+
Indonesian counterpart, written from the same two Paul Ekman Group pages (not from the corpus), so
|
| 5 |
+
the *fit-for-purpose* check can be run in the language the labels are actually decided in.
|
| 6 |
+
|
| 7 |
+
Four of the anger probes deliberately use the corpus's own explicit anger vocabulary - kesal,
|
| 8 |
+
murka, benci, tersinggung - because the Indonesian reading of the anger pool turned those same words
|
| 9 |
+
into `contempt`, which is exactly what this probe set has to test.
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
PROBES_ID = [
|
| 13 |
+
# --- 8 clear anger: blocked / treated unfairly, pushing to remove the obstacle -------------------
|
| 14 |
+
("anger", "Aku antre dua jam, tiba-tiba loketnya ditutup tanpa pemberitahuan. Tidak bisa diterima, "
|
| 15 |
+
"kembalikan uangku sekarang!"),
|
| 16 |
+
("anger", "Tetangga parkir di depan gerbangku lagi. Minggir atau aku panggil derek, sumpah!"),
|
| 17 |
+
("anger", "Setelah semua yang aku lakukan untuk dia, dia bohongin aku di depan orang banyak? "
|
| 18 |
+
"Aku benar-benar murka sama dia."),
|
| 19 |
+
("anger", "Listrik mati lagi pas jam ujian. Pemerintah ini tidak becus dan seharusnya malu!"),
|
| 20 |
+
("anger", "Jangan sentuh pekerjaanku! Kamu baru saja merusak tiga hari kerjaanku karena "
|
| 21 |
+
"kecerobohanmu."),
|
| 22 |
+
("anger", "Tidak adil kalau orang yang sama terus dapat shift bagus. Aku mau bicara sama "
|
| 23 |
+
"manajernya hari ini."),
|
| 24 |
+
("anger", "Beraninya kamu menuduh aku di depan semua orang? Minta maaf sekarang, atau aku bikin "
|
| 25 |
+
"kamu susah."),
|
| 26 |
+
("anger", "Sudah seratus kali aku bilang jangan buka buku harianku. Aku benci kamu karena itu."),
|
| 27 |
+
# --- 8 clear contempt: superiority over a lesser target, dismissing rather than demanding -------
|
| 28 |
+
("contempt", "Ya ampun, kamu tidak akan paham. Ini sedikit di atas level pendidikanmu."),
|
| 29 |
+
("contempt", "Sekolah tinggi-tinggi tapi menulisnya salah semua. Generasi ini memalukan dilihat."),
|
| 30 |
+
("contempt", "Aku sudah tidak mau berdebat dengan orang seperti dia, buat apa, otaknya tidak "
|
| 31 |
+
"sampai."),
|
| 32 |
+
("contempt", "Katanya dia ahli di televisi itu? Aku cuma bisa menghela napas sepanjang "
|
| 33 |
+
"wawancaranya."),
|
| 34 |
+
("contempt", "Biarkan mereka pegang penghargaan itu. Aku tidak akan turun derajat selevel dengan "
|
| 35 |
+
"badut-badut seperti itu."),
|
| 36 |
+
("contempt", "Lihat mereka meminta-minta like ke orang asing. Lucu juga betapa tidak berharganya "
|
| 37 |
+
"semua itu."),
|
| 38 |
+
("contempt", "Aku sudah tidak marah lagi sama mantanku. Aku cuma tidak percaya pernah pacaran "
|
| 39 |
+
"sama orang sekecil itu."),
|
| 40 |
+
("contempt", "Dasar tukang gambar di grup. Sedikit bisa fotoshop, langsung merasa paling "
|
| 41 |
+
"berbakat di dunia."),
|
| 42 |
+
]
|
| 43 |
+
|
| 44 |
+
# The same 16 probes in English, one per line (used for the 2x2 language-control matrix; note these
|
| 45 |
+
# are *literal* renderings of the Indonesian probes, so the comparison isolates the language and not
|
| 46 |
+
# the wording).
|
| 47 |
+
PROBES_ID_EN = [
|
| 48 |
+
("anger", "I queued for two hours and suddenly the counter closed without notice. Unacceptable, "
|
| 49 |
+
"give me my money back now!"),
|
| 50 |
+
("anger", "The neighbour parked in front of my gate again. Move it or I call a tow truck, I swear!"),
|
| 51 |
+
("anger", "After everything I did for him, he lies to me in front of everyone? I am really furious "
|
| 52 |
+
"with him."),
|
| 53 |
+
("anger", "The power went out again during the exam. This government is incompetent and should be "
|
| 54 |
+
"ashamed!"),
|
| 55 |
+
("anger", "Don't touch my work! You just ruined three days of my work with your carelessness."),
|
| 56 |
+
("anger", "It is unfair that the same person keeps getting the good shifts. I want to talk to the "
|
| 57 |
+
"manager today."),
|
| 58 |
+
("anger", "How dare you accuse me in front of everyone? Apologise now, or I will make things hard "
|
| 59 |
+
"for you."),
|
| 60 |
+
("anger", "I told you a hundred times not to open my diary. I hate you for it."),
|
| 61 |
+
("contempt", "Oh my, you won't understand. This is a little above your education level."),
|
| 62 |
+
("contempt", "So highly educated but cannot write a single thing correctly. This generation is "
|
| 63 |
+
"embarrassing to watch."),
|
| 64 |
+
("contempt", "I don't want to argue with people like him any more, what for, his brain cannot "
|
| 65 |
+
"reach that far."),
|
| 66 |
+
("contempt", "They say he is an expert on television? I can only sigh through his entire "
|
| 67 |
+
"interview."),
|
| 68 |
+
("contempt", "Let them keep that award. I will not lower myself to the level of clowns like that."),
|
| 69 |
+
("contempt", "Look at them begging strangers for likes. Funny how worthless all of it is."),
|
| 70 |
+
("contempt", "I am no longer angry with my ex. I just cannot believe I ever dated someone that "
|
| 71 |
+
"small."),
|
| 72 |
+
("contempt", "Just a little photoshop group guy. Can barely edit and already feels like the most "
|
| 73 |
+
"talented person in the world."),
|
| 74 |
+
]
|
publish.py
CHANGED
|
@@ -29,6 +29,12 @@ def main():
|
|
| 29 |
for need in ("README.md",):
|
| 30 |
if not os.path.exists(os.path.join(args.dist, need)):
|
| 31 |
sys.exit("run make_dataset.py first: %s is missing from %s" % (need, args.dist))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
from huggingface_hub import HfApi
|
| 34 |
api = HfApi(token=args.token)
|
|
|
|
| 29 |
for need in ("README.md",):
|
| 30 |
if not os.path.exists(os.path.join(args.dist, need)):
|
| 31 |
sys.exit("run make_dataset.py first: %s is missing from %s" % (need, args.dist))
|
| 32 |
+
# working notes, scratch dirs and the local model cache must never be uploaded
|
| 33 |
+
junk = [f for f in sorted(os.listdir(args.dist))
|
| 34 |
+
if f.upper().startswith(("REVISION_NOTES", "NOTES", "TODO", "CHANGELOG"))
|
| 35 |
+
or f in ("build", "models", "data", "dist", ".git")]
|
| 36 |
+
if junk:
|
| 37 |
+
sys.exit("refusing to publish: %s/%s" % (args.dist, ", ".join(junk)))
|
| 38 |
|
| 39 |
from huggingface_hub import HfApi
|
| 40 |
api = HfApi(token=args.token)
|
runs/label_run_id.log
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[laya] agent ready in 12.6s (321908995 params)
|
| 2 |
+
[laya] option budget ok: every criterion fits laya's 48-token cap
|
| 3 |
+
[data] 475 rows labelled anger (of 2243 annotated tweets)
|
| 4 |
+
[stage id_core] 475 rows to score, 0 already cached
|
| 5 |
+
[stage id_core] {"seconds": 299.8, "docs": 475, "forward_passes": 13, "docs_per_pass": 36.54, "rows": 475, "ms_per_doc": 631.2, "ms_per_row": 631.25, "max_seq_len": 219}
|
| 6 |
+
[stage id_core_swap] 475 rows to score, 0 already cached
|
| 7 |
+
[stage id_core_swap] {"seconds": 299.5, "docs": 475, "forward_passes": 13, "docs_per_pass": 36.54, "rows": 475, "ms_per_doc": 630.6, "ms_per_row": 630.62, "max_seq_len": 219}
|
| 8 |
+
[stage id_diag] 54/475 rows not decided by the Indonesian choice reading
|
| 9 |
+
[stage id_diag] 54 rows to score, 0 already cached
|
| 10 |
+
[stage id_diag] {"seconds": 53.5, "docs": 54, "forward_passes": 3, "docs_per_pass": 18.0, "rows": 108, "ms_per_doc": 991.3, "ms_per_row": 495.65, "max_seq_len": 158}
|
| 11 |
+
[stage id_veto] 475 rows to score, 0 already cached
|
| 12 |
+
[stage id_veto] {"seconds": 198.4, "docs": 475, "forward_passes": 8, "docs_per_pass": 59.38, "rows": 475, "ms_per_doc": 417.7, "ms_per_row": 417.67, "max_seq_len": 165}
|
| 13 |
+
|
| 14 |
+
=== laya anger/contempt split (Indonesian only) ===
|
| 15 |
+
label
|
| 16 |
+
anger 289
|
| 17 |
+
contempt 186
|
| 18 |
+
|
| 19 |
+
label provenance:
|
| 20 |
+
label_source
|
| 21 |
+
ekman_choice_id 421
|
| 22 |
+
ekman_noul_tiebreak 33
|
| 23 |
+
ekman_choice_order_avg 18
|
| 24 |
+
kept_original_label 3
|
| 25 |
+
|
| 26 |
+
contempt share of the pool: 39.2%
|
| 27 |
+
ambiguous (|margin|<0.10): 54
|
| 28 |
+
mean P(anger): as prompted 0.589 | swapped 0.726
|
| 29 |
+
rows whose argmax flips with the option order: 119 (25.1%)
|
| 30 |
+
p(not anger or contempt) > 0.5: 18
|
| 31 |
+
laya seconds: {"id_core": 299.8, "id_core_swap": 299.5, "id_diag": 53.5, "id_veto": 198.4}
|
runs/label_run_id_reconfirm.log
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[laya] agent ready in 15.2s (321908995 params)
|
| 2 |
+
[laya] option budget ok: every criterion fits laya's 48-token cap
|
| 3 |
+
[data] 475 rows labelled anger (of 2243 annotated tweets)
|
| 4 |
+
[stage id_core] 475 rows to score, 0 already cached
|
| 5 |
+
[stage id_core] {"seconds": 305.0, "docs": 475, "forward_passes": 13, "docs_per_pass": 36.54, "rows": 475, "ms_per_doc": 642.1, "ms_per_row": 642.05, "max_seq_len": 219}
|
| 6 |
+
[stage id_core_swap] 475 rows to score, 0 already cached
|
| 7 |
+
[stage id_core_swap] {"seconds": 301.1, "docs": 475, "forward_passes": 13, "docs_per_pass": 36.54, "rows": 475, "ms_per_doc": 633.9, "ms_per_row": 633.91, "max_seq_len": 219}
|
| 8 |
+
[stage id_diag] 54/475 rows not decided by the Indonesian choice reading
|
| 9 |
+
[stage id_diag] 54 rows to score, 0 already cached
|
| 10 |
+
[stage id_diag] {"seconds": 53.9, "docs": 54, "forward_passes": 3, "docs_per_pass": 18.0, "rows": 108, "ms_per_doc": 998.4, "ms_per_row": 499.22, "max_seq_len": 158}
|
| 11 |
+
[stage id_veto] 475 rows to score, 0 already cached
|
| 12 |
+
[stage id_veto] {"seconds": 196.6, "docs": 475, "forward_passes": 8, "docs_per_pass": 59.38, "rows": 475, "ms_per_doc": 413.8, "ms_per_row": 413.83, "max_seq_len": 165}
|
| 13 |
+
|
| 14 |
+
=== laya anger/contempt split (Indonesian only), second run ===
|
| 15 |
+
label
|
| 16 |
+
anger 289
|
| 17 |
+
contempt 186
|
| 18 |
+
|
| 19 |
+
label provenance:
|
| 20 |
+
label_source
|
| 21 |
+
ekman_choice_id 421
|
| 22 |
+
ekman_noul_tiebreak 33
|
| 23 |
+
ekman_choice_order_avg 18
|
| 24 |
+
kept_original_label 3
|
| 25 |
+
|
| 26 |
+
contempt share of the pool: 39.2%
|
| 27 |
+
ambiguous (|margin|<0.10): 54
|
| 28 |
+
mean P(anger): as prompted 0.589 | swapped 0.726
|
| 29 |
+
rows whose argmax flips with the option order: 119 (25.1%)
|
| 30 |
+
p(not anger or contempt) > 0.5: 18
|
| 31 |
+
laya seconds: {"id_core": 305.0, "id_core_swap": 301.1, "id_diag": 53.9, "id_veto": 196.6}
|
split_exact.py
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Exact 8:1:1 stratification that still keeps duplicate groups whole.
|
| 2 |
+
|
| 3 |
+
The published build split with a greedy deficit-filling pass (`make_dataset.stratified_811`), which
|
| 4 |
+
cannot hit exact split sizes when the last group of a class does not fit: it landed 2,243 rows on
|
| 5 |
+
1794/226/223 (0.02 / 0.08 / 0.06 points off 8:1:1) and `anger_split_balanced` on 150/20/18 (0.4 /
|
| 6 |
+
1.2 / 1.2 points off).
|
| 7 |
+
|
| 8 |
+
Two changes make the counts exact without giving up the no-leakage guarantee:
|
| 9 |
+
|
| 10 |
+
1. **Bottleneck targets.** The tenth block b = floor(n / 10) is the unit: `valid` and `test` get
|
| 11 |
+
exactly b rows each, `train` takes n - 2b. That is exact to the last row and keeps the two tail
|
| 12 |
+
splits the same size at their plain 10% floor (2,243 -> 1795 / 224 / 224, i.e. 8b + 3 for train).
|
| 13 |
+
`ideal_targets()` then solves the per-class-per-split cells as an integer program (scipy's HiGHS)
|
| 14 |
+
against those column totals, minimising the total absolute distance to `n_class * fraction`.
|
| 15 |
+
2. **Greedy place, then repair.** Groups are placed by need, then single groups are moved between
|
| 16 |
+
splits as long as a move lowers `PRIMARY * |column deficits| + |cell distances|`. Because all
|
| 17 |
+
but a handful of the ~2,200 groups are singletons, the column totals always reach their exact
|
| 18 |
+
targets, so the shipped files are 8:1:1 to the last row *and* leak-free.
|
| 19 |
+
"""
|
| 20 |
+
from typing import Dict, List, Sequence, Tuple
|
| 21 |
+
|
| 22 |
+
import numpy as np
|
| 23 |
+
import pandas as pd
|
| 24 |
+
|
| 25 |
+
SPLITS = ("train", "valid", "test")
|
| 26 |
+
FRACTIONS = (0.8, 0.1, 0.1)
|
| 27 |
+
PRIMARY = 1e6 # weight on exact column totals vs. per-class cell fit
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def apportion(n: int, fractions: Sequence[float] = FRACTIONS) -> List[int]:
|
| 31 |
+
"""Exact 8b : 1b : 1b, where b = floor(n/10) is the bottleneck.
|
| 32 |
+
|
| 33 |
+
Every split config here is built so that `n` is a multiple of ten - the balanced pools sample a
|
| 34 |
+
multiple of ten rows per class (180 of 186, see `sample_groups_per_class`) - so `n - 2b` is
|
| 35 |
+
exactly `8b` and the three splits are 8:1:1 to the row with nothing left over. The formula
|
| 36 |
+
still returns a sensible answer for an `n` that is not a multiple of ten (the rows no tenth can
|
| 37 |
+
hold go to `train`), but no shipped config relies on that.
|
| 38 |
+
|
| 39 |
+
The tenth block b = floor(n / 10) is the unit every split is measured in. n is never a multiple
|
| 40 |
+
of ten here, and 8b : 1b : 1b can only ever account for 10b <= n rows, so the rows that no tenth
|
| 41 |
+
can hold (n - 10b, at most 9) go to `train` - the largest split, where they move the ratio least,
|
| 42 |
+
and the only placement that keeps both tail splits at exactly one bottleneck each:
|
| 43 |
+
|
| 44 |
+
2,243 -> 1795 / 224 / 224 (b = 224, train = 8b + 3)
|
| 45 |
+
1,302 -> 1042 / 130 / 130 (b = 130, train = 8b + 2)
|
| 46 |
+
658 -> 528 / 65 / 65 (b = 65, train = 8b + 8)
|
| 47 |
+
475 -> 381 / 47 / 47 (b = 47, train = 8b + 5)
|
| 48 |
+
372 -> 298 / 37 / 37 (b = 37, train = 8b + 2)
|
| 49 |
+
|
| 50 |
+
`train` is always `n - 2b`, never `8b`, so the leftover rows are never dropped. For n < 10 the
|
| 51 |
+
tenth block is 0 rows and all n rows go to `train`.
|
| 52 |
+
"""
|
| 53 |
+
b = n // 10
|
| 54 |
+
if b == 0:
|
| 55 |
+
return [n, 0, 0]
|
| 56 |
+
tails = [b] * (len(fractions) - 1)
|
| 57 |
+
return [n - sum(tails)] + tails
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def sample_groups_per_class(df, per_class_rows: int, seed: int, labels=None):
|
| 61 |
+
"""Down-sample to exactly `per_class_rows` rows per class, in whole duplicate groups.
|
| 62 |
+
|
| 63 |
+
A balanced config is a sample, so it can be sized to whatever makes the split exact; every group
|
| 64 |
+
(a wording that repeats, possibly with a different upstream label) is kept or dropped as a unit,
|
| 65 |
+
so duplicate text can never straddle splits. Rows are dropped by shuffling that class's groups
|
| 66 |
+
with `seed` and dropping whole groups until exactly `class_size - per_class_rows` rows are gone,
|
| 67 |
+
which keeps the result deterministic and independent of the group order on disk.
|
| 68 |
+
"""
|
| 69 |
+
labels = list(labels) if labels is not None else sorted(df["label"].unique())
|
| 70 |
+
rng = np.random.RandomState(seed)
|
| 71 |
+
keep = np.zeros(len(df), dtype=bool)
|
| 72 |
+
dropped = {}
|
| 73 |
+
for c in labels:
|
| 74 |
+
idx = df.index[df["label"] == c].to_numpy()
|
| 75 |
+
sizes = df.loc[idx].groupby("group").size()
|
| 76 |
+
need = int(sizes.sum()) - per_class_rows
|
| 77 |
+
assert need >= 0, f"{c}: {sizes.sum()} rows is less than the sample size {per_class_rows}"
|
| 78 |
+
order = rng.permutation(len(sizes))
|
| 79 |
+
drop_groups, got = set(), 0
|
| 80 |
+
for k in order: # prefer groups that fit the budget exactly
|
| 81 |
+
g = sizes.index[k]
|
| 82 |
+
if sizes.iloc[k] <= need - got:
|
| 83 |
+
drop_groups.add(g)
|
| 84 |
+
got += int(sizes.iloc[k])
|
| 85 |
+
if got == need:
|
| 86 |
+
break
|
| 87 |
+
assert got == need, f"{c}: cannot drop exactly {need} rows without cutting a group"
|
| 88 |
+
dropped[c] = [int(g) for g in drop_groups]
|
| 89 |
+
keep |= df.index.isin(idx) & ~df["group"].isin(drop_groups)
|
| 90 |
+
out = df[keep].reset_index(drop=True)
|
| 91 |
+
assert len(out) == per_class_rows * len(labels)
|
| 92 |
+
assert set(out["label"].value_counts()) == {per_class_rows}
|
| 93 |
+
return out, dropped
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def ideal_targets(class_sizes: Dict[str, int], split_sizes: Sequence[int],
|
| 97 |
+
fractions: Sequence[float] = FRACTIONS) -> Dict[str, List[int]]:
|
| 98 |
+
"""Integer per-(class, split) targets: exact column totals, minimal distance to n_c * f_s.
|
| 99 |
+
|
| 100 |
+
Solves min sum_{c,s} |x_cs - n_c f_s| s.t. sum_s x_cs = n_c, sum_c x_cs = N_s (x >= 0 int)
|
| 101 |
+
so the class-level counts stay as close to proportional as the exact split sizes allow.
|
| 102 |
+
"""
|
| 103 |
+
classes = list(class_sizes)
|
| 104 |
+
S = len(split_sizes)
|
| 105 |
+
nc, ns = len(classes), len(split_sizes)
|
| 106 |
+
nvar = nc * S + nc * S # x (int) then d (continuous)
|
| 107 |
+
c_obj = np.zeros(nvar)
|
| 108 |
+
c_obj[nc * S:] = 1.0
|
| 109 |
+
integrality = np.zeros(nvar)
|
| 110 |
+
integrality[:nc * S] = 1
|
| 111 |
+
lb = np.zeros(nvar)
|
| 112 |
+
ub = np.full(nvar, np.inf)
|
| 113 |
+
rows, lows, highs = [], [], []
|
| 114 |
+
for i, cl in enumerate(classes): # sum_s x_cs = n_c
|
| 115 |
+
r = np.zeros(nvar); r[i * S:(i + 1) * S] = 1
|
| 116 |
+
rows.append(r); lows.append(class_sizes[cl]); highs.append(class_sizes[cl])
|
| 117 |
+
for s in range(S): # sum_c x_cs = N_s
|
| 118 |
+
r = np.zeros(nvar)
|
| 119 |
+
for i in range(nc):
|
| 120 |
+
r[i * S + s] = 1
|
| 121 |
+
rows.append(r); lows.append(split_sizes[s]); highs.append(split_sizes[s])
|
| 122 |
+
for i, cl in enumerate(classes): # |x_cs - n_c f_s| <= d_cs
|
| 123 |
+
for s in range(S):
|
| 124 |
+
tgt = class_sizes[cl] * fractions[s]
|
| 125 |
+
r = np.zeros(nvar); r[i * S + s] = 1; r[nc * S + i * S + s] = -1
|
| 126 |
+
rows.append(r); lows.append(-np.inf); highs.append(tgt)
|
| 127 |
+
r = np.zeros(nvar); r[i * S + s] = -1; r[nc * S + i * S + s] = -1
|
| 128 |
+
rows.append(r); lows.append(-np.inf); highs.append(-tgt)
|
| 129 |
+
from scipy.optimize import Bounds, LinearConstraint, milp
|
| 130 |
+
res = milp(c=c_obj, constraints=LinearConstraint(np.array(rows), np.array(lows), np.array(highs)),
|
| 131 |
+
integrality=integrality, bounds=Bounds(lb, ub))
|
| 132 |
+
if not res.success:
|
| 133 |
+
raise RuntimeError("target rounding ILP failed: %s" % res.message)
|
| 134 |
+
x = np.rint(res.x[:nc * S]).astype(int).reshape(nc, S)
|
| 135 |
+
assert (x.sum(1) == np.array([class_sizes[c] for c in classes])).all()
|
| 136 |
+
assert (x.sum(0) == np.array(split_sizes)).all(), (x.sum(0), split_sizes)
|
| 137 |
+
return {cl: [int(v) for v in x[i]] for i, cl in enumerate(classes)}
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
def _cost(cells: Dict[Tuple[str, int], int], ideal: Dict[Tuple[str, int], float],
|
| 141 |
+
col_target: Sequence[int], col_now: Sequence[int]) -> float:
|
| 142 |
+
c = 0.0
|
| 143 |
+
for k in ideal:
|
| 144 |
+
c += abs(cells[k] - ideal[k])
|
| 145 |
+
for s in range(3):
|
| 146 |
+
c += PRIMARY * abs(col_now[s] - col_target[s])
|
| 147 |
+
return c
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
def assign_groups(df: pd.DataFrame, targets: Dict[str, List[int]], seed: int) -> List[str]:
|
| 151 |
+
"""Group-aware assignment: place by need, then repair until the column totals are exact."""
|
| 152 |
+
labels = sorted(targets)
|
| 153 |
+
cols = {s: i for i, s in enumerate(SPLITS)}
|
| 154 |
+
grp = df["group"].to_numpy()
|
| 155 |
+
lab = df["label"].to_numpy()
|
| 156 |
+
groups: Dict[int, List[int]] = {}
|
| 157 |
+
for i, g in enumerate(grp):
|
| 158 |
+
groups.setdefault(int(g), []).append(i)
|
| 159 |
+
# label counts per group (a group can span two labels: one translation, two different tweets)
|
| 160 |
+
gcounts = {g: pd.Series([lab[i] for i in idx]).value_counts().to_dict()
|
| 161 |
+
for g, idx in groups.items()}
|
| 162 |
+
col_target = [sum(targets[c][s] for c in labels) for s in range(3)]
|
| 163 |
+
frac = np.array(FRACTIONS)
|
| 164 |
+
ideal = {(c, s): sum(targets[c]) * frac[s] for c in labels for s in range(3)}
|
| 165 |
+
|
| 166 |
+
rng = np.random.RandomState(seed)
|
| 167 |
+
order = sorted(groups, key=lambda g: -len(groups[g]))
|
| 168 |
+
# shuffle inside each size class so the seed controls which wording lands where
|
| 169 |
+
buckets: Dict[int, List[int]] = {}
|
| 170 |
+
for g in order:
|
| 171 |
+
buckets.setdefault(len(groups[g]), []).append(g)
|
| 172 |
+
ordered: List[int] = []
|
| 173 |
+
for size in sorted(buckets, reverse=True):
|
| 174 |
+
gs = buckets[size]
|
| 175 |
+
rng.shuffle(gs)
|
| 176 |
+
ordered += gs
|
| 177 |
+
|
| 178 |
+
rem = {c: [targets[c][s] for s in range(3)] for c in targets}
|
| 179 |
+
cells = {(c, s): 0 for c in labels for s in range(3)}
|
| 180 |
+
col_now = [0, 0, 0]
|
| 181 |
+
assign: Dict[int, int] = {}
|
| 182 |
+
for g in ordered:
|
| 183 |
+
best, best_score = 0, -1e18
|
| 184 |
+
for s in range(3):
|
| 185 |
+
score = 0.0
|
| 186 |
+
for c, k in gcounts[g].items():
|
| 187 |
+
tgt = targets[c][s]
|
| 188 |
+
score += k * (rem[c][s] / tgt if tgt else -1.0)
|
| 189 |
+
if score > best_score + 1e-12:
|
| 190 |
+
best, best_score = s, score
|
| 191 |
+
assign[g] = best
|
| 192 |
+
for c, k in gcounts[g].items():
|
| 193 |
+
rem[c][best] -= k
|
| 194 |
+
cells[(c, best)] += k
|
| 195 |
+
col_now[best] += len(groups[g])
|
| 196 |
+
|
| 197 |
+
# ---- repair: move whole groups while a move lowers `PRIMARY * column deficits + cell distance`
|
| 198 |
+
def col_penalty(col):
|
| 199 |
+
return PRIMARY * sum(abs(col[s] - col_target[s]) for s in range(3))
|
| 200 |
+
|
| 201 |
+
def cell_delta(g, s_from, s_to):
|
| 202 |
+
return sum(abs(cells[(c, s_to)] + k - ideal[(c, s_to)]) - abs(cells[(c, s_to)] - ideal[(c, s_to)])
|
| 203 |
+
+ abs(cells[(c, s_from)] - k - ideal[(c, s_from)]) - abs(cells[(c, s_from)] - ideal[(c, s_from)])
|
| 204 |
+
for c, k in gcounts[g].items())
|
| 205 |
+
|
| 206 |
+
cur = col_penalty(col_now) + sum(abs(cells[k] - ideal[k]) for k in ideal)
|
| 207 |
+
for _ in range(20000):
|
| 208 |
+
best_move, best_cost = None, cur
|
| 209 |
+
for g, s_from in assign.items():
|
| 210 |
+
n = len(groups[g])
|
| 211 |
+
for s_to in range(3):
|
| 212 |
+
if s_to == s_from:
|
| 213 |
+
continue
|
| 214 |
+
col_after = list(col_now); col_after[s_from] -= n; col_after[s_to] += n
|
| 215 |
+
p_delta = col_penalty(col_after) - col_penalty(col_now)
|
| 216 |
+
if p_delta > 0: # never trade an exact column for a cell
|
| 217 |
+
continue
|
| 218 |
+
cst = cur + p_delta + cell_delta(g, s_from, s_to)
|
| 219 |
+
if cst < best_cost - 1e-9:
|
| 220 |
+
best_move, best_cost = (g, s_from, s_to), cst
|
| 221 |
+
if best_move is None:
|
| 222 |
+
break
|
| 223 |
+
g, s_from, s_to = best_move
|
| 224 |
+
assign[g] = s_to
|
| 225 |
+
col_now[s_from] -= len(groups[g]); col_now[s_to] += len(groups[g])
|
| 226 |
+
for c, k in gcounts[g].items():
|
| 227 |
+
cells[(c, s_from)] -= k
|
| 228 |
+
cells[(c, s_to)] += k
|
| 229 |
+
cur = best_cost
|
| 230 |
+
out = df.copy()
|
| 231 |
+
out["split"] = [SPLITS[assign[int(g)]] for g in out["group"].to_numpy()]
|
| 232 |
+
return out
|
test_split_exact.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Does the build hit exact 8b:1b:1b with no leakage - and are the whole pools really whole?
|
| 2 |
+
|
| 3 |
+
Checks, on the labels actually shipped in `build/out/anger_ekman_rows.csv`:
|
| 4 |
+
|
| 5 |
+
1. `balanced` (7 classes) and `anger_split_balanced` (2 classes) land exactly on 8b : 1b : 1b with
|
| 6 |
+
b = N/10, per class as well as overall, and no duplicate group straddles a split;
|
| 7 |
+
2. `full` and `anger_split` carry the complete pools in one split;
|
| 8 |
+
3. the balanced sample is exactly `m` rows per class, m the largest multiple of ten that fits, and
|
| 9 |
+
dropping rows never cuts a group.
|
| 10 |
+
|
| 11 |
+
The last block re-runs the *published* greedy splitter (`make_dataset.stratified_811_greedy`) on the
|
| 12 |
+
earlier pools for contrast - that is the splitter whose rounding these checks exist to replace.
|
| 13 |
+
"""
|
| 14 |
+
import time
|
| 15 |
+
|
| 16 |
+
import numpy as np
|
| 17 |
+
|
| 18 |
+
import pandas as pd
|
| 19 |
+
|
| 20 |
+
from make_dataset import (LABELS_BINARY, LABELS_EKMAN, SOURCE_TO_EKMAN, add_text_group,
|
| 21 |
+
balanced_pool, norm)
|
| 22 |
+
from split_exact import SPLITS, apportion, assign_groups, ideal_targets
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def build_pool(labels_csv="build/out/anger_ekman_rows.csv"):
|
| 26 |
+
f1 = pd.read_csv("data/file1.csv", index_col=0)
|
| 27 |
+
f2 = pd.read_csv("data/file2.csv", index_col=0)
|
| 28 |
+
df = f1.join(f2)
|
| 29 |
+
df["text"] = df["tweet"].map(norm)
|
| 30 |
+
df["text_en"] = df["tweet_en"].map(norm)
|
| 31 |
+
df["row_src"] = df.index
|
| 32 |
+
df["source_label"] = df["label"].astype(str).str.strip().str.lower()
|
| 33 |
+
df["label"] = df["source_label"].replace({"joy": "enjoyment"})
|
| 34 |
+
lab = pd.read_csv(labels_csv)
|
| 35 |
+
m = df.merge(lab[["row_src", "label"]].rename(columns={"label": "ek"}), on="row_src", how="left")
|
| 36 |
+
df["label"] = m["ek"].where(m["ek"].notna(), df["label"]).values
|
| 37 |
+
return add_text_group(df)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def check_split(name, sub, labels, m):
|
| 41 |
+
"""Exact 8b:1b:1b, every class the same size in every split, no group in two splits."""
|
| 42 |
+
t0 = time.time()
|
| 43 |
+
N = len(sub)
|
| 44 |
+
per_class_want = apportion(m)
|
| 45 |
+
assert N % 10 == 0, f"{name}: {N} rows is not a multiple of ten"
|
| 46 |
+
b = N // 10
|
| 47 |
+
want = [8 * b, b, b]
|
| 48 |
+
assert apportion(N) == want, (apportion(N), want)
|
| 49 |
+
out = assign_groups(sub, ideal_targets(sub["label"].value_counts().to_dict(), want), 0)
|
| 50 |
+
got = [int((out["split"] == s).sum()) for s in SPLITS]
|
| 51 |
+
leak = 0
|
| 52 |
+
for s in SPLITS:
|
| 53 |
+
g = set(out.loc[out["split"] == s, "group"])
|
| 54 |
+
for o in SPLITS:
|
| 55 |
+
if o != s:
|
| 56 |
+
leak += len(g & set(out.loc[out["split"] == o, "group"]))
|
| 57 |
+
per_class_ok = all(
|
| 58 |
+
set(out.loc[out["split"] == s, "label"].value_counts().values) == {per_class_want[i]}
|
| 59 |
+
for i, s in enumerate(SPLITS))
|
| 60 |
+
print("%-22s N=%-5d b=%-4d got=%-16s per class %s per-class=%s leak=%d %.1fs" % (
|
| 61 |
+
name, N, b, "/".join(map(str, got)), "/".join(map(str, per_class_want)),
|
| 62 |
+
"uniform" if per_class_ok else "RAGGED", leak, time.time() - t0))
|
| 63 |
+
assert got == want and leak == 0 and per_class_ok
|
| 64 |
+
return out, want
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def main():
|
| 68 |
+
df = build_pool()
|
| 69 |
+
ang = df[df["source_label"] == "anger"].reset_index(drop=True)
|
| 70 |
+
|
| 71 |
+
# 1-2: the balanced configs split exactly, the whole-pool configs are not split at all
|
| 72 |
+
for name, base, labels in (("balanced", df, LABELS_EKMAN),
|
| 73 |
+
("anger_split_balanced", ang, LABELS_BINARY)):
|
| 74 |
+
sub, m, dropped = balanced_pool(base, labels)
|
| 75 |
+
assert set(sub["label"].value_counts().values) == {m}, (name, m)
|
| 76 |
+
assert m % 10 == 0 and len(sub) == m * len(labels)
|
| 77 |
+
assert all(len(g) > 1 for c in dropped for g in []), "sanity"
|
| 78 |
+
check_split(name, sub, labels, m)
|
| 79 |
+
for name, base in (("full", df), ("anger_split", ang)):
|
| 80 |
+
print("%-22s N=%-5d one split, complete pool, nothing held out" % (name, len(base)))
|
| 81 |
+
|
| 82 |
+
# 3: the sample size rule - largest multiple of ten that fits the smallest class
|
| 83 |
+
small = pd.DataFrame({"label": ["a"] * 186 + ["b"] * 200, "group": range(386)})
|
| 84 |
+
sub, m, _ = balanced_pool(small, ["a", "b"])
|
| 85 |
+
assert m == 180 and set(sub["label"].value_counts().values) == {180}, (m, sub["label"].value_counts())
|
| 86 |
+
print("\nsample rule: 186 / 200 eligible -> %d rows per class (largest multiple of ten)" % m)
|
| 87 |
+
|
| 88 |
+
# contrast: the published pools and the published greedy splitter, for reference
|
| 89 |
+
print("\ncontrast - the earlier pools, split by the published greedy splitter:")
|
| 90 |
+
dfp = build_pool("out_prev/anger_ekman_rows.csv")
|
| 91 |
+
angp = dfp[dfp["source_label"] == "anger"].reset_index(drop=True)
|
| 92 |
+
from make_dataset import stratified_811_greedy
|
| 93 |
+
|
| 94 |
+
def old_pool(frame, labels, seed=0):
|
| 95 |
+
"""the earlier rule: equal to the smallest class exactly, no ten-row block"""
|
| 96 |
+
per = min(int((frame["label"] == l).sum()) for l in labels)
|
| 97 |
+
rng = np.random.RandomState(seed + 1)
|
| 98 |
+
take = []
|
| 99 |
+
for l in labels:
|
| 100 |
+
idx = frame.index[frame["label"] == l].to_list()
|
| 101 |
+
take += idx if len(idx) == per else list(np.array(idx)[rng.permutation(len(idx))[:per]])
|
| 102 |
+
return frame.loc[sorted(take)].reset_index(drop=True)
|
| 103 |
+
|
| 104 |
+
for name, base in (("full", dfp), ("balanced", old_pool(dfp, LABELS_EKMAN)),
|
| 105 |
+
("anger_split", angp), ("anger_split_balanced", old_pool(angp, LABELS_BINARY))):
|
| 106 |
+
o = stratified_811_greedy(base, 0)
|
| 107 |
+
got = [int((o["split"] == s).sum()) for s in SPLITS]
|
| 108 |
+
N = len(base)
|
| 109 |
+
print(" %-22s N=%-5d got=%-18s dev=%s pts" % (
|
| 110 |
+
name, N, "/".join(map(str, got)),
|
| 111 |
+
"/".join("%.2f" % (abs(got[i] / N - f) * 100) for i, f in enumerate((0.8, 0.1, 0.1)))))
|
| 112 |
+
print("\n[test] exact 8b:1b:1b, per-class uniform, no group leakage, complete pools: PASS")
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
if __name__ == "__main__":
|
| 116 |
+
main()
|