Interface ITruncationStrategy
Defines a strategy for truncating token sequences to fit within a maximum length constraint. Implementations determine how to distribute the available length between two token sequences.
Namespace: Unity.InferenceEngine.Tokenization.Truncators.Strategies
Assembly: Unity.InferenceEngine.Tokenization.dll
Syntax
public interface ITruncationStrategy
Methods
GetTruncationLength(int, IReadOnlyList<Token>, IReadOnlyList<Token>)
Calculates the target lengths for two token sequences after truncation to fit within a maximum length.
Declaration
(int lengthA, int lengthB) GetTruncationLength(int maxLength, IReadOnlyList<Token> tokensA, IReadOnlyList<Token> tokensB)
Parameters
| Type | Name | Description |
|---|---|---|
| int | maxLength | The maximum combined length allowed for both sequences after truncation. |
| IReadOnlyList<Token> | tokensA | The first sequence of tokens to consider for truncation. |
| IReadOnlyList<Token> | tokensB | The second sequence of tokens to consider for truncation. Can be
|
Returns
| Type | Description |
|---|---|
| (int, int) | A tuple containing the target length for sequence A (lengthA) and the target length for
sequence B (lengthB).
The sum of these lengths should not exceed |