Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/docs/concepts/ranking.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,32 @@ Please sort repositories by the user's interests.

`feedback` contains the user's recent feedback and `items` contains the list of recommended items to be ranked. The number of `feedback` items can be controlled by the `recommend.context_size`. The LLM-based reranker renders the query template and document templates, then sends them to the reranker API. The response is then parsed to extract the ranked list of item IDs.

#### API Compatibility

Gorse supports the Jina/Cohere-style text reranking API. It sends a `POST` request with `model`, `query`, and a string array of `documents`, authenticates with `Authorization: Bearer <auth_token>`, and reads the document `index` and `relevance_score` from the top-level `results` array.

The following interfaces are compatible with this basic text reranking protocol:

| Service | Reranking endpoint |
|---------|--------------------|
| [Jina AI](https://jina.ai/reranker/) | `https://api.jina.ai/v1/rerank` |
| [Cohere](https://docs.cohere.com/reference/rerank) | `https://api.cohere.com/v2/rerank` |
| [Alibaba Cloud Model Studio](https://help.aliyun.com/en/model-studio/text-rerank-api) | `/compatible-api/v1/reranks` |
| [SiliconFlow](https://docs.siliconflow.cn/docs/api/rerank-post) | `https://api.siliconflow.cn/v1/rerank` |
| [vLLM](https://github.com/vllm-project/vllm/blob/main/examples/pooling/score/rerank_api_online.py) | `http://localhost:8000/rerank` |
| [llama.cpp (llama-server)](https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md) | `http://localhost:8080/v1/rerank` |

Set `url` to the **complete reranking endpoint**, including the path, rather than an API base URL. For example, configure Jina AI as follows, in addition to the query and document templates above:

```toml
[recommend.ranker.reranker_api]
auth_token = "<JINA_API_KEY>"
model = "jina-reranker-v2-base-multilingual"
url = "https://api.jina.ai/v1/rerank"
```

Compatibility here refers to the basic text request and ranking response, not every provider-specific option. Gorse does not send multimodal documents or provider-specific parameters such as reranking instructions and truncation settings. A service advertising OpenAI compatibility is not necessarily compatible with this reranking protocol; interfaces with different authentication, request fields, or response formats require an adapter.

[^1]: Rendle, Steffen. "Factorization machines." 2010 IEEE International conference on data mining. IEEE, 2010.
[^2]: Nogueira, Rodrigo, et al. "Document ranking with a pretrained sequence-to-sequence model." Findings of the association for computational linguistics: EMNLP 2020. 2020.
[^3]: Liu, Junling, et al. "Is chatgpt a good recommender? a preliminary study." arXiv preprint arXiv:2304.10149 (2023).
Expand Down
26 changes: 26 additions & 0 deletions src/zh/docs/concepts/ranking.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,32 @@ Please sort repositories by the user's interests.

`feedback` 包含用户最近的反馈,`items` 包含要排序的推荐物品列表。`feedback` 的数量可以通过 `recommend.context_size` 控制。大语言模型重排器渲染查询模板和文档模板,然后将其发送到 Reranker API。然后解析响应以提取排序后的物品 ID 列表。

#### API 兼容性

Gorse 支持 Jina/Cohere 风格的文本重排 API。它通过 `POST` 请求发送 `model`、`query` 和字符串数组 `documents`,使用 `Authorization: Bearer <auth_token>` 认证,并从响应顶层的 `results` 数组中读取文档的 `index` 和 `relevance_score`。

以下接口兼容这一基础文本重排协议:

| 服务 | 重排接口地址 |
|------|--------------|
| [Jina AI](https://jina.ai/reranker/) | `https://api.jina.ai/v1/rerank` |
| [Cohere](https://docs.cohere.com/reference/rerank) | `https://api.cohere.com/v2/rerank` |
| [阿里云百炼](https://help.aliyun.com/zh/model-studio/text-rerank-api) | `/compatible-api/v1/reranks` |
| [硅基流动](https://docs.siliconflow.cn/docs/api/rerank-post) | `https://api.siliconflow.cn/v1/rerank` |
| [vLLM](https://github.com/vllm-project/vllm/blob/main/examples/pooling/score/rerank_api_online.py) | `http://localhost:8000/rerank` |
| [llama.cpp (llama-server)](https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md) | `http://localhost:8080/v1/rerank` |

`url` 必须填写**包含路径的完整重排接口地址**,而不是 API 基础地址。例如,除了上面的查询和文档模板,还可以配置 Jina AI:

```toml
[recommend.ranker.reranker_api]
auth_token = "<JINA_API_KEY>"
model = "jina-reranker-v2-base-multilingual"
url = "https://api.jina.ai/v1/rerank"
```

这里的兼容性仅指基础文本请求和排序响应,并不涵盖所有服务专属选项。Gorse 不发送多模态文档,也不发送重排指令、截断设置等服务专属参数。声明兼容 OpenAI 的服务不一定兼容这一重排协议;认证方式、请求字段或响应格式不同的接口需要通过适配器接入。

[^1]: Rendle, Steffen. "Factorization machines." 2010 IEEE International conference on data mining. IEEE, 2010.
[^2]: Liu, Junling, et al. "Is chatgpt a good recommender? a preliminary study." arXiv preprint arXiv:2304.10149 (2023).
[^3]: Dai, Sunhao, et al. "Uncovering chatgpt’s capabilities in recommender systems." Proceedings of the 17th ACM Conference on Recommender Systems. 2023.
Loading