MARS-SQL inference and evaluation

August 12, 2026 ยท View on GitHub

This directory contains the MARS-SQL generation entry point, execution-based evaluation, and three candidate-selection strategies.

Environment

conda create -n mars-infer python=3.10 -y
conda activate mars-infer
pip install -r Mars-inference/requirements.txt

Generate candidates

inference.sh can be called from any working directory. DB_PATH is required; the other paths have repository-relative defaults.

VariableDefaultPurpose
DB_PATHrequiredRoot containing <db_id>/<db_id>.sqlite databases
DATA_PATHdata/bird_test.parquetPrepared evaluation prompts
SAVE_PATHMars-inference/step80_bird_@16_turn5_test_result.parquetGenerated trajectories
MODEL_PATHYanghl0526/Qwen-SQL-7B-bird_5turns_80stepLocal or Hugging Face model identifier
STABLE_WORKDIRMars-inference/outputs/hydraHydra run metadata directory
CUDA_VISIBLE_DEVICES0GPU selection
export DB_PATH=/absolute/path/to/bird/databases
bash Mars-inference/inference.sh

Evaluate

python Mars-inference/evaluate_sql.py \
  --input_file Mars-inference/step80_bird_@16_turn5_test_result.parquet \
  --db_path /absolute/path/to/bird/databases \
  --num_cpus 16

The evaluator opens SQLite databases in read-only mode and writes a TSV decision log plus a text score summary. Tune --timeout and --num_cpus for the host.

Candidate selection

ScriptStrategy
select_self_consistency.pySelect by agreement among execution results
select_with_genrm.pyScore candidates with a generative reward model
select_best_sql_api.pySelect with an OpenAI-compatible API

Run any script with --help for its complete input, database, model/API, and output options. Pass API credentials at runtime; do not commit them to the repository.