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

[Feat]: Add support for meta llama hf model conversion #286

Merged
merged 1 commit into from
Aug 14, 2023
Merged

[Feat]: Add support for meta llama hf model conversion #286

merged 1 commit into from
Aug 14, 2023

Conversation

Nick-infinity
Copy link
Contributor

Description:
Llama 2 hf models have weights stored with diff name

Description:
Llama 2 hf models have weights stored with diff name

Signed-off-by: Nikhil Gupta <nikhilg.me@gmail.com>
@Nick-infinity
Copy link
Contributor Author

Just parking it here for others. Merge is not required

@karpathy
Copy link
Owner

I'll take it because i expect a lot of finetunes will be in HF format. Ty.

@karpathy karpathy merged commit 013e012 into karpathy:master Aug 14, 2023
@mukel
Copy link
Contributor

mukel commented Aug 15, 2023

The HF models apply a permutation to wq and wk, so the RoPE is different fro the original Llama 2 models. The permutation must be undone to export from HF to llam2a.c's simple .bin files.
It took me quite some time to figure this out, the symptom is it starts degenerating and printing gibberish after ~20 or more tokens.

See https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/convert_llama_weights_to_hf.py#L113-L115

@Nick-infinity
Copy link
Contributor Author

Nick-infinity commented Aug 15, 2023 via email

@karpathy
Copy link
Owner

... PR fix welcome

@calvintwr
Copy link

calvintwr commented Aug 17, 2023

I don't think this is working. #314 @Nick-infinity @karpathy

@atamurad
Copy link
Contributor

The HF models apply a permutation to wq and wk, so the RoPE is different fro the original Llama 2 models. The permutation must be undone to export from HF to llam2a.c's simple .bin files. It took me quite some time to figure this out, the symptom is it starts degenerating and printing gibberish after ~20 or more tokens.

See https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/convert_llama_weights_to_hf.py#L113-L115

@mukel thanks for tracking this down, fixed it here: #326

vinhtran2611 pushed a commit to vinhtran2611/llama2.c that referenced this pull request Jan 20, 2024
[Feat]: Add support for meta llama hf model conversion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants