SSD Nodes Learn Hosting plans →
How to do am Matt ConnorBy Matt Connor · Updated 2026-11-10

How to import GGUF model enter Ollama

Learn how to run .gguf from Hugging Face or local disk for Ollama, plus fix chat template mismatch wey makes imported models reply with garbage.

Two ways to import a GGUF model into Ollama

Ways dey two to import GGUF model into Ollama, and the correct one depend on where the file dey now. If the model dey for Hugging Face repository, one ollama run command go pull am and run am, without any Modelfile. If the .gguf file don already dey your server disk, you go write one-line Modelfile and run ollama create.

Both methods end for the same place: named model for your local Ollama library wey ollama run and Ollama API fit serve. Use the first method when another person publish the file. Use the second one when na you quantize the model, when the file enter through scp or rsync, or when the machine no fit reach Hugging Face.

GGUF file na one binary wey hold the weights, tokenizer, and model metadata together. Na the format wey llama.cpp dey read, and Ollama build on llama.cpp. Na why almost every open model get community GGUF conversion. Ollama fit also import directory of .safetensors weights, but na separate method, and the section about --quantize below show where e fit enter.

Everything below assume say Ollama don already install and the service dey run. If e no dey run, start with installing Ollama for VPS and come back. Run ollama list first. If e return table, even if the table empty, instead of connection error, the server dey up and the rest of this guide go work.

Route one: run one GGUF from Hugging Face without Modelfile

Ollama fit pull one GGUF directly from one Hugging Face repository. The command na the repository path with hf.co/ prefix:

ollama run hf.co/{username}/{repository}

Both hf.co and huggingface.co fit work as the domain name. See one real example from the Hugging Face documentation:

ollama run hf.co/bartowski/Llama-3.2-3B-Instruct-GGUF

The first time, e go download the file, so chat prompt no go show until the download finish. After that, the model don enter your local library and e go start quickly. Open another shell and run ollama list to see the name wey Ollama store am with. That name na the complete hf.co/... string with the tag, and e long to type every time. Give am short alias:

ollama cp hf.co/bartowski/Llama-3.2-3B-Instruct-GGUF my-llama
ollama run my-llama

This route dey work only for repositories wey really contain GGUF files. If repository publish .safetensors weights only, and nothing else, this route no get anything to fetch. You need one of the local imports wey dey described further down.

Which quantization does Ollama pick?

Hugging Face Ollama documentation, as read on 10 October 2026, clear about the default: "By default, the Q4_K_M quantization scheme is used, when it's present inside the model repo. If not, we default to picking one reasonable quant type present inside the repo." So, if one repository publish ten quants, Ollama go give you Q4_K_M. If the repository no get Q4_K_M, Ollama go choose one for you. Read that page again before you depend on this behaviour, because defaults fit change.

Ask for one specific quant by adding am as a tag:

ollama run hf.co/{username}/{repository}:{quantization}
ollama run hf.co/bartowski/Llama-3.2-3B-Instruct-GGUF:Q8_0
ollama run hf.co/bartowski/Llama-3.2-3B-Instruct-GGUF:iq3_m
ollama run hf.co/bartowski/Llama-3.2-3B-Instruct-GGUF:Llama-3.2-3B-Instruct-IQ3_M.gguf

The quantization name no dey case-sensitive, so :iq3_m and :IQ3_M mean the same thing. You fit also pass the exact filename as the tag. This na the safe option when the short names for one repository fit confuse. The tag must name a file wey dey exist inside that repository. So open the Files and versions tab and check the real filenames before you type one. The quant wey you choose depend on memory and quality. The difference between Q4, Q8 and FP16 explain that trade-off well.

Route two: import a .gguf file from your own disk

When the file don already dey for the server, you need a Modelfile. E fit be one line. Create directory, put the Modelfile inside, then point FROM to the file:

mkdir -p ~/models/my-model
cd ~/models/my-model
FROM /home/you/models/my-model-Q4_K_M.gguf

Save am as Modelfile, then build the model:

ollama create my-model

By default, ollama create dey read file wey dem call Modelfile for the current directory. Use -f when your file get another name or dey somewhere else, like ollama create my-model -f /home/you/models/my-model/Modelfile. Run ollama create --help to see the flag and the default value for your build. The path for FROM fit be absolute, or relative to the Modelfile, so FROM ./my-model-Q4_K_M.gguf go work when both dey inside the same directory. Absolute path remove the doubt completely.

Check the result before you trust am:

ollama list
ollama show my-model
ollama run my-model "Reply with one short sentence."

ollama list suppose now include my-model. ollama show my-model go print the architecture, parameter count, context length, and quantization wey Ollama read from the file own metadata. Read those values instead of trusting the filename, because filename na just text wey person type by hand. If the model answer your test prompt with normal language and then stop, the import work. If e no work, go to the template section below, because na almost always that cause.

Make you know one thing about disk space: ollama create copy the GGUF into Ollama own model store instead of referencing the file where e dey. The weights go dey for disk twice until you remove the original. Delete the source file after ollama run my-model work, or keep am for somewhere wey you no go pay for the space twice. where Ollama dey keep its models for disk get the layout and how to move am.

When --quantize applies, and when e no apply

ollama create get a --quantize flag, and today e apply to only one case: model wey you import from directory of .safetensors weights. The help text for the current Ollama source, checked on 10 October 2026, talk say "Quantize safetensors model to this level (e.g. nvfp4)", and the canonical values na int4, int8, nvfp4, mxfp4 and mxfp8. FP4 and Q4 dey accepted as aliases for int4, while FP8 and Q8 dey accepted as aliases for int8. GGUF quant names like q8_0 or q4_K_M go dey rejected as unsupported types. Ollama import documentation talk am clearly for the GGUF side: "Ollama does not quantize GGUF models during import."

ollama create --quantize int8 my-model

That command assume say Modelfile own FROM line point to the directory wey hold the .safetensors files.

No pass that flag when FROM name a .gguf, no matter the precision. FP16 or FP32 GGUF go get refused the same way as Q4_K_M, with error wey start with "create-time quantization is only supported for safetensors imports". A .gguf wey get Q4_K_M or Q5_K_S for the name don already undergo quantization, and the precision wey e throw away no fit come back. llama.cpp's llama-quantize fit re-encode that kind file as another type, including Q8_0, when you pass --allow-requantize, but the manual warn say this "can severely reduce quality compared to quantizing from 16bit or 32bit". Also, Q4 file wey you rewrite as Q8 go bigger without becoming better. To reduce the size of full-precision GGUF, run llama-quantize on am first. Na the tool wey Ollama documentation point to. Then import the file wey e write. If your source na Hugging Face repository of .safetensors files, you fit point FROM to that directory and let ollama create import am, using --quantize if you want make e smaller. Or you fit convert am with convert_hf_to_gguf.py from the llama.cpp repository, then import the GGUF wey that script write. How Ollama and llama.cpp relate explain why those tools belong to the other project.

Why imported GGUF dey reply with garbage or e no dey stop?

Na this failure most import tutorials dey skip, and na am you go meet. The symptoms go look like say model don spoil. Control tokens go show as visible text for reply, like <|im_start|>assistant or <|end|>. Model go answer, then e go write new user question and answer that one too. Generation go continue until you press Ctrl+C.

Model dey okay. Na chat template dey wrong. Chat template na wrapper wey dey turn your message into the exact token sequence wey model train with, including the model own markers for where system prompt end and user turn start. Ollama dey choose one for you: documentation talk say template "will be selected automatically from a list of commonly used templates", based on built-in tokenizer.chat_template metadata wey dey inside GGUF file. If that metadata no dey, or e no match anything for the list, you go get generic wrapper. Model go then see prompt wey no resemble anything for its training, so e no go ever meet the end-of-turn marker wey e learn to stop on.

Print the template wey Ollama actually choose:

ollama show --template my-model
ollama show --modelfile my-model

If template empty or e clearly generic, that confirm am. Write the template yourself inside Modelfile:

FROM /home/you/models/my-model-Q4_K_M.gguf

TEMPLATE """{{ if .System }}<|system|>
{{ .System }}<|end|>
{{ end }}{{ if .Prompt }}<|user|>
{{ .Prompt }}<|end|>
{{ end }}<|assistant|>
{{ .Response }}<|end|>"""

PARAMETER stop "<|end|>"

Rebuild with ollama create my-model and send the same test prompt again. The stop parameter na your safety net: e tell Ollama to cut generation when that string appear. This go end the never-stops symptom even while you still dey tune the wrapper itself. If reply still continue because no marker wey you name ever appear, num_predict ceiling go cut am off at fixed token count, no matter wetin template emit.

The template must be a Go template, not a Jinja template. Hugging Face documentation talk this directly, and e matter because tokenizer.chat_template field for original model repository dey hold Jinja. If you paste am unchanged, e no go work. Ollama syntax get three variables: {{ .System }} for system prompt, {{ .Prompt }} for user message, and {{ .Response }} for model reply. Find the real turn markers for the model inside its model card or its tokenizer_config.json, then rewrite dem into that Go syntax by hand.

One shortcut fit save you most of this work. Plenty models share common prompt format. So if another model for your library dey use the same one, run ollama show --template against am and copy wetin e print.

The template, system and params files wey dey for Hugging Face repo

The Hugging Face method get the same controls as files wey dey inside repository, instead of instructions wey dey inside Modelfile. If na you own the repository, or you dey publish your own quant, add dem there and every ollama run hf.co/... go pick dem up.

  • File wey dem name template dey hold the Go template. Same rule: na Go, no be Jinja.
  • File wey dem name system dey hold the system prompt.
  • File wey dem name params dey hold sampling parameters, and e must be JSON.

A minimal params file:

{
  "stop": ["<|end|>"],
  "temperature": 0.7
}

When repository no belong to you, you no fit add those files. Pull the model once, run ollama show --modelfile hf.co/... to dump wetin dem give you, then save that output as Modelfile. Its FROM line dey point to the blob wey Ollama don already download, so you fit edit TEMPLATE and PARAMETER lines, then run ollama create to build a fixed local copy without downloading anything again. Na the standard way to repair another person broken quant.

How to import private GGUF repo

Private repository need Ollama SSH key for your Hugging Face account. The documented method for this route dey use SSH key instead of API token.

Print the public key. For Linux server wey you install Ollama with the official script, the service dey run as the ollama user, so the key dey inside that user's home directory:

sudo cat /usr/share/ollama/.ollama/id_ed25519.pub

If you start ollama serve yourself as your own user, the path na ~/.ollama/id_ed25519.pub instead. Copy the complete line, open your Hugging Face account settings for https://huggingface.co/settings/keys, then add am as new SSH key. The normal command go then work for your private repositories:

ollama run hf.co/{username}/{repository}

If the pull still fail after you add the key, you likely print the wrong file. Na the server dey perform the download and present its own key. Also, server wey systemd start no ever read your user's ~/.ollama, so the key wey dey under your home directory no be the one Hugging Face dey see.

Model go fit for your VPS?

The number wey decide this na the file size for disk plus the memory wey your context window need. The weights go load into memory close to the size wey dem occupy for the file, and context allocation dey sit on top of that. E go grow based on the number of tokens wey you allow. Run ollama list to read the size wey Ollama record for the model. Compare am with free -h for the box, and leave extra memory for the operating system and anything else wey the server dey run. If you prefer see this calculation already done for real model, running Nemotron 3.5 Lightning on a VPS gives the exact tag to pull, the RAM wey e need, and whether CPU-only box fit keep up.

Context na the part wey people dey forget. Model fit load with the default window but fail after you increase num_ctx, because that allocation dey scale with the window wey you request. Setting num_ctx and wetin e cost for memory get the sizing details. When the total memory too much, the usual fix na to use smaller quant of the same model. Na this trade-off the Q4 against Q8 comparison dey cover. If even Q4 still too big for your box, how to run Ternary Bonsai 2 27B for CPU VPS show how 27B model wey dem pack for 1.72 bits fit enter 12 to 16 GB of RAM, but that one dey run through special llama.cpp fork, no be through Ollama import.

For CPU-only VPS, memory exhaustion fit trigger the kernel out of memory killer or make memory allocations fail. With overcommit mode 2, Linux dey limit committed memory and, for most situations, e dey return allocation errors instead of killing the process when e access pages. If process get killed, check journalctl -u ollama -n 50 together with dmesg to see the kill. For box wey get GPU, ollama ps go print a PROCESSOR column. This one tells you whether the loaded model enter GPU memory, system memory, or split between both. Model wey spill enter system memory still fit answer, but e go slow. Measuring tokens per second turns “slow” into number wey you fit compare between quants.

Check wetin you import

Run these four commands after any import, for this order:

ollama list
ollama show my-model
ollama show --modelfile my-model
ollama run my-model "Reply with one short sentence."

ollama list dey prove say the model dey exist and show the size wey Ollama record. ollama show dey prove say Ollama read the metadata wey e need from the GGUF. ollama show --modelfile dey prove which template and parameters e go really use. Na this check dey catch garbage-output failure before your users notice am. The test prompt dey exercise the whole chain, because model wey get broken template go fail even for the shortest request. Once that prompt return clean, the name wey you give the model na the same name you go hand to anything else wey dey talk to the Ollama API, including a coding agent wey point to your own server. Imported model still dey answer only from its weights, because Ollama no dey browse by itself. So if you need current facts from am, give am web search through Ollama's search API, Open WebUI with SearXNG, or short Python tool loop. Use ollama rm my-model to remove bad import and build am again. That command go delete Ollama's copy and leave your source .gguf untouched.

FAQ

I fit import a GGUF go Ollama without writing a Modelfile?

Yes, if the file dey inside a Hugging Face repository. ollama run hf.co/{username}/{repository} go pull am and run am directly, while ollama run hf.co/{username}/{repository}:{quantization} go select one specific quant. You only need Modelfile for a .gguf wey already dey your own disk. For that case, e fit be just the single line FROM /path/to/file.gguf, followed by ollama create my-model.

Which quantization Ollama go download if I no specify one?

Hugging Face documentation, as dem read am on 10 October 2026, talk say Q4_K_M go dey used when that quant dey inside the repository. Otherwise, Ollama go choose one reasonable quant type wey dey inside the repo. Add tag like :Q8_0 to control the choice. Confirm wetin you actually receive with ollama show <model>. E go print the quantization from the file metadata, instead of from the file name.

Why my imported model dey repeat itself or e no dey stop generating?

The chat template no match the model. Ollama dey automatically choose template from the tokenizer.chat_template metadata inside the GGUF. If that metadata dey missing or Ollama no recognise am, you go get generic wrapper. Because of that, the model no dey see the end-of-turn marker wey dem train am with. Print the current template with ollama show --template <model>. Then add a TEMPLATE block and a PARAMETER stop line to the Modelfile, and run ollama create again. Write am as a Go template. The Jinja template from the original repository no go work.

I suppose use --quantize on GGUF wey I download?

No. --quantize dey work only for safetensors imports during ollama create. E rejects every GGUF source, including FP16 or FP32, and e go show error wey tell you to quantize GGUF models before importing. If file name already get quant like Q4_K_M, dem don convert am. Quantizing am again no fit restore the precision wey e don lose. llama-quantize --allow-requantize fit rewrite am as Q8_0, but the result go bigger without becoming better. To get smaller file from full precision GGUF, run llama.cpp's llama-quantize on am, then import the result.

How I fit pull private GGUF repository?

Add Ollama SSH public key to your Hugging Face account. For standard Linux install, print am with sudo cat /usr/share/ollama/.ollama/id_ed25519.pub. If you dey run the server as your own user, print am from ~/.ollama/id_ed25519.pub. Then add the key for your account SSH key settings page. After that, ollama run hf.co/{username}/{repository} go work for your own private repositories and repositories inside organisation wey you belong to.

Dis article help you?

#ollama#gguf#local-llm#hugging-face#modelfile