data
BaseModelOutput
extends
ModelOutputBaseModelOutput(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_stateTensorFinal 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
>>> model = AutoModel.from_pretrained("bert_base")
>>> out = model(input_ids)
>>> out.last_hidden_state.shape
(1, 128, 768)Used by 31
- lucid.models
- lucid.models.text.gpt._model
- lucid.models.text.gpt2._model
- lucid.models.vision.alexnet._model
- lucid.models.vision.coatnet._model
- lucid.models.vision.convnext._model
- lucid.models.vision.crossvit._model
- lucid.models.vision.cspnet._model
- lucid.models.vision.cvt._model
- lucid.models.vision.densenet._model
- lucid.models.vision.efficientformer._model
- lucid.models.vision.efficientnet._model
… 19 more
Constructors
1dunder
__init__
→None__init__(last_hidden_state: Tensor, hidden_states: tuple[Tensor, ...] | None = None, attentions: tuple[Tensor, ...] | None = None)Wrap model for cached graph-capture execution.
Parameters
modelnn.Module or _CallableModuleThe compute unit to compile. Stored unwrapped so
attribute access falls through to it.
dynamicboolDeclare that this module will be called with varying batch
sizes. Default
False. Variable batch is always handled by
per-shape static caching — each distinct input shape compiles its
own executable, cached and reused — which works for every model and
never recompiles for a shape already seen. A single executable
shared across batch sizes (a symbolic batch axis) is not offered
automatically: Apple's MPSGraph aborts (uncatchably) the moment a
graph materialises a constant carrying the symbolic axis — scalar
arithmetic (x * 0.5), reshape / flatten, reductions,
convolutions and attention all trip it, i.e. essentially every real
model. The narrow class that is safe (pure linear /
activation / softmax / layer_norm / embedding graphs) can
opt in to the experimental symbolic path with the
LUCID_COMPILE_DYNAMIC=1 environment variable; without it
dynamic=True is exactly the safe per-shape static behaviour.