Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bigbigwatermalon/c3sql
The code for the paper C3: Zero-shot Text-to-SQL with ChatGPT
https://github.com/bigbigwatermalon/c3sql
Last synced: 3 months ago
JSON representation
The code for the paper C3: Zero-shot Text-to-SQL with ChatGPT
- Host: GitHub
- URL: https://github.com/bigbigwatermalon/c3sql
- Owner: bigbigwatermalon
- License: mit
- Created: 2023-06-07T02:59:48.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-12-08T02:10:01.000Z (11 months ago)
- Last Synced: 2024-06-15T13:31:46.520Z (5 months ago)
- Language: Python
- Size: 87.9 KB
- Stars: 99
- Watchers: 4
- Forks: 16
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ChatGPT-repositories - C3SQL - The code for the paper C3: Zero-shot Text-to-SQL with ChatGPT (NLP)
README
# C3SQL
The code for the paper C3: Zero-shot Text-to-SQL with ChatGPT ([https://arxiv.org/abs/2307.07306](https://arxiv.org/abs/2307.07306))## Prepare Spider Data
Download [spider data](https://drive.google.com/uc?export=download&id=1TqleXec_OykOYFREKKtschzY29dUcVAQ) and database (only spider original database right now) and then unzip them:
```shell
mkdir data
unzip spider.zip
mv spider/database .
mv spider data
```### Run Inference
Run the command below, and the predicted sql will be save to the file named "predicted_sql.txt"
```shell
bash run_c3sql.sh
```## Run evaluation
Add your openai key in the *generate_sqls_by_gpt3.5.py*, *column_recall.py*, *table_recall.py* files.
```shell
openai.api_key = "your_api_key"
```Clone evaluation scripts (test-suite-sql-eval:[https://github.com/taoyds/test-suite-sql-eval](https://github.com/taoyds/test-suite-sql-eval)):
```shell
mkdir third_party
cd third_party
git clone https://github.com/taoyds/test-suite-sql-eval
cd ..
```Put the 'predicted_sql.txt' in the current directory.
Then you can run evaluation with following command, and you will see the results on dev data.
For testing, you just need to replace '**dev_gold.sql**' with your test data, folder '**database**' with your database and '**spider/tables.json**' with your test tables.json.
```shell
python third_party/test-suite-sql-eval/evaluation.py --gold dev_gold.sql --pred predicted_sql.txt --db database --table data/spider/tables.json --etype all
```