You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/natural-language-processing/useTextEmbeddings.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,7 @@ import {
33
33
const model =useTextEmbeddings({
34
34
modelSource: ALL_MINILM_L6_V2,
35
35
tokenizerSource: ALL_MINILM_L6_V2_TOKENIZER,
36
+
meanPooling: true,
36
37
});
37
38
38
39
try {
@@ -50,6 +51,8 @@ A string that specifies the location of the model binary. For more information,
50
51
**`tokenizerSource`**
51
52
A string that specifies the location of the tokenizer JSON file.
52
53
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
+
53
56
**`preventLoad?`** - Boolean that can prevent automatic model loading (and downloading the data if you load it for the first time) after running the hook.
|`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. |
|`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.|
30
30
31
31
<details>
32
32
<summary>Type definitions</summary>
@@ -39,7 +39,7 @@ type ResourceSource = string | number | object;
39
39
40
40
## Loading the model
41
41
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.
0 commit comments