If you already use Ollama and have downloaded GGUF models, localLLM can discover and load them directly without re-downloading. This saves disk space and bandwidth by reusing models you’ve already installed.
Use list_ollama_models() to see all GGUF models managed
by Ollama:
#> name size path
#> 1 llama3.2 2.0 GB ~/.ollama/models/blobs/sha256-6340dc32...
#> 2 deepseek-r1:8b 4.9 GB ~/.ollama/models/blobs/sha256-8a2b7c9e...
#> 3 gemma2:9b 5.4 GB ~/.ollama/models/blobs/sha256-9f8a7b6c...
You can reference Ollama models in several ways:
The model_path parameter triggers Ollama model discovery
when it matches specific patterns:
| Input | Triggers Ollama | Description |
|---|---|---|
"ollama" |
Yes | Exact match (case-insensitive) |
"Ollama" |
Yes | Case-insensitive |
" ollama " |
Yes | Whitespace is trimmed |
"ollama:llama3" |
Yes | Starts with ollama: |
"ollama:deepseek-r1:8b" |
Yes | Full model name with tag |
"ollama:6340dc32" |
Yes | SHA256 prefix (8+ chars recommended) |
"myollama" |
No | Not exact match, doesn’t start with ollama: |
"ollama.gguf" |
No | Treated as filename, not Ollama reference |
# Load by exact name
model <- model_load("ollama:llama3.2")
# Create context and generate
ctx <- context_create(model, n_ctx = 4096)
messages <- list(
list(role = "user", content = "What is machine learning?")
)
prompt <- apply_chat_template(model, messages)
response <- generate(ctx, prompt, max_tokens = 200)
cat(response)Ollama stores models in a specific location:
~/.ollama/models/~/.ollama/models/%USERPROFILE%\.ollama\models\The actual GGUF files are stored in:
~/.ollama/models/blobs/sha256-<hash>
localLLM reads the Ollama manifest files to map model names to their blob locations.
#> Error: No Ollama model found matching 'nonexistent'.
#> Available models: llama3.2, deepseek-r1:8b, gemma2:9b
Solution: Check available models with
list_ollama_models() and verify the name.
#> Warning: Ollama directory not found at ~/.ollama/models
#> data frame with 0 columns and 0 rows
Solution: Install Ollama from ollama.com and pull some models:
list_ollama_models()
shows what’s availablelibrary(localLLM)
# 1. Check what's available
available <- list_ollama_models()
print(available)
# 2. Load a model
model <- model_load("ollama:llama3.2", n_gpu_layers = 999)
# 3. Create context
ctx <- context_create(model, n_ctx = 4096)
# 4. Generate text
messages <- list(
list(role = "system", content = "You are a helpful assistant."),
list(role = "user", content = "Write a haiku about coding.")
)
prompt <- apply_chat_template(model, messages)
response <- generate(ctx, prompt, max_tokens = 50, temperature = 0.7)
cat(response)#> Lines of code flow
#> Logic builds like morning dew
#> Bugs hide, then we debug
| Function | Purpose |
|---|---|
list_ollama_models() |
Discover available Ollama models |
model_load("ollama:name") |
Load specific Ollama model |
model_load("ollama") |
Interactive model selection |