wit-ai / wit

Natural Language Interface for apps and devices
https://wit.ai/
936 stars 91 forks source link

Using roles in entity #2322

Closed Daryl-Loo closed 2 years ago

Daryl-Loo commented 2 years ago

Do you want to request a feature, report a bug, or ask a question about wit? Ask a Question about wit.ai entity roles https://wit.ai/docs/recipes#differentiate-several-entities-according-to-their-role-in-the-message

Good morning, I am trying to use wit.ai to extract entity to build a url based on what the user input through query string. I need to group the category together, for example options related to form factor need to be grouped separately from applications.

for example, "I would like to build a server for artificial intelligence" Would extract 'artificial intelligence/ machine learning', which is the option under the category application.

There are 10 categories, with several options in each category, ranging from brands, to number of cpu, to features etc. While multiple options can be selected from a category, not all categories need to be filled.

I was wondering what would be the correct approach, should I make an entity for each category(eg, application), and assign a role to each option(eg. artificial intelligence machine learning)? Or should I make an entity(eg. parameters), then assign a role for every option (artificial intelligence machine learning)?

Also, since there are so many options, is there a way to quickly train wit.ai in the different entity/roles without repeatedly constructing sentences for the utterance? For example If I just put "machine learning" in utterance, assign it the enty/ role, and say its out of scope, would that be the same as using the utterance "Do you have server for machine learning" for the purpose of teaching wit.ai the entity/role?

If applicable, what is the App ID where you are experiencing this issue? If you do not provide this, we cannot help. A general question, haven't implemented it yet.

patapizza commented 2 years ago

Hi @Daryl-Loo,

I would define a category entity with a different keyword for each category, with synonyms. That entity strategy would be Keywords, as it's a strict predefined list. The Keywords strategy works with string matching, so it doesn't require training - just define the keywords and synonyms directly on the entity page.

Roles are used to train Wit to recognize a different flavor of a given entity based on the sentence context. For example, London could be a mere wit$location, but it could also be a wit$location:origin or a wit$location:destination. That way, I could disambiguate between one to another when e.g. booking a flight (I want to go from _London_ to _Brussels_, let's go to _London_ with departure from _Brussels_).

Out of scope utterances are used to teach Wit that those utterances should not return intent predictions for my particular app, because it's not in the scope of my project.

Hope this helps.