<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[OpenCUI - Medium]]></title>
        <description><![CDATA[Provide an update on our research and findings in the areas of chatbots, LLMs, and dialog understanding. - Medium]]></description>
        <link>https://medium.com/opencui-official?source=rss----a696dc8db0a---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>OpenCUI - Medium</title>
            <link>https://medium.com/opencui-official?source=rss----a696dc8db0a---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 15:27:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/opencui-official" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Interaction Logic #2: A Simple Classification]]></title>
            <link>https://medium.com/opencui-official/dialog-management-a-developer-perspective-b34d12cae727?source=rss----a696dc8db0a---4</link>
            <guid isPermaLink="false">https://medium.com/p/b34d12cae727</guid>
            <category><![CDATA[interaction-logic]]></category>
            <category><![CDATA[dialog-policy]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[icu]]></category>
            <category><![CDATA[dialog-management]]></category>
            <dc:creator><![CDATA[Sean Wu]]></dc:creator>
            <pubDate>Fri, 27 Oct 2023 02:24:58 GMT</pubDate>
            <atom:updated>2024-03-18T23:38:28.396Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xdDN6qt4Nhyx0qsd17jbyQ.jpeg" /></figure><p>Dialog policy is the core of any chatbot, responsible for controlling the flow of the conversation. Despite its importance, there is a lack of analysis on how to build dialog policy and how it fits within the framework of user interface development. To build a chatbot effectively, let’s take a look at it from a developer’s perspective.</p><h3>Dialog policy is interaction logic</h3><p>A chatbot is essentially an application with a conversational user interface (CUI). However, it is often described in terms of natural language understanding and dialog management, which can be further decomposed into dialog state tracking and dialog policy. Sometimes, natural language understanding and dialog state tracking are referred to as dialog understanding. While both of these descriptions depict how a chatbot works, they provide limited information on how to build one.</p><p>To make it easy to launch the same product in markets with different languages, graphical user interfaces are typically divided into two layers: front-end engineers are responsible for handling the interaction logic, while UI designers focus on the look-and-feel aspects, including both language and theme. Similarly, conversational user interfaces can also benefit from being decomposed into two distinct layers.</p><ol><li>The language layer is responsible for converting natural language into structured representation and vice versa. It is composed of two modules: language understanding and language generation.</li><li>The interaction logic layer is where the bot takes a structured representation of what users want and generates an action sequence.</li></ol><p>The interaction logic is traditionally known as the dialog policy, inside the dialog understanding (DM) module. Dialog management is responsible for executing the programmable dialog policy defined by the chatbot developer. We prefer “interaction logic” over “dialog policy” in order to make it clearer that it needs to be defined to reflect business objectives.</p><h4>Why we need interaction logic</h4><p>There are many reasons why businesses do not give users what they request directly: there might be missing information in the users’ request, the requested item might be out of stock, or the business may want to promote a different product instead. Businesses need to craft interaction logic that can carry out conversations that benefit both users and the business.</p><p>Clearly, the interaction logic depends on the business conditions in the form of production APIs. For example, when users ask for a particular product, it is better to check the inventory first. It creates a bad experience if we burden the user with all the preference questions about the product and then inform them that the product is out of stock. Furthermore, instead of simply informing the user that the product is out of stock, it is better to recommends other products that maximize the business’s short-term and long-term interests.</p><h4>Who should build interaction logic</h4><p>Since the details of the interaction logic are largely determined by the business conditions and objectives, product managers, conversation designers, and existing application developers are best suited for this job because they are familiar with the business and available to make ongoing changes. Tasking external teams with a background in natural language understanding or machine learning to build chatbot interaction logic is clearly not cost-effective.</p><h3>How should we build interaction logic</h3><p>Over the years, numerous solutions have been proposed, which can be better understood based on the following three criteria.</p><h4>Probabilistic or deterministic</h4><p>With the advent of large language models (LLMs), it has become possible to generate responses given input text and conversational history in an end-to-end manner. Since these implementations, including the popular choice retrieval augmented generation (RAG), are based on statistical machine learning models, the interaction logic is generally considered to be probabilistic in nature. While you can feed in different content into the context and influence how the response is generated, these controls are not deterministic. Furthermore, making changes to these implementations requires an adequate amount of labeled data, which is never efficient.</p><p>In order to achieve their goals under ever-changing conditions and to ensure consistent and reproducible user experiences while adhering to laws and regulations, businesses tend to favor deterministic interaction logic, especially for high-impact interactions. This will be the focus of our further discussion.</p><h4>Imperative or Declarative</h4><p>Deterministic interaction logic can be developed in either a imperative or declarative fashion. The popular flow-based approach is imperative in nature, which means that builders need to specify conversation paths turn by turn. The flow-based approach is very easy to control and can be adapted to arbitrary business logic, and it can be built using a drag-and-drop, no-code solution.</p><p>Building interactions using a flow-based method is suitable for developing graphical user interfaces (GUIs) since users can only interact in predefined ways. However, in a conversational user interface (CUI), users can say anything they want, a complex of service can quickly lead to an exponentially increasing number of potential interaction paths. Consequently, the infamous ‘I don’t get it’ chatbot failure, which occurs when users venture into a conversation path that the developer did not prepare for, is bound to happen as it is not feasible to cover all possible conversational paths. Therefore, imperative tools are not a good fit for CUI.</p><p>In contrast, with a powerful runtime, declarative development tools allow builders to focus on what the bot’s behavior should be rather than how it is implemented. This declarative approach will be the focus of our further discussion.</p><h4>State Machine or schema-driven method</h4><p>There are two choices of declarative approaches: state machine or schema-driven method. The state machine can be used to model the exponentially many conversational paths by first designing the state space, then describing both the emission (bot response to user) and state transition for each state/user input pair. The emission and transition defined on a state and user input is a factorized description of how we want our bot to behave, which is independent of how the conversation reaches that state.</p><p>However, designing a state machine to model conversational behavior for complex real-world businesses can be tedious and labor-intensive. Inadequate abstractions of states are also common as a result of incremental development, thus leading to incomplete use cases. A poorly designed state machine is difficult to maintain, as changes in the state space, sometimes triggered by small feature requests, can result in the rewriting of many parts.</p><p>Instead of modeling conversations, we can directly model the end goal of task-oriented conversations: collecting information needed to trigger APIs. Since the information needed to trigger an API function is determined by its schema, builder only need to specify conversational behavior for bot to solicit required information per schema.</p><p>There are still infinitely many ways we can guide the conversation. To further reduce the design space, we can introduce two more constraints:</p><ol><li>Chatbot will steer conversations toward the delivery of services as quickly as possible, since the main reason that user communicate with business chatbot is because they want to obtain services from businesses.</li><li>Chatbot will only solicit one piece of information at any given time, which is a good practice to avoid overwhelming users.</li></ol><p>Given these two assumption, schema-driven way of define conversation behavior can be done by attach dialog annotation to component of schema. For example, a value recommendation annotation on a slot will be triggered when chatbot need to solicit user’s preference on this slot, but instead of just asking user, this annotation will present user with a candidate list that is obtained from production APIs, so every option here is serviceable. The schema-based declaration of what conversational experience we want can then be translated into low level machinery (like state chart) automatically so its runtime can execute it.</p><h3>Parting Words</h3><p>We introduce a couple of high-level dimensions that categorize how interaction logic can be defined, and list the pros and cons of each choice. We suggest that the schema-driven approach makes it possible for the same application development team to effectively build the conversational interaction logic, with both dialog understanding and scripting tasks taken care of with the help of LLMs. This enables them to build high-quality chatbots cost-effectively. For details on how the schema-driven approach works, read on.</p><h4>P.S</h4><p>If you know about Model-View-Controller, you can see the following parallel: language layer are your view, handles perception or converting interaction to semantics, and interaction layer is your controller, which are programmed to carry out the business objectives.</p><p>Schema-driven approach is first introduced in a<a href="https://nlp.stanford.edu/acvogel/gus.pdf"> seminal paper</a> from Xerox Park under the name of frame-driven approach. There, a frame (also known as a semantic frame) represents the structured information required to deliver a service, thus is another term for schema. Incidentally, Xerox Park also invented the mouse and GUI.</p><p>Reference:</p><ul><li><a href="https://opencui.medium.com/why-chatbots-fail-2f8e21b6e5dd">Interaction logic #1: where chatbots fail</a></li><li><a href="https://medium.com/opencui-official/type-based-conversational-user-interface-67e562185e56">Interaction logic #3: a type-based approach</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b34d12cae727" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opencui-official/dialog-management-a-developer-perspective-b34d12cae727">Interaction Logic #2: A Simple Classification</a> was originally published in <a href="https://medium.com/opencui-official">OpenCUI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dialog Understanding #7: Why Function Calling is Not the solution?]]></title>
            <link>https://medium.com/opencui-official/can-openais-function-calling-solve-dialog-understanding-a-case-study-533d1e23c807?source=rss----a696dc8db0a---4</link>
            <guid isPermaLink="false">https://medium.com/p/533d1e23c807</guid>
            <category><![CDATA[dialog-understanding]]></category>
            <category><![CDATA[conversational-ui]]></category>
            <category><![CDATA[calling-function]]></category>
            <category><![CDATA[usd]]></category>
            <dc:creator><![CDATA[Sean Wu]]></dc:creator>
            <pubDate>Wed, 25 Oct 2023 19:07:44 GMT</pubDate>
            <atom:updated>2024-10-14T03:44:01.060Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6RjeCGwDuo7p9uPY_Qg-Bg.png" /></figure><p>While it is possible to employ elaborate prompt engineering to make ChatGPT convert natural language task requests into structured representations of their meaning, the recent introduction of function calling API has significantly simplified this process. However, can ChatGPT’s function calling alone solve dialog understanding once and for all? Let’s find out.</p><h4>So what is function calling anyways?</h4><p>On the surface, OpenAI’s function calling appears to be a zero-shot implementation of dialog understanding. Given a set of function descriptions, OpenAI models with this feature will determine whether the user’s input implies calling one of these functions. If so, they generate a function object encoded in JSON, specifying which function to call, as well as the values users mentioned for its parameters. Upon receiving this JSON representation of function calling, your dialog management logic can decide what to do in cases such as missing values for required arguments. The OpenAI API can be invoked in the following way:</p><pre>import openai<br>import json<br>openai.api_key = &quot;&quot; // your openai key here.<br>def getFunction(input, functions):<br>    messages = [{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: input}]<br>    response = openai.ChatCompletion.create(<br>        model=&quot;gpt-3.5-turbo-0613&quot;,<br>        messages=messages,<br>        functions=functions,<br>        function_call=&quot;auto&quot;,  # auto is default, but we&#39;ll be explicit<br>    )<br>    return response[&quot;choices&quot;][0][&quot;message&quot;].get(&quot;function_call&quot;)</pre><p>Notice that the same completion API endpoint is used, and the main difference is that you can now supply a list of JSON function objects to specify the names and descriptions of some functions, as well as the names and descriptions of their parameters. When the input utterance can be interpreted as triggering a certain function, the API will return a well-structured JSON object adhering to your custom schema, specifying both the name and arguments of the function.</p><h4>Use case #1: simple food ordering</h4><p>First, let’s try it with single function in the food ordering use case with the following message and function description:</p><pre>foodOrdering = {<br>      &quot;name&quot;: &quot;FoodOrdering&quot;,<br>      &quot;description&quot;: &quot;Get the dish with its quantity&quot;,<br>      # The slots in a skill<br>      &quot;parameters&quot;: {<br>          &quot;type&quot;: &quot;object&quot;,<br>          &quot;properties&quot;: {<br>              &quot;dishName&quot;: {<br>                  &quot;type&quot;: &quot;string&quot;,<br>                  &quot;description&quot;: &quot;The name of the dish, e.g. french fries&quot;,<br>              },<br>              &quot;quantity&quot;: {<br>                  &quot;type&quot;: &quot;string&quot;,<br>                  &quot;description&quot;: &quot;The quantity of this dish&quot;<br>              },<br>          },<br>          &quot;required&quot;: [],<br>      },<br>  }<br><br>print(getFunction(&quot;Hey, can I get some chicken sandwiches please?&quot;, [foodOrdering]))</pre><p>will print this:</p><pre>&gt;{<br>&gt;  &quot;arguments&quot;: &quot;{\n  \&quot;dishName\&quot;: \&quot;chicken sandwiches\&quot;\n}&quot;,<br>&gt;  &quot;name&quot;: &quot;FoodOrdering&quot;<br>&gt;}</pre><p>As you can see, the parsing of the user input is successful, but it is not always reliable. For example, sometimes the model randomly fills the “quantity” slot with either “1” or “2” for the input “some chicken sandwiches.” This can increase the workload for the dialog management module. However, for food ordering, we can always use a confirmation to address this problem.</p><h4>Use case #2: Missing parameters</h4><p>What happens if user failed to mention the required parameters for the function? Let’s try the reservation:</p><pre>function2 = {<br>    &quot;name&quot;: &quot;MakeReservation&quot;,<br>    &quot;description&quot;: &quot;Make Reservation&quot;,<br>    &quot;parameters&quot;: {<br>        &quot;type&quot;: &quot;object&quot;,<br>        &quot;properties&quot;: {<br>            &quot;number&quot;: {<br>                &quot;type&quot;: &quot;number&quot;,<br>                &quot;description&quot;: &quot;number of people&quot;,<br>            },<br>            &quot;date&quot;: {<br>                &quot;type&quot;: &quot;string&quot;,<br>                &quot;description&quot;: &quot;date of the reservation&quot;<br>            },<br>            &quot;time&quot;: {<br>                &quot;type&quot;: &quot;string&quot;,<br>                &quot;description&quot;: &quot;time of the reservation&quot;<br>            },<br>        }<br>    }<br>}<br>message2 = [<br>    &quot;Hi, I would like to make a reservation for a table of two at 2:00 pm tomorrow.&quot;,<br>    &quot;Hi, I would like to make a reservation for a table of two for tomorrow.&quot;,<br>    &quot;Hi, I would like to make a reservation for a table of two.&quot;,<br>    &quot;Hi, I would like to make a reservation for a table&quot;]<br>for message in message2:<br>    print(getFunction(message, [function0, function11, function2]))</pre><p>Interestingly, the number of parameters for which the user provides values significantly influences ChatGPT’s behavior here. It makes conversion only when enough parameters are filled by the user’s utterance. When not enough parameters are filled, it does not perform even if user clearly and explicitly requesting a reservation, evident by last two utterances above. This behavior is not acceptable for dialog understanding as it makes extremely difficult for implementing dialog management. Nonetheless, it might be suitable for tool use as a tool in building agents, which could be the target use case for this API’s design anyway.</p><h4>Use case #3: user changes their mind</h4><p>What happens if user change their mind on some of their choice?</p><pre>function10 = {<br>    &quot;name&quot;: &quot;SlotUpdate&quot;,<br>    &quot;description&quot;: &quot;change the value&quot;,<br>    # The slots in a skill<br>    &quot;parameters&quot;: {<br>        &quot;type&quot;: &quot;object&quot;,<br>        &quot;properties&quot;: {<br>            &quot;newValue&quot;: {<br>                &quot;type&quot;: &quot;string&quot;,<br>                &quot;description&quot;: &quot;the new value&quot;,<br>            },<br>            &quot;oldValue&quot;: {<br>                &quot;type&quot;: &quot;string&quot;,<br>                &quot;description&quot;: &quot;the old value&quot;,<br>            },<br>        }<br>    }<br>}<br><br>function11 = {<br>    &quot;name&quot;: &quot;SlotUpdateDish&quot;,<br>    &quot;description&quot;: &quot;change the dish&quot;,<br>    # The slots in a skill<br>    &quot;parameters&quot;: {<br>        &quot;type&quot;: &quot;object&quot;,<br>        &quot;properties&quot;: {<br>            &quot;newDishName&quot;: {<br>                &quot;type&quot;: &quot;string&quot;,<br>                &quot;description&quot;: &quot;the new dish&quot;,<br>            },<br>            &quot;oldDishName&quot;: {<br>                &quot;type&quot;: &quot;string&quot;,<br>                &quot;description&quot;: &quot;the old dish&quot;,<br>            },<br>        }<br>    }<br>}<br>message1 = &quot;Can I change fish sandwich to chicken sandwich, please?&quot;</pre><p>But it seems that OpenAI models have a hard time if we use the generic version of SlotUpdate (function10):</p><pre>&gt; print(getFunction(message1, [function0, function10]))<br>&lt; {<br>&lt;  &quot;arguments&quot;: &quot;{\n  \&quot;dishName\&quot;: \&quot;chicken sandwich\&quot;\n}&quot;,<br>&lt;  &quot;name&quot;: &quot;FoodOrdering&quot;<br>&lt; }</pre><p>But it worked when a concrete version of SlotUpdate (function11) is provided:</p><pre>&gt; print(getFunction(message1, [function0, function11]))<br>&lt; {<br>&lt; &quot;arguments&quot;: &quot;{\n  \&quot;newDishName\&quot;: \&quot;chicken sandwich\&quot;,\n  \&quot;oldDishName\&quot;: \&quot;fish sandwich\&quot;\n}&quot;,<br>&lt;  &quot;name&quot;: &quot;SlotUpdateDish&quot;<br>&lt; }</pre><h4>Why function calling did not solve dialog understanding?</h4><p>Clearly, the function calling API is NOT a viable solution for dialog understanding. However, the problem is not solely about accuracy, as it can and will be improved. Instead, it needs to be designed for the dialog understanding use case and address the following very issue of users not supply complete information needed to call a function in one shot:</p><pre>User: I like to get your house meal please. <br>Bot: What side do you perfer?<br>User: Onion Rings, thanks.<br>Bot: What about drink?</pre><ol><li>While function calling is appropriate for the first turn, it is completely inadequate for the second turn: “Onion rings, thanks”. To correctly understand this utterance, we need another API with specify both user utterance and the function in focus, along with the parameters specification.</li><li>No matter how much improvement OpenAI makes to their function calling APIs, their model will still make mistakes. When these mistakes pose a high risk or have a high impact on businesses, we need a quick and easy way to address them, instead of waiting for the next round of fine-tuning.</li><li>New product name might not be in both pre and post training of the LLMs, so a list of product names can potentially improve conversions. There needs to be an effective way to make use of such a business-specific list, ideally without resorting back to retraining the model.</li></ol><h4>Parting words</h4><p>Using function descriptions alone, ChatGPT cannot fully address dialog understanding as shown above. That being said, the zero-shot text-to-JSON conversion capability with just an API specification certainly brings hope for a more developer-friendly way of building dialog understanding modules. How do we address these open issues while maintaining the same level of developer-friendliness? Read on.</p><p>Note: this write-up is based on the research done by <a href="https://medium.com/u/2d0781cefb8">SUNNYMAY MAY</a>. Thanks.</p><p>References:</p><ul><li><a href="https://opencui.medium.com/dialog-understanding-7-api-design-cf472d7725f">Dialog Understanding #7: API design</a></li><li><a href="https://opencui.medium.com/service-chatbot-using-chatgpt-case-study-1-f76aa80409e9">Can ChatGPT be used to take food orders? It is complicated.</a></li><li><a href="https://opencui.medium.com/function-calling-shift-focus-to-interaction-logic-30cd457f8012">Function calling: Shift focus to interaction logic</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=533d1e23c807" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opencui-official/can-openais-function-calling-solve-dialog-understanding-a-case-study-533d1e23c807">Dialog Understanding #7: Why Function Calling is Not the solution?</a> was originally published in <a href="https://medium.com/opencui-official">OpenCUI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interaction logic #3: a type-based approach]]></title>
            <link>https://medium.com/opencui-official/type-based-conversational-user-interface-67e562185e56?source=rss----a696dc8db0a---4</link>
            <guid isPermaLink="false">https://medium.com/p/67e562185e56</guid>
            <category><![CDATA[dialog-management]]></category>
            <category><![CDATA[schema-based]]></category>
            <category><![CDATA[interaction-logic]]></category>
            <category><![CDATA[schema-guided]]></category>
            <dc:creator><![CDATA[Sean Wu]]></dc:creator>
            <pubDate>Wed, 25 Oct 2023 02:46:35 GMT</pubDate>
            <atom:updated>2024-03-18T21:28:53.596Z</atom:updated>
            <content:encoded><![CDATA[<h3>Interaction Logic #3: Schema-Driven Approach</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*4LEUC-nttxOOi06cuX4mag.png" /></figure><p>Building conversational experience using LLMs is easy, but the solution is not dependable as we want. What do we do? The flow-based approach, widely used in building user interface applications, models both user input and system response as turn-by-turn chains. Defining the system’s response in the chain gives developers complete control over interactions, making it easier to achieve business objectives and provide an excellent user experience.</p><p>However, defining the system’s response in this way does not reveal why a particular response is necessary. When a current interaction is not covered by predefined flows, the system simply does not know what to do, leading to the infamous chatbot response, ‘I don’t understand’.</p><p>To prevent such a bad user experience, developers must carefully cover every possible interaction flow that a user can get into under this imperative setting. This is not too difficult for graphical user interface (GUI) applications since users can only interact with the system in predefined ways. However, since conversational user interfaces (CUIs) allow users to say anything at any turn, developers are forced to pick their poison: either attempt to enumerate an exponentially increasing number of conversational paths, leading to significant cost overruns, or risk providing a poor user experience by omitting some conversational paths.</p><p>So, are we doomed, or are there alternatives? To figure that out, let’s start with why businesses want to build chatbots in the first place.</p><h4>Conversation is merely a means to expose service APIs</h4><p>In order to provide consistent and reproducible service, most of the functionalities modern businesses provide to their users are digitized in form of APIs, regardless what frontend are used to expose them. Businesses build chatbots just so that they can expose their service APIs through conversational user interface.</p><p>This means that instead of worrying about the infinite paths that users can lead the conversation into, businesses only need to worry about the conversation paths that are related to the services they provide. For example, when faced with a question about the best barber shop in the neighborhood, a dental front-desk chatbot can choose to politely disengage or redirect the conversation back to dental-related topics. None of these choices will generally be construed as negative user experiences.</p><p>Furthermore, as soon as we detect the intent from the user, businesses, not users, are in the better position to steer the conversation toward delivering the service since they have dealt with such requests over and over again. Indeed, since users may not be aware of current business conditions, including inventory, the chatbot often needs to drive the conversation instead of passively responding to user input.</p><p>Furthermore, as soon as the user’s intention is known, businesses, not users, are in the better position to steer the conversation toward delivering the service. This is not only because businesses have dealt with such requests over and over before so they are experience, but also because they have access to current business conditions, including inventory, which can be crucial for effective communication.</p><h4>Interaction logic is about slot filling</h4><p>When a user specifies a service they want and provides all the information needed by the service in one shot, and their choices are serviceable, we simply invoke the target API function, render the result back to the user, and we are done. No interaction logic is needed.</p><p>Often, they will miss something. So after we pick up the user intent on what service they want, we need to design the conversation for the chatbot to gather the required information needed by the corresponding API, or in developer terms, to create a callable instance of that API function. This simply means we need to conduct conversations to recursively collect user preferences on slots, which include both the input parameters and their component attributes, for that API function. This process creates a value instance for each slot required, and thus is known as slot filling.</p><p>Clearly, up-to-date information from the production system can significantly improve slot filling efficiency. For example, when selling movie tickets, instead of asking the user for their preferred showtime, it is much better to provide them with a candidate list of showtimes that still have available seats. This way, we avoid scenarios where we repeatedly apologize for options they choose but we cannot fulfill.</p><p>The question is, how do we inject such information into the chatbot, design the interaction logic for it so that it can take advantage of business conditions and effectively steer conversations to help users? We already know flow-based approach does not work as it requires builder to specify exponentially many path.</p><h4>Runtime with default behavior</h4><p>Modern GUI applications are all developed using an event driven approach. In stead of writing a series of step-by-step instructions that fully defined user experience, in event-driven programming, developer only define events and their corresponding actions, the program responds to events as they happen based on developer defined event-action mapping.</p><p>In this event-driven approach, builders/developers only need to make decisions at a local level: determining the desired behavior if a particular event is triggered. With a smart runtime that provides good default behaviors for various events, it is possible for builders to only specify the behavior when they need to differentiate, which can reduce the effort on the builder’s side.</p><p>The runtime for conversational user interfaces (CUIs) needs to handle more issues due to the flexibility CUIs allow. It needs to maintain the context for more than one topic so that a user can engage in conversation on multiple topics. When the user finishes or abandons a detour topic, the runtime needs to automatically bring the conversation back to the original topic without the developer’s attention. We further assume that the runtime will always ask the user one question at any given time, in order to make it easy for the user to follow. Given a runtime with the goal of bring users the intended service as quickly as possible, we have the following schema-driven approach to define/build conversational user interfaces.</p><h4>Define/Build CUI in 3 Layers</h4><p>When the user does not provide their preference required for a slot, then designers or builders need to define the desired conversational behavior for the chatbot to gather such information. With the runtime defined above, we can define the CUI in three layers using a schema-driven approach:</p><ol><li>First, declare types for API and their parameters at the schema layer so that we know what type we need to create instances for via conversation.</li><li>Then, attach dialog annotations onto these types at the interaction layer, so the chatbot knows what to do if the information is missing for a slot of that type, or when the information provided is not serviceable currently by business.</li><li>Finally, complete dialog annotations at the language layer by adding templates for how semantics should be rendered in natural language and exemplars for how utterances should be converted to structured semantics.</li></ol><p>Dialog annotations specify the expected behavior of the chatbot during its building instances for different types. Here are some example dialog annotations:</p><ul><li>“Prompt” indicates how to prompt the user for their preferences on a slot.</li><li>“Value recommendation” provides a list of candidates to the user for them to choose one from. You need to specify how to get the list, what happens if the list is empty or has only one item, and what to do if there are more items than what you can fit in one turn, etc.</li><li>“Value check” defines what to do if the user’s initial preference is not serviceable, etc. Of course, you want to define how to check the value.</li></ul><p>Taking movie ticketing as an example, the decisions you have to make at each layer are:</p><ol><li>At schema layer, skill ‘<strong>buyMovieTicket’</strong> should have the following slots with their types. We assume the conversation happens in the logged-in session, so the user is known:<br><strong><em>movieTitle</em></strong><em>: MovieTitle, the title of movie.<br></em><strong><em>date</em></strong><em>: LocalDate, The date that the movie ticket for.<br></em><strong><em>showTime</em></strong><em>: LocaTime, The time that the movie is showing.<br></em><strong><em>format</em></strong><em>: The format the movie, e.g. IMAX, 3D, standard. etc.</em></li><li>At interaction layer, you decide how to create an instance of each slot in a language-independent fashion.<br><strong><em>movieTitle</em></strong><em>: required, prompt, value recommendation, value check.<br></em><strong><em>dat</em></strong><em>e: if the user did not mention a particular date, assume today.<br></em><strong><em>showTime</em></strong><em>: required, prompt, value recommendation, value check.<br></em><strong><em>format</em></strong><em>: only prompt if the movie has more than one format available.</em></li><li>At language layer, you define the template to render the dialog act into natural text and exemplar to showcase what semantics a natural language expression should be mapped into. For example, there is the prompt for each slot in English:<br><strong><em>movieTitle</em></strong><em>: ‘Which movie are you interested in?’<br></em><strong><em>showTime</em></strong><em>: ‘Great! Which showtime works best for you?’<br></em><strong><em>format</em></strong><em>: ‘Do you prefer IMAX or regular?’</em></li></ol><h4>Benefits, benefits and benefits</h4><p>This schema-driven approach comes with these characteristics that make it cost-effective to create exceptional conversational experiences.</p><ol><li>Declarative: Dialog annotations declaratively specify the desired conversational behavior for creating an instance of a type. Once defined, these annotations are executed by the OpenCUI runtime. At any given turn, the chatbots identify the slot that is missing a value and then try to fill it by executing the corresponding dialog instructions, regardless of how the conversation was led to that point. This eliminates the need to enumerate all potential interaction paths in order to provide a good user experience.</li><li>Reusable component: One of the cardinal sins in software development is building everything from scratch. Dialog-annotated types, also known as components, are naturally composable. This allows developers to construct complex systems by assembling reusable and interchangeable components, thus alleviating the burden of maintenance and reducing development time and effort.</li><li>Implicit context management: One of the defining characteristics of natural language is that the same word can have different meanings in different contexts. On the OpenCUI platform, all annotations, including template and exemplar, are attached to type. Annotations only come into play when the OpenCUI runtime attempts to create an object to fill the corresponding slot in their hosting type. Therefore, both response rendering and language understanding are inherently context-dependent.</li></ol><h4>Parting words</h4><p>Instead of trying to enumerate all possible conversation paths that users could visit, we propose to focus on the services that all the constructive conversations can lead to, since that how business provide value for their users. By defining actions for conditions under the necessary sense, builders can provide behavior specifications when needed and let the runtime do its thing. We hope the schema-driven OpenCUI can help you build the great conversational experience your users deserve, without trapping you in the implementation details.</p><p>References:</p><p><a href="https://masterofcode.com/blog/conversational-design-1-designing-conversational-interactions">Conversation Design: Designing the Flow of your Bot&#39;s Conversation</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67e562185e56" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opencui-official/type-based-conversational-user-interface-67e562185e56">Interaction logic #3: a type-based approach</a> was originally published in <a href="https://medium.com/opencui-official">OpenCUI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interaction Logic #1: Where Chatbots Fail]]></title>
            <link>https://medium.com/opencui-official/why-chatbots-fail-2f8e21b6e5dd?source=rss----a696dc8db0a---4</link>
            <guid isPermaLink="false">https://medium.com/p/2f8e21b6e5dd</guid>
            <category><![CDATA[interaction-logic]]></category>
            <category><![CDATA[dialog-policy]]></category>
            <category><![CDATA[conversational-ui]]></category>
            <category><![CDATA[dialog-management]]></category>
            <dc:creator><![CDATA[Sean Wu]]></dc:creator>
            <pubDate>Wed, 25 Oct 2023 02:46:10 GMT</pubDate>
            <atom:updated>2024-03-13T04:39:34.443Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ta3jU8Wt6UngkvKCUTyi1A.png" /></figure><p>If you Google ‘chatbot fails’, you will find numerous page hits. Most of these pages merely document the failures without offering detailed analyses on why they occur. However, understanding why chatbots fail is the first step toward achieving the desired results in chatbot development.</p><p>It is useful to base the postmortem analysis on the following conceptual model, where chatbots consist of language understanding, dialog management or interaction logic, the actual functionalities behind service APIs, and text rendering or language generation. In the remainder of this blog, let’s examine some examples from the top Google search results, and identify the potential reasons for their failures, as well as possible fixes for them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*cd9WWcgB4eKaTo7DuVWTvg.png" /></figure><h4>I do not get it.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*HnHf84J0EUkG0aPreGc_jQ.png" /></figure><p>On the surface, this appears to be a dialog understanding issue. However, any legitimate dialog understanding systems would no longer make this kind of error. This should be considered an interaction design failure. Asking more than one question at a time can confuse the user and make it more difficult for dialog understanding to perform its job effectively. Particularly if the interaction logic is flow based, and it will expect an answer to “where you are” and thus get stuck. Therefore, it is advised not to do so.</p><h4>Which location?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*Oj1qKdmfTj2tnTAfPZ3xkQ.png" /></figure><p>Understanding the context of a conversation is crucial for a chatbot to provide relevant and coherent responses. If the chatbot fails to interpret the context correctly or lacks the ability to maintain context over multiple turns, it can lead to misunderstandings and unsatisfactory replies.</p><p>There are two types of context in conversation: conversational context and non-conversational context. The provided example is an instance where conversational context is not utilized. Utilizing conversational context is not difficult. But when the chatbot builder needs to explicitly manage it, it can quickly become problematic for them, especially when the desired service involves multiple slots and the user takes many conversational detours. Luckily, newer chatbot platforms like OpenCUI now come with implicit management of conversational context, allowing you to focus on building the interaction logic that benefits both your business and your users.</p><h4>Don’t you have my number?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*0EhhG_sbFeZQsdJQOar1Vw.png" /></figure><p>Requesting users to identify themselves in a logged-in channel, like iMessage, is another common failure. A chatbot is simply a piece of software with a conversational user interface, and this fact can be overlooked when using fancy terms like conversational AI. Consequently, all the best practices accumulated over the years in developing user-facing applications are disregarded. However, the involvement of software developers is necessary to leverage non-conversational context. Integration with existing business systems, on the other hand, can be easily accomplished by existing business application developers to make conversations natural and effective.</p><h4>Cancel</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*syYYNyX7KlraOA9cXMnHPg.png" /></figure><p>This is an example of undefined scenario. The flow-based approach was initially designed to model user interactions in GUI applications. In GUI applications, users can only interact with your app based on what you’ve implemented for them. Providing a consistent experience is relatively straightforward using the flow-based approach — simply by covering all possible happy paths and eliminating interaction choices that might lead the user away from the desired path. However, for CUI applications or chatbots, due to the user’s ability to freely express their desires at any point, you are compelled to consider all potential conversation paths, or you risk the user becoming stuck in an undefined experience.</p><p>As demonstrated in the example above, some of these user requests are domain-independent. Thus it is helpful to pick a platform that can automatically handle these domain-independent dialog acts so that chatbot builders can focus on domain-dependent interactions and provide a better user experience.</p><h4>Can you take water bottles?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*Bvth_8-a-kmgZwhsUN4evA.png" /></figure><p>On the surface, this may appear to be another language understanding issue. However, in reality, it is more likely due to a lack of skills in handling typical user requests related to the service. Since a chatbot can only understand what it is instructed to comprehend, if the platform makes it easier to develop potentially context-dependent skills, developers can create more skills, leading to a significantly improved user experience. Of course, this particular question can potentially be addressed by retrieval augmented generation (RAG) if there are existing documents that contain the answer to it.</p><h4>Parting words</h4><p>In this blog, we randomly sampled a couple of pages from the top Google search results for ‘chatbot fails’ and analyzed the reasons behind their failures. Despite many failures appearing to be language understanding-related at first glance, a deeper analysis reveals otherwise: most of the time, the key reason is the inability to develop the self contained conversational interaction logic, or dialog policy.</p><p>Designing and implementing dialog policy can be more challenging than its graphical counterpart. Under a graphical user interface (GUI), users can only follow the predefined conversational flow. Given the budget, developers can always define interaction flows so that users never run into an undefined state, even though many possibilities are not covered, so functionality can be hard to find. But for a conversational user interface (CUI), users can and will express themselves freely at any turn, so the interaction logic needs to handle all reasonable possibilities. Trying to cover all these possibilities using a path-based approach is futile, as evident by all the common chatbot failures: ‘Sorry, I do not get that.’</p><p>Chatbots are simply applications with a conversational user interface. While they have the potential to provide a great user experience while achieving your business goals, you need to program it the right way. Since most popular chatbot platforms were designed before advent of LLMs mainly focused on language understanding, it is time for chatbot developers to <a href="https://medium.com/@opencui/rethink-chatbot-building-for-llm-era-a3abe5ac9298">rethink how they develop chatbots</a>.</p><p>Note: This blog is based on the research done by Lu Zeng. Thanks.</p><p>Reference:</p><ul><li><a href="https://opencui.medium.com/dialog-management-a-developer-perspective-b34d12cae727">Interaction logic #2: that is dialog management</a></li><li><a href="https://opencui.medium.com/type-based-conversational-user-interface-67e562185e56">Interaction logic #3: a type-based approach</a></li><li><a href="https://opencui.medium.com/rethink-chatbot-building-for-llm-era-a3abe5ac9298">Rethink Chatbot Building for LLM era</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f8e21b6e5dd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opencui-official/why-chatbots-fail-2f8e21b6e5dd">Interaction Logic #1: Where Chatbots Fail</a> was originally published in <a href="https://medium.com/opencui-official">OpenCUI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interaction logic #5: a state chart implementation]]></title>
            <link>https://medium.com/opencui-official/interaction-logic-5-a-state-chart-implementation-7a1802bd9c49?source=rss----a696dc8db0a---4</link>
            <guid isPermaLink="false">https://medium.com/p/7a1802bd9c49</guid>
            <category><![CDATA[icu]]></category>
            <category><![CDATA[interaction-logic]]></category>
            <category><![CDATA[dialog-management]]></category>
            <dc:creator><![CDATA[Sean Wu]]></dc:creator>
            <pubDate>Wed, 25 Oct 2023 02:45:28 GMT</pubDate>
            <atom:updated>2025-01-10T17:02:34.461Z</atom:updated>
            <content:encoded><![CDATA[<h3>Interaction Logic #5: a statechart implementation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1iSeUDLUqb8MOQ50lCC7WQ.png" /><figcaption>Source: lucidchart.com</figcaption></figure><p>The goal of a user interface (UI) is to create a object of some function type, so that it can be invoked to deliver the corresponding servcie to the end user. To achieve this, we also need to build instances for the function’s parameters according to their types. Schema-guided or type-based approach build a conversational user interface (CUI) by annotating each type with information on how to create instances of that type via conversation. These dialog annotations define the expected behavior for both language perception and interaction logic. We have listed common interaction logic cases and their declarative configuration here; Now, let’s explore how these declarative descriptions can be translated into state machines so chatbot can deliver desired conversational experiences consistenty.</p><h4>What type system do we need?</h4><p>Since APIs involve the exchange of data between different systems or components, to ensure that the exchanged data is well-formed, consistent, and interoperable, API definitions require a well-defined type system. To bridge the user with the APIs served by businesses, the first question is thus: What types do we need to define as the return type and types for input parameters for these APIs?</p><p>OpenAPI, formerly known as Swagger, is the most widely adopted standard for declaring language-agnostic contracts for APIs. By adopting the OpenAPI type system, we can create conversational user interfaces for all the APIs defined using it.</p><p>We will concentrate on a subset of OpenAPI type systems that allow for conversational interaction. Following convention, let’s use the term ‘slot’ to refer to both input parameters for functions and member data for composite types. In addition to primitive types or entities, we also provide support for the following types: containers for multi-valued slots, polymorphism for abstract slots, and user-defined types for composite slots.</p><h4>State machine for entity slot</h4><p>The conversational interaction for a primitive type or entities is simplest, particular when we skip the value recommendation. Under this setting, the interaction for filling a slot of this type can be defined by a state machine with the follow states:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*HsdlQsmVo-9rNNc_s8KMgg.png" /></figure><ol><li>Init state. In this state, bot will check the configuration for two things: whether interaction logic can provide initial value for this slot; and whether user interaction are needed to update the value.</li><li>Ask state. In this state, bot will prompt user for new value for this slot.</li><li>Value check state. In this state, we decide whether the candidate value is valid per interaction logic, which might involve the production API. When candidate value is deemed not serviceable, we go back to ask again, otherwise, we move on to confirmation state.</li><li>Confirmation state. In this state, we ask user to confirm whether the value is indeed what they want for the current slot. If not, we go back to ask state again.</li></ol><p>Please note that the diagram above is just a sketch. Depending on whether value checks and confirmations are configured, there could be many possible transitions missing from this diagram. The actual state machine can be generated at compile time based on the declarative configuration, and its runtime behavior will certainly be influenced by user input.</p><h4>Statechart for composite type</h4><p>Statecharts are an extension of state machines that allow for compound state. The compound state is essentially a state machine defined on its child states. It works as follows: upon entering the compound state, the control is given to the initial state of the nested state machine, and when control reaches the end state of nest state machine, compound state is considered complete. Typically, these nested state machine are context-free, meaning given the compound state, the behavior of nested state machine does not depend on any thing else.</p><p>To conversationally create a instance for a composite type, we just need to create the instance for each slot and then put them together. In particular, we can create one compound state for each slot, each has a nested state machine based on its declarative configuration. We can fill these slots one by one, or we only move the next compound state after we are fully done with the current compound state. When we complete all the nested state machines, we have all the information we need to create the instance of the composite type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*QO8c4mHLP7AW8KCsmSMKIQ.png" /></figure><p>It is easy to use statechart to handle more complex use cases. For example, to fill a slot with composite type instead of primitive type, we can simply nest one additional layer. Furthermore, polymorphism can be supported by first asking the actual type, and then try to create instance of that type. In fact, adding an additional layer of abstraction can solve all the issues, including value recommendation, slot value update etc.</p><h4>Parting words</h4><p>Clearly, statecharts cannot model all possible conversations due to their context-free nature and the rigid depth-first strategy used to execute them. However, a statechart strikes a balance between expressive power and ease of reasoning. It can model a class of structured conversations capable of exposing any APIs conversationally while also providing an easy way to understand and control complex conversational user interactions with clear, modular, and event-driven behavior.</p><p>reference:</p><ul><li><a href="https://opencui.medium.com/interaction-logic-4-openapi-specs-is-not-enough-8ad7b4025bf4">Interaction logic #4: OpenAPI specs is not enough</a></li><li><a href="https://opencui.medium.com/type-based-conversational-user-interface-67e562185e56">Interaction logic #3: a type-based approach</a></li></ul><p><a href="https://docs.staruml.io/working-with-uml-diagrams/statechart-diagram">https://docs.staruml.io/working-with-uml-diagrams/statechart-diagram</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a1802bd9c49" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opencui-official/interaction-logic-5-a-state-chart-implementation-7a1802bd9c49">Interaction logic #5: a state chart implementation</a> was originally published in <a href="https://medium.com/opencui-official">OpenCUI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interaction logic #4: OpenAPI specs is not enough]]></title>
            <link>https://medium.com/opencui-official/interaction-logic-4-openapi-specs-is-not-enough-8ad7b4025bf4?source=rss----a696dc8db0a---4</link>
            <guid isPermaLink="false">https://medium.com/p/8ad7b4025bf4</guid>
            <category><![CDATA[dialog-management]]></category>
            <category><![CDATA[icu]]></category>
            <category><![CDATA[dialog-policy]]></category>
            <category><![CDATA[openapi-specification]]></category>
            <dc:creator><![CDATA[Sean Wu]]></dc:creator>
            <pubDate>Wed, 25 Oct 2023 02:20:03 GMT</pubDate>
            <atom:updated>2024-03-13T04:38:49.354Z</atom:updated>
            <content:encoded><![CDATA[<h3>Interaction Logic #4: OpenAPI specs is not enough</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BFJgpRrNRqf83wsvX9MaSg.png" /></figure><p>The function-calling API from OpenAI serves as a great introduction to the schema-guided approach for building conversational user interfaces (CUIs). By simply attaching an OpenAPI specification of a set of functions, models like ChatGPT can detect whether a user’s utterance implies an intention to trigger one of the functions. If it does, the model converts the utterance into a JSON object that represents a callable function object, which identifies which function to call and provides values for the arguments needed to call that function. The orchestration can then simply dispatch the function call and render the structured function return back into an unstructured natural language representation.</p><p>Clearly, this simple straight-through interaction logic is not sufficient for many real-world use cases. However, with the description for a function and its parameters as the only addition to the schema, the OpenAPI specification lacks the information needed to support complex interaction logic. Let’s go through what is missing if we need a fully functional interaction logic, using a movie ticketing service (via a API function) as an example. To keep it simple, we assume there are only three required parameters for this buyMovieTicket function (or skill):</p><pre>fun buyMovieTicket(<br>  title: MovieTitle<br>  showtime: LocalTime<br>  format: Format // (enum of IMAX, 3D, Standard, ...)<br>)</pre><h3>When the user’s request is not serviceable</h3><p>The user’s initial request might not be serviceable from a business perspective due to missing information, out-of-stock items, or a desire for the business to promote a new product. In any of these cases, the chatbot needs to request new values for certain slots. Here are some scenarios that a fully functional interaction logic needs to be able to handle.</p><h4>Initialization</h4><p>Initialization assigns a value to a slot. This can be useful when the value for a slot can be determined by the chatbot based on what it knows so far. For example, if there is only one IMAX theater for a given movie, there is no need to ask the user’s preference for that slot. In such a case, we need to assign a value to the ‘format’ slot based on potentially arbitrary business logic.</p><h4>Prompt and value recommendation</h4><p>When the user did not provide a value for a slot, or the value from the previous turn is not serviceable, the chatbot needs to prompt the user again. Instead of asking the user to provide a new choice without any help, it is often useful to provide the user with a short list of what is serviceable, so that the conversation can quickly converge. For example:</p><pre>User: Two tickets for Openhemier, please.<br>Bot: Sure, we have two shows left today. 6:00pm and 9:00pm. <br>     Which one do you want?</pre><p>Clearly, value recommendation requires access to the product system in the form of some APIs. How to identify such API functions and define the behavior for corner cases, like when such a function returns only one candidate or no candidate at all.</p><h4>Value check</h4><p>User’s original preference on a slot might not be serviceable, or business might want to promote something else, in such case, business might want to inject interaction logic that guide the conversation toward something else. For example:</p><pre>User: Two tickets for Openhemier for 8:00pm, please.<br>Bot: We have seats available in IMAX theater today at 6:00pm.<br>     Do you want that instead?</pre><p>Clearly, value check also requires access to the product system in the form of some APIs.</p><h4>Confirmation</h4><p>Sometimes, user’s choice for a slot might be questionable in some sense. For example:</p><pre>User: Two tickets for Openhemier for 8:00pm, please.<br>Bot: Oh, our 8:00pm show is almost fully booked, are you sure you want it?</pre><p>How do communicate such subtle information requires some thought. We might also need to logic in case we do not need confirmation all the time.</p><h3>When the user changes his mind</h3><p>Just like we can’t ask user to always say everything upfront, we also can’t not prevent them to change their mind. For example:</p><pre>User: I like to buy two tickes for Openhemier.<br>Bot: What time?<br>User: Wait, I meant Barbie.<br>Bot: Barbie it is. What time?</pre><p>Allowing users to make changes can greatly increase the effectiveness of the CUI, thus improving the overall user experience. This essentially requires the support for creating, updating, and deleting value for slots, with creating and deleting mostly useful for multi-value slots. These CRUD operations can be implemented as system skills.</p><h3>Other semantics</h3><p>The ‘equal-to’ semantic is the default relationship between the value that the user provides and the slot variable. However, natural conversations might require support for other semantics, such as:</p><pre>User: Two tickets for Openhemier, please.<br>Bot: Sure, we have two shows left today. 6:00pm and 9:00pm. <br>     Which one do you want?<br>User: 9:00pm is too late for me.</pre><p>Supporting common semantics such as NOT and OR can further improve the user experience. Unlike CRUD operations on the slot values, to create a seamless end-to-end experience, business APIs might need to be aware of these semantics.</p><h4>Parting words</h4><p>To support these use cases, we certainly need to define new data structures so that we can capture the builder’s choices in terms of how the chatbot should behave. For example, value recommendation requires a code expression that can be evaluated to a list of items of a given type. Builders also need to define what to do if the value check fails. Attaching this information to the OpenAPI specification is not a good idea, as some of this information might be language-dependent. OpenCUI provides a set of dialog annotations used to capture the information needed by interaction logic, and we also have a runtime that can conduct the dialog based on such declarations, regardless of which conversational path we end up taking.</p><p>Reference:</p><ul><li><a href="https://opencui.medium.com/5-levels-of-conversational-ui-3224b335a5df">5 Levels of conversational UI</a></li><li><a href="https://opencui.medium.com/type-based-conversational-user-interface-67e562185e56">Interaction logic #3: a type-based approach</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ad7b4025bf4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opencui-official/interaction-logic-4-openapi-specs-is-not-enough-8ad7b4025bf4">Interaction logic #4: OpenAPI specs is not enough</a> was originally published in <a href="https://medium.com/opencui-official">OpenCUI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dialog Understanding #6: Maintainable Accuracy]]></title>
            <link>https://medium.com/opencui-official/maintainable-accuracy-7869ae291d39?source=rss----a696dc8db0a---4</link>
            <guid isPermaLink="false">https://medium.com/p/7869ae291d39</guid>
            <category><![CDATA[conversational-ui]]></category>
            <category><![CDATA[dialog-understanding]]></category>
            <category><![CDATA[chatbots]]></category>
            <dc:creator><![CDATA[Sean Wu]]></dc:creator>
            <pubDate>Mon, 29 May 2023 17:02:31 GMT</pubDate>
            <atom:updated>2023-06-06T06:48:11.255Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*G7mDWBkpwY5I8Ph-5aecYg.jpeg" /></figure><p>One of the main hurdles in building chatbots is the dialog understanding (DU) module. It is needed to turn user utterance into some structured event, which then is processed by the dialog engine to move the conversation forward and eventually connect users with their desired service.</p><p>There are two closely related understanding problems here: figuring out what the user wants or their implied intentions, and figuring out what their preferences or slot values are. For example, when the user input is: ‘I like to fly to Shanghai tomorrow,’ we need to convert this into a frame event in the form of ‘book_flight(destination=Shanghai, date=…)’, where ‘book_flight’ is the intent and ‘Shanghai’ is the value for the destination slot, and so on.</p><p>Today these natural language understanding problems are generally solved by deep learning methods. This means we first prepare a labeled dataset, consisting of pairs of potential user utterance and corresponding frame events. Then we pass this dataset onto natural language understanding (NLU) training pipeline which turn this dataset into a production worthy model. The model is then used to convert user utterance into structured events.</p><p>Today, these natural language understanding problems are generally solved by deep learning methods. This involves first preparing a labeled dataset, which consists of pairs of potential user utterances and their corresponding frame events. Next, the dataset is fed to a natural language understanding (NLU) training pipeline to produce a production-worthy model. This model is then used to convert user utterances into structured events.</p><p>With recent advance in large language models, the amount of the labeled data required is reducing while the prediction accuracy is moving up. Unfortunately, we still don’t yet have 100% accurate language understanding technology. So launching a chatbot is not the end, but the beginning of iterative dialog understanding improvements. What we really need is maintainable accuracy: a dialog understanding model that can be fixed easily.</p><p>However, escalating every understanding issue to the dedicated NLU/ML team/pipeline for a fix is not a good option. The latency is too high to maintain a reasonable user experience. Asking the existing development team to become proficient in statistical learning-based natural language understanding is not practical. Beyond that, it will take a long time due to the steep learning curve. Asking them to be skilled in both fields is also challenging, as the statistical way of thinking involved in ML is a sharp departure from their deterministic modeling of the application. This greatly limits the number of teams that can create an effective conversational user interface and is partially responsible for the nonexistence of good conversational experiences, despite the widely claimed benefits for end-users.</p><p>Luckily, with the recent advances in NLU research, we can create a tool that hides all the statistical learning concepts and implementation, but can still be used to hot fix any understanding issues simply by providing a labeled example. Let’s use the implicature calculation problem to explain how nonparametric few shot methods can help us get here.</p><p>The starting point for the intent prediction problem is a set of labeled examples, {(x[i], y[i])…}, where x[i] is the ith user example utterance from all possible user utterances X and y[i] is the corresponding intent from the set of all possible intents a chatbot needs to understand.</p><p>The goal of the intent classification training is to produce a model, which is a function that can map any user utterance x into an intent y (for now, assuming there is a catch-all Other intent for ease of discussion). While this problem is well-studied in the past, it is not production-friendly: every time we add a new intent to the chatbot or just want to fix an understanding bug, we need both expertise and sizable labeled data to retrain the model, which is slow and costly.</p><p>However, by combining recent sample-efficient learning algorithms based on pretraining with the nonparametric approach, we can solve the problem in the following way: given a new user utterance x, we can find the correct understanding as follows. First, we use text retrieval to obtain a small set of example utterances that closely resemble x. Then, we use a text equivalency model E to find the best match example for x, and use the corresponding y as the structured understanding. The text equivalency model E, based on BERT, is used to determine if two sentences are the same. It can be pre-trained and then fine-tuned for any intents, even those not seen in the training dataset. This approach is straightforward to implement and can be used to quickly improve the understanding model, allowing for a better user experience without requiring extensive machine learning training.</p><p>With the tools and processes that can deliver maintainable accuracy by the existing development team, we can build effective CUI applications without the need for NLU/MU experts, whether internal or external. This can reduce the cost of building service chatbots overnight and potentially make the conversational experience a lot more accessible.</p><p>Reference:</p><ol><li><em>Xing Shi, Scot Fang, Kevin Knight, </em><a href="https://drive.google.com/file/d/1PRPx3lfJTtX-V23uTFOIPdB0LhQDBFq5/view">A BERT-based Unified Span Detection Framework for Schema-Guided Dialogue State Tracking</a></li><li><em>Vahid Noroozi, Yang Zhang, Evelina Bakhturina, Tomasz Kornuta</em>, <a href="https://arxiv.org/pdf/2008.12335.pdf">A Fast and Robust BERT-based Dialogue State Tracker for Schema-Guided Dialogue Dataset</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7869ae291d39" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opencui-official/maintainable-accuracy-7869ae291d39">Dialog Understanding #6: Maintainable Accuracy</a> was originally published in <a href="https://medium.com/opencui-official">OpenCUI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dialog Understanding #5: Perfer LoRA]]></title>
            <link>https://medium.com/opencui-official/dialog-understanding-5-learning-with-foundation-model-5e66f7f78bc2?source=rss----a696dc8db0a---4</link>
            <guid isPermaLink="false">https://medium.com/p/5e66f7f78bc2</guid>
            <category><![CDATA[dialog-understanding]]></category>
            <category><![CDATA[usd]]></category>
            <category><![CDATA[new-way]]></category>
            <dc:creator><![CDATA[Sean Wu]]></dc:creator>
            <pubDate>Mon, 29 May 2023 17:02:09 GMT</pubDate>
            <atom:updated>2023-10-17T18:08:18.394Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GwJ_ksRf01tddo-S4K85Yw.png" /></figure><p>The traditional method of training separate models for each NLU task, which necessitates a considerable amount of labeled data for every task, has been swiftly replaced by a multi-stage learning paradigm centered on a large language models (LLMs), known as foundation models. This approach is more production-friendly since it requires little or even no labeled data for each new task. We have explained how these few-shot capability comes into being in a <a href="https://medium.com/@opencui/dialog-understanding-3-origin-of-llms-zero-shot-capability-813b1f8634631">previous blog</a>, let’s take a look how to use LLMs to <a href="https://medium.com/@opencui/dialog-understanding-4-new-tools-873c1f0b99eb">solve dialog understanding tasks</a>.</p><h4>How foundation models are trained</h4><p>Foundation models are typically trained in two stages: pre-training and fine-tuning. During the pre-training stage, a large, high quality corpus of text is compiled from various sources, such as books, articles, and web pages. Using a self-labeling schema that either auto-regressively predicts the next word in a sequence given the previous words in the sequence (like ChatGPT) or auto-associatively predicts the original text given a token sequence with a part of it randomly masked (like Bert), these unlabeled texts can then be used to train a foundation model able to produce high-quality meaning representations of text.</p><p>After pre-trained on a large corpus of text, foundation models can be further fine-tuned on many tasks, such as language translation or text generation. For decoder based model like GPT, fine-tuning is framed as a universal conditional text generation problem. Specifically, labeled data points in the form of (task, input, output) are transformed into labeled data in the form of (prompt, output), where the prompt is a natural language representation of the task and original input. For example: (E<em>nglish to Chinese translation, how are you today, 你今天怎么样</em>) can be reformulated into (<em>translate “how are you today” into Chinese, 你今天怎么样</em>), and (g<em>rammar check, “Stalin were a dictator”, “Stalin was a dictator”</em>) into (g<em>rammar check: Stalin were a dictator, Stalin was a dictator</em>). Training with reformulated labeled data from many tasks, commonly known instruction fine-tuning or instruction tuning for short, results in a universal model that can treat text input as instructions.</p><p>The result of these expensive training is the weights for model’s parameter. Foundation models consist of three layers, the parameters for each layer are used for different purpose:</p><ol><li>Embedding parameters: These are the parameters used to map input tokens (e.g., words, subwords) to high-dimensional vectors called embeddings.</li><li>Transformer parameters: These are the parameters that define the architecture of the Transformer model, which is used to process the input embeddings and generate representation that summarize the token sequences. The parameter for this layer are typically shared between multiple tasks, and kept frozen during later stage learning.</li><li>Output parameters: These are the parameters used to generate the output sequence from the final layer of the Transformer. In the case of a language modeling task, the output parameters would typically be the weights of a linear layer that maps the output embeddings back to a vocabulary distribution over the possible output tokens. Clearly different tasks need different output parameters.</li></ol><p>Depending on the proportion of parameters that are modified, there are three strategies for solving NLP tasks using existing foundation models. Let’s see what are these, and which one should we use for dialog understanding tasks.</p><h4>Full-tuning</h4><p>Full-tuning, commonly known as fine-tuning, refers to a process where a foundation model is further trained on a new task, using a new dataset with the goal that this later stage tuning can adept the knowledge embedded in the foundation model to this new task.</p><p>In full-tuning, weights are initially initialized based on the foundation model, but all weights can be modified during the tuning process. Full-tuning usually yields the best performance (in terms of accuracy, not speed) among all three tuning strategies. Nevertheless, as models grow in size, storing and deploying a fine-tuned model for each downstream task may become impractical.</p><h4>No tuning: in-context learning</h4><p>The instruction-tuned foundation model, like InstructGPT, demonstrated convincingly that a <strong>frozen</strong> model can perform different tasks through “in-context” learning. With this approach, a user primes the model for a given task through prompt design or prompt engineering, i.e., hand-crafting a text prompt with a description and sometimes examples of the task. For instance, to predict whether a movie review is positive or not, one could prepend “<em>Is the following movie review positive or negative?</em>” before the actual review to form the prompt, and hopeful get “<em>This movie was amazing!</em>” in return.</p><p>During the in-context learning, all weights are kept frozen. So a single model can serve many tasks. But prompts require careful design, as small change in prompts can result in drastic change in performance. Furthermore, even well-designed prompts can still far under-perform compared to full-tuning. For instance, the performance of a frozen GPT-3 175B parameter model on the <a href="https://super.gluebenchmark.com/">SuperGLUE</a> benchmark is 5 points below a fine-tuned <a href="https://ai.googleblog.com/2020/02/exploring-transfer-learning-with-t5.html">T5 model</a> that uses 800 times fewer parameters. Finally, this paradigm can only use handful of labeled examples, since all examples need to fit into receptive fields of the foundation model (limited to 2k tokens usually). This further limits the performance of this approach.</p><h4>Delta-tuning: LoRA</h4><p>Only small portion of parameters have their weights changed in this family of methods, and these change can be captured by delta weights. This is also known as <a href="https://huggingface.co/blog/peft">parameter efficient fine tuning</a> (PEFT) in the huggingface community. The most popular delta-turning, such as LoRA ( Low-Rank Adaptation of LLMs), prompt tuning (and its variance p-tuning, prefix-tuning), are additive in nature, where extra trainable parameters are introduced. Out of them, LoRA has proven to be effective for a wide range of application, and is the one that we understand most.</p><p>LoRA, which stands for Low-Rank Adaptation of Large Language Models, operates on a crucial insight: the difference between the fine-tuned weights for a specialized task and the initial pre-trained weights often exhibits “low intrinsic rank” — meaning that it can be approximated well by a matrix of low rank. Low-rank matrices can be represented as the product of two much smaller matrices. By focusing on updating these two smaller matrices rather than the entire original weight matrix, the number of parameters and examples need to train these parameters can be substantially reduced.</p><p>In practical terms, the original weight matrix W remains frozen during fine-tuning. Instead, two additional matrices, A and B, are fine-tuned. These matrices act as a decomposition of the fine-tuned weight matrix. Consider the following modified illustration from the original LoRA paper:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*0AfUif-O1DIWiU9y750Nhg.png" /></figure><p>By selecting r &lt;&lt; d, both the memory footprint of the optimizer and the size of the checkpoint can be significantly reduced compared to full-parameter fine-tuning. LoRA allow you to control many things, beside the rank of matrices A and B, this methodology can be applied to any dense layer within the model architecture. This allows a better trade-off between the number of delta parameters and performance.</p><p>Since the release of the original LoRA paper, numerous techniques building upon LoRA have been introduced, and it is now possible to LoRA fine tune 33B model on consumer grade GPU, though they are beyond the scope of this discussion.</p><h4>Conclusion</h4><p>To build a conversational user interface for real-world services, we typically need to solve multiple natural language understanding (NLU) tasks, often in an incremental fashion. Full-tuning is clearly not a good option. The memory requirements for serving multiple models will be a significant burden, and we also run the risk of catastrophic forgetting.</p><p>While prompt engineering or in-context learning is a useful tool for ad-hoc research, its lower accuracy and no easy way exist to be fixed make it unsuitable for any practical production scenarios.</p><p>That leaves us with delta tuning. In particular, LoRA can achieve high-level performance that was previously only possible through full fine-tuning. In fact, it is easy to combine the prompt engineering, retrieval augmented generation (RAG), with LoRA fine tuning in the natural language understanding, resulting in higher performance overall due to the quailty of the base model like llama v2, low effort on the developer side with zero shot capabilities, hot fixable by RAG, as well as the ability to serve multiple tasks with one model thanks to the GPT.</p><p>Reference:</p><ol><li><a href="https://medium.com/@opencui/dialog-understanding-3-origin-of-llms-zero-shot-capability-813b1f863463">https://medium.com/@opencui/dialog-understanding-3-origin-of-llms-zero-shot-capability-813b1f863463</a>1</li><li><a href="https://medium.com/@opencui/dialog-understanding-4-new-tools-873c1f0b99eb">https://medium.com/@opencui/dialog-understanding-4-new-tools-873c1f0b99eb</a></li><li><a href="https://ai.googleblog.com/2022/02/guiding-frozen-language-models-with.html">https://ai.googleblog.com/2022/02/guiding-frozen-language-models-with.html</a></li><li><a href="https://arxiv.org/abs/2210.11416">https://arxiv.org/abs/2210.11416</a></li><li><a href="https://arxiv.org/pdf/2203.06904.pdf">https://arxiv.org/pdf/2203.06904.pdf</a></li><li><a href="https://huggingface.co/blog/peft">https://huggingface.co/blog/peft</a></li><li><a href="https://arxiv.org/pdf/2310.01352.pdf">https://arxiv.org/pdf/2310.01352.pdf</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e66f7f78bc2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opencui-official/dialog-understanding-5-learning-with-foundation-model-5e66f7f78bc2">Dialog Understanding #5: Perfer LoRA</a> was originally published in <a href="https://medium.com/opencui-official">OpenCUI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dialog Understanding #4: New Formulations]]></title>
            <link>https://medium.com/opencui-official/dialog-understanding-4-new-tools-873c1f0b99eb?source=rss----a696dc8db0a---4</link>
            <guid isPermaLink="false">https://medium.com/p/873c1f0b99eb</guid>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[dialog-understanding]]></category>
            <category><![CDATA[usd]]></category>
            <category><![CDATA[icu]]></category>
            <dc:creator><![CDATA[Sean Wu]]></dc:creator>
            <pubDate>Mon, 29 May 2023 17:01:55 GMT</pubDate>
            <atom:updated>2023-04-04T21:32:24.955Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GpLi_phanBZlcFHgynTXqw.jpeg" /><figcaption>tools: old vs new</figcaption></figure><p>The dialog understanding module plays a crucial role in enabling chatbots to understand user inputs and trigger the appropriate skills or functionalities. A skill represents a specific capability or task that the chatbot is designed to perform.</p><p>Dialog understanding can be broken down into two main components: intent detection and slot filling. Intent detection is responsible for identifying the user’s intended skill based on their input. Slot filling, on the other hand, extracts relevant values from the user’s input to populate the input parameters required for the skill.</p><p>For example, if a user inputs “<em>I want to buy two tickets for the 8:00pm showing of Star Wars</em>”, the dialog understanding module would classify this as a request to trigger the “buy_movie_ticket” skill. The slot filling component would then extract the relevant information, such as the quantity (<em>2</em>), the movie (“<em>Star Wars</em>”), and the time (<em>8:00pm</em>), and bind this information to the skill’s input parameters.</p><p>What formulations do we pick to solve these two problems are highly influenced by the technology made available by natural language understanding (NLU) research at the time. Given the recent progress made in the form of large language models, it is time for us to survey the research and see whether there are better formulations available. But first let’s review what we use today.</p><h4>Discriminant Text Classification and Sequence Tagging</h4><p>Before the multi-stage training using large language model (LLM) become popular, the dominant learning paradigm is discriminant method. Discriminant model are more sample efficient on a per task basis. The convex optimization problems resulted from these discriminant models permit a globally optimal solution. This means that theoretically, we can train the model once and achieve a high-quality solution. Finally the discriminant model are usually shallow in structure, so easy on computation budget. So naturally discriminant tools in form of text classification and sequence tagging are used to solve these two DU tasks.</p><p>For intent classification, we model the probability of intent given the user’s utterance, <em>P(intent|utterance)</em>. For slot filling, we assume that the fillers do not overlap, and we model the probabilities of output sequences given the input sequence, simply tokenized user utterance, <em>P([label…] |[token…] )</em>. The output sequences consist of a sequence of labels used to describe whether a token is outside of an entity (O), or the beginning/inside of an entity of a given type (B/I-type). For example, the label sequence for the above utterance is: <em>[O, O, O, O, B-quantity, O, O, O, B-showtime, B-movie, I-Movie],</em> for the token sequence: <em>[I, want, to, buy, two, tickets, for, the, 8:00pm, showing, of, Star, Wars]</em></p><p>The rigid nature of these discriminant models, where both model type (such as classification, or sequence tagging) and target (such as buy_movie_ticket or showtime, quantity and movie) are frozen during the training, any changes after that can be only be solved by restart training from scratch. The problems in the industry are not as cleanly defined, and also they change all the time, there will be new intent, new slots and classification errors. Since discriminant models are not production friendly as we liked, it is time for us to switch to some more flexible tools, like entailment, question answer.</p><h4>Textual Entailment for Intent Detection</h4><p>Textual entailment is a relatively new task in natural language processing (NLP) that aims to determine whether a statement (referred to as the “hypothesis”) can be logically inferred or implied from another statement (known as the “premise”). Unlike traditional text equivalence models, which focus on bi-directional text similarity, textual entailment models capture a one-way relationship between texts, determining whether hypothesis can be implied by the premise.</p><p>When the Stanford Natural Language Inference (SNLI) Corpus, a popular textual entailment dataset, was first introduced, the baseline accuracy is only around 50%. Since large language models, pretrained on the large quantity of longer texts, are exposed to instances of entailment of all shapes and sizes out there on the web, it is no surprise that LLM based method performs well on this task. For example, “<em>Entailment as Few-Shot Learner</em>” from Facebook AI team reports on 93% accuracy even with just few examples. Granted, the entailment logic presented in SNLI is simple, but the fact that we can reach that level of accuracy without elaborated labeling effort means that it is time for us to find the practical application for this research task.</p><p>Traditional intent classification can only understand user in literal sense. But human communication heavily rely on our ability to compute the implied meaning, for example, as a florist, you want to suggest get-well flowers based on user utterance “<em>My mom is sick</em>”, instead of ignore user’s hint. Textual entailment can be directly used to determine what we can do for user implied by their input: simply treat user utterance as premise and service description as hypothesis and pick the service that has highest score from model. In above example, with a good model, user utterance “<em>My mom is sick</em>” as premise should result in high enough score for hypothesis: “<em>User want to buy flowers for his Mom</em>”. Clearly textual entailment can simplify the down stream module such as dialog management towards providing natural and effective conversational experience to their user.</p><h4>Question Answering for Slot Filling</h4><p>Another relevant NLP task is extractive question answering. Given a passage and a question, the goal is to identify a span in the passage that can answer the given question.</p><p>SQuAD (Stanford Question Answering Dataset) is a large-scale dataset that consists of questions posed by crowdworkers on a set of Wikipedia articles, where the answer to each question is a segment of text from the corresponding article. LLM based methods reached human level performance on SQuAD 1.0 quickly. To make it more practical, SQuAD 2.0, is developed to include questions that do not necessarily have a direct answer in the provided passage. But the extra requirement to detect the cases where there is no answer in the passage did not pose any challenge for LLM based methods at all, compared to a human level performance with 87% accuracy, the state of art single model performance is around 90%.</p><p>The methods developed for extractive question answering can be directly used to address the slot-filling subtask, where we need to find the user’s choices on the dimensions that services can be customized. This can be achieved by using the user’s utterance as the passage and creating a question for each slot to extract the value for that slot. For example, using user utterance “<em>I like to have two tickets for 8:00pm Star Wars</em>” as passage, and questions like “<em>what time?</em>” , “<em>which moive?</em>” and “<em>how many tickets?</em>”, we can easily extract the corresponding values for showtime, movie title and quantity with the any SQuAD solutions. Of course, the performance of prompt engineering can be sensitive to choice of prompt, in practice we want something more robust.</p><h4>Parting Words</h4><p>For a better developer experience, dialog understanding should be able to handle other tasks as well. For example, when users are asked to confirm their choice, sometimes they will not respond with a simple yes or no, but instead give a more elaborate feedback. For instance, when a bot asks a user, “<em>Are you sure you want your burger to be extremely spicy</em>?” the user might reply, “<em>I eat jalapeños raw”</em> instead of saying “<em>yes”</em>. The bot should be able to understand this in order to provide an efficient conversational user interface.</p><p>Building a separate understanding model from scratch requires labeling a large enough dataset. Doing this for each new skill seriously hinders the widespread adoption of chatbots. Composite models based on LLM have demonstrated their ability to beat human performance on many tasks under a few-shot setting. Therefore, instead of getting stuck with these old, rigid tools at the expense of developer productivity, it is time for us to look at the research on various NLP tasks and figure out how we can make use of them to build better our conversational user interface more affordably.</p><p>There are different ways in which LLM can be utilized, including fine-tuning, prompt engineering, and prompt tuning. What is the right approach for building dialog understanding? Stay tuned for the next installment of this series, where we will explain what we used in OpenCUI and why.</p><p>References:</p><ol><li><a href="https://nlp.stanford.edu/projects/snli/">https://nlp.stanford.edu/projects/snli/</a></li><li><a href="https://rajpurkar.github.io/SQuAD-explorer/">https://rajpurkar.github.io/SQuAD-explorer/</a></li><li><a href="https://medium.com/@opencui/dialog-understanding-a-deep-dive-c715a6d42a55">https://medium.com/@opencui/dialog-understanding-a-deep-dive-c715a6d42a55</a></li><li><a href="https://medium.com/@opencui/dialog-understanding-3-origin-of-llms-zero-shot-capability-813b1f863463">https://medium.com/@opencui/dialog-understanding-3-origin-of-llms-zero-shot-capability-813b1f863463</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=873c1f0b99eb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opencui-official/dialog-understanding-4-new-tools-873c1f0b99eb">Dialog Understanding #4: New Formulations</a> was originally published in <a href="https://medium.com/opencui-official">OpenCUI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dialog Understanding #3: Origin of LLM’s Zero-shot Capability]]></title>
            <link>https://medium.com/opencui-official/dialog-understanding-3-origin-of-llms-zero-shot-capability-813b1f863463?source=rss----a696dc8db0a---4</link>
            <guid isPermaLink="false">https://medium.com/p/813b1f863463</guid>
            <category><![CDATA[dialog-understanding]]></category>
            <category><![CDATA[usd]]></category>
            <dc:creator><![CDATA[Sean Wu]]></dc:creator>
            <pubDate>Mon, 29 May 2023 17:01:38 GMT</pubDate>
            <atom:updated>2023-07-01T04:28:39.754Z</atom:updated>
            <content:encoded><![CDATA[<h3>Dialog Understanding #3: Towards Zero Shot</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cDmeWhQKAheYx5vdQaXHBQ.jpeg" /></figure><p>Large language models (LLMs), such as ChatGPT, have gained widespread attention due to their remarkable ability to perform multiple tasks with impressive accuracy, without requiring any specialized training. What is the secret sauce behind their magical zero-shot learning capability? If you are a product owner trying to decide how to utilize LLMs, you might want to gain a conceptual-level understanding of this without going into implementation details. Well, this is for you.</p><h4>Machine learning basics</h4><p>To enable a computer to perform a task, we usually need to create a function by declaring and implementing it. Declaration involves defining the function’s name, return type, and parameter types. Implementation entails hard-coding a step-by-step procedure that the computer can follow to provide the correct result for given input parameters. It is possible to have multiple implementations for the same function declaration.</p><p>However, many real world tasks are extremely difficult or even impossible to program via imperative hard-coding. For instance, determining whether an input image contains a car or not can be a challenging task, and basically intractable to the imperative approach. We need an alternative to implement such functions, that is where machine learning comes into play.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*_3CEiyWCk2dXfEqcmWpO4Q.png" /></figure><p>Given a target function declaration, machine learning can create a function implementation in the form of a machine learning model. The machine learning model is an extension of the target function, which means it has all the parameters from the target function, as well as some model parameters <em>(w)</em>. These model parameters can be bound to inputs (x), for example using dot product <em>&lt;(w, b), (x, 1)&gt; </em>in a simple neural network model. The machine learning model can be used as the target function implementation simply by fixing the model parameters (<em>w</em>) with some values, typically based on training.</p><p>Training a model is machine learning way to implement a function. For example, given a dataset of example images, each labeled with a “<em>yes</em>” or “<em>no</em>” indicating whether it contains a car, training determines values for model parameters <em>(w)</em>. Typically the values (known as weights) for model parameter is set to the ones that can map image to prediction of “yes” or “no” with highest accuracy, or simply agree with true label most.</p><p>Some special considerations:</p><ol><li>Multitask models<br>Often, we need to perform multiple tasks on the same input, and it is beneficial for models to share some common parameters. One approach is to train these models using a multi-stage process. In the initial stages, the focus is on training a base or foundation model that models the input data into an intermediate representation in a task-independent manner. In the later stages, the focus is on training the task-specific model that maps from this shared, task-independent representation of the input data to the task-dependent output. The performance of the final model depends heavily on both the foundation model and the learning algorithm used in the later stages. A stronger foundation model generally requires fewer shots.</li><li>Generative and discriminative<br>From a statistical perspective, there are two types of models: generative and discriminant. A generative model estimates the probability distribution of the data itself <em>P(input)</em>, while a discriminant model estimates the conditional probability of the output given the input <em>P(output|input)</em>.<br>Models can also be decomposed, with a generative model potentially being broken down into discriminative component models. For instance, while language models are generative on a sequence of tokens, they are typically decomposed into discriminative models that estimate the conditional probability of each token given the history of the sequence up to that point. In other words, the likelihood of the entire sequence is calculated as the product of the conditional probability of each token given its position in the sequence, from beginning to end.</li></ol><p>Modern models like LLMs, including GPT, have billions of model parameters and are much more complex in structure. Despite their complexity, these models can still be understood conceptually using the approach described earlier. With this conceptual model, three simple tricks are responsible for the magic of zero-shot learning.</p><h4>Trick #1: Solve a problem by modeling its output as input</h4><p>A discriminant function <em>f(x) -&gt; y </em>that maps input to output can be easily implemented by its generative extension (by extension, we simply mean function with more parameters) that contains the output of the target function as the addition input parameter: <em>likelihood(x, y; w)</em>. During training, we can find the model parameter that maximizes likelihood of both the input and output, and then during inference time, we find the output that produces the highest likelihood for given input.</p><p>As an example, say that we need to determine whether user want to buy a ticket based on his input utterance <em>“I need to fly to Beijing tomorrow”</em>. The discriminant solution is to evaluate <em>P(buy_ticket|utterance)</em> directly. Given a well trained generative model in form of <em>P(utterance, action_mentioned)</em>, we can simply compare these two values:<br><em>likelihood(“I need to fly to Beijing tomorrow”, “buy airline ticket”)<br>likelihood(“I need to fly to Beijing tomorrow”, “not buy airline ticket”)<br></em>hopefully the first likelihood is evaluated to be larger thus we can conclude user does want to buy ticket.</p><p>Using this simple trick, we can suddenly use one model to make predictions for any intent. However, if we have not provided any examples for a particular intent during training, how can we expect the model to make reasonable predictions? This is where the second trick comes into play.</p><h4>Trick #2: Just Embed that</h4><p>To find the model parameters that best explain the training data, all practical learning algorithms rely on numerical optimization. Because of this, we need to encode the words, commonly known as tokens into numerical vectors that can be used as input to machine learning model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*g2K677crUydpwSSdrcgnEg.png" /></figure><p>For quite a while, the text encoding of choice has been one-hot encoding. It represents a token as a binary vector, where each dimension of the vector corresponds to a unique token. If we have a vocabulary of V tokens, the binary vector we produce for any token should have a dimension of V. For the above example, the word “the” could be represented by a one-hot vector with a value of 1 in the first position and 0s in all other positions.</p><p>One-hot encoding of a token does not capture the relationships between tokens. For example, if we’re learning a model for the skill “buy ticket,” we know nothing about the skill “purchase airfare.” To address this issue, people started using embeddings. The idea is simple: instead of using a sparse one-hot vector to represent a token, we use a dense vector instead, and hope that the embeddings for these two phrases will be similar in dot product sense. Unfortunately, it’s not clear how to get such embeddings, and there are no known analytical solutions to compute them. So we have to train them using data, and for that, we need one last trick.</p><h4>Trick #3: Self-learning, on Web Crawl with Transformer</h4><p>Since the same phrases can have different meanings in different contexts, and different phrases can mean the same thing, we need an effective model to compute representations for sequences of tokens in a context dependent fashion. The transformer architecture, developed by a team of researchers at Google, has proven to be a capable choice.</p><p>As we’ve shifted more aspects of our lives online, we’ve amassed an enormous corpus of natural language documents that are freely available in every subject and language. This presents a prime opportunity for self-learning or self-supervised learning to take place.</p><p>Rather than relying on explicit human labeling or annotation, self learning creates a high-quality dataset by masking or corrupting parts of the data and use the missing or corrupted parts as label. For example, from “<em>I want to buy a ticket to Beijing</em>”, we can create many labeled pairs, such as (<em>“I want to buy a [mask] to Beijing”, “ticket”</em>), or ( <em>“I want to buy a ticket to”, “Beijing”</em>), etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2-sTMc_0Kp90-i_yIUgyfw.png" /></figure><p>By embedding each token and computing the representation for sequence based on these embedding, a large enough transformer model, trained with a large dump of web crawl via masking, next token prediction and other form of self learning, will have a good “understanding” on both the token, and its context for any sentence. Since the similar words or phrases will occur in the similar context, so it is likely that they have similar embedding as well as representation, which is also generally the case after these self-learning.</p><p>A task model based on such foundation model can thus make quality predictions on any targets even when these targets are NOT observed during later stage training. In fact, by further embedding the task into the generative model, model like InstructGPT can even perform well on the tasks that it is not trained on.</p><h4>Parting words</h4><p>Instead of learning each task from scratch, we can invest in pretraining a large foundation model through self-supervised learning on a massive corpus of natural language documents. By fine-tuning this model with as many tasks as possible, we can create a foundation that easily adapts to different tasks without any additional labeling effort.</p><p>Chatbot platforms, such as OpenCUI, built on this paradigm allow developers to focus only on interaction logic without worrying about dialogue understanding. This greatly reduces the cost of chatbot development, thus democratizing conversational experiences.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=813b1f863463" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opencui-official/dialog-understanding-3-origin-of-llms-zero-shot-capability-813b1f863463">Dialog Understanding #3: Origin of LLM’s Zero-shot Capability</a> was originally published in <a href="https://medium.com/opencui-official">OpenCUI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>