Skip to content

Commit fccdec1

Browse files
committed
Add docs for meanPooliong
1 parent 7cc86f1 commit fccdec1

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

docs/docs/natural-language-processing/useTextEmbeddings.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
const model = useTextEmbeddings({
3434
modelSource: ALL_MINILM_L6_V2,
3535
tokenizerSource: ALL_MINILM_L6_V2_TOKENIZER,
36+
meanPooling: true,
3637
});
3738

3839
try {
@@ -50,6 +51,8 @@ A string that specifies the location of the model binary. For more information,
5051
**`tokenizerSource`**
5152
A string that specifies the location of the tokenizer JSON file.
5253

54+
**`meanPooling?`** - Boolean that controls whether we perform mean pooling on the model output or not. If not set, it will default to true and display warning.
55+
5356
**`preventLoad?`** - Boolean that can prevent automatic model loading (and downloading the data if you load it for the first time) after running the hook.
5457

5558
### Returns
@@ -85,7 +88,8 @@ const dotProduct = (a: number[], b: number[]) =>
8588
function App() {
8689
const model = useTextEmbeddings({
8790
modelSource: ALL_MINILM_L6_V2,
88-
tokenizerSource: ALL_MINILM_L6_V2_TOKENIZER,
91+
tokenizerSource: ALL_MINILM_L6_V2_TOKENIZER
92+
meanPooling: true,
8993
});
9094

9195
...

docs/docs/typescript-api/TextEmbeddingsModule.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ const embedding = await TextEmbeddingsModule.forward('Hello World!');
2222

2323
### Methods
2424

25-
| Method | Type | Description |
26-
| -------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
27-
| `load` | `(modelSource: ResourceSource, tokenizerSource: ResourceSource): Promise<void>` | Loads the model, where `modelSource` is a string that specifies the location of the model binary and `tokenizerSource` is a string that specifies the location of the tokenizer JSON file. |
28-
| `forward` | `(input: string): Promise<number[]>` | Executes the model's forward pass, where `input` is a text that will be embedded. |
29-
| `onDownloadProgress` | `(callback: (downloadProgress: number) => void): any` | Subscribe to the download progress event. |
25+
| Method | Type | Description |
26+
| -------------------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
27+
| `load` | `(modelSource: ResourceSource, tokenizerSource: ResourceSource, meanPooling?: boolean): Promise<void>` | Loads the model, where `modelSource` is a string that specifies the location of the model binary, `tokenizerSource` is a string that specifies the location of the tokenizer JSON file, and `meanPooling` controls when to perform pooling on model outputs. |
28+
| `forward` | `(input: string): Promise<number[]>` | Executes the model's forward pass, where `input` is a text that will be embedded. |
29+
| `onDownloadProgress` | `(callback: (downloadProgress: number) => void): any` | Subscribe to the download progress event. |
3030

3131
<details>
3232
<summary>Type definitions</summary>
@@ -39,7 +39,7 @@ type ResourceSource = string | number | object;
3939

4040
## Loading the model
4141

42-
To load the model, use the `load` method. It accepts the `modelSource` which is a string that specifies the location of the model binary and `tokenizerSource` which is a string that specifies the location of the tokenizer JSON file. For more information, take a look at [loading models](../fundamentals/loading-models.md) page. This method returns a promise, which can resolve to an error or void.
42+
To load the model, use the `load` method. It accepts the `modelSource` which is a string that specifies the location of the model binary, `tokenizerSource` which is a string that specifies the location of the tokenizer JSON file, and optional `meanPooling` flag controls when to perform pooling on model outputs. For more information, take a look at [loading models](../fundamentals/loading-models.md) page. This method returns a promise, which can resolve to an error or void.
4343

4444
## Running the model
4545

0 commit comments

Comments
 (0)