import{S as Zp,i as Up,s as Wp,e as a,k as i,w as M,t as n,M as Gp,c as s,d as t,m as p,a as d,x as v,h as r,b as c,G as e,g as u,y as w,q as T,o as k,B as J,v as Ip,L as st}from"../../chunks/vendor-hf-doc-builder.js";import{T as Rc}from"../../chunks/Tip-hf-doc-builder.js";import{D as S}from"../../chunks/Docstring-hf-doc-builder.js";import{C as q}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Y}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as at}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function zp(W){let h,b,_,f,y;return f=new q({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRDb25maWclMkMlMjBFbmNvZGVyRGVjb2RlckNvbmZpZyUyQyUyMEVuY29kZXJEZWNvZGVyTW9kZWwlMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwQkVSVCUyMGJlcnQtYmFzZS11bmNhc2VkJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBY29uZmlnX2VuY29kZXIlMjAlM0QlMjBCZXJ0Q29uZmlnKCklMEFjb25maWdfZGVjb2RlciUyMCUzRCUyMEJlcnRDb25maWcoKSUwQSUwQWNvbmZpZyUyMCUzRCUyMEVuY29kZXJEZWNvZGVyQ29uZmlnLmZyb21fZW5jb2Rlcl9kZWNvZGVyX2NvbmZpZ3MoY29uZmlnX2VuY29kZXIlMkMlMjBjb25maWdfZGVjb2RlciklMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwQmVydDJCZXJ0JTIwbW9kZWwlMjBmcm9tJTIwdGhlJTIwYmVydC1iYXNlLXVuY2FzZWQlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb25zJTBBbW9kZWwlMjAlM0QlMjBFbmNvZGVyRGVjb2Rlck1vZGVsKGNvbmZpZyUzRGNvbmZpZyklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWdfZW5jb2RlciUyMCUzRCUyMG1vZGVsLmNvbmZpZy5lbmNvZGVyJTBBY29uZmlnX2RlY29kZXIlMjAlM0QlMjBtb2RlbC5jb25maWcuZGVjb2RlciUwQSUyMyUyMHNldCUyMGRlY29kZXIlMjBjb25maWclMjB0byUyMGNhdXNhbCUyMGxtJTBBY29uZmlnX2RlY29kZXIuaXNfZGVjb2RlciUyMCUzRCUyMFRydWUlMEFjb25maWdfZGVjb2Rlci5hZGRfY3Jvc3NfYXR0ZW50aW9uJTIwJTNEJTIwVHJ1ZSUwQSUwQSUyMyUyMFNhdmluZyUyMHRoZSUyMG1vZGVsJTJDJTIwaW5jbHVkaW5nJTIwaXRzJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsLnNhdmVfcHJldHJhaW5lZCglMjJteS1tb2RlbCUyMiklMEElMEElMjMlMjBsb2FkaW5nJTIwbW9kZWwlMjBhbmQlMjBjb25maWclMjBmcm9tJTIwcHJldHJhaW5lZCUyMGZvbGRlciUwQWVuY29kZXJfZGVjb2Rlcl9jb25maWclMjAlM0QlMjBFbmNvZGVyRGVjb2RlckNvbmZpZy5mcm9tX3ByZXRyYWluZWQoJTIybXktbW9kZWwlMjIpJTBBbW9kZWwlMjAlM0QlMjBFbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJteS1tb2RlbCUyMiUyQyUyMGNvbmZpZyUzRGVuY29kZXJfZGVjb2Rlcl9jb25maWcp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertConfig, EncoderDecoderConfig, EncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a BERT bert-base-uncased style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>config_encoder = BertConfig()
<span class="hljs-meta">&gt;&gt;&gt; </span>config_decoder = BertConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span>config = EncoderDecoderConfig.from_encoder_decoder_configs(config_encoder, config_decoder)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Bert2Bert model from the bert-base-uncased style configurations</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel(config=config)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>config_encoder = model.config.encoder
<span class="hljs-meta">&gt;&gt;&gt; </span>config_decoder = model.config.decoder
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># set decoder config to causal lm</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>config_decoder.is_decoder = <span class="hljs-literal">True</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>config_decoder.add_cross_attention = <span class="hljs-literal">True</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Saving the model, including its configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.save_pretrained(<span class="hljs-string">&quot;my-model&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># loading model and config from pretrained folder</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>encoder_decoder_config = EncoderDecoderConfig.from_pretrained(<span class="hljs-string">&quot;my-model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;my-model&quot;</span>, config=encoder_decoder_config)`}}),{c(){h=a("p"),b=n("Examples:"),_=i(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=r(g,"Examples:"),g.forEach(t),_=p(l),v(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),w(f,l,g),y=!0},p:st,i(l){y||(T(f.$$.fragment,l),y=!0)},o(l){k(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),J(f,l)}}}function Vp(W){let h,b,_,f,y;return{c(){h=a("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=a("code"),f=n("Module"),y=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(l){h=s(l,"P",{});var g=d(h);b=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=s(g,"CODE",{});var R=d(_);f=r(R,"Module"),R.forEach(t),y=r(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(l,g){u(l,h,g),e(h,b),e(h,_),e(_,f),e(h,y)},d(l){l&&t(h)}}}function $p(W){let h,b,_,f,y;return f=new q({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEVuY29kZXJEZWNvZGVyTW9kZWwlMkMlMjBCZXJ0VG9rZW5pemVyJTBBaW1wb3J0JTIwdG9yY2glMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBCZXJ0VG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMiklMEFtb2RlbCUyMCUzRCUyMEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9lbmNvZGVyX2RlY29kZXJfcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMiUyQyUyMCUyMmJlcnQtYmFzZS11bmNhc2VkJTIyJTBBKSUyMCUyMCUyMyUyMGluaXRpYWxpemUlMjBCZXJ0MkJlcnQlMjBmcm9tJTIwcHJlLXRyYWluZWQlMjBjaGVja3BvaW50cyUwQSUwQSUyMyUyMHRyYWluaW5nJTBBbW9kZWwuY29uZmlnLmRlY29kZXJfc3RhcnRfdG9rZW5faWQlMjAlM0QlMjB0b2tlbml6ZXIuY2xzX3Rva2VuX2lkJTBBbW9kZWwuY29uZmlnLnBhZF90b2tlbl9pZCUyMCUzRCUyMHRva2VuaXplci5wYWRfdG9rZW5faWQlMEFtb2RlbC5jb25maWcudm9jYWJfc2l6ZSUyMCUzRCUyMG1vZGVsLmNvbmZpZy5kZWNvZGVyLnZvY2FiX3NpemUlMEElMEFpbnB1dF9pZHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIyVGhpcyUyMGlzJTIwYSUyMHJlYWxseSUyMGxvbmclMjB0ZXh0JTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikuaW5wdXRfaWRzJTBBbGFiZWxzJTIwJTNEJTIwdG9rZW5pemVyKCUyMlRoaXMlMjBpcyUyMHRoZSUyMGNvcnJlc3BvbmRpbmclMjBzdW1tYXJ5JTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikuaW5wdXRfaWRzJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKGlucHV0X2lkcyUzRGlucHV0X2lkcyUyQyUyMGxhYmVscyUzRGxhYmVscyklMEFsb3NzJTJDJTIwbG9naXRzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTJDJTIwb3V0cHV0cy5sb2dpdHMlMEElMEElMjMlMjBzYXZlJTIwYW5kJTIwbG9hZCUyMGZyb20lMjBwcmV0cmFpbmVkJTBBbW9kZWwuc2F2ZV9wcmV0cmFpbmVkKCUyMmJlcnQyYmVydCUyMiklMEFtb2RlbCUyMCUzRCUyMEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQyYmVydCUyMiklMEElMEElMjMlMjBnZW5lcmF0aW9uJTBBZ2VuZXJhdGVkJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoaW5wdXRfaWRzKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> EncoderDecoderModel, BertTokenizer
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel.from_encoder_decoder_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;bert-base-uncased&quot;</span>, <span class="hljs-string">&quot;bert-base-uncased&quot;</span>
<span class="hljs-meta">... </span>)  <span class="hljs-comment"># initialize Bert2Bert from pre-trained checkpoints</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># training</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.decoder_start_token_id = tokenizer.cls_token_id
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.pad_token_id = tokenizer.pad_token_id
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.vocab_size = model.config.decoder.vocab_size

<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer(<span class="hljs-string">&quot;This is a really long text&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = tokenizer(<span class="hljs-string">&quot;This is the corresponding summary&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_ids=input_ids, labels=labels)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss, logits = outputs.loss, outputs.logits

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># save and load from pretrained</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.save_pretrained(<span class="hljs-string">&quot;bert2bert&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;bert2bert&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># generation</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generated = model.generate(input_ids)`}}),{c(){h=a("p"),b=n("Examples:"),_=i(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=r(g,"Examples:"),g.forEach(t),_=p(l),v(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),w(f,l,g),y=!0},p:st,i(l){y||(T(f.$$.fragment,l),y=!0)},o(l){k(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),J(f,l)}}}function Rp(W){let h,b,_,f,y;return f=new q({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEVuY29kZXJEZWNvZGVyTW9kZWwlMEElMEElMjMlMjBpbml0aWFsaXplJTIwYSUyMGJlcnQyYmVydCUyMGZyb20lMjB0d28lMjBwcmV0cmFpbmVkJTIwQkVSVCUyMG1vZGVscy4lMjBOb3RlJTIwdGhhdCUyMHRoZSUyMGNyb3NzLWF0dGVudGlvbiUyMGxheWVycyUyMHdpbGwlMjBiZSUyMHJhbmRvbWx5JTIwaW5pdGlhbGl6ZWQlMEFtb2RlbCUyMCUzRCUyMEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9lbmNvZGVyX2RlY29kZXJfcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMiUyQyUyMCUyMmJlcnQtYmFzZS11bmNhc2VkJTIyKSUwQSUyMyUyMHNhdmluZyUyMG1vZGVsJTIwYWZ0ZXIlMjBmaW5lLXR1bmluZyUwQW1vZGVsLnNhdmVfcHJldHJhaW5lZCglMjIuJTJGYmVydDJiZXJ0JTIyKSUwQSUyMyUyMGxvYWQlMjBmaW5lLXR1bmVkJTIwbW9kZWwlMEFtb2RlbCUyMCUzRCUyMEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMi4lMkZiZXJ0MmJlcnQlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> EncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize a bert2bert from two pretrained BERT models. Note that the cross-attention layers will be randomly initialized</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel.from_encoder_decoder_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>, <span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># saving model after fine-tuning</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.save_pretrained(<span class="hljs-string">&quot;./bert2bert&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load fine-tuned model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;./bert2bert&quot;</span>)`}}),{c(){h=a("p"),b=n("Example:"),_=i(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=r(g,"Example:"),g.forEach(t),_=p(l),v(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),w(f,l,g),y=!0},p:st,i(l){y||(T(f.$$.fragment,l),y=!0)},o(l){k(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),J(f,l)}}}function Bp(W){let h,b,_,f,y;return{c(){h=a("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=a("code"),f=n("Module"),y=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(l){h=s(l,"P",{});var g=d(h);b=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=s(g,"CODE",{});var R=d(_);f=r(R,"Module"),R.forEach(t),y=r(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(l,g){u(l,h,g),e(h,b),e(h,_),e(_,f),e(h,y)},d(l){l&&t(h)}}}function Fp(W){let h,b,_,f,y;return f=new q({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGRW5jb2RlckRlY29kZXJNb2RlbCUyQyUyMEJlcnRUb2tlbml6ZXIlMEElMEElMjMlMjBpbml0aWFsaXplJTIwYSUyMGJlcnQyZ3B0MiUyMGZyb20lMjBhJTIwcHJldHJhaW5lZCUyMEJFUlQlMjBhbmQlMjBHUFQyJTIwbW9kZWxzLiUyME5vdGUlMjB0aGF0JTIwdGhlJTIwY3Jvc3MtYXR0ZW50aW9uJTIwbGF5ZXJzJTIwd2lsbCUyMGJlJTIwcmFuZG9tbHklMjBpbml0aWFsaXplZCUwQW1vZGVsJTIwJTNEJTIwVEZFbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fZW5jb2Rlcl9kZWNvZGVyX3ByZXRyYWluZWQoJTIyYmVydC1iYXNlLWNhc2VkJTIyJTJDJTIwJTIyZ3B0MiUyMiklMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBCZXJ0VG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtY2FzZWQlMjIpJTBBJTBBJTIzJTIwZm9yd2FyZCUwQWlucHV0X2lkcyUyMCUzRCUyMHRva2VuaXplci5lbmNvZGUoJTBBJTIwJTIwJTIwJTIwJTIySGVsbG8lMkMlMjBteSUyMGRvZyUyMGlzJTIwY3V0ZSUyMiUyQyUyMGFkZF9zcGVjaWFsX3Rva2VucyUzRFRydWUlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyJTBBKSUyMCUyMCUyMyUyMEJhdGNoJTIwc2l6ZSUyMDElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoaW5wdXRfaWRzJTNEaW5wdXRfaWRzJTJDJTIwZGVjb2Rlcl9pbnB1dF9pZHMlM0RpbnB1dF9pZHMpJTBBJTBBJTIzJTIwdHJhaW5pbmclMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoaW5wdXRfaWRzJTNEaW5wdXRfaWRzJTJDJTIwZGVjb2Rlcl9pbnB1dF9pZHMlM0RpbnB1dF9pZHMlMkMlMjBsYWJlbHMlM0RpbnB1dF9pZHMpJTBBbG9zcyUyQyUyMGxvZ2l0cyUyMCUzRCUyMG91dHB1dHMubG9zcyUyQyUyMG91dHB1dHMubG9naXRzJTBBJTBBJTIzJTIwc2F2ZSUyMGFuZCUyMGxvYWQlMjBmcm9tJTIwcHJldHJhaW5lZCUwQW1vZGVsLnNhdmVfcHJldHJhaW5lZCglMjJiZXJ0MmdwdDIlMjIpJTBBbW9kZWwlMjAlM0QlMjBURkVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQyZ3B0MiUyMiklMEElMEElMjMlMjBnZW5lcmF0aW9uJTBBZ2VuZXJhdGVkJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoaW5wdXRfaWRzJTJDJTIwZGVjb2Rlcl9zdGFydF90b2tlbl9pZCUzRG1vZGVsLmNvbmZpZy5kZWNvZGVyLmJvc190b2tlbl9pZCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFEncoderDecoderModel, BertTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize a bert2gpt2 from a pretrained BERT and GPT2 models. Note that the cross-attention layers will be randomly initialized</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFEncoderDecoderModel.from_encoder_decoder_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>, <span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># forward</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer.encode(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, add_special_tokens=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>
<span class="hljs-meta">... </span>)  <span class="hljs-comment"># Batch size 1</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_ids=input_ids, decoder_input_ids=input_ids)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># training</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_ids=input_ids, decoder_input_ids=input_ids, labels=input_ids)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss, logits = outputs.loss, outputs.logits

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># save and load from pretrained</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.save_pretrained(<span class="hljs-string">&quot;bert2gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;bert2gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># generation</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generated = model.generate(input_ids, decoder_start_token_id=model.config.decoder.bos_token_id)`}}),{c(){h=a("p"),b=n("Examples:"),_=i(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=r(g,"Examples:"),g.forEach(t),_=p(l),v(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),w(f,l,g),y=!0},p:st,i(l){y||(T(f.$$.fragment,l),y=!0)},o(l){k(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),J(f,l)}}}function Cp(W){let h,b,_,f,y;return f=new q({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGRW5jb2RlckRlY29kZXJNb2RlbCUwQSUwQSUyMyUyMGluaXRpYWxpemUlMjBhJTIwYmVydDJncHQyJTIwZnJvbSUyMHR3byUyMHByZXRyYWluZWQlMjBCRVJUJTIwbW9kZWxzLiUyME5vdGUlMjB0aGF0JTIwdGhlJTIwY3Jvc3MtYXR0ZW50aW9uJTIwbGF5ZXJzJTIwd2lsbCUyMGJlJTIwcmFuZG9tbHklMjBpbml0aWFsaXplZCUwQW1vZGVsJTIwJTNEJTIwVEZFbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fZW5jb2Rlcl9kZWNvZGVyX3ByZXRyYWluZWQoJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIlMkMlMjAlMjJncHQyJTIyKSUwQSUyMyUyMHNhdmluZyUyMG1vZGVsJTIwYWZ0ZXIlMjBmaW5lLXR1bmluZyUwQW1vZGVsLnNhdmVfcHJldHJhaW5lZCglMjIuJTJGYmVydDJncHQyJTIyKSUwQSUyMyUyMGxvYWQlMjBmaW5lLXR1bmVkJTIwbW9kZWwlMEFtb2RlbCUyMCUzRCUyMFRGRW5jb2RlckRlY29kZXJNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyLiUyRmJlcnQyZ3B0MiUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFEncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize a bert2gpt2 from two pretrained BERT models. Note that the cross-attention layers will be randomly initialized</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFEncoderDecoderModel.from_encoder_decoder_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>, <span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># saving model after fine-tuning</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.save_pretrained(<span class="hljs-string">&quot;./bert2gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load fine-tuned model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;./bert2gpt2&quot;</span>)`}}),{c(){h=a("p"),b=n("Example:"),_=i(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=r(g,"Example:"),g.forEach(t),_=p(l),v(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),w(f,l,g),y=!0},p:st,i(l){y||(T(f.$$.fragment,l),y=!0)},o(l){k(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),J(f,l)}}}function xp(W){let h,b,_,f,y;return{c(){h=a("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=a("code"),f=n("Module"),y=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(l){h=s(l,"P",{});var g=d(h);b=r(g,"Although the recipe for forward pass needs to be defined within this function, one should call the "),_=s(g,"CODE",{});var R=d(_);f=r(R,"Module"),R.forEach(t),y=r(g,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),g.forEach(t)},m(l,g){u(l,h,g),e(h,b),e(h,_),e(_,f),e(h,y)},d(l){l&&t(h)}}}function Dp(W){let h,b,_,f,y;return f=new q({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEZsYXhFbmNvZGVyRGVjb2Rlck1vZGVsJTJDJTIwQmVydFRva2VuaXplciUyQyUyMEdQVDJUb2tlbml6ZXIlMEElMEElMjMlMjBsb2FkJTIwYSUyMGZpbmUtdHVuZWQlMjBiZXJ0MmdwdDIlMjBtb2RlbCUwQW1vZGVsJTIwJTNEJTIwRmxheEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMnBhdHJpY2t2b25wbGF0ZW4lMkZiZXJ0MmdwdDItY25uX2RhaWx5bWFpbC1mcDE2JTIyKSUwQSUyMyUyMGxvYWQlMjBpbnB1dCUyMCUyNiUyMG91dHB1dCUyMHRva2VuaXplciUwQXRva2VuaXplcl9pbnB1dCUyMCUzRCUyMEJlcnRUb2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQtYmFzZS1jYXNlZCUyMiklMEF0b2tlbml6ZXJfb3V0cHV0JTIwJTNEJTIwR1BUMlRva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMiklMEElMEFhcnRpY2xlJTIwJTNEJTIwJycnU2lnbWElMjBBbHBoYSUyMEVwc2lsb24lMjBpcyUyMHVuZGVyJTIwZmlyZSUyMGZvciUyMGElMjB2aWRlbyUyMHNob3dpbmclMjBwYXJ0eS1ib3VuZCUyMGZyYXRlcm5pdHklMjBtZW1iZXJzJTBBc2luZ2luZyUyMGElMjByYWNpc3QlMjBjaGFudC4lMjBTQUUncyUyMG5hdGlvbmFsJTIwY2hhcHRlciUyMHN1c3BlbmRlZCUyMHRoZSUyMHN0dWRlbnRzJTJDJTBBYnV0JTIwVW5pdmVyc2l0eSUyMG9mJTIwT2tsYWhvbWElMjBQcmVzaWRlbnQlMjBEYXZpZCUyMEJvcmVuJTIwdG9vayUyMGl0JTIwYSUyMHN0ZXAlMjBmdXJ0aGVyJTJDJTBBc2F5aW5nJTIwdGhlJTIwdW5pdmVyc2l0eSdzJTIwYWZmaWxpYXRpb24lMjB3aXRoJTIwdGhlJTIwZnJhdGVybml0eSUyMGlzJTIwcGVybWFuZW50bHklMjBkb25lLicnJyUwQSUwQWlucHV0X2lkcyUyMCUzRCUyMHRva2VuaXplcl9pbnB1dChhcnRpY2xlJTJDJTIwYWRkX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIybnAlMjIpLmlucHV0X2lkcyUwQSUwQSUyMyUyMHVzZSUyMEdQVDIncyUyMGVvc190b2tlbiUyMGFzJTIwdGhlJTIwcGFkJTIwYXMlMjB3ZWxsJTIwYXMlMjBlb3MlMjB0b2tlbiUwQW1vZGVsLmNvbmZpZy5lb3NfdG9rZW5faWQlMjAlM0QlMjBtb2RlbC5jb25maWcuZGVjb2Rlci5lb3NfdG9rZW5faWQlMEFtb2RlbC5jb25maWcucGFkX3Rva2VuX2lkJTIwJTNEJTIwbW9kZWwuY29uZmlnLmVvc190b2tlbl9pZCUwQSUwQXNlcXVlbmNlcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKGlucHV0X2lkcyUyQyUyMG51bV9iZWFtcyUzRDQlMkMlMjBtYXhfbGVuZ3RoJTNEMTIpLnNlcXVlbmNlcyUwQSUwQXN1bW1hcnklMjAlM0QlMjB0b2tlbml6ZXJfb3V0cHV0LmJhdGNoX2RlY29kZShzZXF1ZW5jZXMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSklNUIwJTVEJTBBYXNzZXJ0JTIwc3VtbWFyeSUyMCUzRCUzRCUyMCUyMlNBUyUyMEFscGhhJTIwRXBzaWxvbiUyMHN1c3BlbmRlZCUyMFNpZ21hJTIwQWxwaGElMjBFcHNpbG9uJTIwbWVtYmVycyUyMg==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> FlaxEncoderDecoderModel, BertTokenizer, GPT2Tokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load a fine-tuned bert2gpt2 model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;patrickvonplaten/bert2gpt2-cnn_dailymail-fp16&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load input &amp; output tokenizer</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer_input = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer_output = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>article = <span class="hljs-string">&#x27;&#x27;&#x27;Sigma Alpha Epsilon is under fire for a video showing party-bound fraternity members
<span class="hljs-meta">&gt;&gt;&gt; </span>singing a racist chant. SAE&#x27;s national chapter suspended the students,
<span class="hljs-meta">&gt;&gt;&gt; </span>but University of Oklahoma President David Boren took it a step further,
<span class="hljs-meta">&gt;&gt;&gt; </span>saying the university&#x27;s affiliation with the fraternity is permanently done.&#x27;&#x27;&#x27;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer_input(article, add_special_tokens=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;np&quot;</span>).input_ids

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># use GPT2&#x27;s eos_token as the pad as well as eos token</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.eos_token_id = model.config.decoder.eos_token_id
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.pad_token_id = model.config.eos_token_id

<span class="hljs-meta">&gt;&gt;&gt; </span>sequences = model.generate(input_ids, num_beams=<span class="hljs-number">4</span>, max_length=<span class="hljs-number">12</span>).sequences

<span class="hljs-meta">&gt;&gt;&gt; </span>summary = tokenizer_output.batch_decode(sequences, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">assert</span> summary == <span class="hljs-string">&quot;SAS Alpha Epsilon suspended Sigma Alpha Epsilon members&quot;</span>`}}),{c(){h=a("p"),b=n("Examples:"),_=i(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=r(g,"Examples:"),g.forEach(t),_=p(l),v(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),w(f,l,g),y=!0},p:st,i(l){y||(T(f.$$.fragment,l),y=!0)},o(l){k(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),J(f,l)}}}function Np(W){let h,b,_,f,y;return f=new q({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEZsYXhFbmNvZGVyRGVjb2Rlck1vZGVsJTBBJTBBJTIzJTIwaW5pdGlhbGl6ZSUyMGElMjBiZXJ0MmdwdDIlMjBmcm9tJTIwcHJldHJhaW5lZCUyMEJFUlQlMjBhbmQlMjBHUFQyJTIwbW9kZWxzLiUyME5vdGUlMjB0aGF0JTIwdGhlJTIwY3Jvc3MtYXR0ZW50aW9uJTIwbGF5ZXJzJTIwd2lsbCUyMGJlJTIwcmFuZG9tbHklMjBpbml0aWFsaXplZCUwQW1vZGVsJTIwJTNEJTIwRmxheEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9lbmNvZGVyX2RlY29kZXJfcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtY2FzZWQlMjIlMkMlMjAlMjJncHQyJTIyKSUwQSUyMyUyMHNhdmluZyUyMG1vZGVsJTIwYWZ0ZXIlMjBmaW5lLXR1bmluZyUwQW1vZGVsLnNhdmVfcHJldHJhaW5lZCglMjIuJTJGYmVydDJncHQyJTIyKSUwQSUyMyUyMGxvYWQlMjBmaW5lLXR1bmVkJTIwbW9kZWwlMEFtb2RlbCUyMCUzRCUyMEZsYXhFbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fcHJldHJhaW5lZCglMjIuJTJGYmVydDJncHQyJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> FlaxEncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># initialize a bert2gpt2 from pretrained BERT and GPT2 models. Note that the cross-attention layers will be randomly initialized</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxEncoderDecoderModel.from_encoder_decoder_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>, <span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># saving model after fine-tuning</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.save_pretrained(<span class="hljs-string">&quot;./bert2gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load fine-tuned model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxEncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;./bert2gpt2&quot;</span>)`}}),{c(){h=a("p"),b=n("Example:"),_=i(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=r(g,"Example:"),g.forEach(t),_=p(l),v(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),w(f,l,g),y=!0},p:st,i(l){y||(T(f.$$.fragment,l),y=!0)},o(l){k(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),J(f,l)}}}function qp(W){let h,b,_,f,y,l,g,R,ca,nr,te,ve,Qt,eo,ia,Lt,pa,rr,we,ma,dt,ha,fa,ar,Te,ua,oo,ga,_a,sr,ke,ya,lt,ba,Ma,dr,A,va,ct,wa,Ta,to,ka,Ja,lr,ne,Je,Ot,no,ja,ro,Ea,Kt,Za,Ua,cr,X,it,Wa,Ga,pt,Ia,za,en,Va,$a,ir,ao,pr,re,je,on,so,Ra,lo,Ba,tn,Fa,Ca,mr,j,mt,xa,Da,nn,Na,qa,rn,Xa,Sa,an,Ya,Aa,sn,Ha,Pa,ht,Qa,La,Ee,Oa,dn,Ka,es,ln,os,ts,ft,ns,rs,hr,co,fr,ae,Ze,cn,io,as,po,ss,pn,ds,ls,ur,F,cs,mn,is,ps,ut,ms,hs,hn,fs,us,gr,Ue,gs,fn,_s,ys,_r,mo,yr,se,We,un,ho,bs,fo,Ms,gn,vs,ws,br,de,_n,Ts,ks,yn,Js,js,Mr,uo,vr,le,Ge,bn,go,Es,Mn,Zs,wr,B,Us,vn,Ws,Gs,wn,Is,zs,Tn,Vs,$s,kn,Rs,Bs,Tr,_o,kr,Ie,Fs,yo,Cs,xs,Jr,H,Ds,bo,Ns,qs,Mo,Xs,Ss,jr,ce,ze,Jn,vo,Ys,jn,As,Er,$,wo,Hs,Ve,gt,Ps,Qs,_t,Ls,Os,Ks,ie,ed,yt,od,td,bt,nd,rd,ad,$e,sd,Re,To,dd,ko,ld,Mt,cd,id,Zr,pe,Be,En,Jo,pd,Zn,md,Ur,E,jo,hd,me,fd,vt,ud,gd,wt,_d,yd,bd,Eo,Md,Zo,vd,wd,Td,Un,kd,Jd,Uo,jd,Tt,Ed,Zd,Ud,Wo,Wd,Go,Gd,Id,zd,P,kt,Vd,$d,Wn,Rd,Bd,Gn,Fd,Cd,xd,C,Io,Dd,he,Nd,Jt,qd,Xd,In,Sd,Yd,Ad,Fe,Hd,Ce,Pd,x,zo,Qd,zn,Ld,Od,fe,Kd,Vn,el,ol,$n,tl,nl,rl,xe,Wr,ue,De,Rn,Vo,al,Bn,sl,Gr,Z,$o,dl,ge,ll,jt,cl,il,Et,pl,ml,hl,Ro,fl,Bo,ul,gl,_l,Fn,yl,bl,Fo,Ml,Zt,vl,wl,Tl,Co,kl,xo,Jl,jl,El,Q,Ut,Zl,Ul,Wt,Wl,Gl,Gt,Il,zl,Vl,D,Do,$l,_e,Rl,It,Bl,Fl,Cn,Cl,xl,Dl,Ne,Nl,qe,ql,L,No,Xl,xn,Sl,Yl,Xe,Ir,ye,Se,Dn,qo,Al,Nn,Hl,zr,U,Xo,Pl,be,Ql,zt,Ll,Ol,Vt,Kl,ec,oc,So,tc,Yo,nc,rc,ac,qn,sc,dc,Ao,lc,$t,cc,ic,pc,Ho,mc,Po,hc,fc,uc,O,Rt,gc,_c,Xn,yc,bc,Sn,Mc,vc,wc,N,Qo,Tc,Me,kc,Bt,Jc,jc,Yn,Ec,Zc,Uc,Ye,Wc,Ae,Gc,K,Lo,Ic,An,zc,Vc,He,Vr;return l=new Y({}),eo=new Y({}),no=new Y({}),ao=new q({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRDb25maWclMkMlMjBFbmNvZGVyRGVjb2RlckNvbmZpZyUyQyUyMEVuY29kZXJEZWNvZGVyTW9kZWwlMEElMEFjb25maWdfZW5jb2RlciUyMCUzRCUyMEJlcnRDb25maWcoKSUwQWNvbmZpZ19kZWNvZGVyJTIwJTNEJTIwQmVydENvbmZpZygpJTBBJTBBY29uZmlnJTIwJTNEJTIwRW5jb2RlckRlY29kZXJDb25maWcuZnJvbV9lbmNvZGVyX2RlY29kZXJfY29uZmlncyhjb25maWdfZW5jb2RlciUyQyUyMGNvbmZpZ19kZWNvZGVyKSUwQW1vZGVsJTIwJTNEJTIwRW5jb2RlckRlY29kZXJNb2RlbChjb25maWclM0Rjb25maWcp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertConfig, EncoderDecoderConfig, EncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span>config_encoder = BertConfig()
<span class="hljs-meta">&gt;&gt;&gt; </span>config_decoder = BertConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span>config = EncoderDecoderConfig.from_encoder_decoder_configs(config_encoder, config_decoder)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel(config=config)`}}),so=new Y({}),co=new q({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEVuY29kZXJEZWNvZGVyTW9kZWwlMkMlMjBCZXJ0VG9rZW5pemVyJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQmVydFRva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIpJTBBbW9kZWwlMjAlM0QlMjBFbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fZW5jb2Rlcl9kZWNvZGVyX3ByZXRyYWluZWQoJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIlMkMlMjAlMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> EncoderDecoderModel, BertTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel.from_encoder_decoder_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>, <span class="hljs-string">&quot;bert-base-uncased&quot;</span>)`}}),io=new Y({}),mo=new q({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBFbmNvZGVyRGVjb2Rlck1vZGVsJTBBJTBBJTIzJTIwbG9hZCUyMGElMjBmaW5lLXR1bmVkJTIwc2VxMnNlcSUyMG1vZGVsJTIwYW5kJTIwY29ycmVzcG9uZGluZyUyMHRva2VuaXplciUwQW1vZGVsJTIwJTNEJTIwRW5jb2RlckRlY29kZXJNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIycGF0cmlja3ZvbnBsYXRlbiUyRmJlcnQyYmVydF9jbm5fZGFpbHlfbWFpbCUyMiklMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJwYXRyaWNrdm9ucGxhdGVuJTJGYmVydDJiZXJ0X2Nubl9kYWlseV9tYWlsJTIyKSUwQSUwQSUyMyUyMGxldCdzJTIwcGVyZm9ybSUyMGluZmVyZW5jZSUyMG9uJTIwYSUyMGxvbmclMjBwaWVjZSUyMG9mJTIwdGV4dCUwQUFSVElDTEVfVE9fU1VNTUFSSVpFJTIwJTNEJTIwKCUwQSUyMCUyMCUyMCUyMCUyMlBHJTI2RSUyMHN0YXRlZCUyMGl0JTIwc2NoZWR1bGVkJTIwdGhlJTIwYmxhY2tvdXRzJTIwaW4lMjByZXNwb25zZSUyMHRvJTIwZm9yZWNhc3RzJTIwZm9yJTIwaGlnaCUyMHdpbmRzJTIwJTIyJTBBJTIwJTIwJTIwJTIwJTIyYW1pZCUyMGRyeSUyMGNvbmRpdGlvbnMuJTIwVGhlJTIwYWltJTIwaXMlMjB0byUyMHJlZHVjZSUyMHRoZSUyMHJpc2slMjBvZiUyMHdpbGRmaXJlcy4lMjBOZWFybHklMjA4MDAlMjB0aG91c2FuZCUyMGN1c3RvbWVycyUyMHdlcmUlMjAlMjIlMEElMjAlMjAlMjAlMjAlMjJzY2hlZHVsZWQlMjB0byUyMGJlJTIwYWZmZWN0ZWQlMjBieSUyMHRoZSUyMHNodXRvZmZzJTIwd2hpY2glMjB3ZXJlJTIwZXhwZWN0ZWQlMjB0byUyMGxhc3QlMjB0aHJvdWdoJTIwYXQlMjBsZWFzdCUyMG1pZGRheSUyMHRvbW9ycm93LiUyMiUwQSklMEFpbnB1dF9pZHMlMjAlM0QlMjB0b2tlbml6ZXIoQVJUSUNMRV9UT19TVU1NQVJJWkUlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS5pbnB1dF9pZHMlMEElMEElMjMlMjBhdXRvcmVncmVzc2l2ZWx5JTIwZ2VuZXJhdGUlMjBzdW1tYXJ5JTIwKHVzZXMlMjBncmVlZHklMjBkZWNvZGluZyUyMGJ5JTIwZGVmYXVsdCklMEFnZW5lcmF0ZWRfaWRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoaW5wdXRfaWRzKSUwQWdlbmVyYXRlZF90ZXh0JTIwJTNEJTIwdG9rZW5pemVyLmJhdGNoX2RlY29kZShnZW5lcmF0ZWRfaWRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTVCMCU1RCUwQXByaW50KGdlbmVyYXRlZF90ZXh0KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, EncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load a fine-tuned seq2seq model and corresponding tokenizer</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;patrickvonplaten/bert2bert_cnn_daily_mail&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;patrickvonplaten/bert2bert_cnn_daily_mail&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># let&#x27;s perform inference on a long piece of text</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>ARTICLE_TO_SUMMARIZE = (
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;PG&amp;E stated it scheduled the blackouts in response to forecasts for high winds &quot;</span>
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;amid dry conditions. The aim is to reduce the risk of wildfires. Nearly 800 thousand customers were &quot;</span>
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;scheduled to be affected by the shutoffs which were expected to last through at least midday tomorrow.&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer(ARTICLE_TO_SUMMARIZE, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># autoregressively generate summary (uses greedy decoding by default)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_ids = model.generate(input_ids)
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_text = tokenizer.batch_decode(generated_ids, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(generated_text)
nearly <span class="hljs-number">800</span> thousand customers were affected by the shutoffs. the aim <span class="hljs-keyword">is</span> to reduce the risk of wildfires. nearly <span class="hljs-number">800</span>, <span class="hljs-number">000</span> customers were expected to be affected by high winds amid dry conditions. pg &amp; e said it scheduled the blackouts to last through at least midday tomorrow.`}}),ho=new Y({}),uo=new q({props:{code:"JTIzJTIwYSUyMHdvcmthcm91bmQlMjB0byUyMGxvYWQlMjBmcm9tJTIwcHl0b3JjaCUyMGNoZWNrcG9pbnQlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwRW5jb2RlckRlY29kZXJNb2RlbCUyQyUyMFRGRW5jb2RlckRlY29kZXJNb2RlbCUwQSUwQV9tb2RlbCUyMCUzRCUyMEVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMnBhdHJpY2t2b25wbGF0ZW4lMkZiZXJ0MmJlcnQtY25uX2RhaWx5bWFpbC1mcDE2JTIyKSUwQSUwQV9tb2RlbC5lbmNvZGVyLnNhdmVfcHJldHJhaW5lZCglMjIuJTJGZW5jb2RlciUyMiklMEFfbW9kZWwuZGVjb2Rlci5zYXZlX3ByZXRyYWluZWQoJTIyLiUyRmRlY29kZXIlMjIpJTBBJTBBbW9kZWwlMjAlM0QlMjBURkVuY29kZXJEZWNvZGVyTW9kZWwuZnJvbV9lbmNvZGVyX2RlY29kZXJfcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjIuJTJGZW5jb2RlciUyMiUyQyUyMCUyMi4lMkZkZWNvZGVyJTIyJTJDJTIwZW5jb2Rlcl9mcm9tX3B0JTNEVHJ1ZSUyQyUyMGRlY29kZXJfZnJvbV9wdCUzRFRydWUlMEEpJTBBJTIzJTIwVGhpcyUyMGlzJTIwb25seSUyMGZvciUyMGNvcHlpbmclMjBzb21lJTIwc3BlY2lmaWMlMjBhdHRyaWJ1dGVzJTIwb2YlMjB0aGlzJTIwcGFydGljdWxhciUyMG1vZGVsLiUwQW1vZGVsLmNvbmZpZyUyMCUzRCUyMF9tb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># a workaround to load from pytorch checkpoint</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> EncoderDecoderModel, TFEncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span>_model = EncoderDecoderModel.from_pretrained(<span class="hljs-string">&quot;patrickvonplaten/bert2bert-cnn_dailymail-fp16&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>_model.encoder.save_pretrained(<span class="hljs-string">&quot;./encoder&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>_model.decoder.save_pretrained(<span class="hljs-string">&quot;./decoder&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFEncoderDecoderModel.from_encoder_decoder_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;./encoder&quot;</span>, <span class="hljs-string">&quot;./decoder&quot;</span>, encoder_from_pt=<span class="hljs-literal">True</span>, decoder_from_pt=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># This is only for copying some specific attributes of this particular model.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config = _model.config`}}),go=new Y({}),_o=new q({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRUb2tlbml6ZXIlMkMlMjBFbmNvZGVyRGVjb2Rlck1vZGVsJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQmVydFRva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIpJTBBbW9kZWwlMjAlM0QlMjBFbmNvZGVyRGVjb2Rlck1vZGVsLmZyb21fZW5jb2Rlcl9kZWNvZGVyX3ByZXRyYWluZWQoJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIlMkMlMjAlMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMiklMEElMEFtb2RlbC5jb25maWcuZGVjb2Rlcl9zdGFydF90b2tlbl9pZCUyMCUzRCUyMHRva2VuaXplci5jbHNfdG9rZW5faWQlMEFtb2RlbC5jb25maWcucGFkX3Rva2VuX2lkJTIwJTNEJTIwdG9rZW5pemVyLnBhZF90b2tlbl9pZCUwQSUwQWlucHV0X2lkcyUyMCUzRCUyMHRva2VuaXplciglMEElMjAlMjAlMjAlMjAlMjJUaGUlMjB0b3dlciUyMGlzJTIwMzI0JTIwbWV0cmVzJTIwKDElMkMwNjMlMjBmdCklMjB0YWxsJTJDJTIwYWJvdXQlMjB0aGUlMjBzYW1lJTIwaGVpZ2h0JTIwYXMlMjBhbiUyMDgxLXN0b3JleSUyMGJ1aWxkaW5nJTJDJTIwYW5kJTIwdGhlJTIwdGFsbGVzdCUyMHN0cnVjdHVyZSUyMGluJTIwUGFyaXMuJTIwSXRzJTIwYmFzZSUyMGlzJTIwc3F1YXJlJTJDJTIwbWVhc3VyaW5nJTIwMTI1JTIwbWV0cmVzJTIwKDQxMCUyMGZ0KSUyMG9uJTIwZWFjaCUyMHNpZGUuRHVyaW5nJTIwaXRzJTIwY29uc3RydWN0aW9uJTJDJTIwdGhlJTIwRWlmZmVsJTIwVG93ZXIlMjBzdXJwYXNzZWQlMjB0aGUlMjBXYXNoaW5ndG9uJTIwTW9udW1lbnQlMjB0byUyMGJlY29tZSUyMHRoZSUyMHRhbGxlc3QlMjBtYW4tbWFkZSUyMHN0cnVjdHVyZSUyMGluJTIwdGhlJTIwd29ybGQlMkMlMjBhJTIwdGl0bGUlMjBpdCUyMGhlbGQlMjBmb3IlMjA0MSUyMHllYXJzJTIwdW50aWwlMjB0aGUlMjBDaHJ5c2xlciUyMEJ1aWxkaW5nJTIwaW4lMjBOZXclMjBZb3JrJTIwQ2l0eSUyMHdhcyUyMCUyMGZpbmlzaGVkJTIwaW4lMjAxOTMwLiUyMEl0JTIwd2FzJTIwdGhlJTIwZmlyc3QlMjBzdHJ1Y3R1cmUlMjB0byUyMHJlYWNoJTIwYSUyMGhlaWdodCUyMG9mJTIwMzAwJTIwbWV0cmVzLiUyMER1ZSUyMHRvJTIwdGhlJTIwYWRkaXRpb24lMjBvZiUyMGElMjBicm9hZGNhc3RpbmclMjBhZXJpYWwlMjBhdCUyMHRoZSUyMHRvcCUyMG9mJTIwdGhlJTIwdG93ZXIlMjBpbiUyMDE5NTclMkMlMjBpdCUyMGlzJTIwbm93JTIwdGFsbGVyJTIwdGhhbiUyMHRoZSUyMENocnlzbGVyJTIwQnVpbGRpbmclMjBieSUyMDUuMiUyMG1ldHJlcyUyMCgxNyUyMGZ0KS5FeGNsdWRpbmclMjB0cmFuc21pdHRlcnMlMkMlMjB0aGUlMjBFaWZmZWwlMjBUb3dlciUyMGlzJTIwdGhlJTIwc2Vjb25kJTIwdGFsbGVzdCUyMGZyZWUtc3RhbmRpbmclMjBzdHJ1Y3R1cmUlMjBpbiUyMEZyYW5jZSUyMGFmdGVyJTIwdGhlJTIwTWlsbGF1JTIwVmlhZHVjdC4lMjIlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTBBKS5pbnB1dF9pZHMlMEElMEFsYWJlbHMlMjAlM0QlMjB0b2tlbml6ZXIoJTBBJTIwJTIwJTIwJTIwJTIydGhlJTIwZWlmZmVsJTIwdG93ZXIlMjBzdXJwYXNzZWQlMjB0aGUlMjB3YXNoaW5ndG9uJTIwbW9udW1lbnQlMjB0byUyMGJlY29tZSUyMHRoZSUyMHRhbGxlc3QlMjBzdHJ1Y3R1cmUlMjBpbiUyMHRoZSUyMHdvcmxkLiUyMGl0JTIwd2FzJTIwdGhlJTIwZmlyc3QlMjBzdHJ1Y3R1cmUlMjB0byUyMHJlYWNoJTIwYSUyMGhlaWdodCUyMG9mJTIwMzAwJTIwbWV0cmVzJTIwaW4lMjBwYXJpcyUyMGluJTIwMTkzMC4lMjBpdCUyMGlzJTIwbm93JTIwdGFsbGVyJTIwdGhhbiUyMHRoZSUyMGNocnlzbGVyJTIwYnVpbGRpbmclMjBieSUyMDUuJTIwMiUyMG1ldHJlcyUyMCglMjAxNyUyMGZ0JTIwKSUyMGFuZCUyMGlzJTIwdGhlJTIwc2Vjb25kJTIwdGFsbGVzdCUyMGZyZWUlMjAtJTIwc3RhbmRpbmclMjBzdHJ1Y3R1cmUlMjBpbiUyMHBhcmlzLiUyMiUyQyUwQSUyMCUyMCUyMCUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIlMkMlMEEpLmlucHV0X2lkcyUwQSUwQSUyMyUyMHRoZSUyMGZvcndhcmQlMjBmdW5jdGlvbiUyMGF1dG9tYXRpY2FsbHklMjBjcmVhdGVzJTIwdGhlJTIwY29ycmVjdCUyMGRlY29kZXJfaW5wdXRfaWRzJTBBbG9zcyUyMCUzRCUyMG1vZGVsKGlucHV0X2lkcyUzRGlucHV0X2lkcyUyQyUyMGxhYmVscyUzRGxhYmVscykubG9zcw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertTokenizer, EncoderDecoderModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = EncoderDecoderModel.from_encoder_decoder_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>, <span class="hljs-string">&quot;bert-base-uncased&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.decoder_start_token_id = tokenizer.cls_token_id
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.pad_token_id = tokenizer.pad_token_id

<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side.During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was  finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft).Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct.&quot;</span>,
<span class="hljs-meta">... </span>    return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
<span class="hljs-meta">... </span>).input_ids

<span class="hljs-meta">&gt;&gt;&gt; </span>labels = tokenizer(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;the eiffel tower surpassed the washington monument to become the tallest structure in the world. it was the first structure to reach a height of 300 metres in paris in 1930. it is now taller than the chrysler building by 5. 2 metres ( 17 ft ) and is the second tallest free - standing structure in paris.&quot;</span>,
<span class="hljs-meta">... </span>    return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
<span class="hljs-meta">... </span>).input_ids

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># the forward function automatically creates the correct decoder_input_ids</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = model(input_ids=input_ids, labels=labels).loss`}}),vo=new Y({}),wo=new S({props:{name:"class transformers.EncoderDecoderConfig",anchor:"transformers.EncoderDecoderConfig",parameters:[{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.EncoderDecoderConfig.kwargs",description:`<strong>kwargs</strong> (<em>optional</em>) &#x2014;
Dictionary of keyword arguments. Notably:</p>
<ul>
<li><strong>encoder</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a>, <em>optional</em>) &#x2014; An instance of a configuration object that defines
the encoder config.</li>
<li><strong>decoder</strong> (<a href="/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a>, <em>optional</em>) &#x2014; An instance of a configuration object that defines
the decoder config.</li>
</ul>`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/encoder_decoder/configuration_encoder_decoder.py#L25"}}),$e=new at({props:{anchor:"transformers.EncoderDecoderConfig.example",$$slots:{default:[zp]},$$scope:{ctx:W}}}),To=new S({props:{name:"from_encoder_decoder_configs",anchor:"transformers.EncoderDecoderConfig.from_encoder_decoder_configs",parameters:[{name:"encoder_config",val:": PretrainedConfig"},{name:"decoder_config",val:": PretrainedConfig"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/encoder_decoder/configuration_encoder_decoder.py#L90",returnDescription:`
<p>An instance of a configuration object</p>
`,returnType:`
<p><a
  href="/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig"
>EncoderDecoderConfig</a></p>
`}}),Jo=new Y({}),jo=new S({props:{name:"class transformers.EncoderDecoderModel",anchor:"transformers.EncoderDecoderModel",parameters:[{name:"config",val:": typing.Optional[transformers.configuration_utils.PretrainedConfig] = None"},{name:"encoder",val:": typing.Optional[transformers.modeling_utils.PreTrainedModel] = None"},{name:"decoder",val:": typing.Optional[transformers.modeling_utils.PreTrainedModel] = None"}],parametersDescription:[{anchor:"transformers.EncoderDecoderModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig">EncoderDecoderConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/encoder_decoder/modeling_encoder_decoder.py#L170"}}),Io=new S({props:{name:"forward",anchor:"transformers.EncoderDecoderModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"decoder_input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"decoder_attention_mask",val:": typing.Optional[torch.BoolTensor] = None"},{name:"encoder_outputs",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"},{name:"past_key_values",val:": typing.Tuple[typing.Tuple[torch.FloatTensor]] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"decoder_inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.EncoderDecoderModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.33.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.EncoderDecoderModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.EncoderDecoderModel.forward.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of decoder input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.33.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a></p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see
<code>past_key_values</code>).</p>
<p>For training, <code>decoder_input_ids</code> are automatically created by the model by shifting the <code>labels</code> to the
right, replacing -100 by the <code>pad_token_id</code> and prepending them with the <code>decoder_start_token_id</code>.`,name:"decoder_input_ids"},{anchor:"transformers.EncoderDecoderModel.forward.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.EncoderDecoderModel.forward.encoder_outputs",description:`<strong>encoder_outputs</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>) &#x2014;
This tuple must consist of (<code>last_hidden_state</code>, <em>optional</em>: <code>hidden_states</code>, <em>optional</em>: <code>attentions</code>)
<code>last_hidden_state</code> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) is a tensor
of hidden-states at the output of the last layer of the encoder. Used in the cross-attention of the
decoder.`,name:"encoder_outputs"},{anchor:"transformers.EncoderDecoderModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code> of length <code>config.n_layers</code> with each tuple having 4 tensors of shape <code>(batch_size, num_heads, sequence_length - 1, embed_size_per_head)</code>) &#x2014;
Contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.EncoderDecoderModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.EncoderDecoderModel.forward.decoder_inputs_embeds",description:`<strong>decoder_inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, target_sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>decoder_input_ids</code> you can choose to directly pass an embedded
representation. This is useful if you want more control over how to convert <code>decoder_input_ids</code> indices
into associated vectors than the model&#x2019;s internal embedding lookup matrix.`,name:"decoder_inputs_embeds"},{anchor:"transformers.EncoderDecoderModel.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the masked language modeling loss for the decoder. Indices should be in <code>[-100, 0, ..., config.vocab_size]</code> (see <code>input_ids</code> docstring) Tokens with indices set to <code>-100</code> are ignored
(masked), the loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>`,name:"labels"},{anchor:"transformers.EncoderDecoderModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.EncoderDecoderModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.EncoderDecoderModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.EncoderDecoderModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the model will return a <code>~utils.Seq2SeqLMOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.EncoderDecoderModel.forward.kwargs",description:`<strong>kwargs</strong> (<em>optional</em>) &#x2014; Remaining dictionary of keyword arguments. Keyword arguments come in two flavors:</p>
<ul>
<li>Without a prefix which will be input as <code>**encoder_kwargs</code> for the encoder forward function.</li>
<li>With a <em>decoder_</em> prefix which will be input as <code>**decoder_kwargs</code> for the decoder forward function.</li>
</ul>`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/encoder_decoder/modeling_encoder_decoder.py#L539",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.33.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqLMOutput"
>transformers.modeling_outputs.Seq2SeqLMOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig"
>EncoderDecoderConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Language modeling loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>decoder_hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>decoder_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
<li>
<p><strong>encoder_last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden-states at the output of the last layer of the encoder of the model.</p>
</li>
<li>
<p><strong>encoder_hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>encoder_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.33.0/en/main_classes/output#transformers.modeling_outputs.Seq2SeqLMOutput"
>transformers.modeling_outputs.Seq2SeqLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Fe=new Rc({props:{$$slots:{default:[Vp]},$$scope:{ctx:W}}}),Ce=new at({props:{anchor:"transformers.EncoderDecoderModel.forward.example",$$slots:{default:[$p]},$$scope:{ctx:W}}}),zo=new S({props:{name:"from_encoder_decoder_pretrained",anchor:"transformers.EncoderDecoderModel.from_encoder_decoder_pretrained",parameters:[{name:"encoder_pretrained_model_name_or_path",val:": str = None"},{name:"decoder_pretrained_model_name_or_path",val:": str = None"},{name:"*model_args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.EncoderDecoderModel.from_encoder_decoder_pretrained.encoder_pretrained_model_name_or_path",description:`<strong>encoder_pretrained_model_name_or_path</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Information necessary to initiate the encoder. Can be either:</p>
<ul>
<li>A string, the <em>model id</em> of a pretrained model hosted inside a model repo on huggingface.co.
Valid model ids can be located at the root-level, like <code>bert-base-uncased</code>, or namespaced under a
user or organization name, like <code>dbmdz/bert-base-german-cased</code>.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel.save_pretrained">save_pretrained()</a>, e.g., <code>./my_model_directory/</code>.</li>
<li>A path or url to a <em>tensorflow index checkpoint file</em> (e.g, <code>./tf_model/model.ckpt.index</code>). In
this case, <code>from_tf</code> should be set to <code>True</code> and a configuration object should be provided as
<code>config</code> argument. This loading path is slower than converting the TensorFlow checkpoint in a
PyTorch model using the provided conversion scripts and loading the PyTorch model afterwards.</li>
</ul>`,name:"encoder_pretrained_model_name_or_path"},{anchor:"transformers.EncoderDecoderModel.from_encoder_decoder_pretrained.decoder_pretrained_model_name_or_path",description:`<strong>decoder_pretrained_model_name_or_path</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Information necessary to initiate the decoder. Can be either:</p>
<ul>
<li>A string, the <em>model id</em> of a pretrained model hosted inside a model repo on huggingface.co.
Valid model ids can be located at the root-level, like <code>bert-base-uncased</code>, or namespaced under a
user or organization name, like <code>dbmdz/bert-base-german-cased</code>.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel.save_pretrained">save_pretrained()</a>, e.g., <code>./my_model_directory/</code>.</li>
<li>A path or url to a <em>tensorflow index checkpoint file</em> (e.g, <code>./tf_model/model.ckpt.index</code>). In
this case, <code>from_tf</code> should be set to <code>True</code> and a configuration object should be provided as
<code>config</code> argument. This loading path is slower than converting the TensorFlow checkpoint in a
PyTorch model using the provided conversion scripts and loading the PyTorch model afterwards.</li>
</ul>`,name:"decoder_pretrained_model_name_or_path"},{anchor:"transformers.EncoderDecoderModel.from_encoder_decoder_pretrained.model_args",description:`<strong>model_args</strong> (remaining positional arguments, <em>optional</em>) &#x2014;
All remaining positional arguments will be passed to the underlying model&#x2019;s <code>__init__</code> method.`,name:"model_args"},{anchor:"transformers.EncoderDecoderModel.from_encoder_decoder_pretrained.kwargs",description:`<strong>kwargs</strong> (remaining dictionary of keyword arguments, <em>optional</em>) &#x2014;
Can be used to update the configuration object (after it being loaded) and initiate the model (e.g.,
<code>output_attentions=True</code>).</p>
<ul>
<li>To update the encoder configuration, use the prefix <em>encoder_</em> for each configuration parameter.</li>
<li>To update the decoder configuration, use the prefix <em>decoder_</em> for each configuration parameter.</li>
<li>To update the parent model configuration, do not use a prefix for each configuration parameter.</li>
</ul>
<p>Behaves differently depending on whether a <code>config</code> is provided or automatically loaded.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/encoder_decoder/modeling_encoder_decoder.py#L389"}}),xe=new at({props:{anchor:"transformers.EncoderDecoderModel.from_encoder_decoder_pretrained.example",$$slots:{default:[Rp]},$$scope:{ctx:W}}}),Vo=new Y({}),$o=new S({props:{name:"class transformers.TFEncoderDecoderModel",anchor:"transformers.TFEncoderDecoderModel",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFEncoderDecoderModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig">EncoderDecoderConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/encoder_decoder/modeling_tf_encoder_decoder.py#L193"}}),Do=new S({props:{name:"call",anchor:"transformers.TFEncoderDecoderModel.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"decoder_input_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"decoder_attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"encoder_outputs",val:": np.ndarray | tf.Tensor | None = None"},{name:"past_key_values",val:": Tuple[Tuple[tf.Tensor]] | None = None"},{name:"inputs_embeds",val:": np.ndarray | tf.Tensor | None = None"},{name:"decoder_inputs_embeds",val:": np.ndarray | tf.Tensor | None = None"},{name:"labels",val:": np.ndarray | tf.Tensor | None = None"},{name:"use_cache",val:": Optional[bool] = None"},{name:"output_attentions",val:": Optional[bool] = None"},{name:"output_hidden_states",val:": Optional[bool] = None"},{name:"return_dict",val:": Optional[bool] = None"},{name:"training",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFEncoderDecoderModel.call.input_ids",description:`<strong>input_ids</strong> (<code>np.ndarray</code>, <code>tf.Tensor</code>, <code>List[tf.Tensor]</code> \`<code>Dict[str, tf.Tensor]</code> or <code>Dict[str, np.ndarray]</code> and each example must have the shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.33.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.TFEncoderDecoderModel.call.attention_mask",description:`<strong>attention_mask</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TFEncoderDecoderModel.call.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of decoder input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.33.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a></p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>decoder_input_ids</code> have to be input (see
<code>past_key_values</code>).</p>
<p>Provide for sequence to sequence training to the decoder. Indices can be obtained using
<a href="/docs/transformers/v4.33.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and <a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for
details.`,name:"decoder_input_ids"},{anchor:"transformers.TFEncoderDecoderModel.call.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.TFEncoderDecoderModel.call.encoder_outputs",description:`<strong>encoder_outputs</strong> (<code>tuple(tuple(tf.Tensor)</code>, <em>optional</em>) &#x2014;
This tuple must consist of (<code>last_hidden_state</code>, <em>optional</em>: <code>hidden_states</code>, <em>optional</em>: <code>attentions</code>)
<code>last_hidden_state</code> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) is a tensor of hidden-states at the output
of the last layer of the encoder. Used in the cross-attention of the decoder.`,name:"encoder_outputs"},{anchor:"transformers.TFEncoderDecoderModel.call.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(tf.Tensor))</code> of length <code>config.n_layers</code> with each tuple having 4 tensors of shape <code>(batch_size, num_heads, sequence_length - 1, embed_size_per_head)</code>) &#x2014;
Contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.TFEncoderDecoderModel.call.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.TFEncoderDecoderModel.call.decoder_inputs_embeds",description:`<strong>decoder_inputs_embeds</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>(batch_size, target_sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>decoder_input_ids</code> you can choose to directly pass an embedded
representation. This is useful if you want more control over how to convert <code>decoder_input_ids</code> indices
into associated vectors than the model&#x2019;s internal embedding lookup matrix.`,name:"decoder_inputs_embeds"},{anchor:"transformers.TFEncoderDecoderModel.call.labels",description:`<strong>labels</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the masked language modeling loss for the decoder. Indices should be in <code>[-100, 0, ..., config.vocab_size]</code> (see <code>input_ids</code> docstring) Tokens with indices set to <code>-100</code> are ignored
(masked), the loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>`,name:"labels"},{anchor:"transformers.TFEncoderDecoderModel.call.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.TFEncoderDecoderModel.call.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.TFEncoderDecoderModel.call.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.TFEncoderDecoderModel.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the model will return a <code>~utils.Seq2SeqLMOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.TFEncoderDecoderModel.call.training",description:`<strong>training</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use the model in training mode (some modules like dropout modules have different
behaviors between training and evaluation).`,name:"training"},{anchor:"transformers.TFEncoderDecoderModel.call.kwargs",description:`<strong>kwargs</strong> (<em>optional</em>) &#x2014; Remaining dictionary of keyword arguments. Keyword arguments come in two flavors:</p>
<ul>
<li>Without a prefix which will be input as <code>**encoder_kwargs</code> for the encoder forward function.</li>
<li>With a <em>decoder_</em> prefix which will be input as \`**decoder_kwargs&#x201C; for the decoder forward function.</li>
</ul>`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/encoder_decoder/modeling_tf_encoder_decoder.py#L469",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.33.0/en/main_classes/output#transformers.modeling_tf_outputs.TFSeq2SeqLMOutput"
>transformers.modeling_tf_outputs.TFSeq2SeqLMOutput</a> or a tuple of <code>tf.Tensor</code> (if
<code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various elements depending on the
configuration (<a
  href="/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig"
>EncoderDecoderConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>tf.Tensor</code> of shape <code>(n,)</code>, <em>optional</em>, where n is the number of non-masked labels, returned when <code>labels</code> is provided) \u2014 Language modeling loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>List[tf.Tensor]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 List of <code>tf.Tensor</code> of length <code>config.n_layers</code>, with each tensor of shape <code>(2, batch_size, num_heads, sequence_length, embed_size_per_head)</code>).</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) of the decoder that can be
used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>decoder_hidden_states</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>decoder_attentions</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
<li>
<p><strong>encoder_last_hidden_state</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden-states at the output of the last layer of the encoder of the model.</p>
</li>
<li>
<p><strong>encoder_hidden_states</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>encoder_attentions</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.33.0/en/main_classes/output#transformers.modeling_tf_outputs.TFSeq2SeqLMOutput"
>transformers.modeling_tf_outputs.TFSeq2SeqLMOutput</a> or <code>tuple(tf.Tensor)</code></p>
`}}),Ne=new Rc({props:{$$slots:{default:[Bp]},$$scope:{ctx:W}}}),qe=new at({props:{anchor:"transformers.TFEncoderDecoderModel.call.example",$$slots:{default:[Fp]},$$scope:{ctx:W}}}),No=new S({props:{name:"from_encoder_decoder_pretrained",anchor:"transformers.TFEncoderDecoderModel.from_encoder_decoder_pretrained",parameters:[{name:"encoder_pretrained_model_name_or_path",val:": str = None"},{name:"decoder_pretrained_model_name_or_path",val:": str = None"},{name:"*model_args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFEncoderDecoderModel.from_encoder_decoder_pretrained.encoder_pretrained_model_name_or_path",description:`<strong>encoder_pretrained_model_name_or_path</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Information necessary to initiate the encoder. Can be either:</p>
<ul>
<li>A string, the <em>model id</em> of a pretrained model hosted inside a model repo on huggingface.co.
Valid model ids can be located at the root-level, like <code>bert-base-uncased</code>, or namespaced under a
user or organization name, like <code>dbmdz/bert-base-german-cased</code>.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel.save_pretrained">save_pretrained()</a>, e.g., <code>./my_model_directory/</code>.</li>
<li>A path or url to a <em>pytorch index checkpoint file</em> (e.g, <code>./pt_model/</code>). In this case,
<code>encoder_from_pt</code> should be set to <code>True</code>.</li>
</ul>`,name:"encoder_pretrained_model_name_or_path"},{anchor:"transformers.TFEncoderDecoderModel.from_encoder_decoder_pretrained.decoder_pretrained_model_name_or_path",description:`<strong>decoder_pretrained_model_name_or_path</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Information necessary to initiate the decoder. Can be either:</p>
<ul>
<li>A string, the <em>model id</em> of a pretrained model hosted inside a model repo on huggingface.co.
Valid model ids can be located at the root-level, like <code>bert-base-uncased</code>, or namespaced under a
user or organization name, like <code>dbmdz/bert-base-german-cased</code>.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel.save_pretrained">save_pretrained()</a>, e.g., <code>./my_model_directory/</code>.</li>
<li>A path or url to a <em>pytorch checkpoint file</em> (e.g, <code>./pt_model/</code>). In this case,
<code>decoder_from_pt</code> should be set to <code>True</code>.</li>
</ul>`,name:"decoder_pretrained_model_name_or_path"},{anchor:"transformers.TFEncoderDecoderModel.from_encoder_decoder_pretrained.model_args",description:`<strong>model_args</strong> (remaining positional arguments, <em>optional</em>) &#x2014;
All remaning positional arguments will be passed to the underlying model&#x2019;s <code>__init__</code> method.`,name:"model_args"},{anchor:"transformers.TFEncoderDecoderModel.from_encoder_decoder_pretrained.kwargs",description:`<strong>kwargs</strong> (remaining dictionary of keyword arguments, <em>optional</em>) &#x2014;
Can be used to update the configuration object (after it being loaded) and initiate the model (e.g.,
<code>output_attentions=True</code>).</p>
<ul>
<li>To update the encoder configuration, use the prefix <em>encoder_</em> for each configuration parameter.</li>
<li>To update the decoder configuration, use the prefix <em>decoder_</em> for each configuration parameter.</li>
<li>To update the parent model configuration, do not use a prefix for each configuration parameter.</li>
</ul>
<p>Behaves differently depending on whether a <code>config</code> is provided or automatically loaded.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/encoder_decoder/modeling_tf_encoder_decoder.py#L322"}}),Xe=new at({props:{anchor:"transformers.TFEncoderDecoderModel.from_encoder_decoder_pretrained.example",$$slots:{default:[Cp]},$$scope:{ctx:W}}}),qo=new Y({}),Xo=new S({props:{name:"class transformers.FlaxEncoderDecoderModel",anchor:"transformers.FlaxEncoderDecoderModel",parameters:[{name:"config",val:": EncoderDecoderConfig"},{name:"input_shape",val:": typing.Optional[typing.Tuple] = None"},{name:"seed",val:": int = 0"},{name:"dtype",val:": dtype = <class 'jax.numpy.float32'>"},{name:"_do_init",val:": bool = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.FlaxEncoderDecoderModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig">EncoderDecoderConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.FlaxPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"},{anchor:"transformers.FlaxEncoderDecoderModel.dtype",description:`<strong>dtype</strong> (<code>jax.numpy.dtype</code>, <em>optional</em>, defaults to <code>jax.numpy.float32</code>) &#x2014;
The data type of the computation. Can be one of <code>jax.numpy.float32</code>, <code>jax.numpy.float16</code> (on GPUs) and
<code>jax.numpy.bfloat16</code> (on TPUs).</p>
<p>This can be used to enable mixed-precision training or half-precision inference on GPUs or TPUs. If
specified all the computation will be performed with the given <code>dtype</code>.</p>
<p><strong>Note that this only specifies the dtype of the computation and does not influence the dtype of model
parameters.</strong></p>
<p>If you wish to change the dtype of the model parameters, see <a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.FlaxPreTrainedModel.to_fp16">to_fp16()</a> and
<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.FlaxPreTrainedModel.to_bf16">to_bf16()</a>.`,name:"dtype"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/encoder_decoder/modeling_flax_encoder_decoder.py#L302"}}),Qo=new S({props:{name:"__call__",anchor:"transformers.FlaxEncoderDecoderModel.__call__",parameters:[{name:"input_ids",val:": Array"},{name:"attention_mask",val:": typing.Optional[jax.Array] = None"},{name:"decoder_input_ids",val:": typing.Optional[jax.Array] = None"},{name:"decoder_attention_mask",val:": typing.Optional[jax.Array] = None"},{name:"position_ids",val:": typing.Optional[jax.Array] = None"},{name:"decoder_position_ids",val:": typing.Optional[jax.Array] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"train",val:": bool = False"},{name:"params",val:": dict = None"},{name:"dropout_rng",val:": PRNGKey = None"}],parametersDescription:[{anchor:"transformers.FlaxEncoderDecoderModel.__call__.input_ids",description:`<strong>input_ids</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
it.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.33.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.FlaxEncoderDecoderModel.__call__.attention_mask",description:`<strong>attention_mask</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.FlaxEncoderDecoderModel.__call__.decoder_input_ids",description:`<strong>decoder_input_ids</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of decoder input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.33.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.33.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#decoder-input-ids">What are decoder input IDs?</a></p>
<p>For sequence to sequence training, <code>decoder_input_ids</code> should be provided. <code>decoder_input_ids</code> should be
created outside of the model by shifting the <code>labels</code> to the right, replacing -100 by the <code>pad_token_id</code>
and prepending them with the <code>decoder_start_token_id</code>.`,name:"decoder_input_ids"},{anchor:"transformers.FlaxEncoderDecoderModel.__call__.decoder_attention_mask",description:`<strong>decoder_attention_mask</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, target_sequence_length)</code>, <em>optional</em>) &#x2014;
Default behavior: generate a tensor that ignores pad tokens in <code>decoder_input_ids</code>. Causal mask will also
be used by default.`,name:"decoder_attention_mask"},{anchor:"transformers.FlaxEncoderDecoderModel.__call__.position_ids",description:`<strong>position_ids</strong> (<code>numpy.ndarray</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.encoder.max_position_embeddings - 1]</code>.`,name:"position_ids"},{anchor:"transformers.FlaxEncoderDecoderModel.__call__.decoder_position_ids",description:`<strong>decoder_position_ids</strong> (<code>numpy.ndarray</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each decoder input sequence tokens in the position embeddings. Selected in the
range <code>[0, config.decoder.max_position_embeddings - 1]</code>.`,name:"decoder_position_ids"},{anchor:"transformers.FlaxEncoderDecoderModel.__call__.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.FlaxEncoderDecoderModel.__call__.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.FlaxEncoderDecoderModel.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, the model will return a <code>~utils.FlaxSeq2SeqLMOutput</code> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/encoder_decoder/modeling_flax_encoder_decoder.py#L627",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.33.0/en/main_classes/output#transformers.modeling_flax_outputs.FlaxSeq2SeqLMOutput"
>transformers.modeling_flax_outputs.FlaxSeq2SeqLMOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig"
>EncoderDecoderConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>logits</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(jnp.ndarray))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>tuple(jnp.ndarray)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and 2 additional tensors of shape
<code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>decoder_hidden_states</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>jnp.ndarray</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>decoder_attentions</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>jnp.ndarray</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>jnp.ndarray</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
<li>
<p><strong>encoder_last_hidden_state</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) \u2014 Sequence of hidden-states at the output of the last layer of the encoder of the model.</p>
</li>
<li>
<p><strong>encoder_hidden_states</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>jnp.ndarray</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>encoder_attentions</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>jnp.ndarray</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the
self-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.33.0/en/main_classes/output#transformers.modeling_flax_outputs.FlaxSeq2SeqLMOutput"
>transformers.modeling_flax_outputs.FlaxSeq2SeqLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ye=new Rc({props:{$$slots:{default:[xp]},$$scope:{ctx:W}}}),Ae=new at({props:{anchor:"transformers.FlaxEncoderDecoderModel.__call__.example",$$slots:{default:[Dp]},$$scope:{ctx:W}}}),Lo=new S({props:{name:"from_encoder_decoder_pretrained",anchor:"transformers.FlaxEncoderDecoderModel.from_encoder_decoder_pretrained",parameters:[{name:"encoder_pretrained_model_name_or_path",val:": typing.Union[str, os.PathLike, NoneType] = None"},{name:"decoder_pretrained_model_name_or_path",val:": typing.Union[str, os.PathLike, NoneType] = None"},{name:"*model_args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.FlaxEncoderDecoderModel.from_encoder_decoder_pretrained.encoder_pretrained_model_name_or_path",description:`<strong>encoder_pretrained_model_name_or_path</strong> (<code>Union[str, os.PathLike]</code>, <em>optional</em>) &#x2014;
Information necessary to initiate the encoder. Can be either:</p>
<ul>
<li>A string, the <em>model id</em> of a pretrained model hosted inside a model repo on huggingface.co.
Valid model ids can be located at the root-level, like <code>bert-base-uncased</code>, or namespaced under a
user or organization name, like <code>dbmdz/bert-base-german-cased</code>.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.FlaxPreTrainedModel.save_pretrained">save_pretrained()</a>, e.g., <code>./my_model_directory/</code>.</li>
</ul>`,name:"encoder_pretrained_model_name_or_path"},{anchor:"transformers.FlaxEncoderDecoderModel.from_encoder_decoder_pretrained.decoder_pretrained_model_name_or_path",description:`<strong>decoder_pretrained_model_name_or_path</strong> (<code>Union[str, os.PathLike]</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Information necessary to initiate the decoder. Can be either:</p>
<ul>
<li>A string, the <em>model id</em> of a pretrained model hosted inside a model repo on huggingface.co.
Valid model ids can be located at the root-level, like <code>bert-base-uncased</code>, or namespaced under a
user or organization name, like <code>dbmdz/bert-base-german-cased</code>.</li>
<li>A path to a <em>directory</em> containing model weights saved using
<a href="/docs/transformers/v4.33.0/en/main_classes/model#transformers.FlaxPreTrainedModel.save_pretrained">save_pretrained()</a>, e.g., <code>./my_model_directory/</code>.</li>
</ul>`,name:"decoder_pretrained_model_name_or_path"},{anchor:"transformers.FlaxEncoderDecoderModel.from_encoder_decoder_pretrained.model_args",description:`<strong>model_args</strong> (remaining positional arguments, <em>optional</em>) &#x2014;
All remaning positional arguments will be passed to the underlying model&#x2019;s <code>__init__</code> method.`,name:"model_args"},{anchor:"transformers.FlaxEncoderDecoderModel.from_encoder_decoder_pretrained.kwargs",description:`<strong>kwargs</strong> (remaining dictionary of keyword arguments, <em>optional</em>) &#x2014;
Can be used to update the configuration object (after it being loaded) and initiate the model (e.g.,
<code>output_attentions=True</code>).</p>
<ul>
<li>To update the encoder configuration, use the prefix <em>encoder_</em> for each configuration parameter.</li>
<li>To update the decoder configuration, use the prefix <em>decoder_</em> for each configuration parameter.</li>
<li>To update the parent model configuration, do not use a prefix for each configuration parameter.</li>
</ul>
<p>Behaves differently depending on whether a <code>config</code> is provided or automatically loaded.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/encoder_decoder/modeling_flax_encoder_decoder.py#L759"}}),He=new at({props:{anchor:"transformers.FlaxEncoderDecoderModel.from_encoder_decoder_pretrained.example",$$slots:{default:[Np]},$$scope:{ctx:W}}}),{c(){h=a("meta"),b=i(),_=a("h1"),f=a("a"),y=a("span"),M(l.$$.fragment),g=i(),R=a("span"),ca=n("Encoder Decoder Models"),nr=i(),te=a("h2"),ve=a("a"),Qt=a("span"),M(eo.$$.fragment),ia=i(),Lt=a("span"),pa=n("Overview"),rr=i(),we=a("p"),ma=n("The "),dt=a("a"),ha=n("EncoderDecoderModel"),fa=n(` can be used to initialize a sequence-to-sequence model with any
pretrained autoencoding model as the encoder and any pretrained autoregressive model as the decoder.`),ar=i(),Te=a("p"),ua=n(`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation tasks
was shown in `),oo=a("a"),ga=n("Leveraging Pre-trained Checkpoints for Sequence Generation Tasks"),_a=n(` by
Sascha Rothe, Shashi Narayan, Aliaksei Severyn.`),sr=i(),ke=a("p"),ya=n("After such an "),lt=a("a"),ba=n("EncoderDecoderModel"),Ma=n(` has been trained/fine-tuned, it can be saved/loaded just like
any other models (see the examples for more information).`),dr=i(),A=a("p"),va=n("An application of this architecture could be to leverage two pretrained "),ct=a("a"),wa=n("BertModel"),Ta=n(` as the encoder
and decoder for a summarization model as was shown in: `),to=a("a"),ka=n("Text Summarization with Pretrained Encoders"),Ja=n(" by Yang Liu and Mirella Lapata."),lr=i(),ne=a("h2"),Je=a("a"),Ot=a("span"),M(no.$$.fragment),ja=i(),ro=a("span"),Ea=n("Randomly initializing "),Kt=a("code"),Za=n("EncoderDecoderModel"),Ua=n(" from model configurations."),cr=i(),X=a("p"),it=a("a"),Wa=n("EncoderDecoderModel"),Ga=n(" can be randomly initialized from an encoder and a decoder config. In the following example, we show how to do this using the default "),pt=a("a"),Ia=n("BertModel"),za=n(" configuration for the encoder and the default "),en=a("code"),Va=n("BertForCausalLM"),$a=n(" configuration for the decoder."),ir=i(),M(ao.$$.fragment),pr=i(),re=a("h2"),je=a("a"),on=a("span"),M(so.$$.fragment),Ra=i(),lo=a("span"),Ba=n("Initialising "),tn=a("code"),Fa=n("EncoderDecoderModel"),Ca=n(" from a pretrained encoder and a pretrained decoder."),mr=i(),j=a("p"),mt=a("a"),xa=n("EncoderDecoderModel"),Da=n(" can be initialized from a pretrained encoder checkpoint and a pretrained decoder checkpoint. Note that any pretrained auto-encoding model, "),nn=a("em"),Na=n("e.g."),qa=n(" BERT, can serve as the encoder and both pretrained auto-encoding models, "),rn=a("em"),Xa=n("e.g."),Sa=n(" BERT, pretrained causal language models, "),an=a("em"),Ya=n("e.g."),Aa=n(" GPT2, as well as the pretrained decoder part of sequence-to-sequence models, "),sn=a("em"),Ha=n("e.g."),Pa=n(` decoder of BART, can be used as the decoder.
Depending on which architecture you choose as the decoder, the cross-attention layers might be randomly initialized.
Initializing `),ht=a("a"),Qa=n("EncoderDecoderModel"),La=n(" from a pretrained encoder and decoder checkpoint requires the model to be fine-tuned on a downstream task, as has been shown in "),Ee=a("a"),Oa=n("the "),dn=a("em"),Ka=n("Warm-starting-encoder-decoder blog post"),es=n(`.
To do so, the `),ln=a("code"),os=n("EncoderDecoderModel"),ts=n(" class provides a "),ft=a("a"),ns=n("EncoderDecoderModel.from_encoder_decoder_pretrained()"),rs=n(" method."),hr=i(),M(co.$$.fragment),fr=i(),ae=a("h2"),Ze=a("a"),cn=a("span"),M(io.$$.fragment),as=i(),po=a("span"),ss=n("Loading an existing "),pn=a("code"),ds=n("EncoderDecoderModel"),ls=n(" checkpoint and perform inference."),ur=i(),F=a("p"),cs=n("To load fine-tuned checkpoints of the "),mn=a("code"),is=n("EncoderDecoderModel"),ps=n(" class, "),ut=a("a"),ms=n("EncoderDecoderModel"),hs=n(" provides the "),hn=a("code"),fs=n("from_pretrained(...)"),us=n(" method just like any other model architecture in Transformers."),gr=i(),Ue=a("p"),gs=n("To perform inference, one uses the "),fn=a("code"),_s=n("generate"),ys=n(" method, which allows to autoregressively generate text. This method supports various forms of decoding, such as greedy, beam search and multinomial sampling."),_r=i(),M(mo.$$.fragment),yr=i(),se=a("h2"),We=a("a"),un=a("span"),M(ho.$$.fragment),bs=i(),fo=a("span"),Ms=n("Loading a PyTorch checkpoint into "),gn=a("code"),vs=n("TFEncoderDecoderModel"),ws=n("."),br=i(),de=a("p"),_n=a("code"),Ts=n("TFEncoderDecoderModel.from_pretrained()"),ks=n(` currently doesn\u2019t support initializing the model from a
pytorch checkpoint. Passing `),yn=a("code"),Js=n("from_pt=True"),js=n(` to this method will throw an exception. If there are only pytorch
checkpoints for a particular encoder-decoder model, a workaround is:`),Mr=i(),M(uo.$$.fragment),vr=i(),le=a("h2"),Ge=a("a"),bn=a("span"),M(go.$$.fragment),Es=i(),Mn=a("span"),Zs=n("Training"),wr=i(),B=a("p"),Us=n(`Once the model is created, it can be fine-tuned similar to BART, T5 or any other encoder-decoder model.
As you can see, only 2 inputs are required for the model in order to compute a loss: `),vn=a("code"),Ws=n("input_ids"),Gs=n(` (which are the
`),wn=a("code"),Is=n("input_ids"),zs=n(" of the encoded input sequence) and "),Tn=a("code"),Vs=n("labels"),$s=n(" (which are the "),kn=a("code"),Rs=n("input_ids"),Bs=n(` of the encoded
target sequence).`),Tr=i(),M(_o.$$.fragment),kr=i(),Ie=a("p"),Fs=n("Detailed "),yo=a("a"),Cs=n("colab"),xs=n(" for training."),Jr=i(),H=a("p"),Ds=n("This model was contributed by "),bo=a("a"),Ns=n("thomwolf"),qs=n(`. This model\u2019s TensorFlow and Flax versions
were contributed by `),Mo=a("a"),Xs=n("ydshieh"),Ss=n("."),jr=i(),ce=a("h2"),ze=a("a"),Jn=a("span"),M(vo.$$.fragment),Ys=i(),jn=a("span"),As=n("EncoderDecoderConfig"),Er=i(),$=a("div"),M(wo.$$.fragment),Hs=i(),Ve=a("p"),gt=a("a"),Ps=n("EncoderDecoderConfig"),Qs=n(" is the configuration class to store the configuration of a "),_t=a("a"),Ls=n("EncoderDecoderModel"),Os=n(`. It is
used to instantiate an Encoder Decoder model according to the specified arguments, defining the encoder and decoder
configs.`),Ks=i(),ie=a("p"),ed=n("Configuration objects inherit from "),yt=a("a"),od=n("PretrainedConfig"),td=n(` and can be used to control the model outputs. Read the
documentation from `),bt=a("a"),nd=n("PretrainedConfig"),rd=n(" for more information."),ad=i(),M($e.$$.fragment),sd=i(),Re=a("div"),M(To.$$.fragment),dd=i(),ko=a("p"),ld=n("Instantiate a "),Mt=a("a"),cd=n("EncoderDecoderConfig"),id=n(` (or a derived class) from a pre-trained encoder model configuration and
decoder model configuration.`),Zr=i(),pe=a("h2"),Be=a("a"),En=a("span"),M(Jo.$$.fragment),pd=i(),Zn=a("span"),md=n("EncoderDecoderModel"),Ur=i(),E=a("div"),M(jo.$$.fragment),hd=i(),me=a("p"),fd=n(`This class can be used to initialize a sequence-to-sequence model with any pretrained autoencoding model as the
encoder and any pretrained autoregressive model as the decoder. The encoder is loaded via
`),vt=a("a"),ud=n("from_pretrained()"),gd=n(" function and the decoder is loaded via "),wt=a("a"),_d=n("from_pretrained()"),yd=n(`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like summarization.`),bd=i(),Eo=a("p"),Md=n(`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Zo=a("a"),vd=n(`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),wd=n(` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),Td=i(),Un=a("p"),kd=n(`After such an Encoder Decoder model has been trained/fine-tuned, it can be saved/loaded just like any other models
(see the examples for more information).`),Jd=i(),Uo=a("p"),jd=n("This model inherits from "),Tt=a("a"),Ed=n("PreTrainedModel"),Zd=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Ud=i(),Wo=a("p"),Wd=n("This model is also a PyTorch "),Go=a("a"),Gd=n("torch.nn.Module"),Id=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),zd=i(),P=a("p"),kt=a("a"),Vd=n("EncoderDecoderModel"),$d=n(` is a generic model class that will be instantiated as a transformer architecture with one
of the base model classes of the library as encoder and another one as decoder when created with the
:meth`),Wn=a("em"),Rd=n("~transformers.AutoModel.from_pretrained"),Bd=n(` class method for the encoder and
:meth`),Gn=a("em"),Fd=n("~transformers.AutoModelForCausalLM.from_pretrained"),Cd=n(" class method for the decoder."),xd=i(),C=a("div"),M(Io.$$.fragment),Dd=i(),he=a("p"),Nd=n("The "),Jt=a("a"),qd=n("EncoderDecoderModel"),Xd=n(" forward method, overrides the "),In=a("code"),Sd=n("__call__"),Yd=n(" special method."),Ad=i(),M(Fe.$$.fragment),Hd=i(),M(Ce.$$.fragment),Pd=i(),x=a("div"),M(zo.$$.fragment),Qd=i(),zn=a("p"),Ld=n(`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),Od=i(),fe=a("p"),Kd=n("The model is set in evaluation mode by default using "),Vn=a("code"),el=n("model.eval()"),ol=n(` (Dropout modules are deactivated). To train
the model, you need to first set it back in training mode with `),$n=a("code"),tl=n("model.train()"),nl=n("."),rl=i(),M(xe.$$.fragment),Wr=i(),ue=a("h2"),De=a("a"),Rn=a("span"),M(Vo.$$.fragment),al=i(),Bn=a("span"),sl=n("TFEncoderDecoderModel"),Gr=i(),Z=a("div"),M($o.$$.fragment),dl=i(),ge=a("p"),ll=n(`This class can be used to initialize a sequence-to-sequence model with any pretrained autoencoding model as the
encoder and any pretrained autoregressive model as the decoder. The encoder is loaded via
`),jt=a("a"),cl=n("from_pretrained()"),il=n(" function and the decoder is loaded via "),Et=a("a"),pl=n("from_pretrained()"),ml=n(`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like summarization.`),hl=i(),Ro=a("p"),fl=n(`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Bo=a("a"),ul=n(`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),gl=n(` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),_l=i(),Fn=a("p"),yl=n(`After such an Encoder Decoder model has been trained/fine-tuned, it can be saved/loaded just like any other models
(see the examples for more information).`),bl=i(),Fo=a("p"),Ml=n("This model inherits from "),Zt=a("a"),vl=n("TFPreTrainedModel"),wl=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Tl=i(),Co=a("p"),kl=n("This model is also a "),xo=a("a"),Jl=n("tf.keras.Model"),jl=n(` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),El=i(),Q=a("p"),Ut=a("a"),Zl=n("TFEncoderDecoderModel"),Ul=n(` is a generic model class that will be instantiated as a transformer architecture with one
of the base model classes of the library as encoder and another one as decoder when created with the
`),Wt=a("a"),Wl=n("from_pretrained()"),Gl=n(" class method for the encoder and "),Gt=a("a"),Il=n("from_pretrained()"),zl=n(` class
method for the decoder.`),Vl=i(),D=a("div"),M(Do.$$.fragment),$l=i(),_e=a("p"),Rl=n("The "),It=a("a"),Bl=n("TFEncoderDecoderModel"),Fl=n(" forward method, overrides the "),Cn=a("code"),Cl=n("__call__"),xl=n(" special method."),Dl=i(),M(Ne.$$.fragment),Nl=i(),M(qe.$$.fragment),ql=i(),L=a("div"),M(No.$$.fragment),Xl=i(),xn=a("p"),Sl=n(`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),Yl=i(),M(Xe.$$.fragment),Ir=i(),ye=a("h2"),Se=a("a"),Dn=a("span"),M(qo.$$.fragment),Al=i(),Nn=a("span"),Hl=n("FlaxEncoderDecoderModel"),zr=i(),U=a("div"),M(Xo.$$.fragment),Pl=i(),be=a("p"),Ql=n(`This class can be used to initialize a sequence-to-sequence model with any pretrained autoencoding model as the
encoder and any pretrained autoregressive model as the decoder. The encoder is loaded via
`),zt=a("a"),Ll=n("from_pretrained()"),Ol=n(" function and the decoder is loaded via "),Vt=a("a"),Kl=n("from_pretrained()"),ec=n(`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like summarization.`),oc=i(),So=a("p"),tc=n(`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Yo=a("a"),nc=n(`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),rc=n(` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),ac=i(),qn=a("p"),sc=n(`After such an Encoder Decoder model has been trained/fine-tuned, it can be saved/loaded just like any other models
(see the examples for more information).`),dc=i(),Ao=a("p"),lc=n("This model inherits from "),$t=a("a"),cc=n("FlaxPreTrainedModel"),ic=n(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),pc=i(),Ho=a("p"),mc=n(`This model is also a Flax Linen
`),Po=a("a"),hc=n("flax.nn.Module"),fc=n(` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),uc=i(),O=a("p"),Rt=a("a"),gc=n("FlaxEncoderDecoderModel"),_c=n(` is a generic model class that will be instantiated as a transformer architecture with
the module (flax.nn.Module) of one of the base model classes of the library as encoder module and another one as
decoder module when created with the :meth`),Xn=a("em"),yc=n("~transformers.FlaxAutoModel.from_pretrained"),bc=n(` class method for the
encoder and :meth`),Sn=a("em"),Mc=n("~transformers.FlaxAutoModelForCausalLM.from_pretrained"),vc=n(" class method for the decoder."),wc=i(),N=a("div"),M(Qo.$$.fragment),Tc=i(),Me=a("p"),kc=n("The "),Bt=a("a"),Jc=n("FlaxEncoderDecoderModel"),jc=n(" forward method, overrides the "),Yn=a("code"),Ec=n("__call__"),Zc=n(" special method."),Uc=i(),M(Ye.$$.fragment),Wc=i(),M(Ae.$$.fragment),Gc=i(),K=a("div"),M(Lo.$$.fragment),Ic=i(),An=a("p"),zc=n(`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),Vc=i(),M(He.$$.fragment),this.h()},l(o){const m=Gp('[data-svelte="svelte-1phssyn"]',document.head);h=s(m,"META",{name:!0,content:!0}),m.forEach(t),b=p(o),_=s(o,"H1",{class:!0});var Oo=d(_);f=s(Oo,"A",{id:!0,class:!0,href:!0});var Hn=d(f);y=s(Hn,"SPAN",{});var Pn=d(y);v(l.$$.fragment,Pn),Pn.forEach(t),Hn.forEach(t),g=p(Oo),R=s(Oo,"SPAN",{});var Qn=d(R);ca=r(Qn,"Encoder Decoder Models"),Qn.forEach(t),Oo.forEach(t),nr=p(o),te=s(o,"H2",{class:!0});var Ko=d(te);ve=s(Ko,"A",{id:!0,class:!0,href:!0});var Ln=d(ve);Qt=s(Ln,"SPAN",{});var On=d(Qt);v(eo.$$.fragment,On),On.forEach(t),Ln.forEach(t),ia=p(Ko),Lt=s(Ko,"SPAN",{});var Kn=d(Lt);pa=r(Kn,"Overview"),Kn.forEach(t),Ko.forEach(t),rr=p(o),we=s(o,"P",{});var et=d(we);ma=r(et,"The "),dt=s(et,"A",{href:!0});var er=d(dt);ha=r(er,"EncoderDecoderModel"),er.forEach(t),fa=r(et,` can be used to initialize a sequence-to-sequence model with any
pretrained autoencoding model as the encoder and any pretrained autoregressive model as the decoder.`),et.forEach(t),ar=p(o),Te=s(o,"P",{});var $r=d(Te);ua=r($r,`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation tasks
was shown in `),oo=s($r,"A",{href:!0,rel:!0});var Bc=d(oo);ga=r(Bc,"Leveraging Pre-trained Checkpoints for Sequence Generation Tasks"),Bc.forEach(t),_a=r($r,` by
Sascha Rothe, Shashi Narayan, Aliaksei Severyn.`),$r.forEach(t),sr=p(o),ke=s(o,"P",{});var Rr=d(ke);ya=r(Rr,"After such an "),lt=s(Rr,"A",{href:!0});var Fc=d(lt);ba=r(Fc,"EncoderDecoderModel"),Fc.forEach(t),Ma=r(Rr,` has been trained/fine-tuned, it can be saved/loaded just like
any other models (see the examples for more information).`),Rr.forEach(t),dr=p(o),A=s(o,"P",{});var Ft=d(A);va=r(Ft,"An application of this architecture could be to leverage two pretrained "),ct=s(Ft,"A",{href:!0});var Cc=d(ct);wa=r(Cc,"BertModel"),Cc.forEach(t),Ta=r(Ft,` as the encoder
and decoder for a summarization model as was shown in: `),to=s(Ft,"A",{href:!0,rel:!0});var xc=d(to);ka=r(xc,"Text Summarization with Pretrained Encoders"),xc.forEach(t),Ja=r(Ft," by Yang Liu and Mirella Lapata."),Ft.forEach(t),lr=p(o),ne=s(o,"H2",{class:!0});var Br=d(ne);Je=s(Br,"A",{id:!0,class:!0,href:!0});var Dc=d(Je);Ot=s(Dc,"SPAN",{});var Nc=d(Ot);v(no.$$.fragment,Nc),Nc.forEach(t),Dc.forEach(t),ja=p(Br),ro=s(Br,"SPAN",{});var Fr=d(ro);Ea=r(Fr,"Randomly initializing "),Kt=s(Fr,"CODE",{});var qc=d(Kt);Za=r(qc,"EncoderDecoderModel"),qc.forEach(t),Ua=r(Fr," from model configurations."),Fr.forEach(t),Br.forEach(t),cr=p(o),X=s(o,"P",{});var ot=d(X);it=s(ot,"A",{href:!0});var Xc=d(it);Wa=r(Xc,"EncoderDecoderModel"),Xc.forEach(t),Ga=r(ot," can be randomly initialized from an encoder and a decoder config. In the following example, we show how to do this using the default "),pt=s(ot,"A",{href:!0});var Sc=d(pt);Ia=r(Sc,"BertModel"),Sc.forEach(t),za=r(ot," configuration for the encoder and the default "),en=s(ot,"CODE",{});var Yc=d(en);Va=r(Yc,"BertForCausalLM"),Yc.forEach(t),$a=r(ot," configuration for the decoder."),ot.forEach(t),ir=p(o),v(ao.$$.fragment,o),pr=p(o),re=s(o,"H2",{class:!0});var Cr=d(re);je=s(Cr,"A",{id:!0,class:!0,href:!0});var Ac=d(je);on=s(Ac,"SPAN",{});var Hc=d(on);v(so.$$.fragment,Hc),Hc.forEach(t),Ac.forEach(t),Ra=p(Cr),lo=s(Cr,"SPAN",{});var xr=d(lo);Ba=r(xr,"Initialising "),tn=s(xr,"CODE",{});var Pc=d(tn);Fa=r(Pc,"EncoderDecoderModel"),Pc.forEach(t),Ca=r(xr," from a pretrained encoder and a pretrained decoder."),xr.forEach(t),Cr.forEach(t),mr=p(o),j=s(o,"P",{});var G=d(j);mt=s(G,"A",{href:!0});var Qc=d(mt);xa=r(Qc,"EncoderDecoderModel"),Qc.forEach(t),Da=r(G," can be initialized from a pretrained encoder checkpoint and a pretrained decoder checkpoint. Note that any pretrained auto-encoding model, "),nn=s(G,"EM",{});var Lc=d(nn);Na=r(Lc,"e.g."),Lc.forEach(t),qa=r(G," BERT, can serve as the encoder and both pretrained auto-encoding models, "),rn=s(G,"EM",{});var Oc=d(rn);Xa=r(Oc,"e.g."),Oc.forEach(t),Sa=r(G," BERT, pretrained causal language models, "),an=s(G,"EM",{});var Kc=d(an);Ya=r(Kc,"e.g."),Kc.forEach(t),Aa=r(G," GPT2, as well as the pretrained decoder part of sequence-to-sequence models, "),sn=s(G,"EM",{});var ei=d(sn);Ha=r(ei,"e.g."),ei.forEach(t),Pa=r(G,` decoder of BART, can be used as the decoder.
Depending on which architecture you choose as the decoder, the cross-attention layers might be randomly initialized.
Initializing `),ht=s(G,"A",{href:!0});var oi=d(ht);Qa=r(oi,"EncoderDecoderModel"),oi.forEach(t),La=r(G," from a pretrained encoder and decoder checkpoint requires the model to be fine-tuned on a downstream task, as has been shown in "),Ee=s(G,"A",{href:!0,rel:!0});var $c=d(Ee);Oa=r($c,"the "),dn=s($c,"EM",{});var ti=d(dn);Ka=r(ti,"Warm-starting-encoder-decoder blog post"),ti.forEach(t),$c.forEach(t),es=r(G,`.
To do so, the `),ln=s(G,"CODE",{});var ni=d(ln);os=r(ni,"EncoderDecoderModel"),ni.forEach(t),ts=r(G," class provides a "),ft=s(G,"A",{href:!0});var ri=d(ft);ns=r(ri,"EncoderDecoderModel.from_encoder_decoder_pretrained()"),ri.forEach(t),rs=r(G," method."),G.forEach(t),hr=p(o),v(co.$$.fragment,o),fr=p(o),ae=s(o,"H2",{class:!0});var Dr=d(ae);Ze=s(Dr,"A",{id:!0,class:!0,href:!0});var ai=d(Ze);cn=s(ai,"SPAN",{});var si=d(cn);v(io.$$.fragment,si),si.forEach(t),ai.forEach(t),as=p(Dr),po=s(Dr,"SPAN",{});var Nr=d(po);ss=r(Nr,"Loading an existing "),pn=s(Nr,"CODE",{});var di=d(pn);ds=r(di,"EncoderDecoderModel"),di.forEach(t),ls=r(Nr," checkpoint and perform inference."),Nr.forEach(t),Dr.forEach(t),ur=p(o),F=s(o,"P",{});var Pe=d(F);cs=r(Pe,"To load fine-tuned checkpoints of the "),mn=s(Pe,"CODE",{});var li=d(mn);is=r(li,"EncoderDecoderModel"),li.forEach(t),ps=r(Pe," class, "),ut=s(Pe,"A",{href:!0});var ci=d(ut);ms=r(ci,"EncoderDecoderModel"),ci.forEach(t),hs=r(Pe," provides the "),hn=s(Pe,"CODE",{});var ii=d(hn);fs=r(ii,"from_pretrained(...)"),ii.forEach(t),us=r(Pe," method just like any other model architecture in Transformers."),Pe.forEach(t),gr=p(o),Ue=s(o,"P",{});var qr=d(Ue);gs=r(qr,"To perform inference, one uses the "),fn=s(qr,"CODE",{});var pi=d(fn);_s=r(pi,"generate"),pi.forEach(t),ys=r(qr," method, which allows to autoregressively generate text. This method supports various forms of decoding, such as greedy, beam search and multinomial sampling."),qr.forEach(t),_r=p(o),v(mo.$$.fragment,o),yr=p(o),se=s(o,"H2",{class:!0});var Xr=d(se);We=s(Xr,"A",{id:!0,class:!0,href:!0});var mi=d(We);un=s(mi,"SPAN",{});var hi=d(un);v(ho.$$.fragment,hi),hi.forEach(t),mi.forEach(t),bs=p(Xr),fo=s(Xr,"SPAN",{});var Sr=d(fo);Ms=r(Sr,"Loading a PyTorch checkpoint into "),gn=s(Sr,"CODE",{});var fi=d(gn);vs=r(fi,"TFEncoderDecoderModel"),fi.forEach(t),ws=r(Sr,"."),Sr.forEach(t),Xr.forEach(t),br=p(o),de=s(o,"P",{});var or=d(de);_n=s(or,"CODE",{});var ui=d(_n);Ts=r(ui,"TFEncoderDecoderModel.from_pretrained()"),ui.forEach(t),ks=r(or,` currently doesn\u2019t support initializing the model from a
pytorch checkpoint. Passing `),yn=s(or,"CODE",{});var gi=d(yn);Js=r(gi,"from_pt=True"),gi.forEach(t),js=r(or,` to this method will throw an exception. If there are only pytorch
checkpoints for a particular encoder-decoder model, a workaround is:`),or.forEach(t),Mr=p(o),v(uo.$$.fragment,o),vr=p(o),le=s(o,"H2",{class:!0});var Yr=d(le);Ge=s(Yr,"A",{id:!0,class:!0,href:!0});var _i=d(Ge);bn=s(_i,"SPAN",{});var yi=d(bn);v(go.$$.fragment,yi),yi.forEach(t),_i.forEach(t),Es=p(Yr),Mn=s(Yr,"SPAN",{});var bi=d(Mn);Zs=r(bi,"Training"),bi.forEach(t),Yr.forEach(t),wr=p(o),B=s(o,"P",{});var ee=d(B);Us=r(ee,`Once the model is created, it can be fine-tuned similar to BART, T5 or any other encoder-decoder model.
As you can see, only 2 inputs are required for the model in order to compute a loss: `),vn=s(ee,"CODE",{});var Mi=d(vn);Ws=r(Mi,"input_ids"),Mi.forEach(t),Gs=r(ee,` (which are the
`),wn=s(ee,"CODE",{});var vi=d(wn);Is=r(vi,"input_ids"),vi.forEach(t),zs=r(ee," of the encoded input sequence) and "),Tn=s(ee,"CODE",{});var wi=d(Tn);Vs=r(wi,"labels"),wi.forEach(t),$s=r(ee," (which are the "),kn=s(ee,"CODE",{});var Ti=d(kn);Rs=r(Ti,"input_ids"),Ti.forEach(t),Bs=r(ee,` of the encoded
target sequence).`),ee.forEach(t),Tr=p(o),v(_o.$$.fragment,o),kr=p(o),Ie=s(o,"P",{});var Ar=d(Ie);Fs=r(Ar,"Detailed "),yo=s(Ar,"A",{href:!0,rel:!0});var ki=d(yo);Cs=r(ki,"colab"),ki.forEach(t),xs=r(Ar," for training."),Ar.forEach(t),Jr=p(o),H=s(o,"P",{});var Ct=d(H);Ds=r(Ct,"This model was contributed by "),bo=s(Ct,"A",{href:!0,rel:!0});var Ji=d(bo);Ns=r(Ji,"thomwolf"),Ji.forEach(t),qs=r(Ct,`. This model\u2019s TensorFlow and Flax versions
were contributed by `),Mo=s(Ct,"A",{href:!0,rel:!0});var ji=d(Mo);Xs=r(ji,"ydshieh"),ji.forEach(t),Ss=r(Ct,"."),Ct.forEach(t),jr=p(o),ce=s(o,"H2",{class:!0});var Hr=d(ce);ze=s(Hr,"A",{id:!0,class:!0,href:!0});var Ei=d(ze);Jn=s(Ei,"SPAN",{});var Zi=d(Jn);v(vo.$$.fragment,Zi),Zi.forEach(t),Ei.forEach(t),Ys=p(Hr),jn=s(Hr,"SPAN",{});var Ui=d(jn);As=r(Ui,"EncoderDecoderConfig"),Ui.forEach(t),Hr.forEach(t),Er=p(o),$=s(o,"DIV",{class:!0});var oe=d($);v(wo.$$.fragment,oe),Hs=p(oe),Ve=s(oe,"P",{});var tr=d(Ve);gt=s(tr,"A",{href:!0});var Wi=d(gt);Ps=r(Wi,"EncoderDecoderConfig"),Wi.forEach(t),Qs=r(tr," is the configuration class to store the configuration of a "),_t=s(tr,"A",{href:!0});var Gi=d(_t);Ls=r(Gi,"EncoderDecoderModel"),Gi.forEach(t),Os=r(tr,`. It is
used to instantiate an Encoder Decoder model according to the specified arguments, defining the encoder and decoder
configs.`),tr.forEach(t),Ks=p(oe),ie=s(oe,"P",{});var xt=d(ie);ed=r(xt,"Configuration objects inherit from "),yt=s(xt,"A",{href:!0});var Ii=d(yt);od=r(Ii,"PretrainedConfig"),Ii.forEach(t),td=r(xt,` and can be used to control the model outputs. Read the
documentation from `),bt=s(xt,"A",{href:!0});var zi=d(bt);nd=r(zi,"PretrainedConfig"),zi.forEach(t),rd=r(xt," for more information."),xt.forEach(t),ad=p(oe),v($e.$$.fragment,oe),sd=p(oe),Re=s(oe,"DIV",{class:!0});var Pr=d(Re);v(To.$$.fragment,Pr),dd=p(Pr),ko=s(Pr,"P",{});var Qr=d(ko);ld=r(Qr,"Instantiate a "),Mt=s(Qr,"A",{href:!0});var Vi=d(Mt);cd=r(Vi,"EncoderDecoderConfig"),Vi.forEach(t),id=r(Qr,` (or a derived class) from a pre-trained encoder model configuration and
decoder model configuration.`),Qr.forEach(t),Pr.forEach(t),oe.forEach(t),Zr=p(o),pe=s(o,"H2",{class:!0});var Lr=d(pe);Be=s(Lr,"A",{id:!0,class:!0,href:!0});var $i=d(Be);En=s($i,"SPAN",{});var Ri=d(En);v(Jo.$$.fragment,Ri),Ri.forEach(t),$i.forEach(t),pd=p(Lr),Zn=s(Lr,"SPAN",{});var Bi=d(Zn);md=r(Bi,"EncoderDecoderModel"),Bi.forEach(t),Lr.forEach(t),Ur=p(o),E=s(o,"DIV",{class:!0});var I=d(E);v(jo.$$.fragment,I),hd=p(I),me=s(I,"P",{});var Dt=d(me);fd=r(Dt,`This class can be used to initialize a sequence-to-sequence model with any pretrained autoencoding model as the
encoder and any pretrained autoregressive model as the decoder. The encoder is loaded via
`),vt=s(Dt,"A",{href:!0});var Fi=d(vt);ud=r(Fi,"from_pretrained()"),Fi.forEach(t),gd=r(Dt," function and the decoder is loaded via "),wt=s(Dt,"A",{href:!0});var Ci=d(wt);_d=r(Ci,"from_pretrained()"),Ci.forEach(t),yd=r(Dt,`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like summarization.`),Dt.forEach(t),bd=p(I),Eo=s(I,"P",{});var Or=d(Eo);Md=r(Or,`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Zo=s(Or,"A",{href:!0,rel:!0});var xi=d(Zo);vd=r(xi,`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),xi.forEach(t),wd=r(Or,` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),Or.forEach(t),Td=p(I),Un=s(I,"P",{});var Di=d(Un);kd=r(Di,`After such an Encoder Decoder model has been trained/fine-tuned, it can be saved/loaded just like any other models
(see the examples for more information).`),Di.forEach(t),Jd=p(I),Uo=s(I,"P",{});var Kr=d(Uo);jd=r(Kr,"This model inherits from "),Tt=s(Kr,"A",{href:!0});var Ni=d(Tt);Ed=r(Ni,"PreTrainedModel"),Ni.forEach(t),Zd=r(Kr,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Kr.forEach(t),Ud=p(I),Wo=s(I,"P",{});var ea=d(Wo);Wd=r(ea,"This model is also a PyTorch "),Go=s(ea,"A",{href:!0,rel:!0});var qi=d(Go);Gd=r(qi,"torch.nn.Module"),qi.forEach(t),Id=r(ea,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ea.forEach(t),zd=p(I),P=s(I,"P",{});var tt=d(P);kt=s(tt,"A",{href:!0});var Xi=d(kt);Vd=r(Xi,"EncoderDecoderModel"),Xi.forEach(t),$d=r(tt,` is a generic model class that will be instantiated as a transformer architecture with one
of the base model classes of the library as encoder and another one as decoder when created with the
:meth`),Wn=s(tt,"EM",{});var Si=d(Wn);Rd=r(Si,"~transformers.AutoModel.from_pretrained"),Si.forEach(t),Bd=r(tt,` class method for the encoder and
:meth`),Gn=s(tt,"EM",{});var Yi=d(Gn);Fd=r(Yi,"~transformers.AutoModelForCausalLM.from_pretrained"),Yi.forEach(t),Cd=r(tt," class method for the decoder."),tt.forEach(t),xd=p(I),C=s(I,"DIV",{class:!0});var Qe=d(C);v(Io.$$.fragment,Qe),Dd=p(Qe),he=s(Qe,"P",{});var Nt=d(he);Nd=r(Nt,"The "),Jt=s(Nt,"A",{href:!0});var Ai=d(Jt);qd=r(Ai,"EncoderDecoderModel"),Ai.forEach(t),Xd=r(Nt," forward method, overrides the "),In=s(Nt,"CODE",{});var Hi=d(In);Sd=r(Hi,"__call__"),Hi.forEach(t),Yd=r(Nt," special method."),Nt.forEach(t),Ad=p(Qe),v(Fe.$$.fragment,Qe),Hd=p(Qe),v(Ce.$$.fragment,Qe),Qe.forEach(t),Pd=p(I),x=s(I,"DIV",{class:!0});var Le=d(x);v(zo.$$.fragment,Le),Qd=p(Le),zn=s(Le,"P",{});var Pi=d(zn);Ld=r(Pi,`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),Pi.forEach(t),Od=p(Le),fe=s(Le,"P",{});var qt=d(fe);Kd=r(qt,"The model is set in evaluation mode by default using "),Vn=s(qt,"CODE",{});var Qi=d(Vn);el=r(Qi,"model.eval()"),Qi.forEach(t),ol=r(qt,` (Dropout modules are deactivated). To train
the model, you need to first set it back in training mode with `),$n=s(qt,"CODE",{});var Li=d($n);tl=r(Li,"model.train()"),Li.forEach(t),nl=r(qt,"."),qt.forEach(t),rl=p(Le),v(xe.$$.fragment,Le),Le.forEach(t),I.forEach(t),Wr=p(o),ue=s(o,"H2",{class:!0});var oa=d(ue);De=s(oa,"A",{id:!0,class:!0,href:!0});var Oi=d(De);Rn=s(Oi,"SPAN",{});var Ki=d(Rn);v(Vo.$$.fragment,Ki),Ki.forEach(t),Oi.forEach(t),al=p(oa),Bn=s(oa,"SPAN",{});var ep=d(Bn);sl=r(ep,"TFEncoderDecoderModel"),ep.forEach(t),oa.forEach(t),Gr=p(o),Z=s(o,"DIV",{class:!0});var z=d(Z);v($o.$$.fragment,z),dl=p(z),ge=s(z,"P",{});var Xt=d(ge);ll=r(Xt,`This class can be used to initialize a sequence-to-sequence model with any pretrained autoencoding model as the
encoder and any pretrained autoregressive model as the decoder. The encoder is loaded via
`),jt=s(Xt,"A",{href:!0});var op=d(jt);cl=r(op,"from_pretrained()"),op.forEach(t),il=r(Xt," function and the decoder is loaded via "),Et=s(Xt,"A",{href:!0});var tp=d(Et);pl=r(tp,"from_pretrained()"),tp.forEach(t),ml=r(Xt,`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like summarization.`),Xt.forEach(t),hl=p(z),Ro=s(z,"P",{});var ta=d(Ro);fl=r(ta,`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Bo=s(ta,"A",{href:!0,rel:!0});var np=d(Bo);ul=r(np,`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),np.forEach(t),gl=r(ta,` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),ta.forEach(t),_l=p(z),Fn=s(z,"P",{});var rp=d(Fn);yl=r(rp,`After such an Encoder Decoder model has been trained/fine-tuned, it can be saved/loaded just like any other models
(see the examples for more information).`),rp.forEach(t),bl=p(z),Fo=s(z,"P",{});var na=d(Fo);Ml=r(na,"This model inherits from "),Zt=s(na,"A",{href:!0});var ap=d(Zt);vl=r(ap,"TFPreTrainedModel"),ap.forEach(t),wl=r(na,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),na.forEach(t),Tl=p(z),Co=s(z,"P",{});var ra=d(Co);kl=r(ra,"This model is also a "),xo=s(ra,"A",{href:!0,rel:!0});var sp=d(xo);Jl=r(sp,"tf.keras.Model"),sp.forEach(t),jl=r(ra,` subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`),ra.forEach(t),El=p(z),Q=s(z,"P",{});var nt=d(Q);Ut=s(nt,"A",{href:!0});var dp=d(Ut);Zl=r(dp,"TFEncoderDecoderModel"),dp.forEach(t),Ul=r(nt,` is a generic model class that will be instantiated as a transformer architecture with one
of the base model classes of the library as encoder and another one as decoder when created with the
`),Wt=s(nt,"A",{href:!0});var lp=d(Wt);Wl=r(lp,"from_pretrained()"),lp.forEach(t),Gl=r(nt," class method for the encoder and "),Gt=s(nt,"A",{href:!0});var cp=d(Gt);Il=r(cp,"from_pretrained()"),cp.forEach(t),zl=r(nt,` class
method for the decoder.`),nt.forEach(t),Vl=p(z),D=s(z,"DIV",{class:!0});var Oe=d(D);v(Do.$$.fragment,Oe),$l=p(Oe),_e=s(Oe,"P",{});var St=d(_e);Rl=r(St,"The "),It=s(St,"A",{href:!0});var ip=d(It);Bl=r(ip,"TFEncoderDecoderModel"),ip.forEach(t),Fl=r(St," forward method, overrides the "),Cn=s(St,"CODE",{});var pp=d(Cn);Cl=r(pp,"__call__"),pp.forEach(t),xl=r(St," special method."),St.forEach(t),Dl=p(Oe),v(Ne.$$.fragment,Oe),Nl=p(Oe),v(qe.$$.fragment,Oe),Oe.forEach(t),ql=p(z),L=s(z,"DIV",{class:!0});var Yt=d(L);v(No.$$.fragment,Yt),Xl=p(Yt),xn=s(Yt,"P",{});var mp=d(xn);Sl=r(mp,`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),mp.forEach(t),Yl=p(Yt),v(Xe.$$.fragment,Yt),Yt.forEach(t),z.forEach(t),Ir=p(o),ye=s(o,"H2",{class:!0});var aa=d(ye);Se=s(aa,"A",{id:!0,class:!0,href:!0});var hp=d(Se);Dn=s(hp,"SPAN",{});var fp=d(Dn);v(qo.$$.fragment,fp),fp.forEach(t),hp.forEach(t),Al=p(aa),Nn=s(aa,"SPAN",{});var up=d(Nn);Hl=r(up,"FlaxEncoderDecoderModel"),up.forEach(t),aa.forEach(t),zr=p(o),U=s(o,"DIV",{class:!0});var V=d(U);v(Xo.$$.fragment,V),Pl=p(V),be=s(V,"P",{});var At=d(be);Ql=r(At,`This class can be used to initialize a sequence-to-sequence model with any pretrained autoencoding model as the
encoder and any pretrained autoregressive model as the decoder. The encoder is loaded via
`),zt=s(At,"A",{href:!0});var gp=d(zt);Ll=r(gp,"from_pretrained()"),gp.forEach(t),Ol=r(At," function and the decoder is loaded via "),Vt=s(At,"A",{href:!0});var _p=d(Vt);Kl=r(_p,"from_pretrained()"),_p.forEach(t),ec=r(At,`
function. Cross-attention layers are automatically added to the decoder and should be fine-tuned on a downstream
generative task, like summarization.`),At.forEach(t),oc=p(V),So=s(V,"P",{});var sa=d(So);tc=r(sa,`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Yo=s(sa,"A",{href:!0,rel:!0});var yp=d(Yo);nc=r(yp,`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),yp.forEach(t),rc=r(sa,` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),sa.forEach(t),ac=p(V),qn=s(V,"P",{});var bp=d(qn);sc=r(bp,`After such an Encoder Decoder model has been trained/fine-tuned, it can be saved/loaded just like any other models
(see the examples for more information).`),bp.forEach(t),dc=p(V),Ao=s(V,"P",{});var da=d(Ao);lc=r(da,"This model inherits from "),$t=s(da,"A",{href:!0});var Mp=d($t);cc=r(Mp,"FlaxPreTrainedModel"),Mp.forEach(t),ic=r(da,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),da.forEach(t),pc=p(V),Ho=s(V,"P",{});var la=d(Ho);mc=r(la,`This model is also a Flax Linen
`),Po=s(la,"A",{href:!0,rel:!0});var vp=d(Po);hc=r(vp,"flax.nn.Module"),vp.forEach(t),fc=r(la,` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),la.forEach(t),uc=p(V),O=s(V,"P",{});var rt=d(O);Rt=s(rt,"A",{href:!0});var wp=d(Rt);gc=r(wp,"FlaxEncoderDecoderModel"),wp.forEach(t),_c=r(rt,` is a generic model class that will be instantiated as a transformer architecture with
the module (flax.nn.Module) of one of the base model classes of the library as encoder module and another one as
decoder module when created with the :meth`),Xn=s(rt,"EM",{});var Tp=d(Xn);yc=r(Tp,"~transformers.FlaxAutoModel.from_pretrained"),Tp.forEach(t),bc=r(rt,` class method for the
encoder and :meth`),Sn=s(rt,"EM",{});var kp=d(Sn);Mc=r(kp,"~transformers.FlaxAutoModelForCausalLM.from_pretrained"),kp.forEach(t),vc=r(rt," class method for the decoder."),rt.forEach(t),wc=p(V),N=s(V,"DIV",{class:!0});var Ke=d(N);v(Qo.$$.fragment,Ke),Tc=p(Ke),Me=s(Ke,"P",{});var Ht=d(Me);kc=r(Ht,"The "),Bt=s(Ht,"A",{href:!0});var Jp=d(Bt);Jc=r(Jp,"FlaxEncoderDecoderModel"),Jp.forEach(t),jc=r(Ht," forward method, overrides the "),Yn=s(Ht,"CODE",{});var jp=d(Yn);Ec=r(jp,"__call__"),jp.forEach(t),Zc=r(Ht," special method."),Ht.forEach(t),Uc=p(Ke),v(Ye.$$.fragment,Ke),Wc=p(Ke),v(Ae.$$.fragment,Ke),Ke.forEach(t),Gc=p(V),K=s(V,"DIV",{class:!0});var Pt=d(K);v(Lo.$$.fragment,Pt),Ic=p(Pt),An=s(Pt,"P",{});var Ep=d(An);zc=r(Ep,`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),Ep.forEach(t),Vc=p(Pt),v(He.$$.fragment,Pt),Pt.forEach(t),V.forEach(t),this.h()},h(){c(h,"name","hf:doc:metadata"),c(h,"content",JSON.stringify(Xp)),c(f,"id","encoder-decoder-models"),c(f,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(f,"href","#encoder-decoder-models"),c(_,"class","relative group"),c(ve,"id","overview"),c(ve,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(ve,"href","#overview"),c(te,"class","relative group"),c(dt,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(oo,"href","https://arxiv.org/abs/1907.12461"),c(oo,"rel","nofollow"),c(lt,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(ct,"href","/docs/transformers/v4.33.0/en/model_doc/bert#transformers.BertModel"),c(to,"href","https://arxiv.org/abs/1908.08345"),c(to,"rel","nofollow"),c(Je,"id","randomly-initializing-encoderdecodermodel-from-model-configurations"),c(Je,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Je,"href","#randomly-initializing-encoderdecodermodel-from-model-configurations"),c(ne,"class","relative group"),c(it,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(pt,"href","/docs/transformers/v4.33.0/en/model_doc/bert#transformers.BertModel"),c(je,"id","initialising-encoderdecodermodel-from-a-pretrained-encoder-and-a-pretrained-decoder"),c(je,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(je,"href","#initialising-encoderdecodermodel-from-a-pretrained-encoder-and-a-pretrained-decoder"),c(re,"class","relative group"),c(mt,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(ht,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(Ee,"href","https://huggingface.co/blog/warm-starting-encoder-decoder"),c(Ee,"rel","nofollow"),c(ft,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel.from_encoder_decoder_pretrained"),c(Ze,"id","loading-an-existing-encoderdecodermodel-checkpoint-and-perform-inference"),c(Ze,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Ze,"href","#loading-an-existing-encoderdecodermodel-checkpoint-and-perform-inference"),c(ae,"class","relative group"),c(ut,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(We,"id","loading-a-pytorch-checkpoint-into-tfencoderdecodermodel"),c(We,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(We,"href","#loading-a-pytorch-checkpoint-into-tfencoderdecodermodel"),c(se,"class","relative group"),c(Ge,"id","training"),c(Ge,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Ge,"href","#training"),c(le,"class","relative group"),c(yo,"href","https://colab.research.google.com/drive/1WIk2bxglElfZewOHboPFNj8H44_VAyKE?usp=sharing#scrollTo=ZwQIEhKOrJpl"),c(yo,"rel","nofollow"),c(bo,"href","https://github.com/thomwolf"),c(bo,"rel","nofollow"),c(Mo,"href","https://github.com/ydshieh"),c(Mo,"rel","nofollow"),c(ze,"id","transformers.EncoderDecoderConfig"),c(ze,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(ze,"href","#transformers.EncoderDecoderConfig"),c(ce,"class","relative group"),c(gt,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig"),c(_t,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(yt,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(bt,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(Mt,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig"),c(Re,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Be,"id","transformers.EncoderDecoderModel"),c(Be,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Be,"href","#transformers.EncoderDecoderModel"),c(pe,"class","relative group"),c(vt,"href","/docs/transformers/v4.33.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(wt,"href","/docs/transformers/v4.33.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(Zo,"href","https://arxiv.org/abs/1907.12461"),c(Zo,"rel","nofollow"),c(Tt,"href","/docs/transformers/v4.33.0/en/main_classes/model#transformers.PreTrainedModel"),c(Go,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(Go,"rel","nofollow"),c(kt,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(Jt,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(De,"id","transformers.TFEncoderDecoderModel"),c(De,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(De,"href","#transformers.TFEncoderDecoderModel"),c(ue,"class","relative group"),c(jt,"href","/docs/transformers/v4.33.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(Et,"href","/docs/transformers/v4.33.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(Bo,"href","https://arxiv.org/abs/1907.12461"),c(Bo,"rel","nofollow"),c(Zt,"href","/docs/transformers/v4.33.0/en/main_classes/model#transformers.TFPreTrainedModel"),c(xo,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),c(xo,"rel","nofollow"),c(Ut,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.TFEncoderDecoderModel"),c(Wt,"href","/docs/transformers/v4.33.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(Gt,"href","/docs/transformers/v4.33.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(It,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.TFEncoderDecoderModel"),c(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Se,"id","transformers.FlaxEncoderDecoderModel"),c(Se,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Se,"href","#transformers.FlaxEncoderDecoderModel"),c(ye,"class","relative group"),c(zt,"href","/docs/transformers/v4.33.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(Vt,"href","/docs/transformers/v4.33.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(Yo,"href","https://arxiv.org/abs/1907.12461"),c(Yo,"rel","nofollow"),c($t,"href","/docs/transformers/v4.33.0/en/main_classes/model#transformers.FlaxPreTrainedModel"),c(Po,"href","https://flax.readthedocs.io/en/latest/_autosummary/flax.nn.module.html"),c(Po,"rel","nofollow"),c(Rt,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.FlaxEncoderDecoderModel"),c(Bt,"href","/docs/transformers/v4.33.0/en/model_doc/encoder-decoder#transformers.FlaxEncoderDecoderModel"),c(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(o,m){e(document.head,h),u(o,b,m),u(o,_,m),e(_,f),e(f,y),w(l,y,null),e(_,g),e(_,R),e(R,ca),u(o,nr,m),u(o,te,m),e(te,ve),e(ve,Qt),w(eo,Qt,null),e(te,ia),e(te,Lt),e(Lt,pa),u(o,rr,m),u(o,we,m),e(we,ma),e(we,dt),e(dt,ha),e(we,fa),u(o,ar,m),u(o,Te,m),e(Te,ua),e(Te,oo),e(oo,ga),e(Te,_a),u(o,sr,m),u(o,ke,m),e(ke,ya),e(ke,lt),e(lt,ba),e(ke,Ma),u(o,dr,m),u(o,A,m),e(A,va),e(A,ct),e(ct,wa),e(A,Ta),e(A,to),e(to,ka),e(A,Ja),u(o,lr,m),u(o,ne,m),e(ne,Je),e(Je,Ot),w(no,Ot,null),e(ne,ja),e(ne,ro),e(ro,Ea),e(ro,Kt),e(Kt,Za),e(ro,Ua),u(o,cr,m),u(o,X,m),e(X,it),e(it,Wa),e(X,Ga),e(X,pt),e(pt,Ia),e(X,za),e(X,en),e(en,Va),e(X,$a),u(o,ir,m),w(ao,o,m),u(o,pr,m),u(o,re,m),e(re,je),e(je,on),w(so,on,null),e(re,Ra),e(re,lo),e(lo,Ba),e(lo,tn),e(tn,Fa),e(lo,Ca),u(o,mr,m),u(o,j,m),e(j,mt),e(mt,xa),e(j,Da),e(j,nn),e(nn,Na),e(j,qa),e(j,rn),e(rn,Xa),e(j,Sa),e(j,an),e(an,Ya),e(j,Aa),e(j,sn),e(sn,Ha),e(j,Pa),e(j,ht),e(ht,Qa),e(j,La),e(j,Ee),e(Ee,Oa),e(Ee,dn),e(dn,Ka),e(j,es),e(j,ln),e(ln,os),e(j,ts),e(j,ft),e(ft,ns),e(j,rs),u(o,hr,m),w(co,o,m),u(o,fr,m),u(o,ae,m),e(ae,Ze),e(Ze,cn),w(io,cn,null),e(ae,as),e(ae,po),e(po,ss),e(po,pn),e(pn,ds),e(po,ls),u(o,ur,m),u(o,F,m),e(F,cs),e(F,mn),e(mn,is),e(F,ps),e(F,ut),e(ut,ms),e(F,hs),e(F,hn),e(hn,fs),e(F,us),u(o,gr,m),u(o,Ue,m),e(Ue,gs),e(Ue,fn),e(fn,_s),e(Ue,ys),u(o,_r,m),w(mo,o,m),u(o,yr,m),u(o,se,m),e(se,We),e(We,un),w(ho,un,null),e(se,bs),e(se,fo),e(fo,Ms),e(fo,gn),e(gn,vs),e(fo,ws),u(o,br,m),u(o,de,m),e(de,_n),e(_n,Ts),e(de,ks),e(de,yn),e(yn,Js),e(de,js),u(o,Mr,m),w(uo,o,m),u(o,vr,m),u(o,le,m),e(le,Ge),e(Ge,bn),w(go,bn,null),e(le,Es),e(le,Mn),e(Mn,Zs),u(o,wr,m),u(o,B,m),e(B,Us),e(B,vn),e(vn,Ws),e(B,Gs),e(B,wn),e(wn,Is),e(B,zs),e(B,Tn),e(Tn,Vs),e(B,$s),e(B,kn),e(kn,Rs),e(B,Bs),u(o,Tr,m),w(_o,o,m),u(o,kr,m),u(o,Ie,m),e(Ie,Fs),e(Ie,yo),e(yo,Cs),e(Ie,xs),u(o,Jr,m),u(o,H,m),e(H,Ds),e(H,bo),e(bo,Ns),e(H,qs),e(H,Mo),e(Mo,Xs),e(H,Ss),u(o,jr,m),u(o,ce,m),e(ce,ze),e(ze,Jn),w(vo,Jn,null),e(ce,Ys),e(ce,jn),e(jn,As),u(o,Er,m),u(o,$,m),w(wo,$,null),e($,Hs),e($,Ve),e(Ve,gt),e(gt,Ps),e(Ve,Qs),e(Ve,_t),e(_t,Ls),e(Ve,Os),e($,Ks),e($,ie),e(ie,ed),e(ie,yt),e(yt,od),e(ie,td),e(ie,bt),e(bt,nd),e(ie,rd),e($,ad),w($e,$,null),e($,sd),e($,Re),w(To,Re,null),e(Re,dd),e(Re,ko),e(ko,ld),e(ko,Mt),e(Mt,cd),e(ko,id),u(o,Zr,m),u(o,pe,m),e(pe,Be),e(Be,En),w(Jo,En,null),e(pe,pd),e(pe,Zn),e(Zn,md),u(o,Ur,m),u(o,E,m),w(jo,E,null),e(E,hd),e(E,me),e(me,fd),e(me,vt),e(vt,ud),e(me,gd),e(me,wt),e(wt,_d),e(me,yd),e(E,bd),e(E,Eo),e(Eo,Md),e(Eo,Zo),e(Zo,vd),e(Eo,wd),e(E,Td),e(E,Un),e(Un,kd),e(E,Jd),e(E,Uo),e(Uo,jd),e(Uo,Tt),e(Tt,Ed),e(Uo,Zd),e(E,Ud),e(E,Wo),e(Wo,Wd),e(Wo,Go),e(Go,Gd),e(Wo,Id),e(E,zd),e(E,P),e(P,kt),e(kt,Vd),e(P,$d),e(P,Wn),e(Wn,Rd),e(P,Bd),e(P,Gn),e(Gn,Fd),e(P,Cd),e(E,xd),e(E,C),w(Io,C,null),e(C,Dd),e(C,he),e(he,Nd),e(he,Jt),e(Jt,qd),e(he,Xd),e(he,In),e(In,Sd),e(he,Yd),e(C,Ad),w(Fe,C,null),e(C,Hd),w(Ce,C,null),e(E,Pd),e(E,x),w(zo,x,null),e(x,Qd),e(x,zn),e(zn,Ld),e(x,Od),e(x,fe),e(fe,Kd),e(fe,Vn),e(Vn,el),e(fe,ol),e(fe,$n),e($n,tl),e(fe,nl),e(x,rl),w(xe,x,null),u(o,Wr,m),u(o,ue,m),e(ue,De),e(De,Rn),w(Vo,Rn,null),e(ue,al),e(ue,Bn),e(Bn,sl),u(o,Gr,m),u(o,Z,m),w($o,Z,null),e(Z,dl),e(Z,ge),e(ge,ll),e(ge,jt),e(jt,cl),e(ge,il),e(ge,Et),e(Et,pl),e(ge,ml),e(Z,hl),e(Z,Ro),e(Ro,fl),e(Ro,Bo),e(Bo,ul),e(Ro,gl),e(Z,_l),e(Z,Fn),e(Fn,yl),e(Z,bl),e(Z,Fo),e(Fo,Ml),e(Fo,Zt),e(Zt,vl),e(Fo,wl),e(Z,Tl),e(Z,Co),e(Co,kl),e(Co,xo),e(xo,Jl),e(Co,jl),e(Z,El),e(Z,Q),e(Q,Ut),e(Ut,Zl),e(Q,Ul),e(Q,Wt),e(Wt,Wl),e(Q,Gl),e(Q,Gt),e(Gt,Il),e(Q,zl),e(Z,Vl),e(Z,D),w(Do,D,null),e(D,$l),e(D,_e),e(_e,Rl),e(_e,It),e(It,Bl),e(_e,Fl),e(_e,Cn),e(Cn,Cl),e(_e,xl),e(D,Dl),w(Ne,D,null),e(D,Nl),w(qe,D,null),e(Z,ql),e(Z,L),w(No,L,null),e(L,Xl),e(L,xn),e(xn,Sl),e(L,Yl),w(Xe,L,null),u(o,Ir,m),u(o,ye,m),e(ye,Se),e(Se,Dn),w(qo,Dn,null),e(ye,Al),e(ye,Nn),e(Nn,Hl),u(o,zr,m),u(o,U,m),w(Xo,U,null),e(U,Pl),e(U,be),e(be,Ql),e(be,zt),e(zt,Ll),e(be,Ol),e(be,Vt),e(Vt,Kl),e(be,ec),e(U,oc),e(U,So),e(So,tc),e(So,Yo),e(Yo,nc),e(So,rc),e(U,ac),e(U,qn),e(qn,sc),e(U,dc),e(U,Ao),e(Ao,lc),e(Ao,$t),e($t,cc),e(Ao,ic),e(U,pc),e(U,Ho),e(Ho,mc),e(Ho,Po),e(Po,hc),e(Ho,fc),e(U,uc),e(U,O),e(O,Rt),e(Rt,gc),e(O,_c),e(O,Xn),e(Xn,yc),e(O,bc),e(O,Sn),e(Sn,Mc),e(O,vc),e(U,wc),e(U,N),w(Qo,N,null),e(N,Tc),e(N,Me),e(Me,kc),e(Me,Bt),e(Bt,Jc),e(Me,jc),e(Me,Yn),e(Yn,Ec),e(Me,Zc),e(N,Uc),w(Ye,N,null),e(N,Wc),w(Ae,N,null),e(U,Gc),e(U,K),w(Lo,K,null),e(K,Ic),e(K,An),e(An,zc),e(K,Vc),w(He,K,null),Vr=!0},p(o,[m]){const Oo={};m&2&&(Oo.$$scope={dirty:m,ctx:o}),$e.$set(Oo);const Hn={};m&2&&(Hn.$$scope={dirty:m,ctx:o}),Fe.$set(Hn);const Pn={};m&2&&(Pn.$$scope={dirty:m,ctx:o}),Ce.$set(Pn);const Qn={};m&2&&(Qn.$$scope={dirty:m,ctx:o}),xe.$set(Qn);const Ko={};m&2&&(Ko.$$scope={dirty:m,ctx:o}),Ne.$set(Ko);const Ln={};m&2&&(Ln.$$scope={dirty:m,ctx:o}),qe.$set(Ln);const On={};m&2&&(On.$$scope={dirty:m,ctx:o}),Xe.$set(On);const Kn={};m&2&&(Kn.$$scope={dirty:m,ctx:o}),Ye.$set(Kn);const et={};m&2&&(et.$$scope={dirty:m,ctx:o}),Ae.$set(et);const er={};m&2&&(er.$$scope={dirty:m,ctx:o}),He.$set(er)},i(o){Vr||(T(l.$$.fragment,o),T(eo.$$.fragment,o),T(no.$$.fragment,o),T(ao.$$.fragment,o),T(so.$$.fragment,o),T(co.$$.fragment,o),T(io.$$.fragment,o),T(mo.$$.fragment,o),T(ho.$$.fragment,o),T(uo.$$.fragment,o),T(go.$$.fragment,o),T(_o.$$.fragment,o),T(vo.$$.fragment,o),T(wo.$$.fragment,o),T($e.$$.fragment,o),T(To.$$.fragment,o),T(Jo.$$.fragment,o),T(jo.$$.fragment,o),T(Io.$$.fragment,o),T(Fe.$$.fragment,o),T(Ce.$$.fragment,o),T(zo.$$.fragment,o),T(xe.$$.fragment,o),T(Vo.$$.fragment,o),T($o.$$.fragment,o),T(Do.$$.fragment,o),T(Ne.$$.fragment,o),T(qe.$$.fragment,o),T(No.$$.fragment,o),T(Xe.$$.fragment,o),T(qo.$$.fragment,o),T(Xo.$$.fragment,o),T(Qo.$$.fragment,o),T(Ye.$$.fragment,o),T(Ae.$$.fragment,o),T(Lo.$$.fragment,o),T(He.$$.fragment,o),Vr=!0)},o(o){k(l.$$.fragment,o),k(eo.$$.fragment,o),k(no.$$.fragment,o),k(ao.$$.fragment,o),k(so.$$.fragment,o),k(co.$$.fragment,o),k(io.$$.fragment,o),k(mo.$$.fragment,o),k(ho.$$.fragment,o),k(uo.$$.fragment,o),k(go.$$.fragment,o),k(_o.$$.fragment,o),k(vo.$$.fragment,o),k(wo.$$.fragment,o),k($e.$$.fragment,o),k(To.$$.fragment,o),k(Jo.$$.fragment,o),k(jo.$$.fragment,o),k(Io.$$.fragment,o),k(Fe.$$.fragment,o),k(Ce.$$.fragment,o),k(zo.$$.fragment,o),k(xe.$$.fragment,o),k(Vo.$$.fragment,o),k($o.$$.fragment,o),k(Do.$$.fragment,o),k(Ne.$$.fragment,o),k(qe.$$.fragment,o),k(No.$$.fragment,o),k(Xe.$$.fragment,o),k(qo.$$.fragment,o),k(Xo.$$.fragment,o),k(Qo.$$.fragment,o),k(Ye.$$.fragment,o),k(Ae.$$.fragment,o),k(Lo.$$.fragment,o),k(He.$$.fragment,o),Vr=!1},d(o){t(h),o&&t(b),o&&t(_),J(l),o&&t(nr),o&&t(te),J(eo),o&&t(rr),o&&t(we),o&&t(ar),o&&t(Te),o&&t(sr),o&&t(ke),o&&t(dr),o&&t(A),o&&t(lr),o&&t(ne),J(no),o&&t(cr),o&&t(X),o&&t(ir),J(ao,o),o&&t(pr),o&&t(re),J(so),o&&t(mr),o&&t(j),o&&t(hr),J(co,o),o&&t(fr),o&&t(ae),J(io),o&&t(ur),o&&t(F),o&&t(gr),o&&t(Ue),o&&t(_r),J(mo,o),o&&t(yr),o&&t(se),J(ho),o&&t(br),o&&t(de),o&&t(Mr),J(uo,o),o&&t(vr),o&&t(le),J(go),o&&t(wr),o&&t(B),o&&t(Tr),J(_o,o),o&&t(kr),o&&t(Ie),o&&t(Jr),o&&t(H),o&&t(jr),o&&t(ce),J(vo),o&&t(Er),o&&t($),J(wo),J($e),J(To),o&&t(Zr),o&&t(pe),J(Jo),o&&t(Ur),o&&t(E),J(jo),J(Io),J(Fe),J(Ce),J(zo),J(xe),o&&t(Wr),o&&t(ue),J(Vo),o&&t(Gr),o&&t(Z),J($o),J(Do),J(Ne),J(qe),J(No),J(Xe),o&&t(Ir),o&&t(ye),J(qo),o&&t(zr),o&&t(U),J(Xo),J(Qo),J(Ye),J(Ae),J(Lo),J(He)}}}const Xp={local:"encoder-decoder-models",sections:[{local:"overview",title:"Overview"},{local:"randomly-initializing-encoderdecodermodel-from-model-configurations",title:"Randomly initializing `EncoderDecoderModel` from model configurations."},{local:"initialising-encoderdecodermodel-from-a-pretrained-encoder-and-a-pretrained-decoder",title:"Initialising `EncoderDecoderModel` from a pretrained encoder and a pretrained decoder."},{local:"loading-an-existing-encoderdecodermodel-checkpoint-and-perform-inference",title:"Loading an existing `EncoderDecoderModel` checkpoint and perform inference."},{local:"loading-a-pytorch-checkpoint-into-tfencoderdecodermodel",title:"Loading a PyTorch checkpoint into `TFEncoderDecoderModel`."},{local:"training",title:"Training"},{local:"transformers.EncoderDecoderConfig",title:"EncoderDecoderConfig"},{local:"transformers.EncoderDecoderModel",title:"EncoderDecoderModel"},{local:"transformers.TFEncoderDecoderModel",title:"TFEncoderDecoderModel"},{local:"transformers.FlaxEncoderDecoderModel",title:"FlaxEncoderDecoderModel"}],title:"Encoder Decoder Models"};function Sp(W){return Ip(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Op extends Zp{constructor(h){super();Up(this,h,Sp,qp,Wp,{})}}export{Op as default,Xp as metadata};
