LLamaSharp/docs/xmldocs/llama.statefulexecutorbase.md

5.6 KiB

StatefulExecutorBase

Namespace: LLama

The base class for stateful LLama executors.

public abstract class StatefulExecutorBase : LLama.Abstractions.ILLamaExecutor

Inheritance ObjectStatefulExecutorBase
Implements ILLamaExecutor

Properties

Context

The context used by the executor.

public LLamaContext Context { get; }

Property Value

LLamaContext

Methods

WithSessionFile(String)

This API is currently not verified.

public StatefulExecutorBase WithSessionFile(string filename)

Parameters

filename String

Returns

StatefulExecutorBase

Exceptions

ArgumentNullException

RuntimeError

SaveSessionFile(String)

This API has not been verified currently.

public void SaveSessionFile(string filename)

Parameters

filename String

HandleRunOutOfContext(Int32)

After running out of the context, take some tokens from the original prompt and recompute the logits in batches.

protected void HandleRunOutOfContext(int tokensToKeep)

Parameters

tokensToKeep Int32

TryReuseMathingPrefix()

Try to reuse the matching prefix from the session file.

protected void TryReuseMathingPrefix()

GetLoopCondition(InferStateArgs)

Decide whether to continue the loop.

protected abstract bool GetLoopCondition(InferStateArgs args)

Parameters

args InferStateArgs

Returns

Boolean

PreprocessInputs(String, InferStateArgs)

Preprocess the inputs before the inference.

protected abstract void PreprocessInputs(string text, InferStateArgs args)

Parameters

text String

args InferStateArgs

PostProcess(IInferenceParams, InferStateArgs, IEnumerable`1&)

Do some post processing after the inference.

protected abstract bool PostProcess(IInferenceParams inferenceParams, InferStateArgs args, IEnumerable`1& extraOutputs)

Parameters

inferenceParams IInferenceParams

args InferStateArgs

extraOutputs IEnumerable`1&

Returns

Boolean

InferInternal(IInferenceParams, InferStateArgs)

The core inference logic.

protected abstract void InferInternal(IInferenceParams inferenceParams, InferStateArgs args)

Parameters

inferenceParams IInferenceParams

args InferStateArgs

SaveState(String)

Save the current state to a file.

public abstract void SaveState(string filename)

Parameters

filename String

GetStateData()

Get the current state data.

public abstract ExecutorBaseState GetStateData()

Returns

ExecutorBaseState

LoadState(ExecutorBaseState)

Load the state from data.

public abstract void LoadState(ExecutorBaseState data)

Parameters

data ExecutorBaseState

LoadState(String)

Load the state from a file.

public abstract void LoadState(string filename)

Parameters

filename String

Infer(String, IInferenceParams, CancellationToken)

Execute the inference.

public IEnumerable<string> Infer(string text, IInferenceParams inferenceParams, CancellationToken cancellationToken)

Parameters

text String

inferenceParams IInferenceParams

cancellationToken CancellationToken

Returns

IEnumerable<String>

InferAsync(String, IInferenceParams, CancellationToken)

Execute the inference asynchronously.

public IAsyncEnumerable<string> InferAsync(string text, IInferenceParams inferenceParams, CancellationToken cancellationToken)

Parameters

text String

inferenceParams IInferenceParams

cancellationToken CancellationToken

Returns

IAsyncEnumerable<String>