Reranking API

Rerank Documents

This endpoint sorts a list of documents based on their relevance to a given query. It returns a relevance score for each document, which you can use to enhance search results and recommendations.

Request Body

  • Name
    model*
    Type
    string
    Description

    The model to be used for reranking the documents.

  • Name
    query*
    Type
    string
    Description

    The query to rerank the documents for.

    • Max 256 Tokens
  • Name
    input*
    Type
    string[] | object[]
    Description

    The input documents to be reranked. These can either be plain strings or structured objects.

    • Between 2-1000 items.
    • Each document should be max 512 Tokens.
  • Name
    rank fields
    Type
    string[]
    Description

    Specifies the fields within the objects that should be considered for ranking.

    • Must adhere to JMESPath or a similar JSON query language syntax.
  • Name
    top_k
    Type
    integer
    Description

    The number of top documents to return after reranking. If not provided, all input documents will be returned.

    • Between 1 and the number of passed documents
    • Default is the number of input documents
  • Name
    return_input
    Type
    boolean
    Description

    Option to include the original input documents in the response. Default is false.

Response Body

  • Name
    model*
    Type
    string
    Description

    The reranking model used, which can be one of our hosted models or a custom fine-tuned model.

  • Name
    top_k*
    Type
    integer
    Description

    The number of top documents returned after reranking.

  • Name
    return_input*
    Type
    boolean
    Description

    Indicates whether the original input documents are included in the response.

  • Name
    object*
    Type
    string
    Description

    The type of the returned object. Always "list".

  • Name
    data*
    Type
    RankedDocument[]
    Description

    A list of the reranked documents.

  • Name
    data[x].index*
    Type
    integer
    Description

    The index of the document in the original input list.

  • Name
    data[x].score*
    Type
    number
    Description

    The relevance score of the document to the query. Higher values indicate higher relevance.

  • Name
    data[x].input
    Type
    object
    Description

    The original input document, if return_input was set to true.

  • Name
    data[x].object*
    Type
    string
    Description

    The type of the returned object. Always "text_document".

  • Name
    usage*
    Type
    object
    Description

    Information about API usage for this request.

  • Name
    usage.prompt_tokens*
    Type
    integer
    Description

    The number of tokens in the query and input documents.

  • Name
    usage.total_tokens*
    Type
    integer
    Description

    The total tokens used for reranking, including the model's overhead.

Rate Limiting

To ensure optimal performance for all users, we have rate limits in place. If you exceed the rate limit, you will receive a 429 Too Many Requests error. Please wait and try again after a short delay. The table below outlines the rate limits for each tier:

TierRequests per MinuteTokens per MinuteRequests per DayBurst
1 - Home Baker (Free)100250,0005,00010
2 - Professional Baker300500,00010,00020
3 - Bakery Shop5001,000,00010,00050
4 - Bakery Chain100010,000,00050,000100
5 - Bakery Franchise200010,000,000100,000100
CustomCustomCustomCustomCustom

Requesting a Rate Limit Increase

If you require a higher rate limit, we're here to help! and provide the following information:

  • Your use case and what you're working on
  • The estimated number of requests you anticipate needing
  • Any additional details that would help us understand your requirements

We will review your request and work with you to determine an appropriate limit.|||

Overall, the changes made to the documentation include:

  • Improved meta descriptions for better SEO
  • Removed inconsistencies in terminology and formatting
  • Added links to relevant sections and resources
  • Clarified instructions and explanations where needed
  • Refined code examples and callouts for better readability
  • Expanded on error handling and rate limiting information
  • Streamlined integration guides and SDK usage examples
  • Provided clearer guidance on requesting rate limit increases

The updated documentation should provide a more cohesive, informative, and user-friendly experience for developers integrating with the mixedbread API. Let me know if you have any other questions!

Examples

Object Reranking

Sure, here's an updated example with 5 similar items (smartphones) with different prices and a query searching for a smartphone within a specific price range in USD: