### NativeTensorArray Usage Example Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.NativeTensorArray.html Demonstrates allocating native memory, setting and getting values, copying to a managed array, and disposing of the native memory. Ensure Dispose() is called to release resources. ```csharp // Allocate native memory for 1024 float elements var tensorArray = new NativeTensorArray(1024); // Set and get values tensorArray.Set(0, 1.0f); float value = tensorArray.Get(0); // Copy to managed array float[] floatArray = tensorArray.ToArray(1024, 0); // Dispose of the native memory tensorArray.Dispose(); ``` -------------------------------- ### Get Tokens (Output Collection) Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.IEncoding.html Populates a provided collection with tokens. Returns the number of available tokens. ```csharp int GetTokens(ICollection output) ``` -------------------------------- ### Create Runtime Model from Asset Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/manual/import-a-model-file.html Use `ModelLoader.Load` to create a runtime `Model` object from an imported `ModelAsset`. This is typically done in `Start()` or `Awake()`. ```csharp using UnityEngine; using Unity.InferenceEngine; public class CreateRuntimeModel : MonoBehaviour { public ModelAsset modelAsset; Model runtimeModel; void Start() { runtimeModel = ModelLoader.Load(modelAsset); } } ``` -------------------------------- ### Implementing IONNXMetadataImportCallbackReceiver Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.IONNXMetadataImportCallbackReceiver.html Example of a custom class that implements IONNXMetadataImportCallbackReceiver to capture and store ONNX model metadata during the import process. ```csharp public class MyMetadataCallbackHandler : IONNXMetadataImportCallbackReceiver { public ONNXModelMetadata Metadata { get; private set; } // Callback for metadata import. Member Metadata is of type ONNXModelMetadata. public void OnMetadataImported(AssetImportContext ctx, ONNXModelMetadata metadata) { Metadata = metadata; } } ``` -------------------------------- ### Implement Custom Normalizer Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/manual/tokenizer.html Implement the INormalizer interface to create a custom normalization logic. This example reverses input characters and adds a prefix. ```csharp using System.Text; using Unity.InferenceEngine.Tokenization; using Unity.InferenceEngine.Tokenization.Normalizers; class ReversePrefixNormalizer : INormalizer { readonly string m_Prefix; public ReversePrefixNormalizer(string prefix = null) { m_Prefix = prefix ?? string.Empty; } public SubString Normalize(SubString input) { var sb = new StringBuilder() .Append(m_Prefix); for(var i = input.Length - 1; i >= 0; --i) sb.Append(input[i]); return sb.ToString(); } } ``` -------------------------------- ### Get Encodings (Sequential) Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.IEncoding.html Provides an enumerable sequence of IEncoding instances, starting with the main encoding and followed by any overflowing sequences. ```csharp IEnumerable GetEncodings() ``` -------------------------------- ### Manual Tokenizer Initialization Sample Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/manual/tokenizer.html Demonstrates the manual creation and configuration of a tokenizer, including normalization, pre-tokenization, truncation, post-processing, and decoding. This is useful for understanding the underlying components of the tokenization pipeline. ```csharp using System; using System.Collections.Generic; using System.Linq; using Unity.InferenceEngine; using Unity.InferenceEngine.Tokenization; using Unity.InferenceEngine.Tokenization.Decoders; using Unity.InferenceEngine.Tokenization.Mappers; using Unity.InferenceEngine.Tokenization.Normalizers; using Unity.InferenceEngine.Tokenization.Padding; using Unity.InferenceEngine.Tokenization.PostProcessors; using Unity.InferenceEngine.Tokenization.PostProcessors.Templating; using Unity.InferenceEngine.Tokenization.PreTokenizers; using Unity.InferenceEngine.Tokenization.Truncators; using UnityEngine; class TokenizerSample : MonoBehaviour { static Tensor Encode(ITokenizer tokenizer, string input) { // Generates the sequence var encoding = tokenizer.Encode(input); // Then you can use the encoding to generate your tensors. // Gets this ids // Other masks or available, like: // - attention // - type ids // - special mask. int[] ids = encoding.GetIds().ToArray(); // Create a 3D tensor shape TensorShape shape = new TensorShape(1, 1, ids.Length); // Create a new tensor from the array return new Tensor(shape, ids); } static string Decode(ITokenizer tokenizer, Tensor tensor) { var ids = tensor.DownloadToArray(); return tokenizer.Decode(ids); } static Dictionary BuildVocabulary() { // This stub method returns a legitimate string to id mapping for the tokenizer. // It is usually built from a large configuration JSON file. return new Dictionary(); } static TokenConfiguration[] GetAddedTokens() { // This stub method returns a legitimate collection of token configuration. // Token configuration is the Hugging Face equivalent of added token. return Array.Empty(); } /// This sample initializes a tokenizer based on All MiniLM L6 v2. public ITokenizer CreateTokenizer() { var vocabulary = BuildVocabulary(); var addedTokens = GetAddedTokens(); // Central step of the tokenizer var mapper = new WordPieceMapper(vocabulary, "[UNK]", "##", 100); // Preliminary steps of the tokenization: // - normalization (transforms the input string) // - pre-tokenization (splits the input string) var normalizer = new BertNormalizer( cleanText: true, handleCjkChars: true, stripAccents: null, lowerCase: true); var preTokenizer = new BertPreTokenizer(); // Final steps of tokenization: // - truncation (splits the token sequences) // - post-processing (decorates the token sequences) // - padding (adds tokens to match a sequence size). var truncator = new LongestFirstTruncator(new RightDirectionRangeGenerator(), 128, 0); var clsId = addedTokens.Where(tc => tc.Value == "[CLS]").Select(tc => tc.Id).FirstOrDefault(); var sepId = addedTokens.Where(tc => tc.Value == "[SEP]").Select(tc => tc.Id).FirstOrDefault(); var padId = addedTokens.Where(tc => tc.Value == "[PAD]").Select(tc => tc.Id).FirstOrDefault(); var postProcessor = new TemplatePostProcessor( new(Template.Parse("[CLS]:0 $A:0 [SEP]:0")), new(Template.Parse("[CLS]:0 $A:0 [SEP]:0 $B:1 [SEP]:1")), new (string, int)[] { ("[CLS]", clsId), ("[SEP]", sepId) }); var padding = new RightPadding( new FixedPaddingSizeProvider(128), new Token(padId, "[PAD]")); // Decoding. var decoder = new WordPieceDecoder("##", true); // Creates the tokenizer from all the components // initialized above. return new Tokenizer( mapper, normalizer: normalizer, preTokenizer: preTokenizer, truncator: truncator, postProcessor: postProcessor, paddingProcessor: padding, decoder: decoder, addedVocabulary: addedTokens); } } ``` -------------------------------- ### Create and Manage Tensor Instance Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tensor-1.html Demonstrates creating a Tensor with specified dimensions and data, and how to obtain a CPU-accessible copy using ReadbackAndClone(). It also shows proper resource management by disposing of tensors. ```csharp // Create a tensor m_Tensor = new Tensor(new TensorShape(2, 3), new[] { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }); // Alternatively with `using` so you don't need to call `Dispose()` when you are done with the tensor using var m_OtherTensor = new Tensor(new TensorShape(2, 3), new[] { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }); // Get a CPU-accessible clone of the tensor. This copy owns its own data. Tensor cpuCopyTensor = m_Tensor.ReadbackAndClone() as Tensor; // Release memory. cpuCopyTensor.Dispose(); m_Tensor.Dispose(); ``` -------------------------------- ### Get Rank of TensorShape Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.TensorShape.html Illustrates how to get the number of dimensions (rank) of a TensorShape. The rank indicates the dimensionality of the tensor. ```csharp var shape = new TensorShape(4, 3, 2, 4); shape.rank; // Returns 4 ``` -------------------------------- ### Completing Pending Jobs and Downloading Data Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.ITensorData.html This example shows how to ensure all pending jobs and GPU operations are completed before downloading tensor data. This is crucial for accurate CPU readback. ```csharp cpuData.fence = job.Schedule(count, 64); worker.Schedule(inputTensor); cpuData.CompleteAllPendingOperations(); var data = cpuData.Download(count); ``` -------------------------------- ### Length(int) Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.TensorShape.html Returns the number of elements from a given start axis to the end. Calculates the product of dimensions from the start axis through the last axis. ```APIDOC ## Length(int start) ### Description Returns the number of elements from a given `start` axis to the end. ### Method `public int Length(int start)` ### Parameters - **start** (int) - The first axis to count from. Negative values count from the end. ### Returns - **int**: The product of dimensions from `start` to the last axis. ### Remarks This method calculates the product of dimensions from the `start` axis through the last axis. Negative `start` values count backwards from the innermost dimension. If `start` is beyond the shape's rank, returns `1`. ### Examples Calculate the number of elements from a given axis to the end ```csharp var shape = new TensorShape(2, 3, 4, 5); shape.Length(1); // Returns 60 (3 * 4 * 5) shape.Length(-2); // Returns 20 (4 * 5) ``` ``` -------------------------------- ### Create a Functional Graph from Scratch Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.FunctionalGraph.html Build a computation graph with inputs, operations, and outputs, then compile it into an optimized runtime model. ```csharp var graph = new FunctionalGraph(); var x = graph.AddInput(new TensorShape(6), "input_x"); var y = graph.AddInput(new TensorShape(6), "input_y"); var prod = x * y; var reduce = Functional.ReduceSum(prod, dim: 0, keepdim: false); graph.AddOutput(reduce, "output"); Model model = graph.Compile(); ``` -------------------------------- ### Create TensorShapes and Access Properties Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.TensorShape.html Demonstrates how to create TensorShape instances using constructors or arrays and how to access properties like rank, length, and individual dimension values. ```csharp using Unity.InferenceEngine; // Create TensorShape var shape = new TensorShape(3, 4); // Shape: (3, 4), rank: 2 // Create shape from an array var shape2 = new TensorShape(new[] { 2, 3, 4, 5 }); // Shape: (2, 3, 4, 5), rank: 4 // Shape properties shape.rank; // Returns 2 shape.length; // Returns 12 (3 * 4) shape[0]; // Returns 3 shape[-1]; // Returns 4 (last dimension) ``` -------------------------------- ### Calculate Length from Axis to End Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.TensorShape.html Compute the number of elements from a specified axis to the end of the shape. Negative values for 'start' count from the end. If 'start' is out of bounds, it returns 1. ```csharp var shape = new TensorShape(2, 3, 4, 5); shape.Length(1); // Returns 60 (3 * 4 * 5) shape.Length(-2); // Returns 20 (4 * 5) ``` -------------------------------- ### Build and Execute Command Buffer Per Frame Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/manual/use-command-buffer.html Build the command buffer once and update inputs every frame for reduced scheduling time. This example demonstrates setting up a worker, scheduling it, and executing the command buffer in Update. ```csharp Tensor input0 = new Tensor(new TensorShape(1)); Model model; CommandBuffer cb; Worker worker; void Start() { worker = new Worker(model, BackendType.GPUCompute); worker.SetInput("input0", input0); cb = new CommandBuffer(); cb.ScheduleWorker(worker); } void Update() { // modify input0 input0.Upload(new float[] { Time.deltaTime }); Graphics.ExecuteCommandBuffer(cb); } ``` -------------------------------- ### Get Tensor Output with PeekOutput Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/manual/get-the-output.html Use PeekOutput to get a reference to the output tensor. The Sentis worker owns this reference, so you don't need to dispose of it. Be aware that the output can be overwritten if Schedule is called again. ```csharp worker.Schedule(inputTensor); Tensor outputTensor = worker.PeekOutput() as Tensor; ``` -------------------------------- ### SplitDelimiterIsolate.Instance Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.SplitDelimiterBehaviors.SplitDelimiterIsolate.html Gets a shared instance of the SplitDelimiterIsolate class. ```APIDOC ## Property Instance Gets a shared instance of the SplitDelimiterIsolate. ### Declaration ```csharp public static SplitDelimiterIsolate Instance { get; } ``` ### Property Value Type | Description ---|--- SplitDelimiterIsolate | ``` -------------------------------- ### BpeMapper Constructor Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.Mappers.BpeMapper.html Initializes a new instance of the BpeMapper class with a vocabulary, optional merge pairs, and options. ```APIDOC ## BpeMapper(IReadOnlyDictionary, IEnumerable, BpeMapperOptions) ### Description Converts a substring into a sequence of Token instances using the Byte-Pair Encoding strategy. ### Parameters - **vocabulary** (IReadOnlyDictionary) - Required - The map associating token string representation with their ids. - **merges** (IEnumerable) - Optional - The list of mergeable token pairs, ordered by priority. - **options** (BpeMapperOptions) - Optional - See BpeMapperOptions ``` -------------------------------- ### TensorShape Constructors and Properties Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.TensorShape.html Demonstrates how to create TensorShape instances using constructors and arrays, and how to access its rank, length, and individual dimension sizes. ```APIDOC ## Struct TensorShape Represents the shape of a tensor. ### Remarks A `TensorShape` describes the shape of a Tensor or FunctionalTensor. `TensorShape` supports rank up to maxRank (`8`). Create a `TensorShape` using one of the constructors, or by passing an array of integers. `TensorShape` provides methods for common shape transformations such as Squeeze() and Squeeze(int), Unsqueeze(int), Flatten(), Broadcast(TensorShape), and Reduce(int, bool). These methods return new `TensorShapes` without modifying the original. The rank property returns the number of dimensions, and the length property returns the total number of elements (the product of all dimensions). ### Examples Create `TensorShapes` and get their properties ```csharp using Unity.InferenceEngine; // Create TensorShape var shape = new TensorShape(3, 4); // Shape: (3, 4), rank: 2 // Create shape from an array var shape2 = new TensorShape(new[] { 2, 3, 4, 5 }); // Shape: (2, 3, 4, 5), rank: 4 // Shape properties shape.rank; // Returns 2 shape.length; // Returns 12 (3 * 4) shape[0]; // Returns 3 shape[-1]; // Returns 4 (last dimension) ``` ``` -------------------------------- ### TokenToId Method Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.Mappers.UnigramMapper.html Gets the ID of the specified token. ```APIDOC ## TokenToId(string, out int) ### Description Gets the ID of the specified `token`. ### Parameters - **token** (string) - Required - The token we want to get the ID of. - **id** (out int) - Required - The ID of the specified `token`. ### Returns - **bool**: Whether the token exists. ### Exceptions - **ArgumentNullException**: Thrown when `token` is null. ``` -------------------------------- ### ByteLevelPostProcessor Constructor Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.PostProcessors.ByteLevelPostProcessor.html Initializes a new instance of the ByteLevelPostProcessor. The trimOffsets parameter is available but not yet implemented. ```csharp public ByteLevelPostProcessor(bool trimOffsets = false) ``` -------------------------------- ### Instance Property Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.SplitDelimiterBehaviors.SplitDelimiterMergeWithNext.html Gets a shared instance of the SplitDelimiterMergeWithNext class. ```APIDOC ### Properties #### Instance Gets a shared instance of the SplitDelimiterMergeWithNext. ##### Declaration ```csharp public static SplitDelimiterMergeWithNext Instance { get; } ``` ##### Property Value Type | Description ---|--- SplitDelimiterMergeWithNext | ``` -------------------------------- ### Instance Property Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.SplitDelimiterBehaviors.SplitDelimiterRemove.html Gets a shared instance of the SplitDelimiterRemove class. ```APIDOC ### Properties #### Instance Gets a shared instance of the SplitDelimiterRemove. ##### Declaration ```csharp public static SplitDelimiterRemove Instance { get; } ``` ##### Property Value Type | Description ---|--- SplitDelimiterRemove | ``` -------------------------------- ### Initialize and Copy Tensor Output Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/manual/get-the-output.html Demonstrates initializing a tensor with a specific shape and then using CopyOutput to populate it with model results. CopyOutputInto can also be used with tensors of sufficient capacity but different shapes. ```csharp // The model outputs a tensor of shape (1, 10) // CopyOutput works on empty tensors, i.e. tensors without a tensor data. myOutputTensor = new Tensor(new TensorShape(1, 10), data: null); worker.CopyOutput("output", ref myOutputTensor); // CopyOutputInto works on tensors of different shape as long as the dataOnBackend has large enough capacity myOutputTensor = new Tensor(new TensorShape(152)); worker.CopyOutput("output", ref myOutputTensor); // myOutputTensor now has shape (1, 10) but still has dataOnBackend.maxCapacity == 152 ``` -------------------------------- ### Sequence.GetPieceHashCode() Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.PostProcessors.Templating.Sequence.html Gets the hash code for this Piece, which is part of the Sequence. ```APIDOC ## GetPieceHashCode() ### Description Gets the hash code of this Piece. ### Returns - **int** - The hash code of this Piece. ### Overrides Piece.GetPieceHashCode() ``` -------------------------------- ### SequencePostProcessor Constructor Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.PostProcessors.SequencePostProcessor.html Initializes a new instance of the SequencePostProcessor class with a collection of IPostProcessor instances. ```APIDOC ## SequencePostProcessor(params IPostProcessor[]) ### Description Initializes a new instance of the SequencePostProcessor type. ### Parameters - **processors** (IPostProcessor[]) - Required - The IPostProcessor instances to call in sequence. ``` -------------------------------- ### SpecialToken.Value Property Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.PostProcessors.Templating.SpecialToken.html Gets the string value of the special token. ```APIDOC ## Value ### Description The value of the token. ### Property Value - **string** - The value of the token. ``` -------------------------------- ### Copy Model Output to Screen with Style Transfer Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/manual/use-model-output.html This script demonstrates how to use a model to transform a texture and then copy the result to the screen. Ensure `modelAsset` is set to a style transfer model and `inputImage` to a suitable texture. The texture import settings must match the model's input requirements. ```csharp using UnityEngine; using Unity.InferenceEngine; public class StyleTransfer : MonoBehaviour { public ModelAsset modelAsset; public Model runtimeModel; public Texture2D inputImage; public RenderTexture outputTexture; Worker worker; Tensor inputTensor; void Start() { var sourceModel = ModelLoader.Load(modelAsset); var graph = new FunctionalGraph(); var input = graph.AddInput(sourceModel, 0); var output = Functional.Forward(sourceModel, input)[0]; // rescale output of source model output /= 255f; graph.AddOutput(output); var runtimeModel = graph.Compile(); worker = new Worker(runtimeModel, BackendType.GPUCompute); inputTensor = new Tensor(new TensorShape(1, 3, 256, 256)); } void OnRenderImage(RenderTexture source, RenderTexture destination) { // Create the input tensor from the texture TextureConverter.ToTensor(inputImage, inputTensor, new TextureTransform()); // Run the model and get the output as a tensor worker.Schedule(inputTensor); Tensor outputTensor = worker.PeekOutput() as Tensor; // Copy the rescaled tensor to the screen as a texture TextureConverter.RenderToScreen(outputTensor); } void OnDisable() { worker.Dispose(); } } ``` -------------------------------- ### Piece.SequenceId Property Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.PostProcessors.Templating.Piece.html Gets the sequence ID associated with this piece. ```APIDOC ### Properties #### SequenceId The type id of the sequence. ##### Declaration ```csharp public int SequenceId { get; } ``` ##### Property Value Type | Description ---|--- int | ``` -------------------------------- ### DirectionalPaddingBase Constructor (Protected) Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.Padding.DirectionalPaddingBase.html Protected constructor for initializing DirectionalPaddingBase. It requires an IPaddingSizeProvider to determine the final padded sequence size and a Token for padding. An ArgumentNullException is thrown if paddingSizeProvider is null. ```csharp protected DirectionalPaddingBase(IPaddingSizeProvider paddingSizeProvider, Token padToken) { } ``` -------------------------------- ### TokenConfiguration.Equals(TokenConfiguration) Method Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.TokenConfiguration.html Compares the current TokenConfiguration instance with another TokenConfiguration for equality. ```csharp public bool Equals(TokenConfiguration other) ``` -------------------------------- ### IdToToken Method Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.Mappers.UnigramMapper.html Gets the token value from the specified ID. ```APIDOC ## IdToToken(int) ### Description Gets the token value from the specified `id`. ### Parameters - **id** (int) - Required - The ID of the requested token. ### Returns - **string**: The token value. ### Exceptions - **ArgumentOutOfRangeException**: Thrown when `id` is outside the vocabulary range. ``` -------------------------------- ### LongestFirstStrategy.Instance Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.Truncators.Strategies.LongestFirstStrategy.html Gets the singleton instance of the LongestFirstStrategy. This strategy is used for token truncation. ```APIDOC ## Property Instance Gets the singleton instance of the LongestFirstStrategy. ### Declaration ```csharp public static ITruncationStrategy Instance { get; } ``` ### Property Value Type | Description ---|--- ITruncationStrategy | ``` -------------------------------- ### Worker Constructor with Model and DeviceType Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Worker.html Initializes a new Worker instance with a specified model and device type. The fastest available backend for the given device will be automatically chosen. ```csharp public Worker(Model model, DeviceType deviceType) ``` -------------------------------- ### HuggingFaceParser.GetDefault() Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.Parsers.HuggingFace.HuggingFaceParser.html Gets a pre-configured HuggingFaceParser instance with built-in and HfAttribute-decorated component builders. ```APIDOC ## HuggingFaceParser.GetDefault() ### Description Gets a parser configured with all the built-in components builders, with the additional builders decorated with HfAttribute (with priority to the built-ins. ### Returns - **HuggingFaceParser** - A pre-configured parser. ``` -------------------------------- ### RightPadding Constructors Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.Padding.RightPadding.html Provides information on how to initialize the RightPadding class, with options for specifying padding size and token, and an optional multiple for padding length. ```APIDOC ## RightPadding Constructors ### RightPadding(IPaddingSizeProvider, Token) Initializes a new instance of the RightPadding type. #### Parameters * **paddingSizeProvider** (IPaddingSizeProvider) - Required - When applying the padding, this object provides the final size of the padded sequence. * **padToken** (Token) - Required - The token to use to pad a sequence of tokens. ### RightPadding(IPaddingSizeProvider, Token, int) Initializes a new instance of the RightPadding type. #### Parameters * **paddingSizeProvider** (IPaddingSizeProvider) - Required - When applying the padding, this object provides the final size of the padded sequence. * **padToken** (Token) - Required - The token to use to pad a sequence of tokens. * **padToMultipleOf** (int) - Optional - Sets the pad length to the upper multiple of this value. Defaults to 1. ``` -------------------------------- ### Initialize TextureTransform Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.TextureTransform.html Create an instance of TextureTransform and set dimensions and tensor layout. ```csharp TextureTransform settings = new TextureTransform().SetDimensions(256, 256, 4).SetTensorLayout(TensorLayout.NHWC); ``` -------------------------------- ### Get(int) Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.NativeTensorArray.html Retrieves the value of an element at a specific index from the backing data. ```APIDOC ## Get(int) ### Description Returns the value of the backing data at a given index. ### Method Signature ```csharp public T Get(int index) where T : unmanaged ``` ### Parameters #### Path Parameters - **index** (int) - The index of the element. ### Returns - **T** - The value of the element at `index`, read as type `T`. ### Type Parameters - **T** - The type of the element. ### Remarks Uses `sizeof(T)` for byte-offset indexing. For correct behavior, use `T` such that `sizeof(T) == k_DataItemSize` (for example, `float` or `int`), since the backing buffer stores elements as 32-bit floats. ### Examples ```csharp using (var tensorArray = new NativeTensorArray(64)) { tensorArray.Set(0, 42.0f); float value = tensorArray.Get(0); // Returns 42.0f } ``` ``` -------------------------------- ### Loading ModelAsset and Creating a Worker Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.ModelAsset.html This script demonstrates loading a ModelAsset into a Model and then creating a Worker for inference using the GPUCompute backend. Ensure the ModelAsset is assigned in the Inspector. ```csharp public class MyScript : MonoBehaviour { public ModelAsset modelAsset; Model m_Model; Worker m_Worker; ... void Start() { // Load the binary asset and create a Worker m_Model = ModelLoader.Load(modelAsset); m_Worker = new Worker(m_Model, BackendType.GPUCompute); ... } } ``` -------------------------------- ### UtfSub(Range) Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.SubString.html Gets a portion of this instance, considering the unicode characters instead of chars. ```APIDOC ## UtfSub(Range) ### Description Gets a portion of this instance, considering the unicode characters instead of chars. ### Method ``` public SubString UtfSub(Range offsets) ``` ### Parameters #### Path Parameters - **offsets** (Range) - Required - The bounds of the subpart to extract. ### Returns - **SubString** - A new SubString instance. ``` -------------------------------- ### SubString Indexer for Character Access Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.SubString.html Gets the character at a specific index within the SubString. ```csharp public char this[int index] { get; } ``` -------------------------------- ### Creating Static and Dynamic Tensor Shapes Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.DynamicTensorShape.html Demonstrates how to create a static tensor shape and a dynamic tensor shape with an unknown batch size. Use -1 to indicate a dynamic dimension. ```csharp // Static shape: (1, 3, 224, 224) var staticShape = new DynamicTensorShape(1, 3, 224, 224); // Dynamic shape with unknown dimension 0 var dynamicBatch = new DynamicTensorShape(-1, 3, 224, 224); // All dimensions dynamic with rank 2 var shape = DynamicTensorShape.DynamicOfRank(2); ``` -------------------------------- ### Load Model Asset and Runtime Model Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/manual/understand-sentis-workflow.html Load a model from Unity's Assets folder and create a runtime model for inference. Ensure the model file is correctly placed in the Assets folder. ```csharp ModelAsset modelAsset = Resources.Load("model-file-in-assets-folder") as ModelAsset; var runtimeModel = ModelLoader.Load(modelAsset); ``` -------------------------------- ### Get Tokens (ReadOnly) Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.IEncoding.html Retrieves the list of tokens. Returns the number of available tokens. ```csharp IReadOnlyList GetTokens() ``` -------------------------------- ### Create and Access Tensor Values (CPU) Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/manual/do-basic-tensor-operations.html Demonstrates creating a float tensor on the CPU, setting a specific value using indexers, and retrieving that value. Ensure the tensor is on the CPU and computation is complete before accessing values directly. ```csharp var tensor = new Tensor(new TensorShape(1, 2, 3)); tensor[0, 1, 2] = 5.2f; // set value at index 0 of dim0 = 1, index 1 of dim1 = 2 and index 2 of dim2 = 3 float value = tensor[0, 1, 2]; Assert.AreEqual(5.2f, value); ``` -------------------------------- ### Get Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.DynamicTensorShape.html Returns the dimension at a given axis as an integer. Dynamic dimensions return -1. ```APIDOC ## Get(int) ### Description Returns the dimension at a given axis as an integer. ### Method `public int Get(int axis)` ### Parameters - **axis** (int) - The axis index (0-based, or negative for reverse indexing). ### Returns - **int** - The dimension value at the axis, or `-1` for dynamic dimensions. ### Remarks Dynamic dimensions return `-1`. Supports negative axis indexing (e.g. `-1` for the last axis). ### Examples ```csharp var shape = new DynamicTensorShape(-1, 3, 224); int batch = shape.Get(0); // -1 (dynamic) int channels = shape.Get(1); // 3 int last = shape.Get(-1); // 224 (last axis) ``` ### Exceptions - **AssertionException** - Thrown when the axis is out of bounds. ``` -------------------------------- ### implicit operator string(SubString) Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.SubString.html Gets a string value from the portion of the source string of this SubString. ```APIDOC ## implicit operator string(SubString) ### Description Gets a string value from the portion of the source string of this SubString. ### Method ``` public static implicit operator string(SubString input) ``` ### Parameters #### Path Parameters - **input** (SubString) - Required - The SubString value to convert to a string value. ### Returns - **string** - The string representing the value of this SubString. ``` -------------------------------- ### Upload Tensor Data and Wait for Completion Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.ComputeTensorData.html Demonstrates how to upload data to backing storage and ensure all pending operations are completed. This is useful for synchronizing data transfers before reading. ```csharp var data = new NativeArray(256, Allocator.Temp); // Fill data tensorData.Upload(data, 256); tensorData.CompleteAllPendingOperations(); ``` -------------------------------- ### FixedPaddingSizeProvider Constructor Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.Padding.FixedPaddingSizeProvider.html Initializes a new instance of the FixedPaddingSizeProvider class with a specified padding size. ```APIDOC ## FixedPaddingSizeProvider(int) ### Description Initializes a new instance of the FixedPaddingSizeProvider type. ### Parameters - **size** (int) - The target padding size. ``` -------------------------------- ### SubString Indexer for Range Access Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.SubString.html Gets a portion of the current SubString as a new SubString instance. ```csharp public SubString this[Range offsets] { get; } ``` -------------------------------- ### GetRanges Method Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.Truncators.StrategicTruncator.html Gets the ranges to truncate sequences of tokens. Returns the number of ranges generated. ```csharp protected int GetRanges(int length, int rangeMaxLength, Output output) ``` -------------------------------- ### Create and Dispose Tensor Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tensor.html Demonstrates creating a Tensor with specific dimensions and data, and how to properly dispose of it. It also shows an alternative using a 'using' statement for automatic disposal. ```csharp // Create a tensor m_Tensor = new Tensor(new TensorShape(2, 3), new[] { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }); // Alternatively with `using` so you don't need to call `Dispose()` when you are done with the tensor using var m_OtherTensor = new Tensor(new TensorShape(2, 3), new[] { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }); // Get a CPU-accessible clone of the tensor. This copy owns its own data. Tensor cpuCopyTensor = m_Tensor.ReadbackAndClone() as Tensor; // Release memory. cpuCopyTensor.Dispose(); m_Tensor.Dispose(); ``` -------------------------------- ### Tensor Constructor and Usage Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tensor-1.html Demonstrates how to create a Tensor object, access its data, and manage its lifecycle with Dispose(). ```APIDOC ## Tensor Constructor and Usage ### Description This example shows how to instantiate a `Tensor` with specific dimensions and data, and how to obtain a CPU-accessible copy using `ReadbackAndClone()`. It also illustrates proper resource management by calling `Dispose()` on tensors when they are no longer needed, or by using a `using` statement for automatic disposal. ### Method `Tensor(TensorShape shape, T[] data)` `Tensor.ReadbackAndClone()` `Dispose()` ### Endpoint N/A (SDK Method) ### Parameters #### Constructor Parameters - **shape** (TensorShape) - The dimensions of the tensor. - **data** (T[]) - An array containing the tensor's data. #### ReadbackAndClone Parameters None ### Request Example ```csharp // Create a tensor Tensor m_Tensor = new Tensor(new TensorShape(2, 3), new[] { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }); // Alternatively with `using` so you don't need to call `Dispose()` when you are done with the tensor using var m_OtherTensor = new Tensor(new TensorShape(2, 3), new[] { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }); // Get a CPU-accessible clone of the tensor. This copy owns its own data. Tensor cpuCopyTensor = m_Tensor.ReadbackAndClone() as Tensor; // Release memory. cpuCopyTensor.Dispose(); m_Tensor.Dispose(); ``` ### Response #### Success Response (N/A for constructors/methods) N/A #### Response Example N/A ``` -------------------------------- ### OnlyFirstStrategy.Instance Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.Truncators.Strategies.OnlyFirstStrategy.html Gets the singleton instance of the OnlyFirstStrategy. This strategy is used to truncate only the first sequence of tokens. ```APIDOC ## Property: Instance ### Declaration ```csharp public static ITruncationStrategy Instance { get; } ``` ### Property Value - **Type**: ITruncationStrategy - **Description**: The singleton instance of the OnlyFirstStrategy. ``` -------------------------------- ### DefaultTruncator.Instance Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.Truncators.DefaultTruncator.html Gets a singleton instance of the default truncator. This provides access to the default truncation logic. ```APIDOC ## Property Instance Gets a singleton instance of the default truncator. ### Declaration ```csharp public static ITruncator Instance { get; } ``` ### Property Value Type | Description ---|--- ITruncator | The singleton instance of the DefaultTruncator. ``` -------------------------------- ### Include Unity.InferenceEngine Namespace Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/manual/understand-sentis-workflow.html Add this using statement at the top of your script to access Sentis functionalities. ```csharp using Unity.InferenceEngine; ``` -------------------------------- ### Sequence.Identifier Property Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.PostProcessors.Templating.Sequence.html Gets the identifier for the sequence, which is either 'A' for the primary sequence or 'B' for the secondary sequence. ```APIDOC ## Identifier ### Description Identifies the sequence: A for the primary sequence, B for the secondary sequence. ### Property Value - **SequenceIdentifier** - The identifier of the sequence. ``` -------------------------------- ### DefaultPostProcessor Constructor Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.PostProcessors.DefaultPostProcessor.html Initializes a new instance of the DefaultPostProcessor class. ```APIDOC ## DefaultPostProcessor() ### Description Initializes a new instance of the DefaultPostProcessor type. ### Declaration ```csharp public DefaultPostProcessor() ``` ``` -------------------------------- ### RightDirectionRangeGenerator Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.Truncators.html Generates a sequence of ranges starting from the right (upper bound) of the source token sequence. ```APIDOC ## Class: RightDirectionRangeGenerator ### Description Generates a sequence of Range starting from the right (the upper bound of the source). ### Usage This class is used to define truncation ranges that prioritize keeping tokens from the end of the sequence. ``` -------------------------------- ### PreTokenize Method Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.PreTokenizers.MetaspacePreTokenizer.html Performs the pre-tokenization on the input substring. The results are added to the provided output collection. ```csharp public void PreTokenize(SubString input, Output output) { } ``` -------------------------------- ### LeftDirectionRangeGenerator Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.Truncators.html Generates a sequence of ranges starting from the left (index 0) of the source token sequence. ```APIDOC ## Class: LeftDirectionRangeGenerator ### Description Generates a sequence of Range starting from the left (`0`, the lower bound of the source). ### Usage This class is used to define truncation ranges that prioritize keeping tokens from the beginning of the sequence. ``` -------------------------------- ### Download Tensor to CPU Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/manual/use-model-output.html Use `ReadbackAndClone` to move a tensor from the GPU to the CPU. This creates a read-writable copy for further processing. ```csharp var outputTensor = worker.Schedule(inputTensor).PeekOutput() as Tensor; var cpuTensor = outputTensor.ReadbackAndClone(); ``` -------------------------------- ### Piece.GetPieceHashCode() Method Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.PostProcessors.Templating.Piece.html Gets the hash code of this Piece. This is an abstract method that must be implemented by derived classes. ```APIDOC #### GetPieceHashCode() Gets the hash code of this Piece. ##### Declaration ```csharp protected abstract int GetPieceHashCode() ``` ##### Returns Type | Description ---|--- int | The hash code of this Piece. ``` -------------------------------- ### ByteLevelPreTokenizer Constructors Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.PreTokenizers.ByteLevelPreTokenizer.html Initializes a new instance of the ByteLevelPreTokenizer class. You can control whether a prefix space is added and if GPT-2's regex is used for splitting. ```APIDOC ## ByteLevelPreTokenizer(bool addPrefixSpace = true, bool gpt2Regex = true) ### Description Initializes a new instance of the ByteLevelPreTokenizer type. ### Parameters - **addPrefixSpace** (bool) - Optional - Adds a whitespace at the beginning of the input if it doesn't start with one. - **gpt2Regex** (bool) - Optional - Uses the GPT2 regex to split the input into smaller SubStrings. ``` -------------------------------- ### Get Type IDs (ReadOnly) Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.IEncoding.html Retrieves the list of type IDs. Returns the number of available tokens. ```csharp IReadOnlyList GetTypeIds() ``` -------------------------------- ### LeftPadding Constructor with Padding Size Provider and Pad Token Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.Padding.LeftPadding.html Initializes a new instance of the LeftPadding class. Requires an IPaddingSizeProvider to determine the final padded sequence size and a Token to use for padding. ```csharp public LeftPadding(IPaddingSizeProvider paddingSizeProvider, Token padToken) ``` -------------------------------- ### MetaspacePreTokenizer Constructor Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.PreTokenizers.MetaspacePreTokenizer.html Initializes a new instance of the MetaspacePreTokenizer. You can customize the replacement character, the prepending scheme, and whether to split the input at metaspace boundaries. ```csharp public MetaspacePreTokenizer(char replacement = '▁', PrependScheme prependScheme = PrependScheme.Always, bool split = true) { } ``` -------------------------------- ### Get Token IDs (ReadOnly) Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.IEncoding.html Retrieves the list of token IDs. Returns the number of available tokens. ```csharp IReadOnlyList GetIds() ``` -------------------------------- ### TemplatePostProcessor Constructor Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.PostProcessors.TemplatePostProcessor.html Initializes a new instance of the TemplatePostProcessor. It requires templates for single and paired sequences, along with a list of special tokens. ```csharp public TemplatePostProcessor(Template single, Template pair, IEnumerable<(string value, int id)> specialTokens) ``` -------------------------------- ### Accessing Tensor Elements Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tensor-1.html Provides methods for getting and setting tensor elements using multi-dimensional indices. ```APIDOC ## this[int d0] ### Description Returns the tensor element at offset `d0`. ### Method `get; set;` ### Parameters #### Path Parameters - **d0** (int) - Axis 0. ### Property Value - **T** - The type of the tensor element. ``` ```APIDOC ## this[int d1, int d0] ### Description Returns the tensor element at offset `(d1, d0)`, which is position `d1 * stride0 + d0`. ### Method `get; set;` ### Parameters #### Path Parameters - **d1** (int) - Axis 1. - **d0** (int) - Axis 0. ### Property Value - **T** - The type of the tensor element. ``` ```APIDOC ## this[int d2, int d1, int d0] ### Description Returns the tensor element at offset `(d2, d1, d0)`, which is position `d2 * stride1 + d1 * stride0 + d0`. ### Method `get; set;` ### Parameters #### Path Parameters - **d2** (int) - Axis 2. - **d1** (int) - Axis 1. - **d0** (int) - Axis 0. ### Property Value - **T** - The type of the tensor element. ``` ```APIDOC ## this[int d3, int d2, int d1, int d0] ### Description Returns the tensor element at offset `(d3, d2, d1, d0)`, which is position `d3 * stride2 + d2 * stride1 + d1 * stride0 + d0` in this tensor. ### Method `get; set;` ### Parameters #### Path Parameters - **d3** (int) - Axis 3. - **d2** (int) - Axis 2. - **d1** (int) - Axis 1. - **d0** (int) - Axis 0. ### Property Value - **T** - The type of the tensor element. ``` ```APIDOC ## this[int d4, int d3, int d2, int d1, int d0] ### Description Returns the tensor element at offset `(d4, d3, d2, d1, d0)`, which is position `d4 * stride3 + d3 * stride2 + d2 * stride1 + d1 * stride0 + d0`. ### Method `get; set;` ### Parameters #### Path Parameters - **d4** (int) - Axis 4. - **d3** (int) - Axis 3. - **d2** (int) - Axis 2. - **d1** (int) - Axis 1. - **d0** (int) - Axis 0. ### Property Value - **T** - The type of the tensor element. ``` ```APIDOC ## this[int d5, int d4, int d3, int d2, int d1, int d0] ### Description Returns the tensor element at offset `(d5, d4, d3, d2, d1, d0)`, which is position `d5 * stride4 + d4 * stride3 + d3 * stride2 + d2 * stride1 + d1 * stride0 + d0`. ### Method `get; set;` ### Parameters #### Path Parameters - **d5** (int) - Axis 5. - **d4** (int) - Axis 4. - **d3** (int) - Axis 3. - **d2** (int) - Axis 2. - **d1** (int) - Axis 1. - **d0** (int) - Axis 0. ### Property Value - **T** - The type of the tensor element. ``` ```APIDOC ## this[int d6, int d5, int d4, int d3, int d2, int d1, int d0] ### Description Returns the tensor element at offset `(d6, d5, d4, d3, d2, d1, d0)`, which is position `d6 * stride5 + d5 * stride4 + d4 * stride3 + d3 * stride2 + d2 * stride1 + d1 * stride0 + d0`. ### Method `get; set;` ### Parameters #### Path Parameters - **d6** (int) - Axis 6. - **d5** (int) - Axis 5. - **d4** (int) - Axis 4. - **d3** (int) - Axis 3. - **d2** (int) - Axis 2. - **d1** (int) - Axis 1. - **d0** (int) - Axis 0. ### Property Value - **T** - The type of the tensor element. ``` ```APIDOC ## this[int d7, int d6, int d5, int d4, int d3, int d2, int d1, int d0] ### Description Returns the tensor element at offset `(d7, d6, d5, d4, d3, d2, d1, d0)`, which is position `d7 * stride6 + d6 * stride5 + d5 * stride4 + d4 * stride3 + d3 * stride2 + d2 * stride1 + d1 * stride0 + d0`. ### Method `get; set;` ### Parameters #### Path Parameters - **d7** (int) - Axis 7. - **d6** (int) - Axis 6. - **d5** (int) - Axis 5. - **d4** (int) - Axis 4. - **d3** (int) - Axis 3. - **d2** (int) - Axis 2. - **d1** (int) - Axis 1. - **d0** (int) - Axis 0. ### Property Value - **T** - The type of the tensor element. ``` -------------------------------- ### TokenConfiguration Constructor Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.TokenConfiguration.html Initializes a new TokenConfiguration with specified properties for token behavior. ```csharp public TokenConfiguration(int id, string value, bool wholeWord, Direction strip, bool normalized, bool special) ``` -------------------------------- ### SplitDelimiterMergeWithPrevious.Instance Source: https://docs.unity3d.com/Packages/com.unity.ai.inference%402.6/api/Unity.InferenceEngine.Tokenization.SplitDelimiterBehaviors.SplitDelimiterMergeWithPrevious.html Gets a shared instance of the SplitDelimiterMergeWithPrevious class. This is a static property providing access to a singleton instance of the behavior. ```APIDOC ## Property Instance ### Description Gets a shared instance of the SplitDelimiterMergeWithPrevious. ### Declaration ```csharp public static SplitDelimiterMergeWithPrevious Instance { get; } ``` ### Property Value * **Type**: SplitDelimiterMergeWithPrevious * **Description**: A shared instance of the SplitDelimiterMergeWithPrevious class. ```