bert_large_cls(pretrained: bool | str = False, weights: BERTLargeWeights | None = None, overrides: object = {})Construct a BERT-Large model with a sequence-classification head.
Same trunk as bert_large (L=24, H=1024, A=16, ~340M parameters),
augmented with a pooled-CLS linear classifier of output width
config.num_labels. Use for high-accuracy GLUE-style fine-tunes when
compute permits.
Model Size
Parameters
pretrainedbool or str= FalseEncoder-weight selector.
False → fully random init; True
→ loads the pretrained bert_large encoder
(BERTLargeWeights.DEFAULT) into the .bert trunk; a tag
string selects a specific encoder checkpoint. The classification
head is always randomly initialised (fine-tuning starting point).weights(BERTLargeWeights, optional, keyword - only)= NoneExplicit encoder-weights enum member; takes precedence over
pretrained.**overridesobject= {}Optional
BERTConfig field overrides forwarded into the
underlying config. Pass num_labels=N to set the number of
classes (default 2). Overrides that change the encoder shape are
incompatible with loading pretrained encoder weights.Returns
BERTForSequenceClassificationBERT-Large wrapped with the pooled classifier head (encoder pretrained when requested; head random).
Notes
Reference: Devlin, Chang, Lee, and Toutanova, "BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding", NAACL 2019 (arXiv:1810.04805) §4.1.
Examples
>>> import lucid
>>> from lucid.models.text.bert import bert_large_cls
>>> model = bert_large_cls(num_labels=2).eval()
>>> input_ids = lucid.tensor([[101, 7592, 102]])
>>> out = model(input_ids)
>>> out.logits.shape # (1, 2)
(1, 2)