Skip to content

Instantly share code, notes, and snippets.

@av1d
Last active March 25, 2024 22:01
Show Gist options
  • Save av1d/653932feb5aef8071d336ebd52ad2d80 to your computer and use it in GitHub Desktop.
Save av1d/653932feb5aef8071d336ebd52ad2d80 to your computer and use it in GitHub Desktop.
llama.cpp menu/launcher for storing models in one directory (folder) and easily loading them into llama.cpp quickly
#!/bin/bash
: <<'COMMENT'
Creates a menu system so it's easier to launch models. Example output:
[1] alicecomfy_miqu-70b-openhermes-full-b2131-iMat-c32_ch1000-IQ1_S_v3.gguf (13862 MB)
[2] deepsex-34b.Q2_K.gguf (13881 MB)
[3] ggml-model-q4_0.gguf (18564 MB)
[4] mistral-7b-instruct-v0.2.Q3_K_M.gguf (3355 MB)
[5] mlewdboros-l2-13b.Q3_K_L.gguf (6608 MB)
[6] mlewdboros-l2-13b.Q3_K_M.gguf (6044 MB)
[7] Psyonic-Rose-20B-Q4_K_S.gguf (10815 MB)
[8] rocket-3b.Q2_K.gguf (1143 MB)
[9] solar-10.7b-instruct-v1.0-uncensored.Q2_K.gguf (4339 MB)
[10] tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf (637 MB)
[11] tinyllama-1.1b-chat-v1.0.Q8_0.gguf (1116 MB)
[12] wizardlm-1.0-uncensored-llama2-13b.Q4_K_M.gguf (7501 MB)
[13] xwin-mlewd-13b-v0.2.Q2_K.gguf (5177 MB)
[14] xwin-mlewd-7b-v0.2.Q3_K_S.gguf (2811 MB)
Selection:
COMMENT
# full path to llama.cpp
llamacpp_path="/home/av1d/llama.cpp/main"
# location of your models
gguf_files=(~/models/*.gguf)
if [ ${#gguf_files[@]} -eq 0 ]; then
echo "No GGUF files found in the current directory."
exit 1
fi
NUMBER_SELECTION_COLOR='\e[0;96m'
FILENAME_COLOR='\e[0;93m'
FILE_PATH_COLOR='\e[0;95m' # Magenta
FILE_SIZE_COLOR='\e[0;92m' # Green
NC='\e[0m' # No Color
for ((i=0; i<${#gguf_files[@]}; i++)); do
file_path="${FILE_PATH_COLOR}${gguf_files[i]}${NC}"
file_name=$(basename "$file_path")
dir_path="${file_path%/*}"
file_name_colored=$(echo -e "${FILENAME_COLOR}${file_name}${NC}")
file_size=$(stat -c "%s" "${gguf_files[i]}") # file size in bytes (switch $mb_size below for $file_size)
mb_size=$((file_size / 1024 / 1024))
# colored_file="${NUMBER_SELECTION_COLOR}[$((i+1))]${NC} ${dir_path}/${file_name_colored} (${FILE_SIZE_COLOR}$mb_size MB${NC})"
colored_file="${NUMBER_SELECTION_COLOR}[$((i+1))]${NC} ${file_name_colored} (${FILE_SIZE_COLOR}$mb_size MB${NC})"
echo -e "$colored_file"
done
read -p "Selection: " choice
if ! [[ $choice =~ ^[0-9]+$ ]] || [ $choice -lt 1 ] || [ $choice -gt ${#gguf_files[@]} ]; then
echo "Invalid choice. Please enter a valid number."
exit 1
fi
selected_file=${gguf_files[choice-1]}
echo "You selected: ${FILE_PATH_COLOR}$selected_file${NC}"
$llamacpp_path -m $selected_file --color \
--ctx_size 2048 \
-n -1 \
-ins -b 256 \
--top_k 10000 \
--temp 0.2 \
--repeat_penalty 1.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment