Datasets:
Tasks:
Text Classification
Formats:
parquet
Sub-tasks:
multi-class-classification
Size:
1K - 10K
License:
EmoTweetID unified under Ekman's 7 universal emotions: human labels kept, anger pool split into anger/contempt by laya
f5a2109 verified Download probe_quality.py from mahalisyarifuddin/emotweetid-ekman7: direct link, hf CLI and curl.
- Browser
- Download file 1.57 kB
-
https://huggingface.co/datasets/mahalisyarifuddin/emotweetid-ekman7/resolve/0f9060c525da74fda0baa61a467a4a764122d4e0/probe_quality.py
- Command line
-
hf download hf://datasets/mahalisyarifuddin/emotweetid-ekman7@0f9060c525da74fda0baa61a467a4a764122d4e0/probe_quality.py
-
curl -L -o probe_quality.py https://huggingface.co/datasets/mahalisyarifuddin/emotweetid-ekman7/resolve/0f9060c525da74fda0baa61a467a4a764122d4e0/probe_quality.py
1.57 kB
| """Fit-for-purpose check: can this prompt make laya separate Ekman's anger from contempt at all?""" | |
| import numpy as np, torch, laya_opt | |
| from ekman_questions import EKMAN_QUESTIONS | |
| from probes import PROBES | |
| agent = laya_opt.load_agent() | |
| texts=[t for _,t in PROBES]; gold=[g for g,_ in PROBES] | |
| res, st = laya_opt.score_texts(agent, EKMAN_QUESTIONS, texts, max_len=256, head_max_len=144, token_budget=6144) | |
| sup = [r.get("superiority",{}).get("noul") for r in res] | |
| blk = [r.get("blocked_or_unfair",{}).get("noul") for r in res] | |
| print("%-10s %-8s %-8s %-6s %-6s %s" % ("gold","p_anger","p_cont","conf","margin","flags")) | |
| ok=0 | |
| for g,r,su,bl in zip(gold,res,sup,blk): | |
| pa,pc = r["ekman"]["probabilities"]["anger"], r["ekman"]["probabilities"]["contempt"] | |
| pred = "anger" if pa>=pc else "contempt"; ok += pred==g | |
| print("%-10s %-8.3f %-8.3f %-6.2f %-6.3f sup=%.2f blk=%.2f%s" % (g,pa,pc,r["ekman"]["confidence"],pa-pc,su,bl," <-- WRONG" if pred!=g else "")) | |
| print("\nchoice-head accuracy on the 16 probes: %d/16 = %.3f (chance = 0.50)" % (ok, ok/len(gold))) | |
| n=int(len(gold)) | |
| sup_c = np.mean([s for g,s in zip(gold,sup) if g=="contempt"]); sup_a=np.mean([s for g,s in zip(gold,sup) if g=="anger"]) | |
| blk_a = np.mean([b for g,b in zip(gold,blk) if g=="anger"]); blk_c=np.mean([b for g,b in zip(gold,blk) if g=="contempt"]) | |
| print("noul probes: P(superiority) contempt=%.2f anger=%.2f | P(blocked/unfair) anger=%.2f contempt=%.2f" % (sup_c,sup_a,blk_a,blk_c)) | |
| print("intensity : " + ", ".join("%.1f"%r["intensity"]["score"] for r in res)) | |
| print("timing : %s" % st) | |