メインコンテンツへスキップ

Documentation Index

Fetch the complete documentation index at: https://docs.tokenlab.sh/llms.txt

Use this file to discover all available pages before exploring further.

意味的類似性モデルを使用してドキュメントを再ランク付けします。検索結果の改善や RAG アプリケーションに役立ちます。

リクエストボディ

同期リクエストのタイムアウト: この非チャットエンドポイントは、ルーティング先モデルの処理完了を待ちます。大きな入力、長い音声、大きなバッチは一般的な 30s のクライアント既定値を超えることがあるため、HTTP クライアントのタイムアウトは少なくとも 120s に設定してください。
model
string
必須
使用するリランカーモデルの ID(例:BAAI/bge-reranker-v2-m3qwen3-rerank)。
query
string
必須
ドキュメントをランク付けするためのクエリ。最大長は 32,000 文字です。
documents
array
必須
再ランク付けするドキュメント(文字列)のリスト。上限は最大 1,000 件、各ドキュメント最大 100,000 文字、ドキュメント合計最大 2,000,000 文字です。
top_n
integer
返却する上位結果の数。デフォルトはすべてのドキュメントです。1 以上で、documents.length を超えることはできません。現在 TokenLab には、管理対象のプロバイダー固有のより低いハード上限はありません。今後プロバイダーが公開した場合は、文書化または強制する前に rerank request-shape truth へ追加する必要があります。
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.tokenlab.sh/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
  }
}