#120·minGPT

AssertionError when run generate.ipynb with default parameter

Author: jacquesqiaoCreated Jul 30, 2023Updated May 23, 2026
python
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
Cell In[14], line 2
      1 if use_mingpt:
----> 2     model = GPT.from_pretrained(model_type)
      3 else:
      4     model = GPT2LMHeadModel.from_pretrained(model_type)

File ~/project/llm/minGPT/mingpt/model.py:200, in GPT.from_pretrained(cls, model_type)
    197 transposed = ['attn.c_attn.weight', 'attn.c_proj.weight', 'mlp.c_fc.weight', 'mlp.c_proj.weight']
    198 # basically the openai checkpoints use a "Conv1D" module, but we only want to use a vanilla nn.Linear.
    199 # this means that we have to transpose these weights when we import them
--> 200 assert len(keys) == len(sd)
    201 for k in keys:
    202     if any(k.endswith(w) for w in transposed):
    203         # special treatment for the Conv1D weights we need to transpose

AssertionError: