3. Advanced use
3.4. Few-Shot Prompting

Few-Shot Prompting in Quartzite

You might have noticed that in Quartzite you can modify the Assistant (model) answers by clicking on it. This is a feature that enables you to create powerful completions, leveraging the "Few-Shot Prompting" technique in Prompt Engineering.

In short, "Few-Shot Prompting" is a technique whereby you create a few pairs of question+answer as an example to show the Model how to correctly reply, therefore creating more precise responses.

This technique involves providing the model with a small number of examples (the "shots") to guide it in understanding the task at hand and generating appropriate responses or outputs. The examples serve as a prompt that helps the model grasp the context or the specific format of the response expected. Few-Shot Prompting is part of a broader set of techniques that also includes zero-shot and one-shot prompting, differing in the number of examples provided.

Let's see one of the many applications of Few-Shot Prompting:

Content Generation with "Few-Shot Prompting"

If you're using a model to generate creative stories, you might feed it a few examples of story prompts followed by short stories. This helps the model understand the desired output format and thematic elements.

Prompt 1: "A lost kitten in a big city finds its way home."
Story 1: "In the bustling city of New York, a small kitten named Whiskers finds itself..."
--
Prompt 2: "A detective solves a mystery with an unexpected twist."
Story 2: "Detective Harris had seen it all, but the case of the missing emerald necklace..."
--
New Prompt: "An astronaut discovers an ancient alien artifact on Mars."

Expected Output: A short story following the new prompt, inspired by the format and style of the examples.

How to leverage Few-Shot Prompting in Quartzite

Compared to the example in the previous section, where you would add the prompt and the response in a single message (and tell the model what is what), you can create a whole fake conversation between the user and the assistant, therefore making it "believe" the previous replies were generated by the model. This allows you for better output response when applied to the Few-Shot Prompting.

Quartzite gives you two ways of creating predefined conversations:

  1. Edit an existing Assistant message, adjusting the response or completely replacing it.
  2. Switching a message's author, by clicking on the type (the "User" or "Assistant" label).

How to switch the message type