File size: 1,165 Bytes
6a8d17c
 
 
 
 
 
 
 
a7e8a57
 
 
 
6a8d17c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a7e8a57
 
 
 
 
 
6a8d17c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash

# if conf does not exist, create it
if [ ! -f "$HOME/.config/llama/llama-prompt.conf" ]; then
    mkdir -p "$HOME/.config/llama"
    cat <<EOF > "$HOME/.config/llama/llama-prompt.conf"
LLAMA_MODEL_NAME=$HOME/.ai/models/llama/teknium/OpenHermes-2.5-Mistral-7B/openhermes-2.5-mistral-7b-f16.gguf
LLAMA_CONTEXT_SIZE=8192
LLAMA_TEMPERATURE=1.0
LLAMA_TOP_P=1.0
LLAMA_MIN_P=0.3
LLAMA_TOP_K=0
EOF
fi

source "$HOME/.config/llama/llama-prompt.conf"

# if an extra argument is provided, use it for LLAMA_MODEL_NAME
if [ -n "$2" ]; then
    LLAMA_MODEL_NAME="$2"
fi

# if an extra argument is provided, use it for LLAMA_CONTEXT_SIZE
if [ -n "$3" ]; then
    LLAMA_CONTEXT_SIZE="$3"
fi

# if no arguments are provided, print an error message and exit
if [ -z "$1" ]; then
    echo "Usage: llama-prompt.sh <prompt> [model] [context_size]"
    exit 1
fi

llama \
    --file "$1" \
    --model "$LLAMA_MODEL_NAME" \
    --ctx-size "$LLAMA_CONTEXT_SIZE" \
    --temp "$LLAMA_TEMPERATURE" \
    --min-p "$LLAMA_MIN_P" \
    --top-p "$LLAMA_TOP_P" \
    --top-k "$LLAMA_TOP_K" \
    --min-p "$LLAMA_MIN_P" \
    --threads 6 \
    --log-disable 2> /dev/null | fmt -w 80