Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion LLama/Sampling/DefaultSamplingPipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ public override LLamaToken Sample(SafeLLamaContextHandle ctx, int index)
}

// Extended optimization : Apply the grammar to the TopK tokens and check if the selected token is valid
if (GrammarOptimization == GrammarOptimizationMode.Extended)
// Only run if TopK > 0
if (GrammarOptimization == GrammarOptimizationMode.Extended && TopK > 0)
{
// Calculate a safe TopK value
var safeTopK = Math.Min(TopK, nativeAll.Data.Length);
Expand Down
Loading