Hi everyone,
I’m building a chatbot that generates SQL queries using an NL2SQL function to retrieve data from BigQuery tables. My table contains multiple columns related to categories (e.g., level1, level2, level3) and commodities (e.g., tag1, tag2, etc.)
Expected Functionality
For example, if “Software Engineering” is a Level 1 category, and a user asks:
“What is the total spend for Software Engineering?”
The query should automatically search across the category columns (level1, level2, level3) and return the relevant results.
Problem
The NL2SQL-generated query does not correctly provide answers based on category columns.
-
I attempted prompt engineering, explicitly listing the column names and category values in the prompt. While this improved accuracy, it does not scale well when dealing with a large number of columns.
-
Manually specifying all column details is impractical, so I am looking for alternative approaches to improve NL2SQL performance.
Looking for Solutions
-
Is there a way to automatically map user queries to relevant columns without explicitly listing them in the prompt?
-
Would embedding-based approaches (e.g., vector search for column selection) improve accuracy? I tried using Open Data QnA Pipeline, but when retrieving results for a specific category, it incorrectly returns “data not found.”
-
Are there better techniques for handling this type of scenario in NL2SQL models?