見出し画像

ローカルLLM の対話で使われてるプロンプト書式まとめ

「ローカルLLM」の対話で使われているプロンプト書式をまとめました。

1. FastChat

「ローカルLLM」の対話で使われているプロンプト書式をまとめました。
「FastChat」のコード内のテンプレートを参考にしています。

2. テンプレートのパラメータ

テンプレートで定義されているパラメータは、次のとおりです。

・system : システムプロンプト
・roles : ロール群 (2種類)
・messages : メッセージ群 (role, message)
・offset : Few-Shot例のオフセット
・sep_style : セパレータ種別
    ・ADD_COLON_SINGLE
    ・ADD_COLON_TWO
    ・NO_COLON_SINGLE
    ・BAIZE
    ・DOLLY
    ・RWKV
・sep : セパレータ
・sep2 : セパレータ2
・stop_str : 停止文字 (デフォルトは EOS トークン)
・stop_token_ids : 停止トークン群

セパレータ種別の書式は、次のとおりです。
表記では、読みやすさ重視で改行してますが、実際に改行されるのは<\n>のみになります。

・ADD_COLON_SINGLE

<system><sep>
<role>: <message><sep>
<role>: <message><sep>
<role>: <message><sep>
<role>:

・ADD_COLON_TWO

<system><sep>
<role>: <message><sep>
<role>: <message><sep2>
<role>: <message><sep>
<role>:

・NO_COLON_SINGLE

<system>
<role><message><sep>
<role><message><sep>
<role><message><sep>
<role>

・BAIZE

<system><\n>
<role><message><\n>
<role><message><\n>
<role><message><\n>
<role>

・DOLLY

<system>
<role>:<\n><message><sep>
<role>:<\n><message><sep2><\n><\n>
<role>:<\n><message><sep>
<role>:<\n>

・RWKV

<system>
<role>: <message><\n><\n>
<role>: <message><\n><\n>
<role>: <message><\n><\n>
<role>:

3. テンプレート

3-1. Vicuna v1.1 テンプレート

# Vicuna v1.1 template
conv_vicuna_v1_1 = Conversation(
    system="A chat between a curious user and an artificial intelligence assistant. "
    "The assistant gives helpful, detailed, and polite answers to the user's questions.",
    roles=("USER", "ASSISTANT"),
    messages=(),
    offset=0,
    sep_style=SeparatorStyle.ADD_COLON_TWO,
    sep=" ",
    sep2="</s>",
)

・system (翻訳)

好奇心旺盛なユーザーと人工知能アシスタントのチャット。
アシスタントは、ユーザーの質問に役立つ、詳細で丁寧な回答を提供します。

・roles

・USER
・ASSISTANT

・sep, sep2

" ", </s>

3-2. Koala デフォルトテンプレート

conv_koala_v1 = Conversation(
    system="BEGINNING OF CONVERSATION:",
    roles=("USER", "GPT"),
    messages=(),
    offset=0,
    sep_style=SeparatorStyle.ADD_COLON_TWO,
    sep=" ",
    sep2="</s>",
)

・system (翻訳)

会話の始まり:

・roles

・USER
・GPT

・sep, sep2

" ", </s>

3-3. Dolly V2 デフォルトテンプレート

# Dolly V2 default template
conv_dolly = Conversation(
    system="Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n",
    roles=("### Instruction", "### Response"),
    messages=(),
    offset=0,
    sep_style=SeparatorStyle.DOLLY,
    sep="\n\n",
    sep2="### End",
)

・system (翻訳)

以下は、タスクを説明する命令です。 要求を適切に完了する応答を作成します。

・roles

・### Instruction
・### Response

・sep, sep2

"\n\n", "### End"

3-4. OpenAssistant Pythia デフォルトテンプレート

conv_oasst = Conversation(
    system="",
    roles=("<|prompter|>", "<|assistant|>"),
    messages=(),
    offset=0,
    sep_style=SeparatorStyle.NO_COLON_SINGLE,
    sep="<|endoftext|>",
)

・roles

・<|prompter|>
・<|assistant|>

・sep

<|endoftext|>

3-5. StableLM Alpha デフォルトテンプレート

conv_stablelm = Conversation(
    system="""<|SYSTEM|># StableLM Tuned (Alpha version)
- StableLM is a helpful and harmless open-source AI language model developed by StabilityAI.
- StableLM is excited to be able to help the user, but will refuse to do anything that could be considered harmful to the user.
- StableLM is more than just an information source, StableLM is also able to write poetry, short stories, and make jokes.
- StableLM will refuse to participate in anything that could harm a human.
""",
    roles=("<|USER|>", "<|ASSISTANT|>"),
    messages=(),
    offset=0,
    sep_style=SeparatorStyle.NO_COLON_SINGLE,
    sep="",
    stop_token_ids=[50278, 50279, 50277, 1, 0],
)

・system (翻訳)

<|SYSTEM|># StableLM Tuned (Alpha版)
- StableLM は、StabilityAI によって開発された、便利で無害なオープンソースの AI 言語モデルです。
- StableLM はユーザーを助けることができることに興奮していますが、ユーザーにとって有害と見なされる可能性のあることは一切拒否します。
- StableLM は単なる情報源ではなく、詩や短編小説を書いたり、冗談を言ったりすることもできます。
- StableLM は、人に害を及ぼす可能性のあるものへの参加を拒否します。

・roles

・<|USER|>
・<|ASSISTANT|>

3-6. Baize デフォルトテンプレート

conv_baize = Conversation(
    system="The following is a conversation between a human and an AI assistant named Baize (named after a mythical creature in Chinese folklore). Baize is an open-source AI assistant developed by UCSD and Sun Yat-Sen University. The human and the AI assistant take turns chatting. Human statements start with [|Human|] and AI assistant statements start with [|AI|]. The AI assistant always provides responses in as much detail as possible, and in Markdown format. The AI assistant always declines to engage with topics, questions and instructions related to unethical, controversial, or sensitive issues. Complete the transcript in exactly that format.",
    roles=("[|Human|]", "[|AI|]"),
    messages=(
        ("[|Human|]", "Hello!"),
        ("[|AI|]", "Hi!"),
    ),
    offset=2,
    sep_style=SeparatorStyle.BAIZE,
    sep="[|Human|]",
    stop_str="[|Human|]",
)

・system (翻訳)

以下は、人間と Baize (中国の民間伝承の神話上の生き物にちなんで名付けられた) という名前の AI アシスタントとの間の会話です。 Baize は、UCSD と中山大学によって開発されたオープンソースの AI アシスタントです。 人間と AI アシスタントが交互にチャットします。 ヒューマン ステートメントは [|Human|] で始まり、AI アシスタント ステートメントは [|AI|] で始まります。 AI アシスタントは常に、可能な限り詳細な応答を Markdown 形式で提供します。 AI アシスタントは、非倫理的、物議を醸す、またはデリケートな問題に関連するトピック、質問、および指示に関与することを常に拒否します。 正確にその形式でトランスクリプトを完成させます。

・roles

・[|Human|]
・[|AI|]

・sep

・[|Human|]

3-7. RWKV-4-Raven デフォルトテンプレート

conv_rwkv = Conversation(
    system="",
    roles=("Bob", "Alice"),
    messages=(),
    offset=0,
    sep_style=SeparatorStyle.RWKV,
    sep="",
    stop_str="\n\n",
)

・roles

・Bob
・Alice



この記事が気に入ったらサポートをしてみませんか?