Skip to content

Commit

Permalink
Rebased onto master and fixed breakage due to changes in `BaseSamplin…
Browse files Browse the repository at this point in the history
…gPipeline`
  • Loading branch information
martindevans committed Feb 25, 2024
1 parent 8526d6b commit 879c62e
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions LLama.Examples/Examples/BatchedExecutorGuidance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,20 @@ public override ISamplingPipeline Clone()
throw new NotSupportedException();
}

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

protected override void ProcessLogits(SafeLLamaContextHandle ctx, Span<float> logits, ReadOnlySpan<LLamaToken> lastTokens)
{
if (guidance != null)
{
// Get the logits generated by the guidance sequences
var guidanceLogits = guidance.Sample();
var logitsCopy = logits.ToArray();

// Get the logits generated by the guidance sequences
var guidanceLogits = guidance.Sample();

// Use those logits to guide this sequence
NativeApi.llama_sample_apply_guidance(ctx, logitsCopy, guidanceLogits, 2);

// Use those logits to guide this sequence
NativeApi.llama_sample_apply_guidance(ctx, logits, guidanceLogits, 2);
}
return logitsCopy;
}

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

0 comments on commit 879c62e

Please sign in to comment.