Vezora Suparious commited on
Commit
de4570d
1 Parent(s): 680c9f7

Add alpaca chat template to the Tokenizer (#6)

Browse files

- Add alpaca chat template to the Tokenizer (c15d70465e2fc46c3c4d7fec8fb62f533d4ef09b)


Co-authored-by: Shaun Prince <[email protected]>

Files changed (1) hide show
  1. tokenizer_config.json +1 -0
tokenizer_config.json CHANGED
@@ -27,6 +27,7 @@
27
  "special": true
28
  }
29
  },
 
30
  "additional_special_tokens": [],
31
  "bos_token": "<s>",
32
  "clean_up_tokenization_spaces": false,
 
27
  "special": true
28
  }
29
  },
30
+ "chat_template": "{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% else %}{% set loop_messages = messages %}{% set system_message = false %}{% 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 loop.index0 == 0 and system_message != false %}{% set content = '<<SYS>>\\n' + system_message + '\\n<</SYS>>\\n\\n' + message['content'] %}{% else %}{% set content = message['content'] %}{% endif %}{% if message['role'] == 'user' %}{{ bos_token + '[INST] ' + content.strip() + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ ' ' + content.strip() + ' ' + eos_token }}{% endif %}{% endfor %}",
31
  "additional_special_tokens": [],
32
  "bos_token": "<s>",
33
  "clean_up_tokenization_spaces": false,