基于GPT-4的人机物融合应用构造实践

点击蓝字 关注我们

人类正在进入一个人机物三元融合的万物智能互联时代,各类围绕智慧校园、智慧城市等场景的应用需求应运而生。为此,人们期望充分利用散布在社会、信息、物理三元空间中的海量资源,通过编排资源间协作与交互的方式构造出符合场景需求的人机物融合应用。 

当前,人机物融合应用的构造仍然需要用户在理解人机物资源所在环境的基础上通过专业化工具定制资源间的协作逻辑。然而,诸如在智能家居领域,让家里的老人和孩童也能达到以上目的可能是一件相当困难的事情。例如,通过应用构造,仅仅是完成家居场景下的“我在每天晚上十点洗澡,帮我准备好热水”,或者办公场景下的“我们八点钟要在会议室开会,打开灯和投屏电视”这类小事,都需要用户知晓如何组合这一系列资源,尤其是家居设备提供的功能,同时还要解决设备冲突等问题。

7977626f1953f5d76a4daa4b9fe3938b.png

以GPT-4为代表的大语言模型作为AIGC时代的新生力军,拥有着强大的上下文理解能力与目标文本生成能力,由此也使得我们对大语言模型,尤其是GPT-4能否理解物理环境和用户需求,从而协助人们自动构造出人机物融合应用产生了期待。

84c06eed01826ce7ff4446127eb69020.png

显而易见的是,当依赖GPT-4进行应用构造实践之前,我们首先要考虑的问题是GPT-4对环境的理解能力到底有多强。为此我们首先设计了一个关于环境理解的预实验。如果GPT-4能够通过考验的话,我们将基于GPT-4对环境信息的理解,后续进行两个应用构造的实验。在第一个应用构造实验中要求GPT-4通过自动构建并运行TAP(Trigger-Action Programming)规则的方式来编排人机物资源间的协作,即当trigger事件发生后执行相应的action动作,其中事件与动作均由人机物资源以接口的方式提供。在第二个应用构造实验中,让GPT-4根据用户指定的“价值观”自动对环境中动态发生的感知事件选择和执行action。诸位看官且听分解。

229be0b0c5c436eacb9daa076201f98d.png

01

环境理解

我们首先按照以下模板给出实验室环境信息,告知GPT-4当前实验室的空间信息、设备信息以及可执行的能力:

There is a lab environment consisting of 【num】 rooms:【……】
 Each room has the following equipment and sensors:【……】
Each room contains the following actions:【……】

若环境包含了额外的属性,如人数、外界温度、天气等,也可在此给出所包含的属性及初始值:

【***】 have a attribute for 【……】
Each room contains the following actions: 【……】
Each room has the following perception events:【……】

最后要求GPT给出确认信息:

If you remember the above information, please reply [Confirm]

来看一个具体的环境实例:

There is an environment consisting of four rooms: a laboratory, a conference room, a pantry, and a corridor. Each room has the following equipment and sensors: In the laboratory, there is a light, a window, a door, an air conditioner, a temperature sensor, a humidity sensor, and a light sensor. In the conference room, there is a light, a window, a door, an air conditioner, a TV, a temperature sensor, a humidity sensor, and a light sensor. In the corridor, there is a light and an intelligent meal delivery robot. In the pantry, there is a light, an intelligent water dispenser, and a window.
The conference room and laboratory have a attribute for the current number of people.
Each room contains the following actions:
Light_Turn_On(location): Turn on the lights in the room at location
Light_Turn_Off(location): Turn off the lights in the room at location
AC_Turn_On(location): Turn on the air conditioner in the room at location
AC_Turn_Off(location): Turn off the air conditioner in the room at location
Window_On(location): open the window of the room at location
Window_Off(location): Close the window of the room at location
TV_On(location): Open the TV of the room at location
TV_Off(location): Close the TV of the room at location
Each room has the following perception events:
Person_Entry(location): Someone enters the room at location
Person_Leave(location):  Someone leaves the room at location
People_Count(location): The number of people at location has changed. This method returns the changed number of people
Humidity_Change(location):  The humidity at location has changed. This method returns the changed humidity
Temperature_Change(location):  The temperature at location has changed. This method returns the changed temperature
Light_State(location):  The light intensity at location has changed. This method returns the changed light intensity




If you remember the above information, please reply [Confirm]

终于,在编辑了一长串信息之后,只需等待GPT-4回复【confirm】,我们的初始环境就构建好了!可是GPT-4真的理解了这些信息吗,诸位且看:

首先,我们询问GPT-4当前的环境信息:

13a97c6ff4dde2595a2554a873fc15a5.png

经过验证,GPT-4给出了完成正确的环境信息,可见它已经完全熟悉了自己的工作环境。

02

应用构造

GPT-4已经展现了它对物理环境的强大理解能力,接下来我们分别尝试让它进行不同类型的应用构造。

这里有一个小tip,为了确保GPT-4理解了我们的需求,在给出信息时,我们要求GPT-4在理解信息后回复【confirm】

If you remember the above information, please reply [Confirm]

11125979ca0a41d9e3c5cf820b798e53.png

2.1  基于环境理解的应用构造

Remembering the following examples of grammar rules, in subsequent conversations based on existing devices and sensors in the house, and based on the triggered sensing events, calls existing actions in various rooms, helped me build the IF-THIS-THEN-THAT application, given the IF-THEN statement , and clearly indicate the trigger, condition, and action. And given the python code that implements the above construction.
After that, remember the trigger, condition, and action,  and automatically execute the action when the trigger is triggered in the future
Example: If the temperature in the laboratory is lower than 15°C, THEN turns on the laboratory air conditioner to heat
Trigger: Temperature sensor value change
Condition: 1. Temperature sensor  in the laboratory  reading below 15°C ;2. air conditioner  in the laboratory  is off
Action: AC_Turn_On(laboratory)




If you understand these rules, please reply【Confirm】

以上是一段TAP构造的详细要求,包括trigger、condition、action三部分,我们还贴心的给出了GPT-4一个TAP示例,即当实验室温度低于15℃时打开热空调。如果将这些构造要求及案例告知GPT-4,待GPT回复【Confirm】后就可以开始构造了!

实验过程

接下来我们给出场景,有人进入会议室,要求GPT-4准备好会议环境,按照此要求构造TAP应用:

Someone enters the conference room, please prepare the conference environment. please construct the application

bee896b5b7be5cd90f82c7c9942da59a.png

TAP构造成功!在“有人进入会议室”这个场景下,GPT-4给出了IF-THEN句式,并构造了TAP规则。接下来让我们看看GPT-4会给出什么样的代码来保证TAP规则的执行:

def prepare_conference_environment(location):
    if location.Light == 'off':
        Light_Turn_On(location)
    if location.AC == 'off':
        AC_Turn_On(location)
    if location.TV == 'off':
        TV_On(location)




# 主程序入口
if __name__ == '__main__':
    while True:  
        is_first_person_entered = Person_Entry('conference_room')
        if is_first_person_entered == 1:
            prepare_conference_environment('conference_room')

以上代码对会议室环境循环监听,如果监听到人员进入的location属性为conference_room,调用prepare_conference_environment,当第一个人进入会议室时将灯、空调、投屏电视灯打开,准备好会议环境。

接下来我们将以上TAP应用和代码在真实教研室环境中实地部署,并让同学们进入会议室,实验效果如下图所示:

e377a131e8aaa882cfebdcc91479f0b0.gif

太棒了!GPT-4构造出的应用在同学进入会议室时被成功触发,并在判断当前灯光、电视的状态满足约束条件后调用相应设备接口,调用相应的action完成了会议环境的准备。

当然,善始善终的GPT-4也实现了“打包送走”功能,当参会人员离开会议室后,将灯、空调以及投屏电视等设备关闭。

Everyone leaves the conference room, please clear the conference environment. please construct the application

13a5342608e356bf7043de6890d5bb07.png

具体代码如下:

def clear_conference_environment(location):
    if location.Light == 'on':
        Light_Turn_Off(location)
    if location.AC == 'on':
        AC_Turn_Off(location)
    if location.TV == 'on':
        TV_Off(location)




# 主程序入口
if __name__ == '__main__':
    while True:  
        is_all_person_left = Person_Leave('conference_room')
        if is_all_person_left == 0:
            clear_conference_environment('conference_room')

同样的,在将应用完成部署后,并要求同学们离开会议室,实验效果如下图所示:

outside_default.png

可以看到,当全部人员离开会议室后,自动关闭灯、空调和投屏电视,真正做到了“妈妈再也不用担心我忘记关灯啦!”

88d3817795ed5e9dc7a7ee25a45af129.png

2.2   基于环境属性变更的实时应用构造

上个实验中的GPT-4还只是按照我们的指令模板做事,但如果我们忘了提前告知GPT-4制定TAP规则,进出会议室岂不是得手动开关灯和空调灯设备?优雅的人机物选手是不会允许这么麻烦的事情发生的,那就不得不让第二个实验出场了!

在第二个实验中,我们不会给出具体的TAP构建要求,而是会先告诉GPT-4在当前环境中要遵循的基本“价值观”,比如通过开关各种设备协助工作人员完成任务、维护会议室的清洁等等。同时,我们会构建感知事件提示模板,当事件发生后会按照此模板自动构造prompt并向GPT-4发送,让它结合价值观自行判断是否需要执行action。

实验过程

在实验过程中,我们按照以下模板将环境感知事件信息提供给GPT-4:

The event_type event occurred at location, and the property payload_key of the environment object object_id has been updated to payload_value.

接下来需要将要在环境中维持的“价值观”告知GPT-4,在这个例子中我们要求GPT-4做到“勤劳节俭”,不浪费一度电。

Next, I want you to maintain [Energy Saving Mode] in all your decisions, keeping the environment as comfortable as possible while conference your needs.If you understand these rules, please reply 【Confirm】.

最后我们将可供参考的构造要求及案例告知GPT,待GPT-4回复【Confirm】后就可以发送事件了!

Next, I will tell you some vague requirements. You need to recommend and automatically execute existing actions based on the status of existing devices and sensors in the room. After execution, modify the state of the associated device
For example:
Explanation: The lab is a bit hot
You need to reply: It is recommended to close the window and turn on the air conditioner -> AC_Turn_On(laboratory); Window_Of(laboratory)
If you understand these rules, please reply 【Confirm】.

由于实验室目前可供执行的设备有限,我们在仿真环境中对GPT-4生成的可执行代码进行了模拟,模拟环境如下图所示:

f6cfaf0c54156ad97c35f1f0e40bd07c.png

人机物融合应用模拟运行环境

接下来按照感知事件模板给出事件:人员全部离开会议室:

The Person_leave event occurred at conference_room, and the property people_count of the environment object conference_room_01 has been updated to 0.

fc07f8f902f2c0bb4348df2d774b2b14.png

成功!GPT-4能够分析感知事件,根据当前环境的设备信息判断需要执行的action,由GPT-4自动进行环境事件的分析并自动执行应用,彻底解放双手变得可行!

点火,起飞,应用成功构造,并在我们的模拟环境中实现了正确的效果。

03

分析评估

综合以上的研究内容我们发现,GPT-4具备出色的环境理解能力,能够准确地理解环境中的状态变化。填过提供恰当的prompt信息,它能够感知环境中发生的事件、变化和上下文,并根据这些信息作出相应的响应。

此外,GPT-4还展现出优秀的用户理解力,能够准确地理解用户的需求和意图。它能够解析用户的语言输入,理解用户所表达的意思,并能够根据用户需求构造出符合指定格式的应用。通过这些能力,GPT-4为用户提供了高效、准确的应用构建和交互体验,能够满足用户的个性化需求。

然而,尽管GPT-4仿佛一位无所不能的全能战士一般展现出了其强大的能力,但是小伙伴们在测试和使用GPT-4理解环境并构造应用的过程中,发现了GPT-4的"阿喀琉斯之踵"。

6b262714e611acc05258cd1fe476de1d.png

1. GPT-4对物理环境的理解基本正确,但在一些小问题上会存在错误(如环境中设备的数量),需要进一步增强。

当我们询问环境中有多少个传感器时,将会得到以下错误的回答,将7个传感器设备计算成11个:

6388dd3e3578a066c8d416128eaf49be.png

2. 采用不同的提示模板对GPT-4的表现影响很大,如果提示模板不对GPT-4胃口的话GPT-4很可能会在给出结果时“发癫”。在前文所述的prompt中,我们会要求GPT-4确认自己记住给出的信息,并回复【confirm】进行确认。在此我们对提示模板进行修改,保留前文出现过的各种环境信息,但去掉要求GPT-4记忆并回复确认的语句。

//删除要求确认的信息
/*If you remember the above information, please reply [Confirm].bove information, please reply [Confirm].*/

通过对环境信息进行询问,GPT-4给出了以下回答:

f85fe150151b383a177330b96161d4ab.png

可以看出,GPT-4表示自己只是一个AI,并不知道我们的环境信息,甚至还“贴心”的表示自己能为我们理解环境数据提供哪些泛泛的帮助,处于一个完全忘记了前文信息的“发癫”状态。

此外,在实际测试中发现虽然大多数场景下GPT-4可以帮助用户正确地构造出应用,但仍有小部分情况会对错误的目标设备进行错误的操作。在真实应用场景中,如何对GPT-4构造出的应用进行正确性与安全性的测试与验证将是将其落地需要解决的关键性问题。

04

总结与展望

在本次尝试中,我们初步探索了GPT-4在人机物融合应用场景中的环境理解、用户意图理解、与应用构造的能力,以GPT-4的上下文理解、内容生成能力作为最终用户与人机物世界之间沟通的桥梁,使用户可以灵活按需构造出自己想要的应用。

在未来,我们将基于本次尝试进一步对以GPT-4为代表的大语言模型与人机物融合场景的结合进行探索,包括对不用方式、不同模糊程度的用户需求的更多尝试,以及对GPT-4针对不同场景反馈性能与效率的评估。

05

参考文献

[1] Bingkun Sun, Liwei Shen, Xin Peng, Ziming Wang: SCTAP: Supporting Scenario-Centric Trigger-Action Programming based on Software-Defined Physical Environments. WWW 2023: 2916-2926

[2] Sébastien Bubeck, Varun Chandrasekaran, Ronen Eldan, Johannes Gehrke, Eric Horvitz, Ece Kamar, Peter Lee, Yin Tat Lee, Yuanzhi Li, Scott M. Lundberg, Harsha Nori, Hamid Palangi, Marco Túlio Ribeiro, Yi Zhang: Sparks of Artificial General Intelligence: Early experiments with GPT-4. CoRR abs/2303.12712 (2023)

作者:人机物融合智能组

排版:孙婕

审核:沈立炜

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值