<br />

Performs embedding extraction on text.

**Signature:**

```typescript
export declare class TextEmbedder extends TaskRunner 
```

## Methods

| Method | Modifiers | Description |
|---|---|---|
| [createFromOptions(wasmFileset, textEmbedderOptions)](https://developers.google.com/edge/api/mediapipe/js/tasks-text.textembedder.md.txt#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.md.txt#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.md.txt#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.md.txt#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.md.txt#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.md.txt#textembeddercosinesimilarity) | `static` | Utility function to compute cosine similarity\[1\] between two `Embedding` objects. \[1\]: https://en.wikipedia.org/wiki/Cosine_similarity |

## TextEmbedder.createFromOptions()

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

**Signature:**

```typescript
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()

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

**Signature:**

```typescript
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()

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

**Signature:**

```typescript
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()

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:**

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

### Parameters

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

**Returns:**

Promise\<void\>

## TextEmbedder.embed()

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

**Signature:**

```typescript
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()

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

**Signature:**

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

### Parameters

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

**Returns:**

number