numCtx method

OllamaBuilder numCtx(
  1. int contextLength
)

Sets the context window size (number of tokens)

Controls the size of the context window used to generate the next token. Larger values use more memory but can handle longer conversations.

  • Default: Model-specific (usually 2048-4096)
  • Range: Depends on model, typically 512-32768+
  • Higher values: Better long-term memory, more GPU memory usage
  • Lower values: Less memory usage, shorter context retention

Implementation

OllamaBuilder numCtx(int contextLength) {
  _baseBuilder.extension('numCtx', contextLength);
  return this;
}