Home / spaCy / 3 Ways spaCy can help improve Dialogflow accuracy

3 Ways spaCy can help improve Dialogflow accuracy

spaCy is a free open-source library for Natural Language Processing in Python.

You can use it to improve the accuracy of your Dialogflow bots.

This is somewhat advanced material, and also requires that you already have a Python programmer on your team who is familiar with the basics of Natural Language Understanding (NLU)

Automatically group chat logs into intents

You can do the verb.noun analysis I describe here to automatically group your chat logs into Dialogflow intents. It uses the spaCy dependency tree feature to extract sentences in the format specified.

This can be especially helpful if you have a lot of chat logs and you are trying to sort/cluster them without manually spending a lot of time. Even though the automatic grouping can help a little, you still need to do some manual work to finish the process.

This can improve the accuracy of your Dialogflow ES bot by making sure you are creating intents that help Dialogflow’s existing ML algorithm. To understand why, I recommend going through this article.

Autogenerate test scripts from training phrases

You can run automated conversation tests to ensure that your chatbot is working as expected. This is important because any change you make to your training phrases has the potential to break existing behavior.

The easiest way to generate test scripts is to parse your existing training phrases and programmatically add a filler word at the end. spaCy makes it easy for you to do this.

I explain the idea in this video.

Improve training phrase quality

Dialogflow matches user utterances to existing intents.

During this process, it provides an “intent detection confidence” score.

You can use spaCy to analyze all user utterances and see if you can identify patterns in the utterances which get very low confidence scores. In turn this will help you choose better training phrases for your chatbot.

When Dialogflow matches a user utterance to an intent, there are four possible outcomes: true positives, true negatives, false positives and false negatives (defined here).

We don’t care much about true positives and true negatives, although they can be useful for conversation testing.

To figure out false positives and false negatives, you can do some basic NLU analysis of your user utterance and try and see why the mapping failed. This will give you a lot of insight into what is happening under the hood.