iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🧞

Hacks: ChatGPT: Prompt Engineering with ChatGPT

に公開

Introduction

In this article, I will introduce prompt engineering methods using a natural language processing technology called ChatGPT.
As an example of prompt engineering, I will create a prompt[1] for refining technical blog articles.
By having ChatGPT itself create the prompt, you can design prompts without any specialized knowledge.

ChatGPT is a chatbot that utilizes a large language model called GPT[2].
In this article, I will provide an overview of ChatGPT and introduce how to create prompts using ChatGPT.

The prompts in this article are distributed under the MIT License[3]. You are free to use the prompts, but please credit the source when redistributing them.
The MIT License is an open-source license that allows for free copying, modification, and redistribution.
For details, please see The MIT License.

What is ChatGPT

ChatGPT is a chatbot that uses GPT, a natural language processing technology. Unlike previous chatbots, it can provide natural responses by using an LLM[4].
An LLM (Large Language Model) is a natural language processing model trained using a massive amount of linguistic information, and GPT is one of them.
ChatGPT uses OpenAI's GPT successor technology, GPT-3.

What are Prompts in ChatGPT

When you ask ChatGPT a question, it provides a natural response. For example, if you input "translate this article into English," it will display the blog article translated into English.
These kinds of questions are called prompts. By inputting appropriate prompts, ChatGPT can provide accurate responses.
A prompt is the input provided to ChatGPT and is a key concept in prompt engineering.

What is Prompt Engineering?

The process of designing prompts so that ChatGPT can provide appropriate responses is called prompt engineering.
Prompt engineering is the process of designing prompts (questions input into ChatGPT) so that ChatGPT can provide more appropriate answers. When you input a prompt that includes a professional role for ChatGPT, clear instructions, and practical examples of answers, it will provide more practical and effective responses.
The process of designing the questions to be input to match ChatGPT in order to obtain these kinds of answers is prompt engineering.

In this article, I will introduce how to create effective prompts by performing prompt engineering using ChatGPT.
As an example of a prompt, I will take a prompt that is effective for reviewing and refining technical blogs.
Here, by improving a simple prompt for refinement using ChatGPT, I will turn it into a more practical and effective prompt.
By looking at these specific examples, you will gain a deep understanding of prompt engineering.

Methods of Prompt Engineering

For ChatGPT, there is a site called Prompt Engineering Guide, which is a textbook site for prompt engineering in ChatGPT.
This site covers prompt engineering techniques in ChatGPT comprehensively and can be called the official guide for prompt engineering.

Initially, it is a good idea to write a simple prompt based on this Prompt Engineering Guide.

After that, use the created prompt to actually ask ChatGPT questions. Feed those answers back into the prompt and rewrite it into a more practical and effective one.
As for the method of rewriting at this time, use the aforementioned textbook site and various information on the Web.

The basic principle of prompt engineering with ChatGPT this time is also the same as above.
When you use ChatGPT, it will provide not only points for improvement but also alternative suggestions. In other words, you can rewrite the prompt without having to think of it yourself.

By repeating this, you improve the quality of the prompt.

Flow of Prompt Engineering

Prompt engineering follows the flow below:

  1. Setting the Objective:
    Clarify what you want from ChatGPT and design a prompt to achieve it.

  2. Creating the Prompt:
    Create a prompt according to the objective. The prompt serves as an information source for ChatGPT to generate responses based on the input text.

  3. Adjusting the Prompt:
    Check ChatGPT's responses and adjust the prompt as necessary.

  4. Testing and Evaluation:
    Input into ChatGPT using the adjusted prompt, test whether the response is appropriate, and improve the prompt.

Practice of Creating Prompts

Here, we will create a prompt using ChatGPT.

The creation method is as follows:

  1. Prepare a prompt for creating prompts.

  2. Manually write the first simple prompt.

  3. Open the ChatGPT website: https://chat.openai.com/chat

  4. Paste the prompt for prompts and the prompt you want to create, then press Enter.

  5. ChatGPT will present improvements and alternatives for the prompt.

  6. Rewrite the prompt referring to the pointed out improvements and alternatives.

  7. Repeat steps 3-5 to increase the quality of the prompt.

By manually creating a simple prompt and inputting it into ChatGPT, we will identify points for improvement.

Prompt for Creating Prompts

Since we are using ChatGPT, we need a prompt for that purpose. This time, I used the following prompt:

This prompt is designed to create an appropriate prompt according to a specified purpose.
To explain what is written in the prompt:

  • Review the input prompt and adjust it so that ChatGPT can understand it.
  • Treat the text entered after prompt:--- as the prompt to be improved.
  • Interpret the prompt according to its role. The role is indicated separately using role.
  • Review whether the prompt fits the theme.
  • Specify the improvement goal with goal and create a prompt that matches it.
  • Consider ChatGPT as the reader and create a prompt tailored to it.

In this way, the input prompt is reviewed, and improvements and alternative suggestions are created.
role, goal, target, etc., are defined immediately after this prompt.

Initial Prompt

First, create the base prompt.
The prompt is:

This prompt reviews the article indicated by text according to the role specified in role.
The article is in Markdown format, and improvements and alternatives are output in a bulleted list.

Manual Improvement

Since the initial prompt above is too simple, I will manually improve it a bit.
The improved prompt is:

Referring to Prompt for Creating Prompts, I decided to specify instructions in a bulleted list.
Now, I will improve this prompt using ChatGPT.

Improvements by ChatGPT

When I input the above prompt into ChatGPT,

such improvements were returned.
Using these as a reference, I will improve the prompt.

Improved Prompt

I will improve the prompt referring to Improvements by ChatGPT.
The improved prompt is:

I focused on the following points for improvement:

  • Explicitly state that it will be improved through a multi-step process.
  • Add instructions for each role.
  • Add theme to clarify the direction of the prompt.

In this way, you can use ChatGPT to make the prompt itself even better.

Improvements by ChatGPT (Part 2)

Next, reflect on the points for improvement of the improved prompt and further enhance its accuracy. Below are the improvements by ChatGPT (Part 2).

GitHub GistのページURLを指定してください

Referring to these points for improvement, we will enhance the precision of the prompt.

Final Prompt

The final prompt is as follows:

Using this prompt to ask ChatGPT questions will return points for improvement, which you can then use as a reference to rewrite your blog article.

Specific improvements:

  • Repeat the process logically and step-by-step five times to find more essential and high-quality improvements.
  • Emphasize keywords and technical terms, ensuring they are not left out.
  • Provide reference materials with links.
  • Add instructions for each role and perform proofreading according to each role.
  • Clarify the direction of the prompt.

Conclusion

In this article, we actually created a prompt using ChatGPT.
By following these stages to use ChatGPT, anyone should be able to use it effectively.

References

脚注
  1. In this article, this refers to the questions input into ChatGPT. ↩︎

  2. GPT__(Generative Pre-trained Transformer)__ : A natural language processing model developed by OpenAI. ↩︎

  3. One of the open-source licenses. It is an easy-to-use license with few restrictions. ↩︎

  4. (Large Language Model) A natural language processing model specifically trained using a large dataset of natural language processing tasks. ↩︎

GitHubで編集を提案

Discussion