Namespace: LLama.Native
A batch allows submitting multiple tokens to multiple sequences simultaneously
public class LLamaBatch
Inheritance Object → LLamaBatch
The number of tokens in this batch
public int TokenCount { get; private set; }
Maximum number of sequences a token can be assigned to (automatically grows if exceeded)
public int SequenceCapacity { get; private set; }
Create a new batch for submitting inputs to llama.cpp
public LLamaBatch()
internal GroupDisposable ToNativeBatch(LLamaNativeBatch& batch)
batch LLamaNativeBatch&
Add a single token to the batch at the same position in several sequences
public int Add(LLamaToken token, LLamaPos pos, ReadOnlySpan<LLamaSeqId> sequences, bool logits)
token LLamaToken
The token to add
pos LLamaPos
The position to add it att
sequences ReadOnlySpan<LLamaSeqId>
The set of sequences to add this token to
logits Boolean
Int32
The index that the token was added at. Use this for GetLogitsIth
Remarks:
ad93962657/common/common.cpp (L829C2-L829C2)
Add a single token to the batch at the same position in several sequences
public int Add(LLamaToken token, LLamaPos pos, List<LLamaSeqId> sequences, bool logits)
token LLamaToken
The token to add
pos LLamaPos
The position to add it att
sequences List<LLamaSeqId>
The set of sequences to add this token to
logits Boolean
Int32
The index that the token was added at. Use this for GetLogitsIth
Remarks:
ad93962657/common/common.cpp (L829C2-L829C2)
Add a single token to the batch at a certain position for a single sequences
public int Add(LLamaToken token, LLamaPos pos, LLamaSeqId sequence, bool logits)
token LLamaToken
The token to add
pos LLamaPos
The position to add it att
sequence LLamaSeqId
The sequence to add this token to
logits Boolean
Int32
The index that the token was added at. Use this for GetLogitsIth
Remarks:
ad93962657/common/common.cpp (L829C2-L829C2)
Add a range of tokens to a single sequence, start at the given position.
public int AddRange(ReadOnlySpan<LLamaToken> tokens, LLamaPos start, LLamaSeqId sequence, bool logitsLast)
tokens ReadOnlySpan<LLamaToken>
The tokens to add
start LLamaPos
The starting position to add tokens at
sequence LLamaSeqId
The sequence to add this token to
logitsLast Boolean
Whether the final token should generate logits
Int32
The index that the final token was added at. Use this for GetLogitsIth
Set TokenCount to zero for this batch
public void Clear()
Get the positions where logits can be sampled from
internal Span<ValueTuple<LLamaSeqId, int>> GetLogitPositions(Span<ValueTuple<LLamaSeqId, int>> dest)
dest Span<ValueTuple<LLamaSeqId, Int32>>