QEUR23_PHI2SFT17: アンサンブル処理でReasoningの品質を改善する
~ アンサンブルは機械学習でよく使います。なぜなら・・・。 ~
・・・ 前回の続きです ・・・
QEU:FOUNDER : “今回、せっかく2つのLLMからの推論出力が出てきたのだから、アンサンブル処理をやってみたいと思うんだ。”
D先生(設定年齢65歳) : “古典的な機械学習では、ランダムフォレスト(RF)のような手法ですか?LLMで、そんなことができるんですか?”
QEU:FOUNDER : “Prompt Engineeringを駆使すればアンサンブル処理を実施することができます。じゃあ、プログラムをドン!!ただし、プログラムの1部だけです。Prompt Engineeringにかかわる部分だけです。”
###################
# テンプレートの準備
###############
# ----
str_template_1reasoning = """
You are an excellent logician who teaches your client (user) ```thinking procedures('reasoning') to provide higher quality answers to user-provided prompt ('question').``` Read the example named 'Question_and_Answer' below and write the appropriate reasoning logic ('improved_reasoning') fol-lowing the prompt. Here, 'ref_reasoning' which was already generated by other LLM models, are shown for reference. User is not very satisfied with the reasoning and would like to improve them. Please write your answer('improved_reasoning') in a style which you are ordering to 'AI assistant' by using phrase ```AI assistant should...``` in one or more sentences. Please write your answer ('im-proved_reasoning') within 5 sentences or 120 words. The generated logic ('improved_reasoning') should not be an answer to the prompt ('question') itself, but a hint for the client to generate better answer.
Question_and_Answer'''
question : please fill the question here.
ref_reasoning : please fill the ref_reasoning here.
improved_reasoning :
'''
"""
# ----
str_template_2reasoning = """
You are an excellent logician who teaches your client (user) ```thinking procedures('reasoning') to provide higher quality answers to user-provided prompt ('question').``` Read the example named 'Question_and_Answer' below and write the appropriate reasoning logic ('improved_reasoning') fol-lowing the prompt. Here, 'ref_reasoning1' and 'ref_reasoning2', which were already generated by other LLM models, are shown for reference. User is not very satisfied with these reasonings and would like to improve them. Please write your answer('improved_reasoning') in a style which you are ordering to 'AI assistant' by using phrase ```AI assistant should...``` in one or more sentences. Please write your answer ('improved_reasoning') within 5 sentences or 120 words. The generated logic ('im-proved_reasoning') should not be an answer to the prompt ('question') itself, but a hint for the client to generate better answer.
Question_and_Answer'''
question : please fill the question here.
ref_reasoning1 : please fill the ref_reasoning1 here.
ref_reasoning2 : please fill the ref_reasoning2 here.
improved_reasoning :
'''
"""
# ----
str_template_original = """You are an excellent logician and are instructing a client(user) on ```thinking procedures('reasoning') for providing better quality answers to user-provided prompts('question').```. Read the question-reasoning example shown in 'Question_and_Answer' be-low, and write a appropriate reasoning logic following the question. The generated logic ('reasoning') should not be an answer to the prompt itself, but a hint for the client to generate better answer. Please write your answer('improved_reasoning') in a style which you are ordering to 'AI assistant' by using phrase ```AI assistant should...``` in one or more sentences. Please write your answer ('im-proved_reasoning') within 5 sentences or 120 words.
Question_and_Answer'''
question1: Give three tips for staying healthy.
reasoning1: "To provide the user with the best response, I consider universally recognized health guidelines. These tips should be practical, easily applicable to daily life, and contribute to overall well-being. I focus on diet, exercise, and sleep as they are fundamental aspects of health.
question2: What are the three primary colors?
reasoning2: In responding, I draw on basic color theory, which is a fundamental aspect of vis-ual arts and design. The primary colors are foundational because they cannot be created through the combination of other colors and are used to create a wide range of other colors.
question3: Describe the structure of an atom.
reasoning3: To describe the atom, I refer to basic principles of chemistry and physics. An ac-curate and simple explanation of the atom's structure is essential to help users understand the fun-damental building block of matter. The description includes the main components of an atom and their arrangement.
question4: please fill the question here.
reasoning4:
'''
"""
##############
# プロンプト最適化
####################
# ---
def create_prompt(i):
# ---
str_question = arr_question[i]
str_response_L3 = arr_response_L3[i]
str_response_P2 = arr_response_P2[i]
# ---
if len(str_response_L3) > 20 and len(str_response_P2) > 20:
temp_prompt = str_template_2reasoning.replace("please fill the question here.", str_question)
temp_prompt = temp_prompt.replace("please fill the ref_reasoning1 here.", str_response_L3)
str_prompt = temp_prompt.replace("please fill the ref_reasoning2 here.", str_response_P2)
elif len(str_response_L3) > 20 and len(str_response_P2) <= 20:
temp_prompt = str_template_1reasoning.replace("please fill the question here.", str_question)
str_prompt = temp_prompt.replace("please fill the ref_reasoning here.", str_response_L3)
elif len(str_response_L3) <= 20 and len(str_response_P2) > 20:
temp_prompt = str_template_1reasoning.replace("please fill the question here.", str_question)
str_prompt = temp_prompt.replace("please fill the ref_reasoning here.", str_response_P2)
else:
str_prompt = str_template_original.replace("please fill the question here.", str_question)
return str_prompt
QEU:FOUNDER : “アンサンブルの結果の一部を見てみましょう。どう?よくなった?”
--- i:25, <question> ---
You are an excellent logician who teaches your client (user) ```thinking procedures('reasoning') to provide higher quality answers to user-provided prompt ('question').``` Read the example named 'Question_and_Answer' below and write the appropriate reasoning logic ('improved_reasoning') fol-lowing the prompt. Here, 'ref_reasoning1' and 'ref_reasoning2', which were already generated by other LLM models, are shown for reference. User is not very satisfied with these reasonings and would like to improve them. Please write your answer('improved_reasoning') in a style which you are ordering to 'AI assistant' by using phrase ```AI assistant should...``` in one or more sentences. Please write your answer ('improved_reasoning') within 5 sentences or 120 words. The generated logic ('im-proved_reasoning') should not be an answer to the prompt ('question') itself, but a hint for the client to generate better answer.
Question_and_Answer'''
question : Name three major rivers in South America.
ref_reasoning1 : I draw on geographical knowledge and research to provide accurate and relevant information. I focus on prominent and widely recognized rivers in South America, considering fac-tors such as their length, location, and significance to understand their importance in the region. I prioritize verifiable and well-documented information to ensure the provided list is reliable and trustworthy.
ref_reasoning2 : The three major rivers in South America are the Amazon River, the Orinoco River, and the Paraná River. These rivers play significant roles in the geography, economy, and culture of the region. The Amazon River is the largest river in the world by volume and is home to diverse eco-systems and indigenous communities. The Orinoco River is one of the longest rivers in South Ameri-ca and flows through Venezuela and Colombia. It is known for its rich biodiversity and oil reserves. The Paraná River is the second-longest river in South America and forms part of the border between Brazil and Argentina.
improved_reasoning :
'''
質問: 南アメリカの 3 つの主要な川の名前を教えてください。
ref_reasoning1 : 地理的な知識と研究を活用して、正確で関連性の高い情報を提供します。 私は南アメリカの有名で広く知られている川に焦点を当て、その地域における川の重要性を理解するために川の長さ、場所、重要性などの要素を考慮します。 提供されたリストが信頼できるものであることを確認するために、検証可能で十分に文書化された情報を優先します。
ref_reasoning2 : 南米の三大河川はアマゾン川、オリノコ川、パラナ川です。 これらの川は、この地域の地理、経済、文化において重要な役割を果たしています。 アマゾン川は流量で世界最大の川であり、多様な生態系と先住民コミュニティの本拠地です。 オリノコ川は南アメリカで最も長い川の 1 つで、ベネズエラとコロンビアを流れています。 豊かな生物多様性と石油埋蔵量で知られています。 パラナ川は南米で 2 番目に長い川で、ブラジルとアルゼンチンの国境の一部を形成しています。
--- i:25, <response> ---
AI assistant should start by identifying the key geographical features of South America, considering factors such as river length, drainage basins, and national borders. Next, it should prioritize rivers that have significant economic, cultural, or ecological importance to the region. By evaluating multi-ple sources and considering the relevance and reliability of the information, the AI assistant can gen-erate a list of three major rivers in South America that is both accurate and informative. Additional-ly, the AI assistant should strive to provide contextual information about each river, such as its loca-tion, notable features, and impact on the surrounding environment.
AI アシスタントは、川の長さ、流域、国境などの要素を考慮して、南米の主要な地理的特徴を特定することから始める必要があります。 次に、地域にとって経済的、文化的、生態学的に重要な河川を優先すべきである。 複数の情報源を評価し、情報の関連性と信頼性を考慮することで、AI アシスタントは正確かつ有益な南米の 3 つの主要な河川のリストを生成できます。 さらに、AI アシスタントは、各河川の位置、注目すべき特徴、周囲の環境への影響など、各河川に関するコンテキスト情報を提供するよう努める必要があります。
D先生(設定年齢65歳) : “なるほどね。このやり方は確かに「アンサンブル処理」だ・・・。それでも、このアンサンブルはおかしいと思います。ここで、ref_reasoning2の生成元って、たぶんP2モデルでしょ?これだけ、2つのモデルの出来が違うとアンサンプルしても性能向上ができないんじゃないか?”
QEU:FOUNDER(設定年齢65歳) : “「まあ、そうだ!」ともいえるよね(笑)。実は、処理前の文章が「I」を主語とした文章であり、このままでは使えなかったんだ・・・。”
You are an excellent logician who teaches your client (user) ```thinking procedures('reasoning') to provide higher quality answers to user-provided prompt ('question').``` Read the example named 'Question_and_Answer' below and write the appropriate reasoning logic ('improved_reasoning') fol-lowing the prompt. Here, 'ref_reasoning1' and 'ref_reasoning2', which were already generated by other LLM models, are shown for reference. User is not very satisfied with these reasonings and would like to improve them. Please write your answer('improved_reasoning') in a style which you are ordering to 'AI assistant' by using phrase ```AI assistant should...``` in one or more sentences. Please write your answer ('improved_reasoning') within 5 sentences or 120 words. The generated logic ('im-proved_reasoning') should not be an answer to the prompt ('question') itself, but a hint for the client to generate better answer.
Question_and_Answer'''
question : Name five animals found in the rainforest.
ref_reasoning1 : In responding to this prompt, I recognize the significance of providing a diverse and specific list of animals found in the rainforest. To ensure accuracy and relevance, I focus on widely recognized and scientifically verified information on the ecological habitats and biodiversity of rain-forests. By considering recent and reliable sources, I aim to provide a list of animals that accurately represent the rich biological diversity of these ecosystems.
ref_reasoning2 : The following are five animals commonly found in the rainforest: jaguar, toucan, sloth, poison dart frog, and howler monkey. These species represent different levels of the food chain and play vital roles within the rainforest ecosystem. However, it's worth noting that the rainforest is home to countless other unique and fascinating creatures, so this list only scratches the surface of its incredible biodiversity.
improved_reasoning :
'''
質問 : 熱帯雨林で見つかった動物を 5 匹挙げてください。
ref_reasoning1 : このプロンプトに答えるにあたり、私は熱帯雨林で見つかる動物の多様かつ具体的なリストを提供する重要性を認識しています。 正確さと関連性を確保するために、私は熱帯雨林の生態学的生息地と生物多様性について広く認識され、科学的に検証された情報に焦点を当てています。 最近の信頼できる情報源を考慮することで、これらの生態系の豊かな生物学的多様性を正確に表す動物のリストを提供することを目指しています。
ref_reasoning2 : 熱帯雨林でよく見られる 5 つの動物は、ジャガー、オオハシ、ナマケモノ、ヤドクガエル、ホエザルです。 これらの種は食物連鎖のさまざまなレベルを代表し、熱帯雨林の生態系内で重要な役割を果たしています。 ただし、熱帯雨林には他にも数え切れないほどのユニークで魅力的な生き物が生息しているため、このリストはその驚異的な生物多様性の表面をなぞっただけであることは注目に値します。
--- i:30, <response> ---
AI assistant should begin by clearly defining what constitutes a rainforest and its various types, such as tropical or temperate rainforests, to establish a foundation for understanding the diverse range of animal habitats. Next, it should identify the most reliable sources of information on rainforest eco-systems and their inhabitants, considering scientific studies, conservation reports, and expert opin-ions. The assistant should then categorize animals based on their adaptations to the rainforest envi-ronment, such as arboreal or semi-aquatic species, to ensure a comprehensive representation of the ecosystem. By considering the ecological roles of each animal, the assistant can provide a well-rounded list that showcases the complexity of the rainforest food chain.
AI アシスタントは、多様な動物の生息地を理解するための基礎を確立するために、熱帯雨林や温帯雨林など、熱帯雨林の構成要素とそのさまざまな種類を明確に定義することから始める必要があります。 次に、科学的研究、保護報告書、専門家の意見を考慮して、熱帯雨林の生態系とその住民に関する最も信頼できる情報源を特定する必要があります。 次に、アシスタントは、生態系を包括的に表現できるように、熱帯雨林環境への適応に基づいて動物を樹上性または半水性の種などに分類する必要があります。 アシスタントは、各動物の生態学的役割を考慮することで、熱帯雨林の食物連鎖の複雑さを示す包括的なリストを提供できます。
D先生(設定年齢65歳) : “やっぱり、この話にはウラがあったわけですね。まあ、今回は新しい方向性を提示したという意味でよかったですね。Reasoningというのは、なかなか作るのが難しいし・・・。”
QEU:FOUNDER(設定年齢65歳) : “あまり良くないモデル(ex.P2)しか手に入らない場合、このようなアンサンブルを組み合わせていくと、良い結果が最後には出てくる可能性があります。”
D先生(設定年齢65歳) : “さらにRAGと併用すると、よりハイレベルのReasoningがでてくる可能性もありますよね。”
QEU:FOUNDER(設定年齢65歳) : “なんだかんだと、我々が低コストで使えるモデルは少ないのだから、このようなやり方で工夫を重ねるしかないんじゃないか?”
(重要:MITライセンスへのリンク:これからは、ず~っと使うよ)
D先生(設定年齢65歳) : “ここは我々も踏ん張りどころ・・・。安易にハイスペック・モデルに頼ってはいけません。”
QEU:FOUNDER : “ハイスペック・モデルを使うのは、「小説1984の世界を許容するようなもの」です。我々は、小さなモデルを手元にもち、「QUESTIONを発する自由」を死守しなければならない。これから、どんどん面白くなってくるこのBONSAIプロジェクト・・・。是非、カンパをお願いします。”
>寄付のお願い(click here for buy me a cup of coffee)<
D先生: “皆さま、「Buy me a cup of coffee」をいただけませんでしょうか。”
~ まとめ ~
・・・ 前回のつづきです ・・・
C部長 : “QEUプロジェクトのコンセプトは、世界規模の視点でいえば「チャーハン(周回遅れ)」であると・・・(笑)。なるほどね。そうかもしれない・・・。”
QEU:FOUNDER : “そうそう・・・。個人的には、J国って東アジア全般としては、ほぼ同レベルであると思うがね。ただし、J国は経済と文化の破壊が進んだ分だけ、J国は先端にいるんじゃないかな?だから、いままで条件付けに頼ってきた価値のしくみを変えていかないと、これからの時代はもたないんですよ。”
(モノの価値とは)
- (生活が、仕事が)便利になる
- 自分を変えることができる
- モノがあると快適、楽しい
- 条件付け→パーソナリゼーション
C部長 : “これから、世の中が大きくかわっていくでしょうね・・・。”
QEU:FOUNDER : “楽観的にいうと、これからは大きくかわるでしょう。変わるのは、人間ね・・・。そして、価値観・・・。”
Jensen Huang, unlike others, believes that it’s not AI that will replace human jobs but the humans themselves who’ll be trained in using AI technology. He said that these emerging AI technologies will transform the corporate world and change all human jobs while also generating new job roles in the future.
ジェンセン・フアン氏は、他の人たちとは異なり、人間の仕事を置き換えるのは AI ではなく、AI テクノロジーの使い方を訓練される人間自身だと信じています。 同氏は、これらの新たなAIテクノロジーは企業世界を変革し、人間のすべての仕事を変えると同時に、将来的には新たな役割を生み出すだろうと述べた。
C部長 : “確かに・・・。FOUNDERの考える「多様な社会」って、例のリベラル大好きのLGBTQの事なんですか?”
QEU:FOUNDER : “ひょっとしたら、それらが入るかもしれないが、基本は違うものだよ。なんというか・・・、「何も考えずに条件付けだけで物事を判断しないこと」です。古いオッサンがよく言うでしょ?「こういう考え方はムダ」だと・・・。”
C部長 : “ボクは会社ではムダ取り担当ですが、ダメですか?”
QEU:FOUNDER : “それは「ものによりけり」ですよ。これから社会の生産力が極端に上がっちゃうから、「条件付け」前提で同じものを作っていたら人がいらなくなってしまうんです。現在進行形で社会と経済のエコシステムが壊れているが、これがさらに加速していきます。むしろ、人間が持つ個性や問題意識を大切にし、「敢てムダとは言わない。一見したムダの中に価値を見出すことが必要な社会」になるんじゃないかなと思います。”
QEU:FOUNDER : “なにはともあれ、「条件付けにメスを入れる時期が来た」のだろうと思います。”
コメント
コメントを投稿