メインコンテンツへスキップ
POST
/
v1
/
rerank
curl -X POST "https://api.lemondata.cc/v1/rerank" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "BAAI/bge-reranker-v2-m3",
    "query": "What is machine learning?",
    "documents": [
      "Machine learning is a subset of AI",
      "The weather is nice today",
      "Deep learning uses neural networks"
    ],
    "top_n": 2,
    "return_documents": true
  }'
{
  "results": [
    {
      "index": 0,
      "relevance_score": 0.95,
      "document": "Machine learning is a subset of AI"
    },
    {
      "index": 2,
      "relevance_score": 0.82,
      "document": "Deep learning uses neural networks"
    }
  ],
  "model": "BAAI/bge-reranker-v2-m3",
  "usage": {
    "prompt_tokens": 45,
    "total_tokens": 45
  }
}
意味的類似性モデルを使用してドキュメントを再ランク付けします。検索結果の改善や RAG アプリケーションに役立ちます。

リクエストボディ

model
string
必須
使用するリランカーモデルの ID(例:BAAI/bge-reranker-v2-m3qwen3-rerank)。
query
string
必須
ドキュメントをランク付けするためのクエリ。
documents
array
必須
再ランク付けするドキュメント(文字列)のリスト。
top_n
integer
返却する上位結果の数。デフォルトはすべてのドキュメントです。
return_documents
boolean
デフォルト:"false"
レスポンスに元のドキュメントテキストを含めるかどうか。

レスポンス

results
array
スコア順にランク付けされたドキュメントのリスト。各結果には以下が含まれます:
  • index (integer): 元のドキュメントのインデックス
  • relevance_score (number): 関連性スコア (0-1)
  • document (string): 元のテキスト(return_documents=true の場合)
model
string
再ランク付けに使用されたモデル。
usage
object
トークン使用統計。
curl -X POST "https://api.lemondata.cc/v1/rerank" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "BAAI/bge-reranker-v2-m3",
    "query": "What is machine learning?",
    "documents": [
      "Machine learning is a subset of AI",
      "The weather is nice today",
      "Deep learning uses neural networks"
    ],
    "top_n": 2,
    "return_documents": true
  }'
{
  "results": [
    {
      "index": 0,
      "relevance_score": 0.95,
      "document": "Machine learning is a subset of AI"
    },
    {
      "index": 2,
      "relevance_score": 0.82,
      "document": "Deep learning uses neural networks"
    }
  ],
  "model": "BAAI/bge-reranker-v2-m3",
  "usage": {
    "prompt_tokens": 45,
    "total_tokens": 45
  }
}