Skip to main content
Planned for deprecation. The Rerank API will be removed in a future release. For code search, use WarpGrep instead. WarpGrep is a search agent that handles retrieval, ranking, and file reading in one call, replacing the need to manage embeddings, vector databases, and reranking pipelines yourself.

Overview

Morph’s Rerank API improves search quality by reordering candidate results based on their relevance to a query. Our latest morph-rerank-v4 model achieves state-of-the-art performance across all coding benchmarks for accuracy:speed ratio - no rerank model comes close. Unlike the Apply and Embedding endpoints, the Rerank API uses a custom endpoint specifically designed for reranking tasks.

API Endpoint

Model Versions

The latest version is morph-rerank-v4 with state-of-the-art performance across all code benchmarks for its speed-accuracy ratio.

Example Request

Note that the top_n request parameter is optional and will default to the length of the documents field. Result documents will be sorted by relevance, and the index property can be used to determine original order.

Input Format

The request accepts the following parameters: * Either documents or embedding_ids must be provided.

Using Document Content

Using Embedding IDs

When you have previously generated embeddings and enabled remote content storage, you can rerank using embedding IDs:

cURL Examples

With Document Content

With Embedding IDs

Response Format

When using embedding IDs, the response will include the document content if available

Remote Content Storage

To use embedding IDs for reranking, you must enable remote content storage in your account settings. This allows Morph to retrieve the content associated with each embedding ID for reranking purposes. Without remote content storage enabled, you’ll need to pass in the document content directly. Benefits of using embedding IDs:
  • Reduced payload size for large document collections
  • Improved security as content is stored in your account’s secure storage
  • Ability to rerank content that was previously embedded

Integration with Search Systems

The Rerank API is typically used as a second-pass ranking system in a multi-stage retrieval pipeline.
For best code search performance, we recommend using WarpGrep — our intelligent code search tool that combines fast retrieval with automatic reranking. WarpGrep handles the entire search pipeline for you, delivering 20x faster results than stock grepping.
This two-stage approach combines the efficiency of initial retrieval methods with the accuracy of deep neural reranking models.