Jina AI Rerank Format
Jina AI Rerank Format (Rerank)
Section titled “Jina AI Rerank Format (Rerank)”Page Overview
Official Documentation
Jina AI Rerank
Standard Format
In 4All API API, Jina AI’s rerank format is used as the standard format. Rerank responses from all other providers (such as Xinference, Cohere, etc.) are normalized into Jina AI’s format to provide a unified developer experience.
📝 Introduction
Section titled “📝 Introduction”Jina AI Rerank is a powerful text reranking model that ranks a list of documents by relevance to a query. The model supports multiple languages, can process text in different languages, and assigns a relevance score to each document.
💡 Request Example
Section titled “💡 Request Example”Basic Rerank Request ✅
Section titled “Basic Rerank Request ✅”curl https://4All API地址/v1/rerank \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $4All API_API_KEY" \ -d '{ "model": "jina-reranker-v2-base-multilingual", "query": "Organic skincare products for sensitive skin", "top_n": 3, "documents": [ "Organic skincare for sensitive skin with aloe vera and chamomile...", "New makeup trends focus on bold colors and innovative techniques...", "Bio-Hautpflege für empfindliche Haut mit Aloe Vera und Kamille..." ] }'Response example:
{ "results": [ { "document": { "text": "Organic skincare for sensitive skin with aloe vera and chamomile..." }, "index": 0, "relevance_score": 0.8783142566680908 }, { "document": { "text": "Bio-Hautpflege für empfindliche Haut mit Aloe Vera und Kamille..." }, "index": 2, "relevance_score": 0.7624675869941711 } ], "usage": { "prompt_tokens": 815, "completion_tokens": 0, "total_tokens": 815 }}📮 Request
Section titled “📮 Request”Endpoint
Section titled “Endpoint”POST /v1/rerankAuthentication Method
Section titled “Authentication Method”Include the following in the request header for API key authentication:
Authorization: Bearer $4All API_API_KEYWhere $4All API_API_KEY is your API key.
Request Body Parameters
Section titled “Request Body Parameters”- Type: string
- Required: No
- Default: jina-reranker-v2-base-multilingual
- Description: The reranking model to use
- Type: string
- Required: Yes
- Description: The query text used to rank documents by relevance
- Type: integer
- Required: No
- Default: Unlimited
- Description: Returns the top N ranked documents
documents
Section titled “documents”- Type: string array
- Required: Yes
- Description: The list of documents to rerank
- Limit: Each document should not exceed the model’s maximum token limit
📥 Response
Section titled “📥 Response”Successful Response
Section titled “Successful Response”results
Section titled “results”- Type: array
- Description: The reranked list of documents
- Properties:
- document : An object containing the document text
- index : The index of the document in the original list
- relevance_score : Relevance score (between 0 and 1)
- Type: object
- Description: Token usage statistics
- Properties:
- prompt_tokens : Number of tokens used in the prompt
- completion_tokens : Number of tokens used in the completion
- total_tokens : Total number of tokens
- prompt_tokens_details : Prompt token details cached_tokens : Number of cached tokens audio_tokens : Number of audio tokens
- completion_tokens_details : Completion token details reasoning_tokens : Number of reasoning tokens audio_tokens : Number of audio tokens accepted_prediction_tokens : Number of accepted prediction tokens rejected_prediction_tokens : Number of rejected prediction tokens
Error Response
Section titled “Error Response”When there is an issue with the request, the API returns an error response:
- 400 Bad Request : Invalid request parameters
- 401 Unauthorized : Invalid or missing API key
- 429 Too Many Requests : Rate limit exceeded
- 500 Internal Server Error : Internal server error
💡 Best Practices
Section titled “💡 Best Practices”Query Optimization Tips
Section titled “Query Optimization Tips”- Use clear and specific query text
- Avoid queries that are too broad or vague
- Make sure the query uses the same language style as the documents
Document Handling Tips
Section titled “Document Handling Tips”- Keep documents at a moderate length and do not exceed the model limit
- Make sure document content is complete and meaningful
- Multilingual documents are supported, and the model can match across languages
Performance Optimization
Section titled “Performance Optimization”- Set the
top_nparameter appropriately to reduce unnecessary computation - For large document sets, consider batch processing
- You can cache results for frequently used queries
Multilingual Support
Section titled “Multilingual Support”The model supports reranking documents in multiple languages, including but not limited to:
- English
- Chinese
- German
- Spanish
- Japanese
- French
No language parameter is required; the model automatically detects and handles content in different languages.