Show HN: Vanna AI – Open-sourced text-to-SQL in Python (vanna.ai)

31 points by zainhoda ↗ HN
Hey there HN!

We've just open-sourced Vanna – a Python package that allows you to transform questions into SQL. We've leveraged LLMs to enable you to "ask" databases what you need, bypassing the need to "write" complex SQL.

Quick Overview:

- "Train" using DDL statements, documentation, or known correct SQL statements.

- "Ask" questions in natural language and receive SQL, tables, and charts in return.

- Open Source Flexibility: Swap storage mechanisms, customize LLMs, and choose your databases.

- Local or Hosted: Operate everything locally or use our hosted version for free (including complimentary LLM calls).

- Use it wherever Python is applicable. We provide code examples for integration in Jupyter, Streamlit, Slack, and more.

We would greatly appreciate your feedback, insights on issues, and contributions:

https://github.com/vanna-ai/vanna

13 comments

[ 5.9 ms ] story [ 55.4 ms ] thread
Looks nice but I'm confused why it's advertised as if it's training anything. It's just doing retrieval from a vector db and generating a prompt with openai/LLM.
We use "train" in a colloquial sense because you're right -- it's RAG. We've tried to think about a different term but "train" seems to be the one that most data analysts resonate with.
These results are impressive, guys. I'm saving a pointer to dig deeper to glean the details. Tip in the hat for making it open.
Impressive! Quick question - is it possible to generate sql for a slight variant of sql? My project augments standard sql with a few new constructs.
It probably could but it would require adjusting the prompt. You’d have to override the generate_prompt function and tell it that you’re using a variant of SQL and describe the differences.
Is there a token limit for the train step? Like length of documentation, number of example SQL queries?
There isn't technically a limit on the storage side but it's generally better if you keep documentation to a manageable length.

You call vn.train(sql=...) on each individual SQL statement that you have.

What'll happen under the hood is the package will use the 10 most relevant SQL statement examples, 10 most relevant pieces of documentation, and 10 most relevant DDL statements.

If using 10 examples exceeds the (approximate) token limit for the model, it'll pare down to a smaller number that'll fit into the context limit.