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 is 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. |
Returns |
|
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x 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 |
|
string |
optional |
The embed model family to use. Use values from llm.EmbedModelFamily to set this value. If not specified, the Cohere Embed Multilingual model is used. |
2025.1 |
|
Object |
optional |
Configuration needed for unlimited usage through OCI Generative AI Service. Required only when accessing the LLM through an Oracle Cloud Account and the OCI Generative AI Service. SuiteApps installed to target accounts are prevented from using the free usage pool for N/llm and must use the OCI configuration. |
2025.1 |
|
string |
optional |
Compartment OCID. For more information, refer to Managing Compartments in the Oracle Cloud Infrastructure Documentation. |
2025.1 |
|
string |
optional |
Endpoint ID. This value is needed only when a custom OCI DAC (dedicated AI cluster) is to be used. For more information, refer to Managing an Endpoint in Generative AI in the Oracle Cloud Infrastructure Documentation. |
2025.1 |
|
string |
optional |
Fingerprint of the public key (only a NetSuite secret is accepted—see Creating Secrets ). For more information, refer to Required Keys and OCIDs in the Oracle Cloud Infrastructure Documentation. |
2025.1 |
|
string |
optional |
Private key of the OCI user (only a NetSuite secret is accepted—see Creating Secrets ). For more information, refer to Required Keys and OCIDs in the Oracle Cloud Infrastructure Documentation. |
2025.1 |
|
string |
optional |
Tenancy OCID. For more information, refer to Managing the Tenancy in the Oracle Cloud Infrastructure Documentation. |
2025.1 |
|
string |
optional |
User OCID. For more information, refer to Managing Users in the Oracle Cloud Infrastructure Documentation. |
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 |
|
One or more unrecognized parameters for the OCI configuration were provided. |
|
The For more information about API secrets, see Secrets Management. |
|
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 is not 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_ENGLISH,
timeout: 10000,
truncate: llm.Truncate.START
});
...
// Add additional code