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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model:
|
| 4 |
+
- Qwen/Qwen2.5-0.5B-Instruct
|
| 5 |
+
datasets:
|
| 6 |
+
- agentlans/common-crawl-sample
|
| 7 |
+
- bigcode/the-stack-smol-xl
|
| 8 |
+
- rombodawg/Everything_Instruct
|
| 9 |
+
tags:
|
| 10 |
+
- draft
|
| 11 |
+
- speculative-decoding
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
A `0.8B` parameter draft (speculative decoding) model for use with [command-a-03-2025](https://huggingface.co/CohereLabs/c4ai-command-a-03-2025).
|
| 15 |
+
|
| 16 |
+
See [command-a-03-2025-DRAFT-0.8B-v3.0-GGUF](https://huggingface.co/jukofyork/command-a-03-2025-DRAFT-0.8B-v3.0-GGUF) for the models in `gguf` format for use with `llama.cpp`.
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
# Extending the context above 32k
|
| 22 |
+
|
| 23 |
+
The current `config.json` is set for context length up to 32k tokens. Add the `"rope_scaling"` section to `config.json` to enable [YaRN](https://arxiv.org/abs/2309.00071), eg:
|
| 24 |
+
|
| 25 |
+
## To extend the context to 64k:
|
| 26 |
+
|
| 27 |
+
```json
|
| 28 |
+
"max_position_embeddings": 65536,
|
| 29 |
+
...
|
| 30 |
+
"rope_scaling": {
|
| 31 |
+
"factor": 2.0,
|
| 32 |
+
"original_max_position_embeddings": 32768,
|
| 33 |
+
"type": "yarn"
|
| 34 |
+
},
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
## To extend the context to 128k:
|
| 38 |
+
|
| 39 |
+
```json
|
| 40 |
+
"max_position_embeddings": 131072,
|
| 41 |
+
...
|
| 42 |
+
"rope_scaling": {
|
| 43 |
+
"factor": 4.0,
|
| 44 |
+
"original_max_position_embeddings": 32768,
|
| 45 |
+
"type": "yarn"
|
| 46 |
+
},
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
**NOTE**: Because `llama.cpp` uses "static-YaRN" the scaling factor remains constant regardless of input length! Only add the `rope_scaling` configuration when processing long contexts is required...
|
| 50 |
+
|
| 51 |
+
---
|
| 52 |
+
|
| 53 |
+
# How this model was created
|
| 54 |
+
|
| 55 |
+
## 1. The initial model was created from [Qwen2.5-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct) using [transplant-vocab](https://github.com/jukofyork/transplant-vocab):
|
| 56 |
+
|
| 57 |
+
```sh
|
| 58 |
+
> python ./transplant_vocab.py \
|
| 59 |
+
./Qwen2.5-0.5B-Instruct \
|
| 60 |
+
./command-a-03-2025 \
|
| 61 |
+
./command-a-03-2025-DRAFT-0.8B-UNTRAINED \
|
| 62 |
+
--override "<PAD>" "<|endoftext|>" \
|
| 63 |
+
--override "<UNK>" "<|endoftext|>" \
|
| 64 |
+
--override "<CLS>" "<|endoftext|>" \
|
| 65 |
+
--override "<SEP>" "<|endoftext|>" \
|
| 66 |
+
--override "<MASK_TOKEN>" "<|endoftext|>" \
|
| 67 |
+
--override "<BOS_TOKEN>" "<|endoftext|>" \
|
| 68 |
+
--override "<EOS_TOKEN>" "<|endoftext|>" \
|
| 69 |
+
--override "<EOP_TOKEN>" "<|endoftext|>" \
|
| 70 |
+
--override "<|START_OF_TURN_TOKEN|>" "<|im_start|>" \
|
| 71 |
+
--override "<|END_OF_TURN_TOKEN|>" "<|im_end|>" \
|
| 72 |
+
--override "<|YES_TOKEN|>" "<|endoftext|>" \
|
| 73 |
+
--override "<|NO_TOKEN|>" "<|endoftext|>" \
|
| 74 |
+
--override "<|GOOD_TOKEN|>" "<|endoftext|>" \
|
| 75 |
+
--override "<|BAD_TOKEN|>" "<|endoftext|>" \
|
| 76 |
+
--override "<|USER_TOKEN|>" "user\n" \
|
| 77 |
+
--override "<|CHATBOT_TOKEN|>" "assistant\n" \
|
| 78 |
+
--override "<|SYSTEM_TOKEN|>" "system\n" \
|
| 79 |
+
--override "<|START_THINKING|>" "<think>" \
|
| 80 |
+
--override "<|END_THINKING|>" "</think>" \
|
| 81 |
+
--override "<|START_RESPONSE|>" "<|endoftext|>" \
|
| 82 |
+
--override "<|END_RESPONSE|>" "<|endoftext|>" \
|
| 83 |
+
--override "<|START_ACTION|>" "<tool_call>" \
|
| 84 |
+
--override "<|END_ACTION|>" "</tool_call>" \
|
| 85 |
+
--override "<|START_TOOL_RESULT|>" "<tool_response>" \
|
| 86 |
+
--override "<|END_TOOL_RESULT|>" "</tool_response>" \
|
| 87 |
+
--override "<|BEGINNING_OF_PREFIX_FIM_TOKEN|>" "<|fim_prefix|>" \
|
| 88 |
+
--override "<|BEGINNING_OF_MIDDLE_FIM_TOKEN|>" "<|fim_middle|>" \
|
| 89 |
+
--override "<|BEGINNING_OF_SUFFIX_FIM_TOKEN|>" "<|fim_suffix|>" \
|
| 90 |
+
--override "<|END_OF_MIDDLE_FIM_TOKEN|>" "<|fim_middle|>"
|
| 91 |
+
|
| 92 |
+
Loading config from 'Qwen2.5-0.5B-Instruct'... Done.
|
| 93 |
+
Loading config from 'command-a-03-2025'... Done.
|
| 94 |
+
Loading tokenizer from 'Qwen2.5-0.5B-Instruct'... Done.
|
| 95 |
+
Loading tokenizer from 'command-a-03-2025'... Done.
|
| 96 |
+
Loading model from 'Qwen2.5-0.5B-Instruct'... Done.
|
| 97 |
+
|
| 98 |
+
Input model configuration:
|
| 99 |
+
- Target vocabulary size : 256000 (used = 255033, unused = 967)
|
| 100 |
+
- Donor vocabulary size : 151936
|
| 101 |
+
- Donor num layers : 24 (tied embeddings = True)
|
| 102 |
+
- Donor hidden size : 896
|
| 103 |
+
- Donor attention heads : 14
|
| 104 |
+
- Donor intermediate size : 4864 (ratio = 1:5.4)
|
| 105 |
+
- Donor total parameters : 494032768 (0.49B)
|
| 106 |
+
-- Embedding parameters : 136134656 (0.14B)
|
| 107 |
+
-- Non-embedding parameters : 357898112 (0.36B)
|
| 108 |
+
|
| 109 |
+
Processing 3 automatic token overrides:
|
| 110 |
+
✔ 'bos_token_id' : 5 '<BOS_TOKEN>' → [151643] '<|endoftext|>'
|
| 111 |
+
✔ 'eos_token_id' : 255001 '<|END_OF_TURN_TOKEN|>' → [151645] '<|im_end|>'
|
| 112 |
+
✔ 'pad_token_id' : 0 '<PAD>' → [151643] '<|endoftext|>'
|
| 113 |
+
|
| 114 |
+
Processing 29 manual token overrides:
|
| 115 |
+
✔ 0 : '<PAD>' → [151643] '<|endoftext|>'
|
| 116 |
+
✔ 1 : '<UNK>' → [151643] '<|endoftext|>'
|
| 117 |
+
✔ 2 : '<CLS>' → [151643] '<|endoftext|>'
|
| 118 |
+
✔ 3 : '<SEP>' → [151643] '<|endoftext|>'
|
| 119 |
+
✔ 4 : '<MASK_TOKEN>' → [151643] '<|endoftext|>'
|
| 120 |
+
✔ 5 : '<BOS_TOKEN>' → [151643] '<|endoftext|>'
|
| 121 |
+
✔ 6 : '<EOS_TOKEN>' → [151643] '<|endoftext|>'
|
| 122 |
+
✔ 7 : '<EOP_TOKEN>' → [151643] '<|endoftext|>'
|
| 123 |
+
✔ 255000 : '<|START_OF_TURN_TOKEN|>' → [151644] '<|im_start|>'
|
| 124 |
+
✔ 255001 : '<|END_OF_TURN_TOKEN|>' → [151645] '<|im_end|>'
|
| 125 |
+
✔ 255002 : '<|YES_TOKEN|>' → [151643] '<|endoftext|>'
|
| 126 |
+
✔ 255003 : '<|NO_TOKEN|>' → [151643] '<|endoftext|>'
|
| 127 |
+
✔ 255004 : '<|GOOD_TOKEN|>' → [151643] '<|endoftext|>'
|
| 128 |
+
✔ 255005 : '<|BAD_TOKEN|>' → [151643] '<|endoftext|>'
|
| 129 |
+
✔ 255006 : '<|USER_TOKEN|>' → [872, 198] 'user\n'
|
| 130 |
+
✔ 255007 : '<|CHATBOT_TOKEN|>' → [77091, 198] 'assistant\n'
|
| 131 |
+
✔ 255008 : '<|SYSTEM_TOKEN|>' → [8948, 198] 'system\n'
|
| 132 |
+
✔ 255019 : '<|START_THINKING|>' → [13708, 766, 29] '<think>'
|
| 133 |
+
✔ 255020 : '<|END_THINKING|>' → [522, 26865, 29] '</think>'
|
| 134 |
+
✔ 255021 : '<|START_RESPONSE|>' → [151643] '<|endoftext|>'
|
| 135 |
+
✔ 255022 : '<|END_RESPONSE|>' → [151643] '<|endoftext|>'
|
| 136 |
+
✔ 255023 : '<|START_ACTION|>' → [151657] '<tool_call>'
|
| 137 |
+
✔ 255024 : '<|END_ACTION|>' → [151658] '</tool_call>'
|
| 138 |
+
✔ 255025 : '<|START_TOOL_RESULT|>' → [27, 14172, 9655, 29] '<tool_response>'
|
| 139 |
+
✔ 255026 : '<|END_TOOL_RESULT|>' → [522, 14172, 9655, 29] '</tool_response>'
|
| 140 |
+
✔ 255029 : '<|BEGINNING_OF_PREFIX_FIM_TOKEN|>' → [151659] '<|fim_prefix|>'
|
| 141 |
+
✔ 255030 : '<|BEGINNING_OF_MIDDLE_FIM_TOKEN|>' → [151660] '<|fim_middle|>'
|
| 142 |
+
✔ 255031 : '<|BEGINNING_OF_SUFFIX_FIM_TOKEN|>' → [151661] '<|fim_suffix|>'
|
| 143 |
+
✔ 255032 : '<|END_OF_MIDDLE_FIM_TOKEN|>' → [151660] '<|fim_middle|>'
|
| 144 |
+
|
| 145 |
+
NOTE: Using an "untied" copy of 'embed_tokens.weight' as new 'lm_head.weight' tensor...
|
| 146 |
+
|
| 147 |
+
Transplanting tokens: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████| 255033/255033 [01:58<00:00, 2145.75token/s]
|
| 148 |
+
|
| 149 |
+
Transplant mappings:
|
| 150 |
+
- 1 to 1 : 87077 (34%)
|
| 151 |
+
- 2 to 1 : 117015 (46%)
|
| 152 |
+
- 3 to 1 : 33833 (13%)
|
| 153 |
+
- 4 to 1 : 10325 (4%)
|
| 154 |
+
- 5 to 1 : 3415 (1.3%)
|
| 155 |
+
- 6 to 1 : 1486 (0.58%)
|
| 156 |
+
- 7 to 1 : 761 (0.3%)
|
| 157 |
+
- 8 to 1 : 440 (0.17%)
|
| 158 |
+
- 9 to 1 : 302 (0.12%)
|
| 159 |
+
- 10 to 1 : 177 (0.069%)
|
| 160 |
+
- 11 to 1 : 88 (0.035%)
|
| 161 |
+
- 12 to 1 : 47 (0.018%)
|
| 162 |
+
- 13 to 1 : 28 (0.011%)
|
| 163 |
+
- 14 to 1 : 15 (0.0059%)
|
| 164 |
+
- 15 to 1 : 8 (0.0031%)
|
| 165 |
+
- 16 to 1 : 6 (0.0024%)
|
| 166 |
+
- 17 to 1 : 1 (0.00039%)
|
| 167 |
+
- 18 to 1 : 3 (0.0012%)
|
| 168 |
+
- 19 to 1 : 1 (0.00039%)
|
| 169 |
+
- 21 to 1 : 2 (0.00078%)
|
| 170 |
+
- 36 to 1 : 1 (0.00039%)
|
| 171 |
+
- 37 to 1 : 1 (0.00039%)
|
| 172 |
+
- 39 to 1 : 1 (0.00039%)
|
| 173 |
+
|
| 174 |
+
Head initialized with:
|
| 175 |
+
- Copies : 87077 (34%)
|
| 176 |
+
- Means : 167956 (66%)
|
| 177 |
+
- Zeros : 967 (0.38%)
|
| 178 |
+
|
| 179 |
+
Output model configuration:
|
| 180 |
+
- Output vocabulary size : 256000
|
| 181 |
+
- Output num layers : 24 (tied embeddings = False)
|
| 182 |
+
- Output hidden size : 896
|
| 183 |
+
- Output attention heads : 14
|
| 184 |
+
- Output intermediate size : 4864 (ratio = 1:5.4)
|
| 185 |
+
- Output total parameters : 816650112 (0.82B)
|
| 186 |
+
-- Embedding parameters : 458752000 (0.46B)
|
| 187 |
+
-- Non-embedding parameters : 357898112 (0.36B)
|
| 188 |
+
|
| 189 |
+
Saving model and tokenizer to 'command-a-03-2025-DRAFT-0.8B-UNTRAINED' folder
|
| 190 |
+
|
| 191 |
+
Patching 'torch_dtype' in 'command-a-03-2025-DRAFT-0.8B-UNTRAINED/config.json' based on actual saved tensors
|
| 192 |
+
- Updated 'torch_dtype' to 'bfloat16' based on actual tensor dtype
|
| 193 |
+
|
| 194 |
+
Operation completed successfully (ignore any 'segmentation fault' that follows!!!)
|
| 195 |
+
```
|
| 196 |
+
|
| 197 |
+
## 2. The following datasets were used to create a fine-tuning dataset of ~2.4B tokens:
|
| 198 |
+
|
| 199 |
+
- [agentlans/common-crawl-sample](https://huggingface.co/datasets/agentlans/common-crawl-sample)
|
| 200 |
+
- [bigcode/the-stack-smol-xl](https://huggingface.co/datasets/bigcode/the-stack-smol-xl)
|
| 201 |
+
- [rombodawg/Everything_Instruct](https://huggingface.co/datasets/rombodawg/Everything_Instruct) (NOTE: `output` field only)
|
| 202 |
+
|
| 203 |
+
formatted just between `<|END_OF_TURN_TOKEN|>` tags.
|
| 204 |
+
|
| 205 |
+
## 3. The model was then trained using [qlora-pipe-lite](https://github.com/jukofyork/qlora-pipe-lite) for 1 epoch with a batch size of 60 and a sequence length of 32k (~2M tokens per step):
|
| 206 |
+
|
| 207 |
+
```toml
|
| 208 |
+
# ==============================
|
| 209 |
+
# MODEL AND OUTPUT CONFIGURATION
|
| 210 |
+
# ==============================
|
| 211 |
+
|
| 212 |
+
model_dir = 'models/command-a-03-2025-DRAFT-0.8B-UNTRAINED'
|
| 213 |
+
output_dir = 'finetuned'
|
| 214 |
+
|
| 215 |
+
# ===========================
|
| 216 |
+
# TRAINING TYPE CONFIGURATION
|
| 217 |
+
# ===========================
|
| 218 |
+
|
| 219 |
+
full_fine_tune = true
|
| 220 |
+
|
| 221 |
+
# =======================
|
| 222 |
+
# OPTIMIZER CONFIGURATION
|
| 223 |
+
# =======================
|
| 224 |
+
|
| 225 |
+
lr = 5e-5
|
| 226 |
+
|
| 227 |
+
# ======================
|
| 228 |
+
# TRAINING CONFIGURATION
|
| 229 |
+
# ======================
|
| 230 |
+
|
| 231 |
+
sequence_len = 32768
|
| 232 |
+
|
| 233 |
+
gradient_accumulation_steps = 10 # 10×6 = batch size 60, 10×6×32768 = ~2M tokens per step
|
| 234 |
+
|
| 235 |
+
# =====================
|
| 236 |
+
# DATASET CONFIGURATION
|
| 237 |
+
# =====================
|
| 238 |
+
|
| 239 |
+
drop_tails = true
|
| 240 |
+
|
| 241 |
+
[[datasets]]
|
| 242 |
+
dataset_path = 'datasets/common-crawl-sample/*.json'
|
| 243 |
+
|
| 244 |
+
[[datasets]]
|
| 245 |
+
dataset_path = 'datasets/the-stack-smol-xl/*.jsonl'
|
| 246 |
+
|
| 247 |
+
[[datasets]]
|
| 248 |
+
dataset_path = 'datasets/rombodawg-Everything-Instruct/*.json'
|
| 249 |
+
```
|
| 250 |
+
|
| 251 |
+
I used six `RTX A6000` GPUs over three nodes and hence the `60` batch size (`6 x 10 gradient accumulation steps = 60`).
|
| 252 |
+
|
| 253 |
+

|