Editing Messages to Refine LLM Responses

Introduction: Editing Messages to Refine LLM Responses

Welcome to this lesson on editing messages in LLM conversations. In previous lessons, you learned how LLMs generate text, how different model versions work, and how context windows shape responses. You also saw how guiding the model step by step can improve reasoning.

Now, let's focus on a practical technique: editing previous messages to refine the model's context and improve results. This skill is handy when the model's response isn't quite what you wanted or when you want to guide the conversation in a more specific direction. By the end of this lesson, you'll know how to recognize when an edit is needed and how to make changes that help the LLM give better answers.

How LLMs Use Conversation History

As a quick reminder, LLMs do not just look at your latest message — they process the entire conversation history every time you submit a new message. This means that any changes you make to earlier messages or responses will affect how the model interprets the conversation and what it generates next.

For example, if you ask a question and then edit your question or the model's answer, the LLM will use the updated version as its context for future replies. This is a powerful way to steer the conversation and get more relevant or better-formatted answers.

Defining the Desired Answer Format

Let's consider an example. Imagine you are a teacher wanting to brainstorm a list of teaching strategies. Consider the following prompt:

text
Provide me with a list of strategies for engaging middle school students. Include overview.

By specifying that you want a "list" and an "overview," you set clear expectations for the LLM's response format. However, the prompt is still somewhat general, so the LLM may include a variety of strategy types and additional details. Let's consider a sample output of an LLM:

Certainly! Engaging middle school students requires strategies that address their developmental needs and interests. Here's a list of effective teaching strategies for middle school students:

### Active Learning Strategies

1. **Project-Based Learning**
   - **Overview**: Project-based learning involves students working on complex projects that address real-world problems. It encourages critical thinking, collaboration, and creativity.
   - **Implementation**: Start with a driving question, provide structured milestones, and culminate with student presentations of their work.

2. **Cooperative Learning**
   - **Overview**: Cooperative learning involves students working together in small groups to maximize their own and each other's learning.
   - **Implementation**: Assign specific roles to group members, establish clear objectives, and provide opportunities for group reflection.

<omitted for brevity>

### Technology Integration Strategies

1. **Digital Storytelling**
   - **Overview**: Digital storytelling combines narrative with digital content to create engaging multimedia presentations.
   - **Implementation**: Have students create digital stories using tools like PowerPoint, Google Slides, or specialized apps.

<omitted for brevity>

### Assessment Strategies

<omitted for brevity>

A part of the output is omitted for clarity. Notice that the output includes multiple types of strategies and implementation details, which may go beyond what you wanted if you were only interested in "active learning strategies" and a simpler format. This is not an error by the LLM, but rather a result of the prompt's generality.

One approach is to introduce a set of specific instructions. You can try to define all the details about the output format in your prompt. It could be very time-consuming. Let's take a look at a more efficient approach.

Sign up

Join the 1M+ learners on CodeSignal

Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal