When add rerank modle "Qwen3-Reranker-4B" by XInference plugin, report error "score :input should be a valid number.." #611

Closed
opened 2026-02-16 10:19:54 -05:00 by yindo · 2 comments
Owner

Originally created by @kanjoe888 on GitHub (Sep 2, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.7.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

when I add rerank model "Qwen3-Reranker-4B" by XInference, system report error, then infomation see after, when I add rerank model"bge-reranker-v2-m3", it is normal. i had asked deepseek , it say the reques param need include parameter" score ", and it't type must be float.

I requst the model "Qwen3-Reranker-4B" with xinference 's command line, it can response normal, so i adjust this is the plug's problem :
curl -X 'POST'
'http://0.0.0.0:9997/v1/rerank'
-H 'accept: application/

Image

json'
-H 'Content-Type: application/json'
-d '{
"model": "Qwen3-Reranker-4B",
"query": "人工智能的发展历史",
"documents": [
"AI 起源于 1950 年代图灵测试",
"深度学习在 2012 年取得突破",
"大语言模型如 GPT-3 于 2020 年发布"
]
}'
{"id":"cde7f612-87d1-11f0-a9bc-926b820a47cc","results":[{"index":1,"relevance_score":null,"document":null},{"index":0,"relevance_score":null,"document":null},{"index":2,"relevance_score":0.0012444494059309363,"document":null}],"meta":{"api_version":null,"billed_units":null,"tokens":null,"warnings":null}}%

======>
2025-09-02 09:09:45.075 ERROR [Dummy-38] [base.py:211] - Error in stream reponse for plugin {'code': -500, 'message': '{"message":"{\"args\":{},\"error_type\":\"CredentialsValidateFailedError\",\"message\":\"[models] Bad Request Error, 1 validation error for RerankDocument\\nscore\\n Input should be a valid number [type=float_type, input_value=None, input_type=NoneType]\\n For further information visit https://errors.pydantic.dev/2.11/v/float_type\"}","error_type":"PluginInvokeError","args":null}',⁠ 'data': None}

2025-09-02 09:09:45.075 ERROR [Dummy-38] [models.py:163] - Failed to save model credentials, tenant_id: c67846c0-48f9-49a9-8d20-7ae5095fee39, model: Qwen3-Reranker-4B, model_type: rerank

Traceback (most recent call last):

File "/app/api/controllers/console/workspace/models.py", line 155, in post

model_provider_service.save_model_credentials(

File "/app/api/services/model_provider_service.py", line 237, in save_model_credentials

provider_configuration.add_or_update_custom_model_credentials(

File "/app/api/core/entities/provider_configuration.py", line 422, in add_or_update_custom_model_credentials

provider_model_record, credentials = self.custom_model_credentials_validate(model_type, model, credentials)

                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/app/api/core/entities/provider_configuration.py", line 402, in custom_model_credentials_validate

credentials = model_provider_factory.model_credentials_validate(

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/app/api/core/model_runtime/model_providers/model_provider_factory.py", line 191, in model_credentials_validate

self.plugin_model_manager.validate_model_credentials(

File "/app/api/core/plugin/impl/model.py", line 137, in validate_model_credentials

for resp in response:

            ^^^^^^^^

File "/app/api/core/plugin/impl/base.py", line 212, in _request_with_plugin_daemon_response_stream

self._handle_plugin_daemon_error(error.error_type, error.message)

File "/app/api/core/plugin/impl/base.py", line 242, in _handle_plugin_daemon_error

raise CredentialsValidateFailedError(error_object.get("message"))

core.model_runtime.errors.validate.CredentialsValidateFailedError: [models] Bad Request Error, 1 validation error for RerankDocument

score

Input should be a valid number [type=float_type, input_value=None, input_type=NoneType]

For further information visit [https://errors.pydantic.dev/2.11/v/float_type⁠](https://errors.pydantic.dev/2.11/v/float_type)

nginx

Image Image

✔️ Expected Behavior

normal to add rerank model "Qwen3-Reranker-4B"

Actual Behavior

No response

Originally created by @kanjoe888 on GitHub (Sep 2, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.7.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce when I add rerank model "Qwen3-Reranker-4B" by XInference, system report error, then infomation see after, when I add rerank model"bge-reranker-v2-m3", it is normal. i had asked deepseek , it say the reques param need include parameter" score ", and it't type must be float. I requst the model "Qwen3-Reranker-4B" with xinference 's command line, it can response normal, so i adjust this is the plug's problem : curl -X 'POST' \ 'http://0.0.0.0:9997/v1/rerank' \ -H 'accept: application/ <img width="971" height="371" alt="Image" src="https://github.com/user-attachments/assets/df2e3e0b-1cbf-4ea3-9ed4-c25906c341ec" /> json' \ -H 'Content-Type: application/json' \ -d '{ "model": "Qwen3-Reranker-4B", "query": "人工智能的发展历史", "documents": [ "AI 起源于 1950 年代图灵测试", "深度学习在 2012 年取得突破", "大语言模型如 GPT-3 于 2020 年发布" ] }' {"id":"cde7f612-87d1-11f0-a9bc-926b820a47cc","results":[{"index":1,"relevance_score":null,"document":null},{"index":0,"relevance_score":null,"document":null},{"index":2,"relevance_score":0.0012444494059309363,"document":null}],"meta":{"api_version":null,"billed_units":null,"tokens":null,"warnings":null}}% ======> 2025-09-02 09:09:45.075 ERROR [Dummy-38] [base.py:211] - Error in stream reponse for plugin {'code': -500, 'message': '{"message":"{\\"args\\":{},\\"error_type\\":\\"CredentialsValidateFailedError\\",\\"message\\":\\"[models] Bad Request Error, 1 validation error for RerankDocument\\\\nscore\\\\n Input should be a valid number [type=float_type, input_value=None, input_type=NoneType]\\\\n For further information visit [https://errors.pydantic.dev/2.11/v/float_type\\"}","error_type":"PluginInvokeError","args":null}',⁠](https://errors.pydantic.dev/2.11/v/float_type//%22%7D%22,%22error_type%22:%22PluginInvokeError%22,%22args%22:null%7D',) 'data': None} 2025-09-02 09:09:45.075 ERROR [Dummy-38] [models.py:163] - Failed to save model credentials, tenant_id: c67846c0-48f9-49a9-8d20-7ae5095fee39, model: Qwen3-Reranker-4B, model_type: rerank Traceback (most recent call last): File "/app/api/controllers/console/workspace/models.py", line 155, in post model_provider_service.save_model_credentials( File "/app/api/services/model_provider_service.py", line 237, in save_model_credentials provider_configuration.add_or_update_custom_model_credentials( File "/app/api/core/entities/provider_configuration.py", line 422, in add_or_update_custom_model_credentials provider_model_record, credentials = self.custom_model_credentials_validate(model_type, model, credentials) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/entities/provider_configuration.py", line 402, in custom_model_credentials_validate credentials = model_provider_factory.model_credentials_validate( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/model_runtime/model_providers/model_provider_factory.py", line 191, in model_credentials_validate self.plugin_model_manager.validate_model_credentials( File "/app/api/core/plugin/impl/model.py", line 137, in validate_model_credentials for resp in response: ^^^^^^^^ File "/app/api/core/plugin/impl/base.py", line 212, in _request_with_plugin_daemon_response_stream self._handle_plugin_daemon_error(error.error_type, error.message) File "/app/api/core/plugin/impl/base.py", line 242, in _handle_plugin_daemon_error raise CredentialsValidateFailedError(error_object.get("message")) core.model_runtime.errors.validate.CredentialsValidateFailedError: [models] Bad Request Error, 1 validation error for RerankDocument score Input should be a valid number [type=float_type, input_value=None, input_type=NoneType] For further information visit [https://errors.pydantic.dev/2.11/v/float_type⁠](https://errors.pydantic.dev/2.11/v/float_type) nginx <img width="1231" height="803" alt="Image" src="https://github.com/user-attachments/assets/2d55aff1-2716-4ee3-8855-c22b0bb11a6a" /> <img width="971" height="371" alt="Image" src="https://github.com/user-attachments/assets/765779a0-37b1-419a-869b-cb06ff9df7f7" /> ### ✔️ Expected Behavior normal to add rerank model "Qwen3-Reranker-4B" ### ❌ Actual Behavior _No response_
yindo added the bug label 2026-02-16 10:19:54 -05:00
yindo closed this issue 2026-02-16 10:19:54 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 2, 2025):

The error happens because Dify expects each reranked document to have a score field of type float, but the XInference plugin (or the Qwen3-Reranker-4B model) sometimes returns relevance_score: null for some documents. The plugin passes this as score: None, which fails validation in Dify—score must always be a valid float, never null or missing. This is why bge-reranker-v2-m3 works (it always returns a float), but Qwen3-Reranker-4B does not.

To fix this, you need to ensure the plugin (or a proxy) transforms the response so that every document has a score field (float), and skips or filters out any results where relevance_score is null. There is no built-in mapping or config in Dify to accept relevance_score instead of score—the plugin must provide the correct field and type. If you can't modify the plugin directly, you can use a proxy to rewrite the response JSON before it reaches Dify. Example (in JS):

results = results
  .filter(doc => doc.relevance_score !== null)
  .map(doc => ({
    ...doc,
    score: doc.relevance_score,
    relevance_score: undefined
  }));

This will prevent the validation error and allow you to add the rerank model successfully. More details and similar cases are discussed here.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Sep 2, 2025): <!-- Answer --> The error happens because Dify expects each reranked document to have a `score` field of type float, but the XInference plugin (or the Qwen3-Reranker-4B model) sometimes returns `relevance_score: null` for some documents. The plugin passes this as `score: None`, which fails validation in Dify—`score` must always be a valid float, never null or missing. This is why `bge-reranker-v2-m3` works (it always returns a float), but Qwen3-Reranker-4B does not. To fix this, you need to ensure the plugin (or a proxy) transforms the response so that every document has a `score` field (float), and skips or filters out any results where `relevance_score` is null. There is no built-in mapping or config in Dify to accept `relevance_score` instead of `score`—the plugin must provide the correct field and type. If you can't modify the plugin directly, you can use a proxy to rewrite the response JSON before it reaches Dify. Example (in JS): ```js results = results .filter(doc => doc.relevance_score !== null) .map(doc => ({ ...doc, score: doc.relevance_score, relevance_score: undefined })); ``` This will prevent the validation error and allow you to add the rerank model successfully. More details and similar cases are discussed [here](https://github.com/langgenius/dify-official-plugins/issues/1429). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/59c6f94d-43dd-4050-871e-8b13d9bb4b8a?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/59c6f94d-43dd-4050-871e-8b13d9bb4b8a?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/59c6f94d-43dd-4050-871e-8b13d9bb4b8a?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/59c6f94d-43dd-4050-871e-8b13d9bb4b8a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/59c6f94d-43dd-4050-871e-8b13d9bb4b8a?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/59c6f94d-43dd-4050-871e-8b13d9bb4b8a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/59c6f94d-43dd-4050-871e-8b13d9bb4b8a?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/24992)
Author
Owner

@dosubot[bot] commented on GitHub (Sep 2, 2025):

This error happens because the plugin passes a null value for the score field when integrating Qwen3-Reranker-4B, but Dify strictly requires score to be a valid float for each document. The upstream XInference response sometimes returns relevance_score: null, which causes the downstream validation to fail.

To fix this, update the plugin code that processes rerank results so it maps any null relevance_score to a default float (like 0.0) before constructing the RerankDocument objects. This pattern is already used in other rerank integrations and prevents validation errors when scores are missing or null. You can see an example of this fix in PR #1493, which handles both score and relevance_score fields and defaults to 0 if missing.

There is no built-in configuration in Dify to handle null scores, so this code change (or a proxy that rewrites the response) is needed for robust integration with models that may return null scores.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (Sep 2, 2025): <!-- Answer --> This error happens because the plugin passes a null value for the `score` field when integrating Qwen3-Reranker-4B, but Dify strictly requires `score` to be a valid float for each document. The upstream XInference response sometimes returns `relevance_score: null`, which causes the downstream validation to fail. To fix this, update the plugin code that processes rerank results so it maps any null `relevance_score` to a default float (like `0.0`) before constructing the `RerankDocument` objects. This pattern is already used in other rerank integrations and prevents validation errors when scores are missing or null. You can see an example of this fix in [PR #1493](https://github.com/langgenius/dify-official-plugins/pull/1493), which handles both `score` and `relevance_score` fields and defaults to `0` if missing. There is no built-in configuration in Dify to handle null scores, so this code change (or a proxy that rewrites the response) is needed for robust integration with models that may return null scores. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/3fac0a96-aa8c-45a2-af9f-9664f2d1f80a?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/3fac0a96-aa8c-45a2-af9f-9664f2d1f80a?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/3fac0a96-aa8c-45a2-af9f-9664f2d1f80a?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/3fac0a96-aa8c-45a2-af9f-9664f2d1f80a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/3fac0a96-aa8c-45a2-af9f-9664f2d1f80a?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/3fac0a96-aa8c-45a2-af9f-9664f2d1f80a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/3fac0a96-aa8c-45a2-af9f-9664f2d1f80a?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/1637)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#611