## 7 Dialogue Management and Large Language Models
### Integration of LLMs into Conversation  
Below, we describe, in detail, the four approaches used in the incorporation of Barista with human-written dialogues. The resulting dialogue design resulted in a much more flexible system with respect to traditional rule-based systems while still preserving system designers with a significant amount of control over the system's outputs. The methodologies leverage machine learning algorithms in combination with human-like interaction patterns to improve the system's ability to sustain versatile and dynamic dialogues. The approaches used are detailed below. 1. **Handling of out-of-domain (OOD) inputs:** By leveraging OOD detection techniques, the system determines whether the user input falls outside the scope of the current intents that can handle the continuation of the conversation. If an OOD input is identified, control over the conversation's flow transfers to the LLM, which generates a response to the unexpected input and the Dialogue Selector selects the next dialogue tree to execute. We proposed generating more than one response, i.e., we generated responses for a predetermined number of turns through the LLM loop (see Figure 11(a)). This approach enables SocialBot to handle unforeseen user inputs globally. Moreover, the LLM loop deepens the conversation toward an out-of-domain topic. 2. **Handling of Proactive Questions:** Proactive questions, i.e., questions asked by the user, represent a unique challenge. Dialogue trees tend to ignore proactive questions by default because they are primarily designed to recognize user answers and proceed accordingly without considering additional questions directed toward the SocialBot. For instance, when a bot asks, \"What is your favorite ice cream flavor?\" and the user responds, \"Vanilla. What's yours?\", the intent recognition component recognizes the intent \"Vanilla', for which the system may only provide information about the popularity of vanilla, disregarding the user's reciprocal question. The out-of-domain intent, which is possibly helpful in this situation, is not triggered because there is some amount of semantic similarity between the user input and recognized intent. In contrast, LLMs can effectively address this issue, displaying greater flexibility in handling such questions. By utilizing a punctuator for properly punctuating user inputs and subsequently identifying question marks, the system can redirect the conversational flow to the LLM loop (see Figure 11(a)). The LLM loop responds appropriately to the user's proactive question while delving deeper into the relevant topic for the predetermined number of dialogue turns. This approach allows SocialBot to respond to proactive questions, making it more coherent. 3. **Hybrid Dialogues:** This approach enriches the dialogue system by merging the advantages of both human-designed dialogue trees and LLM-generated responses. Hybrid dialogues start with an engaging question, fun fact, or comment authored by a dialogue designer to spark user interest and set the context for the conversation. When the user responds to this initial question, the LLM loop is triggered for a predetermined number of turns. The LLM can then provide contextually appropriate responses to user inputs, dynamically adapting the conversation to the user's interests and preferences (see Figure 11(b)). This approach allows for the rapid development of engaging conversations, combining the strengths of structured dialogue trees and the flexible responses generated by large language models. 4. **Inserting LLMs into Dialogue Trees:** To improve the responsiveness and depth of interactions within existing dialogue trees, we pinpointed several intents followed by non-informative acknowledgments, such as \"I see\", \"Got it\", or \"I understand\", typically handling user responses to open-ended questions seeking opinions.