Table of Contents

Class NativeAPI.Engine

public static class NativeAPI.Engine
Inheritance
object
NativeAPI.Engine

Methods

litert_lm_engine_create(nint)

Creates a LiteRT LM Engine from the given settings. The caller is responsible for destroying the engine using litert_lm_engine_delete(nint).

public static extern nint litert_lm_engine_create(nint settings)

Parameters

settings nint

The engine settings.

Returns

nint

A pointer to the created engine, or nint.Zero on failure.

litert_lm_engine_create_session(nint, nint)

Creates a LiteRT LM Session. The caller is responsible for destroying the session using litert_lm_session_delete(nint).

public static extern nint litert_lm_engine_create_session(nint engine, nint config)

Parameters

engine nint

The engine to create the session from.

config nint

The session config of the session. If nint.Zero, use the default session config.

Returns

nint

A pointer to the created session, or nint.Zero on failure.

litert_lm_engine_delete(nint)

Destroys a LiteRT LM Engine.

public static extern void litert_lm_engine_delete(nint engine)

Parameters

engine nint

The engine to destroy.

litert_lm_engine_detokenize(nint, int[], nuint)

Detokenizes token ids using the engine's tokenizer.

public static extern nint litert_lm_engine_detokenize(nint engine, int[] tokens, nuint numTokens)

Parameters

engine nint

The engine instance.

tokens int[]

An array of token ids to detokenize.

numTokens nuint

The number of token ids in the array.

Returns

nint

A pointer to the detokenize result, or nint.Zero on failure. The caller is responsible for deleting the result using litert_lm_detokenize_result_delete(nint).

litert_lm_engine_get_start_token(nint)

Returns the configured start token (BOS), if any.

public static extern nint litert_lm_engine_get_start_token(nint engine)

Parameters

engine nint

The engine instance.

Returns

nint

A pointer to the start token, or nint.Zero if none configured. The caller is responsible for deleting the result using litert_lm_token_union_delete(nint).

litert_lm_engine_get_stop_tokens(nint)

Returns the configured stop tokens (EOS).

public static extern nint litert_lm_engine_get_stop_tokens(nint engine)

Parameters

engine nint

The engine instance.

Returns

nint

A pointer to the stop tokens collection, or nint.Zero if none configured. The caller is responsible for deleting the result using litert_lm_token_unions_delete(nint).

litert_lm_engine_tokenize(nint, string)

Tokenizes text using the engine's tokenizer.

public static extern nint litert_lm_engine_tokenize(nint engine, string text)

Parameters

engine nint

The engine instance.

text string

The UTF-8 string to tokenize.

Returns

nint

A pointer to the tokenize result, or nint.Zero on failure. The caller is responsible for deleting the result using litert_lm_tokenize_result_delete(nint).