CISCai commited on
Commit
1de4d72
1 Parent(s): 673a424

Updated with a working chat_template

Browse files

After the recent README.md changes and some experimentation I have come up with the following chat_template, which I'm currently using in my [GGUFs](https://huggingface.co/CISCai/gorilla-openfunctions-v2-SOTA-GGUF).

Minor fix for [#3](https://huggingface.co/gorilla-llm/gorilla-openfunctions-v2/discussions/3), now only generates functions in last message to not waste multi-turn context.

Fixes [#2](https://huggingface.co/gorilla-llm/gorilla-openfunctions-v2/discussions/2).

Files changed (1) hide show
  1. tokenizer_config.json +1 -1
tokenizer_config.json CHANGED
@@ -130,7 +130,7 @@
130
  }
131
  },
132
  "bos_token": "<|begin▁of▁sentence|>",
133
- "chat_template": "{% if not add_generation_prompt is defined %}\n{% set add_generation_prompt = false %}\n{% endif %}\n{%- set ns = namespace(found=false) -%}\n{%- for message in messages -%}\n {%- if message['role'] == 'system' -%}\n {%- set ns.found = true -%}\n {%- endif -%}\n{%- endfor -%}\n{{bos_token}}{%- if not ns.found -%}\n{{'You are an AI programming assistant, utilizing the Deepseek Coder model, developed by Deepseek Company, and you only answer questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer\\n'}}\n{%- endif %}\n{%- for message in messages %}\n {%- if message['role'] == 'system' %}\n{{ message['content'] }}\n {%- else %}\n {%- if message['role'] == 'user' %}\n{{'### Instruction:\\n' + message['content'] + '\\n'}}\n {%- else %}\n{{'### Response:\\n' + message['content'] + '\\n<|EOT|>\\n'}}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{% if add_generation_prompt %}\n{{'### Response:'}}\n{% endif %}",
134
  "clean_up_tokenization_spaces": false,
135
  "eos_token": "<|EOT|>",
136
  "legacy": true,
 
130
  }
131
  },
132
  "bos_token": "<|begin▁of▁sentence|>",
133
+ "chat_template": "{% if not add_generation_prompt is defined %}\n{% set add_generation_prompt = false %}\n{% endif %}\n{%- set ns = namespace(found=false, functions=false) -%}\n{%- if tools -%}\n {%- set ns.functions = tools|selectattr('type','eq','function')|map(attribute='function')|list|tojson -%}\n{%- elif functions -%}\n {%- set ns.functions = functions|tojson -%}\n{%- endif -%}\n{%- for message in messages -%}\n {%- if message['role'] == 'system' -%}\n {%- set ns.found = true -%}\n {%- endif -%}\n{%- endfor -%}\n{{bos_token}}{%- if not ns.found -%}\n{{'You are an AI programming assistant, utilizing the Gorilla LLM model, developed by Gorilla LLM, and you only answer questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer.\\n'}}\n{%- endif %}\n{%- for message in messages %}\n {%- if message['role'] == 'system' %}\n{{ message['content'] }}\n {%- else %}\n {%- if message['role'] == 'user' %}\n{{'### Instruction: '}}{% if loop.last and ns.functions %}{{'<<function>>'}}{{ns.functions + '\\n'}}{% endif %}{{'<<question>>' + message['content'] + '\\n'}}\n {%- else %}\n{{'### Response: ' + message['content'] + '\\n{{eos_token}}\\n'}}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{% if add_generation_prompt %}\n{{'### Response: '}}\n{% endif %}",
134
  "clean_up_tokenization_spaces": false,
135
  "eos_token": "<|EOT|>",
136
  "legacy": true,