Overview
The Rerank API improves search quality by reordering candidate results based on their relevance to a query. Our latestmorph-rerank-v3 model achieves state-of-the-art performance across all coding benchmarks for accuracy:speed ratio - no rerank model comes close. It’s designed specifically for code-related content and goes beyond traditional keyword matching to understand semantic intent.
Custom API Endpoint
Unlike our Apply and Embedding models that use OpenAI-compatible APIs, the Rerank model uses a custom endpoint designed specifically for reranking tasks. It is Cohere client compatible.Endpoint Reference
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The model ID to use for reranking. Use morph-rerank-v3 (latest) or morph-rerank-v3. |
query | string | Yes | The search query to compare documents against. |
documents | array | No* | An array of document strings to be reranked. Required if embedding_ids is not provided. |
embedding_ids | array | No* | An array of embedding IDs to rerank. Required if documents is not provided. Remote content storage must be enabled. |
top_n | integer | No | Number of top results to return. Default is all documents. |
documents or embedding_ids must be provided.
Using Embedding IDs
When you have previously generated embeddings with Morph’s embedding model, you can use the embedding IDs for reranking: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. Benefits of using embedding IDs:- Reduced payload size: Avoid sending large document content in each request
- Better integration: Seamlessly works with content that was previously embedded
- Security: Content is securely stored within your account’s storage
- Convenience: No need to maintain document content separately from embeddings
Response Format
Features
morph-rerank-v3 (Latest)
- State-of-the-Art Performance: Achieves SoTA results across all coding benchmarks for accuracy:speed ratio - no rerank model comes close
- Unmatched Speed: Fastest reranking inference in the market while delivering superior accuracy
- Enhanced Context Understanding: Improved semantic understanding of code relationships and intent
Core Features (All Models)
- Code-Aware: Specifically optimized for ranking code-related content
- Context Understanding: Considers the full context of both query and documents
- Relevance Scoring: Provides numerical scores indicating relevance
- Efficient Processing: Optimized for quick reranking of large result sets
- Language Agnostic: Works with all major programming languages
- Embedding ID Support: Integrates with previously generated embeddings
- Remote Content Storage: Option to use securely stored content with embedding IDs
Integration with Search Systems
The Rerank model is typically used as a second-pass ranking system after an initial retrieval step:- Initial Retrieval: Use embeddings or keyword search to retrieve an initial set of candidates
- Reranking: Apply the Rerank model to sort the candidates by relevance to the query
- Presentation: Display the reranked results to the user