Skip to content
data

BaseModelOutputWithPooling

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

Backbone output + pooled representation (e.g. CLS).

Attributes

last_hidden_stateTensor
Per-token / per-spatial-location output, shape (B, T, H).
pooler_outputTensor
Aggregated representation — typically the [CLS] position passed through tanh(Linear(H, H)) (BERT-style) or a learned attention pool. Shape (B, H).
hidden_states(tuple[Tensor, ...] or None, optional)
Per-layer hidden states; populated when output_hidden_states=True.
attentions(tuple[Tensor, ...] or None, optional)
Per-layer attention weights; populated when output_attentions=True.

Notes

Used by encoder LMs that ship a sentence-level pooling head out of the box — BERT and friends. Downstream classifiers attach to pooler_output rather than re-pooling the per-token sequence.

Examples

>>> import lucid
>>> from lucid.models import BaseModelOutputWithPooling
>>> out = BaseModelOutputWithPooling(
...     last_hidden_state=lucid.zeros(1, 128, 768),
...     pooler_output=lucid.zeros(1, 768),
... )
>>> out.last_hidden_state.shape, out.pooler_output.shape
((1, 128, 768), (1, 768))

Used by 3