transcribe

Simulating & Evaluating Multi turn Conversations

LangChain · 6m · transcribed Jul 2026
More from LangChain Business
𝕏 Share ▶ YouTube 📥 PDF 🤖 .md

Section Insights

# 0:00

Evaluating Chat-Based Applications

How can we evaluate chat-based applications over multiple turns?

Evaluating chat-based applications requires assessing their performance over multi-turn dialogues rather than single responses. This can be achieved through simulations with another AI acting as a user, allowing for the measurement of metrics like goal completion and helpfulness.

  • Multi-turn dialogue evaluation is essential for understanding application performance.
  • Simulations can provide insights into how applications handle follow-up questions and clarifications.
  • Open evals offer utilities to simulate full conversations for comprehensive evaluation.
# 1:19

Setting Up the Evaluation Framework

What are the key components needed to evaluate a chat application?

To evaluate a chat application, you need to define the application function, create a simulated user with specific personas, and establish evaluation criteria to measure success across conversation turns.

  • The application function must accept messages and return responses.
  • Simulated users can be customized to test various scenarios.
  • Evaluation criteria are crucial for measuring user satisfaction and issue resolution.
# 2:39

Running the Simulation

How do you run a multi-turn simulation for a chat application?

To run a multi-turn simulation, you create a client, set up a thread, and define the application logic. You then simulate a user with a specific persona and evaluate the interaction based on predefined criteria.

  • Setting up a client and thread is the first step in running simulations.
  • User personas can significantly impact the evaluation outcomes.
  • Multiple evaluators can assess different aspects of the conversation.
# 3:59

Evaluating Simulation Results

What results can be expected from the evaluation of a chat simulation?

The evaluation results can indicate whether the chat application achieved user satisfaction, resolved the user's issue, and maintained professionalism throughout the conversation.

  • Successful simulations can pass multiple evaluators for satisfaction, resolution, and tone.
  • Professionalism is key in customer support interactions.
  • Evaluators help quantify the effectiveness of the chat application.
# 5:19

Implementing Stopping Conditions

How can stopping conditions enhance the evaluation of chat applications?

Stopping conditions can be implemented to determine when a conversation should end, based on user confirmation of issue resolution. This allows for more realistic simulations and can trigger before reaching the maximum number of conversation turns.

  • Stopping conditions can improve the realism of chat simulations.
  • They help ensure conversations end naturally when issues are resolved.
  • Flexible parameters allow for tailored evaluation scenarios.

Transcript

0:00 Most LM applications today are chat based. The user can send back and forth messages to interact with it. But how would you evaluate this over a conversation? Sure, you can evaluate based on its response over a single term, but that doesn't capture the nuance needed in a multi-turn dialogue where users can ask follow-up questions, change their minds, or need clarification across turns. One way to evaluate is to create a simulation with another AI where one model plays a role of the user sending messages to your application and you observe how the conversation unfolds over multiple turns to test for metrics such as goal completion and helpfulness. Hi, this is Katherine from Lang. Today we're excited to launch open evals, a set of utilities to simulate full conversations and evaluate your application performance across multiple turns. To do this, there are a few key components in open emails. First, you need the chatbased application that you want to test and second, a simulated user. This represents the human on the other side of the chat. You can define specific personas or conversation flows to test how your application reacts in different situations. Third, you can define a set evaluation criteria. This is where you define the success over the conversation turns, whether the agent was able to resolve the user's inquiry within a set number of turns, if it followed a set of predefined procedures, and the overall sentiment of the user. Now, let's see what that looks like step by step.

1:32 First, we want to define an application function. The application can be any application that accepts messages and thread ID and returns a chat message as response. It works seamlessly with any LM framework, whether you're building with Langroth or something completely custom. Second, you want to create a simulated user. You can give it a system prompt to set up user persona. There are also additional parameters that you can customize. You can define prefix trajectories or create your own simulated users. Third, you'll define evaluators.

2:06 In this step, you can create trajectory evaluators. One example is LM as a judge where you grade user satisfaction based on the conversation. And finally putting this together, you can run multi-turn simulations by passing in the application user trajectory evaluators and defining a stopping condition. In this case, we have defined the max number of turns to be five. Now let's hop over to the notebook where we will see some of this in action. Here we'll be evaluating interactions with a customer support agent that has already been deployed. First in terms of setup, we get the client, create a new thread and create relevant assistant ID for the agent. We then create the application logic for the agent. We feed all the inputs into our deployed app. We string the output and we return the final message from our application.

