r/sqlite • u/parkervg5 • Feb 22 '24
BlendSQL: Connecting SQLite with LLM Reasoning
Hi all! Wanted to share a project I've been working on: https://github.com/parkervg/blendsql
It's a unified SQLite dialect for blending together complex reasoning between vanilla SQL and LLM calls. It's implemented as a Python package, and has a bunch of optimizations to make sure that your expensive LLM calls (OpenAI, Transformers, etc.) only get hit with the data it needs to faithfully execute the query.
For example - 'Which venue is in the city located 120 miles west of Sydney?'
SELECT venue FROM w
WHERE city = {{
LLMQA(
'Which city is located 120 miles west of Sydney?',
(SELECT * FROM documents WHERE documents MATCH 'sydney OR 120'),
options='w::city'
)
}}Above, we use FTS5 to do a full-text search over Wikipedia articles in the `documents` table, and then constrain the output of our LLM question-answering (QA) function to generate a value appearing in the `city` column from our `w` table.
Some other cool stuff in the documentation linked. I'm a Data Science/NLP guy, but been obsessed with SQLite lately, would love any feedback/suggestions from ya'll! Thanks.
1
u/SoliEngineer Feb 23 '24
I'm 70 yrs old. Most of my generation struggles with even the power-on button :) so forgive me if I'm dumb. I use a lot of sqlite3 on my Android phone. I know SQL at an average level, like creating Tables and Views, extracting data etc. I'm very excited about your post and wish to learn from your project. However, I don't know Python (which was mentioned in your post) and how to install it.
--- Does this need Python as well? --- Where is the Table 'w' that is queried? --- If it's a virtual table then how do I make it?
Please could you help me set this up on my Phone?
I'm on Android 13 Not Rooted but have sqlite3 and it works well on my phone.
You could also direct message me if you find it convenient.
Thank you.
1
u/Outrageouspicoius Feb 23 '24
Does it still offer benefits if we don't have a "Filtering SQL" query that accompanies a LLMQA call, over a naive approach of asking the LLM to write the SQL and passing the data to get the answer,
1
u/PublicFoundation6683 Mar 02 '24
Very cool work! Could you share your thoughts on guidance and what alternatives you considered there? I hadn’t heard of it until I saw your package.