-
2024-11-12: We release the paper.
-
2024-11-08: Participants no longer need to fill out the BigQuery form; you only need to fill out the Snowflake form.
-
2024-11-04: We released the dataset. Notably, we offer three settings:
Spider 2.0
,Spider 2.0-Lite
,Spider 2.0-Snow
.
Setting | Task Type | #Examples | Databases | Cost |
---|---|---|---|---|
Spider 2.0 | Code agent task | 632 | BigQuery(214), Snowflake(198), Postgres(10), ClickHouse(7), SQLite(135), DuckDB (DBT)(68) | Some cost incurred |
Spider 2.0-Snow | Text-to-SQL task | 547 | Snowflake(547) | NO COST!😊 |
Spider 2.0-Lite | Text-to-SQL task | 547 | BigQuery(214), Snowflake(198), SQLite(135) | Some cost incurred |
In 2018, we introduced Spider 1.0, SParC, and CoSQL as part of the Yale Semantic Parsing and Text-to-SQL Challenge Series, attracting over 300 submissions from leading research labs worldwide.
Now, in the era of Large Language Models (LLMs), we present Spider 2.0 to advance code generation, particularly text-to-SQL capabilities.
This new benchmark offers a more realistic and challenging test of LLMs' performance on complex enterprise-level text-to-SQL workflows, involving complex data environments (e.g., >3000 columns), multiple SQL dialects (e.g., BigQuery, Snowflake), and diverse operations (e.g., transformation, analytics).
Notably, as shown below, even the most advanced LLMs, including GPT-4, solve only 6.0% of Spider 2.0 tasks, compared to 86.6% on Spider 1.0 and 57.4% on BIRD, highlighting the significant challenges posed by Spider 2.0.
Spider 1.0 dev | Spider 1.0 test | BIRD test | Spider 2.0-lite | Spider 2.0-snow | |
---|---|---|---|---|---|
DailSQL + GPT-4 | 82.4 | 86.6 | 57.4 | 5.6 | 2.2 |
CodeS-15B | 85.4 | - | 59.3 | 0.7 | 0.0 |
-
To sign up for a BigQuery account, please follow this guideline, get your own credentials.
-
Follow this guideline and fill out this Spider2 Snowflake Access, and we will send you an account sign-up email, which will allow you to access the Snowflake database.
Important Notes:
-
If you want to access the FULL dataset of Spider 2.0 or Spider 2.0-Lite, you must complete Step1 and Step2.
-
If you only want access to the FULL dataset of Spider 2.0-Snow, you only need to complete Step2.
For Spider 2.0
, all evaluation examples are aggregated in file spider2.jsonl
, where each data point contains the following field:
{
"instance_id": "ga001",
"instruction": "I want to know the preferences of customers who purchased the Google Navy Speckled Tee in December 2020. What other product was purchased with the highest total quantity alongside this item?",
"type": "Bigquery"
}
For each instance, we also provide a separate folder ./spider2/examples/{instruction_id}
as its Execution Context to simulate the agentic setting. Each folder may have the following files:
README.md
: detailed requirements of theinstruction
field for the current example withinstance_id
;*_credential.json
: credential file connecting to realistic enterprise-level databases, e.g., BigQuery. Can be replaced with your OWN;result.csv
: CSV file to store the execution results;- other instance-specific materials which assist in finishing the current task:
- 🏗️ partial project, e.g.,
dbt_project/
. - 📝 reference documentation:
ga4_dimensions_and_metrics.md
,retention_rate.md
, etc. - 🔍 query interface: We have predefined how to access the diverse database systems.
- 🎞️ query history or samples, e.g.,
QUERY_HISTORY/
, etc.
- 🏗️ partial project, e.g.,
The agent has to interact with complex SQL workflows, process extremely long contexts, perform intricate reasoning, and generate multiple SQL queries with diverse operations, often exceeding 100 lines across multiple turns.
For Spider 2.0, we proposed an agent framework Spider-Agent based on Docker environment.
- Install Docker. Follow the instructions in the Docker setup guide to install Docker on your machine.
- Install conda environment.
git clone https://github.com/xlang-ai/Spider2.git
cd methods/spider-agent
# Optional: Create a Conda environment for Spider 2.0
# conda create -n spider2 python=3.11
# conda activate spider2
# Install required dependencies
pip install -r requirements.txt
-
Configure credential: follow this instruction to configure BigQuery for running the SQL queries. follow this guideline to get your own Snowflake username and password in our snowflake database. You must update
bigquery_credential.json
andsnowflake_credential.json
. -
Download Spider 2.0 Database Source
cd spider2
gdown 'https://drive.google.com/uc?id=1OxF-OuPwgb2miQxzftGLZBzPRQtLsyoV'
gdown 'https://drive.google.com/uc?id=1gSB_30ey08GkDrMEXqj3LMJEH4ziQst1'
gdown 'https://drive.google.com/uc?id=1N3f7BSWC4foj-V-1C9n8M2XmgV7FOcqL'
gdown 'https://drive.google.com/uc?id=1s0USV_iQLo4oe05QqAMnhGGp5jeejCzp'
- Spider 2.0 Setup
python setup.py
- Run agent
cd ../../methods/spider-agent
export OPENAI_API_KEY=your_openai_api_key
python run.py --model gpt-4o -s test1
We would like to thank Snowflake for sponsoring our project. To better align with the research interests of the text-to-SQL community, we are offering Spider 2.0-Snow, which hosts all databases from Spider 2.0 in the Snowflake data warehouse. This arrangement facilitates users in developing advanced text-to-SQL systems more conveniently.
We adapt Spider-Agent and other text-to-SQL baselines to this setting.
- Install Docker. Follow the instructions in the Docker setup guide to install Docker on your machine.
- Install conda environment.
git clone https://github.com/xlang-ai/Spider2.git
cd methods/spider-agent-snow
# Optional: Create a Conda environment for Spider 2.0
# conda create -n spider2 python=3.11
# conda activate spider2
# Install required dependencies
pip install -r requirements.txt
-
Configure credential: Follow this guideline to get your own Snowflake username and password in our snowflake database. You must update
snowflake_credential.json
. -
Spider 2.0-Snow Setup
python spider_agent_setup_snow.py
- Run agent
export OPENAI_API_KEY=your_openai_api_key
python run.py --model gpt-4o -s test1
To align with research interests in traditional Text2SQL settings, we also release Spider 2.0-Lite
. This set is more self-contained, with well-prepared database metadata and documentation, making it a text-in, text-out task that supports faster development and evaluation.
You can also access the Spider 2.0-Lite by huggingface dataset.🤗
from datasets import load_dataset
ds = load_dataset("xlangai/spider2-lite")
Each file in spider2-lite.json
contains the following fields:
instance_id
: the unique example iddb
: the database id to which this question is addressedquestion
: the natural language questionexternal_knowledge
: the filenames of external knowledge, documentation, and information required to answer this question are stored in documents
We proposed baselines based on the widely used text2sql methods: Dail-SQL
and CodeS
, with evaluation results reported 🧪.
We only release the gold answer of about partial examples of Spider 2.0, Spider 2.0-Lite and Spider 2.0-Snow. You must follow this submission guidance to get your score on Spider 2.0 FULL dataset. For submission, provide a clear README, compressed code that passes your dev evaluation, any additional API keys required, and a report of prompt token counts for cost estimation. Usually, we will return your results in 10 days!
We thank Snowflake for their generous support in hosting the Spider 2.0 Challenge. We also thank Tianbao Xie, Yiheng Xu, Fan Zhou, Yuting Lan, Per Jacobsson, Yiming Huang, Canwen Xu, Zhewei Yao, and Binyuan Hui for their helpful feedback on this work. The leaderboard submission guidelines are greatly inspired by BIRD-SQL, and we thank them for their contributions.
If you find our work helpful, please cite as
@misc{lei2024spider2,
title={Spider 2.0: Evaluating Language Models on Real-World Enterprise Text-to-SQL Workflows},
author={Fangyu Lei and Jixuan Chen and Yuxiao Ye and Ruisheng Cao and Dongchan Shin and Hongjin Su and Zhaoqing Suo and Hongcheng Gao and Wenjing Hu and Pengcheng Yin and Victor Zhong and Caiming Xiong and Ruoxi Sun and Qian Liu and Sida Wang and Tao Yu},
year={2024},
eprint={2411.07763},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2411.07763},
}