What is a reranker?
A reranker is a specialized model that improves search relevancy by reassessing and reordering a set of retrieved documents based on their relevance to a given query. It takes a query and a set of text inputs (called ‘documents’), and returns a relevancy score for each document relative to the given query. This process helps filter and prioritize the most pertinent information, enhancing the quality of search results. In Retrieval Augmented Generation (RAG) pipelines, the reranking step sits between the initial retrieval step and the final generation phase. It acts as a quality filter, refining the selection of documents that will be used as context for language models. By ensuring that only the most relevant information is passed to the generation phase, rerankers play a crucial role in improving the accuracy of generated responses while potentially reducing processing costs.How does Together’s Rerank API work?
Together’s serverless Rerank API allows you to seamlessly integrate supported rerank models into your enterprise applications. It takes in aquery and a number of documents, and outputs a relevancy score and ordering index for each document. It can also filter its response to the n most relevant documents.
Key features of Together’s Rerank API include:
- Long 8K context per document
- Low latency for fast search queries
Get started
Example with text
In the example below, we use the Rerank API endpoint to index the list ofdocuments from most to least relevant to the query What animals can I find near Peru?.
Example with JSON data (dedicated endpoints only)
The following JSON data format with
rank_fields is only supported on dedicated endpoints running the Salesforce/Llama-Rank-V1 model. All other rerank endpoints only accept documents as a list of strings.Salesforce/Llama-Rank-V1, you can pass in a JSON object and specify the fields you’d like to rank over, and the order they should be considered in. If you do not pass in any rank_fields, it will default to the text key.
The example below shows passing in some emails, with the query Which pricing did we get from Oracle?.
documents parameter, we are passing in a list of objects which have the key values: ['from', 'to', 'date', 'subject', 'text']. As part of the Rerank call, under rank_fields we are specifying which keys to rank over, as well as the order in which the key value pairs should be considered.
When the model returns rankings, we’ll also receive each email in the response because the return_documents option is set to true.
JSON