Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python NLP Intent Identification

I am novice in Python and NLP, and my problem is how to finding out Intent of given questions, for example I have sets of questions and answers like this :

question:What is NLP; answer: NLP stands for Natural Language Processing

I did some basic POS tagger on given questions in above question I get entety [NLP] I also did String Matching using this algo.

Basically I faced following issues :

  1. If user ask what is NLP then it will return exact answers
  2. If user ask meaning of NLP then it fail
  3. If user ask Definition of NLP then it fail
  4. If user ask What is Natural Language Processing then it fail

So how I should identify user intent of given questions because in my case String matching or pattern matching not works.

like image 495
Yogesh Avatar asked May 27 '17 06:05

Yogesh


People also ask

How do you identify intents?

Intent recognition — sometimes called intent classification — is the task of taking a written or spoken input, and classifying it based on what the user wants to achieve. Intent recognition forms an essential component of chatbots and finds use in sales conversions, customer support, and many other areas.

What is intent detection in NLP?

Intent Detection is a vital component of any task-oriented conversational system. In order to understand the user's current goal, the system must leverage its intent detector to classify the user's utterance (provided in varied natural language) into one of several predefined classes, that is, intents.

What is intent extraction?

Intent extraction is a type of Natural-Language-Understanding (NLU) task that helps to understand the type of action conveyed in the sentences and all its participating parts. An example of a sentence with intent could be: Siri, can you please remind me to pickup my laundry on my way home?


2 Answers

You can do intent identification with DeepPavlov, it supports multi-label classification. More information can be found in http://docs.deeppavlov.ai/en/master/components/classifiers.html The demo page https://demo.ipavlov.ai

like image 173
Vlad P Avatar answered Oct 23 '22 02:10

Vlad P


you can use spacy for training a custom parser for chat intent semantics.

spaCy's parser component can be used to trained to predict any type of tree structure over your input text. You can also predict trees over whole documents or chat logs, with connections between the sentence-roots used to annotate discourse structure.

for example: "show me the best hotel in berlin"

('show', 'ROOT', 'show')
('best', 'QUALITY', 'hotel') --> hotel with QUALITY best
('hotel', 'PLACE', 'show') --> show PLACE hotel
('berlin', 'LOCATION', 'hotel') --> hotel with LOCATION berlin

To train the model you need data in this format:

# training data: texts, heads and dependency labels
# for no relation, we simply chose an arbitrary dependency label, e.g. '-'
TRAIN_DATA = [
    ("find a cafe with great wifi", {
        'heads': [0, 2, 0, 5, 5, 2],  # index of token head
        'deps': ['ROOT', '-', 'PLACE', '-', 'QUALITY', 'ATTRIBUTE']
    }),
    ("find a hotel near the beach", {
        'heads': [0, 2, 0, 5, 5, 2],
        'deps': ['ROOT', '-', 'PLACE', 'QUALITY', '-', 'ATTRIBUTE']
    })]

TEST_DATA:
input : show me the best hotel in berlin
output: [
      ('show', 'ROOT', 'show'),
      ('best', 'QUALITY', 'hotel'),
      ('hotel', 'PLACE', 'show'),
      ('berlin', 'LOCATION', 'hotel')
    ]

for more details Please check the below link. https://spacy.io/usage/examples#intent-parser

like image 41
manish Prasad Avatar answered Oct 23 '22 04:10

manish Prasad