基础闯关3

news2024/11/15 18:05:20

一、基础任务

大模型在浮点数大小比较上表现不佳,直接询问大模型浮点数大小往往会出现错误,而通过设定适当的提示词可以引导大模型生成正确的答案。提示工程是指设计和优化输入提示(prompts)的过程,这些提示用于指导大模型生成期望的输出或行为。清晰、具体且针对性的指令,能够让模型更有效地理解和执行任务,从而提高模型的性能和用户体验。

1. 常用提示方法

(1) 零样本和少样本提示

零样本提示(few shot prompting)和少样本提示(few shot prompting)是最简单的提示技术。

在零样本提示中,用户直接输入问题,由大模型生成答案。这也是我们日常使用最多的提示方法。

question: Your question
answer:

在少样本提示中,用户首先给出一些类似的问答对例子,再输入要解决的问题。一般来说,问答对例子数量在3-8个左右。

question: Example question
answer: Example answer
……
question: Your question
answer:

(2) CoT(Chain of Thought)

CoT是一种改进的提示技术,能够显著提高大模型回答问题的准确性,分为零样本CoT和少样本CoT提示。

在零样本CoT提示中,用户直接输入自己的问题,并在最后加上"Let's think step by step"引导大模型一步一步生成中间步骤,最后得到答案。

question: Your question. Let's think step by step.
answer:

在少样本CoT提示中,用户首先给出<问题,思维链,答案>例子,再给出自己的问题。其中思维链表示中间推理步骤。

question: Example question. Let's think step by step.
answer: Reasoning steps. Example answer.
……
question:Your question. Let's think step by step.
answer:

(3) LangGPT

为了帮助用户快速构建高效提示词,LangGPT定义了一套提示词模板,用户可以结合自己的任务来修改模板,从而构建高效的提示词。具体地,LangGPT定义了提示词需要包含的若干模块,包括概要、限制、目标、流程等,每个模块分别描述大模型需要满足的要求。用户只需根据自己的需求组合和修改这些模块,即可完成提示词构建。一个空白的LangGPT提示词模板如下:

# Role: {}

## Profile
- author: LangGPT 
- version: 1.0
- language: {中文/英文}
- description: {}

## Skills
{}

## Background(可选项):

## Goals(可选项):

## OutputFormat(可选项):

## Constraints
{}

## Workflows
{}

## Initialization
{}

2. 基础任务实践

(1)环境配置

我们需要创建Python环境并安装相关库:

# 创建虚拟环境
conda create -n langgpt python=3.10 -y
conda activate langgpt

# 安装一些必要的库
conda install pytorch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 pytorch-cuda=12.1 -c pytorch -c nvidia -y

# 安装其他依赖
pip install transformers==4.43.3
pip install streamlit==1.37.0
pip install huggingface_hub==0.24.3
pip install openai==1.37.1
pip install lmdeploy==0.5.2

安装linux软件依赖:

apt-get install tmux

创建项目文件夹:

## 创建路径
mkdir langgpt
## 进入项目路径
cd langgpt

(2) 模型部署

接下来我们需要将internlm2-chat-1.8b模型部署为openai格式server。由于服务需要持续运行,需要将进程维持在后台,所以这里使用tmux软件创建新的命令窗口:

tmux new -t langgpt

然后使用LMDeploy进行部署,只需一行代码即可部署模型API服务:

CUDA_VISIBLE_DEVICES=0 lmdeploy serve api_server /share/new_models/Shanghai_AI_Laboratory/internlm2-chat-1_8b --server-port 23333 --api-keys internlm2

部署效果如下:

随后可以通过代码测试是否部署成功:

from openai import OpenAI

client = OpenAI(
    api_key = "internlm2",
    base_url = "http://0.0.0.0:23333/v1"
)

response = client.chat.completions.create(
    model=client.models.list().data[0].id,
    messages=[
        {"role": "system", "content": "请介绍一下你自己"}
    ]
)

print(response.choices[0].message.content)

效果如下:

为了简化调用,可以进一步进行图形化界面调用,创建UI应用。InternLM部署完成后,可利用提供的chat_ui.py创建图形化界面。首先从github克隆项目:

git clone https://github.com/InternLM/Tutorial.git

进入项目所在路径并运行脚本部署streamlit应用:

cd Tutorial/tools
python -m streamlit run chat_ui.py

