IREE.Tokenizers.DecodeStream (iree_tokenizers v0.6.0)

Copy Markdown View Source

Streaming decoder state.

Use this when token IDs arrive incrementally and you want to decode them into text while preserving the same result as one-shot decode.

Summary

Types

t()

Mutable streaming decode state owned by the NIF.

Functions

Feeds a list of token IDs into the stream and returns any newly produced text.

Flushes any remaining decode state and returns the final text chunk.

Creates a new decode stream for the given tokenizer.

Types

t()

@type t() :: %IREE.Tokenizers.DecodeStream{resource: reference()}

Mutable streaming decode state owned by the NIF.

Functions

feed(stream, ids)

@spec feed(t(), [integer()]) :: {:ok, binary()} | {:error, {atom(), binary()}}

Feeds a list of token IDs into the stream and returns any newly produced text.

finalize(stream)

@spec finalize(t()) :: {:ok, binary()} | {:error, {atom(), binary()}}

Flushes any remaining decode state and returns the final text chunk.

new(tokenizer, opts \\ [])

@spec new(
  IREE.Tokenizers.Tokenizer.t(),
  keyword()
) :: {:ok, t()} | {:error, {atom(), binary()}}

Creates a new decode stream for the given tokenizer.

Options:

  • :skip_special_tokens - whether to suppress special tokens from output, defaults to true