{
    "componentChunkName": "component---src-templates-doc-page-js",
    "path": "/docs/en/NLU_core/slot_filling/",
    "result": {"data":{"site":{"siteMetadata":{"title":"Gatsby-doc-engine"}},"markdownRemark":{"id":"cdd59e1c-5861-562a-af2b-e984659524cb","excerpt":"Slot Filling Slot Filling is a process of requesting additional data in order to fulfill the client request. The data acquired during an additional data request…","html":"<h1>Slot Filling</h1>\n<hr>\n<p><em>Slot Filling</em> is a process of requesting additional data in order to fulfill the client request. The data acquired during an additional data request are available for use in the script.</p>\n<p><em>Slots</em> are the data that the client sends with a request or when additional data are requested. Each slot has required attributes: <code class=\"language-text\">Name</code>, <code class=\"language-text\">Type</code>.</p>\n</br>\n<h4>Filling slots from a request</h4>\n<p class='warn'><a href=/1.10.3/docs/en/platform_ux/nlu_core_caila/intents  >More details about slot filling in the interface</a></p>\n<p>If we regard the <a href=\"/1.10.3/docs/en/NLU_core/intent\"><code class=\"language-text\">intent</code></a> as a function that the client can call, then a <code class=\"language-text\">slot</code> is a variable or a parameter of this function.</p>\n<p>For example, for the <code class=\"language-text\">/Weather</code> intent, an example phrase can be <code class=\"language-text\">\"Weather in London today\"</code> and the two slots, <code class=\"language-text\">City</code> and <code class=\"language-text\">Date</code>. In this example, London will be placed in the <code class=\"language-text\">City</code> slot and the current date will be placed in the <code class=\"language-text\">Date</code> slot.</p>\n<p>Here, all filled slots will be passed into the script in the variable <code class=\"language-text\">$parseTree._&lt;SlotName></code>. The associated value will be stored in the variable, and text will be included if there is no associated value.</p>\n<p>The filled slots are used in the script as follows:</p>\n<div class=\"gatsby-highlight\" data-language=\"sc\"><pre class=\"language-sc\"><code class=\"language-sc\">    <span class=\"token keyword\">state:</span>\n        <span class=\"token storageType\">intent!:</span> /Weather\n        <span class=\"token variableParameter\">a:</span> The weather in <span class=\"token constantCharacter\">{{ $parseTree._City }}</span> on <span class=\"token constantCharacter\">{{ $parseTree._Date }}</span></code></pre></div>\n</br>\n<h5>The <code class=\"language-text\">Type</code> attribute</h5>\n<p>Each slot must have a <code class=\"language-text\">Type</code> that corresponds to the entity <code class=\"language-text\">Type = entity</code>. This type defines the type of the data that will be placed into the slot. You can use both <a href=\"/1.10.3/docs/en/NLU_core/entities\">system and custom entities</a>.</p>\n<p>For example, for the <code class=\"language-text\">Date</code> slot with the type <code class=\"language-text\">@zb.datetime</code>: the word \"today\" from a client request will be passed to the entity <code class=\"language-text\">@zb.datetime</code> and will be placed into the <code class=\"language-text\">Date</code> slot.</p>\n<p class='warn'>If there are multiple slots of the same type in the intent, then they will be filled in sequentially.</p>\n<p>If you need to handle an arbitrary amount of slots of one type in a request or to handle variables with different entity types, use the <a href=\"/1.10.3/docs/en/NLU_core/entities\"><code class=\"language-text\">$entities</code></a> structure into which all found entities will be passed in their initial form.</p>\n</br>\n<h5>The <code class=\"language-text\">Required</code> attribute</h5>\n<p>Each slot has a <code class=\"language-text\">Required</code> attribute:</p>\n<ul>\n<li>If the slot is a required one and no clarifying questions have been specified, then the system will not output this intent if the slot has not been filled in the replies.</li>\n<li>If the slot is a required one and clarifying questions have been specified, then the system may return the intent without this slot. The intent will be handled by the slot filling module, and the client will be asked clarifying questions.</li>\n</ul>\n<p class='warn'><a href=/1.10.3/docs/en/platform_ux/nlu_core_caila/intents  >Before you start the slot filling process, familiarize yourself with slot filling in more detail</a>.</p>\n</br>\n<h5>Arrays in slots</h5>\n<p>You need to have an array in the filled <code class=\"language-text\">$parseTree._&lt;SlotName></code> slot to process requests with duplicate entities.</p>\n<p>Enable the <em>Is Array</em> switch to have all the entities placed into this slot in the form of an array:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1332px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 11.875%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAACCAYAAABYBvyLAAAACXBIWXMAABJ0AAASdAHeZh94AAAAU0lEQVQI122MOw7AMAhDc/+bVlFCEOU3uYKhU4YnI9t4vCLYLBBzZARUFRGBzOy7MLNfy6/8RmWjSnxOG+4OIoLWYwQeYsx9WvdamHOCmbt3ozY+Bm+au85tFU8AAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Arrays in slots\"\n        title=\":size=950\"\n        src=\"/1.10.3/static/eb1a3d6e87b0403e34e612ed1cae1f36/e5ca1/Screenshot_2.png\"\n        srcset=\"/1.10.3/static/eb1a3d6e87b0403e34e612ed1cae1f36/e85cb/Screenshot_2.png 480w,\n/1.10.3/static/eb1a3d6e87b0403e34e612ed1cae1f36/d9199/Screenshot_2.png 960w,\n/1.10.3/static/eb1a3d6e87b0403e34e612ed1cae1f36/e5ca1/Screenshot_2.png 1332w\"\n        sizes=\"(max-width: 1332px) 100vw, 1332px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n    </span></p>\n<p>If the <em>Is Array</em> switch is...</p>\n<ul>\n<li><strong>Disabled</strong>: the first processed value of this entity is placed into the slot.</li>\n<li><strong>Enabled</strong>: all the entities of this type are placed into the slot in the form of an array. If only one value of an entity is detected, it is also converted into an array.</li>\n</ul>\n</br>\n<h4>Connecting the slot filling module</h4>\n<p>To connect the slot filling module, specify the following in the script in the <code class=\"language-text\">main.sc</code> file:</p>\n<div class=\"gatsby-highlight\" data-language=\"sc\"><pre class=\"language-sc\"><code class=\"language-sc\"><span class=\"token keyword\">require:</span> slotfilling/slotFilling.sc\n  module = sys.zb-common</code></pre></div>\n</br>\n<h4>The mechanism for handling clarifying questions</h4>\n<p>The system will ask clarifying questions in the order they are defined for all the slots that are left unfilled.</p>\n<p>The client replies will be searched for entities that match the slots. If matching entities have been found then the respective slot will be filled.</p>\n<p>After all slots have been filled, control is passed to the main script with all the slots filled in <code class=\"language-text\">$parseTree</code>.</p>\n<p class='tip'>You can exit the slot filling script only by answering all the questions or by using the <code class=\"language-text\">/start</code> command.</p>\n<p>Consider the following script:</p>\n<div class=\"gatsby-highlight\" data-language=\"sc\"><pre class=\"language-sc\"><code class=\"language-sc\">    <span class=\"token keyword\">state:</span>\n        <span class=\"token storageType\">intent!:</span> /Weather\n        <span class=\"token variableParameter\">a:</span> The weather in <span class=\"token constantCharacter\">{{ $parseTree._City }}</span> on <span class=\"token constantCharacter\">{{ $parseTree._Date.value }}</span></code></pre></div>\n<p>In this case, we have filled all the slots as follows:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1448px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 13.125%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAADCAYAAACTWi8uAAAACXBIWXMAABJ0AAASdAHeZh94AAAAbElEQVQI122PCwoDMQhEc/+jtls2pkTzIXnFLLtQiPBgZEbUIFporS1qrY/esvxKX9n/vOveOyGrYabknBERVHWPGa8zckriiAmJkZQSZvZkSikEgDknY4xl+hbvd7y18S2dj/q112f3vOP1Ay+X6pLOtUXTAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Slot filling\"\n        title=\":size=950\"\n        src=\"/1.10.3/static/d842f630421b68e2c5cea18e249a5efb/fe720/Screenshot_1.png\"\n        srcset=\"/1.10.3/static/d842f630421b68e2c5cea18e249a5efb/e85cb/Screenshot_1.png 480w,\n/1.10.3/static/d842f630421b68e2c5cea18e249a5efb/d9199/Screenshot_1.png 960w,\n/1.10.3/static/d842f630421b68e2c5cea18e249a5efb/fe720/Screenshot_1.png 1448w\"\n        sizes=\"(max-width: 1448px) 100vw, 1448px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n    </span></p>\n<p>Here <code class=\"language-text\">@City</code> is a custom entity where we have specified all the cities for which we can provide weather forecasts.</p>\n<p>Client requests:</p>\n<ol>\n<li><code class=\"language-text\">The weather in Moscow for tomorrow</code>: the slots are filled and the bot will provide an answer right away.</li>\n<li><code class=\"language-text\">The weather for tomorrow</code>: the <code class=\"language-text\">City</code> slot is empty so clarifying questions will be asked. As soon as a correct answer is given, the control will be passed to the script and the bot will give a reply.</li>\n<li><code class=\"language-text\">The weather in Moscow</code>: the <code class=\"language-text\">Date</code> slot is empty so clarifying questions will be asked. As soon as a correct answer is given, the control will be passed to the main function and the bot will give a reply.</li>\n</ol>\n</br>\n<h4>Interruption of slot filling</h4>\n<p>You can configure slot interruption conditions in the <a href=\"/1.10.3/docs/en/common/bot_structure/configuration_file\"><code class=\"language-text\">chatbot.yaml</code></a> file in the <a href=\"/1.10.3/docs/en/common/bot_structure/configuration_file#injector\"><code class=\"language-text\">injector</code></a> section:</p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">injector</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">slotfilling</span><span class=\"token punctuation\">:</span>\n        <span class=\"token key atrule\">maxSlotRetries</span><span class=\"token punctuation\">:</span> <span class=\"token number\">1</span>\n        <span class=\"token key atrule\">stopOnAnyIntent</span><span class=\"token punctuation\">:</span> <span class=\"token boolean important\">true</span>\n        <span class=\"token key atrule\">stopOnAnyIntentThreshold</span><span class=\"token punctuation\">:</span> <span class=\"token number\">0.2</span></code></pre></div>\n<p>The following parameters are available here:</p>\n<ul>\n<li><code class=\"language-text\">maxSlotRetries</code> — the number of retries for a single slot. If the client has answered the specified number of times and the slot has not been filled then slot filling will be interrupted. The last phrase of the client will be handled in the bot script.</li>\n<li><code class=\"language-text\">stopOnAnyIntent</code> — takes a Boolean value <code class=\"language-text\">true/false</code>, this parameter defines interruption of slot filling by intent.</li>\n<li><code class=\"language-text\">stopOnAnyIntentThreshold</code> — a matching parameter that specifies the minimum required similarity of the phrase to a class. This is a parameter for slot filling interruption by intent.</li>\n</ul>\n<h5>Interruption by intent</h5>\n<p>If <code class=\"language-text\">stopOnAnyIntent: true</code> and an intent whose <code class=\"language-text\">confidence</code> parameter is greater than <code class=\"language-text\">stopOnAnyIntentThreshold</code> matches the client request, then slot filling will be interrupted by intent.</p>\n<p class='warn'>The <code class=\"language-text\">confidence</code> parameter is the degree of confidence that the JAICP platform has that the input phrase is related to the specified intent.</p>\n<p>Note that it is important to take the starting context of the slot filling into consideration. For example, if on interruption it is not possible to reach the state with the respective intent (for example, the tag <code class=\"language-text\">intent</code> is not global), then the request will result in <code class=\"language-text\"> event!: noMatch</code>.</p>\n<p>If the interruption parameters are not specified in the <code class=\"language-text\">chatbot.yaml</code> configuration file, then slot filling will be interrupted according to the default parameters:</p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">injector</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">slotfilling</span><span class=\"token punctuation\">:</span>\n        <span class=\"token key atrule\">maxSlotRetries</span><span class=\"token punctuation\">:</span> <span class=\"token number\">2</span>\n        <span class=\"token key atrule\">stopOnAnyIntent</span><span class=\"token punctuation\">:</span> <span class=\"token boolean important\">false</span>\n        <span class=\"token key atrule\">stopOnAnyIntentThreshold</span><span class=\"token punctuation\">:</span> <span class=\"token number\">0.2</span></code></pre></div>","frontmatter":{"title":"","description":null},"headings":[{"value":"Slot Filling"}]}},"pageContext":{"slug":"/docs/en/NLU_core/slot_filling/","previous":{"fields":{"slug":"/docs/en/NLU_functions/NLU_functions/"},"frontmatter":{"title":"","description":null}},"next":{"fields":{"slug":"/docs/en/NLU_core/rule_activation/"},"frontmatter":{"title":"","description":null}}}},
    "staticQueryHashes": ["1209419333"]}