Team Ai
Apppublic

KBaba7/llama.cpp

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
tools.sh50 linesDownload Raw Back to .devops
1#!/bin/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" == '--bench' || "$arg1" == '-b' ]]; then17    exec ./llama-bench "$@"18elif [[ "$arg1" == '--perplexity' || "$arg1" == '-p' ]]; then19    exec ./llama-perplexity "$@"20elif [[ "$arg1" == '--all-in-one' || "$arg1" == '-a' ]]; then21    echo "Converting PTH to GGML..."22    for i in $(ls $1/$2/ggml-model-f16.bin*); do23        if [ -f "${i/f16/q4_0}" ]; then24            echo "Skip model quantization, it already exists: ${i/f16/q4_0}"25        else26            echo "Converting PTH to GGML: $i into ${i/f16/q4_0}..."27            exec ./llama-quantize "$i" "${i/f16/q4_0}" q4_028        fi29    done30elif [[ "$arg1" == '--server' || "$arg1" == '-s' ]]; then31    exec ./llama-server "$@"32else33    echo "Unknown command: $arg1"34    echo "Available commands: "35    echo "  --run (-r): Run a model previously converted into ggml"36    echo "              ex: -m /models/7B/ggml-model-q4_0.bin -p \"Building a website can be done in 10 simple steps:\" -n 512"37    echo "  --bench (-b): Benchmark the performance of the inference for various parameters."38    echo "              ex: -m model.gguf"39    echo "  --perplexity (-p): Measure the perplexity of a model over a given text."40    echo "              ex: -m model.gguf -f file.txt"41    echo "  --convert (-c): Convert a llama model into ggml"42    echo "              ex: --outtype f16 \"/models/7B/\" "43    echo "  --quantize (-q): Optimize with quantization process ggml"44    echo "              ex: \"/models/7B/ggml-model-f16.bin\" \"/models/7B/ggml-model-q4_0.bin\" 2"45    echo "  --all-in-one (-a): Execute --convert & --quantize"46    echo "              ex: \"/models/\" 7B"47    echo "  --server (-s): Run a model on the server"48    echo "              ex: -m /models/7B/ggml-model-q4_0.bin -c 2048 -ngl 43 -mg 1 --port 8080"49fi50