Model Outputs and Hidden States
What you'll learn: How to interpret and access the different types of information that transformer models return after processing your input.
The Model's Information Layers
When you load a pre-trained model and feed it tokenized input, the model doesn't just give you one answer — it returns multiple layers of information. Think of it like a calculator that not only shows you the final answer, but also lets you see all the intermediate steps.
What's Inside a Model Output
After running inference, you typically get back an object containing:
Logits
The raw prediction scores before any conversion to probabilities. These are numbers that indicate how strongly the model "thinks" each possible token should come next (for language models) or how likely each class is (for classification). Higher logits mean higher confidence.
Hidden States
The intermediate representations from each layer of the model. Imagine the model processes your input through 12 floors of a building — hidden states let you peek at what the model "understood" at each floor. These are useful for debugging or creating custom outputs.
Attention Weights
Numbers showing which input tokens the model "paid attention to" when making predictions. Like highlighting which words in a sentence were most important for understanding its meaning.
Why This Matters
By default, models only return logits (the final answer). But you can request hidden states and attention weights by passing flags when loading the model. This access is powerful for understanding why a model made certain predictions or for building custom features on top of the base model.
Key Takeaway: Model outputs are structured objects containing logits (predictions), hidden states (intermediate layers), and attention weights (what the model focused on) — each revealing different aspects of how the model processed your input.