-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_models.sh
53 lines (49 loc) · 1.48 KB
/
test_models.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! /bin/bash
rm -rf tests
mkdir -p tests
string_list=(
"codellama:7b-instruct-q4_0"
"codellama:7b-instruct"
"codellama:13b-instruct-q4_0"
"deepseek-coder:6.7b-instruct-q4_0"
"deepseek-coder:6.7b"
"deepseek-coder:6.7b-instruct"
"mistral:v0.2"
)
if [[ ! -f prompt.txt ]]; then
echo "Error: prompt.txt does not exist."
exit 1
fi
count=0
total=${#string_list[@]}
overall_start=$(date +%s)
trap 'echo "Process interrupted by user. Exiting..."; exit' INT
for string_name in "${string_list[@]}"; do
# Pull the model
ollama pull "${string_name}"
echo "=====Testing ${string_name}====="
avg_time=0
# Run the model 5 times
for i in {1..5}; do
echo "=====Test ${i}=====" >>"tests/${string_name}.md"
# Record start time
start_time=$(date +%s)
gtimeout 45 ollama run "${string_name}" "$(cat prompt.txt || true)" >>"tests/${string_name}.md"
end_time=$(date +%s)
elapsed_time=$((end_time - start_time))
avg_time=$((avg_time + elapsed_time))
echo "=====Test took ${elapsed_time} seconds=====" >>"tests/${string_name}.md"
done
# Calculate average time
avg_time=$((avg_time / 5))
echo "" >>"tests/${string_name}.md"
echo "=====END ${string_name}====="
((count++))
echo "${count}/${total} tests completed"
echo "=====Test took ${avg_time} seconds on average=====" >>"tests/${string_name}.md"
echo ""
done
overall_end=$(date +%s)
overall_elapsed=$((overall_end - overall_start))
overall_elapsed_minutes=$((overall_elapsed / 60))
echo "All tests completed in ${overall_elapsed_minutes} minutes"