News for hackers. Stuff that matters.

Show HN: Vanna AI – Open-Sourced Text-to-SQL in Python

https://vanna.ai/blog/vanna-open-source.html

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

( 12 comments | 3 points | on HN )
Re:Show HN: Vanna AI – Open-Sourced Text-to-SQL in Python by ashishsingal on Friday September 08, 2023 @09:05AM (#37432966)
oh how exciting :)
Re:Show HN: Vanna AI – Open-Sourced Text-to-SQL in Python by tzm on Friday September 08, 2023 @11:41AM (#37435071)
Open source, but requires an API key?
Re:Show HN: Vanna AI – Open-Sourced Text-to-SQL in Python by zainhoda on Friday September 08, 2023 @11:59AM (#37435361)
API key is optional -- that's only if you want to use the hosted vector database. When running locally, no Vanna API key is necessary. Instead, you can put in an OpenAI API key as shown here: https://vanna.ai/docs/local.html

If you want to use a locally-hosted LLM, that's also possible by implementing the necessary abstract methods: https://vanna.ai/docs/vanna.html#open-source-and-extending

Re:Show HN: Vanna AI – Open-Sourced Text-to-SQL in Python by ban-lan-gen on Friday September 08, 2023 @11:48AM (#37435184)
Just curious what kinds of models are used in your project?

https://arxiv.org/abs/2306.08891 One paper seems to suggest trained specialized model can outperform LLM in some tasks.

Re:Show HN: Vanna AI – Open-Sourced Text-to-SQL in Python by zainhoda on Friday September 08, 2023 @12:02PM (#37435384)
Thanks for the link! I'll check it out.

In the meantime, this post we wrote might be interesting for you:

https://vanna.ai/blog/ai-sql-accuracy.html

Re:Show HN: Vanna AI – Open-Sourced Text-to-SQL in Python by npace12 on Friday September 08, 2023 @11:50AM (#37435230)
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.
Re:Show HN: Vanna AI – Open-Sourced Text-to-SQL in Python by zainhoda on Friday September 08, 2023 @11:57AM (#37435334)
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.
Re:Show HN: Vanna AI – Open-Sourced Text-to-SQL in Python by jesuslop on Friday September 08, 2023 @07:13PM (#37440457)
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.
Re:Show HN: Vanna AI – Open-Sourced Text-to-SQL in Python by crazy_marksman on Friday September 08, 2023 @08:47PM (#37441091)
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.
Re:Show HN: Vanna AI – Open-Sourced Text-to-SQL in Python by zainhoda on Saturday September 09, 2023 @08:59AM (#37444833)
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.
Re:Show HN: Vanna AI – Open-Sourced Text-to-SQL in Python by crazy_marksman on Sunday September 10, 2023 @12:22PM (#37457342)
Is there a token limit for the train step? Like length of documentation, number of example SQL queries?
Re:Show HN: Vanna AI – Open-Sourced Text-to-SQL in Python by zainhoda on Monday September 11, 2023 @10:01AM (#37467409)
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.