Relative Content

Tag Archive for sqlsql-serverpostgresqldot-product

SQL DOT_PRODUCT function not recognized (possibly type casting error?)

I have been trying to edit a SQL Query in a friend’s code in order for it to do a Dot product between two embedding vectors: a query vector and a vector it retrieves from the Postgre DB. This DB stores paragraphs from different documents, and each row has not only the embedding for the specific paragraph, but the page number, document name, document link and the original paragraph itself.
The original query, which use the Null safe operator to do a comparison between the embeddings as strings, looks like this:
SELECT content, document, page, line, link
FROM documents
ORDER BY embedding <=> %(embedding)s
LIMIT %(n)s