3:01 The next step is creating a simulated user. Here we give it a persona by feeding it with a system prompt, telling it to be a frustrated user who wants a refund for the most recent purchase. From here, we'll create three evaluators that we'll then use to evaluate the simulation. The first centers around user satisfaction. The second is around issue resolution and third is around the tone of the conversation where we likely want our customer support agent to remain their professionalism throughout. Putting this all together to run the simulation.

3:35 We're feeding it with the application the user that we have created the trajectory evaluators. We set the maximum number of conversation turns to be five and feed it with the thread ID that we have created earlier. This has finished running and we can inspect the list of exchanges between our agent and our user. So first we can see that our agent asks for a follow-up question on a customer identifier where the human then provides information around its customer ID and our agent finally responds that it has proceeded with a refund request and our agent provided additional information on the refund status as well as this sales support agent who handled the request.

4:15 Taking a look at the evaluator results, we can see that all three tests have been passed where we achieved user satisfaction towards the end successfully result for their refund request and our agent has been able to remain professional throughout the conversation. Now, I want to showcase additional parameters you can pass in to customize the run multi-turn simulation function. Specifically, we'll be adding a stopping condition parameter in this example. The stopping condition parameter takes in a callable function that outputs a boolean. So here we first create a data schema called condition that we're using to define the format for the output where we want it to be true if the stoping condition was met and false otherwise. Next we create a stoping condition function called has satisfied that takes in a trajectory and returns in the data schema that we have defined above. Here we first create a structured LLM that outputs in a condition format.

5:15 Then we give it a system prompt asking it to determine if the stopping condition was met where the user needs to confirm that there are no additional issues that the customer support agent can help with. We also pass in the conversation from the trajectory. We format the prompt here using it to invoke our structured LLM and return the boolean that our structured LM returns. From here we rerun the multi-turn simulation by putting this all together passing the same parameters with the addition of the stopping function which is the function that we have defined above. It will call the function at the end of every turn to decide if the conversation should be ended. Looks like our simulation has finished running and inspecting the number of turns. It seems like the stopping condition was triggered before the max number of conversation turns limit was hit. And similarly all three value results across satisfaction, resolution and professionalism returned true. Now with open evals you can simulate a full conversation between your application and a user and then evaluate how well your agent performs across the entire interaction. It works seamlessly with any LM framework whether you're building with Lingraph or something completely custom giving you a flexible framework agnostic way to test and improve your agents. Thank you for watching.

Summary

Open evals is a new tool designed to evaluate chat-based language model applications through simulated multi-turn conversations. By creating a virtual user and defining specific evaluation criteria, developers can assess how well their applications handle complex dialogues, ensuring metrics like goal completion and user satisfaction are met.

- Current language model applications primarily use chat interfaces for user interaction.
- Evaluating performance in multi-turn dialogues requires more than single-response assessments.
- Open evals allows developers to simulate full conversations with predefined user personas and conversation flows.
- Key components include the chat application, simulated user, and evaluation criteria focused on user satisfaction and issue resolution.
- Developers can customize simulations with parameters like stopping conditions to determine when a conversation should end.
- The tool is compatible with various language model frameworks, providing flexibility for developers.
- Successful simulations can help improve agent performance by identifying strengths and weaknesses in customer interactions.

Questions Answered

How can we evaluate chat-based applications over multiple turns?

Evaluating chat-based applications requires assessing their performance over multi-turn dialogues rather than single responses. This can be achieved through simulations with another AI acting as a user, allowing for the measurement of metrics like goal completion and helpfulness.

What are the key components needed to evaluate a chat application?

To evaluate a chat application, you need to define the application function, create a simulated user with specific personas, and establish evaluation criteria to measure success across conversation turns.

How do you run a multi-turn simulation for a chat application?

To run a multi-turn simulation, you create a client, set up a thread, and define the application logic. You then simulate a user with a specific persona and evaluate the interaction based on predefined criteria.

What results can be expected from the evaluation of a chat simulation?

The evaluation results can indicate whether the chat application achieved user satisfaction, resolved the user's issue, and maintained professionalism throughout the conversation.

How can stopping conditions enhance the evaluation of chat applications?

Stopping conditions can be implemented to determine when a conversation should end, based on user confirmation of issue resolution. This allows for more realistic simulations and can trigger before reaching the maximum number of conversation turns.

© transcribe · For agents Built with care and craft by Gokul Rajaram