[Llama3] ReAct Prompt 测试实验

ReAct 是一种 LLM 提示和结果处理方法,结合了推理、行动计划和知识源整合,使 LLM 超越其语言模型,并在预测中使用来自现实世界的信息。 ReAct 是推理和行动的结合。

介绍 ReAct 的论文表明它比思维链提示更好。与后者不同的是,ReAct 不会过多地幻化事实。然而,为了获得最佳结果,论文建议将 ReAct 和思维链提示与自我一致性检查结合起来。

前期准备

ReAct Prompt  llama3模板

<|begin_of_text|><|start_header_id|>user<|end_header_id|>
Answer the following questions as best you can.

If the user demands a final answer but you are unsure, execute the thought/action/action input/observation sequence.  

you have access to the following tools:
[{tool_name_and_description}]


use the following format:

Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [{tool_names}]
Action Input: the input to the action
Observation: the result of the action

..(this Thought/Action/Action Input/Observation can repeat N times)

Thought: I now know the final answer
Final Answer: the final answer to the original input question

Begin!

Question: {question}
<|eot_id|><|start_header_id|>assistant<|end_header_id|>

其它大语言模型的模版

You are an assistant to give people the answer of questions.
Human may provide new question to you with a description and you should use tools to get the answer, rather than directly reply from the description.

You have access to the following tools:

> Search: Search for a term in Wikipedia and return the first sentence. The input to this tool should be a string to search.
> Lookup: Lookup a term in the Wikipedia article and return sentence which describes about a term. The input to this tool should be a string to lookup.

To use a tool, please use the following format:

```
Question: the input question you must answer
Thought: your thought about what to do
Action: the action to take, should be one of [Search, Lookup]
Action Input: the input to the action
Observation: the result of the action
... (this Thought/Action/Action Input/Observation can repeat N times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question
```

Begin!

Now human has provided the following question.

Question: Author David Chanoff has collaborated with a U.S. Navy admiral who served as the ambassador to the United Kingdom under which President?

把Observation添加到stop token里。

问题:

Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?

可用的工具

[Search: search the latest information you needs on the internet, Caculator: use it while calculating something ]

实践步骤

实验一:

问题: Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?

执行第一次

prompt

<|begin_of_text|><|start_header_id|>user<|end_header_id|>
Answer the following questions as best you can

you have access to the following tools:
[Search: search the latest information you needs on the internet, Caculator: use it while calculating something ]


use the following format:

Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [Search, Caculator]
Action Input: the input to the action
Observation: the result of the action

..(this Thought/Action/Action Input/Observation can repeat N times)

Thought: I now know the final answer
Final Answer: the final answer to the original input question

Begin!

Question: Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?
<|eot_id|><|start_header_id|>assistant<|end_header_id|>

运行结果

Thought: I need to find out who Olivia Wilde's boyfriend is and then calculate his current age raised to the 0.23 power.
Action: Search
Action Input: "Who is Olivia Wilde's boyfriend?"

然后我在网上查找一下Olivia Wilde's boyfriend.

搜到如下结果:

Olivia Wilde started dating Harry Styles after ending her years-long engagement to Jason Sudeikis — see their relationship timeline.

执行第二次

prompt

<|begin_of_text|><|start_header_id|>user<|end_header_id|>
Answer the following questions as best you can. 
 
you have access to the following tools:
[Search: search the latest information you needs on the internet, Caculator: use it while calculating something ]
 
 
use the following format:
 
Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [Search, Caculator]
Action Input: the input to the action
Observation: the result of the action
 
..(this Thought/Action/Action Input/Observation can repeact N times)
 
Thought: I now know the final answer
Final Answer: the final answer to the original input question
 
Begin!
 
Question: Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?
Thought: I need to find out who Olivia Wilde's boyfriend is and then calculate his current age raised to the 0.23 power.
Action: Search
Action Input: "Who is Olivia Wilde's boyfriend?"
Observation: Olivia Wilde started dating Harry Styles after ending her years-long engagement to Jason Sudeikis — see their relationship timeline.
<|eot_id|><|start_header_id|>assistant<|end_header_id|>

执行结果

结果是:

Thought: I need to find out Harry Styles' current age and then calculate his age raised to the 0.23 power.
Action: Search
Action Input: "What is Harry Styles' current age?"

在网上搜索"Harry Styles age"。 结果是:”29 years“

执行第三次

prompt

<|begin_of_text|><|start_header_id|>user<|end_header_id|>
Answer the following questions as best you can. 
 
