File size: 1,740 Bytes
eea6d8c 0dfa26b eea6d8c 0dfa26b eea6d8c 0dfa26b eea6d8c 0dfa26b eea6d8c 0dfa26b eea6d8c 0dfa26b eea6d8c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
---
language: en
license: apache-2.0
tags:
- mistral
- sql
- lora
- instruction-tuning
datasets:
- custom_sql_dataset
---
# SQL Query Generation Model
This model is a fine-tuned version of mistralai/Mistral-7B-Instruct-v0.3 specialized for SQL query generation.
## Model Details
- **Base Model**: mistralai/Mistral-7B-Instruct-v0.3
- **Training Method**: LoRA (Rank=16, Alpha=32)
- **Task**: SQL query generation from natural language instructions
- **Training Framework**: Unsloth
## Usage
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Load the model
tokenizer = AutoTokenizer.from_pretrained("exaler/aaa-2-sql-2")
model = AutoModelForCausalLM.from_pretrained("exaler/aaa-2-sql-2")
# Format your prompt
instruction = """You are an expert SQL query generator. Database schema:
Table: [dbo].[Users]
Columns: [ID], [Name], [Email], [CreatedDate]
Table: [dbo].[Orders]
Columns: [OrderID], [UserID], [Amount], [Status], [OrderDate]
"""
input_text = "Find all users who placed orders with amount greater than 1000"
prompt = f"<s>[INST] {instruction}\n\n{input_text} [/INST]"
# Generate SQL
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(inputs=inputs.input_ids, max_new_tokens=512, temperature=0.0)
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(response)
```
## Training Dataset
The model was trained on a custom dataset of SQL queries with their corresponding natural language descriptions.
## Limitations
- The model is optimized for the specific SQL database schema it was trained on
- Performance may vary for database schemas significantly different from the training data
|