Class Sequences

java.lang.Object
smile.onnx.genai.Sequences
All Implemented Interfaces:
AutoCloseable

public final class Sequences extends Object implements AutoCloseable
A collection of token-id sequences (batch of prompts / responses).
  • Method Details

    • create

      public static Sequences create()
      Creates an empty sequences container.
      Returns:
      a new sequences object owned by the caller.
    • append

      public Sequences append(int[] tokens)
      Appends a token-id sequence as a new batch entry.
      Parameters:
      tokens - token ids.
      Returns:
      this for chaining.
    • appendToken

      public Sequences appendToken(int token, long sequenceIndex)
      Appends a single token to an existing sequence.
      Parameters:
      token - token id.
      sequenceIndex - sequence index (0-based).
      Returns:
      this for chaining.
    • count

      public long count()
      Returns the number of sequences (batch size).
      Returns:
      sequence count.
    • get

      public int[] get(long sequenceIndex)
      Returns the token ids for the given sequence index.
      Parameters:
      sequenceIndex - 0-based sequence index.
      Returns:
      a copy of the token ids.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable