Text Generation
PEFT
Safetensors
GGUF
English
qwen
lora
qlora
instruction-tuning
conversational
namanadep commited on
Commit
097382c
·
1 Parent(s): 904bac4

Correct the frontier-model distillation claim and one mislabeled metric

Browse files

The "distilled from 6 named frontier models" framing did not hold up:
the parent dataset is a 73-source, 18M-sample general aggregation per
its own card, the data-prep script filters nothing by source model,
and the actual 100 eval prompts are generic instruction tasks, not
frontier-model reasoning content. Reframed accordingly. The unbacked
"parity with frontier models" table (never computed anywhere in this
codebase) is removed. Verified the training loss table against the
real training_metrics.json log: most values matched exactly; one row
was relabeled to its correct step. Adds a data provenance note and a
limitations page. The real 100-prompt comparison and training log are
unchanged.

100_PROMPTS_BASE_VS_FINE_TUNED_MANUS_DISTILL_COMPARISON.md CHANGED
The diff for this file is too large to render. See raw diff
 
README.md CHANGED
@@ -5,159 +5,81 @@ library_name: peft
5
  pipeline_tag: text-generation
6
  tags:
7
  - qwen
8
- - manus
9
- - distillation
10
  - lora
11
  - qlora
12
- - reasoning
13
  - gguf
14
- - cot
15
- - synthetic-data
16
  datasets:
17
  - Manusagents/GPT-5.5-Gemini-3.1-Pro-Grok-4-Claude-Fable-5-Mythos-5-Qwen-3.7-Max-and-more-Distillation-Dataset
18
  language:
19
  - en
20
  ---
21
 
22
- # Qwen2.5-7B Distillation on Manusagents Multi-LLM Dataset
23
 
24
- This repository contains the fine-tuned LoRA adapter and F16 GGUF model for **Qwen2.5-7B-Instruct**, distilled from frontier AI reasoning architectures (**GPT-5.5, Gemini 3.1 Pro, Grok 4, Claude Fable 5, Mythos 5, Qwen 3.7 Max**) using multi-GPU QLoRA Supervised Fine-Tuning (SFT).
25
 
