Originally created by @sp301415 on GitHub (Sep 25, 2024).
Bug Report
Installation Method
Custom Install
Environment
Open WebUI Version: [v0.3.22]
Operating System: [Ubuntu 22.04]
Confirmation:
I have read and followed all the instructions provided in the README.md.
I am on 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 the exact steps to reproduce the bug in the "Steps to Reproduce" section below.
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 522afbb0a0 started this problem.
Originally created by @sp301415 on GitHub (Sep 25, 2024).
# Bug Report
## Installation Method
Custom Install
## Environment
- **Open WebUI Version:** [v0.3.22]
- **Operating System:** [Ubuntu 22.04]
**Confirmation:**
- [x] I have read and followed all the instructions provided in the README.md.
- [ ] I am on the latest version of both Open WebUI and Ollama.
- [ ] I have included the browser console logs.
- [ ] I have included the Docker container logs.
- [x] I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below.
## 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 522afbb0a00aa3c688fe5560a48b53cff8f110c3 started this problem.
I also think this is the root cause of #5637.
## Reproduction Details
**Steps to Reproduce:**
1. Set OpenAI compatible embedding server.
2. Set Batch Size to > 1.
3. Upload PDF.
Currently, something like [embedding_function(text[0]), embedding_function(text[1]), ... is passed to VECTOR_DB_CLIENT.insert, while it should be embedding_function[text[0], text[1], ...]. It seems to be working if it is fixed as
But I'm not really grasping all of the logic here. @tjbck Can you confirm this fix is enough? Thanks!
@sp301415 commented on GitHub (Sep 25, 2024):
Hmm, upon further inspection, I think the issue is in this line: https://github.com/open-webui/open-webui/blob/82cda6e52204f621882df696a4a26cc20ab482a0/backend/open_webui/apps/rag/main.py#L1115-L1126
Currently, something like `[embedding_function(text[0]), embedding_function(text[1]), ...` is passed to `VECTOR_DB_CLIENT.insert`, while it should be `embedding_function[text[0], text[1], ...]`. It seems to be working if it is fixed as
```py
embedding_texts = embedding_function(
list(map(lambda x: x.replace("\n", " "), texts))
)
VECTOR_DB_CLIENT.insert(
collection_name=collection_name,
items=[
{
"id": str(uuid.uuid4()),
"text": text,
"vector": embedding_texts[idx],
"metadata": metadatas[idx],
}
for idx, text in enumerate(texts)
],
)
```
But I'm not really grasping all of the logic here. @tjbck Can you confirm this fix is enough? Thanks!
@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 :)
@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 :)
@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_collection method. I've got the following error while testing:
VECTOR_DB_CLIENT.create_collection(collection_name=collection_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ChromaClient' object has no attribute 'create_collection'
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 with jina-embeddings-v3 and mxbai-rerank-xsmall-v1 reranker:
Best results with Ollama engine was with mxbai-embed-large and cross-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.
@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_collection` method. I've got the following error while testing:
```
VECTOR_DB_CLIENT.create_collection(collection_name=collection_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ChromaClient' object has no attribute 'create_collection'
```
I know nothing about Milvus, what's the advantage?
Anyway, it follows the code that worked for me (note the commented line):
```python
# apps/rag/main.py +1115
embedding_texts = embedding_function(
list(map(lambda x: x.replace("\n", " "), texts))
)
#VECTOR_DB_CLIENT.create_collection(collection_name=collection_name)
VECTOR_DB_CLIENT.insert(
collection_name=collection_name,
items=[
{
"id": str(uuid.uuid4()),
"text": text,
"vector": embedding_texts[idx],
"metadata": metadatas[idx],
}
for idx, text in enumerate(texts)
],
)
```
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 with `jina-embeddings-v3` and `mxbai-rerank-xsmall-v1` reranker:

Best results with Ollama engine was with `mxbai-embed-large` and `cross-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.
@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.
@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 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.
I'm using the dev branch.
@bgeneto 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.
I'm using the dev branch.
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!
@sp301415 commented on GitHub (Sep 26, 2024):
@bgeneto Intresting, it seems like that part of the code is gone after this commit: 4775fe43d8d7e1088e9e3730a82e2caf911622be. Can you check your local repository is up-to-date?
**Edit** Oops, sorry, now I understand. The line
```py
VECTOR_DB_CLIENT.create_collection(collection_name=collection_name)
```
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!
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @sp301415 on GitHub (Sep 25, 2024).
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: https://github.com/open-webui/open-webui/blob/82cda6e52204f621882df696a4a26cc20ab482a0/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!