a-plan-is-not-a-path / code /author_profiles.py
0721alex's picture
Publish A Plan Is Not a Path research materials
557f178 verified
Raw History Blame Contribute Delete
8.46 kB
"""Remote-only instantiation of fixed, authored fictional benchmark profiles."""
from __future__ import annotations
import argparse
import copy
import json
from pathlib import Path
from run_evaluate import write_jsonl
def render_prose(profile):
a = {x["id"]: x for x in profile["actions"]}
day = lambda key: a[key]["allowed_days"][0]
dates = lambda key: "或".join(str(value) for value in a[key]["allowed_days"])
costs = lambda key: a[key].get("cost", 0)
grant = a["G_reimburse"]["cash_effects"][0]["amount"]
reimb_delay = a["G_reimburse"]["cash_effects"][0]["offset"]
advance_delay = a["G_advance"]["cash_effects"][0]["offset"]
stipend = next(x["amount"] for x in a["H"]["cash_effects"] if x["label"] == "月生活补助实际到账")
living = -next(x["amount"] for x in a["H"]["cash_effects"] if x["label"] == "月生活费")
deposit = next(x["amount"] for x in a["H"]["cash_effects"] if x["label"] == "住宿押金退回")
if a["P"].get("hold"):
amount = a["P"]["hold"]["amount"]
proof = (f"资助书O已抵扣它覆盖的生活费,剩余需证明的余额仅{amount}元。"
f"第{day('P')}天完成剩余余额核对P,免费,须在O之后至少14天,"
f"P当天及之前连续28天账户每天都须至少{amount}元。")
else:
proof = ("官方资助书O完全覆盖本实例要求证明的生活费,因此不需要额外现金余额或连续持有银行存款。"
f"第{day('P')}天核对官方资助书P,免费,须在O之后至少14天。")
return (
"【学生来信】" + profile["persona"] + "\n\n"
"【实例说明】这是完全合成的封闭实例。金额、办理批次和机会不代表实际大学、CSC或签证政策。"
"所有金额以人民币元计,30个月按900天计。下面列出的办理日期是本届仅有批次,不接受其他日期;"
"同日步骤按计划列出的顺序办理。只要按要求完成准备与申请,邀请和生活资助就条件性确认,"
"不模拟真实的竞争录取概率。\n\n"
f"【校内准备通知】第{day('R')}天完成科研小项目R,费用{costs('R')}元,不退。"
f"第{day('C')}天完成导师联系C,免费,须在R之后至少60天。语言有两种等效办法:"
f"第{day('L_paid')}天参加英语测试L_paid,{costs('L_paid')}元不退;或第{day('W')}天申请"
f"校内英语证明减免费W,免费,第{day('L_waiver')}天领取等效英文证明L_waiver,"
f"{costs('L_waiver')}元不退,须先完成W至少14天。L_paid与L_waiver互斥。"
f"第{day('A')}天提交访问申请A,费用{costs('A')}元不退,须在C之后至少14天。"
f"第{day('O')}天取得访问邀请及生活资助书O,免费,须在A之后至少30天。\n\n"
"【出行资助说明】确认的资助书不是现金。差旅支持有两种互斥方式,"
f"金额同为{grant}元,须选择一种。普通报销登记G_reimburse只在第{day('G_reimburse')}天办理,"
f"免费,须在O之后至少7天;登记后第{reimb_delay}天,即第{day('G_reimburse') + reimb_delay}天,"
f"{grant}元才实际到账。预付方式须先在第{dates('D1')}天收集证明D1,免费,须在O之后至少5天;"
f"再于第{dates('D2')}天提交差旅估算D2,免费,须在D1之后至少4天。"
f"最后第{dates('G_advance')}天申请预付G_advance,免费,须在D2之后至少7天,"
f"{grant}元于申请后第{advance_delay}天真正到账。G_reimburse与G_advance不能并用。\n\n"
"【行前行政邮件】" + proof + "这只是合成实例中的行政核对,不认定真实签证资格。"
f"第{day('V')}天办理行前手续V,支付{costs('V')}元不退,须在P之后至少1天;"
f"第{day('T')}天预订交通T,支付{costs('T')}元,其中50%可退,须在V之后至少7天。\n\n"
f"【到达及生活资助邮件】第{day('H')}天到达H,须在T之后至少7天,当天支付{costs('H')}元,"
f"其中{deposit}元是可退住宿押金,其余不退。生活资助不提前发:到达后第30、60、90、120、"
f"150、180、210、240、270、300、330天,每次一早到账{stipend}元,晚些时候支付{living}元生活费。"
f"到达后第360天退回{deposit}元押金。第{day('F')}天完成一年访问F,免费,须在H之后至少365天。"
"所有后续到账均在指定日期一早可用,后续生活付款在当天晚些时候支付;步骤当天附带的收支跟随该步骤。\n\n"
"【必须达到的阶段】科研R;语言L_paid或L_waiver;申请A;出行资助G_reimburse或G_advance;"
"行政核对P;行前手续V;交通T;到达H;完成访问F。其他步骤按相关通知的前后要求办理。"
"除上述真正到账的款项外,没有其他收入、赠款、借款或资金来源。"
)
def instantiate(template, spec):
profile = copy.deepcopy(template)
profile["id"], profile["split"] = spec["id"], spec["split"]
profile["persona"] = (
f"我是普通公办大学大二的{spec['major']}专业学生,GPA 3.5/4,六级520分,"
"有一学期校内实验室或研究助理经历,没有论文和海外经历,每周能稳定投入15小时。"
"我希望在30个月内做好科研和英语准备,在获得研究访问邀请与生活资助后真正出发并完成一年访问。"
"正常生活已有保障,额外能动用的现金是题目最后给的数额,家里不能临时追加,也没有借款渠道。"
)
profile["context"] = (
"完全合成的封闭学术访问机会;所有金额和批次均为实例设定。"
"按指定要求完成准备和申请后,邀请和资助条件性确认,不模拟真实竞争录取。"
"官方资助覆盖已抵扣,资助书本身不能再次计为到账现金。"
)
costs = {"R": "research", "L_paid": "paid_language", "L_waiver": "waiver_language",
"A": "application", "V": "administration", "T": "transport", "H": "arrival"}
for action in profile["actions"]:
action["allowed_days"] = [value + spec["shift"] for value in action["allowed_days"]]
action["earliest"], action["latest"] = min(action["allowed_days"]), max(action["allowed_days"])
if action["id"] in costs:
action["cost"] = spec[costs[action["id"]]]
if action["id"] in ("G_advance", "G_reimburse"):
action["cash_effects"][0]["amount"] = spec["travel_support"]
if action["id"] == "G_advance":
action["cash_effects"][0]["offset"] = spec["advance_offset"]
if action["id"] == "P":
if spec["residual_proof"]:
action["hold"]["amount"] = spec["residual_proof"]
else:
action.pop("hold", None)
action["label"] = "核对完全覆盖财务证明的官方资助书"
if action["id"] == "H":
action["refundable_fraction"] = spec["deposit"] / spec["arrival"]
for effect in action["cash_effects"]:
if effect["label"] == "月生活补助实际到账":
effect["amount"] = spec["stipend"]
elif effect["label"] == "月生活费":
effect["amount"] = -spec["living"]
elif effect["label"] == "住宿押金退回":
effect["amount"] = spec["deposit"]
profile.pop("oracle_candidates", None)
profile.pop("author_note", None)
profile["prose_card"] = render_prose(profile)
return profile
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--template", default="data/mechanism_template.json")
parser.add_argument("--specs", default="data/profile_specs.json")
parser.add_argument("--out", default="data/authored_profiles.jsonl")
args = parser.parse_args()
template = json.loads(Path(args.template).read_text(encoding="utf-8"))
specs = json.loads(Path(args.specs).read_text(encoding="utf-8"))
profiles = [instantiate(template, spec) for spec in specs]
write_jsonl(args.out, profiles)
print(json.dumps({"instantiated_profiles": len(profiles), "out": args.out}, ensure_ascii=False))
if __name__ == "__main__":
main()