Get Started with Prompts

Your Practical Guide to Crafting One-Shot Prompts

Coschool
The Prompt Lab
4 min readAug 9, 2024

--

Prompt engineering is the process of crafting effective and efficient prompts. “One-shot prompting” is a technique in natural language processing where a single, concise example is provided to guide a model’s response.

There are generally three types of prompts.

1. Zero-Shot Prompting: Providing a prompt to the AI without any prior examples to guide its response.

2. One-Shot Prompting: Giving the AI a single example along with the prompt to illustrate the desired response.

3. Multiple-Shot Prompting: Supplying several examples to the AI with the prompt to better guide the response generation.

Now, we will explore one-shot prompting as one-shot prompting is often considered better than zero-shot and multiple-shot prompting because it strikes a balance between minimal input and effective guidance.

What is One-Shot Prompting?

One-shot prompting is a technique where a model is given a single example of a task to perform before being asked to generate a response or complete a similar task. The idea is that by providing just one example, the AI can understand the pattern or format required, and then apply that understanding to new, similar instances.

How to Structure an Effective One-Shot Prompt

One-shot prompts and zero-shot prompts typically have similar structures. We will explore how to use one-shot prompts in a classroom setting. For instance, we can consider the task of generating test questions for students as an example.

Provide Context:

Depending on the intended output, it is imperative to provide the context. In our example of creating questions, the definition and meaning of questions should be provided. It can include information such as ‘What is a Single Choice Question’, ‘What are the parts of a Single Choice Question?’, ‘What is the structure of a Single Choice Question?’, ‘Where will the questions be used?’, etc.

After providing the context, the objective of the output should be defined. For our case, it is advisable to explain how and why these questions will be used. For example, ‘The questions will be used in a classroom’, ‘The questions are used to assess the students’ understanding of the concept’, etc.

In our example of single-choice questions, each part of the question needs to be explained, i.e., the question, the options, and the correct answer. E.g., the question should assess the understanding of only one concept, there should be four options, and only one correct answer for each question, etc.

Give a Persona to the AI:

Assigning a persona to the AI has always been the best method, as it takes into account the target audience for the generated output. In our example, a teacher with a lot of classroom experience is the best person to create these questions with the right tone. So, asking the AI to “Act as a teacher with 10 years of experience in teaching that specific subject” can be an efficient method.

Assign a Task to the AI:

Assigning a specific task to the AI increases the probability and accuracy of task completion. It is important to provide complete details such as grade, subject, and topic to get specific outputs. For example, telling the AI, “Your task is to generate 10 questions for Grade 8 Physics on the topic of Friction”, provides a clear task.

Provide Rule Sets:

These rule sets help to control the outputs from the AI, and reinforce the task requirements. Rule sets can include statements to address common issues that the AI might encounter, or rules to refine the output. A few examples of such rules can be: no questions should be similar to each other; use British English in the output, etc. These rules can be specific to subjects, use cases, or general guidelines.

Provide an Example:

For better output, provide a sample. In our example of creating questions for a test, providing a sample Single Choice Question can ensure that the format and quality are followed by the AI in the output.

For example, for a Single Choice Question:

Question: Which of the following methods can be used to increase friction?

Options:

  1. Using rough surfaces
  2. Applying lubricants
  3. Using ball bearings
  4. Using air cushions

Correct Answer: Using rough surfaces

Prompt Engineering is a skill that everyone can learn to make their lives easier and better, regardless of their domain. At its core, accessing the best of AI is all about mastering prompt engineering — a skill that directly influences the quality and accuracy of AI-generated outputs. The more clear and precise the prompts, the more useful and accurate the results. One-shot prompting is a useful technique to achieve the best possible output and is an important aspect of Prompt Engineering.

“The true power of AI is revealed when we master the subtle craft of asking the right questions.” — ChatGPT

Co-authored by Sankhya and Jyothi, Prompt Analysts at Coschool. To learn more, visit www.coschool.ai

--

--

Coschool
The Prompt Lab

World's first comprehensive, AI-enabled learning platform for schools