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

[Bug Report] Different results from HuggingFace when using the GPT2 small example #685

Open
1 task done
nreHieW opened this issue Jul 27, 2024 · 0 comments
Open
1 task done
Labels
complexity-high Very complicated changes for people to address who are quite familiar with the code implementation-inaccuracy Any issues related to our implementation being off from the official version needs-investigation Issues that need to be recreated, or investigated before work can be done

Comments

@nreHieW
Copy link

nreHieW commented Jul 27, 2024

If you are submitting a bug report, please fill in the following details and use the tag [bug].

Describe the bug
The output from gpt2 small is different form the hf implementation. I searched for gpt2 implementation specifically and there doesn't seem to be anything

Code example
Please try to provide a minimal example to reproduce the bug. Error messages and stack traces are also helpful.

import transformer_lens
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

transformer_lens_model = transformer_lens.HookedTransformer.from_pretrained("gpt2-small").cuda()
transformer_lens_model.cfg.default_prepend_bos = False

logits, activations = transformer_lens_model.run_with_cache("Hello World")


tokenizer = AutoTokenizer.from_pretrained("gpt2")
model = AutoModelForCausalLM.from_pretrained("gpt2").cuda()
inputs = tokenizer("Hello World", return_tensors="pt").to("cuda")
outputs = model(**inputs, output_hidden_states=True)
torch.allclose(logits, outputs.logits)

System Info
Describe the characteristic of your environment:
This was run on the free tier of Google Colab

Additional context
Add any other context about the problem here.

Checklist

  • I have checked that there is no similar issue in the repo (required)
@bryce13950 bryce13950 added complexity-high Very complicated changes for people to address who are quite familiar with the code implementation-inaccuracy Any issues related to our implementation being off from the official version needs-investigation Issues that need to be recreated, or investigated before work can be done labels Jul 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity-high Very complicated changes for people to address who are quite familiar with the code implementation-inaccuracy Any issues related to our implementation being off from the official version needs-investigation Issues that need to be recreated, or investigated before work can be done
Projects
None yet
Development

No branches or pull requests

2 participants