News for hackers. Stuff that matters.
Re:Vector Search with SQL by wodenokoto on Thursday January 13, 2022 @12:34AM (#29917215)
While it presents txtai as a very neat framework for calculating and searching for embeddings the article doesn’t seem to mention anything about a database server, except for the drawing at top.

The code looks like it is doing an in-memory search.

When searching an embedding space, it is quite common to look for the closest angle of the query vector against amongst the search vectors.

That is a calculation I don’t know how to make a sql server perform and given the headline I thought the article would show a neat trick for doing this.

Re:Vector Search with SQL by neumll on Thursday January 13, 2022 @05:35AM (#29919153)
More information on how txtai builds SQL statements can be found here: https://neuml.github.io/txtai/embeddings/query/#sql

There is also an example notebook: https://colab.research.google.com/github/neuml/txtai/blob/ma...

At a high level, txtai uses a similar clause embedded in SQL statements. For example, "SELECT id, text, score FROM txtai WHERE similar('feel good story') AND text LIKE '%good%'". This statement is parsed and the similar clause runs against the approximate nearest neighbor index. The result ids are then loaded into a temporary table and the SQL statement is dynamically rewritten to change the similar clause into "id IN <temporary table>".