docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class OnlyFirstStrategy

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

    Inheritance
    object
    OnlyFirstStrategy
    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 OnlyFirstStrategy : ITruncationStrategy

    Properties

    Instance

    Gets the singleton instance of the OnlyFirstStrategy.

    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 first 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 to be truncated.

    IReadOnlyList<Token> tokensB

    The second sequence of tokens (optional). This sequence will not be truncated.

    Returns
    Type Description
    (int, int)

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

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when sequence A is too short to accommodate sequence B within the maximum length, or when the calculated length for sequence A is zero while sequence A 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)