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

相关推荐
da_vinci_x4 小时前
PS 3D Viewer + AI 生成:灰盒(Greybox)一键变“3A”概念图
人工智能·游戏·数学建模·3d·prompt·aigc·游戏美术
xcLeigh16 小时前
AI的提示词专栏:Prompt 与传统机器学习特征工程的异同
人工智能·机器学习·ai·prompt·提示词
猫头虎20 小时前
本地部署 Stable Diffusion3.5超详细教程
stable diffusion·开源·prompt·github·aigc·midjourney·ai编程
iFlow_AI21 小时前
AI 驱动的代码审查与测试用例生成:iFlow CLI在提测阶段的应用实践
prompt·测试用例·测试·心流·iflow·iflowcli
趁你还年轻_1 天前
Prompt Engineering 基础技巧完全指南
prompt
猿类崛起@2 天前
2025秋招LLM大模型多模态面试题:110道大模型面试常见问题及答案,助你拿下AI工程师岗位!
人工智能·机器学习·ai·性能优化·大模型·prompt·大模型训练
海边夕阳20062 天前
【每天一个AI小知识】:什么是Prompt?
人工智能·prompt
极速learner2 天前
n8n本地安装的两种方法:小白入门大白话版本
人工智能·prompt
nvd112 天前
Agent架构升级:解决Gemini超大Prompt处理问题
架构·prompt