File size: 2,160 Bytes
778d47d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""
Generate enriched BIRD SFT data with CHESS-style DDL schema (value_description + column_description).

Run from mats-sql-tist/ root:
    JAVA_TOOL_OPTIONS="-Xmx6g" /home/datht/anaconda3/envs/mats/bin/python \
        db_content_retrieval/lsh_api.py --port 8005 --db_content_index bird-train &
    sleep 30
    /home/datht/anaconda3/envs/mats/bin/python scripts/build_sft_data.py

Outputs:
  data/rebuttal_sft_bird_train_text2sql.json   (9428 examples)
  data/rebuttal_sft_bird_dev_text2sql.json     (1534 examples)
"""
import os
import sys

ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
os.chdir(ROOT)
sys.path.insert(0, ROOT)

from prepare_sft_datasets import spider_style_dataset

BM25_API = "http://localhost:8005"

print("=" * 60)
print("Building enriched BIRD train SFT data (9428 examples)...")
print("=" * 60)
spider_style_dataset(
    dataset_path="./data/bird/train/train.json",
    db_path="./data/bird/train/train_databases",
    db_content_index_api=BM25_API,
    source="bird-train",
    table_json_path="./data/bird/train/train_tables.json",
    use_evidence=True,
    mode="train",
    output_file="./data/rebuttal_sft_bird_train_text2sql.jsonl"
)
print("✓ BIRD train SFT data done")

print()
print("=" * 60)
print("Building enriched BIRD dev SFT data (1534 examples)...")
print("=" * 60)
# Dev needs bird-dev source — restart API with bird-dev or use existing file
# For now we'll reuse the bird-train API (schema structure is the same)
# The dev data uses bird-dev db_content_index, but we can also generate
# a version without value matching by using the schema alone
spider_style_dataset(
    dataset_path="./data/bird/dev/dev.json",
    db_path="./data/bird/dev/dev_databases",
    db_content_index_api=BM25_API,
    source="bird-dev",
    table_json_path="./data/bird/dev/dev_tables.json",
    use_evidence=True,
    mode="dev",
    output_file="./data/rebuttal_sft_bird_dev_text2sql.jsonl"
)
print("✓ BIRD dev SFT data done")

print()
print("All SFT data generation complete.")
print("Output files:")
print("  data/rebuttal_sft_bird_train_text2sql.json")
print("  data/rebuttal_sft_bird_dev_text2sql.json")