-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
llama : auto download HF models if URL provided #4735
Conversation
1412902
to
120a1a5
Compare
I could see this in a shell script, but this seems too hacky to include in llama.cpp. Additionally, this may cause security issues. Consider this:
Applications that want to load a model based on a user request would need to be careful to sanitize the input. |
Yes, probably not a good idea to merge like this |
const std::string cmd = "curl -C - -f -o " + basename + " -L " + url; | ||
LLAMA_LOG_INFO("%s: %s\n", __func__, cmd.c_str()); | ||
|
||
const int ret = system(cmd.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, system and popen should not be used with arbitrary user input. Better to use fork/execlp or posix_spawn (Unix) and _spawnlp or CreateProcess (Windows). This is somewhat tedious to do safely and portably in C or C++ without third-party dependencies such as glib.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I dropped the idea. Will probably add a bash script that can be used something like this:
./main -m $(./examples/hf.sh --model-name TheBloke/Mixtral-8x7B-v0.1-GGUF --quant Q4_K_M) ...
and it will do all the curl
and wget
calls
Usage seems easy enough (from httplib project): https://github.com/yhirose/cpp-httplib#client |
The |
QoL improvement - pass HF URL to auto-download the model if it does not exist:
./main \ -m https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF/resolve/main/mixtral-8x7b-instruct-v0.1.Q2_K.gguf \ -p "Hello world"
Will attempt to download via
wget
orcurl
if they are available in your PATH