How do I use the chat template in oobabooga/sillytavern/koboldcpp?

#2
by siddhesh22 - opened

Would appreciate if any instructions are provided. Most people cannot run fp16 version of mixtral models and will most likely be running a Q4_K_M quantization.

Chat Template for AetherResearch/Cerebrum-1.0-7b :
"For optimal performance, Cerebrum should be prompted with an Alpaca-style template that requests the description of the "thought process". Here is what a conversation should look like from the model's point of view":

<s> A chat between a user and a thinking artificial intelligence assistant. The assistant describes its thought process and gives helpful and detailed answers to the user's questions.
User: Are you conscious?
AI:

Alpaca-Prompt Format:

{System}
###
Instruction:
{User}
###
Response:
{Assistant}

When in doubt, read the source model's model card, if you can't find the proper prompt format listed there, reach out to the model creator(s)/LLM-community. AetherResearch/Cerebrum-1.0-7b is the source model for this MoE (Mixture of Experts), so it follows the same prompt format as it, which just so happens to be Alpaca-Style. I hope this helps. πŸ€”

It seems to actually be closer to (but not exactly the same as) Vicuna-style, given the User: and AI: formatting, and the Jinja prompt template in tokenizer_config.json (reproduced below after formatting).

{% if messages[0]['role'] == 'system' %}
  {% set loop_messages = messages[1:] %}
  {% set system_message = messages[0]['content'] %}
{% else %}
  {% set loop_messages = messages %}
  {% set system_message = 'A chat between a user and a thinking artificial intelligence assistant. The assistant describes its thought process and gives helpful and detailed answers to the user\'s questions.' %}
{% endif %}

{% for message in loop_messages %}
  {% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}
    {{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}
  {% endif %}

  {% if message['role'] == 'user' %}
    {% set content = 'User: ' + message['content'].strip() + '\n' %}
  {% elif message['role'] == 'system' %}
    {% set content = message['content'].strip() + '\n' %}
  {% elif message['role'] == 'assistant' %}
    {% set content = 'AI: '  + message['content'].strip() + '\n' %}
  {% endif %}

  {% if loop.index0 == 0 %}
    {{ bos_token + system_message + '\n' + content }}
  {% else %}
    {{ content | replace(eos_token, '') }}
  {% endif %}

  {% if loop.last and add_generation_prompt %}
    {{ 'AI:' }}
  {% endif %}
{% endfor %}

So, the actual prompt format is likely just

<s> [system prompt]
User: [user question]
AI: [answer]

as described in the card (unless both the card and the template are wrong somehow).

Sign up or log in to comment