中文
本页内容

命令行接口

openMind Library提供命令行接口(command-line interface, CLI),支持用户在shell环境下交互式实现文件上传、文件下载、模型查询、模型删除、模型评估、单轮推理和多轮对话操作。openmind-cli简化了流程,让用户能够以低代码模式迅速启动并使用社区中的模型资源,实现了开箱即用的体验,降低了技术门槛。

openMind Library命令行接口内置于openMind Library中,安装openMind Library即可使用,详细步骤参考openMind Library安装指南

本地模型查询

openmind-cli list用于查询并回显本地已下载的模型清单,可以查询模型缓存目录和指定下载目录。

此接口支持PyTorch和MindSpore框架。

接口调用示例如下。

  • 遍历查询环境变量所定义的缓存目录下存储的模型。

    shell
    openmind-cli list
    

    回显示例如下。

    openmind-cli list

  • 遍历查询~/.cache2/openmind/hub目录下缓存的模型。

    shell
    openmind-cli list --cache_dir ~/.cache2/openmind/hub
    

    注意此处--cache_dir指定的缓存路径优先级高于环境变量所指定的缓存路径优先级。

  • 遍历查询./目录下的模型。

    shell
    openmind-cli list --local_dir ./
    
  • 遍历查询--local_dir--cache_dir目录下的模型。

    shell
    openmind-cli list --local_dir ./ --cache_dir ~/.cache2/openmind/hub
    

openmind-cli list的全量参数可以参考openmind-cli list接口

本地模型删除

openmind-cli rm用于删除给定的本地模型,可以指定模型缓存目录以及本地目录。

此接口支持PyTorch和MindSpore框架。

接口调用示例如下。

  • 删除默认缓存路径下的bluelm_7b_chat模型。

    shell
    openmind-cli rm PyTorch-NPU/bluelm_7b_chat
    

    遍历查询默认缓存路径下的bluelm_7b_chat模型,若成功找到,则将其删除,并回显执行结果以及删除模型的原存储路径;如果没有找到,报错反馈给用户。

    以下是成功删除的回显示例:

    text
    Deleted file path: /xxx/.cache/openmind/hub/models--PyTorch-NPU-bluelm_7b_chat
    File deleted successfully.
    
  • 删除指定缓存路径下的bluelm_7b_chat模型。

    shell
    openmind-cli rm PyTorch-NPU/bluelm_7b_chat --cache_dir ~/.cache2/openmind/hub
    

    遍历查询~/.cache2/openmind/hub目录下的bluelm_7b_chat模型,如找到,则将其删除,注意此处--cache_dir指定的缓存路径优先级高于环境变量所指定的缓存路径优先级。

  • 删除指定本地路径下的bluelm_7b_chat模型。

    shell
    openmind-cli rm PyTorch-NPU/bluelm_7b_chat --local_dir /your/local/path/
    

    遍历查询/your/local/path/目录下的bluelm_7b_chat模型,如找到,则将其删除;如果没有找到,报错反馈给用户。

  • 删除指定缓存路径和指定本地路径下的bluelm_7b_chat模型。

    shell
    openmind-cli rm PyTorch-NPU/bluelm_7b_chat --local_dir /your/local/path/ --cache_dir ~/.cache2/openmind/hub
    

    遍历查询--local_dir--cache_dir目录下的bluelm_7b_chat模型,如找到,则将其删除;如果没有找到,报错反馈给用户。

    以下是两个路径均存在对应模型的回显示例:

    text
    Deleted file path: /your/local/path/models--PyTorch-NPU-bluelm_7b_chat
    Deleted file path: /xxx/.cache2/openmind/hub/models--PyTorch-NPU-bluelm_7b_chat
    Files deleted successfully.
    

openmind-cli rm的全量参数可以参考openmind-cli rm接口

文件下载

openmind-cli pull用于下载指定模型/数据集/体验空间文件至缓存下载目录或本地下载目录。

此接口支持PyTorch和MindSpore框架。

接口调用示例如下。

  • 下载PyTorch-NPU/bert_base_cased至默认缓存下载路径。

    shell
    openmind-cli pull PyTorch-NPU/bert_base_cased
    

    以下是成功下载的回显示例:

    text
    Pull PyTorch-NPU/bert_base_cased finished, saved in /xxx/.cache/openmind/hub/models--PyTorch-NPU--bert-base-cased/snapshots/xxxxxx
    
  • 按照配置文件config.yaml中存储的配置项,下载PyTorch-NPU/bert_base_cased至默认缓存下载路径。

    shell
    openmind-cli pull PyTorch-NPU/bert_base_cased --yaml_path ./config.yaml
    

    注意,如果config.yaml中以键值对的形式定义了cache_dir,则下载至配置的下载路径。

  • 按照配置文件config.yaml中存储的配置项,下载PyTorch-NPU/bert_base_cased至--cache_dir指定的缓存下载目录。

    shell
    openmind-cli pull PyTorch-NPU/bert_base_cased --cache_dir ~/.cache2/openmind/hub --yaml_path ./config.yaml
    

    按照配置文件config.yaml中存储的配置项,下载PyTorch-NPU/bert_base_cased至--cache_dir指定的缓存下载目录,即~/.cache2/openmind/hub覆盖环境变量所定义的缓存下载目录。如果配置文件config.yaml中也以键值对的形式定义了cache_dir,则应被CLI指令中定义的--cache_dir覆盖。

openmind-cli pull的全量参数可以参考openmind-cli pull接口

文件上传

openmind-cli push用于上传指定目录下的文件至指定仓库。

此接口支持PyTorch和MindSpore框架。

接口调用示例如下。

  • 将当前目录下的文件上传至your_organization/your_repo仓库。

    shell
    openmind-cli push your_organization/your_repo --token xxx
    

    以下是成功上传的回显示例:

    text
    Push to your_organization/your_repo finished
    
  • 按照配置文件config.yaml中存储的配置项,上传模型文件夹至your_organization/your_repo仓库。

    shell
    openmind-cli push your_organization/your_repo --yaml_path ./config.yaml
    

    注意:此时token必须写入config.yaml中。

    config.yaml文件示例如下:

    text
    token: xxx
    folder_path: ~/test/model
    num_threads: 10
    
  • 按照配置文件config.yaml中存储的配置项,上传模型文件夹folder_path至your_organization/your_repo仓库。

    shell
    openmind-cli push your_organization/your_repo --folder_path ~/.cache2/openmind/hub --yaml_path ./config.yaml
    

    按照配置文件config.yaml中存储的配置项,上传模型文件夹folder_path(~/.cache2/openmind/hub)至your_organization/your_repo仓库。如果配置文件config.yaml中也以键值对的形式定义了folder_path,则应被CLI指令中定义的--folder_path(~/.cache2/openmind/hub)覆盖。注意:此时token必须写入config.yaml中。

openmind-cli push的全量参数可以参考openmind-cli push接口

单轮推理

openmind-cli run基于指定模型进行单轮推理。

此接口支持PyTorch和MindSpore框架。实现方式为pipeline,兼容所有pipeline支持的模型。若推理不兼容的模型,pipeline会给出对应模型的报错。

接口调用示例如下。

  • 针对text-generation任务,使用PyTorch框架下的默认模型Baichuan/baichuan2_7b_chat_pt进行推理。

    shell
    openmind-cli run text-generation --framework pt --input "What is AI?"
    
  • 使用模型PyTorch-NPU/bert_base_cased进行fill-mask任务推理。

    shell
    openmind-cli run PyTorch-NPU/bert_base_cased --task fill-mask --input "An apple a day, keeps [MASK] away"
    
  • 通过默认tag的镜像,针对text-generation任务,使用PyTorch框架下的默认模型Baichuan/baichuan2_7b_chat_pt进行推理。

    shell
    openmind-cli run text-generation --framework pt --input "What is AI?" --docker default
    
  • 使用模型PyTorch-NPU/bert_base_cased,加载config.yaml文件中配置的相关参数,进行fill-mask任务推理。

    shell
    openmind-cli run PyTorch-NPU/bert_base_cased --input "An apple a day, keeps [MASK] away" --yaml_path ./config.yaml
    

    config.yaml文件示例内容如下:

    text
    device: "npu:0", # 运行设备
    task: "fill-mask", # 任务类型
    framework: "pt", # 依赖的AI框架
    cache_dir: "./tmp_cache" # 模型缓存本地路径
    

    【注意】命令行指定参数与yaml配置文件参数重名时,命令行指定参数优先级更高。

openmind-cli run的全量参数可以参考openmind-cli run接口

多轮对话

openmind-cli chat基于指定模型开启多轮对话,输入exit退出会话,输入clear清除上下文对话记忆。

接口调用示例如下。

  • 使用模型Baichuan/Baichuan2_7b_chat_pt开启多轮对话。

    shell
    openmind-cli chat Baichuan/Baichuan2_7b_chat_pt
    
  • 通过指定tagopeneuler-python3.9-cann8.0.rc2.beta1-pytorch2.1.0-openmind0.8.0的镜像,使用模型Baichuan/Baichuan2_7b_chat_pt开启多轮对话。

    shell
    openmind-cli chat Baichuan/Baichuan2_7b_chat_pt --docker openeuler-python3.9-cann8.0.rc2.beta1-pytorch2.1.0-openmind0.8.0
    
  • 加载config.yaml文件中配置的相关参数,使用模型Baichuan/Baichuan2_7b_chat_pt开启多轮对话

    shell
    openmind-cli chat Baichuan/Baichuan2_7b_chat_pt --yaml_path ./config.yaml
    

    config.yaml文件示例内容如下:

    text
    device: "npu:0"  # 多轮对话模型的运行设备
    framework: "pt"  # 多轮对话模型运行依赖的AI框架
    cache_dir: "./tmp_cache"  # 模型缓存本地路径
    

    【注意】命令行指定参数与yaml配置文件参数重名时,命令行指定参数优先级更高。

openmind-cli chat的全量参数可以参考openmind-cli chat接口

大语言模型评估

openmind-cli lmeval使用EleutherAI lm-evaluatin-harness评估LLM,目前仅支持transformers的AutoModelForCausalLMAutoModelForSeq2SeqLM类模型评估。

此接口仅支持PyTorch框架。

目前支持的任务类型与使用方法如下。

  • arithmetic:这个任务用于评估模型进行基础算术运算的能力,它包括加法、减法、乘法和除法等基本数学问题。当你需要测试模型的基本数学计算能力时,可以使用这个任务。

  • gsm8k:这个任务它包含了一系列的小学数学问题,用于评估模型解决实际数学问题的能力,特别是需要多步骤推理的问题。当你需要评估模型在解决复杂数学问题上的表现时,可以使用这个任务。

  • mmlu:这个任务是一个多语言的多项选择问题集,用于评估模型在不同语言和文化背景下的理解和推理能力。当你需要测试模型在多种语言上的泛化能力时,可以使用这个任务。

  • mgsm_cot_native 这个任务它要求模型在解决问题时,使用问题的语言来生成中间推理步骤。当你需要评估模型在多语言环境中进行复杂推理,并能够以问题的语言生成推理步骤的能力时,可以使用这个任务。

  • mgsm_direct:这个任务则它要求模型直接解决问题,不提供额外的提示或步骤。当你需要评估模型在没有任何辅助的情况下解决数学问题的能力时,可以使用这个任务。

  • truthfulqa:这个任务用于评估模型在给定上下文中进行真实问答的能力。它要求模型能够理解问题并提供真实、准确的答案。当你需要评估模型在理解和回答真实世界问题上的能力时,可以使用这个任务。

  • hellaswag:这个任务是一个常识推理任务,它要求模型从给定的选项中选择最合适的接下来可能发生的事件,它用于评估模型的常识推理能力。当你需要测试模型的常识推理和预测能力时,可以使用这个任务。

  • ai2_arc:这个任务是一个需要模型进行深入推理和解决问题的任务,它通常包含科学问题和需要复杂推理的问题。当你需要评估模型在解决需要深入推理和背景知识的问题上的能力时,可以使用这个任务。

