You will download a model automatically if you run “ollama run xxx” for the first time. But I want to download the model directly from a webpage and import it to ollama. How should I do?
You can download a model file directly from a webpage (like Hugging Face) in GGUF format and import it into Ollama using a local configuration file called a Modelfile
A GGUF file is a single binary file that contains an AI model’s weights and metadata. Ollama is the local tool that runs these models on your computer.
Step 1: Download the GGUF File from a Webpage
- Go to a model repository on Hugging Face Hub.
- Look for a repository that offers GGUF versions of the model (for example, search for
Llama-3.2-3B-Instruct-GGUF).
- Go to the Files and versions tab.
- Choose a quantized file size that fits your computer’s memory (e.g.,
Q4_K_Mis a good balance of speed and quality).
- Click Download to save the
.gguffile directly through your web browser. Move this file to a permanent folder on your computer (e.g.,C:\Models\or~/Documents/LLM/).
Step 2: Create a
Modelfile- Create a new, blank text file in the same folder where you saved your
.gguffile.
- Name the file
Modelfileand make sure it has no file extension (do not save it asModelfile.txt).
- Open the file in a text editor (like Notepad or VS Code) and add a single line pointing to your downloaded file:
dockerfile
FROM /path/to/your/downloaded-model-file.gguf(If you are on Windows, use the full path like
FROM C:\Models\model-name.gguf. On Mac/Linux, use/Users/name/Models/model-name.gguf)save and close the file.
Step 3: Import the Model into Ollama
- Open your terminal (Command Prompt, PowerShell, or Terminal).
- Run the
ollama createcommand to import the model into your local Ollama library, giving it a custom name of your choice:bashollama create my-custom-model -f /path/to/your/Modelfile Once the import finishes, run your newly added model offline using the standard command: ollama run my-custom-model