Downloads · 30 days
2
4% of all-time downloads
MohabMostafa/llama-3-8b-text-to-ddl-lora
llama-3-8b-text-to-ddl-lora is a text generation model from MohabMostafa. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
This model is a fine-tuned version of Meta's LLaMA-3 8B, specialized in generating complex SQL Data Definition Language (DDL) scripts from natural language descriptions.
Downloads · 30 days
2
4% of all-time downloads
All-time downloads
48
Public
Repo size
185 MB
Likes
0
Public
Click a slice to open those files.
.safetensors168 MB · 91%
From the Hugging Face model README
This model is a fine-tuned version of Meta's LLaMA-3 8B, specialized in generating complex SQL Data Definition Language (DDL) scripts from natural language descriptions.
It has been trained to act as a "Strict SQL Architect" that can dynamically switch between Normalized (3NF) and Denormalized (Transaction Log) schema designs based on specific instructions.
unsloth/llama-3-8b-bnb-4bitSince this model contains LoRA adapters, you need to load the base model and apply these adapters. We recommend using unsloth for 2x faster inference, but standard peft works too.
pip install unsloth
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "YOUR_HF_USERNAME/llama-3-8b-text-to-sql-lora", # Replace with your Repo ID
max_seq_length = 2048,
dtype = None,
load_in_4bit = True,
)
FastLanguageModel.for_inference(model)
pip install transformers peft bitsandbytes
from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM, AutoTokenizer
config = PeftConfig.from_pretrained("YOUR_HF_USERNAME/llama-3-8b-text-to-sql-lora")
base_model = AutoModelForCausalLM.from_pretrained("unsloth/llama-3-8b-bnb-4bit")
model = PeftModel.from_pretrained(base_model, "YOUR_HF_USERNAME/llama-3-8b-text-to-sql-lora")
tokenizer = AutoTokenizer.from_pretrained("YOUR_HF_USERNAME/llama-3-8b-text-to-sql-lora")
CRITICAL: This model was fine-tuned on a specific prompt format. You must use the template below for optimal results. The input text should be descriptive and explicit about the entities.
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:
{INSTRUCTION}
### Input:
{INPUT_DESCRIPTION}
### Response:
Instruction:
Design a standard normalized SQL schema for this scenario. Use standard many-to-many relationship tables to ensure data integrity without redundancy.
Input:
Hospital Management System. The database consists of the following tables: Table
Patienthas columns: Patient_ID, Name, DOB, Insurance_Provider. TableDoctorhas columns: Doctor_ID, Name, Specialty, Years_Exp. TableAppointmenthas columns: Appt_ID, Date, Time, Room_Number, Patient_ID, Doctor_ID. Foreign key relationships: TableAppointmentcontains a foreign key references tablePatient. TableAppointmentcontains a foreign key references tableDoctor.
Instruction:
Design a denormalized SQL schema using a Transaction table. You MUST allow for historical repetition and duplicate entries. Do NOT use standard relationship tables.
Input:
Hospital Management System. The database consists of the following tables: Table
Patienthas columns: Patient_ID, Name, DOB, Insurance_Provider. TableDoctorhas columns: Doctor_ID, Name, Specialty, Years_Exp. TableTransaction_Loghas columns: Transaction_ID, Visit_Date, Room_Number, Procedure_Code, Billed_Amount, Patient_ID, Doctor_ID. Foreign key relationships: TableTransaction_Logcontains a foreign key references tablePatient. TableTransaction_Logcontains a foreign key references tableDoctor.
The model was fine-tuned on a high-quality dataset consisting of ~500 pairs of Normalized vs. Denormalized schema scenarios.
Achieved 100% semantic accuracy on a held-out test set of complex schema scenarios, correctly identifying table structures, column types, and foreign key relationships in both normalized and denormalized modes.
Created by: [MohabMostafa] Fine-tuned with: Unsloth