Skip to content

Commit 3ab3e65

Browse files
authored
Add chatLLaMa script (#198)
* Add chatLLaMa script * Fix shellcheck errors and do some cleanup * Move chatLLaMa script to `examples` directory * Reduce chatLLaMa context size to 2048 Ref d7def1a * Include n_predict to 2048 in examples/chatLLaMa
1 parent f157088 commit 3ab3e65

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

examples/chatLLaMa

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
cd "$(dirname "$0")/.." || exit
4+
5+
MODEL="${MODEL:-./models/13B/ggml-model-q4_0.bin}"
6+
USER_NAME="${USER_NAME:-User}"
7+
AI_NAME="${AI_NAME:-ChatLLaMa}"
8+
9+
# Adjust to the number of CPU cores you want to use.
10+
N_THREAD="${N_THREAD:-8}"
11+
# Number of tokens to predict (made it larger than default because we want a long interaction)
12+
N_PREDICTS="${N_PREDICTS:-2048}"
13+
14+
# Note: you can also override the generation options by specifying them on the command line:
15+
# For example, override the context size by doing: ./chatLLaMa --ctx_size 1024
16+
GEN_OPTIONS="${GEN_OPTIONS:---ctx_size 2048 --temp 0.7 --top_k 40 --top_p 0.5 --repeat_last_n 256 --repeat_penalty 1.17647}"
17+
18+
# shellcheck disable=SC2086 # Intended splitting of GEN_OPTIONS
19+
./main $GEN_OPTIONS \
20+
--model "$MODEL" \
21+
--threads "$N_THREAD" \
22+
--n_predict "$N_PREDICTS" \
23+
--color --interactive \
24+
--reverse-prompt "${USER_NAME}:" \
25+
--prompt "
26+
Text transcript of a never ending dialog, where ${USER_NAME} interacts with an AI assistant named ${AI_NAME}.
27+
${AI_NAME} is helpful, kind, honest, friendly, good at writing and never fails to answer ${USER_NAME}’s requests immediately and with details and precision.
28+
There are no annotations like (30 seconds passed...) or (to himself), just what ${USER_NAME} and ${AI_NAME} say alound to each other.
29+
The dialog lasts for years, the entirety of it is shared below. It's 10000 pages long.
30+
The transcript only includes text, it does not include markup like HTML and Markdown.
31+
32+
$USER_NAME: Hello, $AI_NAME!
33+
$AI_NAME: Hello $USER_NAME! How may I help you today?
34+
$USER_NAME: What time is it?
35+
$AI_NAME: It is $(date +%H:%M).
36+
$USER_NAME: What year is it?
37+
$AI_NAME: We are in $(date +%Y).
38+
$USER_NAME: Please tell me the largest city in Europe.
39+
$AI_NAME: The largest city in Europe is Moscow, the capital of Russia.
40+
$USER_NAME: What can you tell me about Moscow?
41+
$AI_NAME: Moscow, on the Moskva River in western Russia, is the nation’s cosmopolitan capital. In its historic core is the Kremlin, a complex that’s home to the president and tsarist treasures in the Armoury. Outside its walls is Red Square, Russia’s symbolic center.
42+
$USER_NAME: What is a cat?
43+
$AI_NAME: A cat is a domestic species of small carnivorous mammal. It is the only domesticated species in the family Felidae.
44+
$USER_NAME: How do I pass command line arguments to a Node.js program?
45+
$AI_NAME: The arguments are stored in process.argv.
46+
47+
argv[0] is the path to the Node. js executable.
48+
argv[1] is the path to the script file.
49+
argv[2] is the first argument passed to the script.
50+
argv[3] is the second argument passed to the script and so on.
51+
$USER_NAME: Name a color.
52+
$AI_NAME: Blue
53+
$USER_NAME:" "$@"

0 commit comments

Comments
 (0)