随后将端口映射到本地并在浏览器页面打开。点击开启新对话后即可发起对话。

(3) 浮点数大小比较

这里可以测试模型是否能够进行浮点大小比较:

可以看到,模型输出了错误的答案。接下来我们编写LangGPT提示模板:

# Role: 数学专家

## Profile
- author: LangGPT
- version: 1.0
- language: 中文
- description: 能够解决任意数值大小比较问题的数学专家。

## Skills
- 理解并执行数值大小比较规则。
- 比较整数和小数的大小。
- 按照十分位、百分位、千分位、万分位等顺序比较小数部分。

## Examples
- 1.8大于1.75
- 1.8小于1.85
- 1.8大于1.54
- 1.1小于1.51
- 3.5大于3.12

## Background
在进行数值大小比较时,需要遵循特定的比较规则,特别是当涉及到小数时。

## Goals
- 接收两个数值进行比较。
- 返回比较结果,明确哪个数值更大或两者相等。

## OutputFormat
- 输出格式为:'数值A {大于/小于/等于} 数值B'

## Constraints
- 输入数值必须为有效的整数或小数。
- 比较结果仅限于'大于'、'小于'或'等于'。

## Workflows
1. 接收两个待比较的数值。
2. 判断两个数值的类型(整数或小数)。
3. 如果是整数,直接比较大小。
4. 如果是小数,先比较整数部分,若整数部分相同,则依次比较小数部分的十分位、百分位、千分位、万分位等。
5. 输出比较结果。

将以上模板填入system prompt区域, 并开启新对话输入问题:

模型成功完成了数值大小比较任务。

二、进阶任务

我们基于GSM8K数据集进行零样本CoT、少样本CoT和LangGPT提示工程评测,使用的模型为Internlm2.5-chat-7b,运行至少需要24GB显存。

1. OpenCompass介绍

OpenCompass是由上海人工智能实验室研发的开源、高效、全面的大模型评测体系及开放平台,支持各种大模型的一站式评测。OpenCompass的中文文档位于OpenCompass司南。

(1) 环境配置

首先创建Python环境并安装基础依赖:

conda create --name opencompass python=3.10 pytorch torchvision pytorch-cuda -c nvidia -c pytorch -y
conda activate opencompass

随后在/root目录下克隆OpenCompass项目并安装:

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

为了进行GSM8K数据集评测,我们需要下载OpenCompass数据集。在 OpenCompass 项目根目录下运行下面命令,将数据集准备至${OpenCompass}/data目录下:

wget https://github.com/open-compass/opencompass/releases/download/0.2.2.rc1/OpenCompassData-core-20240207.zip
unzip OpenCompassData-core-20240207.zip

至此,OpenCompass的基本环境就搭建完了。

(2) 数据集配置

数据集配置是评测过程中非常重要的一步。所有的数据集配置文件都位于${OpenCompass}/configs/datasets 目录下。目录下的gsm8k文件夹即包含了对于gsm8k的数据配置文件。

configs/datasets/
├── agieval
├── apps
├── ARC_c
├── ...
├── CLUE_afqmc  # 数据集
│   ├── CLUE_afqmc_gen_901306.py  # 不同版本数据集配置文件
│   ├── CLUE_afqmc_gen.py
│   ├── CLUE_afqmc_ppl_378c5b.py
│   ├── CLUE_afqmc_ppl_6507d7.py
│   ├── CLUE_afqmc_ppl_7b0c1e.py
│   └── CLUE_afqmc_ppl.py
├── ...
├── XLSum
├── Xsum
└── z_bench

其中,数据集配置命名方式为数据集名称_评测方式_版本号.py

我们分别需要评测零样本CoT、少样本CoT、LangGPT三种提示的效果。下面给出这三种提示的模板:

  • 零样本CoT
gsm8k_infer_cfg = dict(
    prompt_template=dict(
        type=PromptTemplate,
        template=dict(
            round=[
                dict(role='HUMAN', prompt='{question}\nPlease reason step by step, and put your final answer within \\boxed{}.'),
            ],
        ),
    ),
    retriever=dict(type=ZeroRetriever),
    inferencer=dict(type=GenInferencer, max_out_len=512),
)
  • 少样本CoT
