Branch #08 docs/api/08-rerank.md

10. Rerank Endpoint (Semantic Candidate Sorting)

Branch #08 — Tăng độ chính xác retrieval trước khi model tạo câu trả lời cuối.

Endpoints

POST
https://bizgpt.vn/wp-json/llm/router/v1/rerank

Rerank danh sách candidate

Auth: Bearer

GET
https://bizgpt.vn/wp-json/llm/router/v1/rerank/health

Health rerank

Auth: Public

Method Path Auth Mô tả
POST https://bizgpt.vn/wp-json/llm/router/v1/rerank Bearer Rerank danh sách candidate
GET https://bizgpt.vn/wp-json/llm/router/v1/rerank/health Public Health rerank

Query Examples

POST Rerank danh sách candidate
curl -X POST "https://bizgpt.vn/wp-json/llm/router/v1/rerank" -H "Authorization: Bearer biz-YOUR_KEY" -H "Content-Type: application/json" -d '{"sample":true}'
const res = await fetch('https://bizgpt.vn/wp-json/llm/router/v1/rerank', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer biz-YOUR_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"sample":true}),
});
const data = await res.json();
console.log(data);
import requests
url = "https://bizgpt.vn/wp-json/llm/router/v1/rerank"
headers = {'Authorization': 'Bearer biz-YOUR_KEY', 'Content-Type': 'application/json'}
payload = '{"sample":true}'
res = requests.request("POST", url, headers=headers, data=payload)
print(res.json())
GET Health rerank
curl -X GET "https://bizgpt.vn/wp-json/llm/router/v1/rerank/health"
const res = await fetch('https://bizgpt.vn/wp-json/llm/router/v1/rerank/health', {
  method: 'GET',
});
const data = await res.json();
console.log(data);
import requests
url = "https://bizgpt.vn/wp-json/llm/router/v1/rerank/health"
headers = {}
res = requests.get(url, headers=headers)
print(res.json())

Use Cases

  • Rerank passages cho Graph RAG trước step trả lời.
  • Sắp xếp kết quả search web theo intent thực tế.
  • Giảm noise khi context quá dài hoặc đa nguồn.

Implementation Steps

  1. Chuẩn hóa candidate schema id/text/source.
  2. Đặt top_k phù hợp giới hạn context model.
  3. Log điểm rerank để phân tích chất lượng hệ thống.

Quick Start cURL

bash
curl -X POST https://bizgpt.vn/wp-json/llm/router/v1/rerank -H "Authorization: Bearer biz-YOUR_KEY" -H "Content-Type: application/json" -d "{\"query\":\"tối ưu SEO local\",\"candidates\":[{\"id\":\"d1\",\"text\":\"...\"}],\"top_k\":5}"
Canonical Spec

docs/api/08-rerank.md