-
Notifications
You must be signed in to change notification settings - Fork 81
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
Binder exception: Cannot retrieve child type of type ANY. LIST or ARRAY is expected. #3507
Comments
Hi @andriichumak, yup, it seems like we have to figure out the right way to promote types in this very common scenario for embeddings. Here's the sequence of steps leading to this issue:
Note that in Kùzu, The workaround here is to perform explicit casting of the # Slightly rephrase the MATCH query
response = conn.execute(
"""
MATCH (d:MyNode)
WITH d, CAST($emb, "DOUBLE[384]") AS emb
RETURN d.id, array_cosine_similarity(d.embedding, emb)
""", {"emb": embedded}
) Result:
Potential ImprovementsI think this pattern of usage for embeddings is incredibly common though, and it's not ideal that the user has to perform explicit casting in this manner. It's also a little hard to remember the syntax of explicit casting for new users to Kùzu. Maybe we could make some better assumptions about the fact that users will bring in embeddings from Python libraries like @andyfengHKU, I think we need to put a bit more thought into this, as I faced a similar issue (as no doubt others will) in #3481. |
Hey @prrao87. Thanks a lot for a quick feedback. The suggested solution works. One thing I noticed is that if I define the column type as UPD: OK, I missed the part that array similarity function does not work on lists. Still, the error message is suspicious, I'd assume both |
Yup, fully agree. There's something regarding the behaviour we need to change internally to make this easier, because the way most users bring in embeddings into Kùzu is from numpy/python. @andyfengHKU will have some ideas on this. Thanks for reporting! Update:
Well, similarity calculation only works on same-size lists, so at least one of the two lists being compared must be an array. However, the fact that it assumes the internals of the |
Hi team. I'm trying to use Kuzu for semantic search using
array_cosine_similarity
and can't get it working. This looks like a bug to me.Here is the minimal repro:
Kuzu 0.4.2
Python 3.11.9
The text was updated successfully, but these errors were encountered: