mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 14:39:31 -05:00
[GH-ISSUE #5698] OpenAI Embedding Batch Size not working #133817
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sp301415 on GitHub (Sep 25, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/5698
Bug Report
Installation Method
Custom Install
Environment
Open WebUI Version: [v0.3.22]
Operating System: [Ubuntu 22.04]
Confirmation:
Expected Behavior:
Batching queries to OpenAI compatible server working.
Actual Behavior:
Seperate queries get sent, no batching ocurrs.
Description
Regardless of embedding batch size of OpenAI endpoint (
RAG_EMBEDDING_OPENAI_BATCH_SIZE), no batch queries are sent. This significantly slows down RAG for OpenAI endpoints.A Quick git bisect shows commit
522afbb0a0started this problem.I also think this is the root cause of #5637.
Reproduction Details
Steps to Reproduce:
@sp301415 commented on GitHub (Sep 25, 2024):
Hmm, upon further inspection, I think the issue is in this line:
82cda6e522/backend/open_webui/apps/rag/main.py (L1115-L1126)Currently, something like
[embedding_function(text[0]), embedding_function(text[1]), ...is passed toVECTOR_DB_CLIENT.insert, while it should beembedding_function[text[0], text[1], ...]. It seems to be working if it is fixed asBut I'm not really grasping all of the logic here. @tjbck Can you confirm this fix is enough? Thanks!
@tjbck commented on GitHub (Sep 26, 2024):
Looks reasonable to me, were you able to test the code yourself?
@sp301415 commented on GitHub (Sep 26, 2024):
@tjbck Yes, I patched it myself and it seems like there is no issue right now. I'll test it a bit more and if it's fine, then I'll create a PR :)
@ajikmr commented on GitHub (Sep 26, 2024):
Please check the same for ollama batch embedding as well.
@sp301415 commented on GitHub (Sep 26, 2024):
@ajikmr I don’t think open-webui supports batch embedding for ollama.
@bgeneto commented on GitHub (Sep 26, 2024):
@sp301415 You saved us! Totally related to #5637. No more need to rate limit embeddings api calls! Let's dive in...
I think you've tested only with Milvus, right? Because Chroma client has no
create_collectionmethod. I've got the following error while testing:I know nothing about Milvus, what's the advantage?
Anyway, it follows the code that worked for me (note the commented line):
I've reseted the vector database and removed the contents of
data/vector_db/on every test I've done. Best results with OpenAI compatible API was withjina-embeddings-v3andmxbai-rerank-xsmall-v1reranker:Best results with Ollama engine was with
mxbai-embed-largeandcross-encoder/ms-marco-MiniLM-L-6-v2. I don't have a GPU on my Open WebUI docker container, so I need to use a fast (and small) reranker that works until we can also use external API for reranking...Important: We still require a means to alert the user when a document embed fails by displaying a push notification. Logs aren't reliable enough for this. The document will be there, but it will have no use.
@sp301415 commented on GitHub (Sep 26, 2024):
@bgeneto That's great to hear! I'm also using ChromaDB, may I ask what version of open-webui are you using? I've seen that ChromaDB error in previous versions, but I believe it is gone in the latest version.
@bgeneto commented on GitHub (Sep 26, 2024):
I'm using the dev branch.
@sp301415 commented on GitHub (Sep 26, 2024):
@bgeneto Intresting, it seems like that part of the code is gone after this commit:
4775fe43d8. Can you check your local repository is up-to-date?Edit Oops, sorry, now I understand. The line
in my first comment was definitely a mistake. I was testing with an old version, and it slipped into my comment. I'll remove it!