Anticipations when developing a dialogue with a chat bot



    How applied work differs from paper theorizing is the occurrence of problems. Constantly confronted 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. I didn’t think about it before, but then - deciding what words to put in computer lips 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 problem and may not be a revelation to those who have studied AI before, but I have not seen direct language in the press. So let's get started ... The

    dialogue between a person and a chatbot: a person says something, a chatbot must respond reasonably. It seems that the main difficulty in programming is the unpredictability of what will be spoken by a person, because a person can say literally anything. And if anything, it’s difficult to find a reasonable answer: the list of answers to unpredictable questions should be infinite, but infinity is technically impossible. Consequently, the chatbot should “understand” what the interlocutor told him - further on the track run by the AI ​​developers, far beyond the boundaries of the announced topic ...

    The humor of the situation is that to get from the chatbot “understanding”, “comprehending” the phrase of the interlocutor is not only an opportunity, but also a special necessity, for the reason that ... people themselves don’t communicate like that. If you think that people analyze what they hear with the help of the mental apparatus - the brain, then, based on the analysis, they voice the answer, then communication does not happen quite like that, it happens differently.

    Have you ever wondered why you enjoy talking with friends? Is it not because you hear from friends that is mostly pleasant, not only in the sense of “complementary”, but also in the sense of “interesting”, “fascinating”, etc.? Exactly for the same reason, it’s unpleasant for you to talk with enemies, because the information coming from them has the opposite sign or vector for you. In other words,you know in advance what information you will receive from whom, and act in accordance with the circumstances : joyfully make contact with friends, avoid meetings with enemies if possible.

    Here's the question: why do you need to contact your friends if you know in advance what they will say? No, I understand and share: have a good time, relax ... however, the desire to get new information here is clearly in last place. For the most part, people get information - in a sense, new information for themselves - from other sources, and when communicating with friends they get a buzz from something else, namely from the predictability of the conversation, just like when communicating with enemies, long before they communicate, they experience negative emotions, thanks to 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 a future conversation with a particular interlocutor.

    In reality, communication between people is a bit different than what is assumed by default:

    • the interlocutor says something
    • You analyze the phrase you hear and give an answer.

    In reality, communication between people occurs as follows:

    • you anticipate what the interlocutor will tell you, and prepare in advance the answer to the expected phrase ,
    • if the expectations were met, issue a blank,
    • otherwise, you also issue a blank, but not individual, for a given interlocutor, but situational, suitable for any interlocutors.

    This is anticipation, and its laws are applicable not only to conversations with people, the attitude to which is defined (positive or negative), but also to any conversations in principle.

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

    This phrase obeys the situation: in accordance with certain rules, the origin of which in this case is unimportant, 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 the return greeting, you start the prepared phrase immediately, without further deliberation.

    However, in response you can hear something else, for example: "Yes, you go ...". The previously planned conversation turned on a different path, the script changed dramatically. Well, it happens. In this case, your brain gives a standard answer such as: “You yourself go!”, - just a moment later than the phrase that would sound if the planned scenario remains unchanged. A moment is, strictly speaking, not time for reflection, but time for accessing a library of situational blanks. What kind of thinking is there when everything is done “on the machine”, practically on an unconscious level!

    One can imagine that the interlocutor “skips the move”: he doesn’t say hello, but says the following phrase in a friendly manner, familiar to your past communication. Habitual means implied. For you (more precisely, your brain) it makes no sense to wait for an answer that is already known, but it makes sense to prepare phrases for the subsequent dialogue. Then it is highly probable that the subsequent phrase after the missed “hello” will not be taken by surprise: the prepared workpiece will arrive at your mouth without the slightest delay. If desired, the absence of a return greeting can be considered not a “missed move”, but a new branch of the script, 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 interlocutor did not say, we will have to analyze it after pronouncing it. Thus, it is ideal to anticipate not only the following phrase, but the whole dialogue as a whole - but this is from the field of good wishes. People are incapable of such a thing: during the dialogue they are forced to constantly jump from individual procurement libraries to situational ones.

    So, any replica involves a set of subsequent answers, with a very limited set. In the case of greetings, this is due to the ritual of politeness, in the general case - the limit of human reactions to a particular event: joy, grief, admiration, contempt, etc. There are several dozen sensations, you can’t imagine others - people simply don’t feel anything else. Reactions make it possible to anticipate the dialogue, having at hand preparations for any possible phrase of the interlocutor.

    Thus, dialogue is not at all endless possibilities to say something arbitrary and answer something arbitrary, but narrow paths along which you can only move. They are like tracks at the racetrack: it is allowed to turn off only where it is provided by the designer of the track - human psychology. You can’t go off-road: the main fence has been installed, you know.

    Like cars on an autodrome, conversations also move in a circle. Friends get a kick from a troublesome 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." He hears with ears, probably, but your reaction to the conversation plan is not anticipated by the interlocutor, because the interlocutor answers with a standard blank that does not suit you anymore. Roundabout is a hopeless situation.


    Typical graphs. Any phrase can be pronounced, there is always a choice of one or another answer: accordingly, each node must have at least one input edge and several outgoing extension-extensions.

    Ideally, a chatbot needs a margin of several columns - conversation plans: individual for each interlocutor with whom he spoke, and common to strangers. It is obvious that, for example, a man communicating with a beloved woman and a non-good-humored subordinate will have different things: themes, vocabulary, intonations, emotional color, loudness and so on, but first of all - the direction of thought.

    It should be understood that anticipation is not a panacea, but one of many methods, moreover, when developing AI it is not the most significant, there are more important ones. In addition, the technique is extremely difficult to implement.

    If the interlocutor greeted somehow non-standardly, the chatbot may “not guess” about the greeting, and will react differently accordingly (the variability of human speech is the problem of the problems, damn it). But greeting is the simplest case: anticipating subsequent remarks is much more difficult.

    Further, when generating your own phrase, the chatbot can plan an erroneous reaction of the interlocutor, which will lead to discrepancies with the expected answer.

    Finally, in some cases, for purely algorithmic reasons, it is more profitable to wait for the interlocutor’s phrase, then to analyze it. If the chatbot is used to order tickets, it is obvious that there is no sense or opportunity to predict the ticket for which date and which route the buyer will ask for - you need to wait for the information. At the same time, anticipation is necessary in a typical AI-free dialogue: it can save a lot of processing time, at least due to the ability to anticipate while thinking or pronouncing one’s phrase.

    In connection with anticipation and a library of situational blanks, a curious case is recalled. A friend came to my wife and I. After some time, she mentioned her husband, who forever forgets to turn off the light: she began to enthusiastically tell how his czech tail is, and so on. "Well, of course! Of course! You are absolutely right, dear! ”- 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 rooms, a corridor, in the kitchen, in the toilet and in the bathroom. Passing by, I automatically turn it off, and my wife automatically turns it on no less, and there is nothing to be done about it. But the conversation with her friend was just that. The wife used the individual blanks befitting the meeting a little out of place, while nothing interfered with communication.

    P.S
    This article was written as part of a series on the development of a syntactic chat bot by me, Vanya the Sensible.

    Previous articles:

    1. Creation of AI using the glock cuzdra method. Intellectual Odyssey ;
    2. Chatbot gains hearing, or the suffering of an amateur .

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

    Compared to the previous version, Vanya started talking and became less buggy - you can say he got smarter, although not as much as I would like to. As my six-year-old tribe said after talking with the chat bot, “your Vanya is just as stupid as Siri.”

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

    To the inevitable question, how much anticipation is implemented in version 2.0, I will answer this way. Partially implemented, at the initial level, however, it is problematic to notice it during the dialogue. As mentioned earlier, anticipation is one of the many features required in the development of AI, far from the most significant.

    Also popular now: