current position:Home>Chat robot landing and advanced actual combat | millions of people learn AI

Chat robot landing and advanced actual combat | millions of people learn AI

2022-05-08 03:48:02Zhang Zhiqiang

 Chat robot landing and advanced actual combat | Millions of people learn AI

Ding Dong ~ You were hit by welfare ! From now on ,「2020 AI Developer Conference 」299 Tickets are free ! Enter the registration page 【2020 AI Developer Conference ( Online live broadcast tickets )-IT Live training -CSDN college 】, Click on “ Sign up now ”, Use discount code when settling accounts “AIP1410”, The price will become “0" element !

In recent years , Chat robot technology and products have developed rapidly . Chat robot is a killer application of artificial intelligence technology , In full swing , Various intelligent hardware emerge in endlessly .

In this open class ,AI The science and technology base united with the blog viewpoint of electronic industry press to invite the general manager of Shanghai wage Intelligent Technology Co., Ltd , Shao Hao, President of the Artificial Intelligence Research Institute of Setaria science and Technology , He will be in 3 month 21 We will explain the landing and advanced actual combat of chat robot in the open class on the th .

This course will comprehensively explain the technical framework and engineering implementation details of chat robot , And for the next generation paradigm of chat robot : Virtual life , A detailed analysis , meanwhile , Focusing on the important role of knowledge map in the process of realizing cognitive intelligence , The implementation practice of knowledge map is given .

 Chat robot landing and advanced actual combat | Millions of people learn AI

This course is suitable for R & D personnel in the front line of engineering , Through this course, you can understand the implementation details of chat robot . Suitable for college students , You can learn the technical framework and typical algorithms of chat robot through this course .

The following is the shorthand arrangement of open class

Shao Hao : Talk to you today “ Landing and advanced actual combat of robot ”. I'm Shao Hao from Shenzhen Setaria Intelligent Technology Co., Ltd , Now I am responsible for the work of the company's Artificial Intelligence Research Institute , Mainly do chat robot related products .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Today I want to talk to you about these aspects , It includes the following parts :

  • The first part , Let's talk about the background and technical architecture of chat robot ;
  • The second part , I'll talk to you about all aspects of robot engineering implementation , Here I will cooperate with some code , Explain each module to you 、 How each function is realized , I hope that after listening to this part , You can build a chat robot by yourself ;
  • The third part , I want to talk to you about the application and technical path of knowledge atlas in virtual life , And will briefly introduce virtual life , That is, after we found out the problems of chat robot , Think about whether there is a better way to solve many problems faced by chat robots ;
  • Last part , flowers 5-10 Minutes to talk with you about other problems of project landing .

That's all for a brief introduction , Let's get back to business .

Overview of chat robot

Let's start with the background . How do you feel about AI now ? Whether it's AlphaGo, still AlphaGo Zero, Defeat the best go player in mankind ; still Project Debater, A robot participating in the human debate competition , In this year 1 This month has made great achievements ; It's also Boston power, a flowing robot and robot dog , It is also a very good application of artificial intelligence , And like OpenAI Once last year DOTA2 Also very good in the game .DeepMind Doing in recently 《 starcraft 2》 The game , Artificial intelligence is breaking through one human imagination after another , So now we have a very intuitive impression of AI ? Artificial intelligence is omnipotent from heaven to earth , So we think , Whether it's the robot awakening now mentioned in the media , Or human destruction , It becomes a very natural thing .

 Chat robot landing and advanced actual combat | Millions of people learn AI

If we take this feeling to see the chat robot, what is it like ? How do we feel about using ? You may be like me , Anyone who has this chat robot product , We probably used it 1、2 God , After the novelty has passed , I found that this thing will never open again , Or never talk to it again , What causes this phenomenon ? Except for mispronunciation 、 The accuracy is not high , We are still very tolerant of these problems . But last time we saw a report in the media —— Foreign users use Amazon's Echo What happened to the speaker ? He is sleeping at night , Suddenly the light came on , Then he sneered twice ! This is terrible 、 It's scary 、 It's creepy ! If it's me in this situation , In the middle of the night, the speaker suddenly laughed , Except unplug it , Throw it off the building and smash it to pieces , There is no good way to solve my hatred , So we can see that the performance of this chat robot product is really poor .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Speaking of chat robot products, why do they do so badly ? As a practitioner, I am very tolerant , Because I know where the boundary of chat robot is , So when I asked about chat robot products, I was thinking : This chat robot product may have technical problems in this place , So I don't ask or try to avoid asking it . But ordinary users are not so tolerant of chat robot products , I spent so much money on this chat robot speaker , What I want is a robot that can talk to me naturally , But after this can't be reached , He'll complain about developers .

Users generally have a very low tolerance for our product , They think your skills are really poor , In fact, our industry practitioners feel very wronged , We are not to blame for this , It is determined by the current level of Technological Development . As Mr. Zhou Ming, vice president of Microsoft Asia Research Institute, once said , Language intelligence is the Pearl in the crown of artificial intelligence , If we take this beauty as all our skills , Artificial intelligence is the crown on her head , And language intelligence is the Pearl on the crown . What do you mean ? Natural language processing itself is very difficult !

Let me give you a simple example , You get the idea , For example, I say a word called “ I like him for nothing , But he just didn't say .” I asked the students , Who likes who ? Who doesn't say ? This sentence is difficult . Let me say one more thing , such as “ I didn't see him take your wallet ”, If we're in a different tone 、 With different tones and accents , The meaning of this sentence is completely different . for instance “ I didn't see him take your wallet ”( The stress is on “ See ” On ), I didn't see him take your wallet , I may have heard that he took your wallet , But I didn't see it with my own eyes , perhaps “ I didn't see him take your wallet ”( The stress is on “ wallet ” On ), That means he took something else from you , But he didn't take your wallet .

So when we understand a sentence , It's actually related to the context , Talk to the world view of the speaker 、 The mood of the speaker 、 The environment 、 The listener's world view is very relevant , A word of “ how are you ?” Or a word “ Did you have your meal? ?” The meaning of dialogue in different characters is completely different , therefore NLP Technology itself is very difficult ,

Of course , Still have to do , Why ?

I have said in other reports , Microsoft is in 2016 Put forward such a slogan in , It's called “ Dialogue is the platform ”, It believes that language is the most natural way of human interaction , From ancient times , Human beings cooperate with each other when hunting with language 、 Echo each other , When you have a good harvest , Gossip with everyone in the village , Promote our friendship , So language is the most natural way of human interaction . But limited by hardware and software , We used to interact with computers basically with keyboard and mouse , So let's study deeply now 、 big data 、GPU After the hardware upgrade , You can directly use language to interact with the machine , That's why 2016 Microsoft proposed “ Dialogue is the platform ” The concept of .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Chat robot eco technology system

Let's see how chat robots are classified , It can be divided into three major ecosystems : One is the framework , Second, products , The third is the platform .

How to understand ?Echo It's a product ,Apple Of Siri It's a product , Childe Xiaobai is a product ,IBM Watson It's a product , Xiaobing is also a chat robot product . These products have different presentation forms , such as Siri The carrier of is mobile phone 、 Wechat or Weibo ; We have a speaker , Its carrier is its hardware , These products must have a carrier to carry , This carrier is called the platform of chat robot , This platform may include things like wechat 、LINE、MSN And so on . We can understand it as a platform that uses this framework to build this product , There are... Abroad Alexa、LUIS、Wit, There are some in China, such as ruyi、UNIT All belong to the framework of chat robot .

