Let's go with Watson Assistant (formerly Conversation) ① Introduction What is the idea and intention understanding of interactive apps?

Target

Even with zero knowledge, we will bring you to the point where you can create Slack Bot and Line Bot using Watson.

[Updated on June 6, 2019] This post was written during the Watson Conversation era, the predecessor of Watson Assistant, and although screen captures are still old, Watson Assitant's basic ideas and operations Does not change, so please read it as the latest environment. </ font>

■ I would like to touch on the following.

** ① Introduction to thinking, account creation ** ← This article ② Design method of dialogue flow using "Hotel reservation" as an example ③ Utilization of context, practical usage of various functions not mentioned in Tutorial ④ How to link with Java logic ⑤ Create a chatbot with Watson + Java + Slack

__ I thought I'd write it all in one go, but it's too long, so I'll separate the articles. __

For people like this

I've read Watson Assistant (formerly Watson Conversation) articles, read API DOC, and tried samples, but I'm writing for those who don't really understand.

When I first touched it, I didn't really understand it.

What to make

Consider a system such as Slack or LINE where Java is the link between the front end and Watson, and Watson is in charge of natural language processing and dialogue.

kiso00.png

How to make Slack Bot and Line Bot is described in ↓, so the main part of this article is Watson. -Easy to create LINE BOT with Java Servlet -Easy to make Slack Bot with Java

What is Watson Assistant (formerly Watson Conversation)?

Watson Assistant (formerly Watson Conversation) is a service that allows you to easily design and realize a dialogue flow with users like a chatbot.

The feature is that it can handle natural language flexibly, but basically it is suitable for those who can ** rule the dialogue ** (this is called ** rule based **).

Try programming a dialogue with a simple response

Let's first consider a dialogue that does not use Watson Assistant (formerly Watson Conversation).

The tool used here is the if statement.

【hotel reservation】 Let's create a scene of ** booking a hotel ** with an if statement.

What happens when the user says ** "I want to reserve a room" ** Is it like the following?

String inputText="I want to reserve a room";

if(inputText.contains("Reservation")){
return "Understood. It's a room reservation!"
}

If the keyword "reservation" was in the text, I guessed the intention that "this person wants to make a reservation".

However, the user may say ** "I want to take a room" **, so I will support that as well.

String inputText="I want to take a room";

if(inputText.contains("Reservation") || inputText.contains("I wanna get")){
return "Understood. It's a room reservation!"
}

But here the user said ** "I want to cancel my room reservation" **. If you keep the above logic, it will be ** reserved **, so I hurriedly did the following.

String inputText="I want to cancel my room reservation";

if((inputText.contains("Reservation") || inputText.contains("I wanna get")) && !inputText.contains("Cancel")){
return "Understood. It's a room reservation!"
}

In this way, the if statement becomes complicated ...

I do not intend to deny this means (if sentence operation) itself, As the text becomes more complex and more numerous, it turns out to be not easy.

Depending on the person, a little care may be taken to analyze the morpheme and decompose the part of speech. You can do a hook-up analysis, but in any case, it's very good.

Next, let's see how Watson Assistant (formerly Watson Conversation) can make this easy.

Watson Assistant (formerly Watson Conversation) The basics of dialogue thinking

Step 1. Intention classification

Even in Watson Assistant (formerly Watson Conversation), the part that ** guesses the intention from the text ** is Same as the program above.

However, it is not necessary for the developer to create and judge the logic of ** whether or not "reservation" is included in a part of the sentence ** like the above if statement.

All you have to do is enumerate the sentences that the user is likely to say and let Watson remember (learn) them as shown below.

** "I want to reserve a room" ** ** "I want to get a room" **

Then, when you receive the sentences listed above, tell them to classify them as ** "vacancy reservation" **, and Watson will ** learn ** them. ** Intention ** is called ** Intent ** in Watson.

kiso_g01.png

After learning, Watson will determine ** "vacancy reservation" ** even if a ** similar ** sentence arrives. (Probability is expressed by a numerical score.)

Sentences such as ** "I want to make a reservation" ** or ** "Can I get a room?" ** will be properly interpreted as ** Vacancy reservation **.

kiso_g02.png

Now, the process of determining the intention from this ** sentence ** is Since sentences entered with a certain intention are ** classified ** into a certain category This is called ** intention classification **.

This ** intention classification ** is sometimes referred to as ** intent understanding **, but unlike humans ** machines (Watson) cannot understand the meaning and intent of sentences like humans ** Therefore, the name ** classification ** is more appropriate.

This ** ability to classify natural sentences ** is one of the core technologies of Watson Assistant (formerly Watson Conversation). (Watson's internal processing is presumed to be doing ** word2vec **-like things and utilizing various knowledge)

This technology can also be used alone, and a service called Natural Language Classifier (NLC) is available. I will.

Natural Language Classifier (NLC) translates into ** natural language classifier **, which is a correct name without exaggeration.

Step 2. response

Now consider the response.

What is a response?

Continuing with the example of a hotel,

** User "I would like to reserve a room" ** ** Counter "When are you sure?" **

This ** "When are you sure?" ** becomes the ** response **.

kiso02.png

When you receive a sentence classified as ** Vacancy reservation **, the response is how to return it. The designer of the dialogue flow decides how to return it.

This ** response ** itself does not have Watson's unique intellectual processing, It means that the response text (other than the text can be output) is returned according to the rules decided by the dialogue flow designer.

Continuous dialogue flow

As shown in the figure below To summarize step 1 and step 2, ・ Classify input sentences into ** intention ** ・ ** Response ** to ** intention ** according to the set rules It will be.

The basic idea is to make a set of step 1 intention classification and step 2 response and connect multiple responses to form a dialogue.

kiso03.png

Account creation

Create an account now and use Watson Assistant (formerly Watson Conversation).

Create a Bluemix account

--Access Bluemix Create a Bluemix account by accessing the following to use Watson Assistant (formerly Watson Conversation) https://console.ng.bluemix.net/

--Follow the screen and enter the required information

setup1.png

--For the first time, you can use a free trial.

setup2.png

--Tap the menu at the top left of the screen after creating an account setup3.png

-Select ** Service ** setup4.png

-Select ** Watson ** setup5.png

-Select ** Create Watson Service ** setup6.png

-Select ** Conversation ** setup7.png

--Scroll down the screen setup8.png

--Make sure ** Free ** is selected in your pricing plan and select ** Create ** This will create the Watson Assistant (formerly Watson Conversation) service.

setup9.png

For free plans

--1,000 API queries per month --Up to 3 workspaces --Up to 25 intents --Shared public cloud

However, this is sufficient for a simple dialogue flow.

By the way, Watson itself runs on WDC (Watson Developer Cloud), not on Bluemix.

-** Service Credentials ** Select tab step10.png

--Check ** username, password ** in the box below. These will be needed later when calling Watson's API from Java etc. (Can be checked at any time)

step11.png

――Let's create a workspace right away.

Select the ** Manage ** tab and select ** Launch tool ** to open the workspace screen

step12.png

-Select ** Create ** to create a new workspace.

Roughly speaking, a workspace can be thought of as a dialogue flow.

By the way, with the free plan, you can create up to 3 workspaces per service. Create a workspace for hotel reservations

step13.png

――By now, you are ready to start interactive design. step14.png

The continuation is here. ** Let's go with Watson Assistant (formerly Watson Conversation) ② Make a hotel reservation chatbot **

Recommended Posts

Let's go with Watson Assistant (formerly Conversation) ① Introduction What is the idea and intention understanding of interactive apps?
Let's go with Watson Assistant (formerly Conversation) ④ How to link with Java logic
Let's go with Watson Assistant (formerly Conversation) ② Make a hotel reservation chatbot
Let's go with Watson Assistant (formerly Conversation) ⑤ Create a chatbot with Watson + Java + Slack
What is JSP? ~ Let's know the basics of JSP !! ~