Goal: explore a way to enable LLM use structured data in database. Input: Table definition in standard SQL DDL language, and query requirements in human language. Output: SQL query statement.
Background: This is a fine-tuned LLM model based on Qwen-7B-Chat. QLORA(4-bit) was used for fine-tuning. Dataset is https://huggingface.co/datasets/b-mc2/sql-create-context/blob/main/sqlcreatecontext_v4.json.
Example: User: 数据库中的数据表定义如下CREATE TABLE Persons (PersonID int, LastName varchar(255), FirstName varchar(255), Address varchar(255), City varchar(255)); 请严格根据上述表的定义,生成查询语句,查出所有姓李且居住城市是北京的人。 Qwen-Chat: SELECT * FROM Persons WHERE LastName = "李" AND City = "北京"
TODO:
- Generate dataset (or find an existing one) based on SQL language reference documents. Use the dataset to train the model to enable it to understand SQL at high level.
- Evaluate the performance of the model
Clone with HTTP
git clone https://www.modelscope.cn/allspace/Text2SQL.git
评论