修改 lm-evaluation-harness 任务 yaml 的 prompt

修改 lm-evaluation-harness 任务 yaml 的 prompt,以gsm8k_cot_zeroshot.yaml 为例说明。

gsm8k_cot_zeroshot.yaml 在哪里?

如果使用的是 LM Evaluation Harness(lm_eval),文件一般在:

复制代码
<your_env>/site-packages/lm_eval/tasks/gsm8k/

可以直接在终端找到实际路径:

bash 复制代码
python -c "import lm_eval, inspect, os; print(os.path.dirname(inspect.getfile(lm_eval)))"

输出类似:

复制代码
/data/home/usr111/.conda/envs/llm_gpu/lib/python3.10/site-packages/lm_eval

那么 gsm8k 的配置就在:

复制代码
/data/home/usr111/.conda/envs/llm_gpu/lib/python3.10/site-packages/lm_eval/tasks/gsm8k/gsm8k_cot_zeroshot.yaml

📌 你要找的内容就在这个文件里

打开:

bash 复制代码
vim ~/.conda/envs/llm_gpu/lib/python3.10/site-packages/lm_eval/tasks/gsm8k/gsm8k_cot_zeroshot.yaml

会看到类似:

yaml 复制代码
doc_to_text: "Q: {{question}}\nA: Let's think step by step."

而想修改 prompt 是:

yaml 复制代码
doc_to_text: "Solve the following math problem step by step. The last line of your response should be of the form The answer is $ANSWER (without quotes) where $ANSWER is the answer to the problem.\n{{question}}\n Remember to put your answer on its own line after 'The answer is', and you do not need to use a \\boxed command."

⚠️ 注意:不要直接修改 site-packages 的文件!

未来更新/重装会被覆盖。

官方推荐两种方式:


方法 1(推荐):在本地创建自定义 task

创建目录:

复制代码
mkdir -p custom_tasks/gsm8k

新建文件:

复制代码
custom_tasks/gsm8k/gsm8k_cot_zeroshot.yaml

把你的版本粘进去:

yaml 复制代码
task: gsm8k_cot_zeroshot_custom

doc_to_text: |
  Solve the following math problem step by step. The last line of your response should be of the form The answer is $ANSWER (without quotes) where $ANSWER is the answer to the problem.
  {{question}}
  Remember to put your answer on its own line after 'The answer is', and you do not need to use a \boxed command.

doc_to_target: "{{answer}}"

然后运行:

bash 复制代码
lm_eval --tasks gsm8k_cot_zeroshot_custom

或:

bash 复制代码
accelerate launch eval_llada.py --tasks gsm8k_cot_zeroshot_custom

方法 2:直接覆盖原文件(简单但不推荐)

bash 复制代码
vim ~/.conda/envs/llm_gpu/lib/python3.10/site-packages/lm_eval/tasks/gsm8k/gsm8k-cot-zeroshot.yaml

然后把 prompt 改成你需要的。

相关推荐
Swizard6 天前
逐行解剖:扒开 Lovable Agent 源码,看顶级 AI 是如何“思考”与“动刀”的
ai·prompt
杜子不疼.7 天前
大模型应用开发实战:从 Prompt 工程到企业级落地全流程
prompt
觅特科技-互站7 天前
告别手动微调Prompt:DevOps用陌讯Skills重构AI运维工作流
运维·prompt·线性回归·kmeans·devops
小马_xiaoen7 天前
AI Prompt 工程完全指南:从入门到精通的提示词设计艺术
人工智能·prompt
Swizard8 天前
还在无脑堆砌提示词?三分钟看懂 Vercel v0 价值千万的 System Prompt 底层逻辑
ai·prompt
Loo国昌8 天前
【AI应用开发实战】Guardrail风险控制中间件:Agent系统的安全防线
人工智能·python·安全·自然语言处理·中间件·prompt
啦啦啦_99998 天前
SpringAI Alibaba(SAA) 之 Prompt
prompt
AC赳赳老秦8 天前
DeepSeek助力云原生AI降本:容器化部署资源优化与算力利用率提升技巧
网络·python·django·prompt·tornado·ai-native·deepseek
Loo国昌9 天前
【AI应用开发实战】09_Prompt工程与模板管理:构建可演进的LLM交互层
大数据·人工智能·后端·python·自然语言处理·prompt
minhuan9 天前
大模型应用:遗传算法 (GA)+大模型:自动化进化最优Prompt与模型参数.95
prompt·大模型应用·遗传算法 ga·prompt自动调优