Text Embedding Inference have something wrong when embd a file #6865

Closed
opened 2026-02-21 18:17:44 -05:00 by yindo · 6 comments
Owner

Originally created by @bigzws on GitHub (Nov 21, 2024).

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

0.11.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Step1: start the Text Embedding Inferenc docker, download embd model from huggingface online, test the servise on server
Step2: add the embd model to dify, the embd model was added successfully
Step3: create a knowledge, upload a file to embd, dify show "[huggingface_tei]Error : timed out", the server has a high CPU load

My network is no problem, embd model can download from HF, embd model can be add to dify successfully. Well, who report the error? And why can't file be embed?
微信截图_20241121130145
微信截图_20241121130544
微信截图_20241121131227
屏幕截图 2024-11-21 130723
微信截图_20241121131015

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @bigzws on GitHub (Nov 21, 2024). ### 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 0.11.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Step1: start the Text Embedding Inferenc docker, download embd model from huggingface online, test the servise on server Step2: add the embd model to dify, the embd model was added successfully Step3: create a knowledge, upload a file to embd, dify show "[huggingface_tei]Error : timed out", the server has a high CPU load My network is no problem, embd model can download from HF, embd model can be add to dify successfully. Well, who report the error? And why can't file be embed? ![微信截图_20241121130145](https://github.com/user-attachments/assets/60c48cec-caca-4b55-ac27-3bdd71a35af4) ![微信截图_20241121130544](https://github.com/user-attachments/assets/edab60d7-3411-484b-8529-71d2e688270d) ![微信截图_20241121131227](https://github.com/user-attachments/assets/b89e6c84-71f6-4c70-b656-c891cd9a393f) ![屏幕截图 2024-11-21 130723](https://github.com/user-attachments/assets/41e2b4b6-b274-412c-8d70-a20c1c46dd49) ![微信截图_20241121131015](https://github.com/user-attachments/assets/32ac2c02-b2a5-4483-b807-10a47943f669) ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 18:17:44 -05:00
yindo closed this issue 2026-02-21 18:17:44 -05:00
Author
Owner

@bigzws commented on GitHub (Nov 21, 2024):

embd model can be added successfully
微信截图_20241121130902

@bigzws commented on GitHub (Nov 21, 2024): embd model can be added successfully ![微信截图_20241121130902](https://github.com/user-attachments/assets/2819c85f-7817-45e7-ab08-61d4439939df)
Author
Owner

@dosubot[bot] commented on GitHub (Nov 21, 2024):

I found a similar discussion regarding a timeout error when using Hugging Face models in Dify: core.model_runtime.errors.invoke.InvokeError: [huggingface_tei] Error: timed out [1]. This issue might be related to the timeout settings in Dify when interacting with Hugging Face models. Dify sets a timeout of 10 seconds for HTTP requests, and if a request exceeds this timeout, a Timeout exception is raised [2].

To address the high CPU load and timeout issue, consider the following:

  1. Increase Timeout: You might need to increase the timeout setting if the model takes longer to respond. This can be done by modifying the timeout parameter in the relevant code section.

  2. Optimize Resource Usage: Ensure that your server has sufficient resources (CPU and memory) to handle the model inference, especially if the model is large or the input data is complex.

  3. Check Network Stability: Although you mentioned the network is fine, intermittent network issues can still cause timeouts. Ensure a stable and fast connection to Hugging Face servers.

  4. Monitor System Load: Use monitoring tools to check the system load and identify any bottlenecks that might be causing high CPU usage.

These steps should help in diagnosing and potentially resolving the issue you're facing with the Text Embedding Inference service.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Nov 21, 2024): <!-- Answer --> I found a similar discussion regarding a timeout error when using Hugging Face models in Dify: [core.model_runtime.errors.invoke.InvokeError: [huggingface_tei] Error: timed out](https://github.com/langgenius/dify/discussions/7441) <sup>[[1]](https://github.com/langgenius/dify/discussions/7441)</sup>. This issue might be related to the timeout settings in Dify when interacting with Hugging Face models. Dify sets a timeout of 10 seconds for HTTP requests, and if a request exceeds this timeout, a `Timeout` exception is raised <sup>[[2]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/huggingface_tei/tei_helper.py)</sup>. To address the high CPU load and timeout issue, consider the following: 1. **Increase Timeout**: You might need to increase the timeout setting if the model takes longer to respond. This can be done by modifying the timeout parameter in the relevant code section. 2. **Optimize Resource Usage**: Ensure that your server has sufficient resources (CPU and memory) to handle the model inference, especially if the model is large or the input data is complex. 3. **Check Network Stability**: Although you mentioned the network is fine, intermittent network issues can still cause timeouts. Ensure a stable and fast connection to Hugging Face servers. 4. **Monitor System Load**: Use monitoring tools to check the system load and identify any bottlenecks that might be causing high CPU usage. These steps should help in diagnosing and potentially resolving the issue you're facing with the Text Embedding Inference service. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Nov 21, 2024):

@liuyanyi Hello, can you take a look at this issue?

@crazywoola commented on GitHub (Nov 21, 2024): @liuyanyi Hello, can you take a look at this issue?
Author
Owner

@liuyanyi commented on GitHub (Nov 21, 2024):

Based on the logs above, I suspect you are using TEI on the CPU (high CPU load and the logs mentioned the Python backend).
I recommend adjusting the --max-client-batch-size parameter in tei server. In my implementation, to maximize embed efficiency, this parameter is used to set the batch size for each embed batch. A large batch size may cause timeouts on the CPU.

@liuyanyi commented on GitHub (Nov 21, 2024): Based on the logs above, I suspect you are using TEI on the CPU (high CPU load and the logs mentioned the Python backend). I recommend adjusting the --max-client-batch-size parameter in tei server. In my implementation, to maximize embed efficiency, this parameter is used to set the batch size for each embed batch. A large batch size may cause timeouts on the CPU.
Author
Owner

@bigzws commented on GitHub (Nov 21, 2024):

Like you say, that's exactly the case, thank you!

@bigzws commented on GitHub (Nov 21, 2024): Like you say, that's exactly the case, thank you!
Author
Owner

@qiulang commented on GitHub (Apr 17, 2025):

@crazywoola @bigzws I have increased TEXT_GENERATION_TIMEOUT_MS=600000 , 10 minutes

I start my huggingface_tei docker as docker run -d -p 8080:80 -v /home/BAAI/bge-m3:/model ghcr.io/huggingface/text-embeddings-inference:cpu-1.7 --model-id /model --max-client-batch-size 16 --max-batch-tokens 8192

top command does not show high cpu usage at all (around 1%)

But I still get the time out error, what else can I do ?

I also opened an issue at https://github.com/langgenius/dify-official-plugins/issues/748

@qiulang commented on GitHub (Apr 17, 2025): @crazywoola @bigzws I have increased TEXT_GENERATION_TIMEOUT_MS=600000 , 10 minutes I start my huggingface_tei docker as docker run -d -p 8080:80 -v /home/BAAI/bge-m3:/model ghcr.io/huggingface/text-embeddings-inference:cpu-1.7 --model-id /model --max-client-batch-size 16 --max-batch-tokens 8192 top command does not show high cpu usage at all (around 1%) But I still get the time out error, what else can I do ? I also opened an issue at https://github.com/langgenius/dify-official-plugins/issues/748
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6865