基于LLM的对话流生成:约束与实现

2024年09月02日 由 alex 发表 66 0

介绍

下图强调了聊天机器人开发中的一个关键矛盾:灵活性和控制力之间的平衡。


当对话流中嵌入更多的控制时,通常会导致更严格的约束,从而使交互变得不那么灵活。


相反,随着对话从用户的角度来看变得更加灵活,对引导对话实现特定业务目标的控制就会减少。


这种权衡是设计有效聊天机器人时的一个关键考虑因素。


7


因此,精明的聊天机器人开发框架力求在灵活性和控制之间找到最佳平衡。


通过这样做,他们旨在为用户提供更自然、更适应性的对话体验,同时仍引导互动朝着期望的业务成果发展。


这些框架通常包含自适应学习机制,允许聊天机器人在不影响对话整体方向的情况下动态调整回复。


这样做的目的是确保聊天机器人保持用户友好,同时有效推动业务目标的实现。


最终,这种平衡既能提高用户满意度,又能提高聊天机器人实现预期目的的效率。


聊天机器人是特定领域的

是的,有一些通用的对话式用户界面,如 ChatGPT、HuggingChat、Cohere Coral、Alexa 和 Google Home。


这些系统通过了解用户及其特定领域,不断努力建立语境。通过掌握这种语境,它们可以更好地理解和处理对话,最终提高回复的质量和相关性。


然而,大多数聊天机器人都是特定领域的,为特定组织或领域的产品和服务提供服务。


因此,考虑到领域和灵活性/控制性,显然有巨大的机会让 LLM 驱动对话,真正发挥 LLM 的威力......


最近的研究解决了将 LLM 驱动的对话系统集中在专业领域内的难题,这是医疗保健和客户服务等应用的关键需求。


由于这些聊天机器人具有广泛的泛化能力,它们往往有可能提供不准确或不相关的回复。为了解决这个问题,作者提出了一种无监督方法,用于自动生成特定领域的对话流,从而限制基于 LLM 的聊天机器人。


他们根据域内对话数据的可用性,提出了这些对话流的两种变体。


通过对各种对话域进行人工和自动评估,研究表明,这些数据引导的对话流提供了更好的域覆盖率,减少了大量手工制作的需要。


8


该图说明了内在流程归纳的过程。首先是生成初始流程,然后通过一系列反馈、更新和清理阶段对流程进行完善。这是通过详细的提示实现的。


集群

从下图中可以看出,语义相似的语句被归为一组。


意图

这种方法通过合并语义相似的群组来减少动作标签中的冗余,因为这些群组在动作意图上有明显的重叠(通过其标签之间的余弦相似度来识别)。


因此,这一检测强信号的过程,就会浮现出这次对话的相关意图。


9


流程生成

对话流程的生成过程与内在对话流程的生成过程密切相关。


起初,在初始流程生成的提示中包含有代表性的动作标签和领域中的对话样本。随后,应用反馈、更新和清理步骤来完善对话流程。


固有流程方法能生成广泛、通用的对话流程,但可能缺乏在现实世界对话中观察到的特定领域模式。


相反,仅仅依赖特定领域的对话实例可能会由于其可变性而限制对话流的范围。为了解决这个问题,我们采用了一种混合方法,将固有流程的广泛覆盖范围与特定领域数据的详细关注点结合起来。


合并过程包括提示 GPT-4 保留内在流程的显著特征,同时消除多余元素,从而形成所谓的数据引导流程。


固有流程示例

下面是一个名为 city_info_code.txt 的固有流程示例。请注意用户意图是如何定义和编码的。然后,每个意图都被映射到一个也被编码的机器人流程。


例如,U1 转到 B1,以此类推。


 B0[Bot: Greeting and Asks for City Information Inquiry] --> U1[User: Wants to Know About Attractions]
   B0 --> U2[User: Inquires About City Services]
   B0 --> U3[User: Asks About Local Regulations]
   B0 --> U4[User: Interested in City Events]
   B0 --> U45[User: Asks for Personalized Recommendations]
   B0 --> U46[User: Inquires About Local Culture and History]
   B0 --> U47[User: Wants Info on Dining and Shopping]
   B0 --> U48[User: Seeks Accessibility and Accommodation Info]

   U1 --> B1[Bot: Provides Information on Attractions]
   U2 --> B2[Bot: Details City Services]
   U3 --> B3[Bot: Explains Local Regulations]
   U4 --> B4[Bot: Shares Information on Upcoming Events]
   U45 --> B5[Bot: Gives Personalized Recommendations]
   U46 --> B6[Bot: Discusses Local Culture and History]
   U47 --> B7[Bot: Informs About Dining and Shopping]
   U48 --> B8[Bot: Advises on Accessibility and Accommodation]
  
   B1 --> U9[User: Requests Further Details or Ready to Explore]
   B2 --> U9
   B3 --> U9
   B4 --> U9
   B5 --> U9
   B6 --> U9
   B7 --> U9
   B8 --> U9
   U9 --> B9[Bot: Provides Additional Info or Encourages Exploration]


数据流示例

下面是一个数据流示例,名为 “警报设置代码”,对许多人来说应该是再熟悉不过的对话了。


请再次注意预先定义的意图,以及如何将机器人对话分配给不同的用户意图。此外,还有子意图或嵌套意图的概念


B0[Bot: Greeting] --> U1[User: Express need for alarm assistance]
U1 --> B1[Bot: Prompt for alarm action]
B1 --> U2[User: Set alarm]
B1 --> U3[User: Edit alarm]
B1 --> U4[User: Delete alarm]
B1 --> U5[User: Copy alarm]
U2 --> B2[Bot: Set Alarm]
U3 --> B3[Bot: Ask for alarm details]
U4 --> B4[Bot: Ask which alarm to delete]
U5 --> B9[Bot: Ask details for copying alarm]
B2 --> U6[User: Confirm alarm set]
B2 --> U7[User: Request to set repeat]
U6 --> B7[Bot: Confirm Completion]
U7 --> B8[Bot: Set repeat and confirm]
B3 --> U8[User: Specify alarm edit details]
B4 --> U9[User: Specify alarm to delete]
B9 --> U14[User: Confirm copy details]
U8 --> B5[Bot: Perform edit and confirm]
U9 --> B6[Bot: Delete alarm and confirm]
U14 --> B10[Bot: Copy alarm and confirm]
B5 --> U10[User: Confirm edit]
B6 --> U11[User: Request additional deletion]
B6 --> U12[User: End conversation]
B10 --> U15[User: Request further changes]
B10 --> U16[User: End conversation]
U10 --> B7
U11 --> B6
U12 --> B11[Bot: Expressing gratitude and farewell]
U15 --> B3
U16 --> B11
B8 --> U13[User: End Conversation]
U13 --> B11


对话示例

下面是用于生成警报代码重置流程的对话示例的一小段。整个训练文件大约有 700 个对话。每一行都是由语句、会话 ID、域和任务定义的对话。


