Skip to main content
Version: Next

Class: TextEmbeddingsModule

Defined in: packages/react-native-executorch/src/modules/natural_language_processing/TextEmbeddingsModule.ts:12

Module for generating text embeddings from input text.

Extends

  • BaseModule

Constructors

Constructor

new TextEmbeddingsModule(): TextEmbeddingsModule

Returns

TextEmbeddingsModule

Inherited from

BaseModule.constructor

Properties

nativeModule

nativeModule: any = null

Defined in: packages/react-native-executorch/src/modules/BaseModule.ts:8

Native module instance

Inherited from

BaseModule.nativeModule

Methods

delete()

delete(): void

Defined in: packages/react-native-executorch/src/modules/BaseModule.ts:41

Unloads the model from memory.

Returns

void

Inherited from

BaseModule.delete


forward()

forward(input): Promise<Float32Array<ArrayBufferLike>>

Defined in: packages/react-native-executorch/src/modules/natural_language_processing/TextEmbeddingsModule.ts:54

Executes the model's forward pass, where input is a text that will be embedded.

Parameters

input

string

The text string to embed.

Returns

Promise<Float32Array<ArrayBufferLike>>

A Float32Array containing the vector embeddings.


forwardET()

protected forwardET(inputTensor): Promise<TensorPtr[]>

Defined in: packages/react-native-executorch/src/modules/BaseModule.ts:23

Runs the model's forward method with the given input tensors. It returns the output tensors that mimic the structure of output from ExecuTorch.

Parameters

inputTensor

TensorPtr[]

Array of input tensors.

Returns

Promise<TensorPtr[]>

Array of output tensors.

Inherited from

BaseModule.forwardET


getInputShape()

getInputShape(methodName, index): Promise<number[]>

Defined in: packages/react-native-executorch/src/modules/BaseModule.ts:34

Gets the input shape for a given method and index.

Parameters

methodName

string

method name

index

number

index of the argument which shape is requested

Returns

Promise<number[]>

The input shape as an array of numbers.

Inherited from

BaseModule.getInputShape


load()

load(model, onDownloadProgressCallback): Promise<void>

Defined in: packages/react-native-executorch/src/modules/natural_language_processing/TextEmbeddingsModule.ts:21

Loads the model and tokenizer specified by the config object.

Parameters

model

Object containing model and tokenizer sources.

modelSource

ResourceSource

ResourceSource that specifies the location of the text embeddings model binary.

tokenizerSource

ResourceSource

ResourceSource that specifies the location of the tokenizer JSON file.

onDownloadProgressCallback

(progress) => void

Optional callback to track download progress (value between 0 and 1).

Returns

Promise<void>

Overrides

BaseModule.load