-
Notifications
You must be signed in to change notification settings - Fork 273
Expand file tree
/
Copy pathwindows_prepare_llm_models.bat
More file actions
171 lines (148 loc) · 6.54 KB
/
Copy pathwindows_prepare_llm_models.bat
File metadata and controls
171 lines (148 loc) · 6.54 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
::
:: Copyright 2024 Intel Corporation
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under
@echo off
setlocal EnableExtensions EnableDelayedExpansion
if "%~1"=="" (
echo Error: No directory specified.
exit /b 1
)
:: Create a link to preexported models on CI workers
IF /I EXIST c:\opt\llm_testing (
rmdir /S /Q "%~1"
mklink /d "%~1" c:\opt\llm_testing
echo Created link to existing in c:\opt\llm_testing. Skipping downloading models.
)
set "EMBEDDING_MODEL=thenlper/gte-small"
set "RERANK_MODEL=BAAI/bge-reranker-base"
set "TEXT_GENERATION_MODEL=HuggingFaceTB/SmolLM2-360M-Instruct"
set "FACEBOOK_MODEL=facebook/opt-125m"
set "VLM_MODEL=OpenVINO/InternVL2-1B-int4-ov"
set "TTS_MODEL=hexgrad/Kokoro-82M"
set "STT_MODEL=openai/whisper-tiny"
:: Models for tools testing. Only tokenizers are downloaded.
set "QWEN3_MODEL=Qwen/Qwen3-8B"
set "LLAMA3_MODEL=unsloth/Llama-3.1-8B-Instruct"
set "HERMES3_MODEL=NousResearch/Hermes-3-Llama-3.1-8B"
set "PHI4_MODEL=microsoft/Phi-4-mini-instruct"
set "MISTRAL_MODEL=mistralai/Mistral-7B-Instruct-v0.3"
set "GPTOSS_MODEL=openai/gpt-oss-20b"
set "DEVSTRAL_MODEL=unsloth/Devstral-Small-2507"
set "LFM2_MODEL=LiquidAI/LFM2-2.6B"
set "LFM25_MODEL=LiquidAI/LFM2.5-8B-A1B"
set "GEMMA4_MODEL=OpenVINO/gemma-4-E4B-it-int4-ov"
set "MINICPM5_MODEL=openbmb/MiniCPM5-1B"
echo Downloading LLM testing models to directory %~1
set "PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cpu https://storage.openvinotoolkit.org/simple/wheels/nightly"
set "PYTHONPATH="
C:\opt\Python312\python.exe -m venv .venv
if !errorlevel! neq 0 exit /b !errorlevel!
call .\.venv\Scripts\Activate.bat
if !errorlevel! neq 0 exit /b !errorlevel!
python -m pip install --upgrade pip
if !errorlevel! neq 0 exit /b !errorlevel!
pip install -U -r demos\common\export_models\requirements.txt
if !errorlevel! neq 0 exit /b !errorlevel!
if not exist "%~1" mkdir "%~1"
:: Export models
call :download_export_model_tts "%TTS_MODEL%" "text2speech" "--model_type kokoro --weight-format int8" "%~1"
call :download_export_model "%STT_MODEL%" "speech2text" "--weight-format int4" "%~1"
call :download_openvino "%VLM_MODEL%" "%~1" OpenGVLab/InternVL2-1B
call :download_export_model "%TEXT_GENERATION_MODEL%" "text_generation" "--weight-format int8" "%~1"
call :download_export_model "%FACEBOOK_MODEL%" "text_generation" "--weight-format int8" "%~1"
call :download_export_model "%RERANK_MODEL%" "rerank_ov" "--weight-format int8 --model_name %RERANK_MODEL%\ov" "%~1"
call :download_export_model "%EMBEDDING_MODEL%" "embeddings_ov" "--weight-format int8 --model_name %EMBEDDING_MODEL%\ov" "%~1"
if not exist "%~1\%FACEBOOK_MODEL%\chat_template.jinja" (
echo Copying dummy chat template to %FACEBOOK_MODEL% model directory.
copy /Y "src\test\llm\dummy_facebook_template.jinja" "%~1\%FACEBOOK_MODEL%\chat_template.jinja"
if !errorlevel! neq 0 exit /b !errorlevel!
)
:: Download tokenizers for tools testing
call :download_tokenizer "%QWEN3_MODEL%" "%~1\%QWEN3_MODEL%"
call :download_tokenizer "%LLAMA3_MODEL%" "%~1\%LLAMA3_MODEL%"
call :download_tokenizer "%HERMES3_MODEL%" "%~1\%HERMES3_MODEL%"
call :download_tokenizer "%PHI4_MODEL%" "%~1\%PHI4_MODEL%"
call :download_tokenizer "%MISTRAL_MODEL%" "%~1\%MISTRAL_MODEL%"
call :download_tokenizer "%GPTOSS_MODEL%" "%~1\%GPTOSS_MODEL%"
call :download_tokenizer "%DEVSTRAL_MODEL%" "%~1\%DEVSTRAL_MODEL%"
call :download_tokenizer "%LFM2_MODEL%" "%~1\%LFM2_MODEL%"
call :download_tokenizer "%LFM25_MODEL%" "%~1\%LFM25_MODEL%"
call :download_tokenizer "%MINICPM5_MODEL%" "%~1\%MINICPM5_MODEL%"
call :download_openvino_tokenizer "%GEMMA4_MODEL%" "%~1"
exit /b 0
:: Helper subroutine to download export models
:download_export_model
set "model=%~1"
set "model_type=%~2"
set "export_args=%~3"
set "repository=%~4"
if not exist "%repository%\%model%\openvino_tokenizer.bin" (
echo Downloading %model_type% model to %repository%\%model% directory.
python demos\common\export_models\export_model.py %model_type% --source_model "%model%" %export_args% --model_repository_path %repository%
) else (
echo Models file %repository%\%model%\openvino_tokenizer.bin exists. Skipping downloading models.
)
exit /b 0
:download_export_model_tts
set "model=%~1"
set "model_type=%~2"
set "export_args=%~3"
set "repository=%~4"
if not exist "%repository%\%model%\openvino_model.xml" (
echo Downloading %model_type% model to %repository%\%model% directory.
python demos\common\export_models\export_model.py %model_type% --source_model "%model%" %export_args% --model_repository_path %repository%
) else (
echo Models file %repository%\%model%\openvino_model.xml exists. Skipping downloading models.
)
exit /b 0
:download_openvino
set "model=%~1"
set "repository=%~2"
if not exist "%repository%\%model%\openvino_tokenizer.bin" (
echo Downloading model to %repository%\%model% directory.
hf download "%model%" --local-dir "%repository%\%model%"
:: WA to use newer tokenizer model format which supports padding.
convert_tokenizer "%~3" --with_detokenizer -o "%~2\%~1"
) else (
echo Models file %repository%\%model%\openvino_tokenizer.bin exists. Skipping downloading models.
)
exit /b 0
:download_openvino_tokenizer
set "model=%~1"
set "repository=%~2"
if not exist "%repository%\%model%\openvino_tokenizer.bin" (
echo Downloading tokenizer and detokenizer for %model% model to %repository%\%model% directory.
mkdir "%repository%\%model%"
hf download "%model%" --local-dir "%repository%\%model%" --include *tokenizer*
) else (
echo Models file %repository%\%model%\openvino_tokenizer.bin exists. Skipping downloading models.
)
:: Helper subroutine to download tokenizers
:download_tokenizer
set "model=%~1"
set "check_path=%~2"
if exist "%check_path%" (
echo Models file %check_path% exists. Skipping downloading models.
) else (
echo Downloading tokenizer and detokenizer for %model% model to %check_path% directory.
mkdir "%check_path%"
convert_tokenizer "%model%" --with_detokenizer -o "%check_path%"
if !errorlevel! neq 0 exit /b !errorlevel!
)
if not exist "%check_path%\openvino_tokenizer.bin" (
echo Models file %check_path%\openvino_tokenizer.bin does not exist.
exit /b 1
)
exit /b 0
endlocal