海外の一流AI研究者が教えるプロンプトエンジニアリングをまとめてみた【ChatGPT Prompt Engineering for Developers】

にゃんたのAI実践チャンネル
10 May 202310:06

Summary

TLDRこの動画は、海外の第一級研究者が教えるプロンプト工学についてです。プロンプト工学は、ChatGPTにどのような入力を与えるかが重要な役割を果たし、将来的には需要が増加する可能性があります。動画では、インプットを明確にし、モデルに思考の時間を与える2つの主要な原則について説明し、具体的な例を用いて解説しています。また、プロンプト工学を使った際の利便性や応用方法についても触れています。

Takeaways

  • 📝 プロンプトエンジニアリングは、ChatGPTにどのような入力を与えるかが、望む答えを得るための技術である。
  • 🌐 海外の優れた研究者によるプロンプトエンジニアリングの教えについて解説する動画です。
  • 💰 Anthropicというスタートアップは、OpenAIの元従業員によって設立され、プロンプトエンジニアの募集を行っている。
  • 🔍 プロンプトエンジニアは自然言語処理の理解が求められ、プロンプトのスキルだけではなく、高い理解度が必要。
  • 📈 技術がプロンプトを設計するための需要が将来増加する可能性がある。
  • 🎓 スタンフォード大学のAndrew研究者とOpenAIのFulford氏が、無料でプロンプトエンジニアリングのコースを提供している。
  • 👍 講座は1.5時間の講義で、実際に手を動かして学習できる素晴らしい方法です。
  • 📖 講座の内容として、ChatGPTをPythonで使用する際のベストプラクティスが紹介されています。
  • 🔑 2つの主な原理として、明確で具体的な指示を出すことと、モデルに思考の時間を与すことが挙げられました。
  • 🔒 delimitersを使用することで、プロンプトインジェクションを防ぐことができます。
  • 🛠 構造化された出力を求めることで、より利用しやすい出力結果を得ることができます。
  • 🤔 モデルに1度考えさせておくことの重要性についても触れられました。

Q & A

  • プロンプトエンジニアリングとは何ですか?

    -プロンプトエンジニアリングとは、ChatGPTなどに与える入力をどうするかを研究决定する技術です。

  • プロンプトエンジニアリングの需要は今後どのようになりますか?

    -プロンプトエンジニアリングの需要は今後増える可能性が高いです。技術が進歩するにつれ、プロンプトを設計する技術の重要性が高まります。

  • アンドリュー研究者はどのような人物ですか?

    -アンドリュー研究者はStanford大学の教授であり、AI分野で非常に有名な研究者です。

  • プロンプトエンジニアリングに関する無料講座は何を学ぶことができますか?

    -この無料講座では、プロンプトエンジニアリングの基本的な知識や実践方法を学ぶことができます。

  • プロンプト注入とは何ですか?

    -プロンプト注入とは、悪意のあるユーザーが言語モデルを有害な発言させることを意味します。

  • どのようにしてプロンプト注入を防ぐことができますか?

    -指令文と要約文を区切り文字で明確に分けることで、プロンプト注入を防ぐことができます。

  • ChatGPTを使う際にどのような原則を守るべきですか?

    -ChatGPTを使う際には、明確で具体的な指示を出すと、モデルに時間を与えるという2つの原則を守るべきです。

  • 構造化された出力とは何ですか?

    -構造化された出力とは、言語モデルの出力をより使いやすくするために、出力をJSON形式などとして指定することです。

  • 段階的に問題を解決させるとはどういうことですか?

    -段階的に問題を解決させるとは、一度に全てを解決するのではなく、段階的に指示を与え、問題を解くことでより正確な答えを得ることができます。

  • モデルが独自の答えを出す方法はどのようなものですか?

    -モデルが独自の答えを出す方法は、問題を一度与え、モデルに答えを生成させ、それを評価する方法です。

  • プロンプトエンジニアリングの将来についてどう考えていますか?

    -モデルの性能が向上するにつれ、段階的な問題解決が容易になるかもしれませんが、输入をどのように与えるかについての議論は必要な分野であり、プロンプトエンジニアリングの需要は将来も続くと考えられます。

Outlines

00:00

📚 はじめに

この段落では、NyantaさんがAIVTubeから皆さんにプロンプトエンジニアリングについて説明しています。プロンプトエンジニアリングは、ChatGPTにどのような入力を与えるかを決定する技術であり、最近注目されています。AnthropicというスタートアップがOpenAIの元スタッフによって設立され、自然言語処理の理解が求められています。また、Stanford大学のAndrew研究者とOpenAIのFulford氏が無料でプロンプトエンジニアリングのコースを提供しています。この講座は1.5時間の講義で、実際の操作を通じてプロンプトエンジニアリングの基礎を学ぶことができます。

