Design text prompts

This page gives you an overview of and general guidance for designing text prompts.


To follow step-by-step guidance for this task directly in the Google Cloud console, click Guide me:

Guide me


Supported models

  • Gemini 1.5 Flash
  • Gemini 1.5 Pro
  • Gemini 1.0 Pro

Common task types

You can create text prompts for handling any number of tasks. Some of the most common tasks are classification, summarization, and extraction. You can learn more about designing text prompts for these common tasks in the following pages:

Classification prompts

Classification tasks assign a class or category to text. You can specify a list of categories to choose from or let the model choose from its own categories. This page shows you how to create prompts that classify text.

Classification use cases

The following are common use cases for text classification:

  • Fraud detection: Classify whether transactions in financial data are fraudulent or not.
  • Spam filtering: Identify whether an email is spam or not.
  • Sentiment analysis: Classify the sentiment conveyed in text as positive or negative. For example, you can classify movie reviews or email as positive or negative.
  • Content moderation: Identify and flag content that might be harmful, such as offensive language or phishing.

Best practices for classification prompts

Try setting the temperature to zero and top-K to one. Classification tasks are typically deterministic, so these settings often produce the best results.

Summarization prompts

Summarization tasks extract the most important information from text. You can provide information in the prompt to help the model create a summary, or ask the model to create a summary on its own. This page shows you how to design prompts to create different kinds of summaries.

Summarization use cases

The following are common use cases for summarization:

  • Summarize text: Summarize text content such as the following:
    • News articles.
    • Research papers.
    • Legal documents.
    • Financial documents.
    • Technical documents.
    • Customer feedback.
  • Content generation: Generate content for an article, blog, or product description.

Best practices

Use the following guidelines to create optimal text summaries:

  • Specify any characteristics that you want the summary to have.
  • For more creative summaries, specify higher temperature, top-K, and top-P values. For more information, learn about the temperature, topK, and topP parameters in Text parameter definitions.
  • When you write your prompt, focus on the purpose of the summary and what you want to get out of it.

Extraction prompts

Extraction prompts let you extract specific pieces of information from text.

Use cases

The following are common use cases for extraction:

  • Named entity recognition (NER): Extract named entities from text, including people, places, organizations, and dates.
  • Relation extraction: Extract the relationships between entities in text, such as family relationships between people.
  • Event extraction: Extract events from text, such as project milestones and product launches.
  • Question answering: Extract information from text to answer a question.

Best practices

Try setting the temperature to zero and top-K to one. Extraction tasks are typically deterministic, so these settings often produce the best results. For more information, learn about the temperature and topK parameters in Text parameter definitions.

What's next