import{S as Zm,i as Um,s as Wm,e as r,k as i,w as M,t as n,M as Gm,c as s,d as t,m,a as d,x as w,h as a,b as c,G as e,g as u,y as T,q as v,o as k,B as J,v as Im,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 rt}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function zm(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=r("p"),b=n("Examples:"),_=i(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=a(g,"Examples:"),g.forEach(t),_=m(l),w(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),T(f,l,g),y=!0},p:st,i(l){y||(v(f.$$.fragment,l),y=!0)},o(l){k(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),J(f,l)}}}function Vm(W){let h,b,_,f,y;return{c(){h=r("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=r("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=a(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=a(R,"Module"),R.forEach(t),y=a(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 $m(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=r("p"),b=n("Examples:"),_=i(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=a(g,"Examples:"),g.forEach(t),_=m(l),w(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),T(f,l,g),y=!0},p:st,i(l){y||(v(f.$$.fragment,l),y=!0)},o(l){k(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),J(f,l)}}}function Rm(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=r("p"),b=n("Example:"),_=i(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=a(g,"Example:"),g.forEach(t),_=m(l),w(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),T(f,l,g),y=!0},p:st,i(l){y||(v(f.$$.fragment,l),y=!0)},o(l){k(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),J(f,l)}}}function Bm(W){let h,b,_,f,y;return{c(){h=r("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=r("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=a(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=a(R,"Module"),R.forEach(t),y=a(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 Fm(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=r("p"),b=n("Examples:"),_=i(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=a(g,"Examples:"),g.forEach(t),_=m(l),w(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),T(f,l,g),y=!0},p:st,i(l){y||(v(f.$$.fragment,l),y=!0)},o(l){k(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),J(f,l)}}}function Cm(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=r("p"),b=n("Example:"),_=i(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=a(g,"Example:"),g.forEach(t),_=m(l),w(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),T(f,l,g),y=!0},p:st,i(l){y||(v(f.$$.fragment,l),y=!0)},o(l){k(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),J(f,l)}}}function xm(W){let h,b,_,f,y;return{c(){h=r("p"),b=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),_=r("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=a(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=a(R,"Module"),R.forEach(t),y=a(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 Dm(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=r("p"),b=n("Examples:"),_=i(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=a(g,"Examples:"),g.forEach(t),_=m(l),w(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),T(f,l,g),y=!0},p:st,i(l){y||(v(f.$$.fragment,l),y=!0)},o(l){k(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),J(f,l)}}}function Nm(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=r("p"),b=n("Example:"),_=i(),M(f.$$.fragment)},l(l){h=s(l,"P",{});var g=d(h);b=a(g,"Example:"),g.forEach(t),_=m(l),w(f.$$.fragment,l)},m(l,g){u(l,h,g),e(h,b),u(l,_,g),T(f,l,g),y=!0},p:st,i(l){y||(v(f.$$.fragment,l),y=!0)},o(l){k(f.$$.fragment,l),y=!1},d(l){l&&t(h),l&&t(_),J(f,l)}}}function qm(W){let h,b,_,f,y,l,g,R,cr,na,te,we,Qt,eo,ir,Lt,mr,aa,Te,pr,dt,hr,fr,ra,ve,ur,oo,gr,_r,sa,ke,yr,lt,br,Mr,da,A,wr,ct,Tr,vr,to,kr,Jr,la,ne,Je,Ot,no,jr,ao,Er,Kt,Zr,Ur,ca,X,it,Wr,Gr,mt,Ir,zr,en,Vr,$r,ia,ro,ma,ae,je,on,so,Rr,lo,Br,tn,Fr,Cr,pa,j,pt,xr,Dr,nn,Nr,qr,an,Xr,Sr,rn,Yr,Ar,sn,Hr,Pr,ht,Qr,Lr,Ee,Or,dn,Kr,es,ln,os,ts,ft,ns,as,ha,co,fa,re,Ze,cn,io,rs,mo,ss,mn,ds,ls,ua,F,cs,pn,is,ms,ut,ps,hs,hn,fs,us,ga,Ue,gs,fn,_s,ys,_a,po,ya,se,We,un,ho,bs,fo,Ms,gn,ws,Ts,ba,de,_n,vs,ks,yn,Js,js,Ma,uo,wa,le,Ge,bn,go,Es,Mn,Zs,Ta,B,Us,wn,Ws,Gs,Tn,Is,zs,vn,Vs,$s,kn,Rs,Bs,va,_o,ka,Ie,Fs,yo,Cs,xs,Ja,H,Ds,bo,Ns,qs,Mo,Xs,Ss,ja,ce,ze,Jn,wo,Ys,jn,As,Ea,$,To,Hs,Ve,gt,Ps,Qs,_t,Ls,Os,Ks,ie,ed,yt,od,td,bt,nd,ad,rd,$e,sd,Re,vo,dd,ko,ld,Mt,cd,id,Za,me,Be,En,Jo,md,Zn,pd,Ua,E,jo,hd,pe,fd,wt,ud,gd,Tt,_d,yd,bd,Eo,Md,Zo,wd,Td,vd,Un,kd,Jd,Uo,jd,vt,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,al,xe,Wa,ue,De,Rn,Vo,rl,Bn,sl,Ga,Z,$o,dl,ge,ll,jt,cl,il,Et,ml,pl,hl,Ro,fl,Bo,ul,gl,_l,Fn,yl,bl,Fo,Ml,Zt,wl,Tl,vl,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,Ia,ye,Se,Dn,qo,Al,Nn,Hl,za,U,Xo,Pl,be,Ql,zt,Ll,Ol,Vt,Kl,ec,oc,So,tc,Yo,nc,ac,rc,qn,sc,dc,Ao,lc,$t,cc,ic,mc,Ho,pc,Po,hc,fc,uc,O,Rt,gc,_c,Xn,yc,bc,Sn,Mc,wc,Tc,N,Qo,vc,Me,kc,Bt,Jc,jc,Yn,Ec,Zc,Uc,Ye,Wc,Ae,Gc,K,Lo,Ic,An,zc,Vc,He,Va;return l=new Y({}),eo=new Y({}),no=new Y({}),ro=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({}),po=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`}}),wo=new Y({}),To=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/main/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/main/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/main/src/transformers/models/encoder_decoder/configuration_encoder_decoder.py#L25"}}),$e=new rt({props:{anchor:"transformers.EncoderDecoderConfig.example",$$slots:{default:[zm]},$$scope:{ctx:W}}}),vo=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/main/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/main/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/main/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/main/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/main/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/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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/main/src/transformers/models/encoder_decoder/modeling_encoder_decoder.py#L539",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/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/main/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:[Vm]},$$scope:{ctx:W}}}),Ce=new rt({props:{anchor:"transformers.EncoderDecoderModel.forward.example",$$slots:{default:[$m]},$$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/main/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/main/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/main/src/transformers/models/encoder_decoder/modeling_encoder_decoder.py#L389"}}),xe=new rt({props:{anchor:"transformers.EncoderDecoderModel.from_encoder_decoder_pretrained.example",$$slots:{default:[Rm]},$$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/main/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/main/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/main/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/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and <a href="/docs/transformers/main/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/main/src/transformers/models/encoder_decoder/modeling_tf_encoder_decoder.py#L469",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/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/main/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:[Bm]},$$scope:{ctx:W}}}),qe=new rt({props:{anchor:"transformers.TFEncoderDecoderModel.call.example",$$slots:{default:[Fm]},$$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/main/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/main/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/main/src/transformers/models/encoder_decoder/modeling_tf_encoder_decoder.py#L322"}}),Xe=new rt({props:{anchor:"transformers.TFEncoderDecoderModel.from_encoder_decoder_pretrained.example",$$slots:{default:[Cm]},$$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/main/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/main/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/main/en/main_classes/model#transformers.FlaxPreTrainedModel.to_fp16">to_fp16()</a> and
<a href="/docs/transformers/main/en/main_classes/model#transformers.FlaxPreTrainedModel.to_bf16">to_bf16()</a>.`,name:"dtype"}],source:"https://github.com/huggingface/transformers/blob/main/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/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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/main/src/transformers/models/encoder_decoder/modeling_flax_encoder_decoder.py#L627",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/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/main/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:[xm]},$$scope:{ctx:W}}}),Ae=new rt({props:{anchor:"transformers.FlaxEncoderDecoderModel.__call__.example",$$slots:{default:[Dm]},$$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/main/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/main/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/main/src/transformers/models/encoder_decoder/modeling_flax_encoder_decoder.py#L759"}}),He=new rt({props:{anchor:"transformers.FlaxEncoderDecoderModel.from_encoder_decoder_pretrained.example",$$slots:{default:[Nm]},$$scope:{ctx:W}}}),{c(){h=r("meta"),b=i(),_=r("h1"),f=r("a"),y=r("span"),M(l.$$.fragment),g=i(),R=r("span"),cr=n("Encoder Decoder Models"),na=i(),te=r("h2"),we=r("a"),Qt=r("span"),M(eo.$$.fragment),ir=i(),Lt=r("span"),mr=n("Overview"),aa=i(),Te=r("p"),pr=n("The "),dt=r("a"),hr=n("EncoderDecoderModel"),fr=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.`),ra=i(),ve=r("p"),ur=n(`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation tasks
was shown in `),oo=r("a"),gr=n("Leveraging Pre-trained Checkpoints for Sequence Generation Tasks"),_r=n(` by
Sascha Rothe, Shashi Narayan, Aliaksei Severyn.`),sa=i(),ke=r("p"),yr=n("After such an "),lt=r("a"),br=n("EncoderDecoderModel"),Mr=n(` has been trained/fine-tuned, it can be saved/loaded just like
any other models (see the examples for more information).`),da=i(),A=r("p"),wr=n("An application of this architecture could be to leverage two pretrained "),ct=r("a"),Tr=n("BertModel"),vr=n(` as the encoder
and decoder for a summarization model as was shown in: `),to=r("a"),kr=n("Text Summarization with Pretrained Encoders"),Jr=n(" by Yang Liu and Mirella Lapata."),la=i(),ne=r("h2"),Je=r("a"),Ot=r("span"),M(no.$$.fragment),jr=i(),ao=r("span"),Er=n("Randomly initializing "),Kt=r("code"),Zr=n("EncoderDecoderModel"),Ur=n(" from model configurations."),ca=i(),X=r("p"),it=r("a"),Wr=n("EncoderDecoderModel"),Gr=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 "),mt=r("a"),Ir=n("BertModel"),zr=n(" configuration for the encoder and the default "),en=r("code"),Vr=n("BertForCausalLM"),$r=n(" configuration for the decoder."),ia=i(),M(ro.$$.fragment),ma=i(),ae=r("h2"),je=r("a"),on=r("span"),M(so.$$.fragment),Rr=i(),lo=r("span"),Br=n("Initialising "),tn=r("code"),Fr=n("EncoderDecoderModel"),Cr=n(" from a pretrained encoder and a pretrained decoder."),pa=i(),j=r("p"),pt=r("a"),xr=n("EncoderDecoderModel"),Dr=n(" can be initialized from a pretrained encoder checkpoint and a pretrained decoder checkpoint. Note that any pretrained auto-encoding model, "),nn=r("em"),Nr=n("e.g."),qr=n(" BERT, can serve as the encoder and both pretrained auto-encoding models, "),an=r("em"),Xr=n("e.g."),Sr=n(" BERT, pretrained causal language models, "),rn=r("em"),Yr=n("e.g."),Ar=n(" GPT2, as well as the pretrained decoder part of sequence-to-sequence models, "),sn=r("em"),Hr=n("e.g."),Pr=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=r("a"),Qr=n("EncoderDecoderModel"),Lr=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=r("a"),Or=n("the "),dn=r("em"),Kr=n("Warm-starting-encoder-decoder blog post"),es=n(`.
To do so, the `),ln=r("code"),os=n("EncoderDecoderModel"),ts=n(" class provides a "),ft=r("a"),ns=n("EncoderDecoderModel.from_encoder_decoder_pretrained()"),as=n(" method."),ha=i(),M(co.$$.fragment),fa=i(),re=r("h2"),Ze=r("a"),cn=r("span"),M(io.$$.fragment),rs=i(),mo=r("span"),ss=n("Loading an existing "),mn=r("code"),ds=n("EncoderDecoderModel"),ls=n(" checkpoint and perform inference."),ua=i(),F=r("p"),cs=n("To load fine-tuned checkpoints of the "),pn=r("code"),is=n("EncoderDecoderModel"),ms=n(" class, "),ut=r("a"),ps=n("EncoderDecoderModel"),hs=n(" provides the "),hn=r("code"),fs=n("from_pretrained(...)"),us=n(" method just like any other model architecture in Transformers."),ga=i(),Ue=r("p"),gs=n("To perform inference, one uses the "),fn=r("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."),_a=i(),M(po.$$.fragment),ya=i(),se=r("h2"),We=r("a"),un=r("span"),M(ho.$$.fragment),bs=i(),fo=r("span"),Ms=n("Loading a PyTorch checkpoint into "),gn=r("code"),ws=n("TFEncoderDecoderModel"),Ts=n("."),ba=i(),de=r("p"),_n=r("code"),vs=n("TFEncoderDecoderModel.from_pretrained()"),ks=n(` currently doesn\u2019t support initializing the model from a
pytorch checkpoint. Passing `),yn=r("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:`),Ma=i(),M(uo.$$.fragment),wa=i(),le=r("h2"),Ge=r("a"),bn=r("span"),M(go.$$.fragment),Es=i(),Mn=r("span"),Zs=n("Training"),Ta=i(),B=r("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: `),wn=r("code"),Ws=n("input_ids"),Gs=n(` (which are the
`),Tn=r("code"),Is=n("input_ids"),zs=n(" of the encoded input sequence) and "),vn=r("code"),Vs=n("labels"),$s=n(" (which are the "),kn=r("code"),Rs=n("input_ids"),Bs=n(` of the encoded
target sequence).`),va=i(),M(_o.$$.fragment),ka=i(),Ie=r("p"),Fs=n("Detailed "),yo=r("a"),Cs=n("colab"),xs=n(" for training."),Ja=i(),H=r("p"),Ds=n("This model was contributed by "),bo=r("a"),Ns=n("thomwolf"),qs=n(`. This model\u2019s TensorFlow and Flax versions
were contributed by `),Mo=r("a"),Xs=n("ydshieh"),Ss=n("."),ja=i(),ce=r("h2"),ze=r("a"),Jn=r("span"),M(wo.$$.fragment),Ys=i(),jn=r("span"),As=n("EncoderDecoderConfig"),Ea=i(),$=r("div"),M(To.$$.fragment),Hs=i(),Ve=r("p"),gt=r("a"),Ps=n("EncoderDecoderConfig"),Qs=n(" is the configuration class to store the configuration of a "),_t=r("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=r("p"),ed=n("Configuration objects inherit from "),yt=r("a"),od=n("PretrainedConfig"),td=n(` and can be used to control the model outputs. Read the
documentation from `),bt=r("a"),nd=n("PretrainedConfig"),ad=n(" for more information."),rd=i(),M($e.$$.fragment),sd=i(),Re=r("div"),M(vo.$$.fragment),dd=i(),ko=r("p"),ld=n("Instantiate a "),Mt=r("a"),cd=n("EncoderDecoderConfig"),id=n(` (or a derived class) from a pre-trained encoder model configuration and
decoder model configuration.`),Za=i(),me=r("h2"),Be=r("a"),En=r("span"),M(Jo.$$.fragment),md=i(),Zn=r("span"),pd=n("EncoderDecoderModel"),Ua=i(),E=r("div"),M(jo.$$.fragment),hd=i(),pe=r("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
`),wt=r("a"),ud=n("from_pretrained()"),gd=n(" function and the decoder is loaded via "),Tt=r("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=r("p"),Md=n(`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Zo=r("a"),wd=n(`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),Td=n(` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),vd=i(),Un=r("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=r("p"),jd=n("This model inherits from "),vt=r("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=r("p"),Wd=n("This model is also a PyTorch "),Go=r("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=r("p"),kt=r("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=r("em"),Rd=n("~transformers.AutoModel.from_pretrained"),Bd=n(` class method for the encoder and
:meth`),Gn=r("em"),Fd=n("~transformers.AutoModelForCausalLM.from_pretrained"),Cd=n(" class method for the decoder."),xd=i(),C=r("div"),M(Io.$$.fragment),Dd=i(),he=r("p"),Nd=n("The "),Jt=r("a"),qd=n("EncoderDecoderModel"),Xd=n(" forward method, overrides the "),In=r("code"),Sd=n("__call__"),Yd=n(" special method."),Ad=i(),M(Fe.$$.fragment),Hd=i(),M(Ce.$$.fragment),Pd=i(),x=r("div"),M(zo.$$.fragment),Qd=i(),zn=r("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=r("p"),Kd=n("The model is set in evaluation mode by default using "),Vn=r("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=r("code"),tl=n("model.train()"),nl=n("."),al=i(),M(xe.$$.fragment),Wa=i(),ue=r("h2"),De=r("a"),Rn=r("span"),M(Vo.$$.fragment),rl=i(),Bn=r("span"),sl=n("TFEncoderDecoderModel"),Ga=i(),Z=r("div"),M($o.$$.fragment),dl=i(),ge=r("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=r("a"),cl=n("from_pretrained()"),il=n(" function and the decoder is loaded via "),Et=r("a"),ml=n("from_pretrained()"),pl=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=r("p"),fl=n(`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Bo=r("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=r("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=r("p"),Ml=n("This model inherits from "),Zt=r("a"),wl=n("TFPreTrainedModel"),Tl=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.)`),vl=i(),Co=r("p"),kl=n("This model is also a "),xo=r("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=r("p"),Ut=r("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=r("a"),Wl=n("from_pretrained()"),Gl=n(" class method for the encoder and "),Gt=r("a"),Il=n("from_pretrained()"),zl=n(` class
method for the decoder.`),Vl=i(),D=r("div"),M(Do.$$.fragment),$l=i(),_e=r("p"),Rl=n("The "),It=r("a"),Bl=n("TFEncoderDecoderModel"),Fl=n(" forward method, overrides the "),Cn=r("code"),Cl=n("__call__"),xl=n(" special method."),Dl=i(),M(Ne.$$.fragment),Nl=i(),M(qe.$$.fragment),ql=i(),L=r("div"),M(No.$$.fragment),Xl=i(),xn=r("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),Ia=i(),ye=r("h2"),Se=r("a"),Dn=r("span"),M(qo.$$.fragment),Al=i(),Nn=r("span"),Hl=n("FlaxEncoderDecoderModel"),za=i(),U=r("div"),M(Xo.$$.fragment),Pl=i(),be=r("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=r("a"),Ll=n("from_pretrained()"),Ol=n(" function and the decoder is loaded via "),Vt=r("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=r("p"),tc=n(`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Yo=r("a"),nc=n(`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),ac=n(` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),rc=i(),qn=r("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=r("p"),lc=n("This model inherits from "),$t=r("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.)`),mc=i(),Ho=r("p"),pc=n(`This model is also a Flax Linen
`),Po=r("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=r("p"),Rt=r("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=r("em"),yc=n("~transformers.FlaxAutoModel.from_pretrained"),bc=n(` class method for the
encoder and :meth`),Sn=r("em"),Mc=n("~transformers.FlaxAutoModelForCausalLM.from_pretrained"),wc=n(" class method for the decoder."),Tc=i(),N=r("div"),M(Qo.$$.fragment),vc=i(),Me=r("p"),kc=n("The "),Bt=r("a"),Jc=n("FlaxEncoderDecoderModel"),jc=n(" forward method, overrides the "),Yn=r("code"),Ec=n("__call__"),Zc=n(" special method."),Uc=i(),M(Ye.$$.fragment),Wc=i(),M(Ae.$$.fragment),Gc=i(),K=r("div"),M(Lo.$$.fragment),Ic=i(),An=r("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 p=Gm('[data-svelte="svelte-1phssyn"]',document.head);h=s(p,"META",{name:!0,content:!0}),p.forEach(t),b=m(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);w(l.$$.fragment,Pn),Pn.forEach(t),Hn.forEach(t),g=m(Oo),R=s(Oo,"SPAN",{});var Qn=d(R);cr=a(Qn,"Encoder Decoder Models"),Qn.forEach(t),Oo.forEach(t),na=m(o),te=s(o,"H2",{class:!0});var Ko=d(te);we=s(Ko,"A",{id:!0,class:!0,href:!0});var Ln=d(we);Qt=s(Ln,"SPAN",{});var On=d(Qt);w(eo.$$.fragment,On),On.forEach(t),Ln.forEach(t),ir=m(Ko),Lt=s(Ko,"SPAN",{});var Kn=d(Lt);mr=a(Kn,"Overview"),Kn.forEach(t),Ko.forEach(t),aa=m(o),Te=s(o,"P",{});var et=d(Te);pr=a(et,"The "),dt=s(et,"A",{href:!0});var ea=d(dt);hr=a(ea,"EncoderDecoderModel"),ea.forEach(t),fr=a(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),ra=m(o),ve=s(o,"P",{});var $a=d(ve);ur=a($a,`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation tasks
was shown in `),oo=s($a,"A",{href:!0,rel:!0});var Bc=d(oo);gr=a(Bc,"Leveraging Pre-trained Checkpoints for Sequence Generation Tasks"),Bc.forEach(t),_r=a($a,` by
Sascha Rothe, Shashi Narayan, Aliaksei Severyn.`),$a.forEach(t),sa=m(o),ke=s(o,"P",{});var Ra=d(ke);yr=a(Ra,"After such an "),lt=s(Ra,"A",{href:!0});var Fc=d(lt);br=a(Fc,"EncoderDecoderModel"),Fc.forEach(t),Mr=a(Ra,` has been trained/fine-tuned, it can be saved/loaded just like
any other models (see the examples for more information).`),Ra.forEach(t),da=m(o),A=s(o,"P",{});var Ft=d(A);wr=a(Ft,"An application of this architecture could be to leverage two pretrained "),ct=s(Ft,"A",{href:!0});var Cc=d(ct);Tr=a(Cc,"BertModel"),Cc.forEach(t),vr=a(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);kr=a(xc,"Text Summarization with Pretrained Encoders"),xc.forEach(t),Jr=a(Ft," by Yang Liu and Mirella Lapata."),Ft.forEach(t),la=m(o),ne=s(o,"H2",{class:!0});var Ba=d(ne);Je=s(Ba,"A",{id:!0,class:!0,href:!0});var Dc=d(Je);Ot=s(Dc,"SPAN",{});var Nc=d(Ot);w(no.$$.fragment,Nc),Nc.forEach(t),Dc.forEach(t),jr=m(Ba),ao=s(Ba,"SPAN",{});var Fa=d(ao);Er=a(Fa,"Randomly initializing "),Kt=s(Fa,"CODE",{});var qc=d(Kt);Zr=a(qc,"EncoderDecoderModel"),qc.forEach(t),Ur=a(Fa," from model configurations."),Fa.forEach(t),Ba.forEach(t),ca=m(o),X=s(o,"P",{});var ot=d(X);it=s(ot,"A",{href:!0});var Xc=d(it);Wr=a(Xc,"EncoderDecoderModel"),Xc.forEach(t),Gr=a(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 "),mt=s(ot,"A",{href:!0});var Sc=d(mt);Ir=a(Sc,"BertModel"),Sc.forEach(t),zr=a(ot," configuration for the encoder and the default "),en=s(ot,"CODE",{});var Yc=d(en);Vr=a(Yc,"BertForCausalLM"),Yc.forEach(t),$r=a(ot," configuration for the decoder."),ot.forEach(t),ia=m(o),w(ro.$$.fragment,o),ma=m(o),ae=s(o,"H2",{class:!0});var Ca=d(ae);je=s(Ca,"A",{id:!0,class:!0,href:!0});var Ac=d(je);on=s(Ac,"SPAN",{});var Hc=d(on);w(so.$$.fragment,Hc),Hc.forEach(t),Ac.forEach(t),Rr=m(Ca),lo=s(Ca,"SPAN",{});var xa=d(lo);Br=a(xa,"Initialising "),tn=s(xa,"CODE",{});var Pc=d(tn);Fr=a(Pc,"EncoderDecoderModel"),Pc.forEach(t),Cr=a(xa," from a pretrained encoder and a pretrained decoder."),xa.forEach(t),Ca.forEach(t),pa=m(o),j=s(o,"P",{});var G=d(j);pt=s(G,"A",{href:!0});var Qc=d(pt);xr=a(Qc,"EncoderDecoderModel"),Qc.forEach(t),Dr=a(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);Nr=a(Lc,"e.g."),Lc.forEach(t),qr=a(G," BERT, can serve as the encoder and both pretrained auto-encoding models, "),an=s(G,"EM",{});var Oc=d(an);Xr=a(Oc,"e.g."),Oc.forEach(t),Sr=a(G," BERT, pretrained causal language models, "),rn=s(G,"EM",{});var Kc=d(rn);Yr=a(Kc,"e.g."),Kc.forEach(t),Ar=a(G," GPT2, as well as the pretrained decoder part of sequence-to-sequence models, "),sn=s(G,"EM",{});var ei=d(sn);Hr=a(ei,"e.g."),ei.forEach(t),Pr=a(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);Qr=a(oi,"EncoderDecoderModel"),oi.forEach(t),Lr=a(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);Or=a($c,"the "),dn=s($c,"EM",{});var ti=d(dn);Kr=a(ti,"Warm-starting-encoder-decoder blog post"),ti.forEach(t),$c.forEach(t),es=a(G,`.
To do so, the `),ln=s(G,"CODE",{});var ni=d(ln);os=a(ni,"EncoderDecoderModel"),ni.forEach(t),ts=a(G," class provides a "),ft=s(G,"A",{href:!0});var ai=d(ft);ns=a(ai,"EncoderDecoderModel.from_encoder_decoder_pretrained()"),ai.forEach(t),as=a(G," method."),G.forEach(t),ha=m(o),w(co.$$.fragment,o),fa=m(o),re=s(o,"H2",{class:!0});var Da=d(re);Ze=s(Da,"A",{id:!0,class:!0,href:!0});var ri=d(Ze);cn=s(ri,"SPAN",{});var si=d(cn);w(io.$$.fragment,si),si.forEach(t),ri.forEach(t),rs=m(Da),mo=s(Da,"SPAN",{});var Na=d(mo);ss=a(Na,"Loading an existing "),mn=s(Na,"CODE",{});var di=d(mn);ds=a(di,"EncoderDecoderModel"),di.forEach(t),ls=a(Na," checkpoint and perform inference."),Na.forEach(t),Da.forEach(t),ua=m(o),F=s(o,"P",{});var Pe=d(F);cs=a(Pe,"To load fine-tuned checkpoints of the "),pn=s(Pe,"CODE",{});var li=d(pn);is=a(li,"EncoderDecoderModel"),li.forEach(t),ms=a(Pe," class, "),ut=s(Pe,"A",{href:!0});var ci=d(ut);ps=a(ci,"EncoderDecoderModel"),ci.forEach(t),hs=a(Pe," provides the "),hn=s(Pe,"CODE",{});var ii=d(hn);fs=a(ii,"from_pretrained(...)"),ii.forEach(t),us=a(Pe," method just like any other model architecture in Transformers."),Pe.forEach(t),ga=m(o),Ue=s(o,"P",{});var qa=d(Ue);gs=a(qa,"To perform inference, one uses the "),fn=s(qa,"CODE",{});var mi=d(fn);_s=a(mi,"generate"),mi.forEach(t),ys=a(qa," method, which allows to autoregressively generate text. This method supports various forms of decoding, such as greedy, beam search and multinomial sampling."),qa.forEach(t),_a=m(o),w(po.$$.fragment,o),ya=m(o),se=s(o,"H2",{class:!0});var Xa=d(se);We=s(Xa,"A",{id:!0,class:!0,href:!0});var pi=d(We);un=s(pi,"SPAN",{});var hi=d(un);w(ho.$$.fragment,hi),hi.forEach(t),pi.forEach(t),bs=m(Xa),fo=s(Xa,"SPAN",{});var Sa=d(fo);Ms=a(Sa,"Loading a PyTorch checkpoint into "),gn=s(Sa,"CODE",{});var fi=d(gn);ws=a(fi,"TFEncoderDecoderModel"),fi.forEach(t),Ts=a(Sa,"."),Sa.forEach(t),Xa.forEach(t),ba=m(o),de=s(o,"P",{});var oa=d(de);_n=s(oa,"CODE",{});var ui=d(_n);vs=a(ui,"TFEncoderDecoderModel.from_pretrained()"),ui.forEach(t),ks=a(oa,` currently doesn\u2019t support initializing the model from a
pytorch checkpoint. Passing `),yn=s(oa,"CODE",{});var gi=d(yn);Js=a(gi,"from_pt=True"),gi.forEach(t),js=a(oa,` to this method will throw an exception. If there are only pytorch
checkpoints for a particular encoder-decoder model, a workaround is:`),oa.forEach(t),Ma=m(o),w(uo.$$.fragment,o),wa=m(o),le=s(o,"H2",{class:!0});var Ya=d(le);Ge=s(Ya,"A",{id:!0,class:!0,href:!0});var _i=d(Ge);bn=s(_i,"SPAN",{});var yi=d(bn);w(go.$$.fragment,yi),yi.forEach(t),_i.forEach(t),Es=m(Ya),Mn=s(Ya,"SPAN",{});var bi=d(Mn);Zs=a(bi,"Training"),bi.forEach(t),Ya.forEach(t),Ta=m(o),B=s(o,"P",{});var ee=d(B);Us=a(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: `),wn=s(ee,"CODE",{});var Mi=d(wn);Ws=a(Mi,"input_ids"),Mi.forEach(t),Gs=a(ee,` (which are the
`),Tn=s(ee,"CODE",{});var wi=d(Tn);Is=a(wi,"input_ids"),wi.forEach(t),zs=a(ee," of the encoded input sequence) and "),vn=s(ee,"CODE",{});var Ti=d(vn);Vs=a(Ti,"labels"),Ti.forEach(t),$s=a(ee," (which are the "),kn=s(ee,"CODE",{});var vi=d(kn);Rs=a(vi,"input_ids"),vi.forEach(t),Bs=a(ee,` of the encoded
target sequence).`),ee.forEach(t),va=m(o),w(_o.$$.fragment,o),ka=m(o),Ie=s(o,"P",{});var Aa=d(Ie);Fs=a(Aa,"Detailed "),yo=s(Aa,"A",{href:!0,rel:!0});var ki=d(yo);Cs=a(ki,"colab"),ki.forEach(t),xs=a(Aa," for training."),Aa.forEach(t),Ja=m(o),H=s(o,"P",{});var Ct=d(H);Ds=a(Ct,"This model was contributed by "),bo=s(Ct,"A",{href:!0,rel:!0});var Ji=d(bo);Ns=a(Ji,"thomwolf"),Ji.forEach(t),qs=a(Ct,`. This model\u2019s TensorFlow and Flax versions
were contributed by `),Mo=s(Ct,"A",{href:!0,rel:!0});var ji=d(Mo);Xs=a(ji,"ydshieh"),ji.forEach(t),Ss=a(Ct,"."),Ct.forEach(t),ja=m(o),ce=s(o,"H2",{class:!0});var Ha=d(ce);ze=s(Ha,"A",{id:!0,class:!0,href:!0});var Ei=d(ze);Jn=s(Ei,"SPAN",{});var Zi=d(Jn);w(wo.$$.fragment,Zi),Zi.forEach(t),Ei.forEach(t),Ys=m(Ha),jn=s(Ha,"SPAN",{});var Ui=d(jn);As=a(Ui,"EncoderDecoderConfig"),Ui.forEach(t),Ha.forEach(t),Ea=m(o),$=s(o,"DIV",{class:!0});var oe=d($);w(To.$$.fragment,oe),Hs=m(oe),Ve=s(oe,"P",{});var ta=d(Ve);gt=s(ta,"A",{href:!0});var Wi=d(gt);Ps=a(Wi,"EncoderDecoderConfig"),Wi.forEach(t),Qs=a(ta," is the configuration class to store the configuration of a "),_t=s(ta,"A",{href:!0});var Gi=d(_t);Ls=a(Gi,"EncoderDecoderModel"),Gi.forEach(t),Os=a(ta,`. It is
used to instantiate an Encoder Decoder model according to the specified arguments, defining the encoder and decoder
configs.`),ta.forEach(t),Ks=m(oe),ie=s(oe,"P",{});var xt=d(ie);ed=a(xt,"Configuration objects inherit from "),yt=s(xt,"A",{href:!0});var Ii=d(yt);od=a(Ii,"PretrainedConfig"),Ii.forEach(t),td=a(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=a(zi,"PretrainedConfig"),zi.forEach(t),ad=a(xt," for more information."),xt.forEach(t),rd=m(oe),w($e.$$.fragment,oe),sd=m(oe),Re=s(oe,"DIV",{class:!0});var Pa=d(Re);w(vo.$$.fragment,Pa),dd=m(Pa),ko=s(Pa,"P",{});var Qa=d(ko);ld=a(Qa,"Instantiate a "),Mt=s(Qa,"A",{href:!0});var Vi=d(Mt);cd=a(Vi,"EncoderDecoderConfig"),Vi.forEach(t),id=a(Qa,` (or a derived class) from a pre-trained encoder model configuration and
decoder model configuration.`),Qa.forEach(t),Pa.forEach(t),oe.forEach(t),Za=m(o),me=s(o,"H2",{class:!0});var La=d(me);Be=s(La,"A",{id:!0,class:!0,href:!0});var $i=d(Be);En=s($i,"SPAN",{});var Ri=d(En);w(Jo.$$.fragment,Ri),Ri.forEach(t),$i.forEach(t),md=m(La),Zn=s(La,"SPAN",{});var Bi=d(Zn);pd=a(Bi,"EncoderDecoderModel"),Bi.forEach(t),La.forEach(t),Ua=m(o),E=s(o,"DIV",{class:!0});var I=d(E);w(jo.$$.fragment,I),hd=m(I),pe=s(I,"P",{});var Dt=d(pe);fd=a(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
`),wt=s(Dt,"A",{href:!0});var Fi=d(wt);ud=a(Fi,"from_pretrained()"),Fi.forEach(t),gd=a(Dt," function and the decoder is loaded via "),Tt=s(Dt,"A",{href:!0});var Ci=d(Tt);_d=a(Ci,"from_pretrained()"),Ci.forEach(t),yd=a(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=m(I),Eo=s(I,"P",{});var Oa=d(Eo);Md=a(Oa,`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Zo=s(Oa,"A",{href:!0,rel:!0});var xi=d(Zo);wd=a(xi,`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),xi.forEach(t),Td=a(Oa,` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),Oa.forEach(t),vd=m(I),Un=s(I,"P",{});var Di=d(Un);kd=a(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=m(I),Uo=s(I,"P",{});var Ka=d(Uo);jd=a(Ka,"This model inherits from "),vt=s(Ka,"A",{href:!0});var Ni=d(vt);Ed=a(Ni,"PreTrainedModel"),Ni.forEach(t),Zd=a(Ka,`. 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.)`),Ka.forEach(t),Ud=m(I),Wo=s(I,"P",{});var er=d(Wo);Wd=a(er,"This model is also a PyTorch "),Go=s(er,"A",{href:!0,rel:!0});var qi=d(Go);Gd=a(qi,"torch.nn.Module"),qi.forEach(t),Id=a(er,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),er.forEach(t),zd=m(I),P=s(I,"P",{});var tt=d(P);kt=s(tt,"A",{href:!0});var Xi=d(kt);Vd=a(Xi,"EncoderDecoderModel"),Xi.forEach(t),$d=a(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=a(Si,"~transformers.AutoModel.from_pretrained"),Si.forEach(t),Bd=a(tt,` class method for the encoder and
:meth`),Gn=s(tt,"EM",{});var Yi=d(Gn);Fd=a(Yi,"~transformers.AutoModelForCausalLM.from_pretrained"),Yi.forEach(t),Cd=a(tt," class method for the decoder."),tt.forEach(t),xd=m(I),C=s(I,"DIV",{class:!0});var Qe=d(C);w(Io.$$.fragment,Qe),Dd=m(Qe),he=s(Qe,"P",{});var Nt=d(he);Nd=a(Nt,"The "),Jt=s(Nt,"A",{href:!0});var Ai=d(Jt);qd=a(Ai,"EncoderDecoderModel"),Ai.forEach(t),Xd=a(Nt," forward method, overrides the "),In=s(Nt,"CODE",{});var Hi=d(In);Sd=a(Hi,"__call__"),Hi.forEach(t),Yd=a(Nt," special method."),Nt.forEach(t),Ad=m(Qe),w(Fe.$$.fragment,Qe),Hd=m(Qe),w(Ce.$$.fragment,Qe),Qe.forEach(t),Pd=m(I),x=s(I,"DIV",{class:!0});var Le=d(x);w(zo.$$.fragment,Le),Qd=m(Le),zn=s(Le,"P",{});var Pi=d(zn);Ld=a(Pi,`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),Pi.forEach(t),Od=m(Le),fe=s(Le,"P",{});var qt=d(fe);Kd=a(qt,"The model is set in evaluation mode by default using "),Vn=s(qt,"CODE",{});var Qi=d(Vn);el=a(Qi,"model.eval()"),Qi.forEach(t),ol=a(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=a(Li,"model.train()"),Li.forEach(t),nl=a(qt,"."),qt.forEach(t),al=m(Le),w(xe.$$.fragment,Le),Le.forEach(t),I.forEach(t),Wa=m(o),ue=s(o,"H2",{class:!0});var or=d(ue);De=s(or,"A",{id:!0,class:!0,href:!0});var Oi=d(De);Rn=s(Oi,"SPAN",{});var Ki=d(Rn);w(Vo.$$.fragment,Ki),Ki.forEach(t),Oi.forEach(t),rl=m(or),Bn=s(or,"SPAN",{});var em=d(Bn);sl=a(em,"TFEncoderDecoderModel"),em.forEach(t),or.forEach(t),Ga=m(o),Z=s(o,"DIV",{class:!0});var z=d(Z);w($o.$$.fragment,z),dl=m(z),ge=s(z,"P",{});var Xt=d(ge);ll=a(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 om=d(jt);cl=a(om,"from_pretrained()"),om.forEach(t),il=a(Xt," function and the decoder is loaded via "),Et=s(Xt,"A",{href:!0});var tm=d(Et);ml=a(tm,"from_pretrained()"),tm.forEach(t),pl=a(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=m(z),Ro=s(z,"P",{});var tr=d(Ro);fl=a(tr,`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Bo=s(tr,"A",{href:!0,rel:!0});var nm=d(Bo);ul=a(nm,`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),nm.forEach(t),gl=a(tr,` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),tr.forEach(t),_l=m(z),Fn=s(z,"P",{});var am=d(Fn);yl=a(am,`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).`),am.forEach(t),bl=m(z),Fo=s(z,"P",{});var nr=d(Fo);Ml=a(nr,"This model inherits from "),Zt=s(nr,"A",{href:!0});var rm=d(Zt);wl=a(rm,"TFPreTrainedModel"),rm.forEach(t),Tl=a(nr,`. 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.)`),nr.forEach(t),vl=m(z),Co=s(z,"P",{});var ar=d(Co);kl=a(ar,"This model is also a "),xo=s(ar,"A",{href:!0,rel:!0});var sm=d(xo);Jl=a(sm,"tf.keras.Model"),sm.forEach(t),jl=a(ar,` 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.`),ar.forEach(t),El=m(z),Q=s(z,"P",{});var nt=d(Q);Ut=s(nt,"A",{href:!0});var dm=d(Ut);Zl=a(dm,"TFEncoderDecoderModel"),dm.forEach(t),Ul=a(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 lm=d(Wt);Wl=a(lm,"from_pretrained()"),lm.forEach(t),Gl=a(nt," class method for the encoder and "),Gt=s(nt,"A",{href:!0});var cm=d(Gt);Il=a(cm,"from_pretrained()"),cm.forEach(t),zl=a(nt,` class
method for the decoder.`),nt.forEach(t),Vl=m(z),D=s(z,"DIV",{class:!0});var Oe=d(D);w(Do.$$.fragment,Oe),$l=m(Oe),_e=s(Oe,"P",{});var St=d(_e);Rl=a(St,"The "),It=s(St,"A",{href:!0});var im=d(It);Bl=a(im,"TFEncoderDecoderModel"),im.forEach(t),Fl=a(St," forward method, overrides the "),Cn=s(St,"CODE",{});var mm=d(Cn);Cl=a(mm,"__call__"),mm.forEach(t),xl=a(St," special method."),St.forEach(t),Dl=m(Oe),w(Ne.$$.fragment,Oe),Nl=m(Oe),w(qe.$$.fragment,Oe),Oe.forEach(t),ql=m(z),L=s(z,"DIV",{class:!0});var Yt=d(L);w(No.$$.fragment,Yt),Xl=m(Yt),xn=s(Yt,"P",{});var pm=d(xn);Sl=a(pm,`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),pm.forEach(t),Yl=m(Yt),w(Xe.$$.fragment,Yt),Yt.forEach(t),z.forEach(t),Ia=m(o),ye=s(o,"H2",{class:!0});var rr=d(ye);Se=s(rr,"A",{id:!0,class:!0,href:!0});var hm=d(Se);Dn=s(hm,"SPAN",{});var fm=d(Dn);w(qo.$$.fragment,fm),fm.forEach(t),hm.forEach(t),Al=m(rr),Nn=s(rr,"SPAN",{});var um=d(Nn);Hl=a(um,"FlaxEncoderDecoderModel"),um.forEach(t),rr.forEach(t),za=m(o),U=s(o,"DIV",{class:!0});var V=d(U);w(Xo.$$.fragment,V),Pl=m(V),be=s(V,"P",{});var At=d(be);Ql=a(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 gm=d(zt);Ll=a(gm,"from_pretrained()"),gm.forEach(t),Ol=a(At," function and the decoder is loaded via "),Vt=s(At,"A",{href:!0});var _m=d(Vt);Kl=a(_m,"from_pretrained()"),_m.forEach(t),ec=a(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=m(V),So=s(V,"P",{});var sr=d(So);tc=a(sr,`The effectiveness of initializing sequence-to-sequence models with pretrained checkpoints for sequence generation
tasks was shown in `),Yo=s(sr,"A",{href:!0,rel:!0});var ym=d(Yo);nc=a(ym,`Leveraging Pre-trained Checkpoints for Sequence Generation
Tasks`),ym.forEach(t),ac=a(sr,` by Sascha Rothe, Shashi Narayan, Aliaksei Severyn. Michael Matena, Yanqi
Zhou, Wei Li, Peter J. Liu.`),sr.forEach(t),rc=m(V),qn=s(V,"P",{});var bm=d(qn);sc=a(bm,`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).`),bm.forEach(t),dc=m(V),Ao=s(V,"P",{});var dr=d(Ao);lc=a(dr,"This model inherits from "),$t=s(dr,"A",{href:!0});var Mm=d($t);cc=a(Mm,"FlaxPreTrainedModel"),Mm.forEach(t),ic=a(dr,`. 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.)`),dr.forEach(t),mc=m(V),Ho=s(V,"P",{});var lr=d(Ho);pc=a(lr,`This model is also a Flax Linen
`),Po=s(lr,"A",{href:!0,rel:!0});var wm=d(Po);hc=a(wm,"flax.nn.Module"),wm.forEach(t),fc=a(lr,` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),lr.forEach(t),uc=m(V),O=s(V,"P",{});var at=d(O);Rt=s(at,"A",{href:!0});var Tm=d(Rt);gc=a(Tm,"FlaxEncoderDecoderModel"),Tm.forEach(t),_c=a(at,` 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(at,"EM",{});var vm=d(Xn);yc=a(vm,"~transformers.FlaxAutoModel.from_pretrained"),vm.forEach(t),bc=a(at,` class method for the
encoder and :meth`),Sn=s(at,"EM",{});var km=d(Sn);Mc=a(km,"~transformers.FlaxAutoModelForCausalLM.from_pretrained"),km.forEach(t),wc=a(at," class method for the decoder."),at.forEach(t),Tc=m(V),N=s(V,"DIV",{class:!0});var Ke=d(N);w(Qo.$$.fragment,Ke),vc=m(Ke),Me=s(Ke,"P",{});var Ht=d(Me);kc=a(Ht,"The "),Bt=s(Ht,"A",{href:!0});var Jm=d(Bt);Jc=a(Jm,"FlaxEncoderDecoderModel"),Jm.forEach(t),jc=a(Ht," forward method, overrides the "),Yn=s(Ht,"CODE",{});var jm=d(Yn);Ec=a(jm,"__call__"),jm.forEach(t),Zc=a(Ht," special method."),Ht.forEach(t),Uc=m(Ke),w(Ye.$$.fragment,Ke),Wc=m(Ke),w(Ae.$$.fragment,Ke),Ke.forEach(t),Gc=m(V),K=s(V,"DIV",{class:!0});var Pt=d(K);w(Lo.$$.fragment,Pt),Ic=m(Pt),An=s(Pt,"P",{});var Em=d(An);zc=a(Em,`Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model
checkpoints.`),Em.forEach(t),Vc=m(Pt),w(He.$$.fragment,Pt),Pt.forEach(t),V.forEach(t),this.h()},h(){c(h,"name","hf:doc:metadata"),c(h,"content",JSON.stringify(Xm)),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(we,"id","overview"),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","#overview"),c(te,"class","relative group"),c(dt,"href","/docs/transformers/main/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/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(ct,"href","/docs/transformers/main/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/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(mt,"href","/docs/transformers/main/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(ae,"class","relative group"),c(pt,"href","/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(ht,"href","/docs/transformers/main/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/main/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(re,"class","relative group"),c(ut,"href","/docs/transformers/main/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/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderConfig"),c(_t,"href","/docs/transformers/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(yt,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),c(bt,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),c(Mt,"href","/docs/transformers/main/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(me,"class","relative group"),c(wt,"href","/docs/transformers/main/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(Tt,"href","/docs/transformers/main/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(Zo,"href","https://arxiv.org/abs/1907.12461"),c(Zo,"rel","nofollow"),c(vt,"href","/docs/transformers/main/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/main/en/model_doc/encoder-decoder#transformers.EncoderDecoderModel"),c(Jt,"href","/docs/transformers/main/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/main/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(Et,"href","/docs/transformers/main/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/main/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/main/en/model_doc/encoder-decoder#transformers.TFEncoderDecoderModel"),c(Wt,"href","/docs/transformers/main/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(Gt,"href","/docs/transformers/main/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(It,"href","/docs/transformers/main/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/main/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),c(Vt,"href","/docs/transformers/main/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/main/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/main/en/model_doc/encoder-decoder#transformers.FlaxEncoderDecoderModel"),c(Bt,"href","/docs/transformers/main/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,p){e(document.head,h),u(o,b,p),u(o,_,p),e(_,f),e(f,y),T(l,y,null),e(_,g),e(_,R),e(R,cr),u(o,na,p),u(o,te,p),e(te,we),e(we,Qt),T(eo,Qt,null),e(te,ir),e(te,Lt),e(Lt,mr),u(o,aa,p),u(o,Te,p),e(Te,pr),e(Te,dt),e(dt,hr),e(Te,fr),u(o,ra,p),u(o,ve,p),e(ve,ur),e(ve,oo),e(oo,gr),e(ve,_r),u(o,sa,p),u(o,ke,p),e(ke,yr),e(ke,lt),e(lt,br),e(ke,Mr),u(o,da,p),u(o,A,p),e(A,wr),e(A,ct),e(ct,Tr),e(A,vr),e(A,to),e(to,kr),e(A,Jr),u(o,la,p),u(o,ne,p),e(ne,Je),e(Je,Ot),T(no,Ot,null),e(ne,jr),e(ne,ao),e(ao,Er),e(ao,Kt),e(Kt,Zr),e(ao,Ur),u(o,ca,p),u(o,X,p),e(X,it),e(it,Wr),e(X,Gr),e(X,mt),e(mt,Ir),e(X,zr),e(X,en),e(en,Vr),e(X,$r),u(o,ia,p),T(ro,o,p),u(o,ma,p),u(o,ae,p),e(ae,je),e(je,on),T(so,on,null),e(ae,Rr),e(ae,lo),e(lo,Br),e(lo,tn),e(tn,Fr),e(lo,Cr),u(o,pa,p),u(o,j,p),e(j,pt),e(pt,xr),e(j,Dr),e(j,nn),e(nn,Nr),e(j,qr),e(j,an),e(an,Xr),e(j,Sr),e(j,rn),e(rn,Yr),e(j,Ar),e(j,sn),e(sn,Hr),e(j,Pr),e(j,ht),e(ht,Qr),e(j,Lr),e(j,Ee),e(Ee,Or),e(Ee,dn),e(dn,Kr),e(j,es),e(j,ln),e(ln,os),e(j,ts),e(j,ft),e(ft,ns),e(j,as),u(o,ha,p),T(co,o,p),u(o,fa,p),u(o,re,p),e(re,Ze),e(Ze,cn),T(io,cn,null),e(re,rs),e(re,mo),e(mo,ss),e(mo,mn),e(mn,ds),e(mo,ls),u(o,ua,p),u(o,F,p),e(F,cs),e(F,pn),e(pn,is),e(F,ms),e(F,ut),e(ut,ps),e(F,hs),e(F,hn),e(hn,fs),e(F,us),u(o,ga,p),u(o,Ue,p),e(Ue,gs),e(Ue,fn),e(fn,_s),e(Ue,ys),u(o,_a,p),T(po,o,p),u(o,ya,p),u(o,se,p),e(se,We),e(We,un),T(ho,un,null),e(se,bs),e(se,fo),e(fo,Ms),e(fo,gn),e(gn,ws),e(fo,Ts),u(o,ba,p),u(o,de,p),e(de,_n),e(_n,vs),e(de,ks),e(de,yn),e(yn,Js),e(de,js),u(o,Ma,p),T(uo,o,p),u(o,wa,p),u(o,le,p),e(le,Ge),e(Ge,bn),T(go,bn,null),e(le,Es),e(le,Mn),e(Mn,Zs),u(o,Ta,p),u(o,B,p),e(B,Us),e(B,wn),e(wn,Ws),e(B,Gs),e(B,Tn),e(Tn,Is),e(B,zs),e(B,vn),e(vn,Vs),e(B,$s),e(B,kn),e(kn,Rs),e(B,Bs),u(o,va,p),T(_o,o,p),u(o,ka,p),u(o,Ie,p),e(Ie,Fs),e(Ie,yo),e(yo,Cs),e(Ie,xs),u(o,Ja,p),u(o,H,p),e(H,Ds),e(H,bo),e(bo,Ns),e(H,qs),e(H,Mo),e(Mo,Xs),e(H,Ss),u(o,ja,p),u(o,ce,p),e(ce,ze),e(ze,Jn),T(wo,Jn,null),e(ce,Ys),e(ce,jn),e(jn,As),u(o,Ea,p),u(o,$,p),T(To,$,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,ad),e($,rd),T($e,$,null),e($,sd),e($,Re),T(vo,Re,null),e(Re,dd),e(Re,ko),e(ko,ld),e(ko,Mt),e(Mt,cd),e(ko,id),u(o,Za,p),u(o,me,p),e(me,Be),e(Be,En),T(Jo,En,null),e(me,md),e(me,Zn),e(Zn,pd),u(o,Ua,p),u(o,E,p),T(jo,E,null),e(E,hd),e(E,pe),e(pe,fd),e(pe,wt),e(wt,ud),e(pe,gd),e(pe,Tt),e(Tt,_d),e(pe,yd),e(E,bd),e(E,Eo),e(Eo,Md),e(Eo,Zo),e(Zo,wd),e(Eo,Td),e(E,vd),e(E,Un),e(Un,kd),e(E,Jd),e(E,Uo),e(Uo,jd),e(Uo,vt),e(vt,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),T(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),T(Fe,C,null),e(C,Hd),T(Ce,C,null),e(E,Pd),e(E,x),T(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,al),T(xe,x,null),u(o,Wa,p),u(o,ue,p),e(ue,De),e(De,Rn),T(Vo,Rn,null),e(ue,rl),e(ue,Bn),e(Bn,sl),u(o,Ga,p),u(o,Z,p),T($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,ml),e(ge,pl),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,wl),e(Fo,Tl),e(Z,vl),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),T(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),T(Ne,D,null),e(D,Nl),T(qe,D,null),e(Z,ql),e(Z,L),T(No,L,null),e(L,Xl),e(L,xn),e(xn,Sl),e(L,Yl),T(Xe,L,null),u(o,Ia,p),u(o,ye,p),e(ye,Se),e(Se,Dn),T(qo,Dn,null),e(ye,Al),e(ye,Nn),e(Nn,Hl),u(o,za,p),u(o,U,p),T(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,ac),e(U,rc),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,mc),e(U,Ho),e(Ho,pc),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,wc),e(U,Tc),e(U,N),T(Qo,N,null),e(N,vc),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),T(Ye,N,null),e(N,Wc),T(Ae,N,null),e(U,Gc),e(U,K),T(Lo,K,null),e(K,Ic),e(K,An),e(An,zc),e(K,Vc),T(He,K,null),Va=!0},p(o,[p]){const Oo={};p&2&&(Oo.$$scope={dirty:p,ctx:o}),$e.$set(Oo);const Hn={};p&2&&(Hn.$$scope={dirty:p,ctx:o}),Fe.$set(Hn);const Pn={};p&2&&(Pn.$$scope={dirty:p,ctx:o}),Ce.$set(Pn);const Qn={};p&2&&(Qn.$$scope={dirty:p,ctx:o}),xe.$set(Qn);const Ko={};p&2&&(Ko.$$scope={dirty:p,ctx:o}),Ne.$set(Ko);const Ln={};p&2&&(Ln.$$scope={dirty:p,ctx:o}),qe.$set(Ln);const On={};p&2&&(On.$$scope={dirty:p,ctx:o}),Xe.$set(On);const Kn={};p&2&&(Kn.$$scope={dirty:p,ctx:o}),Ye.$set(Kn);const et={};p&2&&(et.$$scope={dirty:p,ctx:o}),Ae.$set(et);const ea={};p&2&&(ea.$$scope={dirty:p,ctx:o}),He.$set(ea)},i(o){Va||(v(l.$$.fragment,o),v(eo.$$.fragment,o),v(no.$$.fragment,o),v(ro.$$.fragment,o),v(so.$$.fragment,o),v(co.$$.fragment,o),v(io.$$.fragment,o),v(po.$$.fragment,o),v(ho.$$.fragment,o),v(uo.$$.fragment,o),v(go.$$.fragment,o),v(_o.$$.fragment,o),v(wo.$$.fragment,o),v(To.$$.fragment,o),v($e.$$.fragment,o),v(vo.$$.fragment,o),v(Jo.$$.fragment,o),v(jo.$$.fragment,o),v(Io.$$.fragment,o),v(Fe.$$.fragment,o),v(Ce.$$.fragment,o),v(zo.$$.fragment,o),v(xe.$$.fragment,o),v(Vo.$$.fragment,o),v($o.$$.fragment,o),v(Do.$$.fragment,o),v(Ne.$$.fragment,o),v(qe.$$.fragment,o),v(No.$$.fragment,o),v(Xe.$$.fragment,o),v(qo.$$.fragment,o),v(Xo.$$.fragment,o),v(Qo.$$.fragment,o),v(Ye.$$.fragment,o),v(Ae.$$.fragment,o),v(Lo.$$.fragment,o),v(He.$$.fragment,o),Va=!0)},o(o){k(l.$$.fragment,o),k(eo.$$.fragment,o),k(no.$$.fragment,o),k(ro.$$.fragment,o),k(so.$$.fragment,o),k(co.$$.fragment,o),k(io.$$.fragment,o),k(po.$$.fragment,o),k(ho.$$.fragment,o),k(uo.$$.fragment,o),k(go.$$.fragment,o),k(_o.$$.fragment,o),k(wo.$$.fragment,o),k(To.$$.fragment,o),k($e.$$.fragment,o),k(vo.$$.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),Va=!1},d(o){t(h),o&&t(b),o&&t(_),J(l),o&&t(na),o&&t(te),J(eo),o&&t(aa),o&&t(Te),o&&t(ra),o&&t(ve),o&&t(sa),o&&t(ke),o&&t(da),o&&t(A),o&&t(la),o&&t(ne),J(no),o&&t(ca),o&&t(X),o&&t(ia),J(ro,o),o&&t(ma),o&&t(ae),J(so),o&&t(pa),o&&t(j),o&&t(ha),J(co,o),o&&t(fa),o&&t(re),J(io),o&&t(ua),o&&t(F),o&&t(ga),o&&t(Ue),o&&t(_a),J(po,o),o&&t(ya),o&&t(se),J(ho),o&&t(ba),o&&t(de),o&&t(Ma),J(uo,o),o&&t(wa),o&&t(le),J(go),o&&t(Ta),o&&t(B),o&&t(va),J(_o,o),o&&t(ka),o&&t(Ie),o&&t(Ja),o&&t(H),o&&t(ja),o&&t(ce),J(wo),o&&t(Ea),o&&t($),J(To),J($e),J(vo),o&&t(Za),o&&t(me),J(Jo),o&&t(Ua),o&&t(E),J(jo),J(Io),J(Fe),J(Ce),J(zo),J(xe),o&&t(Wa),o&&t(ue),J(Vo),o&&t(Ga),o&&t(Z),J($o),J(Do),J(Ne),J(qe),J(No),J(Xe),o&&t(Ia),o&&t(ye),J(qo),o&&t(za),o&&t(U),J(Xo),J(Qo),J(Ye),J(Ae),J(Lo),J(He)}}}const Xm={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 Sm(W){return Im(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Om extends Zm{constructor(h){super();Um(this,h,Sm,qm,Wm,{})}}export{Om as default,Xm as metadata};
