Class Sequences
java.lang.Object
smile.onnx.genai.Sequences
- All Implemented Interfaces:
AutoCloseable
A collection of token-id sequences (batch of prompts / responses).
-
Method Summary
Modifier and TypeMethodDescriptionappend(int[] tokens) Appends a token-id sequence as a new batch entry.appendToken(int token, long sequenceIndex) Appends a single token to an existing sequence.voidclose()longcount()Returns the number of sequences (batch size).static Sequencescreate()Creates an empty sequences container.int[]get(long sequenceIndex) Returns the token ids for the given sequence index.
-
Method Details
-
create
Creates an empty sequences container.- Returns:
- a new sequences object owned by the caller.
-
append
Appends a token-id sequence as a new batch entry.- Parameters:
tokens- token ids.- Returns:
thisfor chaining.
-
appendToken
Appends a single token to an existing sequence.- Parameters:
token- token id.sequenceIndex- sequence index (0-based).- Returns:
thisfor 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:
closein interfaceAutoCloseable
-