0
$\begingroup$

I have created a very simple chat bot based on RASA NLU. In this case, I manually create some sample input text and create a model for using it against unknown source of input. It's fine for now.

As my next step of learning, I want to do use a big documnet as source for my chat bot.

What steps should I do to make the program train automatically on the documnet text corpus and able to answer based on the user query? I want to avoid the manual training.

For this NLU problem statement, what libraries can I use?

Almost all internet sources talk about SQuaD models. How they are related to a custom domain training?

Any blogs, tutorials, libs that can help me to do this will be useful.

Some other related questions but without solid answers:

Build knowledge bot using deep learning

$\endgroup$
4
  • $\begingroup$ What do you mean by using a big document to answer based on a user query? Does it mean that the answer is provided somewhere in the document? Or do you mean that the chatbot should read the document to learn how to form an answer (in terms of language) $\endgroup$ Commented Jul 4, 2018 at 11:25
  • $\begingroup$ I have a software user guide in multiple text files. When some user asks question about the software, the code should give back from response extracted from the text files. It should be able to get response from the files and not frame response on its own. $\endgroup$
    – Purus
    Commented Jul 4, 2018 at 11:44
  • $\begingroup$ I am still a bit confused about what you mean by train automatically vs manually. Could you elaborate? $\endgroup$ Commented Jul 4, 2018 at 11:57
  • $\begingroup$ Generally for a chat bot engine( RASA NLU, DialogFlow, Wit.ai), developer has to manually provide sample inputs to train the engine and find the correct intent. This is supervised learning. I want my model to automatically train tiself(unsupervised) based on the document. $\endgroup$
    – Purus
    Commented Jul 4, 2018 at 12:04

1 Answer 1

2
$\begingroup$

It seems like your problem is some form of FAQ matching. The user asks a question, the NLU part matches this question to a relevant answer located in your files.

For the training aspect, you could do two things:

  • Similarity measure

You could simply use a string matching distance like Levenshtein between your input and the different outputs, and return the output that is the closest. This way you do not need to train your model per se. Since this is a form of a K-Nearest Neighbour with one neighbour, the learning happens during the inference. The advantage of this is that if your files change, or you have more answers, you won't have to change anything.

This is what you mean by self-learning.

This blog explains how to use fuzzywuzzy (a Python package to compute such distances): https://marcobonzanini.com/2015/02/25/fuzzy-string-matching-in-python/

  • Trained model

Obviously, simple distance measures might not scale well or might simply not perform great. Your other option is to treat this as a classification problem. Your classes are your different answers from your file, and your inputs are the user inputs. This will require the user input to be labelled.

This is what you refer to as manual training.

Question answering

Everything that was mentioned above was assuming that you have a known list of possible answers. If what you want is to have your bot "query" your text files and figure out the answer on its own, it will be much more complicated task. Question answering from open text is a complicated field of research. Just think of Google. It is able to sometimes answer simple questions like "Who?", "What time?" etc. but it's not very good yet at giving concise answers to complex queries.

$\endgroup$
6
  • $\begingroup$ Can you please point me some tutorials or blogs to try both of these approaches? What tools should I be using? $\endgroup$
    – Purus
    Commented Jul 4, 2018 at 12:09
  • $\begingroup$ Both approaches are pretty straightforward. The first one, you need to compute the distances between your input and the different possible outputs. For the second, it is a simple text classification problem. You can refer to scikit-learn.org/stable/auto_examples/text/… $\endgroup$ Commented Jul 4, 2018 at 12:16
  • $\begingroup$ Can you explain how it's a simple classitifaction problem? The output should be a sentense from the document.. $\endgroup$
    – Purus
    Commented Jul 4, 2018 at 12:35
  • $\begingroup$ The output in terms of the chatbot yes, but the classification can simply return an index (0,1,2,3,4 etc.) which you can then map to the answers $\endgroup$ Commented Jul 4, 2018 at 12:37
  • $\begingroup$ How does these logics help me extract a part of sentence as respone? I am sorry for too many question. I am trying to understand better. We can not return an entire paragraph or document as response. The response should be a some substring of the paragraph. $\endgroup$
    – Purus
    Commented Jul 4, 2018 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.