Have you ever considered which factors affect the course of a conversation? At first there is the topic itself. But there is also the person that is involved, the surrounding environment and the current situation. Also which questions have already been answered and which answers have already been asked determines the further direction of the conversation.
It can therefore be said that the conversation depends on a complex context. This context consists of the following items:
- What's the topic? Are my questions and suggestions suitable?
- Who am I talking to? Is the person male or female? What is she or he interested in? Am I acquainted with the person?
- Which questions have already been answered in the conversation? Were the questions answered earlier, as we talked about another topic?
- Which answers have I already received?
- Which collected data is valid for the person in general and which apply only in the current conversation?
- What conclusions can I draw from all the answers and information?
Different contextual items
As you can see, there is a complex context that involves many different areas. Let's try to break them down into individual vertices and edges, which we can compose to a graph.
- Conversation: A user can start a new conversation
- User: The user himself is part of the conversation and thus part of the context
- Topic: A conversation always refers to a specific topic, which essentially consists of further questions and answers
- Question: These are the questions that may become relevant in the course of a topic
- Suggestion: A question has one or more answer options
- Conclusion: Different answer options and questions lead to conclusions
In the course of this blog series, other items will be added. But I will not go into detail now for the sake of clarity.
Items form a graph
Now let's combine these items in a graph. At first, we will look at the conversation flow consisting of questions, answers and conclusions. The topic leads to a specific question. This in turn has different answer options and leads directly to another question. Answer options can lead to questions or conclusions. And conclusions can lead to further conclusions or new questions.
In a single graph, the numerous connections would quickly appear confusing. That's why I'll show you the structure of the theme separately. A topic does not just lead to one or more initial questions. It also describes, through further connections, which items are part of it.
So every question, every possible answer and every conclusion belongs to a specific topic. They can also be part of other topics. So the question "How old are you" or the answer option "yes" would make sense in several topics.
As you can see in the following graphic, every conversation involves at least one user. The user's answers are not saved as a separate node. They are just links that are set to answer suggestions. Answers can come either directly from a user or from a conversation. So it's possible to distinguish between answers, that only apply in the respective conversation, and between answers, that apply globally to the user.
A knowledge graph arises
Now imagine, that you could have a network, in which many more items are involved, which are all connected in the way shown above. This network stores which question follows a specific answer, who has answered which questions, which items belong to which topic and is able to conclude complex context. You can also call this network a knowledge graph. This is a network of expert knowledge that is gradually enriched with input from users.
However, the really exciting task is yet to come: We bring the network to life and will walk through it using Graph Traversal. So we will be able to find the next meaningful response based on the complex context. In the course of this series you will find that this is not difficult at all.
Incidentally, the idea of depicting conversations or chatbot conversations in graphs is not new. During my research, I came across different approaches.
There's an interesting post by Mark Watson called have-you-had-the-talk-with-your-chatbot-about-graph-data-structures, the HiAli project of Abfrad and the conversation-kit from pdtyreus.