Menu

Advanced Prompting Techniques

Introduction

Once you master the basics, you can use advanced techniques to tackle complex reasoning tasks and dramatically reduce hallucinations.

Few-Shot Prompting

Instead of just asking the model to do something (zero-shot), you provide a few examples of the input-output pairs you expect. This "trains" the model in-context.

Extract the names of cities from the text.
Text: I visited Paris last summer.
Cities: Paris

Text: She moved from Tokyo to New York.
Cities: Tokyo, New York

Text: We are flying to Berlin tomorrow.
Cities:

Chain of Thought (CoT)

Adding a phrase like "Let's think step by step" forces the LLM to output its reasoning process before giving the final answer. This drastically improves performance on math and logic puzzles.

Assignment

  1. Read about Few-Shot Prompting and write a few-shot prompt that classifies the sentiment of customer reviews.
  2. Read about Chain of Thought (CoT) prompting and test a complex logic puzzle with and without it.

Support me!

I am a software engineer giving back to the community - my name is Musila Peter. Join me in empowering learners around the globe by supporting SaneGenius!