Spaces:
Sleeping
Sleeping
Update evaluation_mode.py & interactive_mode.py version 1.1.0
Browse files- Update scripts to automate the testing and evaluation.
- Write into file for comparison.
- backend/Q&A_report_Qwen_Qwen2.5-Coder-32B-Instruct_featherless-ai.csv +29 -0
- backend/Q&A_report_Qwen_Qwen2.5-Coder-7B-Instruct_featherless-ai.csv +46 -0
- backend/Q&A_report_defog_sqlcoder-7b-2.csv +21 -0
- backend/sql_eval_Qwen_Qwen2.5-Coder-32B-Instruct_featherless-ai.json +137 -0
- backend/sql_eval_Qwen_Qwen2.5-Coder-7B-Instruct_featherless-ai.json +137 -0
- backend/sql_eval_defog_llama-3-sqlcoder-8b_featherless-ai.json +137 -0
- backend/sql_eval_defog_sqlcoder-7b-2.json +137 -0
- backend/src/scripts/evaluation_mode.py +81 -23
- backend/src/scripts/interactive_mode.py +123 -37
backend/Q&A_report_Qwen_Qwen2.5-Coder-32B-Instruct_featherless-ai.csv
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
id,model_id,question,status,data_returned_correct,attempts,nl_response,sql_generated,error
|
| 2 |
+
1,Qwen/Qwen2.5-Coder-32B-Instruct:featherless-ai,List all the artists name in the database.,success,True,1,"The database contains a wide range of artists, including AC/DC, Accept, Aerosmith, Alanis Morissette, Alice In Chains, and many others.",SELECT Name FROM Artist,
|
| 3 |
+
2,Qwen/Qwen2.5-Coder-32B-Instruct:featherless-ai,How many genres are there?,success,True,1,There are 25 genres.,SELECT COUNT(*) FROM Genre,
|
| 4 |
+
3,Qwen/Qwen2.5-Coder-32B-Instruct:featherless-ai,List the names of the first 5 tracks.,success,True,1,"The first 5 tracks are ""For Those About To Rock (We Salute You)"", ""Balls to the Wall"", ""Fast As a Shark"", ""Restless and Wild"", and ""Princess of the Dawn"".",SELECT Name FROM Track LIMIT 5,
|
| 5 |
+
4,Qwen/Qwen2.5-Coder-32B-Instruct:featherless-ai,Count the number of customers located in the USA.,success,True,1,There are 13 customers located in the USA.,SELECT COUNT(*) FROM Customer WHERE Country = 'USA',
|
| 6 |
+
5,Qwen/Qwen2.5-Coder-32B-Instruct:featherless-ai,Find all invoices for the customer with ID 1.,success,True,1,There are 7 invoices for the customer with ID 1.,SELECT * FROM Invoice WHERE CustomerId = 1,
|
| 7 |
+
6,Qwen/Qwen2.5-Coder-32B-Instruct:featherless-ai,List each album title along with the artist's name.,success,True,1,The database contains a list of over 50 albums along with their respective artists.,"SELECT Album.Title, Artist.Name FROM Album JOIN Artist ON Album.ArtistId = Artist.ArtistId",
|
| 8 |
+
7,Qwen/Qwen2.5-Coder-32B-Instruct:featherless-ai,How many tracks belong to the 'Rock' genre?,success,True,1,There are 1297 tracks that belong to the 'Rock' genre.,SELECT COUNT(*) FROM Track AS T JOIN Genre AS G ON T.GenreId = G.GenreId WHERE G.Name = 'Rock',
|
| 9 |
+
8,Qwen/Qwen2.5-Coder-32B-Instruct:featherless-ai,Show the total revenue generated from each country.,success,True,1,"The total revenue generated spans multiple countries, with the USA leading at $523.06, followed by Canada at $303.96, France at $195.10, Brazil at $190.10, and Portugal at $77.24.","SELECT BillingCountry, SUM(Total) AS TotalRevenue FROM Invoice GROUP BY BillingCountry",
|
| 10 |
+
9,Qwen/Qwen2.5-Coder-32B-Instruct:featherless-ai,Find the total number of items sold for each media type.,success,True,1,"The total number of items sold includes 1976 MPEG audio files, 146 protected AAC audio files, 111 protected MPEG-4 video files, and 7 AAC audio files (3 regular and 4 purchased).","SELECT MediaType.Name, COUNT(*) AS TotalItemsSold
|
| 11 |
+
FROM MediaType
|
| 12 |
+
JOIN Track ON MediaType.MediaTypeId = Track.MediaTypeId
|
| 13 |
+
JOIN InvoiceLine ON Track.TrackId = InvoiceLine.TrackId
|
| 14 |
+
GROUP BY MediaType.Name",
|
| 15 |
+
10,Qwen/Qwen2.5-Coder-32B-Instruct:featherless-ai,List the first and last names of all employees who are Sales Support Agents.,success,True,1,"The Sales Support Agents are Jane Peacock, Margaret Park, and Steve Johnson.","SELECT FirstName, LastName FROM Employee WHERE Title = 'Sales Support Agent'",
|
| 16 |
+
11,Qwen/Qwen2.5-Coder-32B-Instruct:featherless-ai,List the top 5 customers who have spent the most money in total.,success,False,1,"The top 5 customers who have spent the most money in total are Helena Holý with $49.62, Richard Cunningham with $47.62, Luis Rojas with $46.62, Ladislav Kovács with $45.62, and Hugh O'Reilly with $45.62.","SELECT c.CustomerId, c.FirstName, c.LastName, SUM(i.Total) AS TotalSpent
|
| 17 |
+
FROM Customer c
|
| 18 |
+
JOIN Invoice i ON c.CustomerId = i.CustomerId
|
| 19 |
+
GROUP BY c.CustomerId, c.FirstName, c.LastName
|
| 20 |
+
ORDER BY TotalSpent DESC
|
| 21 |
+
LIMIT 5",
|
| 22 |
+
12,Qwen/Qwen2.5-Coder-32B-Instruct:featherless-ai,Which artist has the most tracks in the database? Give the name and count.,success,True,1,Iron Maiden has the most tracks in the database with 213 tracks.,"SELECT T2.Name, COUNT(T3.TrackId) AS TrackCount FROM Album AS T1 JOIN Artist AS T2 ON T1.ArtistId = T2.ArtistId JOIN Track AS T3 ON T1.AlbumId = T3.AlbumId GROUP BY T2.Name ORDER BY TrackCount DESC LIMIT 1",
|
| 23 |
+
13,Qwen/Qwen2.5-Coder-32B-Instruct:featherless-ai,Which genres have more than 100 tracks? List the genre name and count.,success,True,1,"Rock has 1297 tracks, Jazz has 130 tracks, Metal has 374 tracks, Alternative & Punk has 332 tracks, and Latin has 579 tracks.","SELECT G.Name, COUNT(T.TrackId) AS TrackCount
|
| 24 |
+
FROM Genre G
|
| 25 |
+
JOIN Track T ON G.GenreId = T.GenreId
|
| 26 |
+
GROUP BY G.GenreId
|
| 27 |
+
HAVING COUNT(T.TrackId) > 100",
|
| 28 |
+
14,Qwen/Qwen2.5-Coder-32B-Instruct:featherless-ai,Calculate the average track length in seconds for each genre.,success,False,1,"The average track lengths vary significantly across genres, ranging from approximately 134.64 seconds to 2625.55 seconds.","SELECT GenreId, AVG(Milliseconds / 1000.0) AS AverageLengthInSeconds FROM Track GROUP BY GenreId",
|
| 29 |
+
15,Qwen/Qwen2.5-Coder-32B-Instruct:featherless-ai,Identify the artist who has earned the most revenue from customers in Canada.,success,False,2,Metallica has earned the most revenue from customers in Canada.,SELECT T3.Name FROM Invoice AS T1 JOIN Customer AS T2 ON T1.CustomerId = T2.CustomerId JOIN InvoiceLine AS T4 ON T1.InvoiceId = T4.InvoiceId JOIN Track AS T5 ON T4.TrackId = T5.TrackId JOIN Album AS T6 ON T5.AlbumId = T6.AlbumId JOIN Artist AS T3 ON T6.ArtistId = T3.ArtistId WHERE T2.Country = 'Canada' GROUP BY T3.Name ORDER BY SUM(T1.Total) DESC LIMIT 1,
|
backend/Q&A_report_Qwen_Qwen2.5-Coder-7B-Instruct_featherless-ai.csv
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
id,model_id,question,status,data_returned_correct,attempts,nl_response,sql_generated,error
|
| 2 |
+
1,Qwen/Qwen2.5-Coder-7B-Instruct:featherless-ai,List all the artists name in the database.,success,True,1,There are 163 artists listed in the database.,SELECT Name FROM Artist,
|
| 3 |
+
2,Qwen/Qwen2.5-Coder-7B-Instruct:featherless-ai,How many genres are there?,success,True,1,There are 25 genres.,SELECT COUNT(*) FROM Genre,
|
| 4 |
+
3,Qwen/Qwen2.5-Coder-7B-Instruct:featherless-ai,List the names of the first 5 tracks.,success,True,1,"The first 5 tracks are: For Those About To Rock (We Salute You), Balls to the Wall, Fast As a Shark, Restless and Wild, and Princess of the Dawn.",SELECT Name FROM Track LIMIT 5,
|
| 5 |
+
4,Qwen/Qwen2.5-Coder-7B-Instruct:featherless-ai,Count the number of customers located in the USA.,success,True,1,There are 13 customers located in the USA.,SELECT COUNT(*) FROM Customer WHERE Country = 'USA';,
|
| 6 |
+
5,Qwen/Qwen2.5-Coder-7B-Instruct:featherless-ai,Find all invoices for the customer with ID 1.,success,True,1,The customer with ID 1 has 7 invoices.,SELECT * FROM Invoice WHERE CustomerId = 1;,
|
| 7 |
+
6,Qwen/Qwen2.5-Coder-7B-Instruct:featherless-ai,List each album title along with the artist's name.,success,True,1,"There are 100 albums listed, each with its corresponding artist's name.","SELECT T1.Title, T2.Name FROM Album AS T1 INNER JOIN Artist AS T2 ON T1.ArtistId = T2.ArtistId",
|
| 8 |
+
7,Qwen/Qwen2.5-Coder-7B-Instruct:featherless-ai,How many tracks belong to the 'Rock' genre?,success,True,1,There are 1297 tracks that belong to the 'Rock' genre.,SELECT COUNT(*) FROM Track JOIN Genre ON Track.GenreId = Genre.GenreId WHERE Genre.Name = 'Rock',
|
| 9 |
+
8,Qwen/Qwen2.5-Coder-7B-Instruct:featherless-ai,Show the total revenue generated from each country.,success,True,1,"Total revenue generated from each country:
|
| 10 |
+
|
| 11 |
+
- Argentina: $37.62
|
| 12 |
+
- Australia: $37.62
|
| 13 |
+
- Austria: $42.62
|
| 14 |
+
- Belgium: $37.62
|
| 15 |
+
- Brazil: $190.1
|
| 16 |
+
- Canada: $303.96
|
| 17 |
+
- Chile: $46.62
|
| 18 |
+
- Czech Republic: $90.24
|
| 19 |
+
- Denmark: $37.62
|
| 20 |
+
- Finland: $41.62
|
| 21 |
+
- France: $195.1
|
| 22 |
+
- Germany: $156.48
|
| 23 |
+
- Hungary: $45.62
|
| 24 |
+
- India: $75.26
|
| 25 |
+
- Ireland: $45.62
|
| 26 |
+
- Italy: $37.62
|
| 27 |
+
- Netherlands: $40.62
|
| 28 |
+
- Norway: $39.62
|
| 29 |
+
- Poland: $37.62
|
| 30 |
+
- Portugal: $77.24
|
| 31 |
+
- Spain: $37.62
|
| 32 |
+
- Sweden: $38.62
|
| 33 |
+
- USA: $523.06
|
| 34 |
+
- United Kingdom: $112.86","SELECT BillingCountry, SUM(Total) AS TotalRevenue FROM Invoice GROUP BY BillingCountry",
|
| 35 |
+
9,Qwen/Qwen2.5-Coder-7B-Instruct:featherless-ai,Find the total number of items sold for each media type.,Error executing SQL after 3 attempts,False,0,N/A,"SELECT T1.Name, COUNT(T2.MediaTypeId) AS TotalItemsSold FROM MediaType AS T1 INNER JOIN Invoices AS T2 ON T1.MediaTypeId = T2.MediaTypeId GROUP BY T1.Name",no such table: Invoices
|
| 36 |
+
10,Qwen/Qwen2.5-Coder-7B-Instruct:featherless-ai,List the first and last names of all employees who are Sales Support Agents.,success,True,1,"The first and last names of all Sales Support Agents are Jane Peacock, Margaret Park, and Steve Johnson.","SELECT FirstName, LastName FROM Employee WHERE Title = 'Sales Support Agent'",
|
| 37 |
+
11,Qwen/Qwen2.5-Coder-7B-Instruct:featherless-ai,List the top 5 customers who have spent the most money in total.,success,False,2,"The top 5 customers who have spent the most money in total are Helena Holý, Richard Cunningham, Luis Rojas, Ladislav Kovács, and Hugh O'Reilly, each with a total expenditure of $49.62.","SELECT c.CustomerId, c.FirstName, c.LastName, SUM(i.Total) AS TotalSpent
|
| 38 |
+
FROM Customer c
|
| 39 |
+
JOIN Invoice i ON c.CustomerId = i.CustomerId
|
| 40 |
+
GROUP BY c.CustomerId
|
| 41 |
+
ORDER BY TotalSpent DESC
|
| 42 |
+
LIMIT 5",
|
| 43 |
+
12,Qwen/Qwen2.5-Coder-7B-Instruct:featherless-ai,Which artist has the most tracks in the database? Give the name and count.,success,True,3,Iron Maiden has the most tracks with 213.,"SELECT T3.Name, COUNT(*) as TrackCount FROM Track AS T1 INNER JOIN Album AS T2 ON T1.AlbumId = T2.AlbumId INNER JOIN Artist AS T3 ON T2.ArtistId = T3.ArtistId GROUP BY T3.Name ORDER BY TrackCount DESC LIMIT 1",
|
| 44 |
+
13,Qwen/Qwen2.5-Coder-7B-Instruct:featherless-ai,Which genres have more than 100 tracks? List the genre name and count.,success,True,1,"Genres with more than 100 tracks include Rock (1297), Metal (374), Latin (579), Jazz (130), and Alternative & Punk (332).","SELECT T2.Name, COUNT(T1.TrackId) AS TrackCount FROM TRACK AS T1 INNER JOIN GENRE AS T2 ON T1.GenreId = T2.GenreId GROUP BY T2.Name HAVING COUNT(T1.TrackId) > 100",
|
| 45 |
+
14,Qwen/Qwen2.5-Coder-7B-Instruct:featherless-ai,Calculate the average track length in seconds for each genre.,success,False,1,The average track length in seconds for each genre ranges from 134.17 seconds (genre 5) to 2934.05 seconds (genre 24).,"SELECT AVG(Milliseconds / 1000) AS AverageLengthInSeconds, GenreId FROM Track GROUP BY GenreId",
|
| 46 |
+
15,Qwen/Qwen2.5-Coder-7B-Instruct:featherless-ai,Identify the artist who has earned the most revenue from customers in Canada.,Error executing SQL after 3 attempts,False,0,N/A,SELECT T1.Name FROM ARTIST AS T1 JOIN ALBUM AS T2 ON T1.ArtistId = T2.ArtistId JOIN TRACK AS T3 ON T2.AlbumId = T3.AlbumId JOIN INVOICEITEM AS T4 ON T3.TrackId = T4.TrackId JOIN CUSTOMER AS T5 ON T4.InvoiceId = T5.InvoiceId WHERE T5.Country = 'Canada' GROUP BY T1.Name ORDER BY SUM(T4.UnitPrice * T4.Quantity) DESC LIMIT 1,no such table: INVOICEITEM
|
backend/Q&A_report_defog_sqlcoder-7b-2.csv
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
id,model_id,question,status,data_returned_correct,attempts,nl_response,sql_generated,error
|
| 2 |
+
1,defog/sqlcoder-7b-2,List all the artists name in the database.,success,True,1,,"SELECT a.""Name"" FROM ""Artist"" a;",
|
| 3 |
+
2,defog/sqlcoder-7b-2,How many genres are there?,success,True,1, There are 25 genres in the database.,SELECT COUNT(g.genreid) AS number_of_genres FROM genre g;,
|
| 4 |
+
3,defog/sqlcoder-7b-2,List the names of the first 5 tracks.,success,True,1," The first 5 tracks are:
|
| 5 |
+
|
| 6 |
+
[('For Those About To Rock (We Salute You)',), ('Balls to the Wall',), ('Fast As a Shark',), ('Restless and Wild',), ('Princess of the Dawn',)]","SELECT t.name FROM ""Track"" t LIMIT 5;",
|
| 7 |
+
4,defog/sqlcoder-7b-2,Count the number of customers located in the USA.,Error executing SQL after 3 attempts,False,0,N/A,"SELECT COUNT(*) FROM ""Customer"" c WHERE c.Country ILIKE '%USA%';","near ""ILIKE"": syntax error"
|
| 8 |
+
5,defog/sqlcoder-7b-2,Find all invoices for the customer with ID 1.,success,True,1," The user asked the following question: ""Find all invoices for the customer with ID 1.""",SELECT * FROM Invoice i WHERE i.CustomerId = 1;,
|
| 9 |
+
6,defog/sqlcoder-7b-2,List each album title along with the artist's name.,Error executing SQL after 3 attempts,True,0,N/A,"SELECT a.""Title"", ar.""Name"" AS ""Artist Name"" FROM ""Album"" a JOIN ""Artist"" ar ON a.""ArtistId"" = ar.""ArtistId"";","(Request ID: Root=1-6a08e19d-1afb35d014009a893606e2f5;074f3f39-9bf6-45d9-a1be-4a596301074a)
|
| 10 |
+
|
| 11 |
+
Bad request:
|
| 12 |
+
{'message': ""This model's maximum context length is 4096 tokens. However, you requested 512 output tokens and your prompt contains at least 3585 input tokens, for a total of at least 4097 tokens. Please reduce the length of the input prompt or the number of requested output tokens. (parameter=input_tokens, value=3585)"", 'type': 'invalid_request_error', 'param': None, 'code': 'bad_request'}"
|
| 13 |
+
7,defog/sqlcoder-7b-2,How many tracks belong to the 'Rock' genre?,success,True,1, There are 1297 tracks in the 'Rock' genre.,"SELECT COUNT(t.TrackId) AS number_of_tracks FROM ""Track"" t JOIN ""Genre"" g ON t.GenreId = g.GenreId WHERE g.Name = 'Rock';",
|
| 14 |
+
8,defog/sqlcoder-7b-2,Show the total revenue generated from each country.,Error executing SQL after 3 attempts,False,0,N/A,"SELECT c.country_name, SUM(i.total) AS total_revenue FROM ""Invoice"" i JOIN ""Customer"" c ON i.customer_id = c.customer_id GROUP BY c.country_name ORDER BY total_revenue DESC NULLS LAST;",no such column: c.country_name
|
| 15 |
+
9,defog/sqlcoder-7b-2,Find the total number of items sold for each media type.,Error executing SQL after 3 attempts,False,0,N/A,"SELECT m.name AS media_type, COUNT(*) AS total_items_sold FROM ""MediaType"" m JOIN ""Sales"" s ON m.media_type_id = s.media_type_id GROUP BY m.name;",no such table: Sales
|
| 16 |
+
10,defog/sqlcoder-7b-2,List the first and last names of all employees who are Sales Support Agents.,Error executing SQL after 3 attempts,False,0,N/A,"SELECT e.first_name, e.last_name FROM ""Employee"" e WHERE e.title = 'Sales Support Agent';",no such column: e.first_name
|
| 17 |
+
11,defog/sqlcoder-7b-2,List the top 5 customers who have spent the most money in total.,Error executing SQL after 3 attempts,False,0,N/A,"SELECT c.customerid, c.firstname, c.lastname, SUM(oi.productid * oi.quantity) AS total_spent FROM customer c JOIN orders o ON c.customerid = o.customerid JOIN orderitems oi ON o.orderid = oi.orderid GROUP BY c.customerid, c.firstname, c.lastname ORDER BY total_spent DESC LIMIT 5;",no such table: orders
|
| 18 |
+
12,defog/sqlcoder-7b-2,Which artist has the most tracks in the database? Give the name and count.,success,False,2," The artist with the most tracks in the database is ""The Beatles"" with 52 tracks.",,
|
| 19 |
+
13,defog/sqlcoder-7b-2,Which genres have more than 100 tracks? List the genre name and count.,success,True,1," The database returned more than 5 rows, so I will provide a brief summary sentence.","SELECT g.name, COUNT(t.trackid) AS COUNT FROM genre g JOIN track t ON g.genreid = t.genreid GROUP BY g.name HAVING COUNT(t.trackid) > 100 ORDER BY COUNT DESC NULLS LAST;",
|
| 20 |
+
14,defog/sqlcoder-7b-2,Calculate the average track length in seconds for each genre.,Error executing SQL after 3 attempts,False,0,N/A,"SELECT g.Name, AVG(t.Milliseconds / 1000)) AS AverageDuration FROM Track t JOIN Genre g ON t.GenreId = g.GenreId GROUP BY g.Name ORDER BY AverageDuration DESC NULLS LAST;","near "")"": syntax error"
|
| 21 |
+
15,defog/sqlcoder-7b-2,Identify the artist who has earned the most revenue from customers in Canada.,Error executing SQL after 3 attempts,False,0,N/A,"SELECT a.""Name"" FROM ""Artist"" a JOIN ""Album"" al ON a.""ArtistId"" = al.""AlbumArtistId"" WHERE al.""AlbumCountry"" = 'Canada' ORDER BY a.""Name"" DESC NULLS LAST LIMIT 1;",no such column: al.AlbumCountry
|
backend/sql_eval_Qwen_Qwen2.5-Coder-32B-Instruct_featherless-ai.json
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"id": 1,
|
| 4 |
+
"question": "List all the artists name in the database.",
|
| 5 |
+
"taxonomy": "Selection",
|
| 6 |
+
"ex_pass": true,
|
| 7 |
+
"esm_pass": true,
|
| 8 |
+
"generated_sql": "SELECT Name FROM Artist",
|
| 9 |
+
"gold_sql": "SELECT Name FROM Artist;"
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"id": 2,
|
| 13 |
+
"question": "How many genres are there?",
|
| 14 |
+
"taxonomy": "Aggregation",
|
| 15 |
+
"ex_pass": true,
|
| 16 |
+
"esm_pass": true,
|
| 17 |
+
"generated_sql": "SELECT COUNT(*) FROM Genre",
|
| 18 |
+
"gold_sql": "SELECT COUNT(*) FROM Genre;"
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"id": 3,
|
| 22 |
+
"question": "List the names of the first 5 tracks.",
|
| 23 |
+
"taxonomy": "Selection, Limit",
|
| 24 |
+
"ex_pass": true,
|
| 25 |
+
"esm_pass": true,
|
| 26 |
+
"generated_sql": "SELECT Name FROM Track LIMIT 5",
|
| 27 |
+
"gold_sql": "SELECT Name FROM Track LIMIT 5;"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"id": 4,
|
| 31 |
+
"question": "Count the number of customers located in the USA.",
|
| 32 |
+
"taxonomy": "Aggregation, Filtering",
|
| 33 |
+
"ex_pass": true,
|
| 34 |
+
"esm_pass": true,
|
| 35 |
+
"generated_sql": "SELECT COUNT(*) FROM Customer WHERE Country = 'USA'",
|
| 36 |
+
"gold_sql": "SELECT COUNT(*) FROM Customer WHERE Country = 'USA';"
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"id": 5,
|
| 40 |
+
"question": "Find all invoices for the customer with ID 1.",
|
| 41 |
+
"taxonomy": "Selection, Filtering",
|
| 42 |
+
"ex_pass": true,
|
| 43 |
+
"esm_pass": true,
|
| 44 |
+
"generated_sql": "SELECT * FROM Invoice WHERE CustomerId = 1",
|
| 45 |
+
"gold_sql": "SELECT * FROM Invoice WHERE CustomerId = 1;"
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"id": 6,
|
| 49 |
+
"question": "List each album title along with the artist's name.",
|
| 50 |
+
"taxonomy": "Simple Join",
|
| 51 |
+
"ex_pass": true,
|
| 52 |
+
"esm_pass": true,
|
| 53 |
+
"generated_sql": "SELECT Album.Title, Artist.Name FROM Album JOIN Artist ON Album.ArtistId = Artist.ArtistId",
|
| 54 |
+
"gold_sql": "SELECT Album.Title, Artist.Name FROM Album JOIN Artist ON Album.ArtistId = Artist.ArtistId;"
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"id": 7,
|
| 58 |
+
"question": "How many tracks belong to the 'Rock' genre?",
|
| 59 |
+
"taxonomy": "Simple Join, Filtering, Aggregation",
|
| 60 |
+
"ex_pass": true,
|
| 61 |
+
"esm_pass": false,
|
| 62 |
+
"generated_sql": "SELECT COUNT(*) FROM Track AS T JOIN Genre AS G ON T.GenreId = G.GenreId WHERE G.Name = 'Rock'",
|
| 63 |
+
"gold_sql": "SELECT COUNT(*) FROM Track JOIN Genre ON Track.GenreId = Genre.GenreId WHERE Genre.Name = 'Rock';"
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"id": 8,
|
| 67 |
+
"question": "Show the total revenue generated from each country.",
|
| 68 |
+
"taxonomy": "Aggregation, Grouping",
|
| 69 |
+
"ex_pass": true,
|
| 70 |
+
"esm_pass": false,
|
| 71 |
+
"generated_sql": "SELECT BillingCountry, SUM(Total) AS TotalRevenue FROM Invoice GROUP BY BillingCountry",
|
| 72 |
+
"gold_sql": "SELECT BillingCountry, SUM(Total) FROM Invoice GROUP BY BillingCountry;"
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
"id": 9,
|
| 76 |
+
"question": "Find the total number of items sold for each media type.",
|
| 77 |
+
"taxonomy": "Multi-Join, Aggregation, Grouping",
|
| 78 |
+
"ex_pass": true,
|
| 79 |
+
"esm_pass": false,
|
| 80 |
+
"generated_sql": "SELECT MediaType.Name, COUNT(*) AS TotalItemsSold\nFROM MediaType\nJOIN Track ON MediaType.MediaTypeId = Track.MediaTypeId\nJOIN InvoiceLine ON Track.TrackId = InvoiceLine.TrackId\nGROUP BY MediaType.Name",
|
| 81 |
+
"gold_sql": "SELECT MediaType.Name, SUM(InvoiceLine.Quantity) FROM InvoiceLine JOIN Track ON InvoiceLine.TrackId = Track.TrackId JOIN MediaType ON Track.MediaTypeId = MediaType.MediaTypeId GROUP BY MediaType.Name;"
|
| 82 |
+
},
|
| 83 |
+
{
|
| 84 |
+
"id": 10,
|
| 85 |
+
"question": "List the first and last names of all employees who are Sales Support Agents.",
|
| 86 |
+
"taxonomy": "Selection, Filtering",
|
| 87 |
+
"ex_pass": true,
|
| 88 |
+
"esm_pass": true,
|
| 89 |
+
"generated_sql": "SELECT FirstName, LastName FROM Employee WHERE Title = 'Sales Support Agent'",
|
| 90 |
+
"gold_sql": "SELECT FirstName, LastName FROM Employee WHERE Title = 'Sales Support Agent';"
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"id": 11,
|
| 94 |
+
"question": "List the top 5 customers who have spent the most money in total.",
|
| 95 |
+
"taxonomy": "Simple Join, Aggregation, Grouping, Ordering, Limit",
|
| 96 |
+
"ex_pass": false,
|
| 97 |
+
"esm_pass": false,
|
| 98 |
+
"generated_sql": "SELECT c.CustomerId, c.FirstName, c.LastName, SUM(i.Total) AS TotalSpent\nFROM Customer c\nJOIN Invoice i ON c.CustomerId = i.CustomerId\nGROUP BY c.CustomerId, c.FirstName, c.LastName\nORDER BY TotalSpent DESC\nLIMIT 5",
|
| 99 |
+
"gold_sql": "SELECT c.FirstName, c.LastName, SUM(i.Total) as TotalSpent FROM Customer c JOIN Invoice i ON c.CustomerId = i.CustomerId GROUP BY c.CustomerId ORDER BY TotalSpent DESC LIMIT 5;"
|
| 100 |
+
},
|
| 101 |
+
{
|
| 102 |
+
"id": 12,
|
| 103 |
+
"question": "Which artist has the most tracks in the database? Give the name and count.",
|
| 104 |
+
"taxonomy": "Multi-Join, Aggregation, Grouping, Ordering, Limit",
|
| 105 |
+
"ex_pass": true,
|
| 106 |
+
"esm_pass": false,
|
| 107 |
+
"generated_sql": "SELECT T2.Name, COUNT(T3.TrackId) AS TrackCount FROM Album AS T1 JOIN Artist AS T2 ON T1.ArtistId = T2.ArtistId JOIN Track AS T3 ON T1.AlbumId = T3.AlbumId GROUP BY T2.Name ORDER BY TrackCount DESC LIMIT 1",
|
| 108 |
+
"gold_sql": "SELECT ar.Name, COUNT(t.TrackId) as TrackCount FROM Artist ar JOIN Album al ON ar.ArtistId = al.ArtistId JOIN Track t ON al.AlbumId = t.AlbumId GROUP BY ar.ArtistId ORDER BY TrackCount DESC LIMIT 1;"
|
| 109 |
+
},
|
| 110 |
+
{
|
| 111 |
+
"id": 13,
|
| 112 |
+
"question": "Which genres have more than 100 tracks? List the genre name and count.",
|
| 113 |
+
"taxonomy": "Simple Join, Aggregation, Grouping, Having",
|
| 114 |
+
"ex_pass": true,
|
| 115 |
+
"esm_pass": false,
|
| 116 |
+
"generated_sql": "SELECT G.Name, COUNT(T.TrackId) AS TrackCount\nFROM Genre G\nJOIN Track T ON G.GenreId = T.GenreId\nGROUP BY G.GenreId\nHAVING COUNT(T.TrackId) > 100",
|
| 117 |
+
"gold_sql": "SELECT g.Name, COUNT(t.TrackId) as TrackCount FROM Genre g JOIN Track t ON g.GenreId = t.GenreId GROUP BY g.GenreId HAVING TrackCount > 100;"
|
| 118 |
+
},
|
| 119 |
+
{
|
| 120 |
+
"id": 14,
|
| 121 |
+
"question": "Calculate the average track length in seconds for each genre.",
|
| 122 |
+
"taxonomy": "Simple Join, Aggregation, Arithmetic, Grouping",
|
| 123 |
+
"ex_pass": false,
|
| 124 |
+
"esm_pass": false,
|
| 125 |
+
"generated_sql": "SELECT GenreId, AVG(Milliseconds / 1000.0) AS AverageLengthInSeconds FROM Track GROUP BY GenreId",
|
| 126 |
+
"gold_sql": "SELECT g.Name, AVG(t.Milliseconds) / 1000.0 as AvgSeconds FROM Genre g JOIN Track t ON g.GenreId = t.GenreId GROUP BY g.GenreId;"
|
| 127 |
+
},
|
| 128 |
+
{
|
| 129 |
+
"id": 15,
|
| 130 |
+
"question": "Identify the artist who has earned the most revenue from customers in Canada.",
|
| 131 |
+
"taxonomy": "Multi-Join, Aggregation, Grouping, Ordering, Limit",
|
| 132 |
+
"ex_pass": false,
|
| 133 |
+
"esm_pass": false,
|
| 134 |
+
"generated_sql": "SELECT T3.Name FROM Invoice AS T1 JOIN Customer AS T2 ON T1.CustomerId = T2.CustomerId JOIN InvoiceLine AS T4 ON T1.InvoiceId = T4.InvoiceId JOIN Track AS T5 ON T4.TrackId = T5.TrackId JOIN Album AS T6 ON T5.AlbumId = T6.AlbumId JOIN Artist AS T3 ON T6.ArtistId = T3.ArtistId WHERE T2.Country = 'Canada' GROUP BY T3.Name ORDER BY SUM(T1.Total) DESC LIMIT 1",
|
| 135 |
+
"gold_sql": "SELECT ar.Name, SUM(il.UnitPrice * il.Quantity) AS Revenue FROM Artist ar JOIN Album al ON ar.ArtistId = al.ArtistId JOIN Track t ON al.AlbumId = t.AlbumId JOIN InvoiceLine il ON t.TrackId = il.TrackId JOIN Invoice i ON il.InvoiceId = i.InvoiceId WHERE i.BillingCountry = 'Canada' GROUP BY ar.ArtistId ORDER BY Revenue DESC LIMIT 1;"
|
| 136 |
+
}
|
| 137 |
+
]
|
backend/sql_eval_Qwen_Qwen2.5-Coder-7B-Instruct_featherless-ai.json
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"id": 1,
|
| 4 |
+
"question": "List all the artists name in the database.",
|
| 5 |
+
"taxonomy": "Selection",
|
| 6 |
+
"ex_pass": true,
|
| 7 |
+
"esm_pass": true,
|
| 8 |
+
"generated_sql": "SELECT Name FROM Artist",
|
| 9 |
+
"gold_sql": "SELECT Name FROM Artist;"
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"id": 2,
|
| 13 |
+
"question": "How many genres are there?",
|
| 14 |
+
"taxonomy": "Aggregation",
|
| 15 |
+
"ex_pass": true,
|
| 16 |
+
"esm_pass": true,
|
| 17 |
+
"generated_sql": "SELECT COUNT(*) FROM Genre",
|
| 18 |
+
"gold_sql": "SELECT COUNT(*) FROM Genre;"
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"id": 3,
|
| 22 |
+
"question": "List the names of the first 5 tracks.",
|
| 23 |
+
"taxonomy": "Selection, Limit",
|
| 24 |
+
"ex_pass": true,
|
| 25 |
+
"esm_pass": true,
|
| 26 |
+
"generated_sql": "SELECT Name FROM Track LIMIT 5",
|
| 27 |
+
"gold_sql": "SELECT Name FROM Track LIMIT 5;"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"id": 4,
|
| 31 |
+
"question": "Count the number of customers located in the USA.",
|
| 32 |
+
"taxonomy": "Aggregation, Filtering",
|
| 33 |
+
"ex_pass": true,
|
| 34 |
+
"esm_pass": true,
|
| 35 |
+
"generated_sql": "SELECT COUNT(*) FROM Customer WHERE Country = 'USA';",
|
| 36 |
+
"gold_sql": "SELECT COUNT(*) FROM Customer WHERE Country = 'USA';"
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"id": 5,
|
| 40 |
+
"question": "Find all invoices for the customer with ID 1.",
|
| 41 |
+
"taxonomy": "Selection, Filtering",
|
| 42 |
+
"ex_pass": true,
|
| 43 |
+
"esm_pass": true,
|
| 44 |
+
"generated_sql": "SELECT * FROM Invoice WHERE CustomerId = 1;",
|
| 45 |
+
"gold_sql": "SELECT * FROM Invoice WHERE CustomerId = 1;"
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"id": 6,
|
| 49 |
+
"question": "List each album title along with the artist's name.",
|
| 50 |
+
"taxonomy": "Simple Join",
|
| 51 |
+
"ex_pass": true,
|
| 52 |
+
"esm_pass": false,
|
| 53 |
+
"generated_sql": "SELECT T1.Title, T2.Name FROM Album AS T1 INNER JOIN Artist AS T2 ON T1.ArtistId = T2.ArtistId",
|
| 54 |
+
"gold_sql": "SELECT Album.Title, Artist.Name FROM Album JOIN Artist ON Album.ArtistId = Artist.ArtistId;"
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"id": 7,
|
| 58 |
+
"question": "How many tracks belong to the 'Rock' genre?",
|
| 59 |
+
"taxonomy": "Simple Join, Filtering, Aggregation",
|
| 60 |
+
"ex_pass": true,
|
| 61 |
+
"esm_pass": true,
|
| 62 |
+
"generated_sql": "SELECT COUNT(*) FROM Track JOIN Genre ON Track.GenreId = Genre.GenreId WHERE Genre.Name = 'Rock'",
|
| 63 |
+
"gold_sql": "SELECT COUNT(*) FROM Track JOIN Genre ON Track.GenreId = Genre.GenreId WHERE Genre.Name = 'Rock';"
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"id": 8,
|
| 67 |
+
"question": "Show the total revenue generated from each country.",
|
| 68 |
+
"taxonomy": "Aggregation, Grouping",
|
| 69 |
+
"ex_pass": true,
|
| 70 |
+
"esm_pass": false,
|
| 71 |
+
"generated_sql": "SELECT BillingCountry, SUM(Total) AS TotalRevenue FROM Invoice GROUP BY BillingCountry",
|
| 72 |
+
"gold_sql": "SELECT BillingCountry, SUM(Total) FROM Invoice GROUP BY BillingCountry;"
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
"id": 9,
|
| 76 |
+
"question": "Find the total number of items sold for each media type.",
|
| 77 |
+
"taxonomy": "Multi-Join, Aggregation, Grouping",
|
| 78 |
+
"ex_pass": false,
|
| 79 |
+
"esm_pass": false,
|
| 80 |
+
"generated_sql": "SELECT T2.Name, COUNT(T1.MediaTypeId) AS TotalItemsSold FROM SalesOrderDetail AS T1 INNER JOIN Media.MediaType AS T2 ON T1.MediaTypeId = T2.MediaTypeId GROUP BY T2.Name",
|
| 81 |
+
"gold_sql": "SELECT MediaType.Name, SUM(InvoiceLine.Quantity) FROM InvoiceLine JOIN Track ON InvoiceLine.TrackId = Track.TrackId JOIN MediaType ON Track.MediaTypeId = MediaType.MediaTypeId GROUP BY MediaType.Name;"
|
| 82 |
+
},
|
| 83 |
+
{
|
| 84 |
+
"id": 10,
|
| 85 |
+
"question": "List the first and last names of all employees who are Sales Support Agents.",
|
| 86 |
+
"taxonomy": "Selection, Filtering",
|
| 87 |
+
"ex_pass": true,
|
| 88 |
+
"esm_pass": true,
|
| 89 |
+
"generated_sql": "SELECT FirstName, LastName FROM Employee WHERE Title = 'Sales Support Agent'",
|
| 90 |
+
"gold_sql": "SELECT FirstName, LastName FROM Employee WHERE Title = 'Sales Support Agent';"
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"id": 11,
|
| 94 |
+
"question": "List the top 5 customers who have spent the most money in total.",
|
| 95 |
+
"taxonomy": "Simple Join, Aggregation, Grouping, Ordering, Limit",
|
| 96 |
+
"ex_pass": false,
|
| 97 |
+
"esm_pass": false,
|
| 98 |
+
"generated_sql": "SELECT c.CustomerId, c.FirstName, c.LastName, SUM(i.Total) AS TotalSpent\nFROM Customer c\nJOIN Invoice i ON c.CustomerId = i.CustomerId\nGROUP BY c.CustomerId\nORDER BY TotalSpent DESC\nLIMIT 5",
|
| 99 |
+
"gold_sql": "SELECT c.FirstName, c.LastName, SUM(i.Total) as TotalSpent FROM Customer c JOIN Invoice i ON c.CustomerId = i.CustomerId GROUP BY c.CustomerId ORDER BY TotalSpent DESC LIMIT 5;"
|
| 100 |
+
},
|
| 101 |
+
{
|
| 102 |
+
"id": 12,
|
| 103 |
+
"question": "Which artist has the most tracks in the database? Give the name and count.",
|
| 104 |
+
"taxonomy": "Multi-Join, Aggregation, Grouping, Ordering, Limit",
|
| 105 |
+
"ex_pass": false,
|
| 106 |
+
"esm_pass": false,
|
| 107 |
+
"generated_sql": "SELECT T2.Name, COUNT(T1.AlbumId) AS TrackCount FROM Album AS T1 INNER JOIN Artist AS T2 ON T1.ArtistId = T2.ArtistId GROUP BY T2.Name ORDER BY TrackCount DESC LIMIT 1",
|
| 108 |
+
"gold_sql": "SELECT ar.Name, COUNT(t.TrackId) as TrackCount FROM Artist ar JOIN Album al ON ar.ArtistId = al.ArtistId JOIN Track t ON al.AlbumId = t.AlbumId GROUP BY ar.ArtistId ORDER BY TrackCount DESC LIMIT 1;"
|
| 109 |
+
},
|
| 110 |
+
{
|
| 111 |
+
"id": 13,
|
| 112 |
+
"question": "Which genres have more than 100 tracks? List the genre name and count.",
|
| 113 |
+
"taxonomy": "Simple Join, Aggregation, Grouping, Having",
|
| 114 |
+
"ex_pass": true,
|
| 115 |
+
"esm_pass": false,
|
| 116 |
+
"generated_sql": "SELECT T2.Name, COUNT(T1.TrackId) AS TrackCount FROM TRACK AS T1 INNER JOIN GENRE AS T2 ON T1.GenreId = T2.GenreId GROUP BY T2.Name HAVING COUNT(T1.TrackId) > 100",
|
| 117 |
+
"gold_sql": "SELECT g.Name, COUNT(t.TrackId) as TrackCount FROM Genre g JOIN Track t ON g.GenreId = t.GenreId GROUP BY g.GenreId HAVING TrackCount > 100;"
|
| 118 |
+
},
|
| 119 |
+
{
|
| 120 |
+
"id": 14,
|
| 121 |
+
"question": "Calculate the average track length in seconds for each genre.",
|
| 122 |
+
"taxonomy": "Simple Join, Aggregation, Arithmetic, Grouping",
|
| 123 |
+
"ex_pass": false,
|
| 124 |
+
"esm_pass": false,
|
| 125 |
+
"generated_sql": "SELECT AVG(Milliseconds / 1000) AS AverageLengthInSeconds, GenreId FROM Track GROUP BY GenreId",
|
| 126 |
+
"gold_sql": "SELECT g.Name, AVG(t.Milliseconds) / 1000.0 as AvgSeconds FROM Genre g JOIN Track t ON g.GenreId = t.GenreId GROUP BY g.GenreId;"
|
| 127 |
+
},
|
| 128 |
+
{
|
| 129 |
+
"id": 15,
|
| 130 |
+
"question": "Identify the artist who has earned the most revenue from customers in Canada.",
|
| 131 |
+
"taxonomy": "Multi-Join, Aggregation, Grouping, Ordering, Limit",
|
| 132 |
+
"ex_pass": false,
|
| 133 |
+
"esm_pass": false,
|
| 134 |
+
"generated_sql": "SELECT T1.Name FROM ARTIST AS T1 JOIN ALBUM AS T2 ON T1.ArtistId = T2.ArtistId JOIN TRACK AS T3 ON T2.AlbumId = T3.AlbumId JOIN INVOICE AS T4 ON T3.TrackId = T4.InvoiceLine.TrackId WHERE T4.InvoiceLine.CustomerId IN ( SELECT CustomerId FROM CUSTOMER WHERE Country = 'Canada' ) GROUP BY T1.Name ORDER BY SUM(T4.InvoiceLine.UnitPrice * T4.InvoiceLine.Quantity) DESC LIMIT 1",
|
| 135 |
+
"gold_sql": "SELECT ar.Name, SUM(il.UnitPrice * il.Quantity) AS Revenue FROM Artist ar JOIN Album al ON ar.ArtistId = al.ArtistId JOIN Track t ON al.AlbumId = t.AlbumId JOIN InvoiceLine il ON t.TrackId = il.TrackId JOIN Invoice i ON il.InvoiceId = i.InvoiceId WHERE i.BillingCountry = 'Canada' GROUP BY ar.ArtistId ORDER BY Revenue DESC LIMIT 1;"
|
| 136 |
+
}
|
| 137 |
+
]
|
backend/sql_eval_defog_llama-3-sqlcoder-8b_featherless-ai.json
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"id": 1,
|
| 4 |
+
"question": "List all the artists name in the database.",
|
| 5 |
+
"taxonomy": "Selection",
|
| 6 |
+
"ex_pass": true,
|
| 7 |
+
"esm_pass": false,
|
| 8 |
+
"generated_sql": "SELECT a.Name FROM Artist a;",
|
| 9 |
+
"gold_sql": "SELECT Name FROM Artist;"
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"id": 2,
|
| 13 |
+
"question": "How many genres are there?",
|
| 14 |
+
"taxonomy": "Aggregation",
|
| 15 |
+
"ex_pass": true,
|
| 16 |
+
"esm_pass": true,
|
| 17 |
+
"generated_sql": "SELECT COUNT(*) FROM Genre;",
|
| 18 |
+
"gold_sql": "SELECT COUNT(*) FROM Genre;"
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"id": 3,
|
| 22 |
+
"question": "List the names of the first 5 tracks.",
|
| 23 |
+
"taxonomy": "Selection, Limit",
|
| 24 |
+
"ex_pass": true,
|
| 25 |
+
"esm_pass": false,
|
| 26 |
+
"generated_sql": "SELECT t.Name FROM Track t ORDER BY t.TrackId LIMIT 5;",
|
| 27 |
+
"gold_sql": "SELECT Name FROM Track LIMIT 5;"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"id": 4,
|
| 31 |
+
"question": "Count the number of customers located in the USA.",
|
| 32 |
+
"taxonomy": "Aggregation, Filtering",
|
| 33 |
+
"ex_pass": true,
|
| 34 |
+
"esm_pass": false,
|
| 35 |
+
"generated_sql": "SELECT COUNT(*) FROM Customer c WHERE c.Country = 'USA';",
|
| 36 |
+
"gold_sql": "SELECT COUNT(*) FROM Customer WHERE Country = 'USA';"
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"id": 5,
|
| 40 |
+
"question": "Find all invoices for the customer with ID 1.",
|
| 41 |
+
"taxonomy": "Selection, Filtering",
|
| 42 |
+
"ex_pass": false,
|
| 43 |
+
"esm_pass": false,
|
| 44 |
+
"generated_sql": "SELECT i.InvoiceId, i.InvoiceDate, i.Total FROM Invoice i WHERE i.CustomerId = 1;",
|
| 45 |
+
"gold_sql": "SELECT * FROM Invoice WHERE CustomerId = 1;"
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"id": 6,
|
| 49 |
+
"question": "List each album title along with the artist's name.",
|
| 50 |
+
"taxonomy": "Simple Join",
|
| 51 |
+
"ex_pass": true,
|
| 52 |
+
"esm_pass": false,
|
| 53 |
+
"generated_sql": "SELECT a.Title, ar.Name FROM Album a JOIN Artist ar ON a.ArtistId = ar.ArtistId;",
|
| 54 |
+
"gold_sql": "SELECT Album.Title, Artist.Name FROM Album JOIN Artist ON Album.ArtistId = Artist.ArtistId;"
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"id": 7,
|
| 58 |
+
"question": "How many tracks belong to the 'Rock' genre?",
|
| 59 |
+
"taxonomy": "Simple Join, Filtering, Aggregation",
|
| 60 |
+
"ex_pass": true,
|
| 61 |
+
"esm_pass": false,
|
| 62 |
+
"generated_sql": "SELECT COUNT(t.TrackId) FROM Track t JOIN Genre g ON t.GenreId = g.GenreId WHERE g.Name = 'Rock';",
|
| 63 |
+
"gold_sql": "SELECT COUNT(*) FROM Track JOIN Genre ON Track.GenreId = Genre.GenreId WHERE Genre.Name = 'Rock';"
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"id": 8,
|
| 67 |
+
"question": "Show the total revenue generated from each country.",
|
| 68 |
+
"taxonomy": "Aggregation, Grouping",
|
| 69 |
+
"ex_pass": true,
|
| 70 |
+
"esm_pass": false,
|
| 71 |
+
"generated_sql": "SELECT i.BillingCountry, SUM(i.Total) AS TotalRevenue FROM Invoice i GROUP BY i.BillingCountry ORDER BY TotalRevenue DESC NULLS LAST;",
|
| 72 |
+
"gold_sql": "SELECT BillingCountry, SUM(Total) FROM Invoice GROUP BY BillingCountry;"
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
"id": 9,
|
| 76 |
+
"question": "Find the total number of items sold for each media type.",
|
| 77 |
+
"taxonomy": "Multi-Join, Aggregation, Grouping",
|
| 78 |
+
"ex_pass": false,
|
| 79 |
+
"esm_pass": false,
|
| 80 |
+
"generated_sql": "SELECT mt.Name, COUNT(*) AS total_items_sold FROM MediaType mt JOIN (SELECT MediaType.MediaTypeId, COUNT(*) AS items_sold FROM Album JOIN MediaType ON Album.MediaTypeId = MediaType.MediaTypeId GROUP BY MediaType.MediaTypeId) AS ms ON mt.MediaTypeId = ms.MediaTypeId GROUP BY mt.Name ORDER BY total_items_sold DESC NULLS LAST;",
|
| 81 |
+
"gold_sql": "SELECT MediaType.Name, SUM(InvoiceLine.Quantity) FROM InvoiceLine JOIN Track ON InvoiceLine.TrackId = Track.TrackId JOIN MediaType ON Track.MediaTypeId = MediaType.MediaTypeId GROUP BY MediaType.Name;"
|
| 82 |
+
},
|
| 83 |
+
{
|
| 84 |
+
"id": 10,
|
| 85 |
+
"question": "List the first and last names of all employees who are Sales Support Agents.",
|
| 86 |
+
"taxonomy": "Selection, Filtering",
|
| 87 |
+
"ex_pass": true,
|
| 88 |
+
"esm_pass": false,
|
| 89 |
+
"generated_sql": "SELECT e.FirstName, e.LastName FROM Employee e WHERE e.Title = 'Sales Support Agent';",
|
| 90 |
+
"gold_sql": "SELECT FirstName, LastName FROM Employee WHERE Title = 'Sales Support Agent';"
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"id": 11,
|
| 94 |
+
"question": "List the top 5 customers who have spent the most money in total.",
|
| 95 |
+
"taxonomy": "Simple Join, Aggregation, Grouping, Ordering, Limit",
|
| 96 |
+
"ex_pass": false,
|
| 97 |
+
"esm_pass": false,
|
| 98 |
+
"generated_sql": "SELECT c.CustomerId, SUM(o.TotalAmount) AS TotalSpent FROM Customer c JOIN Order o ON c.CustomerId = o.CustomerId GROUP BY c.CustomerId ORDER BY TotalSpent DESC LIMIT 5;",
|
| 99 |
+
"gold_sql": "SELECT c.FirstName, c.LastName, SUM(i.Total) as TotalSpent FROM Customer c JOIN Invoice i ON c.CustomerId = i.CustomerId GROUP BY c.CustomerId ORDER BY TotalSpent DESC LIMIT 5;"
|
| 100 |
+
},
|
| 101 |
+
{
|
| 102 |
+
"id": 12,
|
| 103 |
+
"question": "Which artist has the most tracks in the database? Give the name and count.",
|
| 104 |
+
"taxonomy": "Multi-Join, Aggregation, Grouping, Ordering, Limit",
|
| 105 |
+
"ex_pass": false,
|
| 106 |
+
"esm_pass": false,
|
| 107 |
+
"generated_sql": "SELECT a.\"ArtistId\", COUNT(a.\"AlbumId\") AS track_count FROM \"Album\" a GROUP BY a.\"ArtistId\" ORDER BY track_count DESC LIMIT 1;",
|
| 108 |
+
"gold_sql": "SELECT ar.Name, COUNT(t.TrackId) as TrackCount FROM Artist ar JOIN Album al ON ar.ArtistId = al.ArtistId JOIN Track t ON al.AlbumId = t.AlbumId GROUP BY ar.ArtistId ORDER BY TrackCount DESC LIMIT 1;"
|
| 109 |
+
},
|
| 110 |
+
{
|
| 111 |
+
"id": 13,
|
| 112 |
+
"question": "Which genres have more than 100 tracks? List the genre name and count.",
|
| 113 |
+
"taxonomy": "Simple Join, Aggregation, Grouping, Having",
|
| 114 |
+
"ex_pass": true,
|
| 115 |
+
"esm_pass": false,
|
| 116 |
+
"generated_sql": "SELECT g.Name, COUNT(t.TrackId) AS TrackCount FROM Genre g JOIN Track t ON g.GenreId = t.GenreId GROUP BY g.Name HAVING COUNT(t.TrackId) > 100 ORDER BY TrackCount DESC NULLS LAST;",
|
| 117 |
+
"gold_sql": "SELECT g.Name, COUNT(t.TrackId) as TrackCount FROM Genre g JOIN Track t ON g.GenreId = t.GenreId GROUP BY g.GenreId HAVING TrackCount > 100;"
|
| 118 |
+
},
|
| 119 |
+
{
|
| 120 |
+
"id": 14,
|
| 121 |
+
"question": "Calculate the average track length in seconds for each genre.",
|
| 122 |
+
"taxonomy": "Simple Join, Aggregation, Arithmetic, Grouping",
|
| 123 |
+
"ex_pass": false,
|
| 124 |
+
"esm_pass": false,
|
| 125 |
+
"generated_sql": "SELECT t.GenreId, AVG(t.Milliseconds / 1000.0) AS average_length FROM Track t GROUP BY t.GenreId ORDER BY t.GenreId NULLS LAST;",
|
| 126 |
+
"gold_sql": "SELECT g.Name, AVG(t.Milliseconds) / 1000.0 as AvgSeconds FROM Genre g JOIN Track t ON g.GenreId = t.GenreId GROUP BY g.GenreId;"
|
| 127 |
+
},
|
| 128 |
+
{
|
| 129 |
+
"id": 15,
|
| 130 |
+
"question": "Identify the artist who has earned the most revenue from customers in Canada.",
|
| 131 |
+
"taxonomy": "Multi-Join, Aggregation, Grouping, Ordering, Limit",
|
| 132 |
+
"ex_pass": false,
|
| 133 |
+
"esm_pass": false,
|
| 134 |
+
"generated_sql": "SELECT a.Name, SUM(al.Sales) AS TotalRevenue FROM Artist a JOIN Album al ON a.ArtistId = al.ArtistId JOIN Customer c ON al.CustomerId = c.CustomerId WHERE c.Country = 'Canada' GROUP BY a.Name ORDER BY TotalRevenue DESC LIMIT 1;",
|
| 135 |
+
"gold_sql": "SELECT ar.Name, SUM(il.UnitPrice * il.Quantity) AS Revenue FROM Artist ar JOIN Album al ON ar.ArtistId = al.ArtistId JOIN Track t ON al.AlbumId = t.AlbumId JOIN InvoiceLine il ON t.TrackId = il.TrackId JOIN Invoice i ON il.InvoiceId = i.InvoiceId WHERE i.BillingCountry = 'Canada' GROUP BY ar.ArtistId ORDER BY Revenue DESC LIMIT 1;"
|
| 136 |
+
}
|
| 137 |
+
]
|
backend/sql_eval_defog_sqlcoder-7b-2.json
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"id": 1,
|
| 4 |
+
"question": "List all the artists name in the database.",
|
| 5 |
+
"taxonomy": "Selection",
|
| 6 |
+
"ex_pass": true,
|
| 7 |
+
"esm_pass": false,
|
| 8 |
+
"generated_sql": "SELECT a.\"Name\" FROM \"Artist\" a;",
|
| 9 |
+
"gold_sql": "SELECT Name FROM Artist;"
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"id": 2,
|
| 13 |
+
"question": "How many genres are there?",
|
| 14 |
+
"taxonomy": "Aggregation",
|
| 15 |
+
"ex_pass": true,
|
| 16 |
+
"esm_pass": false,
|
| 17 |
+
"generated_sql": "SELECT COUNT(g.genreid) AS number_of_genres FROM genre g;",
|
| 18 |
+
"gold_sql": "SELECT COUNT(*) FROM Genre;"
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"id": 3,
|
| 22 |
+
"question": "List the names of the first 5 tracks.",
|
| 23 |
+
"taxonomy": "Selection, Limit",
|
| 24 |
+
"ex_pass": true,
|
| 25 |
+
"esm_pass": false,
|
| 26 |
+
"generated_sql": "SELECT t.name FROM \"Track\" t LIMIT 5;",
|
| 27 |
+
"gold_sql": "SELECT Name FROM Track LIMIT 5;"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"id": 4,
|
| 31 |
+
"question": "Count the number of customers located in the USA.",
|
| 32 |
+
"taxonomy": "Aggregation, Filtering",
|
| 33 |
+
"ex_pass": false,
|
| 34 |
+
"esm_pass": false,
|
| 35 |
+
"generated_sql": "SELECT COUNT(*) FROM \"Customer\" c WHERE c.Country ILIKE '%USA%';",
|
| 36 |
+
"gold_sql": "SELECT COUNT(*) FROM Customer WHERE Country = 'USA';"
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"id": 5,
|
| 40 |
+
"question": "Find all invoices for the customer with ID 1.",
|
| 41 |
+
"taxonomy": "Selection, Filtering",
|
| 42 |
+
"ex_pass": true,
|
| 43 |
+
"esm_pass": false,
|
| 44 |
+
"generated_sql": "SELECT * FROM Invoice i WHERE i.CustomerId = 1;",
|
| 45 |
+
"gold_sql": "SELECT * FROM Invoice WHERE CustomerId = 1;"
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"id": 6,
|
| 49 |
+
"question": "List each album title along with the artist's name.",
|
| 50 |
+
"taxonomy": "Simple Join",
|
| 51 |
+
"ex_pass": true,
|
| 52 |
+
"esm_pass": false,
|
| 53 |
+
"generated_sql": "SELECT a.\"Title\", ar.\"Name\" AS \"Artist Name\" FROM \"Album\" a JOIN \"Artist\" ar ON a.\"ArtistId\" = ar.\"ArtistId\";",
|
| 54 |
+
"gold_sql": "SELECT Album.Title, Artist.Name FROM Album JOIN Artist ON Album.ArtistId = Artist.ArtistId;"
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"id": 7,
|
| 58 |
+
"question": "How many tracks belong to the 'Rock' genre?",
|
| 59 |
+
"taxonomy": "Simple Join, Filtering, Aggregation",
|
| 60 |
+
"ex_pass": true,
|
| 61 |
+
"esm_pass": false,
|
| 62 |
+
"generated_sql": "SELECT COUNT(t.TrackId) AS number_of_tracks FROM \"Track\" t JOIN \"Genre\" g ON t.GenreId = g.GenreId WHERE g.Name = 'Rock';",
|
| 63 |
+
"gold_sql": "SELECT COUNT(*) FROM Track JOIN Genre ON Track.GenreId = Genre.GenreId WHERE Genre.Name = 'Rock';"
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"id": 8,
|
| 67 |
+
"question": "Show the total revenue generated from each country.",
|
| 68 |
+
"taxonomy": "Aggregation, Grouping",
|
| 69 |
+
"ex_pass": false,
|
| 70 |
+
"esm_pass": false,
|
| 71 |
+
"generated_sql": "SELECT c.country_name, SUM(i.total) AS total_revenue FROM \"Invoice\" i JOIN \"Customer\" c ON i.customer_id = c.customer_id GROUP BY c.country_name ORDER BY total_revenue DESC NULLS LAST;",
|
| 72 |
+
"gold_sql": "SELECT BillingCountry, SUM(Total) FROM Invoice GROUP BY BillingCountry;"
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
"id": 9,
|
| 76 |
+
"question": "Find the total number of items sold for each media type.",
|
| 77 |
+
"taxonomy": "Multi-Join, Aggregation, Grouping",
|
| 78 |
+
"ex_pass": false,
|
| 79 |
+
"esm_pass": false,
|
| 80 |
+
"generated_sql": "SELECT m.name AS media_type, COUNT(*) AS total_items_sold FROM \"MediaType\" m JOIN \"Sales\" s ON m.media_type_id = s.media_type_id GROUP BY m.name;",
|
| 81 |
+
"gold_sql": "SELECT MediaType.Name, SUM(InvoiceLine.Quantity) FROM InvoiceLine JOIN Track ON InvoiceLine.TrackId = Track.TrackId JOIN MediaType ON Track.MediaTypeId = MediaType.MediaTypeId GROUP BY MediaType.Name;"
|
| 82 |
+
},
|
| 83 |
+
{
|
| 84 |
+
"id": 10,
|
| 85 |
+
"question": "List the first and last names of all employees who are Sales Support Agents.",
|
| 86 |
+
"taxonomy": "Selection, Filtering",
|
| 87 |
+
"ex_pass": false,
|
| 88 |
+
"esm_pass": false,
|
| 89 |
+
"generated_sql": "SELECT e.first_name, e.last_name FROM \"Employee\" e WHERE e.title = 'Sales Support Agent';",
|
| 90 |
+
"gold_sql": "SELECT FirstName, LastName FROM Employee WHERE Title = 'Sales Support Agent';"
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"id": 11,
|
| 94 |
+
"question": "List the top 5 customers who have spent the most money in total.",
|
| 95 |
+
"taxonomy": "Simple Join, Aggregation, Grouping, Ordering, Limit",
|
| 96 |
+
"ex_pass": false,
|
| 97 |
+
"esm_pass": false,
|
| 98 |
+
"generated_sql": "SELECT c.customerid, c.firstname, c.lastname, SUM(oi.productid * oi.quantity) AS total_spent FROM customer c JOIN orders o ON c.customerid = o.customerid JOIN orderitems oi ON o.orderid = oi.orderid GROUP BY c.customerid, c.firstname, c.lastname ORDER BY total_spent DESC LIMIT 5;",
|
| 99 |
+
"gold_sql": "SELECT c.FirstName, c.LastName, SUM(i.Total) as TotalSpent FROM Customer c JOIN Invoice i ON c.CustomerId = i.CustomerId GROUP BY c.CustomerId ORDER BY TotalSpent DESC LIMIT 5;"
|
| 100 |
+
},
|
| 101 |
+
{
|
| 102 |
+
"id": 12,
|
| 103 |
+
"question": "Which artist has the most tracks in the database? Give the name and count.",
|
| 104 |
+
"taxonomy": "Multi-Join, Aggregation, Grouping, Ordering, Limit",
|
| 105 |
+
"ex_pass": false,
|
| 106 |
+
"esm_pass": false,
|
| 107 |
+
"generated_sql": "",
|
| 108 |
+
"gold_sql": "SELECT ar.Name, COUNT(t.TrackId) as TrackCount FROM Artist ar JOIN Album al ON ar.ArtistId = al.ArtistId JOIN Track t ON al.AlbumId = t.AlbumId GROUP BY ar.ArtistId ORDER BY TrackCount DESC LIMIT 1;"
|
| 109 |
+
},
|
| 110 |
+
{
|
| 111 |
+
"id": 13,
|
| 112 |
+
"question": "Which genres have more than 100 tracks? List the genre name and count.",
|
| 113 |
+
"taxonomy": "Simple Join, Aggregation, Grouping, Having",
|
| 114 |
+
"ex_pass": true,
|
| 115 |
+
"esm_pass": false,
|
| 116 |
+
"generated_sql": "SELECT g.name, COUNT(t.trackid) AS COUNT FROM genre g JOIN track t ON g.genreid = t.genreid GROUP BY g.name HAVING COUNT(t.trackid) > 100 ORDER BY COUNT DESC NULLS LAST;",
|
| 117 |
+
"gold_sql": "SELECT g.Name, COUNT(t.TrackId) as TrackCount FROM Genre g JOIN Track t ON g.GenreId = t.GenreId GROUP BY g.GenreId HAVING TrackCount > 100;"
|
| 118 |
+
},
|
| 119 |
+
{
|
| 120 |
+
"id": 14,
|
| 121 |
+
"question": "Calculate the average track length in seconds for each genre.",
|
| 122 |
+
"taxonomy": "Simple Join, Aggregation, Arithmetic, Grouping",
|
| 123 |
+
"ex_pass": false,
|
| 124 |
+
"esm_pass": false,
|
| 125 |
+
"generated_sql": "SELECT g.Name, AVG(t.Milliseconds / 1000)) AS AverageDuration FROM Track t JOIN Genre g ON t.GenreId = g.GenreId GROUP BY g.Name ORDER BY AverageDuration DESC NULLS LAST;",
|
| 126 |
+
"gold_sql": "SELECT g.Name, AVG(t.Milliseconds) / 1000.0 as AvgSeconds FROM Genre g JOIN Track t ON g.GenreId = t.GenreId GROUP BY g.GenreId;"
|
| 127 |
+
},
|
| 128 |
+
{
|
| 129 |
+
"id": 15,
|
| 130 |
+
"question": "Identify the artist who has earned the most revenue from customers in Canada.",
|
| 131 |
+
"taxonomy": "Multi-Join, Aggregation, Grouping, Ordering, Limit",
|
| 132 |
+
"ex_pass": false,
|
| 133 |
+
"esm_pass": false,
|
| 134 |
+
"generated_sql": "SELECT a.\"Name\" FROM \"Artist\" a JOIN \"Album\" al ON a.\"ArtistId\" = al.\"AlbumArtistId\" WHERE al.\"AlbumCountry\" = 'Canada' ORDER BY a.\"Name\" DESC NULLS LAST LIMIT 1;",
|
| 135 |
+
"gold_sql": "SELECT ar.Name, SUM(il.UnitPrice * il.Quantity) AS Revenue FROM Artist ar JOIN Album al ON ar.ArtistId = al.ArtistId JOIN Track t ON al.AlbumId = t.AlbumId JOIN InvoiceLine il ON t.TrackId = il.TrackId JOIN Invoice i ON il.InvoiceId = i.InvoiceId WHERE i.BillingCountry = 'Canada' GROUP BY ar.ArtistId ORDER BY Revenue DESC LIMIT 1;"
|
| 136 |
+
}
|
| 137 |
+
]
|
backend/src/scripts/evaluation_mode.py
CHANGED
|
@@ -5,53 +5,79 @@ import sqlglot
|
|
| 5 |
from pathlib import Path
|
| 6 |
import pandas as pd
|
| 7 |
from src.database.db_manager import get_db_connection
|
|
|
|
| 8 |
from src.nl2sql.sql_agent import nl2sql_agent
|
| 9 |
from src.scripts.taxonomy_report import print_taxonomyReport
|
| 10 |
|
| 11 |
TEST_CASES_PATH = Path("src/scripts/test_cases.json")
|
| 12 |
-
RESULTS_PATH = Path("hf_evaluation_results.json")
|
| 13 |
|
| 14 |
-
def _normalize_dataframe(dataframe: pd.DataFrame) ->
|
| 15 |
# Normalize dataframe to ensure accurate comparison
|
| 16 |
"""
|
| 17 |
Standardize dataframes for Execution Accuracy (EX).
|
| 18 |
-
-
|
| 19 |
-
-
|
|
|
|
| 20 |
"""
|
|
|
|
|
|
|
|
|
|
| 21 |
normalized = dataframe.copy()
|
| 22 |
-
#normalized.columns = [str(column).lower() for column in normalized.columns]
|
| 23 |
|
| 24 |
for column in normalized.columns:
|
| 25 |
normalized[column] = normalized[column].map(
|
| 26 |
-
lambda
|
| 27 |
-
if
|
| 28 |
-
else
|
|
|
|
|
|
|
|
|
|
| 29 |
)
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
normalized = normalized.sort_values(by=sort_columns).reset_index(drop=True)
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
# EX: Compare generated SQL results with expected results
|
| 38 |
def calculate_ex(df_generated: pd.DataFrame, df_gold: pd.DataFrame) -> bool:
|
| 39 |
"""
|
| 40 |
Execution Accuracy (EX): Compare generated SQL results with expected results.
|
| 41 |
-
- Column Name Agnostic: Use .values to ignore header differences.
|
| 42 |
"""
|
| 43 |
if df_generated is None or df_gold is None:
|
| 44 |
return False
|
| 45 |
|
|
|
|
|
|
|
|
|
|
| 46 |
try:
|
| 47 |
normalized_generated = _normalize_dataframe(df_generated)
|
| 48 |
normalized_gold = _normalize_dataframe(df_gold)
|
| 49 |
-
|
| 50 |
-
if normalized_generated.shape != normalized_gold.shape:
|
| 51 |
-
return False
|
| 52 |
|
| 53 |
-
return
|
| 54 |
-
|
| 55 |
except Exception as error:
|
| 56 |
print(f"EX Evaluation Error: {error}")
|
| 57 |
return False
|
|
@@ -61,6 +87,9 @@ def calculate_esm(generated_sql: str, gold_sql: str) -> bool:
|
|
| 61 |
Exact Set Match (ESM): Compare AST structure using sqlglot.
|
| 62 |
- Ignores formatting, capitalization, and minor syntactic sugar.
|
| 63 |
"""
|
|
|
|
|
|
|
|
|
|
| 64 |
try:
|
| 65 |
# Parse both SQL queries into expressions
|
| 66 |
generated_exp = sqlglot.parse_one(generated_sql, read=None)
|
|
@@ -72,7 +101,10 @@ def calculate_esm(generated_sql: str, gold_sql: str) -> bool:
|
|
| 72 |
print(f"ESM Evaluation Error: {error}")
|
| 73 |
return False
|
| 74 |
|
| 75 |
-
def run_evaluation():
|
|
|
|
|
|
|
|
|
|
| 76 |
if not TEST_CASES_PATH.exists():
|
| 77 |
print(f"Error: Could not find test cases at {TEST_CASES_PATH}")
|
| 78 |
return
|
|
@@ -91,10 +123,10 @@ def run_evaluation():
|
|
| 91 |
question = case.get("question")
|
| 92 |
gold_sql = case.get("gold_sql")
|
| 93 |
taxonomy = case.get("taxonomy", "Unknown")
|
| 94 |
-
|
| 95 |
|
| 96 |
# Implement agent to handle RAG retrieval and SQL generation
|
| 97 |
-
agent_response = nl2sql_agent(user_question=question)
|
| 98 |
generated_sql = agent_response.get("query", "")
|
| 99 |
|
| 100 |
# ESM Evaluation
|
|
@@ -112,7 +144,22 @@ def run_evaluation():
|
|
| 112 |
df_generated = pd.read_sql_query(generated_sql, connection)
|
| 113 |
df_gold = pd.read_sql_query(gold_sql, connection)
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
ex_result = calculate_ex(df_generated, df_gold)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
if ex_result:
|
| 117 |
ex_count += 1
|
| 118 |
except Exception as error:
|
|
@@ -137,11 +184,22 @@ def run_evaluation():
|
|
| 137 |
|
| 138 |
print("\nEVALUATION SUMMARY")
|
| 139 |
print("-" * 40)
|
|
|
|
| 140 |
print(f"Total Test Cases: {total}")
|
| 141 |
print(f"Execution Accuracy (EX): {ex_accuracy:.2f}% ({ex_count}/{total})")
|
| 142 |
print(f"Exact Set Match (ESM): {esm_accuracy:.2f}% ({esm_count}/{total})")
|
| 143 |
|
| 144 |
-
|
|
|
|
|
|
|
| 145 |
json.dump(results, handle, indent=4)
|
| 146 |
|
| 147 |
-
print_taxonomyReport(results)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
from pathlib import Path
|
| 6 |
import pandas as pd
|
| 7 |
from src.database.db_manager import get_db_connection
|
| 8 |
+
from src.nl2sql.hf_engine import get_models
|
| 9 |
from src.nl2sql.sql_agent import nl2sql_agent
|
| 10 |
from src.scripts.taxonomy_report import print_taxonomyReport
|
| 11 |
|
| 12 |
TEST_CASES_PATH = Path("src/scripts/test_cases.json")
|
|
|
|
| 13 |
|
| 14 |
+
def _normalize_dataframe(dataframe: pd.DataFrame) -> list:
|
| 15 |
# Normalize dataframe to ensure accurate comparison
|
| 16 |
"""
|
| 17 |
Standardize dataframes for Execution Accuracy (EX).
|
| 18 |
+
- Converts dataframe to a list of tuples to ignore column names.
|
| 19 |
+
- Rounds floating points to 4 decimal places to avoid precision mismatch.
|
| 20 |
+
- Sorts the final list to ensure order-agnostic comparison.
|
| 21 |
"""
|
| 22 |
+
if dataframe is None or dataframe.empty:
|
| 23 |
+
return []
|
| 24 |
+
|
| 25 |
normalized = dataframe.copy()
|
|
|
|
| 26 |
|
| 27 |
for column in normalized.columns:
|
| 28 |
normalized[column] = normalized[column].map(
|
| 29 |
+
lambda x: round(float(x), 4)
|
| 30 |
+
if pd.api.types.is_numeric_dtype(type(x)) and isinstance(x, float)
|
| 31 |
+
else x
|
| 32 |
+
#lambda value: round(float(value), 6)
|
| 33 |
+
#if isinstance(value, (float, int))
|
| 34 |
+
#else value
|
| 35 |
)
|
| 36 |
|
| 37 |
+
# Convert to list of tuples for order-agnostic comparison
|
| 38 |
+
data_tuples = [tuple(row) for row in normalized.to_numpy()]
|
|
|
|
| 39 |
|
| 40 |
+
# Sort to ensure order agnoticism
|
| 41 |
+
try:
|
| 42 |
+
data_tuples.sort(key=lambda x: str(x))
|
| 43 |
+
except Exception as e:
|
| 44 |
+
pass
|
| 45 |
+
|
| 46 |
+
return data_tuples
|
| 47 |
+
|
| 48 |
+
# Semantic safety net
|
| 49 |
+
def extract_tables(sql: str) -> set:
|
| 50 |
+
"""
|
| 51 |
+
Extract a set of all table names used in a SQL query.
|
| 52 |
+
Used to catch false positives where EX passes but the model queried the wrong tables.
|
| 53 |
+
"""
|
| 54 |
+
if not sql:
|
| 55 |
+
return set()
|
| 56 |
+
try:
|
| 57 |
+
parsed = sqlglot.parse_one(sql, read=None)
|
| 58 |
+
|
| 59 |
+
# Find all table expressions & extract names, ignore aliases
|
| 60 |
+
return set(table.name.lower() for table in parsed.find_all(sqlglot.exp.Table) if table.name)
|
| 61 |
+
except Exception as e:
|
| 62 |
+
return set()
|
| 63 |
|
| 64 |
# EX: Compare generated SQL results with expected results
|
| 65 |
def calculate_ex(df_generated: pd.DataFrame, df_gold: pd.DataFrame) -> bool:
|
| 66 |
"""
|
| 67 |
Execution Accuracy (EX): Compare generated SQL results with expected results.
|
|
|
|
| 68 |
"""
|
| 69 |
if df_generated is None or df_gold is None:
|
| 70 |
return False
|
| 71 |
|
| 72 |
+
#if normalized_generated.shape != normalized_gold.shape:
|
| 73 |
+
# return False
|
| 74 |
+
|
| 75 |
try:
|
| 76 |
normalized_generated = _normalize_dataframe(df_generated)
|
| 77 |
normalized_gold = _normalize_dataframe(df_gold)
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
+
return normalized_generated == normalized_gold
|
| 80 |
+
|
| 81 |
except Exception as error:
|
| 82 |
print(f"EX Evaluation Error: {error}")
|
| 83 |
return False
|
|
|
|
| 87 |
Exact Set Match (ESM): Compare AST structure using sqlglot.
|
| 88 |
- Ignores formatting, capitalization, and minor syntactic sugar.
|
| 89 |
"""
|
| 90 |
+
if not generated_sql or not gold_sql:
|
| 91 |
+
return False
|
| 92 |
+
|
| 93 |
try:
|
| 94 |
# Parse both SQL queries into expressions
|
| 95 |
generated_exp = sqlglot.parse_one(generated_sql, read=None)
|
|
|
|
| 101 |
print(f"ESM Evaluation Error: {error}")
|
| 102 |
return False
|
| 103 |
|
| 104 |
+
def run_evaluation(model_id: str):
|
| 105 |
+
print(f"\nRunning SQL evaluation for model: {model_id}")
|
| 106 |
+
print("\n" + "-" *50)
|
| 107 |
+
|
| 108 |
if not TEST_CASES_PATH.exists():
|
| 109 |
print(f"Error: Could not find test cases at {TEST_CASES_PATH}")
|
| 110 |
return
|
|
|
|
| 123 |
question = case.get("question")
|
| 124 |
gold_sql = case.get("gold_sql")
|
| 125 |
taxonomy = case.get("taxonomy", "Unknown")
|
| 126 |
+
print(f"Testing ID {id}: {question[:40]}...")
|
| 127 |
|
| 128 |
# Implement agent to handle RAG retrieval and SQL generation
|
| 129 |
+
agent_response = nl2sql_agent(user_question=question, model_id=model_id)
|
| 130 |
generated_sql = agent_response.get("query", "")
|
| 131 |
|
| 132 |
# ESM Evaluation
|
|
|
|
| 144 |
df_generated = pd.read_sql_query(generated_sql, connection)
|
| 145 |
df_gold = pd.read_sql_query(gold_sql, connection)
|
| 146 |
|
| 147 |
+
# Trap the False Positive (empty set): weak test case
|
| 148 |
+
if df_gold.empty:
|
| 149 |
+
print(f"[!]WARNING: Gold SQL for ID {id} returned an emoty response.")
|
| 150 |
+
|
| 151 |
ex_result = calculate_ex(df_generated, df_gold)
|
| 152 |
+
|
| 153 |
+
# Semantic safety net check
|
| 154 |
+
if ex_result:
|
| 155 |
+
gen_tables = extract_tables(generated_sql)
|
| 156 |
+
gold_tables = extract_tables(gold_sql)
|
| 157 |
+
|
| 158 |
+
if gen_tables != gold_tables:
|
| 159 |
+
print(f"[X] FALSE POSITIVE (ID{id}): Data matched, tables not")
|
| 160 |
+
print(f"\nGenerated SQL tables: {gen_tables} | Gold SQL tables: {gold_tables}")
|
| 161 |
+
ex_result = False
|
| 162 |
+
|
| 163 |
if ex_result:
|
| 164 |
ex_count += 1
|
| 165 |
except Exception as error:
|
|
|
|
| 184 |
|
| 185 |
print("\nEVALUATION SUMMARY")
|
| 186 |
print("-" * 40)
|
| 187 |
+
print(f"Model Evaluated: {model_id}")
|
| 188 |
print(f"Total Test Cases: {total}")
|
| 189 |
print(f"Execution Accuracy (EX): {ex_accuracy:.2f}% ({ex_count}/{total})")
|
| 190 |
print(f"Exact Set Match (ESM): {esm_accuracy:.2f}% ({esm_count}/{total})")
|
| 191 |
|
| 192 |
+
safe_model_name = model_id.replace("/", "_").replace(":", "_")
|
| 193 |
+
output_file = Path(f"sql_eval_{safe_model_name}.json")
|
| 194 |
+
with output_file.open("w", encoding="utf-8") as handle:
|
| 195 |
json.dump(results, handle, indent=4)
|
| 196 |
|
| 197 |
+
print_taxonomyReport(results)
|
| 198 |
+
|
| 199 |
+
if __name__ == "__main__":
|
| 200 |
+
from dotenv import load_dotenv, find_dotenv
|
| 201 |
+
load_dotenv(find_dotenv())
|
| 202 |
+
|
| 203 |
+
models_to_test = get_models()
|
| 204 |
+
for model in models_to_test:
|
| 205 |
+
run_evaluation(model)
|
backend/src/scripts/interactive_mode.py
CHANGED
|
@@ -1,43 +1,129 @@
|
|
| 1 |
# Path: src/scripts/interactive_mode.py
|
| 2 |
# Interactive mode: Allows user to manually type questions and see the agent's response
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
from tabulate import tabulate
|
|
|
|
| 4 |
from src.nl2sql.sql_agent import nl2sql_agent
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
print("\n========= Interactive NL2SQL Mode =========")
|
| 9 |
-
print("
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# Path: src/scripts/interactive_mode.py
|
| 2 |
# Interactive mode: Allows user to manually type questions and see the agent's response
|
| 3 |
+
import csv
|
| 4 |
+
import json
|
| 5 |
+
import pandas as pd
|
| 6 |
+
from pathlib import Path
|
| 7 |
from tabulate import tabulate
|
| 8 |
+
from src.database.db_manager import get_db_connection
|
| 9 |
from src.nl2sql.sql_agent import nl2sql_agent
|
| 10 |
+
from src.nl2sql.hf_engine import get_models
|
| 11 |
|
| 12 |
+
TEST_CASES_PATH = Path("src/scripts/test_cases.json")
|
| 13 |
+
|
| 14 |
+
def get_query_data(sql_query: str) -> pd.DataFrame:
|
| 15 |
+
"""
|
| 16 |
+
Executes a SQL query and returns the results as a DataFrame.
|
| 17 |
+
"""
|
| 18 |
+
if not sql_query or sql_query == "N/A":
|
| 19 |
+
return pd.DataFrame()
|
| 20 |
+
|
| 21 |
+
connection = get_db_connection()
|
| 22 |
+
if not connection:
|
| 23 |
+
return pd.DataFrame()
|
| 24 |
+
|
| 25 |
+
try:
|
| 26 |
+
df = pd.read_sql_query(sql_query, connection)
|
| 27 |
+
return df
|
| 28 |
+
except Exception as e:
|
| 29 |
+
print(f"Error executing SQL query: {e}")
|
| 30 |
+
return pd.DataFrame()
|
| 31 |
+
finally:
|
| 32 |
+
connection.close()
|
| 33 |
+
|
| 34 |
+
def verify_data(df_gold: pd.DataFrame, df_generated: pd.DataFrame) -> bool:
|
| 35 |
+
"""
|
| 36 |
+
Guardrail check:
|
| 37 |
+
Verifies if the generated DataFrame matches the expected gold DataFrame.
|
| 38 |
+
"""
|
| 39 |
+
if df_gold.empty and df_generated.empty:
|
| 40 |
+
return False # Both empty: To catch this as a potential issue
|
| 41 |
+
|
| 42 |
+
if len(df_gold) != len(df_generated):
|
| 43 |
+
return False
|
| 44 |
+
|
| 45 |
+
try:
|
| 46 |
+
gold_val = df_gold.fillna("").astype(str).values.tolist()
|
| 47 |
+
gen_val = df_generated.fillna("").astype(str).values.tolist()
|
| 48 |
+
|
| 49 |
+
# Strip whitespace and convert to tuples (sortable)
|
| 50 |
+
gold_tuples = [tuple(val.strip() for val in row) for row in gold_val]
|
| 51 |
+
gen_tuples = [tuple(val.strip() for val in row) for row in gen_val]
|
| 52 |
+
|
| 53 |
+
return sorted(gold_tuples) == sorted(gen_tuples)
|
| 54 |
+
except Exception as e:
|
| 55 |
+
print(f"Error during data verification: {e}")
|
| 56 |
+
return False
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def run_interactiveMode(model_id: str):
|
| 60 |
+
"""
|
| 61 |
+
Automates the interactive Question Answering mode.
|
| 62 |
+
Runs predefined questions through the agent and logs the textual NL response.
|
| 63 |
+
"""
|
| 64 |
print("\n========= Interactive NL2SQL Mode =========")
|
| 65 |
+
print(f"Running Interactive Question Answering Evaluation on Model: {model_id}")
|
| 66 |
+
#print("Type 'exit' or 'q' to return to the main menu.\n")
|
| 67 |
+
|
| 68 |
+
if not TEST_CASES_PATH.exists():
|
| 69 |
+
print(f"Error: Could not find test cases at {TEST_CASES_PATH}")
|
| 70 |
+
return
|
| 71 |
+
|
| 72 |
+
with TEST_CASES_PATH.open("r", encoding="utf-8") as handle:
|
| 73 |
+
test_cases = json.load(handle)
|
| 74 |
+
|
| 75 |
+
questAns_results = []
|
| 76 |
+
|
| 77 |
+
for case in test_cases:
|
| 78 |
+
case_id = case.get("id")
|
| 79 |
+
question = case.get("question")
|
| 80 |
+
gold_sql = case.get("gold_sql")
|
| 81 |
+
print(f"\n\nTesting ID {case_id}: {question[:40]}...")
|
| 82 |
+
|
| 83 |
+
response = nl2sql_agent(user_question=question, model_id=model_id)
|
| 84 |
+
|
| 85 |
+
# Extract metadata
|
| 86 |
+
status = response.get('status')
|
| 87 |
+
nl_answer = response.get('nl_response', 'N/A')
|
| 88 |
+
sql_query = response.get('query', 'N/A')
|
| 89 |
+
error_msg = response.get('error', '')
|
| 90 |
+
attempts = response.get('attempts', 0)
|
| 91 |
+
|
| 92 |
+
# Data cross-check
|
| 93 |
+
df_gold = get_query_data(gold_sql)
|
| 94 |
+
df_generated = get_query_data(sql_query)
|
| 95 |
+
|
| 96 |
+
# Verify accuracy
|
| 97 |
+
is_data_accurate = verify_data(df_gold, df_generated)
|
| 98 |
+
|
| 99 |
+
questAns_results.append({
|
| 100 |
+
"id": case_id,
|
| 101 |
+
"model_id": model_id,
|
| 102 |
+
"question": question,
|
| 103 |
+
"status": status,
|
| 104 |
+
"data_returned_correct": is_data_accurate,
|
| 105 |
+
"attempts": attempts,
|
| 106 |
+
"nl_response": nl_answer,
|
| 107 |
+
"sql_generated": sql_query,
|
| 108 |
+
"error": error_msg
|
| 109 |
+
})
|
| 110 |
+
|
| 111 |
+
# Save to CSV for human-readable and easy comparison
|
| 112 |
+
safe_model_name = model_id.replace("/", "_").replace(":", "_").replace(" ", "_")
|
| 113 |
+
output_csv = Path(f"Q&A_report_{safe_model_name}.csv")
|
| 114 |
+
|
| 115 |
+
keys = questAns_results[0].keys()
|
| 116 |
+
with output_csv.open("w", newline='', encoding="utf-8") as f:
|
| 117 |
+
dict_writer = csv.DictWriter(f, fieldnames=keys)
|
| 118 |
+
dict_writer.writeheader()
|
| 119 |
+
dict_writer.writerows(questAns_results)
|
| 120 |
+
|
| 121 |
+
print(f"\nInteractive evaluation completed. Results saved to: {output_csv}")
|
| 122 |
+
|
| 123 |
+
if __name__ == "__main__":
|
| 124 |
+
from dotenv import load_dotenv, find_dotenv
|
| 125 |
+
load_dotenv(find_dotenv())
|
| 126 |
+
|
| 127 |
+
models_to_test = get_models()
|
| 128 |
+
for model in models_to_test:
|
| 129 |
+
run_interactiveMode(model)
|