java机器人聊天
Helpbot is a customer support chatbot powered by machine learning, which replaces the contact flow for guests trying to message Airbnb for support. We used Helpbot to provide intelligent help regarding COVID-19 questions, and developed workflows for our Extenuating Circumstances policy. Over 50% of users engaged with the COVID specific flow, which resulted in a significant number of customers being able to solve their problem instantly.
Helpbot是由机器学习提供支持的客户支持聊天机器人,它取代了尝试向Airbnb寻求支持的来宾的联系流程。 我们使用Helpbot提供了有关COVID-19问题的智能帮助,并为我们的“ 情节减轻”政策 开发了工作流程 。 超过50%的用户参与了COVID特定流程,这导致大量客户能够立即解决他们的问题。
Guests rely on Airbnb every day to assist them through all stages of a trip. From finding a place to stay, all the way to checking out, and returning home safely.
旅客每天都要依靠Airbnb来协助他们完成旅行的所有阶段。 从寻找住所,一直到退房,然后安全返回家园。
At the same time, users on Airbnb can have a wide variety of different issues, such as changing their payment methods, or finding their host’s phone number. This makes it essential to build a flexible interface for users to easily find solutions we have available, and, if necessary, get help from an agent. Chatbots have become increasingly popular for this use case.
同时,Airbnb上的用户可能会遇到各种各样的问题,例如更改付款方式或查找房东的电话号码。 因此,必须为用户构建灵活的界面以轻松找到我们可用的解决方案,并在必要时从代理商获取帮助。 在此用例中,聊天机器人已变得越来越流行。
For this, we created Atis: a chatbot development platform that provides an intuitive and powerful API for building chatbots.
为此,我们创建了Atis :一个聊天机器人开发平台,该平台提供了用于构建聊天机器人的直观而强大的API。
Atis is Airbnb’s intelligent interaction and assistant platform, the ‘brain’ powering Airbnb’s customer support chatbot: Helpbot.
Atis是Airbnb的智能交互和助手平台,是为Airbnb客户支持聊天机器人Helpbot提供动力的“大脑”。
Helpbot is the second step in contacting a human customer support agent. The goal of Helpbot is to quickly understand the users issue, and attempt to solve the problem in an automated way. Helpbot assists guests with many different types of issues: canceling a listing, changing reservation dates, updating notification settings, etc.
Helpbot是联系人工客户支持代理的第二步。 Helpbot的目标是快速了解用户问题,并尝试以自动化方式解决问题。 Helpbot可以帮助客人解决许多不同类型的问题:取消列表,更改预订日期,更新通知设置等。
Here is a video of a standard Helpbot dialogue that helps a user turn off notifications.
以下是标准Helpbot对话的视频,可帮助用户关闭通知。
Providing quick, reliable support became even more crucial as we faced the pandemic of COVID-19. During the height of the pandemic, we quickly built certain features into Helpbot to deliver immediate help and support to our guests and hosts who contacted us. This was made possible through the fact that:
随着我们面对COVID-19的大流行,提供快速,可靠的支持变得尤为重要。 在大流行期间,我们Swift在Helpbot中内置了某些功能,以便为与我们联系的来宾和房东提供即时帮助和支持。 通过以下事实使之成为可能:
- Chatbots do a better job of understanding the issue a user has by pulling in the user’s context.
- It’s easier to change the behavior of a chatbot, since every interaction is just treated as a message.
(COVID-19 Response)
Helpbot was leaned on heavily during the COVID-19 pandemic to help guests cancel reservations, and provide clarity, in accordance with our extenuating circumstances policy. This is a case study on how easily new behavior could be added to chatbots with significant user impact. The following will discuss a few changes we made to Helpbot to support the COVID-19 efforts.
在COVID-19期间,Helpbot严重依赖 根据我们的“ 严厉形势”政策 ,帮助客人取消预订并提供明确信息。 这是一个案例研究,说明如何将新行为轻松添加到聊天机器人中,从而对用户产生重大影响。 以下内容将讨论我们对Helpbot进行的一些更改,以支持COVID-19的工作。
(Suggested issues)
Helpbot leverages Atis’s NLU model to predict an issue when a user first enters the Helpbot thread. During the COVID-19 crisis, we retrained this model to predict whether or not a user is likely to have a COVID-19 issue, based on features including:
当用户首次进入Helpbot线程时,Helpbot利用Atis的NLU模型来预测问题。 在COVID-19危机期间,我们基于以下功能对模型进行了重新培训,以预测用户是否可能出现COVID-19问题:
- Recently viewed help center articles
- If they have an active reservation
- If they are a guest or host on the platform
If our model determines that they do, we automatically suggest this as the first prompt. Over 50% of guests answered “yes” to this prompt.
如果我们的模型确定他们这样做,我们会自动建议您作为第一个提示。 超过50%的客人对此提示回答“是”。
If a user says “yes” to this prompt, then we can immediately understand their issue without requiring the guest to type anything. After this, we deliver a “contextual instant answer” for COVID-19.
如果用户对此提示说“是”,那么我们可以立即理解他们的问题,而无需访客输入任何内容。 此后,我们为COVID-19提供了“上下文即时答案”。
(Contextual instant answers)
COVID-19 affected Airbnb users differently, depending on whether they are a guest or host, whether or not they have a reservation, and when that reservation was booked. Helpbot delivers a different COVID-19 instant answer depending on the status of the user’s account. For instance:
COVID-19对Airbnb用户的影响不同,这取决于他们是客人还是房东,是否有预订以及预订的时间。 Helpbot根据用户帐户的状态提供不同的COVID-19即时答案。 例如:
- A user who has a reservation that qualifies for an extenuating circumstances is shown a cancellation flow that help them quickly cancel and get a refund.
- A user who has a reservation that does not qualify for an extenuating circumstance is shown a standard cancellation flow, with refunds that follow the cancellation policy of the listing.
(Impact)
Overall, helpbot significantly reduced the ticket creation rate, relative to the existing contact flow during the COVID-19 crisis, and successfully supported thousands of hosts and guests.
总体而言,与COVID-19危机期间的现有联系流程相比,helpbot大大降低了故障单创建速度,并成功地为数千名主机和来宾提供了支持。
(Atis)
Atis is our in-house chatbot platform that Helpbot was developed with. Much of this post will be looking at the internals of how Atis works.
Atis是我们与之合作开发的内部聊天机器人平台。 这篇文章的大部分内容将着眼于Atis工作原理的内部。
Open vs Guided Chatbot
开放式与引导式聊天机器人
Most chatbots in academia are open domain chatbots, which allow a user to say anything, and the bot will reply with generated text that is semantically and grammatically correct. However, most chatbots deployed in practice are usually more closed domain, multi-turn, goal oriented chatbots.
学术界中的大多数聊天机器人都是开放域聊天机器人,它允许用户说任何话,并且该机器人将以生成的在语义和语法上正确的文本进行回复。 但是,实践中部署的大多数聊天机器人通常都是封闭域,多回合,面向目标的聊天机器人。
The bot triages the customer’s issue with multiple questions or “turns” of dialogue.
僵尸程序通过多个问题或“轮流”对话来分类客户的问题。
(Programming Interface)
Atis provides a programming interface that allows product teams to quickly develop chatbots. Here is a simple example of building a “hello world”-like single turn chatbot:
Atis提供了一个编程接口,使产品团队可以快速开发聊天机器人。 这是构建类似“ hello world”的单匝聊天机器人的简单示例:
This would create a simple bot that asks for your name, waits for a response, and replies: “Hi <name>, it’s great to meet you!”
这将创建一个简单的机器人,询问您的名字,等待响应,然后回复:“嗨,<name>,很高兴认识您!”
The Atis dialogue manager knows how to execute any task that implements the TaskHandler class. In this simple task, the dialogue manager will:
Atis对话管理器知道如何执行实现TaskHandler类的任何任务。 在这个简单的任务中,对话管理器将:
- Execute
prompt
执行prompt
- Send the message back to the user (“Hi, what is your name?”)
- On response, execute
response
with the message the user sent back
响应时,使用用户发回的消息执行response
This code defines a chatbot with 3 turns of dialogue, but does not specify in what order they should be executed. For that, ATIS defines a “domain definition” file, which lays out the order of the turns. The final Weather task executes a skip action. This informs the dialogue manager that this task should not wait for a response, since the bot dialogue is complete.
这段代码定义了一个具有3轮对话的聊天机器人,但没有指定应以什么顺序执行。 为此,ATIS定义了一个“域定义”文件,该文件列出了转弯的顺序。 最后的Weather任务执行跳过动作。 这会通知对话管理器该任务不应等待响应,因为机器人对话已完成。
This definition shows 3 tasks that need to be executed: name_question
, location_question
, and weather
. The initial_task_name
defines which task should be performed first, and the next_states
defines the next task that should be executed. Atis will automatically load the task handlers by the camel cased name specified in the multi_turn_domain.json
file and execute them in the specified order.
此定义显示了3个需要执行的任务: name_question
, location_question
和weather
。 initial_task_name
定义应首先执行的任务, next_states
定义应执行的下一个任务。 Atis将按照multi_turn_domain.json
文件中指定的驼峰式名称自动加载任务处理程序,并以指定的顺序执行它们。
(Task Handler Lifecycle)
Task handlers implement a lifecycle that represents the request / response nature of a typical chatbot conversation.
任务处理程序实现了一个生命周期,该生命周期代表了典型聊天机器人对话的请求/响应性质。
Much like lifecycles found in Android activity lifecycles, or React lifecycles, Atis tasks also support a lifecycle pattern where tasks are executed by a dialogue manager. The lifecycle methods Atis tasks implement are:
与Android活动生命周期或React生命周期中发现的生命周期非常相似,Atis任务也支持生命周期模式,其中任务由对话管理器执行。 Atis任务实现的生命周期方法是:
activate?
: This determines whether a task should activate based on the state of a dialogue
activate?
:这根据对话的状态确定是否应激活任务prompt
: A prompt to the user, for instance: showing a message or set of options
prompt
:对用户的提示,例如:显示一条消息或一组选项response(dialogue_input: UserInputMessage)
: A response to a prompt, for instance: the message a user typed in, or an option a user selected.
response(dialogue_input: UserInputMessage)
:对提示的响应,例如:用户键入的消息或用户选择的选项。
(Branching & Activations)
The previous example defined a linear dialogue structure, starting with the name question, and ending with weather. Atis can also define tree or graph structured dialogues with activations and edge handlers.
前面的示例定义了一个线性对话结构,从名称问题开始,以天气结束。 Atis还可以使用激活和边缘处理程序定义树或图结构的对话。
(Linear dialogues vs Tree structured dialogues)
Here is an example of using task activations to build a tree structured dialogue:
这是一个使用任务激活来构建树形对话框的示例:
The tasks that are in the branch need to implement an activate?
method. The dialogue manager will call both TravelSuggestionAnswer#activate?
and WeatherAnswer#activate?
to determine which task will be called next.
分支中的任务需要实施activate?
方法。 对话管理器将同时调用TravelSuggestionAnswer#activate?
和WeatherAnswer#activate?
确定下一步将调用哪个任务。
While the example above is somewhat contrived, this is a powerful framework for expressing complex behaviors.
尽管上面的示例有些人为设计,但这是一个表达复杂行为的强大框架。
(Edge Handlers)
In the examples specified, the activate?
method is defined on a TaksHandler
. Atis also provides an interface to declare EdgeHandler
's, which only implement the activate?
method, and are used for when transitions are too complex to squeeze into a single activate?
method. For instance, in the example above, the tasks also be written with edge handlers like this:
在指定的示例中, activate?
方法在TaksHandler
上定义。 Atis还提供了一个声明EdgeHandler
的接口,该接口仅实现activate?
方法,用于过渡过于复杂而无法压缩到单个activate?
方法。 例如,在上面的示例中,任务还使用如下边缘处理程序编写:
Like task handlers, the edge handlers will be automatically loaded and evaluated by looking up the camel cased name of the tasks in the edge.
像任务处理程序一样,边缘处理程序将通过在边缘中查找驼峰式任务名称来自动加载和评估。
(Messages & Actions)
Atis supports a wide variety of messages for example:
Atis支持多种消息,例如:
- Simple message
- Options
- Reservation Card
- Reservation Picker
- Help articles
- … And many more
These can be called in the task handlers to be sent back to the messaging client. The Atis API also supports a set of “actions” that essentially act as control flow directions for the dialogue manager. For instance:
这些可以在任务处理程序中调用,然后发送回消息传递客户端。 Atis API还支持一组“操作”,这些“操作”实质上充当对话管理器的控制流方向。 例如:
skip
: Skip the response block of a task.
skip
:跳过任务的响应块。goto(next_task_name: String)
: Jump to a task within a workflow.
goto(next_task_name: String)
:跳转到工作流程中的任务。transfer(next_workflow_name: String)
: Transfer to a different workflow.
transfer(next_workflow_name: String)
:转移到另一个工作流程。
Note: Workflows are not covered in this post for the sake of brevity. At a high level, they are a way to group a set of tasks together. For example, a cancellation workflow would involve 2 tasks (select reservation → are you sure? → confirmation).
注意:为简洁起见,本文不涉及工作流程。 从高层次上讲,它们是将一组任务组合在一起的一种方式。 例如,取消工作流程将涉及2个任务(选择预订→确定吗? → 确认)。
(Hooks)
Atis offers before and after hooks for lifecycle methods like prompt
, response
and activate
, similar to Rails.
Atis提供了针对生命周期方法的前,后钩子,例如: prompt
, response
和activate
,类似于Rails。
(Context Switching)
We can combine hooks together with object oriented programming principles to build highly intelligent context switching functionality. Context switching is necessary when the guest expresses an intent out of band. For instance, if a dialogue proceeds like:
我们可以将挂钩与面向对象的编程原理结合在一起,以构建高度智能的上下文切换功能。 当来宾表达带外意图时,必须进行上下文切换。 例如,如果对话进行如下:
In this example, the guest responded with a request instead of their name, and our framework is able to change its behavior and respond with a reservation prompt instead of the standard response of “Hello {name}, it’s great to meet you!”. This is called a context switch.
在此示例中,来宾使用请求而不是其名称进行响应,并且我们的框架能够更改其行为并使用保留提示进行响应,而不是标准的响应“ Hello {name},很高兴认识您!” 。 这称为上下文切换。
This can be implemented by building a simple abstract task handler:
这可以通过构建一个简单的抽象任务处理程序来实现:
This will automatically execute the GreetingTask
, if the term “reservation” is found in the message input.
如果在消息输入中找到“保留”一词,它将自动执行GreetingTask
。
(Dialogue Manager)
A dialogue manager in a conversational bot is responsible for traversing the dialogue graph. The dialogue manager will decide which tasks to execute by calling the activate?
method on task handlers and edge handlers. This allows us to define extremely complex dialogues, like the one we currently use for Helpbot. With the API described above, we are able to build complex flows that walk a guest or host through discovering a solution to their issue, or getting them to the right customer support agent.
对话机器人中的对话管理器负责遍历对话图。 对话管理器将通过调用activate?
来决定要执行哪些任务activate?
任务处理程序和边缘处理程序上的方法。 这使我们能够定义极其复杂的对话,就像我们当前用于Helpbot的对话一样。 借助上述API,我们能够构建复杂的流程,引导来宾或托管人发现问题的解决方案,或将其送至合适的客户支持代理。
(Understanding Customer Intents)
ATIS comes with a default with a powerful text classifier called WideText: a low latency, CNN-based text classifier.
默认情况下,ATIS带有一个功能强大的文本分类器(称为WideText):一种低延迟,基于CNN的文本分类器。
To motivate the need for such a model, imagine you want to build a chatbot that is able to understand what a user says “I want to cancel my reservation” or “my listing is not very clean” and respond intelligently. One way this can be done is by constructing a taxonomy of issues and predicting among them.
为了激发对这种模型的需求,想象一下您想构建一个聊天机器人,该机器人能够理解用户所说的“我想取消我的预订”或“我的清单不是很干净”并做出明智的响应。 做到这一点的一种方法是构建问题分类法并在其中进行预测。
“I want to cancel my reservation” →reservation.guest.cancellation
“我要取消我的预订” → reservation.guest.cancellation
“My listing is not very clean” →reservation.guest.cleanliness
“我的清单不是很干净” → reservation.guest.cleanliness
Typically, a text classification problem is framed as the following:
通常,文本分类问题的框架如下:
However, you will realize that other features will be important for understanding the user. For instance, “this house is not clean” could be a reservation.guest.cleanliness
if the user is a guest, or reservation.host.cleanliness
if the user is a host.
但是,您将意识到其他功能对于理解用户很重要。 举例来说,“这房子不干净”可能是一个reservation.guest.cleanliness
如果用户是一个客人,或reservation.host.cleanliness
如果用户的主机。
WideText is a PyTorch library that makes it easy to train and deploy multi-modal text classification models.
WideText是一个PyTorch库,可以轻松训练和部署多模式文本分类模型。
The exact details of this classifier will be discussed in a separate, future blog post. WideText forms the backbone of our chatbot intelligence.
此分类器的确切详细信息将在以后的单独博客文章中讨论。 WideText构成了我们的聊天机器人智能的Struts。
Circling back to the WhatCanIHelpWith
task, here is an example of how WideText can be used to make a prediction:
回到WhatCanIHelpWith
任务,这是一个如何使用WideText进行预测的示例:
In this example, we relied on a trained WideText model to understand user intents. The details of how to train and deploy this model will be covered separately.
在此示例中,我们依靠训练有素的WideText模型来了解用户意图。 如何训练和部署此模型的细节将分别介绍。
(Helpbot)
Helpbot is the “flagship” chatbot that is built on the Atis platform. It handles by far the most messages. At the time of this writing, Helpbot is currently processing over 100k messages per day.
Helpbot是在Atis平台上构建的“旗舰”聊天机器人。 到目前为止,它处理的邮件最多。 在撰写本文时,Helpbot当前每天处理超过10万条消息。
The core purpose of Helpbot is delivering contextual self solve content. When a guest tries to contact Helpbot, we identify their issue by asking the guest a set of questions and leveraging WideText to predict a topic. Then, we present a user with self solve content that could resolve the users issue immediately.
Helpbot的核心目的是交付上下文自助解决内容 。 当访客尝试联系Helpbot时,我们会通过询问访客一系列问题并利用WideText预测主题来确定他们的问题。 然后,我们向用户提供可以自动解决用户问题的自解决内容。
Mapping user issues to a fixed set of ticket topics makes it easy for us to quickly add new types of self solve content like help articles.
通过将用户问题映射到一组固定的故障单主题,我们可以轻松地快速添加新的自助解决内容类型,例如帮助文章。
(Conclusion)
Airbnb strives to deliver immediate help to guests and hosts who need it, especially during events like COVID. We leveraged Helpbot’s ability to quickly understand customer issues, and provide self solve solutions to help those affected by the COVID epidemic.
Airbnb致力于为需要的客人和房东提供即时帮助,尤其是在诸如COVID之类的活动中。 我们利用Helpbot的能力快速了解客户问题,并提供自助解决方案来帮助受COVID流行影响的人。
(Contributors)
Building Atis and integrating it into Helpbot was a multi-team effort. Thank you to everyone that helped make this possible:
构建Atis并将其集成到Helpbot是一个多团队的工作。 感谢所有帮助实现这一目标的人:
Carter AppletonStephanie PangJack ChenHaitao LiJosh BlaneyMichelle GuarinoCourtney KimotoMariel YoungZhenyu ZhaoBrian WangShahaf AbileahWayne ZhangJeremy WangChris ZhuAlice ZhengJoy Zhang
卡特·阿普尔顿,斯蒂芬妮·庞杰克·陈杰克·李海涛·乔什·布兰妮·米歇尔·瓜里诺·古尔妮·基本·玛丽尔·杨·赵振宇·布赖恩·王沙哈夫·阿比莱·韦恩·张·杰里米·王克里斯·朱·爱丽丝·郑乔伊