common : refactor downloading system, handle mmproj with -hf option #12694
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ref comment: #12664 (comment)
Changes in this PR:
common_get_hf_file
--mmproj-url
; if-hf-repo
is specify, we default to the value returned by HF backendThe goal is to make vision examples a bit more simple to play with, for example:
llama-gemma3-cli -hf bartowski/google_gemma-3-4b-it-GGUF
now works without specifying--mmproj
The download system is now moved to
arg.cpp
. A new structcommon_params_model
is added to store the path/url of the model. The logic is as follow:View text caption
model.path
,model.url
, or hf_repo/hf_file is supplied from CLIcommon_params_handle_model
firstly fill in and make sure the values are correct:hf_repo
is in therepo/user:tag
format, it ask the HF backend for thehf_file
hf_repo
andhf_file
is there, we construct themodel.url
model.url
is there but nomodel.path
, we setmodel.path
to default cache directorycommon_params_handle_model
then callcommon_download_model
to download the actual filecommon_download_file_single
to download the first shardcommon_download_file_multiple
to download the remaining shardsAfter
common_params_handle_model
returns, themodel.path
is ready to be loaded.Diagram generated by Claude: