Repository navigation
Add tongyi gte-rerank-v2 - #14215
Add tongyi gte-rerank-v2#14215
Conversation
📝 WalkthroughWalkthroughAdded two reranking models ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
conf/llm_factories.json
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() ```
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
conf/llm_factories.jsonrag/llm/rerank_model.py
🚧 Files skipped from review as they are similar to previous changes (1)
- conf/llm_factories.json
| # 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 | ||
| ) | ||
|
|
There was a problem hiding this comment.
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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
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