Last active
April 21, 2025 18:55
-
-
Save ngxson/25282ff3038dd7fbbd6e81a614024348 to your computer and use it in GitHub Desktop.
Convert SmolVLM to GGUF and push to HF hub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
convert_and_upload() { | |
local src_user=$1 | |
local src_model=$2 | |
local has_q4=$3 | |
local base_name=$src_model | |
target_model="$src_model-GGUF" | |
target_repo="ggml-org/$target_model" | |
mkdir -p $target_model | |
huggingface-cli download "$src_user/$src_model" --local-dir $src_model | |
python ../convert_hf_to_gguf.py \ | |
--outfile $target_model/$base_name-f16.gguf \ | |
--outtype f16 \ | |
$src_model | |
../build/bin/llama-quantize \ | |
$target_model/$base_name-f16.gguf \ | |
$target_model/$base_name-Q8_0.gguf \ | |
Q8_0 | |
if [ "$has_q4" = "true" ]; then | |
../build/bin/llama-quantize \ | |
$target_model/$base_name-f16.gguf \ | |
$target_model/$base_name-Q4_K_M.gguf \ | |
Q4_K_M | |
fi | |
python ../convert_hf_to_gguf.py \ | |
--outfile $target_model/mmproj-$base_name-f16.gguf \ | |
--outtype f16 --mmproj \ | |
$src_model | |
echo "---" > $target_model/README.md | |
echo "license: apache-2.0" >> $target_model/README.md | |
echo "base_model: $src_user/$src_model" >> $target_model/README.md | |
echo "---" >> $target_model/README.md | |
echo "" >> $target_model/README.md | |
echo "# $src_model" >> $target_model/README.md | |
echo "" >> $target_model/README.md | |
echo "Original model: https://huggingface.co/$src_user/$src_model" >> $target_model/README.md | |
echo "" >> $target_model/README.md | |
echo "For more info, please refer to this PR: https://github.com/ggml-org/llama.cpp/pull/13050" >> $target_model/README.md | |
echo "" >> $target_model/README.md | |
huggingface-cli upload $target_repo $target_model . | |
rm -rf $target_model | |
rm -rf $src_model | |
} | |
convert_and_upload HuggingFaceTB SmolVLM-Instruct true | |
convert_and_upload HuggingFaceTB SmolVLM-256M-Instruct false # no q4, quality degrades too much | |
convert_and_upload HuggingFaceTB SmolVLM-500M-Instruct false # no q4, quality degrades too much | |
convert_and_upload HuggingFaceTB SmolVLM2-2.2B-Instruct true | |
convert_and_upload HuggingFaceTB SmolVLM2-256M-Video-Instruct false # no q4, quality degrades too much | |
convert_and_upload HuggingFaceTB SmolVLM2-500M-Video-Instruct false # no q4, quality degrades too much | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment