Cory Trimm commited on
Commit
3952b6c
Β·
verified Β·
1 Parent(s): 3be8113

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +13 -4
  2. guide.html +182 -0
  3. index.html +0 -0
README.md CHANGED
@@ -1,10 +1,19 @@
1
  ---
2
  title: Twin Builder
3
- emoji: πŸŒ–
4
- colorFrom: indigo
5
- colorTo: purple
6
  sdk: static
7
  pinned: false
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  title: Twin Builder
3
+ colorFrom: blue
4
+ colorTo: indigo
 
5
  sdk: static
6
  pinned: false
7
  ---
8
 
9
+ # Twin Builder
10
+
11
+ 60 quick "this or that" questions that distill you onto a trait vector β€” the first step in
12
+ distilling yourself onto a small model you own.
13
+
14
+ Play, then download your answers as SFT/DPO JSONL in the eval's exact prompt format,
15
+ fine-tune a small model, and evaluate it against the held-out sets in the
16
+ [CDT5058/digital-twin-evals](https://huggingface.co/datasets/CDT5058/digital-twin-evals) dataset.
17
+
18
+ Use **Test your twin** (feedback mode) on the end screen to keep grading the twin: every
19
+ correction becomes a free DPO pair for the next round of tuning.
guide.html ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Distill yourself onto a small model β€” Digital Twin Evals</title>
7
+ <style>
8
+ :root { color-scheme: dark; }
9
+ * { box-sizing: border-box; }
10
+ body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
11
+ background: #101418; color: #e8e6e1; line-height: 1.6; }
12
+ .wrap { max-width: 720px; margin: 0 auto; padding: 24px 18px 64px; }
13
+ h1 { font-size: 30px; line-height: 1.2; margin: 8px 0 4px; }
14
+ h2 { font-size: 21px; margin: 36px 0 8px; border-bottom: 1px solid #2a3138; padding-bottom: 6px; }
15
+ h3 { font-size: 17px; margin: 22px 0 6px; }
16
+ p, li { font-size: 15px; color: #c9c7c2; }
17
+ p.lede { font-size: 17px; color: #e8e6e1; }
18
+ a { color: #7cc4ff; }
19
+ .btn { display: inline-block; background: #4f8ff7; color: #fff !important; text-decoration: none;
20
+ font-weight: 700; padding: 14px 28px; border-radius: 12px; margin: 14px 8px 14px 0; font-size: 16px; }
21
+ .btn.ghost { background: #1e242b; border: 1px solid #39424c; }
22
+ .card { background: #161b21; border: 1px solid #2a3138; border-radius: 12px; padding: 16px; margin: 14px 0; }
23
+ .step { display: flex; gap: 12px; margin: 14px 0; }
24
+ .step .n { flex: 0 0 32px; height: 32px; border-radius: 50%; background: #4f8ff7; color: #fff;
25
+ display: flex; align-items: center; justify-content: center; font-weight: 700; }
26
+ code { background: #1e242b; padding: 2px 6px; border-radius: 6px; font-size: 13.5px; color: #ffd9a0; }
27
+ pre { background: #0b0e11; border: 1px solid #2a3138; border-radius: 10px; padding: 14px;
28
+ overflow-x: auto; font-size: 13px; line-height: 1.5; }
29
+ pre code { background: none; padding: 0; color: #d6e2f0; }
30
+ table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 12px 0; }
31
+ th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #2a3138; }
32
+ th { color: #e8e6e1; }
33
+ td { color: #c9c7c2; }
34
+ .note { font-size: 13.5px; color: #9aa0a8; }
35
+ ul { padding-left: 20px; }
36
+ </style>
37
+ </head>
38
+ <body>
39
+ <div class="wrap">
40
+
41
+ <h1>Distill yourself onto a small model</h1>
42
+ <p class="lede">RLHF distills the crowd into big models. This distills <i>you</i> β€” your taste, your
43
+ trade-offs, your moral instincts β€” into a small model that runs on hardware you own.</p>
44
+ <a class="btn" href="game/">Play Twin Builder</a>
45
+ <a class="btn ghost" href="https://github.com/ctrimm/digital-twin-evals">Eval suite on GitHub</a>
46
+
47
+ <h2>The loop</h2>
48
+ <div class="step"><div class="n">1</div><div><b>Play.</b> 60 rapid-fire this-or-that choices in the
49
+ <a href="game/">Twin Builder</a> game (~5 minutes). The twin predicts each answer live.</div></div>
50
+ <div class="step"><div class="n">2</div><div><b>Export.</b> Download your answers as training data β€”
51
+ SFT and DPO JSONL in the eval's exact format.</div></div>
52
+ <div class="step"><div class="n">3</div><div><b>Fine-tune.</b> Train a LoRA adapter on a small base model,
53
+ on your machine or a rented GPU. Minutes, not hours.</div></div>
54
+ <div class="step"><div class="n">4</div><div><b>Evaluate.</b> Run the eval suite against base vs tuned.
55
+ If tuning internalized <i>your</i> taste, the tuned model should match or beat the base model's
56
+ best in-context score on held-out items.</div></div>
57
+
58
+ <h2>Step 1 β€” Play the game</h2>
59
+ <p>Open <a href="game/">Twin Builder</a>, pick a starting prior (your MBTI type, or blank slate β€”
60
+ it's just a starting point), and tap through 60 choices. Answer fast and honestly; there are no right
61
+ answers. A few questions repeat later on purpose β€” that measures how consistent you are with yourself,
62
+ which is the ceiling your twin is scored against. Want more training data? Hit "keep going" for endless mode.</p>
63
+
64
+ <h2>Step 2 β€” Export your data</h2>
65
+ <p>The end screen offers three downloads. Know which is which:</p>
66
+ <ul>
67
+ <li><b>twin-profile.json</b> β€” the <i>measurement</i>: your fitted 10-trait vector plus stats.
68
+ Good for inspection, not for training.</li>
69
+ <li><b>twin-sft.jsonl</b> β€” the <i>training data</i>: one line per answer,
70
+ <code>{"messages": [{"role":"user","content": prompt}, {"role":"assistant","content":"A"}]}</code>.
71
+ Train on this.</li>
72
+ <li><b>twin-dpo.jsonl</b> β€” same answers as preference pairs,
73
+ <code>{"prompt","chosen","rejected"}</code>, for a DPO second stage.</li>
74
+ </ul>
75
+ <p class="note">Prompts are byte-identical to the eval suite's forced-choice format, so fine-tuned
76
+ agreement is directly comparable to in-context scores. Consistency retests are excluded from training
77
+ files. Your answers never leave your device until <i>you</i> download them.</p>
78
+
79
+ <h2>Step 3 β€” Fine-tune</h2>
80
+ <p>You're training a LoRA adapter (a small set of extra weights on a frozen base model), not the full
81
+ model. With 60–500 short examples this is a minutes-scale job. Pick your platform:</p>
82
+
83
+ <h3>A. Your Mac (Apple Silicon) οΏ½οΏ½οΏ½ recommended</h3>
84
+ <p>Private, free, no uploads. <a href="https://github.com/ml-explore/mlx-lm">MLX</a> is the native path.</p>
85
+ <pre><code>pip install mlx-lm
86
+
87
+ # split into train/valid (hold out ~10 for validation)
88
+ mkdir -p twin-data
89
+ head -n 50 twin-sft.jsonl &gt; twin-data/train.jsonl
90
+ tail -n 10 twin-sft.jsonl &gt; twin-data/valid.jsonl
91
+
92
+ python -m mlx_lm.lora --model mlx-community/Qwen3-4B-Instruct-2507-4bit \
93
+ --train --data twin-data --adapter-path ./twin-adapter \
94
+ --iters 300 --batch-size 4
95
+ # run it:
96
+ python -m mlx_lm.generate --model mlx-community/Qwen3-4B-Instruct-2507-4bit \
97
+ --adapter-path ./twin-adapter --prompt "Scenario: ..." --max-tokens 5</code></pre>
98
+ <p class="note">Check <code>mlx_lm.lora --help</code> for current flags. Any small instruct model with an
99
+ MLX 4-bit build works (Qwen3, Llama 3.2, Gemma 3 in the 1–8B range).</p>
100
+
101
+ <h3>B. Google Colab (free) β€” Unsloth + QLoRA</h3>
102
+ <p>No Mac or no Apple Silicon? A free Colab T4 handles ≀8B models in 4-bit via
103
+ <a href="https://github.com/unslothai/unsloth">Unsloth</a>'s turnkey notebooks:</p>
104
+ <ul>
105
+ <li>New notebook β†’ Runtime β†’ Change runtime type β†’ T4 GPU.</li>
106
+ <li><code>pip install</code> per Unsloth's Colab instructions, load a 4-bit base
107
+ (e.g. an Unsloth Qwen3/Llama 3 4-bit build), attach LoRA adapters.</li>
108
+ <li>Upload <code>twin-sft.jsonl</code>, format with the model's chat template, train with TRL's
109
+ <code>SFTTrainer</code>, download the adapter.</li>
110
+ </ul>
111
+ <p class="note">Start from Unsloth's official Colab notebooks β€” they track library changes better than any
112
+ static guide can.</p>
113
+
114
+ <h3>C. Rented GPU β€” RunPod, Modal, Lambda Labs</h3>
115
+ <p>For bigger models or faster turnaround, rent an A100/H100 by the hour and run the same
116
+ Unsloth/TRL script you would on Colab. A short LoRA run like this typically costs a few dollars
117
+ at current rates β€” check pricing before you start.</p>
118
+
119
+ <h3>D. Fine-tuning APIs</h3>
120
+ <p>Services like Together AI and Fireworks offer hosted fine-tuning: upload the JSONL, get back a
121
+ model endpoint. Least setup, least control, and your data leaves your machine β€” the trade-off to weigh.</p>
122
+
123
+ <div class="card">
124
+ <b>A note on Replicate.</b> Replicate's turnkey fine-tuning is built around image models
125
+ (LoRA trainers for Stable Diffusion / Flux). For LLM LoRA it isn't the push-button path β€”
126
+ use B, C, or D above instead. Replicate <i>is</i> useful afterward if you want to host your
127
+ tuned model behind an API.
128
+ </div>
129
+
130
+ <h3>Rough time estimates</h3>
131
+ <p class="note">For this workload specifically β€” 60–500 short examples, LoRA rank 8–16. Dataset size
132
+ and step count dominate; these are ballparks, not benchmarks.</p>
133
+ <table>
134
+ <tr><th>Setup</th><th>Rough time</th></tr>
135
+ <tr><td>MacBook M1–M3 (MLX), 3–8B model</td><td>~5–30 min</td></tr>
136
+ <tr><td>Mac Studio (MLX), 8B+</td><td>~5–20 min</td></tr>
137
+ <tr><td>Colab free T4 (Unsloth QLoRA)</td><td>~15–45 min</td></tr>
138
+ <tr><td>Colab Pro A100</td><td>~5–15 min</td></tr>
139
+ <tr><td>Rented A100 / H100</td><td>~5–15 min + setup</td></tr>
140
+ </table>
141
+
142
+ <h2>Step 4 β€” Evaluate</h2>
143
+ <p>Clone the eval suite and compare base vs tuned on held-out items:</p>
144
+ <pre><code>export OPENAI_BASE_URL=http://localhost:1234/v1
145
+ export OPENAI_API_KEY=lm-studio
146
+ # in-context baseline (no tuning): how well does the base model predict you from K examples?
147
+ inspect eval src/inspect_evals/tasks/daily_decisions.py@daily_decisions_predict \
148
+ --model openai/&lt;base-model-id&gt; -T profile=twin -T k=30
149
+ # then the same task against your fine-tuned model -- agreement should meet or beat it</code></pre>
150
+ <p class="note">The eval items are held out from the game by design β€” the game draws from a separate
151
+ 504-item capture pool, so a tuned model can't win by memorization. Score twins against your
152
+ self-agreement rate (the retest ceiling), not against 100%.</p>
153
+
154
+ <h2>Step 5 β€” Keep it learning (feedback mode)</h2>
155
+ <p>Your twin doesn't freeze after the first fine-tune. On the game's end screen,
156
+ <b>Test your twin</b> starts feedback mode: the twin shows its prediction <i>first</i>,
157
+ and you agree or disagree with each one.</p>
158
+ <ul>
159
+ <li><b>Agree</b> β€” confirms the twin; it keeps learning from the answer.</li>
160
+ <li><b>Disagree</b> β€” you pick the right answer. That correction becomes a DPO pair
161
+ for free: the twin's wrong pick is the <i>rejected</i> response, yours the
162
+ <i>chosen</i> one.</li>
163
+ </ul>
164
+ <p>The end screen reports your twin's feedback accuracy, and the DPO download now includes
165
+ your corrections alongside the base pairs. Re-tune on the accumulated file every so often β€”
166
+ that's the continual loop: play, tune, judge, correct, re-tune.</p>
167
+
168
+ <h2>Notes</h2>
169
+ <ul>
170
+ <li><b>Privacy:</b> the local path (Mac + MLX, or LM Studio) never sends your answers anywhere.
171
+ Your twin can live entirely on your hardware.</li>
172
+ <li><b>Data size:</b> 60 answers is a start. Endless mode in the game grows the set; a few hundred
173
+ diverse answers beats dozens.</li>
174
+ <li><b>DPO:</b> optional second stage after SFT, using <code>twin-dpo.jsonl</code>.</li>
175
+ <li><b>Eval vs train:</b> never train on the 240-item eval set β€” it's the held-out test.</li>
176
+ </ul>
177
+
178
+ <p class="note">Part of <a href="https://github.com/ctrimm/digital-twin-evals">digital-twin-evals</a> β€”
179
+ eval suites for moral dilemmas, preferences, and individual digital twins.</p>
180
+ </div>
181
+ </body>
182
+ </html>
index.html CHANGED
The diff for this file is too large to render. See raw diff