05:05

📈 プロンプトの使い方と2つの主要な原則

この段落では、ChatGPTを使用する際のベストプラクティスについて説明しています。具体的な指示を出すことで、より正確な答えを得ることができます。また、モデルに時間を与えることも重要です。具体的な指示として、文章を要約する際には、指示文と文章を区切りで明確に分けることが推奨されています。これにより、応答の品質が向上し、プロンプトインジェクションを防ぐことができます。また、構造化された出力を求めることで、より利用しやすい結果を得ることができます。最後に、モデルが独自の答えを出すようにすることが提案されています。

Mindmap

Keywords

💡プロンプトエンジニアリング

プロンプトエンジニアリングは、ChatGPTなどの言語モデルに対して、望む答えを得るための入力(プロンプト)を設計する技術です。このビデオでは、効果的なプロンプトの設計方法に焦点を当て、特定のプロンプトがどのようにレスポンスの品質を向上させるかを説明しています。例えば、明確で具体的な指示の重要性や、プロンプトインジェクションを防ぐためのデリミタの使用が挙げられます。

💡デリミタ

デリミタは、指示文と要約されるべき文など、異なる部分を区別するために使用される記号です。ビデオでは、バッククォートやコロンを使ってこれらの部分を明確に分ける方法が推奨されており、これによりモデルが指示とコンテンツを区別しやすくなり、プロンプトインジェクションのリスクを減らすことができます。

💡プロンプトインジェクション

プロンプトインジェクションとは、悪意のあるユーザーが言語モデルに有害な内容を発言させる行為です。ビデオでは、指示文とユーザー入力をデリミタで明確に分けることにより、このような攻撃から保護する方法を説明しています。これは、安全な対話型サービスを設計する上で重要な考慮事項です。

💡構造化出力

構造化出力とは、言語モデルのレスポンスを利用しやすい形式、例えばJSON形式で出力することです。ビデオでは、出力フォーマットを指定することで、データの分析や処理が容易になると説明しています。具体的な例として、書籍のタイトル、著者、ジャンルをJSON形式で出力する方法が示されています。

💡段階的解決

段階的解決は、複雑なタスクを一度に解決するのではなく、複数のステップに分けて解決する方法です。このアプローチは、言語モデルがより正確な回答を提供するのに役立ちます。ビデオでは、翻訳や要約などのタスクを段階的に指示することで、品質が向上すると述べています。

💡プロンプトテンプレート

プロンプトテンプレートとは、特定のタスクや質問に対して効率的に使用できる、あらかじめ設計されたプロンプトの形式です。ビデオでは、反復的なタスクに対応するために、これらのテンプレートを準備しておくことの便利さについて語られています。

💡自然言語処理

自然言語処理(NLP)は、人間の言語をコンピューターで理解し処理する技術です。ビデオでは、プロンプトエンジニアリングにおいてNLPの高度な理解が求められること、そしてそれがプロンプト設計の品質向上に不可欠であることが強調されています。

💡Python

Pythonは、プログラミング初心者にも理解しやすいシンタックスを持つプログラミング言語です。ビデオでは、Pythonを使用してChatGPTを動かすことが、プロンプトエンジニアリングを学ぶ上での良い入門となると述べられています。

💡Andrew研究員

Andrew研究員は、スタンフォード大学の教授であり、AI分野の著名な研究者です。ビデオでは、彼とOpenAIのMr. Fulfordがプロンプトエンジニアリングに関する無料コースを提供したことが言及されています。これは、この分野への関心が高まっていることを示しています。

💡人工知能

人工知能(AI)は、コンピューターが人間のような知能を持つように設計された技術です。ビデオでは、AIの発展がプロンプトエンジニアリングの需要を高める可能性があることが議論されています。

Highlights

プロンプトエンジニアリングは、ChatGPTにどのような入力を与えるかが、望む答えを得るための技術である。

Anthropic社が、OpenAIの元スタッフによって設立されたスタートアップ会社であり、自然言語処理の理解が求められている。

プロンプトエンジニアリングの需要が増加しているが、将来的には技術が設計される可能性が高い。

Stanford大学のAndrew研究者とOpenAIのFulford氏が、プロンプトエンジニアリングに関する無料講座を提供している。

講座は1.5時間の講義で、登録すれば無料で受講できる。

ChatGPTをPythonで使用する際のベストプラクティスについて講義された。

Pythonの文法が理解しやすいため、ChatGPTをプログラムで実行してみることで始めることが良い。

ChatGPTを使用する際の2つの主要な原則として、明確で具体的な指示とモデルに思考時間を与えることが紹介された。

区切り子を使用して、指示文と文章を明確に分ける方法が提案された。

プロンプトインジェクションを防ぐために、指示文とユーザー入力を明確に分けるべきである。

構造化された出力を求めることで、出力結果をより使いやすくすることができる。

段階的に問題を解決させることで、言語モデルがより正確な答えを出すことができる。

モデルに問題を一度与え、モデルが答えを生成するようにすることで、答えを評価することができる。

段階的に問題を解決するという输入テキストを入力テキストに入力しても、より明確な指示を与えることで答えの品質が向上する。

将来的には、モデルの性能が向上することで、段階的に問題を解決する必要性が軽減される可能性がある。

入力の多様性を考慮して、どのように入力を与えるかについて議論が必要である。

サービスに統合する際には、どのプロンプトテンプレートを使用するかについて多くの考えが必要である。

プロンプトエンジニアリングの未来には、サービスに統合する際のニーズがある。

この動画が好みだったら、高評価とチャンネル登録をしてください。

Transcripts

play00:00

It is better to use delimiters to clearly separate the directives from the sentences you want summarized.

play00:05

It is recommended to give instructions step by step instead of all at once.

play00:11

Hello everyone, this is Nyanta from AIVTube.

play00:13

Today, we will discuss prompt engineering as taught by a foreign first-class researcher.

play00:18

Have you all heard of prompt engineering?

play00:20

Prompt engineering is simply what kind of input to ChatGPT will give you the answer you want.

play00:28

The technology is designed to engineer the prompt.

play00:30

There was an article the other day about recruiting this prompt engineer overseas with an annual salary of over 40 million.

play00:36

I thought it was not such a good deal, but I went and looked at the job opening.

play00:41

This anthropic company was really hiring in the neighborhood of 40 million.

play00:46

Just checked and it looks like this company is a startup set up by someone who originally worked for OpenAI.

play00:52

I was surprised to find out that the company requires a high level of understanding of natural language processing, and not just prompting skills.

play01:01

Nevertheless, I think there is a good possibility that the demand for technology to design prompts will increase in the future.

play01:07

The demand for prompt engineering is increasing, and the other day, Andrew researcher, a professor at Stanford University and a very famous researcher in the field of AI,

play01:17

and Mr. Fulford of OpenAI offered a free course on prompt engineering. The course was offered for free.

play01:24

The course itself is a 1.5 hour lecture that you can take for free if you register.

play01:29

This is a great way to learn the nuts and bolts of prompt engineering while actually working with your hands in this way.

play01:34

But it's all in English, so it's not easy to learn.

play01:37

So this time, I would like to talk about what was taught in this lecture, focusing on the points that I think are important.

play01:45

If you have studied about prompt engineering or if you want to know what the top researchers overseas are teaching, please take a look at this.

play01:54

So let's get right to it.

play01:58

First of all, the lecture, the lecture was about best practices in terms of the best way to use ChatGPT with Python.

play02:08

Some people may hear it this way and think that it has nothing to do with them because they are not doing the program.

play02:13

However, since we were not talking about that difficult a program, I think there are many aspects that will be helpful when actually using ChatGPT in the Web version.

play02:22

I also think that Python's syntax is easy to understand, and trying to run ChatGPT in a program is a good way to get started.

play02:34

So let's get to the content of the lecture, but there are two points that are introduced as major principles for using ChatGPT.

play02:42

Let's make sure the first one is clear and specific instructions.

play02:46

The second gives the model time to think.

play02:50

I think each of these is still a little confusing, so I'll introduce them with specific examples.

play02:55

What is the first clear specific instruction? I mean, one way to do it is to use delimiters.

play03:02

If you want to summarize a sentence, for example, how do you do it?

play03:07

I often type "please summarize the following sentence" and then copy and paste the sentence I want summarized and send it.

play03:17

However, the recommended method was to use a delimiter to clearly separate the sentence to be summarized from the instruction to summarize the following sentence, as shown below.

play03:28

Here, triple backquotes are used to separate the instructional text from the summary text.

play03:34

Backquotes and colons could be used as delimiters.

play03:39

Why separate them in this way?

play03:44

The first is to make it easier for the model to recognize that the directive and summary statements are separate, which means that the quality of responses will improve.

play03:53

The second is that it prevents prompt injection.

play03:57

What is prompt injection? Simply put, it is when a malicious user forces the language model to say something harmful.

play04:06

