Skip to content
data

BaseModelOutput

extendsModelOutput
BaseModelOutput(last_hidden_state: Tensor, hidden_states: tuple[Tensor, ...] | None = None, attentions: tuple[Tensor, ...] | None = None)

Generic backbone forward output — sequence model variant.

Returned by backbone classes that emit a single hidden-state stream (encoder-only and decoder-only language models, ViT-family backbones).

Attributes

last_hidden_stateTensor
Final layer's output, shaped (B, T, H) for sequence models or (B, C, H, W) for spatial backbones.
hidden_states(tuple[Tensor, ...] or None, optional)
Per-layer hidden states when the caller passed output_hidden_states=True (else None).
attentions(tuple[Tensor, ...] or None, optional)
Per-layer attention weights when the caller passed output_attentions=True (else None).

Notes

Produced by transformer-family backbones (BERT, RoFormer, ViT, …) and most other encoder-only architectures that don't need a pooled representation.

Examples

>>> import lucid
>>> from lucid.models import BaseModelOutput
>>> out = BaseModelOutput(last_hidden_state=lucid.zeros(1, 128, 768))
>>> out.last_hidden_state.shape
(1, 128, 768)
The two optional fields are populated only when a model is asked for
them, so an ordinary forward leaves them empty.
>>> out.hidden_states is None, out.attentions is None
(True, True)

Used by 35

… 23 more