Ollama Embedding model embed documents error #116

Closed
opened 2026-02-16 10:18:08 -05:00 by yindo · 7 comments
Owner

Originally created by @Sakura4036 on GitHub (Mar 24, 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.12

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. pull ollama docker
  2. ollama run ollama pull jeffh/intfloat-multilingual-e5-large-instruct:f16 (or other embedding model)
  3. add ollama model on dify model setting
  4. create a Knowledge on dify web, use Parent-Child mode
  5. set embedding model is an ollama embedding model

✔️ Expected Behavior

embed documents success

Actual Behavior

Image

Image

dify celery log

  File "/home/github/dify/api/core/indexing_runner.py", line 625, in _process_chunk
    index_processor.load(dataset, chunk_documents, with_keywords=False)
  File "/home/github/dify/api/core/rag/index_processor/processor/parent_child_index_processor.py", line 108, in load
    vector.create(formatted_child_documents)
  File "/home/github/dify/api/core/rag/datasource/vdb/vector_factory.py", line 160, in create
    embeddings = self._embeddings.embed_documents([document.page_content for document in texts])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/github/dify/api/core/rag/embedding/cached_embedding.py", line 99, in embed_documents
    raise ex
  File "/home/github/dify/api/core/rag/embedding/cached_embedding.py", line 61, in embed_documents
    embedding_result = self._model_instance.invoke_text_embedding(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/github/dify/api/core/model_manager.py", line 221, in invoke_text_embedding
    self._round_robin_invoke(
  File "/home/github/dify/api/core/model_manager.py", line 370, in _round_robin_invoke
    return function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/github/dify/api/core/model_runtime/model_providers/__base/text_embedding_model.py", line 53, in invoke
    raise self._transform_invoke_error(e)
  File "/home/github/dify/api/core/model_runtime/model_providers/__base/text_embedding_model.py", line 42, in invoke
    return plugin_model_manager.invoke_text_embedding(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/github/dify/api/core/plugin/manager/model.py", line 273, in invoke_text_embedding
    for resp in response:
                ^^^^^^^^
  File "/home/github/dify/api/core/plugin/manager/base.py", line 189, in _request_with_plugin_daemon_response_stream
    self._handle_plugin_daemon_error(error.error_type, error.message)
  File "/home/github/dify/api/core/plugin/manager/base.py", line 213, in _handle_plugin_daemon_error
    raise InvokeBadRequestError(description=args.get("description"))
core.model_runtime.errors.invoke.InvokeBadRequestError: [models] Bad Request Error, 500 Server Error: Internal Server Error for url: http://192.168.1.5:11434/api/embed
Originally created by @Sakura4036 on GitHub (Mar 24, 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.12 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce 1. pull ollama docker 2. ollama run ollama pull jeffh/intfloat-multilingual-e5-large-instruct:f16 (or other embedding model) 3. add ollama model on dify model setting 4. create a Knowledge on dify web, use Parent-Child mode 5. set embedding model is an ollama embedding model ### ✔️ Expected Behavior embed documents success ### ❌ Actual Behavior ![Image](https://github.com/user-attachments/assets/8fa8bf66-4fc4-43fb-94e7-a854c393ad95) ![Image](https://github.com/user-attachments/assets/1a8be0fc-c9b0-4be2-9ea6-7593043ae055) ### dify celery log ``` shell File "/home/github/dify/api/core/indexing_runner.py", line 625, in _process_chunk index_processor.load(dataset, chunk_documents, with_keywords=False) File "/home/github/dify/api/core/rag/index_processor/processor/parent_child_index_processor.py", line 108, in load vector.create(formatted_child_documents) File "/home/github/dify/api/core/rag/datasource/vdb/vector_factory.py", line 160, in create embeddings = self._embeddings.embed_documents([document.page_content for document in texts]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/github/dify/api/core/rag/embedding/cached_embedding.py", line 99, in embed_documents raise ex File "/home/github/dify/api/core/rag/embedding/cached_embedding.py", line 61, in embed_documents embedding_result = self._model_instance.invoke_text_embedding( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/github/dify/api/core/model_manager.py", line 221, in invoke_text_embedding self._round_robin_invoke( File "/home/github/dify/api/core/model_manager.py", line 370, in _round_robin_invoke return function(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/github/dify/api/core/model_runtime/model_providers/__base/text_embedding_model.py", line 53, in invoke raise self._transform_invoke_error(e) File "/home/github/dify/api/core/model_runtime/model_providers/__base/text_embedding_model.py", line 42, in invoke return plugin_model_manager.invoke_text_embedding( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/github/dify/api/core/plugin/manager/model.py", line 273, in invoke_text_embedding for resp in response: ^^^^^^^^ File "/home/github/dify/api/core/plugin/manager/base.py", line 189, in _request_with_plugin_daemon_response_stream self._handle_plugin_daemon_error(error.error_type, error.message) File "/home/github/dify/api/core/plugin/manager/base.py", line 213, in _handle_plugin_daemon_error raise InvokeBadRequestError(description=args.get("description")) core.model_runtime.errors.invoke.InvokeBadRequestError: [models] Bad Request Error, 500 Server Error: Internal Server Error for url: http://192.168.1.5:11434/api/embed ```
yindo closed this issue 2026-02-16 10:18:08 -05:00
Author
Owner

@Sakura4036 commented on GitHub (Mar 24, 2025):

Zhipu text embedding model is useful.

Image

Image

@Sakura4036 commented on GitHub (Mar 24, 2025): Zhipu text embedding model is useful. ![Image](https://github.com/user-attachments/assets/d43dab12-2ad7-4f42-bd9a-92726a8566dd) ![Image](https://github.com/user-attachments/assets/01426feb-df2a-4964-a00d-d9e7945d45b3)
Author
Owner

@dosubot[bot] commented on GitHub (Mar 24, 2025):

I found a similar discussion that might be relevant to your issue. In the thread titled Adding a local ollama model error, it was suggested to upgrade the Ollama to the latest version and use the new endpoint api/embed as the old one api/embedings has been deprecated [1].

Additionally, the "Bad Request Error, 500 Server Error: Internal Server Error" could be caused by the Ollama service not being accessible from the Docker container. To resolve this, replace localhost with host.docker.internal in the service URL to ensure the Docker container can access the Ollama service running on the host machine:

http://host.docker.internal:11434

If you are using macOS, you may need to set the OLLAMA_HOST environment variable using launchctl:

launchctl setenv OLLAMA_HOST "0.0.0.0"

For Linux, edit the systemd service to include the environment variable:

[Service]
Environment="OLLAMA_HOST=0.0.0.0"

And for Windows, set the OLLAMA_HOST environment variable through the system settings [2].

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 (Mar 24, 2025): <!-- Answer --> I found a similar discussion that might be relevant to your issue. In the thread titled [Adding a local ollama model error](https://github.com/langgenius/dify/discussions/7362), it was suggested to upgrade the Ollama to the latest version and use the new endpoint `api/embed` as the old one `api/embedings` has been deprecated <sup>[[1]](https://github.com/langgenius/dify/discussions/7362)</sup>. Additionally, the "Bad Request Error, 500 Server Error: Internal Server Error" could be caused by the Ollama service not being accessible from the Docker container. To resolve this, replace `localhost` with `host.docker.internal` in the service URL to ensure the Docker container can access the Ollama service running on the host machine: ```bash http://host.docker.internal:11434 ``` If you are using macOS, you may need to set the `OLLAMA_HOST` environment variable using `launchctl`: ```bash launchctl setenv OLLAMA_HOST "0.0.0.0" ``` For Linux, edit the systemd service to include the environment variable: ```ini [Service] Environment="OLLAMA_HOST=0.0.0.0" ``` And for Windows, set the `OLLAMA_HOST` environment variable through the system settings <sup>[[2]](https://github.com/langgenius/dify-docs/blob/main/en/development/models-integration/ollama.md)</sup>. <!-- 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/338fdd06-aa66-4b5d-980c-5ad67daf41af?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/338fdd06-aa66-4b5d-980c-5ad67daf41af?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/338fdd06-aa66-4b5d-980c-5ad67daf41af?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/338fdd06-aa66-4b5d-980c-5ad67daf41af?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/338fdd06-aa66-4b5d-980c-5ad67daf41af?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/338fdd06-aa66-4b5d-980c-5ad67daf41af?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/338fdd06-aa66-4b5d-980c-5ad67daf41af?feedback_type=other)</sup>
Author
Owner

@Sakura4036 commented on GitHub (Mar 24, 2025):

ollama embedding test

curl -vvvv -H 'Content-Type: application/json' "http://localhost:11434/api/embed" -d '{"input": ["my text 1"], "model": "jeffh/intfloat-multilingual-e5-large-instruct:q8_0"}'
* Host localhost:11434 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:11434...
* Connected to localhost (::1) port 11434
> POST /api/embed HTTP/1.1
> Host: localhost:11434
> User-Agent: curl/8.7.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 87
> 
* upload completely sent off: 87 bytes
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Date: Mon, 24 Mar 2025 06:44:44 GMT
< Transfer-Encoding: chunked
< 
{"model":"jeffh/intfloat-multilingual-e5-large-instruct:q8_0","embeddings":[[0.029308537,0.027903933,-0.01015503,...]], "total_duration":4425398705,"load_duration":3493012556,"prompt_eval_count":3}
@Sakura4036 commented on GitHub (Mar 24, 2025): ### ollama embedding test ```shell curl -vvvv -H 'Content-Type: application/json' "http://localhost:11434/api/embed" -d '{"input": ["my text 1"], "model": "jeffh/intfloat-multilingual-e5-large-instruct:q8_0"}' * Host localhost:11434 was resolved. * IPv6: ::1 * IPv4: 127.0.0.1 * Trying [::1]:11434... * Connected to localhost (::1) port 11434 > POST /api/embed HTTP/1.1 > Host: localhost:11434 > User-Agent: curl/8.7.1 > Accept: */* > Content-Type: application/json > Content-Length: 87 > * upload completely sent off: 87 bytes < HTTP/1.1 200 OK < Content-Type: application/json; charset=utf-8 < Date: Mon, 24 Mar 2025 06:44:44 GMT < Transfer-Encoding: chunked < {"model":"jeffh/intfloat-multilingual-e5-large-instruct:q8_0","embeddings":[[0.029308537,0.027903933,-0.01015503,...]], "total_duration":4425398705,"load_duration":3493012556,"prompt_eval_count":3} ```
Author
Owner

@darkSuperman commented on GitHub (Mar 24, 2025):

I have the same problem. I guess it may be a problem with dify, because adding a PDF file will cause this problem, but adding a txt file is successful. And I also tested it through the ollama interface http://xxxxxx:11434/api/embed and it is OK

Image

Image

@darkSuperman commented on GitHub (Mar 24, 2025): I have the same problem. I guess it may be a problem with dify, because adding a PDF file will cause this problem, but adding a txt file is successful. And I also tested it through the `ollama `interface `http://xxxxxx:11434/api/embed` and it is OK ![Image](https://github.com/user-attachments/assets/71f70950-bfcd-4e84-acd6-34bc034c4ded) ![Image](https://github.com/user-attachments/assets/ef55fe6d-97de-476a-8e9e-794afb91a3b1)
Author
Owner

@Sakura4036 commented on GitHub (Mar 25, 2025):

Oh, thanks for your txt file test, which made the issue clearer.

@Sakura4036 commented on GitHub (Mar 25, 2025): Oh, thanks for your txt file test, which made the issue clearer.
Author
Owner

@dosubot[bot] commented on GitHub (Apr 25, 2025):

Hi, @Sakura4036. I'm Dosu, and I'm helping the Dify team manage their backlog. I'm marking this issue as stale.

Issue Summary

  • You encountered errors embedding documents using the Ollama model in a self-hosted Dify setup.
  • I suggested upgrading the Ollama model and adjusting the service URL.
  • You confirmed successful embedding with a curl test.
  • darkSuperman noted the issue might be specific to PDF files, as txt files embedded without problems.
  • The issue was resolved by upgrading the Ollama model and adjusting the service URL.

Next Steps

  • Please let us know if this issue is still relevant to the latest version of Dify by commenting here.
  • If there are no further updates, this issue will be automatically closed in 15 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Apr 25, 2025): Hi, @Sakura4036. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog. I'm marking this issue as stale. **Issue Summary** - You encountered errors embedding documents using the Ollama model in a self-hosted Dify setup. - I suggested upgrading the Ollama model and adjusting the service URL. - You confirmed successful embedding with a curl test. - darkSuperman noted the issue might be specific to PDF files, as txt files embedded without problems. - The issue was resolved by upgrading the Ollama model and adjusting the service URL. **Next Steps** - Please let us know if this issue is still relevant to the latest version of Dify by commenting here. - If there are no further updates, this issue will be automatically closed in 15 days. Thank you for your understanding and contribution!
Author
Owner

@ultradawn commented on GitHub (Nov 20, 2025):

I have faced same issue and solved it after downgrade the ollama version to 0.11.11

@ultradawn commented on GitHub (Nov 20, 2025): I have faced same issue and solved it after downgrade the ollama version to 0.11.11
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#116