sankhlatarun's picture
Upload folder using huggingface_hub
224c728 verified

Text-to-SQL Fine-tuned Model: DeepSeek-Coder-1.3B

This model was fine-tuned on the Gretel synthetic text-to-SQL dataset to generate SQL queries from natural language questions.

Model Details

  • Base model: DeepSeek-Coder-1.3B

Usage Example

from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("sankhlatarun/text-to-sql-deepseek-coder-1.3b")
tokenizer = AutoTokenizer.from_pretrained("sankhlatarun/text-to-sql-deepseek-coder-1.3b")
# Example schema and question
schema = """CREATE TABLE employees (
    id INTEGER PRIMARY KEY,
    name TEXT,
    department TEXT,
    salary INTEGER,
    hire_date DATE
)"""
question = "Show me the names of employees in the sales department with a salary greater than 50000."
# Format the prompt
prompt = f"""### Schema:
schema
### Question:
question
### SQL:
"""
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=256)
generated_sql = tokenizer.decode(outputs[0], skip_special_tokens=True)[len(prompt):]
print(generated_sql)