Skip to content

ISamplingPipeline

Namespace: LLama.Sampling

Convert a span of logits into a single sampled token. This interface can be implemented to completely customise the sampling process.

1
public interface ISamplingPipeline : System.IDisposable

Implements IDisposable

Methods

Sample(SafeLLamaContextHandle, Span<Single>, ReadOnlySpan<LLamaToken>)

Sample a single token from the given logits

1
LLamaToken Sample(SafeLLamaContextHandle ctx, Span<float> logits, ReadOnlySpan<LLamaToken> lastTokens)

Parameters

ctx SafeLLamaContextHandle
The context being sampled from

logits Span<Single>
The logits produced by the model

lastTokens ReadOnlySpan<LLamaToken>
A span of tokens recently returned by the model

Returns

LLamaToken

Accept(SafeLLamaContextHandle, LLamaToken)

Update the pipeline, with knowledge that a particular token was just accepted

1
void Accept(SafeLLamaContextHandle ctx, LLamaToken token)

Parameters

ctx SafeLLamaContextHandle

token LLamaToken

Reset()

Reset all internal state of the sampling pipeline

1
void Reset()

Clone()

Create a copy of this sampling pipeline

1
ISamplingPipeline Clone()

Returns

ISamplingPipeline