书生白嫖A100活动之——OpenCompass

news2024/10/1 14:28:59

 

内容来源:Tutorial/opencompass/readme.md at camp2 · InternLM/Tutorial · GitHub

概览

在 OpenCompass 中评估一个模型通常包括以下几个阶段:配置 -> 推理 -> 评估 -> 可视化。

  • 配置:这是整个工作流的起点。您需要配置整个评估过程,选择要评估的模型和数据集。此外,还可以选择评估策略、计算后端等,并定义显示结果的方式。
  • 推理与评估:在这个阶段,OpenCompass 将会开始对模型和数据集进行并行推理和评估。推理阶段主要是让模型从数据集产生输出,而评估阶段则是衡量这些输出与标准答案的匹配程度。这两个过程会被拆分为多个同时运行的“任务”以提高效率,但请注意,如果计算资源有限,这种策略可能会使评测变得更慢。如果需要了解该问题及解决方案,可以参考 FAQ: 效率。
  • 可视化:评估完成后,OpenCompass 将结果整理成易读的表格,并将其保存为 CSV 和 TXT 文件。你也可以激活飞书状态上报功能,此后可以在飞书客户端中及时获得评测状态报告。 接下来,我们将展示 OpenCompass 的基础用法,展示书生浦语在 C-Eval 基准任务上的评估。它们的配置文件可以在 configs/eval_demo.py 中找到。

实战:

github下载,并按照包:

git clone -b 0.2.4 https://github.com/open-compass/opencompass
cd opencompass
pip install -e .

apt-get update
apt-get install cmake
pip install -r requirements.txt
pip install protobuf

复制测评数据集:

cp /share/temp/datasets/OpenCompassData-core-20231110.zip /root/opencompass/
unzip OpenCompassData-core-20231110.zip

查询可测评数据集:

python tools/list_configs.py internlm ceval

 类似于linux命令中的grep,在list_configs.py后面输入关键字。如果想查别的模型可以输入模型名称:

想查别的数据集可以直接输入数据集名称:

根据配置信息,开始测评:

