error when using embedding models. the backend is OpenAI-API-compatible, sglang. #293

Closed
opened 2026-02-16 10:18:50 -05:00 by yindo · 1 comment
Owner

Originally created by @hahchenchen on GitHub (May 19, 2025).

Self Checks

  • 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 (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.3.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. using the backend is OpenAI-API-compatible, sglang. the embedding model is intfloat/e5-mistral-7b-instruct.

  2. When constructing a knowledge base using this model, embedding failed.

  3. the sglang error log is:File "/usr/local/lib/python3.10/dist-packages/transformers/tokenization_utils_fast.py", line 539, in _batch_encode_plus
    encodings = self._tokenizer.encode_batch(
    TypeError: TextEncodeInput must be Union[TextInputSequence, Tuple[InputSequence, InputSequence]]

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @hahchenchen on GitHub (May 19, 2025). ### Self Checks - [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 (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.3.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. using the backend is OpenAI-API-compatible, sglang. the embedding model is intfloat/e5-mistral-7b-instruct. 2. When constructing a knowledge base using this model, embedding failed. 3. the sglang error log is:File "/usr/local/lib/python3.10/dist-packages/transformers/tokenization_utils_fast.py", line 539, in _batch_encode_plus encodings = self._tokenizer.encode_batch( TypeError: TextEncodeInput must be Union[TextInputSequence, Tuple[InputSequence, InputSequence]] ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo closed this issue 2026-02-16 10:18:50 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (May 19, 2025):

Hello @hahchenchen! I'm Dosu, a bot here to help you solve bugs, answer your questions, and guide you as you become a contributor. I'm ready to assist you while we wait for a human maintainer. Let's tackle this together!

The error you're encountering, TypeError: TextEncodeInput must be Union[TextInputSequence, Tuple[InputSequence, InputSequence]], typically arises from incorrect input types being passed to the tokenizer. Here are some steps you can take to troubleshoot and resolve this issue:

  1. Check Input Format: Ensure that the input to the tokenizer is in the correct format. The input should be either a single sequence of text or a tuple containing two sequences. Verify that the data being passed matches these requirements.

  2. Update Dependencies: Make sure that all dependencies, especially the transformers library, are up to date. Sometimes, issues like these are resolved in newer versions of libraries.

  3. Review Backend Configuration: Double-check the configuration of the sglang backend to ensure it is correctly set up to handle the embedding model. There might be specific settings or requirements for using the intfloat/e5-mistral-7b-instruct model.

  4. Debugging Logs: Examine the logs for any additional error messages or warnings that might provide more context about the issue. This can help pinpoint where the input is being mishandled.

If these steps do not resolve the issue, consider isolating the problem by testing with a different embedding model or backend to see if the error persists. This can help determine if the issue is specific to the model or the backend configuration.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (May 19, 2025): <!-- Greeting --> Hello @hahchenchen! I'm [Dosu](https://dosu.dev), a bot here to help you solve bugs, answer your questions, and guide you as you become a contributor. I'm ready to assist you while we wait for a human maintainer. Let's tackle this together! <!-- Answer --> The error you're encountering, `TypeError: TextEncodeInput must be Union[TextInputSequence, Tuple[InputSequence, InputSequence]]`, typically arises from incorrect input types being passed to the tokenizer. Here are some steps you can take to troubleshoot and resolve this issue: 1. **Check Input Format**: Ensure that the input to the tokenizer is in the correct format. The input should be either a single sequence of text or a tuple containing two sequences. Verify that the data being passed matches these requirements. 2. **Update Dependencies**: Make sure that all dependencies, especially the `transformers` library, are up to date. Sometimes, issues like these are resolved in newer versions of libraries. 3. **Review Backend Configuration**: Double-check the configuration of the sglang backend to ensure it is correctly set up to handle the embedding model. There might be specific settings or requirements for using the `intfloat/e5-mistral-7b-instruct` model. 4. **Debugging Logs**: Examine the logs for any additional error messages or warnings that might provide more context about the issue. This can help pinpoint where the input is being mishandled. If these steps do not resolve the issue, consider isolating the problem by testing with a different embedding model or backend to see if the error persists. This can help determine if the issue is specific to the model or the backend configuration. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/ec3432fa-a8df-4fef-8c29-429cf7fab505?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/ec3432fa-a8df-4fef-8c29-429cf7fab505?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/ec3432fa-a8df-4fef-8c29-429cf7fab505?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/ec3432fa-a8df-4fef-8c29-429cf7fab505?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/ec3432fa-a8df-4fef-8c29-429cf7fab505?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/ec3432fa-a8df-4fef-8c29-429cf7fab505?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/ec3432fa-a8df-4fef-8c29-429cf7fab505?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#293