saadkhi commited on
Commit
d983985
·
verified ·
1 Parent(s): 84c3938

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +59 -41
README.md CHANGED
@@ -3,7 +3,6 @@ language:
3
  - en
4
  license: apache-2.0
5
  library_name: peft
6
- pipeline_tag: text-generation
7
  tags:
8
  - text-generation
9
  - sql
@@ -11,61 +10,80 @@ tags:
11
  - peft
12
  - lora
13
  - transformers
14
- base_model: "unsloth/Phi-3-mini-4k-instruct-bnb-4bit"
15
- datasets:
16
- - your-dataset-name
 
 
17
  ---
18
 
19
- # 🧠 SQL Chat Finetuned Model
20
 
21
  **Model ID:** `saadkhi/SQL_Chat_finetuned_model`
22
- **Task:** Conversational SQL query generation and response
23
- **Base Model:** `unsloth/Phi-3-mini-4k-instruct-bnb-4bit`
 
 
 
24
 
25
- This model is fine-tuned to assist with generating SQL queries and provide conversational responses related to SQL tasks.
26
 
27
- ---
28
 
29
- ## 🔍 Model Description
 
 
 
30
 
31
- This model was fine-tuned using PEFT/LoRA techniques on SQL question–answering and instruction data. It’s designed to understand natural language questions about databases and generate corresponding SQL queries or explanations.
32
 
33
- **Intended uses:**
34
- - Assist developers in writing SQL queries from natural language descriptions.
35
- - Educational SQL support and explanations.
 
 
 
36
 
37
- **Out-of-scope uses:**
38
- - Complex query optimization advice
39
- - Handling proprietary or highly specialized SQL dialects
 
 
40
 
41
- ---
42
-
43
- ## 🚀 How to Use
44
-
45
- ### Python (Transformers + PEFT)
46
 
47
  ```python
48
- from transformers import AutoModelForCausalLM, AutoTokenizer
49
  import torch
50
 
51
  model_id = "saadkhi/SQL_Chat_finetuned_model"
52
 
53
  tokenizer = AutoTokenizer.from_pretrained(model_id)
54
- model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16)
55
-
56
- prompt = "Show me the SQL to select all users older than 30 from the users table."
57
- inputs = tokenizer(prompt, return_tensors="pt")
58
-
59
- outputs = model.generate(**inputs, max_new_tokens=150)
60
- print(tokenizer.decode(outputs[0], skip_special_tokens=True))
61
-
62
- ---
63
-
64
- ### 🧾 Notes
65
-
66
- ✔️ The YAML metadata at the top (between `---`) helps the Hub display model tags, license, task type, languages, and base model. :contentReference[oaicite:1]{index=1}
67
- ✔️ You can fill in any missing **More Information Needed** parts from your own fine-tuning logs, dataset info, evaluation results, etc.
68
- ✔️ Once updated, save this as `README.md` in your repo root. The Hugging Face Hub will render it as your **model card**.
69
-
70
- Would you like me to **fill this with real data** from your training logs/parameters if you share them? (e.g., datasets used, evaluation results, hyperparameters)
71
- ::contentReference[oaicite:2]{index=2}
 
 
 
 
 
 
 
 
 
 
 
3
  - en
4
  license: apache-2.0
5
  library_name: peft
 
6
  tags:
7
  - text-generation
8
  - sql
 
10
  - peft
11
  - lora
12
  - transformers
13
+ - phi-3
14
+ - instruction-tuning
15
+ base_model: unsloth/Phi-3-mini-4k-instruct-bnb-4bit
16
+ pipeline_tag: text-generation
17
+ inference: false
18
  ---
19
 
20
+ # 🧠 SQL Chat Phi-3-mini SQL Assistant
21
 
22
  **Model ID:** `saadkhi/SQL_Chat_finetuned_model`
23
+ **Base model:** `unsloth/Phi-3-mini-4k-instruct-bnb-4bit`
24
+ **Model type:** LoRA (merged)
25
+ **Task:** Natural Language → SQL query generation + conversational SQL assistance
26
+ **Language:** English
27
+ **License:** Apache 2.0
28
 
29
+ This model is a fine-tuned version of **Phi-3-mini-4k-instruct** (4-bit quantized) specialized in understanding natural language questions about databases and generating correct, clean SQL queries.
30
 
31
+ ## ✨ Key Features
32
 
33
+ - Very good balance between size, speed and SQL generation quality
34
+ - Works well with common database dialects (PostgreSQL, MySQL, SQLite, SQL Server, etc.)
35
+ - Can explain queries, suggest improvements and handle follow-up questions
36
+ - Fast inference even on consumer hardware (especially with 4-bit quantization)
37
 
38
+ ## 🎯 Intended Use & Capabilities
39
 
40
+ **Best for:**
41
+ - Converting natural language questions SQL queries
42
+ - Helping beginners learn SQL through explanations
43
+ - Quick prototyping of SQL queries in development
44
+ - Building SQL chat interfaces / tools / assistants
45
+ - Educational purposes
46
 
47
+ **Limitations / Not recommended for:**
48
+ - Extremely complex analytical/business intelligence queries
49
+ - Real-time query optimization advice
50
+ - Very database-specific or proprietary SQL extensions
51
+ - Production systems without human review (always validate generated SQL!)
52
 
53
+ ## 🛠️ Quick Start (merged LoRA version)
 
 
 
 
54
 
55
  ```python
56
+ from transformers import AutoTokenizer, AutoModelForCausalLM
57
  import torch
58
 
59
  model_id = "saadkhi/SQL_Chat_finetuned_model"
60
 
61
  tokenizer = AutoTokenizer.from_pretrained(model_id)
62
+ model = AutoModelForCausalLM.from_pretrained(
63
+ model_id,
64
+ torch_dtype=torch.bfloat16,
65
+ device_map="auto",
66
+ trust_remote_code=True
67
+ )
68
+
69
+ # Simple prompt style (chat template is recommended)
70
+ prompt = """Show all customers who placed more than 5 orders in 2024"""
71
+
72
+ messages = [{"role": "user", "content": prompt}]
73
+
74
+ inputs = tokenizer.apply_chat_template(
75
+ messages,
76
+ tokenize=True,
77
+ add_generation_prompt=True,
78
+ return_tensors="pt"
79
+ ).to(model.device)
80
+
81
+ outputs = model.generate(
82
+ inputs,
83
+ max_new_tokens=180,
84
+ do_sample=False,
85
+ temperature=0.0,
86
+ pad_token_id=tokenizer.eos_token_id
87
+ )
88
+
89
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))