Let's look in the direction of products , Products are mainly divided into two categories , The first category is Passive interaction , The second category is Active interaction . The so-called passive interaction is that I ask it and answer , Let me tell it , It said to me , This is called passive interaction . We just talked about passive interaction , Passive interaction is actually divided into several types .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Engineering practice of chat robot ( Code interpretation )

The next code actual combat link , I'll chat with everyone from 、 To the task dialogue 、 To Q & A , Let's completely sort out all the categories of chat robots . Many chat robots can't do active interaction , Because it requires a strong knowledge map knowledge and scene design , For example, what kind of music do you recommend when you are in a bad mood , This is the aspect of active interaction , Not doing very well now . The amway , We published a Book , It's called 《 The principle and application of chat robot technology 》, Interested students can have a look .

Now start to enter the actual combat link , I'll start with the simplest , There is no need to have any knowledge reserve , You can be a chat robot , Until we build the framework of a chat robot by ourselves , And make use of Python To realize this chat robot .

Quick start

 Chat robot landing and advanced actual combat | Millions of people learn AI

The first step is to show you this “ Quick start ”. What I have prepared for you is this example , You can look at my website , The example I prepared for you is one called ruyi The platform of , Its website is, After opening this page, there is a page called “ The ring ” Skills plug-in tools , At this time, there is a sentence on it called “ I want to produce robots ”, Sign off , We can use its platform to build a robot . It can be seen here that I have built many chat robots now , I can create a new one , To save time , I directly manage my existing chat robot . Can make robots have skills that they can't , In the skill store, robots can have Chinese English translation skills 、 Video on demand skills 、 Challenge word skills 、 Children's chatting skills , Click on “ Acquire skills ”, It can be deployed directly , After deployment, I can chat with it directly , This function has been embedded . There is another kind. , Yes, we can establish some new intentions in the dialogue scene , This intention is equivalent to you matching some corpus , Then it answers some specific corpus , For example, I created a new idea here called “ Greetings ”, This means when the user says “Hi” perhaps “Hello” perhaps “ Hello ” When , The robot's answer is “Hi”/“Hello”/“ Hello , Long time no see .” This ruyi Robot, if we set it according to this skill , We can try it , For example, I say “Hello”, It will say “ Hello , Long time no see ”, Let me say one more thing “Hello”, It will randomly choose one of the two replies to reply . In fact, you don't need any basic knowledge , You can build your own chat robot , We are using The platform to do this , This is the simplest way to operate .

Next , Let's talk about a slightly more difficult platform . This platform is called Baidu's UNIT, Baidu UNIT Well done now , Let's take a look at this Baidu UNIT How to use the , The address is, This is beautiful , Moving the mouse has some dazzling effects in the past . Get into UNIT after , Or to save time , I won't just build a new robot , I'll do a test directly on the robot I built this afternoon , I built one called “ test ” Robot , It's the same as ruyi You can also add some skills , For example, I can add a call 、 The movie 、 The weather 、 Plane ticket 、 Such skills as chatting and so on , And it also has a better function ? I can customize some skills , For example, in my skills, I can match one called test The function of , I'm here test There's a “ The weather ”, Is to ask the intention of the weather 、 dialogue .

How to do this ? When talking about this platform , Why do I say it's better than the one just now ruyi A little harder ? It needs to involve our understanding of the slot position . Let's not explain what a slot is , Let's first look at how I set this intention . I set this intention as “weather”, Its alias is “ The weather ”. How does it do ? I designed a word slot called “city( City )”, That is, when I ask the robot a question , I have to put “ City ” The information in this word slot tells the robot , If I hadn't told the robot , It will automatically ask “ What city are you in? ?” At this time, if we set it like this , When I say, for example “ What's the weather like in Shanghai today ” when , It can say “ Now broadcast the weather in Shanghai ”, It will check whether I already have... During the conversation “ctiy” Such a slot . These are the two very simple platforms we talked about .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Just now I mentioned that in order to use UNIT You need to understand what this slot means . What does slot mean ? Let me explain to you in detail . Let's take a look at such a dialogue , For example, I'm in the office now , Let's talk about this topic , i'm exhausted , I told this chat robot “ Can you order me a cup of Starbucks coffee to the office ”, The chat robot may reply “ well , Can I order your favorite large American ?” It's actually a task-based conversation , Task-based dialogue is to meet specific task indicators , Like booking tickets 、 Order coffee 、 Ordering meals . In a task-based conversation , Generally, slot extraction and filling are involved , Slot location is the key information needed in this task .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Let's take a look at its processing flow , When this sentence comes in, we will first be in NLU The natural language understanding part makes an intention recognition , You can do it in a regular way , You can use the method of classifier to do , You can also use the existing deep learning methods to do , There's no problem . If we judge the intention of this sentence is to order coffee , What to do next ? The next thing to do is to put these slots needed for coffee , Such as location 、 Shop name 、 taste 、 Fill in the type , This method involves many natural language processing technologies , This is not the focus of our class , We only focus on the information I can extract from this sentence . For example, location , It is the Oriental Science and technology building , According to me GPS location , I'm located in the Oriental Science and technology building , The name of the store is Starbucks , The type is takeout . Because I'm talking about “ Book me a drink and send it to the office ”, No taste , At this step, the robot doesn't know what flavor of coffee I want , Then there is a problem , I don't know what flavor. How can I help you ? This conversation now comes to what we call “ Dialogue management ” modular , Dialogue management is divided into two parts , The first part is called DST, The second part is called DPO( We used to call DPL).DST It means “ Conversation status tracking ”,DPO It means “ Dialogue strategy optimization ”.DST All you do is track its status , And see if there's a context , Maybe he said directly above “ I'd like an American ”, There is no need to guess the user's taste , If we find that this context is absent , I need to guess what his taste is , Here I wrote directly , It may be based on the user's preference for coffee , I made a direct order , American first , Latte second , Mocha third . Then it needs to make a decision , At this time, we have to ask the user what kind of taste to drink ? Or directly reply to the user , Help him order a default coffee ? Here you need to reply with the product settings .

We don't want chat robots to have too many rounds of interaction in functional conversations , We hope to be able to understand what I mean in one sentence . Just like emperors and eunuchs , The Emperor gave a look , The eunuch knew what to do soon , This is the best . But chat robots are not that smart , We try our best to make the product design smarter . Then how to design ? For example, this sentence is to design a scene , We know that users like American style best , This sentence may say “ Can I have your favorite large American drink ?” On the one hand, it asked the user's taste , On the other hand, it saves the number of dialogue rounds , This is the processing flow of Task-based dialogue . Of course , Finally, when generating natural language, you also need to use slot to generate this sentence , This is the basic concept of what we call task-based dialogue . Understand this thing , I understand what we're doing UNIT Fill the weather slot .

The realization of three different forms of chat robot

