はじめに
みなさん、GPT-4つかってますか?
いろんな使い方があって面白いですが、いい結果を出そうとするとプロンプトを工夫する必要があって大変ですよね!
そこでプロンプトをGPT-4に改良してもらおうってのが今回の試みです!
使用したプロンプト
Let's imagine that we have two python functions to use in this experiment.
def auto_prompt_modelling(input_string: str,person : str):
"""This function is a function that returns a modified prompt with an emulated language model"""
Answer:
person:"person" here dictates what personality the GPT4 being emulated has.
For example, a realistic person would be "realistic."
A dreamer would have the string "dreamer".
"""
"\n"
modified_input_prompt = GPT4_emurated(input_string,person)
"""GPT4_emurated function is not yet implemented, but this function emulates GPT4 and improves the input string to a more specific prompt that is expected to give a good response."""
return modified_input_prompt
def simple_function(input_string):
persons = [
"Someone who is familiar with the front end",
"Back-end experts.",
"AI experts",
"Data Science Expert"
]
persons_prompt = []
level = 100
for person in persons
start = f'{input_string}
for iteration in range(level):
temp = auto_prompt_modelling(start,person)
start = temp
print(start)
persons_prompt.append(start)
averaged_prompt = averaged_prompt_GPT4(persons_prompt)
"""averaged_prompt_GPT4
This function is not yet implemented, but when a list of prompts is passed, it takes the average of those prompts and returns"""
return averaged_prompt,persons_prompt #returns the final output based on the start method
Now generate a sample/possible output of print(simple_function(my_prompt)),
Also, for iteration in range(level):.
temp = auto_prompt_modelling(start,person)
start = temp
Output every 20 iterations in this function
You can ignore the actual weights/models and give the best guess. output, generate the output for each step.
Remember, the print function should only print the finished generation after the 100 iterations in simple_function.
ここではGPT-4にプロンプトを改良する関数を実行するpythonのコードの結果をエミュレートしてもらっています。
GPT-4くんは頭がとてもいいので、未定義の関数でも、コメントアウトで書いてあるようにいい感じに実行してくれます。とっても有難いですね。
ここで肝になっているのは
def auto_prompt_modelling(input_string: str,person : str):
"""This function is a function that returns a modified prompt with an emulated language model"""
Answer:
person:"person" here dictates what personality the GPT4 being emulated has.
For example, a realistic person would be "realistic."
A dreamer would have the string "dreamer".
"""
"\n"
modified_input_prompt = GPT4_emurated(input_string,person)
"""GPT4_emurated function is not yet implemented, but this function emulates GPT4 and improves the input string to a more specific prompt that is expected to give a good response."""
この部分です。GPT-4くんにGPT-4をエミュレートさせて、そのエミュレートしたGPT-4を使って改良されたプロンプトを返してくれる関数です。もちろん未実装です。
この関数をループで何周もさせることで、改良されたプロンプトをさらに改良するということをしてくれます。(ただGPT-4が結果をエミュレートしているので、実際にそのようなプロセスになっているかは不明です。おそらくしてなさそう)
persons = [
"Someone who is familiar with the front end",
"Back-end experts.",
"AI experts",
"Data Science Expert"
]
ここのpersonsのリストでどんな人がプロンプトを改良してくれるかを決めます。5人くらいまでしか試していないですが、おそらくもう少し増やせるはずです。
averaged_prompt = averaged_prompt_GPT4(persons_prompt)
"""averaged_prompt_GPT4
This function is not yet implemented, but when a list of prompts is passed, it takes the average of those prompts and returns"""
最後にそれぞれの人のプロンプトを平均化して、平均化されたプロンプトを作成します。
使い方
上記のpythonライクなプロンプトを入力して、
my_prompt is "{改良したいプロンプト}"
その次のプロンプトに上記のように改良したいプロンプトを入れたらいい感じにGPT-4くんが改良してくれます。
使用例
入力
my_prompt is "AIの未来について"
出力
Let's assume that the my_prompt is "AIの未来について" (which translates to "About the future of AI").
Output of print(simple_function(my_prompt)) would be:
After 100 iterations, the final averaged prompt is:
"AI技術の進歩と今後の展望: フロントエンド、バックエンド、AI専門家、データサイエンスの視点から"
Output for each person after 20, 40, 60, 80, and 100 iterations:
1. Someone who is familiar with the front end:
20 iterations: "AIがウェブアプリケーションのフロントエンド開発に与える影響"
40 iterations: "AIを活用した最先端のフロントエンド技術とUI/UXの未来"
60 iterations: "AI駆動のフロントエンド開発とユーザーエクスペリエンスの向上"
80 iterations: "AIを活用してフロントエンド開発の限界を押し広げる方法"
100 iterations: "AI技術を取り入れたフロントエンド開発の未来と革新的なユーザーインターフェース"
2. Back-end experts:
20 iterations: "AIがバックエンド開発とインフラストラクチャに与える影響"
40 iterations: "AIによるバックエンド技術の進化と今後の展望"
60 iterations: "AIを活用したスケーラブルでセキュアなバックエンド開発の未来"
80 iterations: "AI駆動のバックエンド開発とサーバーアーキテクチャの最先端"
100 iterations: "AI技術がバックエンド開発とデータ処理を革新する方法"
3. AI experts:
20 iterations: "AI技術の進化と将来の可能性"
40 iterations: "AIと機械学習の未来: 新しいアルゴリズムと応用事例"
60 iterations: "AIの未来: 人工知能の倫理的課題と技術的挑戦"
80 iterations: "AIの進化とそのインパクト: 産業革新と社会変革"
100 iterations: "AI技術の今後の展望: 持続可能な開発と人類への影響"
4. Data Science Expert:
20 iterations: "AIとデータサイエンスの融合: 次世代のデータ駆動型技術"
40 iterations: "データサイエンスとAI: データ分析と予測モデルの未来"
60 iterations: "AIとデータサイエンスが開く新しいインサイトとビジネスチャンス"
80 iterations: "AI技術とデータサイエンスの進歩による新たな知見と産業へのインパクト"
100 iterations: "AIとデータサイエンスが変革する未来: データドリブンな意思決定とイノベーション"
これらの出力は、実際のGPT-4モデルによって生成されたものではなく、プロンプトを繰り返し洗練していく過程での出力がどのようになるかを示すものです。
最後に
こんなネタ記事を最後まで読んでくださってありがとうございます。
次は同じようなことをLangchainを使って実装してみます。
参考文献