Shizu0n commited on
Commit
1159918
·
verified ·
1 Parent(s): 8399a3d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +27 -9
README.md CHANGED
@@ -1,9 +1,11 @@
1
  ---
2
  base_model: microsoft/Phi-3-mini-4k-instruct
3
  library_name: peft
4
- license: apache-2.0
5
  language:
6
  - en
 
 
7
  tags:
8
  - sql
9
  - code-generation
@@ -30,16 +32,19 @@ Evaluated on 200 held-out examples from [b-mc2/sql-create-context](https://huggi
30
  | Phi-3-mini-4k-instruct (base) | 2.0% |
31
  | **This adapter (fine-tuned)** | **73.5%** |
32
 
 
 
33
  ## Training Details
34
 
35
  - **Dataset:** b-mc2/sql-create-context — 1,000 train / 200 validation examples
36
  - **Epochs:** 3
37
  - **Effective batch size:** 8
38
  - **Learning rate:** 0.0002
 
39
  - **Hardware:** NVIDIA T4 (Google Colab free tier)
40
  - **Training time:** 21.2 min
41
  - **Final train loss:** 0.6526
42
- - **Best checkpoint:** step 250 (by eval loss)
43
 
44
  ## LoRA Config
45
 
@@ -48,7 +53,7 @@ Evaluated on 200 held-out examples from [b-mc2/sql-create-context](https://huggi
48
  | Rank (r) | 16 |
49
  | Alpha | 32 |
50
  | Dropout | 0.05 |
51
- | Target modules | ['down_proj', 'qkv_proj', 'gate_up_proj', 'o_proj'] |
52
  | Quantization | 4-bit NF4 (QLoRA) |
53
 
54
  ## How to Use
@@ -58,17 +63,24 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
58
  from peft import PeftModel
59
  import torch
60
 
61
- tokenizer = AutoTokenizer.from_pretrained("Shizu0n/phi3-mini-sql-generator", trust_remote_code=True)
 
 
62
  base_model = AutoModelForCausalLM.from_pretrained(
63
  "microsoft/Phi-3-mini-4k-instruct",
64
- torch_dtype=torch.float16, device_map="auto", trust_remote_code=True,
 
 
 
65
  )
66
  model = PeftModel.from_pretrained(base_model, "Shizu0n/phi3-mini-sql-generator")
67
  model.eval()
68
 
69
- prompt = "Given the following SQL table, write a SQL query.\n\n"\
70
- "Table: employees (id, name, department, salary)\n\n"\
71
- "Question: What is the average salary per department?\n\nSQL:"
 
 
72
 
73
  inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
74
  with torch.inference_mode():
@@ -77,8 +89,14 @@ prompt_len = inputs["input_ids"].shape[-1]
77
  print(tokenizer.decode(outputs[0][prompt_len:], skip_special_tokens=True))
78
  ```
79
 
 
 
 
 
 
 
80
  ## Limitations
81
 
82
  - Fine-tuned on 1,000 examples — best suited for simple to medium complexity SELECT queries
83
  - Not tested on dialect-specific SQL (PostgreSQL/MySQL-specific functions)
84
- - May struggle with multi-table JOINs and nested subqueries
 
1
  ---
2
  base_model: microsoft/Phi-3-mini-4k-instruct
3
  library_name: peft
4
+ license: mit
5
  language:
6
  - en
7
+ datasets:
8
+ - b-mc2/sql-create-context
9
  tags:
10
  - sql
11
  - code-generation
 
32
  | Phi-3-mini-4k-instruct (base) | 2.0% |
33
  | **This adapter (fine-tuned)** | **73.5%** |
34
 
35
+ > Exact match: normalized SQL comparison (lowercase, strip whitespace/semicolons).
36
+
37
  ## Training Details
38
 
39
  - **Dataset:** b-mc2/sql-create-context — 1,000 train / 200 validation examples
40
  - **Epochs:** 3
41
  - **Effective batch size:** 8
42
  - **Learning rate:** 0.0002
43
+ - **Max sequence length:** 512
44
  - **Hardware:** NVIDIA T4 (Google Colab free tier)
45
  - **Training time:** 21.2 min
46
  - **Final train loss:** 0.6526
47
+ - **Best checkpoint:** step 250 (lowest eval loss — mild overfitting observed after epoch 2)
48
 
49
  ## LoRA Config
50
 
 
53
  | Rank (r) | 16 |
54
  | Alpha | 32 |
55
  | Dropout | 0.05 |
56
+ | Target modules | `qkv_proj`, `o_proj`, `gate_up_proj`, `down_proj` |
57
  | Quantization | 4-bit NF4 (QLoRA) |
58
 
59
  ## How to Use
 
63
  from peft import PeftModel
64
  import torch
65
 
66
+ tokenizer = AutoTokenizer.from_pretrained(
67
+ "microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True
68
+ )
69
  base_model = AutoModelForCausalLM.from_pretrained(
70
  "microsoft/Phi-3-mini-4k-instruct",
71
+ torch_dtype=torch.float16,
72
+ device_map="auto",
73
+ trust_remote_code=True,
74
+ attn_implementation="eager",
75
  )
76
  model = PeftModel.from_pretrained(base_model, "Shizu0n/phi3-mini-sql-generator")
77
  model.eval()
78
 
79
+ prompt = (
80
+ "Given the following SQL table, write a SQL query.\n\n"
81
+ "Table: employees (id, name, department, salary)\n\n"
82
+ "Question: What is the average salary per department?\n\nSQL:"
83
+ )
84
 
85
  inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
86
  with torch.inference_mode():
 
89
  print(tokenizer.decode(outputs[0][prompt_len:], skip_special_tokens=True))
90
  ```
91
 
92
+ ## Related
93
+
94
+ The LoRA adapter weights have been merged into a standalone model at
95
+ [Shizu0n/phi3-mini-sql-generator-merged](https://huggingface.co/Shizu0n/phi3-mini-sql-generator-merged)
96
+ — no PEFT dependency required for inference.
97
+
98
  ## Limitations
99
 
100
  - Fine-tuned on 1,000 examples — best suited for simple to medium complexity SELECT queries
101
  - Not tested on dialect-specific SQL (PostgreSQL/MySQL-specific functions)
102
+ - May struggle with multi-table JOINs and nested subqueries