tests.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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_big() {
  30. if [ "$RUN_BIG_TESTS" = true ]; then
  31. add_test "$@"
  32. fi
  33. }
  34. add_test "llama-mtmd-cli" "ggml-org/SmolVLM-500M-Instruct-GGUF:Q8_0"
  35. add_test "llama-mtmd-cli" "ggml-org/SmolVLM2-2.2B-Instruct-GGUF:Q4_K_M"
  36. add_test "llama-mtmd-cli" "ggml-org/SmolVLM2-500M-Video-Instruct-GGUF:Q8_0"
  37. add_test "llama-mtmd-cli" "ggml-org/gemma-3-4b-it-GGUF:Q4_K_M"
  38. add_test "llama-mtmd-cli" "guinmoon/MobileVLM-3B-GGUF:Q4_K_M" "deepseek"
  39. add_test "llama-mtmd-cli" "THUDM/glm-edge-v-5b-gguf:Q4_K_M"
  40. add_test "llama-mtmd-cli" "second-state/Llava-v1.5-7B-GGUF:Q2_K" "vicuna"
  41. add_test "llama-mtmd-cli" "cjpais/llava-1.6-mistral-7b-gguf:Q3_K" "vicuna"
  42. add_test "llama-mtmd-cli" "ibm-research/granite-vision-3.2-2b-GGUF:Q4_K_M"
  43. add_test "llama-mtmd-cli" "second-state/MiniCPM-Llama3-V-2_5-GGUF:Q2_K" # model from openbmb is corrupted
  44. add_test "llama-mtmd-cli" "openbmb/MiniCPM-V-2_6-gguf:Q2_K"
  45. add_test "llama-mtmd-cli" "openbmb/MiniCPM-o-2_6-gguf:Q4_0"
  46. add_test "llama-qwen2vl-cli" "bartowski/Qwen2-VL-2B-Instruct-GGUF:Q4_K_M"
  47. # to test the big models, run: ./tests.sh big
  48. add_test_big "llama-mtmd-cli" "ggml-org/pixtral-12b-GGUF:Q4_K_M"
  49. # these models always give the wrong answer, not sure why
  50. # add_test "llama-mtmd-cli" "ggml-org/SmolVLM-Instruct-GGUF:Q4_K_M"
  51. # add_test "llama-mtmd-cli" "ggml-org/SmolVLM-256M-Instruct-GGUF:Q8_0"
  52. # add_test "llama-mtmd-cli" "ggml-org/SmolVLM2-256M-Video-Instruct-GGUF:Q8_0"
  53. # this model has broken chat template, not usable
  54. # add_test "llama-mtmd-cli" "cmp-nct/Yi-VL-6B-GGUF:Q5_K"
  55. ###############
  56. cmake --build build -j --target "${arr_bin[@]}"
  57. arr_res=()
  58. for i in "${!arr_bin[@]}"; do
  59. bin="${arr_bin[$i]}"
  60. hf="${arr_hf[$i]}"
  61. tmpl="${arr_tmpl[$i]}"
  62. echo "Running test with binary: $bin and HF model: $hf"
  63. echo ""
  64. echo ""
  65. output=$(\
  66. "$PROJ_ROOT/build/bin/$bin" \
  67. -hf "$hf" \
  68. --image $SCRIPT_DIR/test-1.jpeg \
  69. -p "what is the publisher name of the newspaper?" \
  70. --temp 0 -n 128 \
  71. ${tmpl:+--chat-template "$tmpl"} \
  72. 2>&1 | tee /dev/tty)
  73. echo "$output" > $SCRIPT_DIR/output/$bin-$(echo "$hf" | tr '/' '-').log
  74. if echo "$output" | grep -iq "new york"; then
  75. result="\033[32mOK\033[0m: $bin $hf"
  76. else
  77. result="\033[31mFAIL\033[0m: $bin $hf"
  78. fi
  79. echo -e "$result"
  80. arr_res+=("$result")
  81. echo ""
  82. echo ""
  83. echo ""
  84. echo "#################################################"
  85. echo "#################################################"
  86. echo ""
  87. echo ""
  88. done
  89. set +x
  90. for i in "${!arr_res[@]}"; do
  91. echo -e "${arr_res[$i]}"
  92. done
  93. echo ""
  94. echo "Output logs are saved in $SCRIPT_DIR/output"