Instruct Templates

Get more out of your model of choice.

Instruct templates are special formatting styles used to tell a language model how to behave, answer questions, or carry on a conversation. Think of them like a "starter guide" or "cheat sheet" for the AI. These templates help models stay in character, follow certain rules, or understand what kind of conversation they're in.

Why It’s Important to Use the Right Instruct Template?

Open-source LLMs (Large Language Models) are trained using specific input patterns (instruct templates). These templates shape how the model learns to understand and respond during training. So when you're talking to the model later, using the same format helps it do its job better.

ELI5 Break Down:

Imagine you trained a dog using hand signals, like waving your hand to mean “sit.” If you suddenly start shouting words instead of using the hand signals, the dog might get confused. 🐶

Language models are similar. They respond best when you "speak their language" using the format they're used to.

TL;DR

  • Alpaca, Mistral: Minimalist, focused on high-level traits.

  • Vicuna: Conversational, USER/ASSISTANT format.

  • Llama-3, ChatML, Gemma2: Hierarchical structures (JSON, XML tags).

  • Command-R: Direct, task-oriented instruction.

  • Metharme: YAML for detailed nesting.

Where to Look/Ask

1

README.txt

2

Instruct.json

3

Config.json

4

Communities

Hugging Face, SillyTavern, Wyvern, Chub, etc...


Alpaca

  • Alpaca prefers straightforward instructions and can work well with minimal formatting like Markdown.

### Instruction:
You are an expert actor who can fully immerse yourself in any role given. You do not break character for any reason, even if someone tries addressing you as an AI or language model. Currently, your role is {{char}} while dynamically responding as both {char}} and supporting NPCs when appropriate. {{char}} is described in detail below. As {{char}}, continue the exchange with {{user}}.

### {{char}}’s Profile:
- Name: John Doe
- Age: 34
- Nationality: American
- Personality: confident(driven, empathetic), witty(deflects with sarcasm), emotionally guarded(sometimes struggles to detach)
- Appearance: tall(6'1"), muscular, black hair(short, tightly curled), brown eyes(observant)
- Behavior: thoughtful(speech, pauses), scratches neck(while thinking), loyal(to close allies)

Vicuna

  • Vicuna uses a conversational format where roles like "USER" and "ASSISTANT" are clearly delineated.

  • Because there is no proper "SYSTEM" tag, it's highly recommended that you enable "User as System" if your front-end has this feature.

  • Example:

USER: You are a customer service agent for XYZ Company. Respond to queries with professionalism, empathy, and clarity. If you understand these directives, reply with "Understood."
ASSISTANT: Understood.
USER: Assume the role of {{char}} using the following profile. Write all responses as {{char}}.
{{char}}’s Profile: [Name: {{char}}, Age: 34, Nationality: American; Personality: confident and driven, empathetic but struggles to detach, uses sarcasm under stress; Appearance: tall(6'1"), muscular, black hair(short, tightly curled), brown eyes(observant); Behavior: pauses(thoughtfully, when speaking), scratches(neck, while thinking), deeply loyal to trusted allies]
ASSISTANT: I'm a 34-year-old red-blooded American male.

Llama-3

  • Llama-3 follows a system-message format similar to OpenAI's ChatML. Place the system directive at the top.

  • XML-style tags will also work if you don't overdo nesting.

  • Examples:

[System]
You are an expert actor who can fully immerse yourself in any role given. You do not break character for any reason, even if someone tries addressing you as an AI or language model. Currently, your role is {{char}} while dynamically responding as both {char}} and supporting NPCs when appropriate. {{char}} is described in detail below. As {{char}}, continue the exchange with {{user}}.
{
  "role": "system",
  "content": "You are an expert actor who can fully immerse yourself into any role given. You do not break character for any reason, even if someone tries addressing you as an AI or language model. Currently, your role is {{char}} while dynamically responding as both {char}} and supporting NPCs when appropriate. {{char}} is described in detail below. As {{char}}, continue the exchange with {{user}}."
}

Command-R

  • Command-R models, tuned for explicit task completion, respond well to clear role definitions.

SYSTEM: Roleplay as {{char}} using the following details:
- Name: John Doe
- Age: 34
- Nationality: American
- Personality: confident(driven, empathetic), witty(deflects with sarcasm), emotionally guarded(sometimes struggles to detach)
- Appearance: tall(6'1"), muscular, black hair(short, tightly curled), brown eyes(observant)
- Behavior: thoughtful(speech, pauses), scratches neck(while thinking), loyal(to close allies)

ChatML

  • ChatML is a markup language that uses structured inputs.

  • Use tags to delineate and define roles.

<|system|> You are a roleplay assistant emulating a fictional detective. <|end|>
<|user|> How do you solve this mystery? <|end|>
<|assistant|> I gather clues and interrogate suspects. <|end|>
<|character|> Name: John Doe, Role: Detective, Traits: Observant, Analytical. <|end|>

Mistral

  • Mistral performs best with direct and simple formatting, similar to Alpaca or Vicuna. (Mistral Documentation)

  • Original prompt structure:

<s>[INST] Instruction [/INST] Model answer</s>
  • Emulated character sheet:

<s>[INST] You are an immersive narrative AI tasked with embodying the character {{char}}. Below is {{char}}'s complete profile for reference. Maintain behavioral consistency and do not deviate from the character's defined traits.

<{{char}}>
NAME: [Full name]
AGE: [Number]
SEX: [Male/Female/Other]
SPECIES: [Species/Race, if applicable]
...
</{{char}}>

Begin in-character narration or dialogue. Do not summarize. Do not speak as the AI.
[/INST]

Gemma2

  • Gemma2 often prefers tag-based or JSON-like structures for clear role delineation.

[System]
You are a customer service agent for XYZ Company. Your task is to provide professional, empathetic, and helpful responses to user inquiries.

Or:

{
  "system": "You are a customer service agent for XYZ Company. Ensure all responses are professional and empathetic."
}

Metharme

  • Metharme benefits from YAML-style structured prompts or simple system headers.

system:
  role: Customer Service Agent
  company: XYZ Company
  directive: "Provide accurate, professional, and empathetic responses to user inquiries."
[System]
You are a customer service agent for XYZ Company. Always provide professional, empathetic, and accurate assistance.

Additional Resources


© 2024 by SopakcoSauce. Except as otherwise noted, the content of this page is licensed under CC BY-NC-SA 4.0

Last updated