snipsco / snips-nlu

Snips Python library to extract meaning from text
https://snips-nlu.readthedocs.io
Apache License 2.0
3.89k stars 513 forks source link

Slot parsing for specified intents not possible for short entity strings #847

Closed felixvor closed 6 months ago

felixvor commented 5 years ago

Hello,

I am new to snips-nlu and I got the following problem.

I want to create a chatbot that is able to fill missing slots if they are required. As an example, I got an intent that is called tellJoke, which requires a topic to be set. If the intent "tellJoke" is detected, but the topic slot is empty, I want to be able to extract the topic out of any string the user types in afterwards.

Example Dataset:

# tellJoke Intent
---
type: intent
name: tellJoke
slots:
  - name: topic
    entity: topic
utterances:
  - Tell me a joke about a [topic](fish)
  - ...

# joke topic entities
---
type: entity
name: topic
automatically_extensible: yes
values:
- [knock knock, door, knock]
- [dad, father, dads, fathers]
- [cat, kitten, kitty, cats]
- ...

Detecting the intent works great. It is also perfectly detecting slots if the initial queries contains them. However, I want to be able to handle missing information interactivley. If the user does not specify a topic, but just asks for a general joke, the bot asks about the topic that the user wants. For example:

{
  "input": "i want to hear a joke",
  "intent": {
    "intentName": "tellJoke",
    "probability": 0.79340987912516253
  },
  "slots": []
}

Now the chatbot could aks: "What should the joke be about" to start the slot filling. The problem: The user now answers with a singe word string that describes the topic of the joke. This single word might resemble a correct entity value like "knock knock" or "cat", however I am unable to parse it correctly with the parse_slot function.

parsing = engine.get_slots("Knock Knock", "tellJoke")
print(parsing)
>>>[ ]

The parse_slot function depends on the query parameter to resemble the correct intent so the slot can be parsed. How can I parse the "topic" entity out of strings that are a None intent or any other intent? The parse_slot function should be able to do that if the intent is manually defined.

adrienball commented 5 years ago

@DieseKartoffel What you want to do in that case is create a specific elicitation intent (on top of the main intent) which would cover formulations used by the user to specify a missing slot. This is discussed more thoroughly in #849 . Let me know if you are still stuck. Cheers