11#! /bin/bash
22set -e
33
4+ MODELS_REPO=https://huggingface.co/ltoniazzi/reduce-llms-for-testing
5+
46# Step 1: Clone the Hugging Face repository if the directory does not exist
57if [ ! -d " reduce-llms-for-testing" ]; then
68 echo " Cloning the Hugging Face repository..."
7- git clone https://huggingface.co/ltoniazzi/reduce-llms-for-testing
9+ git clone $MODELS_REPO
810else
911 echo " Repository already exists. Skipping clone."
1012fi
@@ -16,22 +18,51 @@ run_conversion_and_inference_lora() {
1618 local model_size_mb=$3
1719
1820 echo " Running convert_hf_to_gguf.py for $model_name with size $size_matrix ..."
19- python convert_hf_to_gguf.py reduce-llms-for-testing/$model_name /size=$size_matrix /base --outtype f32
21+ python convert_hf_to_gguf.py reduce-llms-for-testing/$model_name /size=$size_matrix /base \
22+ --outtype f32
2023
2124 echo " Running convert_lora_to_gguf.py for $model_name with size $size_matrix ..."
22- python3 convert_lora_to_gguf.py reduce-llms-for-testing/$model_name /size=$size_matrix /lora --base reduce-llms-for-testing/$model_name /size=$size_matrix /base --outtype f32
25+ python3 convert_lora_to_gguf.py reduce-llms-for-testing/$model_name /size=$size_matrix /lora \
26+ --base reduce-llms-for-testing/$model_name /size=$size_matrix /base \
27+ --outtype f32
2328
2429 echo " Running llama-cli without lora for $model_name with size $size_matrix and model size $model_size_mb ..."
25- llama-cli -m reduce-llms-for-testing/$model_name /size=$size_matrix /base/Base-$model_size_mb -F32.gguf -p " <bos>When forty winters shall besiege" -n 50
30+ OUTPUT_BASE=$( llama-cli -m reduce-llms-for-testing/$model_name /size=$size_matrix /base/Base-$model_size_mb -F32.gguf \
31+ -p " <bos>When forty winters shall besiege" -n 50 --seed 42)
2632
2733 echo " Running llama-cli with lora for $model_name with size $size_matrix and model size $model_size_mb ..."
28- llama-cli -m reduce-llms-for-testing/$model_name /size=$size_matrix /base/Base-$model_size_mb -F32.gguf --lora reduce-llms-for-testing/$model_name /size=$size_matrix /lora/Lora-F32-LoRA.gguf -p " <bos>I see a little silhouetto" -n 50
34+ OUTPUT_LORA_HOT=$( llama-cli -m reduce-llms-for-testing/$model_name /size=$size_matrix /base/Base-$model_size_mb -F32.gguf \
35+ --lora reduce-llms-for-testing/$model_name /size=$size_matrix /lora/Lora-F32-LoRA.gguf \
36+ -p " <bos>I see a little silhouetto" -n 50 --seed 42)
2937
3038 # TODO add merge lora with lora-export and check
39+ echo " Running llama-export-lora with lora for $model_name with size $size_matrix and model size $model_size_mb ..."
40+ llama-export-lora \
41+ -m reduce-llms-for-testing/$model_name /size=$size_matrix /base/Base-$model_size_mb -F32.gguf \
42+ -o reduce-llms-for-testing/$model_name /size=$size_matrix /base/Base-$model_size_mb -F32-lora-merged.gguf \
43+ --lora reduce-llms-for-testing/$model_name /size=$size_matrix /lora/Lora-F32-LoRA.gguf \
44+
45+ echo " Running llama-cli with exported lora for $model_name with size $size_matrix and model size $model_size_mb ..."
46+ OUTPUT_LORA_MERGED=$( llama-cli -m reduce-llms-for-testing/$model_name /size=$size_matrix /base/Base-$model_size_mb -F32-lora-merged.gguf \
47+ -p " <bos>I see a little silhouetto" -n 50 --seed 42)
48+
49+
50+ # Echo the outputs with bullet points and spacing
51+ echo -e " \n\n\n\033[1mResults:\033[0m"
52+ echo -e " \n • \033[32mBase:\n $OUTPUT_BASE " # Green color for "BASE"
53+ echo -e " \n • \033[34mLora hot:\n $OUTPUT_LORA_HOT " # Blue color for "Lora hot"
54+ echo -e " \n • \033[36mLora merged:\n $OUTPUT_LORA_MERGED " # Cyan color for "Lora merged"
55+ echo -e " \n\n\n \033[0m"
56+
3157
3258 echo " All steps completed for $model_name with size $size_matrix and model size $model_size_mb !"
3359}
3460
35- # Example usage:
36- run_conversion_and_inference_lora " Gemma2ForCausalLM" " 64" " 19M"
61+ declare -a params=(
62+ " Gemma2ForCausalLM 64 19M"
63+ # "AnotherModel 128 25M"
64+ )
3765
66+ for param in " ${params[@]} " ; do
67+ run_conversion_and_inference_lora $param
68+ done
0 commit comments