Editing Prompts to Refine LLM Responses

Introduction: Editing Prompts to Refine LLM Responses

Welcome to this lesson on editing prompts 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 a message you have already sent, so you can refine your prompt without starting over. 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 will affect how the model interprets the conversation and what it generates next.

Editing works differently from sending another message. When you send a follow-up, you add to the history: your original prompt, the disappointing answer, and your correction all stay in the context. When you edit an earlier message, you replace part of that history instead.

Once you save an edit, the model answers again from the revised version of your message, as though you had phrased it that way the first time. The exchange that followed your original wording is replaced rather than kept alongside it.

This distinction matters more than it might seem, and we will come back to it.

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:

text
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.

The prompt needs to be more specific. You could type a new prompt from scratch, or send a follow-up asking the model to trim its answer. But there is a tidier option: go back and edit the prompt you already sent.

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