Notebooks
G
Google Gemini
Few Shot Prompting

Few Shot Prompting

promptinggemini-cookbookgemini-apiexamplesgemini
Copyright 2025 Google LLC.
[ ]

Gemini API: Few-shot prompting

Some prompts may need a bit more information or require a specific output schema for the LLM to understand and accomplish the requested task. In such cases, providing example questions with answers to the model may greatly increase the quality of the response.

[ ]
[10]

Configure your API key

To run the following cell, your API key must be stored it in a Colab Secret named GOOGLE_API_KEY. If you don't already have an API key, or you're not sure how to create a Colab Secret, see Authentication for an example.

[ ]

Examples

Use Gemini Flash as your model to run through the following examples.

[5]
MODEL_ID
[ ]
Whale > Monkey > Goldfish

[ ]
{"Austin": "USA", "Lisbon": "Portugal"}

Next steps

Be sure to explore other examples of prompting in the repository. Try writing prompts about classifying your own data, or try some of the other prompting techniques such as zero-shot prompting.