bugdaryan/sql-create-context-instruction
收藏数据集概述
该数据集基于SQL Create Context构建,使用了WikiSQL和Spider的数据。包含78,577个自然语言查询示例、SQL CREATE TABLE语句以及使用CREATE语句作为上下文的SQL查询。该数据集旨在为文本到SQL的LLM模型设计,以防止在训练文本到SQL数据集时常见的列和表名幻觉问题。通过仅提供CREATE TABLE语句作为上下文,可以在不提供实际数据行的情况下,为模型提供更好的基础,从而限制令牌使用和避免敏感或专有数据的暴露。
数据清洗和增强
对合并的WikiSQL和Spider数据进行了清洗和数据增强。使用SQLGlot对来自Spider和WikiSQL的查询进行解析,生成不同的表和列。根据> <操作符以及MIN()、MAX()、AVG()和SUM()的使用推断列数据类型。这些表和列随后用于生成使用推断类型的CREATE TABLE语句。SQLGlot再次用于确保SQL查询和CREATE TABLE语句无错误解析。
对于没有列名的查询(例如SELECT * FROM table),默认添加了Id列到CREATE TABLE语句中。对于使用通用table作为FROM表的查询,已更改为table_name_1或其他数字,并在CREATE TABLE语句中反映这一变化。
TODO
- 进一步增强数据,通过将查询和CREATE TABLE语句转换为不同的SQL方言。可以使用SQLGlot完成此操作,并可能在问题中添加方言参考。
随机样本
json { "text" : "[INST] Write SQLite query to answer the following question given the database schema. Please wrap your code answer using : Schema: CREATE TABLE head (age INTEGER) Question: How many heads of the departments are older than 56 ? [/INST] Here is the SQLite query to answer to the question: How many heads of the departments are older than 56 ?: SELECT COUNT(*) FROM head WHERE age > 56 ", "text" : "[INST] Write SQLite query to answer the following question given the database schema. Please wrap your code answer using : Schema: CREATE TABLE head (name VARCHAR, born_state VARCHAR, age VARCHAR) Question: List the name, born state and age of the heads of departments ordered by age. [/INST] Here is the SQLite query to answer to the question: List the name, born state and age of the heads of departments ordered by age.: SELECT name, born_state, age FROM head ORDER BY age " }



