Skip to content
Snippets Groups Projects
Commit a6343018 authored by Martin Forell's avatar Martin Forell
Browse files

llama grammar

parent df1aef12
Branches main
No related tags found
No related merge requests found
...@@ -11,10 +11,18 @@ config_file: | ...@@ -11,10 +11,18 @@ config_file: |
parameters: parameters:
model: downloads/llama_backend/Meta-Llama-3.1-8B-Instruct-Q8_0.gguf model: downloads/llama_backend/Meta-Llama-3.1-8B-Instruct-Q8_0.gguf
stopwords:
- <|im_end|>
- <dummy32000>
- <|eot_id|>
- <|end_of_text|>
template: template:
chat: |
<|begin_of_text|>{{.Input }}
<|start_header_id|>assistant<|end_header_id|>
chat_message: | chat_message: |
<|start_header_id|>{{if eq .RoleName "assistant"}}assistant{{else if eq .RoleName "system"}}system{{else if eq .RoleName "tool"}}tool{{else if eq .RoleName "user"}}user{{end}}<|end_header_id|> <|start_header_id|>{{if eq .RoleName "assistant"}}assistant{{else if eq .RoleName "system"}}system{{else if eq .RoleName "tool"}}tool{{else if eq .RoleName "user"}}user{{end}}<|end_header_id|>
{{ if .FunctionCall -}} {{ if .FunctionCall -}}
Function call: Function call:
{{ else if eq .RoleName "tool" -}} {{ else if eq .RoleName "tool" -}}
...@@ -26,29 +34,43 @@ config_file: | ...@@ -26,29 +34,43 @@ config_file: |
{{ toJson .FunctionCall -}} {{ toJson .FunctionCall -}}
{{ end -}} {{ end -}}
<|eot_id|> <|eot_id|>
completion: |
{{.Input}}
function: | function: |
<|start_header_id|>system<|end_header_id|> <|start_header_id|>system<|end_header_id|>
You are a function calling AI model. You are provided with function signatures within <tools></tools> XML tags. You may call one or more functions to assist with the user query. Don't make assumptions about what values to plug into functions. Here are the available tools: You have access to the following functions:
<tools>
{{range .Functions}} {{range .Functions}}
{'type': 'function', 'function': {'name': '{{.Name}}', 'description': '{{.Description}}', 'parameters': {{toJson .Parameters}} }} Use the function '{{.Name}}' to '{{.Description}}'
{{toJson .Parameters}}
{{end}} {{end}}
</tools>
Use the following pydantic model json schema for each tool call you will make: Think very carefully before calling functions.
{'title': 'FunctionCall', 'type': 'object', 'properties': {'arguments': {'title': 'Arguments', 'type': 'object'}, 'name': {'title': 'Name', 'type': 'string'}}, 'required': ['arguments', 'name']}<|eot_id|><|start_header_id|>assistant<|end_header_id|> If a you choose to call a function ONLY reply in the following format with no prefix or suffix:
Function call:
chat: | <function=example_function_name>{{`{{"example_name": "example_value"}}`}}</function>
<|begin_of_text|>{{.Input }}
Reminder:
- If looking for real time information use relevant functions before falling back to searching on internet
- Function calls MUST follow the specified format, start with <function= and end with </function>
- Required parameters MUST be specified
- Only call one function at a time
- Put the entire function call reply on one line
<|eot_id|>
{{.Input }}
<|start_header_id|>assistant<|end_header_id|> <|start_header_id|>assistant<|end_header_id|>
completion: | function:
{{.Input}} disable_no_action: true
grammar:
#disable: true
no_mixed_free_string: true
mixed_mode: true
schema_type: llama3.1 # or JSON is supported too (json)
response_regex:
- <function=(?P<name>\w+)>(?P<arguments>.*)</function>
context_size: 8192 context_size: 8192
stopwords:
- <|im_end|>
- <dummy32000>
- "<|eot_id|>"
- <|end_of_text|>
usage: | usage: |
curl http://localhost:8080/v1/chat/completions -H "Content-Type: application/json" -d '{ curl http://localhost:8080/v1/chat/completions -H "Content-Type: application/json" -d '{
"model": "gpt-4", "model": "gpt-4",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment