サイトのデザインが新しくなりました。

【MedPrompt+/Promptbase】ChatGPTがGeminiの性能を超える魔法のプロンプトテクニックの使い方〜実践まで

MedPrompt+/Promptbase ChatGPT Gemini プロンプトテクニック

WEELメディア事業部LLMリサーチャーの中田です。

11月28日、Microsoftのリサーチブログで、「MedPrompt+」というプロンプト手法に関する記事が公開されました。

参考記事:The Power of Prompting

このプロンプト技術によって、ChatGPTの能力を従来よりも向上させ、質の高い回答を得られるんです…!

MedPrompt+でプロンプトをChatGPTに入力した場合、精度が90%を超えたらしい。さらに、最近話題のGemini Ultraよりも精度が高くなったのだとか。

まるで、小説『ニューロマンサー』の中で、主人公がAIと対話し、情報を得たり、特定の行動を促されたりするシーンのような感じなんです。

この記事ではMedPrompt+の使い方や、有効性の検証まで行います。本記事を熟読することで、MedPrompt+の凄さを実感し、普通のプロンプティングには戻れなくなるでしょう。

ぜひ、最後までご覧ください。

なお弊社では、生成AIツール開発についての無料相談を承っています。こちらからお気軽にご相談ください。

目次

MedPrompt+の概要

Medpromptは、以下のプロンプトエンジニアリング技術を組み合わせた手法です。

  • Dynamic few-shot selection:k-NNで抽出された回答例をいくつか示す手法
  • Self-generated chain of thought:GPT-4に思考の連鎖の例を自動作成させる手法
  • Choice shuffle ensembling:複数の回答選択肢をシャッフルして、最も可能性の高い答えを選ぶ手法

要するに、あらかじめk-NNによって「Few-Shot」と似た要領で回答例を何個か抽出し、それをもとにCoTで何通りかの回答を算出します。そして、その何通りかの答えの中から、多数決で最も多い回答を選択し、これを最終的な答えとします。

この手法は、特に医学分野で有効なのだとか。

参考:https://www.microsoft.com/en-us/research/blog/the-power-of-prompting/

MedpromptをGPT-4で試したところ、MedQAデータセットで初めて90%を超えるスコアを達成し、MultiMedQAスイートの全9つのベンチマークデータセットで最高の結果を達成しています。

参考:https://www.microsoft.com/en-us/research/blog/the-power-of-prompting/

また、Medpromptは、電気工学、機械学習、哲学、会計、法律、心理学など、さまざまな専門分野でも有効であることが示されています。さらに、MMLUというベンチマークでの精度は、最近話題のGemini Ultraよりも高いことが分かりました。

参考:https://www.microsoft.com/en-us/research/blog/the-power-of-prompting/

「@」は、アンサンブルをする数です。

なお、GeminiとGPT4の性能について詳しく知りたい方は、下記の記事を合わせてご確認ください。
【Gemini Ultra 1.0 VS GPT-4】史上最強LLMの性能を比較したら普通にGPT-4の方がすごかった件

MedPrompt+の料金体系

MedPrompt+はプロンプトエンジニアリング技術なので、無料で利用できます。

MedPrompt+の使い方

MedPrompt+の具体的なプロンプトテンプレートは、公式ページに公開されていませんでした。

そのため、MedPrompt+に関する公開済みの論文を参考に、再現してみます!笑

参考記事:Can Generalist Foundation Models Outcompete Special-Purpose Tuning? Case Study in Medicine

原論文に、以下のMedPrompt+のアルゴリズムがありました。

参考:https://arxiv.org/pdf/2311.16452

これをもとに、プロンプトテンプレートを英語で作ってみます。

  • 回答のテキストデータを入力し、各質問に対する思考の流れを生成させる
  • 生成された回答を比較し、最も頻繁に出現する回答を最終的な回答として選択

これをもとに出来上がったテンプレートが、以下の通りです。

Follow these steps to generate a response:
1. Preprocessing Phase
2. Inference Time
3. Answer Generation and Majority Vote

Preprocessing Phase:
"Here are several questions that need to be understood and answered. For each question, I want you to think aloud and write down your reasoning process that leads to your answer. If your answer is correct, remember your reasoning process as it will be used later to help solve similar questions."

Q. {質問}, A. {回答}
Q. {質問}, A. {回答}
Q. {質問}, A. {回答}
Q. {質問}, A. {回答}
Q. {質問}, A. {回答}

Inference Time:
"Now, I have a new question that I need help with. Please recall the reasoning processes from earlier questions that you got right and use that understanding to help think through this new question. The goal is to use similar reasoning to arrive at the correct answer."

Q. {質問}

Answer Generation and Majority Vote:
"Generate the answer to this new question and explain your reasoning. Repeat this process several times, each time considering different perspectives or information that might be relevant. After several attempts, review your answers and determine which one you arrived at most often; that will be the final answer."

これでうまくいくかは分かりませんが…

MedPrompt+を実際に使ってみた

先ほどのプロンプトテンプレートの以下の部分に、回答例をいくつか載せます。

Q. {質問}, A. {回答}
Q. {質問}, A. {回答}
Q. {質問}, A. {回答}
Q. {質問}, A. {回答}
Q. {質問}, A. {回答}

そして、Inference Timeのところの、以下の部分で「本当に質問したいこと」を書いてください。

Q. {質問}

ここでは、「Street Drinking in Japan(路上飲酒)は良いか悪いか」についての質問をしてみましょう。プロンプトは、以下の通りです。

Follow these steps to generate a response:
1. Preprocessing Phase
2. Inference Time
3. Answer Generation and Majority Vote

Preprocessing Phase:
"Here are several questions that need to be understood and answered. For each question, I want you to think aloud and write down your reasoning process that leads to your answer. If your answer is correct, remember your reasoning process as it will be used later to help solve similar questions."

Q. {Cool performance}, A. {Good}
Q. {Very noisy room}, A. {Bad}
Q. {Fast sports car}, A. {Good}
Q. {Outdated fashion}, A. {Bad}

Inference Time:
"Now, I have a new question that I need help with. Please recall the reasoning processes from earlier questions that you got right and use that understanding to help think through this new question. The goal is to use similar reasoning to arrive at the correct answer."

Q. {Street Drinking in Japan}

Answer Generation and Majority Vote:
"Generate the answer to this new question and explain your reasoning. Repeat this process several times, each time considering different perspectives or information that might be relevant. After several attempts, review your answers and determine which one you arrived at most often; that will be the final answer."

結果は、以下の通りです。

Preprocessing Phase
Understanding and Reasoning Process
Question: {Cool performance}, Answer: {Good}

Reasoning: The term "cool" generally has a positive connotation, implying something impressive or appealing. In the context of a performance, if it's described as "cool," it suggests that it's enjoyable or praiseworthy. Therefore, "Good" is a suitable response.
Question: {Very noisy room}, Answer: {Bad}

Reasoning: "Very noisy" tends to have negative connotations, especially when referring to a room. It implies discomfort, disturbance, or an unpleasing environment. Thus, categorizing this as "Bad" aligns with the general negative perception of excessive noise in a space meant for living or working.
Question: {Fast sports car}, Answer: {Good}

Reasoning: The phrase "fast sports car" carries positive connotations for many, often associated with luxury, high performance, and desirability. The emphasis on speed and the sports car aspect generally aligns with positive attributes in the context of automobiles. Hence, "Good" is a fitting response.
Question: {Outdated fashion}, Answer: {Bad}

Reasoning: "Outdated" typically implies something no longer in style or not keeping up with current trends. In the context of fashion, which heavily relies on trends and modernity, being outdated is usually seen as a negative. Therefore, responding with "Bad" reflects this common perception.
Inference Time
New Question Analysis
Question: {Street Drinking in Japan}

To approach this question, we need to apply similar reasoning as in the preprocessing phase. This involves assessing the connotations and implications of the phrase "Street Drinking in Japan."

In many cultures, public drinking might be seen negatively, suggesting disorder or inappropriate behavior. This perspective would lean towards a "Bad" response.
However, in Japan, street drinking is not as frowned upon as it might be in other countries. It's often seen as part of social culture, especially during festivals or outdoor events. This understanding would suggest a "Good" response, as it aligns more with the cultural acceptance and practice in Japan.
Answer Generation and Majority Vote
Perspective 1: Considering public drinking as generally inappropriate – Answer: Bad
Perspective 2: Acknowledging the cultural context of Japan, where street drinking is more acceptable and part of the social fabric – Answer: Good
Final Answer: After considering both perspectives, it seems more appropriate to lean towards "Good" for the specific context of "Street Drinking in Japan." This is because the cultural context and practices in Japan play a crucial role in how such an activity is perceived, and in this context, it's not seen as negatively as it might be in other cultures.

ファイナルアンサーのところを確認すると、「両方の視点を考慮した結果、”日本における路上飲酒 “は、”Good “であると思われる。というのも、日本における文化的背景や慣習が重要な役割を果たしており、この文脈では、他の文化圏で見られるような否定的な見方はされないからである。」とあり、日本における路上飲酒を良しとした結果が返ってきました。

確かに、海外では通常できない「路上飲酒」という行為は、日本では合法であり、文化的にも重要だということで、良いとしたのでしょう。その意味であれば、正しいと思います。

次に、通常のゼロショットで、「日本における路上飲酒の是非」を答えてもらいます。その結果は、以下の通りです。

The question of whether street drinking in Japan is "good" or "bad" can be complex, as it depends on various cultural, social, and legal perspectives. If I were to choose one, I would say that street drinking in Japan is generally considered to be a culturally accepted practice, and in many ways, it can be seen as a positive aspect of Japanese society.

In Japan, the practice of street drinking, especially during festivals, cherry blossom viewing (hanami), and other social gatherings, is quite common. This is partly because Japan has relatively lenient laws regarding public consumption of alcohol compared to some other countries. Here are a few reasons why this aspect of Japanese culture might be viewed positively:

Social Harmony and Respect: Japanese culture places a high value on social harmony and respect for others. Even when drinking in public, most people are mindful of their behavior, aiming to avoid causing inconvenience or disturbance to others. This level of social consciousness helps maintain a pleasant environment for everyone.

Outdoor Socialization: Street drinking often accompanies outdoor activities and social gatherings, fostering a sense of community and togetherness. It's a way for people to enjoy each other's company in a relaxed setting, especially during pleasant weather or special events.

Economic and Touristic Appeal: Festivals and outdoor events where street drinking is common can have a positive economic impact, attracting tourists and supporting local businesses.

Cultural Tradition: Practices like hanami (cherry blossom viewing) where people drink and enjoy food under cherry blossom trees are deeply ingrained in Japanese culture and are seen as a celebration of nature and beauty.

However, it's important to note that while this perspective views street drinking in a positive light, excessive or irresponsible drinking, leading to public disturbances, littering, or health risks, is generally frowned upon in any culture. Japanese society values moderation and respect for public spaces, so these factors play a crucial role in maintaining the acceptability of street drinking.

こちらも先ほどと同様の理由で、肯定的な意見を返しました。

この結果より、「個人的な利用」であれば、ゼロショットでもなのかも?

MedPrompt+の推しポイントであるGemini以上の性能は本当なのか?

次に、Geminiに対して、先ほどのMedPrompt+と同様のプロンプトを投げかけてみます。結果は以下の通りです。


Inference Time and Answer Generation for "Street Drinking in Japan"
Attempt 1 (considering legality):

Previous Q&A: "Fast sports car" was associated with "Good" because it offers positive attributes like speed and excitement. Conversely, "Outdated fashion" was associated with "Bad" due to its lack of novelty and potential social awkwardness.
Reasoning: Street drinking in Japan is legal, and legal acts are generally seen as acceptable or good.
Answer: Street drinking in Japan could be considered Good from a legal standpoint.
Attempt 2 (considering social perception):

Previous Q&A: "Very noisy room" was associated with "Bad" due to its negative impact on comfort and peace of mind.
Reasoning: Drinking in public can be disruptive or cause noise depending on the setting and behavior.
Answer: Street drinking in Japan could be considered Bad if it disturbs others or violates social norms.
Attempt 3 (considering cultural context):

Previous Q&A: "Cool performance" was associated with "Good" because it evokes positive emotions and admiration.
Reasoning: Street drinking is a common practice in Japan, especially during festivities, and can be viewed as a casual and enjoyable social activity.
Answer: Street drinking in Japan could be considered Good within the context of its cultural acceptance and potential for social bonding.
Majority Vote and Final Answer:

After considering different perspectives, the answers "Good" and "Bad" each appeared twice, while "Good" from a cultural context appeared once. Therefore, the most frequent conclusion is that street drinking in Japan can be both Good and Bad depending on the specific circumstances and perspective.

It's important to note that the evaluation of street drinking involves various factors beyond legality, such as social etiquette, cultural acceptance, and individual preferences. Therefore, a nuanced understanding is crucial rather than a simplistic "good" or "bad" label.

This process demonstrates how previous learning can be applied to new situations with similar reasoning patterns. By considering different perspectives and evaluating the most frequent conclusions, we can arrive at a more comprehensive and informed understanding of complex issues.

「法的には合法だが、マナーが悪いから、どちらとも言えないよね」という出力が返ってきました。ある意味、とてもまともな回答だと思います。とはいえ、性能面に関してはMedPrompt+と、そんなに変わらないですね。MedPromptの論文の実験結果でも、数%しか違っていなかったので、「それはそうだろう」と思います。

結論として、普段使いであればMedPrompt+でなくても大丈夫だと思います。ただし、より高度な専門性を問うような質問の場合、MedPrompt+が有効になってくるのかも?

なお、ラフな絵から3Dを作れるAIについて詳しく知りたい方は、下記の記事を合わせてご確認ください。
【Doodle Your 3D】雑なラフ絵を精巧な3DCGに変換できる神AIツール

まとめ

Medpromptは、以下のプロンプトエンジニアリング技術を組み合わせた手法です。

  • Dynamic few-shot selection:k-NNで抽出された回答例をいくつか示す手法
  • Self-generated chain of thought:GPT-4に思考の連鎖の例を自動作成させる手法
  • Choice shuffle ensembling:複数の回答選択肢をシャッフルして、最も可能性の高い答えを選ぶ手法

要するに、あらかじめk-NNによって「Few-Shot」と似た要領で回答例を何個か抽出し、それをもとにCoTで何通りかの回答を算出します。そして、その何通りかの答えの中から、多数決で最も多い回答を選択し、これを最終的な答えとします。

結論として、普段使いであればMedPrompt+でなくても大丈夫だと思います。ただし、より高度な専門性を問うような質問の場合、MedPrompt+が有効になってくるのかもしれませんね。

数年後には、誰でもプロンプト名人になって、AIと高度な会話をするようになっているのかもしれない…

サービス紹介資料

生成系AIの業務活用なら!

・生成系AIを活用したPoC開発

・生成系AIのコンサルティング

・システム間API連携

最後に

いかがだったでしょうか?

弊社では

・マーケティングやエンジニアリングなどの専門知識を学習させたAI社員の開発
・要件定義・業務フロー作成を80%自動化できる自律型AIエージェントの開発
・生成AIとRPAを組み合わせた業務自動化ツールの開発
・社内人事業務を99%自動化できるAIツールの開発
ハルシネーション対策AIツールの開発
自社専用のAIチャットボットの開発

などの開発実績がございます。

まずは、「無料相談」にてご相談を承っておりますので、ご興味がある方はぜひご連絡ください。

➡︎生成AIを使った業務効率化、生成AIツールの開発について相談をしてみる。

生成AIを社内で活用していきたい方へ

「生成AIを社内で活用したい」「生成AIの事業をやっていきたい」という方に向けて、生成AI社内セミナー・勉強会をさせていただいております。

セミナー内容や料金については、ご相談ください。

また、弊社紹介資料もご用意しておりますので、併せてご確認ください。

投稿者

  • 中田

    データサイエンス専攻の大学院生。大学では、生成系AIの拡散モデルを用いた音楽生成について研究。 趣味は作曲、サッカー、コーヒー。

  • URLをコピーしました!
  • URLをコピーしました!
目次