⬆️ ⬇️

Anticipation in developing a dialogue with a chat bot





How applied work differs from paper theorizing is how problems arise. Constantly faced with new difficulties, which in turn provide food for the mind.



In the process of working on a chat bot, I was faced with the need to anticipate (that is, anticipate) the development of dialogue. Previously, I somehow did not think about it, but here, when deciding which words to put into computer mouths in response to a particular human phrase, I had to think about it.

')

The conclusions seemed interesting to me. They lie on the surface of the problematic and may not be a revelation for those who have been engaged in AI before, but I have not seen any direct formulations in print. Therefore, let's start ...



Dialogue of the person and chatbot: the person says something, the chatbot has to answer reasonably . It seems that the main difficulty of programming is in the unpredictability of what will be uttered by a person now, because a person can literally say anything. And if anything, then finding a reasonable answer is difficult: the list of answers to unpredictable questions should be infinite, but infinity is technically impracticable. Consequently, the chat bot must “understand” what the interlocutor told him - further along the gauge run by the developers of the AI, far beyond the bounds of the announced topic ...



The humor of the situation is that there is no only need but also a special need for a chat bot to “understand”, “comprehend” the phrase of the interlocutor, because ... the people themselves do not communicate like that. If you think that people analyze what they have heard with the help of the thinking apparatus - the brain, then, based on the analysis, they voice the answer, then the communication does not quite happen, it happens differently.



Have you ever thought about why you are pleased to talk with friends? Is it because, in response, you hear from your friends mostly pleasant, not only in the “complimentary” sense, but also in the “interesting”, “fascinating” sense, etc.? Exactly for the same reason, it is unpleasant for you to talk with enemies, because the information coming from them has an opposite sign or vector for you. In other words, you know in advance what information you will get from someone, and act in accordance with circumstances : joyfully go on contact with friends, avoid encounters with enemies if possible.



Here is the question: why do you need to contact with friends, if you know in advance what they will say? No, I understand and share: have a good time, relax ... but the desire to get new information here is clearly in last place. Information - in the sense of new information for themselves - people receive mostly from other sources, and when communicating with friends they catch a buzz from something else, namely from the predictability of the conversation, just like when communicating with enemies, long before communication, they experience negative emotions, thanks to all the same predictability of what will happen.



Most conversations are predictable, and this can only mean one thing: people know in advance the course of the future conversation with one or another interlocutor.



In reality, communication between people is a little different from what is assumed by default:





In reality, communication between people is as follows:





This is anticipation, and its laws apply not only to conversations with people whose attitude is determined (positive or negative), but also to any conversations in principle.



Suppose you meet a friend and say to him: "Hi."



This phrase is subject to the situation: in accordance with certain rules, the origin of which in this case does not matter, it is used at the beginning of the dialogue. It makes no sense to wait for the answer, which is probably known, you can begin to construct the next phrase. Hearing a greeting greeting, you let the prepared phrase into the course immediately, without additional deliberation.



However, in response, you can hear something else, for example: "Yes, you go ...". Previously scheduled conversation turned the other way, the script has changed dramatically. Well, it happens. In this case, your brain produces a standard answer like: “You go!”, Just a moment later than a phrase that would have been heard if the planned scenario was unchanged. A moment is, strictly speaking, not a time for reflection, but a time for accessing a library of situational blanks. What a reflection there, when everything is done “on the machine”, almost at an unconscious level!



It is possible to imagine that the interlocutor “misses the move”: he does not greet, but in a friendly way says the following phrase, which is usual for your past communication. The habitual means the intended. You (or rather, your brain) have no reason to wait for an answer, which is already known, but it makes sense to prepare phrases for the subsequent dialogue. Then the likelihood is high that the subsequent phrase after the missed "hello" will not catch surprise: the stored preparation will go to your mouth without the slightest delay. If desired, the absence of a reciprocal greeting can be counted not as a “missed move”, but as a new offshoot of the scenario, but this does not change the overall picture.





The third option makes you decide on the depth of anticipation. If we are not able to anticipate the phrase that the non-greeted interlocutor utters, we will have to analyze it after uttering. Thereby, it is ideal to anticipate not only the subsequent phrase, but the whole dialogue as a whole - but this is from the area of ​​good wishes. People are incapable of this: during the dialogue they are forced to constantly jump from individual libraries to situational blanks.



So, any replica involves a set of subsequent responses, and a very limited set . In the case of greetings, this is due to the ritual of politeness, in general - the limit of human reactions to an event: joy, sorrow, admiration, contempt, etc. Several dozens of sensations, you can’t think of others - people simply don’t feel anything else. Reactions allow to anticipate a dialogue, having at hand blanks for any possible phrase of the interlocutor.



Thus, the dialogue is not at all the endless possibilities to say something arbitrary and answer something arbitrary, but narrow paths that you can walk along. They are like tracks on an autodrome: it is allowed to turn only where it is provided for by the designer of the track - human psychology. On the roads do not go: the main fence is set, you know.



Like cars on a circuit, conversations also move in a circle. Friends get a buzz from the greasy topic, girlfriends gossip among themselves no less enthusiastically. If a dispute arises between hostile people, the arguments of the opposite side are passed between the ears. In the latter case, they say: "He does not hear me." Ears can hear, probably, but only your reaction is not provided for in the outgoing interlocutor, because the interlocutor responds with a standard blank, which does not suit you already. Movement in a circle is a hopeless situation.





Typical graphs. Any phrase can be spoken, the choice of a particular answer is always there: accordingly, each node must have at least one input edge and several outgoing edges-continuations.



Ideally, a chat bot needs a reserve of several graphs — plans for conversations: individual for each interlocutor with whom he spoke, and common for strangers. It is obvious that, for example, in a man who communicates with his beloved woman and with a useless subordinate, everything will be different: the subject, vocabulary, intonation, emotional color, loudness, etc., but first of all - the direction of thought.



It should be understood that anticipation is not a panacea, but one of many techniques, and not the most essential in the development of AI, is more important. In addition, the technique is extremely difficult to implement.



If the interlocutor has greeted in some unusual way, the chat bot can “not guess” about the greeting, and accordingly respond in a different way (the variability of human speech is the problem of the problems, damn it). But the greeting is the simplest case: anticipating subsequent remarks is much more complicated.



Further, when generating your own phrase, the chat bot may schedule an erroneous response of the interlocutor, which will lead to discrepancies with the expected response.



Finally, in some cases, for purely algorithmic reasons, it is more profitable to wait for the interlocutor's phrase, then analyze it. If a chat bot is used to order tickets, it is obvious that there is neither a sense nor a possibility to foresee, a ticket for which date and what route the buyer asks for - you need to wait for the information. At the same time, in the free dialogue characteristic of AI, anticipation is necessary: ​​it can save a great deal of processing time, at least due to the possibility of anticipating during the process of deliberation or pronouncing your phrase by the interlocutor.



In connection with the anticipation and the library of situational blanks a curious case is recalled. An acquaintance came to my wife. After a while, she mentioned her husband, who always forgets to turn off the light: she began to tell with enthusiasm how he chewed him, and so on. "Well, of course! Of course! You are absolutely right, dear! ”- I heard the compassionate remarks of my wife. The joke was that in my family exactly the opposite. The wife basically does not turn off the light: a minute after her arrival home, the light is on everywhere — in the rooms, the hallway, in the kitchen, in the toilet and in the bathroom. Passing by, I automatically turn it off, and my wife turns on no less automatically, and nothing can be done about it. But the conversation with a friend was just that. The wife used individual blanks that were appropriate for the meeting, but at the same time nothing interfered with communication. The women, as they say, sang in unison - were completely unanimous and happy.



P.S
This article was written as part of a series on the development of a syntax chatbot by Vanya Reasonable.



Previous articles:



  1. Creation of AI by the method of "coarse kuzdra" Intellectual odyssey ;
  2. Chat bot gains hearing, or suffering amateur .


If someone wants to meet Vanya in his current state, release 2.0 is here: bitbucket.org/mikejum/intellectualivan/downloads



Compared with the previous version, Vanya spoke and became less buggy - one could say that he had become wiser, although not as much as he would have liked. As my six-year-old nephew said after talking to the chat bot, “Your Vanya is a fool like Siri”.



In connection with the transition from Access to PostgreSQL, there were problems with the installation: now unzip the file is not enough, you have to install PostgreSQL and deploy the dump, instructions are attached.



To the inevitable question, and how far is the anticipation implemented in version 2.0, I will answer so. It is implemented partially, at the initial level, but it is problematic to notice it during the dialogue. As mentioned earlier, anticipation is one of the many features required when developing AI, which is far from the most essential.

Source: https://habr.com/ru/post/442332/



All Articles