llm.embed(options)
The content in this help topic pertains to SuiteScript 2.1.
|
Method Description |
Returns the embeddings from the LLM for a given input. You can use embeddings to compare the similarity of a set of inputs, which is useful for finding similar items based on item attributes, implementing semantic search, and applying text classification or text clustering. For example, consider a scenario where you sell items, and if an item is out of stock, you want to provide a list of similar items for customers to purchase instead. Here's an example of how you might use embeddings to find similar items:
NetSuite supports specific embeddings models from Cohere. For a list of these models, see llm.EmbedModelFamily.
Important:
Embeddings include the semantic information of the original data and should be treated with the same level of sensitivity. Embeddings created from sensitive data must be protected, stored, logged, shared, retained, and deleted according to the same rules as the original data. This method consumes AI Units. For more information, see NetSuite AI Units and NetSuite Features and AI Units FAQ. |
|
Returns |
|
|
Supported Script Types |
Server scripts For more information, see SuiteScript 2.1 Script Types. |
|
Governance |
50 |
|
Module |
|
|
Since |
2025.1 |
Parameters
|
Parameter |
Type |
Required / Optional |
Description |
Since |
|---|---|---|---|---|
|
|
string[] |
required |
An array of inputs to get embeddings for. |
2025.1 |
|
|
number |
optional |
The number of dimensions of the returned embeddings array. Embedding dimensions refer to the length of the numeric vector used to represent data, such as text. Each dimension corresponds to a specific feature or attribute that the model has learned about the data's meaning or context. A higher number of dimensions can capture more nuanced semantic information and complex relationships within the data. You can use this parameter to limit the number of dimensions in the returned embeddings. The embed model that's currently supported, Cohere Embed v4.0, returns embeddings with 1536 dimensions, which is more than those returned by previously supported embed models. If you generated embeddings using previously supported models and stored these embeddings for later use, you should regenerate those embeddings using the currently supported embed model with the additional supported dimensions. The supported range of values for this parameter is 1 - 1536. The default value is 1536. |
2025.2 |
|
|
string |
optional |
The embed model family to use. Use values from llm.EmbedModelFamily to set this value. If not specified, the Cohere Embed model ( |
2025.1 |
|
|
Object |
optional |
Important:
This object is no longer supported. Any values specified in this object are ignored. |
2025.1 |
|
|
number |
optional |
The amount of time to wait for a response from the LLM, in milliseconds. If not specified, the default value is 30,000. |
2025.1 |
|
|
string |
optional |
The truncation method to use when embeddings input exceeds 512 tokens. Use values from llm.Truncate to set this value. If not specified, no truncation method is used. |
2025.1 |
Errors
|
Error Code |
Thrown If |
|---|---|
|
|
The |
|
|
The value provided for the |
|
|
The number of parallel requests to the LLM is greater than 5. |
|
|
The value of the |
|
|
The value of the You can provide a maximum of 96 inputs in a single call to llm.embed(options). |
|
|
The value of the |
|
|
Too many tokens were provided as embeddings input. Use a truncation method from llm.Truncate to reduce the size of the embeddings input. |
Syntax
The following code sample shows the syntax for this member. It isn't a functional example. For a complete script example, see N/llm Module Script Samples.
// Add additional code
...
const response = llm.embed({
inputs: ["Hello World"],
embedModelFamily: llm.EmbedModelFamily.COHERE_EMBED,
timeout: 10000,
truncate: llm.Truncate.START
});
...
// Add additional code