327 karma · joined March 20, 2019
The agent also can be finetuned on sample NL <> SQL pairs or they can be used in few shot prompting.
Anyone tried this yet or have thoughts?
tldr -> For zero-shot prompting, the closed source LLMs are still far ahead in terms of generating accurate SQL. However the gap is closing. With the right dataset for fine-tuning the open-source LLMs might be able to perform at the same level.
This is a sample set up showing how to set up with US real estate data. With ~60 sample NL <> SQL pairs and ~5 instructions the accuracy gets pretty good. The agent does take ~90 seconds to answer each question though.
Since the issue is often the context, plugging in data dictionaries (and passing those to the LLM) can help
Based on the results, fine-tuning can match and outperform RAG (the approach matches the state of the art on accuracy while being far faster and cheaper). The big challenge for fine-tuning tasks like this is building the training datasets. Things should get even more interesting when GPT-4 is opened for fine-tuning.
You can even see the entire chain of LLM calls in the intermediate_steps field to help debug the agent.
We have some samples (including a quickstart in the README and docs https://dataherald.readthedocs.io/en/latest/quickstart.html) but will be adding more tutorials in the coming days.
You can connect the hosted version to your data warehouse using the SQLAlchemy connectors which are in the open source engine, and the connection info will be stored after being encrypted. An on-prem version of the enterprise product is also on the roadmap.
For protecting against errors the approach is to allow for a human to be in the loop as you alluded to. One of the core pieces of the engine is the Evaluation module which combines white box and black box techniques. You can block the response from going back to the question asker if the confidence level is below a certain threshold until a human verifies the response manually (or always put the human from the data team in the loop).