you have access to the following tools:
[Search: search the latest information you needs on the internet, Caculator: use it while calculating something ]
 
 
use the following format:
 
Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [Search, Caculator]
Action Input: the input to the action
Observation: the result of the action
 
..(this Thought/Action/Action Input/Observation can repeact N times)
 
Thought: I now know the final answer
Final Answer: the final answer to the original input question
 
Begin!
 
Question: Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?
Thought: I need to find out who Olivia Wilde's boyfriend is and then calculate his current age raised to the 0.23 power.
Action: Search
Action Input: "Who is Olivia Wilde's boyfriend?"
Observation: Olivia Wilde started dating Harry Styles after ending her years-long engagement to Jason Sudeikis — see their relationship timeline.
Thought: I need to find out Harry Styles' current age and then calculate his age raised to the 0.23 power.
Action: Search
Action Input: "What is Harry Styles' current age?"
Observation: 29 years
<|eot_id|><|start_header_id|>assistant<|end_header_id|>

执行结果:

Thought: I need to calculate Harry Styles' age raised to the 0.23 power.
Action: Caculator
Action Input: "29^0.23"

利用计算器计算29 ^ 0.23。 得到:2.169459462491557

执行第四次

prompt

<|begin_of_text|><|start_header_id|>user<|end_header_id|>
Answer the following questions as best you can. 
 
you have access to the following tools:
[Search: search the latest information you needs on the internet, Caculator: use it while calculating something ]
 
 
use the following format:
 
Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [Search, Caculator]
Action Input: the input to the action
Observation: the result of the action
 
..(this Thought/Action/Action Input/Observation can repeact N times)
 
Thought: I now know the final answer
Final Answer: the final answer to the original input question
 
Begin!
 
Question: Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?
Thought: I need to find out who Olivia Wilde's boyfriend is and then calculate his current age raised to the 0.23 power.
Action: Search
Action Input: "Who is Olivia Wilde's boyfriend?"
Observation: Olivia Wilde started dating Harry Styles after ending her years-long engagement to Jason Sudeikis — see their relationship timeline.
Thought: I need to find out Harry Styles' current age and then calculate his age raised to the 0.23 power.
Action: Search
Action Input: "What is Harry Styles' current age?"
Observation: 29 years
Thought: I need to calculate Harry Styles' age raised to the 0.23 power.
Action: Caculator
Action Input: "29^0.23"
Observation: 2.169459462491557
<|eot_id|><|start_header_id|>assistant<|end_header_id|>

执行结果

Final Answer: The answer to the question "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?" is Harry Styles, and his current age raised to the 0.23 power is approximately 2.17.

实验二:

问题:I want to know what privileges does Harry user have ?

工具:[
{tool_name: getUser, description:search user information including pk_user_id based on username, tool parameter: username},
{tool_name: GetRole, description:get role information including role_id based on pk_user_Id, tool parameter: pk_user_Id } ,
{tool_name: GetPrivilege, description:get all privilege based on role_id , tool parameter: role_id } 
]

执行第一次

prompt

<|begin_of_text|><|start_header_id|>user<|end_header_id|>
Answer the following questions as best you can. 

If the user demands a final answer but you are unsure, execute the thought/action/action input/observation sequence.
 
you have access to the following tools:
[
{tool_name: getUser, description:search user information including pk_user_id based on username, tool parameter: username},
{tool_name: GetRole, description:get role information including role_id based on pk_user_Id, tool parameter: pk_user_Id } ,
{tool_name: GetPrivilege, description:get all privilege based on role_id , tool parameter: role_id } 
]
 
 
use the following format:
 
Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [GetUser, GetRole, GetPrivilege]
Action Input: the input to the action
Observation: the result of the action
 
..(this Thought/Action/Action Input/Observation can repeat N times)
 
Thought: I now know the final answer
Final Answer: the final answer to the original input question
 
Begin!
 
Question: I want to know what privileges does Harry user have ?
<|eot_id|><|start_header_id|>assistant<|end_header_id|>

执行结果:

Thought: I need to get the user information first
Action: GetUser
Action Input: Harry

执行第二次

prompt

<|begin_of_text|><|start_header_id|>user<|end_header_id|>
Answer the following questions as best you can. 

If the user demands a final answer but you are unsure, execute the thought/action/action input/observation sequence.
 
you have access to the following tools:
[
{tool_name: getUser, description:search user information including pk_user_id based on username, tool parameter: username},
{tool_name: GetRole, description:get role information including role_id based on pk_user_Id, tool parameter: pk_user_Id } ,
{tool_name: GetPrivilege, description:get all privilege based on role_id , tool parameter: role_id } 
]
 
 
use the following format:
 
Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [GetUser, GetRole, GetPrivilege]
Action Input: the input to the action
Observation: the result of the action
 
