Qubot NLU
Introduction
If you want your bot to be up-to-date and able to process natural text input, then use our innovative technology - Natural Language Processing (NLP). It is NLP that allows your bot to understand the meaning of users' messages and generate appropriate responses. Whether the client wants “two Margherita pizzas and cola” or “cola and cheesecake for two”, the bot will understand and place the correct order.
How NLP works. General information
The essence of the work of NLP comes down to the analysis of the main components of any sentence - entities and intents.
- Entities are any real world objects, e.g. cola (drink), Ukraine (country), 2022 (number), Dmitry (name).
- Intents are the client's wishes described as a sentence, for example, I would like a cola (want), how to get to the theater (finding a way), hello (greeting).
To recognize intentions, machine learning methods are used based on prepared phrases as examples for each class. These methods range from a simple bag-of-words to neural networks of fairly complex architecture. Words, n-grams of words, n-grams of letters (combating typos), the presence of a question mark and others are used as features.
Using combinations of recognized entities and intents, we can confidently state what the client wants and take appropriate actions.
There are some simple examples from a pizzeria bot in the table below:
| Message 👩 | Entities | Intents | Reply 💻 |
| Hi | - | greet | Hello |
| Hi, I'm Margo | $NAME = Margaret | greet | Nice to meet you, Margaret! |
| I would like two Margheritas and a cola | $NUMBER = 2 $NAME = Margherita $DRINK = cola | want | Would you like to place an order for: 2 Margherita pizzas and one cola? |
| I would like | - | want | What would you like? |
| I would like to go to Ukraine | $COUNTRY = Ukraine | want | The distance from you to Ukraine is 4768.95 km. It will be most convenient to fly by plane. |
В каждом из представленных примеров бот, несмотря на схожие намерения и распознанные сущности бот дает осмысленные ответы. В случае намерения greet, мы понимаем что $NAME - имя клиента, а в случае намерения want мы понимаем что $NAME название пиццы.
Улучшение интеллектуального развития бота
Описанные ранее общие сведения применяются для работы NLP у многих компаний, это довольно простая схема, только у неё есть недостаток - бот не способен ориентироваться в контексте. Это значит что во всех примерах из таблицы 1 всегда будет один и тот же ответ.
Для предоставления боту большего интеллекта в NLP от QuData используются забываемые намерения, а также механизм сохраняющий историю общения с клиентом.
Забываемые намерения - это такие намерения, которые происходят вне основного направления бота и забываются при первом же обычном намерении.
Благодаря этому Вам бот может ориентироваться в контексте, а также обрабатывать более сложные цепочки диалогов, например, такие:
Желтым выделены забываемые намерения.
| Сообщение 👩 | Сущности | Намерение | Ответ 💻 |
| Хочу фанту | $DRINKS = фанта | want | Сколько фанты Вы хотите? |
| А сколько она стоит? | - | [ want, what-is-the-price ] | Фанта стоит 20 гривен. |
| Тогда три | $NUMBER = 3 | [ want, number ] | Я добавила в заказ 3 фанты |
| Сообщение 👩 | Сущности | Намерение | Ответ 💻 |
| /start | - | start | Здравствуйте. Меня зовут Бот. Как Вас зовут? |
| Меня зовут Катя | $NAME = Екатерина | [start, my name is] | Очень приятно Екатерина, рад знакомству. |
| Привет | - | greet | Всегда рад поздороваться повторно. |
| Meня зовут Маша | $NAME = Мария | my name is | Понятно... То есть Вас зовут Мария? |
| Нет. | - | deny | Как же Вас тогда зовут? |
| Даша | $NAME = Дарья | name | Понятно... То есть Вас зовут Дарья? |
| Да | - | yes | Хорошо, Дарья, я это запомню. |
| Meня зовут Даша | $NAME = Дарья | my name is | Да, Дарья, я знаю. |
| Я хочу фанту | $DRINKS = фанта | want | Сколько фанты Вы хотите? |