{"id":314,"date":"2018-09-14T18:07:11","date_gmt":"2018-09-14T18:07:11","guid":{"rendered":"http:\/\/freedville.com\/blog\/?p=314"},"modified":"2019-04-12T13:59:40","modified_gmt":"2019-04-12T13:59:40","slug":"chatbots-and-compound-intents","status":"publish","type":"post","link":"https:\/\/freedville.com\/blog\/2018\/09\/14\/chatbots-and-compound-intents\/","title":{"rendered":"Chatbots and compound intents"},"content":{"rendered":"<figure id=\"attachment_315\" aria-describedby=\"caption-attachment-315\" style=\"width: 700px\" class=\"wp-caption alignleft\"><img decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-315\" src=\"http:\/\/freedville.com\/blog\/wp-content\/uploads\/2018\/09\/card-catalog-700x428.jpeg\" alt=\"Rows of card catalog drawers\" width=\"700\" height=\"428\" srcset=\"https:\/\/freedville.com\/blog\/wp-content\/uploads\/2018\/09\/card-catalog-700x428.jpeg 700w, https:\/\/freedville.com\/blog\/wp-content\/uploads\/2018\/09\/card-catalog-300x183.jpeg 300w, https:\/\/freedville.com\/blog\/wp-content\/uploads\/2018\/09\/card-catalog-768x469.jpeg 768w, https:\/\/freedville.com\/blog\/wp-content\/uploads\/2018\/09\/card-catalog.jpeg 1638w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><figcaption id=\"caption-attachment-315\" class=\"wp-caption-text\">Classifiers put input into a single category. But what if that input belongs to two categories?<\/figcaption><\/figure>\n<p class=\"p1\">Chatbot developers want their bots to be able to handle as many types of user inputs as possible.<span class=\"Apple-converted-space\">&nbsp; <\/span>One core technique in chatbots is to classify user utterances into intents. <span class=\"Apple-converted-space\">&nbsp; <\/span>An intent signifies want the user wants to achieve and drives the way you respond.<span class=\"Apple-converted-space\">&nbsp; <\/span>&#8220;I want to cancel my last order&#8221; may be #cancel_order intent and &#8220;I want to check my points balance&#8221; may be #check_balance intent.<span class=\"Apple-converted-space\">&nbsp; <\/span>But what happens if the user has two intents in a single utterance, say &#8220;I want to cancel my last order and verify my points balance&#8221;?<span class=\"Apple-converted-space\">&nbsp; <\/span>We can reasonably assume the user wants both #cancel_order and #check_balance intents and we could consider this a compound intent.<span class=\"Apple-converted-space\">&nbsp; <\/span>Let\u2019s dive into this problem space further.<\/p>\n<p class=\"p1\">Training-wise classifiers like those in chatbots perform best when there are clear distinctions between target classes.<span class=\"Apple-converted-space\">&nbsp; <\/span>(Chatbots use classifiers where the intents are the classes)<span class=\"Apple-converted-space\">&nbsp; <\/span>Training on compound intents blurs distinctions between the target classes leading to poorer performance on the individuals and the compounds.<span class=\"Apple-converted-space\">&nbsp; <\/span>In the worst case &#8211; where all combinations are allowed &#8211; complexity increases exponentially from n classes to 2^n classes.<span class=\"Apple-converted-space\">&nbsp; <\/span>Chat classifiers thus work best when trained on single intent utterances.<span class=\"Apple-converted-space\">&nbsp; <\/span>What does this mean for compound intents?<\/p>\n<p class=\"p1\">Let&#8217;s assume a classifier well-trained on single intents.<span class=\"Apple-converted-space\">&nbsp; <\/span>For any utterance this classifier will return a list of candidate intents with associated confidence.<span class=\"Apple-converted-space\">&nbsp; <\/span>The way you detect compound intents is by &#8220;doing math&#8221; on the confidence scores. <span class=\"Apple-converted-space\">&nbsp; <\/span>Ideally our example &#8220;I want to cancel my last order and verify my points balance&#8221; scores highly on #cancel_order and #check_balance, and scores lowly on the other possible intents, and ideally there is a clear dividing line in the confidence scores.<span class=\"Apple-converted-space\">&nbsp; <\/span>The happy path for detecting compound intents has a cluster of high confidence intents cleanly separated from low confidence intents.<\/p>\n<p class=\"p1\"><span style=\"text-decoration: underline;\">True positive example of compound intents<\/span><\/p>\n<p class=\"p1\">&#8220;I want to cancel my last order and verify my points balance&#8221;<br \/>\n<b>#cancel_order (confidence 0.9053)<\/b><br \/>\n<b>#check_balance (confidence 0.7393)<\/b><br \/>\n#modify_order (confidence 0.2704)<br \/>\n#payment_inquiry (confidence 0.2342)<\/p>\n<p class=\"p1\">Our initial hypothesis might be to return all intents over a certain confidence.<span class=\"Apple-converted-space\">&nbsp; <\/span>However this hypothesis can lead to false positive detection of compounds.<span class=\"Apple-converted-space\">&nbsp; <\/span>There can be a single intent utterance that the system is unsure about, leading to two relatively high confidence intents being clustered incorrectly incorrectly into a compound intent.<span class=\"Apple-converted-space\">&nbsp; <\/span>Falsely detecting a compound intent leads to a negative user experience.<\/p>\n<p class=\"p1\"><span style=\"text-decoration: underline;\">False positive example of compound intents<\/span><\/p>\n<p class=\"p1\">&#8220;I want to verify my last order is cancelled&#8221;<\/p>\n<p><b>#check_balance (confidence 0.7507)<\/b><br \/>\n<b>#cancel_order (confidence 0.7273)<\/b><br \/>\n#modify_order (confidence 0.2739)<br \/>\n#payment_inquiry (confidence 0.2340)<\/p>\n<p class=\"p1\">In this case the user only wants to check the balance, however their utterance is closely classified against order cancellation as well.<span class=\"Apple-converted-space\">&nbsp; <\/span>The correct intent is still identified, but if we are trying to detect compound intents via confidence values, this looks even more like a compound intent than our first example!<\/p>\n<p class=\"p1\">Classification technology is wonderful at quickly sorting large numbers of data inputs into buckets via training on a representative small subset.<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span>This post explores a boundary condition that chatbot classifiers struggle with.<span class=\"Apple-converted-space\">&nbsp; <\/span>From a design point of view you need to be aware of what mistakes your system can make and how you deal with them.<span class=\"Apple-converted-space\">&nbsp; <\/span>If your decision is to never attempt the detection of a compound intent you will live with false negatives (never detecting actual compound intents).<span class=\"Apple-converted-space\">&nbsp; <\/span>If you decide to attempt compound intent detection you will introduce false positives (detecting compound intents that never existed).<span class=\"Apple-converted-space\">&nbsp; <\/span>Both decisions affect your chatbot and your overall design.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Chatbot developers want their bots to be able to handle as many types of user inputs as possible.&nbsp; One core technique in chatbots is to classify user utterances into intents. &nbsp; An intent signifies want&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[9,2,5],"_links":{"self":[{"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/posts\/314"}],"collection":[{"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/comments?post=314"}],"version-history":[{"count":2,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/posts\/314\/revisions"}],"predecessor-version":[{"id":400,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/posts\/314\/revisions\/400"}],"wp:attachment":[{"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/media?parent=314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/categories?post=314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/tags?post=314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}