..(this Thought/Action/Action Input/Observation can repeat N times)
 
Thought: I now know the final answer
Final Answer: the final answer to the original input question
 
Begin!
 
Question: I want to know what privileges does Harry user have ?
Thought: I need to get the user information first
Action: GetUser
Action Input: Harry
Observation: pk_user_id =1, user_name = Harry, age: 35
<|eot_id|><|start_header_id|>assistant<|end_header_id|>

结果:

Thought: Now that I have the user information, I need to get the role of this user
Action: GetRole
Action Input: 1

执行第三次

prompt

<|begin_of_text|><|start_header_id|>user<|end_header_id|>
Answer the following questions as best you can. 

If the user demands a final answer but you are unsure, execute the thought/action/action input/observation sequence.
 
you have access to the following tools:
[
{tool_name: getUser, description:search user information including pk_user_id based on username, tool parameter: username},
{tool_name: GetRole, description:get role information including role_id based on pk_user_Id, tool parameter: pk_user_Id } ,
{tool_name: GetPrivilege, description:get all privilege based on role_id , tool parameter: role_id } 
]
 
use the following format:

Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [ GetUser, GetRole, GetPrivilege ]
Action Input: the input to the action
Observation: the result of the action
..(this Thought/Action/Action Input/Observation can repeat N times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question

 
Begin!
 
Question: I want to know what privileges does Harry user have?
Thought: I need to get the user information first
Action: GetUser
Action Input: Harry
Observation: user id is 1, user_name is Harry, age is35 .
Thought: Now that I have the user information, I need to get the role of this user
Action: GetRole
Action Input: 1
Observation: role id is 3.
<|eot_id|><|start_header_id|>assistant<|end_header_id|>

执行结果有问题,很明显还要根据role id查询privileges.

在prompt里后面追加一个引导词Thought:

结果:

Action: GetPrivilege
Action Input: 3

执行第四次

prompt

<|begin_of_text|><|start_header_id|>user<|end_header_id|>
Answer the following questions as best you can. 

If the user demands a final answer but you are unsure, execute the thought/action/action input/observation sequence.
 
you have access to the following tools:

getUser: search user information including pk user id based on user name
GetRole: get role information including role id based on pk user Id
GetPrivilege: get all privilege based on role id

 
To use a tool, please use the following format:

Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [ GetUser, GetRole, GetPrivilege ]
Action Input: the input to the action
Observation: the result of the action

..(this Thought/Action/Action Input/Observation can repeat N times)

Thought: I now know the final answer
Final Answer: the final answer to the original input question

 
Begin!

Now human has provided the following question.
 
Question: I want to know what privileges does Harry user have?
Thought: I need to get the user information first
Action: GetUser
Action Input: Harry
Observation: user id is 1, user_name is Harry, age is35 .
Thought: Now that I have the user information, I need to get the role of this user
Action: GetRole
Action Input: 1
Observation: role id is 3.
Thought:
Action: GetPrivilege 
Action Input: 3
Observation: previleges for role whose role id is 3 are edit account and delete account
Thought: <|eot_id|><|start_header_id|>assistant<|end_header_id|>

执行结果:

I now know the final answer
Final Answer: Harry has privileges to edit account and delete account.

实验三:

问题:I need to search Apple Remote and find the program it was original designed to interact with.

执行第一次

propmt

<|begin_of_text|><|start_header_id|>user<|end_header_id|>
Answer the following questions as best you can. 
 
you have access to the following tools:
[Search: search the latest information you needs on the internet, Caculator: use it while calculating something ]
 
 
use the following format:
 
Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [Search, Caculator]
Action Input: the input to the action
Observation: the result of the action
 
..(this Thought/Action/Action Input/Observation can repeact N times)
 
Thought: I now know the final answer
Final Answer: the final answer to the original input question
 
Begin!
 
Question: I need to search Apple Remote and find the program it was original designed to interact with.
<|eot_id|><|start_header_id|>assistant<|end_header_id|>

执行结果:

Thought: I need to find the original purpose of Apple Remote
Action: Search
Action Input: "Apple Remote original purpose"

搜索结果:

The Apple Remote is a remote control introduced in October 2005 by Apple. originally designed to control the Front Row media center program.

执行第二次

prompt

<|begin_of_text|><|start_header_id|>user<|end_header_id|>
Answer the following questions as best you can. 
 
you have access to the following tools:
[Search: search the latest information you needs on the internet, Caculator: use it while calculating something ]
 
 
use the following format:
 
Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [Search, Caculator]
Action Input: the input to the action
Observation: the result of the action
 
..(this Thought/Action/Action Input/Observation can repeact N times)
 
Thought: I now know the final answer
Final Answer: the final answer to the original input question
 
Begin!
 
Question: I need to search Apple Remote and find the program it was original designed to interact with.
Thought: I need to find the original purpose of Apple Remote
Action: Search
Action Input: "Apple Remote"
Observation: The Apple Remote is a remote control introduced in October 2005 by Apple. originally designed to control the Front Row media center program.
<|eot_id|><|start_header_id|>assistant<|end_header_id|>

执行结果:

The original program that Apple Remote was designed to interact with is Front Row.

复现失败,找寻答案中。。。

参考资料

ReAct 论文地址

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【数据结构】【版本1.0】【线性时代】——顺序表

快乐的流畅&#xff1a;个人主页 个人专栏&#xff1a;《算法神殿》《数据结构世界》《进击的C》 远方有一堆篝火&#xff0c;在为久候之人燃烧&#xff01; 文章目录 引言一、顺序表的概念1.1 最基础的数据结构&#xff1a;数组1.2 数组与顺序表的区别 二、静态顺序表三、动态…

基于STM32F030设计的多点温度采集系统(BC26+OneNet)

一、项目背景 随着物联网技术的迅猛发展&#xff0c;越来越多的智能设备应运而生&#xff0c;而温度采集系统是其中重要的一类。在现代工业和家庭生活中&#xff0c;温度对于生产、居住和储存等过程的控制有着非常重要的作用。因此&#xff0c;准确地采集环境温度数据并进行处…

Ubuntu基础 - 常用命令

目录 一.打开终端 1.快捷键 2.右键桌面 3.应用程序管理 二. 常用命令 1. ls命令 2. cd 命令 3. pwd 命令 4. mkdir 命令 5. rm 命令 和 rmdir 命令 6. mv 命令 7. cp 命令 8. touch 9. more 命令 less 命令 10. echo > 前言:大家好,这是一篇ubuntu常用的基…

进程概念(二)

目录 进程优先级基本概念查看系统进程PRI and NIPRI vs NI修改进程优先级的命令renice修改优先级进程其他概念 环境变量基本概念查看环境变量方法常见环境变量PATHHOMESHELL 查看环境变量环境变量相关的命令 环境变量特征命令行参数main函数中的俩个参数 argc argvmain函数的第…

机器学习--生成式模型和判别式模型的具体分析

文章目录 生成式模型和判别式模型的具体分析生成式模型定义工作原理优点缺点常见模型 判别式模型 总结生成式模型判别式模型 生成式模型和判别式模型的具体分析 生成式模型和判别式模型在机器学习中有着不同的目标、应用场景和性能特点。以下将详细分析它们的定义、工作原理、…

Golang-分离式加载器(传参)AES加密

目录 enc.go 生成: dec.go --执行dec.go...--上线 cs生成个c语言的shellcode. enc.go go run .\enc.go shellcode 生成: --key为公钥. --code为AES加密后的数据, ----此脚本每次运行key和code都会变化. package mainimport ("bytes""crypto/aes"&…

【Vue】核心概念 - module

目标 掌握核心概念 module 模块的创建 问题 由于使用单一状态树&#xff0c;应用的所有状态会集中到一个比较大的对象。当应用变得非常复杂时&#xff0c;store 对象就有可能变得相当臃肿。 这句话的意思是&#xff0c;如果把所有的状态都放在state中&#xff0c;当项目变得…

解锁ChatGPT:从GPT-2实践入手解密ChatGPT

⭐️我叫忆_恒心&#xff0c;一名喜欢书写博客的研究生&#x1f468;‍&#x1f393;。 如果觉得本文能帮到您&#xff0c;麻烦点个赞&#x1f44d;呗&#xff01; 近期会不断在专栏里进行更新讲解博客~~~ 有什么问题的小伙伴 欢迎留言提问欧&#xff0c;喜欢的小伙伴给个三连支…

虚拟机开启网络代理设置

前言&#xff1a; 不管是物理主机还是实验环境中的VMware虚拟机&#xff0c;有时候总要访问一些镜像网站或者资源网站拉取一些学习资料&#xff0c;但由于国内外网络环境的差异和网络安全的问题。总是会被阻拦。物理机相对比较容易一些&#xff0c;今天我们来说一说虚拟机应该…

Java——IO流(一)-(2/9):File类的常用方法(判断文件类型、获取文件信息、创建删除文件、遍历文件夹)

目录 常用方法1&#xff1a;判断文件类型、获取文件信息 方法 实例演示 常用方法2&#xff1a;创建文件、删除文件 方法 实例演示 常用方法3&#xff1a;遍历文件夹 方法 实例演示 常用方法1&#xff1a;判断文件类型、获取文件信息 方法 File提供的判断文件类型、获…

【数据结构(邓俊辉)学习笔记】图06——最小支撑树

文章目录 0. 概述1. 支撑树2. 最小支撑树3. 歧义性4. 蛮力算法5. Prim算法5.1 割与极短跨越边5.2 贪心迭代5.3 实例5.4 实现5.5 复杂度 0. 概述 学习下最小支撑树和prim算法。 1. 支撑树 最小的连通图是树。 连通图G的某一无环连通子图T若覆盖G中所有的顶点&#xff0c;则称…

将克隆到本地的6.824项目上传到自己的github

前置知识见&#xff1a;把自己在本地完成的mit6.s081项目上传到自己的github仓库里_mit6.s081 lab上传-CSDN博客 先在github建立一个自己的仓库 由于github可以给自己的主分支改名了&#xff0c;我这次是勾选了创建README文件 在本地同样是建立一条remote分支 git remote add…

机器学习-- 如何清洗数据集

文章目录 引言&#xff1a;数据清洗的具体步骤数据清洗的具体方法和示例1. 处理缺失值2. 去除重复数据3. 修正数据格式4. 处理异常值5. 标准化和归一化6. 处理不一致的数据7. 转换数据类型8. 数据集成 总结 引言&#xff1a; 数据清洗是数据处理和分析的关键步骤&#xff0c;旨…

MLU370-M8 chattts-ui快速出击

目录 一、paas平台环境选择二、代码环境准备1.代码下载2.环境安装modelsopetransformersaccelerate 3.常规pip安装4.代码修改4.代码修改 三.算法启动 一、paas平台环境选择 驱动选择&#xff1a;5.10.22及以上 镜像选择&#xff1a;pytorch2.1 二、代码环境准备 1.代码下载…

macOS - 终端快捷键

本文转自 Mac 上“终端”中的键盘快捷键 https://support.apple.com/zh-cn/guide/terminal/trmlshtcts/mac 以下基于系统版本 macOS Sonoma 14 文章目录 Mac 上“终端”中的键盘快捷键1、使用“终端”窗口和标签页2、编辑命令行3、在“终端”窗口中选择和查找文本4、使用标记和…

UE5基础1-下载安装

目录 一.下载 二.安装 三.安装引擎 四.其他 简介: UE5&#xff08;Unreal Engine 5&#xff09;是一款功能极其强大的游戏引擎。 它具有以下显著特点&#xff1a; 先进的图形技术&#xff1a;能够呈现出令人惊叹的逼真视觉效果&#xff0c;包括高逼真的光影、材…

《Brave New Words 》3.4 最重要的学科领域

Part III Empowering the Next Innovators 第三部分 赋能下一代创新者 The Most Important Subject-Matter Domain to Master 最重要的学科领域 In the world of education, it’s crucial for developers to field-test their ideas. Essentially, it means taking our educat…

导数和微分

导数和微分 flyfish 本文主要论述其中的区别 导数是描述函数变化率的量&#xff0c;它表示函数在某点的瞬时变化速度和切线斜率。 微分是导数的一个线性近似&#xff0c;表示函数在某点处随着自变量变化的增量。 导数和微分在本质上都是研究函数变化的工具&#xff0c;但导数…

西门子学习笔记11 - PTO脉冲指令的使用

1、使用指令前的设置 1、打开一个脉冲发生器&#xff0c;并启用 2、选择使用PTO(脉冲A和方向B) 3、硬件设置输出 4、这样前期的准备工作就完成了 2、指令的使用 1、添加指令CTRL_PTO 2、配置如下 3、方向控制程序如下 4、最后进行测试即可

总结【GetHub的WebAPI,ASSET_ID】,【Linux的jq命令】(草稿版+实际操作)

目录 1.介绍一下github中的 asset_id 2. GitHub 的 asset_id相关操作 2.1.获取特定 repository 的 release 列表&#xff1a; 2.2.获取特定 release 中的 asset 列表&#xff0c;并找到 asset_id&#xff1a; 2.3.使用ASSET_ID获取资材 3.返回的 assets 的信息 是什么样样…