banner
田野放空

田野放空

认真扮演一个擅长白日做梦的普通人

chatGPT prompt engineering

What is Prompt Engineering? Prompt engineering is the process of creating prompts or instructions that guide the output of language models like ChatGPT. It allows users to control the model's output and generate text that meets their specific needs. ChatGPT is an advanced language model capable of generating human-like text. It is built on the Transformer architecture, which can process large amounts of data and generate high-quality text. However, to get the best results from ChatGPT, it is important to understand how to prompt the model correctly. Prompts enable users to control the model's output and generate relevant, accurate, and high-quality text. When using ChatGPT, it is crucial to understand its capabilities and limitations. The model can generate human-like text, but without proper guidance, it may not always produce the desired output. This is where prompt engineering comes in; by providing clear and specific instructions, you can guide the model's output and ensure its relevance. The prompt formula is a specific format for prompts, typically consisting of three main elements:

  • Task: A clear and concise statement of what the prompt requires the model to generate.
  • Instructions: The instructions the model should follow when generating text.
  • Role: The role the model should assume when generating text.

Instruction Prompting Techniques#

Instruction prompting techniques are a way to guide ChatGPT's output by providing specific instructions to the model. This technique is useful for ensuring that the output is relevant and high-quality. To use instruction prompting techniques, you need to provide the model with a clear and concise task, along with specific instructions for the model to follow. For example, if you are generating customer service responses, you would provide a task such as "Generate a response to a customer inquiry" with instructions like "The response should be professional and provide accurate information." Prompt formula: "Generate [task] according to the following instructions: [instructions]”

Generate Customer Service Response:

  • Task: Generate a response to a customer inquiry
  • Instructions: The response should be professional and provide accurate information
  • Prompt formula: “Generate a professional and accurate response to a customer inquiry according to the following instructions: The response should be professional and provide accurate information.”

Generate Legal Document:

  • Task: Generate a legal document
  • Instructions: The document should comply with relevant laws and regulations
  • Prompt formula: “Generate a legal document that complies with relevant laws and regulations according to the following instructions: The document should comply with relevant laws and regulations.”

When using instruction prompting techniques, it is important to remember that the instructions should be clear and specific. This will help ensure that the output is relevant and high-quality. Instruction prompting techniques can be combined with the "role prompting" and "seed word prompting" techniques explained in the next chapter to enhance ChatGPT's output.

Role Prompting#

Role prompting techniques are a way to guide ChatGPT's output by assigning a specific role to the model. This technique is very useful for generating text targeted at specific contexts or audiences. To use role prompting techniques, you need to provide the model with a clear and specific role. For example, if you are generating customer service replies, you might provide a role such as "customer service representative." Prompt formula: “Generate [task] as [role]”

Generate Customer Service Reply:

  • Task: Generate a reply to a customer inquiry
  • Role: Customer service representative
  • Prompt formula: “Generate a reply to a customer inquiry as a customer service representative.”

Generate Legal Document:

  • Task: Generate a legal document
  • Role: Lawyer
  • Prompt formula: “Generate a legal document as a lawyer.”

Combining role prompting techniques with instruction prompting and seed word prompting can enhance ChatGPT's output. Here is an example of how to combine instruction prompting, role prompting, and seed word prompting techniques:

  • Task: Generate a product description for a new smartphone
  • Instructions: The description should be informative, persuasive, and highlight the unique features of the smartphone
  • Role: Marketing representative
  • Seed word: “Innovative”
  • Prompt formula: “As a marketing representative, generate an informative and persuasive product description that highlights the innovative features of the new smartphone. The smartphone has the following features [insert your features]”

In this example, instruction prompting is used to ensure that the product description is informative and persuasive. Role prompting ensures that the description is written from the perspective of a marketing representative. Seed word prompting ensures that the description focuses on the innovative features of the smartphone.

Standard Prompting#

