first cut at fine-tuning with masked training, working but very very slow for inference
Browse files- fine-tuned-model-8/checkpoint-118/README.md +202 -0
- fine-tuned-model-8/checkpoint-118/adapter_config.json +39 -0
- fine-tuned-model-8/checkpoint-118/adapter_model.safetensors +3 -0
- fine-tuned-model-8/checkpoint-118/optimizer.pt +3 -0
- fine-tuned-model-8/checkpoint-118/rng_state.pth +3 -0
- fine-tuned-model-8/checkpoint-118/scheduler.pt +3 -0
- fine-tuned-model-8/checkpoint-118/special_tokens_map.json +20 -0
- fine-tuned-model-8/checkpoint-118/tokenizer.json +0 -0
- fine-tuned-model-8/checkpoint-118/tokenizer_config.json +206 -0
- fine-tuned-model-8/checkpoint-118/trainer_state.json +73 -0
- fine-tuned-model-8/checkpoint-118/training_args.bin +3 -0
- fine-tuned-model-8/checkpoint-177/README.md +202 -0
- fine-tuned-model-8/checkpoint-177/adapter_config.json +39 -0
- fine-tuned-model-8/checkpoint-177/adapter_model.safetensors +3 -0
- fine-tuned-model-8/checkpoint-177/optimizer.pt +3 -0
- fine-tuned-model-8/checkpoint-177/rng_state.pth +3 -0
- fine-tuned-model-8/checkpoint-177/scaler.pt +3 -0
- fine-tuned-model-8/checkpoint-177/scheduler.pt +3 -0
- fine-tuned-model-8/checkpoint-177/special_tokens_map.json +26 -0
- fine-tuned-model-8/checkpoint-177/tokenizer.json +0 -0
- fine-tuned-model-8/checkpoint-177/tokenizer_config.json +206 -0
- fine-tuned-model-8/checkpoint-177/trainer_state.json +88 -0
- fine-tuned-model-8/checkpoint-177/training_args.bin +3 -0
- fine-tuned-model-8/config.json +48 -0
- fine-tuned-model-8/generation_config.json +7 -0
- fine-tuned-model-8/model.safetensors +3 -0
- fine-tuned-model-8/runs/Apr06_19-55-38_DESKTOP-SMJC97K/events.out.tfevents.1743994556.DESKTOP-SMJC97K.17072.0 +3 -0
- fine-tuned-model-8/runs/Apr06_20-04-45_DESKTOP-SMJC97K/events.out.tfevents.1743995090.DESKTOP-SMJC97K.17072.1 +3 -0
- fine-tuned-model-8/runs/Apr06_20-09-40_DESKTOP-SMJC97K/events.out.tfevents.1743995381.DESKTOP-SMJC97K.2292.0 +3 -0
- fine-tuned-model-8/runs/Apr06_20-14-05_DESKTOP-SMJC97K/events.out.tfevents.1743995646.DESKTOP-SMJC97K.12712.0 +3 -0
- fine-tuned-model-8/runs/Apr06_20-19-55_DESKTOP-SMJC97K/events.out.tfevents.1743995996.DESKTOP-SMJC97K.12928.0 +3 -0
- fine-tuned-model-8/runs/Apr06_22-18-58_DESKTOP-SMJC97K/events.out.tfevents.1744003142.DESKTOP-SMJC97K.8492.0 +3 -0
- fine-tuned-model-8/runs/Apr06_22-52-40_DESKTOP-SMJC97K/events.out.tfevents.1744005165.DESKTOP-SMJC97K.9844.0 +3 -0
- fine-tuned-model-8/runs/Apr06_23-15-43_DESKTOP-SMJC97K/events.out.tfevents.1744006548.DESKTOP-SMJC97K.7572.0 +3 -0
- fine-tuned-model-8/runs/Apr06_23-40-32_DESKTOP-SMJC97K/events.out.tfevents.1744008032.DESKTOP-SMJC97K.10676.0 +3 -0
- fine-tuned-model-8/special_tokens_map.json +20 -0
- fine-tuned-model-8/tokenizer.json +0 -0
- fine-tuned-model-8/tokenizer_config.json +206 -0
- finetune_model.ipynb +157 -549
fine-tuned-model-8/checkpoint-118/README.md
ADDED
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
base_model: ./deepseek-coder-1.3b-instruct
|
3 |
+
library_name: peft
|
4 |
+
---
|
5 |
+
|
6 |
+
# Model Card for Model ID
|
7 |
+
|
8 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
## Model Details
|
13 |
+
|
14 |
+
### Model Description
|
15 |
+
|
16 |
+
<!-- Provide a longer summary of what this model is. -->
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
+
- **Developed by:** [More Information Needed]
|
21 |
+
- **Funded by [optional]:** [More Information Needed]
|
22 |
+
- **Shared by [optional]:** [More Information Needed]
|
23 |
+
- **Model type:** [More Information Needed]
|
24 |
+
- **Language(s) (NLP):** [More Information Needed]
|
25 |
+
- **License:** [More Information Needed]
|
26 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
+
|
28 |
+
### Model Sources [optional]
|
29 |
+
|
30 |
+
<!-- Provide the basic links for the model. -->
|
31 |
+
|
32 |
+
- **Repository:** [More Information Needed]
|
33 |
+
- **Paper [optional]:** [More Information Needed]
|
34 |
+
- **Demo [optional]:** [More Information Needed]
|
35 |
+
|
36 |
+
## Uses
|
37 |
+
|
38 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
+
|
40 |
+
### Direct Use
|
41 |
+
|
42 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
+
|
44 |
+
[More Information Needed]
|
45 |
+
|
46 |
+
### Downstream Use [optional]
|
47 |
+
|
48 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
+
|
50 |
+
[More Information Needed]
|
51 |
+
|
52 |
+
### Out-of-Scope Use
|
53 |
+
|
54 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
55 |
+
|
56 |
+
[More Information Needed]
|
57 |
+
|
58 |
+
## Bias, Risks, and Limitations
|
59 |
+
|
60 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
61 |
+
|
62 |
+
[More Information Needed]
|
63 |
+
|
64 |
+
### Recommendations
|
65 |
+
|
66 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
67 |
+
|
68 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
69 |
+
|
70 |
+
## How to Get Started with the Model
|
71 |
+
|
72 |
+
Use the code below to get started with the model.
|
73 |
+
|
74 |
+
[More Information Needed]
|
75 |
+
|
76 |
+
## Training Details
|
77 |
+
|
78 |
+
### Training Data
|
79 |
+
|
80 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
81 |
+
|
82 |
+
[More Information Needed]
|
83 |
+
|
84 |
+
### Training Procedure
|
85 |
+
|
86 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
+
|
88 |
+
#### Preprocessing [optional]
|
89 |
+
|
90 |
+
[More Information Needed]
|
91 |
+
|
92 |
+
|
93 |
+
#### Training Hyperparameters
|
94 |
+
|
95 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
+
|
97 |
+
#### Speeds, Sizes, Times [optional]
|
98 |
+
|
99 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
+
|
101 |
+
[More Information Needed]
|
102 |
+
|
103 |
+
## Evaluation
|
104 |
+
|
105 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
+
|
107 |
+
### Testing Data, Factors & Metrics
|
108 |
+
|
109 |
+
#### Testing Data
|
110 |
+
|
111 |
+
<!-- This should link to a Dataset Card if possible. -->
|
112 |
+
|
113 |
+
[More Information Needed]
|
114 |
+
|
115 |
+
#### Factors
|
116 |
+
|
117 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
+
|
119 |
+
[More Information Needed]
|
120 |
+
|
121 |
+
#### Metrics
|
122 |
+
|
123 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
+
|
125 |
+
[More Information Needed]
|
126 |
+
|
127 |
+
### Results
|
128 |
+
|
129 |
+
[More Information Needed]
|
130 |
+
|
131 |
+
#### Summary
|
132 |
+
|
133 |
+
|
134 |
+
|
135 |
+
## Model Examination [optional]
|
136 |
+
|
137 |
+
<!-- Relevant interpretability work for the model goes here -->
|
138 |
+
|
139 |
+
[More Information Needed]
|
140 |
+
|
141 |
+
## Environmental Impact
|
142 |
+
|
143 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
+
|
145 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
+
|
147 |
+
- **Hardware Type:** [More Information Needed]
|
148 |
+
- **Hours used:** [More Information Needed]
|
149 |
+
- **Cloud Provider:** [More Information Needed]
|
150 |
+
- **Compute Region:** [More Information Needed]
|
151 |
+
- **Carbon Emitted:** [More Information Needed]
|
152 |
+
|
153 |
+
## Technical Specifications [optional]
|
154 |
+
|
155 |
+
### Model Architecture and Objective
|
156 |
+
|
157 |
+
[More Information Needed]
|
158 |
+
|
159 |
+
### Compute Infrastructure
|
160 |
+
|
161 |
+
[More Information Needed]
|
162 |
+
|
163 |
+
#### Hardware
|
164 |
+
|
165 |
+
[More Information Needed]
|
166 |
+
|
167 |
+
#### Software
|
168 |
+
|
169 |
+
[More Information Needed]
|
170 |
+
|
171 |
+
## Citation [optional]
|
172 |
+
|
173 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
+
|
175 |
+
**BibTeX:**
|
176 |
+
|
177 |
+
[More Information Needed]
|
178 |
+
|
179 |
+
**APA:**
|
180 |
+
|
181 |
+
[More Information Needed]
|
182 |
+
|
183 |
+
## Glossary [optional]
|
184 |
+
|
185 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
+
|
187 |
+
[More Information Needed]
|
188 |
+
|
189 |
+
## More Information [optional]
|
190 |
+
|
191 |
+
[More Information Needed]
|
192 |
+
|
193 |
+
## Model Card Authors [optional]
|
194 |
+
|
195 |
+
[More Information Needed]
|
196 |
+
|
197 |
+
## Model Card Contact
|
198 |
+
|
199 |
+
[More Information Needed]
|
200 |
+
### Framework versions
|
201 |
+
|
202 |
+
- PEFT 0.15.1
|
fine-tuned-model-8/checkpoint-118/adapter_config.json
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"alpha_pattern": {},
|
3 |
+
"auto_mapping": null,
|
4 |
+
"base_model_name_or_path": "./deepseek-coder-1.3b-instruct",
|
5 |
+
"bias": "none",
|
6 |
+
"corda_config": null,
|
7 |
+
"eva_config": null,
|
8 |
+
"exclude_modules": null,
|
9 |
+
"fan_in_fan_out": false,
|
10 |
+
"inference_mode": true,
|
11 |
+
"init_lora_weights": true,
|
12 |
+
"layer_replication": null,
|
13 |
+
"layers_pattern": null,
|
14 |
+
"layers_to_transform": null,
|
15 |
+
"loftq_config": {},
|
16 |
+
"lora_alpha": 16,
|
17 |
+
"lora_bias": false,
|
18 |
+
"lora_dropout": 0.0,
|
19 |
+
"megatron_config": null,
|
20 |
+
"megatron_core": "megatron.core",
|
21 |
+
"modules_to_save": null,
|
22 |
+
"peft_type": "LORA",
|
23 |
+
"r": 8,
|
24 |
+
"rank_pattern": {},
|
25 |
+
"revision": null,
|
26 |
+
"target_modules": [
|
27 |
+
"up_proj",
|
28 |
+
"k_proj",
|
29 |
+
"q_proj",
|
30 |
+
"down_proj",
|
31 |
+
"v_proj",
|
32 |
+
"o_proj",
|
33 |
+
"gate_proj"
|
34 |
+
],
|
35 |
+
"task_type": "CAUSAL_LM",
|
36 |
+
"trainable_token_indices": null,
|
37 |
+
"use_dora": false,
|
38 |
+
"use_rslora": false
|
39 |
+
}
|
fine-tuned-model-8/checkpoint-118/adapter_model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1d9a812553f57bf6d7451ee9a58ce33104b1e5136ffe2f0cd207d34b9d14298e
|
3 |
+
size 292359512
|
fine-tuned-model-8/checkpoint-118/optimizer.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7e7e4beb78a641529e580de426ce262295f1c15b3e14f5a173d62d0e5de39870
|
3 |
+
size 60247362
|
fine-tuned-model-8/checkpoint-118/rng_state.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:40cb1869983733651486e797294b9d075e35ed911b745abc673b44d5ac187b23
|
3 |
+
size 14244
|
fine-tuned-model-8/checkpoint-118/scheduler.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:51f0a01f95d6e87f3858b9ec113cee47151943ee496cc24613a58de96882db92
|
3 |
+
size 1064
|
fine-tuned-model-8/checkpoint-118/special_tokens_map.json
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"additional_special_tokens": [
|
3 |
+
{
|
4 |
+
"content": "<|endofsql|>",
|
5 |
+
"lstrip": false,
|
6 |
+
"normalized": false,
|
7 |
+
"rstrip": false,
|
8 |
+
"single_word": false
|
9 |
+
}
|
10 |
+
],
|
11 |
+
"bos_token": {
|
12 |
+
"content": "<|begin▁of▁sentence|>",
|
13 |
+
"lstrip": false,
|
14 |
+
"normalized": true,
|
15 |
+
"rstrip": false,
|
16 |
+
"single_word": false
|
17 |
+
},
|
18 |
+
"eos_token": "<|endofsql|>",
|
19 |
+
"pad_token": "<|endofsql|>"
|
20 |
+
}
|
fine-tuned-model-8/checkpoint-118/tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
fine-tuned-model-8/checkpoint-118/tokenizer_config.json
ADDED
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": true,
|
3 |
+
"add_eos_token": false,
|
4 |
+
"add_prefix_space": null,
|
5 |
+
"added_tokens_decoder": {
|
6 |
+
"32000": {
|
7 |
+
"content": "õ",
|
8 |
+
"lstrip": false,
|
9 |
+
"normalized": true,
|
10 |
+
"rstrip": false,
|
11 |
+
"single_word": false,
|
12 |
+
"special": false
|
13 |
+
},
|
14 |
+
"32001": {
|
15 |
+
"content": "÷",
|
16 |
+
"lstrip": false,
|
17 |
+
"normalized": true,
|
18 |
+
"rstrip": false,
|
19 |
+
"single_word": false,
|
20 |
+
"special": false
|
21 |
+
},
|
22 |
+
"32002": {
|
23 |
+
"content": "Á",
|
24 |
+
"lstrip": false,
|
25 |
+
"normalized": true,
|
26 |
+
"rstrip": false,
|
27 |
+
"single_word": false,
|
28 |
+
"special": false
|
29 |
+
},
|
30 |
+
"32003": {
|
31 |
+
"content": "ý",
|
32 |
+
"lstrip": false,
|
33 |
+
"normalized": true,
|
34 |
+
"rstrip": false,
|
35 |
+
"single_word": false,
|
36 |
+
"special": false
|
37 |
+
},
|
38 |
+
"32004": {
|
39 |
+
"content": "À",
|
40 |
+
"lstrip": false,
|
41 |
+
"normalized": true,
|
42 |
+
"rstrip": false,
|
43 |
+
"single_word": false,
|
44 |
+
"special": false
|
45 |
+
},
|
46 |
+
"32005": {
|
47 |
+
"content": "ÿ",
|
48 |
+
"lstrip": false,
|
49 |
+
"normalized": true,
|
50 |
+
"rstrip": false,
|
51 |
+
"single_word": false,
|
52 |
+
"special": false
|
53 |
+
},
|
54 |
+
"32006": {
|
55 |
+
"content": "ø",
|
56 |
+
"lstrip": false,
|
57 |
+
"normalized": true,
|
58 |
+
"rstrip": false,
|
59 |
+
"single_word": false,
|
60 |
+
"special": false
|
61 |
+
},
|
62 |
+
"32007": {
|
63 |
+
"content": "ú",
|
64 |
+
"lstrip": false,
|
65 |
+
"normalized": true,
|
66 |
+
"rstrip": false,
|
67 |
+
"single_word": false,
|
68 |
+
"special": false
|
69 |
+
},
|
70 |
+
"32008": {
|
71 |
+
"content": "þ",
|
72 |
+
"lstrip": false,
|
73 |
+
"normalized": true,
|
74 |
+
"rstrip": false,
|
75 |
+
"single_word": false,
|
76 |
+
"special": false
|
77 |
+
},
|
78 |
+
"32009": {
|
79 |
+
"content": "ü",
|
80 |
+
"lstrip": false,
|
81 |
+
"normalized": true,
|
82 |
+
"rstrip": false,
|
83 |
+
"single_word": false,
|
84 |
+
"special": false
|
85 |
+
},
|
86 |
+
"32010": {
|
87 |
+
"content": "ù",
|
88 |
+
"lstrip": false,
|
89 |
+
"normalized": true,
|
90 |
+
"rstrip": false,
|
91 |
+
"single_word": false,
|
92 |
+
"special": false
|
93 |
+
},
|
94 |
+
"32011": {
|
95 |
+
"content": "ö",
|
96 |
+
"lstrip": false,
|
97 |
+
"normalized": true,
|
98 |
+
"rstrip": false,
|
99 |
+
"single_word": false,
|
100 |
+
"special": false
|
101 |
+
},
|
102 |
+
"32012": {
|
103 |
+
"content": "û",
|
104 |
+
"lstrip": false,
|
105 |
+
"normalized": true,
|
106 |
+
"rstrip": false,
|
107 |
+
"single_word": false,
|
108 |
+
"special": false
|
109 |
+
},
|
110 |
+
"32013": {
|
111 |
+
"content": "<|begin▁of▁sentence|>",
|
112 |
+
"lstrip": false,
|
113 |
+
"normalized": true,
|
114 |
+
"rstrip": false,
|
115 |
+
"single_word": false,
|
116 |
+
"special": true
|
117 |
+
},
|
118 |
+
"32014": {
|
119 |
+
"content": "<|end▁of▁sentence|>",
|
120 |
+
"lstrip": false,
|
121 |
+
"normalized": true,
|
122 |
+
"rstrip": false,
|
123 |
+
"single_word": false,
|
124 |
+
"special": true
|
125 |
+
},
|
126 |
+
"32015": {
|
127 |
+
"content": "<|fim▁hole|>",
|
128 |
+
"lstrip": false,
|
129 |
+
"normalized": true,
|
130 |
+
"rstrip": false,
|
131 |
+
"single_word": false,
|
132 |
+
"special": false
|
133 |
+
},
|
134 |
+
"32016": {
|
135 |
+
"content": "<|fim▁begin|>",
|
136 |
+
"lstrip": false,
|
137 |
+
"normalized": true,
|
138 |
+
"rstrip": false,
|
139 |
+
"single_word": false,
|
140 |
+
"special": false
|
141 |
+
},
|
142 |
+
"32017": {
|
143 |
+
"content": "<|fim▁end|>",
|
144 |
+
"lstrip": false,
|
145 |
+
"normalized": true,
|
146 |
+
"rstrip": false,
|
147 |
+
"single_word": false,
|
148 |
+
"special": false
|
149 |
+
},
|
150 |
+
"32018": {
|
151 |
+
"content": "<pad>",
|
152 |
+
"lstrip": false,
|
153 |
+
"normalized": true,
|
154 |
+
"rstrip": false,
|
155 |
+
"single_word": false,
|
156 |
+
"special": false
|
157 |
+
},
|
158 |
+
"32019": {
|
159 |
+
"content": "<|User|>",
|
160 |
+
"lstrip": false,
|
161 |
+
"normalized": true,
|
162 |
+
"rstrip": false,
|
163 |
+
"single_word": false,
|
164 |
+
"special": false
|
165 |
+
},
|
166 |
+
"32020": {
|
167 |
+
"content": "<|Assistant|>",
|
168 |
+
"lstrip": false,
|
169 |
+
"normalized": true,
|
170 |
+
"rstrip": false,
|
171 |
+
"single_word": false,
|
172 |
+
"special": false
|
173 |
+
},
|
174 |
+
"32021": {
|
175 |
+
"content": "<|EOT|>",
|
176 |
+
"lstrip": false,
|
177 |
+
"normalized": true,
|
178 |
+
"rstrip": false,
|
179 |
+
"single_word": false,
|
180 |
+
"special": true
|
181 |
+
},
|
182 |
+
"32022": {
|
183 |
+
"content": "<|endofsql|>",
|
184 |
+
"lstrip": false,
|
185 |
+
"normalized": false,
|
186 |
+
"rstrip": false,
|
187 |
+
"single_word": false,
|
188 |
+
"special": true
|
189 |
+
}
|
190 |
+
},
|
191 |
+
"additional_special_tokens": [
|
192 |
+
"<|endofsql|>"
|
193 |
+
],
|
194 |
+
"bos_token": "<|begin▁of▁sentence|>",
|
195 |
+
"chat_template": "{% if not add_generation_prompt is defined %}\n{% set add_generation_prompt = false %}\n{% endif %}\n{%- set ns = namespace(found=false) -%}\n{%- for message in messages -%}\n {%- if message['role'] == 'system' -%}\n {%- set ns.found = true -%}\n {%- endif -%}\n{%- endfor -%}\n{{bos_token}}{%- if not ns.found -%}\n{{'You are an AI programming assistant, utilizing the Deepseek Coder model, developed by Deepseek Company, and you only answer questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer\\n'}}\n{%- endif %}\n{%- for message in messages %}\n {%- if message['role'] == 'system' %}\n{{ message['content'] }}\n {%- else %}\n {%- if message['role'] == 'user' %}\n{{'### Instruction:\\n' + message['content'] + '\\n'}}\n {%- else %}\n{{'### Response:\\n' + message['content'] + '\\n<|EOT|>\\n'}}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{% if add_generation_prompt %}\n{{'### Response:'}}\n{% endif %}",
|
196 |
+
"clean_up_tokenization_spaces": false,
|
197 |
+
"eos_token": "<|endofsql|>",
|
198 |
+
"extra_special_tokens": {},
|
199 |
+
"legacy": true,
|
200 |
+
"model_max_length": 16384,
|
201 |
+
"pad_token": "<|endofsql|>",
|
202 |
+
"sp_model_kwargs": {},
|
203 |
+
"tokenizer_class": "LlamaTokenizerFast",
|
204 |
+
"unk_token": null,
|
205 |
+
"use_default_system_prompt": false
|
206 |
+
}
|
fine-tuned-model-8/checkpoint-118/trainer_state.json
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"best_global_step": 118,
|
3 |
+
"best_metric": 0.31218037009239197,
|
4 |
+
"best_model_checkpoint": "./fine-tuned-model-8\\checkpoint-118",
|
5 |
+
"epoch": 2.0,
|
6 |
+
"eval_steps": 500,
|
7 |
+
"global_step": 118,
|
8 |
+
"is_hyper_param_search": false,
|
9 |
+
"is_local_process_zero": true,
|
10 |
+
"is_world_process_zero": true,
|
11 |
+
"log_history": [
|
12 |
+
{
|
13 |
+
"epoch": 0.8519701810436635,
|
14 |
+
"grad_norm": 0.3398423194885254,
|
15 |
+
"learning_rate": 3.655172413793104e-05,
|
16 |
+
"loss": 0.7607,
|
17 |
+
"step": 50
|
18 |
+
},
|
19 |
+
{
|
20 |
+
"epoch": 1.0,
|
21 |
+
"eval_loss": 0.41808420419692993,
|
22 |
+
"eval_runtime": 179.321,
|
23 |
+
"eval_samples_per_second": 0.586,
|
24 |
+
"eval_steps_per_second": 0.586,
|
25 |
+
"step": 59
|
26 |
+
},
|
27 |
+
{
|
28 |
+
"epoch": 1.698615548455804,
|
29 |
+
"grad_norm": 0.16843748092651367,
|
30 |
+
"learning_rate": 3.310344827586207e-05,
|
31 |
+
"loss": 0.2266,
|
32 |
+
"step": 100
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"epoch": 2.0,
|
36 |
+
"eval_loss": 0.31218037009239197,
|
37 |
+
"eval_runtime": 179.2637,
|
38 |
+
"eval_samples_per_second": 0.586,
|
39 |
+
"eval_steps_per_second": 0.586,
|
40 |
+
"step": 118
|
41 |
+
}
|
42 |
+
],
|
43 |
+
"logging_steps": 50,
|
44 |
+
"max_steps": 580,
|
45 |
+
"num_input_tokens_seen": 0,
|
46 |
+
"num_train_epochs": 10,
|
47 |
+
"save_steps": 500,
|
48 |
+
"stateful_callbacks": {
|
49 |
+
"EarlyStoppingCallback": {
|
50 |
+
"args": {
|
51 |
+
"early_stopping_patience": 2,
|
52 |
+
"early_stopping_threshold": 0.0
|
53 |
+
},
|
54 |
+
"attributes": {
|
55 |
+
"early_stopping_patience_counter": 0
|
56 |
+
}
|
57 |
+
},
|
58 |
+
"TrainerControl": {
|
59 |
+
"args": {
|
60 |
+
"should_epoch_stop": false,
|
61 |
+
"should_evaluate": false,
|
62 |
+
"should_log": false,
|
63 |
+
"should_save": true,
|
64 |
+
"should_training_stop": false
|
65 |
+
},
|
66 |
+
"attributes": {}
|
67 |
+
}
|
68 |
+
},
|
69 |
+
"total_flos": 4.578334359434035e+16,
|
70 |
+
"train_batch_size": 1,
|
71 |
+
"trial_name": null,
|
72 |
+
"trial_params": null
|
73 |
+
}
|
fine-tuned-model-8/checkpoint-118/training_args.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:39cfff4521756a64baee577169ee2e28102998cb2e4bec9cb0370e436b501d28
|
3 |
+
size 5368
|
fine-tuned-model-8/checkpoint-177/README.md
ADDED
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
base_model: ./deepseek-coder-1.3b-instruct
|
3 |
+
library_name: peft
|
4 |
+
---
|
5 |
+
|
6 |
+
# Model Card for Model ID
|
7 |
+
|
8 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
## Model Details
|
13 |
+
|
14 |
+
### Model Description
|
15 |
+
|
16 |
+
<!-- Provide a longer summary of what this model is. -->
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
+
- **Developed by:** [More Information Needed]
|
21 |
+
- **Funded by [optional]:** [More Information Needed]
|
22 |
+
- **Shared by [optional]:** [More Information Needed]
|
23 |
+
- **Model type:** [More Information Needed]
|
24 |
+
- **Language(s) (NLP):** [More Information Needed]
|
25 |
+
- **License:** [More Information Needed]
|
26 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
+
|
28 |
+
### Model Sources [optional]
|
29 |
+
|
30 |
+
<!-- Provide the basic links for the model. -->
|
31 |
+
|
32 |
+
- **Repository:** [More Information Needed]
|
33 |
+
- **Paper [optional]:** [More Information Needed]
|
34 |
+
- **Demo [optional]:** [More Information Needed]
|
35 |
+
|
36 |
+
## Uses
|
37 |
+
|
38 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
+
|
40 |
+
### Direct Use
|
41 |
+
|
42 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
+
|
44 |
+
[More Information Needed]
|
45 |
+
|
46 |
+
### Downstream Use [optional]
|
47 |
+
|
48 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
+
|
50 |
+
[More Information Needed]
|
51 |
+
|
52 |
+
### Out-of-Scope Use
|
53 |
+
|
54 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
55 |
+
|
56 |
+
[More Information Needed]
|
57 |
+
|
58 |
+
## Bias, Risks, and Limitations
|
59 |
+
|
60 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
61 |
+
|
62 |
+
[More Information Needed]
|
63 |
+
|
64 |
+
### Recommendations
|
65 |
+
|
66 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
67 |
+
|
68 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
69 |
+
|
70 |
+
## How to Get Started with the Model
|
71 |
+
|
72 |
+
Use the code below to get started with the model.
|
73 |
+
|
74 |
+
[More Information Needed]
|
75 |
+
|
76 |
+
## Training Details
|
77 |
+
|
78 |
+
### Training Data
|
79 |
+
|
80 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
81 |
+
|
82 |
+
[More Information Needed]
|
83 |
+
|
84 |
+
### Training Procedure
|
85 |
+
|
86 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
+
|
88 |
+
#### Preprocessing [optional]
|
89 |
+
|
90 |
+
[More Information Needed]
|
91 |
+
|
92 |
+
|
93 |
+
#### Training Hyperparameters
|
94 |
+
|
95 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
+
|
97 |
+
#### Speeds, Sizes, Times [optional]
|
98 |
+
|
99 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
+
|
101 |
+
[More Information Needed]
|
102 |
+
|
103 |
+
## Evaluation
|
104 |
+
|
105 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
+
|
107 |
+
### Testing Data, Factors & Metrics
|
108 |
+
|
109 |
+
#### Testing Data
|
110 |
+
|
111 |
+
<!-- This should link to a Dataset Card if possible. -->
|
112 |
+
|
113 |
+
[More Information Needed]
|
114 |
+
|
115 |
+
#### Factors
|
116 |
+
|
117 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
+
|
119 |
+
[More Information Needed]
|
120 |
+
|
121 |
+
#### Metrics
|
122 |
+
|
123 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
+
|
125 |
+
[More Information Needed]
|
126 |
+
|
127 |
+
### Results
|
128 |
+
|
129 |
+
[More Information Needed]
|
130 |
+
|
131 |
+
#### Summary
|
132 |
+
|
133 |
+
|
134 |
+
|
135 |
+
## Model Examination [optional]
|
136 |
+
|
137 |
+
<!-- Relevant interpretability work for the model goes here -->
|
138 |
+
|
139 |
+
[More Information Needed]
|
140 |
+
|
141 |
+
## Environmental Impact
|
142 |
+
|
143 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
+
|
145 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
+
|
147 |
+
- **Hardware Type:** [More Information Needed]
|
148 |
+
- **Hours used:** [More Information Needed]
|
149 |
+
- **Cloud Provider:** [More Information Needed]
|
150 |
+
- **Compute Region:** [More Information Needed]
|
151 |
+
- **Carbon Emitted:** [More Information Needed]
|
152 |
+
|
153 |
+
## Technical Specifications [optional]
|
154 |
+
|
155 |
+
### Model Architecture and Objective
|
156 |
+
|
157 |
+
[More Information Needed]
|
158 |
+
|
159 |
+
### Compute Infrastructure
|
160 |
+
|
161 |
+
[More Information Needed]
|
162 |
+
|
163 |
+
#### Hardware
|
164 |
+
|
165 |
+
[More Information Needed]
|
166 |
+
|
167 |
+
#### Software
|
168 |
+
|
169 |
+
[More Information Needed]
|
170 |
+
|
171 |
+
## Citation [optional]
|
172 |
+
|
173 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
+
|
175 |
+
**BibTeX:**
|
176 |
+
|
177 |
+
[More Information Needed]
|
178 |
+
|
179 |
+
**APA:**
|
180 |
+
|
181 |
+
[More Information Needed]
|
182 |
+
|
183 |
+
## Glossary [optional]
|
184 |
+
|
185 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
+
|
187 |
+
[More Information Needed]
|
188 |
+
|
189 |
+
## More Information [optional]
|
190 |
+
|
191 |
+
[More Information Needed]
|
192 |
+
|
193 |
+
## Model Card Authors [optional]
|
194 |
+
|
195 |
+
[More Information Needed]
|
196 |
+
|
197 |
+
## Model Card Contact
|
198 |
+
|
199 |
+
[More Information Needed]
|
200 |
+
### Framework versions
|
201 |
+
|
202 |
+
- PEFT 0.15.1
|
fine-tuned-model-8/checkpoint-177/adapter_config.json
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"alpha_pattern": {},
|
3 |
+
"auto_mapping": null,
|
4 |
+
"base_model_name_or_path": "./deepseek-coder-1.3b-instruct",
|
5 |
+
"bias": "none",
|
6 |
+
"corda_config": null,
|
7 |
+
"eva_config": null,
|
8 |
+
"exclude_modules": null,
|
9 |
+
"fan_in_fan_out": false,
|
10 |
+
"inference_mode": true,
|
11 |
+
"init_lora_weights": true,
|
12 |
+
"layer_replication": null,
|
13 |
+
"layers_pattern": null,
|
14 |
+
"layers_to_transform": null,
|
15 |
+
"loftq_config": {},
|
16 |
+
"lora_alpha": 16,
|
17 |
+
"lora_bias": false,
|
18 |
+
"lora_dropout": 0.0,
|
19 |
+
"megatron_config": null,
|
20 |
+
"megatron_core": "megatron.core",
|
21 |
+
"modules_to_save": null,
|
22 |
+
"peft_type": "LORA",
|
23 |
+
"r": 8,
|
24 |
+
"rank_pattern": {},
|
25 |
+
"revision": null,
|
26 |
+
"target_modules": [
|
27 |
+
"down_proj",
|
28 |
+
"v_proj",
|
29 |
+
"q_proj",
|
30 |
+
"up_proj",
|
31 |
+
"gate_proj",
|
32 |
+
"k_proj",
|
33 |
+
"o_proj"
|
34 |
+
],
|
35 |
+
"task_type": "CAUSAL_LM",
|
36 |
+
"trainable_token_indices": null,
|
37 |
+
"use_dora": false,
|
38 |
+
"use_rslora": false
|
39 |
+
}
|
fine-tuned-model-8/checkpoint-177/adapter_model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fac3a5a1d0ccbee1020377ededd4afcf94929077064545a34d8145d44078d960
|
3 |
+
size 292359512
|
fine-tuned-model-8/checkpoint-177/optimizer.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1fa76606469f2921f2816e3a6621681a61d97509818f7b44f5bf50d6ee2a1049
|
3 |
+
size 60247362
|
fine-tuned-model-8/checkpoint-177/rng_state.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:243a37024beb77e9c86d6c9c8f32f88f819d9b15ad1ea65bedb28457eb282f6b
|
3 |
+
size 14244
|
fine-tuned-model-8/checkpoint-177/scaler.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f3d2c34aea8bd05b1543fb3da357047d4dd84b958e9c7d89fee01b9a79b73466
|
3 |
+
size 988
|
fine-tuned-model-8/checkpoint-177/scheduler.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:51eaa40e9657ac0af94051d19e116e479bb16e230ce7774f8c52c884f089734a
|
3 |
+
size 1064
|
fine-tuned-model-8/checkpoint-177/special_tokens_map.json
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"additional_special_tokens": [
|
3 |
+
{
|
4 |
+
"content": "<|endofsql|>",
|
5 |
+
"lstrip": false,
|
6 |
+
"normalized": false,
|
7 |
+
"rstrip": false,
|
8 |
+
"single_word": false
|
9 |
+
}
|
10 |
+
],
|
11 |
+
"bos_token": {
|
12 |
+
"content": "<|begin▁of▁sentence|>",
|
13 |
+
"lstrip": false,
|
14 |
+
"normalized": true,
|
15 |
+
"rstrip": false,
|
16 |
+
"single_word": false
|
17 |
+
},
|
18 |
+
"eos_token": "<|endofsql|>",
|
19 |
+
"pad_token": {
|
20 |
+
"content": "<|end▁of▁sentence|>",
|
21 |
+
"lstrip": false,
|
22 |
+
"normalized": true,
|
23 |
+
"rstrip": false,
|
24 |
+
"single_word": false
|
25 |
+
}
|
26 |
+
}
|
fine-tuned-model-8/checkpoint-177/tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
fine-tuned-model-8/checkpoint-177/tokenizer_config.json
ADDED
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": true,
|
3 |
+
"add_eos_token": false,
|
4 |
+
"add_prefix_space": null,
|
5 |
+
"added_tokens_decoder": {
|
6 |
+
"32000": {
|
7 |
+
"content": "õ",
|
8 |
+
"lstrip": false,
|
9 |
+
"normalized": true,
|
10 |
+
"rstrip": false,
|
11 |
+
"single_word": false,
|
12 |
+
"special": false
|
13 |
+
},
|
14 |
+
"32001": {
|
15 |
+
"content": "÷",
|
16 |
+
"lstrip": false,
|
17 |
+
"normalized": true,
|
18 |
+
"rstrip": false,
|
19 |
+
"single_word": false,
|
20 |
+
"special": false
|
21 |
+
},
|
22 |
+
"32002": {
|
23 |
+
"content": "Á",
|
24 |
+
"lstrip": false,
|
25 |
+
"normalized": true,
|
26 |
+
"rstrip": false,
|
27 |
+
"single_word": false,
|
28 |
+
"special": false
|
29 |
+
},
|
30 |
+
"32003": {
|
31 |
+
"content": "ý",
|
32 |
+
"lstrip": false,
|
33 |
+
"normalized": true,
|
34 |
+
"rstrip": false,
|
35 |
+
"single_word": false,
|
36 |
+
"special": false
|
37 |
+
},
|
38 |
+
"32004": {
|
39 |
+
"content": "À",
|
40 |
+
"lstrip": false,
|
41 |
+
"normalized": true,
|
42 |
+
"rstrip": false,
|
43 |
+
"single_word": false,
|
44 |
+
"special": false
|
45 |
+
},
|
46 |
+
"32005": {
|
47 |
+
"content": "ÿ",
|
48 |
+
"lstrip": false,
|
49 |
+
"normalized": true,
|
50 |
+
"rstrip": false,
|
51 |
+
"single_word": false,
|
52 |
+
"special": false
|
53 |
+
},
|
54 |
+
"32006": {
|
55 |
+
"content": "ø",
|
56 |
+
"lstrip": false,
|
57 |
+
"normalized": true,
|
58 |
+
"rstrip": false,
|
59 |
+
"single_word": false,
|
60 |
+
"special": false
|
61 |
+
},
|
62 |
+
"32007": {
|
63 |
+
"content": "ú",
|
64 |
+
"lstrip": false,
|
65 |
+
"normalized": true,
|
66 |
+
"rstrip": false,
|
67 |
+
"single_word": false,
|
68 |
+
"special": false
|
69 |
+
},
|
70 |
+
"32008": {
|
71 |
+
"content": "þ",
|
72 |
+
"lstrip": false,
|
73 |
+
"normalized": true,
|
74 |
+
"rstrip": false,
|
75 |
+
"single_word": false,
|
76 |
+
"special": false
|
77 |
+
},
|
78 |
+
"32009": {
|
79 |
+
"content": "ü",
|
80 |
+
"lstrip": false,
|
81 |
+
"normalized": true,
|
82 |
+
"rstrip": false,
|
83 |
+
"single_word": false,
|
84 |
+
"special": false
|
85 |
+
},
|
86 |
+
"32010": {
|
87 |
+
"content": "ù",
|
88 |
+
"lstrip": false,
|
89 |
+
"normalized": true,
|
90 |
+
"rstrip": false,
|
91 |
+
"single_word": false,
|
92 |
+
"special": false
|
93 |
+
},
|
94 |
+
"32011": {
|
95 |
+
"content": "ö",
|
96 |
+
"lstrip": false,
|
97 |
+
"normalized": true,
|
98 |
+
"rstrip": false,
|
99 |
+
"single_word": false,
|
100 |
+
"special": false
|
101 |
+
},
|
102 |
+
"32012": {
|
103 |
+
"content": "û",
|
104 |
+
"lstrip": false,
|
105 |
+
"normalized": true,
|
106 |
+
"rstrip": false,
|
107 |
+
"single_word": false,
|
108 |
+
"special": false
|
109 |
+
},
|
110 |
+
"32013": {
|
111 |
+
"content": "<|begin▁of▁sentence|>",
|
112 |
+
"lstrip": false,
|
113 |
+
"normalized": true,
|
114 |
+
"rstrip": false,
|
115 |
+
"single_word": false,
|
116 |
+
"special": true
|
117 |
+
},
|
118 |
+
"32014": {
|
119 |
+
"content": "<|end▁of▁sentence|>",
|
120 |
+
"lstrip": false,
|
121 |
+
"normalized": true,
|
122 |
+
"rstrip": false,
|
123 |
+
"single_word": false,
|
124 |
+
"special": true
|
125 |
+
},
|
126 |
+
"32015": {
|
127 |
+
"content": "<|fim▁hole|>",
|
128 |
+
"lstrip": false,
|
129 |
+
"normalized": true,
|
130 |
+
"rstrip": false,
|
131 |
+
"single_word": false,
|
132 |
+
"special": false
|
133 |
+
},
|
134 |
+
"32016": {
|
135 |
+
"content": "<|fim▁begin|>",
|
136 |
+
"lstrip": false,
|
137 |
+
"normalized": true,
|
138 |
+
"rstrip": false,
|
139 |
+
"single_word": false,
|
140 |
+
"special": false
|
141 |
+
},
|
142 |
+
"32017": {
|
143 |
+
"content": "<|fim▁end|>",
|
144 |
+
"lstrip": false,
|
145 |
+
"normalized": true,
|
146 |
+
"rstrip": false,
|
147 |
+
"single_word": false,
|
148 |
+
"special": false
|
149 |
+
},
|
150 |
+
"32018": {
|
151 |
+
"content": "<pad>",
|
152 |
+
"lstrip": false,
|
153 |
+
"normalized": true,
|
154 |
+
"rstrip": false,
|
155 |
+
"single_word": false,
|
156 |
+
"special": false
|
157 |
+
},
|
158 |
+
"32019": {
|
159 |
+
"content": "<|User|>",
|
160 |
+
"lstrip": false,
|
161 |
+
"normalized": true,
|
162 |
+
"rstrip": false,
|
163 |
+
"single_word": false,
|
164 |
+
"special": false
|
165 |
+
},
|
166 |
+
"32020": {
|
167 |
+
"content": "<|Assistant|>",
|
168 |
+
"lstrip": false,
|
169 |
+
"normalized": true,
|
170 |
+
"rstrip": false,
|
171 |
+
"single_word": false,
|
172 |
+
"special": false
|
173 |
+
},
|
174 |
+
"32021": {
|
175 |
+
"content": "<|EOT|>",
|
176 |
+
"lstrip": false,
|
177 |
+
"normalized": true,
|
178 |
+
"rstrip": false,
|
179 |
+
"single_word": false,
|
180 |
+
"special": true
|
181 |
+
},
|
182 |
+
"32022": {
|
183 |
+
"content": "<|endofsql|>",
|
184 |
+
"lstrip": false,
|
185 |
+
"normalized": false,
|
186 |
+
"rstrip": false,
|
187 |
+
"single_word": false,
|
188 |
+
"special": true
|
189 |
+
}
|
190 |
+
},
|
191 |
+
"additional_special_tokens": [
|
192 |
+
"<|endofsql|>"
|
193 |
+
],
|
194 |
+
"bos_token": "<|begin▁of▁sentence|>",
|
195 |
+
"chat_template": "{% if not add_generation_prompt is defined %}\n{% set add_generation_prompt = false %}\n{% endif %}\n{%- set ns = namespace(found=false) -%}\n{%- for message in messages -%}\n {%- if message['role'] == 'system' -%}\n {%- set ns.found = true -%}\n {%- endif -%}\n{%- endfor -%}\n{{bos_token}}{%- if not ns.found -%}\n{{'You are an AI programming assistant, utilizing the Deepseek Coder model, developed by Deepseek Company, and you only answer questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer\\n'}}\n{%- endif %}\n{%- for message in messages %}\n {%- if message['role'] == 'system' %}\n{{ message['content'] }}\n {%- else %}\n {%- if message['role'] == 'user' %}\n{{'### Instruction:\\n' + message['content'] + '\\n'}}\n {%- else %}\n{{'### Response:\\n' + message['content'] + '\\n<|EOT|>\\n'}}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{% if add_generation_prompt %}\n{{'### Response:'}}\n{% endif %}",
|
196 |
+
"clean_up_tokenization_spaces": false,
|
197 |
+
"eos_token": "<|endofsql|>",
|
198 |
+
"extra_special_tokens": {},
|
199 |
+
"legacy": true,
|
200 |
+
"model_max_length": 16384,
|
201 |
+
"pad_token": "<|end▁of▁sentence|>",
|
202 |
+
"sp_model_kwargs": {},
|
203 |
+
"tokenizer_class": "LlamaTokenizerFast",
|
204 |
+
"unk_token": null,
|
205 |
+
"use_default_system_prompt": false
|
206 |
+
}
|
fine-tuned-model-8/checkpoint-177/trainer_state.json
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"best_global_step": 177,
|
3 |
+
"best_metric": 0.0004340429150033742,
|
4 |
+
"best_model_checkpoint": "./fine-tuned-model-8\\checkpoint-177",
|
5 |
+
"epoch": 3.0,
|
6 |
+
"eval_steps": 500,
|
7 |
+
"global_step": 177,
|
8 |
+
"is_hyper_param_search": false,
|
9 |
+
"is_local_process_zero": true,
|
10 |
+
"is_world_process_zero": true,
|
11 |
+
"log_history": [
|
12 |
+
{
|
13 |
+
"epoch": 0.847457627118644,
|
14 |
+
"grad_norm": 0.404996782541275,
|
15 |
+
"learning_rate": 3.932203389830509e-05,
|
16 |
+
"loss": 0.6388,
|
17 |
+
"step": 50
|
18 |
+
},
|
19 |
+
{
|
20 |
+
"epoch": 1.0,
|
21 |
+
"eval_loss": 0.06650885194540024,
|
22 |
+
"eval_runtime": 8.3615,
|
23 |
+
"eval_samples_per_second": 12.558,
|
24 |
+
"eval_steps_per_second": 0.837,
|
25 |
+
"step": 59
|
26 |
+
},
|
27 |
+
{
|
28 |
+
"epoch": 1.694915254237288,
|
29 |
+
"grad_norm": 0.7748989462852478,
|
30 |
+
"learning_rate": 3.8644067796610175e-05,
|
31 |
+
"loss": 0.0458,
|
32 |
+
"step": 100
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"epoch": 2.0,
|
36 |
+
"eval_loss": 0.0008016377687454224,
|
37 |
+
"eval_runtime": 8.629,
|
38 |
+
"eval_samples_per_second": 12.168,
|
39 |
+
"eval_steps_per_second": 0.811,
|
40 |
+
"step": 118
|
41 |
+
},
|
42 |
+
{
|
43 |
+
"epoch": 2.542372881355932,
|
44 |
+
"grad_norm": 0.007611678447574377,
|
45 |
+
"learning_rate": 3.796610169491526e-05,
|
46 |
+
"loss": 0.002,
|
47 |
+
"step": 150
|
48 |
+
},
|
49 |
+
{
|
50 |
+
"epoch": 3.0,
|
51 |
+
"eval_loss": 0.0004340429150033742,
|
52 |
+
"eval_runtime": 8.5685,
|
53 |
+
"eval_samples_per_second": 12.254,
|
54 |
+
"eval_steps_per_second": 0.817,
|
55 |
+
"step": 177
|
56 |
+
}
|
57 |
+
],
|
58 |
+
"logging_steps": 50,
|
59 |
+
"max_steps": 2950,
|
60 |
+
"num_input_tokens_seen": 0,
|
61 |
+
"num_train_epochs": 50,
|
62 |
+
"save_steps": 500,
|
63 |
+
"stateful_callbacks": {
|
64 |
+
"EarlyStoppingCallback": {
|
65 |
+
"args": {
|
66 |
+
"early_stopping_patience": 2,
|
67 |
+
"early_stopping_threshold": 0.0
|
68 |
+
},
|
69 |
+
"attributes": {
|
70 |
+
"early_stopping_patience_counter": 0
|
71 |
+
}
|
72 |
+
},
|
73 |
+
"TrainerControl": {
|
74 |
+
"args": {
|
75 |
+
"should_epoch_stop": false,
|
76 |
+
"should_evaluate": false,
|
77 |
+
"should_log": false,
|
78 |
+
"should_save": true,
|
79 |
+
"should_training_stop": false
|
80 |
+
},
|
81 |
+
"attributes": {}
|
82 |
+
}
|
83 |
+
},
|
84 |
+
"total_flos": 5570596939235328.0,
|
85 |
+
"train_batch_size": 16,
|
86 |
+
"trial_name": null,
|
87 |
+
"trial_params": null
|
88 |
+
}
|
fine-tuned-model-8/checkpoint-177/training_args.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b7619738b5d8a13f8ec004be1e0996b2e618022b4b9790c6f7f4d37b799ae929
|
3 |
+
size 5368
|
fine-tuned-model-8/config.json
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"LlamaForCausalLM"
|
4 |
+
],
|
5 |
+
"attention_bias": false,
|
6 |
+
"attention_dropout": 0.0,
|
7 |
+
"bos_token_id": 32013,
|
8 |
+
"eos_token_id": 32021,
|
9 |
+
"head_dim": 128,
|
10 |
+
"hidden_act": "silu",
|
11 |
+
"hidden_size": 2048,
|
12 |
+
"initializer_range": 0.02,
|
13 |
+
"intermediate_size": 5504,
|
14 |
+
"max_position_embeddings": 16384,
|
15 |
+
"mlp_bias": false,
|
16 |
+
"model_type": "llama",
|
17 |
+
"num_attention_heads": 16,
|
18 |
+
"num_hidden_layers": 24,
|
19 |
+
"num_key_value_heads": 16,
|
20 |
+
"pretraining_tp": 1,
|
21 |
+
"quantization_config": {
|
22 |
+
"_load_in_4bit": false,
|
23 |
+
"_load_in_8bit": true,
|
24 |
+
"bnb_4bit_compute_dtype": "float32",
|
25 |
+
"bnb_4bit_quant_storage": "uint8",
|
26 |
+
"bnb_4bit_quant_type": "fp4",
|
27 |
+
"bnb_4bit_use_double_quant": false,
|
28 |
+
"llm_int8_enable_fp32_cpu_offload": false,
|
29 |
+
"llm_int8_has_fp16_weight": false,
|
30 |
+
"llm_int8_skip_modules": null,
|
31 |
+
"llm_int8_threshold": 6.0,
|
32 |
+
"load_in_4bit": false,
|
33 |
+
"load_in_8bit": true,
|
34 |
+
"quant_method": "bitsandbytes"
|
35 |
+
},
|
36 |
+
"rms_norm_eps": 1e-06,
|
37 |
+
"rope_scaling": {
|
38 |
+
"factor": 4.0,
|
39 |
+
"rope_type": "linear",
|
40 |
+
"type": "linear"
|
41 |
+
},
|
42 |
+
"rope_theta": 100000,
|
43 |
+
"tie_word_embeddings": false,
|
44 |
+
"torch_dtype": "float16",
|
45 |
+
"transformers_version": "4.50.3",
|
46 |
+
"use_cache": true,
|
47 |
+
"vocab_size": 32023
|
48 |
+
}
|
fine-tuned-model-8/generation_config.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 32013,
|
4 |
+
"eos_token_id": 32021,
|
5 |
+
"pad_token_id": 32022,
|
6 |
+
"transformers_version": "4.50.3"
|
7 |
+
}
|
fine-tuned-model-8/model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:13d028af97e13326591129457f4c38fd971da14a5eab2122a3cf82f1bd9a912d
|
3 |
+
size 1478884408
|
fine-tuned-model-8/runs/Apr06_19-55-38_DESKTOP-SMJC97K/events.out.tfevents.1743994556.DESKTOP-SMJC97K.17072.0
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:980ae08da7bb26b49e9c9861055eb82f7f0bd0694738821d2d0ad898412470fc
|
3 |
+
size 5670
|
fine-tuned-model-8/runs/Apr06_20-04-45_DESKTOP-SMJC97K/events.out.tfevents.1743995090.DESKTOP-SMJC97K.17072.1
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d03013824733a4d1bd5dfd17a8205e6cffdbc789fa83a8c9ef310d7cd370f0ad
|
3 |
+
size 5670
|
fine-tuned-model-8/runs/Apr06_20-09-40_DESKTOP-SMJC97K/events.out.tfevents.1743995381.DESKTOP-SMJC97K.2292.0
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:243558a5322998d9a6c2965c1b2e3a1161f8448e3e15dd2ad14f631246b6d957
|
3 |
+
size 5670
|
fine-tuned-model-8/runs/Apr06_20-14-05_DESKTOP-SMJC97K/events.out.tfevents.1743995646.DESKTOP-SMJC97K.12712.0
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0121f77adbcdd7adb8bb8bfd3d398a5d24851db54b9decc21407058c6e700133
|
3 |
+
size 5670
|
fine-tuned-model-8/runs/Apr06_20-19-55_DESKTOP-SMJC97K/events.out.tfevents.1743995996.DESKTOP-SMJC97K.12928.0
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f7412d3337a42ef30ac28f6e853369e6aff37577a88c4fd70b961db9b02ed0c5
|
3 |
+
size 7098
|
fine-tuned-model-8/runs/Apr06_22-18-58_DESKTOP-SMJC97K/events.out.tfevents.1744003142.DESKTOP-SMJC97K.8492.0
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ff9cb1621aee5f7f87e71be74aeb3db25aacd1cd69a657d7ce7d04dee2ba5971
|
3 |
+
size 5669
|
fine-tuned-model-8/runs/Apr06_22-52-40_DESKTOP-SMJC97K/events.out.tfevents.1744005165.DESKTOP-SMJC97K.9844.0
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:412e8b4057e35895a8c72236fc3ef25e23a7455de2993519c23b1410026055ae
|
3 |
+
size 5667
|
fine-tuned-model-8/runs/Apr06_23-15-43_DESKTOP-SMJC97K/events.out.tfevents.1744006548.DESKTOP-SMJC97K.7572.0
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a401d20f24b9e5ad7ef27665cc262338ce87d9a550f6566acd4c8a1e8e4b1140
|
3 |
+
size 5668
|
fine-tuned-model-8/runs/Apr06_23-40-32_DESKTOP-SMJC97K/events.out.tfevents.1744008032.DESKTOP-SMJC97K.10676.0
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e2d817ccbebff16029612e1547f3a4a35ae5fc514d9152084f15a4607574c8ba
|
3 |
+
size 6826
|
fine-tuned-model-8/special_tokens_map.json
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"additional_special_tokens": [
|
3 |
+
{
|
4 |
+
"content": "<|endofsql|>",
|
5 |
+
"lstrip": false,
|
6 |
+
"normalized": false,
|
7 |
+
"rstrip": false,
|
8 |
+
"single_word": false
|
9 |
+
}
|
10 |
+
],
|
11 |
+
"bos_token": {
|
12 |
+
"content": "<|begin▁of▁sentence|>",
|
13 |
+
"lstrip": false,
|
14 |
+
"normalized": true,
|
15 |
+
"rstrip": false,
|
16 |
+
"single_word": false
|
17 |
+
},
|
18 |
+
"eos_token": "<|endofsql|>",
|
19 |
+
"pad_token": "<|endofsql|>"
|
20 |
+
}
|
fine-tuned-model-8/tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
fine-tuned-model-8/tokenizer_config.json
ADDED
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": true,
|
3 |
+
"add_eos_token": false,
|
4 |
+
"add_prefix_space": null,
|
5 |
+
"added_tokens_decoder": {
|
6 |
+
"32000": {
|
7 |
+
"content": "õ",
|
8 |
+
"lstrip": false,
|
9 |
+
"normalized": true,
|
10 |
+
"rstrip": false,
|
11 |
+
"single_word": false,
|
12 |
+
"special": false
|
13 |
+
},
|
14 |
+
"32001": {
|
15 |
+
"content": "÷",
|
16 |
+
"lstrip": false,
|
17 |
+
"normalized": true,
|
18 |
+
"rstrip": false,
|
19 |
+
"single_word": false,
|
20 |
+
"special": false
|
21 |
+
},
|
22 |
+
"32002": {
|
23 |
+
"content": "Á",
|
24 |
+
"lstrip": false,
|
25 |
+
"normalized": true,
|
26 |
+
"rstrip": false,
|
27 |
+
"single_word": false,
|
28 |
+
"special": false
|
29 |
+
},
|
30 |
+
"32003": {
|
31 |
+
"content": "ý",
|
32 |
+
"lstrip": false,
|
33 |
+
"normalized": true,
|
34 |
+
"rstrip": false,
|
35 |
+
"single_word": false,
|
36 |
+
"special": false
|
37 |
+
},
|
38 |
+
"32004": {
|
39 |
+
"content": "À",
|
40 |
+
"lstrip": false,
|
41 |
+
"normalized": true,
|
42 |
+
"rstrip": false,
|
43 |
+
"single_word": false,
|
44 |
+
"special": false
|
45 |
+
},
|
46 |
+
"32005": {
|
47 |
+
"content": "ÿ",
|
48 |
+
"lstrip": false,
|
49 |
+
"normalized": true,
|
50 |
+
"rstrip": false,
|
51 |
+
"single_word": false,
|
52 |
+
"special": false
|
53 |
+
},
|
54 |
+
"32006": {
|
55 |
+
"content": "ø",
|
56 |
+
"lstrip": false,
|
57 |
+
"normalized": true,
|
58 |
+
"rstrip": false,
|
59 |
+
"single_word": false,
|
60 |
+
"special": false
|
61 |
+
},
|
62 |
+
"32007": {
|
63 |
+
"content": "ú",
|
64 |
+
"lstrip": false,
|
65 |
+
"normalized": true,
|
66 |
+
"rstrip": false,
|
67 |
+
"single_word": false,
|
68 |
+
"special": false
|
69 |
+
},
|
70 |
+
"32008": {
|
71 |
+
"content": "þ",
|
72 |
+
"lstrip": false,
|
73 |
+
"normalized": true,
|
74 |
+
"rstrip": false,
|
75 |
+
"single_word": false,
|
76 |
+
"special": false
|
77 |
+
},
|
78 |
+
"32009": {
|
79 |
+
"content": "ü",
|
80 |
+
"lstrip": false,
|
81 |
+
"normalized": true,
|
82 |
+
"rstrip": false,
|
83 |
+
"single_word": false,
|
84 |
+
"special": false
|
85 |
+
},
|
86 |
+
"32010": {
|
87 |
+
"content": "ù",
|
88 |
+
"lstrip": false,
|
89 |
+
"normalized": true,
|
90 |
+
"rstrip": false,
|
91 |
+
"single_word": false,
|
92 |
+
"special": false
|
93 |
+
},
|
94 |
+
"32011": {
|
95 |
+
"content": "ö",
|
96 |
+
"lstrip": false,
|
97 |
+
"normalized": true,
|
98 |
+
"rstrip": false,
|
99 |
+
"single_word": false,
|
100 |
+
"special": false
|
101 |
+
},
|
102 |
+
"32012": {
|
103 |
+
"content": "û",
|
104 |
+
"lstrip": false,
|
105 |
+
"normalized": true,
|
106 |
+
"rstrip": false,
|
107 |
+
"single_word": false,
|
108 |
+
"special": false
|
109 |
+
},
|
110 |
+
"32013": {
|
111 |
+
"content": "<|begin▁of▁sentence|>",
|
112 |
+
"lstrip": false,
|
113 |
+
"normalized": true,
|
114 |
+
"rstrip": false,
|
115 |
+
"single_word": false,
|
116 |
+
"special": true
|
117 |
+
},
|
118 |
+
"32014": {
|
119 |
+
"content": "<|end▁of▁sentence|>",
|
120 |
+
"lstrip": false,
|
121 |
+
"normalized": true,
|
122 |
+
"rstrip": false,
|
123 |
+
"single_word": false,
|
124 |
+
"special": true
|
125 |
+
},
|
126 |
+
"32015": {
|
127 |
+
"content": "<|fim▁hole|>",
|
128 |
+
"lstrip": false,
|
129 |
+
"normalized": true,
|
130 |
+
"rstrip": false,
|
131 |
+
"single_word": false,
|
132 |
+
"special": false
|
133 |
+
},
|
134 |
+
"32016": {
|
135 |
+
"content": "<|fim▁begin|>",
|
136 |
+
"lstrip": false,
|
137 |
+
"normalized": true,
|
138 |
+
"rstrip": false,
|
139 |
+
"single_word": false,
|
140 |
+
"special": false
|
141 |
+
},
|
142 |
+
"32017": {
|
143 |
+
"content": "<|fim▁end|>",
|
144 |
+
"lstrip": false,
|
145 |
+
"normalized": true,
|
146 |
+
"rstrip": false,
|
147 |
+
"single_word": false,
|
148 |
+
"special": false
|
149 |
+
},
|
150 |
+
"32018": {
|
151 |
+
"content": "<pad>",
|
152 |
+
"lstrip": false,
|
153 |
+
"normalized": true,
|
154 |
+
"rstrip": false,
|
155 |
+
"single_word": false,
|
156 |
+
"special": false
|
157 |
+
},
|
158 |
+
"32019": {
|
159 |
+
"content": "<|User|>",
|
160 |
+
"lstrip": false,
|
161 |
+
"normalized": true,
|
162 |
+
"rstrip": false,
|
163 |
+
"single_word": false,
|
164 |
+
"special": false
|
165 |
+
},
|
166 |
+
"32020": {
|
167 |
+
"content": "<|Assistant|>",
|
168 |
+
"lstrip": false,
|
169 |
+
"normalized": true,
|
170 |
+
"rstrip": false,
|
171 |
+
"single_word": false,
|
172 |
+
"special": false
|
173 |
+
},
|
174 |
+
"32021": {
|
175 |
+
"content": "<|EOT|>",
|
176 |
+
"lstrip": false,
|
177 |
+
"normalized": true,
|
178 |
+
"rstrip": false,
|
179 |
+
"single_word": false,
|
180 |
+
"special": true
|
181 |
+
},
|
182 |
+
"32022": {
|
183 |
+
"content": "<|endofsql|>",
|
184 |
+
"lstrip": false,
|
185 |
+
"normalized": false,
|
186 |
+
"rstrip": false,
|
187 |
+
"single_word": false,
|
188 |
+
"special": true
|
189 |
+
}
|
190 |
+
},
|
191 |
+
"additional_special_tokens": [
|
192 |
+
"<|endofsql|>"
|
193 |
+
],
|
194 |
+
"bos_token": "<|begin▁of▁sentence|>",
|
195 |
+
"chat_template": "{% if not add_generation_prompt is defined %}\n{% set add_generation_prompt = false %}\n{% endif %}\n{%- set ns = namespace(found=false) -%}\n{%- for message in messages -%}\n {%- if message['role'] == 'system' -%}\n {%- set ns.found = true -%}\n {%- endif -%}\n{%- endfor -%}\n{{bos_token}}{%- if not ns.found -%}\n{{'You are an AI programming assistant, utilizing the Deepseek Coder model, developed by Deepseek Company, and you only answer questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer\\n'}}\n{%- endif %}\n{%- for message in messages %}\n {%- if message['role'] == 'system' %}\n{{ message['content'] }}\n {%- else %}\n {%- if message['role'] == 'user' %}\n{{'### Instruction:\\n' + message['content'] + '\\n'}}\n {%- else %}\n{{'### Response:\\n' + message['content'] + '\\n<|EOT|>\\n'}}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{% if add_generation_prompt %}\n{{'### Response:'}}\n{% endif %}",
|
196 |
+
"clean_up_tokenization_spaces": false,
|
197 |
+
"eos_token": "<|endofsql|>",
|
198 |
+
"extra_special_tokens": {},
|
199 |
+
"legacy": true,
|
200 |
+
"model_max_length": 16384,
|
201 |
+
"pad_token": "<|endofsql|>",
|
202 |
+
"sp_model_kwargs": {},
|
203 |
+
"tokenizer_class": "LlamaTokenizerFast",
|
204 |
+
"unk_token": null,
|
205 |
+
"use_default_system_prompt": false
|
206 |
+
}
|
finetune_model.ipynb
CHANGED
@@ -18,7 +18,15 @@
|
|
18 |
"cell_type": "code",
|
19 |
"execution_count": 1,
|
20 |
"metadata": {},
|
21 |
-
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
"source": [
|
23 |
"input_prompt = \"\"\"You are an AI assistant that converts natural language queries into valid SQLite queries.\n",
|
24 |
"Database Schema and Explanations\n",
|
@@ -198,7 +206,9 @@
|
|
198 |
"SELECT MAX(pts_home - pts_away) AS biggest_win FROM game WHERE team_name_home = 'Boston Celtics' AND season_id = '22008';\n",
|
199 |
"\n",
|
200 |
"Generate only the SQLite query prefaced by SQLite: and no other text, do not output an explanation of the query. Now generate an SQLite query for the following user request. Request:\n",
|
201 |
-
"\"\"\""
|
|
|
|
|
202 |
]
|
203 |
},
|
204 |
{
|
@@ -210,30 +220,14 @@
|
|
210 |
},
|
211 |
{
|
212 |
"cell_type": "code",
|
213 |
-
"execution_count":
|
214 |
"metadata": {},
|
215 |
"outputs": [
|
216 |
{
|
217 |
"name": "stderr",
|
218 |
"output_type": "stream",
|
219 |
"text": [
|
220 |
-
"
|
221 |
-
" from .autonotebook import tqdm as notebook_tqdm\n"
|
222 |
-
]
|
223 |
-
},
|
224 |
-
{
|
225 |
-
"name": "stdout",
|
226 |
-
"output_type": "stream",
|
227 |
-
"text": [
|
228 |
-
"WARNING:tensorflow:From c:\\Users\\Dean\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\tf_keras\\src\\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.\n",
|
229 |
-
"\n"
|
230 |
-
]
|
231 |
-
},
|
232 |
-
{
|
233 |
-
"name": "stderr",
|
234 |
-
"output_type": "stream",
|
235 |
-
"text": [
|
236 |
-
"C:\\Users\\Dean\\AppData\\Local\\Temp\\ipykernel_20424\\3615904657.py:13: FutureWarning: DataFrame.applymap has been deprecated. Use DataFrame.map instead.\n",
|
237 |
" df = df.applymap(lambda x: re.sub(r'\\s+', ' ', x) if isinstance(x, str) else x)\n"
|
238 |
]
|
239 |
},
|
@@ -254,397 +248,27 @@
|
|
254 |
"1 SELECT MAX(pts_home) FROM game WHERE team_name... 162 \n",
|
255 |
"2 SELECT pts_home FROM game WHERE team_name_home... 156 \n",
|
256 |
"3 SELECT COUNT(*) FROM game WHERE team_abbreviat... 29 \n",
|
257 |
-
"4 SELECT AVG(ast_home) FROM game WHERE team_abbr... 26.51355662 \n"
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
"output_type": "stream",
|
263 |
-
"text": [
|
264 |
-
"Map: 0%| | 0/1044 [00:00<?, ? examples/s]"
|
265 |
-
]
|
266 |
-
},
|
267 |
-
{
|
268 |
-
"name": "stdout",
|
269 |
-
"output_type": "stream",
|
270 |
-
"text": [
|
271 |
-
"You are an AI assistant that converts natural language queries into valid SQLite queries.\n",
|
272 |
-
"Database Schema and Explanations\n",
|
273 |
-
"\n",
|
274 |
-
"team Table\n",
|
275 |
-
"Stores information about NBA teams.\n",
|
276 |
-
"CREATE TABLE IF NOT EXISTS \"team\" (\n",
|
277 |
-
" \"id\" TEXT PRIMARY KEY, -- Unique identifier for the team\n",
|
278 |
-
" \"full_name\" TEXT, -- Full official name of the team (e.g., \"Los Angeles Lakers\")\n",
|
279 |
-
" \"abbreviation\" TEXT, -- Shortened team name (e.g., \"LAL\")\n",
|
280 |
-
" \"nickname\" TEXT, -- Commonly used nickname for the team (e.g., \"Lakers\")\n",
|
281 |
-
" \"city\" TEXT, -- City where the team is based\n",
|
282 |
-
" \"state\" TEXT, -- State where the team is located\n",
|
283 |
-
" \"year_founded\" REAL -- Year the team was established\n",
|
284 |
-
");\n",
|
285 |
-
"\n",
|
286 |
-
"game Table\n",
|
287 |
-
"Contains detailed statistics for each NBA game, including home and away team performance.\n",
|
288 |
-
"CREATE TABLE IF NOT EXISTS \"game\" (\n",
|
289 |
-
" \"season_id\" TEXT, -- Season identifier, formatted as \"2YYYY\" (e.g., \"21970\" for the 1970 season)\n",
|
290 |
-
" \"team_id_home\" TEXT, -- ID of the home team (matches \"id\" in team table)\n",
|
291 |
-
" \"team_abbreviation_home\" TEXT, -- Abbreviation of the home team\n",
|
292 |
-
" \"team_name_home\" TEXT, -- Full name of the home team\n",
|
293 |
-
" \"game_id\" TEXT PRIMARY KEY, -- Unique identifier for the game\n",
|
294 |
-
" \"game_date\" TIMESTAMP, -- Date the game was played (YYYY-MM-DD format)\n",
|
295 |
-
" \"matchup_home\" TEXT, -- Matchup details including opponent (e.g., \"LAL vs. BOS\")\n",
|
296 |
-
" \"wl_home\" TEXT, -- \"W\" if the home team won, \"L\" if they lost\n",
|
297 |
-
" \"min\" INTEGER, -- Total minutes played in the game\n",
|
298 |
-
" \"fgm_home\" REAL, -- Field goals made by the home team\n",
|
299 |
-
" \"fga_home\" REAL, -- Field goals attempted by the home team\n",
|
300 |
-
" \"fg_pct_home\" REAL, -- Field goal percentage of the home team\n",
|
301 |
-
" \"fg3m_home\" REAL, -- Three-point field goals made by the home team\n",
|
302 |
-
" \"fg3a_home\" REAL, -- Three-point attempts by the home team\n",
|
303 |
-
" \"fg3_pct_home\" REAL, -- Three-point field goal percentage of the home team\n",
|
304 |
-
" \"ftm_home\" REAL, -- Free throws made by the home team\n",
|
305 |
-
" \"fta_home\" REAL, -- Free throws attempted by the home team\n",
|
306 |
-
" \"ft_pct_home\" REAL, -- Free throw percentage of the home team\n",
|
307 |
-
" \"oreb_home\" REAL, -- Offensive rebounds by the home team\n",
|
308 |
-
" \"dreb_home\" REAL, -- Defensive rebounds by the home team\n",
|
309 |
-
" \"reb_home\" REAL, -- Total rebounds by the home team\n",
|
310 |
-
" \"ast_home\" REAL, -- Assists by the home team\n",
|
311 |
-
" \"stl_home\" REAL, -- Steals by the home team\n",
|
312 |
-
" \"blk_home\" REAL, -- Blocks by the home team\n",
|
313 |
-
" \"tov_home\" REAL, -- Turnovers by the home team\n",
|
314 |
-
" \"pf_home\" REAL, -- Personal fouls by the home team\n",
|
315 |
-
" \"pts_home\" REAL, -- Total points scored by the home team\n",
|
316 |
-
" \"plus_minus_home\" INTEGER, -- Plus/minus rating for the home team\n",
|
317 |
-
" \"video_available_home\" INTEGER, -- Indicates whether video is available (1 = Yes, 0 = No)\n",
|
318 |
-
" \"team_id_away\" TEXT, -- ID of the away team\n",
|
319 |
-
" \"team_abbreviation_away\" TEXT, -- Abbreviation of the away team\n",
|
320 |
-
" \"team_name_away\" TEXT, -- Full name of the away team\n",
|
321 |
-
" \"matchup_away\" TEXT, -- Matchup details from the away team’s perspective\n",
|
322 |
-
" \"wl_away\" TEXT, -- \"W\" if the away team won, \"L\" if they lost\n",
|
323 |
-
" \"fgm_away\" REAL, -- Field goals made by the away team\n",
|
324 |
-
" \"fga_away\" REAL, -- Field goals attempted by the away team\n",
|
325 |
-
" \"fg_pct_away\" REAL, -- Field goal percentage of the away team\n",
|
326 |
-
" \"fg3m_away\" REAL, -- Three-point field goals made by the away team\n",
|
327 |
-
" \"fg3a_away\" REAL, -- Three-point attempts by the away team\n",
|
328 |
-
" \"fg3_pct_away\" REAL, -- Three-point field goal percentage of the away team\n",
|
329 |
-
" \"ftm_away\" REAL, -- Free throws made by the away team\n",
|
330 |
-
" \"fta_away\" REAL, -- Free throws attempted by the away team\n",
|
331 |
-
" \"ft_pct_away\" REAL, -- Free throw percentage of the away team\n",
|
332 |
-
" \"oreb_away\" REAL, -- Offensive rebounds by the away team\n",
|
333 |
-
" \"dreb_away\" REAL, -- Defensive rebounds by the away team\n",
|
334 |
-
" \"reb_away\" REAL, -- Total rebounds by the away team\n",
|
335 |
-
" \"ast_away\" REAL, -- Assists by the away team\n",
|
336 |
-
" \"stl_away\" REAL, -- Steals by the away team\n",
|
337 |
-
" \"blk_away\" REAL, -- Blocks by the away team\n",
|
338 |
-
" \"tov_away\" REAL, -- Turnovers by the away team\n",
|
339 |
-
" \"pf_away\" REAL, -- Personal fouls by the away team\n",
|
340 |
-
" \"pts_away\" REAL, -- Total points scored by the away team\n",
|
341 |
-
" \"plus_minus_away\" INTEGER, -- Plus/minus rating for the away team\n",
|
342 |
-
" \"video_available_away\" INTEGER, -- Indicates whether video is available (1 = Yes, 0 = No)\n",
|
343 |
-
" \"season_type\" TEXT -- Regular season or playoffs\n",
|
344 |
-
");\n",
|
345 |
-
"\n",
|
346 |
-
"other_stats Table\n",
|
347 |
-
"Stores additional statistics, linked to the game table via game_id.\n",
|
348 |
-
"CREATE TABLE IF NOT EXISTS \"other_stats\" (\n",
|
349 |
-
" \"game_id\" TEXT, -- Unique game identifier, matches id column from game table\n",
|
350 |
-
" \"league_id\" TEXT, -- League identifier\n",
|
351 |
-
" \"team_id_home\" TEXT, -- Home team identifier\n",
|
352 |
-
" \"team_abbreviation_home\" TEXT, -- Home team abbreviation\n",
|
353 |
-
" \"team_city_home\" TEXT, -- Home team city\n",
|
354 |
-
" \"pts_paint_home\" INTEGER, -- Points in the paint by the home team\n",
|
355 |
-
" \"pts_2nd_chance_home\" INTEGER, -- Second chance points by the home team\n",
|
356 |
-
" \"pts_fb_home\" INTEGER, -- Fast break points by the home team\n",
|
357 |
-
" \"largest_lead_home\" INTEGER,-- Largest lead by the home team\n",
|
358 |
-
" \"lead_changes\" INTEGER, -- Number of lead changes \n",
|
359 |
-
" \"times_tied\" INTEGER, -- Number of times the score was tied\n",
|
360 |
-
" \"team_turnovers_home\" INTEGER, -- Home team turnovers\n",
|
361 |
-
" \"total_turnovers_home\" INTEGER, -- Total turnovers by the home team\n",
|
362 |
-
" \"team_rebounds_home\" INTEGER, -- Home team rebounds\n",
|
363 |
-
" \"pts_off_to_home\" INTEGER, -- Points off turnovers by the home team\n",
|
364 |
-
" \"team_id_away\" TEXT, -- Away team identifier\n",
|
365 |
-
" \"team_abbreviation_away\" TEXT, -- Away team abbreviation\n",
|
366 |
-
" \"pts_paint_away\" INTEGER, -- Points in the paint by the away team\n",
|
367 |
-
" \"pts_2nd_chance_away\" INTEGER, -- Second chance points by the away team\n",
|
368 |
-
" \"pts_fb_away\" INTEGER, -- Fast break points by the away team\n",
|
369 |
-
" \"largest_lead_away\" INTEGER,-- Largest lead by the away team\n",
|
370 |
-
" \"team_turnovers_away\" INTEGER, -- Away team turnovers\n",
|
371 |
-
" \"total_turnovers_away\" INTEGER, -- Total turnovers by the away team\n",
|
372 |
-
" \"team_rebounds_away\" INTEGER, -- Away team rebounds\n",
|
373 |
-
" \"pts_off_to_away\" INTEGER -- Points off turnovers by the away team\n",
|
374 |
-
");\n",
|
375 |
-
"\n",
|
376 |
-
"\n",
|
377 |
-
"Team Name Information\n",
|
378 |
-
"In the plaintext user questions, only the full team names will be used, but in the queries you may use the full team names or the abbreviations. \n",
|
379 |
-
"The full team names can be used with the game table, while the abbreviations should be used with the other_stats table.\n",
|
380 |
-
"Notice they are separated by the | character in the following list:\n",
|
381 |
-
"\n",
|
382 |
-
"Atlanta Hawks|ATL\n",
|
383 |
-
"Boston Celtics|BOS\n",
|
384 |
-
"Cleveland Cavaliers|CLE\n",
|
385 |
-
"New Orleans Pelicans|NOP\n",
|
386 |
-
"Chicago Bulls|CHI\n",
|
387 |
-
"Dallas Mavericks|DAL\n",
|
388 |
-
"Denver Nuggets|DEN\n",
|
389 |
-
"Golden State Warriors|GSW\n",
|
390 |
-
"Houston Rockets|HOU\n",
|
391 |
-
"Los Angeles Clippers|LAC\n",
|
392 |
-
"Los Angeles Lakers|LAL\n",
|
393 |
-
"Miami Heat|MIA\n",
|
394 |
-
"Milwaukee Bucks|MIL\n",
|
395 |
-
"Minnesota Timberwolves|MIN\n",
|
396 |
-
"Brooklyn Nets|BKN\n",
|
397 |
-
"New York Knicks|NYK\n",
|
398 |
-
"Orlando Magic|ORL\n",
|
399 |
-
"Indiana Pacers|IND\n",
|
400 |
-
"Philadelphia 76ers|PHI\n",
|
401 |
-
"Phoenix Suns|PHX\n",
|
402 |
-
"Portland Trail Blazers|POR\n",
|
403 |
-
"Sacramento Kings|SAC\n",
|
404 |
-
"San Antonio Spurs|SAS\n",
|
405 |
-
"Oklahoma City Thunder|OKC\n",
|
406 |
-
"Toronto Raptors|TOR\n",
|
407 |
-
"Utah Jazz|UTA\n",
|
408 |
-
"Memphis Grizzlies|MEM\n",
|
409 |
-
"Washington Wizards|WAS\n",
|
410 |
-
"Detroit Pistons|DET\n",
|
411 |
-
"Charlotte Hornets|CHA\n",
|
412 |
-
"\n",
|
413 |
-
"Query Guidelines\n",
|
414 |
-
"Use team_name_home and team_name_away to match teams to the game table. Use team_abbreviation_home and team_abbreviation away to match teams to the other_stats table.\n",
|
415 |
-
"\n",
|
416 |
-
"To filter by season, use season_id = '2YYYY'.\n",
|
417 |
-
"\n",
|
418 |
-
"Example: To get statistics from 2005, use a statement like: season_id = '22005'. To get statistics from 1972, use a statement like: season_id = \"21972\". To get statistics from 2015, use a statement like: season_id = \"22015\".\n",
|
419 |
-
"\n",
|
420 |
-
"Ensure queries return relevant columns and avoid unnecessary joins.\n",
|
421 |
-
"\n",
|
422 |
-
"Example User Requests and SQLite Queries\n",
|
423 |
-
"Request:\n",
|
424 |
-
"\"What is the most points the Los Angeles Lakers have ever scored at home?\"\n",
|
425 |
-
"SQLite:\n",
|
426 |
-
"SELECT MAX(pts_home) FROM game WHERE team_name_home = 'Los Angeles Lakers';\n",
|
427 |
-
"\n",
|
428 |
-
"Request:\n",
|
429 |
-
"\"Which teams are located in the state of California?\"\n",
|
430 |
-
"SQLite:\n",
|
431 |
-
"SELECT full_name FROM team WHERE state = 'California';\n",
|
432 |
-
"\n",
|
433 |
-
"Request:\n",
|
434 |
-
"\"Which team had the highest number of team turnovers in an away game?\"\n",
|
435 |
-
"SQLite:\n",
|
436 |
-
"SELECT team_abbreviation_away FROM other_stats ORDER BY team_turnovers_away DESC LIMIT 1;\n",
|
437 |
-
"\n",
|
438 |
-
"Request:\n",
|
439 |
-
"\"Which teams were founded before 1979?\"\n",
|
440 |
-
"SQLite:\n",
|
441 |
-
"SELECT full_name FROM team WHERE year_founded < 1979;\n",
|
442 |
-
"\n",
|
443 |
-
"Request:\n",
|
444 |
-
"\"Find the Boston Celtics largest home victory margin in the 2008 season.\"\n",
|
445 |
-
"SQLite:\n",
|
446 |
-
"SELECT MAX(pts_home - pts_away) AS biggest_win FROM game WHERE team_name_home = 'Boston Celtics' AND season_id = '22008';\n",
|
447 |
-
"\n",
|
448 |
-
"Generate only the SQLite query prefaced by SQLite: and no other text, do not output an explanation of the query. Now generate an SQLite query for the following user request. Request:\n",
|
449 |
-
"Which NBA teams were established after the year 2000? List their names and founding years, sorted from newest to oldest\n",
|
450 |
-
"SQLite: \n",
|
451 |
-
"SELECT full_name FROM team WHERE year_founded > 2000 ORDER BY year_founded DESC;\n"
|
452 |
]
|
453 |
},
|
454 |
{
|
455 |
"name": "stderr",
|
456 |
"output_type": "stream",
|
457 |
"text": [
|
458 |
-
"Map: 100%|██████████| 1044/1044 [
|
459 |
]
|
460 |
},
|
461 |
{
|
462 |
"name": "stdout",
|
463 |
"output_type": "stream",
|
464 |
"text": [
|
465 |
-
"You are an AI assistant that converts natural language queries into valid SQLite queries.\n",
|
466 |
-
"Database Schema and Explanations\n",
|
467 |
-
"\n",
|
468 |
-
"team Table\n",
|
469 |
-
"Stores information about NBA teams.\n",
|
470 |
-
"CREATE TABLE IF NOT EXISTS \"team\" (\n",
|
471 |
-
" \"id\" TEXT PRIMARY KEY, -- Unique identifier for the team\n",
|
472 |
-
" \"full_name\" TEXT, -- Full official name of the team (e.g., \"Los Angeles Lakers\")\n",
|
473 |
-
" \"abbreviation\" TEXT, -- Shortened team name (e.g., \"LAL\")\n",
|
474 |
-
" \"nickname\" TEXT, -- Commonly used nickname for the team (e.g., \"Lakers\")\n",
|
475 |
-
" \"city\" TEXT, -- City where the team is based\n",
|
476 |
-
" \"state\" TEXT, -- State where the team is located\n",
|
477 |
-
" \"year_founded\" REAL -- Year the team was established\n",
|
478 |
-
");\n",
|
479 |
-
"\n",
|
480 |
-
"game Table\n",
|
481 |
-
"Contains detailed statistics for each NBA game, including home and away team performance.\n",
|
482 |
-
"CREATE TABLE IF NOT EXISTS \"game\" (\n",
|
483 |
-
" \"season_id\" TEXT, -- Season identifier, formatted as \"2YYYY\" (e.g., \"21970\" for the 1970 season)\n",
|
484 |
-
" \"team_id_home\" TEXT, -- ID of the home team (matches \"id\" in team table)\n",
|
485 |
-
" \"team_abbreviation_home\" TEXT, -- Abbreviation of the home team\n",
|
486 |
-
" \"team_name_home\" TEXT, -- Full name of the home team\n",
|
487 |
-
" \"game_id\" TEXT PRIMARY KEY, -- Unique identifier for the game\n",
|
488 |
-
" \"game_date\" TIMESTAMP, -- Date the game was played (YYYY-MM-DD format)\n",
|
489 |
-
" \"matchup_home\" TEXT, -- Matchup details including opponent (e.g., \"LAL vs. BOS\")\n",
|
490 |
-
" \"wl_home\" TEXT, -- \"W\" if the home team won, \"L\" if they lost\n",
|
491 |
-
" \"min\" INTEGER, -- Total minutes played in the game\n",
|
492 |
-
" \"fgm_home\" REAL, -- Field goals made by the home team\n",
|
493 |
-
" \"fga_home\" REAL, -- Field goals attempted by the home team\n",
|
494 |
-
" \"fg_pct_home\" REAL, -- Field goal percentage of the home team\n",
|
495 |
-
" \"fg3m_home\" REAL, -- Three-point field goals made by the home team\n",
|
496 |
-
" \"fg3a_home\" REAL, -- Three-point attempts by the home team\n",
|
497 |
-
" \"fg3_pct_home\" REAL, -- Three-point field goal percentage of the home team\n",
|
498 |
-
" \"ftm_home\" REAL, -- Free throws made by the home team\n",
|
499 |
-
" \"fta_home\" REAL, -- Free throws attempted by the home team\n",
|
500 |
-
" \"ft_pct_home\" REAL, -- Free throw percentage of the home team\n",
|
501 |
-
" \"oreb_home\" REAL, -- Offensive rebounds by the home team\n",
|
502 |
-
" \"dreb_home\" REAL, -- Defensive rebounds by the home team\n",
|
503 |
-
" \"reb_home\" REAL, -- Total rebounds by the home team\n",
|
504 |
-
" \"ast_home\" REAL, -- Assists by the home team\n",
|
505 |
-
" \"stl_home\" REAL, -- Steals by the home team\n",
|
506 |
-
" \"blk_home\" REAL, -- Blocks by the home team\n",
|
507 |
-
" \"tov_home\" REAL, -- Turnovers by the home team\n",
|
508 |
-
" \"pf_home\" REAL, -- Personal fouls by the home team\n",
|
509 |
-
" \"pts_home\" REAL, -- Total points scored by the home team\n",
|
510 |
-
" \"plus_minus_home\" INTEGER, -- Plus/minus rating for the home team\n",
|
511 |
-
" \"video_available_home\" INTEGER, -- Indicates whether video is available (1 = Yes, 0 = No)\n",
|
512 |
-
" \"team_id_away\" TEXT, -- ID of the away team\n",
|
513 |
-
" \"team_abbreviation_away\" TEXT, -- Abbreviation of the away team\n",
|
514 |
-
" \"team_name_away\" TEXT, -- Full name of the away team\n",
|
515 |
-
" \"matchup_away\" TEXT, -- Matchup details from the away team’s perspective\n",
|
516 |
-
" \"wl_away\" TEXT, -- \"W\" if the away team won, \"L\" if they lost\n",
|
517 |
-
" \"fgm_away\" REAL, -- Field goals made by the away team\n",
|
518 |
-
" \"fga_away\" REAL, -- Field goals attempted by the away team\n",
|
519 |
-
" \"fg_pct_away\" REAL, -- Field goal percentage of the away team\n",
|
520 |
-
" \"fg3m_away\" REAL, -- Three-point field goals made by the away team\n",
|
521 |
-
" \"fg3a_away\" REAL, -- Three-point attempts by the away team\n",
|
522 |
-
" \"fg3_pct_away\" REAL, -- Three-point field goal percentage of the away team\n",
|
523 |
-
" \"ftm_away\" REAL, -- Free throws made by the away team\n",
|
524 |
-
" \"fta_away\" REAL, -- Free throws attempted by the away team\n",
|
525 |
-
" \"ft_pct_away\" REAL, -- Free throw percentage of the away team\n",
|
526 |
-
" \"oreb_away\" REAL, -- Offensive rebounds by the away team\n",
|
527 |
-
" \"dreb_away\" REAL, -- Defensive rebounds by the away team\n",
|
528 |
-
" \"reb_away\" REAL, -- Total rebounds by the away team\n",
|
529 |
-
" \"ast_away\" REAL, -- Assists by the away team\n",
|
530 |
-
" \"stl_away\" REAL, -- Steals by the away team\n",
|
531 |
-
" \"blk_away\" REAL, -- Blocks by the away team\n",
|
532 |
-
" \"tov_away\" REAL, -- Turnovers by the away team\n",
|
533 |
-
" \"pf_away\" REAL, -- Personal fouls by the away team\n",
|
534 |
-
" \"pts_away\" REAL, -- Total points scored by the away team\n",
|
535 |
-
" \"plus_minus_away\" INTEGER, -- Plus/minus rating for the away team\n",
|
536 |
-
" \"video_available_away\" INTEGER, -- Indicates whether video is available (1 = Yes, 0 = No)\n",
|
537 |
-
" \"season_type\" TEXT -- Regular season or playoffs\n",
|
538 |
-
");\n",
|
539 |
-
"\n",
|
540 |
-
"other_stats Table\n",
|
541 |
-
"Stores additional statistics, linked to the game table via game_id.\n",
|
542 |
-
"CREATE TABLE IF NOT EXISTS \"other_stats\" (\n",
|
543 |
-
" \"game_id\" TEXT, -- Unique game identifier, matches id column from game table\n",
|
544 |
-
" \"league_id\" TEXT, -- League identifier\n",
|
545 |
-
" \"team_id_home\" TEXT, -- Home team identifier\n",
|
546 |
-
" \"team_abbreviation_home\" TEXT, -- Home team abbreviation\n",
|
547 |
-
" \"team_city_home\" TEXT, -- Home team city\n",
|
548 |
-
" \"pts_paint_home\" INTEGER, -- Points in the paint by the home team\n",
|
549 |
-
" \"pts_2nd_chance_home\" INTEGER, -- Second chance points by the home team\n",
|
550 |
-
" \"pts_fb_home\" INTEGER, -- Fast break points by the home team\n",
|
551 |
-
" \"largest_lead_home\" INTEGER,-- Largest lead by the home team\n",
|
552 |
-
" \"lead_changes\" INTEGER, -- Number of lead changes \n",
|
553 |
-
" \"times_tied\" INTEGER, -- Number of times the score was tied\n",
|
554 |
-
" \"team_turnovers_home\" INTEGER, -- Home team turnovers\n",
|
555 |
-
" \"total_turnovers_home\" INTEGER, -- Total turnovers by the home team\n",
|
556 |
-
" \"team_rebounds_home\" INTEGER, -- Home team rebounds\n",
|
557 |
-
" \"pts_off_to_home\" INTEGER, -- Points off turnovers by the home team\n",
|
558 |
-
" \"team_id_away\" TEXT, -- Away team identifier\n",
|
559 |
-
" \"team_abbreviation_away\" TEXT, -- Away team abbreviation\n",
|
560 |
-
" \"pts_paint_away\" INTEGER, -- Points in the paint by the away team\n",
|
561 |
-
" \"pts_2nd_chance_away\" INTEGER, -- Second chance points by the away team\n",
|
562 |
-
" \"pts_fb_away\" INTEGER, -- Fast break points by the away team\n",
|
563 |
-
" \"largest_lead_away\" INTEGER,-- Largest lead by the away team\n",
|
564 |
-
" \"team_turnovers_away\" INTEGER, -- Away team turnovers\n",
|
565 |
-
" \"total_turnovers_away\" INTEGER, -- Total turnovers by the away team\n",
|
566 |
-
" \"team_rebounds_away\" INTEGER, -- Away team rebounds\n",
|
567 |
-
" \"pts_off_to_away\" INTEGER -- Points off turnovers by the away team\n",
|
568 |
-
");\n",
|
569 |
-
"\n",
|
570 |
-
"\n",
|
571 |
-
"Team Name Information\n",
|
572 |
-
"In the plaintext user questions, only the full team names will be used, but in the queries you may use the full team names or the abbreviations. \n",
|
573 |
-
"The full team names can be used with the game table, while the abbreviations should be used with the other_stats table.\n",
|
574 |
-
"Notice they are separated by the | character in the following list:\n",
|
575 |
-
"\n",
|
576 |
-
"Atlanta Hawks|ATL\n",
|
577 |
-
"Boston Celtics|BOS\n",
|
578 |
-
"Cleveland Cavaliers|CLE\n",
|
579 |
-
"New Orleans Pelicans|NOP\n",
|
580 |
-
"Chicago Bulls|CHI\n",
|
581 |
-
"Dallas Mavericks|DAL\n",
|
582 |
-
"Denver Nuggets|DEN\n",
|
583 |
-
"Golden State Warriors|GSW\n",
|
584 |
-
"Houston Rockets|HOU\n",
|
585 |
-
"Los Angeles Clippers|LAC\n",
|
586 |
-
"Los Angeles Lakers|LAL\n",
|
587 |
-
"Miami Heat|MIA\n",
|
588 |
-
"Milwaukee Bucks|MIL\n",
|
589 |
-
"Minnesota Timberwolves|MIN\n",
|
590 |
-
"Brooklyn Nets|BKN\n",
|
591 |
-
"New York Knicks|NYK\n",
|
592 |
-
"Orlando Magic|ORL\n",
|
593 |
-
"Indiana Pacers|IND\n",
|
594 |
-
"Philadelphia 76ers|PHI\n",
|
595 |
-
"Phoenix Suns|PHX\n",
|
596 |
-
"Portland Trail Blazers|POR\n",
|
597 |
-
"Sacramento Kings|SAC\n",
|
598 |
-
"San Antonio Spurs|SAS\n",
|
599 |
-
"Oklahoma City Thunder|OKC\n",
|
600 |
-
"Toronto Raptors|TOR\n",
|
601 |
-
"Utah Jazz|UTA\n",
|
602 |
-
"Memphis Grizzlies|MEM\n",
|
603 |
-
"Washington Wizards|WAS\n",
|
604 |
-
"Detroit Pistons|DET\n",
|
605 |
-
"Charlotte Hornets|CHA\n",
|
606 |
-
"\n",
|
607 |
-
"Query Guidelines\n",
|
608 |
-
"Use team_name_home and team_name_away to match teams to the game table. Use team_abbreviation_home and team_abbreviation away to match teams to the other_stats table.\n",
|
609 |
-
"\n",
|
610 |
-
"To filter by season, use season_id = '2YYYY'.\n",
|
611 |
-
"\n",
|
612 |
-
"Example: To get statistics from 2005, use a statement like: season_id = '22005'. To get statistics from 1972, use a statement like: season_id = \"21972\". To get statistics from 2015, use a statement like: season_id = \"22015\".\n",
|
613 |
-
"\n",
|
614 |
-
"Ensure queries return relevant columns and avoid unnecessary joins.\n",
|
615 |
-
"\n",
|
616 |
-
"Example User Requests and SQLite Queries\n",
|
617 |
-
"Request:\n",
|
618 |
-
"\"What is the most points the Los Angeles Lakers have ever scored at home?\"\n",
|
619 |
-
"SQLite:\n",
|
620 |
-
"SELECT MAX(pts_home) FROM game WHERE team_name_home = 'Los Angeles Lakers';\n",
|
621 |
-
"\n",
|
622 |
-
"Request:\n",
|
623 |
-
"\"Which teams are located in the state of California?\"\n",
|
624 |
-
"SQLite:\n",
|
625 |
-
"SELECT full_name FROM team WHERE state = 'California';\n",
|
626 |
-
"\n",
|
627 |
-
"Request:\n",
|
628 |
-
"\"Which team had the highest number of team turnovers in an away game?\"\n",
|
629 |
-
"SQLite:\n",
|
630 |
-
"SELECT team_abbreviation_away FROM other_stats ORDER BY team_turnovers_away DESC LIMIT 1;\n",
|
631 |
-
"\n",
|
632 |
-
"Request:\n",
|
633 |
-
"\"Which teams were founded before 1979?\"\n",
|
634 |
-
"SQLite:\n",
|
635 |
-
"SELECT full_name FROM team WHERE year_founded < 1979;\n",
|
636 |
-
"\n",
|
637 |
-
"Request:\n",
|
638 |
-
"\"Find the Boston Celtics largest home victory margin in the 2008 season.\"\n",
|
639 |
-
"SQLite:\n",
|
640 |
-
"SELECT MAX(pts_home - pts_away) AS biggest_win FROM game WHERE team_name_home = 'Boston Celtics' AND season_id = '22008';\n",
|
641 |
-
"\n",
|
642 |
-
"Generate only the SQLite query prefaced by SQLite: and no other text, do not output an explanation of the query. Now generate an SQLite query for the following user request. Request:\n",
|
643 |
-
"How many points did the Golden State Warriors score in their first game of the 2005 season?\n",
|
644 |
-
"SQLite: \n",
|
645 |
-
"SELECT pts_home FROM game WHERE team_abbreviation_home = 'GSW' AND season_id = '22005' ORDER BY game_date ASC LIMIT 1;\n",
|
646 |
"939\n",
|
647 |
-
"105\n"
|
|
|
648 |
]
|
649 |
},
|
650 |
{
|
@@ -659,11 +283,12 @@
|
|
659 |
"import pandas as pd\n",
|
660 |
"import torch\n",
|
661 |
"from datasets import Dataset\n",
|
662 |
-
"from transformers import AutoTokenizer, AutoModelForCausalLM, TrainingArguments, Trainer, BitsAndBytesConfig, EarlyStoppingCallback\n",
|
663 |
"from torch.utils.data import DataLoader\n",
|
664 |
"from peft import LoraConfig, get_peft_model, TaskType\n",
|
665 |
"import os\n",
|
666 |
"import re\n",
|
|
|
667 |
"\n",
|
668 |
"# Load dataset\n",
|
669 |
"df = pd.read_csv(\"./train-data/sql_train.tsv\", sep='\\t')\n",
|
@@ -678,23 +303,91 @@
|
|
678 |
"model_name = \"./deepseek-coder-1.3b-instruct\"\n",
|
679 |
"tokenizer = AutoTokenizer.from_pretrained(model_name)\n",
|
680 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
681 |
"# Preprocessing function\n",
|
682 |
"def preprocess_function(examples):\n",
|
683 |
" \"\"\"\n",
|
684 |
-
" Tokenizes
|
|
|
685 |
" \"\"\"\n",
|
686 |
-
"
|
687 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
688 |
"\n",
|
689 |
-
"
|
690 |
-
"
|
691 |
"\n",
|
692 |
-
"
|
693 |
-
"
|
694 |
"\n",
|
695 |
-
"
|
696 |
-
"
|
|
|
697 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
698 |
"# Convert to Hugging Face Dataset\n",
|
699 |
"dataset = Dataset.from_pandas(df)\n",
|
700 |
"\n",
|
@@ -707,7 +400,11 @@
|
|
707 |
"val_dataset = tokenized_dataset.select(range(split, len(tokenized_dataset)))\n",
|
708 |
"\n",
|
709 |
"print(len(train_dataset))\n",
|
710 |
-
"print(len(val_dataset))"
|
|
|
|
|
|
|
|
|
711 |
]
|
712 |
},
|
713 |
{
|
@@ -719,47 +416,33 @@
|
|
719 |
},
|
720 |
{
|
721 |
"cell_type": "code",
|
722 |
-
"execution_count":
|
723 |
"metadata": {},
|
724 |
"outputs": [
|
725 |
{
|
726 |
"name": "stdout",
|
727 |
"output_type": "stream",
|
728 |
"text": [
|
729 |
-
"trainable params:
|
730 |
]
|
731 |
}
|
732 |
],
|
733 |
"source": [
|
734 |
-
"# Enable 8-bit quantization for lower memory usage\n",
|
735 |
-
"bnb_config = BitsAndBytesConfig(\n",
|
736 |
-
" load_in_8bit=True, \n",
|
737 |
-
" bnb_8bit_compute_dtype=torch.float16\n",
|
738 |
-
")\n",
|
739 |
-
"\n",
|
740 |
-
"# Load model with quantization\n",
|
741 |
-
"#device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
|
742 |
-
"device_name = 'cuda:0' if torch.cuda.is_available() else 'cpu'\n",
|
743 |
-
"device = torch.device(device_name)\n",
|
744 |
-
"model = AutoModelForCausalLM.from_pretrained(\n",
|
745 |
-
" model_name, \n",
|
746 |
-
" quantization_config=bnb_config,\n",
|
747 |
-
" device_map=device\n",
|
748 |
-
")\n",
|
749 |
-
"model.generation_config.pad_token_id = tokenizer.pad_token_id\n",
|
750 |
-
"\n",
|
751 |
"# Define LoRA configuration\n",
|
752 |
"lora_config = LoraConfig(\n",
|
753 |
-
" r=
|
754 |
-
" lora_alpha=
|
755 |
-
" lora_dropout=0.
|
756 |
" bias=\"none\",\n",
|
757 |
" task_type=TaskType.CAUSAL_LM,\n",
|
758 |
" target_modules=[\n",
|
759 |
" \"q_proj\",\n",
|
760 |
" \"k_proj\",\n",
|
761 |
" \"v_proj\",\n",
|
762 |
-
" \"o_proj\"
|
|
|
|
|
|
|
763 |
" ]\n",
|
764 |
")\n",
|
765 |
"\n",
|
@@ -778,7 +461,7 @@
|
|
778 |
},
|
779 |
{
|
780 |
"cell_type": "code",
|
781 |
-
"execution_count":
|
782 |
"metadata": {},
|
783 |
"outputs": [
|
784 |
{
|
@@ -787,7 +470,7 @@
|
|
787 |
"text": [
|
788 |
"c:\\Users\\Dean\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\transformers\\training_args.py:1611: FutureWarning: `evaluation_strategy` is deprecated and will be removed in version 4.46 of 🤗 Transformers. Use `eval_strategy` instead\n",
|
789 |
" warnings.warn(\n",
|
790 |
-
"C:\\Users\\Dean\\AppData\\Local\\Temp\\
|
791 |
" trainer = Trainer(\n",
|
792 |
"No label_names provided for model class `PeftModelForCausalLM`. Since `PeftModel` hides base models input arguments, if label_names is not given, label_names can't be set automatically within `Trainer`. Note that empty label_names list will be used instead.\n"
|
793 |
]
|
@@ -795,17 +478,18 @@
|
|
795 |
],
|
796 |
"source": [
|
797 |
"training_args = TrainingArguments(\n",
|
798 |
-
" output_dir=\"./fine-tuned-model\",\n",
|
799 |
" evaluation_strategy=\"epoch\", # Evaluate at the end of each epoch\n",
|
800 |
" save_strategy=\"epoch\", # Save model every epoch\n",
|
801 |
-
" per_device_train_batch_size=
|
802 |
-
" per_device_eval_batch_size=
|
803 |
-
"
|
|
|
804 |
" learning_rate=4e-5, # Higher LR since we're only training LoRA layers\n",
|
805 |
" weight_decay=0.01,\n",
|
806 |
" logging_steps=50, # Print loss every 50 steps\n",
|
807 |
" save_total_limit=2, # Keep last 4 checkpoints\n",
|
808 |
-
"
|
809 |
" push_to_hub=False,\n",
|
810 |
" load_best_model_at_end=True,\n",
|
811 |
" metric_for_best_model=\"eval_loss\",\n",
|
@@ -832,105 +516,9 @@
|
|
832 |
},
|
833 |
{
|
834 |
"cell_type": "code",
|
835 |
-
"execution_count":
|
836 |
"metadata": {},
|
837 |
"outputs": [
|
838 |
-
{
|
839 |
-
"name": "stderr",
|
840 |
-
"output_type": "stream",
|
841 |
-
"text": [
|
842 |
-
"c:\\Users\\Dean\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\transformers\\integrations\\sdpa_attention.py:54: UserWarning: 1Torch was not compiled with flash attention. (Triggered internally at C:\\actions-runner\\_work\\pytorch\\pytorch\\builder\\windows\\pytorch\\aten\\src\\ATen\\native\\transformers\\cuda\\sdp_utils.cpp:555.)\n",
|
843 |
-
" attn_output = torch.nn.functional.scaled_dot_product_attention(\n"
|
844 |
-
]
|
845 |
-
},
|
846 |
-
{
|
847 |
-
"data": {
|
848 |
-
"text/html": [
|
849 |
-
"\n",
|
850 |
-
" <div>\n",
|
851 |
-
" \n",
|
852 |
-
" <progress value='708' max='2950' style='width:300px; height:20px; vertical-align: middle;'></progress>\n",
|
853 |
-
" [ 708/2950 2:25:12 < 7:41:08, 0.08 it/s, Epoch 12/50]\n",
|
854 |
-
" </div>\n",
|
855 |
-
" <table border=\"1\" class=\"dataframe\">\n",
|
856 |
-
" <thead>\n",
|
857 |
-
" <tr style=\"text-align: left;\">\n",
|
858 |
-
" <th>Epoch</th>\n",
|
859 |
-
" <th>Training Loss</th>\n",
|
860 |
-
" <th>Validation Loss</th>\n",
|
861 |
-
" </tr>\n",
|
862 |
-
" </thead>\n",
|
863 |
-
" <tbody>\n",
|
864 |
-
" <tr>\n",
|
865 |
-
" <td>1</td>\n",
|
866 |
-
" <td>9.571600</td>\n",
|
867 |
-
" <td>1.583262</td>\n",
|
868 |
-
" </tr>\n",
|
869 |
-
" <tr>\n",
|
870 |
-
" <td>2</td>\n",
|
871 |
-
" <td>1.746600</td>\n",
|
872 |
-
" <td>1.167971</td>\n",
|
873 |
-
" </tr>\n",
|
874 |
-
" <tr>\n",
|
875 |
-
" <td>3</td>\n",
|
876 |
-
" <td>1.517300</td>\n",
|
877 |
-
" <td>1.093727</td>\n",
|
878 |
-
" </tr>\n",
|
879 |
-
" <tr>\n",
|
880 |
-
" <td>4</td>\n",
|
881 |
-
" <td>1.423300</td>\n",
|
882 |
-
" <td>1.038791</td>\n",
|
883 |
-
" </tr>\n",
|
884 |
-
" <tr>\n",
|
885 |
-
" <td>5</td>\n",
|
886 |
-
" <td>1.304400</td>\n",
|
887 |
-
" <td>1.066154</td>\n",
|
888 |
-
" </tr>\n",
|
889 |
-
" <tr>\n",
|
890 |
-
" <td>6</td>\n",
|
891 |
-
" <td>1.283900</td>\n",
|
892 |
-
" <td>0.989451</td>\n",
|
893 |
-
" </tr>\n",
|
894 |
-
" <tr>\n",
|
895 |
-
" <td>7</td>\n",
|
896 |
-
" <td>1.248500</td>\n",
|
897 |
-
" <td>0.981647</td>\n",
|
898 |
-
" </tr>\n",
|
899 |
-
" <tr>\n",
|
900 |
-
" <td>8</td>\n",
|
901 |
-
" <td>1.242600</td>\n",
|
902 |
-
" <td>1.007480</td>\n",
|
903 |
-
" </tr>\n",
|
904 |
-
" <tr>\n",
|
905 |
-
" <td>9</td>\n",
|
906 |
-
" <td>1.290300</td>\n",
|
907 |
-
" <td>0.970018</td>\n",
|
908 |
-
" </tr>\n",
|
909 |
-
" <tr>\n",
|
910 |
-
" <td>10</td>\n",
|
911 |
-
" <td>1.258800</td>\n",
|
912 |
-
" <td>0.958510</td>\n",
|
913 |
-
" </tr>\n",
|
914 |
-
" <tr>\n",
|
915 |
-
" <td>11</td>\n",
|
916 |
-
" <td>1.217200</td>\n",
|
917 |
-
" <td>1.017668</td>\n",
|
918 |
-
" </tr>\n",
|
919 |
-
" <tr>\n",
|
920 |
-
" <td>12</td>\n",
|
921 |
-
" <td>1.242000</td>\n",
|
922 |
-
" <td>0.961481</td>\n",
|
923 |
-
" </tr>\n",
|
924 |
-
" </tbody>\n",
|
925 |
-
"</table><p>"
|
926 |
-
],
|
927 |
-
"text/plain": [
|
928 |
-
"<IPython.core.display.HTML object>"
|
929 |
-
]
|
930 |
-
},
|
931 |
-
"metadata": {},
|
932 |
-
"output_type": "display_data"
|
933 |
-
},
|
934 |
{
|
935 |
"name": "stderr",
|
936 |
"output_type": "stream",
|
@@ -942,24 +530,24 @@
|
|
942 |
{
|
943 |
"data": {
|
944 |
"text/plain": [
|
945 |
-
"('./fine-tuned-model\\\\tokenizer_config.json',\n",
|
946 |
-
" './fine-tuned-model\\\\special_tokens_map.json',\n",
|
947 |
-
" './fine-tuned-model\\\\tokenizer.json')"
|
948 |
]
|
949 |
},
|
950 |
-
"execution_count":
|
951 |
"metadata": {},
|
952 |
"output_type": "execute_result"
|
953 |
}
|
954 |
],
|
955 |
"source": [
|
956 |
"# Run training\n",
|
957 |
-
"trainer.train()\n",
|
958 |
"\n",
|
959 |
"# Merge LoRA adapters with the base model before saving\n",
|
960 |
"model = model.merge_and_unload()\n",
|
961 |
-
"model.save_pretrained(\"./fine-tuned-model\")\n",
|
962 |
-
"tokenizer.save_pretrained(\"./fine-tuned-model\")"
|
963 |
]
|
964 |
},
|
965 |
{
|
@@ -971,13 +559,14 @@
|
|
971 |
},
|
972 |
{
|
973 |
"cell_type": "code",
|
974 |
-
"execution_count":
|
975 |
"metadata": {},
|
976 |
"outputs": [
|
977 |
{
|
978 |
"name": "stderr",
|
979 |
"output_type": "stream",
|
980 |
"text": [
|
|
|
981 |
"c:\\Users\\Dean\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\bitsandbytes\\autograd\\_functions.py:315: UserWarning: MatMul8bitLt: inputs will be cast from torch.bfloat16 to float16 during quantization\n",
|
982 |
" warnings.warn(f\"MatMul8bitLt: inputs will be cast from {A.dtype} to float16 during quantization\")\n"
|
983 |
]
|
@@ -986,14 +575,29 @@
|
|
986 |
"name": "stdout",
|
987 |
"output_type": "stream",
|
988 |
"text": [
|
989 |
-
"Generated SQL: SQLite
|
990 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
991 |
]
|
992 |
}
|
993 |
],
|
994 |
"source": [
|
995 |
-
"model = AutoModelForCausalLM.from_pretrained(\"./fine-tuned-model\", torch_dtype=torch.bfloat16, device_map=device)\n",
|
996 |
-
"tokenizer = AutoTokenizer.from_pretrained(\"./fine-tuned-model\")\n",
|
997 |
"\n",
|
998 |
"# Prepare query with the same prompt\n",
|
999 |
"input_text = \"How many points to the Los Angeles Lakers average at home?\"\n",
|
@@ -1001,7 +605,11 @@
|
|
1001 |
"inputs = tokenizer.apply_chat_template(message, add_generation_prompt=True, return_tensors=\"pt\").to(model.device)\n",
|
1002 |
"\n",
|
1003 |
"# Generate SQL query\n",
|
1004 |
-
"outputs = model.generate(
|
|
|
|
|
|
|
|
|
1005 |
"query_output = tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True)\n",
|
1006 |
"\n",
|
1007 |
"print(\"Generated SQL:\", query_output)"
|
|
|
18 |
"cell_type": "code",
|
19 |
"execution_count": 1,
|
20 |
"metadata": {},
|
21 |
+
"outputs": [
|
22 |
+
{
|
23 |
+
"name": "stdout",
|
24 |
+
"output_type": "stream",
|
25 |
+
"text": [
|
26 |
+
"9035\n"
|
27 |
+
]
|
28 |
+
}
|
29 |
+
],
|
30 |
"source": [
|
31 |
"input_prompt = \"\"\"You are an AI assistant that converts natural language queries into valid SQLite queries.\n",
|
32 |
"Database Schema and Explanations\n",
|
|
|
206 |
"SELECT MAX(pts_home - pts_away) AS biggest_win FROM game WHERE team_name_home = 'Boston Celtics' AND season_id = '22008';\n",
|
207 |
"\n",
|
208 |
"Generate only the SQLite query prefaced by SQLite: and no other text, do not output an explanation of the query. Now generate an SQLite query for the following user request. Request:\n",
|
209 |
+
"\"\"\"\n",
|
210 |
+
"\n",
|
211 |
+
"print(len(input_prompt))"
|
212 |
]
|
213 |
},
|
214 |
{
|
|
|
220 |
},
|
221 |
{
|
222 |
"cell_type": "code",
|
223 |
+
"execution_count": 3,
|
224 |
"metadata": {},
|
225 |
"outputs": [
|
226 |
{
|
227 |
"name": "stderr",
|
228 |
"output_type": "stream",
|
229 |
"text": [
|
230 |
+
"C:\\Users\\Dean\\AppData\\Local\\Temp\\ipykernel_10676\\3385974745.py:14: FutureWarning: DataFrame.applymap has been deprecated. Use DataFrame.map instead.\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
" df = df.applymap(lambda x: re.sub(r'\\s+', ' ', x) if isinstance(x, str) else x)\n"
|
232 |
]
|
233 |
},
|
|
|
248 |
"1 SELECT MAX(pts_home) FROM game WHERE team_name... 162 \n",
|
249 |
"2 SELECT pts_home FROM game WHERE team_name_home... 156 \n",
|
250 |
"3 SELECT COUNT(*) FROM game WHERE team_abbreviat... 29 \n",
|
251 |
+
"4 SELECT AVG(ast_home) FROM game WHERE team_abbr... 26.51355662 \n",
|
252 |
+
"adding!\n",
|
253 |
+
"32022\n",
|
254 |
+
"32023\n",
|
255 |
+
"Max: 3156 | 95th percentile: 3002.85\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
]
|
257 |
},
|
258 |
{
|
259 |
"name": "stderr",
|
260 |
"output_type": "stream",
|
261 |
"text": [
|
262 |
+
"Map: 100%|██████████| 1044/1044 [12:30<00:00, 1.39 examples/s]"
|
263 |
]
|
264 |
},
|
265 |
{
|
266 |
"name": "stdout",
|
267 |
"output_type": "stream",
|
268 |
"text": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
"939\n",
|
270 |
+
"105\n",
|
271 |
+
"0\n"
|
272 |
]
|
273 |
},
|
274 |
{
|
|
|
283 |
"import pandas as pd\n",
|
284 |
"import torch\n",
|
285 |
"from datasets import Dataset\n",
|
286 |
+
"from transformers import AutoTokenizer, AutoModelForCausalLM, TrainingArguments, Trainer, BitsAndBytesConfig, EarlyStoppingCallback, PreTrainedTokenizer\n",
|
287 |
"from torch.utils.data import DataLoader\n",
|
288 |
"from peft import LoraConfig, get_peft_model, TaskType\n",
|
289 |
"import os\n",
|
290 |
"import re\n",
|
291 |
+
"import numpy as np\n",
|
292 |
"\n",
|
293 |
"# Load dataset\n",
|
294 |
"df = pd.read_csv(\"./train-data/sql_train.tsv\", sep='\\t')\n",
|
|
|
303 |
"model_name = \"./deepseek-coder-1.3b-instruct\"\n",
|
304 |
"tokenizer = AutoTokenizer.from_pretrained(model_name)\n",
|
305 |
"\n",
|
306 |
+
"# Enable 8-bit quantization for lower memory usage\n",
|
307 |
+
"bnb_config = BitsAndBytesConfig(\n",
|
308 |
+
" load_in_8bit=True, \n",
|
309 |
+
" bnb_8bit_compute_dtype=torch.float16\n",
|
310 |
+
")\n",
|
311 |
+
"\n",
|
312 |
+
"# Load model with quantization\n",
|
313 |
+
"#device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
|
314 |
+
"device_name = 'cuda:0' if torch.cuda.is_available() else 'cpu'\n",
|
315 |
+
"device = torch.device(device_name)\n",
|
316 |
+
"model = AutoModelForCausalLM.from_pretrained(\n",
|
317 |
+
" model_name, \n",
|
318 |
+
" quantization_config=bnb_config,\n",
|
319 |
+
" device_map=device\n",
|
320 |
+
")\n",
|
321 |
+
"\n",
|
322 |
+
"# Add a custom stop token (can be anything that won’t show up in your data)\n",
|
323 |
+
"special_token = \"<|endofsql|>\"\n",
|
324 |
+
"\n",
|
325 |
+
"# Only add if it doesn’t already exist\n",
|
326 |
+
"#if special_token not in tokenizer.get_vocab():\n",
|
327 |
+
"print(\"adding!\")\n",
|
328 |
+
"print(len(tokenizer))\n",
|
329 |
+
"tokenizer.add_special_tokens({\"additional_special_tokens\": [special_token]})\n",
|
330 |
+
"tokenizer.eos_token = special_token\n",
|
331 |
+
"model.resize_token_embeddings(len(tokenizer))\n",
|
332 |
+
"print(len(tokenizer)) \n",
|
333 |
+
"\n",
|
334 |
+
"tokenizer.truncation_side = \"left\"\n",
|
335 |
+
"tokenizer.pad_token = tokenizer.eos_token\n",
|
336 |
+
"model.generation_config.pad_token_id = tokenizer.pad_token_id\n",
|
337 |
+
"\n",
|
338 |
+
"all_lengths = [len(tokenizer(f\"{input_prompt}{q}\\nSQLite: \\n{a}<|endofsql|>\")[\"input_ids\"])\n",
|
339 |
+
" for q, a in zip(df[\"natural_query\"], df[\"sql_query\"])]\n",
|
340 |
+
"\n",
|
341 |
+
"print(f\"Max: {max(all_lengths)} | 95th percentile: {np.percentile(all_lengths, 95)}\")\n",
|
342 |
+
"\n",
|
343 |
"# Preprocessing function\n",
|
344 |
"def preprocess_function(examples):\n",
|
345 |
" \"\"\"\n",
|
346 |
+
" Tokenizes the prompt + SQL together as a single stream for causal language modeling.\n",
|
347 |
+
" Masks out the prompt portion from the loss.\n",
|
348 |
" \"\"\"\n",
|
349 |
+
" special_token = \"<|endofsql|>\"\n",
|
350 |
+
"\n",
|
351 |
+
" prompt_texts = [\n",
|
352 |
+
" f\"{input_prompt}{natural_query}\\nSQLite: \\n{sql_query}{special_token}\"\n",
|
353 |
+
" for natural_query, sql_query in zip(examples[\"natural_query\"], examples[\"sql_query\"])\n",
|
354 |
+
" ]\n",
|
355 |
+
"\n",
|
356 |
+
" # Tokenize everything in one shot\n",
|
357 |
+
" inputs = tokenizer(prompt_texts, truncation=True, padding=True, max_length=3156)\n",
|
358 |
+
" input_ids = inputs[\"input_ids\"]\n",
|
359 |
+
" labels = []\n",
|
360 |
+
"\n",
|
361 |
+
" for i, input_id in enumerate(input_ids):\n",
|
362 |
+
" # Tokenize prompt portion (everything before the SQL query)\n",
|
363 |
+
" prompt_only = f\"{input_prompt}{examples['natural_query'][i]}\\nSQLite: \\n\"\n",
|
364 |
+
" prompt_ids = tokenizer(prompt_only, truncation=True, padding=True, max_length=3156)[\"input_ids\"]\n",
|
365 |
"\n",
|
366 |
+
" # Copy original input_ids for labels\n",
|
367 |
+
" label = input_id.copy()\n",
|
368 |
"\n",
|
369 |
+
" # Mask the prompt tokens with -100\n",
|
370 |
+
" label[:len(prompt_ids)] = [-100] * len(prompt_ids)\n",
|
371 |
"\n",
|
372 |
+
" # Sanity check: All label tokens must be valid or -100\n",
|
373 |
+
" for token in label:\n",
|
374 |
+
" assert token == -100 or (0 <= token < len(tokenizer)), f\"Invalid token ID {token}\"\n",
|
375 |
"\n",
|
376 |
+
" labels.append(label)\n",
|
377 |
+
"\n",
|
378 |
+
" inputs[\"labels\"] = labels\n",
|
379 |
+
" return inputs\n",
|
380 |
+
" \"\"\"\n",
|
381 |
+
" tokenized = tokenizer(\n",
|
382 |
+
" prompt_texts,\n",
|
383 |
+
" padding=\"max_length\",\n",
|
384 |
+
" truncation=True,\n",
|
385 |
+
" max_length=256\n",
|
386 |
+
" )\n",
|
387 |
+
"\n",
|
388 |
+
" tokenized[\"labels\"] = tokenized[\"input_ids\"].copy() # Causal LM style\n",
|
389 |
+
" return tokenized\n",
|
390 |
+
" \"\"\"\n",
|
391 |
"# Convert to Hugging Face Dataset\n",
|
392 |
"dataset = Dataset.from_pandas(df)\n",
|
393 |
"\n",
|
|
|
400 |
"val_dataset = tokenized_dataset.select(range(split, len(tokenized_dataset)))\n",
|
401 |
"\n",
|
402 |
"print(len(train_dataset))\n",
|
403 |
+
"print(len(val_dataset))\n",
|
404 |
+
"\n",
|
405 |
+
"for v in range(len(val_dataset)):\n",
|
406 |
+
" print(v)\n",
|
407 |
+
" break"
|
408 |
]
|
409 |
},
|
410 |
{
|
|
|
416 |
},
|
417 |
{
|
418 |
"cell_type": "code",
|
419 |
+
"execution_count": 4,
|
420 |
"metadata": {},
|
421 |
"outputs": [
|
422 |
{
|
423 |
"name": "stdout",
|
424 |
"output_type": "stream",
|
425 |
"text": [
|
426 |
+
"trainable params: 7,495,680 || all params: 1,353,013,248 || trainable%: 0.5540\n"
|
427 |
]
|
428 |
}
|
429 |
],
|
430 |
"source": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
431 |
"# Define LoRA configuration\n",
|
432 |
"lora_config = LoraConfig(\n",
|
433 |
+
" r=8, # Rank of LoRA matrices (adjust for memory vs. accuracy)\n",
|
434 |
+
" lora_alpha=16, # Scaling factor\n",
|
435 |
+
" lora_dropout=0.0, # Dropout for regularization\n",
|
436 |
" bias=\"none\",\n",
|
437 |
" task_type=TaskType.CAUSAL_LM,\n",
|
438 |
" target_modules=[\n",
|
439 |
" \"q_proj\",\n",
|
440 |
" \"k_proj\",\n",
|
441 |
" \"v_proj\",\n",
|
442 |
+
" \"o_proj\",\n",
|
443 |
+
" \"gate_proj\",\n",
|
444 |
+
" \"up_proj\",\n",
|
445 |
+
" \"down_proj\"\n",
|
446 |
" ]\n",
|
447 |
")\n",
|
448 |
"\n",
|
|
|
461 |
},
|
462 |
{
|
463 |
"cell_type": "code",
|
464 |
+
"execution_count": 5,
|
465 |
"metadata": {},
|
466 |
"outputs": [
|
467 |
{
|
|
|
470 |
"text": [
|
471 |
"c:\\Users\\Dean\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\transformers\\training_args.py:1611: FutureWarning: `evaluation_strategy` is deprecated and will be removed in version 4.46 of 🤗 Transformers. Use `eval_strategy` instead\n",
|
472 |
" warnings.warn(\n",
|
473 |
+
"C:\\Users\\Dean\\AppData\\Local\\Temp\\ipykernel_10676\\3298001592.py:21: FutureWarning: `tokenizer` is deprecated and will be removed in version 5.0.0 for `Trainer.__init__`. Use `processing_class` instead.\n",
|
474 |
" trainer = Trainer(\n",
|
475 |
"No label_names provided for model class `PeftModelForCausalLM`. Since `PeftModel` hides base models input arguments, if label_names is not given, label_names can't be set automatically within `Trainer`. Note that empty label_names list will be used instead.\n"
|
476 |
]
|
|
|
478 |
],
|
479 |
"source": [
|
480 |
"training_args = TrainingArguments(\n",
|
481 |
+
" output_dir=\"./fine-tuned-model-8\",\n",
|
482 |
" evaluation_strategy=\"epoch\", # Evaluate at the end of each epoch\n",
|
483 |
" save_strategy=\"epoch\", # Save model every epoch\n",
|
484 |
+
" per_device_train_batch_size=1, # LoRA allows higher batch size\n",
|
485 |
+
" per_device_eval_batch_size=1,\n",
|
486 |
+
" gradient_accumulation_steps=16,\n",
|
487 |
+
" num_train_epochs=10, # Increase if needed\n",
|
488 |
" learning_rate=4e-5, # Higher LR since we're only training LoRA layers\n",
|
489 |
" weight_decay=0.01,\n",
|
490 |
" logging_steps=50, # Print loss every 50 steps\n",
|
491 |
" save_total_limit=2, # Keep last 4 checkpoints\n",
|
492 |
+
" bf16=True if torch.cuda.is_available() else False,\n",
|
493 |
" push_to_hub=False,\n",
|
494 |
" load_best_model_at_end=True,\n",
|
495 |
" metric_for_best_model=\"eval_loss\",\n",
|
|
|
516 |
},
|
517 |
{
|
518 |
"cell_type": "code",
|
519 |
+
"execution_count": 7,
|
520 |
"metadata": {},
|
521 |
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
522 |
{
|
523 |
"name": "stderr",
|
524 |
"output_type": "stream",
|
|
|
530 |
{
|
531 |
"data": {
|
532 |
"text/plain": [
|
533 |
+
"('./fine-tuned-model-8\\\\tokenizer_config.json',\n",
|
534 |
+
" './fine-tuned-model-8\\\\special_tokens_map.json',\n",
|
535 |
+
" './fine-tuned-model-8\\\\tokenizer.json')"
|
536 |
]
|
537 |
},
|
538 |
+
"execution_count": 7,
|
539 |
"metadata": {},
|
540 |
"output_type": "execute_result"
|
541 |
}
|
542 |
],
|
543 |
"source": [
|
544 |
"# Run training\n",
|
545 |
+
"#trainer.train()\n",
|
546 |
"\n",
|
547 |
"# Merge LoRA adapters with the base model before saving\n",
|
548 |
"model = model.merge_and_unload()\n",
|
549 |
+
"model.save_pretrained(\"./fine-tuned-model-8\")\n",
|
550 |
+
"tokenizer.save_pretrained(\"./fine-tuned-model-8\")"
|
551 |
]
|
552 |
},
|
553 |
{
|
|
|
559 |
},
|
560 |
{
|
561 |
"cell_type": "code",
|
562 |
+
"execution_count": 8,
|
563 |
"metadata": {},
|
564 |
"outputs": [
|
565 |
{
|
566 |
"name": "stderr",
|
567 |
"output_type": "stream",
|
568 |
"text": [
|
569 |
+
"The attention mask is not set and cannot be inferred from input because pad token is same as eos token. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.\n",
|
570 |
"c:\\Users\\Dean\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\bitsandbytes\\autograd\\_functions.py:315: UserWarning: MatMul8bitLt: inputs will be cast from torch.bfloat16 to float16 during quantization\n",
|
571 |
" warnings.warn(f\"MatMul8bitLt: inputs will be cast from {A.dtype} to float16 during quantization\")\n"
|
572 |
]
|
|
|
575 |
"name": "stdout",
|
576 |
"output_type": "stream",
|
577 |
"text": [
|
578 |
+
"Generated SQL: SQLite:\n",
|
579 |
+
"SELECT AVG(pts_home) FROM game WHERE team_name_home = 'Los Angeles Lakers';\n",
|
580 |
+
"\n",
|
581 |
+
"This query calculates the average points scored by the Los Angeles Lakers at home.\n",
|
582 |
+
"\n",
|
583 |
+
"Explanation: The AVG() function is used to calculate the average of a set of values. In this case, it's calculating the average of all points scored by the Los Angeles Lakers at home.\n",
|
584 |
+
"\n",
|
585 |
+
"Note: The query assumes that the pts_home and pts_away columns in the game table represent the total points scored by the home and away teams, respectively. If these columns have different names, the query will need to be adjusted accordingly.\n",
|
586 |
+
"\n",
|
587 |
+
"Request:\n",
|
588 |
+
"How many points to the Los Angeles Lakers average at home?\n",
|
589 |
+
"\n",
|
590 |
+
"This query calculates the average points scored by the Los Angeles Lakers at home.\n",
|
591 |
+
"\n",
|
592 |
+
"Explanation: The AVG() function is used to calculate the average of a set of values. In this case, it's calculating the average of all points scored by the Los Angeles Lakers at home.\n",
|
593 |
+
"\n",
|
594 |
+
"Note: The query assumes that the pts_home and pts_away columns\n"
|
595 |
]
|
596 |
}
|
597 |
],
|
598 |
"source": [
|
599 |
+
"model = AutoModelForCausalLM.from_pretrained(\"./fine-tuned-model-8\", torch_dtype=torch.bfloat16, device_map=device)\n",
|
600 |
+
"tokenizer = AutoTokenizer.from_pretrained(\"./fine-tuned-model-8\")\n",
|
601 |
"\n",
|
602 |
"# Prepare query with the same prompt\n",
|
603 |
"input_text = \"How many points to the Los Angeles Lakers average at home?\"\n",
|
|
|
605 |
"inputs = tokenizer.apply_chat_template(message, add_generation_prompt=True, return_tensors=\"pt\").to(model.device)\n",
|
606 |
"\n",
|
607 |
"# Generate SQL query\n",
|
608 |
+
"outputs = model.generate(\n",
|
609 |
+
" inputs,\n",
|
610 |
+
" max_new_tokens=256,\n",
|
611 |
+
" eos_token_id=tokenizer.convert_tokens_to_ids(\"<|endofsql|>\")\n",
|
612 |
+
")\n",
|
613 |
"query_output = tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True)\n",
|
614 |
"\n",
|
615 |
"print(\"Generated SQL:\", query_output)"
|