modrill commited on
Commit
4889e4c
·
verified ·
1 Parent(s): c8b9c96

Add README.md

Browse files
Files changed (1) hide show
  1. README.md +119 -0
README.md ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Qwen/Qwen3-4B-Base
4
+ tags:
5
+ - code
6
+ - reasoning
7
+ - lora-merged
8
+ - livecodebench
9
+ pipeline_tag: text-generation
10
+ library_name: transformers
11
+ ---
12
+
13
+ # CodeThink-V4-Qwen3-4B-Mix
14
+
15
+ Research checkpoint: **Qwen/Qwen3-4B-Base** (`906bfd4b4dc7f14ee4320094d8b41684abff8539`) after V4 LoRA SFT on a **Mix Distillation** payload, then merged to full weights.
16
+
17
+ This is a **research checkpoint, not a product**. Single-seed diagnostic numbers only. Do not treat DEV256 as a leaderboard claim.
18
+
19
+ License: **Apache-2.0**, inherited from [Qwen/Qwen3-4B-Base](https://huggingface.co/Qwen/Qwen3-4B-Base) (verified from the local base `README.md` / `LICENSE`).
20
+
21
+ ## Base, teacher, and data
22
+
23
+ | | |
24
+ |---|---|
25
+ | Student | `Qwen/Qwen3-4B-Base` revision `906bfd4b4dc7f14ee4320094d8b41684abff8539` |
26
+ | Recipe | Mix Distillation **Mix-Large** (Li et al., 2025, ["Small Models Struggle to Learn from Strong Reasoners"](https://arxiv.org/abs/2502.12143), arXiv:2502.12143): **0.2** traces from `Qwen/Qwen3-30B-A3B-Thinking-2507` : **0.8** traces from `Qwen/Qwen3-4B-Thinking-2507`, one teacher trace per problem |
27
+ | Problems | **4155** unique problems (`source_1ep_rows`); physical 2-epoch concat = **8310** rows |
28
+ | Mix split | **831** (30B) : **3324** (4B) rows in the 1-epoch mix (`n30`/`n4`) |
29
+ | Dose | **32,424,225** assistant tokens / epoch; endpoint **64,848,450** assistant tokens (2 epochs) |
30
+ | Train seed | **42** |
31
+
32
+ ## Recipe
33
+
34
+ - LoRA **r64 / α128**, dropout 0.0, seven projections: `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj`
35
+ - Embeddings / `lm_head` frozen except **two-sided trainable B-rows** for special tokens **151643** (`<|endoftext|>`), **151667** (`<think>`), **151668** (`</think>`). Qwen3-4B-Base embeddings were tied; training **untied** them. Token ids from `adapter/TOKEN_ROWS_META.json`.
36
+ - Assistant supervised tail: `<|endoftext|>` (**151643**)
37
+ - LR **1e-4**, AdamW (β 0.9/0.95), **cosine** over assistant-token dose, **warmup 6%** (3,890,907 / 64,848,450 tokens), weight decay **0.1** (LoRA; row WD 0)
38
+ - **bf16** activations, fp32 trainable masters, no packing, no truncation, context 32768
39
+ - **2 epochs**, physical concat of the 1-epoch mix (same order). Endpoint-only score; no checkpoint picking.
40
+
41
+ Merged weights in this repo are the 2-epoch endpoint (`step-000920`, 64,848,450 assistant tokens). The LoRA adapter and B-row file are under `adapter/`.
42
+
43
+ ## Evaluation (DEV256)
44
+
45
+ 256-problem LiveCodeBench-derived **dev** split. Seed **3407**, **think** mode, **no `<think>` prefill**, max generation ~32k (model context 32768), sandbox-verified **pass@1**. Temperature 0.6, top-p 0.95, top-k 20.
46
+
47
+ **Cap** = generations that hit the 32k length limit without closing `</think>`.
48
+
49
+ | Model | pass@1 | Cap | Notes |
50
+ |---|---:|---:|---|
51
+ | **CodeThink-V4-Qwen3-4B-Mix** | **73/256** | **136** | this repo; seed 3407 |
52
+ | Qwen3-4B-Base (same contract, think) | 63/256 | 6 | bare base, seed 3407 |
53
+ | Qwen3-4B-Base 5-seed band | 55.2 ± 4.9 | — | seeds {3407→61, 12345→52, 20260903→49, 777→55, 2024→59}; sample SD 4.92 |
54
+
55
+ Single seed. These are research checkpoints, not product scores.
56
+
57
+ ### Why Mix (sibling V4 controls)
58
+
59
+ Pure strong-teacher traces **hurt** this 4B student; a same-size teacher and the 0.2:0.8 mix did not:
60
+
61
+ | Sibling (same student / recipe family) | pass@1 | Cap |
62
+ |---|---:|---:|
63
+ | V4 Q4B-THINK (100% 30B-A3B-Thinking traces) | 60/256 | 150 |
64
+ | V4 Q4B-THINK-T4BDATA (100% 4B-Thinking traces) | 72/256 | 106 |
65
+ | **This Mix 0.2 : 0.8** | **73/256** | **136** |
66
+
67
+ That pattern matches Li et al. 2025 (arXiv:2502.12143): small students often learn worse from much stronger reasoners than from a mixed or same-size teacher.
68
+
69
+ ## Usage
70
+
71
+ Merged full weights; no PEFT required at inference. Think mode: pass `enable_thinking=True` and **do not** prefill `<think>`.
72
+
73
+ ```python
74
+ from transformers import AutoModelForCausalLM, AutoTokenizer
75
+
76
+ repo = "modrill/CodeThink-V4-Qwen3-4B-Mix"
77
+ tokenizer = AutoTokenizer.from_pretrained(repo)
78
+ model = AutoModelForCausalLM.from_pretrained(
79
+ repo, torch_dtype="bfloat16", device_map="auto"
80
+ )
81
+
82
+ system = (
83
+ "You are an expert Python programmer. You will be given a question "
84
+ "(problem specification) and will generate a correct Python program that "
85
+ "matches the specification and passes all tests. You will NOT return "
86
+ "anything except for the program."
87
+ )
88
+ messages = [
89
+ {"role": "system", "content": system},
90
+ {"role": "user", "content": problem_statement},
91
+ ]
92
+ prompt = tokenizer.apply_chat_template(
93
+ messages,
94
+ tokenize=False,
95
+ add_generation_prompt=True,
96
+ enable_thinking=True, # think mode; no <think> prefill
97
+ )
98
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
99
+ output = model.generate(
100
+ **inputs,
101
+ max_new_tokens=32768,
102
+ do_sample=True,
103
+ temperature=0.6,
104
+ top_p=0.95,
105
+ top_k=20,
106
+ )
107
+ print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False))
108
+ ```
109
+
110
+ Stop ids used in the official eval: `151643` (`<|endoftext|>`), `151645` (`<|im_end|>`).
111
+
112
+ ## Repo layout
113
+
114
+ - Root: merged HF weights (`config.json`, `model.safetensors`, tokenizer, `generation_config.json`, `chat_template.jinja`) plus the merge record `OFFICIAL_MERGE_RECEIPT.json`
115
+ - `adapter/`: LoRA (`adapter_config.json`, `adapter_model.safetensors`), two-sided B-rows (`token_rows_both_sides.safetensors`), `TOKEN_ROWS_META.json`, checkpoint `MANIFEST.json`
116
+ - `provenance/`: train `RUN_IDENTITY.json`, `TRAINING_CONFIG.json`, `POLICY.json`; DEV256 `COMPLETE.json`; mix builder and MQ0 near-dup report
117
+ - `MANIFEST.sha256`: sha256 of every uploaded file
118
+
119
+ Optimizer / resume states are **not** included.