gsm8k_infer_cfg = dict(
    prompt_template=dict(
        type=PromptTemplate,
        template=dict(
            round=[
                dict(role='HUMAN', prompt="Question: Angelo and Melanie want to plan how many hours over the next week they should study together for their test next week. They have 2 chapters of their textbook to study and 4 worksheets to memorize. They figure out that they should dedicate 3 hours to each chapter of their textbook and 1.5 hours for each worksheet. If they plan to study no more than 4 hours each day, how many days should they plan to study total over the next week if they take a 10-minute break every hour, include 3 10-minute snack breaks each day, and 30 minutes for lunch each day?\nLet's think step by step\nAnswer:"),
                dict(role='BOT', prompt='Angelo and Melanie think they should dedicate 3 hours to each of the 2 chapters, 3 hours x 2 chapters = 6 hours total.\nFor the worksheets they plan to dedicate 1.5 hours for each worksheet, 1.5 hours x 4 worksheets = 6 hours total.\nAngelo and Melanie need to start with planning 12 hours to study, at 4 hours a day, 12 / 4 = 3 days.\nHowever, they need to include time for breaks and lunch. Every hour they want to include a 10-minute break, so 12 total hours x 10 minutes = 120 extra minutes for breaks.\nThey also want to include 3 10-minute snack breaks, 3 x 10 minutes = 30 minutes.\nAnd they want to include 30 minutes for lunch each day, so 120 minutes for breaks + 30 minutes for snack breaks + 30 minutes for lunch = 180 minutes, or 180 / 60 minutes per hour = 3 extra hours.\nSo Angelo and Melanie want to plan 12 hours to study + 3 hours of breaks = 15 hours total.\nThey want to study no more than 4 hours each day, 15 hours / 4 hours each day = 3.75\nThey will need to plan to study 4 days to allow for all the time they need.\nThe answer is 4\n'),
                dict(role='HUMAN', prompt="Question: Mark's basketball team scores 25 2 pointers, 8 3 pointers and 10 free throws.  Their opponents score double the 2 pointers but half the 3 pointers and free throws.  What's the total number of points scored by both teams added together?\nLet's think step by step\nAnswer:"),
                dict(role='BOT', prompt="Mark's team scores 25 2 pointers, meaning they scored 25*2= 50 points in 2 pointers.\nHis team also scores 6 3 pointers, meaning they scored 8*3= 24 points in 3 pointers\nThey scored 10 free throws, and free throws count as one point so they scored 10*1=10 points in free throws.\nAll together his team scored 50+24+10= 84 points\nMark's opponents scored double his team's number of 2 pointers, meaning they scored 50*2=100 points in 2 pointers.\nHis opponents scored half his team's number of 3 pointers, meaning they scored 24/2= 12 points in 3 pointers.\nThey also scored half Mark's team's points in free throws, meaning they scored 10/2=5 points in free throws.\nAll together Mark's opponents scored 100+12+5=117 points\nThe total score for the game is both team's scores added together, so it is 84+117=201 points\nThe answer is 201\n"),
                dict(role='HUMAN', prompt="Question: Bella has two times as many marbles as frisbees. She also has 20 more frisbees than deck cards. If she buys 2/5 times more of each item, what would be the total number of the items she will have if she currently has 60 marbles?\nLet's think step by step\nAnswer:"),
                dict(role='BOT', prompt="When Bella buys 2/5 times more marbles, she'll have increased the number of marbles by 2/5*60 = 24\nThe total number of marbles she'll have is 60+24 = 84\nIf Bella currently has 60 marbles, and she has two times as many marbles as frisbees, she has 60/2 = 30 frisbees.\nIf Bella buys 2/5 times more frisbees, she'll have 2/5*30 = 12 more frisbees.\nThe total number of frisbees she'll have will increase to 30+12 = 42\nBella also has 20 more frisbees than deck cards, meaning she has 30-20 = 10 deck cards\nIf she buys 2/5 times more deck cards, she'll have 2/5*10 = 4 more deck cards.\nThe total number of deck cards she'll have is 10+4 = 14\nTogether, Bella will have a total of 14+42+84 = 140 items\nThe answer is 140\n"),
                dict(role='HUMAN', prompt="Question: A group of 4 fruit baskets contains 9 apples, 15 oranges, and 14 bananas in the first three baskets and 2 less of each fruit in the fourth basket. How many fruits are there?\nLet's think step by step\nAnswer:"),
                dict(role='BOT', prompt='For the first three baskets, the number of apples and oranges in one basket is 9+15=24\nIn total, together with bananas, the number of fruits in one basket is 24+14=38 for the first three baskets.\nSince there are three baskets each having 38 fruits, there are 3*38=114 fruits in the first three baskets.\nThe number of apples in the fourth basket is 9-2=7\nThere are also 15-2=13 oranges in the fourth basket\nThe combined number of oranges and apples in the fourth basket is 13+7=20\nThe fourth basket also contains 14-2=12 bananas.\nIn total, the fourth basket has 20+12=32 fruits.\nThe four baskets together have 32+114=146 fruits.\nThe answer is 146\n'),
                dict(role='HUMAN', prompt="Question: {question}\nLet's think step by step\nAnswer:"),
            ],
        )),
    retriever=dict(type=ZeroRetriever),
    inferencer=dict(type=GenInferencer, max_out_len=512))
  • LangGPT
