The results are a little off.
I tried it with this input "convert question and table into SQL query. tables: student_name(id,name), student_age(student_id,age). question: how many students with name jui and age less than 25"
I get "SELECT count(*) FROM student_name WHERE name = 'jui' AND age < 25". I just renamed the input parameters, didn't change the overall structure of the tables.
@moon-cake22 Thank you very much for the testing.
I notice this point as well. The current result is not good for some type of table. I will try to improve it further.
@juierror . Could you please provide scripts for how you're finetuning this model? Thanks!
Sorry for late reply, here is the code
https://github.com/juierror/flan-t5-text-to-sql/blob/main/flan_t5_text2sql_multi_table.ipynb
Thank you!
Thanks for letting us play around with the model. Here is another prompt that came out wrong, if you want more training material:
print(inference(
"Among the artists having concerts in year 2020, which artist has a song whose title equals the name of the stadium on which the concert takes place?",
{
"stadium": ["stadium_id", "location", "name", "capacity", "highest", "lowest", "average"],
"singer": ["singer_id", "name", "country", "song_name"],
"concert": ["concert_id", "stadium_id", "year"],
"singer_in_concert": ["concert_id", "singer_id"]
}))
Returned (which would not work):
SELECT T1.song_name
FROM singer AS T1
JOIN concert AS T2 ON T1.singer_id = T2.singer_id
WHERE T2.year = 2020
AND T1.stadium_id = (
SELECT stadium_id FROM concert WHERE YEAR = 2020
)
To be frank, I still did not have a time to retrain the model. The current model is still not updated.