docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    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 null if only one sequence is present.

    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 maxLength.

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)