# A Conversation History-Based Q&A Cache Mechanism for Multi-Layered Chatbot Services
## 5 Experiments
### Comparison Experiment and Results
#### 5.3.2 Response Time  
Response time in this study is the round-trip time from the user terminal to the system and back to the user. Round Trip Time (RTT) is the length of time it takes for a data packet to be sent to a destination plus the time it takes for an acknowledgment of that packet to be received back at the origin. The aim of this study was to use the cache mechanism to decrease the RTT from \"user \(\rightarrow\) broker \(\rightarrow\) chatbot \(\rightarrow\) broker \(\rightarrow\) user\" to \"user \(\rightarrow\) broker (cache) \(\rightarrow\) user\" (Figure 9). Figure 9 shows the RTT of a system without a cache mechanism. The RTT in this case is calculated by (6):  
\[RTT_{chatbot}=(t_{2}-t_{1})+(t_{4}-t_{3})+(t_{6}-t_{5})+(t_{8}-t_{7}) \tag{6}\]  
In the case of a system with a cache mechanism, RTT is calculated by the following equation:  
\[RTT_{cache}=(t_{8}-t_{7})+(t_{4}-t_{3}). \tag{7}\]  
Figure 10 shows the difference between response times for a question in the cache and the question from the chatbot itself. These results show that the main goal of this study was achieved, which was to shorten the response time of chatbot services by caching Q&A sets. The environment for the calculation of response times consisted of three different terminals. The first was the terminal of the user, who was sending questions to the broker. The broker \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline  & \multirow{2}{*}{**Sequence**} & \multicolumn{6}{c}{**Cache Size**} \\ \cline{3-6}  & & **10** & **15** & **20** & **25** & **30** \\ \hline \multirow{2}{*}{Case 1 (50)} & Random & 21 & 30 & 40 & 50 & 60 \\  & Related & 82 & 87 & 88 & 91 & 93 \\ \hline \multirow{2}{*}{Case 2 (100)} & Random & 11 & 16 & 22 & 27 & 32 \\  & Related & 80 & 82 & 83 & 85 & 86 \\ \hline \multirow{2}{*}{Case 3 (150)} & Random & 7 & 11 & 7 & 17 & 20 \\  & Related & 77 & 78 & 82 & 81 & 82 \\ \hline \multirow{2}{*}{Case 4 (200)} & Random & 9 & 14 & 19 & 25 & 29 \\  & Related & 74 & 75 & 76 & 78 & 79 \\ \hline \multirow{2}{*}{Total} & Random & 12 & 17.75 & 22 & 50 & 35.25 \\  & Related & 78.25 & 80.5 & 76.75 & 79 & 81 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Average hit ratio of all cases in random and related-question sequence. Figure 9: Response time of the system process. terminal was responsible for caching Q&A sets and answering the user's question from the cache or through the chatbot. The final terminal was the chatbot terminal, which answered the user's questions that were not cached. Two questions were asked 500 times each. One question was already cached, and another question was not cached yet. In the case of a cached question, the user's question was sent to the broker, and the answer was shown to the user immediately from the cache. However, in the case of a question that was not cached, the system sent the user's question to the broker, and the broker sent it to the chatbot, where it was matched with Q&A pairs in the chatbot database, and the answer was returned to the user from the chatbot through the broker. In Figure 10, the blue line shows response times of the system with answers from the chatbot (\(RTT_{chatbot}\)). The red line shows response times of the system with answers from the cache (\(RTT_{cache}\)). The difference in response time is 2-3 times, as the average response times for questions that are not cached is \(RTT_{chatbot}=2.9\ ms\), whereas the average response time for cached questions is \(RTT_{cache}=0.9\ ms\). The experimental results showed what we expected to see. The experiment showed that the Q&A set number and cache size are consistent. As the Q&A set number increases, the hit ratio decreases. An increase in cache size produced an increase in the average hit ratio. As people ask questions based on the context of the conversation, the results using related sequences show the proposed cache mechanism is an effective one to use in the system. The presented cache mechanism can lighten system processes and reduce the response time of the chatbot system.