gsm8k_infer_cfg = dict(
    prompt_template=dict(
        type=PromptTemplate,
        template=dict(
            begin=[
                dict(role='SYSTEM',fallback_role='HUMAN', prompt="""
# Role: MathExpert
## Profile
- author: LangGPT 
- version: 1.0
- language: 英文
- description: An AI math expert capable of solving a wide range of mathematical problems, including algebra, calculus, geometry, and statistics.
## Skills
- Solving algebraic equations and inequalities.
- Solving mathematical problems in real-life applications.
- Interpreting and manipulating statistical data.
## Background
The MathExpert is designed for students, educators, and anyone who needs assistance with mathematical concepts and problem-solving.
## Goals
- To provide accurate and clear solutions to math problems.
- To explain mathematical concepts in an understandable way.
- To assist in the learning and mastery of mathematical subjects.
## OutputFormat
- The solution to the math problem presented in a step-by-step format.
- Explanations of the concepts used in the solution.
- Visual aids (where applicable) to illustrate the problem and solution.
## Constraints
- The math problems should be within the scope of high school and undergraduate level mathematics.
- The AI will not perform real-time calculations or data analysis that requires external data sources.
## Workflows
1. User presents a math problem or asks for an explanation of a mathematical concept.
2. MathExpert analyzes the problem and determines the appropriate approach to solve it.
3. MathExpert provides a step-by-step solution, including explanations.
## Initialization
- Please present your mathematical problem.
"""),
            ],
            round=[
                dict(role='HUMAN', prompt="Question: Angelo and Melanie want to plan how many hours over the next week they should study together for their test next week. They have 2 chapters of their textbook to study and 4 worksheets to memorize. They figure out that they should dedicate 3 hours to each chapter of their textbook and 1.5 hours for each worksheet. If they plan to study no more than 4 hours each day, how many days should they plan to study total over the next week if they take a 10-minute break every hour, include 3 10-minute snack breaks each day, and 30 minutes for lunch each day?\nLet's think step by step\nAnswer:"),
                dict(role='BOT', prompt='Angelo and Melanie think they should dedicate 3 hours to each of the 2 chapters, 3 hours x 2 chapters = 6 hours total.\nFor the worksheets they plan to dedicate 1.5 hours for each worksheet, 1.5 hours x 4 worksheets = 6 hours total.\nAngelo and Melanie need to start with planning 12 hours to study, at 4 hours a day, 12 / 4 = 3 days.\nHowever, they need to include time for breaks and lunch. Every hour they want to include a 10-minute break, so 12 total hours x 10 minutes = 120 extra minutes for breaks.\nThey also want to include 3 10-minute snack breaks, 3 x 10 minutes = 30 minutes.\nAnd they want to include 30 minutes for lunch each day, so 120 minutes for breaks + 30 minutes for snack breaks + 30 minutes for lunch = 180 minutes, or 180 / 60 minutes per hour = 3 extra hours.\nSo Angelo and Melanie want to plan 12 hours to study + 3 hours of breaks = 15 hours total.\nThey want to study no more than 4 hours each day, 15 hours / 4 hours each day = 3.75\nThey will need to plan to study 4 days to allow for all the time they need.\nThe answer is 4\n'),
                dict(role='HUMAN', prompt="Question: Mark's basketball team scores 25 2 pointers, 8 3 pointers and 10 free throws.  Their opponents score double the 2 pointers but half the 3 pointers and free throws.  What's the total number of points scored by both teams added together?\nLet's think step by step\nAnswer:"),
                dict(role='BOT', prompt="Mark's team scores 25 2 pointers, meaning they scored 25*2= 50 points in 2 pointers.\nHis team also scores 6 3 pointers, meaning they scored 8*3= 24 points in 3 pointers\nThey scored 10 free throws, and free throws count as one point so they scored 10*1=10 points in free throws.\nAll together his team scored 50+24+10= 84 points\nMark's opponents scored double his team's number of 2 pointers, meaning they scored 50*2=100 points in 2 pointers.\nHis opponents scored half his team's number of 3 pointers, meaning they scored 24/2= 12 points in 3 pointers.\nThey also scored half Mark's team's points in free throws, meaning they scored 10/2=5 points in free throws.\nAll together Mark's opponents scored 100+12+5=117 points\nThe total score for the game is both team's scores added together, so it is 84+117=201 points\nThe answer is 201\n"),
                dict(role='HUMAN', prompt="Question: Bella has two times as many marbles as frisbees. She also has 20 more frisbees than deck cards. If she buys 2/5 times more of each item, what would be the total number of the items she will have if she currently has 60 marbles?\nLet's think step by step\nAnswer:"),
                dict(role='BOT', prompt="When Bella buys 2/5 times more marbles, she'll have increased the number of marbles by 2/5*60 = 24\nThe total number of marbles she'll have is 60+24 = 84\nIf Bella currently has 60 marbles, and she has two times as many marbles as frisbees, she has 60/2 = 30 frisbees.\nIf Bella buys 2/5 times more frisbees, she'll have 2/5*30 = 12 more frisbees.\nThe total number of frisbees she'll have will increase to 30+12 = 42\nBella also has 20 more frisbees than deck cards, meaning she has 30-20 = 10 deck cards\nIf she buys 2/5 times more deck cards, she'll have 2/5*10 = 4 more deck cards.\nThe total number of deck cards she'll have is 10+4 = 14\nTogether, Bella will have a total of 14+42+84 = 140 items\nThe answer is 140\n"),
                dict(role='HUMAN', prompt="Question: A group of 4 fruit baskets contains 9 apples, 15 oranges, and 14 bananas in the first three baskets and 2 less of each fruit in the fourth basket. How many fruits are there?\nLet's think step by step\nAnswer:"),
                dict(role='BOT', prompt='For the first three baskets, the number of apples and oranges in one basket is 9+15=24\nIn total, together with bananas, the number of fruits in one basket is 24+14=38 for the first three baskets.\nSince there are three baskets each having 38 fruits, there are 3*38=114 fruits in the first three baskets.\nThe number of apples in the fourth basket is 9-2=7\nThere are also 15-2=13 oranges in the fourth basket\nThe combined number of oranges and apples in the fourth basket is 13+7=20\nThe fourth basket also contains 14-2=12 bananas.\nIn total, the fourth basket has 20+12=32 fruits.\nThe four baskets together have 32+114=146 fruits.\nThe answer is 146\n'),
                dict(
                    role='HUMAN', prompt="Question: {question}\nLet's think step by step\nAnswer:"),
            ],
        )),
    retriever=dict(type=ZeroRetriever),
    inferencer=dict(type=GenInferencer, max_out_len=512))

