forked from ckkissane/crosscoder-model-diff-replication
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrain.py
More file actions
51 lines (46 loc) · 1.11 KB
/
train.py
File metadata and controls
51 lines (46 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# %%
from utils import *
from trainer import Trainer
# %%
device = 'cuda:0'
base_model = HookedTransformer.from_pretrained(
"Qwen/Qwen2.5-1.5B",
device=device,
)
chat_model = HookedTransformer.from_pretrained(
"deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B",
trust_remote_code=True,
device=device,
)
# %%
# all_tokens = load_pile_lmsys_mixed_tokens()
all_tokens = load_pile_chat_tokens()
# %%
default_cfg = {
"seed": 49,
"batch_size": 4096,
"buffer_mult": 128,
"lr": 5e-5,
"num_tokens": 400_000_000,
"l1_coeff": 2,
"beta1": 0.9,
"beta2": 0.999,
"d_in": base_model.cfg.d_model,
"dict_size": 2**14,
"seq_len": 1024,
"enc_dtype": "fp32",
"model_name": "gemma-2-2b",
"site": "resid_pre",
"device": "cuda:0",
"model_batch_size": 4,
"log_every": 100,
"save_every": 30000,
"dec_init_norm": 0.08,
"hook_point": "blocks.14.hook_resid_pre",
"wandb_entity": "mram18900",
"wandb_project": "your-project-name"
}
cfg = arg_parse_update_cfg(default_cfg)
trainer = Trainer(cfg, base_model, chat_model, all_tokens)
trainer.train()
# %%