Next, we begin to introduce how three different forms of chat robot are realized . What's the simplest way to do a search robot ? For example, users say to this product “ The clothes you wear are so beautiful ”. The robot will reply “ Thank you for your compliment ”, How does it usually do ? When you say “ The clothes you wear are so beautiful ” When , It will search in a large corpus , Search which sentence is closest to the question I'm asking now , Then reply the reply of the recent sentence directly to the user , Does this look simple ? So in fact, if you master the retrieval method , You can make a great robot . As long as you write enough corpus , Using better similarity algorithm , This chat robot will perform very well . But this only happens in a single round , If in the case of multiple rounds , The search method must have died . What's the most important thing here ? The key is to match .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Let's take a look at how the basic technical process goes , For example, I said just now “ You look so beautiful in your clothes ”. It is as a question , We need to make a retrieval, This retrieval It's a search , We search for some sentences closest to my sentence from a large number of document corpus pairs , And filter out this candidate set , With the candidate set , We'll do a sort , Which of these two sentences is the most similar to mine , Then I will reply to the user with its reply , This is its basic retrieval process , It works 2014 The classical model mentioned in a paper in , I used it directly .

(1) Based on text similarity

Next, let's start with text similarity 、 Retrieval method based on semantic similarity and deep learning , In other words, for retrieval methods , Now let's say here 3 A relatively basic technology .

 Chat robot landing and advanced actual combat | Millions of people learn AI

The first one is , Method based on text similarity . What is text similarity ? for instance “ The clothes you wear are so beautiful ”,“ Your clothes are so beautiful ” These two words , We feel very similar when we face each other , How similar it is ? Because its words 、 Its words have a lot of overlap , This is the intuitive feeling of text similarity . We know that text similarity algorithms have very classic, such as marginal distance 、TF-IDF、BM25, This is a very classic algorithm , I won't do more in-depth description of the algorithm here , If you are interested , I recommend you to attend a course CS 224N, This course is at the University of Stanford Christopher Manning A course taught by the professor in the past few years , It should be called NLP( natural language processing ) This course , It explains the classical natural language processing algorithms very well .

Then our general practice is , This similarity algorithm usually uses string matching , We know that string matching is usually very slow , However, we can improve its search efficiency with the help of similarity search engine . There are two , One is called ElasticSearch(ES), Another call HNSW, If you're interested , You can see it later in the course PDF、PPT Take a look at these two projects .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Next, in actual combat, this is based on ES Similarity search engine , Let's realize a retrieval chat robot , What I have listed here is basically the core code , I won't show you here ,PPT Maybe you can see more clearly .ES How to use ? This is very simple , Let's go straight to Import This ElasticSearch, First, configure it ES Information about , What does the information include ? Its host IP, For example, here I am, The port number is 9201, Then what is the database name ? We called it similarity_chat, What is the name of its table ? For example, we call it “qa_corpus”.

 Chat robot landing and advanced actual combat | Millions of people learn AI

The next step is the normal process , For example, we first need to initialize an object , Lowercase es This object , All the information in this object comes from what we just configured es Information , Here are the port number and IP. Next, we want to go to this es Add data to the , Because we want to add such a batch of data to es In go to ,13 The data in the page , How to add it ? Here we are define One way , This method is called insert_one_data, That is, we insert a question and answer corpus , How to insert ? A question and answer corpus consists of two parts , One is called Query, One is called Answer, It's just one. Q, One A, Then we will call a es Of index Method , This index The method is actually a directly encapsulated method of inserting corpus . How does it do ? If the database doesn't exist , It will directly generate a new database called this name , And create a table called “qa_corpus”. Then for each piece of data , except Query and Answer, Here are two columns of data , One Query, One Answer, It also automatically generates a id, It is equivalent that the data we finally generated is three columns of data , The first column is Query, The second column is Answer, The third column is id, Here are some sentences we saved in advance .

 Chat robot landing and advanced actual combat | Millions of people learn AI

What to do next ? The next step is to search , After we have a question , Defines a method called “similarity_chat”, We search this question , Which sentence is closest to that in my database just now , Then we set up an artificial 90% The threshold of . The similarity is 90% The above answers are returned as the best candidate .Body The format is query And this one. minimum_should_match, Is it 90% Value . And then we use es This search To find its candidate set , After finding the candidate set, compare the threshold , If all thresholds are lower than what we designed 90% Words , It will return a reply directly , such as else,answer This is a thorough reply , then return answer, This is our whole implementation method .

See the specific process above , First , The figure on the left is the three corpora we inserted , Insert three pieces of corpus Query and Answer Namely “ Your clothes are so beautiful ”、“ Thank you for your compliment ”, Then there are these two sentences . We have one now query_sent yes “ Your clothes are very beautiful. ”, We call what we have just set “similarity_chat” This method puts this query_sent Pour it in , Then the best sentence is the first . In other words, we actually use it directly here ES The calculation method of the score of the default similarity , This calculation method can actually tell you here , You can change your calculation method in it , Because we know that the score of matching degree can be optimized by ourselves . therefore , Here, you can adjust the calculation method of score according to your actual situation , Then make a more personalized search engine , The final answer is “ Thank you for your compliment ”, Overall use ES As a retrieval method, I will briefly introduce it to you here .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Just to summarize , be based on ES What are the advantages of similarity retrieval engine ? Text similarity itself has certain generalization support , For example, you add a modal particle “ ah ” perhaps “ Oh ”, Or add a comma 、 Add a punctuation , It can play a better generalization effect in similarity retrieval . Of course , This generalization itself is an important module that can be carried out separately . For example, the method we often use now is called machine translation , We can use the method of machine translation to generalize the design of a large number of sentences , So that our chat robot can support more generalized statements . The second advantage ,ES It comes with BM25 The algorithm has many weights that can be adjusted , In the case of short text, it is much more reasonable than the marginal distance .

The disadvantages are obvious , Let me give you two examples , Everyone will understand , for instance “ How are you beautiful ”、“ I think you look good ”, Let's take a look at the text similarity , Which words in it are the same ?“ you ” It's the same “ good ” It's the same , Other words are different , Semantic similarity but text characters are not very similar , This text similarity algorithm may not be so good , But its semantics are very similar . In the second case, what about the determiner ? such as “ I like you ” and “ I don't like you ” It means the exact opposite , But in text similarity retrieval , If we don't restrict negative words , These two scores are very high ,“ I like you ” and “ I don't like you ” The score is very high , This situation is very difficult to deal with . What is our general treatment method ? The first method is rule , For example, I can set some filter rules for negative words , meet “ No ” In this case, it means the opposite of the original sentence , Or how to use the method of text semantic similarity to retrieve the similarity , Let's talk about the second piece , Is how to do it based on semantic similarity .

(2) Based on semantic similarity

 Chat robot landing and advanced actual combat | Millions of people learn AI

The second kind , Based on semantic similarity . Semantic similarity is generally a three-step process , The three strategies I listed here are three-step strategies , First step , First, turn the words in a sentence into a vectorial representation , There are too many methods of vectorization , And many people have talked about special talk, I won't talk about how to do embedded here , If you are interested, you can read Word2vec This original paper , Or take a look at our current ELMo、Transformer、Bert How do these language vector models do . I won't explain the word vector . The output of word vector is to turn a word into a vector , For example, become a 200 Weior 300 Dimension vector , This is the vector representation of the word .

The second step is to make a vector representation of the sentence , For example, the example I gave just now “ I like you ” It's three words , I 、 like 、 you , After we take the vectors of these three words, how can we make the vectors of the sentence , This requires some methods , For example, add and average , For example, vector extremum , For example, recently used more FastText、Skip-Thought、Quick-Thoughts, These are some methods that are very easy to use , You can express the vector of the sentence according to the specific situation . You can actually use some pre trained vectors , For example, Tencent should have a pre trained vector on a large-scale corpus , You can use it .

The third step is to calculate the vector distance , After we have the vector of two sentences , The next step is to calculate its similarity , That is, its vector distance . In general, Euclidean distance or cosine similarity may be used , That means we get a score . Or some methods based on deep learning , It is also a continuation of what we just PPT The method of calculating the semantic similarity of text similarity . In terms of matching algorithm , I only listed some of the earliest or most classic algorithms , If you're interested , There are still many papers to read , Including many new papers in this field recently .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Let's start from the earliest ,2014 Two algorithms are proposed in this paper by Noah's Ark Laboratory , One algorithm is based on expression , One algorithm is based on interaction . The biggest difference between the two is when calculating the similarity of sentences , The expression based algorithm convolutes the two sentences respectively 、 Pooling , After vectorization, its matching degree is obtained through multi-layer perceptron . image MatchPyramid This algorithm is based on interaction , This algorithm crumples up two sentences at the beginning . We are equivalent to one that is calculated separately , The two brothers separated first , Then divide the property finally ; And this kind of two brothers knead together first , Knead into a matrix , There are some similarities Operator, When you look at the original paper ,Operator There are two kinds , One is point multiplication , One is to maximize . Let's put the words in this sentence, such as this 8 Word , Each word carries out a similarity operation , It becomes 8×8 Matrix , Then we do convolution on this 、 Pooling such operations , Get its final score through the last multi-layer perceptron . So there are basically only these two directions , One is expression based Matching Method , One is called interaction based Matching Method . If you are interested, you can have an in-depth look at the paper .

 Chat robot landing and advanced actual combat | Millions of people learn AI

(3) Based on deep learning

The third kind of , There is also a retrieval method based on deep learning . I chose a classic paper , Let's briefly talk about its idea . Microsoft Xiaobing team is 2016 A method was proposed in , It not only considers the word level , Also consider sentence level similarity . What does that mean ? A brief explanation , We have 4 A sentence :u(1)、u(n-1)、u(n)、r, There are many sentences in the middle , Let's assume it's 4 A sentence , Now it wants to calculate u Follow r Similarity degree , How to calculate? ? It embeds every word , That is to do vectorization , Then follow the word r The word "dot multiplication" is used directly , Which is to get M2 This matrix , After you get this matrix, you can do GRU, Let's calculate the cosine similarity of the final hidden state , Get is M1 This matrix , therefore M1 and M2 These two matrices represent the similarity at the word and sentence levels respectively , And then it's through CNN, One more GRU, Finally, I got one Score. This is that we have some retrieval methods based on deep learning , I'm not going to introduce it in depth . I've finished talking to you just now based on the similarity of the text 、 Based on semantic similarity 、 Retrieval method based on deep learning .

 Chat robot landing and advanced actual combat | Millions of people learn AI

(4) Deep learning method based on generative

A fourth , Let's talk about the deep learning method based on generative learning . This is the first paper , It should also be a paper made by Huawei , What they did at that time was how to directly generate its final reply through a sentence , It is through x(1) To x(t), Directly generate y(1) To y(t), They propose three different methods . One gets it directly from this implicit state context, Another way is to add attention, Use this in a weighted way attention To get the last sentence , There is another one contextAttention, There is also a word level Attention, They call it local and global these two items. Attention Generated reply . There are many generative methods behind this , Because of this talk Based on actual combat , So we don't do too much in-depth explanation of the theory .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Architecture design

Finally came to the most complex piece , If we want to go from 0 To 1 Use your own Python Code to create a chat robot , How to do it ? First step , We need to design the architecture first . The architecture of this chat robot should be divided into several parts , We must use Python Write a DM( Dialogue management ) This module , Then this module will receive natural language understanding (NLU) Some information , meanwhile , It will make an intention analysis of the sentence , At the same time, it will select a function according to the result of intention analysis , For example, it is a task dialogue , Or functional dialogue , Or ask and answer , Or chatting , It has different ways to deal with , At the time of the last reply, we still have one NLG Module , This is a simple structure of the whole chat robot .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Next, the serial number is that I want to go through all these modules with you : first ,NLU, the second , Intention to parse , Third ,DM, Fourth , Task dialogue , The fifth , Question and answer , The sixth ,NLG. Why not talk about functions and gossip ? The function assumes that it can be used directly ruyi、UNIT Your skill pack , We don't do development here . I just talked about gossip , We directly use the retrieval method to chat , We use a lot of corpora to do retrieval chat directly, and then it's over . This is what we call architecture design .


The first point ,NLU How do you do it? . Let everyone down ,NLU There is no code in the , Why is there no code ? Because many open source projects are doing NLU Things about ,NLU In fact, there are many modules , At least we have more than a dozen modules now 、 twenty , What's included here ? participle 、 Part of speech tagging 、 interdependent 、 Sentiment analysis 、 Entity link 、 Entity discovery 、 Semantic disambiguation 、 Subject recognition 、 Sentence validity judgment and so on , This is not something that can be finished in one class . But I suggest , If you really want to implement a chat robot in a simple way , Why don't we use good things ?Jieba Word segmentation is a good open source project , The Chinese Academy of Sciences has another NLPIR, Harbin Institute of technology has a LTP, Stanford has CoreNLP, We also have the most classic NLTK My bag , also HanLP、AllenNLP. stay NLU If you do this by yourself, it's really annoying , For example, participle 、 Depend on what you do , This time is too much , The best way is for me to use other people's things , I'll add some of my own personalization , I am what I am NLU What I want to tell you .

Classification of intention

 Chat robot landing and advanced actual combat | Millions of people learn AI

Second point , Classification of intention . I want to talk to you about the easiest way to implement intention classification , There are actually several classifications of the whole method , such as : traditional method , In traditional methods, we can use features , Use some classifiers , Then directly to this intention , For example, we use decision tree or SVM Classify sentences directly . Of course, you can also use the depth method , such as CNN perhaps CNN+LSTM To sort it out . This is the way to classify the depth map on the right , It is a of a sentence embedding after ,I It's a word , It's a 5 Dimension vector , This is an example , Then it has a vector for each word , After taking this matrix , We'll have some convolution 、 Pool operation , Finally, we get a result of binary classification , This is also done by using the method of deep learning . But what else do we need to consider in the project ? We also need to consider whether we are two categories 、 Many classification , Or hierarchical classification . The second category is very simple ,1 and 0. Multi classification is also very simple , For example, there are emotions “ Positive and negative ”. Hierarchical classification is more complex , For example, there are five categories in our products ,300 Multiple intentions , So when I was doing it , What methods can be used to ensure that it has a relatively high RECALL. This is what we need to do in the project , It's actually a very complicated thing .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Next, I'll talk to you about how to use rule method to realize intention classification , It is very accurate to realize intention classification by rule method , But its disadvantage is that we have to cover every sentence regularly , And when there are too many rules, the model becomes very difficult to maintain , This is its disadvantage . Let's see how the rules do , For example, I give an example of three different intentions , One is “ tell jokes ”, One is called “ The idiom Jielong ”, There's another one called “ The weather ”. Its corresponding rule is written like this , such as “ A joke ” This can cover ,“ Tell a joke ” You can override ,“ tell jokes ” It can also cover ,“ Tell a joke ” It can also cover , It's a rule , The rest is the same .

