Spaces:
Sleeping
Sleeping
Commit ·
b08652c
1
Parent(s): 5de8f8e
replace ambiguous fixes with deterministic ones across all tasks
Browse filesEasy: misspelled department, extra-digit salary typo (inferrable)
Medium: OCR error (1O→10), misspelled product/status, 3-decimal price
Hard: misspelled model name, truncated sci notation, sign typo
All demo trajectories only propose fixes with logically deducible answers.
Grading now rewards valid fixes (correct type, right range, right format)
even without exact match.
124 tests passing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Files changed (4)
27 unmodified lines28293031323334352 unmodified lines3839404142434445464748495051525354555657582 unmodified lines61626364656667686970711 unmodified line7374757677787980818283848586878889909192939495969722 unmodified lines12012112212312412512612712812913013113213313413513613727 unmodified lines"issues": ["row:4,col:name,issue:missing_value","row:7,col:salary,issue:wrong_type","row:9,col:salary,issue:out_of_range","row:18,col:start_date,issue:out_of_range","row:3,col:email,issue:format_violation", # FP],"fixes": [],2 unmodified lines"issues": ["row:4,col:name,issue:missing_value","row:7,col:salary,issue:wrong_type","row:9,col:salary,issue:out_of_range","row:21,col:employee_id,issue:duplicate_row","row:15,col:email,issue:inconsistent_value","row:18,col:start_date,issue:out_of_range",],"fixes": [# Inferrable: name "David Kim" deduced from email david.kim@company.com"row:4,col:name,fix:David Kim",# Inferrable: "seventy-five thousand" is clearly 75000"row:7,col:salary,fix:75000",# Inferrable: email must match name pattern oscar.rivera@company.com"row:15,col:email,fix:oscar.rivera@company.com",# NOT proposed: row:9 salary (any valid salary 50000-150000 works)# NOT proposed: row:18 start_date (any past date works)# NOT proposed: row:21 duplicate (remove or reassign — ambiguous)],},],2 unmodified lines"issues": ["row:5,col:total,issue:inconsistent_value","row:10,col:category,issue:format_violation","row:14,col:product_name,issue:missing_value","row:17,col:quantity,issue:out_of_range","row:19,col:order_id,issue:duplicate_row","row:12,col:order_date,issue:format_violation","row:24,col:shipping_country,issue:format_violation",],"fixes": [],},1 unmodified line"issues": ["row:5,col:total,issue:inconsistent_value","row:10,col:category,issue:format_violation","row:14,col:product_name,issue:missing_value","row:17,col:quantity,issue:out_of_range","row:19,col:order_id,issue:duplicate_row","row:12,col:order_date,issue:format_violation","row:24,col:shipping_country,issue:format_violation","row:29,col:order_date,issue:inconsistent_value",],"fixes": [# Inferrable: total = qty(1) * price(42.00) = 42.00"row:5,col:total,fix:42.00",# Inferrable: "Fitness" is closest to "Sports" in allowed categories"row:10,col:category,fix:Sports",# Inferrable: 26/01/2024 reformatted to YYYY-MM-DD"row:12,col:order_date,fix:2024-01-26",# NOT proposed: row:14 product_name (any product name works)# NOT proposed: row:17 quantity (any positive int)# NOT proposed: row:19 duplicate order_id (reassign — ambiguous)# NOT proposed: row:24 country (could be any valid ISO code)# NOT proposed: row:29 future date (any past date works)],},],22 unmodified lines"row:12,col:test_accuracy,issue:statistical_outlier",],"fixes": [# Inferrable: batch_size 250 → nearest power of 2 = 256"row:9,col:batch_size,fix:256",# Inferrable: negative time -72.0 → absolute value 72.0"row:14,col:training_time_hours,fix:72.0",# NOT proposed: row:13 LR (any valid LR 1e-7 to 1.0)# NOT proposed: row:15 model_name (could be any model)# NOT proposed: row:5 val_loss (any val >= train_loss)# NOT proposed: row:7 GPU memory (any reasonable value)# NOT proposed: row:10 train_size (any value > test_size)# NOT proposed: row:11 timestamp (any date after prev)# NOT proposed: row:9 training_time (any reasonable hours)# NOT proposed: row:12 test_accuracy (any < SOTA)],},],27 unmodified lines28293031323334352 unmodified lines3839404142434445464748495051525354552 unmodified lines585960616263646566671 unmodified line6970717273747576777879808182838485868788899022 unmodified lines11311411511611711811912012112212327 unmodified lines"issues": ["row:4,col:name,issue:missing_value","row:7,col:salary,issue:wrong_type","row:11,col:department,issue:format_violation","row:15,col:email,issue:inconsistent_value","row:3,col:email,issue:format_violation", # FP],"fixes": [],2 unmodified lines"issues": ["row:4,col:name,issue:missing_value","row:7,col:salary,issue:wrong_type","row:11,col:department,issue:format_violation","row:15,col:email,issue:inconsistent_value","row:18,col:salary,issue:out_of_range","row:21,col:employee_id,issue:duplicate_row",],"fixes": [# All deterministic fixes:"row:4,col:name,fix:David Kim", # from email david.kim@"row:7,col:salary,fix:75000", # "seventy-five thousand" → 75000"row:11,col:department,fix:Engineering", # "Engneering" → "Engineering""row:15,col:email,fix:oscar.rivera@company.com", # from name Oscar Rivera"row:18,col:salary,fix:99000", # 990000 → remove extra digit],},],2 unmodified lines"issues": ["row:5,col:total,issue:inconsistent_value","row:10,col:category,issue:format_violation","row:10,col:quantity,issue:wrong_type","row:12,col:order_date,issue:format_violation","row:29,col:product_name,issue:format_violation","row:24,col:status,issue:format_violation",],"fixes": [],},1 unmodified line"issues": ["row:5,col:total,issue:inconsistent_value","row:10,col:category,issue:format_violation","row:10,col:quantity,issue:wrong_type","row:12,col:order_date,issue:format_violation","row:19,col:order_id,issue:duplicate_row","row:21,col:unit_price,issue:format_violation","row:24,col:status,issue:format_violation","row:29,col:product_name,issue:format_violation",],"fixes": [# All deterministic:"row:5,col:total,fix:42.00", # qty(1) * price(42.00)"row:10,col:category,fix:Sports", # "Fitness" → nearest valid"row:10,col:quantity,fix:10", # "1O" (letter O) → "10""row:12,col:order_date,fix:2024-01-26", # DD/MM/YYYY → YYYY-MM-DD"row:24,col:status,fix:delivered", # "deliverred" → "delivered""row:29,col:product_name,fix:Wireless Charger", # "Wireles" → "Wireless""row:21,col:unit_price,fix:24.99", # 24.999 → round to 2 decimals],},],22 unmodified lines"row:12,col:test_accuracy,issue:statistical_outlier",],"fixes": [# All deterministic:"row:9,col:batch_size,fix:256", # 250 → nearest power of 2"row:14,col:training_time_hours,fix:72.0", # -72.0 → remove negative sign"row:15,col:model_name,fix:whisper-small", # "whsiper-small" → fix spelling"row:13,col:learning_rate,fix:0.000025", # 2.5 → likely 2.5e-5],},],
143 unmodified lines14414514614714814915015115215315415515615715815916016116216316416516616791 unmodified lines2592602612622632642652662672682692702712722732742757 unmodified lines283284285286287288289290291292293294295296297298299300301119 unmodified lines421422423424425426427428429430431432433434435436437438439440441442443143 unmodified linesissues.append(PlantedIssue(row=len(data), col="employee_id", issue_type="duplicate_row",description=f"Exact duplicate of row {dup_source + 1}", difficulty=1.5))# Issue 4: Out of range salary (easy to spot)r = 8data[r][4] = "5000"issues.append(PlantedIssue(row=r + 1, col="salary", issue_type="out_of_range",description="Salary 5000 is below minimum 50000", difficulty=1.0))# Issue 5: Email doesn't match name pattern (moderate — cross-column check)r = 14 # Oscar Rivera -> email should be oscar.rivera@company.comdata[r][2] = "john.doe@company.com"issues.append(PlantedIssue(row=r + 1, col="email", issue_type="inconsistent_value",description="Email john.doe@company.com doesn't match name Oscar Rivera",difficulty=1.5))# Issue 6: Future start date (requires knowing current date context)r = 17 # Rosa Diazdata[r][5] = "2027-06-15"issues.append(PlantedIssue(row=r + 1, col="start_date", issue_type="out_of_range",description="Start date 2027-06-15 is in the future (beyond 2025-12-31)",difficulty=1.5))corrupted = _rows_to_csv([header] + data)91 unmodified linesissues.append(PlantedIssue(row=r + 1, col="category", issue_type="format_violation",description="'Fitness' is not in allowed categories", difficulty=1.5))# Issue 3: Missing value in product_name (easy to spot)r = 13 # ORD-014data[r][2] = ""issues.append(PlantedIssue(row=r + 1, col="product_name", issue_type="missing_value",description="Empty product_name", difficulty=1.0))# Issue 4: Out of range quantity (easy to spot)r = 16 # ORD-017data[r][4] = "-1"issues.append(PlantedIssue(row=r + 1, col="quantity", issue_type="out_of_range",description="Negative quantity", difficulty=1.0))# Issue 5: Duplicate order_id (requires cross-row comparison)r = 18 # ORD-0197 unmodified linesissues.append(PlantedIssue(row=r + 1, col="order_date", issue_type="format_violation",description="Date format DD/MM/YYYY instead of YYYY-MM-DD", difficulty=1.5))# Issue 7: Invalid country code (requires ISO knowledge)r = 23 # ORD-024data[r][7] = "XX" # not a valid ISO country codeissues.append(PlantedIssue(row=r + 1, col="shipping_country", issue_type="format_violation",description="'XX' is not a valid ISO 2-letter country code", difficulty=1.5))# Issue 8: Status-date inconsistency — order from Feb 13 still "processing" is suspicious# but more importantly: delivered order with a future dater = 28 # ORD-029data[r][6] = "2025-12-25" # future date but status is "delivered"issues.append(PlantedIssue(row=r + 1, col="order_date", issue_type="inconsistent_value",description="Order date 2025-12-25 is in the future but status is 'delivered'",difficulty=2.0))corrupted = _rows_to_csv([header] + data)119 unmodified linesdescription="train_size (500) is smaller than test_size (1821)",difficulty=2.0))# Issue 6: Negative training time (easy to spot)r = 13 # EXP-014data[r][13] = "-72.0"issues.append(PlantedIssue(row=r + 1, col="training_time_hours", issue_type="out_of_range",description="Negative training time", difficulty=1.0))# Issue 7: Learning rate out of range (easy to spot)r = 12 # EXP-013data[r][6] = "2.5" # way too highissues.append(PlantedIssue(row=r + 1, col="learning_rate", issue_type="out_of_range",description="Learning rate 2.5 exceeds maximum of 1.0", difficulty=1.5))# Issue 8: Missing model name (hard — whitespace-only is subtle)r = 14 # EXP-015data[r][1] = " "issues.append(PlantedIssue(row=r + 1, col="model_name", issue_type="missing_value",description="model_name is whitespace-only", difficulty=2.5))# Issue 9: Training time impossibly fast for dataset size and epochs# EXP-004: vit-base on imagenet-1k, 300 epochs, but only 96 hours is plausible.143 unmodified lines14414514614714814915015115215315415515615715815916016116216316416516616716891 unmodified lines2602612622632642652662672682692702712722732742752762772787 unmodified lines286287288289290291292293294295296297298299300301302303304305119 unmodified lines425426427428429430431432433434435436437438439440441442443444445446447448449450143 unmodified linesissues.append(PlantedIssue(row=len(data), col="employee_id", issue_type="duplicate_row",description=f"Exact duplicate of row {dup_source + 1}", difficulty=1.5))# Issue 4: Department is not in allowed set (deterministic: "Engneering" is not valid, closest match = "Engineering")r = 10 # Kevin Zhang, department is Engineeringdata[r][3] = "Engneering"issues.append(PlantedIssue(row=r + 1, col="department", issue_type="format_violation",description="Department 'Engneering' is misspelled — should be 'Engineering'",difficulty=1.0))# Issue 5: Email doesn't match name pattern (deterministic fix: derive from name)r = 14 # Oscar Rivera -> email should be oscar.rivera@company.comdata[r][2] = "john.doe@company.com"issues.append(PlantedIssue(row=r + 1, col="email", issue_type="inconsistent_value",description="Email john.doe@company.com doesn't match name Oscar Rivera",difficulty=1.5))# Issue 6: Salary with extra digit — typo (deterministic fix: "950000" → "95000")r = 17 # Rosa Diaz, original salary is 99000data[r][4] = "990000" # extra zeroissues.append(PlantedIssue(row=r + 1, col="salary", issue_type="out_of_range",description="Salary 990000 exceeds maximum 150000 — likely extra digit typo (should be 99000)",difficulty=1.5))corrupted = _rows_to_csv([header] + data)91 unmodified linesissues.append(PlantedIssue(row=r + 1, col="category", issue_type="format_violation",description="'Fitness' is not in allowed categories", difficulty=1.5))# Issue 3: Product name misspelling (deterministic fix: "Wireles Charger" → "Wireless Charger")r = 28 # ORD-029data[r][2] = "Wireles Charger"issues.append(PlantedIssue(row=r + 1, col="product_name", issue_type="format_violation",description="Product name 'Wireles Charger' is misspelled — should be 'Wireless Charger'",difficulty=1.0))# Issue 4: Quantity is letter O instead of zero — OCR/encoding error (deterministic: "1O" → "10")r = 9 # ORD-010data[r][4] = "1O" # letter O not digit 0issues.append(PlantedIssue(row=r + 1, col="quantity", issue_type="wrong_type",description="Quantity '1O' contains letter O instead of digit 0 — should be '10'",difficulty=1.5))# Issue 5: Duplicate order_id (requires cross-row comparison)r = 18 # ORD-0197 unmodified linesissues.append(PlantedIssue(row=r + 1, col="order_date", issue_type="format_violation",description="Date format DD/MM/YYYY instead of YYYY-MM-DD", difficulty=1.5))# Issue 7: Status misspelling (deterministic fix: "deliverred" → "delivered")r = 23 # ORD-024data[r][8] = "deliverred"issues.append(PlantedIssue(row=r + 1, col="status", issue_type="format_violation",description="Status 'deliverred' is misspelled — should be 'delivered'",difficulty=1.0))# Issue 8: Unit price has 3 decimal places (deterministic fix: "34.999" → "34.99")# Rule says: all monetary values must have at most 2 decimal placesr = 20 # ORD-021data[r][5] = "24.999"issues.append(PlantedIssue(row=r + 1, col="unit_price", issue_type="format_violation",description="Unit price 24.999 has 3 decimal places — rule requires at most 2 (should be 24.99 or 25.00)",difficulty=1.5))corrupted = _rows_to_csv([header] + data)119 unmodified linesdescription="train_size (500) is smaller than test_size (1821)",difficulty=2.0))# Issue 6: Negative training time — sign typo (deterministic: "-72.0" → "72.0")r = 13 # EXP-014data[r][13] = "-72.0"issues.append(PlantedIssue(row=r + 1, col="training_time_hours", issue_type="out_of_range",description="Negative training time -72.0 — likely sign typo (should be 72.0)",difficulty=1.0))# Issue 7: Learning rate in wrong notation (deterministic: "2.5e1" intended as "2.5e-5" → "0.000025")r = 12 # EXP-013data[r][6] = "2.5" # clearly missing the "e-5" partissues.append(PlantedIssue(row=r + 1, col="learning_rate", issue_type="out_of_range",description="Learning rate 2.5 exceeds maximum 1.0 — likely truncated scientific notation (e.g. 2.5e-5 → 0.000025)",difficulty=1.5))# Issue 8: Model name misspelling (deterministic: "whsiper-small" → "whisper-small")r = 14 # EXP-015data[r][1] = "whsiper-small"issues.append(PlantedIssue(row=r + 1, col="model_name", issue_type="format_violation",description="Model name 'whsiper-small' is misspelled — should be 'whisper-small'",difficulty=1.5))# Issue 9: Training time impossibly fast for dataset size and epochs# EXP-004: vit-base on imagenet-1k, 300 epochs, but only 96 hours is plausible.
196 unmodified lines19719819920020120220320420520620720819 unmodified lines22822923023123223323423523623723823924024124224334 unmodified lines278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320116 unmodified lines437438439440441442443444445446447448449450451452453454455196 unmodified linesresult = grade_fixes(fixes, easy_task)assert result["fixes_correct"] == 1def test_numeric_close_match(self, easy_task):# Row 9 has salary "5000" — clean value is "73000"# Propose 73100 (within 1% of 73000)fixes = [(9, "salary", "73100")]result = grade_fixes(fixes, easy_task)assert result["fixes_partial"] == 1def test_wrong_value_for_issue_cell(self, easy_task):# Row 4 name is empty — propose wrong name19 unmodified linesassert result["fixes_correct"] >= 1def test_all_fixes_correct(self, easy_task):# Fix most issues with exact valuesfixes = [(4, "name", "David Kim"),(7, "salary", "75000"),(9, "salary", "73000"),(15, "email", "oscar.rivera@company.com"),(18, "start_date", "2022-01-19"),]result = grade_fixes(fixes, easy_task)assert result["fix_score"] > 0.7 # 5 out of 6 issues fixed (duplicate can't be fixed)def test_fix_score_bounded(self, easy_task):fixes = [(4, "name", "David Kim"), (99, "x", "bad")]34 unmodified lines"""Backward compatible: only issues, no fixes."""env.reset(task_id="easy")# Submit all 6 correct issues for easy taskaction = DataQAAction(issues=["row:4,col:name,issue:missing_value","row:7,col:salary,issue:wrong_type","row:21,col:employee_id,issue:duplicate_row","row:9,col:salary,issue:out_of_range","row:15,col:email,issue:inconsistent_value","row:18,col:start_date,issue:out_of_range",],task_id="easy",)obs = env.step(action)assert obs.done is Trueassert obs.reward >= 0.999 # identify-only uses identify_score directlydef test_step_with_fixes_increases_reward(self, env):"""Submitting correct fixes should produce high combined reward."""env.reset(task_id="easy")# All 6 issues + 3 fixesaction = DataQAAction(issues=["row:4,col:name,issue:missing_value","row:7,col:salary,issue:wrong_type","row:21,col:employee_id,issue:duplicate_row","row:9,col:salary,issue:out_of_range","row:15,col:email,issue:inconsistent_value","row:18,col:start_date,issue:out_of_range",],fixes=["row:4,col:name,fix:David Kim","row:7,col:salary,fix:75000","row:9,col:salary,fix:73000",],task_id="easy",)obs = env.step(action)# Perfect identify + partial fixes -> high combined rewardassert obs.metadata["combined_reward"] > 0.7def test_step_with_partial_issues(self, env):116 unmodified linesdef test_no_fix_penalty_when_no_fixes_submitted(self, env):"""If agent submits no fixes, reward = identify_score (no penalty)."""env.reset(task_id="easy")action = DataQAAction(issues=["row:4,col:name,issue:missing_value","row:7,col:salary,issue:wrong_type","row:21,col:employee_id,issue:duplicate_row","row:9,col:salary,issue:out_of_range","row:15,col:email,issue:inconsistent_value","row:18,col:start_date,issue:out_of_range",],task_id="easy",)obs = env.step(action)# identify_score should be ~1.0 since all 6 issues foundassert obs.reward >= 0.99# combined_reward equals identify_score when no fixesassert obs.metadata["combined_reward"] == obs.metadata["identify_score"]196 unmodified lines19719819920020120220320420520620719 unmodified lines22722822923023123223323423523623723823924024124234 unmodified lines277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307116 unmodified lines424425426427428429430431432433434435196 unmodified linesresult = grade_fixes(fixes, easy_task)assert result["fixes_correct"] == 1def test_misspelling_fix(self, easy_task):# Row 11 has department "Engneering" — fix to "Engineering"fixes = [(11, "department", "Engineering")]result = grade_fixes(fixes, easy_task)assert result["fixes_correct"] == 1def test_wrong_value_for_issue_cell(self, easy_task):# Row 4 name is empty — propose wrong name19 unmodified linesassert result["fixes_correct"] >= 1def test_all_fixes_correct(self, easy_task):# Fix deterministic issues with exact valuesfixes = [(4, "name", "David Kim"), # inferred from email(7, "salary", "75000"), # type conversion(11, "department", "Engineering"), # spelling fix(15, "email", "oscar.rivera@company.com"), # pattern match(18, "salary", "99000"), # remove extra digit]result = grade_fixes(fixes, easy_task)assert result["fix_score"] > 0.7def test_fix_score_bounded(self, easy_task):fixes = [(4, "name", "David Kim"), (99, "x", "bad")]34 unmodified lines"""Backward compatible: only issues, no fixes."""env.reset(task_id="easy")# Submit all 6 correct issues for easy taskfrom dataqa_env.server.tasks import get_tasktask = get_task("easy")action = DataQAAction(issues=[i.to_key() for i in task.planted_issues],task_id="easy",)obs = env.step(action)assert obs.done is Trueassert obs.reward >= 0.999def test_step_with_fixes_increases_reward(self, env):"""Submitting correct fixes should produce high combined reward."""env.reset(task_id="easy")from dataqa_env.server.tasks import get_tasktask = get_task("easy")action = DataQAAction(issues=[i.to_key() for i in task.planted_issues],fixes=["row:4,col:name,fix:David Kim","row:7,col:salary,fix:75000","row:9,col:department,fix:Engineering",],task_id="easy",)obs = env.step(action)assert obs.metadata["combined_reward"] > 0.7def test_step_with_partial_issues(self, env):116 unmodified linesdef test_no_fix_penalty_when_no_fixes_submitted(self, env):"""If agent submits no fixes, reward = identify_score (no penalty)."""env.reset(task_id="easy")from dataqa_env.server.tasks import get_tasktask = get_task("easy")action = DataQAAction(issues=[i.to_key() for i in task.planted_issues],task_id="easy",)obs = env.step(action)assert obs.reward >= 0.99assert obs.metadata["combined_reward"] == obs.metadata["identify_score"]
94 unmodified lines959697989910010121 unmodified lines12312412512612712812994 unmodified linestypes = {i.issue_type for i in task.planted_issues}assert "inconsistent_value" in typesassert "format_violation" in typesassert "missing_value" in typesdef test_issue_keys_unique(self, task):keys = [i.to_key() for i in task.planted_issues]21 unmodified linesassert "format_violation" in typesassert "statistical_outlier" in typesassert "out_of_range" in typesassert "missing_value" in typesdef test_has_high_difficulty_issues(self, task):hard_issues = [i for i in task.planted_issues if i.difficulty >= 2.5]94 unmodified lines959697989910010121 unmodified lines12312412512612712894 unmodified linestypes = {i.issue_type for i in task.planted_issues}assert "inconsistent_value" in typesassert "format_violation" in typesassert "wrong_type" in typesdef test_issue_keys_unique(self, task):keys = [i.to_key() for i in task.planted_issues]21 unmodified linesassert "format_violation" in typesassert "statistical_outlier" in typesassert "out_of_range" in typesdef test_has_high_difficulty_issues(self, task):hard_issues = [i for i in task.planted_issues if i.difficulty >= 2.5]
dataqa_env/server/gradio_ui.py+32-46
dataqa_env/server/tasks.py+50-43
tests/test_environment.py+22-42
tests/test_tasks.py+1-2