其中,retriever参数指定不进行检索,inferencer指定进行推理生成,并限制最大长度。LangGPT提示作为system prompt

以上三种提示方法仅在推理配置部分不同,其余配置均相同。 其余部分代码如下:

# gsm8k_gen_0806.py 数据集配置文件(gsm8k_infer_cfg为以上需要评测的提示词配置)
from opencompass.openicl.icl_prompt_template import PromptTemplate
from opencompass.openicl.icl_retriever import ZeroRetriever
from opencompass.openicl.icl_inferencer import GenInferencer
from opencompass.datasets import GSM8KDataset, gsm8k_postprocess, gsm8k_dataset_postprocess, Gsm8kEvaluator

# 数据集输入字段为question,输出字段为answer
gsm8k_reader_cfg = dict(input_columns=['question'], output_column='answer')

# 推理配置
gsm8k_infer_cfg = 

# 数据集总配置
gsm8k_datasets = [
    dict(
        abbr='gsm8k',    # 简称
        type=GSM8KDataset,  
        path='opencompass/gsm8k',
        reader_cfg=gsm8k_reader_cfg,
        infer_cfg=gsm8k_infer_cfg,
        eval_cfg=gsm8k_eval_cfg)
]

(3) 评测配置

我们需要定义评测配置文件。所有的评测配置文件都位于${OpenCompass}/configs/ 目录下。对于自定义评测任务,我们需要新建评测文件,并定义modelsdatasets变量。其中datasets变量可以直接从第(2)部分的数据集配置文件导入gsm8k_datasets

我们使用LMDeploy来部署本地模型,因此使用的模型类型为TurboMindModel 。此外,我们简单介绍一下OpenCompass中模型侧的Meta Template。在 LLM 的 Supervised Fine-Tuning (SFT) 过程中,我们常常会根据实际的要求往对话内注入一些预定义的字符串,以求模型能按照一定的要求输出内容。因此,我们需要针对不同模型指定不同的解析模板。其中,Internlm2.5-chat-7b的解析模板示例如下:

如图,Internlm2.5-chat-7b的解析模板会在对话最开始添加<s>词元,在每轮对话开始前加入<im_start>,并加入对应角色。在每轮对话结束后加入<im_end>。因此我们可以尝试加入meta_template 解析模板,以得到符合指令微调阶段的输入。

我们定义的meta template如下:

internlm2_meta_template = dict(
    begin='<s>',
    reserved_roles=[dict(role='SYSTEM', begin='<|im_start|>system\n', end='<im_end>\n'),],
    round=[
        dict(role='HUMAN', begin='<|im_start|>user\n', end='<|im_end|>\n'),
        dict(role='BOT', begin='<|im_start|>assistant\n', end='<|im_end|>\n', generate=True),
    ],
    eos_token_id=92542
) 

于是,整体配置文件样例如下:

# eval.py
from mmengine.config import read_base
from opencompass.models.turbomind import TurboMindModel

# 导入前面定义的数据集配置
with read_base():
    # choose a list of datasets
    from .datasets.gsm8k.gsm8k_gen_1d7fe4 import gsm8k_datasets
    # and output the results in a chosen format
    from .summarizers.medium import summarizer

# 定义评测数据集
datasets = gsm8k_datasets

internlm2_meta_template = dict(
    begin='<s>',
    reserved_roles=[dict(role='SYSTEM', begin='<|im_start|>system\n', end='<im_end>\n'),],
    round=[
        dict(role='HUMAN', begin='<|im_start|>user\n', end='<|im_end|>\n'),
        dict(role='BOT', begin='<|im_start|>assistant\n', end='<|im_end|>\n', generate=True),
    ],
    eos_token_id=92542
)

# config for internlm-20b model
internlm_7b = dict(
        type=TurboMindModel,
        abbr='internlm-7b-chat-langgpt',
        path="internlm/internlm2_5-7b-chat", # 注意路径与huggingface保持一致
        engine_config=dict(session_len=2048,
                           max_batch_size=32,
                           rope_scaling_factor=1.0),
        gen_config=dict(top_k=1, top_p=0.8,
                        temperature=1.0,
                        max_new_tokens=100),
        meta_template=internlm2_meta_template, # 如果不使用解析模板,可以删除这行
        max_out_len=100,
        max_seq_len=2048,
        batch_size=8,
        concurrency=8,
        run_cfg=dict(num_gpus=1, num_procs=1),
        end_str='<im_end>'
    )

# 定义评测模型
models = [internlm_7b]

以上为少样本CoT评测数据集评测文件,可以进一步加入零样本CoT、LangGPT数据集配置。

至此,我们的评测文件已经全部建立完毕。

2. 提示词评测

(1) 运行评测

目前OpenCompass还存在一些环境冲突,在评测开始前,我们需要设定环境变量:

export MKL_SERVICE_FORCE_INTEL=1

在OpenCompass根目录下运行命令:

python run.py configs/eval.py

(2) 评测结果

我们分别评测了少样本CoT、零样本CoT、LangGPT三种提示的效果。结果如下:

使用meta template零样本CoT少样本CoTLangGPT
23.834.881.5
34.681.655.9

令人意外的是,meta template提升了LangGPT的准确率,却降低了零样本和少样本CoT的准确率。其中,少样本CoT达到了最高的准确率81.6%,LangGPT也实现了相当的性能。

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

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

相关文章

一网统管政企联动:计讯构建城市生命线安全智能体的应急管理革新

城市生命线国家政策推动生命线风险频发 随着城市化进程加速&#xff0c;城市安全问题日益凸显&#xff0c;包括自然灾害、建筑老化、环境污染和公共卫生事件等潜在风险。城市不仅要更新“硬设施”&#xff0c;更在于通过大数据、云计算、5G等新兴技术提升城市管理的“软实力”。…

three.js 开发粒子系统

在 three.js 中开发粒子系统&#xff0c;你通常会使用 THREE.Points 和 THREE.PointsMaterial。这些组件允许你创建一个由大量点组成的系统&#xff0c;每个点都可以代表一个粒子&#xff0c;并可以自定义其大小、颜色、透明度等属性。以下是一个基本的步骤指南&#xff0c;用于…

赞奇科技与华为云共襄828 B2B企业节,激活数字内容“云”创作

8月28日&#xff0c;在2024中国国际大数据产业博览会上&#xff0c;第三届828 B2B企业节正式开幕&#xff0c;旨在融通数智供需&#xff0c;加速企业智改数转&#xff0c;助推中国数智产业实力再升级。 828 B2B企业节是全国首个基于数字化赋能的企业节&#xff0c;由华为联合上…

kafka安装配置、以及遇到闪退问题的解决办法

一、Kafka对于zookeeper是强依赖&#xff0c;保存kafka相关的节点数据&#xff0c;所以安装Kafka之前必须先安装 zookeeper 详细安装过程参见这位大神写的博客 windows系统kafka小白入门篇——下载安装&#xff0c;环境配置&#xff0c;入门代码书写_windows kafka-CSDN博客 注…

【C++11及其特性】智能指针——unique_ptr

unique_ptr目录 一.排他所有权模式二.auto_ptr的缺点1.可以直接复制和拷贝构造2.STL可以直接赋值3.不支持动态内存分配数组 三.unique_ptr(C11)1.不支持直接赋值和构造2.STL可以不可以直接赋值3.支持动态内存分配数组 四.unique_ptr的用法1.构造函数2.赋值操作3.主动释放对象4.…

免费的电脑录屏软件,这几款软件满足录屏需求!

在数字化时代&#xff0c;电脑录屏已成为我们日常生活和工作中不可或缺的一部分。无论是教学演示、游戏直播、会议记录&#xff0c;还是视频创作&#xff0c;一款优秀的录屏软件都是不可或缺的。今天&#xff0c;就为大家推荐几款免费、高效、易用的电脑录屏软件&#xff0c;帮…

首批国自然博士项目获批名单

【SciencePub学术】从公开新闻来看&#xff0c;已经有20所高校的博士生获批项目&#xff0c;分别是北京大学、清华大学、北京航空航天大学、东南大学、复旦大学、华中科技大学、吉林大学、兰州大学、南方科技大学、南开大学、山东大学、上海交通大学、四川大学、武汉大学、南京…

VSCode必备插件!快看过来!

同学同学&#xff0c;你是不是也很头疼VSCode不知道安装什么插件啊&#xff1f;尤其是萌新小白&#xff0c;更是一头雾水&#xff0c;那就快来一起看看吧~我帮你整理了一些非常实用的插件&#xff0c;安装上它们&#xff0c;你的开发体验会大大提升&#xff01; 1. Chinese (S…

DWG如何转换成PDF?总结了四种转换

DWG如何转换成PDF&#xff1f;在日常工作和学习中&#xff0c;经常需要将CAD软件中的DWG文件转换为PDF格式&#xff0c;以便于更广泛地分享和查阅。那么具体要怎么做&#xff0c;才能实现两种格式的顺利转换呢&#xff1f;为了帮助读者轻松完成这一任务&#xff0c;本文将详细介…

网络价格管控行动:四大策略,打击低价

网络价格管控的举措 设定最低售价约束&#xff1a;品牌方能够与在线零售商订立协议&#xff0c;清晰界定产品的最低售价&#xff0c;以守护品牌形象与市场秩序。推行动态定价策略&#xff1a;依照市场需求、竞争态势以及库存状况动态调节产品价格&#xff0c;保障市场竞争力并…

Java爬虫开发:Jsoup库在图片URL提取中的实战应用

