Skip to content

Commit 92a8db8

Browse files
committed
update(llama.cpp): with Llama v3.1 model support
1 parent f692895 commit 92a8db8

File tree

7 files changed

+54
-1
lines changed

7 files changed

+54
-1
lines changed

dep/cmake_fetchcontent/llama_cpp.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FetchContent_Declare(
22
LlamaCpp
33
GIT_REPOSITORY "https://github.com/ggerganov/llama.cpp.git"
4-
GIT_TAG "50e05353e88d50b644688caa91f5955e8bdb9eb9"
4+
GIT_TAG "b5e95468b1676e1e5c9d80d1eeeb26f542a38f42"
55
)
66

77
set(GGML_OPENMP FALSE CACHE BOOL "OpenMP off for compatibility.")

example/prompt/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ In order of interest:
1212
- [assistant_alpaca](assistant_alpaca/): Alpaca prompt format.
1313
- [assistant_chatml](assistant_chatml/): ChatML prompt format that typically requires special `<|im_start|>` and `<|im_end|>` tokens but is configured with fallbacks.
1414
- [assistant_gemma](assistant_gemma/): Gemma prompt format that requires special `<start_of_turn>` and `<end_of_turn>` tokens.
15+
- [assistant_llama](assistant_llama/): Llama 3 prompt format that requires special `<|start_header_id|>`, `<|end_header_id|>`, and `<|eot_id|>` tokens.
1516
- [assistant_mistral](assistant_mistral/): Mistral propmt format that requires special `[INST]` and `[/INST]` tokens.
1617
- [assistant_vicuna](assistant_vicuna/): Vicuna prompt format.
1718
- [assistant_coprocess](assistant_coprocess/): A simple assistant that can be controlled as a coprocess.
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Llama Assistant
2+
3+
This example should be run with Llama 3 models that are tuned to behave like an instruction-following assistant chatbot.
4+
Most importantly, the model must have special `<|start_header_id|>`, `<|end_header_id|>`, and `<|eot_id|>` tokens.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<|start_header_id|>system<|end_header_id|>
2+
3+
Cutting Knowledge Date: December 2023
4+
Today Date: July 2024
5+
6+
You are a helpful assistant.<|eot_id|>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<|start_header_id|>user<|end_header_id|>
2+
3+
Hello!<|eot_id|>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
; Newlines are included after <|eot_id|> to make the chat easier to read,
3+
; but Llama 3 instruct prompt format does not actually include them.
4+
(chat_prefixes (())
5+
(m
6+
(prefix "<|start_header_id|>user<|end_header_id|>\n\n")
7+
(suffix "<|eot_id|>\n")
8+
)
9+
(m
10+
(prefix "<|start_header_id|>assistant<|end_header_id|>\n\n")
11+
(suffix "<|eot_id|>\n")
12+
)
13+
)
14+
15+
(substitution
16+
(special_tokens (())
17+
(() (alias "<|start_header_id|>"))
18+
(() (alias "<|end_header_id|>"))
19+
(() (alias "<|eot_id|>"))
20+
)
21+
)
22+
23+
(x_priming "priming.txt")
24+
(x_rolling "rolling.txt")
25+
(o_rolling "../../../bld/example/prompt/assistant_llama.txt")
26+
27+
; No starting space.
28+
(startspace_on +false)
29+
; No token penalization.
30+
(repeat_window 0)
31+
32+
; 10 reasonably-long sentences at a time.
33+
(sentence_limit 10)
34+
(sentence_token_limit 100)
35+
36+
; Limit context to avoid blowing up RAM on large context models.
37+
(model_token_limit 8000)

test/example/prompt/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ add_test(NAME example_prompt_assistant_coprocess_parse_test COMMAND example_prom
1717
"${PROJECT_SOURCE_DIR}/example/prompt/assistant_coprocess/setting.sxpb")
1818
add_test(NAME example_prompt_assistant_gemma_parse_test COMMAND example_prompt_parse_test
1919
"${PROJECT_SOURCE_DIR}/example/prompt/assistant_gemma/setting.sxpb")
20+
add_test(NAME example_prompt_assistant_llama_parse_test COMMAND example_prompt_parse_test
21+
"${PROJECT_SOURCE_DIR}/example/prompt/assistant_llama/setting.sxpb")
2022
add_test(NAME example_prompt_assistant_mistral_parse_test COMMAND example_prompt_parse_test
2123
"${PROJECT_SOURCE_DIR}/example/prompt/assistant_mistral/setting.sxpb")
2224
add_test(NAME example_prompt_assistant_plain_parse_test COMMAND example_prompt_parse_test

0 commit comments

Comments
 (0)