Instructions to use NeelContractor/finetuning-checkpoints with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use NeelContractor/finetuning-checkpoints with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Desktop
Add model card / README for the checkpoint repository
Browse files
README.md
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: peft
|
| 3 |
+
base_model: Qwen/Qwen3-0.6B
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
license: apache-2.0
|
| 6 |
+
tags:
|
| 7 |
+
- qwen3
|
| 8 |
+
- lora
|
| 9 |
+
- peft
|
| 10 |
+
- cpt
|
| 11 |
+
- sft
|
| 12 |
+
- dpo
|
| 13 |
+
- grpo
|
| 14 |
+
- reasoning
|
| 15 |
+
- unsloth
|
| 16 |
+
- trl
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# finetuning-checkpoints β Qwen3-0.6B post-training pipeline
|
| 20 |
+
|
| 21 |
+
Checkpoints from an end-to-end post-training run on **Qwen/Qwen3-0.6B** (~600M
|
| 22 |
+
parameters) covering **continued pre-training (CPT) β supervised fine-tuning
|
| 23 |
+
(SFT) β DPO β reasoning-format warm-up β GRPO**.
|
| 24 |
+
|
| 25 |
+
This is a **checkpoint repository**, not a single deployable model. Pick the
|
| 26 |
+
subfolder for the stage you want. The last stage (`grpo_qwen06_merged`) is the
|
| 27 |
+
"final" model; `grpo_qwen06/llm_best_0` is the best GRPO adapter by eval reward.
|
| 28 |
+
|
| 29 |
+
Produced by [NeelContractor/finetuning_recipes](https://github.com/NeelContractor/finetuning_recipes),
|
| 30 |
+
based on the [avbiswas/finetuning_recipes](https://github.com/avbiswas/finetuning_recipes)
|
| 31 |
+
course repo. Built with Unsloth, TRL, and PEFT on Kaggle 2Γ Tesla T4.
|
| 32 |
+
|
| 33 |
+
---
|
| 34 |
+
|
| 35 |
+
## Pipeline
|
| 36 |
+
|
| 37 |
+
```
|
| 38 |
+
ββββββββββββββββΊ dpo_qwen06 (DPO, side branch)
|
| 39 |
+
β
|
| 40 |
+
Qwen3-0.6B βββΊ CPT βββΊ SFT βββ¬βββΊ reasoning_warmup βββΊ GRPO βββΊ final
|
| 41 |
+
β
|
| 42 |
+
ββββΊ DPO
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
Two branches leave SFT: preference optimization (DPO) and the reasoning branch
|
| 46 |
+
(format warm-up, then GRPO). GRPO is trained from `reasoning_warmup_qwen06_merged`,
|
| 47 |
+
not from the DPO adapter.
|
| 48 |
+
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
## What's in the repo
|
| 52 |
+
|
| 53 |
+
| Path | Type | Stage | Base / notes |
|
| 54 |
+
|---|---|---|---|
|
| 55 |
+
| `models/cpt_qwen06/final` + `checkpoint-20β¦131` | LoRA adapter | CPT on arXiv paper text | `unsloth/Qwen3-0.6B-unsloth-bnb-4bit` |
|
| 56 |
+
| `models/cpt_qwen06_merged` | Full model (fp) | merged CPT | Qwen3-0.6B |
|
| 57 |
+
| `models/sft_qwen06/final` + `checkpoint-100/150/198` | LoRA adapter | Instruction SFT | `cpt_qwen06_merged` |
|
| 58 |
+
| `models/sft_qwen06_merged` | Full model (fp) | merged SFT | Qwen3-0.6B |
|
| 59 |
+
| `models/dpo_qwen06/final` + `checkpoint-50/77` | LoRA adapter (+ `ref/`) | DPO preference tuning | `sft_qwen06_merged` |
|
| 60 |
+
| `models/reasoning_warmup_qwen06/final` + `checkpoint-3` | LoRA adapter | Reasoning-format SFT (`think`/answer) | `sft_qwen06_merged` |
|
| 61 |
+
| `models/reasoning_warmup_qwen06_merged` | Full model (fp) | merged warm-up | Qwen3-0.6B |
|
| 62 |
+
| `models/grpo_qwen06/llm` | LoRA adapter | GRPO (latest) | `reasoning_warmup_qwen06_merged` |
|
| 63 |
+
| `models/grpo_qwen06/llm_best_0` | LoRA adapter | GRPO (best eval reward) | `reasoning_warmup_qwen06_merged` |
|
| 64 |
+
| `models/grpo_qwen06_merged` | Full model (fp) | **final merged model** | Qwen3-0.6B |
|
| 65 |
+
| `models/grpo_qwen06/logs` | JSON/JSONL | GRPO train + eval logs | β |
|
| 66 |
+
|
| 67 |
+
Notes on naming:
|
| 68 |
+
- `final/` β last adapter saved for the stage.
|
| 69 |
+
- `checkpoint-N/` β resumable checkpoints (adapter + optimizer/scheduler/RNG state).
|
| 70 |
+
- `*_merged/` β LoRA merged into the base, saved as a full-precision
|
| 71 |
+
`Qwen3ForCausalLM` (safe to load directly with `transformers`).
|
| 72 |
+
|
| 73 |
+
---
|
| 74 |
+
|
| 75 |
+
## Quick start
|
| 76 |
+
|
| 77 |
+
### Load the final merged model (recommended)
|
| 78 |
+
|
| 79 |
+
```python
|
| 80 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 81 |
+
|
| 82 |
+
REPO = "NeelContractor/finetuning-checkpoints"
|
| 83 |
+
SUB = "models/grpo_qwen06_merged"
|
| 84 |
+
|
| 85 |
+
tokenizer = AutoTokenizer.from_pretrained(REPO, subfolder=SUB)
|
| 86 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 87 |
+
REPO, subfolder=SUB, torch_dtype="auto", device_map="auto"
|
| 88 |
+
)
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
### Load a LoRA adapter
|
| 92 |
+
|
| 93 |
+
The adapter configs were written on Kaggle and reference local paths
|
| 94 |
+
(`/kaggle/working/...`), so load the matching merged base explicitly:
|
| 95 |
+
|
| 96 |
+
```python
|
| 97 |
+
from peft import PeftModel
|
| 98 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 99 |
+
|
| 100 |
+
REPO = "NeelContractor/finetuning-checkpoints"
|
| 101 |
+
|
| 102 |
+
base = AutoModelForCausalLM.from_pretrained(
|
| 103 |
+
REPO, subfolder="models/reasoning_warmup_qwen06_merged",
|
| 104 |
+
torch_dtype="auto", device_map="auto",
|
| 105 |
+
)
|
| 106 |
+
model = PeftModel.from_pretrained(
|
| 107 |
+
base, REPO, subfolder="models/grpo_qwen06/llm_best_0"
|
| 108 |
+
)
|
| 109 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 110 |
+
REPO, subfolder="models/grpo_qwen06/llm_best_0"
|
| 111 |
+
)
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
### Generate
|
| 115 |
+
|
| 116 |
+
The reasoning branch expects a system prompt that asks for a `think` block:
|
| 117 |
+
|
| 118 |
+
```python
|
| 119 |
+
SYSTEM = (
|
| 120 |
+
"You are a helpful, respectful and honest assistant. You are an expert in "
|
| 121 |
+
"AI, deep learning, and machine learning research. Generate your reasoning "
|
| 122 |
+
"first inside thinking and </think> tags. After </think>, generate only "
|
| 123 |
+
"the requested final response. When JSON is requested, the content after "
|
| 124 |
+
"</think> must contain only that format, without Markdown fences."
|
| 125 |
+
)
|
| 126 |
+
|
| 127 |
+
messages = [
|
| 128 |
+
{"role": "system", "content": SYSTEM},
|
| 129 |
+
{"role": "user", "content": "Explain LoRA in two sentences."},
|
| 130 |
+
]
|
| 131 |
+
text = tokenizer.apply_chat_template(
|
| 132 |
+
messages, tokenize=False, add_generation_prompt=True
|
| 133 |
+
)
|
| 134 |
+
inputs = tokenizer(text, return_tensors="pt").to(model.device)
|
| 135 |
+
output = model.generate(
|
| 136 |
+
**inputs, max_new_tokens=256, do_sample=True, temperature=0.7, top_p=0.9
|
| 137 |
+
)
|
| 138 |
+
print(tokenizer.decode(
|
| 139 |
+
output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True
|
| 140 |
+
))
|
| 141 |
+
```
|
| 142 |
+
|
| 143 |
+
---
|
| 144 |
+
|
| 145 |
+
## Training details
|
| 146 |
+
|
| 147 |
+
| | |
|
| 148 |
+
|---|---|
|
| 149 |
+
| Base model | `Qwen/Qwen3-0.6B` (CPT loaded via `unsloth/Qwen3-0.6B-unsloth-bnb-4bit`) |
|
| 150 |
+
| Method | LoRA (PEFT) with Unsloth kernels / TRL trainers |
|
| 151 |
+
| LoRA rank | `r=32`, `lora_alpha=32` (CPT/SFT/DPO/warm-up), `lora_alpha=64` (GRPO) |
|
| 152 |
+
| Target modules | `q, k, v, o, gate, up, down` projections |
|
| 153 |
+
| LoRA dropout | 0.0 |
|
| 154 |
+
| Hardware | Kaggle, 2Γ Tesla T4 (15 GB), DDP |
|
| 155 |
+
| Precision | fp16 training on T4; merged checkpoints saved as bf16 |
|
| 156 |
+
| Max sequence length | 1024 (SFT / reasoning / GRPO) |
|
| 157 |
+
|
| 158 |
+
### Data
|
| 159 |
+
|
| 160 |
+
| Stage | Data |
|
| 161 |
+
|---|---|
|
| 162 |
+
| CPT | arXiv paper text prepared by `data_prep/cpt` |
|
| 163 |
+
| SFT | [`paperbd/paper_instructions_300K-v1`](https://huggingface.co/datasets/paperbd/paper_instructions_300K-v1) (default config, ~20k rows) |
|
| 164 |
+
| DPO | Preference pairs produced/ranked by the preference-optimization scripts |
|
| 165 |
+
| Reasoning warm-up | `reasoning` config of `paperbd/paper_instructions_300K-v1` |
|
| 166 |
+
| GRPO | Train slice of the same `reasoning` config, scored by [`paperbd/neuraltxt-reward-22M`](https://huggingface.co/paperbd/neuraltxt-reward-22M) plus format/schema/length terms |
|
| 167 |
+
|
| 168 |
+
---
|
| 169 |
+
|
| 170 |
+
## GRPO evaluation (recorded run)
|
| 171 |
+
|
| 172 |
+
From `models/grpo_qwen06/logs/eval_summary_5.json` (64 held-out prompts):
|
| 173 |
+
|
| 174 |
+
| Metric | Mean |
|
| 175 |
+
|---|---|
|
| 176 |
+
| `total_reward` | **0.440** |
|
| 177 |
+
| `neuraltxt_reward` | **0.486** |
|
| 178 |
+
| `length_penalty_reward` | β0.094 |
|
| 179 |
+
| `num_tokens` | 101 |
|
| 180 |
+
| `think_format_reward` | 0.000 |
|
| 181 |
+
| `output_datatype_reward` | 0.000 |
|
| 182 |
+
| `output_schema_reward` | 0.000 |
|
| 183 |
+
|
| 184 |
+
**Known limitation:** this run's reasoning warm-up was only 3 optimizer steps, so
|
| 185 |
+
the model never learned to emit `think...` blocks and the format-related rewards
|
| 186 |
+
stayed at zero. The pipeline has since added a dedicated `reasoning` stage that
|
| 187 |
+
trains the format on ~10k rows for 3 epochs; the artifacts in this repo predate
|
| 188 |
+
that change. Do not treat these checkpoints as strong reasoning models β they
|
| 189 |
+
are research/teaching artifacts from a short, small-model run.
|
| 190 |
+
|
| 191 |
+
---
|
| 192 |
+
|
| 193 |
+
## Reproducing / extending
|
| 194 |
+
|
| 195 |
+
The orchestrator builds the data, runs each stage, and optionally pushes
|
| 196 |
+
checkpoints to the Hub:
|
| 197 |
+
|
| 198 |
+
```bash
|
| 199 |
+
python cloud_train.py --install --num-gpus 2 \
|
| 200 |
+
--push-to-hub --hub-repo NeelContractor/finetuning-checkpoints
|
| 201 |
+
```
|
| 202 |
+
|
| 203 |
+
Run only the stages you need:
|
| 204 |
+
|
| 205 |
+
```bash
|
| 206 |
+
# Retrain the reasoning-format warm-up, then GRPO
|
| 207 |
+
python cloud_train.py --stages reasoning grpo --num-gpus 2
|
| 208 |
+
```
|
| 209 |
+
|
| 210 |
+
See the [project README](https://github.com/NeelContractor/finetuning_recipes)
|
| 211 |
+
for stage-by-stage details, dataset prep, and evaluation scripts.
|
| 212 |
+
|
| 213 |
+
---
|
| 214 |
+
|
| 215 |
+
## Limitations & intended use
|
| 216 |
+
|
| 217 |
+
- Research / educational checkpoints from a short, small-model run.
|
| 218 |
+
- Not instruction-tuned for production, not safety-tuned, not evaluated for
|
| 219 |
+
harmful content.
|
| 220 |
+
- Reasoning format is unreliable in these artifacts (see metrics above).
|
| 221 |
+
- Derived from Qwen3-0.6B (Apache-2.0); check the licenses of the training
|
| 222 |
+
datasets and the reward model before redistributing or commercial use.
|