{"session_id": "298663b0", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "i need to edit an alarm", "ok which one?", "the \"walk dog\"", "what would you like to do with it?", "change to \"feed cat\"", "changing. do you want to apply this to other alarms with this name?", "yes", "ok", "thanks", "yes"], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "9fefc2ac", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "I would like to edit a feature on my alarm.", "Alright, what would you like to edit?", "I would like to cancel all my alarms for the next week, but could you first list them all before I do anything?", "Sure. You have 5 alarms for next week. Monday at 8 AM, Tuesday at 9 AM, Wednesday at 10 AM, Thursday at 11 AM, and Friday at 12 PM. Would you like to cancel all of the alarms for next week?", "Alright, thanks. Could you cancel all my alarms?", "Sure. This action cannot be undone once completed. Would you like to proceed with deleting all of your alarms for next week?", "I would like to confirm my cancellation of all my alarms for next week.", "Your alarms for next week have been deleted.", "Very good. Thank you very much!", "You're welcome!"], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "63fb88cb", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "I needed to change one of my alarms", "I can help you with that, which alarm would you like to change?", "I need to change my 10:30 alarm \"Walk Dog\"", "Ok, what would you like to change it to?", "Let's change it to \"Feed Cat\"", "Ok. You also have \"walk dog\" set for 7PM each day. Would you like to change those alarms as well?", "Erase them. I'm not walking the dog anymore. I hired a kid.", "I can do that, is there anything else I can help you with", "Nope, that's it. Thanks, bot!", "Have a great day"], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "8c8066e6", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "I need to set an alarm", "Ok, what day and time?", "Please set an alarm for Monday June 11th at 8am", "Ok, should it be on vibrate or sound?", "Set this alarm to vibrate", "Ok, what should it be called?", "Please Title this alarm 'Pay Bills'", "Ok, anything else?", "No, that's all. Thanks!", "Welcome!"], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "dbfc73d9", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello, how may I help you?", "Set an alarm for 6:30pm", "Okay. Do you want it on sound or on vibrate?", "Sound Please", "Okay. What sound should it make? Ringing or do you want a personalized ringtone?", "I want a speaking voice tone i mean", "Okay. What speaking tone would you like?", "A gorgeous lady like", "Okay. When should the alarm go off?", "6:30pm", "What day?", "Everyday", "Okay. Alarm set successfully."], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "481aec04", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "I need to move an alarm", "which alarm", "I need my Monday alarm at three changed", "whats the new time and day", "Friday at four please", "do you want to change the name of the alarm", "Please change to ding dong", "done. anything else", "No thanks!", "yw"], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "ee342fd6", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "I need some help with my alarms.", "It would be my pleasure to assist", "I want to set a new alarm.", "I can do that for you. Would you like to title the alarm?", "Wake-up alarm. Set it for 7:00 AM.", "Creating \"Wake-up\" alarm for 7:00am. Would you like any particular sound to wake to?", "Great. Now set it to have an air horn sound.", "Setting to blow horn sound Anything else I can set for you today?", "Excellent. That's all I need. Thank you.", "You're most welcome"], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "328d3657", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "I want to change the settings for my 7:30pm alarm", "i think you mean at 8. there is no 7:30 alarm", "That's right.", "what do you want to change?", "I want to change the sound. What sound is currently set?", "sound is set at birds chirp right now", "Change that to a chime", "changing", "Thanks", "no problem"], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "d22e3a13", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "I need to modify my alarms", "I can help, what would you like to change?", "I want an alarm every Friday at 8 pm", "Every Friday at 8 PM alarm is that correct?", "yes", "Alarm noise or Vibrate?", "both", "What Alarm sound would you like?", "old phone tone", "Ok I have set an alarm for Friday at 8 PM", "thanks"], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER"]}
{"session_id": "5cb1b497", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "I need to change an alarm please.", "I can help you with that. What alarm would you like to edit?", "I would like to change my 10:30 am alarm to 11:30 am for Monday.", "Alright, I've made that change for you. Would you like to enable the vibrate feature on this alarm?", "I would like to set this alarm to vibrate.", "Enable vibrate for this alarm. You also have the option of enabling vibrate with sound, would you like to have sound play for this alarm, or only vibrate?", "Only vibrate.", "Ok, I've set this alarm up for you. Would you like to add a title?", "Yes. Add \"Milk Meeting\" as my title.", "I've made this change for you. Anything else I can do?", "That's all."], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER"]}
{"session_id": "b479a288", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "I need some help managing my alarms", "Sure, how can I help with alarms today", "I need an alarm set for ever 2 minutes between 6am and 8am.", "What sound settings do you want for these alarms?", "Shrieking baby sound", "And for what day specifically?", "Monday and Thursday", "Alarms set, anything else I can assist with?", "That is all, thanks bot.", "No problem"], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "620925cc", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "I want you to set an alarm for me", "What time would you like your alarm set for?", "7am for tomorrow please", "Alright. Your alarm is set for 7 AM.", "And can you set an alarm for Saturday at 3pm?", "Sure. A second alarm is set for Saturday, 3 PM.", "Okay, thank you so much", "You are welcome! May I help you with anything else today?", "No, that was all, goodbyte", "Goodbye. Have a nice day."], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "b5b3d0b0", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "Hello. i wanted help with setting some alarms.", "I can help with that. What alarms would you like to set?", "Starting at 6 AM tomorrow, I want to have alarms go off every 30 minutes until 8 AM.", "Done. Your alarms starting at 6 AM tomorrow have been set. Would you like to add more alarms?", "No, but can a choose the sound the alarms will make?", "Yes. Do you want the same sound settings for all alarms ?", "Yes. I want a loud sound, similar to a siren.", "Loud siren has been set to your alarms.", "Thank you. You have been very helpful.", "You are welcome."], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "c9fb5fc5", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "I need to rename an alarm please", "which alarm", "Please rename the alarm titled 'walk dog' to 'feed cat'", "done. do you want to apply it to similarly named alarms", "Yes. Please change all alarms titled 'walk dog' to 'feed cat'", "are you sure", "Yes, I'm positive", "changes done", "Great! Thanks so much", "yw"], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "84adfea3", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "I need to delete an alarm", "Okay. Which alarm do you want to delete?", "I am not entirely sure. I know I have 2 alarms at night, one is for 9pm and the other is for 10pm but I can't remember which is which. What are their titles?", "They both have the same name, actually: Nighttime Alarm.", "Oh man, Do I have an alarm named \"pick Jess up\"?", "Yes, you have several alarms under that name too.", "Okay, just delete all of those please", "Alright, I've deleted all of the alarms with that name.", "You rock! Thanks", "You are welcome. Have a good day."], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "d6077f73", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "Can you pull up my list of alarms?", "Sure, here is you alarm list.", "What alarm do I have next week on Tuesday?", "You have three meetings for Tuesday.", "Are there alarms for those? I'd like to delete the earliest one", "Three alarms named \"Meetings\" for Tuesday. The earliest alarm is for 8AM, shall I delete that alarm?", "Yes please, delete that", "Alarm \"Meetings\" set for 8AM deleted.", "Great, thanks for that!", "You're welcome"], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "c2d70b5c", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "I need help editing an alamr", "Ok, which alarm?", "My Monday 3pm alarm move it to Friday at 4pm", "Ok, same sound on that alarm?", "yes please", "and same name?", "Yes keep everything the same", "Anything else I can do for you?", "That's all thank you", "Great"], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "2e27a20b", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "Cancel all my alarms", "You have five alarms set for next week, are you sure you want to cancel all of them?", "Yeah but I want you to list them before cancelling", "Ok, your first alarm is for Monday at 3pm. Do you want to cancel that one?", "Yes. but kindly list them", "Your second alarm is for Tuesday at 1pm.", "Yes", "Your third alarm is set for Wednesday at 1pm.", "Yes", "Your fourth alarm is set for Wednesday at 3pm."], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "1763c59a", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "I'd like to edit an alarm.", "Sure! Which alarm would you like to edit?", "My alarm for tomorrow at 10 AM.", "Got it! What would you like to change it to?", "I'd like to have it play a sound.", "No problem! Which sound would you like this alarm to play?", "\"Waterfalls\".", "All done! This alarm will now play \"Waterfalls\". Is there anything else I can help you with?", "That's all, thank you!", "You are welcome! Have a great day."], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "741540d2", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "I want my Saturday alarm set for 7:00 am. to vibrate and make a bell sound.", "Sure. I can help you to set your alarm for 7:00AM and make it vibrate and make a bell sound.", "Thank you. Could you also set up a Monday to Friday alarm for 5:00 am.?", "Sure. I can set you an alarm from Monday to Friday for 5:00AM. What sound would you like that alarm to make?", "I want it to play thunder sounds.", "All done. Your alarm now makes thunder sounds.", "Could you also set up an alarm for 9:00 pm. everyday?", "Yes. I can also set up an alarm for 9:00PM everyday. What sound would you like it to play?", "Horse sounds, please.", "All done! Your 9:00PM alarm will make horse sounds!"], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "0b03aafa", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "Hi! I need help with my device.", "I can help you set and edit alarms. Do you need assistance with that?", "I want to set my alarm for 7:30 PM to vibrate only.", "You do not currently have an alarm set for 7:30 PM. You do have an alarm set for 8 PM.", "Oh okay. please change the setting for that alarm instead.", "To confirm, you want to set your 8 PM alarm to vibrate only. Correct?", "Yes.", "I will make that change. Do you need to make any other changes?", "No. That's all. Thanks!", "I am here to serve"], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}
{"session_id": "063c3d96", "domain": "ALARM_SET", "task": "ALARM_SET", "utterances": ["Hello how may I help you?", "i need to set an alarm", "What alarm do you want to set?", "i need to set several alarms", "What are the alarms that you want to set?", "i need to set alarms 15 mins apart between 6am and 8 am", "Okay. Do want the alarms every day of the week?", "yes", "Okay. I have set alarms from Mon-Sun 6 to 8 at 15 minute intervals", "great ty", "You are welcome. Can I help with anything else?"], "roles": ["BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT", "USER", "BOT"]}


