Basic Prompting Techniques

Andrew Ellis

22 February, 2024

What is a prompt?

  • Remember: the goal of an LLM is complete text.
  • A prompt is a piece of text (instruction) that is given to a language model to complete.

PROMPT : Write a haiku about a workshop on large language models.

ASSISTANT : Whispers of circuits,
Knowledge blooms in bytes and bits,
Model learns and fits.

  • The response is generated as continuation of the prompt.

Unlocking knowledge

  • LLMs learn to do things they were not explicitly trained to do.
  • Often, these capabilities need to be “unlocked” by the right prompt.
  • What is the right prompt?
  • The answer is very similar to what you would tell a human dialogue partner.
  • You can increase the probability of getting the desired output by asking good questions.

Basics of prompting

Basics of prompting

OpenAI give a set of strategies for using their models

These include:

  • writing clear instructions
  • providing reference texts
  • splitting tasks into subtasks
  • giving GPT ‘time to think’
  • using external tools

Writing clear instructions

Adopt a persona (role)

: You are an expert on learning techniques. Explain the concept of ‘flipped classroom’ in one paragraph.

: You are an expert financial derivatives. Explain the concept of ‘flipped classroom’ in one paragraph.

Provide reference texts

  • Provide a model with trusted and relevant information.
  • Then instruct the model to use the provided information to compose its answer.

Provide reference texts

: You will be provided with a document delimited by triple quotes and a question. Your task is to provide a simplified answer to the question using only the provided document and to cite the passage(s) of the document used to answer the question. If the document does not contain the information needed to answer this question then simply write: “Insufficient information.” If an answer to the question is provided, it must be annotated with a citation. Use the following format for to cite relevant passages ({“citation”: …}).

## Document

’‘’The flipped classroom intentionally shifts instruction to a learner-centered model, in which students are often initially introduced to new topics outside of school, freeing up classroom time for the exploration of topics in greater depth, creating meaningful learning opportunities. With a flipped classroom, ’content delivery’ may take a variety of forms, often featuring video lessons prepared by the teacher or third parties, although online collaborative discussions, digital research, and text readings may alternatively be used. The ideal length for a video lesson is widely cited as eight to twelve minutes.’’’

## Question

What is flipped classroom?

Giving GPT ‘time to think’

  • LLMs generate text one word at a time–the model spends the same amount of computation on each word.
  • Giving the model more context gives it more steps to “think”.
  • This increases the chances that the model will give a good answer.
  • This technique is known as chain-of-thought prompting, and can often be induced by simply instructing the model to think step-by-step or Take a deep breath and work on this problem step-by-step (Yang et al. 2023).

Chain-of-thought prompting

  • Chain-of-thought prompting encourages the LLM to “explain” its intermediate reasoning steps.
  • Enables complex reasoning and problem solving.

Instead of this:

: The odd numbers in this group add up to an even number: 4, 8, 9, 15, 12, 2, 1.

Do this:

: The odd numbers in this group add up to an even number: 4, 8, 9, 15, 12, 2, 1.
The odd numbers are 9, 15, 1.
The sum of the odd numbers is 9 + 15 + 1 = 25.
25 is an odd number.
Therefore, the statement is false.

Zero-shot chain-of-thought prompting

: The odd numbers in this group add up to an even number: 4, 8, 9, 15, 12, 2, 1. Take a deep breath and think step-by-step.

Explore prompting techniques

Now open the first activity to learn more about ChatGPT and OpenAI Playground:

👉 Activity 1.

References

Broschinski, Sebastian, Titus Plattner, Patrick Meier, and Patrick Vögeli. 2023. “In 9 Grafiken erklärt – So funktioniert künstliche Intelligenz.” Der Bund. June 10, 2023. https://www.derbund.ch/so-funktioniert-kuenstliche-intelligenz-599276436215.
Yang, Chengrun, Xuezhi Wang, Yifeng Lu, Hanxiao Liu, Quoc V. Le, Denny Zhou, and Xinyun Chen. 2023. “Large Language Models as Optimizers.” September 6, 2023. http://arxiv.org/abs/2309.03409.