-
Notifications
You must be signed in to change notification settings - Fork 15.8k
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
Community: LlamaCppEmbeddings embed_documents
and embed_query
#28827
Community: LlamaCppEmbeddings embed_documents
and embed_query
#28827
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test?
@ccurme OKAY |
@ccurme please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@@ -116,7 +117,14 @@ def embed_documents(self, texts: List[str]) -> List[List[float]]: | |||
List of embeddings, one for each text. | |||
""" | |||
embeddings = self.client.create_embedding(texts) | |||
return [list(map(float, e["embedding"])) for e in embeddings["data"]] | |||
if not isinstance(embeddings["data"][0]["embedding"][0], list): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible for this line to raise IndexError where it previously would not? e.g., if texts
is empty or contains empty strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion. I didn't mean to request that we raise an error where it previously would not.
From an ignorant reading of the code (i.e., no knowledge of the behavior of the client) the update introduced the potential to raise IndexError where it previously wouldn't. I've pushed a change that passes your tests. Let me know if you see any issues with it.
@ccurme please review |
embed_documents
andembed_query
was throwing off the error as stated in the issue. The issue was thatLlama
client is returning the embeddings in a nested list which is not being accounted for in the current implementation and therefore the stated error is being raised.