Spaces:
Running on Zero
Running on Zero
multimodalart HF Staff
TRUST-SQL agent demo: four-phase tool-integrated text-to-SQL over unknown schemas
c48f4e6 verified |
Download README.md from hugging-apps/trust-sql-text2sql-demo: direct link, hf CLI and curl.
- Browser
- Download file 3.16 kB
-
https://huggingface.co/spaces/hugging-apps/trust-sql-text2sql-demo/resolve/main/README.md
- Command line
-
hf download hf://spaces/hugging-apps/trust-sql-text2sql-demo/README.md
-
curl -L -o README.md https://huggingface.co/spaces/hugging-apps/trust-sql-text2sql-demo/resolve/main/README.md
3.16 kB
A newer version of the Gradio SDK is available: 6.29.1
metadata
title: TRUST-SQL
emoji: π
colorFrom: gray
colorTo: indigo
sdk: gradio
sdk_version: 6.27.0
app_file: app.py
python_version: '3.12'
startup_duration_timeout: 1h
pinned: false
license: apache-2.0
short_description: Text-to-SQL over unknown schemas, via tool use
models:
- AIJian/TrustSQL-8B
TRUST-SQL β Text-to-SQL over unknown schemas
Demo of AIJian/TrustSQL-8B, from
TRUST-SQL: Tool-Integrated Multi-Turn Reinforcement Learning for Text-to-SQL over Unknown Schemas
(Jian et al., 2026). Code: JaneEyre0530/TrustSQL.
Unlike ordinary text-to-SQL demos, the schema is never put in the prompt. The model is given only the database name, the question, and a single read-only SQL tool, and has to discover the schema itself by following the authors' four-phase action protocol:
explore_schemaβ issue metadata queries (PRAGMA,sqlite_master, sampling rows)propose_schemaβ write down the tables/columns/joins it has actually verifiedgenerate_sqlβ draft the answer query and execute it to check it worksconfirm_answerβ emit the final SQL
The agent may loop back at any point. The full trajectory (reasoning, tool calls, observations) is streamed into the transcript so you can watch the schema being discovered.
Implementation notes
- The system prompt is
trustsql_eval/prompt_template.txt, copied verbatim from the authors' repo. - The user message reproduces the exact
**Task Configuration** / **Database Engine** / **Database** / **External Knowledge** / **User Question**format found inAIJian/TrustSQL-data. - The turn loop, progress prefixes,
<schema>acknowledgement, malformed-output feedback and observation truncation (2048 tokens) are ported fromtrustsql_eval/message_processor.py. - Sampling defaults match
trustsql_eval/main.py(temperature 0.7, top-p 0.9). - Deviation:
WITHis added to theSELECT/PRAGMA/EXPLAINallow-list so CTE answers can be executed. Every query still runs over a read-only SQLite connection. - Runs on ZeroGPU with plain
transformersgeneration rather than the vLLM path used for the paper's benchmarks, so it is slower than the reported latency figures.
Credits & licensing
- Model and code: Apache-2.0, Β© the TRUST-SQL authors (Meituan / BUPT).
- Bundled sample databases and the example questions +
evidencehints are from the BIRD dev set (bird-bench.github.io), licensed CC BY-SA 4.0; SQLite files mirrored viaprem-research/birdbench.
@article{jian2026trustsql,
title = {TRUST-SQL: Tool-Integrated Multi-Turn Reinforcement Learning for Text-to-SQL over Unknown Schemas},
author = {Jian, Ai and Zhang, Xiaoyun and Du, Wanrou and Ruan, Jingqing and Pei, Jiangbo and Zhang, Weipeng and Zeng, Ke and Cai, Xunliang},
journal= {arXiv preprint arXiv:2603.16448},
year = {2026}
}