Downloads · 30 days
27
7% of all-time downloads
Ary-007/Text-to-sql-llama-3.2
Text-to-sql-llama-3.2 is a text generation model from Ary-007. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as mit.
This model is a fine-tuned version of Llama-3.2-3B-Instruct designed specifically for Text-to-SQL tasks. It was trained to accept a database schema and a natural language question, and output a valid SQL query along w…
Downloads · 30 days
27
7% of all-time downloads
All-time downloads
392
Public
Parameters
3.2B
6.4 GB on disk
Likes
5
Public
Click a slice to open those files.
.safetensors6.4 GB · 100%
From the Hugging Face model README
This model is a fine-tuned version of Llama-3.2-3B-Instruct designed specifically for Text-to-SQL tasks. It was trained to accept a database schema and a natural language question, and output a valid SQL query along with a brief explanation of the logic. It is lightweight (3B parameters), making it suitable for local deployment on consumer GPUs using 4-bit quantization.
The model was trained using the Alpaca prompt format. For best results, structure your input as follows:

import torch
from transformers import pipeline
model_id = "Ary-007/Text-to-sql-llama-3.2"
# Load the pipeline
pipe = pipeline(
"text-generation",
model=model_id,
device_map="auto",
)
# Define the schema (Context)
schema = """
CREATE TABLE employees (
id INT,
name TEXT,
department TEXT,
salary INT,
hire_date DATE
);
"""
# Define the user question
question = "Find the name and salary of employees in the 'Engineering' department who earn more than 80000."
# Format the prompt exactly as trained
prompt = f"""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
### Instruction:
Company Database : {schema}
### Input:
SQL Prompt :{question}
### Response:
"""
outputs = pipe(
prompt,
max_new_tokens=200,
do_sample=True,
temperature=0.1,
top_p=0.9
)
print(outputs[0]["generated_text"])
The model was fine-tuned using Unsloth on a Tesla T4 GPU (Google Colab).
Hyperparameters
The model was trained on the gretelai/synthetic_text_to_sql dataset, utilizing the following fields:
This model is derived from Llama-3.2 and is subject to the Llama 3.2 Community License.