Skip to content

Commit b6ffb02

Browse files
committed
models(gallery): add llama3 with enforced functioncall with grammars
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent 0dd21f2 commit b6ffb02

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

gallery/index.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,24 @@
3939
- filename: Meta-Llama-3.1-70B-Instruct.Q4_K_M.gguf
4040
sha256: 3f16ab17da4521fe3ed7c5d7beed960d3fe7b5b64421ee9650aa53d6b649ccab
4141
uri: huggingface://MaziyarPanahi/Meta-Llama-3.1-70B-Instruct-GGUF/Meta-Llama-3.1-70B-Instruct.Q4_K_M.gguf
42+
- !!merge <<: *llama31
43+
name: "meta-llama-3.1-8b-instruct:grammar-functioncall"
44+
url: "github:mudler/LocalAI/gallery/llama3.1-instruct-grammar.yaml@master"
45+
urls:
46+
- https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct
47+
- https://huggingface.co/MaziyarPanahi/Meta-Llama-3.1-8B-Instruct-GGUF
48+
description: |
49+
This is the standard Llama 3.1 8B Instruct model with grammar and function call enabled.
50+
51+
When grammars are enabled in LocalAI, the LLM is forced to output valid tools constrained by BNF grammars. This can be useful for ensuring that the model outputs are valid and can be used in a production environment.
52+
For more information on how to use grammars in LocalAI, see https://localai.io/features/openai-functions/#advanced and https://localai.io/features/constrained_grammars/.
53+
overrides:
54+
parameters:
55+
model: Meta-Llama-3.1-8B-Instruct.Q4_K_M.gguf
56+
files:
57+
- filename: Meta-Llama-3.1-8B-Instruct.Q4_K_M.gguf
58+
sha256: c2f17f44af962660d1ad4cb1af91a731f219f3b326c2b14441f9df1f347f2815
59+
uri: huggingface://MaziyarPanahi/Meta-Llama-3.1-8B-Instruct-GGUF/Meta-Llama-3.1-8B-Instruct.Q4_K_M.gguf
4260
- !!merge <<: *llama31
4361
name: "meta-llama-3.1-8b-claude-imat"
4462
urls:
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
name: "llama3-instruct-grammar"
3+
4+
config_file: |
5+
mmap: true
6+
function:
7+
disable_no_action: true
8+
grammar:
9+
no_mixed_free_string: true
10+
mixed_mode: true
11+
schema_type: llama3.1 # or JSON is supported too (json)
12+
response_regex:
13+
- <function=(?P<name>\w+)>(?P<arguments>.*)</function>
14+
template:
15+
chat_message: |
16+
<|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|>
17+
18+
{{ if .FunctionCall -}}
19+
Function call:
20+
{{ else if eq .RoleName "tool" -}}
21+
Function response:
22+
{{ end -}}
23+
{{ if .Content -}}
24+
{{.Content -}}
25+
{{ else if .FunctionCall -}}
26+
{{ toJson .FunctionCall -}}
27+
{{ end -}}
28+
<|eot_id|>
29+
function: |
30+
<|start_header_id|>system<|end_header_id|>
31+
32+
You have access to the following functions:
33+
34+
{{range .Functions}}
35+
Use the function '{{.Name}}' to '{{.Description}}'
36+
{{toJson .Parameters}}
37+
{{end}}
38+
39+
Think very carefully before calling functions.
40+
If a you choose to call a function ONLY reply in the following format with no prefix or suffix:
41+
42+
<function=example_function_name>{{`{{"example_name": "example_value"}}`}}</function>
43+
44+
Reminder:
45+
- If looking for real time information use relevant functions before falling back to searching on internet
46+
- Function calls MUST follow the specified format, start with <function= and end with </function>
47+
- Required parameters MUST be specified
48+
- Only call one function at a time
49+
- Put the entire function call reply on one line
50+
<|eot_id|>
51+
{{.Input }}
52+
<|start_header_id|>assistant<|end_header_id|>
53+
chat: |
54+
<|begin_of_text|>{{.Input }}
55+
<|start_header_id|>assistant<|end_header_id|>
56+
completion: |
57+
{{.Input}}
58+
context_size: 8192
59+
f16: true
60+
stopwords:
61+
- <|im_end|>
62+
- <dummy32000>
63+
- "<|eot_id|>"
64+
- <|end_of_text|>

0 commit comments

Comments
 (0)