[GH-ISSUE #19749] issue: Embedding model not working (“NoneType has no attribute encode”) when using local SentenceTransformers (engine="") #57648

Closed
opened 2026-05-05 21:17:50 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @tar-s on GitHub (Dec 4, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/19749

Check Existing Issues

  • I have searched for any existing and/or related issues.
  • I have searched for any existing and/or related discussions.
  • I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!).
  • I am using the latest version of Open WebUI.

Installation Method

Docker

Open WebUI Version

v0.6.39

Ollama Version (if applicable)

No response

Operating System

Ubuntu 22.04

Browser (if applicable)

No response

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided every relevant configuration, setting, and environment variable used in my setup.
  • I have clearly listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc).
  • I have documented step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation. My steps:
  • Start with the initial platform/version/OS and dependencies used,
  • Specify exact install/launch/configure commands,
  • List URLs visited, user input (incl. example values/emails/passwords if needed),
  • Describe all options and toggles enabled or changed,
  • Include any files or environmental changes,
  • Identify the expected and actual result at each stage,
  • Ensure any reasonably skilled user can follow and hit the same issue.

Expected Behavior

When using the default local embedding engine (embedding_engine="") with a SentenceTransformers model such as BAAI/bge-m3, OpenWebUI should:

  • Initialize a proper SentenceTransformer embedding model (e.g., SentenceTransformer(embedding_model)).
  • Provide a valid embedding_function object with an .encode() method.
  • Successfully generate embeddings during document ingestion.
  • Not crash with NoneType errors.

Local embeddings should work reliably without requiring Ollama/OpenAI engines.

Actual Behavior

OpenWebUI fails to generate embeddings using the default local embedding engine.

Backend logs:

ERROR: 'NoneType' object has no attribute 'encode'
Traceback [...]
embedding_function.encode(...)
AttributeError: 'NoneType' object has no attribute 'encode'

This indicates that embedding_function is never initialized and remains None, causing embedding generation to fail for any document ingestion.

Steps to Reproduce

Steps to Reproduce

  1. Start OpenWebUI using the latest Docker image:

    ghcr.io/open-webui/open-webui:latest
    
  2. Go to Settings → Embeddings.

  3. Configure:

    • Embedding engine: Default (SentenceTransformers)
      (embedding_engine="")
    • Model name: BAAI/bge-m3
  4. Upload any document (PDF, PPTX, DOCX).

  5. Observe backend logs — embedding generation fails with:

    'NoneType' object has no attribute 'encode'
    

Logs & Screenshots

Relevant Logs

ERROR: 'NoneType' object has no attribute 'encode'
Traceback [...]
embedding_function.encode(...)
AttributeError: 'NoneType' object has no attribute 'encode'

Additional fragment:

embedding_function.encode(
    query, ...
)

This confirms embedding_function is None.

Additional Information

Root Cause (identified)

In retrieval/utils.py, the code path for embedding_engine == "" defines an async wrapper around embedding_function.encode, but never initializes embedding_function:

if embedding_engine == "":
    async def async_embedding_function(query, prefix=None, user=None):
        return await asyncio.to_thread(
            lambda query, prefix=None: embedding_function.encode(...),
            query, prefix
        )
    return async_embedding_function

Problems:

  1. embedding_function is never created for the default engine.
  2. Only “ollama”, “openai”, “azure_openai” have initialization logic.
  3. Therefore, the local embedding backend is non-functional.

Verification inside the container

Manual test succeeds:

from sentence_transformers import SentenceTransformer
m = SentenceTransformer("BAAI/bge-m3")
print(m.encode(["test"]))

CUDA and Torch work as expected.


Proposed Fix

Add initialization for the default embedding engine:

if embedding_engine == "":
    from sentence_transformers import SentenceTransformer
    embedding_function = SentenceTransformer(embedding_model)

Then wrap it in the async function.

This aligns with previous versions of OpenWebUI where SentenceTransformers embeddings worked correctly.

Originally created by @tar-s on GitHub (Dec 4, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/19749 ### Check Existing Issues - [x] I have searched for any existing and/or related issues. - [x] I have searched for any existing and/or related discussions. - [x] I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!). - [x] I am using the latest version of Open WebUI. ### Installation Method Docker ### Open WebUI Version v0.6.39 ### Ollama Version (if applicable) _No response_ ### Operating System Ubuntu 22.04 ### Browser (if applicable) _No response_ ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have **provided every relevant configuration, setting, and environment variable used in my setup.** - [x] I have clearly **listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup** (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc). - [x] I have documented **step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation**. My steps: - Start with the initial platform/version/OS and dependencies used, - Specify exact install/launch/configure commands, - List URLs visited, user input (incl. example values/emails/passwords if needed), - Describe all options and toggles enabled or changed, - Include any files or environmental changes, - Identify the expected and actual result at each stage, - Ensure any reasonably skilled user can follow and hit the same issue. ### Expected Behavior When using the default local embedding engine (`embedding_engine=""`) with a SentenceTransformers model such as **BAAI/bge-m3**, OpenWebUI should: * Initialize a proper SentenceTransformer embedding model (e.g., `SentenceTransformer(embedding_model)`). * Provide a valid `embedding_function` object with an `.encode()` method. * Successfully generate embeddings during document ingestion. * Not crash with `NoneType` errors. Local embeddings should work reliably without requiring Ollama/OpenAI engines. ### Actual Behavior OpenWebUI fails to generate embeddings using the default local embedding engine. Backend logs: ``` ERROR: 'NoneType' object has no attribute 'encode' Traceback [...] embedding_function.encode(...) AttributeError: 'NoneType' object has no attribute 'encode' ``` This indicates that **`embedding_function` is never initialized** and remains `None`, causing embedding generation to fail for any document ingestion. ### Steps to Reproduce ### **Steps to Reproduce** 1. Start OpenWebUI using the latest Docker image: ``` ghcr.io/open-webui/open-webui:latest ``` 2. Go to **Settings → Embeddings**. 3. Configure: * **Embedding engine:** Default (SentenceTransformers) (`embedding_engine=""`) * **Model name:** `BAAI/bge-m3` 4. Upload any document (PDF, PPTX, DOCX). 5. Observe backend logs — embedding generation fails with: ``` 'NoneType' object has no attribute 'encode' ``` ### Logs & Screenshots ### **Relevant Logs** ``` ERROR: 'NoneType' object has no attribute 'encode' Traceback [...] embedding_function.encode(...) AttributeError: 'NoneType' object has no attribute 'encode' ``` Additional fragment: ``` embedding_function.encode( query, ... ) ``` This confirms `embedding_function` is `None`. ### Additional Information **Root Cause (identified)** In `retrieval/utils.py`, the code path for `embedding_engine == ""` defines an async wrapper around `embedding_function.encode`, but **never initializes `embedding_function`**: ```python if embedding_engine == "": async def async_embedding_function(query, prefix=None, user=None): return await asyncio.to_thread( lambda query, prefix=None: embedding_function.encode(...), query, prefix ) return async_embedding_function ``` Problems: 1. **`embedding_function` is never created** for the default engine. 2. Only “ollama”, “openai”, “azure_openai” have initialization logic. 3. Therefore, the local embedding backend is non-functional. **Verification inside the container** Manual test succeeds: ```python from sentence_transformers import SentenceTransformer m = SentenceTransformer("BAAI/bge-m3") print(m.encode(["test"])) ``` CUDA and Torch work as expected. --- **Proposed Fix** Add initialization for the default embedding engine: ```python if embedding_engine == "": from sentence_transformers import SentenceTransformer embedding_function = SentenceTransformer(embedding_model) ``` Then wrap it in the async function. This aligns with previous versions of OpenWebUI where SentenceTransformers embeddings worked correctly.
GiteaMirror added the bug label 2026-05-05 21:17:50 -05:00
Author
Owner

@owui-terminator[bot] commented on GitHub (Dec 4, 2025):

🔍 Similar Issues Found

I found some existing issues that might be related to this one. Please check if any of these are duplicates or contain helpful solutions:

  1. #17005 issue: 'NoneType' object has no attribute 'encode'
    by zic04 • Aug 28, 2025 • bug

  2. #19474 issue: Embeddings using API not working
    by curious-broccoli • Nov 25, 2025 • bug

  3. #19512 issue: Regression: 'NoneType' object has no attribute 'encode' with SentenceTransformers embedding Qwen/Qwen3-Embedding-0.6B in v0.6.40 (works in v0.6.38)
    by borntoknow • Nov 26, 2025 • bug

  4. #14433 issue: WebSearch does not work - 'NoneType' object has no attribute 'encode'
    by yazon • May 28, 2025 • bug

  5. #13630 issue: Notes broken because of embeddings exception: TypeError: 'NoneType' object is not iterable
    by thiswillbeyourgithub • May 07, 2025 • bug

Show 5 more related issues
  1. #16389 issue: embeddings based on OpenAI-compatible APIs are broken
    by MattBash17 • Aug 08, 2025 • bug

  2. #17605 issue: non_ASCII UTF-8 always encoded in payload sent to model (leading to bad tokenization)
    by mramendi • Sep 19, 2025 • bug

  3. #15535 issue: Plain text file upload to knowledge fails with 400: 'NoneType' object has no attribute 'encode'
    by GanizaniSitara • Jul 04, 2025 • bug

  4. #11224 issue: Embedding model set: sentence-transformers/all-MiniLM-L6-v2 THEN exited with code 0 (DOCKER)
    by toddpage • Mar 05, 2025 • bug

  5. #19423 issue: Embedding regression
    by scheatkode • Nov 24, 2025 • bug


💡 Tips:

  • If this is a duplicate, please consider closing this issue and adding any additional details to the existing one
  • If you found a solution in any of these issues, please share it here to help others

This comment was generated automatically by a bot. Please react with a 👍 if this comment was helpful, or a 👎 if it was not.

<!-- gh-comment-id:3611969326 --> @owui-terminator[bot] commented on GitHub (Dec 4, 2025): 🔍 **Similar Issues Found** I found some existing issues that might be related to this one. Please check if any of these are duplicates or contain helpful solutions: 1. [#17005](https://github.com/open-webui/open-webui/issues/17005) **issue: 'NoneType' object has no attribute 'encode'** *by zic04 • Aug 28, 2025 • `bug`* 2. [#19474](https://github.com/open-webui/open-webui/issues/19474) **issue: Embeddings using API not working** *by curious-broccoli • Nov 25, 2025 • `bug`* 3. [#19512](https://github.com/open-webui/open-webui/issues/19512) **issue: Regression: 'NoneType' object has no attribute 'encode' with SentenceTransformers embedding Qwen/Qwen3-Embedding-0.6B in v0.6.40 (works in v0.6.38)** *by borntoknow • Nov 26, 2025 • `bug`* 4. [#14433](https://github.com/open-webui/open-webui/issues/14433) **issue: WebSearch does not work - 'NoneType' object has no attribute 'encode'** *by yazon • May 28, 2025 • `bug`* 5. [#13630](https://github.com/open-webui/open-webui/issues/13630) **issue: Notes broken because of embeddings exception: TypeError: 'NoneType' object is not iterable** *by thiswillbeyourgithub • May 07, 2025 • `bug`* <details> <summary>Show 5 more related issues</summary> 6. [#16389](https://github.com/open-webui/open-webui/issues/16389) **issue: embeddings based on OpenAI-compatible APIs are broken** *by MattBash17 • Aug 08, 2025 • `bug`* 7. [#17605](https://github.com/open-webui/open-webui/issues/17605) **issue: non_ASCII UTF-8 always encoded in payload sent to model (leading to bad tokenization)** *by mramendi • Sep 19, 2025 • `bug`* 8. [#15535](https://github.com/open-webui/open-webui/issues/15535) **issue: Plain text file upload to knowledge fails with 400: 'NoneType' object has no attribute 'encode'** *by GanizaniSitara • Jul 04, 2025 • `bug`* 9. [#11224](https://github.com/open-webui/open-webui/issues/11224) **issue: Embedding model set: sentence-transformers/all-MiniLM-L6-v2 THEN exited with code 0 (DOCKER)** *by toddpage • Mar 05, 2025 • `bug`* 10. [#19423](https://github.com/open-webui/open-webui/issues/19423) **issue: Embedding regression** *by scheatkode • Nov 24, 2025 • `bug`* </details> --- 💡 **Tips:** - If this is a duplicate, please consider closing this issue and adding any additional details to the existing one - If you found a solution in any of these issues, please share it here to help others *This comment was generated automatically by a bot.* Please react with a 👍 if this comment was helpful, or a 👎 if it was not.
Author
Owner

@Classic298 commented on GitHub (Dec 4, 2025):

setup details? Did you enter the model in the Document settings AND press the download button AND press on save? Did you enable offline mode of hf hub offline per any chance?

<!-- gh-comment-id:3611979933 --> @Classic298 commented on GitHub (Dec 4, 2025): setup details? Did you enter the model in the Document settings AND press the download button AND press on save? Did you enable offline mode of hf hub offline per any chance?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#57648