jsmall12 commited on
Commit
bc4443f
·
verified ·
1 Parent(s): 0cf3d09

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Qwen/Qwen2.5-Coder-14B-Instruct
4
+ library_name: peft
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - qlora
8
+ - data-science
9
+ - code-generation
10
+ - peft
11
+ - qwen2
12
+ - lora
13
+ - sft
14
+ - unsloth
15
+ language:
16
+ - en
17
+ ---
18
+
19
+ # DataSci-Coder-14B: Qwen2.5-Coder-14B LoRA Adapter for Data Science
20
+
21
+ A QLoRA fine-tuned adapter for [Qwen2.5-Coder-14B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-14B-Instruct) optimized for data science code generation. The model outputs clean, runnable Python code with zero explanatory text — strictly following code-only instructions.
22
+
23
+ ## Key Results
24
+
25
+ | Metric | DS-Tuned (FT) | Base Model | Delta |
26
+ |--------|:---:|:---:|:---:|
27
+ | Hard Eval (12 complex tasks) | 12/12 | 12/12 | Tie |
28
+ | Constraint Compliance | 93.3% | 91.4% | **+1.9%** |
29
+ | Code-Only Compliance | 10/10 | 6/10 | **+67%** |
30
+ | Code Ratio | 100% | 87.9% | **+12.1%** |
31
+
32
+ ## What It Does
33
+
34
+ - Generates complete, runnable Python code for data science tasks
35
+ - Covers statistics, machine learning, deep learning, NLP, time series, and visualization
36
+ - Follows instructions precisely — when told "no explanations," it outputs only code (base model ignores this 40% of the time)
37
+ - Handles complex tasks: Bayesian inference, VAEs, GANs, survival analysis, stacking ensembles, SHAP, anomaly detection
38
+
39
+ ## Training Details
40
+
41
+ | Parameter | Value |
42
+ |-----------|-------|
43
+ | Base Model | `unsloth/Qwen2.5-Coder-14B-Instruct-bnb-4bit` |
44
+ | Method | QLoRA (4-bit quantization) |
45
+ | LoRA Rank | 16 |
46
+ | LoRA Alpha | 32 |
47
+ | LoRA Targets | q/k/v/o_proj, gate/up/down_proj |
48
+ | Trainable Parameters | 68.8M / 14.8B (0.46%) |
49
+ | Training Examples | 10,795 |
50
+ | Epochs | 1 |
51
+ | Final Loss | 0.5933 |
52
+ | Training Time | 1.9 hours on NVIDIA L40S |
53
+ | Precision | bfloat16 |
54
+ | Optimizer | Paged AdamW 8-bit |
55
+ | Learning Rate | 3e-5 (cosine schedule) |
56
+ | Effective Batch Size | 16 (1 x 16 grad accum) |
57
+
58
+ ## Training Data
59
+
60
+ 10,795 curated data science instruction-response pairs from:
61
+ - 6 public HuggingFace datasets (CodeAlpaca, Evol-Instruct, etc.)
62
+ - University coursework (statistics, ML, deep learning)
63
+ - Data science newsletters
64
+ - Hand-curated examples
65
+
66
+ All examples filtered for Python code quality, data science relevance, and length. Categories: machine learning, deep learning, statistics, data wrangling, visualization, NLP, time series, numerical computing.
67
+
68
+ ## Usage
69
+
70
+ ```python
71
+ from unsloth import FastLanguageModel
72
+ import torch
73
+
74
+ model, tokenizer = FastLanguageModel.from_pretrained(
75
+ model_name="jsmall12/DataSci-Coder-14B-LoRA",
76
+ max_seq_length=2048,
77
+ load_in_4bit=True,
78
+ dtype=None,
79
+ )
80
+ FastLanguageModel.for_inference(model)
81
+
82
+ messages = [
83
+ {"role": "system", "content": "You are an expert data science coding assistant. Respond ONLY with clean, runnable Python code. Use inline comments for explanation. No text outside code blocks."},
84
+ {"role": "user", "content": "Write a function to train a logistic regression model with sklearn and print the classification report."},
85
+ ]
86
+
87
+ text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
88
+ inputs = tokenizer(text, return_tensors="pt").to("cuda")
89
+
90
+ with torch.no_grad():
91
+ output = model.generate(
92
+ **inputs,
93
+ max_new_tokens=1024,
94
+ temperature=0.1,
95
+ do_sample=True,
96
+ top_p=0.9,
97
+ repetition_penalty=1.15,
98
+ use_cache=False,
99
+ )
100
+
101
+ response = tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
102
+ print(response)
103
+ ```
104
+
105
+ ## Evaluation
106
+
107
+ ### Hard Eval (12 Complex Tasks)
108
+
109
+ All 12 tasks produced correct, complete, runnable implementations:
110
+
111
+ | Category | Tasks | Score |
112
+ |----------|-------|:---:|
113
+ | Statistics | Bayesian A/B testing, Kaplan-Meier survival analysis, time series CV + ARIMA, VIF + Ridge/Lasso/ElasticNet | 4/4 |
114
+ | Machine Learning | Stacking ensemble, SHAP importance, Isolation Forest, TF-IDF + SVM pipeline | 4/4 |
115
+ | Deep Learning | LR scheduler (warmup + cosine), BiLSTM + attention, VAE, GAN | 4/4 |
116
+
117
+ ### Constraint Eval (10 Multi-Constraint Tests)
118
+
119
+ | Test | FT | Base | Delta |
120
+ |------|:---:|:---:|:---:|
121
+ | C01 Multi-step data cleaning | 8/8 | 8/8 | 0 |
122
+ | C02 Complete ML pipeline | 12/12 | 12/12 | 0 |
123
+ | C03 Statistical hypothesis test | 9/9 | 7/9 | **+2** |
124
+ | C04 PyTorch architecture | 9/9 | 7/9 | **+2** |
125
+ | C05 EDA visualizations | 11/12 | 10/12 | **+1** |
126
+ | C06 Cross-validated pipeline | 12/12 | 12/12 | 0 |
127
+ | C07 Time series ARIMA | 9/10 | 10/10 | -1 |
128
+ | C08 DL training function | 8/10 | 8/10 | 0 |
129
+ | C09 Pandas method chain | 10/10 | 10/10 | 0 |
130
+ | C10 Model evaluation | 10/13 | 12/13 | -2 |
131
+ | **Total** | **98/105** | **96/105** | **+2** |
132
+
133
+ ## Hardware Requirements
134
+
135
+ - **Minimum:** ~10GB VRAM (4-bit quantized)
136
+ - **Recommended:** 24GB+ VRAM (L4, A100, etc.)
137
+ - Tested on: NVIDIA L40S (44GB), NVIDIA T4 x2 (15GB each)
138
+
139
+ ## License
140
+
141
+ Apache 2.0
adapter_config.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": {
6
+ "base_model_class": "Qwen2ForCausalLM",
7
+ "parent_library": "transformers.models.qwen2.modeling_qwen2",
8
+ "unsloth_fixed": true
9
+ },
10
+ "base_model_name_or_path": "unsloth/Qwen2.5-Coder-14B-Instruct-bnb-4bit",
11
+ "bias": "none",
12
+ "corda_config": null,
13
+ "ensure_weight_tying": false,
14
+ "eva_config": null,
15
+ "exclude_modules": null,
16
+ "fan_in_fan_out": false,
17
+ "inference_mode": true,
18
+ "init_lora_weights": true,
19
+ "layer_replication": null,
20
+ "layers_pattern": null,
21
+ "layers_to_transform": null,
22
+ "loftq_config": {},
23
+ "lora_alpha": 32,
24
+ "lora_bias": false,
25
+ "lora_dropout": 0.05,
26
+ "megatron_config": null,
27
+ "megatron_core": "megatron.core",
28
+ "modules_to_save": null,
29
+ "peft_type": "LORA",
30
+ "peft_version": "0.18.1",
31
+ "qalora_group_size": 16,
32
+ "r": 16,
33
+ "rank_pattern": {},
34
+ "revision": null,
35
+ "target_modules": [
36
+ "v_proj",
37
+ "up_proj",
38
+ "gate_proj",
39
+ "down_proj",
40
+ "o_proj",
41
+ "q_proj",
42
+ "k_proj"
43
+ ],
44
+ "target_parameters": null,
45
+ "task_type": "CAUSAL_LM",
46
+ "trainable_token_indices": null,
47
+ "use_dora": false,
48
+ "use_qalora": false,
49
+ "use_rslora": false
50
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:29025996a3f095ddc80f270f6ac16990cea5e5e372dce46989e6ff09352fbea1
3
+ size 275341720
chat_template.jinja ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}
7
+ {%- endif %}
8
+ {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
9
+ {%- for tool in tools %}
10
+ {{- "\n" }}
11
+ {{- tool | tojson }}
12
+ {%- endfor %}
13
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
14
+ {%- else %}
15
+ {%- if messages[0]['role'] == 'system' %}
16
+ {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
17
+ {%- else %}
18
+ {{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }}
19
+ {%- endif %}
20
+ {%- endif %}
21
+ {%- for message in messages %}
22
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
23
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
24
+ {%- elif message.role == "assistant" %}
25
+ {{- '<|im_start|>' + message.role }}
26
+ {%- if message.content %}
27
+ {{- '\n' + message.content }}
28
+ {%- endif %}
29
+ {%- for tool_call in message.tool_calls %}
30
+ {%- if tool_call.function is defined %}
31
+ {%- set tool_call = tool_call.function %}
32
+ {%- endif %}
33
+ {{- '\n<tool_call>\n{"name": "' }}
34
+ {{- tool_call.name }}
35
+ {{- '", "arguments": ' }}
36
+ {{- tool_call.arguments | tojson }}
37
+ {{- '}\n</tool_call>' }}
38
+ {%- endfor %}
39
+ {{- '<|im_end|>\n' }}
40
+ {%- elif message.role == "tool" %}
41
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
42
+ {{- '<|im_start|>user' }}
43
+ {%- endif %}
44
+ {{- '\n<tool_response>\n' }}
45
+ {{- message.content }}
46
+ {{- '\n</tool_response>' }}
47
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
48
+ {{- '<|im_end|>\n' }}
49
+ {%- endif %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+ {%- if add_generation_prompt %}
53
+ {{- '<|im_start|>assistant\n' }}
54
+ {%- endif %}
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:94df820dd44997bc42540f6e0b8629201e4b45285972712cda88b704fbf5c640
3
+ size 11422455
tokenizer_config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": null,
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "<|im_end|>",
7
+ "errors": "replace",
8
+ "extra_special_tokens": [],
9
+ "is_local": false,
10
+ "model_max_length": 32768,
11
+ "pad_token": "<|PAD_TOKEN|>",
12
+ "padding_side": "left",
13
+ "split_special_tokens": false,
14
+ "tokenizer_class": "Qwen2Tokenizer",
15
+ "unk_token": null
16
+ }
training_config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model": "unsloth/Qwen2.5-Coder-14B-Instruct-bnb-4bit",
3
+ "lora_r": 16,
4
+ "lora_alpha": 32,
5
+ "seq_length": 2048,
6
+ "epochs": 1,
7
+ "batch_size": 1,
8
+ "grad_accum": 16,
9
+ "effective_batch_size": 16,
10
+ "lr": 3e-05,
11
+ "train_loss": 0.5933350541856554,
12
+ "train_examples": 10795,
13
+ "val_examples": 1195,
14
+ "train_time_hours": 1.87
15
+ }