在当今的互联网时代&#xff0c;数据的获取和处理变得尤为重要。对于网站内容的自动化抓取&#xff0c;爬虫技术扮演着不可或缺的角色。Java作为一种广泛使用的编程语言&#xff0c;拥有丰富的库支持网络爬虫的开发。其中&#xff0c;Jsoup库以其简洁、高效的特点&#xff0c;成…

51单片机 - 定时器0(按键控制LED流水灯模式)

时间&#xff1a;2024.9.2 目的&#xff1a;手撕51 作者&#xff1a;Whappy 定时器0寄存器配置 1.定时器0配置过程 首先要配置定时器的寄存器TCON和TMOD使计数器开始计数及定时器的初始值&#xff0c;配置使这个链路连起来。 #include <REGX52.H>void Timer0_Init() {…

【HarmonyOS 4.0】鸿蒙应用模型

应用模型是HarmonyOS为开发者提供的应用程序所需能力的抽象提炼&#xff0c;它提供了应用程序必备的组件和运行机制。有了应用模型&#xff0c;开发者可以基于一套统一的模型进行应用开发&#xff0c;使应用开发更简单、高效。随着系统的演进发展&#xff0c;HarmonyOS先后提供…

java 实现文本转音频

文章目录 一、前言二、实现流程2.1 下载jacob-1.18.zip2.2 拷贝jacob-1.18-x64.dll2.3 pom 添加依赖2.4 代码实现 一、前言 本文基于Windows自带的SAPI.SpVoice&#xff0c;通过java代码实现文本转语音的功能。 二、实现流程 2.1 下载jacob-1.18.zip 链接&#xff1a;https…

红帽认证初级有用吗?对个人帮助,报名时间分享

红帽认证初级即红帽认证系统管理员&#xff08;RHCSA&#xff09;是有用的。 拥有 RHCSA 认证的管理员掌握了 Linux 操作系统的基本知识和技能&#xff0c;能够准确理解和解决系统操作中的各种问题。他们了解并熟悉 Linux 命令行和 GUI 界面&#xff0c;可以高效地完成各种任务…

OpenCV绘图函数(15)图像上绘制矩形函数 rectangle()的使用

操作系统&#xff1a;ubuntu22.04 OpenCV版本&#xff1a;OpenCV4.9 IDE:Visual Studio Code 编程语言&#xff1a;C11 算法描述 绘制一个简单的、粗的或填充的直立矩形。 这个函数 cv::rectangle 绘制一个矩形轮廓或一个填充的矩形&#xff0c;其两个相对的顶点分别是 pt1 和…

大数据-114 Flink DataStreamAPI 程序输入源 自定义输入源 Rich并行源 RichParallelSourceFunction

点一下关注吧&#xff01;&#xff01;&#xff01;非常感谢&#xff01;&#xff01;持续更新&#xff01;&#xff01;&#xff01; 目前已经更新到了&#xff1a; Hadoop&#xff08;已更完&#xff09;HDFS&#xff08;已更完&#xff09;MapReduce&#xff08;已更完&am…

(五)vForm 动态表单文件上传、下载

系列文章目录 (一)vForm 动态表单设计器之使用 (二)vForm 动态表单设计器之下拉、选择 (三)vForm 动态表单解决下拉框无数据显示id问题 (四)vForm 动态表单自定义组件、属性 目录 系列文章目录 前言 一、文件上传 1.前端 2.后端 二、文件下载 1.前端 2.后端 总结 …

你可能被 Vue 中的 v-show 骗了,它并没有像你想的那样切换 display 的属性

你好同学&#xff0c;我是沐爸&#xff0c;欢迎点赞、收藏、评论和关注&#xff01; 在 Vue 中 v-show 是如何条件性地渲染内容的&#xff0c;你可能知道是通过切换 display 属性实现&#xff0c;但真的跟你想的一样吗&#xff1f; 一、你被骗了吗&#xff1f; v-show 和 v-…

JAVAEE初阶第三节——多线程进阶

系列文章目录 JAVAEE初阶第三节——多线程进阶 文章目录 系列文章目录JAVAEE初阶第三节——多线程进阶 一. 常见的锁策略1.乐观锁和悲观锁2. 轻量级锁和重量级锁3.自旋锁和挂起等待锁4. 普通互斥锁和读写锁5. 公平锁和非公平锁6.可重入锁和不可重入锁 二. synchronized的优化手…