Skip to content

Commit

Permalink
Model llama 3.2 (#734)
Browse files Browse the repository at this point in the history
* fixed typo

* added llama 3.2-1b

* configured 3b

* configured instruct models
  • Loading branch information
bryce13950 authored Sep 26, 2024
1 parent 0eda78f commit 4172ce8
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 1 deletion.
2 changes: 1 addition & 1 deletion transformer_lens/HookedEncoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def from_pretrained(
if move_to_device:
model.to(cfg.device)

print(f"Loaded pretrained model {model_name} into HookedTransformer")
print(f"Loaded pretrained model {model_name} into HookedEncoder")

return model

Expand Down
80 changes: 80 additions & 0 deletions transformer_lens/loading_from_pretrained.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@
"meta-llama/Meta-Llama-3-8B-Instruct",
"meta-llama/Meta-Llama-3-70B",
"meta-llama/Meta-Llama-3-70B-Instruct",
"meta-llama/Llama-3.2-1B",
"meta-llama/Llama-3.2-3B",
"meta-llama/Llama-3.2-1B-Instruct",
"meta-llama/Llama-3.2-3B-Instruct",
"Baidicoot/Othello-GPT-Transformer-Lens",
"bert-base-cased",
"roneneldan/TinyStories-1M",
Expand Down Expand Up @@ -885,6 +889,82 @@ def convert_hf_model_config(model_name: str, **kwargs):
"final_rms": True,
"gated_mlp": True,
}
elif "Llama-3.2-1B" in official_model_name:
cfg_dict = {
"d_model": 2048,
"d_head": 64,
"n_heads": 32,
"d_mlp": 8192,
"n_layers": 16,
"n_ctx": 2048, # capped due to memory issues
"eps": 1e-5,
"d_vocab": 128256,
"act_fn": "silu",
"n_key_value_heads": 8,
"normalization_type": "RMS",
"positional_embedding_type": "rotary",
"rotary_adjacent_pairs": False,
"rotary_dim": 64,
"final_rms": True,
"gated_mlp": True,
}
elif "Llama-3.2-3B" in official_model_name:
cfg_dict = {
"d_model": 3072,
"d_head": 128,
"n_heads": 24,
"d_mlp": 8192,
"n_layers": 28,
"n_ctx": 2048, # capped due to memory issues
"eps": 1e-5,
"d_vocab": 128256,
"act_fn": "silu",
"n_key_value_heads": 8,
"normalization_type": "RMS",
"positional_embedding_type": "rotary",
"rotary_adjacent_pairs": False,
"rotary_dim": 128,
"final_rms": True,
"gated_mlp": True,
}
elif "Llama-3.2-1B-Instruct" in official_model_name:
cfg_dict = {
"d_model": 2048,
"d_head": 64,
"n_heads": 32,
"d_mlp": 8192,
"n_layers": 16,
"n_ctx": 2048, # capped due to memory issues
"eps": 1e-5,
"d_vocab": 128256,
"act_fn": "silu",
"n_key_value_heads": 8,
"normalization_type": "RMS",
"positional_embedding_type": "rotary",
"rotary_adjacent_pairs": False,
"rotary_dim": 64,
"final_rms": True,
"gated_mlp": True,
}
elif "Llama-3.2-3B-Instruct" in official_model_name:
cfg_dict = {
"d_model": 3072,
"d_head": 128,
"n_heads": 24,
"d_mlp": 8192,
"n_layers": 28,
"n_ctx": 2048, # capped due to memory issues
"eps": 1e-5,
"d_vocab": 128256,
"act_fn": "silu",
"n_key_value_heads": 8,
"normalization_type": "RMS",
"positional_embedding_type": "rotary",
"rotary_adjacent_pairs": False,
"rotary_dim": 128,
"final_rms": True,
"gated_mlp": True,
}
elif architecture == "GPTNeoForCausalLM":
cfg_dict = {
"d_model": hf_config.hidden_size,
Expand Down

0 comments on commit 4172ce8

Please sign in to comment.