修改 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 改成你需要的。

相关推荐
Yolanda947 小时前
【人工智能】《从零搭建AI问答助手项目(九):Prompt优化》
人工智能·prompt
TheRouter1 天前
AI Agent 的Prompt Injection 防御实战:从EchoLeak 零点击外泄到6层防护栈(含可运行代码与对比表)
人工智能·ai·prompt
Nayxxu1 天前
Claude Prompt Caching 详解:缓存写入、缓存读取与成本计算
缓存·prompt
AI布道师-wang1 天前
第 6 章:Prompt 工程——和模型高效沟通
人工智能·机器学习·prompt
meilindehuzi_a1 天前
Vibe Coding 实战:我用一条 Prompt 指挥 AI “盲盒式”生成 3D 积木物理世界
3d·prompt
霍格沃兹测试学院-小舟畅学2 天前
Anthropic 开源 Skills:Agent 工程化,开始从 Prompt 走向能力封装
prompt
玄米乌龙茶1232 天前
LLM 应用开发学习笔记:System Prompt 设计、注入风险与成本优化
笔记·学习·prompt
一条泥憨鱼2 天前
全面解析 AI 大模型中的 Prompt
人工智能·ai·prompt
sugar__salt2 天前
从Prompt到3D世界:用大模型精准构建你的迷你村庄
3d·ai·prompt·ai编程
闵孚龙2 天前
Claude Code 驾驭工程原则全解析:AI Agent、上下文工程、Prompt Cache、权限安全、A/B测试、长期记忆与多智能体架构底层方法论
人工智能·安全·prompt