andstor commited on
Commit
2df34c0
1 Parent(s): 02050fe

Update chat template to handle tools automatically

Browse files
Files changed (1) hide show
  1. tokenizer_config.json +1 -0
tokenizer_config.json CHANGED
@@ -136,6 +136,7 @@
136
  ],
137
  "bos_token": "<|begin▁of▁sentence|>",
138
  "chat_template": "{% set system_message = 'You are an AI assistant for function calling.For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer\\n' %}{% if messages[0]['role'] == 'system' %}{% set system_message = messages[0]['content'] %}{% endif %}{% if system_message is defined %}{{ system_message }}{% endif %}{% for message in messages %}{% set content = message['content'] %}{% if message['role'] == 'user' %}{{ '### Instruction:\\n' + content + '\\n### Response:' }}{% elif message['role'] == 'assistant' %}{{ '\\n' + content + '\\n<|EOT|>\\n' }}{% endif %}{% endfor %}",
 
139
  "clean_up_tokenization_spaces": false,
140
  "eos_token": "<|EOT|>",
141
  "model_max_length": 4096,
 
136
  ],
137
  "bos_token": "<|begin▁of▁sentence|>",
138
  "chat_template": "{% set system_message = 'You are an AI assistant for function calling.For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer\\n' %}{% if messages[0]['role'] == 'system' %}{% set system_message = messages[0]['content'] %}{% endif %}{% if system_message is defined %}{{ system_message }}{% endif %}{% for message in messages %}{% set content = message['content'] %}{% if message['role'] == 'user' %}{{ '### Instruction:\\n' + content + '\\n### Response:' }}{% elif message['role'] == 'assistant' %}{{ '\\n' + content + '\\n<|EOT|>\\n' }}{% endif %}{% endfor %}",
139
+ "chat_template": "{%- set system_message = 'You are an AI assistant for function calling.For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer\\n' %}\n{%- if messages[0]['role'] == 'system' %}\n {%- set system_message = messages[0]['content'] %}\n{%- endif %}\n\n{%- if system_message is defined %}\n {{- system_message }}\n{%- endif %}\n\n{%- for message in messages %}\n {%- set content = message['content'] %}\n {%- if message['role'] == 'user' %}\n {{- '### Instruction:\\n' }}\n {{- '[BEGIN OF TASK INSTRUCTION]\\n' }}\n {{- 'You are an expert in composing functions. You are given a question and a set of possible functions.\\nBased on the question, you will need to make one or more function/tool calls to achieve the purpose.\\nIf none of the functions can be used, point it out and refuse to answer.\\nIf the given question lacks the parameters required by the function, also point it out.' }}\n {{- '\\n[END OF TASK INSTRUCTION]\\n\\n' }}\n\n {{- '[BEGIN OF AVAILABLE TOOLS]\\n' }} \n {{- '[' }}\n {%- for tool in tools %}\n {{- '{\"name\": ' + tool['function']['name'] + ', ' }}\n {{- '\"description\": ' + tool['function']['description'] + ', ' }}\n {{- '\"parameters\": {' }}\n {%- for argument in tool['function']['parameters']['properties'] %}\n {{- '\"' + argument + '\": {\"type\": \"' + tool['function']['parameters']['properties'][argument]['type'] + '\", \"' + tool['function']['parameters']['properties'][argument]['description'] + '\"}' }}\n {{- ', ' if not loop.last else '' }}\n {%- endfor %}\n {{- '}, ' if not loop.last else '}' }}\n {%- endfor %}\n {{- ']' }}\n {{- '\\n[END OF AVAILABLE TOOLS]\\n\\n' }}\n\n {{- '[BEGIN OF FORMAT INSTRUCTION]\\n' }}\n {{- 'The output MUST strictly adhere to the following JSON format, and NO other text MUST be included.\\nThe example format is as follows. Please make sure the parameter type is correct. If no function call is needed, please make tool_calls an empty list \\'[]\\'.\\n```\\n{\\n \"tool_calls\": [\\n {\"name\": \"func_name1\", \"arguments\": {\"argument1\": \"value1\", \"argument2\": \"value2\"}},\\n ... (more tool calls as required)\\n ]\\n}\\n```' }}\n {{- '\\n[END OF FORMAT INSTRUCTION]\\n\\n' }}\n\n {{- '[BEGIN OF QUERY]\\n' + content + '\\n[END OF QUERY]\\n\\n' }}\n {{- '\\n### Response:' }}\n {%- elif message['role'] == 'assistant' %}\n {{- '\\n' + content + '\\n<|EOT|>\\n' }}\n {%- endif %}\n{%- endfor %}",
140
  "clean_up_tokenization_spaces": false,
141
  "eos_token": "<|EOT|>",
142
  "model_max_length": 4096,