char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
a6b3260a4
char/aliceai-t5-moe
1#!/usr/bin/env bash 2 3# make sure we are in the right directory 4SCRIPT_DIR =$( cd -- " $( dirname -- " ${ BASH_SOURCE [0]} " ) " &> /dev/null && pwd ) 5cd $ SCRIPT_DIR 6 7#export LLAMA_CACHE="$SCRIPT_DIR/tmp" 8 9set -eux 10 11mkdir -p $ SCRIPT_DIR /output 12 13PROJ_ROOT =" $ SCRIPT_DIR /../.." 14cd $ PROJ_ROOT 15 16export MTMD_TEST_RESPONSE_MARKER ="<MTMD_TEST_RESPONSE_MARKER>" 17 18# Check if the first argument is "big", then run test with big models 19# This is useful if we're running the script on a larger machine, so we can test the big models 20RUN_BIG_TESTS =false 21if [" ${ 1 :-} " ="big" ];then 22RUN_BIG_TESTS =true 23echo "Include BIG models..." 24fi 25 26RUN_HUGE_TESTS =false 27if [" ${ 1 :-} " ="huge" ];then 28RUN_HUGE_TESTS =true 29RUN_BIG_TESTS =true 30echo "Include BIG and HUGE models..." 31fi 32 33USE_VIDEO =false 34if [" ${ 1 :-} " ="video" ];then 35USE_VIDEO =true 36echo "Using video as input..." 37# behavior of USE_VIDEO: 38# do NOT check if the output contains "new york", only verify if the exit code is 0 39# when printing the result, print the OK/FAIL line then print the generated text 40fi 41 42# Check if the second argument is "flash", then enable flash attention 43# This is useful to test if flash attention off works correctly 44FLASH_ATTN ="on" 45if [" ${ 2 :-} " ="flash_off" ] || [" ${ 1 :-} " ="flash_off" ];then 46FLASH_ATTN ="off" 47echo "Flash attention disabled..." 48fi 49 50############### 51 52arr_prefix =() 53arr_hf =() 54arr_extra_args =() 55arr_file =() 56 57add_test_vision () { 58 localhf =$ 1 59shift 60 localextra_args ="" 61if [$ # -gt 0 ];then 62extra_args =$( printf " %q" " $ @" ) 63fi 64if [" $ USE_VIDEO " = true ];then 65arr_file +=("test-3.mp4" ) 66else 67arr_file +=("test-1.jpeg" ) 68fi 69arr_prefix +=("[vision]" ) 70arr_hf +=(" $ hf " ) 71arr_extra_args +=(" $ extra_args " ) 72} 73 74add_test_audio () { 75if [" $ USE_VIDEO " = true ];then 76return 0 77fi 78 localhf =$ 1 79shift 80 localextra_args ="" 81if [$ # -gt 0 ];then 82extra_args =$( printf " %q" " $ @" ) 83fi 84arr_prefix +=("[audio] " ) 85arr_hf +=(" $ hf " ) 86arr_extra_args +=(" $ extra_args " ) 87arr_file +=("test-2.mp3" ) 88} 89 90add_test_vision "ggml-org/SmolVLM-500M-Instruct-GGUF:Q8_0" 91add_test_vision "ggml-org/SmolVLM2-2.2B-Instruct-GGUF:Q4_K_M" 92add_test_vision "ggml-org/SmolVLM2-500M-Video-Instruct-GGUF:Q8_0" 93add_test_vision "ggml-org/gemma-3-4b-it-GGUF:Q4_K_M" 94add_test_vision "THUDM/glm-edge-v-5b-gguf:Q4_K_M" -p "name of the newspaper?<__media__>" 95add_test_vision "second-state/Llava-v1.5-7B-GGUF:Q2_K" --chat-template vicuna 96add_test_vision "cjpais/llava-1.6-mistral-7b-gguf:Q3_K_M" --chat-template vicuna 97add_test_vision "ibm-research/granite-vision-3.2-2b-GGUF:Q4_K_M" 98add_test_vision "second-state/MiniCPM-Llama3-V-2_5-GGUF:Q2_K" # model from openbmb is corrupted 99add_test_vision "openbmb/MiniCPM-V-2_6-gguf:Q2_K" 100add_test_vision "openbmb/MiniCPM-o-2_6-gguf:Q4_0" 101add_test_vision "bartowski/Qwen2-VL-2B-Instruct-GGUF:Q4_K_M" 102add_test_vision "ggml-org/Qwen2.5-VL-3B-Instruct-GGUF:Q4_K_M" 103add_test_vision "ggml-org/InternVL2_5-1B-GGUF:Q8_0" 104add_test_vision "ggml-org/InternVL3-1B-Instruct-GGUF:Q8_0" 105add_test_vision "ggml-org/Qwen2.5-Omni-3B-GGUF:Q4_K_M" 106add_test_vision "ggml-org/LFM2-VL-450M-GGUF:Q8_0" 107add_test_vision "ggml-org/granite-docling-258M-GGUF:Q8_0" 108add_test_vision "ggml-org/LightOnOCR-1B-1025-GGUF:Q8_0" 109add_test_vision "ggml-org/DeepSeek-OCR-GGUF:Q8_0" -p "Free OCR." --chat-template deepseek-ocr 110add_test_vision "ggml-org/dots.ocr-GGUF:Q8_0" -p "OCR" 111add_test_vision "ggml-org/HunyuanOCR-GGUF:Q8_0" -p "OCR" 112add_test_vision "ggml-org/gemma-4-E2B-it-GGUF:Q8_0" --jinja 113 114add_test_audio "ggml-org/ultravox-v0_5-llama-3_2-1b-GGUF:Q8_0" 115add_test_audio "ggml-org/Qwen2.5-Omni-3B-GGUF:Q4_K_M" 116add_test_audio "ggml-org/Voxtral-Mini-3B-2507-GGUF:Q4_K_M" 117add_test_audio "ggml-org/LFM2-Audio-1.5B-GGUF:Q8_0" 118add_test_audio "ggml-org/gemma-4-E2B-it-GGUF:Q8_0" --jinja 119add_test_audio "ggml-org/Qwen3-ASR-0.6B-GGUF:Q8_0" 120 121# to test the big models, run: ./tests.sh big 122if [" $ RUN_BIG_TESTS " = true ];then 123add_test_vision "ggml-org/pixtral-12b-GGUF:Q4_K_M" 124add_test_vision "ggml-org/Mistral-Small-3.1-24B-Instruct-2503-GGUF" --chat-template mistral-v7 125add_test_vision "ggml-org/Qwen2-VL-2B-Instruct-GGUF:Q4_K_M" 126add_test_vision "ggml-org/Qwen2-VL-7B-Instruct-GGUF:Q4_K_M" 127add_test_vision "ggml-org/Qwen2.5-VL-3B-Instruct-GGUF:Q4_K_M" 128add_test_vision "ggml-org/Qwen2.5-VL-7B-Instruct-GGUF:Q4_K_M" 129add_test_vision "ggml-org/Qwen3-VL-2B-Instruct-GGUF:Q8_0" 130add_test_vision "ggml-org/InternVL3-8B-Instruct-GGUF:Q4_K_M" 131add_test_vision "ggml-org/InternVL3-14B-Instruct-GGUF:Q4_K_M" 132add_test_vision "ggml-org/Qwen2.5-Omni-7B-GGUF:Q4_K_M" 133# add_test_vision "ggml-org/Qwen2.5-VL-32B-Instruct-GGUF:Q4_K_M" # does not work on my mac M3 Ultra 134# add_test_vision "ggml-org/Kimi-VL-A3B-Thinking-2506-GGUF:Q4_K_M" # not always working 135add_test_vision "ggml-org/GLM-4.6V-Flash-GGUF:Q4_K_M" -p "extract all texts from this image" 136 137add_test_audio "ggml-org/ultravox-v0_5-llama-3_1-8b-GGUF:Q4_K_M" 138add_test_audio "ggml-org/Qwen2.5-Omni-7B-GGUF:Q4_K_M" 139fi 140 141# to test the huge models, run: ./tests.sh huge 142# this will run both the big and huge models 143# huge models are > 32B parameters 144if [" $ RUN_HUGE_TESTS " = true ];then 145add_test_vision "ggml-org/Qwen2.5-VL-72B-Instruct-GGUF:Q4_K_M" 146add_test_vision "ggml-org/Llama-4-Scout-17B-16E-Instruct-GGUF:IQ1_S" 147fi 148 149# these models always give the wrong answer, not sure why 150# add_test_vision "ggml-org/SmolVLM-Instruct-GGUF:Q4_K_M" 151# add_test_vision "ggml-org/SmolVLM-256M-Instruct-GGUF:Q8_0" 152# add_test_vision "ggml-org/SmolVLM2-256M-Video-Instruct-GGUF:Q8_0" 153 154# this model has broken chat template, not usable 155# add_test_vision "cmp-nct/Yi-VL-6B-GGUF:Q5_K" 156# add_test_vision "guinmoon/MobileVLM-3B-GGUF:Q4_K_M" "deepseek" 157 158############### 159 160cmake --build build-j --target llama-mtmd-cli 161 162arr_res =() 163 164for i in " ${! arr_hf [@]} " ;do 165bin ="llama-mtmd-cli" 166prefix =" ${ arr_prefix [ $ i ]} " 167hf =" ${ arr_hf [ $ i ]} " 168extra_args =" ${ arr_extra_args [ $ i ]} " 169inp_file =" ${ arr_file [ $ i ]} " 170 171echo "Running test with binary: $ bin and HF model: $ hf " 172echo "" 173echo "" 174 175cmd =" $( printf %q " $ PROJ_ROOT /build/bin/ $ bin " ) \ 176-hf $( printf %q " $ hf " ) \ 177--image $( printf %q " $ SCRIPT_DIR / $ inp_file " ) \ 178--temp 0 -n 128 \ 179--flash-attn $( printf %q " $ FLASH_ATTN " ) \ 180${ extra_args } " 181 182# if extra_args does not contain -p, we add a default prompt 183if ! [[" $ extra_args " =~"-p" ]];then 184cmd +=" -p \"what is the publisher name of the newspaper?\"" 185fi 186 187exit_code =0 188output =$( eval " $ cmd " 2 >&1 | tee /dev/tty) ||exit_code =$ ? 189 190echo " $ output " > $ SCRIPT_DIR /output/$ bin-$( echo " $ hf " | tr '/' '-' ) .log 191 192if [" $ USE_VIDEO " = true ];then 193# for video, only check exit code; do not grep for "new york" 194if [$ exit_code -eq 0 ];then 195result =" $ prefix \033[32mOK\033[0m: $ hf " 196else 197result =" $ prefix \033[31mFAIL\033[0m: $ hf " 198fi 199# append generated text (after the response marker) 200generated_text =$( echo " $ output " | sed "1,/ ${ MTMD_TEST_RESPONSE_MARKER } /d" | tail -10 ) 201if [ -n" $ generated_text " ];then 202result +="\n $ generated_text " 203fi 204echo -e " $ result " 205else 206# either contains "new york" or both "men" and "walk" 207if echo " $ output " | grep -iq "new york" \ 208 || (echo " $ output " | grep -iq "men" && echo " $ output " | grep -iq "walk" ) 209then 210result =" $ prefix \033[32mOK\033[0m: $ hf " 211else 212result =" $ prefix \033[31mFAIL\033[0m: $ hf " 213fi 214echo -e " $ result " 215fi 216arr_res +=(" $ result " ) 217 218echo "" 219echo "" 220echo "" 221echo "#################################################" 222echo "#################################################" 223echo "" 224echo "" 225done 226 227set +x 228 229for i in " ${! arr_res [@]} " ;do 230echo -e " ${ arr_res [ $ i ]} " 231done 232echo "" 233echo "Output logs are saved in $ SCRIPT_DIR /output"