generated at
guidance
>guidanceを使用すると、従来のプロンプトやチェーンよりも効果的かつ効率的に最新の言語モデルを制御できます。ガイダンス プログラムを使用すると、生成、プロンプト、および論理制御を、言語モデルが実際にテキストを処理する方法に一致する単一の連続フローにインターリーブすることができます。 Chain of Thought やその多くのバリアント (ARTAuto-CoT など) のような単純な出力構造は、LLM のパフォーマンスを向上させることが示されています。 GPT-4 のようなより強力な LLM の出現により、さらに豊富な構造が可能になり、ガイダンスによりその構造が簡単かつ安価になります。

サンプル
Pythonではないけど見やすいので .py で表示
guidance.py
import guidance # set the default language model used to execute guidance programs guidance.llm = guidance.llms.OpenAI("text-davinci-003") # define a guidance program that adapts a proverb program = guidance("""Tweak this proverb to apply to model instructions instead. {{proverb}} - {{book}} {{chapter}}:{{verse}} UPDATED Where there is no guidance{{gen 'rewrite' stop="\\n-"}} - GPT {{gen 'chapter'}}:{{gen 'verse'}}""") # execute the program on a specific proverb executed_program = program( proverb="Where there is no guidance, a people falls,\nbut in an abundance of counselors there is safety.", book="Proverbs", chapter=11, verse=14 )

guidance.py
# connect to a chat model like GPT-4 or Vicuna gpt4 = guidance.llms.OpenAI("gpt-4") # vicuna = guidance.llms.transformers.Vicuna("your_path/vicuna_13B", device_map="auto") experts = guidance(''' {{#system~}} You are a helpful and terse assistant. {{~/system}} {{#user~}} I want a response to the following question: {{query}} Name 3 world-class experts (past or present) who would be great at answering this? Don't answer the question yet. {{~/user}} {{#assistant~}} {{gen 'expert_names' temperature=0 max_tokens=300}} {{~/assistant}} {{#user~}} Great, now please answer the question as if these experts had collaborated in writing a joint anonymous answer. {{~/user}} {{#assistant~}} {{gen 'answer' temperature=0 max_tokens=500}} {{~/assistant}} ''', llm=gpt4) experts(query='How can I be more productive?')