Skip to content

Add tongyi gte-rerank-v2 - #14215

Merged
JinHai-CN merged 3 commits into
infiniflow:mainfrom
rhinoceros:main
Apr 20, 2026
Merged

JinHai-CN merged 3 commits into
infiniflow:mainfrom
rhinoceros:main

Conversation

@rhinoceros

@rhinoceros rhinoceros commented Apr 19, 2026 •

Copy link
Copy Markdown
Contributor

https://bailian.console.aliyun.com/cn-beijing?tab=api#/api/?type=model&url=2780056

What problem does this PR solve?

Briefly describe what this PR aims to solve. Include background context that will help reviewers understand the purpose of the PR.

Type of change

  • Other (please describe): add gte-rerank-v2、qwen3-rerank

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Apr 19, 2026
@coderabbitai

coderabbitai Bot commented Apr 19, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Added two reranking models (gte-rerank-v2, qwen3-rerank) to the Tongyi-Qianwen factory in conf/llm_factories.json; updated QWenRerank.similarity() in rag/llm/rerank_model.py to vary TextReRank.call(...) arguments based on self.model_name (omit return_documents for qwen3-rerank).

Changes

Cohort / File(s) Summary
Configuration — LLM factories
conf/llm_factories.json
Inserted two rerank model entries gte-rerank-v2, qwen3-rerank into the Tongyi-Qianwen factory's llm array; both have tags="RE-RANK,4k", max_tokens=4000, and model_type="rerank".
Rerank runtime behavior
rag/llm/rerank_model.py
Modified QWenRerank.similarity() to call TextReRank.call(...) with different arguments depending on self.model_name: for names starting with qwen3-rerank omit return_documents; otherwise pass return_documents=False. Added trailing newline.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I’m a rabbit in the code-glade, hopping light,
Two rerankers added to the night,
One skips a flag, the other stays true,
Tokens counted — four thousand, woohoo! 🐰✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description is incomplete and lacks essential information required by the template, including a proper problem statement and detailed explanation of changes. Provide a clear explanation of what problem this PR solves and why these new rerank models are being added. Include technical context about qwen3-rerank's API limitations and the rationale for modifying the similarity() method.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add tongyi gte-rerank-v2' accurately describes the primary change: adding a new reranking model (gte-rerank-v2) to the Tongyi-Qianwen factory configuration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@conf/llm_factories.json`:
- Around line 794-799: Update the gte-rerank-v2 entry so its max_tokens reflects
the model's actual long-context capability: change "max_tokens": 4000 to
"max_tokens": 8192, and make the tags consistent with that capacity (e.g.,
change "tags": "RE-RANK,30k" to "tags": "RE-RANK,8k" or remove the token-size
suffix) in the JSON object containing "llm_name": "gte-rerank-v2".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c48e8390-2c93-4c06-bad3-d78759f56880

📥 Commits

Reviewing files that changed from the base of the PR and between 6712b50 and a7210d9.

📒 Files selected for processing (1)
  • conf/llm_factories.json

Comment thread conf/llm_factories.json Resolved
qwen3-rerank cannot pass return_documents; it needs to be distinguished by model name.
https://bailian.console.aliyun.com/cn-beijing?tab=api#/api/?type=model&url=2780056
```
curl --request POST \
  --url https://dashscope.aliyuncs.com/compatible-api/v1/reranks \
  --header "Authorization: Bearer $DASHSCOPE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
        "model": "qwen3-rerank",
        "documents": [
                "文本排序模型广泛用于搜索引擎和推荐系统中,它们根据文本相关性对候选文本进行排序",
                "量子计算是计算科学的一个前沿领域",
                "预训练语言模型的发展给文本排序模型带来了新的进展"
        ],
        "query": "什么是文本排序模型",
        "top_n": 2,
        "instruct": "Given a web search query, retrieve relevant passages that answer the query."
}'

```

```
import dashscope
from http import HTTPStatus

def text_rerank():
    resp = dashscope.TextReRank.call(
        model="qwen3-rerank",
        query="什么是文本排序模型",
        documents=[
            "文本排序模型广泛用于搜索引擎和推荐系统中,它们根据文本相关性对候选文本进行排序",
            "量子计算是计算科学的一个前沿领域",
            "预训练语言模型的发展给文本排序模型带来了新的进展"
        ],
        top_n=10,
        return_documents=True,
        instruct="Given a web search query, retrieve relevant passages that answer the query."
    )
    if resp.status_code == HTTPStatus.OK:
        print(resp)
    else:
        print(resp)


if __name__ == '__main__':
    text_rerank()
```
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Apr 19, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@rag/llm/rerank_model.py`:
- Around line 378-390: Add a structured debug/info log before the model-specific
TextReRank.call so the path is traceable: log the selected branch (whether
self.model_name startswith "qwen3-rerank"), the actual self.model_name, and key
parameters like query and top_n (len(texts)) just prior to each call in
rerank_model.py where TextReRank.call is invoked; use the module/class logger
used by this file (or create one if missing) and ensure the log level is
debug/info so it appears in traces for incident triage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 96efdf6c-221d-4fa6-a8f9-5fdd81b6b6cd

📥 Commits

Reviewing files that changed from the base of the PR and between a7210d9 and 7146388.

📒 Files selected for processing (2)
  • conf/llm_factories.json
  • rag/llm/rerank_model.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • conf/llm_factories.json

Comment thread rag/llm/rerank_model.py
Comment on lines +378 to +390
# qwen3-rerank does not support return_documents parameter
if self.model_name.startswith("qwen3-rerank"):
resp = dashscope.TextReRank.call(
api_key=self.api_key, model=self.model_name,
query=query, documents=texts, top_n=len(texts)
)
else:
resp = dashscope.TextReRank.call(
api_key=self.api_key, model=self.model_name,
query=query, documents=texts,
top_n=len(texts), return_documents=False
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add logging for the new model-specific request path.

The new branch introduces a behavior split but adds no traceability (selected branch/model). A small structured debug/info log before the call would help incident triage.

As per coding guidelines: **/*.py: Add logging for new flows.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@rag/llm/rerank_model.py` around lines 378 - 390, Add a structured debug/info
log before the model-specific TextReRank.call so the path is traceable: log the
selected branch (whether self.model_name startswith "qwen3-rerank"), the actual
self.model_name, and key parameters like query and top_n (len(texts)) just prior
to each call in rerank_model.py where TextReRank.call is invoked; use the
module/class logger used by this file (or create one if missing) and ensure the
log level is debug/info so it appears in traces for incident triage.

@JinHai-CN JinHai-CN changed the title tongyi添加gte-rerank-v2 Add tongyi gte-rerank-v2 Apr 20, 2026
@JinHai-CN JinHai-CN added the ci Continue Integration label Apr 20, 2026
@JinHai-CN
JinHai-CN marked this pull request as draft April 20, 2026 02:39
@JinHai-CN
JinHai-CN marked this pull request as ready for review April 20, 2026 02:39
@codecov

codecov Bot commented Apr 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.66%. Comparing base (6712b50) to head (7146388).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14215      +/-   ##
==========================================
- Coverage   98.11%   96.66%   -1.45%     
==========================================
  Files          10       10              
  Lines         690      690              
  Branches      108      108              
==========================================
- Hits          677      667      -10     
- Misses          4        8       +4     
- Partials        9       15       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JinHai-CN
JinHai-CN merged commit 4e992de into infiniflow:main Apr 20, 2026
2 checks passed
JasleenKaurSethi pushed a commit to stackhpc/ragflow that referenced this pull request Apr 28, 2026
https://bailian.console.aliyun.com/cn-beijing?tab=api#/api/?type=model&url=2780056

### What problem does this PR solve?

_Briefly describe what this PR aims to solve. Include background context
that will help reviewers understand the purpose of the PR._

### Type of change
- [x] Other (please describe): add gte-rerank-v2、qwen3-rerank
@coderabbitai coderabbitai Bot mentioned this pull request May 8, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants