Skip to content
fn

transformer_large_seq2seq

→TransformerForSeq2SeqLM214M
transformer_large_seq2seq(pretrained: bool = False, overrides: object = {})

Construct a Transformer "big" with a tied seq2seq-LM head.

Same trunk as transformer_large (N=6, d_model=1024, h=16), augmented with a linear LM head whose weight is tied to the target-side embedding when config.tie_word_embeddings is True. Use for high-accuracy translation / summarisation fine-tunes when compute permits.

Model Size

Parameters

pretrainedbool= False
No checkpoint is published for transformer_large_seq2seq, so True raises NotImplementedError rather than return randomly initialised weights.
**overridesobject= {}
Optional TransformerConfig field overrides forwarded into the underlying config.

Returns

TransformerForSeq2SeqLM

Encoder-decoder trunk wrapped with the tied LM head.

Notes

Reference: Vaswani et al., "Attention Is All You Need", NeurIPS, 2017.

Examples

>>> import lucid
>>> from lucid.models.text.transformer import transformer_large_seq2seq
>>> model = transformer_large_seq2seq().eval()
>>> src = lucid.tensor([[1, 234, 567, 2]])
>>> tgt = lucid.tensor([[1, 100, 200]])
>>> out = model(src, decoder_input_ids=tgt)
>>> out.logits.shape   # (B=1, T_tgt=3, vocab=37000)
(1, 3, 37000)

Used by 1