How to do it ? Let's see , There are two functions on the right , The first function is called build, The second function is called intent_recognition. This function is used for regular compilation , Regular compilation should also be very clear , If we precompile regular expressions , Regular matching can speed up the effective matching , This is compilation , I won't talk about it . The second is above the classification of intention , If there is query Come in after ,candidate_list At first it was empty , Then we compile the regular code , Choose regular from regular to match this sentence , After matching, we will compare the length of the matched string with the intention ranking. That is, it may match different intentions , At this time, we need to sort the intentions according to the length of the string it matches , Finally put all the candidate Output after sorting , This is a piece of code when we use rules to realize intention classification .

Magic medicine :fastText

 Chat robot landing and advanced actual combat | Millions of people learn AI

If people don't want to be so troublesome , There is also a magic medicine that can cure all diseases fastText, Is in 2018 A classification method widely used in engineering circles in . Of course , Now this method is Bert and ELMo、Transformer This more advanced algorithm replaces , It's not beyond , Let's do it together , Sometimes do something Stacking Use the method when , We will also use Bert Or new GPT This algorithm . however fastText The effect of itself on intention classification is very obvious , And because it is based on character substrings , So its performance is also very high , It's not only fast , The performance is also very high , So in 2018 In, we joked that fastText yes “ A panacea for all diseases ”, This magic medicine has greatly promoted the classification of engineering circles .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Let's see fastText How to use it? , It's simple ! Its code is very simple , We just need to prepare a dataset with classification labels . Classification data set here are the words that have been divided , For example, in this sentence label yes weather, In this sentence label yes music, In this sentence label yes news, We have prepared tens of thousands of data sets , Divide it into test sets 、 Verification set 、 Training set , Then we import fasttext, Then define a training function , Define a prediction function , For training functions, for example, directly use train_supervised That's it , Then we can calculate its precision,recall also F1, This is training . How to use it when you use it ? We put model Bring up , Then go to predict This sentence Of label, then return This label It's over .fasText It is a very easy algorithm to use .

 Chat robot landing and advanced actual combat | Millions of people learn AI

DM( Dialogue management )

The third point , The following part starts with DM.DM The code is not posted here , Because this is too complicated . Let me tell you how the whole framework is implemented ,DM Is to control the conversation , In many cases, it is to control multiple rounds of dialogue . Here I give a typical multi round dialogue , The example here is the weather , I've listed here 1、2、3, It's what the user said in the first three rounds , For example, the user's first sentence says “ Did it rain in Shanghai last Sunday ?” Its conversation time is 3 month 21 The no. 8 spot , Its intention is the weather , The location is Shanghai , Time is 2019 year 3 month 17 Number , Because it rained last Sunday . After we extract this information , Will give it a reply 3 month 17 What's the weather like in Shanghai on the th , Did it rain . This is the first sentence the user asked , The following is the same .

The user's second question is “ What's the weather like in Shanghai today ”, So its final reply is 3 month 21 The weather in Shanghai on the th . In the third sentence, the user said an irrelevant , The user feels as if the weather is very bad today , What shall I do? , He said a word “ Don't go out tomorrow ”, At this time, we begin to focus on . The point is that when users say in the fourth sentence “ And tomorrow , What do I do ?” Let's take a look at its processing flow ,“ And tomorrow ” This sentence enters the intention analysis , We find that the normal intention score of this sentence is very low , In other words, it doesn't seem like a normal intention , In the intention judgment, we have loaded the context , In other words, it is the log above , At this time, we use the classifier model to judge or use some rules , Judge that it may belong to a multi round intention . Which one does this multi round intention belong to ? We're going to find this window , There are two windows inside , A time window , A window called rounds , For example, the number of rounds window we set here is 3 round ,3 The contents of the wheel will be captured , The time window is 5 minute ,5 Data will be captured within minutes , After these data are captured , We judge that it is really the weather intention . With this sentence, we fill the slot ,“ And tomorrow ” We judged that he was asking about the weather , What is the slot information of this weather ? Tomorrow is the time information , Where is that place ? Location we directly use the slot information of the location where he asked about the weather in the last round . So finally, our slot information is actually “ Shanghai ” It's the place , Time is “3 month 22 Number ”, What's the weather like in Shanghai tomorrow . This uses a state machine , Then decide what we're going to do next , There will be DST Steps for . meanwhile , After we reply, we also add these logs to the log Go to the database , Finally, a dialogue will be returned , This is a DM Operation process of .

An instance of a conversation based on a specific task

 Chat robot landing and advanced actual combat | Millions of people learn AI

Fourth, , Next is an example of a conversation based on a specific task , There is a lot of code for specific tasks , Can't paste it all , Then post the most basic modules . For example, we will first limit the slot position , such as date Is the slot of time, including “ today | Tomorrow, | The day after tomorrow | This week, | Next week, ” wait , Locations include “ Beijing | Shanghai | Shenzhen | Guangzhou ” Such places , When there is such a question , We will first identify the intention ,intent-recogniton, We'll be on this query Conduct intention recognition , If this intent yes weather When , Enter a slot first , The slot position we extracted is based on weather The following slot information is mentioned , It needs to include time and place , So we have such a function to extract its time and place information . Next , After the slot is extracted, we will request the weather interface , At this time, for example, we use Sina weather , Sina weather has a service , We need to use this date and location Go and ask Sina weather for this service , Return to the current weather , It's called weather-info, With this weather-info Then we use NLG Module into a reply , Get this anwser, This is a simple process based on the implementation of our specific task dialogue .

Q & a module

 Chat robot landing and advanced actual combat | Millions of people learn AI

The first five , Next, let's introduce the question and answer module in the module just now . Let's briefly talk about the module based question and answer method , And more , For example, semantic parsing is beyond the scope of this course . How to do it based on the template ? For example, the user asked “ Do you like watching the pirate king ?” In this sentence, the processing method of template is to match the template library first , It will match who this sentence is closest to in the template library . After matching, we will have an animation Dictionary , It belongs to the pirate king , Pirate king belongs to the type of entertainment animation , So finally give a corresponding reply statement .

 Chat robot landing and advanced actual combat | Millions of people learn AI

How to do ? This is the process , Its approach is like this , We first maintain a regular template library , such as “ You like it (.*)”, This regular template library contains thousands or hundreds of regular templates , When a question comes in , It will match all regular templates in the regular template library , For example, its matching regularity finally matches “ You like it ” Such a sentence , And then put “ You like it ” The latter part is extracted , in other words “ See the pirate king ?” All these characters are extracted as candidates . The candidate must include some adjectives 、 Punctuation 、 Meaningless words , How to delete them ? We used a method called TrieMatch Methods , In fact, you can use the most common matching method to match , We finally matched it to the dictionary called “ One piece ” Dictionary library , And then we put “ One piece ” Keyword extraction into text ,“ One piece ” It belongs to animation dictionary , Then give the user a reply , This is a simple explanation here .

Natural language generation (NLG) example

 Chat robot landing and advanced actual combat | Millions of people learn AI

