decode method
Run the decoder to generate tokens given encoder output.
encoderOutput: (1, numPatches, encoderOutputDim)
promptTokens: initial tokens (e.g., task-specific start tokens)
maxLength: maximum generation length
eosTokenId: end-of-sequence token ID
Returns generated token list.
Implementation
List<int> decode({
required Tensor encoderOutput,
required List<int> promptTokens,
int? maxLength,
int? eosTokenId,
}) {
return decoder.generate(
encoderOutput: encoderOutput,
promptTokens: promptTokens,
maxLength: maxLength ?? config.maxLength,
eosTokenId: eosTokenId ?? tokenizer?.eosTokenId,
);
}