12 KiB
12 KiB
参数说明
执行 evalscope eval --help 可获取全部参数说明。
模型参数
--model: 被评测的模型名称。- 指定为模型在ModelScope中的
id,将自动下载模型,例如Qwen/Qwen2.5-0.5B-Instruct; - 指定为模型的本地路径,例如
/path/to/model,将从本地加载模型; - 评测目标为模型API服务时,需要指定为服务对应的模型id,例如
Qwen2.5-0.5B-Instruct。
- 指定为模型在ModelScope中的
--model-id: 被评测的模型的别名,用于报告展示。默认为model的最后一部分,例如Qwen/Qwen2.5-0.5B-Instruct的model-id为Qwen2.5-0.5B-Instruct。--model-args: 模型加载参数,以逗号分隔的key=value形式;或以json字符串格式传入,将解析为字典。默认参数:revision: 模型版本,默认为masterprecision: 模型精度,默认为torch.float16device_map: 模型分配设备,默认为auto
--model-task: 模型任务类型,默认为text_generation,可选text_generation,image_generation--generation-config: 生成参数,以逗号分隔的key=value形式;或以json字符串格式传入,将解析为字典:- 若使用本地模型推理(基于Transformers)包括如下参数(全部参数指南):
do_sample: 是否使用采样,默认为falsemax_length: 最大长度,默认为2048max_new_tokens: 生成最大长度,默认为512num_return_sequences: 生成序列数量,默认为1;设置大于1时,将生成多个序列,需要设置do_sample=Truetemperature: 生成温度top_k: 生成top-ktop_p: 生成top-p
- 若使用模型API服务推理(
eval-type设置为service),包括如下参数(具体请参考部署的模型服务):max_tokens: 生成最大长度,默认为2048temperature: 生成温度, 默认为0.0n: 生成序列数量,默认为1(注意:lmdeploy目前仅支持n=1)
# 例如用key=value形式传入 --model-args revision=master,precision=torch.float16,device_map=auto --generation-config do_sample=true,temperature=0.5 # 或者用json字符串传入更复杂的参数 --model-args '{"revision": "master", "precision": "torch.float16", "device_map": "auto"}' --generation-config '{"do_sample":true,"temperature":0.5,"chat_template_kwargs":{"enable_thinking": false}}'- 若使用本地模型推理(基于Transformers)包括如下参数(全部参数指南):
--chat-template: 模型推理模板,默认为None,表示使用transformers的apply_chat_template;支持传入jinjia模版字符串,来自定义推理模板--template-type: 模型推理模板,已弃用,参考--chat-template
以下参数仅在eval-type=service时有效:
--api-url: 模型API端点,默认为None;支持传入本地或远端的OpenAI API格式端点,例如http://127.0.0.1:8000/v1。--api-key: 模型API端点密钥,默认为EMPTY--timeout: 模型API请求超时时间,默认为None--stream: 是否使用流式传输,默认为False
数据集参数
--datasets: 数据集名称,支持输入多个数据集,使用空格分开,数据集将自动从modelscope下载,支持的数据集参考数据集列表--dataset-args: 评测数据集的设置参数,以json字符串格式传入,将解析为字典,注意需要跟--datasets参数中的值对应:dataset_id(或local_path): 可指定数据集本地路径,指定后将尝试从本地加载数据。prompt_template: 评测数据集的prompt模板,指定后将使用模板生成prompt。例如gsm8k的模版为Question: {query}\nLet's think step by step\nAnswer:,数据集的问题将填充到模板query字段中。query_template: 评测数据集的query模板,指定后将使用模板生成query。例如general_mcq的模版为问题:{question}\n{choices}\n答案: {answer}\n\n,数据集的问题将填充到模板question字段中,选项填充到choices字段中,答案填充到answer字段中(答案填充仅对few-shot生效)。system_prompt: 评测数据集的系统prompt。model_adapter: 评测数据集的模型适配器,指定后将使用给定的模型适配器评测,目前支持generation,multiple_choice_logits,continuous_logits;对于service评测,目前仅支持generation;部分多选题数据集支持logits输出。subset_list: 评测数据子集列表,指定后将只使用子集数据。few_shot_num: few-shot的数量。few_shot_random: 是否随机采样few-shot数据,默认为False。metric_list: 评测数据集的指标列表,指定后使用给定的指标评测,目前支持AverageAccuracy,AveragePass@1,Pass@[1-16]。例如humaneval数据集可指定["Pass@1", "Pass@5"],注意此时需要指定n=5让模型返回5个结果。filters: 评测数据集的过滤器,指定后将使用给定的过滤器过滤评测结果,可用来处理推理模型的输出,目前支持:remove_until {string}: 过滤掉模型输出结果中指定字符串之前的部分。extract {regex}: 提取模型输出结果中指定正则表达式匹配的部分。 例如ifeval数据集可指定{"remove_until": "</think>"},将过滤掉模型输出结果中</think>之前的部分,避免影响打分。
# 例如 --datasets gsm8k arc --dataset-args '{"gsm8k": {"few_shot_num": 4, "few_shot_random": false}, "arc": {"dataset_id": "/path/to/arc"}}, "ifeval": {"filters": {"remove_until": "</think>"}}'--dataset-dir: 数据集下载路径,默认为~/.cache/modelscope/datasets--dataset-hub: 数据集下载源,默认为modelscope,可选huggingface--limit: 每个数据集最大评测数据量,不填写则默认为全部评测,可用于快速验证。支持int和float类型,int表示评测数据集的前N条数据,float表示评测数据集的前N%条数据。例如0.1表示评测数据集的前10%的数据,100表示评测数据集的前100条数据。
评测参数
--eval-batch-size: 评测批量大小,默认为1;在eval-type=service时,表示并发评测的请求数,默认为8--eval-stage: (已弃用,参考--use-cache)评测阶段,可选all,infer,review, 默认为all--eval-type: 评测类型,可选checkpoint,custom,service;默认为checkpoint--eval-backend: 评测后端,可选Native,OpenCompass,VLMEvalKit,RAGEval,ThirdParty,默认为Native--eval-config: 使用非Native评测后端时,需要传入该参数
Judge参数
LLM-as-a-Judge评测参数,使用裁判模型来判断正误,包括以下参数:
--judge-strategy: 使用裁判模型的策略,可选:auto: 默认策略,根据数据集是否需要judge来决定是否使用裁判模型llm: 总是使用裁判模型rule: 不使用裁判模型,使用规则判断llm_recall: 先使用规则判断,若规则判断失败再使用裁判模型
--judge-worker-num: 裁判模型并发数,默认为1--judge-model-args: 设置裁判模型参数,以json字符串格式传入,将解析为字典,支持如下字段:api_key: 模型API端点密钥,未设置时将从环境变量MODELSCOPE_SDK_TOKEN中读取,默认为EMPTYapi_url: 模型API端点,未设置时将从环境变量MODELSCOPE_API_BASE中读取,默认为https://api-inference.modelscope.cn/v1/model_id: 模型ID,未设置时将从环境变量MODELSCOPE_JUDGE_LLM中读取,默认为Qwen/Qwen3-235B-A22B关于ModelScope的模型推理服务的更多信息,请参考[ModelScope API推理服务](https://modelscope.cn/docs/model-service/API-Inference/intro)system_prompt: 评测数据集的系统promptprompt_template: 评测数据集的prompt模板generation_config: 模型生成参数,与--generation-config参数相同。score_type: 预置的模型打分方式,可选:-
pattern: (默认选项)直接判断模型输出与参考答案是否相同,适合有参考答案评测。默认prompt_template
Your job is to look at a question, a gold target, and a predicted answer, and return a letter "A" or "B" to indicate whether the predicted answer is correct or incorrect. [Question] {question} [Reference Answer] {gold} [Predicted Answer] {pred} Evaluate the model's answer based on correctness compared to the reference answer. Grade the predicted answer of this new question as one of: A: CORRECT B: INCORRECT Just return the letters "A" or "B", with no text around it. -
numeric: 判断模型输出在prompt条件下的打分,适合无参考答案评价。默认prompt_template
Please act as an impartial judge and evaluate the quality of the response provided by an AI assistant to the user question displayed below. Your evaluation should consider factors such as the helpfulness, relevance, accuracy, depth, creativity, and level of detail of the response. Begin your evaluation by providing a short explanation. Be as objective as possible. After providing your explanation, you must rate the response on a scale of 0 (worst) to 1 (best) by strictly following this format: \"[[rating]]\", for example: \"Rating: [[0.5]]\" [Question] {question} [Response] {pred}
-
score_pattern:解析模型输出的正则表达式,pattern模式默认为(A|B);numeric模式默认为\[\[(\d+(?:\.\d+)?)\]\],用于提取模型打分结果。score_mapping:pattern模式下的分数映射字典,默认为{'A': 1.0, 'B': 0.0}
--analysis-report: 是否生成分析报告,默认为false;如果设置该参数,将使用judge model生成分析报告,报告中包含模型评测结果的分析解读和建议。报告输出语言将根据locale.getlocale()自动判断。
其他参数
--work-dir: 模型评测输出路径,默认为./outputs/{timestamp},文件夹结构示例如下:. ├── configs │ └── task_config_b6f42c.yaml ├── logs │ └── eval_log.log ├── predictions │ └── Qwen2.5-0.5B-Instruct │ └── general_qa_example.jsonl ├── reports │ └── Qwen2.5-0.5B-Instruct │ └── general_qa.json └── reviews └── Qwen2.5-0.5B-Instruct └── general_qa_example.jsonl--use-cache: 使用本地缓存的路径,默认为None;如果为指定路径,例如outputs/20241210_194434,将重用路径下的模型推理结果,若未完成推理则会继续推理,之后进行评测。--seed: 随机种子,默认为42--debug: 是否开启调试模式,默认为false--ignore-errors: 是否忽略模型生成过程中的错误,默认为false--dry-run: 预检参数,不进行推理,只打印参数,默认为false