Table of Contents

Property MaxContextWindowCharacters

Namespace
LMKit.Retrieval
Assembly
LM-Kit.NET.dll

MaxContextWindowCharacters

Gets or sets the maximum total payload characters allowed in the expanded result set after context window expansion.

public int MaxContextWindowCharacters { get; set; }

Property Value

int

A non-negative integer. Default is 0 (unlimited).

Examples

LM embeddingModel = LM.LoadFromModelID("embeddinggemma-300m");
RagEngine ragEngine = new RagEngine(embeddingModel);

// Enable context window expansion with a character budget
ragEngine.ContextWindow = 3;
ragEngine.MaxContextWindowCharacters = 8000;

Remarks

When ContextWindow is active, expansion can produce a large amount of context text, especially with many matches across long sections. Setting this property limits the cumulative character count of all partition payloads in the expanded results. Once the budget is exhausted, no further neighbor partitions are added.

Anchor partitions (original matches) are always included regardless of the budget. Only neighbor partitions added during expansion are subject to the cap.

Share