Learn To Use AI Prompt Mechanics For High-Quality Output
Learn To Use AI Prompt Mechanics For High-Quality Output
quality output
This will be a slightly different tutorial than most of the ones on our platform. Instead of walking
through a specific AI tool and workflow, we’ll be reviewing the mechanics and theory behind various
prompting techniques.
Zero-shot
Few-shot
Chain-of-thought
Context-aware
Retrieval augmented generation (RAG)
⠀
Chances are, if you’ve worked with LLMs or used a prompt-based tool, you’ve used many, if not all, of
these prompting techniques. We’ll be using ChatGPT in our example prompts if you want to follow
along.
The list of techniques in this tutorial is non-exhaustive; instead, we tried to gather the most popular
techniques when working with an AI chatbot at the interface level (not at the development level). The
goal of this tutorial is to guide you on when it might be helpful to use a certain prompting technique
to improve your prompt-based workflows.
Zero-shot prompting is the most basic type of prompt. It involves requesting something from an LLM
without providing any examples or context.
Essentially, when doing a zero-shot prompt, you’re relying on the training data of the LLM. In earlier
LLM models (i.e. GPT-2), you’d get much worse results with this method vs. today’s leading models
(i.e. GPT-4o). So from our point of view, while zero-shot prompting is the simplest method, it’s often
all you need for generalized LLM tasks.
⠀
** Zero-shot prompting is best for certain applications: **
Language translation
Text summarization
Basic question answering
⠀
** Example zero-shot prompt: **
2. Few-shot prompting
Few-shot prompting involves giving the model only a few examples (or shots) of the desired input-
output behavior within the prompt.
As you can tell from the name, this is more complex than zero-shot prompting. We’re providing not
only context and a query to the model, but also a list of examples to help guide the model on our
thinking.
1. Set up the task: You start by clearly defining the task you want the model to perform. For
** **
instance, if you want the model to label specific data, you set up the context for that task.
2. Provide examples: Within the prompt, you include a small number of examples that show how
** **
the input should be mapped to the output. This could be a one-shot (one example) or a few-shot
(a few examples).
3. Ask the model: After providing the examples, you then present a new instance(s) for the model
** **
to process. The model uses the pattern demonstrated by the examples to generate the
appropriate output.
⠀
** Few-shot prompting is best for certain applications: **
Sentiment analysis
Data extraction
Data labelling
⠀
** Example few-shot prompt: **
FlopFlop:
3. Chain-of-thought prompting
1. Define the task: Clearly describe the task or question in the prompt.
** **
2. Guide the model: Encourage the model to explicitly reason through the problem by generating a
** **
answer.
⠀
** Chain-of-thought is best for certain applications: **
⠀
** Example chain-of-thought prompt: **
Generate a business proposal by following the provided steps.Step 1: Understand the client's
needs. Research the client's business and gather information about their needs, challenges, and
goals.Step 2: Define the solution. Clearly outline the products or services you are offering and
explain how they will address the client's needs.Step 3: Develop a structure. Create a clear
structure for your proposal, including an introduction, background information, proposed
solution, timeline, pricing, and terms and conditions.Step 4: Write the introduction. Introduce
your company and provide an overview of the proposal's purpose.Step 5: Present the
background information. Provide context about the client's business and the problem you are
addressing.Step 6: Detail the proposed solution. Explain your proposed solution in detail,
including the benefits and how it will be implemented.Step 7: Create a timeline. Outline the key
milestones and deliverables, along with the projected timeline for completion.Step 8: Provide
pricing information. Include a detailed breakdown of costs, any payment terms, and any
additional fees.Step 9: Outline the terms and conditions. Specify the terms and conditions,
including any legal or contractual obligations.Step 10: Review and edit. Carefully review the
proposal for accuracy, clarity, and professionalism. Edit as necessary.
Step 11: Submit the proposal. Provide the completed proposal and be available for any follow-up
questions.
4. Context-aware prompting
Context-aware prompting is a technique where the model is provided with detailed context or
background information within the prompt to help it generate more accurate and relevant responses.
This approach leverages the model's ability to understand and utilize context to improve the quality of
its outputs.
1. Define the task: Clearly describe the task or question you want the model to perform or answer.
** **
2. Provide detailed context: Include relevant background information or context that can help the
** **
⠀
** Context-aware prompts are best for certain applications: **
Content generation
Context-specific problem-solving
Scenario planning
⠀
** Example context-aware prompt: **
Context: In a small medieval village nestled at the foot of a mountain, the villagers live in fear of
a dragon that resides in a nearby cave. Every year, they must offer a tribute to the dragon to
prevent it from attacking the village. The story follows a young hero who decides to confront the
dragon and end its reign of terror.
The RAG approach involves retrieving relevant information from a knowledge base or external
documents and using this information to generate more informed and accurate responses.
Oftentimes, when working with an AI chatbot, this will look like providing it with external documents
or pointing it to an external database of information.
1. Input query: You provide a query or prompt with a link to or uploaded external knowledge
** **
source.
2. Retrieval step: The model searches the knowledge base, database, or document corpus to find
** **
relevant pieces of information related to the query.
3. Augmentation: The retrieved information is combined with the original query to create an
** **
enhanced prompt.
4. Generation step: The enhanced prompt is fed into a generative model, which produces a
** **
⠀
** RAG is best for certain applications: **
Domain-specific question-answering
Document summarization
Content-specific generation
⠀
** Example RAG prompt: **