Your email will be used for anonymous survey. It will NOT be shared with anyone.
This model is the full-weight version of the adapter model
OneSQL-v0.1-Qwen-3B.
To use this model, craft your prompt to start with your database schema in the form of CREATE TABLE, followed by your natural language query preceded by --.
Make sure your prompt ends with SELECT in order for the model to finish the query for you.
1from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
2from peft import PeftModel
3
4model_name = "onekq-ai/OneSQL-v0.2-Qwen-3B"
5model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7tokenizer.padding_side = "left"
8
9generator = pipeline("text-generation", model=model, tokenizer=tokenizer, return_full_text=False)
10
11prompt = """
12CREATE TABLE students (
13 id INTEGER PRIMARY KEY,
14 name TEXT,
15 age INTEGER,
16 grade TEXT
17);
18
19-- Find the three youngest students
20SELECT """
21
22result = generator(f"<|im_start|>system\nYou are a SQL expert. Return code only.<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n")[0]
23print(result["generated_text"])