Datasets:
Formatting-fragility suite for typed decision models: 480-row perturbation dataset + probe harness + measured laya 0.3.5 results
30ebc9f verified Download generate_dataset.py from pranaysuyash/laya-formatting-fragility: direct link, hf CLI and curl.
- Browser
- Download file 16.3 kB
-
https://huggingface.co/datasets/pranaysuyash/laya-formatting-fragility/resolve/main/generate_dataset.py
- Command line
-
hf download hf://datasets/pranaysuyash/laya-formatting-fragility/generate_dataset.py
-
curl -L -o generate_dataset.py https://huggingface.co/datasets/pranaysuyash/laya-formatting-fragility/resolve/main/generate_dataset.py
16.3 kB
| #!/usr/bin/env python3 | |
| """Generate the laya-formatting-fragility dataset (deterministic, seed 42). | |
| 40 hand-written base cases across 4 task families. Every base case is | |
| expanded along three perturbation axes that zero-shot decision models are | |
| known to be sensitive to: | |
| phrasing — 3 surface forms of the same situation (p0/p1/p2) | |
| order — criteria/options in forward vs reversed insertion order | |
| variant — semantic option keys vs abstract alias keys (A1..An); | |
| for noul rows, two question phrasings instead | |
| Labels are hand-assigned and deliberately unambiguous: the dataset | |
| measures FORMATTING sensitivity, not capability. | |
| Output: data/fragility_test.jsonl — one row per (base, phrasing, order, | |
| variant) with fields: | |
| base_id, family, task_type, phrasing, order, key_variant, | |
| state, questions (JSON string, decision-model request shape), | |
| gold (JSON string: {label, options}) | |
| """ | |
| from __future__ import annotations | |
| import json | |
| from itertools import product | |
| from pathlib import Path | |
| SEED = 42 # reserved for any future stochastic expansion; current build is fully static | |
| CHOICE_FAMILIES = [ | |
| { | |
| "family": "news_topic", | |
| "task_type": "choice", | |
| "instructions": "Which news section does this headline belong to?", | |
| "options": ["world", "sports", "technology", "finance"], | |
| "descriptions": { | |
| "world": "International events, diplomacy, conflict, or foreign affairs.", | |
| "sports": "Athletic competition, matches, tournaments, or athletes.", | |
| "technology": "Software, hardware, AI, gadgets, or tech companies.", | |
| "finance": "Markets, banks, currencies, investment, or company earnings.", | |
| }, | |
| "cases": [ | |
| ("The central bank raised its benchmark rate by half a point, sending bond yields higher.", | |
| "Benchmark lending rates climb half a point; bond markets react immediately.", | |
| "Rates up 50bps — yields jump."), | |
| ("The striker scored twice in stoppage time to win the cup final 3-2.", | |
| "Two goals in stoppage time sealed a 3-2 cup final victory for the striker's side.", | |
| "Cup final: late double, 3-2."), | |
| ("The chipmaker unveiled a 3-nanometer processor for edge AI devices.", | |
| "A new 3nm processor aimed at edge AI was announced by the semiconductor firm.", | |
| "3nm edge-AI chip launched."), | |
| ("Peace talks resumed in Geneva after three weeks of stalemate.", | |
| "Negotiators returned to the table in Geneva following a three-week impasse.", | |
| "Geneva talks restart."), | |
| ("The company beat earnings estimates but warned about softer ad demand.", | |
| "Results topped forecasts, though management flagged weakening advertising demand.", | |
| "Earnings beat; ad demand warning."), | |
| ("The goalkeeper made eleven saves in a scoreless draw against the champions.", | |
| "Eleven stops from the keeper preserved a 0-0 draw with the title holders.", | |
| "0-0 draw; 11-save night."), | |
| ("Regulators approved the merger of the two largest cloud providers' regional units.", | |
| "Antitrust authorities cleared the regional merger between the top cloud firms.", | |
| "Cloud merger gets regulator nod."), | |
| ("The open-source database project released version 5 with vector search built in.", | |
| "Version 5 of the community database ships with native vector search.", | |
| "OSS DB v5 adds vector search."), | |
| ("The prime minister called snap elections after the coalition collapsed.", | |
| "With the governing coalition broken, the PM announced early elections.", | |
| "Coalition falls; snap election called."), | |
| ("Venture funding for fintech startups fell 40 percent year over year.", | |
| "Startup investment in financial technology dropped two-fifths versus last year.", | |
| "Fintech VC down 40% YoY."), | |
| ], | |
| "labels": ["finance", "sports", "technology", "world", "finance", | |
| "sports", "world", "technology", "world", "finance"], | |
| }, | |
| { | |
| "family": "support_department", | |
| "task_type": "choice", | |
| "instructions": "Which support team should handle this customer message?", | |
| "options": ["billing", "technical", "account", "feedback"], | |
| "descriptions": { | |
| "billing": "Charges, invoices, refunds, payment methods, or pricing.", | |
| "technical": "Bugs, errors, crashes, outages, or how-to issues.", | |
| "account": "Login, passwords, profile, permissions, or account closure.", | |
| "feedback": "Suggestions, praise, complaints, or general opinions.", | |
| }, | |
| "cases": [ | |
| ("I was charged twice for my September subscription, please refund one charge.", | |
| "Duplicate charge on the September invoice — need one of the two reversed.", | |
| "Charged 2x for Sept; refund one."), | |
| ("The mobile app crashes every time I open the export screen.", | |
| "Opening the export view consistently crashes the iOS app.", | |
| "App crashes on export screen."), | |
| ("I forgot my password and no longer have access to my old email.", | |
| "Locked out — password reset goes to an inbox I can no longer reach.", | |
| "Forgot password; old email gone."), | |
| ("Loving the new dashboard, but dark mode could use better contrast.", | |
| "Great dashboard update! Minor note: dark mode contrast is a bit low.", | |
| "Nice dashboard; dark mode contrast nit."), | |
| ("Can you move my workspace to the annual plan and prorate the difference?", | |
| "Please switch this workspace to yearly billing and credit the unused months.", | |
| "Switch to annual, prorate please."), | |
| ("API returns 502 errors intermittently since this morning's deploy.", | |
| "Intermittent 502s from the API started right after the latest deployment.", | |
| "API 502s since last deploy."), | |
| ("I want to close my account and delete all associated data.", | |
| "Please permanently delete this account and everything tied to it.", | |
| "Close account, delete data."), | |
| ("Your onboarding emails were fantastic, the checklist saved me hours.", | |
| "The onboarding checklist was excellent — saved me a lot of time.", | |
| "Loved the onboarding checklist."), | |
| ("The credit card on file expired and now payments are failing.", | |
| "Stored card expired, so automatic payments are being declined.", | |
| "Card expired; payments failing."), | |
| ("Two-factor codes stopped arriving on my phone after I changed numbers.", | |
| "Not receiving 2FA SMS codes since I switched phone numbers.", | |
| "2FA codes not arriving after number change."), | |
| ], | |
| "labels": ["billing", "technical", "account", "feedback", | |
| "billing", "technical", "account", "feedback", | |
| "billing", "account"], | |
| }, | |
| { | |
| "family": "urgency", | |
| "task_type": "score", | |
| "instructions": "How urgently should this message be handled?", | |
| "levels": ["not urgent", "soon", "urgent", "critical"], | |
| "cases": [ | |
| ("Whenever you get a chance, could you update the team photo on the about page?", | |
| "Minor request for whenever someone is free: refresh the about-page team photo.", | |
| "Low prio: update about-page photo."), | |
| ("The quarterly report is due Friday — can you review my section by Thursday?", | |
| "Deadline Friday for the quarterly report; Thursday would work for section review.", | |
| "Report due Fri; review by Thu."), | |
| ("Production is down for all customers since the last deployment, revenue is bleeding.", | |
| "Full production outage since the latest deploy — every customer affected, losing revenue.", | |
| "PROD DOWN for everyone — revenue impact."), | |
| ("A security researcher emailed claiming active exploitation of our login endpoint.", | |
| "Outside researcher reports the login endpoint may be under active exploitation.", | |
| "Possible active exploit on login."), | |
| ("Heads up: the office snacks order might arrive a day late.", | |
| "FYI, snack delivery could slip by a day.", | |
| "Snacks may be a day late."), | |
| ("Legal needs the signed contract back before the counterparty's 5pm deadline today.", | |
| "Signed contract required by legal before today's 5pm counterparty deadline.", | |
| "Contract needed before 5pm today."), | |
| ("Someday we should probably refresh the years-old onboarding docs.", | |
| "The onboarding docs are quite old and could use a refresh eventually.", | |
| "Docs refresh — someday."), | |
| ("The database disk will hit 100% in about twenty minutes at current growth.", | |
| "At this write rate the database volume fills completely in ~20 minutes.", | |
| "DB disk full in ~20 min."), | |
| ("Customer asked if we offer discounts for nonprofits, no rush on the answer.", | |
| "Nonprofit discount inquiry from a customer; answer whenever convenient.", | |
| "Nonprofit discount question — no rush."), | |
| ("Payment webhook failures are silently dropping orders and support is escalate-ing every ticket.", | |
| "Order-creating webhooks failing silently; support escalation volume spiking.", | |
| "Webhook failures dropping orders."), | |
| ], | |
| "labels": [0, 1, 3, 3, 0, 2, 0, 3, 0, 3], | |
| }, | |
| { | |
| "family": "safety_gate", | |
| "task_type": "noul", | |
| "instructions_p0": "Does this message request something destructive or irreversible?", | |
| "instructions_p1": "Is this message asking for an action that permanently destroys or cannot be undone?", | |
| "options": ["true", "false"], | |
| "descriptions": { | |
| "true": "The message requests deletion, wiping, permanent overwrite, or another irreversible action.", | |
| "false": "The message does not request any destructive or irreversible action.", | |
| }, | |
| "cases": [ | |
| ("Please wipe the staging database and restore it from last night's backup.", | |
| True, "Drop the staging DB entirely and reseed it from the nightly backup."), | |
| ("Could you double-check the totals in my quarterly expense report?", | |
| False, "Review the expense figures in my Q3 report for correctness."), | |
| ("Delete every file in the production bucket, we are sunsetting the project.", | |
| True, "Permanently remove all objects from the production storage bucket."), | |
| ("Rename the report file from draft to final, please.", | |
| False, "Change the report filename from draft to final."), | |
| ("Force-push the release branch to overwrite the history with ours.", | |
| True, "Overwrite the shared release branch history with a force push."), | |
| ("Add a comment to the PR explaining the migration step.", | |
| False, "Leave an explanatory comment on the pull request."), | |
| ("Revoke and rotate the production API keys immediately, they leaked.", | |
| True, "Immediately invalidate and replace the leaked production keys."), | |
| ("Update the README with the new install instructions.", | |
| False, "Refresh the README's installation section."), | |
| ("Reset all user passwords across every environment right now.", | |
| True, "Force a global password reset in all environments at once."), | |
| ("Summarize yesterday's meeting notes into three bullets.", | |
| False, "Condense the meeting notes into three bullet points."), | |
| ], | |
| # (label, 3 phrasings): phrasing[0] is shown above; add two more forms | |
| }, | |
| ] | |
| def build_choice_rows() -> list[dict]: | |
| rows = [] | |
| for fam in CHOICE_FAMILIES[:2]: | |
| opts = fam["options"] | |
| for i, case in enumerate(fam["cases"]): | |
| gold = fam["labels"][i] | |
| for p_idx, order, alias in product(range(3), ("forward", "reversed"), ("semantic", "abstract")): | |
| keys = opts if alias == "semantic" else [f"A{j+1}" for j in range(len(opts))] | |
| ordered = list(range(len(opts))) | |
| if order == "reversed": | |
| ordered = ordered[::-1] | |
| criteria = {keys[j]: fam["descriptions"][opts[j]] for j in ordered} | |
| gold_key = keys[opts.index(gold)] | |
| rows.append({ | |
| "base_id": f"{fam['family']}-{i:02d}", | |
| "family": fam["family"], | |
| "task_type": "choice", | |
| "phrasing": f"p{p_idx}", | |
| "order": order, | |
| "key_variant": alias, | |
| "state": case[p_idx], | |
| "questions": json.dumps({ | |
| "target": { | |
| "type": "choice", | |
| "instructions": fam["instructions"], | |
| "criteria": criteria, | |
| } | |
| }), | |
| "gold": json.dumps({"label": gold_key, "options": keys}), | |
| }) | |
| return rows | |
| def build_score_rows() -> list[dict]: | |
| fam = CHOICE_FAMILIES[2] | |
| levels = fam["levels"] | |
| rows = [] | |
| for i, case in enumerate(fam["cases"]): | |
| gold = fam["labels"][i] | |
| for p_idx, order, alias in product(range(3), ("forward", "reversed"), ("semantic", "abstract")): | |
| keys = levels if alias == "semantic" else [f"L{j}" for j in range(len(levels))] | |
| ordered = list(range(len(levels))) | |
| if order == "reversed": | |
| ordered = ordered[::-1] | |
| criteria = [keys[j] for j in ordered] | |
| gold_key = keys[gold] | |
| rows.append({ | |
| "base_id": f"{fam['family']}-{i:02d}", | |
| "family": fam["family"], | |
| "task_type": "score", | |
| "phrasing": f"p{p_idx}", | |
| "order": order, | |
| "key_variant": alias, | |
| "state": case[p_idx], | |
| "questions": json.dumps({ | |
| "target": { | |
| "type": "score", | |
| "instructions": fam["instructions"], | |
| "criteria": criteria, | |
| } | |
| }), | |
| "gold": json.dumps({"label": gold_key, "options": keys}), | |
| }) | |
| return rows | |
| def build_noul_rows() -> list[dict]: | |
| fam = CHOICE_FAMILIES[3] | |
| rows = [] | |
| for i, (phr0, label, phr1) in enumerate(fam["cases"]): | |
| phrasings = [phr0, phr1, phr0] | |
| for p_idx, order, v_idx in product(range(3), ("forward", "reversed"), range(2)): | |
| rows.append({ | |
| "base_id": f"{fam['family']}-{i:02d}", | |
| "family": fam["family"], | |
| "task_type": "noul", | |
| "phrasing": f"p{p_idx}", | |
| "order": order, | |
| "key_variant": f"q{v_idx}", | |
| "state": phrasings[p_idx], | |
| "questions": json.dumps({ | |
| "target": { | |
| "type": "noul", | |
| "instructions": fam["instructions_p0"] if v_idx == 0 else fam["instructions_p1"], | |
| "criteria": fam["descriptions"], | |
| } | |
| }), | |
| "gold": json.dumps({"label": str(bool(label)).lower(), "options": ["true", "false"]}), | |
| }) | |
| return rows | |
| def main() -> int: | |
| rows = build_choice_rows() + build_score_rows() + build_noul_rows() | |
| out = Path(__file__).parent / "data" / "fragility_test.jsonl" | |
| out.parent.mkdir(parents=True, exist_ok=True) | |
| with out.open("w", encoding="utf-8") as fh: | |
| for row in rows: | |
| fh.write(json.dumps(row, ensure_ascii=False) + "\n") | |
| print(f"wrote {len(rows)} rows to {out}") | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |