tests.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/bin/bash
  2. # make sure we are in the right directory
  3. SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
  4. cd $SCRIPT_DIR
  5. #export LLAMA_CACHE="$SCRIPT_DIR/tmp"
  6. set -eux
  7. mkdir -p $SCRIPT_DIR/output
  8. PROJ_ROOT="$SCRIPT_DIR/../.."
  9. cd $PROJ_ROOT
  10. # Check if the first argument is "big", then run test with big models
  11. # This is useful if we're running the script on a larger machine, so we can test the big models
  12. RUN_BIG_TESTS=false
  13. if [ "${1:-}" = "big" ]; then
  14. RUN_BIG_TESTS=true
  15. echo "Include BIG models..."
  16. fi
  17. ###############
  18. arr_bin=()
  19. arr_hf=()
  20. arr_tmpl=() # chat template
  21. add_test() {
  22. local bin=$1
  23. local hf=$2
  24. local tmpl=${3:-""} # default to empty string if not provided
  25. arr_bin+=("$bin")
  26. arr_hf+=("$hf")
  27. arr_tmpl+=("$tmpl")
  28. }
  29. add_test "llama-mtmd-cli" "ggml-org/SmolVLM-500M-Instruct-GGUF:Q8_0"
  30. add_test "llama-mtmd-cli" "ggml-org/SmolVLM2-2.2B-Instruct-GGUF:Q4_K_M"
  31. add_test "llama-mtmd-cli" "ggml-org/SmolVLM2-500M-Video-Instruct-GGUF:Q8_0"
  32. add_test "llama-mtmd-cli" "ggml-org/gemma-3-4b-it-GGUF:Q4_K_M"
  33. add_test "llama-mtmd-cli" "guinmoon/MobileVLM-3B-GGUF:Q4_K_M" "deepseek"
  34. add_test "llama-mtmd-cli" "THUDM/glm-edge-v-5b-gguf:Q4_K_M"
  35. add_test "llama-mtmd-cli" "second-state/Llava-v1.5-7B-GGUF:Q2_K" "vicuna"
  36. add_test "llama-mtmd-cli" "cjpais/llava-1.6-mistral-7b-gguf:Q3_K" "vicuna"
  37. add_test "llama-mtmd-cli" "ibm-research/granite-vision-3.2-2b-GGUF:Q4_K_M"
  38. add_test "llama-mtmd-cli" "second-state/MiniCPM-Llama3-V-2_5-GGUF:Q2_K" # model from openbmb is corrupted
  39. add_test "llama-mtmd-cli" "openbmb/MiniCPM-V-2_6-gguf:Q2_K"
  40. add_test "llama-mtmd-cli" "openbmb/MiniCPM-o-2_6-gguf:Q4_0"
  41. add_test "llama-mtmd-cli" "bartowski/Qwen2-VL-2B-Instruct-GGUF:Q4_K_M"
  42. add_test "llama-mtmd-cli" "ggml-org/Qwen2.5-VL-3B-Instruct-GGUF:Q4_K_M"
  43. # to test the big models, run: ./tests.sh big
  44. if [ "$RUN_BIG_TESTS" = true ]; then
  45. add_test "llama-mtmd-cli" "ggml-org/pixtral-12b-GGUF:Q4_K_M"
  46. add_test "llama-mtmd-cli" "ggml-org/Mistral-Small-3.1-24B-Instruct-2503-GGUF" "mistral-v7"
  47. add_test "llama-mtmd-cli" "ggml-org/Qwen2-VL-2B-Instruct-GGUF:Q4_K_M"
  48. add_test "llama-mtmd-cli" "ggml-org/Qwen2-VL-7B-Instruct-GGUF:Q4_K_M"
  49. add_test "llama-mtmd-cli" "ggml-org/Qwen2.5-VL-3B-Instruct-GGUF:Q4_K_M"
  50. add_test "llama-mtmd-cli" "ggml-org/Qwen2.5-VL-7B-Instruct-GGUF:Q4_K_M"
  51. # add_test "llama-mtmd-cli" "ggml-org/Qwen2.5-VL-32B-Instruct-GGUF:Q4_K_M" # does not work on my mac M3 Ultra
  52. # add_test "llama-mtmd-cli" "ggml-org/Qwen2.5-VL-72B-Instruct-GGUF:Q4_K_M" # too big
  53. fi
  54. # these models always give the wrong answer, not sure why
  55. # add_test "llama-mtmd-cli" "ggml-org/SmolVLM-Instruct-GGUF:Q4_K_M"
  56. # add_test "llama-mtmd-cli" "ggml-org/SmolVLM-256M-Instruct-GGUF:Q8_0"
  57. # add_test "llama-mtmd-cli" "ggml-org/SmolVLM2-256M-Video-Instruct-GGUF:Q8_0"
  58. # this model has broken chat template, not usable
  59. # add_test "llama-mtmd-cli" "cmp-nct/Yi-VL-6B-GGUF:Q5_K"
  60. ###############
  61. cmake --build build -j --target "${arr_bin[@]}"
  62. arr_res=()
  63. for i in "${!arr_bin[@]}"; do
  64. bin="${arr_bin[$i]}"
  65. hf="${arr_hf[$i]}"
  66. tmpl="${arr_tmpl[$i]}"
  67. echo "Running test with binary: $bin and HF model: $hf"
  68. echo ""
  69. echo ""
  70. output=$(\
  71. "$PROJ_ROOT/build/bin/$bin" \
  72. -hf "$hf" \
  73. --image $SCRIPT_DIR/test-1.jpeg \
  74. -p "what is the publisher name of the newspaper?" \
  75. --temp 0 -n 128 \
  76. ${tmpl:+--chat-template "$tmpl"} \
  77. 2>&1 | tee /dev/tty)
  78. echo "$output" > $SCRIPT_DIR/output/$bin-$(echo "$hf" | tr '/' '-').log
  79. if echo "$output" | grep -iq "new york"; then
  80. result="\033[32mOK\033[0m: $bin $hf"
  81. else
  82. result="\033[31mFAIL\033[0m: $bin $hf"
  83. fi
  84. echo -e "$result"
  85. arr_res+=("$result")
  86. echo ""
  87. echo ""
  88. echo ""
  89. echo "#################################################"
  90. echo "#################################################"
  91. echo ""
  92. echo ""
  93. done
  94. set +x
  95. for i in "${!arr_res[@]}"; do
  96. echo -e "${arr_res[$i]}"
  97. done
  98. echo ""
  99. echo "Output logs are saved in $SCRIPT_DIR/output"