# Using Large Language Models for Goal-Oriented Dialogue Systems
## 3 Materials and Methods
Using a locally deployed LLM, we compared two methods for constructing a dialogue scenario graph: tuning a large language model to an iterative dialogue manager with context preservation based on the prompt technique without training on labeled dialogues and tuning a large language model to an iterative dialogue manager with context preservation based on the prompt technique with additional training on labeled dialogues in the MultiWOZ 2.2 and MANtIS datasets. The quality assessment of the large language models was performed based on the following:  
* BERTScore [51]--an automatic evaluation metric of text generation by large language models, which calculates the similarity of tokens using contextual embeddings for each token in the generated text and the original marked-up dialogue sentence;
* Rouge [52]--a metric used to evaluate automatic summarization and machine translation;
* Bleu [53]--a metric for assessing the accuracy between machine translation and reference user translations of a single source sentence;
* Meteor [54]--a metric for assessing the quality of machine translation, which is based on the use of n-grams and is focused on the use of statistical and accurate assessment of the source text. Generation of a Scenario Graph for a Goal-Oriented Dialogue System with Preservation of the Dialogue Context Based on an LLM with Additional Training on Labeled Dialogues  
The general algorithm was as follows:  
1. Prepare training and test sets. In the training set, sentences from the MultiWOZ 2.2 dialogue corpus were grouped by three parameters (the step number, the intent of the previous message, and the intent of the current message). Each triple reflected the transition from one state to another, which allowed for a more accurate modeling of the interaction between participants during a dialogue. Figure 1: (**a**) Prompt for intent mining in Russian/English. (**b**) Prompt for named entity recognition in Russian/English. 2. Construct the graph. At this stage, nodes were created from pairs of [step number; cluster]. The vertices contained the user's message or intent that would be extracted when moving to this vertex. Edges were built on the basis of information triples: for each triple, information was formed about the incoming node [step number; current cluster], the outgoing node [step number-1; previous cluster], and the edge connecting them [step number; current cluster]. It was important to ensure that the graph did not use duplicate edges with the same pairs from one outgoing node. However, using the same edges to the incoming node was acceptable. This ensured that the graph would have unambiguous transition scenarios. 3. During the dialogue, the user's intent was selected, and a step was made along the edge with the selected intent. 4. Having reached a certain vertex, the utterance assigned to this vertex was extracted. The proposed heuristic-based approach is summarized in Algorithm 1. ```
Graph Construction Input: Training set Output: Graph Procedure BuildDialogueGraph(\(D\)) // Corpus preparation For each dialogue in \(D\): Add start and end markers to the dialogue // Step numbering For each dialogue in \(D\): For each message in the dialogue: Assign a step number to the message // Vectorization and clustering For each message in \(D\): Convert the message into a vector Cluster vectors based on feature similarity and step number // Extracting information triplets For each cluster \(C_{i}\): For each next cluster \(C_{j}\): If (\(C_{i}\) step number + 1 = \(C_{j}\) step number) AND (any messages in \(C_{i}\) and \(C_{j}\) belong to the same dialogue): Create an information triplet (\(C_{i}\), \(C_{j}\), \(C_{i}\) step number) // Building the graph For each triplet: Create vertices and edges in the graph based on the triplet Return the constructed graph \(G\) End procedure
```  
**Algorithm 1** Pseudo-code of heuristic-based approach  
We implemented three different variations of the dialogue graph with different approaches:  
1.