Skip to main content

Section 2.4 The Anatomy of a Prompt and Writing Loops

In the context of large language models (LLMs)β€”artificial intelligence systems designed to understand and generate human-like textβ€”prompting refers to the method of providing an LLM with a specific input or cue to generate a desired output or perform a task. Prompting is crucial because it directly influences how effectively these models understand and respond to user queries. A well-crafted prompt can guide an LLM to generate more accurate, relevant, and contextually appropriate responses.
A prompt can be constructed using a prompt template, which is a segment of text containing placeholders or variables that are filled with specific information depending on the context. Consider a template with a single placeholder:

Basic Prompt Template Example.

If {premise}, what are your suggestions for a fun weekend?
The variable {premise} is specified by the user to set the context for the model’s recommendations. For instance, if the input is β€œthe weather is nice this weekend,” the final prompt becomes: β€œIf the weather is nice this weekend, what are your suggestions for a fun weekend?”
When a problem is difficult to describe purely through specific variables, it is common to provide the LLM with a detailed instruction set or context. One effective strategy is to assign a persona or role to the model.

Persona-Based Prompt Template.

You are a computer scientist with extensive knowledge in the field of deep learning. Please explain the following computer-related concept to a child around 10 years old, using simple examples whenever possible: {concept}

Subsection 2.4.1 In-Context Learning

An essential concept in prompt engineering is in-context learning. When prompting an LLM, users can include new information outside the model’s static training dataβ€”such as step-by-step demonstrationsβ€”allowing the LLM to learn how to perform a task within that specific conversation.
For example, an LLM can be provided with a few demonstrations of how to perform text classification:

In-Context Demonstration Example.

Here are some examples of text classification.
Example 1: We had a delightful dinner together. \(\rightarrow\) Label: Positive.
Example 2: I’m frustrated with the delays. \(\rightarrow\) Label: Negative.
What is the label for β€œThat comment was quite hurtful.”?
Label:
In-context learning is typically characterized by the number of examples provided prior to the target query:
Zero-shot learning does not involve providing any concrete examples of solved tasks. Instead, it directly prompts the LLM to address a problem using its baseline training.

Zero-Shot Grammar Prompt.

You are a helpful assistant, and are great at grammar correction. You will be provided with a sentence in English. The task is to output the correct sentence.
Input: She don’t like going to the park.
Output:
One-shot learning expands on this approach by supplying a single demonstration of the desired task, allowing the model to learn from the provided example:

One-Shot Grammar Prompt.

You are a helpful assistant, and are great at grammar correction. You will be provided with a sentence in English. The task is to output the correct sentence.
Input: There is many reasons to celebrate.
Output: There are many reasons to celebrate.
Input: She don’t like going to the park.
Output:
Few-shot learning provides multiple demonstrations to establish a clear pattern mapping inputs to outputs, which the model follows to generate its prediction:

Few-Shot Grammar Prompt.

You are a helpful assistant, and are great at grammar correction. You will be provided with a sentence in English. The task is to output the correct sentence.
Input: There is many reasons to celebrate.
Output: There are many reasons to celebrate.
Input: Me and my friend goes to the gym every day.
Output: My friend and I go to the gym every day.
Input: She don’t like going to the park.
Output:

Subsection 2.4.2 Strategies for Effective Prompts

Writing effective prompts involves strategic structure and clarity. Key techniques include:
  • Clarity and Precision: Providing a precise, specific description of the task ensures the model remains aligned with expectations.
  • Step-by-Step Reasoning: Instructing LLMs to reason through a problem step-by-step improves performance on complex logic tasks.
  • Context Files: Standing documents you give an AI to define how it should work across many tasks, such as your role, preferences, style rules, and background. The AI reads them at the start so you do not have to repeat instructions each time.
  • Reference Context: Supplying authoritative source text and instructing the model to rely exclusively on that reference helps prevent ungrounded predictions.
  • Formatting Sensitivity: Modifying structural layout or punctuation can significantly impact the model’s output consistency.
To bypass manual trial-and-error, LLMs can be used to automate prompt creation through discrete prompt optimization. By instructing the LLM to act as a prompt engineer, the model can iteratively rewrite, expand, and refine instructions.

Automated Prompt Generation Template.

You are given a task to complete using LLMs. Please write a prompt to guide the LLMs. {task-description}
To improve reliability on complex operations, tasks can be divided into smaller components. In prompt chaining, the output of one prompt serves directly as the input for the next, building a sequence of specialized operations to accomplish a multi-step task.

Subsection 2.4.3 Human-AI Writing Loops

In practice, combining structured prompt design with interactive workflows creates an effective human-AI writing loop. This process demonstrates how an LLM functions as an active collaborator rather than a single-use tool:
  1. Preparation & Brainstorming: Begin by gathering research and developing an outline. Prompt the AI to brainstorm alternative approaches aligned with that outline.
  2. Drafting: Combine primary knowledge with selected AI ideas to author an initial draft.
  3. Critique & Verification: Ask the AI for detailed feedback and critique on the draft. Evaluate its suggestions critically, verifying all cited facts and claims manually.
  4. Revision & Polishing: Revise the content and use target prompts to refine sentence mechanics, punctuation, and style.
  5. Attribution & Voice Check: Ensure that the final text reflects your distinct voice, accurate reasoning, and includes proper attribution of AI involvement throughout the writing process.
Relying on iterative workflows allows writers to maintain control and precision, identify errors early, and ensure that final artifacts remain original and aligned with primary learning goals.
You have attempted of activities on this page.