[GH-ISSUE #4509] API HTTP code: 500, "error":"failed to generate embedding with langchain #49337

Open
opened 2026-04-28 11:16:55 -05:00 by GiteaMirror · 8 comments
Owner

Originally created by @buaa39055211 on GitHub (May 18, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/4509

What is the issue?

after version 0.1.32 of Ollama,there always have a bug with the api of embedding
the embedding model I used is "smartcreation/bge-large-zh-v1.5",and dztech/bge-large-zh:v1.5 pulled from ollama

`
from langchain_community.embeddings import OllamaEmbeddings
from langchain_community.document_loaders import (
CSVLoader,
UnstructuredWordDocumentLoader,
)
from langchain_community.vectorstores import Qdrant
from qdrant_client import QdrantClient
base_url="http://127.0.0.1:11434")
embeddings = OllamaEmbeddings(model="dztech/bge-large-zh:v1.5",base_url=base_url)
LOADER_MAPPING = {
".csv": (CSVLoader, {}),
# ".docx": (Docx2txtLoader, {}),
".doc": (UnstructuredWordDocumentLoader, {"mode": "elements"}),
".docx": (UnstructuredWordDocumentLoader, {}),}
def split(uploaded_file_name):
# Create embeddings
print("Creating new vectorstore")
texts = process_documents(uploaded_file_name)
print(f"Creating embeddings. May take some minutes...")
db = Qdrant.from_documents(texts, embedding=embeddings,url='localhost:7541', collection_name=uploaded_file_name)
print(uploaded_file_name)
query = "insert"
docs = db.similarity_search(query)
print(docs[0].page_content)

`
File "/Users/mac/anaconda3/envs/ag2/lib/python3.11/site-packages/langchain_community/vectorstores/qdrant.py", line 2037, in _embed_texts
embeddings = self.embeddings.embed_documents(list(texts))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mac/anaconda3/envs/ag2/lib/python3.11/site-packages/langchain_community/embeddings/ollama.py", line 204, in embed_documents
embeddings = self._embed(instruction_pairs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mac/anaconda3/envs/ag2/lib/python3.11/site-packages/langchain_community/embeddings/ollama.py", line 192, in _embed
return [self.process_emb_response(prompt) for prompt in iter]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mac/anaconda3/envs/ag2/lib/python3.11/site-packages/langchain_community/embeddings/ollama.py", line 192, in
return [self.process_emb_response(prompt) for prompt in iter]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mac/anaconda3/envs/ag2/lib/python3.11/site-packages/langchain_community/embeddings/ollama.py", line 166, in _process_emb_response
raise ValueError(
ValueError: Error raised by inference API HTTP code: 500, {"error":"failed to generate embedding"}

OS

Linux

GPU

Nvidia

CPU

Intel

Ollama version

0.1.33-0.1.38

Originally created by @buaa39055211 on GitHub (May 18, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/4509 ### What is the issue? after version 0.1.32 of Ollama,there always have a bug with the api of embedding the embedding model I used is "smartcreation/bge-large-zh-v1.5",and dztech/bge-large-zh:v1.5 pulled from ollama ` from langchain_community.embeddings import OllamaEmbeddings from langchain_community.document_loaders import ( CSVLoader, UnstructuredWordDocumentLoader, ) from langchain_community.vectorstores import Qdrant from qdrant_client import QdrantClient base_url="http://127.0.0.1:11434") embeddings = OllamaEmbeddings(model="dztech/bge-large-zh:v1.5",base_url=base_url) LOADER_MAPPING = { ".csv": (CSVLoader, {}), # ".docx": (Docx2txtLoader, {}), ".doc": (UnstructuredWordDocumentLoader, {"mode": "elements"}), ".docx": (UnstructuredWordDocumentLoader, {}),} def split(uploaded_file_name): # Create embeddings print("Creating new vectorstore") texts = process_documents(uploaded_file_name) print(f"Creating embeddings. May take some minutes...") db = Qdrant.from_documents(texts, embedding=embeddings,url='localhost:7541', collection_name=uploaded_file_name) print(uploaded_file_name) query = "insert" docs = db.similarity_search(query) print(docs[0].page_content) ` File "/Users/mac/anaconda3/envs/ag2/lib/python3.11/site-packages/langchain_community/vectorstores/qdrant.py", line 2037, in _embed_texts embeddings = self.embeddings.embed_documents(list(texts)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mac/anaconda3/envs/ag2/lib/python3.11/site-packages/langchain_community/embeddings/ollama.py", line 204, in embed_documents embeddings = self._embed(instruction_pairs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mac/anaconda3/envs/ag2/lib/python3.11/site-packages/langchain_community/embeddings/ollama.py", line 192, in _embed return [self._process_emb_response(prompt) for prompt in iter_] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mac/anaconda3/envs/ag2/lib/python3.11/site-packages/langchain_community/embeddings/ollama.py", line 192, in <listcomp> return [self._process_emb_response(prompt) for prompt in iter_] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mac/anaconda3/envs/ag2/lib/python3.11/site-packages/langchain_community/embeddings/ollama.py", line 166, in _process_emb_response raise ValueError( ValueError: Error raised by inference API HTTP code: 500, {"error":"failed to generate embedding"} ### OS Linux ### GPU Nvidia ### CPU Intel ### Ollama version 0.1.33-0.1.38
GiteaMirror added the bugapi labels 2026-04-28 11:16:58 -05:00
Author
Owner

@colorfuldarkgray commented on GitHub (Aug 3, 2024):

This is not a solution but it helped in my case. What embeddings are you using now?

import chromadb import time client = chromadb.Client() collection = client.create_collection(name="A_review_of_visualisation-as-explanation_techniques")

store each document in a vector embedding database

for i, d in enumerate(all_splits): try: response = ollama.embeddings(model="nomic-embed-text", prompt=d.page_content) except: print(i) time.sleep(0.5) response = ollama.embeddings(model="nomic-embed-text", prompt=d.page_content) embedding = response["embedding"] collection.add( ids=[str(i)], embeddings=[embedding], documents=[d.page_content])

<!-- gh-comment-id:2267201582 --> @colorfuldarkgray commented on GitHub (Aug 3, 2024): > This is not a solution but it helped in my case. What embeddings are you using now? > > import chromadb import time client = chromadb.Client() collection = client.create_collection(name="A_review_of_visualisation-as-explanation_techniques") > > ##### store each document in a vector embedding database > for i, d in enumerate(all_splits): try: response = ollama.embeddings(model="nomic-embed-text", prompt=d.page_content) except: print(i) time.sleep(0.5) response = ollama.embeddings(model="nomic-embed-text", prompt=d.page_content) embedding = response["embedding"] collection.add( ids=[str(i)], embeddings=[embedding], documents=[d.page_content])
Author
Owner

@mokby commented on GitHub (Oct 25, 2024):

same error, did you solve it?

<!-- gh-comment-id:2436677429 --> @mokby commented on GitHub (Oct 25, 2024): same error, did you solve it?
Author
Owner

@colorfuldarkgray commented on GitHub (Oct 25, 2024):

This helped me, have you tried something similar?

for i, d in enumerate(all_splits): 
    try: 
        response = ollama.embeddings(model="nomic-embed-text", prompt=d.page_content) 
    except: 
        time.sleep(0.5) 
        response = ollama.embeddings(model="nomic-embed-text", prompt=d.page_content)
    embedding = response["embedding"] 
    collection.add( ids=[str(i)], embeddings=[embedding], documents=[d.page_content])
<!-- gh-comment-id:2436702918 --> @colorfuldarkgray commented on GitHub (Oct 25, 2024): This helped me, have you tried something similar? ``` for i, d in enumerate(all_splits): try: response = ollama.embeddings(model="nomic-embed-text", prompt=d.page_content) except: time.sleep(0.5) response = ollama.embeddings(model="nomic-embed-text", prompt=d.page_content) embedding = response["embedding"] collection.add( ids=[str(i)], embeddings=[embedding], documents=[d.page_content]) ```
Author
Owner

@mokby commented on GitHub (Oct 25, 2024):

This helped me, have you tried something similar?

for i, d in enumerate(all_splits): 
    try: 
        response = ollama.embeddings(model="nomic-embed-text", prompt=d.page_content) 
    except: 
        time.sleep(0.5) 
        response = ollama.embeddings(model="nomic-embed-text", prompt=d.page_content)
    embedding = response["embedding"] 
    collection.add( ids=[str(i)], embeddings=[embedding], documents=[d.page_content])

Thanks for you replying. When using nomic-embed-text, everything just fine, but after I changed embedding model into anything else, errors occured, I am using LightRAG by the way.

<!-- gh-comment-id:2436713030 --> @mokby commented on GitHub (Oct 25, 2024): > This helped me, have you tried something similar? > > ``` > for i, d in enumerate(all_splits): > try: > response = ollama.embeddings(model="nomic-embed-text", prompt=d.page_content) > except: > time.sleep(0.5) > response = ollama.embeddings(model="nomic-embed-text", prompt=d.page_content) > embedding = response["embedding"] > collection.add( ids=[str(i)], embeddings=[embedding], documents=[d.page_content]) > ``` Thanks for you replying. When using `nomic-embed-text`, everything just fine, but after I changed embedding model into anything else, errors occured, I am using LightRAG by the way.
Author
Owner

@kexul commented on GitHub (Nov 2, 2024):

Same issue here.

<!-- gh-comment-id:2452875029 --> @kexul commented on GitHub (Nov 2, 2024): Same issue here.
Author
Owner

@kexul commented on GitHub (Nov 2, 2024):

C:\a\ollama\ollama\llm\llama.cpp\ggml\src\ggml.c:13289: GGML_ASSERT(i01 >= 0 && i01 < ne01) failed

<!-- gh-comment-id:2452875418 --> @kexul commented on GitHub (Nov 2, 2024): C:\a\ollama\ollama\llm\llama.cpp\ggml\src\ggml.c:13289: GGML_ASSERT(i01 >= 0 && i01 < ne01) failed
Author
Owner

@kexul commented on GitHub (Nov 2, 2024):

As this suggested, https://github.com/ollama/ollama/issues/7441 we should downgrade ollama to 0.3.13.

<!-- gh-comment-id:2452876099 --> @kexul commented on GitHub (Nov 2, 2024): As this suggested, https://github.com/ollama/ollama/issues/7441 we should downgrade ollama to 0.3.13.
Author
Owner

@mokby commented on GitHub (Nov 4, 2024):

As this suggested, #7441 we should downgrade ollama to 0.3.13.

Thanks, will try that later

<!-- gh-comment-id:2453675349 --> @mokby commented on GitHub (Nov 4, 2024): > As this suggested, #7441 we should downgrade ollama to 0.3.13. Thanks, will try that later
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#49337