CoolFace
Modelpublic

Felipe97/llama-cpp-compiled

sourceHugging Faceupdated 3d agoView on Hugging Face
0likes1.1kdownloads
tools.sh54 linesDownload Raw Back to .devops
1#!/usr/bin/env bash2set -e3 4# Read the first argument into a variable5arg1="$1"6 7# Shift the arguments to remove the first one8shift9 10if [[ "$arg1" == '--convert' || "$arg1" == '-c' ]]; then11    exec python3 ./convert_hf_to_gguf.py "$@"12elif [[ "$arg1" == '--quantize' || "$arg1" == '-q' ]]; then13    exec ./llama-quantize "$@"14elif [[ "$arg1" == '--run' || "$arg1" == '-r' ]]; then15    exec ./llama-cli "$@"16elif [[ "$arg1" == '--run-legacy' || "$arg1" == '-l' ]]; then17    exec ./llama-completion "$@"18elif [[ "$arg1" == '--bench' || "$arg1" == '-b' ]]; then19    exec ./llama-bench "$@"20elif [[ "$arg1" == '--perplexity' || "$arg1" == '-p' ]]; then21    exec ./llama-perplexity "$@"22elif [[ "$arg1" == '--all-in-one' || "$arg1" == '-a' ]]; then23    echo "Converting PTH to GGML..."24    for i in $(ls $1/$2/ggml-model-f16.bin*); do25        if [ -f "${i/f16/q4_0}" ]; then26            echo "Skip model quantization, it already exists: ${i/f16/q4_0}"27        else28            echo "Converting PTH to GGML: $i into ${i/f16/q4_0}..."29            exec ./llama-quantize "$i" "${i/f16/q4_0}" q4_030        fi31    done32elif [[ "$arg1" == '--server' || "$arg1" == '-s' ]]; then33    exec ./llama-server "$@"34else35    echo "Unknown command: $arg1"36    echo "Available commands: "37    echo "  --run (-r): Run a model (chat) previously converted into ggml"38    echo "              ex: -m /models/7B/ggml-model-q4_0.bin"39    echo "  --run-legacy (-l): Run a model (legacy completion) previously converted into ggml"40    echo "              ex: -m /models/7B/ggml-model-q4_0.bin -no-cnv -p \"Building a website can be done in 10 simple steps:\" -n 512"41    echo "  --bench (-b): Benchmark the performance of the inference for various parameters."42    echo "              ex: -m model.gguf"43    echo "  --perplexity (-p): Measure the perplexity of a model over a given text."44    echo "              ex: -m model.gguf -f file.txt"45    echo "  --convert (-c): Convert a llama model into ggml"46    echo "              ex: --outtype f16 \"/models/7B/\" "47    echo "  --quantize (-q): Optimize with quantization process ggml"48    echo "              ex: \"/models/7B/ggml-model-f16.bin\" \"/models/7B/ggml-model-q4_0.bin\" 2"49    echo "  --all-in-one (-a): Execute --convert & --quantize"50    echo "              ex: \"/models/\" 7B"51    echo "  --server (-s): Run a model on the server"52    echo "              ex: -m /models/7B/ggml-model-q4_0.bin -c 2048 -ngl 43 -mg 1 --port 8080"53fi54