Add types-of-work classification, benchmarks and score pages

- Work type = area x role (fixed vs varied), vocabulary in scripts/worktypes.json
- LLM-read labels for 2,678 agent-related papers (data/labels), rule labels for the rest
- Per-type synthesis notes (why-same, sub-variants, benchmarks, workflow)
- Pages: /work-types matrix and detail (timeline, benchmarks, workflow, score charts), /benchmarks
- build_worktypes.py adds work-type tables to data/papers.db

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bhs9LU8eMixk6g1kb1d3j7
This commit is contained in:
zzyang
2026-10-21 11:55:46 +00:00
parent 13924f8985
commit d6fc7c1dfa
60 changed files with 4792 additions and 4 deletions
+158
View File
@@ -0,0 +1,158 @@
#!/usr/bin/env python3
"""Add work-type tables to data/papers.db.
Inputs
scripts/worktypes.json role + area vocabulary
data/labels/o*.jsonl LLM-assisted labels (title+abstract) for agent-related papers
data/labels/type_notes.json optional per-type synthesis (why-same, workflow, benchmark summary)
Everything not covered by an LLM label gets rule-based labels (source='rule').
usage: python3 scripts/build_worktypes.py [--db data/papers.db]
"""
import argparse, collections, glob, json, os, re, sqlite3
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
W = json.load(open(os.path.join(ROOT, "scripts", "worktypes.json")))
ROLES, AGENT_AREAS, GEN_AREAS = W["roles"], W["agent_areas"], W["general_areas"]
SCHEMA = """
DROP TABLE IF EXISTS roles; DROP TABLE IF EXISTS areas; DROP TABLE IF EXISTS work_types; DROP TABLE IF EXISTS paper_work_types;
DROP TABLE IF EXISTS paper_meta; DROP TABLE IF EXISTS benchmarks; DROP TABLE IF EXISTS paper_benchmarks; DROP TABLE IF EXISTS results; DROP TABLE IF EXISTS type_notes;
CREATE TABLE roles(id TEXT PRIMARY KEY, label TEXT, descr TEXT, fixes TEXT, varies TEXT, pattern TEXT, sort INT);
CREATE TABLE areas(id TEXT PRIMARY KEY, label TEXT, kind TEXT, sort INT);
CREATE TABLE work_types(id TEXT PRIMARY KEY, area TEXT REFERENCES areas(id), role TEXT REFERENCES roles(id), n_papers INT, n_llm_labeled INT);
CREATE TABLE paper_work_types(paper_id INT NOT NULL, type_id TEXT NOT NULL, why TEXT, source TEXT, PRIMARY KEY(paper_id, type_id));
CREATE TABLE paper_meta(paper_id INTEGER PRIMARY KEY, summary TEXT, fixes TEXT, varies TEXT, workflow TEXT, in_agent_scope INT, label_source TEXT);
CREATE TABLE benchmarks(id INTEGER PRIMARY KEY, key TEXT UNIQUE, name TEXT, n_papers INT, n_new INT);
CREATE TABLE paper_benchmarks(paper_id INT, bench_id INT, purpose TEXT, is_new INT, source TEXT, PRIMARY KEY(paper_id, bench_id));
CREATE TABLE results(id INTEGER PRIMARY KEY, paper_id INT, bench_id INT, system TEXT, base_model TEXT, setting TEXT, metric TEXT, score REAL, unit TEXT);
CREATE TABLE type_notes(type_id TEXT PRIMARY KEY, why_same TEXT, workflow TEXT, bench_summary TEXT, narrative TEXT);
CREATE INDEX idx_pwt_type ON paper_work_types(type_id);
CREATE INDEX idx_pb_bench ON paper_benchmarks(bench_id);
CREATE INDEX idx_res_bench ON results(bench_id);
"""
# ---------- rule-based roles for papers without an LLM label ----------
R = lambda p: re.compile(p, re.I)
RX = {
"survey": R(r"\b(survey|systematic (literature )?review|literature review|tutorial|position paper|we argue that|roadmap|perspective paper)\b"),
"benchmark": R(r"(we (introduce|present|propose|release|construct|build|curate|develop|create|collect)[^.]{0,100}(benchmark|dataset|corpus|testbed|test suite|evaluation suite|resource)|\bbench\b|-bench\b|\bbenchmark\b)"),
"eval-method": R(r"(llm[- ]as[- ]a[- ]judge|evaluation (metric|framework|protocol)|new metric|automatic evaluation|evaluator)"),
"analysis": R(r"(we (study|investigate|analy[sz]e|examine|explore whether|find that|conduct an? (empirical|systematic|large-scale)|show that [^.]{0,40}(fail|struggle|limit))|empirical (study|analysis|investigation)|case study|\brevisit\w*|\brethink\w*|do (llms?|language models|models) (really|actually)|\bunderstanding\b)"),
"attack": R(r"\b(attacks?|jailbreak\w*|red[- ]team\w*|backdoor\w*|poison\w*|adversarial (prompt|example|suffix))\b"),
"defense": R(r"\b(defen[cs]es?|mitigat\w*|guardrails?|safeguards?|detect(ion|ing|or)s?|unlearning|watermark\w*)\b"),
"theory": R(r"\b(we prove|provabl\w*|theoretical (analysis|framework|guarantee)|convergence (rate|guarantee)|regret bound|sample complexity|lower bound)\b"),
"scaffold": R(r"\b(training-free|tuning-free|without (any )?(additional )?(training|fine-?tuning)|prompting|in-context|plug-and-play|inference-time|test-time|decoding)\b"),
"train-agent": R(r"\b(fine-?tun\w*|reinforcement learning|\brl\b|grpo|dpo|rlhf|post-training|supervised|pre-?train\w*|distill\w*|we train)\b"),
"data": R(r"\b(synthetic data|data synthesis|data selection|data curation|data filtering|data augmentation|instruction data|training data)\b"),
"environment": R(r"\b(environments?|simulator|sandbox|world model)\b"),
}
def rule_roles(title, abstract, area):
t = f"{title}. {abstract or ''}"
head = f"{title}. {(abstract or '')[:600]}"
found = []
if RX["survey"].search(head): found.append("survey")
if RX["benchmark"].search(head) and (re.search(r"bench", title, re.I) or re.search(r"we (introduce|present|propose|release|construct|build|curate|create|collect)", head, re.I)):
found.append("benchmark")
if area.startswith("safety/"):
if RX["attack"].search(head) and "defense" not in found: found.append("attack")
if RX["defense"].search(head): found.append("defense")
if RX["theory"].search(t): found.append("theory")
if RX["eval-method"].search(head) and area.startswith("eval/"): found.append("eval-method")
if not found or (found == ["benchmark"] and False):
if RX["analysis"].search(head) and not RX["benchmark"].search(title):
found.append("analysis")
if not found:
if RX["scaffold"].search(head): found.append("scaffold")
elif RX["train-agent"].search(head): found.append("train-agent")
elif RX["data"].search(head): found.append("data")
elif area.startswith("apps/"): found.append("application")
else: found.append("method")
return found[:2]
def bkey(name):
return re.sub(r"[^a-z0-9]", "", name.lower())
def main():
ap = argparse.ArgumentParser(); ap.add_argument("--db", default=os.path.join(ROOT, "data", "papers.db")); a = ap.parse_args()
db = sqlite3.connect(a.db); db.executescript(SCHEMA)
for i, (k, v) in enumerate(ROLES.items()):
db.execute("INSERT INTO roles VALUES(?,?,?,?,?,?,?)", (k, v["label"], v["desc"], "; ".join(v["fixes"]), "; ".join(v["varies"]), v["pattern"], i))
i = 0
for k, v in AGENT_AREAS.items(): db.execute("INSERT INTO areas VALUES(?,?,?,?)", (k, v, "agent", i)); i += 1
for k, v in GEN_AREAS.items(): db.execute("INSERT INTO areas VALUES(?,?,?,?)", (k, v, "general", i)); i += 1
areas = {r[0] for r in db.execute("SELECT id FROM areas")}
# --- LLM labels
labelled = {}
for f in sorted(glob.glob(os.path.join(ROOT, "data", "labels", "o*.jsonl"))):
for l in open(f):
if l.strip():
o = json.loads(l); labelled[o["id"]] = o
bench_names = collections.defaultdict(collections.Counter) # key -> display counter
bench_rows = []
for pid, o in labelled.items():
db.execute("INSERT OR REPLACE INTO paper_meta VALUES(?,?,?,?,?,?,?)", (pid, o.get("summary", ""), json.dumps(o.get("fixes", [])), json.dumps(o.get("varies", [])), json.dumps(o.get("workflow", [])), 1 if o.get("in_agent_scope") else 0, "llm"))
for t in o.get("types", []):
if t["area"] in areas and t["role"] in ROLES:
db.execute("INSERT OR IGNORE INTO paper_work_types VALUES(?,?,?,?)", (pid, f"{t['area']}|{t['role']}", t.get("why", ""), "llm"))
for b in o.get("benchmarks", []):
if b.get("name"):
k = bkey(b["name"]); bench_names[k][b["name"].strip()] += 1
bench_rows.append((pid, k, b.get("purpose", ""), 1 if b.get("is_new") else 0))
for r in o.get("results", []):
if r.get("benchmark") and isinstance(r.get("score"), (int, float)):
k = bkey(r["benchmark"]); bench_names[k][r["benchmark"].strip()] += 1
bench_rows.append((pid, k, "", 0))
db.execute("INSERT INTO results(paper_id,bench_id,system,base_model,setting,metric,score,unit) VALUES(?,?,?,?,?,?,?,?)", (pid, k, r.get("system"), r.get("base_model"), r.get("setting"), r.get("metric"), r["score"], r.get("unit")))
# resolve benchmark ids
key2id = {}
for k, c in bench_names.items():
cur = db.execute("INSERT INTO benchmarks(key,name,n_papers,n_new) VALUES(?,?,0,0)", (k, c.most_common(1)[0][0])); key2id[k] = cur.lastrowid
for pid, k, purpose, new in bench_rows:
db.execute("INSERT OR IGNORE INTO paper_benchmarks VALUES(?,?,?,?,?)", (pid, key2id[k], purpose, new, "llm"))
db.execute("UPDATE results SET bench_id = (SELECT id FROM benchmarks WHERE key = results.bench_id)") if False else None
# results.bench_id currently holds the key string -> map to ids
for k, i_ in key2id.items(): db.execute("UPDATE results SET bench_id=? WHERE bench_id=?", (i_, k))
# --- rule labels for every other LLM-related paper
rows = db.execute("""SELECT p.id, p.title, p.abstract,
(SELECT node_id FROM paper_taxonomy pt WHERE pt.paper_id=p.id AND pt.is_primary=1) AS area
FROM papers p WHERE p.is_llm=1""").fetchall()
n_rule = 0
for pid, title, abstract, area in rows:
if pid in labelled: continue
area = area if area in areas else "other/ml"
if area == "other/unclassified": area = "apps/classic"
for role in rule_roles(title, abstract, area):
db.execute("INSERT OR IGNORE INTO paper_work_types VALUES(?,?,?,?)", (pid, f"{area}|{role}", "", "rule")); n_rule += 1
db.execute("INSERT OR IGNORE INTO paper_meta VALUES(?,?,?,?,?,?,?)", (pid, "", "[]", "[]", "[]", 0, "rule"))
# non-LLM ML papers: single bucket
for (pid,) in db.execute("SELECT id FROM papers WHERE is_llm=0").fetchall():
db.execute("INSERT OR IGNORE INTO paper_work_types VALUES(?,?,?,?)", (pid, "other/ml|method", "", "rule"))
# --- benchmark string matching on rule-labelled papers (benchmarks seen >=3 times in LLM labels)
common = db.execute("SELECT id, key, name FROM benchmarks b WHERE (SELECT COUNT(*) FROM paper_benchmarks pb WHERE pb.bench_id=b.id) >= 3 AND length(key) >= 5").fetchall()
pats = [(i, name, re.compile(r"(?<![A-Za-z0-9])" + re.escape(name).replace(r"\-", r"[- ]?").replace(r"\ ", r"[- ]?") + r"(?![A-Za-z0-9])", re.I)) for i, k, name in common]
for pid, title, abstract in db.execute("SELECT p.id, p.title, p.abstract FROM papers p WHERE p.is_llm=1 AND p.id NOT IN (SELECT paper_id FROM paper_meta WHERE label_source='llm')").fetchall():
txt = f"{title} {abstract or ''}"
for i, name, rx in pats:
if rx.search(txt): db.execute("INSERT OR IGNORE INTO paper_benchmarks VALUES(?,?,?,?,?)", (pid, i, "", 0, "match"))
db.execute("UPDATE benchmarks SET n_papers=(SELECT COUNT(*) FROM paper_benchmarks pb WHERE pb.bench_id=benchmarks.id), n_new=(SELECT COUNT(*) FROM paper_benchmarks pb WHERE pb.bench_id=benchmarks.id AND pb.is_new=1)")
# --- work types
db.execute("""INSERT INTO work_types SELECT type_id, substr(type_id,1,instr(type_id,'|')-1), substr(type_id,instr(type_id,'|')+1), COUNT(*), SUM(source='llm')
FROM paper_work_types GROUP BY type_id""")
# --- optional synthesis notes
nf = os.path.join(ROOT, "data", "labels", "type_notes.json")
if os.path.exists(nf):
for tid, n in json.load(open(nf)).items():
db.execute("INSERT OR REPLACE INTO type_notes VALUES(?,?,?,?,?)", (tid, n.get("why_same", ""), json.dumps(n.get("workflow", [])), n.get("bench_summary", ""), n.get("narrative", "")))
db.commit()
print("llm-labelled:", len(labelled), " rule-labelled:", n_rule, " work types:", db.execute("SELECT COUNT(*) FROM work_types").fetchone()[0],
" benchmarks:", db.execute("SELECT COUNT(*) FROM benchmarks").fetchone()[0], " results:", db.execute("SELECT COUNT(*) FROM results").fetchone()[0])
db.execute("VACUUM"); db.close()
if __name__ == "__main__":
main()
+208
View File
@@ -0,0 +1,208 @@
{
"roles": {
"benchmark": {
"label": "New benchmark / task suite",
"fixes": [
"agents/models under test"
],
"varies": [
"tasks",
"environments"
],
"desc": "Introduces a new evaluation set or task suite and measures existing models/agents on it. The contribution is the yardstick; the systems being measured are held fixed.",
"pattern": "fix-agent-vary-env"
},
"environment": {
"label": "New environment / simulator / world model",
"fixes": [
"agent"
],
"varies": [
"environment"
],
"desc": "Builds or synthesizes an interactive environment, simulator, sandbox or world model (often for scalable training or evaluation). The environment is the thing being changed.",
"pattern": "fix-agent-vary-env"
},
"train-agent": {
"label": "Train / fine-tune the model (SFT, RL, preference, self-evolution)",
"fixes": [
"environment",
"benchmark"
],
"varies": [
"model weights",
"training algorithm or reward"
],
"desc": "Changes the model itself with fine-tuning, RL, preference or self-improvement training, evaluated in a fixed environment or benchmark.",
"pattern": "fix-env-vary-model"
},
"data": {
"label": "Data / trajectory synthesis or selection",
"fixes": [
"environment",
"training recipe"
],
"varies": [
"training data"
],
"desc": "Constructs, filters or selects training data (tasks, trajectories, queries) so that an otherwise standard training recipe works better.",
"pattern": "vary-data"
},
"scaffold": {
"label": "Training-free design (prompting, workflow, planning, memory, test-time compute)",
"fixes": [
"model weights",
"environment"
],
"varies": [
"scaffold",
"inference procedure"
],
"desc": "Keeps the underlying model frozen and changes how it is orchestrated: prompts, workflows, planning, reflection, memory, tool routing or test-time search.",
"pattern": "fix-model-vary-scaffold"
},
"analysis": {
"label": "Empirical analysis / failure study",
"fixes": [
"methods"
],
"varies": [
"conditions",
"models",
"settings"
],
"desc": "Measures or explains behaviour of existing models/agents under controlled variations to find limits, failure modes or scaling trends, without proposing a new system.",
"pattern": "vary-conditions"
},
"eval-method": {
"label": "Evaluation methodology / metrics / judges",
"fixes": [
"systems under test"
],
"varies": [
"evaluation protocol",
"metric"
],
"desc": "Proposes a new way to measure (metric, judge, protocol, contamination control) rather than a new task set.",
"pattern": "vary-evaluation"
},
"attack": {
"label": "Attack / red-teaming / vulnerability discovery",
"fixes": [
"agent"
],
"varies": [
"adversarial input or condition"
],
"desc": "Probes an agent or model for safety, security or privacy failures with attacks or automated red-teaming.",
"pattern": "fix-agent-vary-condition"
},
"defense": {
"label": "Defense / monitoring / guardrails / alignment",
"fixes": [
"threat model"
],
"varies": [
"protective mechanism"
],
"desc": "Adds a protective mechanism (monitor, filter, alignment training, unlearning) and checks it against a fixed threat model.",
"pattern": "fix-threat-vary-defense"
},
"survey": {
"label": "Survey / position / tutorial",
"fixes": [],
"varies": [],
"desc": "Organizes or argues about a field instead of running a new experiment.",
"pattern": "n/a"
},
"application": {
"label": "Domain application / end-to-end system",
"fixes": [
"general-purpose model"
],
"varies": [
"domain pipeline"
],
"desc": "Packages models and tools into a system for a specific domain or product and evaluates it there.",
"pattern": "vary-pipeline"
},
"theory": {
"label": "Theory / formal analysis",
"fixes": [],
"varies": [
"assumptions"
],
"desc": "Proves properties or provides formal analysis of a learning or decision procedure.",
"pattern": "vary-assumptions"
},
"method": {
"label": "General method (not specific to agents)",
"fixes": [
"benchmark"
],
"varies": [
"method"
],
"desc": "A new technique evaluated on standard benchmarks, used when the paper does not fit a finer role.",
"pattern": "vary-method"
}
},
"agent_areas": {
"web-gui": "Web, browser, GUI, mobile and computer-use agents; GUI grounding",
"search-research": "Deep research, agentic search, information-seeking, search-augmented agents",
"code-swe": "Coding agents, SWE-bench style tasks, ML-engineering agents, text-to-SQL agents",
"tool-use": "Tool calling, function calling, MCP, API use, tool-integrated reasoning",
"multi-agent": "Multi-agent coordination, debate, team structure, communication, agent societies",
"memory-selfevolve": "Agent memory, experience reuse, reflection, self-evolving or lifelong agents",
"planning-decision": "Planning, exploration, sequential decision making, long-horizon tasks, credit assignment, agentic RL algorithms",
"embodied-nav": "Embodied agents, navigation, robotics, games, world-model use",
"science-data": "Scientific-discovery and data-analysis / data-science agents",
"social-sim": "Role-play, user simulators, persona, negotiation, economic and social simulation",
"domain-agents": "Domain agents (health, finance, legal, education, recommendation, CAD, design, etc.)",
"agent-safety": "Safety, security, privacy and trustworthiness of agents"
},
"general_areas": {
"arch/attention": "Attention, SSMs, MoE",
"arch/diffusion": "Diffusion / non-autoregressive LMs",
"arch/tokenization": "Tokenization & embeddings",
"arch/multimodal": "Multimodal & vision-language models",
"arch/longctx": "Long context & memory",
"train/pretrain": "Pretraining & scaling laws",
"train/data": "Data curation & synthetic data",
"train/sft": "Instruction tuning & SFT",
"train/peft": "Parameter-efficient fine-tuning",
"train/continual": "Continual learning & model merging",
"train/distill": "Distillation & small models",
"align/pref": "Preference optimization & reward models",
"align/rlvr": "RL for reasoning (RLVR/GRPO)",
"align/values": "Values, sycophancy, pluralistic alignment",
"reason/cot": "Chain-of-thought & test-time compute",
"reason/math": "Math & formal reasoning",
"reason/code": "Code generation (non-agentic)",
"reason/planning": "Logic, commonsense, planning (non-agentic)",
"knowledge/rag": "Retrieval-augmented generation",
"knowledge/halluc": "Hallucination & factuality",
"knowledge/editing": "Knowledge editing & probing",
"eval/bench": "Benchmarks & datasets (non-agentic)",
"eval/judge": "LLM-as-a-judge & eval methodology",
"eval/robust": "Robustness, contamination, calibration",
"interp/mech": "Mechanistic interpretability",
"interp/steering": "Representation analysis & steering",
"interp/icl": "In-context learning & emergent abilities",
"efficiency/compress": "Quantization & pruning",
"efficiency/inference": "Inference acceleration",
"efficiency/training": "Efficient training",
"safety/jailbreak": "Jailbreaks & red-teaming (models)",
"safety/security": "Security, backdoors, watermarking (models)",
"safety/privacy": "Privacy, memorization, unlearning",
"safety/fairness": "Bias, fairness, culture",
"multiling/multi": "Multilingual LLMs",
"multiling/lowres": "Low-resource languages",
"multiling/mt": "Machine translation",
"apps/science": "Biomedical & scientific applications",
"apps/domain": "Legal, finance, education, social science",
"apps/dialogue": "Dialogue & generation",
"apps/classic": "Classical NLP tasks",
"other/ml": "Not language-model related (vision, RL theory, etc.)"
}
}