-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error cache and out of range float values are not json compliant #11827
Comments
Hello @jiangvi! I'm here to help you with any bugs, questions, or contributions. Let's tackle this issue together! To resolve the "Out of range float values are not JSON compliant" error in your self-hosted Dify version 0.13.0, you should ensure that the float values in the embeddings are within a range that JSON can handle. This error often occurs when the float values are too large, too small, or not finite (e.g., NaN). Here's a way to modify your code to handle this:
Here's an example modification: import numpy as np
import logging
from sqlalchemy.exc import IntegrityError
# Inside the embed_documents method
for vector in embedding_result.embeddings:
try:
# Normalize the vector
normalized_vector = vector / np.linalg.norm(vector)
# Ensure all values are finite
if not np.all(np.isfinite(normalized_vector)):
raise ValueError("Embedding contains non-finite values.")
# Convert to list and append
normalized_embedding = normalized_vector.tolist()
embedding_queue_embeddings.append(normalized_embedding)
except IntegrityError:
db.session.rollback()
except Exception as e:
logging.exception("Failed to transform embedding") This modification checks if all values in the normalized vector are finite using To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
can you share full log? |
Moreover, I haven’t identified the root cause of the NaN values. Directly calling the Ollama API doesn’t produce them, and I’ve tested it concurrently many times.
|
|
Seems the same as #11792 |
Hi the log error code is different from your screen shot |
|
it's means: |
copy that thanks . |
Signed-off-by: yihong0618 <[email protected]>
Signed-off-by: yihong0618 <[email protected]>
Signed-off-by: yihong0618 <[email protected]>
…anggenius#11840) Signed-off-by: yihong0618 <[email protected]>
…ggenius#11864) Signed-off-by: yihong0618 <[email protected]>
Self Checks
Dify version
0.13.0
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
My Ollama occasionally returns an error when generating embeddings, where the values appear as [NaN, NaN, NaN, ...]. This leads to the following error: "Out of range float values are not JSON compliant."
When I try to reindex, the erroneous embeddings are repeatedly returned due to cached errors.
this is the code where in:
✔️ Expected Behavior
No response
❌ Actual Behavior
No response
The text was updated successfully, but these errors were encountered: