-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minja
: generate chat goldens w/ fixed date to support Llama-3.2-3B-…
…Instruct (uses strftime_now)
- Loading branch information
Showing
5 changed files
with
236 additions
and
1 deletion.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
tests/chat/goldens/meta-llama-Llama-3.2-3B-Instruct-simple.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<|startoftext|><|start_header_id|>system<|end_header_id|> | ||
|
||
Cutting Knowledge Date: December 2023 | ||
Today Date: 26 Jul 2024 | ||
|
||
<|eot_id|><|start_header_id|>user<|end_header_id|> | ||
|
||
What's your favourite LLM framework?<|eot_id|><|start_header_id|>assistant<|end_header_id|> | ||
|
||
llama.cpp!<|eot_id|><|start_header_id|>assistant<|end_header_id|> | ||
|
11 changes: 11 additions & 0 deletions
11
tests/chat/goldens/meta-llama-Llama-3.2-3B-Instruct-system.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<|startoftext|><|start_header_id|>system<|end_header_id|> | ||
|
||
Cutting Knowledge Date: December 2023 | ||
Today Date: 26 Jul 2024 | ||
|
||
You only tell the truth.<|eot_id|><|start_header_id|>user<|end_header_id|> | ||
|
||
What's your favourite LLM framework?<|eot_id|><|start_header_id|>assistant<|end_header_id|> | ||
|
||
llama.cpp!<|eot_id|><|start_header_id|>assistant<|end_header_id|> | ||
|
116 changes: 116 additions & 0 deletions
116
tests/chat/goldens/meta-llama-Llama-3.2-3B-Instruct-tool_use.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<|startoftext|><|start_header_id|>system<|end_header_id|> | ||
|
||
Environment: ipython | ||
Cutting Knowledge Date: December 2023 | ||
Today Date: 26 Jul 2024 | ||
|
||
<|eot_id|><|start_header_id|>user<|end_header_id|> | ||
|
||
Given the following functions, please respond with a JSON for a function call with its proper arguments that best answers the given prompt. | ||
|
||
Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.Do not use variables. | ||
|
||
{ | ||
"type": "function", | ||
"function": { | ||
"name": "ipython", | ||
"description": "Runs code in an ipython interpreter and returns the result of the execution after 60 seconds.", | ||
"parameters": { | ||
"type": "object", | ||
"properties": { | ||
"code": { | ||
"type": "string", | ||
"description": "The code to run in the ipython interpreter." | ||
} | ||
}, | ||
"required": [ | ||
"code" | ||
] | ||
} | ||
} | ||
} | ||
|
||
{ | ||
"type": "function", | ||
"function": { | ||
"name": "brave_search", | ||
"description": "Executes a web search with Brave.", | ||
"parameters": { | ||
"type": "object", | ||
"properties": { | ||
"query": { | ||
"type": "string", | ||
"description": "The query to search for." | ||
} | ||
}, | ||
"required": [ | ||
"query" | ||
] | ||
} | ||
} | ||
} | ||
|
||
{ | ||
"type": "function", | ||
"function": { | ||
"name": "wolfram_alpha", | ||
"description": "Executes a query with Wolfram Alpha.", | ||
"parameters": { | ||
"type": "object", | ||
"properties": { | ||
"query": { | ||
"type": "string", | ||
"description": "The query to execute." | ||
} | ||
}, | ||
"required": [ | ||
"query" | ||
] | ||
} | ||
} | ||
} | ||
|
||
{ | ||
"type": "function", | ||
"function": { | ||
"name": "test", | ||
"description": "Runs a test.", | ||
"parameters": { | ||
"type": "object", | ||
"properties": { | ||
"condition": { | ||
"type": "boolean", | ||
"description": "The condition to test." | ||
} | ||
}, | ||
"required": [ | ||
"condition" | ||
] | ||
} | ||
} | ||
} | ||
|
||
Print a hello world message with python.<|eot_id|><|start_header_id|>assistant<|end_header_id|> | ||
|
||
{"name": "ipython", "parameters": "{\"code\": \"print('Hello, World!')\"}"}<|eot_id|><|start_header_id|>ipython<|end_header_id|> | ||
|
||
"{\"stdout\": \"Hello, World!\"}"<|eot_id|><|start_header_id|>assistant<|end_header_id|> | ||
|
||
Anything else?<|eot_id|><|start_header_id|>user<|end_header_id|> | ||
|
||
Test a tautology.<|eot_id|><|start_header_id|>assistant<|end_header_id|> | ||
|
||
{"name": "test", "parameters": "{\"condition\":true}"}<|eot_id|><|start_header_id|>ipython<|end_header_id|> | ||
|
||
"true"<|eot_id|><|start_header_id|>assistant<|end_header_id|> | ||
|
||
Truth is definitely true.<|eot_id|><|start_header_id|>user<|end_header_id|> | ||
|
||
Check it on the web.<|eot_id|><|start_header_id|>assistant<|end_header_id|> | ||
|
||
{"name": "brave_search", "parameters": "{\"query\": \"what is truth anyway am I right?\"}"}<|eot_id|><|start_header_id|>ipython<|end_header_id|> | ||
|
||
"{\"title\":\"Truth: don't ask the web, ask an LLM instead!\",\"url\":\"https://en.wikipedia.org/wiki/Truth\"}"<|eot_id|><|start_header_id|>assistant<|end_header_id|> | ||
|
||
I don't need the web to answer you but I did check, as you asked. What now?<|eot_id|><|start_header_id|>assistant<|end_header_id|> | ||
|
93 changes: 93 additions & 0 deletions
93
tests/chat/templates/meta-llama-Llama-3.2-3B-Instruct.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
{{- bos_token }} | ||
{%- if custom_tools is defined %} | ||
{%- set tools = custom_tools %} | ||
{%- endif %} | ||
{%- if not tools_in_user_message is defined %} | ||
{%- set tools_in_user_message = true %} | ||
{%- endif %} | ||
{%- if not date_string is defined %} | ||
{%- if strftime_now is defined %} | ||
{%- set date_string = strftime_now("%d %b %Y") %} | ||
{%- else %} | ||
{%- set date_string = "26 Jul 2024" %} | ||
{%- endif %} | ||
{%- endif %} | ||
{%- if not tools is defined %} | ||
{%- set tools = none %} | ||
{%- endif %} | ||
|
||
{#- This block extracts the system message, so we can slot it into the right place. #} | ||
{%- if messages[0]['role'] == 'system' %} | ||
{%- set system_message = messages[0]['content']|trim %} | ||
{%- set messages = messages[1:] %} | ||
{%- else %} | ||
{%- set system_message = "" %} | ||
{%- endif %} | ||
|
||
{#- System message #} | ||
{{- "<|start_header_id|>system<|end_header_id|>\n\n" }} | ||
{%- if tools is not none %} | ||
{{- "Environment: ipython\n" }} | ||
{%- endif %} | ||
{{- "Cutting Knowledge Date: December 2023\n" }} | ||
{{- "Today Date: " + date_string + "\n\n" }} | ||
{%- if tools is not none and not tools_in_user_message %} | ||
{{- "You have access to the following functions. To call a function, please respond with JSON for a function call." }} | ||
{{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.' }} | ||
{{- "Do not use variables.\n\n" }} | ||
{%- for t in tools %} | ||
{{- t | tojson(indent=4) }} | ||
{{- "\n\n" }} | ||
{%- endfor %} | ||
{%- endif %} | ||
{{- system_message }} | ||
{{- "<|eot_id|>" }} | ||
|
||
{#- Custom tools are passed in a user message with some extra guidance #} | ||
{%- if tools_in_user_message and not tools is none %} | ||
{#- Extract the first user message so we can plug it in here #} | ||
{%- if messages | length != 0 %} | ||
{%- set first_user_message = messages[0]['content']|trim %} | ||
{%- set messages = messages[1:] %} | ||
{%- else %} | ||
{{- raise_exception("Cannot put tools in the first user message when there's no first user message!") }} | ||
{%- endif %} | ||
{{- '<|start_header_id|>user<|end_header_id|>\n\n' -}} | ||
{{- "Given the following functions, please respond with a JSON for a function call " }} | ||
{{- "with its proper arguments that best answers the given prompt.\n\n" }} | ||
{{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.' }} | ||
{{- "Do not use variables.\n\n" }} | ||
{%- for t in tools %} | ||
{{- t | tojson(indent=4) }} | ||
{{- "\n\n" }} | ||
{%- endfor %} | ||
{{- first_user_message + "<|eot_id|>"}} | ||
{%- endif %} | ||
|
||
{%- for message in messages %} | ||
{%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %} | ||
{{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] | trim + '<|eot_id|>' }} | ||
{%- elif 'tool_calls' in message %} | ||
{%- if not message.tool_calls|length == 1 %} | ||
{{- raise_exception("This model only supports single tool-calls at once!") }} | ||
{%- endif %} | ||
{%- set tool_call = message.tool_calls[0].function %} | ||
{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}} | ||
{{- '{"name": "' + tool_call.name + '", ' }} | ||
{{- '"parameters": ' }} | ||
{{- tool_call.arguments | tojson }} | ||
{{- "}" }} | ||
{{- "<|eot_id|>" }} | ||
{%- elif message.role == "tool" or message.role == "ipython" %} | ||
{{- "<|start_header_id|>ipython<|end_header_id|>\n\n" }} | ||
{%- if message.content is mapping or message.content is iterable %} | ||
{{- message.content | tojson }} | ||
{%- else %} | ||
{{- message.content }} | ||
{%- endif %} | ||
{{- "<|eot_id|>" }} | ||
{%- endif %} | ||
{%- endfor %} | ||
{%- if add_generation_prompt %} | ||
{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' }} | ||
{%- endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters