Live data from Hacker News

Show HN: Natural Language to SQL "Text-to-SQL" API

dataherald.com

31–40 of 41 posts

Re: Show HN: Natural Language to SQL "Text-to-SQL" API

#31

How does someone take structured data from a database and turn it into unstructured data for an LLM? I know RAG is a thing but they talk in terms of documents not tables and fields. Could the LLM derive that same California sales answer from just knowing the dataset, but not by writing sql?

Rather than converting the entirety of structured data into unstructured text, we opt to provide the language model with sample rows and the database schema. Utilizing this approach, the LLM is then tasked with generating a SQL query to address the posed question. An alternative strategy, as you've suggested, involves transforming all structured data into textual format and subsequently training an LLM to directly respond to queries. This method, however, presents several challenges:

Linearizing structured data into text risks losing the inherent organization by columns and rows, potentially obfuscating the structured information.

The amount of information encapsulated within large tables poses significant challenges for training or fine-tuning models, attributable to the extensive number of tokens required, which may prove prohibitive for many due to resource constraints.

Re: Show HN: Natural Language to SQL "Text-to-SQL" API

#33
post #20

This looks very polished, and a more self-serve experience than what some other companies have built. Seeing what has happened with Assistants API, do you expect OpenAI to soon introduce an SQL API as well? As someone in the position to evaluate integrating a text-to-SQL pipeline in our product, I'm left wondering "why not just wait until OpenAI does this?" Especially when you consider the pipeline ends at OpenAI's m…

Thanks so much for the kind words.

Getting NL-to-SQL to work at the enterprise grade takes work and a specialized engine / agent to do so (we use fine-tuning together with RAG). I don't believe this will be the objective of OpenAI. Additionally, there are plenty of companies who will want to use a LLM not governed by OpenAI (e.g. another open source model). Dataherald will ultimately allow anyone to swap out the LLM of their choosing. At the moment however GPT4 performs far and above any other model that we've tested.

Re: Show HN: Natural Language to SQL "Text-to-SQL" API

#37
post #17

Earlier quoted context omitted.

All DML commands are blocked by the engine. You can wrap the returned SQL in a CTE only passing the rows the customer is allowed to access.

Wouldn't the AI-generated query need knowledge of the CTE that will be wrapping it? How would the CTE prevent arbitrary joins, or access to tables that use the fully-qualified `schema.table`? And couldn't somebody execute any arbitrary function on the SQL server? Example `pg_sleep(9999999)`.

You could set a low query execution timeout for the session.

Re: Show HN: Natural Language to SQL "Text-to-SQL" API

#40
post #39
post #36

Is it possible to use your own LLM models with Dataherald?

this is on roadmap. which LLM are you focused on using? so far GPT 4 has performed best, head and shoulders above other LLMs, so as a result we are using this one now.

SqlCoder claims to perform better than OpenAI.
Post reply on HN