看到: [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process... 就成功了

使用到6G左右的显存:

 测评结果:

terminal会显示,也会存储到指定文件夹下,并将位置打印出来

进阶任务:

1.主观评价:

教程:

https://opencompass.readthedocs.io/zh-cn/latest/advanced_guides/subjective_evaluation.html

下载数据集 AlignBench

修改数据格式:

 {

  "question": "高音单簧管和高音萨克斯的调性相同吗?如果相同,请说出他们的调性,如果不同,请分别说出他们的调性",

  "capability": "专业能力",

  "others": {

   "subcategory": "音乐",

   "reference": "高音单簧管和高音萨克斯的调性不同。高音单簧管的调性通常为E♭,而高音萨克斯的调性则为B♭。",

   "question_id": 1

  }

 },

 申请了火星大模型免费API,作为judge_models

控制台-讯飞开放平台

修改配置文件:

/root/opencompass/configs/datasets/subjective/alignbench/alignbench_judgeby_critiquellm.py

/root/opencompass/configs/eval_subjective_alignbench.py

from mmengine.config import read_base
from opencompass.models.xunfei_api import XunFei
from opencompass.models import HuggingFaceCausalLM
from opencompass.partitioners.sub_size import SubjectiveSizePartitioner
from opencompass.runners import LocalRunner
from opencompass.tasks.subjective_eval import SubjectiveEvalTask
from opencompass.summarizers import AlignmentBenchSummarizer

with read_base():
    from .datasets.subjective.alignbench.alignbench_judgeby_critiquellm import subjective_datasets
    from .datasets.subjective.alpaca_eval.alpacav2_judgeby_gpt4 import subjective_datasets as alpacav2
    from .models.qwen.hf_qwen_7b import models
    from .summarizers.subjective import summarizer
    from.models.hf_internlm.hf_internlm2_1_8b import models



api_meta_template = dict(
    round=[
        dict(role='HUMAN', api_role='HUMAN'),
        dict(role='BOT', api_role='BOT', generate=True),
    ]
)

# -------------Inference Stage ----------------------------------------
# For subjective evaluation, we often set do sample for models

models = [
    dict(
        type=HuggingFaceCausalLM,
        abbr='internlm2-chat-1.8b-hf',
        path="internlm/internlm2-chat-1_8b",
        tokenizer_path='internlm/internlm2-chat-1_8b',
        model_kwargs=dict(
            trust_remote_code=True,
            device_map='auto',
        ),
        tokenizer_kwargs=dict(
            padding_side='left',
            truncation_side='left',
            use_fast=False,
            trust_remote_code=True,
        ),
        max_out_len=2048,
        max_seq_len=4096,
        batch_size=8,
        meta_template=api_meta_template,
        run_cfg=dict(num_gpus=1, num_procs=1),
        # generation_kwargs = {"eos_token_id": [2, 92542]},
        generation_kwargs=dict(
             do_sample=True,
         ),
    )
]
# models = [
#     dict(
#         type=HuggingFaceChatGLM3,
#         abbr='chatglm3-6b-hf',
#         path='THUDM/chatglm3-6b',
#         tokenizer_path='THUDM/chatglm3-6b',
#         model_kwargs=dict(
#             device_map='auto',
#             trust_remote_code=True,
#         ),
#         tokenizer_kwargs=dict(
#             padding_side='left',
#             truncation_side='left',
#             trust_remote_code=True,
#         ),
#         generation_kwargs=dict(
#             do_sample=True,
#         ),
#         meta_template=api_meta_template,
#         max_out_len=2048,
#         max_seq_len=4096,
#         batch_size=8,
#         run_cfg=dict(num_gpus=1, num_procs=1),
#     )
# ]

datasets = [*subjective_datasets]

# -------------Evalation Stage ----------------------------------------

## ------------- JudgeLLM Configuration
judge_models = [
#     dict(
#     abbr='GPT4-Turbo',
#     type=OpenAI,
#     path='gpt-4-1106-preview',
#     key='xxxx',  # The key will be obtained from $OPENAI_API_KEY, but you can write down your key here as well
#     meta_template=api_meta_template,
#     query_per_second=16,
#     max_out_len=2048,
#     max_seq_len=2048,
#     batch_size=8,
#     temperature=0,
# )
    dict(
            abbr='Spark-v3-5',
            type=XunFei,
            appid="xxxxxxxxxxxxxxx",
            path='ws(s)://spark-api.xf-yun.com/v3.5/chat',
            api_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxx",
            api_key = "xxxxxxxxxxxxxxxxxxxxxx",
            query_per_second=1,
            max_out_len=2048,
            max_seq_len=2048,
            batch_size=8),
]

## ------------- Evaluation Configuration
eval = dict(
    partitioner=dict(
        type=SubjectiveSizePartitioner, max_task_size=1000, mode='singlescore', models=models, judge_models=judge_models,
    ),
    runner=dict(type=LocalRunner, max_num_workers=2, task=dict(type=SubjectiveEvalTask)),
)

summarizer = dict(type=AlignmentBenchSummarizer, judge_type='general')

work_dir = 'outputs/alignment_bench/'

结果:

output/config

alpacav2=[
    dict(abbr='alpaca_eval',
        eval_cfg=dict(
            evaluator=dict(
                prompt_template=dict(
                    template=dict(
                        begin=[
                            dict(fallback_role='HUMAN',
                                prompt='You are a highly efficient assistant, who evaluates and selects the best large language model (LLMs) based on the quality of their responses to a given instruction. This process will be used to create a leaderboard reflecting the most accurate and human-preferred answers.',
                                role='SYSTEM'),
                            ],
                        round=[
                            dict(prompt='\nI require a leaderboard for various large language models. I\'ll provide you with prompts given to these models and their corresponding outputs. Your task is to assess these responses, and select the model that produces the best output from a human perspective.\n\n## Instruction\n\n{\n    "instruction": "{question}",\n}\n\n## Model Outputs\n\nHere are the unordered outputs from the models. Each output is associated with a specific model, identified by a unique model identifier.\n\n{\n    {\n        "model_identifier": "m",\n        "output": "{prediction}"\n    },\n    {\n        "model_identifier": "M",\n        "output": "{prediction2}"\n    }\n}\n\n## Task\n\nEvaluate the models based on the quality and relevance of their outputs, and select the model that generated the best output. Answer by providing the model identifier of the best model. We will use your output as the name of the best model, so make sure your output only contains one of the following model identifiers and nothing else (no quotes, no spaces, no new lines, ...): m or M.\n\n## Best Model Identifier\n',
                                role='HUMAN'),
                            ]),
                    type='opencompass.openicl.icl_prompt_template.PromptTemplate'),
                type='opencompass.openicl.icl_evaluator.LMEvaluator'),
            pred_role='BOT'),
        infer_cfg=dict(
            inferencer=dict(
                max_out_len=4096,
                type='opencompass.openicl.icl_inferencer.GenInferencer'),
            prompt_template=dict(
                template=dict(
                    round=[
                        dict(prompt='{question}',
                            role='HUMAN'),
                        ]),
                type='opencompass.openicl.icl_prompt_template.PromptTemplate'),
            retriever=dict(
                type='opencompass.openicl.icl_retriever.ZeroRetriever')),
        name='alpaca_eval',
        path='./data/subjective/alpaca_eval',
        reader_cfg=dict(
            input_columns=[
                'question',
                ],
            output_column='judge'),
        type='opencompass.datasets.SubjectiveCmpDataset'),
    ]
api_meta_template=dict(
    round=[
        dict(api_role='HUMAN',
            role='HUMAN'),
        dict(api_role='BOT',
            generate=True,
            role='BOT'),
        ])
datasets=[
    dict(abbr='alignment_bench',
        alignment_bench_config_name='multi-dimension',
        alignment_bench_config_path='/root/opencompass/AlignBench/config',
        eval_cfg=dict(
            evaluator=dict(
                prompt_template=dict(
                    template=dict(
                        round=[
                            dict(prompt='{critiquellm_prefix}[助手的答案开始]\n{prediction}\n[助手的答案结束]\n',
                                role='HUMAN'),
                            ]),
                    type='opencompass.openicl.icl_prompt_template.PromptTemplate'),
                type='opencompass.openicl.icl_evaluator.LMEvaluator'),
            pred_role='BOT'),
        infer_cfg=dict(
            inferencer=dict(
                max_out_len=2048,
                type='opencompass.openicl.icl_inferencer.GenInferencer'),
            prompt_template=dict(
                template=dict(
                    round=[
                        dict(prompt='{question}',
                            role='HUMAN'),
                        ]),
                type='opencompass.openicl.icl_prompt_template.PromptTemplate'),
            retriever=dict(
                type='opencompass.openicl.icl_retriever.ZeroRetriever')),
        name='alignment_bench',
        path='/root/opencompass/AlignBench/data',
        reader_cfg=dict(
            input_columns=[
                'question',
                'capability',
                'critiquellm_prefix',
                ],
            output_column='judge'),
        type='opencompass.datasets.AlignmentBenchDataset'),
    ]
eval=dict(
    partitioner=dict(
        judge_models=[
            dict(abbr='Spark-v3-5',
                api_key='xxxxxxxxxxxxxxxxxx',
                api_secret='xxxxxxxxxxxxxxxxx',
                appid='xxxxxxxxxxx',
                batch_size=8,
                max_out_len=2048,
                max_seq_len=2048,
                path='ws(s)://spark-api.xf-yun.com/v3.5/chat',
                query_per_second=1,
                type='opencompass.models.xunfei_api.XunFei'),
            ],
        max_task_size=1000,
        mode='singlescore',
        models=[
            dict(abbr='internlm2-chat-1.8b-hf',
                batch_size=8,
                generation_kwargs=dict(
                    do_sample=True),
                max_out_len=2048,
                max_seq_len=4096,
                meta_template=dict(
                    round=[
                        dict(api_role='HUMAN',
                            role='HUMAN'),
                        dict(api_role='BOT',
                            generate=True,
                            role='BOT'),
                        ]),
                model_kwargs=dict(
                    device_map='auto',
                    trust_remote_code=True),
                path='internlm/internlm2-chat-1_8b',
                run_cfg=dict(
                    num_gpus=1,
                    num_procs=1),
                tokenizer_kwargs=dict(
                    padding_side='left',
                    truncation_side='left',
                    trust_remote_code=True,
                    use_fast=False),
                tokenizer_path='internlm/internlm2-chat-1_8b',
                type='opencompass.models.HuggingFaceCausalLM'),
            ],
        type='opencompass.partitioners.sub_size.SubjectiveSizePartitioner'),
    runner=dict(
        max_num_workers=2,
        task=dict(
            type='opencompass.tasks.subjective_eval.SubjectiveEvalTask'),
        type='opencompass.runners.LocalRunner'))
judge_models=[
    dict(abbr='Spark-v3-5',
        api_key='9c7849c19377c2748db367a289458fbe',
        api_secret='MTgyZGYyNjI3OWE3MzlhMzE4MmQ4N2Jh',
        appid='bec61d4e',
        batch_size=8,
        max_out_len=2048,
        max_seq_len=2048,
        path='ws(s)://spark-api.xf-yun.com/v3.5/chat',
        query_per_second=1,
        type='opencompass.models.xunfei_api.XunFei'),
    ]
models=[
    dict(abbr='internlm2-chat-1.8b-hf',
        batch_size=8,
        generation_kwargs=dict(
            do_sample=True),
        max_out_len=2048,
        max_seq_len=4096,
        meta_template=dict(
            round=[
                dict(api_role='HUMAN',
                    role='HUMAN'),
                dict(api_role='BOT',
                    generate=True,
                    role='BOT'),
                ]),
        model_kwargs=dict(
            device_map='auto',
            trust_remote_code=True),
        path='internlm/internlm2-chat-1_8b',
        run_cfg=dict(
            num_gpus=1,
            num_procs=1),
        tokenizer_kwargs=dict(
            padding_side='left',
            truncation_side='left',
            trust_remote_code=True,
            use_fast=False),
        tokenizer_path='internlm/internlm2-chat-1_8b',
        type='opencompass.models.HuggingFaceCausalLM'),
    ]
subjective_datasets=[
    dict(abbr='alignment_bench',
        alignment_bench_config_name='multi-dimension',
        alignment_bench_config_path='/root/opencompass/AlignBench/config',
        eval_cfg=dict(
            evaluator=dict(
                prompt_template=dict(
                    template=dict(
                        round=[
                            dict(prompt='{critiquellm_prefix}[助手的答案开始]\n{prediction}\n[助手的答案结束]\n',
                                role='HUMAN'),
                            ]),
                    type='opencompass.openicl.icl_prompt_template.PromptTemplate'),
                type='opencompass.openicl.icl_evaluator.LMEvaluator'),
            pred_role='BOT'),
        infer_cfg=dict(
            inferencer=dict(
                max_out_len=2048,
                type='opencompass.openicl.icl_inferencer.GenInferencer'),
            prompt_template=dict(
                template=dict(
                    round=[
                        dict(prompt='{question}',
                            role='HUMAN'),
                        ]),
                type='opencompass.openicl.icl_prompt_template.PromptTemplate'),
            retriever=dict(
                type='opencompass.openicl.icl_retriever.ZeroRetriever')),
        name='alignment_bench',
        path='/root/opencompass/AlignBench/data',
        reader_cfg=dict(
            input_columns=[
                'question',
                'capability',
                'critiquellm_prefix',
                ],
            output_column='judge'),
        type='opencompass.datasets.AlignmentBenchDataset'),
    ]
summarizer=dict(
    judge_type='autoj',
    type='opencompass.summarizers.AlignmentBenchSummarizer')
work_dir='outputs/alignment_bench/20240926_062247'

log:

/root/opencompass/outputs/alignment_bench/20240926_062247/logs/eval/internlm2-chat-1.8b-hf/alignment_bench_13.out

/bin/sh: 1: 0: not found

找不到BUG在哪...

2.使用 OpenCompass 评测 InternLM2-Chat-1.8B 模型使用 LMDeploy部署后在 ceval 数据集上的性能(选做)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2166361.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

HTML中的表单(超详细)

一、表单 1.语法 <!-- action&#xff1a;提交的地方 method&#xff1a;提交的方式&#xff08;get会显示&#xff0c;post不会&#xff09; --> <form action"#" method"get"><p>名字&#xff1a;<input name"name" ty…

【Geoserver使用】SRS处理选项

文章目录 前言一、Geoserver的三种SRS处理二、对Bounding Boxes计算的影响总结 前言 今天来看看Geoserver中发布图层时的坐标参考处理这一项。根据Geoserver官方文档&#xff0c;坐标参考系统 (CRS) 定义了地理参考空间数据与地球表面实际位置的关系。CRS 是更通用的模型&…

3. 轴指令(omron 机器自动化控制器)——>MC_MoveFeed

机器自动化控制器——第三章 轴指令 8 MC_MoveFeed变量▶输入变量▶输出变量▶输入输出变量 功能说明▶指令详情▶时序图▶重启运动指令▶多重启动运动指令▶异常 示例程序▶参数设定▶动作示例▶梯形图▶结构文本(ST) MC_MoveFeed 指定自外部输入的中断输入发生位置起的移动距…

2024免费录屏软件的宝藏功能与实用技巧

在手机上操作很多时候为了记录方便都直接截图或者录屏&#xff0c;其实电脑也一样。现在面向电脑的录屏工具纷繁复杂&#xff0c;很容易让我们挑花了眼。今天这篇文章我将介绍几款免费的录屏软件为大家提供参考。 1.福昕录屏大师 链接达达&#xff1a;www.foxitsoftware.cn/R…

深入探索 RUM 与全链路追踪:优化数字体验的利器

作者&#xff1a;梅光辉&#xff08;重彦&#xff09; 背景介绍 随着可观测技术的持续演进&#xff0c;多数企业已广泛采用 APM、Tracing 及 Logging 解决方案&#xff0c;以此强化业务监控能力&#xff0c;尤其在互联网行业&#xff0c;产品的体验直接关系着用户的口碑&…

使用Crawler实例进行网页内容抓取

网页内容抓取的背景 随着互联网的快速发展&#xff0c;网页上的信息量日益庞大。如何从海量的网页中快速、准确地抓取所需信息&#xff0c;成为了一个技术挑战。网页内容抓取技术通过自动化的方式&#xff0c;模拟用户浏览网页的过程&#xff0c;获取网页上的文本、图片、链接…

mybatisplus介绍以及使用(上)

目录 一、概念 1、什么是mybatisplus 2、为什么要使用mybatisplus 二、mybatisplus的使用 1、安装 2、常用注解 3、条件构造器 一、概念 1、什么是mybatisplus MyBatis-Plus&#xff08;简称MP&#xff09;是一个基于MyBatis的增强框架&#xff0c;旨在简化开发、提高…

学习C语言(20)

在这段没有更新的时间作者大一开学了&#xff0c;军训期间一直比较忙没时间学习&#xff0c;9月23号结束了为期十四天的军训&#xff0c;今天开始重新更学习C语言的博客 整理今天的学习内容 1.浮点数在内存中的储存 浮点数包括float&#xff0c;double&#xff0c;long doub…

vue实现左侧数据拖拽到右侧区域,且左侧数据保留且左侧数据不能互相拖拽改变顺序

一、案例效果 二、案例代码 封装左侧抽屉 DrawerSearch.vue <template><div><mtd-form :model"formDrawerSearch" ref"formCustom" inline><mtd-form-item><mtd-inputtype"text"v-model"formDrawerSearch.hos…

美团一面:给定两棵二叉树 `A` 和 `B`,判断 `B` 是否是 `A` 的子结构?

目录标题 问题描述思路分析代码解释详细步骤复杂度分析 问题描述 给定两棵二叉树 A 和 B&#xff0c;判断 B 是否是 A 的子结构。所谓子结构是指 B 中任意节点在 A 中存在相同的结构和节点值。 例子1&#xff1a; 输入&#xff1a;tree1 [1,7,5], tree2 [6,1] 输出&#…

LeaferJS 动画、状态、过渡、游戏框架

LeaferJS 现阶段依然专注于绘图、交互和图形编辑场景。我们引入游戏场景&#xff0c;只是希望让 LeaferJS 被更多有需要的人看到&#xff0c;以充分发挥它的价值 LeaferJS 为你带来了全新的游戏、动画、状态和过渡功能&#xff0c;助你实现那些年少时的游戏梦想。我们引入了丰富…

NVIDIA TAO 工具套件5.3.0学习介绍及操作-01

什么是 NVIDIA TAO 工具套件&#xff1f; NVIDIA TAO 工具套件基于 TensorFlow 和 PyTorch 构建&#xff0c;是 NVIDIA TAO 框架的低代码版本&#xff0c;通过抽象出 AI/深度学习框架的复杂性来加速模型训练过程。TAO 工具套件让您利用迁移学习的强大功能和自己的数据对预训练 …

Remotion:使用前端技术开发视频

前言 最近做文章突然想到很多文章其实也可以用视频的方式来展现&#xff0c;以现在短视频的火爆程度&#xff0c;肯定能让更多的人看到。 恰巧最近看了很多关于动画的前端 js 库&#xff0c;那如果将这些动画帧连续起来&#xff0c;岂不是就成了一个视频吗&#xff1f; 而且…

集成Elasticsearch到django restful

文章目录 集成ES到django restful服务端项目安装haystack基本使用安装配置索引模型ORM模型中新增discount_json字段方法全文索引字段模板 索引序列化器全文搜索的索引视图路由手动构建es索引 集成ES到django restful服务端项目 如果直接在Django项目直接编写代码作为ElasticSe…

YOLOv5白皮书-第Y2周:训练自己的数据集(云jupyter运行版 )

>- **&#x1f368; 本文为[&#x1f517;365天深度学习训练营](小团体&#xff5e;第八波) 中的学习记录博客** >- **&#x1f356; 原作者&#xff1a;[K同学啊](K同学啊-CSDN博客)** 目录 前言 一、.xml文件里保存的是什么 二、准备好自己的数据 三、创建split_tr…

spring boot 3 + 虚拟线程 + MDC traceId

虚拟线程&#xff08;Virtual Thread&#xff09;也称协程或纤程&#xff0c;是一种轻量级的线程实现&#xff0c;与传统的线程以及操作系统级别的线程&#xff08;也称为平台线程&#xff09;相比&#xff0c;它的创建开销更小、资源利用率更高&#xff0c;是 Java 并发编程领…

ChatGPT-4模型镜像站对比和【软件开发人员】提示词

AI如今很强大&#xff0c;聊聊天、写论文、搞翻译、写代码、写文案、审合同等等&#xff0c;ChatGPT 真是无所不能~ 作为一款出色的大语言模型&#xff0c;ChatGPT 实现了人类般的对话交流&#xff0c;最主要是能根据上下文进行互动。 接下来&#xff0c;我将介绍 ChatGPT 在…

活动|华院计算参与《数字生态指数2024》报告发布并受邀主题分享

9月20-21日&#xff0c;“第二届数字生态与治理论坛暨数字生态指数2024发布会”在湖北省武汉市举办。华院计算作为研究团队一员受邀出席论坛&#xff0c;并发表“人工智能赋能基层社会治理”主题演讲。 《数字生态指数2024》报告为国家对外积极调整全球数字治理战略定位&#x…

UE学习篇ContentExample解读------Blueprint_Communication-下

文章目录 总览描述批次阅览2.1 Using an Event Dispatcher function to call an event in the level Blueprint2.2 Binding an Event Dispatcher function to a custom event2.3 Binding an Event Dispathcer to a custom event on spawn3.1 Basic communication using a Bluep…

Java Set类

欢迎来到Cefler的博客&#x1f601; &#x1f54c;博客主页&#xff1a;折纸花满衣 &#x1f3e0;个人专栏&#xff1a;Java 目录 &#x1f449;&#x1f3fb;set1. 接口与实现2. 特性3. 常用方法4. 示例代码5. 遍历6. 线程安全 &#x1f449;&#x1f3fb;set更多方法1. 其他常…