[PR #7201] [CLOSED] Add support for downloading model from HG #12345

Closed
opened 2026-04-12 23:56:11 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/7201
Author: @JoseCarlosGarcia95
Created: 10/14/2024
Status: Closed

Base: mainHead: main


📝 Commits (6)

  • ddafbb1 Include support for getting models from HG
  • 806771b Merge branch 'feat/hg-download-support'
  • 641caa4 update llm/llama.cpp to production
  • d9a5748 fix cmd.go
  • 299ea14 fix modelfile.md
  • e647b7e revert changes to .gitignore

📊 Changes

4 files changed (+159 additions, -1 deletions)

View changed files

📝 .gitignore (+2 -1)
📝 cmd/cmd.go (+98 -0)
📝 docs/modelfile.md (+7 -0)
examples/modelfile-from-hg/Modelfile (+52 -0)

📄 Description

Description:

This PR introduces a new feature that allows models specified with the FROM keyword to be downloaded directly from Hugging Face if the URL starts with the prefix hg://. This enhancement ensures seamless integration with Hugging Face’s model hub, automatically downloading and saving models from the specified Hugging Face URLs.

Key changes:

  • Added a check for hg:// URLs in the FROM command.
  • Implemented a download function that fetches the model from Hugging Face using the provided URL and saves it to the designated path.
  • If the model file already exists in the target directory, the download is skipped to avoid redundant downloads.
  • Progress tracking is provided during the download process to ensure visibility of the operation.

How it works:

  • The code checks if the FROM URL starts with hg://.
  • It then parses the URL and constructs a valid Hugging Face model download link.
  • If the model doesn't already exist locally, it proceeds to download and save the model.
  • Supports displaying the download progress in real-time.

Why this is needed:

This feature simplifies the process of pulling models directly from Hugging Face, reducing manual steps and allowing users to focus more on model usage rather than setup.

How to test:

  1. Use a FROM directive with a Hugging Face URL, for example:
    FROM hg://QuantFactory/Qwen2.5-1.5B-Instruct-GGUF/qwen2.5-1.5b-instruct-q8_0
    
  2. Ensure that the model is downloaded to the specified path if it doesn't already exist.
  3. Observe the download progress and verify that the model is being fetched correctly from Hugging Face.

Notes:

  • Make sure to have internet access when testing this feature.
  • This implementation supports the standard Hugging Face URL structure.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/7201 **Author:** [@JoseCarlosGarcia95](https://github.com/JoseCarlosGarcia95) **Created:** 10/14/2024 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (6) - [`ddafbb1`](https://github.com/ollama/ollama/commit/ddafbb1fe1652657b3fa2f7c109e9cee80ff32ab) Include support for getting models from HG - [`806771b`](https://github.com/ollama/ollama/commit/806771b05f30e51d53b65bb015be08311f0e8e80) Merge branch 'feat/hg-download-support' - [`641caa4`](https://github.com/ollama/ollama/commit/641caa46d7f9c04385e1356dfb507046fd1ac219) update llm/llama.cpp to production - [`d9a5748`](https://github.com/ollama/ollama/commit/d9a5748d677abf22caa6a566e64a921e4d501e25) fix cmd.go - [`299ea14`](https://github.com/ollama/ollama/commit/299ea143a0b085552ae12d2806be34b645f68001) fix modelfile.md - [`e647b7e`](https://github.com/ollama/ollama/commit/e647b7e8e280cf8e9dedb9ec8331bf7c95dea327) revert changes to .gitignore ### 📊 Changes **4 files changed** (+159 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+2 -1) 📝 `cmd/cmd.go` (+98 -0) 📝 `docs/modelfile.md` (+7 -0) ➕ `examples/modelfile-from-hg/Modelfile` (+52 -0) </details> ### 📄 Description ### Description: This PR introduces a new feature that allows models specified with the `FROM` keyword to be downloaded directly from Hugging Face if the URL starts with the prefix `hg://`. This enhancement ensures seamless integration with Hugging Face’s model hub, automatically downloading and saving models from the specified Hugging Face URLs. #### Key changes: - Added a check for `hg://` URLs in the `FROM` command. - Implemented a download function that fetches the model from Hugging Face using the provided URL and saves it to the designated path. - If the model file already exists in the target directory, the download is skipped to avoid redundant downloads. - Progress tracking is provided during the download process to ensure visibility of the operation. ### How it works: - The code checks if the `FROM` URL starts with `hg://`. - It then parses the URL and constructs a valid Hugging Face model download link. - If the model doesn't already exist locally, it proceeds to download and save the model. - Supports displaying the download progress in real-time. ### Why this is needed: This feature simplifies the process of pulling models directly from Hugging Face, reducing manual steps and allowing users to focus more on model usage rather than setup. ### How to test: 1. Use a `FROM` directive with a Hugging Face URL, for example: ```bash FROM hg://QuantFactory/Qwen2.5-1.5B-Instruct-GGUF/qwen2.5-1.5b-instruct-q8_0 ``` 2. Ensure that the model is downloaded to the specified path if it doesn't already exist. 3. Observe the download progress and verify that the model is being fetched correctly from Hugging Face. ### Notes: - Make sure to have internet access when testing this feature. - This implementation supports the standard Hugging Face URL structure. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-12 23:56:11 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#12345