Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Variable name #476

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lit_llama/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def llama_model_lookup(checkpoint: dict) -> str:

Checks the width of the lm_head.weight matrix, as these uniquely identify the model.
"""
embedding_size = checkpoint['transformer.wte.weight'].shape[1]
embedding_size = checkpoint['lm_head.weight'].shape[1]
Copy link
Contributor

@rasbt rasbt Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the original key should exist for the original Llama weights. Maybe you downloaded the weights from somewhere else? Perhaps the following would be a good compromise:

Suggested change
embedding_size = checkpoint['lm_head.weight'].shape[1]
if 'transformer.wte.weight' in checkpoint:
embedding_size = checkpoint['transformer.wte.weight'].shape[1]
elif 'lm_head.weight' in checkpoint:
embedding_size = checkpoint['lm_head.weight'].shape[1]
else:
raise ValueError("Neither 'transformer.wte.weight' nor 'lm_head.weight' found in the checkpoint")

return llama_model_sizes[embedding_size]


Expand Down