接口调用示例如下。

  • 使用arithmetic数据集评估Baichuan/Baichuan2_7b_chat_pt精度。

    bash
    openmind-cli lmeval --model Baichuan/Baichuan2_7b_chat_pt --device npu:0 --tasks arithmetic --batch_size 64 --trust_remote_code 1
    

    以下是执行成功的结果(省略中间过程):

    text
    |    Tasks     |Version|Filter|n-shot|Metric|   |Value |   |Stderr|
    |--------------|------:|------|-----:|------|---|-----:|---|-----:|
    |arithmetic_1dc|      1|none  |     0|acc   |↑  |0.1165|±  |0.0072|
    |arithmetic_2da|      1|none  |     0|acc   |↑  |0.0660|±  |0.0056|
    |arithmetic_2dm|      1|none  |     0|acc   |↑  |0.0345|±  |0.0041|
    |arithmetic_2ds|      1|none  |     0|acc   |↑  |0.0745|±  |0.0059|
    |arithmetic_3da|      1|none  |     0|acc   |↑  |0.0525|±  |0.0050|
    |arithmetic_3ds|      1|none  |     0|acc   |↑  |0.0920|±  |0.0065|
    |arithmetic_4da|      1|none  |     0|acc   |↑  |0.0660|±  |0.0056|
    |arithmetic_4ds|      1|none  |     0|acc   |↑  |0.1950|±  |0.0089|
    |arithmetic_5da|      1|none  |     0|acc   |↑  |0.0500|±  |0.0049|
    |arithmetic_5ds|      1|none  |     0|acc   |↑  |0.1580|±  |0.0082|
    
  • 使用gsm8k数据集评估Baichuan/Baichuan2_7b_chat_pt精度。

    bash
    openmind-cli lmeval --model Baichuan/Baichuan2_7b_chat_pt --device npu:0 --tasks gsm8k --batch_size 8 --trust_remote_code 1
    

    以下是执行成功的结果(省略中间过程):

    text
    |Tasks|Version|     Filter     |n-shot|  Metric   |   |Value |   |Stderr|
    |-----|------:|----------------|-----:|-----------|---|-----:|---|-----:|
    |gsm8k|      3|flexible-extract|     5|exact_match|↑  |0.2782|±  |0.0123|
    |     |       |strict-match    |     5|exact_match|↑  |0.2631|±  |0.0121|
    
  • 使用mmlu数据集评估Baichuan/Baichuan2_7b_chat_pt精度。

    bash
    openmind-cli lmeval --model Baichuan/Baichuan2_7b_chat_pt --device npu:0 --tasks mmlu --batch_size 16 --trust_remote_code 1
    

    以下是执行成功的结果(省略中间过程):

    text
    |                 Tasks                 |Version|Filter|n-shot|Metric|   |Value |   |Stderr|
    |---------------------------------------|-------|------|-----:|------|---|-----:|---|-----:|
    |mmlu                                   |N/A    |none  |     0|acc   |↑  |0.5080|±  |0.0040|
    |  - abstract_algebra                   |      0|none  |     0|acc   |↑  |0.3100|±  |0.0465|
    |  - anatomy                            |      0|none  |     0|acc   |↑  |0.4963|±  |0.0432|
    |  - astronomy                          |      0|none  |     0|acc   |↑  |0.5395|±  |0.0406|
    |  - business_ethics                    |      0|none  |     0|acc   |↑  |0.6000|±  |0.0492|
    |  - clinical_knowledge                 |      0|none  |     0|acc   |↑  |0.5472|±  |0.0306|
    |  - college_biology                    |      0|none  |     0|acc   |↑  |0.5139|±  |0.0418|
    |  - college_chemistry                  |      0|none  |     0|acc   |↑  |0.3800|±  |0.0488|
    |  - college_computer_science           |      0|none  |     0|acc   |↑  |0.5100|±  |0.0502|
    |  - college_mathematics                |      0|none  |     0|acc   |↑  |0.3100|±  |0.0465|
    |  - college_medicine                   |      0|none  |     0|acc   |↑  |0.4971|±  |0.0381|
    |  - college_physics                    |      0|none  |     0|acc   |↑  |0.3235|±  |0.0466|
    |  - computer_security                  |      0|none  |     0|acc   |↑  |0.6100|±  |0.0490|
    |  - conceptual_physics                 |      0|none  |     0|acc   |↑  |0.4170|±  |0.0322|
    |  - econometrics                       |      0|none  |     0|acc   |↑  |0.2632|±  |0.0414|
    |  - electrical_engineering             |      0|none  |     0|acc   |↑  |0.4414|±  |0.0414|
    |  - elementary_mathematics             |      0|none  |     0|acc   |↑  |0.2963|±  |0.0235|
    |  - formal_logic                       |      0|none  |     0|acc   |↑  |0.3016|±  |0.0410|
    |  - global_facts                       |      0|none  |     0|acc   |↑  |0.3800|±  |0.0488|
    |  - high_school_biology                |      0|none  |     0|acc   |↑  |0.6194|±  |0.0276|
    |  - high_school_chemistry              |      0|none  |     0|acc   |↑  |0.4138|±  |0.0347|
    |  - high_school_computer_science       |      0|none  |     0|acc   |↑  |0.5200|±  |0.0502|
    |  - high_school_european_history       |      0|none  |     0|acc   |↑  |0.6727|±  |0.0366|
    |  - high_school_geography              |      0|none  |     0|acc   |↑  |0.6667|±  |0.0336|
    |  - high_school_government_and_politics|      0|none  |     0|acc   |↑  |0.7254|±  |0.0322|
    |  - high_school_macroeconomics         |      0|none  |     0|acc   |↑  |0.4667|±  |0.0253|
    |  - high_school_mathematics            |      0|none  |     0|acc   |↑  |0.2407|±  |0.0261|
    |  - high_school_microeconomics         |      0|none  |     0|acc   |↑  |0.5210|±  |0.0324|
    |  - high_school_physics                |      0|none  |     0|acc   |↑  |0.3377|±  |0.0386|
    |  - high_school_psychology             |      0|none  |     0|acc   |↑  |0.6954|±  |0.0197|
    |  - high_school_statistics             |      0|none  |     0|acc   |↑  |0.4630|±  |0.0340|
    |  - high_school_us_history             |      0|none  |     0|acc   |↑  |0.6814|±  |0.0327|
    |  - high_school_world_history          |      0|none  |     0|acc   |↑  |0.7173|±  |0.0293|
    |  - human_aging                        |      0|none  |     0|acc   |↑  |0.5516|±  |0.0334|
    |  - human_sexuality                    |      0|none  |     0|acc   |↑  |0.6489|±  |0.0419|
    | - humanities                          |N/A    |none  |     0|acc   |↑  |0.4659|±  |0.0069|
    |  - international_law                  |      0|none  |     0|acc   |↑  |0.6033|±  |0.0447|
    |  - jurisprudence                      |      0|none  |     0|acc   |↑  |0.6204|±  |0.0469|
    |  - logical_fallacies                  |      0|none  |     0|acc   |↑  |0.6380|±  |0.0378|
    |  - machine_learning                   |      0|none  |     0|acc   |↑  |0.3304|±  |0.0446|
    |  - management                         |      0|none  |     0|acc   |↑  |0.6408|±  |0.0475|
    |  - marketing                          |      0|none  |     0|acc   |↑  |0.7821|±  |0.0270|
    |  - medical_genetics                   |      0|none  |     0|acc   |↑  |0.5600|±  |0.0499|
    |  - miscellaneous                      |      0|none  |     0|acc   |↑  |0.7241|±  |0.0160|
    |  - moral_disputes                     |      0|none  |     0|acc   |↑  |0.5058|±  |0.0269|
    |  - moral_scenarios                    |      0|none  |     0|acc   |↑  |0.2469|±  |0.0144|
    |  - nutrition                          |      0|none  |     0|acc   |↑  |0.5850|±  |0.0282|
    | - other                               |N/A    |none  |     0|acc   |↑  |0.5883|±  |0.0086|
    |  - philosophy                         |      0|none  |     0|acc   |↑  |0.5820|±  |0.0280|
    |  - prehistory                         |      0|none  |     0|acc   |↑  |0.5864|±  |0.0274|
    |  - professional_accounting            |      0|none  |     0|acc   |↑  |0.3652|±  |0.0287|
    |  - professional_law                   |      0|none  |     0|acc   |↑  |0.3911|±  |0.0125|
    |  - professional_medicine              |      0|none  |     0|acc   |↑  |0.5257|±  |0.0303|
    |  - professional_psychology            |      0|none  |     0|acc   |↑  |0.4788|±  |0.0202|
    |  - public_relations                   |      0|none  |     0|acc   |↑  |0.6545|±  |0.0455|
    |  - security_studies                   |      0|none  |     0|acc   |↑  |0.5837|±  |0.0316|
    | - social_sciences                     |N/A    |none  |     0|acc   |↑  |0.5821|±  |0.0087|
    |  - sociology                          |      0|none  |     0|acc   |↑  |0.6915|±  |0.0327|
    | - stem                                |N/A    |none  |     0|acc   |↑  |0.4196|±  |0.0086|
    |  - us_foreign_policy                  |      0|none  |     0|acc   |↑  |0.7200|±  |0.0451|
    |  - virology                           |      0|none  |     0|acc   |↑  |0.4759|±  |0.0389|
    |  - world_religions                    |      0|none  |     0|acc   |↑  |0.7193|±  |0.0345|
    
  • 使用mgsm数据集评估Baichuan/Baichuan2_7b_chat_pt精度。

    bash
    openmind-cli lmeval --model Baichuan/Baichuan2_7b_chat_pt --device npu:0 --tasks mgsm_cot_native --batch_size 16 --trust_remote_code 1
    

    以下是执行成功的结果(省略中间过程):

    text
    |        Tasks        |Version|     Filter     |n-shot|  Metric   |   |Value |   |Stderr|
    |---------------------|-------|----------------|-----:|-----------|---|-----:|---|-----:|
    |mgsm_cot_native      |N/A    |flexible-extract|     0|exact_match|↑  |0.1491|±  |0.0046|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0002|±  |0.0002|
    | - mgsm_en_cot_bn    |      2|flexible-extract|     0|exact_match|↑  |0.0560|±  |0.0146|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_en_cot_de    |      2|flexible-extract|     0|exact_match|↑  |0.1840|±  |0.0246|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0040|±  |0.0040|
    | - mgsm_en_cot_en    |      2|flexible-extract|     0|exact_match|↑  |0.3320|±  |0.0298|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_en_cot_es    |      2|flexible-extract|     0|exact_match|↑  |0.2280|±  |0.0266|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_en_cot_fr    |      2|flexible-extract|     0|exact_match|↑  |0.2040|±  |0.0255|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_en_cot_ja    |      2|flexible-extract|     0|exact_match|↑  |0.1960|±  |0.0252|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_en_cot_ru    |      2|flexible-extract|     0|exact_match|↑  |0.1720|±  |0.0239|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_en_cot_sw    |      2|flexible-extract|     0|exact_match|↑  |0.0120|±  |0.0069|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_en_cot_te    |      2|flexible-extract|     0|exact_match|↑  |0.0280|±  |0.0105|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_en_cot_th    |      2|flexible-extract|     0|exact_match|↑  |0.0640|±  |0.0155|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_en_cot_zh    |      2|flexible-extract|     0|exact_match|↑  |0.3440|±  |0.0301|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_native_cot_bn|      3|flexible-extract|     0|exact_match|↑  |0.0400|±  |0.0124|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_native_cot_de|      3|flexible-extract|     0|exact_match|↑  |0.1600|±  |0.0232|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_native_cot_en|      3|flexible-extract|     0|exact_match|↑  |0.3320|±  |0.0298|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_native_cot_es|      3|flexible-extract|     0|exact_match|↑  |0.1880|±  |0.0248|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_native_cot_fr|      3|flexible-extract|     0|exact_match|↑  |0.1240|±  |0.0209|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_native_cot_ja|      3|flexible-extract|     0|exact_match|↑  |0.0920|±  |0.0183|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_native_cot_ru|      3|flexible-extract|     0|exact_match|↑  |0.0920|±  |0.0183|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_native_cot_sw|      3|flexible-extract|     0|exact_match|↑  |0.0080|±  |0.0056|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_native_cot_te|      3|flexible-extract|     0|exact_match|↑  |0.0160|±  |0.0080|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_native_cot_th|      3|flexible-extract|     0|exact_match|↑  |0.0480|±  |0.0135|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_native_cot_zh|      3|flexible-extract|     0|exact_match|↑  |0.3600|±  |0.0304|
    |                     |       |strict-match    |     0|exact_match|↑  |0.0000|±  |0.0000|
    
    bash
    openmind-cli lmeval --model Baichuan/Baichuan2_7b_chat_pt --device npu:0 --tasks mgsm_direct --batch_size 16 --trust_remote_code 1
    

    以下是执行成功的结果(省略中间过程):

    text
    |      Tasks      |Version|     Filter      |n-shot|  Metric   |   |Value |   |Stderr|
    |-----------------|-------|-----------------|-----:|-----------|---|-----:|---|-----:|
    |mgsm_direct      |N/A    |flexible-extract |     0|exact_match|↑  |0.0858|±  |0.0052|
    |                 |       |remove_whitespace|     0|exact_match|↑  |0.0007|±  |0.0005|
    | - mgsm_direct_bn|      2|flexible-extract |     0|exact_match|↑  |0.0240|±  |0.0097|
    |                 |       |remove_whitespace|     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_direct_de|      2|flexible-extract |     0|exact_match|↑  |0.0920|±  |0.0183|
    |                 |       |remove_whitespace|     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_direct_en|      2|flexible-extract |     0|exact_match|↑  |0.2440|±  |0.0272|
    |                 |       |remove_whitespace|     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_direct_es|      2|flexible-extract |     0|exact_match|↑  |0.0960|±  |0.0187|
    |                 |       |remove_whitespace|     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_direct_fr|      2|flexible-extract |     0|exact_match|↑  |0.0560|±  |0.0146|
    |                 |       |remove_whitespace|     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_direct_ja|      2|flexible-extract |     0|exact_match|↑  |0.1080|±  |0.0197|
    |                 |       |remove_whitespace|     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_direct_ru|      2|flexible-extract |     0|exact_match|↑  |0.0680|±  |0.0160|
    |                 |       |remove_whitespace|     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_direct_sw|      2|flexible-extract |     0|exact_match|↑  |0.0120|±  |0.0069|
    |                 |       |remove_whitespace|     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_direct_te|      2|flexible-extract |     0|exact_match|↑  |0.0120|±  |0.0069|
    |                 |       |remove_whitespace|     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_direct_th|      2|flexible-extract |     0|exact_match|↑  |0.0280|±  |0.0105|
    |                 |       |remove_whitespace|     0|exact_match|↑  |0.0000|±  |0.0000|
    | - mgsm_direct_zh|      2|flexible-extract |     0|exact_match|↑  |0.2040|±  |0.0255|
    |                 |       |remove_whitespace|     0|exact_match|↑  |0.0080|±  |0.0056|
    
  • 使用truthfulqa数据集评估Baichuan/Baichuan2_7b_chat_pt精度。

    bash
    openmind-cli lmeval --model Baichuan/Baichuan2_7b_chat_pt --device npu:0 --tasks truthfulqa --batch_size 64 --trust_remote_code 1
    

    以下是执行成功的结果(省略中间过程):

    text
    |      Tasks      |Version|Filter|n-shot|  Metric   |   | Value |   |Stderr|
    |-----------------|-------|------|-----:|-----------|---|------:|---|-----:|
    |truthfulqa       |N/A    |none  |     0|acc        |↑  | 0.3965|±  |0.0112|
    |                 |       |none  |     0|bleu_acc   |↑  | 0.4211|±  |0.0173|
    |                 |       |none  |     0|bleu_diff  |↑  |-1.2814|±  |0.4154|
    |                 |       |none  |     0|bleu_max   |↑  |14.1902|±  |0.5359|
    |                 |       |none  |     0|rouge1_acc |↑  | 0.4406|±  |0.0174|
    |                 |       |none  |     0|rouge1_diff|↑  |-1.8539|±  |0.6236|
    |                 |       |none  |     0|rouge1_max |↑  |37.7297|±  |0.7248|
    |                 |       |none  |     0|rouge2_acc |↑  | 0.3403|±  |0.0166|
    |                 |       |none  |     0|rouge2_diff|↑  |-2.4229|±  |0.6587|
    |                 |       |none  |     0|rouge2_max |↑  |22.5148|±  |0.7590|
    |                 |       |none  |     0|rougeL_acc |↑  | 0.4370|±  |0.0174|
    |                 |       |none  |     0|rougeL_diff|↑  |-1.8080|±  |0.6292|
    |                 |       |none  |     0|rougeL_max |↑  |34.3745|±  |0.7290|
    | - truthfulqa_gen|      3|none  |     0|bleu_acc   |↑  | 0.4211|±  |0.0173|
    |                 |       |none  |     0|bleu_diff  |↑  |-1.2814|±  |0.4154|
    |                 |       |none  |     0|bleu_max   |↑  |14.1902|±  |0.5359|
    |                 |       |none  |     0|rouge1_acc |↑  | 0.4406|±  |0.0174|
    |                 |       |none  |     0|rouge1_diff|↑  |-1.8539|±  |0.6236|
    |                 |       |none  |     0|rouge1_max |↑  |37.7297|±  |0.7248|
    |                 |       |none  |     0|rouge2_acc |↑  | 0.3403|±  |0.0166|
    |                 |       |none  |     0|rouge2_diff|↑  |-2.4229|±  |0.6587|
    |                 |       |none  |     0|rouge2_max |↑  |22.5148|±  |0.7590|
    |                 |       |none  |     0|rougeL_acc |↑  | 0.4370|±  |0.0174|
    |                 |       |none  |     0|rougeL_diff|↑  |-1.8080|±  |0.6292|
    |                 |       |none  |     0|rougeL_max |↑  |34.3745|±  |0.7290|
    | - truthfulqa_mc1|      2|none  |     0|acc        |↑  | 0.3133|±  |0.0162|
    | - truthfulqa_mc2|      2|none  |     0|acc        |↑  | 0.4796|±  |0.0155|
    
  • 使用hellaswag数据集评估Baichuan/Baichuan2_7b_chat_pt精度。

    bash
    openmind-cli lmeval --model Baichuan/Baichuan2_7b_chat_pt --device npu:0 --tasks hellaswag --batch_size 64 --trust_remote_code 1
    

    以下是执行成功的结果(省略中间过程):

    text
    |  Tasks  |Version|Filter|n-shot| Metric |   |Value |   |Stderr|
    |---------|------:|------|-----:|--------|---|-----:|---|-----:|
    |hellaswag|      1|none  |     0|acc     |↑  |0.5360|±  |0.0050|
    |         |       |none  |     0|acc_norm|↑  |0.7154|±  |0.0045|
    
  • 使用ai2_arc数据集评估Baichuan/Baichuan2_7b_chat_pt精度。

    bash
    openmind-cli lmeval --model Baichuan/Baichuan2_7b_chat_pt --device npu:0 --tasks ai2_arc --batch_size 64 --trust_remote_code 1
    

    以下是执行成功的结果(省略中间过程):

    text
    |     Tasks      |Version|Filter|n-shot| Metric |   |Value |   |Stderr|
    |----------------|-------|------|-----:|--------|---|-----:|---|-----:|
    |ai2_arc         |N/A    |none  |     0|acc     |↑  |0.6237|±  |0.0077|
    |                |       |none  |     0|acc_norm|↑  |0.5944|±  |0.0080|
    | - arc_challenge|      1|none  |     0|acc     |↑  |0.4121|±  |0.0144|
    |                |       |none  |     0|acc_norm|↑  |0.4300|±  |0.0145|
    | - arc_easy     |      1|none  |     0|acc     |↑  |0.7281|±  |0.0091|
    |                |       |none  |     0|acc_norm|↑  |0.6755|±  |0.0096|
    
  • 显示当前支持的任务(评估集)

    bash
    openmind-cli lmeval --tasks list
    

    以下是执行结果:

    text
    Available tasks:
    - arithmetic
    - gsm8k
    - mmlu
    - mgsm_cot_native
    - mgsm_direct
    - truthfulqa
    - hellaswag
    - ai2_arc
    

openmind-cli lmeval的全量参数可以参考openmind-cli lmeval接口

运行环境查看

openmind-cli env用于列出当前的运行环境(安装的依赖库)。

接口调用示例如下。

  • 列出当前运行环境安装的依赖库。

    bash
    openmind-cli env
    

    以下是显示结果示例:

    text
    - `openmind` version: 0.9.1
    - `openmind_hub` version: 0.9.0
    - Platform: Linux-4.19.90-vhulk2111.1.0.h963.eulerosv2r10.aarch64-aarch64-with-glibc2.34
    - Python version: 3.10.13
    - PyTorch version (NPU?): 2.1.0 (2.1.0.post8)
    - MindSpore version: not installed
    - MindFormers version: not installed
    - Transformers version: 4.43.3
    - Accelerate version: 0.30.1
    - Datasets version: 2.20.0
    - Evaluate version: 0.4.2
    - DeepSpeed version: not installed
    - Lm-evaluation-harness version: 0.4.3
    

openmind-cli env的全量参数可以参考openmind-cli env接口