[GH-ISSUE #5138] [FEAT]: context loading of models. #4935

Closed
opened 2026-06-05 14:50:58 -04:00 by yindo · 2 comments
Owner

Originally created by @iplayfast on GitHub (Mar 4, 2026).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/5138

What would you like to see?

I'm using ollama on my desktop and it's working well, except it loads the huge model for every request. This, of course slows everything down.
An enhancement I would like to see is the option to load a lightweight mode that's always loaded, that 1. First determings if the request is simple or complex, and if simple just handles it, and if complex hands it of the the larger model. The larger model could be on the cloud or local.

Originally created by @iplayfast on GitHub (Mar 4, 2026). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/5138 ### What would you like to see? I'm using ollama on my desktop and it's working well, except it loads the huge model for every request. This, of course slows everything down. An enhancement I would like to see is the option to load a lightweight mode that's always loaded, that 1. First determings if the request is simple or complex, and if simple just handles it, and if complex hands it of the the larger model. The larger model could be on the cloud or local.
yindo added the enhancementfeature request labels 2026-06-05 14:50:58 -04:00
yindo closed this issue 2026-06-05 14:50:59 -04:00
Author
Owner

@timothycarambat commented on GitHub (Mar 4, 2026):

In the Ollama provider expand "advanced options" and just set a context window limit you wish to have, this is all that is going on. We already set a max token context of 16K (or less if the model doesnt support that) we will not lower this automatic window because we have already had a number of issues about Ollamas default 8K window (previously was 4k!!) and how it would break the tool calling flow from its super small window.

If you are on a device that is resource limited that 16K can still sometimes be a lot as the KV cache fills. Maybe in the future we can do some basic RAM/VRAM math to make the assumed default max lower to fit on smaller devices, but in general and from feedback - people want the largest window. However, asking for a 264K windows is usually overkill - so we landed on 16k :)

https://github.com/Mintplex-Labs/anything-llm/blob/e10b8d7b35dc6299c0c308147532fab23dd4d6cb/server/utils/AiProviders/ollama/index.js#L170

This detail:

An enhancement I would like to see is the option to load a lightweight mode that's always loaded, that 1. First determings if the request is simple or complex, and if simple just handles it, and if complex hands it of the the larger model. The larger model could be on the cloud or local.

Is called model routing and in its most simple form you are doing this on context window, but we actually plan on a more flexible routing solution that will make other solutions look quaint!

<!-- gh-comment-id:4000526887 --> @timothycarambat commented on GitHub (Mar 4, 2026): In the Ollama provider expand "advanced options" and just set a context window limit you wish to have, this is all that is going on. We already set a max token context of 16K (or less if the model doesnt support that) we will not lower this automatic window because we have already had a number of issues about Ollamas default 8K window (previously was 4k!!) and how it would break the tool calling flow from its super small window. If you are on a device that is resource limited that 16K can still sometimes be a lot as the KV cache fills. Maybe in the future we can do some basic RAM/VRAM math to make the assumed default max lower to fit on smaller devices, but in general and from feedback - people want the largest window. However, asking for a 264K windows is usually overkill - so we landed on 16k :) https://github.com/Mintplex-Labs/anything-llm/blob/e10b8d7b35dc6299c0c308147532fab23dd4d6cb/server/utils/AiProviders/ollama/index.js#L170 This detail: > An enhancement I would like to see is the option to load a lightweight mode that's always loaded, that 1. First determings if the request is simple or complex, and if simple just handles it, and if complex hands it of the the larger model. The larger model could be on the cloud or local. Is called model routing and in its most simple form you are doing this on context window, but we actually plan on a more flexible routing solution that will make other solutions look quaint!
Author
Owner

@iplayfast commented on GitHub (Mar 4, 2026):

Cool!

<!-- gh-comment-id:4000607234 --> @iplayfast commented on GitHub (Mar 4, 2026): Cool!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#4935