# A Conversation History-Based Q&A Cache Mechanism for Multi-Layered Chatbot Services
## 4 Cache Mechanism
### Cache Mechanism Architecture
#### 4.1.3 Frequency and Relevance Management Module  
As mentioned above, the keywords extracted by the keyword extraction module are used to create the Q&A graph based on the mutual relevancies of all Q&A pairs. The usage of keywords helps to calculate the relevance of the Q&A pairs. In this study, Q&A pairs with the same keywords are considered relevant to each other. Figure 3 shows an example of the Q&A relevance. \begin{table}
\begin{tabular}{c c c c} \hline
**Keyword** & **Keyword** & **Keyword** & **Keyword** \\ \hline computer & program & system & object \\ Java & software & data & network \\ language & Windows & internet & HTML \\ AIML & category & methods & source \\ robot & pattern & Linux & tags \\ \hline \end{tabular}
\end{table} 
Table 1: Example of top keywords. The meaning of this graph is as follows:  
The keyword of \(Q_{1}A_{1}C_{1}\) is \"computer,\" and this Q&A pair has relevance to questions from the related questions list \(RelQ_{8}=\{Q_{2}A_{2}C_{1}\), \(Q_{3}A_{3}C_{1}\), \(Q_{5}A_{5}C_{3}\}\). The \(Q_{2}A_{2}C_{1}\) pair has keywords \"computer,\" \"program,\" and \"software,\" and the relevant Q&A pairs are \(RelQ_{8}=\{Q_{1}A_{1}C_{1}\), \(Q_{2}A_{3}C_{1}\), \(Q_{4}A_{4}C_{2}\), \(Q_{5}A_{5}C_{3}\}\). In the case of \(Q_{3}A_{3}C_{1}\), the keywords are \"computer\" and \"internet,\" and \(RelQ_{8}=\{Q_{1}A_{1}C_{1}\), \(Q_{2}A_{2}C_{1}\), \(Q_{5}A_{5}C_{3}\}\). The \(Q_{4}A_{4}C_{2}\) pair's keywords are \"debugger,\" \"software,\" and \"program,\" and \(RelQ_{8}=\{Q_{2}A_{2}C_{1}\), \(Q_{5}A_{5}C_{3}\}\). The \(Q_{5}A_{5}C_{3}\) pair's keywords are \"software,\" \"computer,\" and \"program,\" and \(RelQ_{8}=\{Q_{1}A_{1}C_{1}\), \(Q_{2}A_{2}C_{1}\), \(Q_{3}A_{3}C_{1}\), \(Q_{4}A_{4}C_{2}\}\). The concept of relevance proposed in this paper depends on the number of similar keywords between Q&A pairs. In the case of [25], the policy of a cache mechanism depends on the document semantics. The algorithm of this paper caches semantically closed documents to the current page and removes the least frequently used documents. The proposed cache in this paper uses similar keywords in Q&A pairs to create relevance. This method might have limitations, but it is one of the easiest ways to make the cache work. Figure 4 shows the representation of the relevance graph. This graph has the id of Q&A (\(Q_{1}A_{1}\), \(Q_{2}A_{2}\), \(Q_{3}A_{3}\), \(Q_{4}A_{4}\), \(Q_{5}A_{5}\)) and the chatbot id (\(C_{1}\), \(C_{2}\), \(C_{3}\)) that sent this information to the cache. Figure 3: Example of relevancies among Q&A pairs. The frequency in this mechanism depends on the conversation history of the chatbot. Here the frequency calculation works based on the previous and present questions. In other words, the frequency of a question is the number of times each question in the Q&A dataset is followed immediately by this question. This concept is different from the context view of NLP; in fact, handling the context of the NLP view is beyond the scope of this paper. Nevertheless, the method used in this paper, that is, the method based on the occurrences of previous questions in the conversation history, is considered to be engineeringly suitable for the cache mechanism. The frequency of Q&A pairs is computed using conversation history. Table 2 presents an example of a Q&A set frequency graph showing how many times each question was called after other questions from the Q&A dataset. For example, after \(Q_{1}\), \([Q_{3}]\) was asked five times, \([Q_{4}]\) was asked three times, \([Q_{2}]\) only once, and \(Q_{1}\) never (as it is itself). Another example is \(Q_{5}\), where \([Q_{2}]\) was asked eight times after \(Q_{5}\), \([Q_{1}]\) three times, \([Q_{4}]\) two times, and \([Q_{3}]\) was never asked. This table is updated every time a new question is asked.