Skip to content

< Back


LLamaTokenDataArray

Namespace: LLama.Native

Contains an array of LLamaTokenData, potentially sorted.

1
public struct LLamaTokenDataArray

Inheritance ObjectValueTypeLLamaTokenDataArray

Fields

Data

The LLamaTokenData

1
public Memory<LLamaTokenData> Data;

Sorted

Indicates if data is sorted by logits in descending order. If this is false the token data is in no particular order.

1
public bool Sorted;

Constructors

LLamaTokenDataArray(Memory<LLamaTokenData>, Boolean)

Create a new LLamaTokenDataArray

1
LLamaTokenDataArray(Memory<LLamaTokenData> tokens, bool isSorted)

Parameters

tokens Memory<LLamaTokenData>

isSorted Boolean

Methods

Create(ReadOnlySpan<Single>)

Create a new LLamaTokenDataArray, copying the data from the given logits

1
LLamaTokenDataArray Create(ReadOnlySpan<float> logits)

Parameters

logits ReadOnlySpan<Single>

Returns

LLamaTokenDataArray

Create(ReadOnlySpan<Single>, Memory<LLamaTokenData>)

Create a new LLamaTokenDataArray, copying the data from the given logits into temporary memory.

1
LLamaTokenDataArray Create(ReadOnlySpan<float> logits, Memory<LLamaTokenData> buffer)

Parameters

logits ReadOnlySpan<Single>

buffer Memory<LLamaTokenData>
Temporary memory which will be used to work on these logits. Must be at least as large as logits array

Returns

LLamaTokenDataArray

Remarks:

The memory must not be modified while this LLamaTokenDataArray is in use.

OverwriteLogits(ReadOnlySpan<ValueTuple<LLamaToken, Single>>)

Overwrite the logit values for all given tokens

1
void OverwriteLogits(ReadOnlySpan<ValueTuple<LLamaToken, float>> values)

Parameters

values ReadOnlySpan<ValueTuple<LLamaToken, Single>>
tuples of token and logit value to overwrite

Softmax()

Sorts candidate tokens by their logits in descending order and calculate probabilities based on logits.

1
void Softmax()

< Back