docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class OnlySecondStrategy

    Truncation strategy that only truncates the second sequence. The first sequence length is preserved, and the second sequence is adjusted to fit within the maximum length.

    Inheritance
    object
    OnlySecondStrategy
    Implements
    ITruncationStrategy
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.InferenceEngine.Tokenization.Truncators.Strategies
    Assembly: Unity.InferenceEngine.Tokenization.dll
    Syntax
    public class OnlySecondStrategy : ITruncationStrategy

    Properties

    Instance

    Gets the singleton instance of the OnlySecondStrategy.

    Declaration
    public static ITruncationStrategy Instance { get; }
    Property Value
    Type Description
    ITruncationStrategy

    Methods

    GetTruncationLength(int, IReadOnlyList<Token>, IReadOnlyList<Token>)

    Calculates the truncation lengths for two token sequences, truncating only the second sequence.

    Declaration
    public (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.

    IReadOnlyList<Token> tokensA

    The first sequence of tokens. This sequence will not be truncated.

    IReadOnlyList<Token> tokensB

    The second sequence of tokens to be truncated (optional).

    Returns
    Type Description
    (int, int)

    A tuple containing the preserved length for sequence A and the truncated length for sequence B.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when sequence B cannot be truncated to fit within the maximum length after preserving sequence A, or when the calculated length for sequence B is zero while sequence B has tokens.

    Implements

    ITruncationStrategy
    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)