Skip to content
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

TypeError when calling dot_product in faiss library #38

Open
xiaofuhu opened this issue Nov 6, 2024 · 2 comments
Open

TypeError when calling dot_product in faiss library #38

xiaofuhu opened this issue Nov 6, 2024 · 2 comments

Comments

@xiaofuhu
Copy link

xiaofuhu commented Nov 6, 2024

I was following this doc to set up SUQL and trying to get the entry point example working. I was able to create the table in psql and run the 2 servers, but got this error while running the entry point:

Error executing SQL query: table "temp_table_71x0scb5r0gk" does not exist

The query runs fine without the "WHERE answer(...) ..." part.

I got log in the embedding server:

[2024-11-03 18:14:34,081] ERROR in app: Exception on /search [POST]
Traceback (most recent call last):
  File "/home/fuhuxiao/.pyenv/versions/3.9.0/lib/python3.9/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/fuhuxiao/.pyenv/versions/3.9.0/lib/python3.9/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/fuhuxiao/.pyenv/versions/3.9.0/lib/python3.9/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/fuhuxiao/.pyenv/versions/3.9.0/lib/python3.9/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/home/fuhuxiao/.pyenv/versions/3.9.0/lib/python3.9/site-packages/suql/faiss_embedding.py", line 548, in search
    user="select_user",
  File "/home/fuhuxiao/.pyenv/versions/3.9.0/lib/python3.9/site-packages/suql/faiss_embedding.py", line 537, in dot_product
    primary_key_field_name="_id",
  File "/home/fuhuxiao/.pyenv/versions/3.9.0/lib/python3.9/site-packages/suql/faiss_embedding.py", line 493, in _dot_product
    free_text_field_table,
  File "/home/fuhuxiao/.pyenv/versions/3.9.0/lib/python3.9/site-packages/suql/faiss_embedding.py", line 296, in dot_product
TypeError: __init__() missing 1 required positional argument: 'indices'

With some more digging, I think the issue is in suql/faiss_embedding.py, line 297.
In the library code, commenting out

       sel = faiss.IDSelectorBatch(embedding_indices)

and removing params=faiss.SearchParametersIVF(sel=sel) from self.embeddings.search function call made the error go away and the entry point running.

I checked the definition of IDSelectorBatch in faiss repo- it is a python wrapper for a C++ class, but I see both usages (init with an array and init with a size and an array).

Exact query that triggered this issue:
suql = "SELECT * FROM restaurants WHERE answer(reviews, 'Is this good?') = 'Yes';"

SUQL version:
1.1.6

Python version:
3.9.0

Database dump:
tmp.sql.txt

@george1459
Copy link
Contributor

Can you check what is your PostgreSQL version?

@xiaofuhu
Copy link
Author

xiaofuhu commented Nov 6, 2024

Can you check what is your PostgreSQL version?

psql (10.23 (Ubuntu 10.23-0ubuntu0.18.04.2))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants