evalscope_v0.17.0/evalscope.0.17.0/docs/zh/get_started/parameters.md

12 KiB
Raw Blame History

参数说明

执行 evalscope eval --help 可获取全部参数说明。

模型参数

  • --model: 被评测的模型名称。
    • 指定为模型在ModelScope中的id,将自动下载模型,例如Qwen/Qwen2.5-0.5B-Instruct
    • 指定为模型的本地路径,例如/path/to/model,将从本地加载模型;
    • 评测目标为模型API服务时需要指定为服务对应的模型id例如Qwen2.5-0.5B-Instruct
  • --model-id: 被评测的模型的别名,用于报告展示。默认为model的最后一部分,例如Qwen/Qwen2.5-0.5B-Instructmodel-idQwen2.5-0.5B-Instruct
  • --model-args: 模型加载参数,以逗号分隔的key=value形式或以json字符串格式传入将解析为字典。默认参数
    • revision: 模型版本,默认为master
    • precision: 模型精度,默认为torch.float16
    • device_map: 模型分配设备,默认为auto
  • --model-task: 模型任务类型,默认为text_generation,可选text_generation, image_generation
  • --generation-config: 生成参数,以逗号分隔的key=value形式或以json字符串格式传入将解析为字典:
    • 若使用本地模型推理基于Transformers包括如下参数全部参数指南
      • do_sample: 是否使用采样,默认为false
      • max_length: 最大长度默认为2048
      • max_new_tokens: 生成最大长度默认为512
      • num_return_sequences: 生成序列数量默认为1设置大于1时将生成多个序列需要设置do_sample=True
      • temperature: 生成温度
      • top_k: 生成top-k
      • top_p: 生成top-p
    • 若使用模型API服务推理eval-type设置为service),包括如下参数(具体请参考部署的模型服务):
      • max_tokens: 生成最大长度默认为2048
      • temperature: 生成温度, 默认为0.0
      • n: 生成序列数量默认为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}}'
    
  • --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
    • OpenCompass用于评测大语言模型
    • VLMEvalKit用于评测多模态模型
    • RAGEval用于评测RAG流程、Embedding模型、Reranker模型、CLIP模型
      其他评测后端[使用指南](../user_guides/backend/index.md)
      
    • ThirdParty 用于其他特殊任务评测,例如ToolBench, LongBench
  • --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中读取,默认为EMPTY
    • api_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: 评测数据集的系统prompt
    • prompt_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_mappingpattern模式下的分数映射字典,默认为{'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