重排序文档
curl --request POST \
--url https://api.aisa.one/v1/rerank \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "jina-reranker-v3",
"query": "What is the capital of France?",
"documents": [
"Paris is the capital of France.",
"Berlin is the capital of Germany.",
"The Eiffel Tower is in Paris."
],
"top_n": 2
}
'import requests
url = "https://api.aisa.one/v1/rerank"
payload = {
"model": "jina-reranker-v3",
"query": "What is the capital of France?",
"documents": ["Paris is the capital of France.", "Berlin is the capital of Germany.", "The Eiffel Tower is in Paris."],
"top_n": 2
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'jina-reranker-v3',
query: 'What is the capital of France?',
documents: [
'Paris is the capital of France.',
'Berlin is the capital of Germany.',
'The Eiffel Tower is in Paris.'
],
top_n: 2
})
};
fetch('https://api.aisa.one/v1/rerank', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisa.one/v1/rerank",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'jina-reranker-v3',
'query' => 'What is the capital of France?',
'documents' => [
'Paris is the capital of France.',
'Berlin is the capital of Germany.',
'The Eiffel Tower is in Paris.'
],
'top_n' => 2
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aisa.one/v1/rerank"
payload := strings.NewReader("{\n \"model\": \"jina-reranker-v3\",\n \"query\": \"What is the capital of France?\",\n \"documents\": [\n \"Paris is the capital of France.\",\n \"Berlin is the capital of Germany.\",\n \"The Eiffel Tower is in Paris.\"\n ],\n \"top_n\": 2\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.aisa.one/v1/rerank")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"jina-reranker-v3\",\n \"query\": \"What is the capital of France?\",\n \"documents\": [\n \"Paris is the capital of France.\",\n \"Berlin is the capital of Germany.\",\n \"The Eiffel Tower is in Paris.\"\n ],\n \"top_n\": 2\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisa.one/v1/rerank")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"jina-reranker-v3\",\n \"query\": \"What is the capital of France?\",\n \"documents\": [\n \"Paris is the capital of France.\",\n \"Berlin is the capital of Germany.\",\n \"The Eiffel Tower is in Paris.\"\n ],\n \"top_n\": 2\n}"
response = http.request(request)
puts response.read_body{
"model": "jina-reranker-v3",
"results": [
{
"index": 0,
"relevance_score": 0.98,
"document": {
"text": "Paris is the capital of France."
}
},
{
"index": 2,
"relevance_score": 0.71,
"document": {
"text": "The Eiffel Tower is in Paris."
}
}
],
"usage": {
"total_tokens": 27
}
}Embeddings 与重排序
重排序文档
使用 Jina rerank 按与查询的相关性对文档重新排序,通过 OpenAI 兼容的 AIsa 中继提供服务。
POST
https://api.aisa.one/v1
/
rerank
重排序文档
curl --request POST \
--url https://api.aisa.one/v1/rerank \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "jina-reranker-v3",
"query": "What is the capital of France?",
"documents": [
"Paris is the capital of France.",
"Berlin is the capital of Germany.",
"The Eiffel Tower is in Paris."
],
"top_n": 2
}
'import requests
url = "https://api.aisa.one/v1/rerank"
payload = {
"model": "jina-reranker-v3",
"query": "What is the capital of France?",
"documents": ["Paris is the capital of France.", "Berlin is the capital of Germany.", "The Eiffel Tower is in Paris."],
"top_n": 2
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'jina-reranker-v3',
query: 'What is the capital of France?',
documents: [
'Paris is the capital of France.',
'Berlin is the capital of Germany.',
'The Eiffel Tower is in Paris.'
],
top_n: 2
})
};
fetch('https://api.aisa.one/v1/rerank', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisa.one/v1/rerank",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'jina-reranker-v3',
'query' => 'What is the capital of France?',
'documents' => [
'Paris is the capital of France.',
'Berlin is the capital of Germany.',
'The Eiffel Tower is in Paris.'
],
'top_n' => 2
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aisa.one/v1/rerank"
payload := strings.NewReader("{\n \"model\": \"jina-reranker-v3\",\n \"query\": \"What is the capital of France?\",\n \"documents\": [\n \"Paris is the capital of France.\",\n \"Berlin is the capital of Germany.\",\n \"The Eiffel Tower is in Paris.\"\n ],\n \"top_n\": 2\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.aisa.one/v1/rerank")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"jina-reranker-v3\",\n \"query\": \"What is the capital of France?\",\n \"documents\": [\n \"Paris is the capital of France.\",\n \"Berlin is the capital of Germany.\",\n \"The Eiffel Tower is in Paris.\"\n ],\n \"top_n\": 2\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisa.one/v1/rerank")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"jina-reranker-v3\",\n \"query\": \"What is the capital of France?\",\n \"documents\": [\n \"Paris is the capital of France.\",\n \"Berlin is the capital of Germany.\",\n \"The Eiffel Tower is in Paris.\"\n ],\n \"top_n\": 2\n}"
response = http.request(request)
puts response.read_body{
"model": "jina-reranker-v3",
"results": [
{
"index": 0,
"relevance_score": 0.98,
"document": {
"text": "Paris is the capital of France."
}
},
{
"index": 2,
"relevance_score": 0.71,
"document": {
"text": "The Eiffel Tower is in Paris."
}
}
],
"usage": {
"total_tokens": 27
}
}使用
jina-reranker-v3 针对某个 query 对文档列表重排序。需要提供非空的 query 和非空的 documents 数组;结果按 relevance_score 排序返回。可选的 top_n 用于只返回最相关的若干文档。它与基于 embedding 的检索天然互补:先用 embedding 召回候选,再用重排序确定最终顺序。
通过 AIsa 中继路径 /v1/rerank 提供服务——OpenAI 兼容。按 token 计费,每 100 万 tokens $0.050;usage.total_tokens 字段给出每次请求计费的 token 数。
curl https://api.aisa.one/v1/rerank \
-H "Authorization: Bearer $AISA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "jina-reranker-v3",
"query": "What is the capital of France?",
"documents": [
"Paris is the capital of France.",
"Berlin is the capital of Germany.",
"The Eiffel Tower is in Paris."
],
"top_n": 2
}'
import requests
resp = requests.post(
"https://api.aisa.one/v1/rerank",
headers={"Authorization": "Bearer sk-aisa-..."},
json={
"model": "jina-reranker-v3",
"query": "What is the capital of France?",
"documents": [
"Paris is the capital of France.",
"Berlin is the capital of Germany.",
"The Eiffel Tower is in Paris.",
],
"top_n": 2,
},
)
print(resp.json()["results"])
授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
application/json
重排序模型名称。
示例:
"jina-reranker-v3"
用于对文档排序的非空查询字符串。
示例:
"What is the capital of France?"
要重排序的非空文档字符串数组。
Minimum array length:
1示例:
[ "Paris is the capital of France.", "Berlin is the capital of Germany.", "The Eiffel Tower is in Paris." ]
可选。只返回相关性最高的前 N 个文档。
示例:
2
⌘I