[GH-ISSUE #7032] Persistent context #4459

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

Originally created by @tomstdenis on GitHub (Sep 29, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/7032

When using an LLM for say a lesson it'd be nice to prime the LLM with a persistent initial "basic instruction" that never falls out of the window, e.g.

"You're a German language instructor, I'm an Anglophone, help me learn German."

With most LLM drivers (ChatGPT/Ollama/etc) these instructions will fall out of the window and it'll forget what it's doing after about 5-10 mins of use.

It'd be nice to lock a message into the context window and should be fairly simple to implement I'd think.

Originally created by @tomstdenis on GitHub (Sep 29, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/7032 When using an LLM for say a lesson it'd be nice to prime the LLM with a persistent initial "basic instruction" that never falls out of the window, e.g. "You're a German language instructor, I'm an Anglophone, help me learn German." With most LLM drivers (ChatGPT/Ollama/etc) these instructions will fall out of the window and it'll forget what it's doing after about 5-10 mins of use. It'd be nice to lock a message into the context window and should be fairly simple to implement I'd think.
GiteaMirror added the feature request label 2026-04-12 15:23:11 -05:00
Author
Owner

@rick-github commented on GitHub (Sep 29, 2024):

ollama already does this, it's the system prompt. The client specifies a system prompt, and if the messages (system, user, assistant) grow longer than the context window, ollama will discard messages between the system prompt and more recent prompts until they fit in the context window.

<!-- gh-comment-id:2381326925 --> @rick-github commented on GitHub (Sep 29, 2024): ollama already does this, it's the system prompt. The client specifies a system prompt, and if the messages (system, user, assistant) grow longer than the context window, ollama will [discard messages](https://github.com/ollama/ollama/blob/03608cb46ecdccaf8c340c9390626a9d8fcc3c6b/server/prompt.go#L16) between the system prompt and more recent prompts until they fit in the context window.
Author
Owner

@pdevine commented on GitHub (Oct 1, 2024):

@rick-github is correct here. You can also set the system prompt via a Modelfile using the SYSTEM command to set the system prompt for a model. Use ollama create to then create it.

I'll go ahead and close the issue.

<!-- gh-comment-id:2387233085 --> @pdevine commented on GitHub (Oct 1, 2024): @rick-github is correct here. You can also set the system prompt via a `Modelfile` using the `SYSTEM` command to set the system prompt for a model. Use `ollama create` to then create it. I'll go ahead and close the issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#4459