[PR #13342] server: add env variable to preload models #60868

Open
opened 2026-04-29 15:59:05 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13342
Author: @YetheSamartaka
Created: 12/5/2025
Status: 🔄 Open

Base: mainHead: preload-models


📝 Commits (2)

  • 3357cf6 server: add env variable to preload models
  • 95a9a1d Merge branch 'main' into preload-models

📊 Changes

5 files changed (+280 additions, -0 deletions)

View changed files

📝 cmd/cmd.go (+1 -0)
📝 docs/faq.mdx (+16 -0)
📝 envconfig/config.go (+6 -0)
server/preload.go (+249 -0)
📝 server/routes.go (+8 -0)

📄 Description

You can also have Ollama preload models automatically at startup with the OLLAMA_PRELOAD_MODELS environment variable. Provide a comma-separated list of models and optional query-style parameters (the same keys you would pass with ollama run model parameters) to tune the warm-up request:

OLLAMA_PRELOAD_MODELS="llama3.2,phi3?temperature=0.2&num_ctx=4096&keepalive=30m" ollama serve
  • Each item is processed in order. Parameters such as temperature, num_ctx, or other model options are sent just like using ollama run -p key=value.
  • Use keepalive to control how long the preloaded model stays in memory (e.g., keepalive=-1 to keep it loaded).
  • Optional prompt lets you send text during warm-up; embedding models automatically use "init" so they receive a required input without you having to specify it.

For embedding models, a simple configuration like the following warms the model with the implicit "init" prompt and leaves it loaded:

OLLAMA_PRELOAD_MODELS="mxbai-embed-large?keepalive=-1" ollama serve

🔄 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/13342 **Author:** [@YetheSamartaka](https://github.com/YetheSamartaka) **Created:** 12/5/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `preload-models` --- ### 📝 Commits (2) - [`3357cf6`](https://github.com/ollama/ollama/commit/3357cf6d103c7f3089bb1cb3d8158ddf06e2741a) server: add env variable to preload models - [`95a9a1d`](https://github.com/ollama/ollama/commit/95a9a1d8dd68213f7acbac566d89734fbaa14285) Merge branch 'main' into preload-models ### 📊 Changes **5 files changed** (+280 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `cmd/cmd.go` (+1 -0) 📝 `docs/faq.mdx` (+16 -0) 📝 `envconfig/config.go` (+6 -0) ➕ `server/preload.go` (+249 -0) 📝 `server/routes.go` (+8 -0) </details> ### 📄 Description You can also have Ollama preload models automatically at startup with the `OLLAMA_PRELOAD_MODELS` environment variable. Provide a comma-separated list of models and optional query-style parameters (the same keys you would pass with `ollama run` model parameters) to tune the warm-up request: ```shell OLLAMA_PRELOAD_MODELS="llama3.2,phi3?temperature=0.2&num_ctx=4096&keepalive=30m" ollama serve ``` - Each item is processed in order. Parameters such as `temperature`, `num_ctx`, or other model options are sent just like using `ollama run -p key=value`. - Use `keepalive` to control how long the preloaded model stays in memory (e.g., `keepalive=-1` to keep it loaded). - Optional `prompt` lets you send text during warm-up; embedding models automatically use `"init"` so they receive a required input without you having to specify it. For embedding models, a simple configuration like the following warms the model with the implicit `"init"` prompt and leaves it loaded: ```shell OLLAMA_PRELOAD_MODELS="mxbai-embed-large?keepalive=-1" ollama serve ``` --- <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-29 15:59:05 -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#60868