总结

  • 流程创建过程首先是使用大型语言模型(LLM)生成初始流程。这种自动化水平可以很好地解决空白画布问题或空白画布瘫痪问题。
  • 然而,从现有对话入手是一种更为明智的方法。利用客户与服务代表之间现有的对话转折点,可以利用有影响力和有意义的对话。
  • 我想,有人可以遵循同样的方法,只是用现实世界的对话取代最初的 LLM 对话生成。
  • 这种方法的目的是让人类只扮演弱监督角色,从而减轻设计者和构建者的负担。
  • 对话也以具有节点和条件边的图方法为前提。
  • 该工具非常适合利用现有对话、创建语义相似的群组以及创建或生成流程,这些流程可用作开发聊天机器人的起点。
  • 这些流程可以作为设计和构建聊天机器人的起点,也可以创建原型流程,在此基础上进行构建。
  • 我不确定实现生成流程的最佳方法是什么......有一个工具可以将 ASCII 转换为可视化表示或某种图形用户界面会很有帮助。
  • 或者是某种能够解释和摄取基于文本的设计的开发框架。

文章来源:https://medium.com/@cobusgreyling/dialog-flow-generation-to-constrain-llm-based-chatbots-fe6dee4955ce
欢迎关注ATYUN官方公众号
商务合作及内容投稿请联系邮箱:bd@atyun.com
评论 登录
热门职位
Maluuba
20000~40000/月
Cisco
25000~30000/月 深圳市
PilotAILabs
30000~60000/年 深圳市
写评论取消
回复取消