Skip to main content

A Text2SQL benchmark for evaluation of Large Language Models

Project description

Downloads codecov PyPI Version CI Python Versions License

LLMSQL

Patched and improved version of the original large crowd-sourced dataset for developing natural language interfaces for relational databases, WikiSQL.

Our datasets are available for different scenarios on our HuggingFace page.

Overview

Install

pip3 install llmsql

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.

Note

The package doesn't have the dataset, it is stored on our HuggingFace page.

This package contains

  • Support for modern LLMs.
  • Tools for evaluation, inference, and finetuning.
  • Support for Hugging Face models out-of-the-box.
  • Structured for reproducibility and benchmarking.

Usage Recommendations

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

  1. Run inference directly on the full benchmark: model_or_model_name_or_path="Qwen/Qwen2.5-1.5B-Instruct", output_file="path_to_your_outputs.jsonl",

    • Use llmsql.inference_transformers (the function for transformers inference) for generation of SQL predictions with your model. If you want to do vllm based inference, use llmsql.inference_vllm. Works both with HF model id, e.g. Qwen/Qwen2.5-1.5B-Instruct and model instance passed directly, e.g. inference_transformers(model_or_model_name_or_path=model, ...)
    • Evaluate results against the benchmark with the llmsql.LLMSQLEvaluator evaluator class.
  2. Optional finetuning:

    • For research or domain adaptation, we provide finetuning script for HF models. Use llmsql finetune --help or read Finetune Readme to find more about finetuning.

[!Tip] You can find additional manuals in the README files of each folder(Inferece Readme, Evaluation Readme, Finetune Readme)

[!Tip] vllm based inference require vllm optional dependency group installed: pip install llmsql[vllm]


Repository Structure


llmsql/
├── evaluation/          # Scripts for downloading DB + evaluating predictions
├── inference/           # Generate SQL queries with your LLM
└── finetune/            # Fine-tuning with TRL's SFTTrainer

Quickstart

Install

Make sure you have the package installed (we used python3.11):

pip3 install llmsql

1. Run Inference

from llmsql import inference_transformers

# Run generation directly with transformers
results = inference_transformers(
    model_or_model_name_or_path="Qwen/Qwen2.5-1.5B-Instruct",
    output_file="path_to_your_outputs.jsonl",
    num_fewshots=5,
    batch_size=8,
    max_new_tokens=256,
    do_sample=False,
    model_args={
        "torch_dtype": "bfloat16",
    }
)

2. Evaluate Results

from llmsql import LLMSQLEvaluator

evaluator = LLMSQLEvaluator(workdir_path="llmsql_workdir")
report = evaluator.evaluate(outputs_path="path_to_your_outputs.jsonl")
print(report)

Finetuning (Optional)

If you want to adapt a base model on LLMSQL:

llmsql finetune --config_file examples/example_finetune_args.yaml

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.

Suggested Workflow

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

Contributing

Check out our open issues and feel free to submit pull requests!

We also encourage you to submit new issues!

To get started with development, first fork the repository and install the dev dependencies.

For more information on the contributing: check CONTRIBUTING.md and our documentation page.

License & Citation

Please cite LLMSQL if you use it in your work:

@inproceedings{llmsql_bench,
  title={LLMSQL: Upgrading WikiSQL for the LLM Era of Text-to-SQL},
  author={Pihulski, Dzmitry and  Charchut, Karol and Novogrodskaia, Viktoria and Koco{'n}, Jan},
  booktitle={2025 IEEE International Conference on Data Mining Workshops (ICDMW)},
  year={2025},
  organization={IEEE}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llmsql-0.1.9.tar.gz (30.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llmsql-0.1.9-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file llmsql-0.1.9.tar.gz.

File metadata

  • Download URL: llmsql-0.1.9.tar.gz
  • Upload date:
  • Size: 30.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for llmsql-0.1.9.tar.gz
Algorithm Hash digest
SHA256 3a3e0fa0452b973c6987dfb410c386e3fc49838f8bc644311e131d77d6b06628
MD5 efd5bda3c6b6717dcd983b612c847cca
BLAKE2b-256 bae85f13710c3087d994e5cb0d60089d88ddb5f29716eb03380e60fb3d40b588

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmsql-0.1.9.tar.gz:

Publisher: publish.yml on LLMSQL/llmsql-benchmark

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llmsql-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: llmsql-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 24.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for llmsql-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 6f673eaa9cbb06fc8b452d974398ec68c3f43da42a7357c77ff4f4b754853318
MD5 04eadb8537482365c5560cf6ac157e5e
BLAKE2b-256 135fb3fe4733e04697d360e3d2cb5db6678d9651de41e2c4b51bb909a08be195

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmsql-0.1.9-py3-none-any.whl:

Publisher: publish.yml on LLMSQL/llmsql-benchmark

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page