shabul commited on
Commit
9b3dd25
·
verified ·
1 Parent(s): 781eb83

Revert README to original state

Browse files
Files changed (1) hide show
  1. README.md +161 -35
README.md CHANGED
@@ -1,61 +1,187 @@
1
  ---
2
- license: apache-2.0
3
  base_model: Qwen/Qwen2.5-3B-Instruct
4
- tags:
5
- - mlx
6
- - lora
7
- - education
8
- - science
9
- - feynman
10
- - qwen
11
  datasets:
12
  - shabul/feynman-explainer-dataset
13
  language:
14
  - en
15
- library_name: transformers
16
- pipeline_tag: text-generation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  ---
18
 
19
- # 🔬 Feynman Explainer
20
 
21
- > "If you can't explain it simply, you don't understand it well enough."
 
 
 
 
 
 
 
 
22
 
23
- **Feynman Explainer** is a specialized fine-tune of `Qwen/Qwen2.5-3B-Instruct` designed to explain complex concepts using the Richard Feynman method: building intuition from the ground up with concrete analogies and everyday language.
24
 
25
- ## 🌟 Key Features
 
26
 
27
- - **Analogy-First Teaching:** Opens with a scenario you already understand before introducing abstraction.
28
- - **Jargon Management:** Technical terms are only introduced after the concept is clear, and always unpacked immediately.
29
- - **Flowing Prose:** Avoids dry bullet points in favor of conversational, enthusiastic explanations.
30
- - **MLX Optimized:** Designed for seamless local execution on Mac hardware.
31
 
32
- ## 🚀 Quickstart (MLX)
33
 
34
  ```python
35
  from mlx_lm import load, generate
36
 
37
  model, tokenizer = load("shabul/qwen2.5-3b-feynman-explainer")
38
 
39
- prompt = "Why does ice float on water?"
40
-
41
  messages = [
42
- {"role": "system", "content": "You are a Feynman-style explainer. For every question, build intuition from the ground up using concrete analogies and everyday language. No jargon until it's earned. No bullet points. Pure flowing prose."},
43
- {"role": "user", "content": prompt}
 
 
 
44
  ]
45
- input_ids = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
46
-
47
- response = generate(model, tokenizer, prompt=input_ids, max_tokens=400)
48
- print(response)
49
  ```
50
 
51
- ## 🧠 Training Details
 
 
 
 
 
 
 
52
 
53
- - **Base Model:** `Qwen/Qwen2.5-3B-Instruct`
54
- - **Dataset:** `shabul/feynman-explainer-dataset` (Synthetic dataset of 300+ scientific and technical concepts).
55
- - **Technique:** LoRA (Low-Rank Adaptation)
56
- - **Validation Loss:** 1.612
57
- - **Hardware:** Trained locally on an Apple M5 MacBook Pro (24GB Unified Memory).
58
 
59
- ## 📜 License
 
 
 
 
 
 
 
60
 
61
- This model is licensed under the Apache 2.0 license.
 
1
  ---
 
2
  base_model: Qwen/Qwen2.5-3B-Instruct
 
 
 
 
 
 
 
3
  datasets:
4
  - shabul/feynman-explainer-dataset
5
  language:
6
  - en
7
+ library_name: mlx
8
+ tags:
9
+ - lora
10
+ - fine-tuned
11
+ - feynman
12
+ - explanation
13
+ - teaching
14
+ - apple-silicon
15
+ - mlx-lm
16
+ - qwen2.5
17
+ license: apache-2.0
18
+ ---
19
+
20
+ # qwen2.5-3b-feynman-explainer
21
+
22
+ > *"You don't understand something unless you can explain it to your grandmother."* — Feynman
23
+
24
+ A LoRA fine-tune of Qwen2.5-3B-Instruct trained to explain anything the way
25
+ Richard Feynman did — from the ground up, with vivid analogies, no jargon until
26
+ it's earned, and pure flowing prose.
27
+
28
+ Built by **Shabul Abdul**, Sr. Data Scientist.
29
+ Trained on Apple M5 MacBook Pro · 24 GB unified memory · Apple MLX.
30
+
31
+ ---
32
+
33
+ ## Try it right here — no download needed
34
+
35
+ The difference is immediate. Same model weights, same question. Just a style shift.
36
+
37
+ ---
38
+
39
+ ### "How does gradient descent work?"
40
+
41
+ **Base model** (`Qwen2.5-3B-Instruct`, no fine-tuning):
42
+ > Gradient descent is an optimization algorithm used in machine learning to minimize
43
+ > a loss function. It works by computing the gradient of the loss with respect to
44
+ > the model parameters and updating the parameters in the opposite direction of the
45
+ > gradient, scaled by a learning rate. This process is repeated iteratively until
46
+ > convergence...
47
+
48
+ **This model** (Feynman fine-tuned):
49
+ > Imagine you're blindfolded somewhere on a hilly landscape, and your only goal is to
50
+ > reach the lowest valley. You can't see anything — but you can feel the slope of the
51
+ > ground under your feet.
52
+ >
53
+ > Here's what you do: take a small step in whichever direction feels most downhill.
54
+ > Then stop. Feel the slope again. Take another step downhill. Repeat.
55
+ >
56
+ > That's gradient descent. The "gradient" is just the slope — which direction is up,
57
+ > how steep it is. You always step opposite to it, because you're trying to go *down*.
58
+ > The "learning rate" is how big each step is. Too big and you overshoot the valley
59
+ > and bounce around the hillside forever. Too small and you're shuffling along for
60
+ > eternity.
61
+ >
62
+ > The key insight: you never need to see the whole landscape. You only ever need to
63
+ > know the slope exactly where you're standing.
64
+
65
+ ---
66
+
67
+ ### "What is entropy?"
68
+
69
+ **Base model:**
70
+ > Entropy is a thermodynamic quantity representing the amount of disorder or randomness
71
+ > in a system. In information theory, entropy measures the average amount of information
72
+ > or uncertainty in a random variable. Higher entropy indicates greater disorder...
73
+
74
+ **This model:**
75
+ > Here's something that bothered physicists for a long time: heat always flows from
76
+ > hot things to cold things. Never the other way. You've never seen a warm cup of
77
+ > coffee spontaneously get hotter while the air around it gets colder. But why not?
78
+ > The laws of physics don't actually forbid it.
79
+ >
80
+ > The answer is entropy, and it's not really about disorder — that's a metaphor that
81
+ > confuses more than it helps. It's about *counting*.
82
+ >
83
+ > Take a room with all the air molecules crammed in one corner. That's one arrangement.
84
+ > Now consider all the arrangements where molecules are spread out evenly — there are
85
+ > astronomically more of them. So when molecules move randomly, they almost certainly
86
+ > end up spread out, simply because there are so many more ways to be spread out than
87
+ > bunched up.
88
+ >
89
+ > Entropy is just a measure of how many arrangements look like what you've got.
90
+ > High entropy means lots of arrangements produce this same picture. The reason entropy
91
+ > always increases is brutally simple: there are more ways to be disordered than ordered,
92
+ > so randomness always drifts toward disorder.
93
+
94
+ ---
95
+
96
+ ### "What is a p-value?"
97
+
98
+ **Base model:**
99
+ > A p-value is the probability of obtaining results at least as extreme as the observed
100
+ > results, assuming the null hypothesis is true. If the p-value is below the significance
101
+ > threshold (typically 0.05), the result is considered statistically significant...
102
+
103
+ **This model:**
104
+ > Scientists get this wrong all the time, so let's go slowly.
105
+ >
106
+ > You've run an experiment. You gave half the patients a drug and half a sugar pill,
107
+ > and the drug group got better faster. Great — but here's the question you should be
108
+ > asking: *could this difference have shown up just by chance, even if the drug does
109
+ > absolutely nothing?*
110
+ >
111
+ > The p-value answers that question. It says: if the drug had zero effect, what's the
112
+ > probability I'd still see a difference this big, just from the randomness of who got
113
+ > sick and who got better?
114
+ >
115
+ > If that probability is tiny — say, 2% — we say p = 0.02. That's suspicious. It's
116
+ > hard to believe chance alone did this.
117
+ >
118
+ > Here's what p-value does NOT mean, and this is where everyone goes wrong: it is not
119
+ > the probability that the drug works. It's not even close to that. It's only the
120
+ > probability of your data, assuming the drug doesn't work.
121
+ >
122
+ > The difference matters enormously. One is a statement about the drug. The other is
123
+ > a statement about your data.
124
+
125
  ---
126
 
127
+ ## Training details
128
 
129
+ | | |
130
+ |---|---|
131
+ | **Base model** | `Qwen/Qwen2.5-3B-Instruct` |
132
+ | **Method** | LoRA (rank 16, alpha 32) |
133
+ | **Dataset** | [`shabul/feynman-explainer-dataset`](https://huggingface.co/datasets/shabul/feynman-explainer-dataset) · 575 synthetic prompts, chat-formatted into 517 train + 58 validation rows |
134
+ | **Hardware** | Apple M5 MacBook Pro · 24 GB unified memory |
135
+ | **Framework** | `mlx-lm` (Apple MLX) |
136
+ | **Iterations** | 1,500 steps |
137
+ | **Learning rate** | 2e-4 |
138
 
139
+ *Full loss curve and throughput stats will be added after training.*
140
 
141
+ The full training dataset is published here:
142
+ [`shabul/feynman-explainer-dataset`](https://huggingface.co/datasets/shabul/feynman-explainer-dataset)
143
 
144
+ ---
 
 
 
145
 
146
+ ## How to run
147
 
148
  ```python
149
  from mlx_lm import load, generate
150
 
151
  model, tokenizer = load("shabul/qwen2.5-3b-feynman-explainer")
152
 
153
+ question = "Why does ice float on water?"
 
154
  messages = [
155
+ {"role": "system", "content": (
156
+ "You are a Feynman-style explainer. Build intuition from the ground up "
157
+ "using concrete analogies. No jargon until it's earned. Flowing prose only."
158
+ )},
159
+ {"role": "user", "content": question},
160
  ]
161
+ prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
162
+ print(generate(model, tokenizer, prompt=prompt, max_tokens=400))
 
 
163
  ```
164
 
165
+ ---
166
+
167
+ ## Why this works
168
+
169
+ Style transfer via LoRA is a different beast from knowledge fine-tuning.
170
+ The base model already knows *what* gradient descent is. We're teaching it
171
+ *how to talk about it* — the rhythm, the analogy-first structure, the short
172
+ declarative sentences, the moment of "here's where most people get confused."
173
 
174
+ Rank 16 (vs. rank 8 for a knowledge fine-tune) gives the adapter enough
175
+ capacity to shift the generative distribution meaningfully. Higher learning
176
+ rate (2e-4) pushes the style harder in fewer steps.
 
 
177
 
178
+ ---
179
+
180
+ ## Author
181
+
182
+ **Shabul Abdul** — Sr. Data Scientist
183
+ [huggingface.co/shabul](https://huggingface.co/shabul)
184
+
185
+ ---
186
 
187
+ *No cloud GPUs. No PhD required. Just a MacBook and a good idea.*