重排序
本頁收錄重排序接口及其兼容性說明。
Apifox 覆蓋範圍補充
- 標準重排序(Rerank)
- Jina AI 重排序格式
- Cohere 重排序格式
- Xinference 重排序格式
模型接口/重排序 (Rerank)
POST Xinference 重排序格式
POST /rerank
重要提示:Xinference的rerank響應結構將被格式化為Jina的rerank響應結構,使用方式和Jina的rerank相同。對於Dify等客戶端用戶:在配置時請選擇 Jina AI 作為供應商類型,而不是Xinference,並使用Xinference支持的模型名稱。
簡介:Xinference的重排序API與Jina AI的重排序API完全兼容。請參考Jina AI 重排序格式(Rerank)文檔瞭解詳細的使用方法、請求參數和響應格式。
使用方法:使用Xinference重排序API時,只需將model參數設置為Xinference支持的重排序模型即可,其餘參數和使用方式與Jina AI重排序API相同。
Body 請求參數
{
"model": "jina-reranker-m0",
"query": "什麼是美國的首都?",
"documents": [
"內華達州的首府是卡森城。",
"北馬裡亞納群島是太平洋上的一組島嶼,其首都是塞班島。",
"華盛頓特區(也稱為華盛頓或特區,正式名稱為哥倫比亞特區)是美國的首都。",
"英語語法中的大寫是在單詞開頭使用大寫字母。英語用法與其他語言的大寫不同。",
"自美國成為一個國家之前,美國就存在死刑。截至2017年,在50個州中有30個州死刑合法。"
],
"top_n": 3
}
請求參數
| 名稱 | 位置 | 類型 | 必選 | 說明 |
|---|---|---|---|---|
| Content-Type | header | string | 是 | none |
| Accept | header | string | 是 | none |
| Authorization | header | string | 否 | none |
| body | body | object | 否 | none |
| » model | body | string | 是 | 要使用的模型的 ID。有關哪些模型適用於聊天 API 的詳細信息,請參閱模型端點兼容性表。 |
| » messages | body | [object] | 是 | 以聊天格式生成聊天完成的消息。 |
| »» role | body | string | 否 | none |
| »» content | body | string | 否 | none |
| » temperature | body | integer | 否 | 使用什麼採樣溫度,介於 0 和 2 之間。較高的值(如 0.8)將使輸出更加隨機,而較低的值(如 0.2)將使輸出更加集中和確定。 我們通常建議改變這個或top_p但不是兩者。 |
| » top_p | body | integer | 否 | 一種替代溫度採樣的方法,稱為核採樣,其中模型考慮具有 top_p 概率質量的標記的結果。所以 0.1 意味著只考慮構成前 10% 概率質量的標記。 我們通常建議改變這個或temperature但不是兩者。 |
| » n | body | integer | 否 | 為每個輸入消息生成多少個聊天完成選項。 |
| » stream | body | boolean | 否 | 如果設置,將發送部分消息增量,就像在 ChatGPT 中一樣。當令牌可用時,令牌將作為純數據服務器發送事件data: [DONE]發送,流由消息終止。有關示例代碼,請參閱 OpenAI Cookbook 。 |
| » stop | body | string | 否 | API 將停止生成更多令牌的最多 4 個序列。 |
| » max_tokens | body | integer | 否 | 聊天完成時生成的最大令牌數。 輸入標記和生成標記的總長度受模型上下文長度的限制。 |
| » presence_penalty | body | number | 否 | -2.0 和 2.0 之間的數字。正值會根據到目前為止是否出現在文本中來懲罰新標記,從而增加模型談論新主題的可能性。 查看有關頻率和存在懲罰的更多信息。 |
| » frequency_penalty | body | number | 否 | -2.0 和 2.0 之間的數字。正值會根據新標記在文本中的現有頻率對其進行懲罰,從而降低模型逐字重複同一行的可能性。 查看有關頻率和存在懲罰的更多信息。 |
| » logit_bias | body | null | 否 | 修改指定標記出現在完成中的可能性。 接受一個 json 對象,該對象將標記(由標記器中的標記 ID 指定)映射到從 -100 到 100 的關聯偏差值。從數學上講,偏差會在採樣之前添加到模型生成的 logits 中。確切的效果因模型而異,但 -1 和 1 之間的值應該會減少或增加選擇的可能性;像 -100 或 100 這樣的值應該導致相關令牌的禁止或獨佔選擇。 |
| » user | body | string | 否 | 代表您的最終用戶的唯一標識符,可以幫助 OpenAI 監控和檢測濫用行為。瞭解更多。 |
返回示例
200 Response
{
"id": "string",
"object": "string",
"created": 0,
"choices": [
{
"index": 0,
"message": {
"role": "string",
"content": "string"
},
"finish_reason": "string"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}
返回結果
| 狀態碼 | 狀態碼含義 | 說明 | 數據模型 |
|---|---|---|---|
| 200 | OK | none | Inline |
返回數據結構
狀態碼 200
| 名稱 | 類型 | 必選 | 約束 | 中文名 | 說明 |
|---|---|---|---|---|---|
| » id | string | true | none | none | |
| » object | string | true | none | none | |
| » created | integer | true | none | none | |
| » choices | [object] | true | none | none | |
| »» index | integer | false | none | none | |
| »» message | object | false | none | none | |
| »»» role | string | true | none | none | |
| »»» content | string | true | none | none | |
| »» finish_reason | string | false | none | none | |
| » usage | object | true | none | none | |
| »» prompt_tokens | integer | true | none | none | |
| »» completion_tokens | integer | true | none | none | |
| »» total_tokens | integer | true | none | none |