Skip to content

scripts : add hf.sh helper script #5501

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

Merged
merged 3 commits into from
Feb 15, 2024
Merged

scripts : add hf.sh helper script #5501

merged 3 commits into from
Feb 15, 2024

Conversation

ggerganov
Copy link
Member

@ggerganov ggerganov commented Feb 15, 2024

Helper script to download an HF model file using wget or curl (whichever is available). Supports resuming downloads.

Sample usage:

./main \
  -m $(./scripts/hf.sh --repo TheBloke/Mixtral-8x7B-v0.1-GGUF --file mixtral-8x7b-v0.1.Q4_K_M.gguf) \
  -p "I believe the meaning of life is" -n 64

./main \
  -m $(./scripts/hf.sh https://huggingface.co/TheBloke/Mixtral-8x7B-v0.1-GGUF/blob/main/mixtral-8x7b-v0.1.Q4_K_M.gguf) \
  -p "I believe the meaning of life is" -n 64

./main \
  -m $(./scripts/hf.sh --url https://huggingface.co/TheBloke/Mixtral-8x7B-v0.1-GGUF/blob/main/mixtral-8x7b-v0.1.Q4_K_M.gguf) \
  -p "I believe the meaning of life is" -n 64

old attempt: #4735

@ggerganov ggerganov changed the title scripts : add hf.sh helper scripts scripts : add hf.sh helper script Feb 15, 2024
fi

if [ "$is_url" = false ]; then
exit 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a log could be added here? otherwise non-HF/mistyped URIs will quit silently

Copy link
Collaborator

@Vaibhavs10 Vaibhavs10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love itt! Conceptually I wonder if it'd make more sense to add support for providing the repo name as well as the file name and we make the URL in the script.

This helps remove any possibility of people executing malicious code or accidentally putting in the wrong URL too.

model-repo & quant-file (or something like that).

./main \ -m $(./scripts/hf.sh --model-repo TheBloke/Mixtral-8x7B-v0.1-GGUF --quant-file mixtral-8x7b-v0.1.Q4_K_M.gguf) \ -p "I believe the meaning of life is" -n 64

What do you think?

@ggerganov
Copy link
Member Author

Just added the optional --repo and --file args

I prefer --url because I can just copy paste the URL from the browser and don't have to split it into parts. But both options are available now.

This helps remove any possibility of people executing malicious code or accidentally putting in the wrong URL too.

This script is mainly a helper for llama.cpp examples. It's not meant for production use, so I don't think we have to worry about wrong-doings here.

Copy link
Collaborator

@Vaibhavs10 Vaibhavs10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant thanks for iterating! This looks good to me! I think this could help the community quite a bit! ⚡

@ggerganov ggerganov merged commit 9350a1c into master Feb 15, 2024
jordankanter pushed a commit to jordankanter/llama.cpp that referenced this pull request Mar 13, 2024
* scripts : add hf.sh helper scripts

* hf : add error logs

* hf : add support for --repo and --file
hodlen pushed a commit to hodlen/llama.cpp that referenced this pull request Apr 1, 2024
* scripts : add hf.sh helper scripts

* hf : add error logs

* hf : add support for --repo and --file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants