Skip to content

Conversation

mcowger
Copy link
Contributor

@mcowger mcowger commented Aug 31, 2025

  • Add parseOllamaParametersToJSON function to properly parse model parameters
  • Enhance context window detection by checking model_info keys ending with '.context_length'
  • Prioritize environment variable OLLAMA_CONTEXT_LENGTH over model defaults
  • Update default context window from 200K to 128K to match common Ollama models
  • Fix maxTokens assignment to use defined context window

This change ensures more accurate context window detection for Ollama models and provides better handling of model parameters.

Context

Previous effort didn't quite work with models that had a large default context (like qwen3:8b) of 256K.

Implementation

New method does more careful parsing of the parameters field returned by Ollama. If thats set, it uses that.
Other wise, it uses the default context that is set in the model architecture section (qwen3.context_window or gemma3._context_window).
If the env var is sat, that overrides all.
Lastly, it uses the default hardcoded, which is changed to be 128K, matching the top 3 models on ollama library.

Get in Touch

mcowger

- Add parseOllamaParametersToJSON function to properly parse model parameters
- Enhance context window detection by checking model_info keys ending with '.context_length'
- Prioritize environment variable OLLAMA_CONTEXT_LENGTH over model defaults
- Update default context window from 200K to 128K to match common Ollama models
- Fix maxTokens assignment to use defined context window

This change ensures more accurate context window detection for Ollama models
and provides better handling of model parameters.
Copy link

changeset-bot bot commented Aug 31, 2025

⚠️ No Changeset found

Latest commit: ee2c4b9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant