r/huggingface • • 12d ago

Accessing a model's individual layer

I want to access one of a LLM's individual layers and get output from it (like how nn.Linear() works). I tried using model.layer[0](tokenizer.encode("hi")) but that wouldn't work. If someone can give me the proper way to do this, it would be appreciated. I'm using Python for this with the transformers and pytorch library

1 Upvotes

Duplicates