Difference between revisions of "Qubot NLU"

From QuData
Jump to navigation Jump to search
(Created page with "<span id="qubot-nlu"></span> {{TOCright}} ==Introduction== If you want your bot to be up-to-date and able to process natural text input, then use our innovative technology -...")
 
Line 8: Line 8:
 
The essence of the work of NLP comes down to the analysis of the main components of any sentence - '''entities''' and '''intents'''.
 
The essence of the work of NLP comes down to the analysis of the main components of any sentence - '''entities''' and '''intents'''.
  
*'''Entities''' представляют собой любые объекты реального мира, например, кола (drink), Украина (country), 2022 (number), Дмитрий (name).  
+
*'''Entities''' are any real world objects, e.g. cola (drink), Ukraine (country), 2022 (number), Dmitry (name).  
  
*'''Intents''' - это желание клиента описанное в виде предложения, например, я хочу колу (want), как пройти к театру (finding a way), привет (greeting).
+
*'''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).
  
Для распознавания намерений используют методы машинного обучения на основе подготовленных фраз-примеров для каждого класса. Эти методы варьируются от простого мешка слов до нейронных сетей достаточно сложной архитектуры. В качестве признаков выступают слова, n-граммы слов, n-граммы букв (борьба с опечатками), наличие знака вопроса и т.д.
+
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.
  
Ниже в таблице 1 представлено несколько простых примеров из бота пиццерии:
+
There are some simple examples from a pizzeria bot in the table below:
  
 
<table style="border-style: solid; border-width: 1px; border-color: lightgray;">
 
<table style="border-style: solid; border-width: 1px; border-color: lightgray;">
     <tr><td>'''Сообщение 👩'''</td><td>'''Сущности'''</td><td>'''Намерение'''</td><td>'''Ответ 💻'''</td></tr>
+
     <tr><td>'''Message 👩'''</td><td>'''Entities'''</td><td>'''Intents'''</td><td>'''Reply 💻'''</td></tr>
     <tr><td>Привет</td><td>-</td><td>greet</td><td>Здравствуйте</td></tr>
+
     <tr><td>Hi</td><td>-</td><td>greet</td><td>Hello</td></tr>
     <tr><td>Привет, я Марго</td><td>$NAME = Маргарита</td><td>greet</td><td>Очень приятно, Маргарита!</td></tr>
+
     <tr><td>Hi, I'm Margo</td><td>$NAME = Margaret</td><td>greet</td><td>Nice to meet you, Margaret!</td></tr>
     <tr><td>Я хочу две Маргариты и колу</td><td>$NUMBER = 2<br/>$NAME  = Маргарита<br/>$DRINK = кола</td><td>want</td><td>Вам оформить заказ:<br/>2 пиццы Маргарита и одна кола?</td></tr>
+
     <tr><td>I would like two Margheritas and a cola</td><td>$NUMBER = 2<br/>$NAME  = Margherita<br/>$DRINK = cola</td><td>want</td><td>Would you like to place an order for:<br/>2 Margherita pizzas and one cola?</td></tr>
     <tr><td>Я хочу</td><td>-</td><td>want</td><td>Что Вы хотите?</td></tr>
+
     <tr><td>I would like</td><td>-</td><td>want</td><td>What would you like?</td></tr>
     <tr><td>Я хочу в Украину</td><td>$COUNTRY = Украина</td><td>want</td><td>От Вас до Украины 4768.95 км. Удобнее всего Вам будет лететь на самолёте.</td></tr>
+
     <tr><td>I would like to go to Ukraine</td><td>$COUNTRY = Ukraine</td><td>want</td><td>The distance from you to Ukraine is 4768.95 km. It will be most convenient to fly by plane.</td></tr>
 
</table>
 
</table>
  

Revision as of 14:24, 5 July 2022

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 👩EntitiesIntentsReply 💻
Hi-greetHello
Hi, I'm Margo$NAME = MargaretgreetNice to meet you, Margaret!
I would like two Margheritas and a cola$NUMBER = 2
$NAME = Margherita
$DRINK = cola
wantWould you like to place an order for:
2 Margherita pizzas and one cola?
I would like-wantWhat would you like?
I would like to go to Ukraine$COUNTRY = UkrainewantThe 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Сколько фанты Вы хотите?