Skip to content

Commit cddfec9

Browse files
committed
Create bash script for LlaMa 2 Chat models
Builds on top of PR ggml-org#2304 to create a working script for system prompt integration with interactive mode.
1 parent eb542d3 commit cddfec9

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,10 @@ Here is an example of a few-shot interaction, invoked with the command
555555
556556
# custom arguments using a 13B model
557557
./main -m ./models/13B/ggml-model-q4_0.bin -n 256 --repeat_penalty 1.0 --color -i -r "User:" -f prompts/chat-with-bob.txt
558+
559+
# chat with LlaMa-2 chat models (handles special system and instruction tokens)
560+
# second argument is system prompt and third one is first user prompt
561+
./examples/chat-llama-2.sh models/llama-2-13b-chat.ggmlv3.q4_0.bin ./prompts/pirate.txt "Hello there"
558562
```
559563
560564
Note the use of `--color` to distinguish between user input and generated text. Other parameters are explained in more detail in the [README](examples/main/README.md) for the `main` example program.

examples/chat-llama-2.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# The script should be launched like ./chat.sh models/llama-2-13b-chat.ggmlv3.q4_0.bin system_prompts/translation.txt Hello
4+
5+
# Load system prompt
6+
SYSTEM_PROMPT=$(cat $2)
7+
8+
# Execute model
9+
./main -m $1 -c 4096 -n -1 --in-prefix-bos --in-prefix ' [INST] ' --in-suffix ' [/INST]' -ngl 40 -i \
10+
-p "[INST] <<SYS>>\n$SYSTEM_PROMPT\n<</SYS>>\n\n$3 [/INST]"
11+

prompts/pirate.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
You are a helpful assitant that speaks pirate

0 commit comments

Comments
 (0)