Skip to content

Commit 879c62e

Browse files
committed
Rebased onto master and fixed breakage due to changes in BaseSamplingPipeline
1 parent 8526d6b commit 879c62e

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

LLama.Examples/Examples/BatchedExecutorGuidance.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,20 @@ public override ISamplingPipeline Clone()
9797
throw new NotSupportedException();
9898
}
9999

100-
protected override IReadOnlyList<LLamaToken> GetProtectedTokens(SafeLLamaContextHandle ctx)
100+
protected override ReadOnlySpan<float> ProcessLogits(SafeLLamaContextHandle ctx, ReadOnlySpan<float> logits, ReadOnlySpan<LLamaToken> lastTokens)
101101
{
102-
return Array.Empty<LLamaToken>();
103-
}
102+
if (guidance == null)
103+
return logits;
104104

105-
protected override void ProcessLogits(SafeLLamaContextHandle ctx, Span<float> logits, ReadOnlySpan<LLamaToken> lastTokens)
106-
{
107-
if (guidance != null)
108-
{
109-
// Get the logits generated by the guidance sequences
110-
var guidanceLogits = guidance.Sample();
105+
var logitsCopy = logits.ToArray();
106+
107+
// Get the logits generated by the guidance sequences
108+
var guidanceLogits = guidance.Sample();
109+
110+
// Use those logits to guide this sequence
111+
NativeApi.llama_sample_apply_guidance(ctx, logitsCopy, guidanceLogits, 2);
111112

112-
// Use those logits to guide this sequence
113-
NativeApi.llama_sample_apply_guidance(ctx, logits, guidanceLogits, 2);
114-
}
113+
return logitsCopy;
115114
}
116115

117116
protected override LLamaToken ProcessTokenDataArray(SafeLLamaContextHandle ctx, LLamaTokenDataArray candidates, ReadOnlySpan<LLamaToken> lastTokens)

0 commit comments

Comments
 (0)