<br />

Performs embedding extraction on text.

**Signature:**

    export declare class TextEmbedder extends TaskRunner 

## Methods

| Method | Modifiers | Description |
|---|---|---|
| [createFromOptions(wasmFileset, textEmbedderOptions)](https://developers.google.com/edge/api/mediapipe/js/tasks-text.textembedder#textembeddercreatefromoptions) | `static` | Initializes the Wasm runtime and creates a new text embedder from the provided options. |
| [createFromModelBuffer(wasmFileset, modelAssetBuffer)](https://developers.google.com/edge/api/mediapipe/js/tasks-text.textembedder#textembeddercreatefrommodelbuffer) | `static` | Initializes the Wasm runtime and creates a new text embedder based on the provided model asset buffer. |
| [createFromModelPath(wasmFileset, modelAssetPath)](https://developers.google.com/edge/api/mediapipe/js/tasks-text.textembedder#textembeddercreatefrommodelpath) | `static` | Initializes the Wasm runtime and creates a new text embedder based on the path to the model asset. |
| [setOptions(options)](https://developers.google.com/edge/api/mediapipe/js/tasks-text.textembedder#textembeddersetoptions) |   | Sets new options for the text embedder. Calling `setOptions()` with a subset of options only affects those options. You can reset an option back to its default value by explicitly setting it to `undefined`. |
| [embed(text, formatOptions)](https://developers.google.com/edge/api/mediapipe/js/tasks-text.textembedder#textembedderembed) |   | Performs embeding extraction on the provided text and waits synchronously for the response. |
| [cosineSimilarity(u, v)](https://developers.google.com/edge/api/mediapipe/js/tasks-text.textembedder#textembeddercosinesimilarity) | `static` | Utility function to compute cosine similarity\[1\] between two `Embedding` objects. \[1\]: https://en.wikipedia.org/wiki/Cosine_similarity |

## TextEmbedder.createFromOptions() {#textembeddercreatefromoptions}

Initializes the Wasm runtime and creates a new text embedder from the provided options.

**Signature:**

    static createFromOptions(wasmFileset: WasmFileset, textEmbedderOptions: TextEmbedderOptions): Promise<TextEmbedder>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| textEmbedderOptions | TextEmbedderOptions | The options for the text embedder. Note that either a path to the TFLite model or the model itself needs to be provided (via `baseOptions`). |

**Returns:**

Promise\<TextEmbedder\>

## TextEmbedder.createFromModelBuffer() {#textembeddercreatefrommodelbuffer}

Initializes the Wasm runtime and creates a new text embedder based on the provided model asset buffer.

**Signature:**

    static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array | ReadableStreamDefaultReader): Promise<TextEmbedder>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| modelAssetBuffer | Uint8Array \| ReadableStreamDefaultReader | An array or a stream containing a binary representation of the model. |

**Returns:**

Promise\<TextEmbedder\>

## TextEmbedder.createFromModelPath() {#textembeddercreatefrommodelpath}

Initializes the Wasm runtime and creates a new text embedder based on the path to the model asset.

**Signature:**

    static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<TextEmbedder>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| modelAssetPath | string | The path to the TFLite model. |

**Returns:**

Promise\<TextEmbedder\>

## TextEmbedder.setOptions() {#textembeddersetoptions}

Sets new options for the text embedder. Calling `setOptions()` with a subset of options only affects those options. You can reset an option back to its default value by explicitly setting it to `undefined`.

**Signature:**

    setOptions(options: TextEmbedderOptions): Promise<void>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| options | TextEmbedderOptions | The options for the text embedder. |

**Returns:**

Promise\<void\>

## TextEmbedder.embed() {#textembedderembed}

Performs embeding extraction on the provided text and waits synchronously for the response.

**Signature:**

    embed(text: string, formatOptions?: TextFormatOptions): TextEmbedderResult;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| text | string | The text to process. |
| formatOptions | TextFormatOptions | The formatting to apply to the input text. |

**Returns:**

TextEmbedderResult

## TextEmbedder.cosineSimilarity() {#textembeddercosinesimilarity}

Utility function to compute cosine similarity\[1\] between two `Embedding` objects. \[1\]: https://en.wikipedia.org/wiki/Cosine_similarity

**Signature:**

    static cosineSimilarity(u: Embedding, v: Embedding): number;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| u | Embedding |   |
| v | Embedding |   |

**Returns:**

number