Standard prompting is a simple method of guiding ChatGPT's output by providing a specific task for the model. For example, if you want to generate a summary of a news article, you might provide a task such as “Summarize this news article.” Prompt formula: “Generate a [task]”

Generate a summary of a news article:

  • Task: Summarize this news article
  • Prompt formula: “Generate a summary of this news article”

Generate a product review:

  • Task: Write a review for a new smartphone
  • Prompt formula: “Generate a review for this new smartphone”

An example of combining standard prompting, role prompting, and seed word prompting techniques:

Task: Write a product review for a new laptop

  • Instructions: The review should be objective, informative, and highlight the unique features of the laptop
  • Role: Technology expert
  • Seed word: “Powerful”
  • Prompt formula: “As a technology expert, generate an objective and informative product review that highlights the powerful features of the new laptop.”

In this example, standard prompting techniques are used to ensure that the model generates a product review. Role prompting ensures that the review is written from the perspective of a technology expert. Seed word prompting ensures that the review focuses on the powerful features of the laptop.

Zero, One, and Few-Shot Prompting#

Zero-shot, one-shot, and few-shot prompting are techniques used to generate text from ChatGPT with minimal or no examples. These techniques are very useful when data for a specific task is limited or when the task is new and undefined. When there are no available examples for the task, use zero-shot prompting techniques. The model provides a general task and generates text based on its understanding of the task. When there is only one example available for the task, use one-shot prompting techniques. The model provides the example and generates text based on its understanding of the example. When there are only a limited number of examples available for the task, use few-shot prompting techniques. The model provides examples and generates text based on its understanding of the examples. Prompt formula: “Generate text based on [number] examples”

Write a product description for a new product with no available examples:

  • Task: Write a product description for a new smartwatch
  • Prompt formula: “Generate a product description for this new smartwatch based on zero examples”

Use one example to generate a product comparison:

  • Task: Compare the new smartphone with the latest iPhone
  • Prompt formula: “Generate a product comparison for this new smartphone using one example (the latest iPhone)”

Use a few examples to generate a product review:

  • Task: Write a review for a new e-reader
  • Prompt formula: “Generate a review for this new e-reader using a few examples (3 other e-readers)”

These techniques can be used to generate text based on the model's understanding of the task or the examples provided.

"Let's Think About It" Prompt#

The "Let's think about it" prompt is a technique that encourages ChatGPT to generate reflective and thoughtful text. This technique is suitable for tasks such as writing essays, poetry, or creative writing. The formula for the "Let's think about it" prompt is very simple: it consists of "Let's think about it" followed by a topic or question.

Generate a reflective essay:

  • Task: Write a reflective essay on the theme of personal growth
  • Prompt formula: “Let's think about it: personal growth”

Generate a poem:

  • Task: Write a poem about the changing seasons
  • Prompt formula: “Let's think about it: the changing seasons”

This prompt invites a dialogue or discussion about a specific topic or idea. The speaker invites ChatGPT to engage in a discussion on the relevant topic. The model provides a prompt as a starting point for the dialogue or text generation. The model then uses its training data and algorithms to generate responses related to the prompt. This technique allows ChatGPT to generate contextually appropriate and coherent text based on the provided prompt. To use the "Let's think about it" prompt technique with ChatGPT, you can follow these steps:

  1. Identify the topic or idea you want to discuss.
  2. Formulate a prompt that clearly expresses the topic or idea to start the dialogue or text generation.
  3. Start the prompt with "Let's think about" or "Let's discuss" to indicate that you are initiating a dialogue or discussion.
  4. Here are some examples of prompts using this technique:

Prompt: “Let's think about the impact of climate change on agriculture”

Prompt: “Let's discuss the current state of artificial intelligence”

Prompt: “Let's talk about the pros and cons of remote work”

You can also add open-ended questions, statements, or a paragraph of text that you want the model to continue or expand upon. After providing the prompt, the model will use its training data and algorithms to generate responses related to the prompt and continue the dialogue coherently. This unique prompt helps ChatGPT provide answers from different perspectives and angles, resulting in more dynamic and informative paragraphs. The steps for using the prompt are straightforward and can truly enhance your writing. Give it a try and see how it works.

Self-Consistency Prompt#

Self-consistency prompting is a technique used to ensure that ChatGPT's output is consistent with the provided input. This technique is very useful for tasks such as fact-checking, data validation, or consistency checks in text generation. The formula for self-consistency prompting is to follow the input text with the instruction “Please ensure that the following text is self-consistent”. Alternatively, you can prompt the model to generate text that is consistent with the provided input.

Task: Generate a product review (text generation)

  • Instructions: The review should be consistent with the product information provided in the input
  • Prompt formula: “Generate a product review that is consistent with the following product information [insert product information]”

Task: Summarize a news article (text summarization)

  • Instructions: The summary should be consistent with the information provided in the article
  • Prompt formula: “Summarize the following news article in a way that is consistent with the information provided [insert news article]”

Task: Complete a sentence (text completion)

  • Instructions: The completion should be consistent with the context provided in the input
  • Prompt formula: “Complete the following sentence in a way that is consistent with the context provided [insert sentence]”

Task: Check the consistency of a given news article (fact-checking)

  • Input text: “The article states that the city's population is 5 million, but later says the city's population is 7 million.”
  • Prompt formula: “Please ensure that the following text is self-consistent: The article states that the city's population is 5 million, but later says the city's population is 7 million.”

Task: Check the consistency of a given dataset (data validation)

  • Input text: “The data shows that the average temperature in July is 30 degrees, but the lowest recorded temperature is 20 degrees.”
  • Prompt formula: “Please ensure that the following text is self-consistent: The data shows that the average temperature in July is 30 degrees, but the lowest recorded temperature is 20 degrees.”

Seed Word Prompting#

Seed word prompting is a technique that controls ChatGPT's output by providing specific seed words or phrases. The formula for seed word prompting is to provide a seed word or phrase followed by the instruction “Please generate text based on the following seed word.”

Task: Write a story about dragons (text generation)

  • Seed word: “Dragon”
  • Prompt formula: “Please generate text based on the following seed word: Dragon”

Task: Translate a sentence from English to Spanish (language translation)

  • Seed word: “Hello”
  • Prompt formula: “Please generate text based on the following seed word: Hello”

Seed word prompting can be combined with role prompting and instruction prompting to create more specific and targeted generated text. By providing seed words or phrases, the model can generate text related to that seed word or phrase, and by providing information about the expected output and role, the model can generate text in a style or tone specific to the role or instruction. This allows for better control over the generated text and can be used for various applications. Here are examples of prompts and their formulas: Example 1: Text generation

Task: Write a poem

  • Instructions: The poem should relate to the seed word “love” and be written in the form of a sonnet.
  • Role: Poet
  • Prompt formula: “As a poet, generate a sonnet related to the seed word 'love':”

Task: Complete a sentence

  • Instructions: The completion should relate to the seed word “science” and be written in the form of a research paper.
  • Role: Researcher
  • Prompt formula: “As a researcher, please complete the following sentence in a way that relates to the seed word 'science' and is written in the form of a research paper: [insert sentence]”

Task: Summarize a news article (text summarization)

  • Instructions: The summary should relate to the seed word “politics” and be written in a neutral and objective tone.
  • Role: Journalist
  • Prompt formula: “As a journalist, please summarize the following news article in a neutral and objective tone, relating to the seed word 'politics': [insert news article]”

Knowledge Generation Prompt#

Knowledge generation prompting is a technique for eliciting new, original information from ChatGPT. The formula for knowledge generation prompting is “Please generate new and original information about X,” where X is the topic of interest. This is a technique that leverages the model's pre-existing knowledge to generate new information or answer questions. To use this prompt with ChatGPT, you need to provide the question or topic as input to the model, along with a prompt specifying the task or goal of the generated text. The prompt should include information about the desired output, such as the type of text to be generated and any specific requirements or constraints.

Task: Generate new information about a specific topic (content generation)

  • Instructions: The generated information should be accurate and relevant to the topic
  • Prompt formula: “Generate new and accurate information about [specific topic]”

Task: Answer a question (Q&A)

  • Instructions: The answer should be accurate and relevant to the question
  • Prompt formula: “Answer the following question: [insert question]”

Task: Integrate new information with existing knowledge (knowledge integration)

  • Instructions: The integration should be accurate and relevant to the topic
  • Prompt formula: “Integrate the following information with existing knowledge about [specific topic]: [insert new information]”

Task: Generate insights about customer behavior from a given dataset (data analysis)

  • Prompt formula: “Please generate new and original information about customer behavior from this dataset”

Knowledge Integration Prompt#

This technique leverages the model's existing knowledge to integrate new information or connect different pieces of information. This technique is very useful for combining existing knowledge with new information to generate a more comprehensive understanding of a specific topic.

How to use with ChatGPT:

  • The model should be provided with new information and existing knowledge as input, along with a prompt specifying the task or goal of the generated text.
  • The prompt should include information about the desired output, such as the type of text to be generated and any specific requirements or constraints.

Task: Integrate new information with existing knowledge (knowledge integration)

  • Instructions: The integration should be accurate and relevant to the topic
  • Prompt formula: “Integrate the following information with existing knowledge about [specific topic]: [insert new information]”

Task: Connect different pieces of information (connecting information pieces)

  • Instructions: The connection should be relevant and logically clear
  • Prompt formula: “Connect the following pieces of information in a relevant and logically clear way: [insert information 1] [insert information 2]”

Task: Update existing knowledge with new information (updating existing knowledge)

  • Instructions: The updated information should be accurate and relevant
  • Prompt formula: “Update the existing knowledge about [specific topic] with the following information: [insert new information]”

Multiple Choice Prompt#

This technique provides the model with a question or task along with a set of predefined options as potential answers.

This technique is very useful for generating text limited to a specific set of options and can be used for Q&A, text completion, and other tasks. The model can generate text limited to predefined options.

To use multiple choice prompting with ChatGPT, you need to provide the model with a question or task as input, along with a set of predefined options as potential answers. The prompt should also include information about the desired output, such as the type of text to be generated and any specific requirements or constraints.

Task: Answer a multiple-choice question (Q&A)

  • Instructions: The answer should be one of the predefined options
  • Prompt formula: “Answer the following question by choosing one of the following options: [insert question] [insert option 1] [insert option 2] [insert option 3]”

Task: Complete a sentence using one of the predefined options (text completion)

  • Instructions: The completion should be one of the predefined options
  • Prompt formula: “Complete the following sentence by choosing one of the following options: [insert sentence] [insert option 1] [insert option 2] [insert option 3]”

Task: Classify text as positive, neutral, or negative (sentiment analysis)

  • Instructions: The classification should be one of the predefined options
  • Prompt formula: “Classify the following text as positive, neutral, or negative by choosing one of the following options: [insert text] [positive] [neutral] [negative]”

Explainable Soft Prompt#

Explainable soft prompting is a technique that allows for controlled text generation while providing a degree of flexibility. It achieves this by providing a set of controlled inputs and additional information about the desired output. This technique can generate more interpretable and controllable generated text.

Task: Generate a story

  • Instructions: The story should be based on a given set of characters and a specific theme
  • Prompt formula: “Generate a story based on the following characters: [insert characters] and theme: [insert theme]”

Task: Complete a sentence (text completion)

  • Instructions: The completion should be based on the style of a specific author
  • Prompt formula: “Complete the following sentence in the style of [specific author]: [insert sentence]”

Task: Generate text in a specific style (language modeling)

  • Instructions: The text should be based on the style of a specific period
  • Prompt formula: “Generate text in the style of [specific period]: [insert context]”

Controlled Generation Prompt#

Controlled generation prompting is a technique that allows for high control over the output during text generation. This can be achieved by providing a set of specific inputs, such as templates, specific vocabulary, or a set of constraints that can guide the generation process.

Task: Generate a story

  • Instructions: The story should be based on a specific template
  • Prompt formula: “Generate a story based on the following template: [insert template]”

Task: Complete a sentence (text completion)

  • Instructions: The completion should use specific vocabulary
  • Prompt formula: “Complete the following sentence using the following vocabulary: [insert vocabulary]: [insert sentence]”

Task: Generate text following a specific set of grammatical rules (language modeling)

  • Instructions: The text should adhere to a specific set of grammatical rules
  • Prompt formula: “Generate text that follows the following grammatical rules: [insert rules]: [insert context]”

By providing a set of specific inputs to guide the generation process, controlled generation prompting makes the generated text more controllable and predictable.

Q&A Prompt#

Q&A prompting is a technique that allows the model to generate text that answers specific questions or tasks. This is achieved by providing the model with a question or task along with any other information that may be relevant to the question or task.

Task: Answer a factual question (fact question answering)

  • Instructions: The answer should be accurate and relevant
  • Prompt formula: “Answer the following factual question: [insert question]”

Task: Provide a definition of a word

  • Prompt formula: “Define the following word: [insert word]”

Task: Retrieve information from a specific source

  • Prompt formula: “Retrieve information about [specific topic] from the following source: [insert source]”

Summary Prompt#

Summary prompting is a technique that allows the model to generate a shorter version of a given text while retaining its main ideas and information. This can be achieved by providing a longer text as input to the model and asking it to generate a summary of that text. This technique is very useful for text summarization and information compression tasks. How to use in ChatGPT:

  • The model should be provided with a longer text as input and asked to generate a summary of that text.
  • The prompt should also include information about the desired output, such as the desired length of the summary and any specific requirements or constraints.

Task: Summarize a news article

  • Instructions: The summary should be a brief overview of the main points of the article
  • Prompt formula: “Summarize the following news article in a short sentence: [insert article]”

Task: Summarize meeting notes

  • Instructions: The summary should highlight the main decisions and actions from the meeting
  • Prompt formula: “Summarize the following meeting notes by listing the main decisions and actions: [insert notes]”

Task: Summarize a book

  • Instructions: The summary should be a brief overview of the main points of the book
  • Prompt formula: “Summarize the following book in a short paragraph: [insert book title]”

Dialogue Prompt#

Dialogue prompting is a technique that allows the model to generate text that simulates a conversation between two or more entities. This is achieved by providing the model with a context and a set of roles or entities, along with their roles and backgrounds, and asking the model to generate dialogue between them. Therefore, the model should be provided with context and a set of roles or entities, along with their roles and backgrounds. It should also be given information about the desired output, such as the type of dialogue or conversation and any specific requirements or constraints.

Task: Generate dialogue between two characters

  • Instructions: The dialogue should be natural and relevant to the given context
  • Prompt formula: “Generate dialogue between the following characters in the following situation: [insert characters]”

Task: Generate dialogue in a story

  • Instructions: The dialogue should be consistent with the characters and events of the story
  • Prompt formula: “Generate dialogue between the following characters in the following story: [insert story]”

Task: Generate dialogue for a customer service chatbot

  • Instructions: The dialogue should be professional and provide accurate information
  • Prompt formula: “Generate professional and accurate dialogue for a customer service chatbot when a customer inquires about [insert topic]”

Thus, this technique is very useful for dialogue generation, storytelling, and chatbot development tasks.

Adversarial Prompt#

Adversarial prompting is a technique that allows the model to generate text that resists certain types of attacks or biases. This technique can be used to train models that are more robust and resistant to certain types of attacks or biases.

To use adversarial prompting in ChatGPT, you need to provide the model with a prompt designed to make it difficult for the model to generate text that meets the expected output. The prompt should also include information about the desired output, such as the type of text to be generated and any specific requirements or constraints.

Task: Generate text that is classified as a specific label

  • Instructions: The generated text should be difficult to classify as a specific label
  • Prompt formula: “Generate text that is difficult to classify as [insert label]”

Task: Generate text that is difficult to classify as a specific sentiment

  • Instructions: The generated text should be difficult to classify as a specific sentiment
  • Prompt formula: “Generate text that is difficult to classify as having [insert sentiment] sentiment”

Task: Generate text that is difficult to translate

  • Instructions: The generated text should be difficult to translate into the target language
  • Prompt formula: “Generate text that is difficult to translate into [insert target language]”

Clustering Prompt#

Clustering prompting is a technique that allows the model to group similar data points together based on certain features or characteristics.

This can be achieved by providing a set of data points and asking the model to group them into clusters based on certain features or characteristics.

This technique is very useful in tasks such as data analysis, machine learning, and natural language processing.

How to use in ChatGPT:

  • The model should be provided with a set of data points and asked to group them into clusters based on certain features or characteristics. The prompt should also include information about the desired output, such as the number of clusters to be generated and any specific requirements or constraints.

Task: Group similar customer reviews together

  • Prompt formula: “Group the following customer reviews into clusters based on sentiment: [insert reviews]”

Task: Group similar news articles together

  • Prompt formula: “Group the following news articles into clusters based on topic: [insert articles]”

Task: Group similar scientific papers together

  • Prompt formula: “Group the following scientific papers into clusters based on research field: [insert papers]”

Reinforcement Learning Prompt#

Reinforcement learning prompting is a technique that allows the model to learn from past actions and improve its performance over time. To use reinforcement learning prompting in ChatGPT, you need to provide the model with a set of inputs and rewards, allowing it to adjust its behavior based on the rewards received. The prompt should also include information about the expected output, such as the task to be completed and any specific requirements or constraints. This technique is very useful for decision-making, gameplay, and natural language generation tasks.

Task: Generate text consistent with a specific style

  • Prompt formula: “Use reinforcement learning to generate text consistent with the following style: [insert style]”

Task: Translate text from one language to another

  • Prompt formula: “Use reinforcement learning to translate the following text [insert text] from [insert language] to [insert language]”

Task: Answer a question

  • Prompt formula: “Use reinforcement learning to answer the following question: [insert question]”

Curriculum Learning Prompt#

Curriculum learning is a technique that allows the model to learn complex tasks by first training on simpler tasks and gradually increasing the difficulty. To use curriculum learning prompting in ChatGPT, the model should be provided with a series of tasks that gradually increase in difficulty. The prompt should also include information about the expected output, such as the final task to be completed and any specific requirements or constraints.

Task: Generate text consistent with a specific style

  • Instructions: The model should first train on simpler styles before moving to more complex ones.
  • Prompt formula: “Use curriculum learning to generate text consistent with the following style [insert style], in the following order [insert order].”

Task: Translate text from one language to another

  • Instructions: The model should first train on simpler languages before moving to more complex ones.
  • Prompt formula: “Use curriculum learning to translate text from the following language [insert language] into the following order [insert order].”

Task: Answer a question

  • Instructions: The model should first train on simpler questions before moving to more complex ones.
  • Prompt formula: “Use curriculum learning to answer the following question [insert question], generating answers in the following order [insert order].”

Sentiment Analysis Prompt#

Sentiment analysis is a technique that allows the model to determine the emotional tone or attitude of a text, such as whether it is positive, negative, or neutral. To use sentiment analysis prompting in ChatGPT, the model should be provided with a piece of text and asked to classify it based on its sentiment. The prompt should also include information about the desired output, such as the type of sentiment to be detected (e.g., positive, negative, neutral) and any specific requirements or constraints.

Task: Determine the sentiment of customer reviews

  • Instructions: The model should classify the reviews as positive, negative, or neutral
  • Prompt formula: “Perform sentiment analysis on the following customer reviews [insert reviews] and classify them as positive, negative, or neutral.”

Task: Determine the sentiment of tweets

  • Instructions: The model should classify the tweets as positive, negative, or neutral
  • Prompt formula: “Perform sentiment analysis on the following tweets [insert tweets] and classify them as positive, negative, or neutral.”

Task: Determine the sentiment of product reviews

  • Instructions: The model should classify the reviews as positive, negative, or neutral
  • Prompt formula: “Perform sentiment analysis on the following product reviews [insert reviews] and classify them as positive, negative, or neutral.”

Named Entity Recognition Prompt#

Named entity recognition (NER) is a technique that enables the model to identify and classify named entities in a text, such as names of people, organizations, locations, and dates.

To use named entity recognition prompting in ChatGPT, you need to provide a piece of text and ask it to identify and classify the named entities in the text.

The prompt should also include information about the desired output, such as the types of named entities to be identified (e.g., names of people, organizations, locations, dates) and any specific requirements or constraints.

Task: Identify and classify named entities in a news article

  • Instructions: The model should identify and classify names of people, organizations, locations, and dates
  • Prompt formula: “Perform named entity recognition on the following news article [insert article] and identify and classify names of people, organizations, locations, and dates.”

Task: Identify and classify named entities in a legal document

  • Instructions: The model should identify and classify names of people, organizations, locations, and dates
  • Prompt formula: “Perform named entity recognition on the following legal document [insert document] and identify and classify names of people, organizations, locations, and dates.”

Task: Identify and classify named entities in a research paper

  • Instructions: The model should identify and classify names of people, organizations, locations, and dates
  • Prompt formula: “Perform named entity recognition on the following research paper [insert paper] and identify and classify names of people, organizations, locations, and dates.”

Text Classification Prompt#

Text classification is a technique that allows the model to categorize text into different classes. This technique is very useful for tasks such as natural language processing, text analysis, and sentiment analysis.

It is important to note that text classification and sentiment analysis are different. Sentiment analysis specifically focuses on determining the emotions or sentiments expressed in the text. This may include determining whether the text expresses positive, negative, or neutral sentiments. Sentiment analysis is often used for customer reviews, social media posts, and other texts that require emotional expression.

To use text classification prompting in ChatGPT, the model needs to be provided with a piece of text and asked to classify it based on predefined categories or labels. The prompt should also include information about the desired output, such as the number of categories or labels and any specific requirements or constraints.

Task: Classify customer reviews into different categories, such as electronics, clothing, and furniture

  • Instructions: The model should classify the reviews based on their content
  • Prompt formula: “Classify the following customer reviews [insert reviews] into different categories, such as electronics, clothing, and furniture.”

Task: Classify news articles into different categories, such as sports, politics, and entertainment

  • Instructions: The model should classify the articles based on their content
  • Prompt formula: “Classify the following news articles [insert articles] into different categories, such as sports, politics, and entertainment.”

Task: Classify emails into different categories, such as spam, important, or urgent

  • Instructions: The model should classify the emails based on their content and sender
  • Prompt formula: “Classify the following emails [insert emails] into different categories, such as spam, important, or urgent.”

Text Generation Prompt#

Text generation prompting is related to other prompting techniques mentioned in this book, such as zero-shot, one-shot, few-shot prompting, controlled generation prompting, translation prompting, language modeling prompting, sentence completion prompting, etc. These prompts all relate to generating text, but they differ in the way text is generated and the specific requirements or constraints placed on the generated text. Text generation prompts can be used to fine-tune pre-trained models or train new models to perform specific tasks.

Task: Generate a story based on a given prompt

  • Instructions: The story should contain at least 1000 words and include a specific set of characters and plot.
  • Prompt formula: “Generate a story based on the following prompt [insert prompt] that contains at least 1000 words, including characters [insert characters] and plot [insert plot].”

Task: Translate the given text into another language

  • Prompt formula: “Translate the following text [insert text] into [insert target language], ensuring accuracy and idiomatic expression.”

Task: Complete the given text

  • Prompt formula: “Complete the following text [insert text], ensuring coherence and consistency with the input text.”
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.