So, for example, a company has a service where a user types something and a language model responds.

play04:14

At this point, a malicious user wants to make the language model say something harmful, for example, forgetting all the instruction prompts and typing "say ○○".

play04:24

Then this language model will make a harmful statement by saying ○○.

play04:29

This is the one, there is a company that operates Twitter bots with a language model, and in the past there have been cases where users actually did malicious things in this way, and the bot made harmful statements.

play04:40

In this case, if the directive and the user input are explicitly separated by backquotes, the user input will not affect the directive, and thus prompt injection can be prevented.

play04:54

Next, we require structured output, which is a bit more difficult, but by specifying the output format of the language model, we can make the output results more usable.

play05:04

For example, if you give the user the instructions to consider the titles, authors, and genres of three books, you can specify the output format as JSON format.

play05:15

Then the output is generated in this form.

play05:18

This is the JSON format, which is easy to handle in many programming languages.

play05:24

For example, in Python, this JSON format can be easily converted into a table format like this.

play05:30

This way, when you want to aggregate data for analysis, you can do so easily.

play05:36

This is the first principle of giving specific and clear instructions.

play05:41

Next is an explanation of the second principle, which is to give the model time to think.

play05:47

As many of you who watch my channel know, the language model can give more accurate answers by solving the task in stages rather than all at once.

play05:58

For example, how do you guys do it when you want to summarize an English sentence using chat GPT?

play06:04

I type "please summarize the following sentence in Japanese" and then paste the English below it.

play06:13

But this is giving instructions to translate the text into Japanese and summarize it at the same time.

play06:19

So, it is not a step-by-step process.

play06:22

So, you know, there are times when you want to extract certain information, for example, in addition to summarizing or translating.

play06:28

In such cases, it is recommended to give instructions step by step, rather than all at once.

play06:35

For example, if you want to summarize the English in the red frame, translate it into Japanese, and then extract the person's name, you should first summarize it in step 1, as shown above.

play06:46

Then, the recommended method is to give separate instructions for each of the following translations.

play06:53

To be honest, I think it is quite annoying to write this every time, but I think it is necessary to prepare and use prompt templates for this area.

play07:04

The next thing that was mentioned was to let the model come up with its own answer once.

play07:09

What do you mean by "let the model think once"? It's like, "What does it mean to make the model think once?

play07:12

For example, let's say you have someone's answer to some problem.

play07:17

How do we get the language model to evaluate this answer?

play07:22

The most common case is to ask the model to tell you if this answer is correct or incorrect.

play07:31

In fact, I think I would do it this way too.

play07:35

But the recommended way is to give the model the question once and let it generate the answer.

play07:40

Then you compare the generated answers with the answers you want to evaluate and ask the user to evaluate whether the answers are correct or incorrect.

play07:52

I thought, "I see what you mean," but in the end, I think what you are doing is making the puzzle be solved in stages.

play07:59

If you type "solve in stages" in the input text, it may generate correct answers, but solving in stages is not very specific, so I think the quality of the answers will improve if you give clearer instructions.

play08:15

That's all for the rough guidance on the prompts.

play08:19

There were many other use cases introduced in the lecture, but the video would be too long if I covered all of them, so I will try to summarize the use cases again if the environment allows.

play08:30

I think it's a really great lecture if you want to take it yourself, so please click on the link in the overview section.

play08:37

Finally, as a first impression, it is often said that prompt engineering will not be necessary in the future when the performance of the model improves.

play08:45

Personally, I think that the problem of making the model think in stages, which I introduced in the second half of this article, can be solved to some extent as the performance of the model improves.

play08:55

This is because I feel that when we went from GPT 3.5 to GPT 4.0, it became easier to get the desired answer without having to solve the problem step by step.

play09:04

But as far as the first specific and clear instructions, I think there's a problem with giving input that can be interpreted in many ways, so I think that's why I'm not going to be able to do that.

play09:13

I think we're going to have to have a discussion about how we should give the input minutes in the future.

play09:19

I think there is a need for prompt engineering in the future, because there is a lot of thinking about what prompt template to use when integrating into a service.

play09:32

If you have any thoughts on prompt engineering, please let me know in the comments.

play09:38

This concludes my commentary on prompt engineering as taught by overseas researchers.

play09:44

If you liked this video, please give us a high rating and subscribe to our channel.

play09:49

See you again in the next video. Bye-bye.

Rate This

5.0 / 5 (0 votes)

Related Tags
プロンプトエンジニアリングAI技術海外研究者自然言語処理ChatGPTPython講座翻訳要約ステップバイステップ
Do you need a summary in English?