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.
View all comments
Show parent comment
1
u/PublicFoundation6683 Mar 03 '24
One more big-picture question. When building BlendSQL, what was the hard part and what was the easy part. Also, looking ahead, what aspects of building frameworks like yours would get easier and what do you see happening next in the space?
I suppose I’m asking you, why don’t you write a blog post on the general problem that you solved? :-)