Skip to main content

Zero-Shot Prompting

Rather than using a vanilla model with few-shot prompting, we recommend using a Luminous-*-control variant along with a "zero-shot"-prompt for most use-cases. This is because these models have been optimized for downstream task performance. When zero-shot prompting, we simply provide a natural language instruction to the model and expect it to respond accordingly. Let’s illustrate this using an example.

Provide a short description of AI: AI is a set of techniques that use machine learning to make computer programs learn from data.

This worked well! However, the model’s best continuation is not necessarily aligned with your desired continuation. In such cases, you may explore one of two things:

  • Prompt engineering: Improve your prompt by trying different instructions and formulations.
  • Few-shot prompting: Try providing examples of the task along with your instruction. This may work better with our vanilla models. Learn more.

Luminous-*-control Prompting

Our control models have been optimized to work well with zero-shot instructions. Therefore, they do not necessarily need a set of examples as in few-shot learning. Still, structuring the prompt can help achieve better model performance. Generally, a control model prompt should follow the following pattern:

YOUR INSTRUCTION AND ANY ADDITIONAL CONTEXT HERE

### Response: COMPLETION OF THE MODEL

For performance reasons, we recommend using a prompt that ends with ### Response:. This makes it easier for the model to "understand" that it is required to produce a completion now.

Translate "How are you?" to the language my colleague Hans Müller understands.

### Response: "Wie geht es dir?"

Advantages Over Few-Shot Prompting

One upside of our control models is their ability to follow instructions without the need to provide examples. Let's have a look at a specific examples to compare the zero- to few-shot prompting.

We want to predict the topic of a given text. For a vanilla model, that would look like this:

Identify the topic of each text.
###
Text: After initially making significant recovery gains, the most important indices turned into the red later in the day. The downward trend was particularly steep in the last few minutes of trading. 
Topic: Finance 
### 
Text: The wizard rose from his chair and gazed across the room. Finally, his blue eyes settled on a stocky man. In a surprisingly swift manner, the old wizard waved his wand and the man turned into a large frog. 
Topic: Fantasy 
### 
Text: Flowering plants grow fruits to spread their seeds. Edible fruits function symbiotically. Animals obtain nourishment from consuming the fruit and the animal's movement helps spread the seed. 
Topic: Biology

When using a control model, we can (but do not have to) omit the few-shot examples and provide only the instruction, along with some formatting requirements for easier parsing of the answer.

Identify the topic of the text.
 Reply like this: "The topic is: <topic>"

Flowering plants grow fruits to spread their seeds. Edible fruits function symbiotically. Animals obtain nourishment from consuming the fruit and the animal's movement helps spread the seed. 

### Response: The topic is: plants.
tip
  1. Can I still use few-shot examples when using Luminous-control models?

    Yes, you can still use few-shot examples. You can put them in both, the ### Instruction: and ### Input: patterns of the prompt.

  2. Where do I put the question, if I want to do Q&A with Luminous-control models?

    A question, too, can be put in either the ### Instruction: or ### Input: part. However, we generally recommend the following format:

{question}
If there's no answer in the text, respond "NO ANSWER IN TEXT".

{document_text}

### Response:
  1. To generate structured output, you can instruct the model to produce text in a certain format, like json. Notice how we prefixed the completion with the opening bracket of the dictionary we would like to generate. This helps the model in adhering to the desired structure.
I need a vegan recipe. I still have bell peppers in my fridge. Suggest a dish.
Output in the following json-Format:
{
"name": "name of the dish",
"ingredients": [list of ingredients],
"explanation": "which steps to take"
}

### Response: {