26
- ---
27
-
28
- ## 📌 Executive Summary
29
-
30
- - **Student Model**: `Qwen/Qwen2.5-7B-Instruct` (7.61 Billion Parameters)
31
- - **Teacher Model Distillation Pool**: GPT-5.5, Gemini 3.1 Pro, Grok 4, Claude Fable 5, Mythos 5, Qwen 3.7 Max
32
- - **Teacher Dataset Source**: [`Manusagents Multi-LLM Distillation Dataset`](https://huggingface.co/datasets/Manusagents/GPT-5.5-Gemini-3.1-Pro-Grok-4-Claude-Fable-5-Mythos-5-Qwen-3.7-Max-and-more-Distillation-Dataset) (15,000 multi-turn synthetic reasoning dialogs)
33
- - **Deployment Formats**: LoRA Adapter (155 MB), Merged F16 GGUF (`qwen2.5-7b-manus-distill:latest` in Ollama, 15.2 GB)
34
- - **Hardware Infrastructure**: 2x NVIDIA H200 SXM NVL GPUs (288 GB VRAM)
35
- - **Holdout Benchmark**: 100-Prompt Pre vs. Post Evaluation Benchmark
36
-
37
- ---
38
-
39
- ## 📊 1. Model Performance & Training Dynamics
40
-
41
- ### Training Metrics & Loss Progression
42
- - **Total Training Steps**: `5,064` steps across 3 full epochs (13,500 training records, 1,500 validation records).
43
- - **Training Duration**: **61.31 minutes** (3,678.88 seconds) on 2x NVIDIA H200 NVL GPUs.
44
- - **Initial Training Loss**: `3.4970`
45
- - **Final Training Loss**: **`1.6724`**
46
- - **Final Validation Loss**: **`1.1940`**
47
-
48
- ### Loss Convergence Table
49
-
50
- | Epoch | Step | Learning Rate | Grad Norm | Training Loss |
51
- | :--- | :--- | :--- | :--- | :--- |
52
- | **0.01** | 50 | 1.98e-4 | 1.15 | 2.0216 |
53
- | **0.18** | 300 | 1.88e-4 | 0.77 | 1.9351 |
54
- | **0.50** | 840 | 1.67e-4 | 0.89 | 1.9976 |
55
- | **1.00** | 1,688 | 1.34e-4 | 0.91 | 1.7412 |
56
- | **2.00** | 3,376 | 6.72e-5 | 0.85 | 1.6980 |
57
- | **3.00** | 5,064 | 2.00e-7 | 0.82 | **1.6724** |
58
-
59
- ---
60
-
61
- ## 🔬 2. Baseline Model vs. Fine-Tuned Model Performance
62
-
63
- Evaluation was conducted on a **100-prompt holdout benchmark** spanning code generation, architectural reasoning, scientific analysis, and structured problem-solving.
64
-
65
- ### Quantitative Comparison Summary
66
 
67
- | Metric / Attribute | Base Qwen 2.5-7B Instruct | Fine-Tuned Manus-Distilled Model | Improvement |
68
- | :--- | :--- | :--- | :--- |
69
- | **Average Response Length** | 442.8 characters | **785.4 characters** | **+77.4% (+1.77x expansion)** |
70
- | **Structured Markdown Output** | 42.0% | **94.0%** | **+123.8% relative gain** |
71
- | **Chain-of-Thought Tracing** | Implicit / Direct | **Native `<think>` Reasoning** | **Emergent capability** |
72
- | **Instruction Adherence** | Standard | **High-Density & Precise** | **Significant improvement** |
73
 
74
- ### Qualitative Analysis: Base vs. Fine-Tuned
75
- 1. **Chain-of-Thought Integration**: The fine-tuned model adopts systematic internal reasoning (`<think>`) before outputting code or architectural decisions.
76
- 2. **Dense Technical Depth**: Replaces generic high-level summaries with rigorous, step-by-step implementation details.
77
- 3. **Structured Code & Pseudocode**: Consistently formats programming responses with proper language tags, type annotations, and edge-case handling.
78
 
79
- ---
 
 
80
 
81
- ## 3. Comparative Analysis: Distilled 7B vs. Frontier Teacher Models
82
 
83
- This distilled 7B model distills knowledge and reasoning patterns from frontier models (**Gemini 3.1 Pro, GPT-5.5, Claude Fable 5, Mythos 5, Grok 4, Qwen 3.7 Max**). Below is a comparative capability assessment based on benchmark evaluation data:
84
 
85
- ### Frontier Model Capability & Parity Matrix
86
 
87
- | Capability Dimension | Base Qwen 2.5-7B | **Qwen 2.5-7B Manus Distill (Our Model)** | Frontier Teacher Models (GPT-5.5 / Gemini 3.1 / Claude Fable 5 / Qwen 3.7 Max) | Parity Achieved |
88
- | :--- | :--- | :--- | :--- | :--- |
89
- | **Chain-of-Thought (`<think>`)** | Direct / Basic | **Native Step-by-Step CoT** | ✅ Advanced Deep CoT | **~85 - 90%** |
90
- | **Code & Script Generation** | ⚠️ Basic Implementations | ✅ **Structured & Typed** | ✅ Full Production-Grade | **~80 - 85%** |
91
- | **Architectural Reasoning** | ⚠️ High-Level Summary | ✅ **Detailed Engineering Steps** | ✅ Comprehensive System Design | **~80%** |
92
- | **Mathematical Logic & Proofs** | ⚠️ Occasional Steps | ✅ **Rigorous Verification** | ✅ Advanced Symbolic Math | **~75%** |
93
- | **Multi-Turn Context Retention** | ⚠️ Standard Context | ✅ **High-Density Output** | ✅ Ultra-Long Context | **~70 - 75%** |
94
 
95
- ### Key Distillation Insights by Teacher Model Source
96
- - **GPT-5.5 & Gemini 3.1 Pro**: Contributed structured analytical breakdowns and step-by-step problem decomposition.
97
- - **Claude Fable 5 & Mythos 5**: Enhanced conceptual clarity, academic phrasing, and nuanced technical explanations.
98
- - **Grok 4 & Qwen 3.7 Max**: Provided concise, high-efficiency algorithmic implementations and competitive coding patterns.
99
 
100
- ---
101
 
102
- ## ⚙️ Training Infrastructure & Hyperparameters
 
 
 
 
103
 
104
- ```python
105
- # LoRA Configuration
106
- peft_config = LoraConfig(
107
- r=16,
108
- lora_alpha=32,
109
- target_modules=["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"],
110
- lora_dropout=0.05,
111
- bias="none",
112
- task_type="CAUSAL_LM"
113
- )
114
-
115
- # Training Hyperparameters
116
- sft_config = SFTConfig(
117
- max_length=2048,
118
- per_device_train_batch_size=4,
119
- gradient_accumulation_steps=2,
120
- learning_rate=2e-4,
121
- num_train_epochs=3,
122
- bf16=True,
123
- logging_steps=10
124
- )
125
- ```
126
 
127
- ---
128
 
129
- ## 🚀 Quickstart & Usage
130
 
131
- ### 1. Run in Ollama
132
- ```bash
133
- ollama run qwen2.5-7b-manus-distill:latest "Write a Python function to perform binary search on a rotated sorted array."
134
- ```
135
 
136
- ### 2. Run via Transformers & PEFT
137
  ```python
138
- import torch
139
  from transformers import AutoModelForCausalLM, AutoTokenizer
140
  from peft import PeftModel
 
141
 
142
- base_model_id = "Qwen/Qwen2.5-7B-Instruct"
143
  adapter_id = "namanadep/Qwen2.5-7B-Manus-Distill"
144
 
145
- tokenizer = AutoTokenizer.from_pretrained(base_model_id)
146
- base_model = AutoModelForCausalLM.from_pretrained(
147
- base_model_id,
148
- torch_dtype=torch.bfloat16,
149
- device_map="auto"
150
  )
151
- model = PeftModel.from_pretrained(base_model, adapter_id)
 
152
 
153
- messages = [{"role": "user", "content": "Explain the trade-offs between REST and gRPC in microservice architectures."}]
154
- text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
155
- inputs = tokenizer(text, return_tensors="pt").to(model.device)
156
 
157
- outputs = model.generate(**inputs, max_new_tokens=512)
158
- print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
159
- ```
 
 
 
 
160
 
161
- ### 3. View Full 100-Prompt Comparison Benchmark
162
- View the complete side-by-side prompt output report at:
163
- [`100_PROMPTS_BASE_VS_FINE_TUNED_MANUS_DISTILL_COMPARISON.md`](./100_PROMPTS_BASE_VS_FINE_TUNED_MANUS_DISTILL_COMPARISON.md)
 
5
  pipeline_tag: text-generation
6
  tags:
7
  - qwen
 
 
8
  - lora
9
  - qlora
10
+ - instruction-tuning
11
  - gguf
 
 
12
  datasets:
13
  - Manusagents/GPT-5.5-Gemini-3.1-Pro-Grok-4-Claude-Fable-5-Mythos-5-Qwen-3.7-Max-and-more-Distillation-Dataset
14
  language:
15
  - en
16
  ---
17
 
18
+ # Qwen2.5-7B QLoRA Fine-Tune on a Large Mixed-Source Instruction Dataset
19
 
20
+ Fine-tunes `Qwen/Qwen2.5-7B-Instruct` with QLoRA on 15,000 instruction/response pairs sampled from a large public dataset aggregation, then evaluates the result against the untouched base model on 100 held-out prompts.
21
 
22
+ Full code and write-up: [github.com/namanadep/qwen2.5-7b-manus-distill](https://github.com/namanadep/qwen2.5-7b-manus-distill).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
+ ## What this model was actually trained on
 
 
 
 
 
25
 
26
+ An earlier version of this project's documentation described it as distilled from six named frontier models (GPT-5.5, Gemini 3.1 Pro, Grok 4, Claude Fable 5, Mythos 5, Qwen 3.7 Max). That framing does not hold up:
 
 
 
27
 
28
+ - The training data comes from [`Manusagents/GPT-5.5-Gemini-3.1-Pro-Grok-4-Claude-Fable-5-Mythos-5-Qwen-3.7-Max-and-more-Distillation-Dataset`](https://huggingface.co/datasets/Manusagents/GPT-5.5-Gemini-3.1-Pro-Grok-4-Claude-Fable-5-Mythos-5-Qwen-3.7-Max-and-more-Distillation-Dataset). That dataset's own card describes itself as "The Open Distillation Codex": an aggregation of 18M+ samples from 73 different open-source datasets across 8 categories (coding, science, cybersecurity, math, general instruction), 76 GB total. Its card lists a different, larger set of source models than this project's name suggests (Claude Opus 4.8, GPT-5.5, Gemini 3.5 and Pro 3.2, Grok 4.4, DeepSeek v4, Fable-5), and never mentions "Mythos 5" or "Qwen 3.7 Max" at all.
29
+ - `src/prepare_dataset.py`, the script that built this project's training set, reads whatever JSONL shards were cached from that aggregation and takes the first 15,000 valid instruction/response records it finds. It does not check, record, or filter by which of the 73 upstream sources or which model produced any given example.
30
+ - The actual 100 evaluation prompts (see `100_PROMPTS_BASE_VS_FINE_TUNED_MANUS_DISTILL_COMPARISON.md`) are generic instruction-following tasks: "write some code that stores data in a dictionary," "name the four types of teeth humans have," "what is the latest information about the upcoming iPhone 12." These read as standard instruction-tuning-dataset content, not curated frontier-model reasoning traces.
31
 
32
+ What's accurate: this is a QLoRA fine-tune of Qwen2.5-7B-Instruct on 15,000 general-purpose instruction/response examples drawn from a large, unfiltered public aggregation. Whether any specific example originated from one of the named frontier models is unverified and, per the pipeline itself, unverifiable after the fact.
33
 
34
+ ## What the evaluation actually shows
35
 
36
+ The fine-tuned model answers in a noticeably more concise, direct style that matches the gold reference format, where the base model tends to over-explain. Example (prompt 1, "write some code that stores the following data in a dictionary"):
37
 
38
+ - Base model: writes a full explanation, invents example data (name/age/city/occupation), and prints the result with commentary.
39
+ - Fine-tuned model: `person = {"name": "John", "age": 30, "gender": "male"}`, nothing else.
40
+ - Gold reference: `dict = {"author": "Shakespeare", "title": "Romeo and Juliet"}`, also nothing else.
 
 
 
 
41
 
42
+ That pattern (short, direct, format-matching answers replacing verbose explanations) holds across most of the 100 prompts. It's a real, consistent training effect. It's also a much more modest finding than "80-90% parity with frontier models," a claim with no computation behind it anywhere in this codebase; that table has been removed. Full account: `docs/LIMITATIONS_AND_HONESTY.md` on the GitHub repo.
 
 
 
43
 
44
+ ## Training (verified against the real training log)
45
 
46
+ - Base model: `Qwen/Qwen2.5-7B-Instruct` (7.61B parameters).
47
+ - Method: QLoRA, rank 16, alpha 32, targeting all linear projections, via TRL's `SFTTrainer`.
48
+ - Data: 13,500 training / 1,500 validation records, 3 epochs, 5,064 steps, effective batch size 16.
49
+ - Hardware: 2x NVIDIA H200 SXM NVL GPUs, 61.31 minutes total training time.
50
+ - Loss: 3.4970 at step 10 to 1.6724 at step 5,064 (final). Final validation loss 1.1943.
51
 
52
+ `training_metrics.json` in this repository is the real `Trainer` log (510 entries). I checked the loss-table values published in the original README against it: the values at steps 50, 300, 840, and the final step all match to full float precision. One row didn't: the original table listed a loss of 1.6980 at "epoch 2.00, step 3,376," but that exact loss value actually occurs at step 2,400 (epoch 1.42) in the log. It's a real logged number, just attached to the wrong step, likely a labeling bug rather than an invented figure. This version's numbers are pulled directly from `training_metrics.json`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
+ ## Data provenance and terms
55
 
56
+ Training data is drawn from a large, unfiltered public aggregation (`Manusagents/...-Distillation-Dataset`) whose own documentation states it aggregates model-generated content from multiple frontier LLMs, but this project's pipeline does not track or verify which model produced any specific example it used. If any of that upstream content originates from providers whose usage policies restrict training competing models on their outputs, those terms would apply regardless of whether this project's own code can identify which examples they affect. Review the source dataset's documentation before redistributing or commercializing a model trained this way.
57
 
58
+ ## Usage
 
 
 
59
 
 
60
  ```python
 
61
  from transformers import AutoModelForCausalLM, AutoTokenizer
62
  from peft import PeftModel
63
+ import torch
64
 
65
+ base_id = "Qwen/Qwen2.5-7B-Instruct"
66
  adapter_id = "namanadep/Qwen2.5-7B-Manus-Distill"
67
 
68
+ tok = AutoTokenizer.from_pretrained(base_id, trust_remote_code=True)
69
+ model = AutoModelForCausalLM.from_pretrained(
70
+ base_id, torch_dtype=torch.bfloat16, device_map="auto", trust_remote_code=True
 
 
71
  )
72
+ model = PeftModel.from_pretrained(model, adapter_id)
73
+ ```
74
 
75
+ ## Repository contents
 
 
76
 
77
+ - `adapter_model.safetensors`, `adapter_config.json`, `chat_template.jinja`, `tokenizer.json`, `tokenizer_config.json`: LoRA adapter and tokenizer files.
78
+ - `qwen2.5-7b-manus-distill.gguf`: F16 GGUF export for Ollama and llama.cpp (15.2 GB).
79
+ - `100_PROMPTS_BASE_VS_FINE_TUNED_MANUS_DISTILL_COMPARISON.md`: the real 100-prompt base/fine-tuned/gold comparison.
80
+ - `training_metrics.json`: the real training log this README's numbers are drawn from.
81
+ - `src/`: training, evaluation, and export scripts, mirrored and kept current on [GitHub](https://github.com/namanadep/qwen2.5-7b-manus-distill).
82
+
83
+ ## License
84
 
85
+ Apache 2.0 for the code and documentation in this repository. The base Qwen2.5 model and the upstream dataset keep their own terms; see the data provenance note above.
 
 
docs/LIMITATIONS_AND_HONESTY.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Limitations and honesty
2
+
3
+ This page exists because an earlier draft of this project's documentation made a specific, checkable claim, that the model was distilled from six named frontier models, that does not hold up against the training pipeline or the parent dataset's own documentation. This version states only what's checkable against the files in this repository.
4
+
5
+ ## Claims we stand behind
6
+
7
+ 1. **This is a QLoRA fine-tune of `Qwen2.5-7B-Instruct` on 15,000 general instruction/response pairs.** Verified from [`src/prepare_dataset.py`](../src/prepare_dataset.py) and [`src/train_qlora.py`](../src/train_qlora.py).
8
+ 2. **The reported training metrics are real.** [`training_metrics.json`](../training_metrics.json) is a genuine `Trainer` log with 510 entries. Spot-checking the original README's loss table against it: values at steps 50, 300, 840, and the final step (5,064) match to full float precision. `train_loss` (1.6724), `num_train_samples` (13,500), `num_val_samples` (1,500), `epochs` (3), and `total_train_time_min` (61.31) all match exactly.
9
+ 3. **The fine-tuned model produces shorter, more direct answers that match the training data's gold format, replacing the base model's tendency to over-explain.** This is a consistent, checkable pattern across the 100-prompt comparison, not an isolated example.
10
+
11
+ ## Claims we do not make
12
+
13
+ | Non-claim | Why |
14
+ |---|---|
15
+ | "Distilled from GPT-5.5, Gemini 3.1 Pro, Grok 4, Claude Fable 5, Mythos 5, Qwen 3.7 Max" | The training script (`src/prepare_dataset.py`) takes the first 15,000 valid records from cached shards of a 73-source, 18M-sample aggregation, with no field or logic that records or filters by source model. The parent dataset's own card lists a different, larger model list (including Claude Opus 4.8, Gemini 3.5, Grok 4.4, DeepSeek v4) and never mentions "Mythos 5" or "Qwen 3.7 Max." There is no way, from this pipeline, to know which model (if any) generated any specific training example. |
16
+ | "~80-90% parity with frontier models" (and the other rows of the original capability matrix) | Not computed anywhere in this codebase. The table was typed directly into the README as prose; no script in `src/` produces it. |
17
+ | "Structured markdown output rose from 42% to 94%" | No markdown-detection or scoring code exists anywhere in this repository. |
18
+ | "Response length increased by 77.4%" | `src/eval_100_prompts_pre_post.py` does save per-response character counts, so a real average could in principle be computed from them, but the intermediate results file that would confirm this specific figure isn't included in the published repository. Treat it as unverified, not as disproven. |
19
+ | Epoch 2.00 / step 3,376 had a training loss of 1.6980 | That loss value is real, but it occurred at step 2,400 (epoch 1.42) in the actual log, not step 3,376. Corrected in this version's training table. |
20
+
21
+ ## Why the "frontier model distillation" framing likely happened
22
+
23
+ The parent dataset's name and branding (`Manusagents/GPT-5.5-Gemini-3.1-Pro-Grok-4-Claude-Fable-5-Mythos-5-Qwen-3.7-Max-and-more-Distillation-Dataset`) itself asserts frontier-model provenance for its contents. A project built on top of it inherited that framing without checking whether the specific 15,000-record sample used here actually came from those models, or from any of the other 72 sources in the aggregation. The 100 evaluation prompts (generic instruction-following tasks, not domain-expert reasoning questions) are more consistent with a broad instruction-tuning corpus than with curated frontier-model output.
24
+
25
+ ## What we would do differently
26
+
27
+ 1. If source-model attribution matters for a project's headline claim, verify it against the actual per-record metadata in the dataset shards before publishing that claim, rather than inheriting the parent dataset's name.
28
+ 2. Publish the intermediate `eval_100_pre_post_results.json` alongside the rendered comparison markdown, so response-length and other derived statistics can be recomputed and checked rather than only reported.
29
+ 3. Replace hand-written "parity" tables with an actual computed metric, even a simple one.