Last , Let's talk about natural language generation . In other words, when our robot replies , It's impossible to let it just reply to the answers we found . Take the weather , The final result of the weather is usually the temperature , And the weather . So I can't directly reply to the user and say “ cloudy ,10 degree 、15 degree ”, I must reply to very natural sentences . Its approach is like this : For example, we are interested in the whole NLG It's designed like this in the weather reply , its Answer It consists of four parts , The first part is called “ What's the weather today ”, The second part is called “ What's the lowest temperature ”, The third part is called “ What's the maximum temperature ”, The fourth part is called “ Personalized reply corpus ”. We can see , When we have such a slots_info When , We have “ cloudy ,10-15” When the degree of , We can just put this 4 Put one message into one sentence , This sentence may be “ Today's weather is cloudy , The lowest temperature is 10 degree , The highest temperature 15 degree , It's a little cold , Master, wear a thin coat ”, This is natural language generation , We use slot filling to do the specific implementation of the module , In fact, it is also a piece of pseudo code .

 Chat robot landing and advanced actual combat | Millions of people learn AI

To sum up , How do we implement the whole framework ? First ,NLU, We use it Jieba participle 、 Harbin Institute of technology LTP; Intention to parse We can use FastText perhaps Bert;NLG We use the configuration method to do ;DM We use it Python Write for yourself ; Task dialogue We use rules to realize ; Function module We use ready-made ; Q & a module We use templates ; Chat module We use a retrieval based approach , In this way, we can easily implement a chat robot . That's all for the main part of today .

Application and technical path of knowledge atlas in virtual life

Next, I'll talk to you about the knowledge map , The basic technical aspect of chat robot is almost the same as that of everyone .

Talk about the Turing test . Chat robots are now performing very poorly , But in 2014 Still passed the Turing test , The Turing test itself is Turing in 1950 The test invented in the s , It tests whether robots can deceive humans , Its test method is in 5 Within minutes , by myself , There's a wall , I don't know if there is a computer or a person across the street , I talk to it 5 minute , If the person involved in the test 30% All cheated , So this computer passed the Turing test . In fact, this test standard is very subjective , We can use a lot of trick To bypass some of these settings . So in fact, Turing test can't really reflect the intelligence of robot , Because what is the source of the Turing test ? You may have heard this story , Turing is gay , So the Turing test is for every gay in the UK 1950 The day-to-day tests that the s must pass , That means being gay , Can you pretend to be heterosexual , In fact, this is the first reason for the Turing test , It's actually a very tragic story , Finally accepted by Turing due to chemical castration , And then commit suicide in depression , What a pity . So the reason we're talking about this is , We think even the chat robot has passed the Turing test , It doesn't mean that it really has an effect of intelligence .

 Chat robot landing and advanced actual combat | Millions of people learn AI

So we're going to think : Since this chat robot is so bad , How to improve its experience and effect ? One way we think of is to give the chat robot personality and IP turn , For example, big white , such as R2D2, Like aliens , It seems to be called AI, This movie ,《 Western world 》, Can we put these images into the chat robot , This is what we want to do .

We used to make a second-generation product , Is how to make a chat robot more life expression , The video will not be played because of time . So we have a relatively complete definition of virtual life , We call it “ Virtual life ”, In addition to having the most basic ability of chat robot , It also has, for example, look 、 listen 、 say 、 reflection 、 Such abilities as action , This is the effect we expect of virtual life . The definition is that we want it to interact in multiple forms and modes , Strong perceptual and cognitive abilities , And further realize self cognition and self evolution . This is our summary of the overall technology of virtual life , You can see in addition to the image 、 Beyond acoustic and cognitive interaction , We also have a posture like 、 emotional 、 Write words and music 、 Singing 、 What a character 、 Emotion recognition 、 Ability to actively recommend and other aspects .

 Chat robot landing and advanced actual combat | Millions of people learn AI

How to realize these abilities ? The foreshadowing in front of us is to lead to the content we want to talk about next , It's called “ Knowledge map ”, How to really let the chat robot have its own thinking 、 understand 、 Reasoning power , That is what we can expect from the knowledge map technology we are studying . We know , Now is the era of deep learning and big data , Deep learning and big data use its computing power 、 Use its data , At the perceptual level , For example, image recognition 、 speech recognition 、 Speech synthesis achieves very good results , But when you encounter some problems that need to be considered, deep learning must die . A simple example , For example, teacher Xiao Yanghua once gave a classic example called “ I put the eggs in the basket , Is it an egg or a basket ?” This problem is very difficult to solve for deep learning , Because it doesn't have common sense and reasoning , So it can't answer the question whether the egg is big or the basket is big . in addition , I can also ask a question , It's called “ What is the nationality of Yao Ming's wife's daughter's mother's husband ?” I think today's chat robots will be dizzy without exception , Because Yao Ming's wife's daughter's mother's husband is actually Yao Ming , But robots can't understand such a complex piece of information . But at this time, if we have such a rich knowledge map , We can actually reason , Including common sense reasoning .

 Chat robot landing and advanced actual combat | Millions of people learn AI

 Chat robot landing and advanced actual combat | Millions of people learn AI

The whole process of knowledge map

Next, we will introduce the whole process of the knowledge map , The whole process of the knowledge map is clearly written on this map . At the bottom are three different types of data ( structured 、 Semi structured 、 Unstructured ) Data processing , Knowledge representation is used here 、 Knowledge fusion 、 Relationship extraction 、 Event extraction 、 Entity classification 、 Attribute classification and other methods to establish their own knowledge map , Our own knowledge map is called “ eight-line poem with seven characters to a line and a strict tonal pattern and rhyme scheme ”, So I put “ eight-line poem with seven characters to a line and a strict tonal pattern and rhyme scheme ” These two words are written . When we build these knowledge maps , At the top, you can imagine that it can do many applications , Like Q & A 、 Reasoning 、 lenovo 、 recommend , wait , But before doing these applications, we need to have an intermediate layer , It's called “ Knowledge mapping layer ”, For example, we need to do knowledge retrieval 、 Ontology alignment 、 Entity disambiguation 、 Things about machine reading , Only in this way can this knowledge map really become a knowledge application .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Sources of knowledge

First, let's talk about the source of knowledge , Our source comes from Baidu 、 Interactive encyclopedia 、 You know 、 Sina 、 wikipedia 、 Baby girl encyclopedia . Why is there a cute mother encyclopedia ? Our own products tend to be quadratic and entertaining , Therefore, when establishing the knowledge map, we must establish the knowledge map according to our own field , Mengniang encyclopedia brings us a lot of encyclopedia knowledge about quadratic elements , This is some of our very useful knowledge , So we set up such a set of knowledge map that is biased towards the second dimension .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Knowledge means

Then there is knowledge representation , We all know that if knowledge is to be stored, it must be expressed in a certain way , In addition to more intuitive graphical representation , And this RDF Is represented by , You can understand that it is a triple , For example, Trump's wife is Melania , Trump's daughter is Ivanka , It's actually two entities , The relationship between trump and Melania is a wife relationship , Trump's wife is Melania , This is our representation of knowledge . So after we deal with knowledge at the bottom , Let's make a representation of the need for knowledge .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Knowledge completion

And then this PPT I'm talking to you about knowledge completion , How is knowledge completion done ? Let me give you an example , For example, Chen Daoming's wife is Du Xian , Let's look up the entry Chen Daoming in the encyclopedia , We will find that it has a message that his wife is Du Xian , But when we checked Du Xian, we found that none of Du Xian pointed to Chen Daoming , If we have a set of knowledge system , It will limit if one person is another's husband , Then this man must be this man's wife , This logic should not be wrong ? This may also be wrong , Why? ? If both men , Or if both are women , There's a problem with this . But we assume that this does not exist , We assume that if a person is a person's wife , Then this man must be another man's husband . So with this knowledge system , We can patch up a side , For example, Du Xian's husband is Chen Daoming , This edge can be mended automatically , Felida's husband is Cheng Yuan , So Cheng Yuan's wife is felida , Some knowledge can be used to complete , This is also a thing that needs to be done during preprocessing .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Knowledge expansion

What is knowledge expansion ? That is, we learn some nonexistent relationships and add them to the knowledge map . The example I gave may not be appropriate , Because this relationship already exists , I'm just talking about how this method is done .

 Chat robot landing and advanced actual combat | Millions of people learn AI

“2015 year 10 month 1 Number , Liu qiangdong and his sister, milk tea, were married in Australia ”, There is a relation in this sentence , What's the relationship ? Liu qiangdong and his milk tea sister are husband and wife , Then we go on to link through entities , Find the younger sister of milk tea in the database. In fact, her real name is Zhang Zetian , In this way, we can directly establish a husband and wife relationship between Liu qiangdong and Zhang Zetian , And extend this knowledge to our existing knowledge map , This is what we call knowledge expansion .

New knowledge discovery

 Chat robot landing and advanced actual combat | Millions of people learn AI

New knowledge discovery is also something we need to do , Because we know that knowledge changes too fast , We have a lot of hot knowledge recently, constantly refreshing our cognition . such as “ The three royal families ” What do you mean ? Originally, it refers to the three families outside Tokugawa's own family , Now it might mean this , For example, the three Asian expression bags : Yao Ming 、 Curator Jin 、 hyoko north , This kind of royal family . also “ Next to the Lao wang ”, Lao Wang next door used to mean Lao Wang next door , Now it has a meaning called “ Biological father ”, This is also a new knowledge discovery , Something we're looking for .“ Sacrifice to heaven ” It was also very popular the year before last , About storm video , But I think it's interesting , Sacrifice to heaven is by killing programmers 、 Product manager, etc , A ritual to retain users . It is also a new interpretation of old words , In fact, when we discover new knowledge , We need to discover such new knowledge , What to do with this new knowledge ? Then there is the update . We have two ways to update , The first update method is incremental , When we found such hot words , We will update it and its surrounding entities incrementally ; The other is full update , For example, we regularly update the knowledge map every month , Because it costs a lot , Therefore, knowledge updating is also an indispensable part of the whole construction chain of our knowledge map to ensure the freshness of the knowledge map .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Q & A based on knowledge map

Q & A based on knowledge map is an application of knowledge map , The example given here is the question and answer of the knowledge map based on semantic analysis . We can see , The whole Q & A integrates various modules of natural language processing , It also integrates the knowledge fields involved in our knowledge map .

 Chat robot landing and advanced actual combat | Millions of people learn AI

What is the nationality of Trump's wife ? First, we will extract the entity to “ Trump ”,“ Trump ” It refers to Sichuan Mandarin ? Or trump ? Here we need to have a mapping , There is an entity disambiguation , Finally, we get that it means trump .“ The wife ” The corresponding standard name is “ spouse ”,“ nationality ” yes “ nationality ”,“?” yes “?X”, We will combine this semantics , For example, Trump's spouse is “?y”“?y” Your nationality is “?x”, And the last thing we checked was “?x”, So it says ,“SELECT DISTINCT?X”WHERE, What are the qualifications ?“?y” Your nationality is “?x”, And limit Trump's spouse to “?y”, Finally, we get that Trump's spouse is Melania , Melania's nationality is the United States , So the final answer is “ The United States ”, For specific details, we can study the knowledge map based on semantic parsing . A lot of Technology , Including participles 、 Part of speech tagging 、NER、 Relationship extraction , wait , It's not what we're talking about in this class .

Other problems of project implementation

 Chat robot landing and advanced actual combat | Millions of people learn AI

We feel we have mastered a lot NLP knowledge , Master a lot KG technology , There are also some engineering means , I think I can make great products . But as this picture shows you , What kind of bird is this , I also forgot whether it was a wild duck or something , It slipped on the ice , The real landing is sometimes completely different from what we think . Therefore, there are many factors to be considered when the project is implemented , It's not just about technology , Technology may only account for a very small part of our whole productization . We need to consider who this product is sold to 、 How to sell , Then we need to consider the performance architecture of the whole system .

We use the Q & a method , Or do multimodal interactive Q & A , At the same time, we should also consider its software and hardware investment 、 What is the human investment and market situation . Especially now the chat robot itself is not a red sea market , It's already a sea of blood market , Everyone is really beaten up in this market , If you still want to enter the market in the form of simple chat robots , What kind of competition will you face ? Will face 49 Yuan Xiaomi Xiaoai speaker , Will face 79 The heavenly cat spirit of yuan , Will face 199 Yuan's Xiaomi's Xiaoai classmate , also 299 Baidu's Xiaodu is at home . So how to do engineering and product , It is also a problem that we need to think about in the logic of business .

 Chat robot landing and advanced actual combat | Millions of people learn AI


Finally, it will delay everyone 2 minute , Let's briefly talk about what we do , What we do is chat robot , I won't tell you the specific process , First, young master Xiaobai . We are 2018 year 8 In January, a new product called amber was launched , It is a holographic projection intelligent chat speaker ,2019 year 5 In May, I will work with full-time experts , Introduce a version of Ye Xiu's Amber robot , We expect users to interact directly with Ye Xiu through robots , Then look at some of its actions .2019 year 12 month , At the end of this year , We'll launch a male star , This male star should be before our domestic traffic 10 A male star of , A little fresh meat male star , I also hope you will pay attention to our products .

 Chat robot landing and advanced actual combat | Millions of people learn AI

Our AI research institute was established in Shanghai , Experts also include Mr. Zhang Min 、 Dr. Wang haofen , Our members come from well-known universities , With Su Da 、 East China Normal University has also established joint laboratories , Also launched a product called “ Virtual life engine ”(GAVE) The engine of .

 Chat robot landing and advanced actual combat | Millions of people learn AI

This is my last page , Let's talk to you again , Our entire virtual life engine includes several levels : We actually do a lot of things in the data layer , Including knowledge maps , Including basic data analysis and operation platform ; In the middle layer, we will do some research based on cognitive intelligence 、 Perceptual intelligence , Like sound 、 Images 、 Face recognition 、 Emotion recognition , It also includes things like reasoning 、 lenovo 、 memory 、 Such cognitive intelligence as emotion ; At the service level, we will have a chat 、 Smart home 、 Multimodal Q & A and so on ; Finally, we can also provide access points for open platforms , Let's access some of our functions conveniently .

Thank you for your support , That's all for my course .


put questions to 1: A dialogue system includes so much content , Use an end-to-end system , It's better to do it step by step ? I feel that the engineering quantity is very large .

Shao Hao : It depends on your purpose , If you're doing research , That must be end-to-end , If you write a paper, it must be end-to-end , There is no doubt about it . It is better to use in Engineering , Therefore, the principle of engineering is to use the simplest method to get the effect as far as possible ; If it doesn't , Let's think of other ways .

Just now I said there are two levels , If you want to study engineering , Just use these rules to do it yourself ; If you want to do thesis research , You'd better focus on papers and end-to-end systems .

put questions to 2: teacher , Is the knowledge map important in the dialogue system ? Do you use it much now ?

Shao Hao : important , But it's not used much now , Why? ? What you're talking about is the knowledge map in the dialogue system . Knowledge map is still very important in question and answer system , We still make extensive use of knowledge map in the Q & A based on knowledge map , But in other functional modules , I just talked about , Like chatting , Such as task dialogue , The knowledge map is not used much . Moreover, the engineering community does not use the knowledge map very much .

put questions to 3:DM in slot If you hit Keyword, There is no return date and time , The corresponding question will be returned to the user , Please add the date and time , Is this question also set manually ?

Shao Hao : The problem was set before we went to do the task , For example, I will give it several slots in the weather , One is called “ Time ”, One is called “ date ”. I'll give it a few slots to book tickets : Place of departure 、 Destination 、 Departure time 、 flight 、 The airport . So you can actually set the task manually , A simple answer to this question , It's set manually .

put questions to 4: If the goal is to store knowledge from a non relational database 、 extract 、 Reasoning , Excuse me, this storage is stored in SQL still noSQL better ?

Shao Hao : image JENA、MongoDB、Dom4J, In the project, we should choose different implementation methods of the database according to the specific scenario ,. Tell the truth , Now? MySQL It's really easy to use in some scenes , also MongoDB and ES, Sometimes this kind of database is really much more efficient than graph database . Therefore, it should be determined according to what functions should be realized in the specific project scenario .

put questions to 5: The application effect of the current algorithm is not as good as that of regular or template , So how to choose ?

Shao Hao : It's a fusion approach , We also have a lot of... In our own chat robot system , But we will design some multi-layer strategies . For example, we will make some strategies in intention recognition , We will have some rules in front of the intention , If the rule can cover the accuracy of the problem, it's best , If you can't cover it , When we use deep learning method to classify intention, we also use fusion method (Stacking), After integration, we will comprehensively judge whether to select the model with the highest score and finally clarify the intention .

And when we do this, we usually return top3 perhaps top5, At the same time, if we find that this intention cannot be carried out in the later module , We have one more “ Rejection ” modular , Even if we get through, we'll put it “ Rejection ” fall , This should be selected according to the effect of the product .

put questions to 6: Does intention recognition rely on manual editing of all intention rules for judgment ? Is there any other way ?

Shao Hao : The example I just gave is to use rules for intention recognition , But there's one behind me PPT It's also about , Intention recognition is actually a fusion method , So you can have the rules first , Then use some deep learning methods later , What I just said fastText You can also do this intention classification , But we need a lot of data for supervised learning .

put questions to 7: How to automatically test the effect of chat robot ?

Shao Hao : This depends on the evaluation criteria . We will have our own internal evaluation standards , This evaluation standard contains hundreds of tests , For example, its sound recognition , Its sound recognition needs to be divided into several meters , For example, near-field sound recognition 、 Far field sound recognition , Then it the number of rounds in the conversation 、 Learning time 、 The naturalness of dialogue 、 The naturalness of speech , wait , Will be used as the test effect of chat robot . So now the engineering community does not have a very accurate 、 A rigorous way to test the effectiveness of chat robots . If you want to refer to it , There are many evaluations of this chat robot in academia , A lot of reviews , You can go and have a look , There is also a chapter in our book about the method of evaluation .

put questions to 8: What is the best way to classify after intention recognition ? Distribute directly from top to bottom to domain perhaps bot, Or the central control will distribute it first 、 Collect feedback after ?

Shao Hao : Every family bot They all do different things , What you said domain It's actually a two-level classification , We are a five level classification . Our approach will adopt a two-tier strategy , Let's make a rough classification first , And then there's a topK Result , And put this topK Distribute the results to K The sub modules are executed , Each sub module is equivalent to a competitive relationship , After they have implemented these questions , Give it to me DM A feedback . For example, I'm a music module , I gave it to me DM Feedback is that I think I do the best , I called myself 10 branch , Are you willing to accept my score . then DM The central control will decide what I collected , For example, I am in 500 Milliseconds after collecting feedback from all modules , Then decide which module to choose for the final return . So this piece is finally based on each family bot The system is different .

put questions to 9: If the Turing test can not reflect the progressiveness of the chat robot , So what kind of test is used to test the performance ?

Shao Hao : This is the same as the question I just said , Academia is a competition with more evaluation data , You can pay attention to these competitions , Let's take a look at what the theoretical community has done .

put questions to 10: In intention recognition, if you encounter a query There are multiple intentions , How to deal with it is better ?

Shao Hao : We actually have topK, Will judge by its final score .

put questions to 11:NLU Can you do pretreatment ?

Shao Hao : It will be , I'm sure I will , And they are all separate modules , For example, modal particles 、 Standardization , They are all done by separate modules .

put questions to 12: How to do word sense disambiguation ?

Shao Hao : There are different ways of word sense disambiguation , There are rules based , And based on heat . For example, based on heat , For example, we are talking about “737” when , It may refer to 737-800, May also refer to 737max, At this time, we may depend on the popularity of social media , To judge the hottest news recently is 737max The plane crash , At this time, we can use heat for disambiguation . There are many ways to disambiguate , We can use context 、 degree of heat 、 Contribution words , This can be used .

put questions to 13: Dialogue in the vertical field , Use the knowledge map , Whether the performance will be improved ?

Shao Hao : There must be , Because we have also done many vertical projects similar to the government 、 The vertical project of Medical , The use of knowledge map will greatly improve its Q & A effect , This is sure to happen .

put questions to 14: The link of robot processing is very long , How to balance the response speed and the quality of the link module ?

Shao Hao : That's a good question , Because we now have a very serious problem in the chat robot called “ Error delivery ”, If you have many serial modules , Its errors will pass down very badly . We should balance according to the specific situation , For example, we will set up a “ Overtime ”, When some modules are processed in parallel , We will choose the one with no timeout and the best effect .

put questions to 15: How to measure the quality of emotion ?

Shao Hao : We have a three-tier system , Probably 27 Two criteria , This may also be judged according to the specific situation , There is no way to give a standard indicator .

put questions to 16: What are the indicators to determine the advantages of gossip answers ?

Shao Hao : One of the most direct indicators is to see if users are willing to talk to you , Xiaobing actually puts forward many indicators , For example, the number of rounds of conversation between users and you is taken as an indicator .

put questions to 17: How to realize multi round intention classification ?

Shao Hao : I was just PPT It should be made clear in ,“ And tomorrow ” It didn't go into the normal intention , Its normal intention score will be very low , It's lower than our domain value , So we either throw it away , Or refuse , Or judge whether it is multi round , If it goes into multiple rounds , We will use the multi round state machine to do the Q & A behind it .

put questions to 18: A matching method for retrieving the answers to questions and answers about whether amber is useful , Or just use the matching method between the problem and the problem ?

Shao Hao : That's a good question , We use both . Because what? ? Because of our log There are a lot of data , This may involve our lower level things , I won't say much more . We can use both methods , And the way from question to answer , Sometimes the question is matched after the answer is generated in other ways , This method is very effective , I suggest you try .

copyright notice
author[Zhang Zhiqiang],Please bring the original link to reprint, thank you.

Random recommended