Datasets:
Download code/build_core_dev.py from 0721alex/a-plan-is-not-a-path: direct link, hf CLI and curl.
- Browser
- Download file 11.6 kB
-
https://huggingface.co/datasets/0721alex/a-plan-is-not-a-path/resolve/main/code/build_core_dev.py
- Command line
-
hf download hf://datasets/0721alex/a-plan-is-not-a-path/code/build_core_dev.py
-
curl -L -o build_core_dev.py https://huggingface.co/datasets/0721alex/a-plan-is-not-a-path/resolve/main/code/build_core_dev.py
11.6 kB
| """Build the one prespecified after-offer diagnostic on Molab only.""" | |
| from __future__ import annotations | |
| import copy | |
| import json | |
| from itertools import product | |
| from pathlib import Path | |
| from build_dataset import SYNTHETIC_NOTICE | |
| from run_evaluate import oracle, read_jsonl, write_jsonl | |
| PERSONA = ( | |
| "我是普通公办大学的学生,已经完成科研、英语、导师联系与访问申请,并已取得一年访问邀请及生活资助书O。" | |
| "此前准备费用已经支付。今天是取得确认后的第0天,我现在要办好剩余手续、实际出发并完成一年访问。" | |
| "正常生活已有保障,题目给的B是今天实际可立即动用的剩余现金;家里不能追加,也没有借款渠道。" | |
| ) | |
| def core_profile(source): | |
| profile = copy.deepcopy(source) | |
| origin = next(action["allowed_days"][0] for action in source["actions"] if action["id"] == "O") | |
| profile["horizon_days"] -= origin | |
| profile["initial_completed"] = {"O": 0} | |
| future_ids = {"G_reimburse", "D1", "D2", "G_advance", "P", "V", "T", "H", "F"} | |
| profile["actions"] = [action for action in profile["actions"] if action["id"] in future_ids] | |
| for action in profile["actions"]: | |
| action["allowed_days"] = [day - origin for day in action["allowed_days"]] | |
| action["earliest"] -= origin | |
| action["latest"] -= origin | |
| profile["external_cash_events"] = [dict(event, day=event["day"] - origin) | |
| for event in profile.get("external_cash_events", []) | |
| if event["day"] >= origin] | |
| profile["required_groups"] = [group for group in profile["required_groups"] | |
| if all(key in future_ids for key in group["ids"])] | |
| profile["available_routes"] = [ | |
| {"id": "advance", "actions": ["D1", "D2", "G_advance", "P", "V", "T", "H", "F"]}, | |
| {"id": "reimbursement", "actions": ["G_reimburse", "P", "V", "T", "H", "F"]}, | |
| ] | |
| profile["persona"] = PERSONA | |
| profile["context"] = ( | |
| "完全合成的封闭实例,所有金额、机会和本届办理批次都是实验设定,不代表真实大学、CSC或签证政策。" | |
| "邀请及资助书O是第0天已完成的初始事实,无需重新办理或列入未来日程;资助书不等于已到账现金。" | |
| "过去科研、语言和申请费用已支付,当前B是支付之后的实际余额,不再扣除那些历史费用。" | |
| ) | |
| profile["prose_card"] = core_prose(profile) | |
| return profile | |
| def core_prose(profile): | |
| a = {action["id"]: action for action in profile["actions"]} | |
| day = lambda key: a[key]["allowed_days"][0] | |
| dates = lambda key: "或".join(str(value) for value in a[key]["allowed_days"]) | |
| grant = a["G_reimburse"]["cash_effects"][0]["amount"] | |
| reimbursement_offset = a["G_reimburse"]["cash_effects"][0]["offset"] | |
| advance_offset = a["G_advance"]["cash_effects"][0]["offset"] | |
| deposit = next(effect["amount"] for effect in a["H"]["cash_effects"] if effect["label"] == "住宿押金退回") | |
| stipend = next(effect["amount"] for effect in a["H"]["cash_effects"] if effect["label"] == "月生活补助实际到账") | |
| living = -next(effect["amount"] for effect in a["H"]["cash_effects"] if effect["label"] == "月生活费") | |
| hold = a["P"].get("hold") | |
| if hold: | |
| proof_text = ( | |
| f"官方资助书O已抵扣它覆盖的生活费,剩余需证明的余额仅{hold['amount']}元。" | |
| f"第{day('P')}天办理剩余余额核对P,免费,须在O之后至少14天;P当天及之前连续28天" | |
| f"账户每天都须至少{hold['amount']}元。" | |
| ) | |
| proof_stage = "余额核对P" | |
| else: | |
| proof_text = ( | |
| "官方资助书O已覆盖本实例需证明的全部生活费,不需要额外现金余额或连续持有银行存款。" | |
| f"第{day('P')}天核对这份官方资助书P,免费,须在O之后至少14天。" | |
| ) | |
| proof_stage = "资助书核对P" | |
| return ( | |
| "【学生来信】" + profile["persona"] + "\n\n" | |
| "【已确认事实与实例说明】" + profile["context"] + | |
| f"目标是在第{profile['horizon_days']}天前完成一年访问。以下所有日期以今天第0天为原点," | |
| "是本届仅有的办理批次,不接受其他日期。\n\n" | |
| f"【出行资助邮件】差旅支持有两种互斥方式,金额同为{grant}元,必须选择一种。" | |
| f"普通报销登记G_reimburse仅第{day('G_reimburse')}天办理,免费,须在已经完成的O之后至少7天;" | |
| f"登记后第{reimbursement_offset}天,即第{day('G_reimburse') + reimbursement_offset}天," | |
| f"{grant}元才实际到账。预付方式先在第{dates('D1')}天收集证明D1,免费,须在O之后至少5天;" | |
| f"再在第{dates('D2')}天提交差旅估算D2,免费,须在D1之后至少4天。" | |
| f"最后第{dates('G_advance')}天申请预付G_advance,免费,须在D2之后至少7天;" | |
| f"{grant}元在申请后第{advance_offset}天真正到账。G_reimburse和G_advance不能并用。\n\n" | |
| "【行前行政通知】" + proof_text + "这是合成行政核对,不认定真实签证资格。" | |
| f"第{day('V')}天办理行前手续V,支付{a['V']['cost']}元不退,须在P之后至少1天。" | |
| f"第{day('T')}天预订交通T,支付{a['T']['cost']}元,其中50%可退,须在V之后至少7天。\n\n" | |
| f"【到达及生活资助邮件】第{day('H')}天到达H,须在T之后至少7天," | |
| f"当天支付{a['H']['cost']}元,其中{deposit}元是可退住宿押金,其余不退。" | |
| "生活资助不提前发:到达后第30、60、90、120、150、180、210、240、270、300、330天," | |
| f"每次一早到账{stipend}元,晚些时候支付{living}元生活费。到达后第360天退回{deposit}元押金。" | |
| f"第{day('F')}天完成访问F,免费,须在H之后至少365天。\n\n" | |
| f"【未来必须完成的阶段】差旅资助G_reimburse或G_advance;{proof_stage};行前手续V;交通T;到达H;" | |
| "完成访问F。预付方式的免费前置手续D1和D2也须按通知完成。除明确到账的这些款项外," | |
| "没有其他收入、赠款或借款;已确认的资助书本身不能当作可花现金。" | |
| ) | |
| def core_prompt(profile, buffer): | |
| return SYNTHETIC_NOTICE + "\n\n" + profile["prose_card"] + "\n\n" + ( | |
| f"截至第0天,我现在能立即动用的现金只有{buffer}元,这已是过去准备费用支付后的余额。" | |
| "请仅规划未来步骤,安排能真实执行并在本实例给定期限内完成一年访问的计划。" | |
| "给出实际采用的步骤代号与办理日期,选择融资路线和付款顺序。若确实无法完成,说明卡点," | |
| "并仍列出当前值得且能够实际执行的步骤。日期只能从通知列出的本届办理批次中选择," | |
| "满足最短间隔后也不能自行改变日期。逐项列出所选方案全部未来必需步骤,包括免费的前置手续和核对;" | |
| "不能改名、合并或默认自动完成。先用不超过150字中文说明,再给出一个且仅一个JSON对象," | |
| '格式为{"actions":[{"id":"步骤代号","day":整数日期}],"reason":"简短说明"}。' | |
| "day从今天第0天起算,同日步骤按列出的顺序办理。后续到账在指定日期一早可用," | |
| "后续生活付款在当天晚些时候支付;步骤当天附带的收支跟随该步骤。" | |
| ) | |
| def main(): | |
| destination = Path("data/dev_v3") | |
| sources = [profile for profile in read_jsonl("data/dev_v1/profiles.jsonl") | |
| if profile["id"] in ("dev_01", "dev_04")] | |
| profiles = [core_profile(source) for source in sources] | |
| requests, oracle_rows, buffer_selection = [], [], [] | |
| models, seeds = ["Qwen/Qwen3.5-2B", "Qwen/Qwen3.5-4B"], [1729] | |
| for profile in profiles: | |
| result = oracle(profile) | |
| oracle_rows.append({"profile_id": profile["id"], **result}) | |
| reimbursement = next(route["minimum_initial_cash"] for route in result["route_minima"] | |
| if route["route_id"] == "reimbursement") | |
| best = result["minimum_initial_cash"] | |
| middle = best + 500 | |
| middle_rule = "R_star_plus_500" | |
| if not best < middle < reimbursement: | |
| middle = (best + reimbursement) // 2 | |
| middle_rule = "integer_reference_midpoint" | |
| buffers = [best - 1000, middle, reimbursement + 1000] | |
| buffer_selection.append({"profile_id": profile["id"], "minimum_initial_cash": best, | |
| "reimbursement_minimum_initial_cash": reimbursement, | |
| "buffers": buffers, "middle_rule": middle_rule}) | |
| for buffer, model, seed in product(buffers, models, seeds): | |
| request_id = f"{profile['id']}__B{buffer}__{model.split('/')[-1]}__s{seed}__natural" | |
| requests.append({"id": request_id, "profile_id": profile["id"], "B": buffer, | |
| "model": model, "seed": seed, "condition": "natural", | |
| "prompt": core_prompt(profile, buffer)}) | |
| write_jsonl(destination / "profiles.jsonl", profiles) | |
| write_jsonl(destination / "requests.jsonl", requests) | |
| write_jsonl(destination / "oracle.jsonl", oracle_rows) | |
| destination.mkdir(parents=True, exist_ok=True) | |
| design = {"version": "dev_v3", "profile_ids": [profile["id"] for profile in profiles], | |
| "models": models, "seeds": seeds, "profile_specific_buffers": buffer_selection, | |
| "request_count": len(requests), "fully_synthetic": True, "conditions": ["natural"], | |
| "output_max_tokens_both_models": 32768, "context_length_both_models": 131072, | |
| "all_generation_and_scoring_location": "Molab RTX PRO 6000"} | |
| (destination / "design.json").write_text(json.dumps(design, ensure_ascii=False, indent=2), encoding="utf-8") | |
| (destination / "change_note.txt").write_text( | |
| "This is the one prespecified core after-offer diagnostic, not a rerun of the full preparation task. " | |
| "Sources are the unchanged authored dev_01 and dev_04 facts. O is already completed at day 0; " | |
| "past academic/language/contact/application actions and their already-paid expenses are omitted. " | |
| "Initial B is remaining spendable cash after those past payments. Future absolute dates and horizon " | |
| "are shifted by the original O day. Future costs, relative cash-effect offsets, amounts, refund terms, " | |
| "holds, dependency lags, exclusions and permitted-date menus are unchanged. Initial completed O0 " | |
| "satisfies its published prerequisite lags. Only two future funding routes remain. The three buffers " | |
| "per profile are chosen from the newly enumerated reference thresholds, without model outputs: " | |
| "R*-1000, R*+500 (reference midpoint if not strictly between thresholds), and Rreimburse+1000. " | |
| "Both native systems use seed1729, common32768 output cap and131072 context. Conditional start, " | |
| "task/action scope, clock origin, buffers, prompt wording and output cap change together; no effect " | |
| "may be attributed to a single cause. All previous dev results remain separate. No money or rule " | |
| "was changed to manufacture a result.\n", encoding="utf-8") | |
| print(json.dumps(design, ensure_ascii=False), flush=True) | |
| if __name__ == "__main__": | |
| main() | |