Namespace: LLama
Decodes a stream of tokens into a stream of characters
public sealed class StreamingTokenDecoder
Inheritance Object → StreamingTokenDecoder
The number of decoded characters waiting to be read
public int AvailableCharacters { get; }
Create a new decoder
public StreamingTokenDecoder(Encoding encoding, LLamaWeights weights)
encoding Encoding
Text encoding to use
weights LLamaWeights
Model weights
Create a new decoder
public StreamingTokenDecoder(LLamaContext context)
context LLamaContext
Context to retrieve encoding and model weights from
Create a new decoder
public StreamingTokenDecoder(Encoding encoding, SafeLLamaContextHandle context)
encoding Encoding
Text encoding to use
context SafeLLamaContextHandle
Context to retrieve model weights from
Create a new decoder
public StreamingTokenDecoder(Encoding encoding, SafeLlamaModelHandle weights)
encoding Encoding
Text encoding to use
weights SafeLlamaModelHandle
Models weights to use
Add a single token to the decoder
public void Add(LLamaToken token)
token LLamaToken
Add a single token to the decoder
public void Add(int token)
token Int32
Add all tokens in the given enumerable
public void AddRange<T>(T tokens)
T
tokens T
Add all tokens in the given span
public void AddRange(ReadOnlySpan<LLamaToken> tokens)
tokens ReadOnlySpan<LLamaToken>
Read all decoded characters and clear the buffer
public void Read(List<char> dest)
dest List<Char>
Read all decoded characters as a string and clear the buffer
public string Read()
Set the decoder back to its initial state
public void Reset()
internal static Span<byte> <Add>g__TokenToBytes|9_0(Byte[]& bytes, LLamaToken token, SafeLlamaModelHandle model)
bytes Byte[]&
token LLamaToken
model SafeLlamaModelHandle