Skip to content

Commit a3bc2d3

Browse files
Merge pull request #5 from LLMSQL/2-create-package-for-pypi
2 create package for pypi
2 parents dccffcf + 2ef6d85 commit a3bc2d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+10149
-315972
lines changed

.github/workflows/docs.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Deploy Sphinx docs to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
permissions:
8+
contents: read
9+
pages: write
10+
id-token: write
11+
12+
jobs:
13+
deploy:
14+
environment:
15+
name: github-pages
16+
url: ${{ steps.deployment.outputs.page_url }}
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Setup Pages
22+
uses: actions/configure-pages@v4
23+
24+
- name: Upload artifact
25+
uses: actions/upload-pages-artifact@v3
26+
with:
27+
path: ./docs/_build
28+
29+
- name: Deploy to GitHub Pages
30+
id: deployment
31+
uses: actions/deploy-pages@v4

.github/workflows/publish.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Publish Python distribution to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
build:
10+
name: Build distribution
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.x"
19+
20+
- name: Check version consistency
21+
run: |
22+
# Extract version from pyproject.toml
23+
PYPROJECT_VERSION=$(grep 'version = ' pyproject.toml | head -1 | cut -d'"' -f2)
24+
25+
# Extract version from __init__.py
26+
INIT_VERSION=$(grep '__version__ = ' llmsql/__init__.py | head -1 | cut -d'"' -f2)
27+
28+
echo "Version in pyproject.toml: $PYPROJECT_VERSION"
29+
echo "Version in __init__.py: $INIT_VERSION"
30+
31+
# Check if versions match
32+
if [ "$PYPROJECT_VERSION" != "$INIT_VERSION" ]; then
33+
echo "Error: Version mismatch between pyproject.toml ($PYPROJECT_VERSION) and __init__.py ($INIT_VERSION)"
34+
exit 1
35+
fi
36+
37+
echo "Version check passed: $PYPROJECT_VERSION"
38+
39+
- name: Install pypa/build
40+
run: >-
41+
python3 -m
42+
pip install
43+
build
44+
--user
45+
- name: Build a binary wheel and a source tarball
46+
run: python3 -m build
47+
- name: Store the distribution packages
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: python-package-distributions
51+
path: dist/
52+
53+
publish-to-pypi:
54+
name: >-
55+
Publish Python distribution to PyPI
56+
if: startsWith(github.ref, 'refs/tags/')
57+
needs:
58+
- build
59+
runs-on: ubuntu-latest
60+
environment:
61+
name: pypi
62+
url: https://pypi.org/p/llmsql
63+
permissions:
64+
id-token: write
65+
66+
steps:
67+
- name: Download all the dists
68+
uses: actions/download-artifact@v4
69+
with:
70+
name: python-package-distributions
71+
path: dist/
72+
- name: Publish distribution to PyPI
73+
uses: pypa/gh-action-pypi-publish@release/v1
74+
75+
publish-to-testpypi:
76+
name: Publish Python distribution to TestPyPI
77+
needs:
78+
- build
79+
runs-on: ubuntu-latest
80+
81+
environment:
82+
name: testpypi
83+
url: https://test.pypi.org/p/llmsql
84+
85+
permissions:
86+
id-token: write
87+
88+
steps:
89+
- name: Download all the dists
90+
uses: actions/download-artifact@v4
91+
with:
92+
name: python-package-distributions
93+
path: dist/
94+
- name: Publish distribution to TestPyPI
95+
uses: pypa/gh-action-pypi-publish@release/v1
96+
with:
97+
repository-url: https://test.pypi.org/legacy/

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
.venv
22
dataset/sqlite_tables.db
33
*__pycache__
4-
.env
4+
.env
5+
dist/
6+
7+
*.egg-info/

CITATION.bib

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@inproceedings{llmsql_bench,
2+
title={LLMSQL: Upgrading WikiSQL for the LLM Era of Text-to-SQLels},
3+
author={Pihulski, Dzmitry and Charchut, Karol and Novogrodskaia, Viktoria and Koco{'n}, Jan},
4+
booktitle={2025 IEEE International Conference on Data Mining Workshops (ICDMW)},
5+
year={2025},
6+
organization={IEEE}
7+
}

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
MIT License
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 57 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -3,137 +3,132 @@
33
Patched and improved version of the original large crowd-sourced dataset for developing natural language interfaces for relational databases, [WikiSQL](https://github.com/salesforce/WikiSQL).
44

55

6-
Our datasets are also available for different scenarios on our [HuggingFace page](https://huggingface.co/llmsql-bench).
6+
Our datasets are available for different scenarios on our [HuggingFace page](https://huggingface.co/llmsql-bench).
77
---
88

99
## Overview
1010

11-
This repository provides the **LLMSQL Benchmark** — a modernized, cleaned, and extended version of WikiSQL, designed for evaluating and fine-tuning large language models (LLMs) on **Text-to-SQL** tasks.
11+
### Install
1212

13-
### ✨ Highlights
14-
- Updated schema and improved SQL annotations.
13+
```bash
14+
pip3 install llmsql
15+
```
16+
17+
This repository provides the **LLMSQL Benchmark** — a modernized, cleaned, and extended version of WikiSQL, designed for evaluating and fine-tuning large language models (LLMs) on **Text-to-SQL** tasks.
18+
19+
### Note
20+
The package doesn't have the dataset, it is stored on our [HuggingFace page](https://huggingface.co/llmsql-bench).
21+
22+
### This package contains
1523
- Support for modern LLMs.
1624
- Tools for **evaluation**, **inference**, and **finetuning**.
1725
- Support for Hugging Face models out-of-the-box.
1826
- Structured for reproducibility and benchmarking.
1927

2028
---
2129

22-
## 🚨 Version Notice
23-
24-
This is the **first release** of the LLMSQL Benchmark.
25-
Expect refinements, new features, and additional tools in future updates.
26-
27-
---
28-
2930
## Usage Recommendations
3031

3132
Modern LLMs are already strong at **producing SQL queries without finetuning**.
3233
We therefore recommend that most users:
3334

3435
1. **Run inference** directly on the full benchmark:
35-
- Use `dataset/questions.jsonl` (the main evaluation set).
36-
- Generate SQL predictions with your LLM.
37-
- Evaluate results against the benchmark.
36+
- Use [`llmsql.LLMSQLVLLMInference`](./llmsql/inference/inference.py) (the main inference class) for generation of SQL predictions with your LLM from HF.
37+
- Evaluate results against the benchmark with the [`llmsql.LLMSQLEvaluator`](./llmsql/evaluation/evaluator.py) evaluator class.
3838

3939
2. **Optional finetuning**:
40-
- For research or domain adaptation, we provide `train_questions.jsonl`, `val_questions.jsonl`, and `test_questions.jsonl`.
41-
- Use the `finetune/` scripts if you want to adapt a base model.
40+
- For research or domain adaptation, we provide finetuning script for HF models. Use `llmsql finetune --help` or read [Finetune Readme](./llmsql/finetune/README.md) to find more about finetuning.
4241

42+
> [!Tip]
43+
> You can find additional manuals in the README files of each folder([Inferece Readme](./llmsql/inference/README.md), [Evaluation Readme](./llmsql/evaluation/README.md), [Finetune Readme](./llmsql/finetune/README.md))
4344
---
4445

4546
## Repository Structure
4647

4748
```
4849
4950
WikiSQLv2/
50-
├── dataset/ # JSONL files (questions, tables, splits)
5151
├── evaluation/ # Scripts for downloading DB + evaluating predictions
5252
├── inference/ # Generate SQL queries with your LLM
53-
── finetune/ # Fine-tuning with TRL's SFTTrainer
54-
├── outputs/ # Example location for your model outputs
55-
└── utils/ # Shared helpers (prompt builders, logging, etc.)
53+
── finetune/ # Fine-tuning with TRL's SFTTrainer
54+
55+
```
5656

57-
````
5857

59-
---
6058

6159
## Quickstart
6260

63-
## Install
6461

65-
Make sure you have the repo cloned (we used python3.11):
62+
### Install
63+
64+
Make sure you have the package installed (we used python3.11):
6665

6766
```bash
68-
git clone https://github.com/LLMSQL/llmsql-benchmark.git
69-
cd LLMSQL
70-
pip3 install -r requirements.txt
67+
pip3 install llmsql
7168
```
7269

73-
### 1. Download the Benchmark Database
74-
```bash
75-
python3 evaluation/download_db.py
76-
````
70+
### 1. Run Inference
71+
72+
```python
73+
from llmsql import LLMSQLVLLMInference
74+
75+
# Initialize inference engine
76+
inference = LLMSQLVLLMInference(
77+
model_name="Qwen/Qwen2.5-1.5B-Instruct", # or any Hugging Face causal LM
78+
tensor_parallel_size=1,
79+
)
80+
81+
# Run generation
82+
results = inference.generate(
83+
output_file="path_to_your_outputs.jsonl",
84+
questions_path="data/questions.jsonl",
85+
tables_path="data/tables.jsonl",
86+
shots=5,
87+
batch_size=8,
88+
max_new_tokens=256,
89+
temperature=0.7,
90+
)
91+
```
7792

78-
This will fetch `sqlite_tables.db` into `dataset/`.
93+
### 2. Evaluate Results
7994

80-
### 2. Run Inference
95+
```python
96+
from llmsql import LLMSQLEvaluator
8197

82-
```bash
83-
python3 inference/inference.py \
84-
--questions_file dataset/questions.jsonl \
85-
--tables_file dataset/tables.jsonl \
86-
--output_file outputs/my_model_preds.jsonl \
87-
--model_name meta-llama/Llama-3.2-1B-Instruct \
88-
--shots 5 \
89-
--batch_size 16
98+
evaluator = LLMSQLEvaluator(workdir_path="llmsql_workdir")
99+
report = evaluator.evaluate(outputs_path="path_to_your_outputs.jsonl")
100+
print(report)
90101
```
91102

92-
### 3. Evaluate Results
93-
94-
```bash
95-
python3 evaluation/evaluate_answers.py \
96-
--pred_file outputs/my_model_preds.jsonl
97-
```
98103

99-
---
100104

101105
## Finetuning (Optional)
102106

103107
If you want to adapt a base model on LLMSQL:
104108

105109
```bash
106-
python3 finetune/finetune.py \
107-
--model_name_or_path meta-llama/Llama-3.2-1B-Instruct \
108-
--output_dir outputs/finetuned-llama \
109-
--train_file dataset/train_questions.jsonl \
110-
--val_file dataset/val_questions.jsonl \
111-
--tables_file dataset/tables.jsonl \
112-
--num_train_epochs 2 \
113-
--per_device_train_batch_size 1
110+
llmsql finetune --config_file examples/example_finetune_args.yaml
114111
```
115112

116-
This will train a model on the train/val splits and save it under `outputs/`.
113+
This will train a model on the train/val splits with the parameters provided in the config file. You can find example config file [here](./examples/example_finetune_args.yaml).
114+
117115

118-
---
119116

120117
## Suggested Workflow
121118

122119
* **Primary**: Run inference on `dataset/questions.jsonl` → Evaluate with `evaluation/`.
123120
* **Secondary (optional)**: Fine-tune on `train/val` → Test on `test_questions.jsonl`.
124121

125-
---
122+
126123

127124
## License & Citation
128125

129-
This project builds on the original [WikiSQL](https://github.com/salesforce/WikiSQL) dataset.
130126
Please cite LLMSQL if you use it in your work:
131-
```
127+
```text
132128
@inproceedings{llmsql_bench,
133129
title={LLMSQL: Upgrading WikiSQL for the LLM Era of Text-to-SQLels},
134130
author={Pihulski, Dzmitry and Charchut, Karol and Novogrodskaia, Viktoria and Koco{'n}, Jan},
135131
booktitle={2025 IEEE International Conference on Data Mining Workshops (ICDMW)},
136-
pages={...},
137132
year={2025},
138133
organization={IEEE}
139134
}

0 commit comments

Comments
 (0)