API Reference

Rank Chunks

Description

Sorts a list of text chunks by similarity against a given query string.

Details

Use this API endpoint to rank which text chunks provide the most relevant responses to a given a query string.

This is useful for stuffing chunks into a prompt where order may matter or for filtering out less relevant chunks according to the ranking strategy. For example, this API may be useful when doing retrieval augment generation (RAG). Sometimes vector store similarity search does not always return the best ranking of text chunks, since this is heavily dependent on embedding generation. This API endpoint can act as a post-processing step to re-sort the given chunks using more complex strategies that may outperform vector search, and then filter only the top-k most relevant chunks to stuff into the prompt for RAG.

Restrictions and Limits

Ranking can be a very intensive and slow process depending on methodology where duration scales with number of chunks. For best performance, we recommend ranking less than 640 chunks at a time, and you may see a decrease in performance as the number of chunks ranked increases.

Log in to see full request history
Body Params
string
required

Natural language query to re-rank chunks against. If a vector store query was originally used to retrieve these chunks, please use the same query for this ranking

relevant_chunks
array of objects
required

List of chunks to rank

Relevant Chunks*
required

The ranking strategy to use.

Rank strategies determine how the ranking is done, They consist of the ranking method name and additional params needed to compute the ranking.

Use the built-in cross_encoder or rouge strategies or create a custom one with the Models API.

integer

Number of chunks to return. Must be greater than 0 if specified. If not specified, all chunks will be returned.

string

Account to rank chunks with. If you have access to more than one account, you must specify an account_id

Responses

Language
Credentials
Request
Click Try It! to start a request and see the response here! Or choose an example:
application/json