Different from embedding model, reranker uses question and document as input and directly output similarity instead of embedding. You can get a relevance score by inputting query and passage to the reranker. And the score can be mapped to a float value in [0,1] by sigmoid function.
Bge-Reranker-Base (baai/bge-reranker-base) is a rerank model from BAAI, released 2025-02-14. Context window: — tokens; max output —. Pricing via AIgateway: $0.0000 per request. Call it via https://api.aigateway.sh/v1/rerank — set model="baai/bge-reranker-base".
curl https://api.aigateway.sh/v1/rerank \
-H "Authorization: Bearer $AIGATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"baai/bge-reranker-base","query":"weather","documents":["sun is bright","mars is red"]}'{
"model": "baai/bge-reranker-base",
"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": 3
}{
"model": "baai/bge-reranker-base",
"results": [
{ "index": 0, "document": "Paris is the capital of France.", "score": 0.98 },
{ "index": 2, "document": "The Eiffel Tower is in Paris.", "score": 0.71 },
{ "index": 1, "document": "Berlin is the capital of Germany.", "score": 0.04 }
]
}import os, requests
r = requests.post(
"https://api.aigateway.sh/v1/rerank",
headers={"Authorization": f"Bearer {os.environ['AIGATEWAY_API_KEY']}"},
json={
"model": "baai/bge-reranker-base",
"query": "What is the capital of France?",
"documents": [
"Paris is the capital of France.",
"Berlin is the capital of Germany."
]
},
)
print(r.json())