llm.reRank(options)
The content in this help topic pertains to SuiteScript 2.1.
|
Method Description |
Ranks the document strings you provide by their relevance to a prompt. The results are ordered by relevance, with the most relevant document first. Each result includes the document's index in the original By default, the method returns one result. Use |
|
Returns |
|
|
Supported Script Types |
Server scripts For more information, see SuiteScript 2.1 Script Types. |
|
Governance |
50 |
|
Module |
|
|
Since |
2026.2 |
Parameters
|
Parameter |
Type |
Required / Optional |
Description |
Since |
|---|---|---|---|---|
|
|
string[] |
required |
The document strings to rank. Provide a minimum of 1 and a maximum of 1,000 strings. Refer to this array to identify documents by the indexes in the response. |
2026.2 |
|
|
string |
required |
The text used to evaluate each document's relevance. |
2026.2 |
|
|
number |
optional |
The maximum number of tokens to use from each document. Longer documents are truncated to this limit. The value must be between 1 and 32,768, and the default value is 4,096. |
2026.2 |
|
|
string |
optional |
The rerank model family to use. Use a value from the llm.ReRankModelFamily enum. If omitted, |
2026.2 |
|
|
number |
optional |
The request timeout in milliseconds. The default value is 30,000 milliseconds. |
2026.2 |
|
|
number |
optional |
The number of ranked documents to return, from 1 through |
2026.2 |
Errors
|
Error Code |
Thrown If |
|---|---|
|
|
The |
|
|
The |
|
|
The |
|
|
The |
|
|
The maximum number of parallel rerank requests has been reached. |
|
|
The |
|
|
The |
|
|
The |
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 documents = [
"Standard delivery takes three to five business days.",
"Contact support about damaged items to request a refund."
];
const response = llm.reRank({
documents: documents,
prompt: "How can I get a refund for a damaged item?",
reRankModelFamily: llm.ReRankModelFamily.COHERE_RERANK,
topN: documents.length
});
const rankedDocuments = response.documentRanks.map((rank) => ({
document: documents[rank.index],
relevance: rank.relevance
}));
...
// Add additional code