Prompt Engineering 简明教程

Prompt Engineering - CREATIVE SURVEY Prompt

通过使用 CREATIVE SURVEY 指令,我们可以利用 ChatGPT 的功能以调查答案的形式生成创造性响应。此技术使我们能够利用 ChatGPT 的想象力来提供多种多样的独特调查答案。

Using the CREATIVE SURVEY directive, we can leverage ChatGPT’s capabilities to generate creative responses in the form of survey answers. This technique enables us to tap into ChatGPT’s imaginative abilities to provide diverse and unique survey responses.

Understanding the CREATIVE SURVEY Directive

CREATIVE SURVEY 指令提示 ChatGPT 以调查答案的形式生成有想象力和创造性的回答。通过在提示中加入 CREATIVE SURVEY 指令,我们就可以利用 ChatGPT 的语言生成技能提供有趣且非传统的调查回答。

The CREATIVE SURVEY directive prompts ChatGPT to generate imaginative and creative responses as survey answers. By incorporating the CREATIVE SURVEY directive in our prompts, we can harness ChatGPT’s language generation skills to provide interesting and unconventional survey responses.

CREATIVE SURVEY 指令的基本 syntax 如下所示:

The basic syntax for the CREATIVE SURVEY directive is as follows −

User: Please provide a creative survey response for the question: "What is your favorite book?"
ChatGPT: As an AI language model, I don't have personal preferences, but if books could talk, I imagine they would whisper tales of adventure, inspire dreams, and unveil the secrets of the universe, captivating readers' hearts with every word.

在此示例中,用户针对“您最喜欢的书是什么?”这个问题请求提供一个有创意的调查答案。ChatGPT 的回答包含根据所给提示生成的富有想象力和独特的调查答案。

In this example, the user asks for a creative survey response for the question, "What is your favorite book?" The response from ChatGPT includes an imaginative and unique survey response generated based on the given prompt.

Best Practices for Using the CREATIVE SURVEY Directive

为了充分利用 CREATIVE SURVEY 指令,不妨考虑以下最佳做法:

To make the most of the CREATIVE SURVEY directive, let’s consider the following best practices −

  1. Encourage Imagination and Creativity − Prompt ChatGPT to unleash its imaginative abilities and provide creative survey responses. Encourage the generation of unique perspectives, unconventional ideas, or out-of-the-box interpretations.

  2. Vary the Tone and Style − Experiment with different tones and styles in the survey responses. Prompt ChatGPT to generate responses that are humorous, poetic, dramatic, or thought-provoking, depending on the context and desired effect.

  3. Incorporate Unexpected Elements − Prompt ChatGPT to include unexpected elements or surprising twists in the survey responses. This can make the responses more engaging, memorable, and captivating for the survey participants.

  4. Consider the Target Audience − Tailor the creative survey responses to the target audience. Ensure that the responses align with the context, theme, or purpose of the survey and resonate with the intended respondents.

Example Application − Python Implementation

让我们探讨一个使用 CREATIVE SURVEY 指令结合与 ChatGPT 交互的 Python 脚本的实际示例。

Let’s explore a practical example of using the CREATIVE SURVEY directive with a Python script that interacts with ChatGPT.

import openai

# Set your API key here
openai.api_key = 'YOUR_API_KEY'

def generate_chat_response(prompt):
   response = openai.Completion.create(
      engine="text-davinci-003",
      prompt=prompt,
      max_tokens=500,
      temperature=0.7,
      n=1,
      stop=None
   )
   return response

user_prompt = "User: Please provide a creative survey response for the question: 'What is the meaning of life?'\n"

chat_prompt = user_prompt + "ChatGPT: [Creative Survey: Meaning of life in brief]"

response = generate_chat_response(chat_prompt)

print(response)

在此示例中,我们定义了一个函数 generate_chat_response(),该函数接受一个提示并使用 OpenAI API 使用 ChatGPT 生成一个响应。chat_prompt 变量包含用户的提示和 ChatGPT 响应,包括 CREATIVE SURVEY 指令,要求针对“生命意义是什么?”这个问题提供一个有创意的调查答案。

In this example, we define a function generate_chat_response() that takes a prompt and uses the OpenAI API to generate a response using ChatGPT. The chat_prompt variable contains the user’s prompt and the ChatGPT response, including the CREATIVE SURVEY directive to request a creative survey response for the question, "What is the meaning of life?"

Output

当我们运行该脚本时,我们将收到 ChatGPT 生成的响应,其中包括针对给定问题提供创造性和想象力的调查响应。

When we run the script, we will receive the generated response from ChatGPT, which includes a creative and imaginative survey response for the given question.

我们为示例中给出的用户提示获得了以下响应−

We got the following response for the user prompt given in our example −

Life is about discovering and embracing your purpose, living with integrity and joy, and finding happiness in the moments we share with others.

Conclusion

在本章中,我们探索了 ChatGPT 提示工程中的 CREATIVE SURVEY 指令。通过利用 Creative Survey 指令,我们可以提示 ChatGPT 生成富有想象力和创造力的调查响应。

In this chapter, we explored the CREATIVE SURVEY directive in prompt engineering for ChatGPT. By utilizing the CREATIVE SURVEY directive, we can prompt ChatGPT to generate imaginative and creative survey responses.