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

error line 200, in from_pretrained assert len(keys) == len(sd) #128

Open
Sandy4321 opened this issue Jan 21, 2024 · 7 comments
Open

error line 200, in from_pretrained assert len(keys) == len(sd) #128

Sandy4321 opened this issue Jan 21, 2024 · 7 comments

Comments

@Sandy4321
Copy link

error line 200, in from_pretrained assert len(keys) == len(sd)

len(keys)
581
len(sd)
629

image

mingpt-master\mingpt-master\mingpt\model.py", line 200, in from_pretrained
assert len(keys) == len(sd)

windows 11 OS
torch version 1.13.1
transformers version 4.36.2

@Sandy4321
Copy link
Author

Python 3.10.11

@Sandy4321
Copy link
Author

code
import torch
from transformers import GPT2Tokenizer, GPT2LMHeadModel
from mingpt.model import GPT
from mingpt.utils import set_seed
from mingpt.bpe import BPETokenizer
set_seed(3407)

use_mingpt = True # use minGPT or huggingface/transformers model?
model_type = 'gpt2-xl'
device = 'cuda'
if use_mingpt:
model = GPT.from_pretrained(model_type)
else:
model = GPT2LMHeadModel.from_pretrained(model_type)
model.config.pad_token_id = model.config.eos_token_id # suppress a warning

ship model to device and set to eval mode

model.to(device)
model.eval();

q = 0

@Sandy4321
Copy link
Author

mingpt-master\mingpt-master\s_mingpt_jan21.py", line 15, in
model = GPT.from_pretrained(model_type)
File "c:\mingpt-master\mingpt-master\mingpt\model.py", line 200, in from_pretrained
assert len(keys) == len(sd)

builtins.AssertionError

@xiaoyuxie-vico
Copy link

I have the same issue.

@Sandy4321
Copy link
Author

MAY @karpathy FIX IT ?

@chenokay
Copy link

is it fixed?

@vanduc103
Copy link

It was fixed in here #120 and also the reason of the error.

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

No branches or pull requests

4 participants