import{S as Dw,i as Vw,s as Sw,e as a,k as c,w as v,t as n,M as Lw,c as r,d as t,m as p,a as i,x as k,h as s,b as u,N as Rw,G as e,g,y as w,q as M,o as $,B as P,v as Xw,L as De}from"../../chunks/vendor-hf-doc-builder.js";import{T as Be}from"../../chunks/Tip-hf-doc-builder.js";import{D as A}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Ve}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as we}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Re}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";import{P as Ow}from"../../chunks/PipelineTag-hf-doc-builder.js";function Qw(G){let d,y,f,m,T;return m=new Ve({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEdQVDJDb25maWclMkMlMjBHUFQyTW9kZWwlMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwR1BUMiUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwR1BUMkNvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBHUFQyTW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Config, GPT2Model

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a GPT2 configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = GPT2Config()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GPT2Model(configuration)

<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>configuration = model.config`}}),{c(){d=a("p"),y=n("Example:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"Example:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function Yw(G){let d,y,f,m,T;return m=new Ve({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEdQVDJUb2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBHUFQyVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJncHQyJTIyKSUwQXRva2VuaXplciglMjJIZWxsbyUyMHdvcmxkJTIyKSU1QiUyMmlucHV0X2lkcyUyMiU1RCUwQSUwQXRva2VuaXplciglMjIlMjBIZWxsbyUyMHdvcmxkJTIyKSU1QiUyMmlucHV0X2lkcyUyMiU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer(<span class="hljs-string">&quot;Hello world&quot;</span>)[<span class="hljs-string">&quot;input_ids&quot;</span>]
[<span class="hljs-number">15496</span>, <span class="hljs-number">995</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer(<span class="hljs-string">&quot; Hello world&quot;</span>)[<span class="hljs-string">&quot;input_ids&quot;</span>]
[<span class="hljs-number">18435</span>, <span class="hljs-number">995</span>]`}}),{c(){d=a("p"),y=n("be encoded differently whether it is at the beginning of the sentence (without space) or not:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"be encoded differently whether it is at the beginning of the sentence (without space) or not:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function Kw(G){let d,y,f,m,T;return{c(){d=a("p"),y=n("When used with "),f=a("code"),m=n("is_split_into_words=True"),T=n(", this tokenizer will add a space before each word (even the first one).")},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"When used with "),f=r(h,"CODE",{});var F=i(f);m=s(F,"is_split_into_words=True"),F.forEach(t),T=s(h,", this tokenizer will add a space before each word (even the first one)."),h.forEach(t)},m(l,h){g(l,d,h),e(d,y),e(d,f),e(f,m),e(d,T)},d(l){l&&t(d)}}}function eM(G){let d,y,f,m,T;return m=new Ve({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEdQVDJUb2tlbml6ZXJGYXN0JTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwR1BUMlRva2VuaXplckZhc3QuZnJvbV9wcmV0cmFpbmVkKCUyMmdwdDIlMjIpJTBBdG9rZW5pemVyKCUyMkhlbGxvJTIwd29ybGQlMjIpJTVCJTIyaW5wdXRfaWRzJTIyJTVEJTBBJTBBdG9rZW5pemVyKCUyMiUyMEhlbGxvJTIwd29ybGQlMjIpJTVCJTIyaW5wdXRfaWRzJTIyJTVE",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2TokenizerFast

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2TokenizerFast.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer(<span class="hljs-string">&quot;Hello world&quot;</span>)[<span class="hljs-string">&quot;input_ids&quot;</span>]
[<span class="hljs-number">15496</span>, <span class="hljs-number">995</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer(<span class="hljs-string">&quot; Hello world&quot;</span>)[<span class="hljs-string">&quot;input_ids&quot;</span>]
[<span class="hljs-number">18435</span>, <span class="hljs-number">995</span>]`}}),{c(){d=a("p"),y=n("be encoded differently whether it is at the beginning of the sentence (without space) or not:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"be encoded differently whether it is at the beginning of the sentence (without space) or not:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function tM(G){let d,y,f,m,T,l,h,F;return{c(){d=a("p"),y=n("When used with "),f=a("code"),m=n("is_split_into_words=True"),T=n(", this tokenizer needs to be instantiated with "),l=a("code"),h=n("add_prefix_space=True"),F=n(".")},l(R){d=r(R,"P",{});var N=i(d);y=s(N,"When used with "),f=r(N,"CODE",{});var J=i(f);m=s(J,"is_split_into_words=True"),J.forEach(t),T=s(N,", this tokenizer needs to be instantiated with "),l=r(N,"CODE",{});var O=i(l);h=s(O,"add_prefix_space=True"),O.forEach(t),F=s(N,"."),N.forEach(t)},m(R,N){g(R,d,N),e(d,y),e(d,f),e(f,m),e(d,T),e(d,l),e(l,h),e(d,F)},d(R){R&&t(d)}}}function oM(G){let d,y,f,m,T;return{c(){d=a("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),m=n("Module"),T=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){d=r(l,"P",{});var h=i(d);y=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var F=i(f);m=s(F,"Module"),F.forEach(t),T=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(l,h){g(l,d,h),e(d,y),e(d,f),e(f,m),e(d,T)},d(l){l&&t(d)}}}function nM(G){let d,y,f,m,T;return m=new Ve({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBHUFQyTW9kZWwlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmdwdDIlMjIpJTBBbW9kZWwlMjAlM0QlMjBHUFQyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmdwdDIlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMkhlbGxvJTJDJTIwbXklMjBkb2clMjBpcyUyMGN1dGUlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyklMEElMEFsYXN0X2hpZGRlbl9zdGF0ZXMlMjAlM0QlMjBvdXRwdXRzLmxhc3RfaGlkZGVuX3N0YXRl",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, GPT2Model
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GPT2Model.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state`}}),{c(){d=a("p"),y=n("Example:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"Example:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function sM(G){let d,y,f,m,T;return{c(){d=a("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),m=n("Module"),T=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){d=r(l,"P",{});var h=i(d);y=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var F=i(f);m=s(F,"Module"),F.forEach(t),T=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(l,h){g(l,d,h),e(d,y),e(d,f),e(f,m),e(d,T)},d(l){l&&t(d)}}}function aM(G){let d,y,f,m,T;return m=new Ve({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMEdQVDJMTUhlYWRNb2RlbCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmdwdDIlMjIpJTBBbW9kZWwlMjAlM0QlMjBHUFQyTE1IZWFkTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmdwdDIlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMkhlbGxvJTJDJTIwbXklMjBkb2clMjBpcyUyMGN1dGUlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyUyQyUyMGxhYmVscyUzRGlucHV0cyU1QiUyMmlucHV0X2lkcyUyMiU1RCklMEFsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTBBbG9naXRzJTIwJTNEJTIwb3V0cHV0cy5sb2dpdHM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, GPT2LMHeadModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GPT2LMHeadModel.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, labels=inputs[<span class="hljs-string">&quot;input_ids&quot;</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),{c(){d=a("p"),y=n("Example:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"Example:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function rM(G){let d,y,f,m,T;return{c(){d=a("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),m=n("Module"),T=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){d=r(l,"P",{});var h=i(d);y=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var F=i(f);m=s(F,"Module"),F.forEach(t),T=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(l,h){g(l,d,h),e(d,y),e(d,f),e(f,m),e(d,T)},d(l){l&&t(d)}}}function iM(G){let d,y,f,m,T;return m=new Ve({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMEdQVDJEb3VibGVIZWFkc01vZGVsJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMiklMEFtb2RlbCUyMCUzRCUyMEdQVDJEb3VibGVIZWFkc01vZGVsLmZyb21fcHJldHJhaW5lZCglMjJncHQyJTIyKSUwQSUwQSUyMyUyMEFkZCUyMGElMjAlNUJDTFMlNUQlMjB0byUyMHRoZSUyMHZvY2FidWxhcnklMjAod2UlMjBzaG91bGQlMjB0cmFpbiUyMGl0JTIwYWxzbyEpJTBBbnVtX2FkZGVkX3Rva2VucyUyMCUzRCUyMHRva2VuaXplci5hZGRfc3BlY2lhbF90b2tlbnMoJTdCJTIyY2xzX3Rva2VuJTIyJTNBJTIwJTIyJTVCQ0xTJTVEJTIyJTdEKSUwQSUyMyUyMFVwZGF0ZSUyMHRoZSUyMG1vZGVsJTIwZW1iZWRkaW5ncyUyMHdpdGglMjB0aGUlMjBuZXclMjB2b2NhYnVsYXJ5JTIwc2l6ZSUwQWVtYmVkZGluZ19sYXllciUyMCUzRCUyMG1vZGVsLnJlc2l6ZV90b2tlbl9lbWJlZGRpbmdzKGxlbih0b2tlbml6ZXIpKSUwQSUwQWNob2ljZXMlMjAlM0QlMjAlNUIlMjJIZWxsbyUyQyUyMG15JTIwZG9nJTIwaXMlMjBjdXRlJTIwJTVCQ0xTJTVEJTIyJTJDJTIwJTIySGVsbG8lMkMlMjBteSUyMGNhdCUyMGlzJTIwY3V0ZSUyMCU1QkNMUyU1RCUyMiU1RCUwQWVuY29kZWRfY2hvaWNlcyUyMCUzRCUyMCU1QnRva2VuaXplci5lbmNvZGUocyklMjBmb3IlMjBzJTIwaW4lMjBjaG9pY2VzJTVEJTBBY2xzX3Rva2VuX2xvY2F0aW9uJTIwJTNEJTIwJTVCdG9rZW5zLmluZGV4KHRva2VuaXplci5jbHNfdG9rZW5faWQpJTIwZm9yJTIwdG9rZW5zJTIwaW4lMjBlbmNvZGVkX2Nob2ljZXMlNUQlMEElMEFpbnB1dF9pZHMlMjAlM0QlMjB0b3JjaC50ZW5zb3IoZW5jb2RlZF9jaG9pY2VzKS51bnNxdWVlemUoMCklMjAlMjAlMjMlMjBCYXRjaCUyMHNpemUlM0ElMjAxJTJDJTIwbnVtYmVyJTIwb2YlMjBjaG9pY2VzJTNBJTIwMiUwQW1jX3Rva2VuX2lkcyUyMCUzRCUyMHRvcmNoLnRlbnNvciglNUJjbHNfdG9rZW5fbG9jYXRpb24lNUQpJTIwJTIwJTIzJTIwQmF0Y2glMjBzaXplJTNBJTIwMSUwQSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbChpbnB1dF9pZHMlMkMlMjBtY190b2tlbl9pZHMlM0RtY190b2tlbl9pZHMpJTBBbG1fbG9naXRzJTIwJTNEJTIwb3V0cHV0cy5sb2dpdHMlMEFtY19sb2dpdHMlMjAlM0QlMjBvdXRwdXRzLm1jX2xvZ2l0cw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, GPT2DoubleHeadsModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GPT2DoubleHeadsModel.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Add a [CLS] to the vocabulary (we should train it also!)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_added_tokens = tokenizer.add_special_tokens({<span class="hljs-string">&quot;cls_token&quot;</span>: <span class="hljs-string">&quot;[CLS]&quot;</span>})
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Update the model embeddings with the new vocabulary size</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>embedding_layer = model.resize_token_embeddings(<span class="hljs-built_in">len</span>(tokenizer))

<span class="hljs-meta">&gt;&gt;&gt; </span>choices = [<span class="hljs-string">&quot;Hello, my dog is cute [CLS]&quot;</span>, <span class="hljs-string">&quot;Hello, my cat is cute [CLS]&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>encoded_choices = [tokenizer.encode(s) <span class="hljs-keyword">for</span> s <span class="hljs-keyword">in</span> choices]
<span class="hljs-meta">&gt;&gt;&gt; </span>cls_token_location = [tokens.index(tokenizer.cls_token_id) <span class="hljs-keyword">for</span> tokens <span class="hljs-keyword">in</span> encoded_choices]

<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = torch.tensor(encoded_choices).unsqueeze(<span class="hljs-number">0</span>)  <span class="hljs-comment"># Batch size: 1, number of choices: 2</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>mc_token_ids = torch.tensor([cls_token_location])  <span class="hljs-comment"># Batch size: 1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_ids, mc_token_ids=mc_token_ids)
<span class="hljs-meta">&gt;&gt;&gt; </span>lm_logits = outputs.logits
<span class="hljs-meta">&gt;&gt;&gt; </span>mc_logits = outputs.mc_logits`}}),{c(){d=a("p"),y=n("Example:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"Example:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function lM(G){let d,y,f,m,T;return{c(){d=a("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),m=n("Module"),T=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){d=r(l,"P",{});var h=i(d);y=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var F=i(f);m=s(F,"Module"),F.forEach(t),T=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(l,h){g(l,d,h),e(d,y),e(d,f),e(f,m),e(d,T)},d(l){l&&t(d)}}}function dM(G){let d,y,f,m,T,l,h,F;return{c(){d=a("p"),y=n(`This example uses a random model as the real ones are all very big. To get proper results, you should use
gpt2 instead of gpt2. If you get out-of-memory when loading that checkpoint, you can try
adding `),f=a("code"),m=n('device_map="auto"'),T=n(" in the "),l=a("code"),h=n("from_pretrained"),F=n(" call.")},l(R){d=r(R,"P",{});var N=i(d);y=s(N,`This example uses a random model as the real ones are all very big. To get proper results, you should use
gpt2 instead of gpt2. If you get out-of-memory when loading that checkpoint, you can try
adding `),f=r(N,"CODE",{});var J=i(f);m=s(J,'device_map="auto"'),J.forEach(t),T=s(N," in the "),l=r(N,"CODE",{});var O=i(l);h=s(O,"from_pretrained"),O.forEach(t),F=s(N," call."),N.forEach(t)},m(R,N){g(R,d,N),e(d,y),e(d,f),e(f,m),e(d,T),e(d,l),e(l,h),e(d,F)},d(R){R&&t(d)}}}function cM(G){let d,y,f,m,T;return m=new Ve({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBHUFQyRm9yUXVlc3Rpb25BbnN3ZXJpbmclMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmdwdDIlMjIpJTBBbW9kZWwlMjAlM0QlMjBHUFQyRm9yUXVlc3Rpb25BbnN3ZXJpbmcuZnJvbV9wcmV0cmFpbmVkKCUyMmdwdDIlMjIpJTBBJTBBcXVlc3Rpb24lMkMlMjB0ZXh0JTIwJTNEJTIwJTIyV2hvJTIwd2FzJTIwSmltJTIwSGVuc29uJTNGJTIyJTJDJTIwJTIySmltJTIwSGVuc29uJTIwd2FzJTIwYSUyMG5pY2UlMjBwdXBwZXQlMjIlMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIocXVlc3Rpb24lMkMlMjB0ZXh0JTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQSUwQWFuc3dlcl9zdGFydF9pbmRleCUyMCUzRCUyMG91dHB1dHMuc3RhcnRfbG9naXRzLmFyZ21heCgpJTBBYW5zd2VyX2VuZF9pbmRleCUyMCUzRCUyMG91dHB1dHMuZW5kX2xvZ2l0cy5hcmdtYXgoKSUwQSUwQXByZWRpY3RfYW5zd2VyX3Rva2VucyUyMCUzRCUyMGlucHV0cy5pbnB1dF9pZHMlNUIwJTJDJTIwYW5zd2VyX3N0YXJ0X2luZGV4JTIwJTNBJTIwYW5zd2VyX2VuZF9pbmRleCUyMCUyQiUyMDElNUQlMEElMEElMjMlMjB0YXJnZXQlMjBpcyUyMCUyMm5pY2UlMjBwdXBwZXQlMjIlMEF0YXJnZXRfc3RhcnRfaW5kZXglMjAlM0QlMjB0b3JjaC50ZW5zb3IoJTVCMTQlNUQpJTBBdGFyZ2V0X2VuZF9pbmRleCUyMCUzRCUyMHRvcmNoLnRlbnNvciglNUIxNSU1RCklMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMlMkMlMjBzdGFydF9wb3NpdGlvbnMlM0R0YXJnZXRfc3RhcnRfaW5kZXglMkMlMjBlbmRfcG9zaXRpb25zJTNEdGFyZ2V0X2VuZF9pbmRleCklMEFsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3Nz",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, GPT2ForQuestionAnswering
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GPT2ForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>question, text = <span class="hljs-string">&quot;Who was Jim Henson?&quot;</span>, <span class="hljs-string">&quot;Jim Henson was a nice puppet&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(question, text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>answer_start_index = outputs.start_logits.argmax()
<span class="hljs-meta">&gt;&gt;&gt; </span>answer_end_index = outputs.end_logits.argmax()

<span class="hljs-meta">&gt;&gt;&gt; </span>predict_answer_tokens = inputs.input_ids[<span class="hljs-number">0</span>, answer_start_index : answer_end_index + <span class="hljs-number">1</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># target is &quot;nice puppet&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>target_start_index = torch.tensor([<span class="hljs-number">14</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>target_end_index = torch.tensor([<span class="hljs-number">15</span>])

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, start_positions=target_start_index, end_positions=target_end_index)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss`}}),{c(){d=a("p"),y=n("Example:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"Example:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function pM(G){let d,y,f,m,T;return{c(){d=a("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),m=n("Module"),T=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){d=r(l,"P",{});var h=i(d);y=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var F=i(f);m=s(F,"Module"),F.forEach(t),T=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(l,h){g(l,d,h),e(d,y),e(d,f),e(f,m),e(d,T)},d(l){l&&t(d)}}}function hM(G){let d,y,f,m,T;return m=new Ve({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMEdQVDJGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGRGlhbG9nUlBULXVwZG93biUyMiklMEFtb2RlbCUyMCUzRCUyMEdQVDJGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZEaWFsb2dSUFQtdXBkb3duJTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplciglMjJIZWxsbyUyQyUyMG15JTIwZG9nJTIwaXMlMjBjdXRlJTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cyUwQSUwQXByZWRpY3RlZF9jbGFzc19pZCUyMCUzRCUyMGxvZ2l0cy5hcmdtYXgoKS5pdGVtKCklMEElMEElMjMlMjBUbyUyMHRyYWluJTIwYSUyMG1vZGVsJTIwb24lMjAlNjBudW1fbGFiZWxzJTYwJTIwY2xhc3NlcyUyQyUyMHlvdSUyMGNhbiUyMHBhc3MlMjAlNjBudW1fbGFiZWxzJTNEbnVtX2xhYmVscyU2MCUyMHRvJTIwJTYwLmZyb21fcHJldHJhaW5lZCguLi4pJTYwJTBBbnVtX2xhYmVscyUyMCUzRCUyMGxlbihtb2RlbC5jb25maWcuaWQybGFiZWwpJTBBbW9kZWwlMjAlM0QlMjBHUFQyRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGRGlhbG9nUlBULXVwZG93biUyMiUyQyUyMG51bV9sYWJlbHMlM0RudW1fbGFiZWxzKSUwQSUwQWxhYmVscyUyMCUzRCUyMHRvcmNoLnRlbnNvciglNUIxJTVEKSUwQWxvc3MlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyUyQyUyMGxhYmVscyUzRGxhYmVscykubG9zcw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, GPT2ForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;microsoft/DialogRPT-updown&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GPT2ForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/DialogRPT-updown&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    logits = model(**inputs).logits

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_class_id = logits.argmax().item()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># To train a model on \`num_labels\` classes, you can pass \`num_labels=num_labels\` to \`.from_pretrained(...)\`</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_labels = <span class="hljs-built_in">len</span>(model.config.id2label)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GPT2ForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/DialogRPT-updown&quot;</span>, num_labels=num_labels)

<span class="hljs-meta">&gt;&gt;&gt; </span>labels = torch.tensor([<span class="hljs-number">1</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = model(**inputs, labels=labels).loss`}}),{c(){d=a("p"),y=n("Example of single-label classification:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"Example of single-label classification:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function uM(G){let d,y,f,m,T;return m=new Ve({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMEdQVDJGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGRGlhbG9nUlBULXVwZG93biUyMiklMEFtb2RlbCUyMCUzRCUyMEdQVDJGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZEaWFsb2dSUFQtdXBkb3duJTIyJTJDJTIwcHJvYmxlbV90eXBlJTNEJTIybXVsdGlfbGFiZWxfY2xhc3NpZmljYXRpb24lMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMkhlbGxvJTJDJTIwbXklMjBkb2clMjBpcyUyMGN1dGUlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBJTBBcHJlZGljdGVkX2NsYXNzX2lkcyUyMCUzRCUyMHRvcmNoLmFyYW5nZSgwJTJDJTIwbG9naXRzLnNoYXBlJTVCLTElNUQpJTVCdG9yY2guc2lnbW9pZChsb2dpdHMpLnNxdWVlemUoZGltJTNEMCklMjAlM0UlMjAwLjUlNUQlMEElMEElMjMlMjBUbyUyMHRyYWluJTIwYSUyMG1vZGVsJTIwb24lMjAlNjBudW1fbGFiZWxzJTYwJTIwY2xhc3NlcyUyQyUyMHlvdSUyMGNhbiUyMHBhc3MlMjAlNjBudW1fbGFiZWxzJTNEbnVtX2xhYmVscyU2MCUyMHRvJTIwJTYwLmZyb21fcHJldHJhaW5lZCguLi4pJTYwJTBBbnVtX2xhYmVscyUyMCUzRCUyMGxlbihtb2RlbC5jb25maWcuaWQybGFiZWwpJTBBbW9kZWwlMjAlM0QlMjBHUFQyRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIybWljcm9zb2Z0JTJGRGlhbG9nUlBULXVwZG93biUyMiUyQyUyMG51bV9sYWJlbHMlM0RudW1fbGFiZWxzJTJDJTIwcHJvYmxlbV90eXBlJTNEJTIybXVsdGlfbGFiZWxfY2xhc3NpZmljYXRpb24lMjIlMEEpJTBBJTBBbGFiZWxzJTIwJTNEJTIwdG9yY2guc3VtKCUwQSUyMCUyMCUyMCUyMHRvcmNoLm5uLmZ1bmN0aW9uYWwub25lX2hvdChwcmVkaWN0ZWRfY2xhc3NfaWRzJTVCTm9uZSUyQyUyMCUzQSU1RC5jbG9uZSgpJTJDJTIwbnVtX2NsYXNzZXMlM0RudW1fbGFiZWxzKSUyQyUyMGRpbSUzRDElMEEpLnRvKHRvcmNoLmZsb2F0KSUwQWxvc3MlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyUyQyUyMGxhYmVscyUzRGxhYmVscykubG9zcw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, GPT2ForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;microsoft/DialogRPT-updown&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GPT2ForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/DialogRPT-updown&quot;</span>, problem_type=<span class="hljs-string">&quot;multi_label_classification&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    logits = model(**inputs).logits

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_class_ids = torch.arange(<span class="hljs-number">0</span>, logits.shape[-<span class="hljs-number">1</span>])[torch.sigmoid(logits).squeeze(dim=<span class="hljs-number">0</span>) &gt; <span class="hljs-number">0.5</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># To train a model on \`num_labels\` classes, you can pass \`num_labels=num_labels\` to \`.from_pretrained(...)\`</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_labels = <span class="hljs-built_in">len</span>(model.config.id2label)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GPT2ForSequenceClassification.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;microsoft/DialogRPT-updown&quot;</span>, num_labels=num_labels, problem_type=<span class="hljs-string">&quot;multi_label_classification&quot;</span>
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>labels = torch.<span class="hljs-built_in">sum</span>(
<span class="hljs-meta">... </span>    torch.nn.functional.one_hot(predicted_class_ids[<span class="hljs-literal">None</span>, :].clone(), num_classes=num_labels), dim=<span class="hljs-number">1</span>
<span class="hljs-meta">... </span>).to(torch.<span class="hljs-built_in">float</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = model(**inputs, labels=labels).loss`}}),{c(){d=a("p"),y=n("Example of multi-label classification:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"Example of multi-label classification:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function mM(G){let d,y,f,m,T;return{c(){d=a("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),m=n("Module"),T=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){d=r(l,"P",{});var h=i(d);y=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var F=i(f);m=s(F,"Module"),F.forEach(t),T=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(l,h){g(l,d,h),e(d,y),e(d,f),e(f,m),e(d,T)},d(l){l&&t(d)}}}function fM(G){let d,y,f,m,T;return m=new Ve({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBHUFQyRm9yVG9rZW5DbGFzc2lmaWNhdGlvbiUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyYnJhZDExNDElMkZncHQyLWZpbmV0dW5lZC1jb21wMiUyMiklMEFtb2RlbCUyMCUzRCUyMEdQVDJGb3JUb2tlbkNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJicmFkMTE0MSUyRmdwdDItZmluZXR1bmVkLWNvbXAyJTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplciglMEElMjAlMjAlMjAlMjAlMjJIdWdnaW5nRmFjZSUyMGlzJTIwYSUyMGNvbXBhbnklMjBiYXNlZCUyMGluJTIwUGFyaXMlMjBhbmQlMjBOZXclMjBZb3JrJTIyJTJDJTIwYWRkX3NwZWNpYWxfdG9rZW5zJTNERmFsc2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTBBKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBJTBBcHJlZGljdGVkX3Rva2VuX2NsYXNzX2lkcyUyMCUzRCUyMGxvZ2l0cy5hcmdtYXgoLTEpJTBBJTBBJTIzJTIwTm90ZSUyMHRoYXQlMjB0b2tlbnMlMjBhcmUlMjBjbGFzc2lmaWVkJTIwcmF0aGVyJTIwdGhlbiUyMGlucHV0JTIwd29yZHMlMjB3aGljaCUyMG1lYW5zJTIwdGhhdCUwQSUyMyUyMHRoZXJlJTIwbWlnaHQlMjBiZSUyMG1vcmUlMjBwcmVkaWN0ZWQlMjB0b2tlbiUyMGNsYXNzZXMlMjB0aGFuJTIwd29yZHMuJTBBJTIzJTIwTXVsdGlwbGUlMjB0b2tlbiUyMGNsYXNzZXMlMjBtaWdodCUyMGFjY291bnQlMjBmb3IlMjB0aGUlMjBzYW1lJTIwd29yZCUwQXByZWRpY3RlZF90b2tlbnNfY2xhc3NlcyUyMCUzRCUyMCU1Qm1vZGVsLmNvbmZpZy5pZDJsYWJlbCU1QnQuaXRlbSgpJTVEJTIwZm9yJTIwdCUyMGluJTIwcHJlZGljdGVkX3Rva2VuX2NsYXNzX2lkcyU1QjAlNUQlNUQlMEFwcmVkaWN0ZWRfdG9rZW5zX2NsYXNzZXMlMEElMEFsYWJlbHMlMjAlM0QlMjBwcmVkaWN0ZWRfdG9rZW5fY2xhc3NfaWRzJTBBbG9zcyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzJTJDJTIwbGFiZWxzJTNEbGFiZWxzKS5sb3NzJTBBcm91bmQobG9zcy5pdGVtKCklMkMlMjAyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, GPT2ForTokenClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;brad1141/gpt2-finetuned-comp2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = GPT2ForTokenClassification.from_pretrained(<span class="hljs-string">&quot;brad1141/gpt2-finetuned-comp2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;HuggingFace is a company based in Paris and New York&quot;</span>, add_special_tokens=<span class="hljs-literal">False</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    logits = model(**inputs).logits

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_token_class_ids = logits.argmax(-<span class="hljs-number">1</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Note that tokens are classified rather then input words which means that</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># there might be more predicted token classes than words.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Multiple token classes might account for the same word</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_tokens_classes = [model.config.id2label[t.item()] <span class="hljs-keyword">for</span> t <span class="hljs-keyword">in</span> predicted_token_class_ids[<span class="hljs-number">0</span>]]
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_tokens_classes
[<span class="hljs-string">&#x27;Lead&#x27;</span>, <span class="hljs-string">&#x27;Lead&#x27;</span>, <span class="hljs-string">&#x27;Lead&#x27;</span>, <span class="hljs-string">&#x27;Position&#x27;</span>, <span class="hljs-string">&#x27;Lead&#x27;</span>, <span class="hljs-string">&#x27;Lead&#x27;</span>, <span class="hljs-string">&#x27;Lead&#x27;</span>, <span class="hljs-string">&#x27;Lead&#x27;</span>, <span class="hljs-string">&#x27;Lead&#x27;</span>, <span class="hljs-string">&#x27;Lead&#x27;</span>, <span class="hljs-string">&#x27;Lead&#x27;</span>, <span class="hljs-string">&#x27;Lead&#x27;</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>labels = predicted_token_class_ids
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = model(**inputs, labels=labels).loss
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">round</span>(loss.item(), <span class="hljs-number">2</span>)
<span class="hljs-number">0.25</span>`}}),{c(){d=a("p"),y=n("Example:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"Example:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function gM(G){let d,y,f,m,T,l,h,F,R,N,J,O,re,E,Ge,S,fe,Se,Q,le,pe,L,he,Fe,X,Ee,Me,H,je,ue,me,x,C,ze,oe,$e,ge,ne,Pe,_e,U,xe,Y,Te,Ce,K,ee,ye,D,Ue,V,Je,de,I,Ie,W,q,Ne;return{c(){d=a("p"),y=n("TensorFlow models and layers in "),f=a("code"),m=n("transformers"),T=n(" accept two formats as input:"),l=c(),h=a("ul"),F=a("li"),R=n("having all inputs as keyword arguments (like PyTorch models), or"),N=c(),J=a("li"),O=n("having all inputs as a list, tuple or dict in the first positional argument."),re=c(),E=a("p"),Ge=n(`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),S=a("code"),fe=n("model.fit()"),Se=n(` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),Q=a("code"),le=n("model.fit()"),pe=n(` supports! If, however, you want to use the second
format outside of Keras methods like `),L=a("code"),he=n("fit()"),Fe=n(" and "),X=a("code"),Ee=n("predict()"),Me=n(`, such as when creating your own layers or models with
the Keras `),H=a("code"),je=n("Functional"),ue=n(` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),me=c(),x=a("ul"),C=a("li"),ze=n("a single Tensor with "),oe=a("code"),$e=n("input_ids"),ge=n(" only and nothing else: "),ne=a("code"),Pe=n("model(input_ids)"),_e=c(),U=a("li"),xe=n(`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),Y=a("code"),Te=n("model([input_ids, attention_mask])"),Ce=n(" or "),K=a("code"),ee=n("model([input_ids, attention_mask, token_type_ids])"),ye=c(),D=a("li"),Ue=n(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),V=a("code"),Je=n('model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),de=c(),I=a("p"),Ie=n(`Note that when creating models and layers with
`),W=a("a"),q=n("subclassing"),Ne=n(` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),this.h()},l(b){d=r(b,"P",{});var j=i(d);y=s(j,"TensorFlow models and layers in "),f=r(j,"CODE",{});var nt=i(f);m=s(nt,"transformers"),nt.forEach(t),T=s(j," accept two formats as input:"),j.forEach(t),l=p(b),h=r(b,"UL",{});var ce=i(h);F=r(ce,"LI",{});var st=i(F);R=s(st,"having all inputs as keyword arguments (like PyTorch models), or"),st.forEach(t),N=p(ce),J=r(ce,"LI",{});var at=i(J);O=s(at,"having all inputs as a list, tuple or dict in the first positional argument."),at.forEach(t),ce.forEach(t),re=p(b),E=r(b,"P",{});var z=i(E);Ge=s(z,`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),S=r(z,"CODE",{});var rt=i(S);fe=s(rt,"model.fit()"),rt.forEach(t),Se=s(z,` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),Q=r(z,"CODE",{});var it=i(Q);le=s(it,"model.fit()"),it.forEach(t),pe=s(z,` supports! If, however, you want to use the second
format outside of Keras methods like `),L=r(z,"CODE",{});var Xe=i(L);he=s(Xe,"fit()"),Xe.forEach(t),Fe=s(z," and "),X=r(z,"CODE",{});var lt=i(X);Ee=s(lt,"predict()"),lt.forEach(t),Me=s(z,`, such as when creating your own layers or models with
the Keras `),H=r(z,"CODE",{});var dt=i(H);je=s(dt,"Functional"),dt.forEach(t),ue=s(z,` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),z.forEach(t),me=p(b),x=r(b,"UL",{});var Z=i(x);C=r(Z,"LI",{});var se=i(C);ze=s(se,"a single Tensor with "),oe=r(se,"CODE",{});var ct=i(oe);$e=s(ct,"input_ids"),ct.forEach(t),ge=s(se," only and nothing else: "),ne=r(se,"CODE",{});var Le=i(ne);Pe=s(Le,"model(input_ids)"),Le.forEach(t),se.forEach(t),_e=p(Z),U=r(Z,"LI",{});var ae=i(U);xe=s(ae,`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),Y=r(ae,"CODE",{});var pt=i(Y);Te=s(pt,"model([input_ids, attention_mask])"),pt.forEach(t),Ce=s(ae," or "),K=r(ae,"CODE",{});var Oe=i(K);ee=s(Oe,"model([input_ids, attention_mask, token_type_ids])"),Oe.forEach(t),ae.forEach(t),ye=p(Z),D=r(Z,"LI",{});var qe=i(D);Ue=s(qe,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),V=r(qe,"CODE",{});var ht=i(V);Je=s(ht,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),ht.forEach(t),qe.forEach(t),Z.forEach(t),de=p(b),I=r(b,"P",{});var ie=i(I);Ie=s(ie,`Note that when creating models and layers with
`),W=r(ie,"A",{href:!0,rel:!0});var ut=i(W);q=s(ut,"subclassing"),ut.forEach(t),Ne=s(ie,` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),ie.forEach(t),this.h()},h(){u(W,"href","https://keras.io/guides/making_new_layers_and_models_via_subclassing/"),u(W,"rel","nofollow")},m(b,j){g(b,d,j),e(d,y),e(d,f),e(f,m),e(d,T),g(b,l,j),g(b,h,j),e(h,F),e(F,R),e(h,N),e(h,J),e(J,O),g(b,re,j),g(b,E,j),e(E,Ge),e(E,S),e(S,fe),e(E,Se),e(E,Q),e(Q,le),e(E,pe),e(E,L),e(L,he),e(E,Fe),e(E,X),e(X,Ee),e(E,Me),e(E,H),e(H,je),e(E,ue),g(b,me,j),g(b,x,j),e(x,C),e(C,ze),e(C,oe),e(oe,$e),e(C,ge),e(C,ne),e(ne,Pe),e(x,_e),e(x,U),e(U,xe),e(U,Y),e(Y,Te),e(U,Ce),e(U,K),e(K,ee),e(x,ye),e(x,D),e(D,Ue),e(D,V),e(V,Je),g(b,de,j),g(b,I,j),e(I,Ie),e(I,W),e(W,q),e(I,Ne)},d(b){b&&t(d),b&&t(l),b&&t(h),b&&t(re),b&&t(E),b&&t(me),b&&t(x),b&&t(de),b&&t(I)}}}function _M(G){let d,y,f,m,T;return{c(){d=a("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),m=n("Module"),T=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){d=r(l,"P",{});var h=i(d);y=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var F=i(f);m=s(F,"Module"),F.forEach(t),T=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(l,h){g(l,d,h),e(d,y),e(d,f),e(f,m),e(d,T)},d(l){l&&t(d)}}}function TM(G){let d,y,f,m,T;return m=new Ve({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkdQVDJNb2RlbCUwQWltcG9ydCUyMHRlbnNvcmZsb3clMjBhcyUyMHRmJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMiklMEFtb2RlbCUyMCUzRCUyMFRGR1BUMk1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJncHQyJTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplciglMjJIZWxsbyUyQyUyMG15JTIwZG9nJTIwaXMlMjBjdXRlJTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJ0ZiUyMiklMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoaW5wdXRzKSUwQSUwQWxhc3RfaGlkZGVuX3N0YXRlcyUyMCUzRCUyMG91dHB1dHMubGFzdF9oaWRkZW5fc3RhdGU=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFGPT2Model
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFGPT2Model.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state`}}),{c(){d=a("p"),y=n("Example:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"Example:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function yM(G){let d,y,f,m,T,l,h,F,R,N,J,O,re,E,Ge,S,fe,Se,Q,le,pe,L,he,Fe,X,Ee,Me,H,je,ue,me,x,C,ze,oe,$e,ge,ne,Pe,_e,U,xe,Y,Te,Ce,K,ee,ye,D,Ue,V,Je,de,I,Ie,W,q,Ne;return{c(){d=a("p"),y=n("TensorFlow models and layers in "),f=a("code"),m=n("transformers"),T=n(" accept two formats as input:"),l=c(),h=a("ul"),F=a("li"),R=n("having all inputs as keyword arguments (like PyTorch models), or"),N=c(),J=a("li"),O=n("having all inputs as a list, tuple or dict in the first positional argument."),re=c(),E=a("p"),Ge=n(`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),S=a("code"),fe=n("model.fit()"),Se=n(` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),Q=a("code"),le=n("model.fit()"),pe=n(` supports! If, however, you want to use the second
format outside of Keras methods like `),L=a("code"),he=n("fit()"),Fe=n(" and "),X=a("code"),Ee=n("predict()"),Me=n(`, such as when creating your own layers or models with
the Keras `),H=a("code"),je=n("Functional"),ue=n(` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),me=c(),x=a("ul"),C=a("li"),ze=n("a single Tensor with "),oe=a("code"),$e=n("input_ids"),ge=n(" only and nothing else: "),ne=a("code"),Pe=n("model(input_ids)"),_e=c(),U=a("li"),xe=n(`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),Y=a("code"),Te=n("model([input_ids, attention_mask])"),Ce=n(" or "),K=a("code"),ee=n("model([input_ids, attention_mask, token_type_ids])"),ye=c(),D=a("li"),Ue=n(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),V=a("code"),Je=n('model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),de=c(),I=a("p"),Ie=n(`Note that when creating models and layers with
`),W=a("a"),q=n("subclassing"),Ne=n(` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),this.h()},l(b){d=r(b,"P",{});var j=i(d);y=s(j,"TensorFlow models and layers in "),f=r(j,"CODE",{});var nt=i(f);m=s(nt,"transformers"),nt.forEach(t),T=s(j," accept two formats as input:"),j.forEach(t),l=p(b),h=r(b,"UL",{});var ce=i(h);F=r(ce,"LI",{});var st=i(F);R=s(st,"having all inputs as keyword arguments (like PyTorch models), or"),st.forEach(t),N=p(ce),J=r(ce,"LI",{});var at=i(J);O=s(at,"having all inputs as a list, tuple or dict in the first positional argument."),at.forEach(t),ce.forEach(t),re=p(b),E=r(b,"P",{});var z=i(E);Ge=s(z,`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),S=r(z,"CODE",{});var rt=i(S);fe=s(rt,"model.fit()"),rt.forEach(t),Se=s(z,` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),Q=r(z,"CODE",{});var it=i(Q);le=s(it,"model.fit()"),it.forEach(t),pe=s(z,` supports! If, however, you want to use the second
format outside of Keras methods like `),L=r(z,"CODE",{});var Xe=i(L);he=s(Xe,"fit()"),Xe.forEach(t),Fe=s(z," and "),X=r(z,"CODE",{});var lt=i(X);Ee=s(lt,"predict()"),lt.forEach(t),Me=s(z,`, such as when creating your own layers or models with
the Keras `),H=r(z,"CODE",{});var dt=i(H);je=s(dt,"Functional"),dt.forEach(t),ue=s(z,` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),z.forEach(t),me=p(b),x=r(b,"UL",{});var Z=i(x);C=r(Z,"LI",{});var se=i(C);ze=s(se,"a single Tensor with "),oe=r(se,"CODE",{});var ct=i(oe);$e=s(ct,"input_ids"),ct.forEach(t),ge=s(se," only and nothing else: "),ne=r(se,"CODE",{});var Le=i(ne);Pe=s(Le,"model(input_ids)"),Le.forEach(t),se.forEach(t),_e=p(Z),U=r(Z,"LI",{});var ae=i(U);xe=s(ae,`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),Y=r(ae,"CODE",{});var pt=i(Y);Te=s(pt,"model([input_ids, attention_mask])"),pt.forEach(t),Ce=s(ae," or "),K=r(ae,"CODE",{});var Oe=i(K);ee=s(Oe,"model([input_ids, attention_mask, token_type_ids])"),Oe.forEach(t),ae.forEach(t),ye=p(Z),D=r(Z,"LI",{});var qe=i(D);Ue=s(qe,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),V=r(qe,"CODE",{});var ht=i(V);Je=s(ht,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),ht.forEach(t),qe.forEach(t),Z.forEach(t),de=p(b),I=r(b,"P",{});var ie=i(I);Ie=s(ie,`Note that when creating models and layers with
`),W=r(ie,"A",{href:!0,rel:!0});var ut=i(W);q=s(ut,"subclassing"),ut.forEach(t),Ne=s(ie,` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),ie.forEach(t),this.h()},h(){u(W,"href","https://keras.io/guides/making_new_layers_and_models_via_subclassing/"),u(W,"rel","nofollow")},m(b,j){g(b,d,j),e(d,y),e(d,f),e(f,m),e(d,T),g(b,l,j),g(b,h,j),e(h,F),e(F,R),e(h,N),e(h,J),e(J,O),g(b,re,j),g(b,E,j),e(E,Ge),e(E,S),e(S,fe),e(E,Se),e(E,Q),e(Q,le),e(E,pe),e(E,L),e(L,he),e(E,Fe),e(E,X),e(X,Ee),e(E,Me),e(E,H),e(H,je),e(E,ue),g(b,me,j),g(b,x,j),e(x,C),e(C,ze),e(C,oe),e(oe,$e),e(C,ge),e(C,ne),e(ne,Pe),e(x,_e),e(x,U),e(U,xe),e(U,Y),e(Y,Te),e(U,Ce),e(U,K),e(K,ee),e(x,ye),e(x,D),e(D,Ue),e(D,V),e(V,Je),g(b,de,j),g(b,I,j),e(I,Ie),e(I,W),e(W,q),e(I,Ne)},d(b){b&&t(d),b&&t(l),b&&t(h),b&&t(re),b&&t(E),b&&t(me),b&&t(x),b&&t(de),b&&t(I)}}}function bM(G){let d,y,f,m,T;return{c(){d=a("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),m=n("Module"),T=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){d=r(l,"P",{});var h=i(d);y=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var F=i(f);m=s(F,"Module"),F.forEach(t),T=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(l,h){g(l,d,h),e(d,y),e(d,f),e(f,m),e(d,T)},d(l){l&&t(d)}}}function vM(G){let d,y,f,m,T;return m=new Ve({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkdQVDJMTUhlYWRNb2RlbCUwQWltcG9ydCUyMHRlbnNvcmZsb3clMjBhcyUyMHRmJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMiklMEFtb2RlbCUyMCUzRCUyMFRGR1BUMkxNSGVhZE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJncHQyJTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplciglMjJIZWxsbyUyQyUyMG15JTIwZG9nJTIwaXMlMjBjdXRlJTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJ0ZiUyMiklMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoaW5wdXRzKSUwQWxvZ2l0cyUyMCUzRCUyMG91dHB1dHMubG9naXRz",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFGPT2LMHeadModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFGPT2LMHeadModel.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),{c(){d=a("p"),y=n("Example:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"Example:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function kM(G){let d,y,f,m,T,l,h,F,R,N,J,O,re,E,Ge,S,fe,Se,Q,le,pe,L,he,Fe,X,Ee,Me,H,je,ue,me,x,C,ze,oe,$e,ge,ne,Pe,_e,U,xe,Y,Te,Ce,K,ee,ye,D,Ue,V,Je,de,I,Ie,W,q,Ne;return{c(){d=a("p"),y=n("TensorFlow models and layers in "),f=a("code"),m=n("transformers"),T=n(" accept two formats as input:"),l=c(),h=a("ul"),F=a("li"),R=n("having all inputs as keyword arguments (like PyTorch models), or"),N=c(),J=a("li"),O=n("having all inputs as a list, tuple or dict in the first positional argument."),re=c(),E=a("p"),Ge=n(`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),S=a("code"),fe=n("model.fit()"),Se=n(` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),Q=a("code"),le=n("model.fit()"),pe=n(` supports! If, however, you want to use the second
format outside of Keras methods like `),L=a("code"),he=n("fit()"),Fe=n(" and "),X=a("code"),Ee=n("predict()"),Me=n(`, such as when creating your own layers or models with
the Keras `),H=a("code"),je=n("Functional"),ue=n(` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),me=c(),x=a("ul"),C=a("li"),ze=n("a single Tensor with "),oe=a("code"),$e=n("input_ids"),ge=n(" only and nothing else: "),ne=a("code"),Pe=n("model(input_ids)"),_e=c(),U=a("li"),xe=n(`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),Y=a("code"),Te=n("model([input_ids, attention_mask])"),Ce=n(" or "),K=a("code"),ee=n("model([input_ids, attention_mask, token_type_ids])"),ye=c(),D=a("li"),Ue=n(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),V=a("code"),Je=n('model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),de=c(),I=a("p"),Ie=n(`Note that when creating models and layers with
`),W=a("a"),q=n("subclassing"),Ne=n(` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),this.h()},l(b){d=r(b,"P",{});var j=i(d);y=s(j,"TensorFlow models and layers in "),f=r(j,"CODE",{});var nt=i(f);m=s(nt,"transformers"),nt.forEach(t),T=s(j," accept two formats as input:"),j.forEach(t),l=p(b),h=r(b,"UL",{});var ce=i(h);F=r(ce,"LI",{});var st=i(F);R=s(st,"having all inputs as keyword arguments (like PyTorch models), or"),st.forEach(t),N=p(ce),J=r(ce,"LI",{});var at=i(J);O=s(at,"having all inputs as a list, tuple or dict in the first positional argument."),at.forEach(t),ce.forEach(t),re=p(b),E=r(b,"P",{});var z=i(E);Ge=s(z,`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),S=r(z,"CODE",{});var rt=i(S);fe=s(rt,"model.fit()"),rt.forEach(t),Se=s(z,` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),Q=r(z,"CODE",{});var it=i(Q);le=s(it,"model.fit()"),it.forEach(t),pe=s(z,` supports! If, however, you want to use the second
format outside of Keras methods like `),L=r(z,"CODE",{});var Xe=i(L);he=s(Xe,"fit()"),Xe.forEach(t),Fe=s(z," and "),X=r(z,"CODE",{});var lt=i(X);Ee=s(lt,"predict()"),lt.forEach(t),Me=s(z,`, such as when creating your own layers or models with
the Keras `),H=r(z,"CODE",{});var dt=i(H);je=s(dt,"Functional"),dt.forEach(t),ue=s(z,` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),z.forEach(t),me=p(b),x=r(b,"UL",{});var Z=i(x);C=r(Z,"LI",{});var se=i(C);ze=s(se,"a single Tensor with "),oe=r(se,"CODE",{});var ct=i(oe);$e=s(ct,"input_ids"),ct.forEach(t),ge=s(se," only and nothing else: "),ne=r(se,"CODE",{});var Le=i(ne);Pe=s(Le,"model(input_ids)"),Le.forEach(t),se.forEach(t),_e=p(Z),U=r(Z,"LI",{});var ae=i(U);xe=s(ae,`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),Y=r(ae,"CODE",{});var pt=i(Y);Te=s(pt,"model([input_ids, attention_mask])"),pt.forEach(t),Ce=s(ae," or "),K=r(ae,"CODE",{});var Oe=i(K);ee=s(Oe,"model([input_ids, attention_mask, token_type_ids])"),Oe.forEach(t),ae.forEach(t),ye=p(Z),D=r(Z,"LI",{});var qe=i(D);Ue=s(qe,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),V=r(qe,"CODE",{});var ht=i(V);Je=s(ht,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),ht.forEach(t),qe.forEach(t),Z.forEach(t),de=p(b),I=r(b,"P",{});var ie=i(I);Ie=s(ie,`Note that when creating models and layers with
`),W=r(ie,"A",{href:!0,rel:!0});var ut=i(W);q=s(ut,"subclassing"),ut.forEach(t),Ne=s(ie,` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),ie.forEach(t),this.h()},h(){u(W,"href","https://keras.io/guides/making_new_layers_and_models_via_subclassing/"),u(W,"rel","nofollow")},m(b,j){g(b,d,j),e(d,y),e(d,f),e(f,m),e(d,T),g(b,l,j),g(b,h,j),e(h,F),e(F,R),e(h,N),e(h,J),e(J,O),g(b,re,j),g(b,E,j),e(E,Ge),e(E,S),e(S,fe),e(E,Se),e(E,Q),e(Q,le),e(E,pe),e(E,L),e(L,he),e(E,Fe),e(E,X),e(X,Ee),e(E,Me),e(E,H),e(H,je),e(E,ue),g(b,me,j),g(b,x,j),e(x,C),e(C,ze),e(C,oe),e(oe,$e),e(C,ge),e(C,ne),e(ne,Pe),e(x,_e),e(x,U),e(U,xe),e(U,Y),e(Y,Te),e(U,Ce),e(U,K),e(K,ee),e(x,ye),e(x,D),e(D,Ue),e(D,V),e(V,Je),g(b,de,j),g(b,I,j),e(I,Ie),e(I,W),e(W,q),e(I,Ne)},d(b){b&&t(d),b&&t(l),b&&t(h),b&&t(re),b&&t(E),b&&t(me),b&&t(x),b&&t(de),b&&t(I)}}}function wM(G){let d,y,f,m,T;return{c(){d=a("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),m=n("Module"),T=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){d=r(l,"P",{});var h=i(d);y=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var F=i(f);m=s(F,"Module"),F.forEach(t),T=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(l,h){g(l,d,h),e(d,y),e(d,f),e(f,m),e(d,T)},d(l){l&&t(d)}}}function MM(G){let d,y,f,m,T;return m=new Ve({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMFRGR1BUMkRvdWJsZUhlYWRzTW9kZWwlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJncHQyJTIyKSUwQW1vZGVsJTIwJTNEJTIwVEZHUFQyRG91YmxlSGVhZHNNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMiklMEElMEElMjMlMjBBZGQlMjBhJTIwJTVCQ0xTJTVEJTIwdG8lMjB0aGUlMjB2b2NhYnVsYXJ5JTIwKHdlJTIwc2hvdWxkJTIwdHJhaW4lMjBpdCUyMGFsc28hKSUwQW51bV9hZGRlZF90b2tlbnMlMjAlM0QlMjB0b2tlbml6ZXIuYWRkX3NwZWNpYWxfdG9rZW5zKCU3QiUyMmNsc190b2tlbiUyMiUzQSUyMCUyMiU1QkNMUyU1RCUyMiU3RCklMEElMEFlbWJlZGRpbmdfbGF5ZXIlMjAlM0QlMjBtb2RlbC5yZXNpemVfdG9rZW5fZW1iZWRkaW5ncyglMEElMjAlMjAlMjAlMjBsZW4odG9rZW5pemVyKSUwQSklMjAlMjAlMjMlMjBVcGRhdGUlMjB0aGUlMjBtb2RlbCUyMGVtYmVkZGluZ3MlMjB3aXRoJTIwdGhlJTIwbmV3JTIwdm9jYWJ1bGFyeSUyMHNpemUlMEElMEFjaG9pY2VzJTIwJTNEJTIwJTVCJTIySGVsbG8lMkMlMjBteSUyMGRvZyUyMGlzJTIwY3V0ZSUyMCU1QkNMUyU1RCUyMiUyQyUyMCUyMkhlbGxvJTJDJTIwbXklMjBjYXQlMjBpcyUyMGN1dGUlMjAlNUJDTFMlNUQlMjIlNUQlMEFlbmNvZGVkX2Nob2ljZXMlMjAlM0QlMjAlNUJ0b2tlbml6ZXIuZW5jb2RlKHMpJTIwZm9yJTIwcyUyMGluJTIwY2hvaWNlcyU1RCUwQWNsc190b2tlbl9sb2NhdGlvbiUyMCUzRCUyMCU1QnRva2Vucy5pbmRleCh0b2tlbml6ZXIuY2xzX3Rva2VuX2lkKSUyMGZvciUyMHRva2VucyUyMGluJTIwZW5jb2RlZF9jaG9pY2VzJTVEJTBBJTBBaW5wdXRfaWRzJTIwJTNEJTIwdGYuY29uc3RhbnQoZW5jb2RlZF9jaG9pY2VzKSU1Qk5vbmUlMkMlMjAlM0ElNUQlMjAlMjAlMjMlMjBCYXRjaCUyMHNpemUlM0ElMjAxJTJDJTIwbnVtYmVyJTIwb2YlMjBjaG9pY2VzJTNBJTIwMiUwQW1jX3Rva2VuX2lkcyUyMCUzRCUyMHRmLmNvbnN0YW50KCU1QmNsc190b2tlbl9sb2NhdGlvbiU1RCklMjAlMjAlMjMlMjBCYXRjaCUyMHNpemUlM0ElMjAxJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKGlucHV0X2lkcyUyQyUyMG1jX3Rva2VuX2lkcyUzRG1jX3Rva2VuX2lkcyklMEFsbV9wcmVkaWN0aW9uX3Njb3JlcyUyQyUyMG1jX3ByZWRpY3Rpb25fc2NvcmVzJTIwJTNEJTIwb3V0cHV0cyU1QiUzQTIlNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFGPT2DoubleHeadsModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFGPT2DoubleHeadsModel.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Add a [CLS] to the vocabulary (we should train it also!)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_added_tokens = tokenizer.add_special_tokens({<span class="hljs-string">&quot;cls_token&quot;</span>: <span class="hljs-string">&quot;[CLS]&quot;</span>})

<span class="hljs-meta">&gt;&gt;&gt; </span>embedding_layer = model.resize_token_embeddings(
<span class="hljs-meta">... </span>    <span class="hljs-built_in">len</span>(tokenizer)
<span class="hljs-meta">... </span>)  <span class="hljs-comment"># Update the model embeddings with the new vocabulary size</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>choices = [<span class="hljs-string">&quot;Hello, my dog is cute [CLS]&quot;</span>, <span class="hljs-string">&quot;Hello, my cat is cute [CLS]&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>encoded_choices = [tokenizer.encode(s) <span class="hljs-keyword">for</span> s <span class="hljs-keyword">in</span> choices]
<span class="hljs-meta">&gt;&gt;&gt; </span>cls_token_location = [tokens.index(tokenizer.cls_token_id) <span class="hljs-keyword">for</span> tokens <span class="hljs-keyword">in</span> encoded_choices]

<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tf.constant(encoded_choices)[<span class="hljs-literal">None</span>, :]  <span class="hljs-comment"># Batch size: 1, number of choices: 2</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>mc_token_ids = tf.constant([cls_token_location])  <span class="hljs-comment"># Batch size: 1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(input_ids, mc_token_ids=mc_token_ids)
<span class="hljs-meta">&gt;&gt;&gt; </span>lm_prediction_scores, mc_prediction_scores = outputs[:<span class="hljs-number">2</span>]`}}),{c(){d=a("p"),y=n("Examples:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"Examples:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function $M(G){let d,y,f,m,T,l,h,F,R,N,J,O,re,E,Ge,S,fe,Se,Q,le,pe,L,he,Fe,X,Ee,Me,H,je,ue,me,x,C,ze,oe,$e,ge,ne,Pe,_e,U,xe,Y,Te,Ce,K,ee,ye,D,Ue,V,Je,de,I,Ie,W,q,Ne;return{c(){d=a("p"),y=n("TensorFlow models and layers in "),f=a("code"),m=n("transformers"),T=n(" accept two formats as input:"),l=c(),h=a("ul"),F=a("li"),R=n("having all inputs as keyword arguments (like PyTorch models), or"),N=c(),J=a("li"),O=n("having all inputs as a list, tuple or dict in the first positional argument."),re=c(),E=a("p"),Ge=n(`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),S=a("code"),fe=n("model.fit()"),Se=n(` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),Q=a("code"),le=n("model.fit()"),pe=n(` supports! If, however, you want to use the second
format outside of Keras methods like `),L=a("code"),he=n("fit()"),Fe=n(" and "),X=a("code"),Ee=n("predict()"),Me=n(`, such as when creating your own layers or models with
the Keras `),H=a("code"),je=n("Functional"),ue=n(` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),me=c(),x=a("ul"),C=a("li"),ze=n("a single Tensor with "),oe=a("code"),$e=n("input_ids"),ge=n(" only and nothing else: "),ne=a("code"),Pe=n("model(input_ids)"),_e=c(),U=a("li"),xe=n(`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),Y=a("code"),Te=n("model([input_ids, attention_mask])"),Ce=n(" or "),K=a("code"),ee=n("model([input_ids, attention_mask, token_type_ids])"),ye=c(),D=a("li"),Ue=n(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),V=a("code"),Je=n('model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),de=c(),I=a("p"),Ie=n(`Note that when creating models and layers with
`),W=a("a"),q=n("subclassing"),Ne=n(` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),this.h()},l(b){d=r(b,"P",{});var j=i(d);y=s(j,"TensorFlow models and layers in "),f=r(j,"CODE",{});var nt=i(f);m=s(nt,"transformers"),nt.forEach(t),T=s(j," accept two formats as input:"),j.forEach(t),l=p(b),h=r(b,"UL",{});var ce=i(h);F=r(ce,"LI",{});var st=i(F);R=s(st,"having all inputs as keyword arguments (like PyTorch models), or"),st.forEach(t),N=p(ce),J=r(ce,"LI",{});var at=i(J);O=s(at,"having all inputs as a list, tuple or dict in the first positional argument."),at.forEach(t),ce.forEach(t),re=p(b),E=r(b,"P",{});var z=i(E);Ge=s(z,`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like `),S=r(z,"CODE",{});var rt=i(S);fe=s(rt,"model.fit()"),rt.forEach(t),Se=s(z,` things should \u201Cjust work\u201D for you - just
pass your inputs and labels in any format that `),Q=r(z,"CODE",{});var it=i(Q);le=s(it,"model.fit()"),it.forEach(t),pe=s(z,` supports! If, however, you want to use the second
format outside of Keras methods like `),L=r(z,"CODE",{});var Xe=i(L);he=s(Xe,"fit()"),Xe.forEach(t),Fe=s(z," and "),X=r(z,"CODE",{});var lt=i(X);Ee=s(lt,"predict()"),lt.forEach(t),Me=s(z,`, such as when creating your own layers or models with
the Keras `),H=r(z,"CODE",{});var dt=i(H);je=s(dt,"Functional"),dt.forEach(t),ue=s(z,` API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`),z.forEach(t),me=p(b),x=r(b,"UL",{});var Z=i(x);C=r(Z,"LI",{});var se=i(C);ze=s(se,"a single Tensor with "),oe=r(se,"CODE",{});var ct=i(oe);$e=s(ct,"input_ids"),ct.forEach(t),ge=s(se," only and nothing else: "),ne=r(se,"CODE",{});var Le=i(ne);Pe=s(Le,"model(input_ids)"),Le.forEach(t),se.forEach(t),_e=p(Z),U=r(Z,"LI",{});var ae=i(U);xe=s(ae,`a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`),Y=r(ae,"CODE",{});var pt=i(Y);Te=s(pt,"model([input_ids, attention_mask])"),pt.forEach(t),Ce=s(ae," or "),K=r(ae,"CODE",{});var Oe=i(K);ee=s(Oe,"model([input_ids, attention_mask, token_type_ids])"),Oe.forEach(t),ae.forEach(t),ye=p(Z),D=r(Z,"LI",{});var qe=i(D);Ue=s(qe,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),V=r(qe,"CODE",{});var ht=i(V);Je=s(ht,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),ht.forEach(t),qe.forEach(t),Z.forEach(t),de=p(b),I=r(b,"P",{});var ie=i(I);Ie=s(ie,`Note that when creating models and layers with
`),W=r(ie,"A",{href:!0,rel:!0});var ut=i(W);q=s(ut,"subclassing"),ut.forEach(t),Ne=s(ie,` then you don\u2019t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`),ie.forEach(t),this.h()},h(){u(W,"href","https://keras.io/guides/making_new_layers_and_models_via_subclassing/"),u(W,"rel","nofollow")},m(b,j){g(b,d,j),e(d,y),e(d,f),e(f,m),e(d,T),g(b,l,j),g(b,h,j),e(h,F),e(F,R),e(h,N),e(h,J),e(J,O),g(b,re,j),g(b,E,j),e(E,Ge),e(E,S),e(S,fe),e(E,Se),e(E,Q),e(Q,le),e(E,pe),e(E,L),e(L,he),e(E,Fe),e(E,X),e(X,Ee),e(E,Me),e(E,H),e(H,je),e(E,ue),g(b,me,j),g(b,x,j),e(x,C),e(C,ze),e(C,oe),e(oe,$e),e(C,ge),e(C,ne),e(ne,Pe),e(x,_e),e(x,U),e(U,xe),e(U,Y),e(Y,Te),e(U,Ce),e(U,K),e(K,ee),e(x,ye),e(x,D),e(D,Ue),e(D,V),e(V,Je),g(b,de,j),g(b,I,j),e(I,Ie),e(I,W),e(W,q),e(I,Ne)},d(b){b&&t(d),b&&t(l),b&&t(h),b&&t(re),b&&t(E),b&&t(me),b&&t(x),b&&t(de),b&&t(I)}}}function PM(G){let d,y,f,m,T;return{c(){d=a("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),m=n("Module"),T=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){d=r(l,"P",{});var h=i(d);y=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var F=i(f);m=s(F,"Module"),F.forEach(t),T=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(l,h){g(l,d,h),e(d,y),e(d,f),e(f,m),e(d,T)},d(l){l&&t(d)}}}function GM(G){let d,y,f,m,T;return m=new Ve({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkdQVDJGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uJTBBaW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZEaWFsb2dSUFQtdXBkb3duJTIyKSUwQW1vZGVsJTIwJTNEJTIwVEZHUFQyRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGRGlhbG9nUlBULXVwZG93biUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIySGVsbG8lMkMlMjBteSUyMGRvZyUyMGlzJTIwY3V0ZSUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIpJTBBJTBBbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cyUwQSUwQXByZWRpY3RlZF9jbGFzc19pZCUyMCUzRCUyMGludCh0Zi5tYXRoLmFyZ21heChsb2dpdHMlMkMlMjBheGlzJTNELTEpJTVCMCU1RCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFGPT2ForSequenceClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;microsoft/DialogRPT-updown&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFGPT2ForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/DialogRPT-updown&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>logits = model(**inputs).logits

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_class_id = <span class="hljs-built_in">int</span>(tf.math.argmax(logits, axis=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>])`}}),{c(){d=a("p"),y=n("Example:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"Example:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function FM(G){let d,y;return d=new Ve({props:{code:"JTIzJTIwVG8lMjB0cmFpbiUyMGElMjBtb2RlbCUyMG9uJTIwJTYwbnVtX2xhYmVscyU2MCUyMGNsYXNzZXMlMkMlMjB5b3UlMjBjYW4lMjBwYXNzJTIwJTYwbnVtX2xhYmVscyUzRG51bV9sYWJlbHMlNjAlMjB0byUyMCU2MC5mcm9tX3ByZXRyYWluZWQoLi4uKSU2MCUwQW51bV9sYWJlbHMlMjAlM0QlMjBsZW4obW9kZWwuY29uZmlnLmlkMmxhYmVsKSUwQW1vZGVsJTIwJTNEJTIwVEZHUFQyRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGRGlhbG9nUlBULXVwZG93biUyMiUyQyUyMG51bV9sYWJlbHMlM0RudW1fbGFiZWxzKSUwQSUwQWxhYmVscyUyMCUzRCUyMHRmLmNvbnN0YW50KDEpJTBBbG9zcyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzJTJDJTIwbGFiZWxzJTNEbGFiZWxzKS5sb3Nz",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># To train a model on `num_labels` classes, you can pass `num_labels=num_labels` to `.from_pretrained(...)`</span>\n<span class="hljs-meta">&gt;&gt;&gt; </span>num_labels = <span class="hljs-built_in">len</span>(model.config.id2label)\n<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFGPT2ForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/DialogRPT-updown&quot;</span>, num_labels=num_labels)\n\n<span class="hljs-meta">&gt;&gt;&gt; </span>labels = tf.constant(<span class="hljs-number">1</span>)\n<span class="hljs-meta">&gt;&gt;&gt; </span>loss = model(**inputs, labels=labels).loss'}}),{c(){v(d.$$.fragment)},l(f){k(d.$$.fragment,f)},m(f,m){w(d,f,m),y=!0},p:De,i(f){y||(M(d.$$.fragment,f),y=!0)},o(f){$(d.$$.fragment,f),y=!1},d(f){P(d,f)}}}function EM(G){let d,y,f,m,T;return m=new Ve({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGR1BUMlRva2VuaXplciUwQSUwQXRmX3Rva2VuaXplciUyMCUzRCUyMFRGR1BUMlRva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFGPT2Tokenizer

tf_tokenizer = TFGPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)`}}),{c(){d=a("p"),y=n("Examples:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"Examples:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function jM(G){let d,y,f,m,T;return m=new Ve({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkdQVDJUb2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJncHQyJTIyKSUwQXRmX3Rva2VuaXplciUyMCUzRCUyMFRGR1BUMlRva2VuaXplci5mcm9tX3Rva2VuaXplcih0b2tlbml6ZXIp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFGPT2Tokenizer

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
tf_tokenizer = TFGPT2Tokenizer.from_tokenizer(tokenizer)`}}),{c(){d=a("p"),y=n("Examples:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"Examples:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function zM(G){let d,y,f,m,T;return{c(){d=a("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),m=n("Module"),T=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){d=r(l,"P",{});var h=i(d);y=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var F=i(f);m=s(F,"Module"),F.forEach(t),T=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(l,h){g(l,d,h),e(d,y),e(d,f),e(f,m),e(d,T)},d(l){l&&t(d)}}}function xM(G){let d,y,f,m,T;return m=new Ve({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBGbGF4R1BUMk1vZGVsJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMiklMEFtb2RlbCUyMCUzRCUyMEZsYXhHUFQyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmdwdDIlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMkhlbGxvJTJDJTIwbXklMjBkb2clMjBpcyUyMGN1dGUlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMmpheCUyMiklMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpJTBBJTBBbGFzdF9oaWRkZW5fc3RhdGVzJTIwJTNEJTIwb3V0cHV0cy5sYXN0X2hpZGRlbl9zdGF0ZQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, FlaxGPT2Model

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxGPT2Model.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;jax&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state`}}),{c(){d=a("p"),y=n("Example:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"Example:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function CM(G){let d,y,f,m,T;return{c(){d=a("p"),y=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),m=n("Module"),T=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){d=r(l,"P",{});var h=i(d);y=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var F=i(f);m=s(F,"Module"),F.forEach(t),T=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(l,h){g(l,d,h),e(d,y),e(d,f),e(f,m),e(d,T)},d(l){l&&t(d)}}}function UM(G){let d,y,f,m,T;return m=new Ve({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBGbGF4R1BUMkxNSGVhZE1vZGVsJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMiklMEFtb2RlbCUyMCUzRCUyMEZsYXhHUFQyTE1IZWFkTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmdwdDIlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMkhlbGxvJTJDJTIwbXklMjBkb2clMjBpcyUyMGN1dGUlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMm5wJTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyklMEElMEElMjMlMjByZXRyaWV2ZSUyMGxvZ3RzJTIwZm9yJTIwbmV4dCUyMHRva2VuJTBBbmV4dF90b2tlbl9sb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cyU1QiUzQSUyQyUyMC0xJTVE",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, FlaxGPT2LMHeadModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxGPT2LMHeadModel.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;np&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># retrieve logts for next token</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>next_token_logits = outputs.logits[:, -<span class="hljs-number">1</span>]`}}),{c(){d=a("p"),y=n("Example:"),f=c(),v(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);y=s(h,"Example:"),h.forEach(t),f=p(l),k(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,y),g(l,f,h),w(m,l,h),T=!0},p:De,i(l){T||(M(m.$$.fragment,l),T=!0)},o(l){$(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),P(m,l)}}}function JM(G){let d,y,f,m,T,l,h,F,R,N,J,O,re,E,Ge,S,fe,Se,Q,le,pe,L,he,Fe,X,Ee,Me,H,je,ue,me,x,C,ze,oe,$e,ge,ne,Pe,_e,U,xe,Y,Te,Ce,K,ee,ye,D,Ue,V,Je,de,I,Ie,W,q,Ne,b,j,nt,ce,st,at,z,rt,it,Xe,lt,dt,Z,se,ct,Le,ae,pt,Oe,qe,ht,ie,ut,Th,yh,Bt,bh,Qi,vh,kh,Yi,wh,Mh,gs,$h,Ph,kc,po,_s,Gh,Fh,Ki,Eh,jh,wc,Xt,zh,Ts,xh,Ch,ys,Uh,Jh,Mc,ho,Qo,el,bs,Ih,tl,Nh,$c,Vr,qh,Pc,vs,Gc,B,ks,Wh,ws,Ah,Hh,Zh,Ms,Bh,$s,Rh,Dh,Vh,Ps,Sh,Gs,Lh,Xh,Oh,Fs,Qh,Es,Yh,Kh,eu,js,tu,zs,ou,nu,su,xs,au,Cs,ru,iu,lu,Us,du,Js,cu,pu,hu,Sr,Is,uu,mu,fu,Et,Lr,gu,_u,Ns,Tu,yu,qs,bu,vu,Ws,ku,wu,Mu,Ot,Xr,$u,Pu,As,Gu,Fu,Hs,Eu,ju,zu,Qt,Or,xu,Cu,Zs,Uu,Ju,Bs,Iu,Nu,qu,ol,Qr,Wu,Au,nl,Yr,Hu,Zu,sl,Kr,Bu,Fc,uo,Yo,al,Rs,Ru,rl,Du,Ec,Pt,Ds,Vu,Rt,Su,ei,Lu,Xu,ti,Ou,Qu,Vs,Yu,Ku,em,mo,tm,oi,om,nm,ni,sm,am,rm,Ko,jc,fo,en,il,Ss,im,ll,lm,zc,be,Ls,dm,dl,cm,pm,cl,hm,um,tn,mm,Xs,fm,pl,gm,_m,Tm,on,ym,Os,bm,si,vm,km,wm,ai,Qs,xc,go,nn,hl,Ys,Mm,ul,$m,Cc,We,Ks,Pm,ea,Gm,ml,Fm,Em,jm,fl,zm,xm,sn,Cm,ta,Um,gl,Jm,Im,Nm,an,qm,oa,Wm,ri,Am,Hm,Uc,_o,rn,_l,na,Zm,Tl,Bm,Jc,To,sa,Rm,yl,Dm,Ic,yo,aa,Vm,bl,Sm,Nc,bo,ln,vl,ra,Lm,kl,Xm,qc,mt,ia,Om,wl,Qm,Ym,la,Km,ii,ef,tf,of,da,nf,ca,sf,af,rf,jt,pa,lf,vo,df,li,cf,pf,Ml,hf,uf,mf,dn,ff,cn,Wc,ko,pn,$l,ha,gf,Pl,_f,Ac,ft,ua,Tf,Gl,yf,bf,ma,vf,di,kf,wf,Mf,fa,$f,ga,Pf,Gf,Ff,zt,_a,Ef,wo,jf,ci,zf,xf,Fl,Cf,Uf,Jf,hn,If,un,Hc,Mo,mn,El,Ta,Nf,jl,qf,Zc,gt,ya,Wf,zl,Af,Hf,ba,Zf,pi,Bf,Rf,Df,va,Vf,ka,Sf,Lf,Xf,xt,wa,Of,$o,Qf,hi,Yf,Kf,xl,eg,tg,og,fn,ng,gn,Bc,Po,_n,Cl,Ma,sg,Ul,ag,Rc,_t,$a,rg,Go,ig,Jl,lg,dg,Il,cg,pg,hg,Pa,ug,ui,mg,fg,gg,Ga,_g,Fa,Tg,yg,bg,yt,Ea,vg,Fo,kg,mi,wg,Mg,Nl,$g,Pg,Gg,Tn,Fg,yn,Eg,bn,Dc,Eo,vn,ql,ja,jg,Wl,zg,Vc,Ae,za,xg,Al,Cg,Ug,fi,gi,Jg,Ig,Ng,Gt,qg,Hl,Wg,Ag,Zl,Hg,Zg,Bl,Bg,Rg,Rl,Dg,Vg,Sg,xa,Lg,_i,Xg,Og,Qg,Ca,Yg,Ua,Kg,e_,t_,bt,Ja,o_,jo,n_,Ti,s_,a_,Dl,r_,i_,l_,kn,d_,wn,c_,Mn,Sc,zo,$n,Vl,Ia,p_,Sl,h_,Lc,Tt,Na,u_,Ll,m_,f_,qa,g_,yi,__,T_,y_,Wa,b_,Aa,v_,k_,w_,Ct,Ha,M_,xo,$_,bi,P_,G_,Xl,F_,E_,j_,Pn,z_,Gn,Xc,Co,Fn,Ol,Za,x_,Ql,C_,Oc,Qe,Ba,U_,Yl,J_,I_,Ra,N_,vi,q_,W_,A_,Da,H_,Va,Z_,B_,R_,En,D_,Ut,Sa,V_,Uo,S_,ki,L_,X_,Kl,O_,Q_,Y_,jn,K_,zn,Qc,Jo,xn,ed,La,eT,td,tT,Yc,Ye,Xa,oT,od,nT,sT,Oa,aT,wi,rT,iT,lT,Qa,dT,Ya,cT,pT,hT,Cn,uT,Jt,Ka,mT,Io,fT,Mi,gT,_T,nd,TT,yT,bT,Un,vT,Jn,Kc,No,In,sd,er,kT,ad,wT,ep,Ke,tr,MT,rd,$T,PT,or,GT,$i,FT,ET,jT,nr,zT,sr,xT,CT,UT,Nn,JT,It,ar,IT,qo,NT,Pi,qT,WT,id,AT,HT,ZT,qn,BT,Wn,tp,Wo,An,ld,rr,RT,dd,DT,op,ve,ir,VT,cd,ST,LT,Gi,Fi,XT,OT,QT,Ft,YT,pd,KT,ey,hd,ty,oy,ud,ny,sy,md,ay,ry,iy,lr,ly,Ei,dy,cy,py,dr,hy,cr,uy,my,fy,Hn,gy,vt,pr,_y,Ao,Ty,ji,yy,by,fd,vy,ky,wy,Zn,My,Bn,$y,Rn,np,Ho,Dn,gd,hr,Py,_d,Gy,sp,Zo,ur,Fy,Td,Ey,ap,Bo,Vn,yd,mr,jy,bd,zy,rp,et,fr,xy,Ro,Cy,vd,Uy,Jy,kd,Iy,Ny,qy,gr,Wy,wd,Ay,Hy,Zy,Sn,_r,By,Md,Ry,Dy,Yt,Tr,Vy,$d,Sy,Ly,Ln,Xy,Kt,yr,Oy,Pd,Qy,Yy,Xn,ip,Do,On,Gd,br,Ky,Fd,eb,lp,He,vr,tb,Ed,ob,nb,kr,sb,zi,ab,rb,ib,wr,lb,Mr,db,cb,pb,jd,hb,ub,Dt,zd,$r,mb,fb,xd,Pr,gb,_b,Cd,Gr,Tb,yb,Ud,Fr,bb,vb,Nt,Er,kb,Vo,wb,Jd,Mb,$b,Id,Pb,Gb,Fb,Qn,Eb,Yn,dp,So,Kn,Nd,jr,jb,qd,zb,cp,Ze,zr,xb,Wd,Cb,Ub,xr,Jb,xi,Ib,Nb,qb,Cr,Wb,Ur,Ab,Hb,Zb,Ad,Bb,Rb,Vt,Hd,Jr,Db,Vb,Zd,Ir,Sb,Lb,Bd,Nr,Xb,Ob,Rd,qr,Qb,Yb,qt,Wr,Kb,Lo,e2,Dd,t2,o2,Vd,n2,s2,a2,es,r2,ts,pp;return l=new we({}),he=new we({}),bs=new we({}),vs=new Ow({props:{pipeline:"text-generation"}}),Rs=new we({}),Ds=new A({props:{name:"class transformers.GPT2Config",anchor:"transformers.GPT2Config",parameters:[{name:"vocab_size",val:" = 50257"},{name:"n_positions",val:" = 1024"},{name:"n_embd",val:" = 768"},{name:"n_layer",val:" = 12"},{name:"n_head",val:" = 12"},{name:"n_inner",val:" = None"},{name:"activation_function",val:" = 'gelu_new'"},{name:"resid_pdrop",val:" = 0.1"},{name:"embd_pdrop",val:" = 0.1"},{name:"attn_pdrop",val:" = 0.1"},{name:"layer_norm_epsilon",val:" = 1e-05"},{name:"initializer_range",val:" = 0.02"},{name:"summary_type",val:" = 'cls_index'"},{name:"summary_use_proj",val:" = True"},{name:"summary_activation",val:" = None"},{name:"summary_proj_to_labels",val:" = True"},{name:"summary_first_dropout",val:" = 0.1"},{name:"scale_attn_weights",val:" = True"},{name:"use_cache",val:" = True"},{name:"bos_token_id",val:" = 50256"},{name:"eos_token_id",val:" = 50256"},{name:"scale_attn_by_inverse_layer_idx",val:" = False"},{name:"reorder_and_upcast_attn",val:" = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.GPT2Config.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 50257) &#x2014;
Vocabulary size of the GPT-2 model. Defines the number of different tokens that can be represented by the
<code>inputs_ids</code> passed when calling <a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2Model">GPT2Model</a> or <a href="/docs/transformers/main/en/model_doc/gpt2#transformers.TFGPT2Model">TFGPT2Model</a>.`,name:"vocab_size"},{anchor:"transformers.GPT2Config.n_positions",description:`<strong>n_positions</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
The maximum sequence length that this model might ever be used with. Typically set this to something large
just in case (e.g., 512 or 1024 or 2048).`,name:"n_positions"},{anchor:"transformers.GPT2Config.n_embd",description:`<strong>n_embd</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimensionality of the embeddings and hidden states.`,name:"n_embd"},{anchor:"transformers.GPT2Config.n_layer",description:`<strong>n_layer</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"n_layer"},{anchor:"transformers.GPT2Config.n_head",description:`<strong>n_head</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"n_head"},{anchor:"transformers.GPT2Config.n_inner",description:`<strong>n_inner</strong> (<code>int</code>, <em>optional</em>, defaults to None) &#x2014;
Dimensionality of the inner feed-forward layers. <code>None</code> will set it to 4 times n_embd`,name:"n_inner"},{anchor:"transformers.GPT2Config.activation_function",description:`<strong>activation_function</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
Activation function, to be selected in the list <code>[&quot;relu&quot;, &quot;silu&quot;, &quot;gelu&quot;, &quot;tanh&quot;, &quot;gelu_new&quot;]</code>.`,name:"activation_function"},{anchor:"transformers.GPT2Config.resid_pdrop",description:`<strong>resid_pdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.`,name:"resid_pdrop"},{anchor:"transformers.GPT2Config.embd_pdrop",description:`<strong>embd_pdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout ratio for the embeddings.`,name:"embd_pdrop"},{anchor:"transformers.GPT2Config.attn_pdrop",description:`<strong>attn_pdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout ratio for the attention.`,name:"attn_pdrop"},{anchor:"transformers.GPT2Config.layer_norm_epsilon",description:`<strong>layer_norm_epsilon</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-5) &#x2014;
The epsilon to use in the layer normalization layers.`,name:"layer_norm_epsilon"},{anchor:"transformers.GPT2Config.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.GPT2Config.summary_type",description:`<strong>summary_type</strong> (<code>string</code>, <em>optional</em>, defaults to <code>&quot;cls_index&quot;</code>) &#x2014;
Argument used when doing sequence summary, used in the models <a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a> and
<a href="/docs/transformers/main/en/model_doc/gpt2#transformers.TFGPT2DoubleHeadsModel">TFGPT2DoubleHeadsModel</a>.</p>
<p>Has to be one of the following options:</p>
<ul>
<li><code>&quot;last&quot;</code>: Take the last token hidden state (like XLNet).</li>
<li><code>&quot;first&quot;</code>: Take the first token hidden state (like BERT).</li>
<li><code>&quot;mean&quot;</code>: Take the mean of all tokens hidden states.</li>
<li><code>&quot;cls_index&quot;</code>: Supply a Tensor of classification token position (like GPT/GPT-2).</li>
<li><code>&quot;attn&quot;</code>: Not implemented now, use multi-head attention.</li>
</ul>`,name:"summary_type"},{anchor:"transformers.GPT2Config.summary_use_proj",description:`<strong>summary_use_proj</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Argument used when doing sequence summary, used in the models <a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a> and
<a href="/docs/transformers/main/en/model_doc/gpt2#transformers.TFGPT2DoubleHeadsModel">TFGPT2DoubleHeadsModel</a>.</p>
<p>Whether or not to add a projection after the vector extraction.`,name:"summary_use_proj"},{anchor:"transformers.GPT2Config.summary_activation",description:`<strong>summary_activation</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Argument used when doing sequence summary. Used in for the multiple choice head in
<a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a>.</p>
<p>Pass <code>&quot;tanh&quot;</code> for a tanh activation to the output, any other value will result in no activation.`,name:"summary_activation"},{anchor:"transformers.GPT2Config.summary_proj_to_labels",description:`<strong>summary_proj_to_labels</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Argument used when doing sequence summary, used in the models <a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a> and
<a href="/docs/transformers/main/en/model_doc/gpt2#transformers.TFGPT2DoubleHeadsModel">TFGPT2DoubleHeadsModel</a>.</p>
<p>Whether the projection outputs should have <code>config.num_labels</code> or <code>config.hidden_size</code> classes.`,name:"summary_proj_to_labels"},{anchor:"transformers.GPT2Config.summary_first_dropout",description:`<strong>summary_first_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
Argument used when doing sequence summary, used in the models <a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a> and
<a href="/docs/transformers/main/en/model_doc/gpt2#transformers.TFGPT2DoubleHeadsModel">TFGPT2DoubleHeadsModel</a>.</p>
<p>The dropout ratio to be used after the projection and activation.`,name:"summary_first_dropout"},{anchor:"transformers.GPT2Config.scale_attn_weights",description:`<strong>scale_attn_weights</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Scale attention weights by dividing by sqrt(hidden_size)..`,name:"scale_attn_weights"},{anchor:"transformers.GPT2Config.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the model should return the last key/values attentions (not used by all models).`,name:"use_cache"},{anchor:"transformers.GPT2Config.scale_attn_by_inverse_layer_idx",description:`<strong>scale_attn_by_inverse_layer_idx</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to additionally scale attention weights by <code>1 / layer_idx + 1</code>.`,name:"scale_attn_by_inverse_layer_idx"},{anchor:"transformers.GPT2Config.reorder_and_upcast_attn",description:`<strong>reorder_and_upcast_attn</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to scale keys (K) prior to computing attention (dot-product) and upcast attention
dot-product/softmax to float() when training with mixed precision.`,name:"reorder_and_upcast_attn"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/configuration_gpt2.py#L37"}}),Ko=new Re({props:{anchor:"transformers.GPT2Config.example",$$slots:{default:[Qw]},$$scope:{ctx:G}}}),Ss=new we({}),Ls=new A({props:{name:"class transformers.GPT2Tokenizer",anchor:"transformers.GPT2Tokenizer",parameters:[{name:"vocab_file",val:""},{name:"merges_file",val:""},{name:"errors",val:" = 'replace'"},{name:"unk_token",val:" = '<|endoftext|>'"},{name:"bos_token",val:" = '<|endoftext|>'"},{name:"eos_token",val:" = '<|endoftext|>'"},{name:"pad_token",val:" = None"},{name:"add_prefix_space",val:" = False"},{name:"add_bos_token",val:" = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.GPT2Tokenizer.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>) &#x2014;
Path to the vocabulary file.`,name:"vocab_file"},{anchor:"transformers.GPT2Tokenizer.merges_file",description:`<strong>merges_file</strong> (<code>str</code>) &#x2014;
Path to the merges file.`,name:"merges_file"},{anchor:"transformers.GPT2Tokenizer.errors",description:`<strong>errors</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;replace&quot;</code>) &#x2014;
Paradigm to follow when decoding bytes to UTF-8. See
<a href="https://docs.python.org/3/library/stdtypes.html#bytes.decode" rel="nofollow">bytes.decode</a> for more information.`,name:"errors"},{anchor:"transformers.GPT2Tokenizer.unk_token",description:`<strong>unk_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&lt;|endoftext|&gt;</code>) &#x2014;
The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
token instead.`,name:"unk_token"},{anchor:"transformers.GPT2Tokenizer.bos_token",description:`<strong>bos_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&lt;|endoftext|&gt;</code>) &#x2014;
The beginning of sequence token.`,name:"bos_token"},{anchor:"transformers.GPT2Tokenizer.eos_token",description:`<strong>eos_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&lt;|endoftext|&gt;</code>) &#x2014;
The end of sequence token.`,name:"eos_token"},{anchor:"transformers.GPT2Tokenizer.add_prefix_space",description:`<strong>add_prefix_space</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to add an initial space to the input. This allows to treat the leading word just as any
other word. (GPT2 tokenizer detect beginning of words by the preceding space).`,name:"add_prefix_space"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/tokenization_gpt2.py#L104"}}),tn=new Re({props:{anchor:"transformers.GPT2Tokenizer.example",$$slots:{default:[Yw]},$$scope:{ctx:G}}}),on=new Be({props:{$$slots:{default:[Kw]},$$scope:{ctx:G}}}),Qs=new A({props:{name:"save_vocabulary",anchor:"transformers.GPT2Tokenizer.save_vocabulary",parameters:[{name:"save_directory",val:": str"},{name:"filename_prefix",val:": typing.Optional[str] = None"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/tokenization_gpt2.py#L322"}}),Ys=new we({}),Ks=new A({props:{name:"class transformers.GPT2TokenizerFast",anchor:"transformers.GPT2TokenizerFast",parameters:[{name:"vocab_file",val:" = None"},{name:"merges_file",val:" = None"},{name:"tokenizer_file",val:" = None"},{name:"unk_token",val:" = '<|endoftext|>'"},{name:"bos_token",val:" = '<|endoftext|>'"},{name:"eos_token",val:" = '<|endoftext|>'"},{name:"add_prefix_space",val:" = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.GPT2TokenizerFast.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>) &#x2014;
Path to the vocabulary file.`,name:"vocab_file"},{anchor:"transformers.GPT2TokenizerFast.merges_file",description:`<strong>merges_file</strong> (<code>str</code>) &#x2014;
Path to the merges file.`,name:"merges_file"},{anchor:"transformers.GPT2TokenizerFast.errors",description:`<strong>errors</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;replace&quot;</code>) &#x2014;
Paradigm to follow when decoding bytes to UTF-8. See
<a href="https://docs.python.org/3/library/stdtypes.html#bytes.decode" rel="nofollow">bytes.decode</a> for more information.`,name:"errors"},{anchor:"transformers.GPT2TokenizerFast.unk_token",description:`<strong>unk_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&lt;|endoftext|&gt;</code>) &#x2014;
The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
token instead.`,name:"unk_token"},{anchor:"transformers.GPT2TokenizerFast.bos_token",description:`<strong>bos_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&lt;|endoftext|&gt;</code>) &#x2014;
The beginning of sequence token.`,name:"bos_token"},{anchor:"transformers.GPT2TokenizerFast.eos_token",description:`<strong>eos_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&lt;|endoftext|&gt;</code>) &#x2014;
The end of sequence token.`,name:"eos_token"},{anchor:"transformers.GPT2TokenizerFast.add_prefix_space",description:`<strong>add_prefix_space</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to add an initial space to the input. This allows to treat the leading word just as any
other word. (GPT2 tokenizer detect beginning of words by the preceding space).`,name:"add_prefix_space"},{anchor:"transformers.GPT2TokenizerFast.trim_offsets",description:`<strong>trim_offsets</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the post-processing step should trim offsets to avoid including whitespaces.`,name:"trim_offsets"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/tokenization_gpt2_fast.py#L70"}}),sn=new Re({props:{anchor:"transformers.GPT2TokenizerFast.example",$$slots:{default:[eM]},$$scope:{ctx:G}}}),an=new Be({props:{$$slots:{default:[tM]},$$scope:{ctx:G}}}),na=new we({}),sa=new A({props:{name:"class transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput",anchor:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput",parameters:[{name:"loss",val:": typing.Optional[torch.FloatTensor] = None"},{name:"mc_loss",val:": typing.Optional[torch.FloatTensor] = None"},{name:"logits",val:": FloatTensor = None"},{name:"mc_logits",val:": FloatTensor = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None"},{name:"hidden_states",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"},{name:"attentions",val:": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"}],parametersDescription:[{anchor:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput.loss",description:`<strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) &#x2014;
Language modeling loss.`,name:"loss"},{anchor:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput.mc_loss",description:`<strong>mc_loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>mc_labels</code> is provided) &#x2014;
Multiple choice classification loss.`,name:"mc_loss"},{anchor:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput.logits",description:`<strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices, sequence_length, config.vocab_size)</code>) &#x2014;
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).`,name:"logits"},{anchor:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput.mc_logits",description:`<strong>mc_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices)</code>) &#x2014;
Prediction scores of the multiple choice classification head (scores for each choice before SoftMax).`,name:"mc_logits"},{anchor:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) &#x2014;
Tuple of length <code>config.n_layers</code>, containing tuples of tensors of shape <code>(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) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.`,name:"past_key_values"},{anchor:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput.hidden_states",description:`<strong>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>) &#x2014;
Tuple of <code>torch.FloatTensor</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 model at the output of each layer plus the initial embedding outputs.`,name:"hidden_states"},{anchor:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput.attentions",description:`<strong>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>) &#x2014;
Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>GPT2Attentions weights after the attention softmax, used to compute the weighted average in the
self-attention heads.`,name:"attentions"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/modeling_gpt2.py#L489"}}),aa=new A({props:{name:"class transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput",anchor:"transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput",parameters:[{name:"logits",val:": tf.Tensor = None"},{name:"mc_logits",val:": tf.Tensor = None"},{name:"past_key_values",val:": List[tf.Tensor] | None = None"},{name:"hidden_states",val:": Tuple[tf.Tensor] | None = None"},{name:"attentions",val:": Tuple[tf.Tensor] | None = None"}],parametersDescription:[{anchor:"transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput.logits",description:`<strong>logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, num_choices, sequence_length, config.vocab_size)</code>) &#x2014;
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).`,name:"logits"},{anchor:"transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput.mc_logits",description:`<strong>mc_logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, num_choices)</code>) &#x2014;
Prediction scores of the multiple choice classification head (scores for each choice before SoftMax).`,name:"mc_logits"},{anchor:"transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput.past_key_values",description:`<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>) &#x2014;
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) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.`,name:"past_key_values"},{anchor:"transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput.hidden_states",description:`<strong>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>) &#x2014;
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 model at the output of each layer plus the initial embedding outputs.`,name:"hidden_states"},{anchor:"transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput.attentions",description:`<strong>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>) &#x2014;
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 after the attention softmax, used to compute the weighted average in the self-attention
heads.`,name:"attentions"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/modeling_tf_gpt2.py#L526"}}),ra=new we({}),ia=new A({props:{name:"class transformers.GPT2Model",anchor:"transformers.GPT2Model",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.GPT2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</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/gpt2/modeling_gpt2.py#L669"}}),pa=new A({props:{name:"forward",anchor:"transformers.GPT2Model.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_hidden_states",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_attention_mask",val:": typing.Optional[torch.FloatTensor] = 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"}],parametersDescription:[{anchor:"transformers.GPT2Model.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past_key_values</code> is <code>None</code> else
<code>past_key_values[0][0].shape[-2]</code> (<code>sequence_length</code> of input past key value states). Indices of input
sequence tokens in the vocabulary.</p>
<p>If <code>past_key_values</code> is used, only <code>input_ids</code> that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__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.GPT2Model.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code> of length <code>config.n_layers</code>) &#x2014;
Contains precomputed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past_key_values</code> output below). Can be used to speed up sequential decoding. The <code>input_ids</code> which have
their past given to this model should not be passed as <code>input_ids</code> as they have already been computed.`,name:"past_key_values"},{anchor:"transformers.GPT2Model.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>If <code>past_key_values</code> is used, <code>attention_mask</code> needs to contain the masking strategy that was used for
<code>past_key_values</code>. In other words, the <code>attention_mask</code> always has to have the length:
<code>len(past_key_values) + len(input_ids)</code></p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.GPT2Model.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.GPT2Model.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</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.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.GPT2Model.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.GPT2Model.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.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>inputs_embeds</code> have to be input (see
<code>past_key_values</code>).`,name:"inputs_embeds"},{anchor:"transformers.GPT2Model.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.GPT2Model.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.GPT2Model.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.GPT2Model.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/modeling_gpt2.py#L747",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions</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/gpt2#transformers.GPT2Config"
>GPT2Config</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
<p>If <code>past_key_values</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</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 optionally if
<code>config.is_encoder_decoder=True</code> 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 optionally if
<code>config.is_encoder_decoder=True</code> 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>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 model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>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 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> and <code>config.add_cross_attention=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>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),dn=new Be({props:{$$slots:{default:[oM]},$$scope:{ctx:G}}}),cn=new Re({props:{anchor:"transformers.GPT2Model.forward.example",$$slots:{default:[nM]},$$scope:{ctx:G}}}),ha=new we({}),ua=new A({props:{name:"class transformers.GPT2LMHeadModel",anchor:"transformers.GPT2LMHeadModel",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.GPT2LMHeadModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</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/gpt2/modeling_gpt2.py#L956"}}),_a=new A({props:{name:"forward",anchor:"transformers.GPT2LMHeadModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_hidden_states",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_attention_mask",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"}],parametersDescription:[{anchor:"transformers.GPT2LMHeadModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past_key_values</code> is <code>None</code> else
<code>past_key_values[0][0].shape[-2]</code> (<code>sequence_length</code> of input past key value states). Indices of input
sequence tokens in the vocabulary.</p>
<p>If <code>past_key_values</code> is used, only <code>input_ids</code> that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__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.GPT2LMHeadModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code> of length <code>config.n_layers</code>) &#x2014;
Contains precomputed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past_key_values</code> output below). Can be used to speed up sequential decoding. The <code>input_ids</code> which have
their past given to this model should not be passed as <code>input_ids</code> as they have already been computed.`,name:"past_key_values"},{anchor:"transformers.GPT2LMHeadModel.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>If <code>past_key_values</code> is used, <code>attention_mask</code> needs to contain the masking strategy that was used for
<code>past_key_values</code>. In other words, the <code>attention_mask</code> always has to have the length:
<code>len(past_key_values) + len(input_ids)</code></p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.GPT2LMHeadModel.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.GPT2LMHeadModel.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</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.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.GPT2LMHeadModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.GPT2LMHeadModel.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.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>inputs_embeds</code> have to be input (see
<code>past_key_values</code>).`,name:"inputs_embeds"},{anchor:"transformers.GPT2LMHeadModel.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.GPT2LMHeadModel.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.GPT2LMHeadModel.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.GPT2LMHeadModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.GPT2LMHeadModel.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for language modeling. Note that the labels <strong>are shifted</strong> inside the model, i.e. you can set
<code>labels = input_ids</code> Indices are selected in <code>[-100, 0, ..., config.vocab_size]</code> All labels set to <code>-100</code>
are ignored (masked), the loss is only computed for labels in <code>[0, ..., config.vocab_size]</code>`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/modeling_gpt2.py#L1045",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</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/gpt2#transformers.GPT2Config"
>GPT2Config</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 (for next-token prediction).</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>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 model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>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 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>Cross attentions weights after the attention softmax, used to compute the weighted average in the
cross-attention heads.</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>torch.FloatTensor</code> tuples of length <code>config.n_layers</code>, with each tuple containing the cached key,
value states of the self-attention and the cross-attention layers if model is used in encoder-decoder
setting. Only relevant if <code>config.is_decoder = True</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),hn=new Be({props:{$$slots:{default:[sM]},$$scope:{ctx:G}}}),un=new Re({props:{anchor:"transformers.GPT2LMHeadModel.forward.example",$$slots:{default:[aM]},$$scope:{ctx:G}}}),Ta=new we({}),ya=new A({props:{name:"class transformers.GPT2DoubleHeadsModel",anchor:"transformers.GPT2DoubleHeadsModel",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.GPT2DoubleHeadsModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</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/gpt2/modeling_gpt2.py#L1148"}}),wa=new A({props:{name:"forward",anchor:"transformers.GPT2DoubleHeadsModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"mc_token_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"mc_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.GPT2DoubleHeadsModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past_key_values</code> is <code>None</code> else
<code>past_key_values[0][0].shape[-2]</code> (<code>sequence_length</code> of input past key value states). Indices of input
sequence tokens in the vocabulary.</p>
<p>If <code>past_key_values</code> is used, only <code>input_ids</code> that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__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.GPT2DoubleHeadsModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code> of length <code>config.n_layers</code>) &#x2014;
Contains precomputed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past_key_values</code> output below). Can be used to speed up sequential decoding. The <code>input_ids</code> which have
their past given to this model should not be passed as <code>input_ids</code> as they have already been computed.`,name:"past_key_values"},{anchor:"transformers.GPT2DoubleHeadsModel.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>If <code>past_key_values</code> is used, <code>attention_mask</code> needs to contain the masking strategy that was used for
<code>past_key_values</code>. In other words, the <code>attention_mask</code> always has to have the length:
<code>len(past_key_values) + len(input_ids)</code></p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</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.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.GPT2DoubleHeadsModel.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.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>inputs_embeds</code> have to be input (see
<code>past_key_values</code>).`,name:"inputs_embeds"},{anchor:"transformers.GPT2DoubleHeadsModel.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.GPT2DoubleHeadsModel.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.GPT2DoubleHeadsModel.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.GPT2DoubleHeadsModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.mc_token_ids",description:`<strong>mc_token_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_choices)</code>, <em>optional</em>, default to index of the last token of the input) &#x2014;
Index of the classification token in each input sequence. Selected in the range <code>[0, input_ids.size(-1) - 1]</code>.`,name:"mc_token_ids"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for language modeling. Note that the labels <strong>are shifted</strong> inside the model, i.e. you can set
<code>labels = input_ids</code>. Indices are selected in <code>[-100, 0, ..., config.vocab_size - 1]</code>. All labels set to
<code>-100</code> are ignored (masked), the loss is only computed for labels in <code>[0, ..., config.vocab_size - 1]</code>`,name:"labels"},{anchor:"transformers.GPT2DoubleHeadsModel.forward.mc_labels",description:`<strong>mc_labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size)</code>, <em>optional</em>) &#x2014;
Labels for computing the multiple choice classification loss. Indices should be in <code>[0, ..., num_choices]</code>
where <em>num_choices</em> is the size of the second dimension of the input tensors. (see <em>input_ids</em> above)`,name:"mc_labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/modeling_gpt2.py#L1233",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/model_doc/gpt2#transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput"
>transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput</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/gpt2#transformers.GPT2Config"
>GPT2Config</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>mc_loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>mc_labels</code> is provided) \u2014 Multiple choice classification loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices, 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>mc_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices)</code>) \u2014 Prediction scores of the multiple choice classification head (scores for each choice before SoftMax).</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of length <code>config.n_layers</code>, containing tuples of tensors of shape <code>(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) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>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 + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>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>GPT2Attentions weights 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/model_doc/gpt2#transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput"
>transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),fn=new Be({props:{$$slots:{default:[rM]},$$scope:{ctx:G}}}),gn=new Re({props:{anchor:"transformers.GPT2DoubleHeadsModel.forward.example",$$slots:{default:[iM]},$$scope:{ctx:G}}}),Ma=new we({}),$a=new A({props:{name:"class transformers.GPT2ForQuestionAnswering",anchor:"transformers.GPT2ForQuestionAnswering",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.GPT2ForQuestionAnswering.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</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/gpt2/modeling_gpt2.py#L1599"}}),Ea=new A({props:{name:"forward",anchor:"transformers.GPT2ForQuestionAnswering.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"start_positions",val:": typing.Optional[torch.LongTensor] = None"},{name:"end_positions",val:": typing.Optional[torch.LongTensor] = 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"}],parametersDescription:[{anchor:"transformers.GPT2ForQuestionAnswering.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past_key_values</code> is <code>None</code> else
<code>past_key_values[0][0].shape[-2]</code> (<code>sequence_length</code> of input past key value states). Indices of input
sequence tokens in the vocabulary.</p>
<p>If <code>past_key_values</code> is used, only <code>input_ids</code> that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__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.GPT2ForQuestionAnswering.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code> of length <code>config.n_layers</code>) &#x2014;
Contains precomputed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past_key_values</code> output below). Can be used to speed up sequential decoding. The <code>input_ids</code> which have
their past given to this model should not be passed as <code>input_ids</code> as they have already been computed.`,name:"past_key_values"},{anchor:"transformers.GPT2ForQuestionAnswering.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>If <code>past_key_values</code> is used, <code>attention_mask</code> needs to contain the masking strategy that was used for
<code>past_key_values</code>. In other words, the <code>attention_mask</code> always has to have the length:
<code>len(past_key_values) + len(input_ids)</code></p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.GPT2ForQuestionAnswering.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.GPT2ForQuestionAnswering.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</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.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.GPT2ForQuestionAnswering.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.GPT2ForQuestionAnswering.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.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>inputs_embeds</code> have to be input (see
<code>past_key_values</code>).`,name:"inputs_embeds"},{anchor:"transformers.GPT2ForQuestionAnswering.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.GPT2ForQuestionAnswering.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.GPT2ForQuestionAnswering.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.GPT2ForQuestionAnswering.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.GPT2ForQuestionAnswering.forward.start_positions",description:`<strong>start_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for position (index) of the start of the labelled span for computing the token classification loss.
Positions are clamped to the length of the sequence (<code>sequence_length</code>). Position outside of the sequence
are not taken into account for computing the loss.`,name:"start_positions"},{anchor:"transformers.GPT2ForQuestionAnswering.forward.end_positions",description:`<strong>end_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for position (index) of the end of the labelled span for computing the token classification loss.
Positions are clamped to the length of the sequence (<code>sequence_length</code>). Position outside of the sequence
are not taken into account for computing the loss.`,name:"end_positions"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/modeling_gpt2.py#L1614",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</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/gpt2#transformers.GPT2Config"
>GPT2Config</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 Total span extraction loss is the sum of a Cross-Entropy for the start and end positions.</p>
</li>
<li>
<p><strong>start_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) \u2014 Span-start scores (before SoftMax).</p>
</li>
<li>
<p><strong>end_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) \u2014 Span-end scores (before SoftMax).</p>
</li>
<li>
<p><strong>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 model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>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 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.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Tn=new Be({props:{$$slots:{default:[lM]},$$scope:{ctx:G}}}),yn=new Be({props:{warning:!0,$$slots:{default:[dM]},$$scope:{ctx:G}}}),bn=new Re({props:{anchor:"transformers.GPT2ForQuestionAnswering.forward.example",$$slots:{default:[cM]},$$scope:{ctx:G}}}),ja=new we({}),za=new A({props:{name:"class transformers.GPT2ForSequenceClassification",anchor:"transformers.GPT2ForSequenceClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.GPT2ForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</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/gpt2/modeling_gpt2.py#L1376"}}),Ja=new A({props:{name:"forward",anchor:"transformers.GPT2ForSequenceClassification.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"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"}],parametersDescription:[{anchor:"transformers.GPT2ForSequenceClassification.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past_key_values</code> is <code>None</code> else
<code>past_key_values[0][0].shape[-2]</code> (<code>sequence_length</code> of input past key value states). Indices of input
sequence tokens in the vocabulary.</p>
<p>If <code>past_key_values</code> is used, only <code>input_ids</code> that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__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.GPT2ForSequenceClassification.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code> of length <code>config.n_layers</code>) &#x2014;
Contains precomputed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past_key_values</code> output below). Can be used to speed up sequential decoding. The <code>input_ids</code> which have
their past given to this model should not be passed as <code>input_ids</code> as they have already been computed.`,name:"past_key_values"},{anchor:"transformers.GPT2ForSequenceClassification.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>If <code>past_key_values</code> is used, <code>attention_mask</code> needs to contain the masking strategy that was used for
<code>past_key_values</code>. In other words, the <code>attention_mask</code> always has to have the length:
<code>len(past_key_values) + len(input_ids)</code></p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.GPT2ForSequenceClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.GPT2ForSequenceClassification.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</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.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.GPT2ForSequenceClassification.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.GPT2ForSequenceClassification.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.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>inputs_embeds</code> have to be input (see
<code>past_key_values</code>).`,name:"inputs_embeds"},{anchor:"transformers.GPT2ForSequenceClassification.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.GPT2ForSequenceClassification.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.GPT2ForSequenceClassification.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.GPT2ForSequenceClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.GPT2ForSequenceClassification.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the sequence classification/regression loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>. If <code>config.num_labels == 1</code> a regression loss is computed (Mean-Square loss), If
<code>config.num_labels &gt; 1</code> a classification loss is computed (Cross-Entropy).`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/modeling_gpt2.py#L1390",returnDescription:`
<p>A <code>transformers.modeling_outputs.SequenceClassifierOutputWithPast</code> 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/gpt2#transformers.GPT2Config"
>GPT2Config</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 Classification (or regression if config.num_labels==1) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.num_labels)</code>) \u2014 Classification (or regression if config.num_labels==1) scores (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>)</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>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 model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>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 after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.modeling_outputs.SequenceClassifierOutputWithPast</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),kn=new Be({props:{$$slots:{default:[pM]},$$scope:{ctx:G}}}),wn=new Re({props:{anchor:"transformers.GPT2ForSequenceClassification.forward.example",$$slots:{default:[hM]},$$scope:{ctx:G}}}),Mn=new Re({props:{anchor:"transformers.GPT2ForSequenceClassification.forward.example-2",$$slots:{default:[uM]},$$scope:{ctx:G}}}),Ia=new we({}),Na=new A({props:{name:"class transformers.GPT2ForTokenClassification",anchor:"transformers.GPT2ForTokenClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.GPT2ForTokenClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</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/gpt2/modeling_gpt2.py#L1501"}}),Ha=new A({props:{name:"forward",anchor:"transformers.GPT2ForTokenClassification.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"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"}],parametersDescription:[{anchor:"transformers.GPT2ForTokenClassification.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past_key_values</code> is <code>None</code> else
<code>past_key_values[0][0].shape[-2]</code> (<code>sequence_length</code> of input past key value states). Indices of input
sequence tokens in the vocabulary.</p>
<p>If <code>past_key_values</code> is used, only <code>input_ids</code> that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__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.GPT2ForTokenClassification.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code> of length <code>config.n_layers</code>) &#x2014;
Contains precomputed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past_key_values</code> output below). Can be used to speed up sequential decoding. The <code>input_ids</code> which have
their past given to this model should not be passed as <code>input_ids</code> as they have already been computed.`,name:"past_key_values"},{anchor:"transformers.GPT2ForTokenClassification.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>If <code>past_key_values</code> is used, <code>attention_mask</code> needs to contain the masking strategy that was used for
<code>past_key_values</code>. In other words, the <code>attention_mask</code> always has to have the length:
<code>len(past_key_values) + len(input_ids)</code></p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.GPT2ForTokenClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.GPT2ForTokenClassification.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</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.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.GPT2ForTokenClassification.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.GPT2ForTokenClassification.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.</p>
<p>If <code>past_key_values</code> is used, optionally only the last <code>inputs_embeds</code> have to be input (see
<code>past_key_values</code>).`,name:"inputs_embeds"},{anchor:"transformers.GPT2ForTokenClassification.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.GPT2ForTokenClassification.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.GPT2ForTokenClassification.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.GPT2ForTokenClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.GPT2ForTokenClassification.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 sequence classification/regression loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>. If <code>config.num_labels == 1</code> a regression loss is computed (Mean-Square loss), If
<code>config.num_labels &gt; 1</code> a classification loss is computed (Cross-Entropy).`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/modeling_gpt2.py#L1523",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</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/gpt2#transformers.GPT2Config"
>GPT2Config</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 Classification loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.num_labels)</code>) \u2014 Classification scores (before SoftMax).</p>
</li>
<li>
<p><strong>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 model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>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 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.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Pn=new Be({props:{$$slots:{default:[mM]},$$scope:{ctx:G}}}),Gn=new Re({props:{anchor:"transformers.GPT2ForTokenClassification.forward.example",$$slots:{default:[fM]},$$scope:{ctx:G}}}),Za=new we({}),Ba=new A({props:{name:"class transformers.TFGPT2Model",anchor:"transformers.TFGPT2Model",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFGPT2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</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/gpt2/modeling_tf_gpt2.py#L675"}}),En=new Be({props:{$$slots:{default:[gM]},$$scope:{ctx:G}}}),Sa=new A({props:{name:"call",anchor:"transformers.TFGPT2Model.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"past_key_values",val:": Optional[Tuple[Tuple[Union[np.ndarray, tf.Tensor]]]] = None"},{name:"attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"token_type_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"position_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"head_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"inputs_embeds",val:": np.ndarray | tf.Tensor | None = None"},{name:"encoder_hidden_states",val:": np.ndarray | tf.Tensor | None = None"},{name:"encoder_attention_mask",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:": Optional[bool] = False"}],parametersDescription:[{anchor:"transformers.TFGPT2Model.call.input_ids",description:`<strong>input_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past_key_values</code> is <code>None</code> else <code>past_key_values[0].shape[-2]</code>
(<code>sequence_length</code> of input past key value states). Indices of input sequence tokens in the vocabulary.</p>
<p>If <code>past_key_values</code> is used, only input IDs that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.TFGPT2Model.call.past_key_values",description:`<strong>past_key_values</strong> (<code>List[tf.Tensor]</code> of length <code>config.n_layers</code>) &#x2014;
Contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past_key_values</code> output below). Can be used to speed up sequential decoding. The token ids which have
their past given to this model should not be passed as input ids as they have already been computed.`,name:"past_key_values"},{anchor:"transformers.TFGPT2Model.call.attention_mask",description:`<strong>attention_mask</strong> (<code>tf.Tensor</code> or <code>Numpy array</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>If <code>past_key_values</code> is used, <code>attention_mask</code> needs to contain the masking strategy that was used for
<code>past_key_values</code>. In other words, the <code>attention_mask</code> always has to have the length:
<code>len(past_key_values) + len(input_ids)</code></p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TFGPT2Model.call.token_type_ids",description:`<strong>token_type_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.TFGPT2Model.call.position_ids",description:`<strong>position_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</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.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.TFGPT2Model.call.head_mask",description:`<strong>head_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.TFGPT2Model.call.inputs_embeds",description:`<strong>inputs_embeds</strong> (<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.TFGPT2Model.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. This argument can be used only in eager mode, in graph mode the value in the
config will be used instead.`,name:"output_attentions"},{anchor:"transformers.TFGPT2Model.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. This argument can be used only in eager mode, in graph mode the value in the config will be
used instead.`,name:"output_hidden_states"},{anchor:"transformers.TFGPT2Model.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple. This argument can be used in
eager mode, in graph mode the value will always be set to True.`,name:"return_dict"},{anchor:"transformers.TFGPT2Model.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.TFGPT2Model.call.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong>  (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
the model is configured as a decoder.`,name:"encoder_hidden_states"},{anchor:"transformers.TFGPT2Model.call.encoder_attention_mask",description:`<strong>encoder_attention_mask</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in
the cross-attention if the model is configured as a decoder. 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>`,name:"encoder_attention_mask"},{anchor:"transformers.TFGPT2Model.call.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[tf.Tensor]]</code> of length <code>config.n_layers</code>) &#x2014;
contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.
If <code>past</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.TFGPT2Model.call.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#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</code>). Set to <code>False</code> during training, <code>True</code> during generation`,name:"use_cache"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/modeling_tf_gpt2.py#L680",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_tf_outputs.TFBaseModelOutputWithPastAndCrossAttentions"
>transformers.modeling_tf_outputs.TFBaseModelOutputWithPastAndCrossAttentions</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/gpt2#transformers.GPT2Config"
>GPT2Config</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
<p>If <code>past_key_values</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</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) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(tf.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>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 model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>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 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>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_tf_outputs.TFBaseModelOutputWithPastAndCrossAttentions"
>transformers.modeling_tf_outputs.TFBaseModelOutputWithPastAndCrossAttentions</a> or <code>tuple(tf.Tensor)</code></p>
`}}),jn=new Be({props:{$$slots:{default:[_M]},$$scope:{ctx:G}}}),zn=new Re({props:{anchor:"transformers.TFGPT2Model.call.example",$$slots:{default:[TM]},$$scope:{ctx:G}}}),La=new we({}),Xa=new A({props:{name:"class transformers.TFGPT2LMHeadModel",anchor:"transformers.TFGPT2LMHeadModel",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFGPT2LMHeadModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</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/gpt2/modeling_tf_gpt2.py#L752"}}),Cn=new Be({props:{$$slots:{default:[yM]},$$scope:{ctx:G}}}),Ka=new A({props:{name:"call",anchor:"transformers.TFGPT2LMHeadModel.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"past_key_values",val:": Optional[Tuple[Tuple[Union[np.ndarray, tf.Tensor]]]] = None"},{name:"attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"token_type_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"position_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"head_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"inputs_embeds",val:": np.ndarray | tf.Tensor | None = None"},{name:"encoder_hidden_states",val:": np.ndarray | tf.Tensor | None = None"},{name:"encoder_attention_mask",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:"labels",val:": np.ndarray | tf.Tensor | None = None"},{name:"training",val:": Optional[bool] = False"}],parametersDescription:[{anchor:"transformers.TFGPT2LMHeadModel.call.input_ids",description:`<strong>input_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past_key_values</code> is <code>None</code> else <code>past_key_values[0].shape[-2]</code>
(<code>sequence_length</code> of input past key value states). Indices of input sequence tokens in the vocabulary.</p>
<p>If <code>past_key_values</code> is used, only input IDs that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.TFGPT2LMHeadModel.call.past_key_values",description:`<strong>past_key_values</strong> (<code>List[tf.Tensor]</code> of length <code>config.n_layers</code>) &#x2014;
Contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past_key_values</code> output below). Can be used to speed up sequential decoding. The token ids which have
their past given to this model should not be passed as input ids as they have already been computed.`,name:"past_key_values"},{anchor:"transformers.TFGPT2LMHeadModel.call.attention_mask",description:`<strong>attention_mask</strong> (<code>tf.Tensor</code> or <code>Numpy array</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>If <code>past_key_values</code> is used, <code>attention_mask</code> needs to contain the masking strategy that was used for
<code>past_key_values</code>. In other words, the <code>attention_mask</code> always has to have the length:
<code>len(past_key_values) + len(input_ids)</code></p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TFGPT2LMHeadModel.call.token_type_ids",description:`<strong>token_type_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.TFGPT2LMHeadModel.call.position_ids",description:`<strong>position_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</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.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.TFGPT2LMHeadModel.call.head_mask",description:`<strong>head_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.TFGPT2LMHeadModel.call.inputs_embeds",description:`<strong>inputs_embeds</strong> (<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.TFGPT2LMHeadModel.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. This argument can be used only in eager mode, in graph mode the value in the
config will be used instead.`,name:"output_attentions"},{anchor:"transformers.TFGPT2LMHeadModel.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. This argument can be used only in eager mode, in graph mode the value in the config will be
used instead.`,name:"output_hidden_states"},{anchor:"transformers.TFGPT2LMHeadModel.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple. This argument can be used in
eager mode, in graph mode the value will always be set to True.`,name:"return_dict"},{anchor:"transformers.TFGPT2LMHeadModel.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.TFGPT2LMHeadModel.call.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong>  (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
the model is configured as a decoder.`,name:"encoder_hidden_states"},{anchor:"transformers.TFGPT2LMHeadModel.call.encoder_attention_mask",description:`<strong>encoder_attention_mask</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in
the cross-attention if the model is configured as a decoder. 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>`,name:"encoder_attention_mask"},{anchor:"transformers.TFGPT2LMHeadModel.call.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[tf.Tensor]]</code> of length <code>config.n_layers</code>) &#x2014;
contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.
If <code>past</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.TFGPT2LMHeadModel.call.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#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</code>). Set to <code>False</code> during training, <code>True</code> during generation`,name:"use_cache"},{anchor:"transformers.TFGPT2LMHeadModel.call.labels",description:`<strong>labels</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the cross entropy classification loss. Indices should be in <code>[0, ..., config.vocab_size - 1]</code>.`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/modeling_tf_gpt2.py#L788",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_tf_outputs.TFCausalLMOutputWithCrossAttentions"
>transformers.modeling_tf_outputs.TFCausalLMOutputWithCrossAttentions</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/gpt2#transformers.GPT2Config"
>GPT2Config</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 (for next-token prediction).</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>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 model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>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 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>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) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_tf_outputs.TFCausalLMOutputWithCrossAttentions"
>transformers.modeling_tf_outputs.TFCausalLMOutputWithCrossAttentions</a> or <code>tuple(tf.Tensor)</code></p>
`}}),Un=new Be({props:{$$slots:{default:[bM]},$$scope:{ctx:G}}}),Jn=new Re({props:{anchor:"transformers.TFGPT2LMHeadModel.call.example",$$slots:{default:[vM]},$$scope:{ctx:G}}}),er=new we({}),tr=new A({props:{name:"class transformers.TFGPT2DoubleHeadsModel",anchor:"transformers.TFGPT2DoubleHeadsModel",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFGPT2DoubleHeadsModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</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/gpt2/modeling_tf_gpt2.py#L886"}}),Nn=new Be({props:{$$slots:{default:[kM]},$$scope:{ctx:G}}}),ar=new A({props:{name:"call",anchor:"transformers.TFGPT2DoubleHeadsModel.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"past_key_values",val:": Optional[Tuple[Tuple[Union[np.ndarray, tf.Tensor]]]] = None"},{name:"attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"token_type_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"position_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"head_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"inputs_embeds",val:": np.ndarray | tf.Tensor | None = None"},{name:"mc_token_ids",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:": Optional[bool] = False"}],parametersDescription:[{anchor:"transformers.TFGPT2DoubleHeadsModel.call.input_ids",description:`<strong>input_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past_key_values</code> is <code>None</code> else <code>past_key_values[0].shape[-2]</code>
(<code>sequence_length</code> of input past key value states). Indices of input sequence tokens in the vocabulary.</p>
<p>If <code>past_key_values</code> is used, only input IDs that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.past_key_values",description:`<strong>past_key_values</strong> (<code>List[tf.Tensor]</code> of length <code>config.n_layers</code>) &#x2014;
Contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past_key_values</code> output below). Can be used to speed up sequential decoding. The token ids which have
their past given to this model should not be passed as input ids as they have already been computed.`,name:"past_key_values"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.attention_mask",description:`<strong>attention_mask</strong> (<code>tf.Tensor</code> or <code>Numpy array</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>If <code>past_key_values</code> is used, <code>attention_mask</code> needs to contain the masking strategy that was used for
<code>past_key_values</code>. In other words, the <code>attention_mask</code> always has to have the length:
<code>len(past_key_values) + len(input_ids)</code></p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.token_type_ids",description:`<strong>token_type_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.position_ids",description:`<strong>position_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</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.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.head_mask",description:`<strong>head_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.inputs_embeds",description:`<strong>inputs_embeds</strong> (<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.TFGPT2DoubleHeadsModel.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. This argument can be used only in eager mode, in graph mode the value in the
config will be used instead.`,name:"output_attentions"},{anchor:"transformers.TFGPT2DoubleHeadsModel.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. This argument can be used only in eager mode, in graph mode the value in the config will be
used instead.`,name:"output_hidden_states"},{anchor:"transformers.TFGPT2DoubleHeadsModel.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple. This argument can be used in
eager mode, in graph mode the value will always be set to True.`,name:"return_dict"},{anchor:"transformers.TFGPT2DoubleHeadsModel.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.TFGPT2DoubleHeadsModel.call.mc_token_ids",description:`<strong>mc_token_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, num_choices)</code>, <em>optional</em>, default to index of the last token of the input) &#x2014;
Index of the classification token in each input sequence. Selected in the range <code>[0, input_ids.size(-1) - 1]</code>.`,name:"mc_token_ids"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/modeling_tf_gpt2.py#L895",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/model_doc/gpt2#transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput"
>transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput</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/gpt2#transformers.GPT2Config"
>GPT2Config</a>) and inputs.</p>
<ul>
<li>
<p><strong>logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, num_choices, 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>mc_logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, num_choices)</code>) \u2014 Prediction scores of the multiple choice classification head (scores for each choice 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) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>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 model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>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 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/model_doc/gpt2#transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput"
>transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput</a> or <code>tuple(tf.Tensor)</code></p>
`}}),qn=new Be({props:{$$slots:{default:[wM]},$$scope:{ctx:G}}}),Wn=new Re({props:{anchor:"transformers.TFGPT2DoubleHeadsModel.call.example",$$slots:{default:[MM]},$$scope:{ctx:G}}}),rr=new we({}),ir=new A({props:{name:"class transformers.TFGPT2ForSequenceClassification",anchor:"transformers.TFGPT2ForSequenceClassification",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFGPT2ForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</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/gpt2/modeling_tf_gpt2.py#L1021"}}),Hn=new Be({props:{$$slots:{default:[$M]},$$scope:{ctx:G}}}),pr=new A({props:{name:"call",anchor:"transformers.TFGPT2ForSequenceClassification.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"past_key_values",val:": Optional[Tuple[Tuple[Union[np.ndarray, tf.Tensor]]]] = None"},{name:"attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"token_type_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"position_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"head_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"inputs_embeds",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:"labels",val:": np.ndarray | tf.Tensor | None = None"},{name:"training",val:": Optional[bool] = False"}],parametersDescription:[{anchor:"transformers.TFGPT2ForSequenceClassification.call.input_ids",description:`<strong>input_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past_key_values</code> is <code>None</code> else <code>past_key_values[0].shape[-2]</code>
(<code>sequence_length</code> of input past key value states). Indices of input sequence tokens in the vocabulary.</p>
<p>If <code>past_key_values</code> is used, only input IDs that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.past_key_values",description:`<strong>past_key_values</strong> (<code>List[tf.Tensor]</code> of length <code>config.n_layers</code>) &#x2014;
Contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past_key_values</code> output below). Can be used to speed up sequential decoding. The token ids which have
their past given to this model should not be passed as input ids as they have already been computed.`,name:"past_key_values"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.attention_mask",description:`<strong>attention_mask</strong> (<code>tf.Tensor</code> or <code>Numpy array</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>If <code>past_key_values</code> is used, <code>attention_mask</code> needs to contain the masking strategy that was used for
<code>past_key_values</code>. In other words, the <code>attention_mask</code> always has to have the length:
<code>len(past_key_values) + len(input_ids)</code></p>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.token_type_ids",description:`<strong>token_type_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.position_ids",description:`<strong>position_ids</strong> (<code>tf.Tensor</code> or <code>Numpy array</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.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.head_mask",description:`<strong>head_mask</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.inputs_embeds",description:`<strong>inputs_embeds</strong> (<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.TFGPT2ForSequenceClassification.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. This argument can be used only in eager mode, in graph mode the value in the
config will be used instead.`,name:"output_attentions"},{anchor:"transformers.TFGPT2ForSequenceClassification.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. This argument can be used only in eager mode, in graph mode the value in the config will be
used instead.`,name:"output_hidden_states"},{anchor:"transformers.TFGPT2ForSequenceClassification.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple. This argument can be used in
eager mode, in graph mode the value will always be set to True.`,name:"return_dict"},{anchor:"transformers.TFGPT2ForSequenceClassification.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.TFGPT2ForSequenceClassification.call.labels",description:`<strong>labels</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the cross entropy classification loss. Indices should be in <code>[0, ..., config.vocab_size - 1]</code>.`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/modeling_tf_gpt2.py#L1033",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/model_doc/gpt2#transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast"
>transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast</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/gpt2#transformers.GPT2Config"
>GPT2Config</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, )</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Classification (or regression if config.num_labels==1) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, config.num_labels)</code>) \u2014 Classification (or regression if config.num_labels==1) scores (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) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>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 model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>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 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/model_doc/gpt2#transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast"
>transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast</a> or <code>tuple(tf.Tensor)</code></p>
`}}),Zn=new Be({props:{$$slots:{default:[PM]},$$scope:{ctx:G}}}),Bn=new Re({props:{anchor:"transformers.TFGPT2ForSequenceClassification.call.example",$$slots:{default:[GM]},$$scope:{ctx:G}}}),Rn=new Re({props:{anchor:"transformers.TFGPT2ForSequenceClassification.call.example-2",$$slots:{default:[FM]},$$scope:{ctx:G}}}),hr=new we({}),ur=new A({props:{name:"class transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast",anchor:"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast",parameters:[{name:"loss",val:": tf.Tensor | None = None"},{name:"logits",val:": tf.Tensor = None"},{name:"past_key_values",val:": List[tf.Tensor] | None = None"},{name:"hidden_states",val:": Tuple[tf.Tensor] | None = None"},{name:"attentions",val:": Tuple[tf.Tensor] | None = None"}],parametersDescription:[{anchor:"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast.loss",description:`<strong>loss</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, )</code>, <em>optional</em>, returned when <code>labels</code> is provided) &#x2014;
Classification (or regression if config.num_labels==1) loss.`,name:"loss"},{anchor:"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast.logits",description:`<strong>logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, config.num_labels)</code>) &#x2014;
Classification (or regression if config.num_labels==1) scores (before SoftMax).`,name:"logits"},{anchor:"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast.past_key_values",description:`<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>) &#x2014;
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) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.`,name:"past_key_values"},{anchor:"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast.hidden_states",description:`<strong>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>) &#x2014;
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 model at the output of each layer plus the initial embedding outputs.`,name:"hidden_states"},{anchor:"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast.attentions",description:`<strong>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>) &#x2014;
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 after the attention softmax, used to compute the weighted average in the self-attention
heads.`,name:"attentions"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_tf_outputs.py#L901"}}),mr=new we({}),fr=new A({props:{name:"class transformers.TFGPT2Tokenizer",anchor:"transformers.TFGPT2Tokenizer",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFGPT2Tokenizer.vocab",description:"<strong>vocab</strong> (Dict[str, int]) &#x2014; Vocabulary dict for Byte Pair Tokenizer",name:"vocab"},{anchor:"transformers.TFGPT2Tokenizer.merges",description:"<strong>merges</strong> (List[str]) &#x2014; Merges list for Byte Pair Tokenizer",name:"merges"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/tokenization_gpt2_tf.py#L11"}}),_r=new A({props:{name:"from_config",anchor:"transformers.TFGPT2Tokenizer.from_config",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.TFGPT2Tokenizer.from_config.config",description:"<strong>config</strong> (Dict) &#x2014; Dictionary with keys such as stated in <code>get_config</code>.",name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/tokenization_gpt2_tf.py#L73"}}),Tr=new A({props:{name:"from_pretrained",anchor:"transformers.TFGPT2Tokenizer.from_pretrained",parameters:[{name:"pretrained_model_name_or_path",val:": typing.Union[str, os.PathLike]"},{name:"*init_inputs",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFGPT2Tokenizer.from_pretrained.pretrained_model_name_or_path",description:"<strong>pretrained_model_name_or_path</strong> (Union[str, os.PathLike]) &#x2014; Path to pretrained model",name:"pretrained_model_name_or_path"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/tokenization_gpt2_tf.py#L55"}}),Ln=new Re({props:{anchor:"transformers.TFGPT2Tokenizer.from_pretrained.example",$$slots:{default:[EM]},$$scope:{ctx:G}}}),yr=new A({props:{name:"from_tokenizer",anchor:"transformers.TFGPT2Tokenizer.from_tokenizer",parameters:[{name:"tokenizer",val:": GPT2Tokenizer"},{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFGPT2Tokenizer.from_tokenizer.tokenizer",description:"<strong>tokenizer</strong> (GPT2Tokenizer) &#x2014;",name:"tokenizer"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/tokenization_gpt2_tf.py#L35"}}),Xn=new Re({props:{anchor:"transformers.TFGPT2Tokenizer.from_tokenizer.example",$$slots:{default:[jM]},$$scope:{ctx:G}}}),br=new we({}),vr=new A({props:{name:"class transformers.FlaxGPT2Model",anchor:"transformers.FlaxGPT2Model",parameters:[{name:"config",val:": GPT2Config"},{name:"input_shape",val:": typing.Tuple = (1, 1)"},{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.FlaxGPT2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</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.FlaxGPT2Model.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/gpt2/modeling_flax_gpt2.py#L665"}}),Er=new A({props:{name:"__call__",anchor:"transformers.FlaxGPT2Model.__call__",parameters:[{name:"input_ids",val:""},{name:"attention_mask",val:" = None"},{name:"position_ids",val:" = None"},{name:"encoder_hidden_states",val:": typing.Optional[jax.Array] = None"},{name:"encoder_attention_mask",val:": typing.Optional[jax.Array] = None"},{name:"params",val:": dict = None"},{name:"past_key_values",val:": dict = None"},{name:"dropout_rng",val:": PRNGKey = None"},{name:"train",val:": bool = False"},{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"}],parametersDescription:[{anchor:"transformers.FlaxGPT2Model.__call__.input_ids",description:`<strong>input_ids</strong> (<code>numpy.ndarray</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code>. Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__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.FlaxGPT2Model.__call__.attention_mask",description:`<strong>attention_mask</strong> (<code>numpy.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.FlaxGPT2Model.__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.max_position_embeddings - 1]</code>.`,name:"position_ids"},{anchor:"transformers.FlaxGPT2Model.__call__.past_key_values",description:`<strong>past_key_values</strong> (<code>Dict[str, np.ndarray]</code>, <em>optional</em>, returned by <code>init_cache</code> or when passing previous <code>past_key_values</code>) &#x2014;
Dictionary of pre-computed hidden-states (key and values in the attention blocks) that can be used for fast
auto-regressive decoding. Pre-computed key and value hidden-states are of shape <em>[batch_size, max_length]</em>.`,name:"past_key_values"},{anchor:"transformers.FlaxGPT2Model.__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.FlaxGPT2Model.__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.FlaxGPT2Model.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/modeling_flax_gpt2.py#L456",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_flax_outputs.FlaxBaseModelOutputWithPastAndCrossAttentions"
>transformers.modeling_flax_outputs.FlaxBaseModelOutputWithPastAndCrossAttentions</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/gpt2#transformers.GPT2Config"
>GPT2Config</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
<p>If <code>past_key_values</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</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 optionally if
<code>config.is_encoder_decoder=True</code> 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 optionally if
<code>config.is_encoder_decoder=True</code> 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>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 model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>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 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> and <code>config.add_cross_attention=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>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_flax_outputs.FlaxBaseModelOutputWithPastAndCrossAttentions"
>transformers.modeling_flax_outputs.FlaxBaseModelOutputWithPastAndCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Qn=new Be({props:{$$slots:{default:[zM]},$$scope:{ctx:G}}}),Yn=new Re({props:{anchor:"transformers.FlaxGPT2Model.__call__.example",$$slots:{default:[xM]},$$scope:{ctx:G}}}),jr=new we({}),zr=new A({props:{name:"class transformers.FlaxGPT2LMHeadModel",anchor:"transformers.FlaxGPT2LMHeadModel",parameters:[{name:"config",val:": GPT2Config"},{name:"input_shape",val:": typing.Tuple = (1, 1)"},{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.FlaxGPT2LMHeadModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</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.FlaxGPT2LMHeadModel.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/gpt2/modeling_flax_gpt2.py#L742"}}),Wr=new A({props:{name:"__call__",anchor:"transformers.FlaxGPT2LMHeadModel.__call__",parameters:[{name:"input_ids",val:""},{name:"attention_mask",val:" = None"},{name:"position_ids",val:" = None"},{name:"encoder_hidden_states",val:": typing.Optional[jax.Array] = None"},{name:"encoder_attention_mask",val:": typing.Optional[jax.Array] = None"},{name:"params",val:": dict = None"},{name:"past_key_values",val:": dict = None"},{name:"dropout_rng",val:": PRNGKey = None"},{name:"train",val:": bool = False"},{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"}],parametersDescription:[{anchor:"transformers.FlaxGPT2LMHeadModel.__call__.input_ids",description:`<strong>input_ids</strong> (<code>numpy.ndarray</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code>. Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/model_doc/perceiver#transformers.PerceiverTokenizer.__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.FlaxGPT2LMHeadModel.__call__.attention_mask",description:`<strong>attention_mask</strong> (<code>numpy.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.FlaxGPT2LMHeadModel.__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.max_position_embeddings - 1]</code>.`,name:"position_ids"},{anchor:"transformers.FlaxGPT2LMHeadModel.__call__.past_key_values",description:`<strong>past_key_values</strong> (<code>Dict[str, np.ndarray]</code>, <em>optional</em>, returned by <code>init_cache</code> or when passing previous <code>past_key_values</code>) &#x2014;
Dictionary of pre-computed hidden-states (key and values in the attention blocks) that can be used for fast
auto-regressive decoding. Pre-computed key and value hidden-states are of shape <em>[batch_size, max_length]</em>.`,name:"past_key_values"},{anchor:"transformers.FlaxGPT2LMHeadModel.__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.FlaxGPT2LMHeadModel.__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.FlaxGPT2LMHeadModel.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/modeling_flax_gpt2.py#L456",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_flax_outputs.FlaxCausalLMOutputWithCrossAttentions"
>transformers.modeling_flax_outputs.FlaxCausalLMOutputWithCrossAttentions</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/gpt2#transformers.GPT2Config"
>GPT2Config</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>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 model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>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 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>Cross attentions weights after the attention softmax, used to compute the weighted average in the
cross-attention heads.</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>jnp.ndarray</code> tuples of length <code>config.n_layers</code>, with each tuple containing the cached key, value
states of the self-attention and the cross-attention layers if model is used in encoder-decoder setting.
Only relevant if <code>config.is_decoder = True</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_flax_outputs.FlaxCausalLMOutputWithCrossAttentions"
>transformers.modeling_flax_outputs.FlaxCausalLMOutputWithCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),es=new Be({props:{$$slots:{default:[CM]},$$scope:{ctx:G}}}),ts=new Re({props:{anchor:"transformers.FlaxGPT2LMHeadModel.__call__.example",$$slots:{default:[UM]},$$scope:{ctx:G}}}),{c(){d=a("meta"),y=c(),f=a("h1"),m=a("a"),T=a("span"),v(l.$$.fragment),h=c(),F=a("span"),R=n("OpenAI GPT2"),N=c(),J=a("div"),O=a("a"),re=a("img"),Ge=c(),S=a("a"),fe=a("img"),Q=c(),le=a("h2"),pe=a("a"),L=a("span"),v(he.$$.fragment),Fe=c(),X=a("span"),Ee=n("Overview"),Me=c(),H=a("p"),je=n("OpenAI GPT-2 model was proposed in "),ue=a("a"),me=n("Language Models are Unsupervised Multitask Learners"),x=n(` by Alec
Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei and Ilya Sutskever from `),C=a("a"),ze=n("OpenAI"),oe=n(`. It\u2019s a causal (unidirectional)
transformer pretrained using language modeling on a very large corpus of ~40 GB of text data.`),$e=c(),ge=a("p"),ne=n("The abstract from the paper is the following:"),Pe=c(),_e=a("p"),U=a("em"),xe=n(`GPT-2 is a large transformer-based language model with 1.5 billion parameters, trained on a dataset[1] of 8 million
web pages. GPT-2 is trained with a simple objective: predict the next word, given all of the previous words within some
text. The diversity of the dataset causes this simple goal to contain naturally occurring demonstrations of many tasks
across diverse domains. GPT-2 is a direct scale-up of GPT, with more than 10X the parameters and trained on more than
10X the amount of data.`),Y=c(),Te=a("p"),Ce=n("Tips:"),K=c(),ee=a("ul"),ye=a("li"),D=n(`GPT-2 is a model with absolute position embeddings so it\u2019s usually advised to pad the inputs on the right rather than
the left.`),Ue=c(),V=a("li"),Je=n(`GPT-2 was trained with a causal language modeling (CLM) objective and is therefore powerful at predicting the next
token in a sequence. Leveraging this feature allows GPT-2 to generate syntactically coherent text as it can be
observed in the `),de=a("em"),I=n("run_generation.py"),Ie=n(" example script."),W=c(),q=a("li"),Ne=n("The model can take the "),b=a("em"),j=n("past_key_values"),nt=n(" (for PyTorch) or "),ce=a("em"),st=n("past"),at=n(` (for TF) as input, which is the previously computed
key/value attention pairs. Using this (`),z=a("em"),rt=n("past_key_values"),it=n(" or "),Xe=a("em"),lt=n("past"),dt=n(`) value prevents the model from re-computing
pre-computed values in the context of text generation. For PyTorch, see `),Z=a("em"),se=n("past_key_values"),ct=n(` argument of the
`),Le=a("a"),ae=n("GPT2Model.forward()"),pt=n(" method, or for TF the "),Oe=a("em"),qe=n("past"),ht=n(` argument of the
`),ie=a("a"),ut=n("TFGPT2Model.call()"),Th=n(" method for more information on its usage."),yh=c(),Bt=a("li"),bh=n("Enabling the "),Qi=a("em"),vh=n("scale_attn_by_inverse_layer_idx"),kh=n(" and "),Yi=a("em"),wh=n("reorder_and_upcast_attn"),Mh=n(` flags will apply the training stability
improvements from `),gs=a("a"),$h=n("Mistral"),Ph=n(" (for PyTorch only)."),kc=c(),po=a("p"),_s=a("a"),Gh=n("Write With Transformer"),Fh=n(` is a webapp created and hosted by
Hugging Face showcasing the generative capabilities of several models. GPT-2 is one of them and is available in five
different sizes: small, medium, large, xl and a distilled version of the small checkpoint: `),Ki=a("em"),Eh=n("distilgpt-2"),jh=n("."),wc=c(),Xt=a("p"),zh=n("This model was contributed by "),Ts=a("a"),xh=n("thomwolf"),Ch=n(". The original code can be found "),ys=a("a"),Uh=n("here"),Jh=n("."),Mc=c(),ho=a("h2"),Qo=a("a"),el=a("span"),v(bs.$$.fragment),Ih=c(),tl=a("span"),Nh=n("Resources"),$c=c(),Vr=a("p"),qh=n("A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with GPT2. If you\u2019re interested in submitting a resource to be included here, please feel free to open a Pull Request and we\u2019ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource."),Pc=c(),v(vs.$$.fragment),Gc=c(),B=a("ul"),ks=a("li"),Wh=n("A blog on how to "),ws=a("a"),Ah=n("Finetune a non-English GPT-2 Model with Hugging Face"),Hh=n("."),Zh=c(),Ms=a("li"),Bh=n("A blog on "),$s=a("a"),Rh=n("How to generate text: using different decoding methods for language generation with Transformers"),Dh=n(" with GPT-2."),Vh=c(),Ps=a("li"),Sh=n("A blog on "),Gs=a("a"),Lh=n("Training CodeParrot \u{1F99C} from Scratch"),Xh=n(", a large GPT-2 model."),Oh=c(),Fs=a("li"),Qh=n("A blog on "),Es=a("a"),Yh=n("Faster Text Generation with TensorFlow and XLA"),Kh=n(" with GPT-2."),eu=c(),js=a("li"),tu=n("A blog on "),zs=a("a"),ou=n("How to train a Language Model with Megatron-LM"),nu=n(" with a GPT-2 model."),su=c(),xs=a("li"),au=n("A notebook on how to "),Cs=a("a"),ru=n("finetune GPT2 to generate lyrics in the style of your favorite artist"),iu=n(". \u{1F30E}"),lu=c(),Us=a("li"),du=n("A notebook on how to "),Js=a("a"),cu=n("finetune GPT2 to generate tweets in the style of your favorite Twitter user"),pu=n(". \u{1F30E}"),hu=c(),Sr=a("li"),Is=a("a"),uu=n("Causal language modeling"),mu=n(" chapter of the \u{1F917} Hugging Face Course."),fu=c(),Et=a("li"),Lr=a("a"),gu=n("GPT2LMHeadModel"),_u=n(" is supported by this "),Ns=a("a"),Tu=n("causal language modeling example script"),yu=n(", "),qs=a("a"),bu=n("text generation example script"),vu=n(", and "),Ws=a("a"),ku=n("notebook"),wu=n("."),Mu=c(),Ot=a("li"),Xr=a("a"),$u=n("TFGPT2LMHeadModel"),Pu=n(" is supported by this "),As=a("a"),Gu=n("causal language modeling example script"),Fu=n(" and "),Hs=a("a"),Eu=n("notebook"),ju=n("."),zu=c(),Qt=a("li"),Or=a("a"),xu=n("FlaxGPT2LMHeadModel"),Cu=n(" is supported by this "),Zs=a("a"),Uu=n("causal language modeling example script"),Ju=n(" and "),Bs=a("a"),Iu=n("notebook"),Nu=n("."),qu=c(),ol=a("li"),Qr=a("a"),Wu=n("Text classification task guide"),Au=c(),nl=a("li"),Yr=a("a"),Hu=n("Token classification task guide"),Zu=c(),sl=a("li"),Kr=a("a"),Bu=n("Causal language modeling task guide"),Fc=c(),uo=a("h2"),Yo=a("a"),al=a("span"),v(Rs.$$.fragment),Ru=c(),rl=a("span"),Du=n("GPT2Config"),Ec=c(),Pt=a("div"),v(Ds.$$.fragment),Vu=c(),Rt=a("p"),Su=n("This is the configuration class to store the configuration of a "),ei=a("a"),Lu=n("GPT2Model"),Xu=n(" or a "),ti=a("a"),Ou=n("TFGPT2Model"),Qu=n(`. It is used to
instantiate a GPT-2 model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a similar configuration to that of the GPT-2
`),Vs=a("a"),Yu=n("gpt2"),Ku=n(" architecture."),em=c(),mo=a("p"),tm=n("Configuration objects inherit from "),oi=a("a"),om=n("PretrainedConfig"),nm=n(` and can be used to control the model outputs. Read the
documentation from `),ni=a("a"),sm=n("PretrainedConfig"),am=n(" for more information."),rm=c(),v(Ko.$$.fragment),jc=c(),fo=a("h2"),en=a("a"),il=a("span"),v(Ss.$$.fragment),im=c(),ll=a("span"),lm=n("GPT2Tokenizer"),zc=c(),be=a("div"),v(Ls.$$.fragment),dm=c(),dl=a("p"),cm=n("Construct a GPT-2 tokenizer. Based on byte-level Byte-Pair-Encoding."),pm=c(),cl=a("p"),hm=n("This tokenizer has been trained to treat spaces like parts of the tokens (a bit like sentencepiece) so a word will"),um=c(),v(tn.$$.fragment),mm=c(),Xs=a("p"),fm=n("You can get around that behavior by passing "),pl=a("code"),gm=n("add_prefix_space=True"),_m=n(` when instantiating this tokenizer or when you
call it on some text, but since the model was not pretrained this way, it might yield a decrease in performance.`),Tm=c(),v(on.$$.fragment),ym=c(),Os=a("p"),bm=n("This tokenizer inherits from "),si=a("a"),vm=n("PreTrainedTokenizer"),km=n(` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),wm=c(),ai=a("div"),v(Qs.$$.fragment),xc=c(),go=a("h2"),nn=a("a"),hl=a("span"),v(Ys.$$.fragment),Mm=c(),ul=a("span"),$m=n("GPT2TokenizerFast"),Cc=c(),We=a("div"),v(Ks.$$.fragment),Pm=c(),ea=a("p"),Gm=n("Construct a \u201Cfast\u201D GPT-2 tokenizer (backed by HuggingFace\u2019s "),ml=a("em"),Fm=n("tokenizers"),Em=n(` library). Based on byte-level
Byte-Pair-Encoding.`),jm=c(),fl=a("p"),zm=n("This tokenizer has been trained to treat spaces like parts of the tokens (a bit like sentencepiece) so a word will"),xm=c(),v(sn.$$.fragment),Cm=c(),ta=a("p"),Um=n("You can get around that behavior by passing "),gl=a("code"),Jm=n("add_prefix_space=True"),Im=n(` when instantiating this tokenizer, but since
the model was not pretrained this way, it might yield a decrease in performance.`),Nm=c(),v(an.$$.fragment),qm=c(),oa=a("p"),Wm=n("This tokenizer inherits from "),ri=a("a"),Am=n("PreTrainedTokenizerFast"),Hm=n(` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Uc=c(),_o=a("h2"),rn=a("a"),_l=a("span"),v(na.$$.fragment),Zm=c(),Tl=a("span"),Bm=n("GPT2 specific outputs"),Jc=c(),To=a("div"),v(sa.$$.fragment),Rm=c(),yl=a("p"),Dm=n("Base class for outputs of models predicting if two sentences are consecutive or not."),Ic=c(),yo=a("div"),v(aa.$$.fragment),Vm=c(),bl=a("p"),Sm=n("Base class for outputs of models predicting if two sentences are consecutive or not."),Nc=c(),bo=a("h2"),ln=a("a"),vl=a("span"),v(ra.$$.fragment),Lm=c(),kl=a("span"),Xm=n("GPT2Model"),qc=c(),mt=a("div"),v(ia.$$.fragment),Om=c(),wl=a("p"),Qm=n("The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top."),Ym=c(),la=a("p"),Km=n("This model inherits from "),ii=a("a"),ef=n("PreTrainedModel"),tf=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.)`),of=c(),da=a("p"),nf=n("This model is also a PyTorch "),ca=a("a"),sf=n("torch.nn.Module"),af=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),rf=c(),jt=a("div"),v(pa.$$.fragment),lf=c(),vo=a("p"),df=n("The "),li=a("a"),cf=n("GPT2Model"),pf=n(" forward method, overrides the "),Ml=a("code"),hf=n("__call__"),uf=n(" special method."),mf=c(),v(dn.$$.fragment),ff=c(),v(cn.$$.fragment),Wc=c(),ko=a("h2"),pn=a("a"),$l=a("span"),v(ha.$$.fragment),gf=c(),Pl=a("span"),_f=n("GPT2LMHeadModel"),Ac=c(),ft=a("div"),v(ua.$$.fragment),Tf=c(),Gl=a("p"),yf=n(`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input
embeddings).`),bf=c(),ma=a("p"),vf=n("This model inherits from "),di=a("a"),kf=n("PreTrainedModel"),wf=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.)`),Mf=c(),fa=a("p"),$f=n("This model is also a PyTorch "),ga=a("a"),Pf=n("torch.nn.Module"),Gf=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ff=c(),zt=a("div"),v(_a.$$.fragment),Ef=c(),wo=a("p"),jf=n("The "),ci=a("a"),zf=n("GPT2LMHeadModel"),xf=n(" forward method, overrides the "),Fl=a("code"),Cf=n("__call__"),Uf=n(" special method."),Jf=c(),v(hn.$$.fragment),If=c(),v(un.$$.fragment),Hc=c(),Mo=a("h2"),mn=a("a"),El=a("span"),v(Ta.$$.fragment),Nf=c(),jl=a("span"),qf=n("GPT2DoubleHeadsModel"),Zc=c(),gt=a("div"),v(ya.$$.fragment),Wf=c(),zl=a("p"),Af=n(`The GPT2 Model transformer with a language modeling and a multiple-choice classification head on top e.g. for
RocStories/SWAG tasks. The two heads are two linear layers. The language modeling head has its weights tied to the
input embeddings, the classification head takes as input the input of a specified classification token index in the
input sequence).`),Hf=c(),ba=a("p"),Zf=n("This model inherits from "),pi=a("a"),Bf=n("PreTrainedModel"),Rf=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.)`),Df=c(),va=a("p"),Vf=n("This model is also a PyTorch "),ka=a("a"),Sf=n("torch.nn.Module"),Lf=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Xf=c(),xt=a("div"),v(wa.$$.fragment),Of=c(),$o=a("p"),Qf=n("The "),hi=a("a"),Yf=n("GPT2DoubleHeadsModel"),Kf=n(" forward method, overrides the "),xl=a("code"),eg=n("__call__"),tg=n(" special method."),og=c(),v(fn.$$.fragment),ng=c(),v(gn.$$.fragment),Bc=c(),Po=a("h2"),_n=a("a"),Cl=a("span"),v(Ma.$$.fragment),sg=c(),Ul=a("span"),ag=n("GPT2ForQuestionAnswering"),Rc=c(),_t=a("div"),v($a.$$.fragment),rg=c(),Go=a("p"),ig=n(`The GPT-2 Model transformer with a span classification head on top for extractive question-answering tasks like
SQuAD (a linear layer on top of the hidden-states output to compute `),Jl=a("code"),lg=n("span start logits"),dg=n(" and "),Il=a("code"),cg=n("span end logits"),pg=n(")."),hg=c(),Pa=a("p"),ug=n("This model inherits from "),ui=a("a"),mg=n("PreTrainedModel"),fg=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.)`),gg=c(),Ga=a("p"),_g=n("This model is also a PyTorch "),Fa=a("a"),Tg=n("torch.nn.Module"),yg=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),bg=c(),yt=a("div"),v(Ea.$$.fragment),vg=c(),Fo=a("p"),kg=n("The "),mi=a("a"),wg=n("GPT2ForQuestionAnswering"),Mg=n(" forward method, overrides the "),Nl=a("code"),$g=n("__call__"),Pg=n(" special method."),Gg=c(),v(Tn.$$.fragment),Fg=c(),v(yn.$$.fragment),Eg=c(),v(bn.$$.fragment),Dc=c(),Eo=a("h2"),vn=a("a"),ql=a("span"),v(ja.$$.fragment),jg=c(),Wl=a("span"),zg=n("GPT2ForSequenceClassification"),Vc=c(),Ae=a("div"),v(za.$$.fragment),xg=c(),Al=a("p"),Cg=n("The GPT2 Model transformer with a sequence classification head on top (linear layer)."),Ug=c(),fi=a("p"),gi=a("a"),Jg=n("GPT2ForSequenceClassification"),Ig=n(` uses the last token in order to do the classification, as other causal models
(e.g. GPT-1) do.`),Ng=c(),Gt=a("p"),qg=n(`Since it does classification on the last token, it requires to know the position of the last token. If a
`),Hl=a("code"),Wg=n("pad_token_id"),Ag=n(` is defined in the configuration, it finds the last token that is not a padding token in each row. If
no `),Zl=a("code"),Hg=n("pad_token_id"),Zg=n(` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
padding tokens when `),Bl=a("code"),Bg=n("inputs_embeds"),Rg=n(" are passed instead of "),Rl=a("code"),Dg=n("input_ids"),Vg=n(`, it does the same (take the last value in
each row of the batch).`),Sg=c(),xa=a("p"),Lg=n("This model inherits from "),_i=a("a"),Xg=n("PreTrainedModel"),Og=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.)`),Qg=c(),Ca=a("p"),Yg=n("This model is also a PyTorch "),Ua=a("a"),Kg=n("torch.nn.Module"),e_=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),t_=c(),bt=a("div"),v(Ja.$$.fragment),o_=c(),jo=a("p"),n_=n("The "),Ti=a("a"),s_=n("GPT2ForSequenceClassification"),a_=n(" forward method, overrides the "),Dl=a("code"),r_=n("__call__"),i_=n(" special method."),l_=c(),v(kn.$$.fragment),d_=c(),v(wn.$$.fragment),c_=c(),v(Mn.$$.fragment),Sc=c(),zo=a("h2"),$n=a("a"),Vl=a("span"),v(Ia.$$.fragment),p_=c(),Sl=a("span"),h_=n("GPT2ForTokenClassification"),Lc=c(),Tt=a("div"),v(Na.$$.fragment),u_=c(),Ll=a("p"),m_=n(`GPT2 Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
Named-Entity-Recognition (NER) tasks.`),f_=c(),qa=a("p"),g_=n("This model inherits from "),yi=a("a"),__=n("PreTrainedModel"),T_=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.)`),y_=c(),Wa=a("p"),b_=n("This model is also a PyTorch "),Aa=a("a"),v_=n("torch.nn.Module"),k_=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),w_=c(),Ct=a("div"),v(Ha.$$.fragment),M_=c(),xo=a("p"),$_=n("The "),bi=a("a"),P_=n("GPT2ForTokenClassification"),G_=n(" forward method, overrides the "),Xl=a("code"),F_=n("__call__"),E_=n(" special method."),j_=c(),v(Pn.$$.fragment),z_=c(),v(Gn.$$.fragment),Xc=c(),Co=a("h2"),Fn=a("a"),Ol=a("span"),v(Za.$$.fragment),x_=c(),Ql=a("span"),C_=n("TFGPT2Model"),Oc=c(),Qe=a("div"),v(Ba.$$.fragment),U_=c(),Yl=a("p"),J_=n("The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top."),I_=c(),Ra=a("p"),N_=n("This model inherits from "),vi=a("a"),q_=n("TFPreTrainedModel"),W_=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.)`),A_=c(),Da=a("p"),H_=n("This model is also a "),Va=a("a"),Z_=n("tf.keras.Model"),B_=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.`),R_=c(),v(En.$$.fragment),D_=c(),Ut=a("div"),v(Sa.$$.fragment),V_=c(),Uo=a("p"),S_=n("The "),ki=a("a"),L_=n("TFGPT2Model"),X_=n(" forward method, overrides the "),Kl=a("code"),O_=n("__call__"),Q_=n(" special method."),Y_=c(),v(jn.$$.fragment),K_=c(),v(zn.$$.fragment),Qc=c(),Jo=a("h2"),xn=a("a"),ed=a("span"),v(La.$$.fragment),eT=c(),td=a("span"),tT=n("TFGPT2LMHeadModel"),Yc=c(),Ye=a("div"),v(Xa.$$.fragment),oT=c(),od=a("p"),nT=n(`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input
embeddings).`),sT=c(),Oa=a("p"),aT=n("This model inherits from "),wi=a("a"),rT=n("TFPreTrainedModel"),iT=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.)`),lT=c(),Qa=a("p"),dT=n("This model is also a "),Ya=a("a"),cT=n("tf.keras.Model"),pT=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.`),hT=c(),v(Cn.$$.fragment),uT=c(),Jt=a("div"),v(Ka.$$.fragment),mT=c(),Io=a("p"),fT=n("The "),Mi=a("a"),gT=n("TFGPT2LMHeadModel"),_T=n(" forward method, overrides the "),nd=a("code"),TT=n("__call__"),yT=n(" special method."),bT=c(),v(Un.$$.fragment),vT=c(),v(Jn.$$.fragment),Kc=c(),No=a("h2"),In=a("a"),sd=a("span"),v(er.$$.fragment),kT=c(),ad=a("span"),wT=n("TFGPT2DoubleHeadsModel"),ep=c(),Ke=a("div"),v(tr.$$.fragment),MT=c(),rd=a("p"),$T=n(`The GPT2 Model transformer with a language modeling and a multiple-choice classification head on top e.g. for
RocStories/SWAG tasks. The two heads are two linear layers. The language modeling head has its weights tied to the
input embeddings, the classification head takes as input the input of a specified classification token index in the
input sequence).`),PT=c(),or=a("p"),GT=n("This model inherits from "),$i=a("a"),FT=n("TFPreTrainedModel"),ET=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.)`),jT=c(),nr=a("p"),zT=n("This model is also a "),sr=a("a"),xT=n("tf.keras.Model"),CT=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.`),UT=c(),v(Nn.$$.fragment),JT=c(),It=a("div"),v(ar.$$.fragment),IT=c(),qo=a("p"),NT=n("The "),Pi=a("a"),qT=n("TFGPT2DoubleHeadsModel"),WT=n(" forward method, overrides the "),id=a("code"),AT=n("__call__"),HT=n(" special method."),ZT=c(),v(qn.$$.fragment),BT=c(),v(Wn.$$.fragment),tp=c(),Wo=a("h2"),An=a("a"),ld=a("span"),v(rr.$$.fragment),RT=c(),dd=a("span"),DT=n("TFGPT2ForSequenceClassification"),op=c(),ve=a("div"),v(ir.$$.fragment),VT=c(),cd=a("p"),ST=n("The GPT2 Model transformer with a sequence classification head on top (linear layer)."),LT=c(),Gi=a("p"),Fi=a("a"),XT=n("TFGPT2ForSequenceClassification"),OT=n(` uses the last token in order to do the classification, as other causal models
(e.g. GPT-1) do.`),QT=c(),Ft=a("p"),YT=n(`Since it does classification on the last token, it requires to know the position of the last token. If a
`),pd=a("code"),KT=n("pad_token_id"),ey=n(` is defined in the configuration, it finds the last token that is not a padding token in each row. If
no `),hd=a("code"),ty=n("pad_token_id"),oy=n(` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
padding tokens when `),ud=a("code"),ny=n("inputs_embeds"),sy=n(" are passed instead of "),md=a("code"),ay=n("input_ids"),ry=n(`, it does the same (take the last value in
each row of the batch).`),iy=c(),lr=a("p"),ly=n("This model inherits from "),Ei=a("a"),dy=n("TFPreTrainedModel"),cy=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.)`),py=c(),dr=a("p"),hy=n("This model is also a "),cr=a("a"),uy=n("tf.keras.Model"),my=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.`),fy=c(),v(Hn.$$.fragment),gy=c(),vt=a("div"),v(pr.$$.fragment),_y=c(),Ao=a("p"),Ty=n("The "),ji=a("a"),yy=n("TFGPT2ForSequenceClassification"),by=n(" forward method, overrides the "),fd=a("code"),vy=n("__call__"),ky=n(" special method."),wy=c(),v(Zn.$$.fragment),My=c(),v(Bn.$$.fragment),$y=c(),v(Rn.$$.fragment),np=c(),Ho=a("h2"),Dn=a("a"),gd=a("span"),v(hr.$$.fragment),Py=c(),_d=a("span"),Gy=n("TFSequenceClassifierOutputWithPast"),sp=c(),Zo=a("div"),v(ur.$$.fragment),Fy=c(),Td=a("p"),Ey=n("Base class for outputs of sentence classification models."),ap=c(),Bo=a("h2"),Vn=a("a"),yd=a("span"),v(mr.$$.fragment),jy=c(),bd=a("span"),zy=n("TFGPT2Tokenizer"),rp=c(),et=a("div"),v(fr.$$.fragment),xy=c(),Ro=a("p"),Cy=n(`This is an in-graph tokenizer for GPT2. It should be initialized similarly to other tokenizers, using the
`),vd=a("code"),Uy=n("from_pretrained()"),Jy=n(" method. It can also be initialized with the "),kd=a("code"),Iy=n("from_tokenizer()"),Ny=n(` method, which imports settings
from an existing standard tokenizer object.`),qy=c(),gr=a("p"),Wy=n(`In-graph tokenizers, unlike other Hugging Face tokenizers, are actually Keras layers and are designed to be run
when the model is called, rather than during preprocessing. As a result, they have somewhat more limited options
than standard tokenizer classes. They are most useful when you want to create an end-to-end model that goes
straight from `),wd=a("code"),Ay=n("tf.string"),Hy=n(" inputs to outputs."),Zy=c(),Sn=a("div"),v(_r.$$.fragment),By=c(),Md=a("p"),Ry=n("Creates TFGPT2Tokenizer from configurations"),Dy=c(),Yt=a("div"),v(Tr.$$.fragment),Vy=c(),$d=a("p"),Sy=n("Creates TFGPT2Tokenizer from pretrained GPT2Tokenizer"),Ly=c(),v(Ln.$$.fragment),Xy=c(),Kt=a("div"),v(yr.$$.fragment),Oy=c(),Pd=a("p"),Qy=n("Creates TFGPT2Tokenizer from GPT2Tokenizer"),Yy=c(),v(Xn.$$.fragment),ip=c(),Do=a("h2"),On=a("a"),Gd=a("span"),v(br.$$.fragment),Ky=c(),Fd=a("span"),eb=n("FlaxGPT2Model"),lp=c(),He=a("div"),v(vr.$$.fragment),tb=c(),Ed=a("p"),ob=n("The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top."),nb=c(),kr=a("p"),sb=n("This model inherits from "),zi=a("a"),ab=n("FlaxPreTrainedModel"),rb=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.)`),ib=c(),wr=a("p"),lb=n(`This model is also a Flax Linen
`),Mr=a("a"),db=n("flax.nn.Module"),cb=n(` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),pb=c(),jd=a("p"),hb=n("Finally, this model supports inherent JAX features such as:"),ub=c(),Dt=a("ul"),zd=a("li"),$r=a("a"),mb=n("Just-In-Time (JIT) compilation"),fb=c(),xd=a("li"),Pr=a("a"),gb=n("Automatic Differentiation"),_b=c(),Cd=a("li"),Gr=a("a"),Tb=n("Vectorization"),yb=c(),Ud=a("li"),Fr=a("a"),bb=n("Parallelization"),vb=c(),Nt=a("div"),v(Er.$$.fragment),kb=c(),Vo=a("p"),wb=n("The "),Jd=a("code"),Mb=n("FlaxGPT2PreTrainedModel"),$b=n(" forward method, overrides the "),Id=a("code"),Pb=n("__call__"),Gb=n(" special method."),Fb=c(),v(Qn.$$.fragment),Eb=c(),v(Yn.$$.fragment),dp=c(),So=a("h2"),Kn=a("a"),Nd=a("span"),v(jr.$$.fragment),jb=c(),qd=a("span"),zb=n("FlaxGPT2LMHeadModel"),cp=c(),Ze=a("div"),v(zr.$$.fragment),xb=c(),Wd=a("p"),Cb=n(`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input
embeddings).`),Ub=c(),xr=a("p"),Jb=n("This model inherits from "),xi=a("a"),Ib=n("FlaxPreTrainedModel"),Nb=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.)`),qb=c(),Cr=a("p"),Wb=n(`This model is also a Flax Linen
`),Ur=a("a"),Ab=n("flax.nn.Module"),Hb=n(` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),Zb=c(),Ad=a("p"),Bb=n("Finally, this model supports inherent JAX features such as:"),Rb=c(),Vt=a("ul"),Hd=a("li"),Jr=a("a"),Db=n("Just-In-Time (JIT) compilation"),Vb=c(),Zd=a("li"),Ir=a("a"),Sb=n("Automatic Differentiation"),Lb=c(),Bd=a("li"),Nr=a("a"),Xb=n("Vectorization"),Ob=c(),Rd=a("li"),qr=a("a"),Qb=n("Parallelization"),Yb=c(),qt=a("div"),v(Wr.$$.fragment),Kb=c(),Lo=a("p"),e2=n("The "),Dd=a("code"),t2=n("FlaxGPT2PreTrainedModel"),o2=n(" forward method, overrides the "),Vd=a("code"),n2=n("__call__"),s2=n(" special method."),a2=c(),v(es.$$.fragment),r2=c(),v(ts.$$.fragment),this.h()},l(o){const _=Lw('[data-svelte="svelte-1phssyn"]',document.head);d=r(_,"META",{name:!0,content:!0}),_.forEach(t),y=p(o),f=r(o,"H1",{class:!0});var Ar=i(f);m=r(Ar,"A",{id:!0,class:!0,href:!0});var Sd=i(m);T=r(Sd,"SPAN",{});var Ld=i(T);k(l.$$.fragment,Ld),Ld.forEach(t),Sd.forEach(t),h=p(Ar),F=r(Ar,"SPAN",{});var Xd=i(F);R=s(Xd,"OpenAI GPT2"),Xd.forEach(t),Ar.forEach(t),N=p(o),J=r(o,"DIV",{class:!0});var Hr=i(J);O=r(Hr,"A",{href:!0});var Od=i(O);re=r(Od,"IMG",{alt:!0,src:!0}),Od.forEach(t),Ge=p(Hr),S=r(Hr,"A",{href:!0});var Qd=i(S);fe=r(Qd,"IMG",{alt:!0,src:!0}),Qd.forEach(t),Hr.forEach(t),Q=p(o),le=r(o,"H2",{class:!0});var Zr=i(le);pe=r(Zr,"A",{id:!0,class:!0,href:!0});var Yd=i(pe);L=r(Yd,"SPAN",{});var Kd=i(L);k(he.$$.fragment,Kd),Kd.forEach(t),Yd.forEach(t),Fe=p(Zr),X=r(Zr,"SPAN",{});var ec=i(X);Ee=s(ec,"Overview"),ec.forEach(t),Zr.forEach(t),Me=p(o),H=r(o,"P",{});var Xo=i(H);je=s(Xo,"OpenAI GPT-2 model was proposed in "),ue=r(Xo,"A",{href:!0,rel:!0});var tc=i(ue);me=s(tc,"Language Models are Unsupervised Multitask Learners"),tc.forEach(t),x=s(Xo,` by Alec
Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei and Ilya Sutskever from `),C=r(Xo,"A",{href:!0,rel:!0});var oc=i(C);ze=s(oc,"OpenAI"),oc.forEach(t),oe=s(Xo,`. It\u2019s a causal (unidirectional)
transformer pretrained using language modeling on a very large corpus of ~40 GB of text data.`),Xo.forEach(t),$e=p(o),ge=r(o,"P",{});var nc=i(ge);ne=s(nc,"The abstract from the paper is the following:"),nc.forEach(t),Pe=p(o),_e=r(o,"P",{});var sc=i(_e);U=r(sc,"EM",{});var ac=i(U);xe=s(ac,`GPT-2 is a large transformer-based language model with 1.5 billion parameters, trained on a dataset[1] of 8 million
web pages. GPT-2 is trained with a simple objective: predict the next word, given all of the previous words within some
text. The diversity of the dataset causes this simple goal to contain naturally occurring demonstrations of many tasks
across diverse domains. GPT-2 is a direct scale-up of GPT, with more than 10X the parameters and trained on more than
10X the amount of data.`),ac.forEach(t),sc.forEach(t),Y=p(o),Te=r(o,"P",{});var rc=i(Te);Ce=s(rc,"Tips:"),rc.forEach(t),K=p(o),ee=r(o,"UL",{});var St=i(ee);ye=r(St,"LI",{});var ic=i(ye);D=s(ic,`GPT-2 is a model with absolute position embeddings so it\u2019s usually advised to pad the inputs on the right rather than
the left.`),ic.forEach(t),Ue=p(St),V=r(St,"LI",{});var Br=i(V);Je=s(Br,`GPT-2 was trained with a causal language modeling (CLM) objective and is therefore powerful at predicting the next
token in a sequence. Leveraging this feature allows GPT-2 to generate syntactically coherent text as it can be
observed in the `),de=r(Br,"EM",{});var lc=i(de);I=s(lc,"run_generation.py"),lc.forEach(t),Ie=s(Br," example script."),Br.forEach(t),W=p(St),q=r(St,"LI",{});var ke=i(q);Ne=s(ke,"The model can take the "),b=r(ke,"EM",{});var dc=i(b);j=s(dc,"past_key_values"),dc.forEach(t),nt=s(ke," (for PyTorch) or "),ce=r(ke,"EM",{});var cc=i(ce);st=s(cc,"past"),cc.forEach(t),at=s(ke,` (for TF) as input, which is the previously computed
key/value attention pairs. Using this (`),z=r(ke,"EM",{});var pc=i(z);rt=s(pc,"past_key_values"),pc.forEach(t),it=s(ke," or "),Xe=r(ke,"EM",{});var hc=i(Xe);lt=s(hc,"past"),hc.forEach(t),dt=s(ke,`) value prevents the model from re-computing
pre-computed values in the context of text generation. For PyTorch, see `),Z=r(ke,"EM",{});var uc=i(Z);se=s(uc,"past_key_values"),uc.forEach(t),ct=s(ke,` argument of the
`),Le=r(ke,"A",{href:!0});var mc=i(Le);ae=s(mc,"GPT2Model.forward()"),mc.forEach(t),pt=s(ke," method, or for TF the "),Oe=r(ke,"EM",{});var fc=i(Oe);qe=s(fc,"past"),fc.forEach(t),ht=s(ke,` argument of the
`),ie=r(ke,"A",{href:!0});var gc=i(ie);ut=s(gc,"TFGPT2Model.call()"),gc.forEach(t),Th=s(ke," method for more information on its usage."),ke.forEach(t),yh=p(St),Bt=r(St,"LI",{});var Lt=i(Bt);bh=s(Lt,"Enabling the "),Qi=r(Lt,"EM",{});var _c=i(Qi);vh=s(_c,"scale_attn_by_inverse_layer_idx"),_c.forEach(t),kh=s(Lt," and "),Yi=r(Lt,"EM",{});var Tc=i(Yi);wh=s(Tc,"reorder_and_upcast_attn"),Tc.forEach(t),Mh=s(Lt,` flags will apply the training stability
improvements from `),gs=r(Lt,"A",{href:!0,rel:!0});var yc=i(gs);$h=s(yc,"Mistral"),yc.forEach(t),Ph=s(Lt," (for PyTorch only)."),Lt.forEach(t),St.forEach(t),kc=p(o),po=r(o,"P",{});var os=i(po);_s=r(os,"A",{href:!0,rel:!0});var bc=i(_s);Gh=s(bc,"Write With Transformer"),bc.forEach(t),Fh=s(os,` is a webapp created and hosted by
Hugging Face showcasing the generative capabilities of several models. GPT-2 is one of them and is available in five
different sizes: small, medium, large, xl and a distilled version of the small checkpoint: `),Ki=r(os,"EM",{});var vc=i(Ki);Eh=s(vc,"distilgpt-2"),vc.forEach(t),jh=s(os,"."),os.forEach(t),wc=p(o),Xt=r(o,"P",{});var Ci=i(Xt);zh=s(Ci,"This model was contributed by "),Ts=r(Ci,"A",{href:!0,rel:!0});var c2=i(Ts);xh=s(c2,"thomwolf"),c2.forEach(t),Ch=s(Ci,". The original code can be found "),ys=r(Ci,"A",{href:!0,rel:!0});var p2=i(ys);Uh=s(p2,"here"),p2.forEach(t),Jh=s(Ci,"."),Ci.forEach(t),Mc=p(o),ho=r(o,"H2",{class:!0});var hp=i(ho);Qo=r(hp,"A",{id:!0,class:!0,href:!0});var h2=i(Qo);el=r(h2,"SPAN",{});var u2=i(el);k(bs.$$.fragment,u2),u2.forEach(t),h2.forEach(t),Ih=p(hp),tl=r(hp,"SPAN",{});var m2=i(tl);Nh=s(m2,"Resources"),m2.forEach(t),hp.forEach(t),$c=p(o),Vr=r(o,"P",{});var f2=i(Vr);qh=s(f2,"A list of official Hugging Face and community (indicated by \u{1F30E}) resources to help you get started with GPT2. If you\u2019re interested in submitting a resource to be included here, please feel free to open a Pull Request and we\u2019ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource."),f2.forEach(t),Pc=p(o),k(vs.$$.fragment,o),Gc=p(o),B=r(o,"UL",{});var te=i(B);ks=r(te,"LI",{});var up=i(ks);Wh=s(up,"A blog on how to "),ws=r(up,"A",{href:!0,rel:!0});var g2=i(ws);Ah=s(g2,"Finetune a non-English GPT-2 Model with Hugging Face"),g2.forEach(t),Hh=s(up,"."),up.forEach(t),Zh=p(te),Ms=r(te,"LI",{});var mp=i(Ms);Bh=s(mp,"A blog on "),$s=r(mp,"A",{href:!0,rel:!0});var _2=i($s);Rh=s(_2,"How to generate text: using different decoding methods for language generation with Transformers"),_2.forEach(t),Dh=s(mp," with GPT-2."),mp.forEach(t),Vh=p(te),Ps=r(te,"LI",{});var fp=i(Ps);Sh=s(fp,"A blog on "),Gs=r(fp,"A",{href:!0,rel:!0});var T2=i(Gs);Lh=s(T2,"Training CodeParrot \u{1F99C} from Scratch"),T2.forEach(t),Xh=s(fp,", a large GPT-2 model."),fp.forEach(t),Oh=p(te),Fs=r(te,"LI",{});var gp=i(Fs);Qh=s(gp,"A blog on "),Es=r(gp,"A",{href:!0,rel:!0});var y2=i(Es);Yh=s(y2,"Faster Text Generation with TensorFlow and XLA"),y2.forEach(t),Kh=s(gp," with GPT-2."),gp.forEach(t),eu=p(te),js=r(te,"LI",{});var _p=i(js);tu=s(_p,"A blog on "),zs=r(_p,"A",{href:!0,rel:!0});var b2=i(zs);ou=s(b2,"How to train a Language Model with Megatron-LM"),b2.forEach(t),nu=s(_p," with a GPT-2 model."),_p.forEach(t),su=p(te),xs=r(te,"LI",{});var Tp=i(xs);au=s(Tp,"A notebook on how to "),Cs=r(Tp,"A",{href:!0,rel:!0});var v2=i(Cs);ru=s(v2,"finetune GPT2 to generate lyrics in the style of your favorite artist"),v2.forEach(t),iu=s(Tp,". \u{1F30E}"),Tp.forEach(t),lu=p(te),Us=r(te,"LI",{});var yp=i(Us);du=s(yp,"A notebook on how to "),Js=r(yp,"A",{href:!0,rel:!0});var k2=i(Js);cu=s(k2,"finetune GPT2 to generate tweets in the style of your favorite Twitter user"),k2.forEach(t),pu=s(yp,". \u{1F30E}"),yp.forEach(t),hu=p(te),Sr=r(te,"LI",{});var i2=i(Sr);Is=r(i2,"A",{href:!0,rel:!0});var w2=i(Is);uu=s(w2,"Causal language modeling"),w2.forEach(t),mu=s(i2," chapter of the \u{1F917} Hugging Face Course."),i2.forEach(t),fu=p(te),Et=r(te,"LI",{});var Oo=i(Et);Lr=r(Oo,"A",{href:!0});var M2=i(Lr);gu=s(M2,"GPT2LMHeadModel"),M2.forEach(t),_u=s(Oo," is supported by this "),Ns=r(Oo,"A",{href:!0,rel:!0});var $2=i(Ns);Tu=s($2,"causal language modeling example script"),$2.forEach(t),yu=s(Oo,", "),qs=r(Oo,"A",{href:!0,rel:!0});var P2=i(qs);bu=s(P2,"text generation example script"),P2.forEach(t),vu=s(Oo,", and "),Ws=r(Oo,"A",{href:!0,rel:!0});var G2=i(Ws);ku=s(G2,"notebook"),G2.forEach(t),wu=s(Oo,"."),Oo.forEach(t),Mu=p(te),Ot=r(te,"LI",{});var Rr=i(Ot);Xr=r(Rr,"A",{href:!0});var F2=i(Xr);$u=s(F2,"TFGPT2LMHeadModel"),F2.forEach(t),Pu=s(Rr," is supported by this "),As=r(Rr,"A",{href:!0,rel:!0});var E2=i(As);Gu=s(E2,"causal language modeling example script"),E2.forEach(t),Fu=s(Rr," and "),Hs=r(Rr,"A",{href:!0,rel:!0});var j2=i(Hs);Eu=s(j2,"notebook"),j2.forEach(t),ju=s(Rr,"."),Rr.forEach(t),zu=p(te),Qt=r(te,"LI",{});var Dr=i(Qt);Or=r(Dr,"A",{href:!0});var z2=i(Or);xu=s(z2,"FlaxGPT2LMHeadModel"),z2.forEach(t),Cu=s(Dr," is supported by this "),Zs=r(Dr,"A",{href:!0,rel:!0});var x2=i(Zs);Uu=s(x2,"causal language modeling example script"),x2.forEach(t),Ju=s(Dr," and "),Bs=r(Dr,"A",{href:!0,rel:!0});var C2=i(Bs);Iu=s(C2,"notebook"),C2.forEach(t),Nu=s(Dr,"."),Dr.forEach(t),qu=p(te),ol=r(te,"LI",{});var U2=i(ol);Qr=r(U2,"A",{href:!0});var J2=i(Qr);Wu=s(J2,"Text classification task guide"),J2.forEach(t),U2.forEach(t),Au=p(te),nl=r(te,"LI",{});var I2=i(nl);Yr=r(I2,"A",{href:!0});var N2=i(Yr);Hu=s(N2,"Token classification task guide"),N2.forEach(t),I2.forEach(t),Zu=p(te),sl=r(te,"LI",{});var q2=i(sl);Kr=r(q2,"A",{href:!0});var W2=i(Kr);Bu=s(W2,"Causal language modeling task guide"),W2.forEach(t),q2.forEach(t),te.forEach(t),Fc=p(o),uo=r(o,"H2",{class:!0});var bp=i(uo);Yo=r(bp,"A",{id:!0,class:!0,href:!0});var A2=i(Yo);al=r(A2,"SPAN",{});var H2=i(al);k(Rs.$$.fragment,H2),H2.forEach(t),A2.forEach(t),Ru=p(bp),rl=r(bp,"SPAN",{});var Z2=i(rl);Du=s(Z2,"GPT2Config"),Z2.forEach(t),bp.forEach(t),Ec=p(o),Pt=r(o,"DIV",{class:!0});var ns=i(Pt);k(Ds.$$.fragment,ns),Vu=p(ns),Rt=r(ns,"P",{});var ss=i(Rt);Su=s(ss,"This is the configuration class to store the configuration of a "),ei=r(ss,"A",{href:!0});var B2=i(ei);Lu=s(B2,"GPT2Model"),B2.forEach(t),Xu=s(ss," or a "),ti=r(ss,"A",{href:!0});var R2=i(ti);Ou=s(R2,"TFGPT2Model"),R2.forEach(t),Qu=s(ss,`. It is used to
instantiate a GPT-2 model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a similar configuration to that of the GPT-2
`),Vs=r(ss,"A",{href:!0,rel:!0});var D2=i(Vs);Yu=s(D2,"gpt2"),D2.forEach(t),Ku=s(ss," architecture."),ss.forEach(t),em=p(ns),mo=r(ns,"P",{});var Ui=i(mo);tm=s(Ui,"Configuration objects inherit from "),oi=r(Ui,"A",{href:!0});var V2=i(oi);om=s(V2,"PretrainedConfig"),V2.forEach(t),nm=s(Ui,` and can be used to control the model outputs. Read the
documentation from `),ni=r(Ui,"A",{href:!0});var S2=i(ni);sm=s(S2,"PretrainedConfig"),S2.forEach(t),am=s(Ui," for more information."),Ui.forEach(t),rm=p(ns),k(Ko.$$.fragment,ns),ns.forEach(t),jc=p(o),fo=r(o,"H2",{class:!0});var vp=i(fo);en=r(vp,"A",{id:!0,class:!0,href:!0});var L2=i(en);il=r(L2,"SPAN",{});var X2=i(il);k(Ss.$$.fragment,X2),X2.forEach(t),L2.forEach(t),im=p(vp),ll=r(vp,"SPAN",{});var O2=i(ll);lm=s(O2,"GPT2Tokenizer"),O2.forEach(t),vp.forEach(t),zc=p(o),be=r(o,"DIV",{class:!0});var tt=i(be);k(Ls.$$.fragment,tt),dm=p(tt),dl=r(tt,"P",{});var Q2=i(dl);cm=s(Q2,"Construct a GPT-2 tokenizer. Based on byte-level Byte-Pair-Encoding."),Q2.forEach(t),pm=p(tt),cl=r(tt,"P",{});var Y2=i(cl);hm=s(Y2,"This tokenizer has been trained to treat spaces like parts of the tokens (a bit like sentencepiece) so a word will"),Y2.forEach(t),um=p(tt),k(tn.$$.fragment,tt),mm=p(tt),Xs=r(tt,"P",{});var kp=i(Xs);fm=s(kp,"You can get around that behavior by passing "),pl=r(kp,"CODE",{});var K2=i(pl);gm=s(K2,"add_prefix_space=True"),K2.forEach(t),_m=s(kp,` when instantiating this tokenizer or when you
call it on some text, but since the model was not pretrained this way, it might yield a decrease in performance.`),kp.forEach(t),Tm=p(tt),k(on.$$.fragment,tt),ym=p(tt),Os=r(tt,"P",{});var wp=i(Os);bm=s(wp,"This tokenizer inherits from "),si=r(wp,"A",{href:!0});var ev=i(si);vm=s(ev,"PreTrainedTokenizer"),ev.forEach(t),km=s(wp,` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),wp.forEach(t),wm=p(tt),ai=r(tt,"DIV",{class:!0});var tv=i(ai);k(Qs.$$.fragment,tv),tv.forEach(t),tt.forEach(t),xc=p(o),go=r(o,"H2",{class:!0});var Mp=i(go);nn=r(Mp,"A",{id:!0,class:!0,href:!0});var ov=i(nn);hl=r(ov,"SPAN",{});var nv=i(hl);k(Ys.$$.fragment,nv),nv.forEach(t),ov.forEach(t),Mm=p(Mp),ul=r(Mp,"SPAN",{});var sv=i(ul);$m=s(sv,"GPT2TokenizerFast"),sv.forEach(t),Mp.forEach(t),Cc=p(o),We=r(o,"DIV",{class:!0});var kt=i(We);k(Ks.$$.fragment,kt),Pm=p(kt),ea=r(kt,"P",{});var $p=i(ea);Gm=s($p,"Construct a \u201Cfast\u201D GPT-2 tokenizer (backed by HuggingFace\u2019s "),ml=r($p,"EM",{});var av=i(ml);Fm=s(av,"tokenizers"),av.forEach(t),Em=s($p,` library). Based on byte-level
Byte-Pair-Encoding.`),$p.forEach(t),jm=p(kt),fl=r(kt,"P",{});var rv=i(fl);zm=s(rv,"This tokenizer has been trained to treat spaces like parts of the tokens (a bit like sentencepiece) so a word will"),rv.forEach(t),xm=p(kt),k(sn.$$.fragment,kt),Cm=p(kt),ta=r(kt,"P",{});var Pp=i(ta);Um=s(Pp,"You can get around that behavior by passing "),gl=r(Pp,"CODE",{});var iv=i(gl);Jm=s(iv,"add_prefix_space=True"),iv.forEach(t),Im=s(Pp,` when instantiating this tokenizer, but since
the model was not pretrained this way, it might yield a decrease in performance.`),Pp.forEach(t),Nm=p(kt),k(an.$$.fragment,kt),qm=p(kt),oa=r(kt,"P",{});var Gp=i(oa);Wm=s(Gp,"This tokenizer inherits from "),ri=r(Gp,"A",{href:!0});var lv=i(ri);Am=s(lv,"PreTrainedTokenizerFast"),lv.forEach(t),Hm=s(Gp,` which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.`),Gp.forEach(t),kt.forEach(t),Uc=p(o),_o=r(o,"H2",{class:!0});var Fp=i(_o);rn=r(Fp,"A",{id:!0,class:!0,href:!0});var dv=i(rn);_l=r(dv,"SPAN",{});var cv=i(_l);k(na.$$.fragment,cv),cv.forEach(t),dv.forEach(t),Zm=p(Fp),Tl=r(Fp,"SPAN",{});var pv=i(Tl);Bm=s(pv,"GPT2 specific outputs"),pv.forEach(t),Fp.forEach(t),Jc=p(o),To=r(o,"DIV",{class:!0});var Ep=i(To);k(sa.$$.fragment,Ep),Rm=p(Ep),yl=r(Ep,"P",{});var hv=i(yl);Dm=s(hv,"Base class for outputs of models predicting if two sentences are consecutive or not."),hv.forEach(t),Ep.forEach(t),Ic=p(o),yo=r(o,"DIV",{class:!0});var jp=i(yo);k(aa.$$.fragment,jp),Vm=p(jp),bl=r(jp,"P",{});var uv=i(bl);Sm=s(uv,"Base class for outputs of models predicting if two sentences are consecutive or not."),uv.forEach(t),jp.forEach(t),Nc=p(o),bo=r(o,"H2",{class:!0});var zp=i(bo);ln=r(zp,"A",{id:!0,class:!0,href:!0});var mv=i(ln);vl=r(mv,"SPAN",{});var fv=i(vl);k(ra.$$.fragment,fv),fv.forEach(t),mv.forEach(t),Lm=p(zp),kl=r(zp,"SPAN",{});var gv=i(kl);Xm=s(gv,"GPT2Model"),gv.forEach(t),zp.forEach(t),qc=p(o),mt=r(o,"DIV",{class:!0});var eo=i(mt);k(ia.$$.fragment,eo),Om=p(eo),wl=r(eo,"P",{});var _v=i(wl);Qm=s(_v,"The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top."),_v.forEach(t),Ym=p(eo),la=r(eo,"P",{});var xp=i(la);Km=s(xp,"This model inherits from "),ii=r(xp,"A",{href:!0});var Tv=i(ii);ef=s(Tv,"PreTrainedModel"),Tv.forEach(t),tf=s(xp,`. 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.)`),xp.forEach(t),of=p(eo),da=r(eo,"P",{});var Cp=i(da);nf=s(Cp,"This model is also a PyTorch "),ca=r(Cp,"A",{href:!0,rel:!0});var yv=i(ca);sf=s(yv,"torch.nn.Module"),yv.forEach(t),af=s(Cp,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Cp.forEach(t),rf=p(eo),jt=r(eo,"DIV",{class:!0});var as=i(jt);k(pa.$$.fragment,as),lf=p(as),vo=r(as,"P",{});var Ji=i(vo);df=s(Ji,"The "),li=r(Ji,"A",{href:!0});var bv=i(li);cf=s(bv,"GPT2Model"),bv.forEach(t),pf=s(Ji," forward method, overrides the "),Ml=r(Ji,"CODE",{});var vv=i(Ml);hf=s(vv,"__call__"),vv.forEach(t),uf=s(Ji," special method."),Ji.forEach(t),mf=p(as),k(dn.$$.fragment,as),ff=p(as),k(cn.$$.fragment,as),as.forEach(t),eo.forEach(t),Wc=p(o),ko=r(o,"H2",{class:!0});var Up=i(ko);pn=r(Up,"A",{id:!0,class:!0,href:!0});var kv=i(pn);$l=r(kv,"SPAN",{});var wv=i($l);k(ha.$$.fragment,wv),wv.forEach(t),kv.forEach(t),gf=p(Up),Pl=r(Up,"SPAN",{});var Mv=i(Pl);_f=s(Mv,"GPT2LMHeadModel"),Mv.forEach(t),Up.forEach(t),Ac=p(o),ft=r(o,"DIV",{class:!0});var to=i(ft);k(ua.$$.fragment,to),Tf=p(to),Gl=r(to,"P",{});var $v=i(Gl);yf=s($v,`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input
embeddings).`),$v.forEach(t),bf=p(to),ma=r(to,"P",{});var Jp=i(ma);vf=s(Jp,"This model inherits from "),di=r(Jp,"A",{href:!0});var Pv=i(di);kf=s(Pv,"PreTrainedModel"),Pv.forEach(t),wf=s(Jp,`. 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.)`),Jp.forEach(t),Mf=p(to),fa=r(to,"P",{});var Ip=i(fa);$f=s(Ip,"This model is also a PyTorch "),ga=r(Ip,"A",{href:!0,rel:!0});var Gv=i(ga);Pf=s(Gv,"torch.nn.Module"),Gv.forEach(t),Gf=s(Ip,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ip.forEach(t),Ff=p(to),zt=r(to,"DIV",{class:!0});var rs=i(zt);k(_a.$$.fragment,rs),Ef=p(rs),wo=r(rs,"P",{});var Ii=i(wo);jf=s(Ii,"The "),ci=r(Ii,"A",{href:!0});var Fv=i(ci);zf=s(Fv,"GPT2LMHeadModel"),Fv.forEach(t),xf=s(Ii," forward method, overrides the "),Fl=r(Ii,"CODE",{});var Ev=i(Fl);Cf=s(Ev,"__call__"),Ev.forEach(t),Uf=s(Ii," special method."),Ii.forEach(t),Jf=p(rs),k(hn.$$.fragment,rs),If=p(rs),k(un.$$.fragment,rs),rs.forEach(t),to.forEach(t),Hc=p(o),Mo=r(o,"H2",{class:!0});var Np=i(Mo);mn=r(Np,"A",{id:!0,class:!0,href:!0});var jv=i(mn);El=r(jv,"SPAN",{});var zv=i(El);k(Ta.$$.fragment,zv),zv.forEach(t),jv.forEach(t),Nf=p(Np),jl=r(Np,"SPAN",{});var xv=i(jl);qf=s(xv,"GPT2DoubleHeadsModel"),xv.forEach(t),Np.forEach(t),Zc=p(o),gt=r(o,"DIV",{class:!0});var oo=i(gt);k(ya.$$.fragment,oo),Wf=p(oo),zl=r(oo,"P",{});var Cv=i(zl);Af=s(Cv,`The GPT2 Model transformer with a language modeling and a multiple-choice classification head on top e.g. for
RocStories/SWAG tasks. The two heads are two linear layers. The language modeling head has its weights tied to the
input embeddings, the classification head takes as input the input of a specified classification token index in the
input sequence).`),Cv.forEach(t),Hf=p(oo),ba=r(oo,"P",{});var qp=i(ba);Zf=s(qp,"This model inherits from "),pi=r(qp,"A",{href:!0});var Uv=i(pi);Bf=s(Uv,"PreTrainedModel"),Uv.forEach(t),Rf=s(qp,`. 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.)`),qp.forEach(t),Df=p(oo),va=r(oo,"P",{});var Wp=i(va);Vf=s(Wp,"This model is also a PyTorch "),ka=r(Wp,"A",{href:!0,rel:!0});var Jv=i(ka);Sf=s(Jv,"torch.nn.Module"),Jv.forEach(t),Lf=s(Wp,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Wp.forEach(t),Xf=p(oo),xt=r(oo,"DIV",{class:!0});var is=i(xt);k(wa.$$.fragment,is),Of=p(is),$o=r(is,"P",{});var Ni=i($o);Qf=s(Ni,"The "),hi=r(Ni,"A",{href:!0});var Iv=i(hi);Yf=s(Iv,"GPT2DoubleHeadsModel"),Iv.forEach(t),Kf=s(Ni," forward method, overrides the "),xl=r(Ni,"CODE",{});var Nv=i(xl);eg=s(Nv,"__call__"),Nv.forEach(t),tg=s(Ni," special method."),Ni.forEach(t),og=p(is),k(fn.$$.fragment,is),ng=p(is),k(gn.$$.fragment,is),is.forEach(t),oo.forEach(t),Bc=p(o),Po=r(o,"H2",{class:!0});var Ap=i(Po);_n=r(Ap,"A",{id:!0,class:!0,href:!0});var qv=i(_n);Cl=r(qv,"SPAN",{});var Wv=i(Cl);k(Ma.$$.fragment,Wv),Wv.forEach(t),qv.forEach(t),sg=p(Ap),Ul=r(Ap,"SPAN",{});var Av=i(Ul);ag=s(Av,"GPT2ForQuestionAnswering"),Av.forEach(t),Ap.forEach(t),Rc=p(o),_t=r(o,"DIV",{class:!0});var no=i(_t);k($a.$$.fragment,no),rg=p(no),Go=r(no,"P",{});var qi=i(Go);ig=s(qi,`The GPT-2 Model transformer with a span classification head on top for extractive question-answering tasks like
SQuAD (a linear layer on top of the hidden-states output to compute `),Jl=r(qi,"CODE",{});var Hv=i(Jl);lg=s(Hv,"span start logits"),Hv.forEach(t),dg=s(qi," and "),Il=r(qi,"CODE",{});var Zv=i(Il);cg=s(Zv,"span end logits"),Zv.forEach(t),pg=s(qi,")."),qi.forEach(t),hg=p(no),Pa=r(no,"P",{});var Hp=i(Pa);ug=s(Hp,"This model inherits from "),ui=r(Hp,"A",{href:!0});var Bv=i(ui);mg=s(Bv,"PreTrainedModel"),Bv.forEach(t),fg=s(Hp,`. 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.)`),Hp.forEach(t),gg=p(no),Ga=r(no,"P",{});var Zp=i(Ga);_g=s(Zp,"This model is also a PyTorch "),Fa=r(Zp,"A",{href:!0,rel:!0});var Rv=i(Fa);Tg=s(Rv,"torch.nn.Module"),Rv.forEach(t),yg=s(Zp,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Zp.forEach(t),bg=p(no),yt=r(no,"DIV",{class:!0});var so=i(yt);k(Ea.$$.fragment,so),vg=p(so),Fo=r(so,"P",{});var Wi=i(Fo);kg=s(Wi,"The "),mi=r(Wi,"A",{href:!0});var Dv=i(mi);wg=s(Dv,"GPT2ForQuestionAnswering"),Dv.forEach(t),Mg=s(Wi," forward method, overrides the "),Nl=r(Wi,"CODE",{});var Vv=i(Nl);$g=s(Vv,"__call__"),Vv.forEach(t),Pg=s(Wi," special method."),Wi.forEach(t),Gg=p(so),k(Tn.$$.fragment,so),Fg=p(so),k(yn.$$.fragment,so),Eg=p(so),k(bn.$$.fragment,so),so.forEach(t),no.forEach(t),Dc=p(o),Eo=r(o,"H2",{class:!0});var Bp=i(Eo);vn=r(Bp,"A",{id:!0,class:!0,href:!0});var Sv=i(vn);ql=r(Sv,"SPAN",{});var Lv=i(ql);k(ja.$$.fragment,Lv),Lv.forEach(t),Sv.forEach(t),jg=p(Bp),Wl=r(Bp,"SPAN",{});var Xv=i(Wl);zg=s(Xv,"GPT2ForSequenceClassification"),Xv.forEach(t),Bp.forEach(t),Vc=p(o),Ae=r(o,"DIV",{class:!0});var wt=i(Ae);k(za.$$.fragment,wt),xg=p(wt),Al=r(wt,"P",{});var Ov=i(Al);Cg=s(Ov,"The GPT2 Model transformer with a sequence classification head on top (linear layer)."),Ov.forEach(t),Ug=p(wt),fi=r(wt,"P",{});var l2=i(fi);gi=r(l2,"A",{href:!0});var Qv=i(gi);Jg=s(Qv,"GPT2ForSequenceClassification"),Qv.forEach(t),Ig=s(l2,` uses the last token in order to do the classification, as other causal models
(e.g. GPT-1) do.`),l2.forEach(t),Ng=p(wt),Gt=r(wt,"P",{});var ao=i(Gt);qg=s(ao,`Since it does classification on the last token, it requires to know the position of the last token. If a
`),Hl=r(ao,"CODE",{});var Yv=i(Hl);Wg=s(Yv,"pad_token_id"),Yv.forEach(t),Ag=s(ao,` is defined in the configuration, it finds the last token that is not a padding token in each row. If
no `),Zl=r(ao,"CODE",{});var Kv=i(Zl);Hg=s(Kv,"pad_token_id"),Kv.forEach(t),Zg=s(ao,` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
padding tokens when `),Bl=r(ao,"CODE",{});var ek=i(Bl);Bg=s(ek,"inputs_embeds"),ek.forEach(t),Rg=s(ao," are passed instead of "),Rl=r(ao,"CODE",{});var tk=i(Rl);Dg=s(tk,"input_ids"),tk.forEach(t),Vg=s(ao,`, it does the same (take the last value in
each row of the batch).`),ao.forEach(t),Sg=p(wt),xa=r(wt,"P",{});var Rp=i(xa);Lg=s(Rp,"This model inherits from "),_i=r(Rp,"A",{href:!0});var ok=i(_i);Xg=s(ok,"PreTrainedModel"),ok.forEach(t),Og=s(Rp,`. 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.)`),Rp.forEach(t),Qg=p(wt),Ca=r(wt,"P",{});var Dp=i(Ca);Yg=s(Dp,"This model is also a PyTorch "),Ua=r(Dp,"A",{href:!0,rel:!0});var nk=i(Ua);Kg=s(nk,"torch.nn.Module"),nk.forEach(t),e_=s(Dp,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Dp.forEach(t),t_=p(wt),bt=r(wt,"DIV",{class:!0});var ro=i(bt);k(Ja.$$.fragment,ro),o_=p(ro),jo=r(ro,"P",{});var Ai=i(jo);n_=s(Ai,"The "),Ti=r(Ai,"A",{href:!0});var sk=i(Ti);s_=s(sk,"GPT2ForSequenceClassification"),sk.forEach(t),a_=s(Ai," forward method, overrides the "),Dl=r(Ai,"CODE",{});var ak=i(Dl);r_=s(ak,"__call__"),ak.forEach(t),i_=s(Ai," special method."),Ai.forEach(t),l_=p(ro),k(kn.$$.fragment,ro),d_=p(ro),k(wn.$$.fragment,ro),c_=p(ro),k(Mn.$$.fragment,ro),ro.forEach(t),wt.forEach(t),Sc=p(o),zo=r(o,"H2",{class:!0});var Vp=i(zo);$n=r(Vp,"A",{id:!0,class:!0,href:!0});var rk=i($n);Vl=r(rk,"SPAN",{});var ik=i(Vl);k(Ia.$$.fragment,ik),ik.forEach(t),rk.forEach(t),p_=p(Vp),Sl=r(Vp,"SPAN",{});var lk=i(Sl);h_=s(lk,"GPT2ForTokenClassification"),lk.forEach(t),Vp.forEach(t),Lc=p(o),Tt=r(o,"DIV",{class:!0});var io=i(Tt);k(Na.$$.fragment,io),u_=p(io),Ll=r(io,"P",{});var dk=i(Ll);m_=s(dk,`GPT2 Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
Named-Entity-Recognition (NER) tasks.`),dk.forEach(t),f_=p(io),qa=r(io,"P",{});var Sp=i(qa);g_=s(Sp,"This model inherits from "),yi=r(Sp,"A",{href:!0});var ck=i(yi);__=s(ck,"PreTrainedModel"),ck.forEach(t),T_=s(Sp,`. 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.)`),Sp.forEach(t),y_=p(io),Wa=r(io,"P",{});var Lp=i(Wa);b_=s(Lp,"This model is also a PyTorch "),Aa=r(Lp,"A",{href:!0,rel:!0});var pk=i(Aa);v_=s(pk,"torch.nn.Module"),pk.forEach(t),k_=s(Lp,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Lp.forEach(t),w_=p(io),Ct=r(io,"DIV",{class:!0});var ls=i(Ct);k(Ha.$$.fragment,ls),M_=p(ls),xo=r(ls,"P",{});var Hi=i(xo);$_=s(Hi,"The "),bi=r(Hi,"A",{href:!0});var hk=i(bi);P_=s(hk,"GPT2ForTokenClassification"),hk.forEach(t),G_=s(Hi," forward method, overrides the "),Xl=r(Hi,"CODE",{});var uk=i(Xl);F_=s(uk,"__call__"),uk.forEach(t),E_=s(Hi," special method."),Hi.forEach(t),j_=p(ls),k(Pn.$$.fragment,ls),z_=p(ls),k(Gn.$$.fragment,ls),ls.forEach(t),io.forEach(t),Xc=p(o),Co=r(o,"H2",{class:!0});var Xp=i(Co);Fn=r(Xp,"A",{id:!0,class:!0,href:!0});var mk=i(Fn);Ol=r(mk,"SPAN",{});var fk=i(Ol);k(Za.$$.fragment,fk),fk.forEach(t),mk.forEach(t),x_=p(Xp),Ql=r(Xp,"SPAN",{});var gk=i(Ql);C_=s(gk,"TFGPT2Model"),gk.forEach(t),Xp.forEach(t),Oc=p(o),Qe=r(o,"DIV",{class:!0});var Wt=i(Qe);k(Ba.$$.fragment,Wt),U_=p(Wt),Yl=r(Wt,"P",{});var _k=i(Yl);J_=s(_k,"The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top."),_k.forEach(t),I_=p(Wt),Ra=r(Wt,"P",{});var Op=i(Ra);N_=s(Op,"This model inherits from "),vi=r(Op,"A",{href:!0});var Tk=i(vi);q_=s(Tk,"TFPreTrainedModel"),Tk.forEach(t),W_=s(Op,`. 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.)`),Op.forEach(t),A_=p(Wt),Da=r(Wt,"P",{});var Qp=i(Da);H_=s(Qp,"This model is also a "),Va=r(Qp,"A",{href:!0,rel:!0});var yk=i(Va);Z_=s(yk,"tf.keras.Model"),yk.forEach(t),B_=s(Qp,` 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.`),Qp.forEach(t),R_=p(Wt),k(En.$$.fragment,Wt),D_=p(Wt),Ut=r(Wt,"DIV",{class:!0});var ds=i(Ut);k(Sa.$$.fragment,ds),V_=p(ds),Uo=r(ds,"P",{});var Zi=i(Uo);S_=s(Zi,"The "),ki=r(Zi,"A",{href:!0});var bk=i(ki);L_=s(bk,"TFGPT2Model"),bk.forEach(t),X_=s(Zi," forward method, overrides the "),Kl=r(Zi,"CODE",{});var vk=i(Kl);O_=s(vk,"__call__"),vk.forEach(t),Q_=s(Zi," special method."),Zi.forEach(t),Y_=p(ds),k(jn.$$.fragment,ds),K_=p(ds),k(zn.$$.fragment,ds),ds.forEach(t),Wt.forEach(t),Qc=p(o),Jo=r(o,"H2",{class:!0});var Yp=i(Jo);xn=r(Yp,"A",{id:!0,class:!0,href:!0});var kk=i(xn);ed=r(kk,"SPAN",{});var wk=i(ed);k(La.$$.fragment,wk),wk.forEach(t),kk.forEach(t),eT=p(Yp),td=r(Yp,"SPAN",{});var Mk=i(td);tT=s(Mk,"TFGPT2LMHeadModel"),Mk.forEach(t),Yp.forEach(t),Yc=p(o),Ye=r(o,"DIV",{class:!0});var At=i(Ye);k(Xa.$$.fragment,At),oT=p(At),od=r(At,"P",{});var $k=i(od);nT=s($k,`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input
embeddings).`),$k.forEach(t),sT=p(At),Oa=r(At,"P",{});var Kp=i(Oa);aT=s(Kp,"This model inherits from "),wi=r(Kp,"A",{href:!0});var Pk=i(wi);rT=s(Pk,"TFPreTrainedModel"),Pk.forEach(t),iT=s(Kp,`. 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.)`),Kp.forEach(t),lT=p(At),Qa=r(At,"P",{});var eh=i(Qa);dT=s(eh,"This model is also a "),Ya=r(eh,"A",{href:!0,rel:!0});var Gk=i(Ya);cT=s(Gk,"tf.keras.Model"),Gk.forEach(t),pT=s(eh,` 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.`),eh.forEach(t),hT=p(At),k(Cn.$$.fragment,At),uT=p(At),Jt=r(At,"DIV",{class:!0});var cs=i(Jt);k(Ka.$$.fragment,cs),mT=p(cs),Io=r(cs,"P",{});var Bi=i(Io);fT=s(Bi,"The "),Mi=r(Bi,"A",{href:!0});var Fk=i(Mi);gT=s(Fk,"TFGPT2LMHeadModel"),Fk.forEach(t),_T=s(Bi," forward method, overrides the "),nd=r(Bi,"CODE",{});var Ek=i(nd);TT=s(Ek,"__call__"),Ek.forEach(t),yT=s(Bi," special method."),Bi.forEach(t),bT=p(cs),k(Un.$$.fragment,cs),vT=p(cs),k(Jn.$$.fragment,cs),cs.forEach(t),At.forEach(t),Kc=p(o),No=r(o,"H2",{class:!0});var th=i(No);In=r(th,"A",{id:!0,class:!0,href:!0});var jk=i(In);sd=r(jk,"SPAN",{});var zk=i(sd);k(er.$$.fragment,zk),zk.forEach(t),jk.forEach(t),kT=p(th),ad=r(th,"SPAN",{});var xk=i(ad);wT=s(xk,"TFGPT2DoubleHeadsModel"),xk.forEach(t),th.forEach(t),ep=p(o),Ke=r(o,"DIV",{class:!0});var Ht=i(Ke);k(tr.$$.fragment,Ht),MT=p(Ht),rd=r(Ht,"P",{});var Ck=i(rd);$T=s(Ck,`The GPT2 Model transformer with a language modeling and a multiple-choice classification head on top e.g. for
RocStories/SWAG tasks. The two heads are two linear layers. The language modeling head has its weights tied to the
input embeddings, the classification head takes as input the input of a specified classification token index in the
input sequence).`),Ck.forEach(t),PT=p(Ht),or=r(Ht,"P",{});var oh=i(or);GT=s(oh,"This model inherits from "),$i=r(oh,"A",{href:!0});var Uk=i($i);FT=s(Uk,"TFPreTrainedModel"),Uk.forEach(t),ET=s(oh,`. 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.)`),oh.forEach(t),jT=p(Ht),nr=r(Ht,"P",{});var nh=i(nr);zT=s(nh,"This model is also a "),sr=r(nh,"A",{href:!0,rel:!0});var Jk=i(sr);xT=s(Jk,"tf.keras.Model"),Jk.forEach(t),CT=s(nh,` 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.`),nh.forEach(t),UT=p(Ht),k(Nn.$$.fragment,Ht),JT=p(Ht),It=r(Ht,"DIV",{class:!0});var ps=i(It);k(ar.$$.fragment,ps),IT=p(ps),qo=r(ps,"P",{});var Ri=i(qo);NT=s(Ri,"The "),Pi=r(Ri,"A",{href:!0});var Ik=i(Pi);qT=s(Ik,"TFGPT2DoubleHeadsModel"),Ik.forEach(t),WT=s(Ri," forward method, overrides the "),id=r(Ri,"CODE",{});var Nk=i(id);AT=s(Nk,"__call__"),Nk.forEach(t),HT=s(Ri," special method."),Ri.forEach(t),ZT=p(ps),k(qn.$$.fragment,ps),BT=p(ps),k(Wn.$$.fragment,ps),ps.forEach(t),Ht.forEach(t),tp=p(o),Wo=r(o,"H2",{class:!0});var sh=i(Wo);An=r(sh,"A",{id:!0,class:!0,href:!0});var qk=i(An);ld=r(qk,"SPAN",{});var Wk=i(ld);k(rr.$$.fragment,Wk),Wk.forEach(t),qk.forEach(t),RT=p(sh),dd=r(sh,"SPAN",{});var Ak=i(dd);DT=s(Ak,"TFGPT2ForSequenceClassification"),Ak.forEach(t),sh.forEach(t),op=p(o),ve=r(o,"DIV",{class:!0});var ot=i(ve);k(ir.$$.fragment,ot),VT=p(ot),cd=r(ot,"P",{});var Hk=i(cd);ST=s(Hk,"The GPT2 Model transformer with a sequence classification head on top (linear layer)."),Hk.forEach(t),LT=p(ot),Gi=r(ot,"P",{});var d2=i(Gi);Fi=r(d2,"A",{href:!0});var Zk=i(Fi);XT=s(Zk,"TFGPT2ForSequenceClassification"),Zk.forEach(t),OT=s(d2,` uses the last token in order to do the classification, as other causal models
(e.g. GPT-1) do.`),d2.forEach(t),QT=p(ot),Ft=r(ot,"P",{});var lo=i(Ft);YT=s(lo,`Since it does classification on the last token, it requires to know the position of the last token. If a
`),pd=r(lo,"CODE",{});var Bk=i(pd);KT=s(Bk,"pad_token_id"),Bk.forEach(t),ey=s(lo,` is defined in the configuration, it finds the last token that is not a padding token in each row. If
no `),hd=r(lo,"CODE",{});var Rk=i(hd);ty=s(Rk,"pad_token_id"),Rk.forEach(t),oy=s(lo,` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
padding tokens when `),ud=r(lo,"CODE",{});var Dk=i(ud);ny=s(Dk,"inputs_embeds"),Dk.forEach(t),sy=s(lo," are passed instead of "),md=r(lo,"CODE",{});var Vk=i(md);ay=s(Vk,"input_ids"),Vk.forEach(t),ry=s(lo,`, it does the same (take the last value in
each row of the batch).`),lo.forEach(t),iy=p(ot),lr=r(ot,"P",{});var ah=i(lr);ly=s(ah,"This model inherits from "),Ei=r(ah,"A",{href:!0});var Sk=i(Ei);dy=s(Sk,"TFPreTrainedModel"),Sk.forEach(t),cy=s(ah,`. 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.)`),ah.forEach(t),py=p(ot),dr=r(ot,"P",{});var rh=i(dr);hy=s(rh,"This model is also a "),cr=r(rh,"A",{href:!0,rel:!0});var Lk=i(cr);uy=s(Lk,"tf.keras.Model"),Lk.forEach(t),my=s(rh,` 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.`),rh.forEach(t),fy=p(ot),k(Hn.$$.fragment,ot),gy=p(ot),vt=r(ot,"DIV",{class:!0});var co=i(vt);k(pr.$$.fragment,co),_y=p(co),Ao=r(co,"P",{});var Di=i(Ao);Ty=s(Di,"The "),ji=r(Di,"A",{href:!0});var Xk=i(ji);yy=s(Xk,"TFGPT2ForSequenceClassification"),Xk.forEach(t),by=s(Di," forward method, overrides the "),fd=r(Di,"CODE",{});var Ok=i(fd);vy=s(Ok,"__call__"),Ok.forEach(t),ky=s(Di," special method."),Di.forEach(t),wy=p(co),k(Zn.$$.fragment,co),My=p(co),k(Bn.$$.fragment,co),$y=p(co),k(Rn.$$.fragment,co),co.forEach(t),ot.forEach(t),np=p(o),Ho=r(o,"H2",{class:!0});var ih=i(Ho);Dn=r(ih,"A",{id:!0,class:!0,href:!0});var Qk=i(Dn);gd=r(Qk,"SPAN",{});var Yk=i(gd);k(hr.$$.fragment,Yk),Yk.forEach(t),Qk.forEach(t),Py=p(ih),_d=r(ih,"SPAN",{});var Kk=i(_d);Gy=s(Kk,"TFSequenceClassifierOutputWithPast"),Kk.forEach(t),ih.forEach(t),sp=p(o),Zo=r(o,"DIV",{class:!0});var lh=i(Zo);k(ur.$$.fragment,lh),Fy=p(lh),Td=r(lh,"P",{});var ew=i(Td);Ey=s(ew,"Base class for outputs of sentence classification models."),ew.forEach(t),lh.forEach(t),ap=p(o),Bo=r(o,"H2",{class:!0});var dh=i(Bo);Vn=r(dh,"A",{id:!0,class:!0,href:!0});var tw=i(Vn);yd=r(tw,"SPAN",{});var ow=i(yd);k(mr.$$.fragment,ow),ow.forEach(t),tw.forEach(t),jy=p(dh),bd=r(dh,"SPAN",{});var nw=i(bd);zy=s(nw,"TFGPT2Tokenizer"),nw.forEach(t),dh.forEach(t),rp=p(o),et=r(o,"DIV",{class:!0});var Zt=i(et);k(fr.$$.fragment,Zt),xy=p(Zt),Ro=r(Zt,"P",{});var Vi=i(Ro);Cy=s(Vi,`This is an in-graph tokenizer for GPT2. It should be initialized similarly to other tokenizers, using the
`),vd=r(Vi,"CODE",{});var sw=i(vd);Uy=s(sw,"from_pretrained()"),sw.forEach(t),Jy=s(Vi," method. It can also be initialized with the "),kd=r(Vi,"CODE",{});var aw=i(kd);Iy=s(aw,"from_tokenizer()"),aw.forEach(t),Ny=s(Vi,` method, which imports settings
from an existing standard tokenizer object.`),Vi.forEach(t),qy=p(Zt),gr=r(Zt,"P",{});var ch=i(gr);Wy=s(ch,`In-graph tokenizers, unlike other Hugging Face tokenizers, are actually Keras layers and are designed to be run
when the model is called, rather than during preprocessing. As a result, they have somewhat more limited options
than standard tokenizer classes. They are most useful when you want to create an end-to-end model that goes
straight from `),wd=r(ch,"CODE",{});var rw=i(wd);Ay=s(rw,"tf.string"),rw.forEach(t),Hy=s(ch," inputs to outputs."),ch.forEach(t),Zy=p(Zt),Sn=r(Zt,"DIV",{class:!0});var ph=i(Sn);k(_r.$$.fragment,ph),By=p(ph),Md=r(ph,"P",{});var iw=i(Md);Ry=s(iw,"Creates TFGPT2Tokenizer from configurations"),iw.forEach(t),ph.forEach(t),Dy=p(Zt),Yt=r(Zt,"DIV",{class:!0});var Si=i(Yt);k(Tr.$$.fragment,Si),Vy=p(Si),$d=r(Si,"P",{});var lw=i($d);Sy=s(lw,"Creates TFGPT2Tokenizer from pretrained GPT2Tokenizer"),lw.forEach(t),Ly=p(Si),k(Ln.$$.fragment,Si),Si.forEach(t),Xy=p(Zt),Kt=r(Zt,"DIV",{class:!0});var Li=i(Kt);k(yr.$$.fragment,Li),Oy=p(Li),Pd=r(Li,"P",{});var dw=i(Pd);Qy=s(dw,"Creates TFGPT2Tokenizer from GPT2Tokenizer"),dw.forEach(t),Yy=p(Li),k(Xn.$$.fragment,Li),Li.forEach(t),Zt.forEach(t),ip=p(o),Do=r(o,"H2",{class:!0});var hh=i(Do);On=r(hh,"A",{id:!0,class:!0,href:!0});var cw=i(On);Gd=r(cw,"SPAN",{});var pw=i(Gd);k(br.$$.fragment,pw),pw.forEach(t),cw.forEach(t),Ky=p(hh),Fd=r(hh,"SPAN",{});var hw=i(Fd);eb=s(hw,"FlaxGPT2Model"),hw.forEach(t),hh.forEach(t),lp=p(o),He=r(o,"DIV",{class:!0});var Mt=i(He);k(vr.$$.fragment,Mt),tb=p(Mt),Ed=r(Mt,"P",{});var uw=i(Ed);ob=s(uw,"The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top."),uw.forEach(t),nb=p(Mt),kr=r(Mt,"P",{});var uh=i(kr);sb=s(uh,"This model inherits from "),zi=r(uh,"A",{href:!0});var mw=i(zi);ab=s(mw,"FlaxPreTrainedModel"),mw.forEach(t),rb=s(uh,`. 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.)`),uh.forEach(t),ib=p(Mt),wr=r(Mt,"P",{});var mh=i(wr);lb=s(mh,`This model is also a Flax Linen
`),Mr=r(mh,"A",{href:!0,rel:!0});var fw=i(Mr);db=s(fw,"flax.nn.Module"),fw.forEach(t),cb=s(mh,` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),mh.forEach(t),pb=p(Mt),jd=r(Mt,"P",{});var gw=i(jd);hb=s(gw,"Finally, this model supports inherent JAX features such as:"),gw.forEach(t),ub=p(Mt),Dt=r(Mt,"UL",{});var hs=i(Dt);zd=r(hs,"LI",{});var _w=i(zd);$r=r(_w,"A",{href:!0,rel:!0});var Tw=i($r);mb=s(Tw,"Just-In-Time (JIT) compilation"),Tw.forEach(t),_w.forEach(t),fb=p(hs),xd=r(hs,"LI",{});var yw=i(xd);Pr=r(yw,"A",{href:!0,rel:!0});var bw=i(Pr);gb=s(bw,"Automatic Differentiation"),bw.forEach(t),yw.forEach(t),_b=p(hs),Cd=r(hs,"LI",{});var vw=i(Cd);Gr=r(vw,"A",{href:!0,rel:!0});var kw=i(Gr);Tb=s(kw,"Vectorization"),kw.forEach(t),vw.forEach(t),yb=p(hs),Ud=r(hs,"LI",{});var ww=i(Ud);Fr=r(ww,"A",{href:!0,rel:!0});var Mw=i(Fr);bb=s(Mw,"Parallelization"),Mw.forEach(t),ww.forEach(t),hs.forEach(t),vb=p(Mt),Nt=r(Mt,"DIV",{class:!0});var us=i(Nt);k(Er.$$.fragment,us),kb=p(us),Vo=r(us,"P",{});var Xi=i(Vo);wb=s(Xi,"The "),Jd=r(Xi,"CODE",{});var $w=i(Jd);Mb=s($w,"FlaxGPT2PreTrainedModel"),$w.forEach(t),$b=s(Xi," forward method, overrides the "),Id=r(Xi,"CODE",{});var Pw=i(Id);Pb=s(Pw,"__call__"),Pw.forEach(t),Gb=s(Xi," special method."),Xi.forEach(t),Fb=p(us),k(Qn.$$.fragment,us),Eb=p(us),k(Yn.$$.fragment,us),us.forEach(t),Mt.forEach(t),dp=p(o),So=r(o,"H2",{class:!0});var fh=i(So);Kn=r(fh,"A",{id:!0,class:!0,href:!0});var Gw=i(Kn);Nd=r(Gw,"SPAN",{});var Fw=i(Nd);k(jr.$$.fragment,Fw),Fw.forEach(t),Gw.forEach(t),jb=p(fh),qd=r(fh,"SPAN",{});var Ew=i(qd);zb=s(Ew,"FlaxGPT2LMHeadModel"),Ew.forEach(t),fh.forEach(t),cp=p(o),Ze=r(o,"DIV",{class:!0});var $t=i(Ze);k(zr.$$.fragment,$t),xb=p($t),Wd=r($t,"P",{});var jw=i(Wd);Cb=s(jw,`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input
embeddings).`),jw.forEach(t),Ub=p($t),xr=r($t,"P",{});var gh=i(xr);Jb=s(gh,"This model inherits from "),xi=r(gh,"A",{href:!0});var zw=i(xi);Ib=s(zw,"FlaxPreTrainedModel"),zw.forEach(t),Nb=s(gh,`. 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.)`),gh.forEach(t),qb=p($t),Cr=r($t,"P",{});var _h=i(Cr);Wb=s(_h,`This model is also a Flax Linen
`),Ur=r(_h,"A",{href:!0,rel:!0});var xw=i(Ur);Ab=s(xw,"flax.nn.Module"),xw.forEach(t),Hb=s(_h,` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),_h.forEach(t),Zb=p($t),Ad=r($t,"P",{});var Cw=i(Ad);Bb=s(Cw,"Finally, this model supports inherent JAX features such as:"),Cw.forEach(t),Rb=p($t),Vt=r($t,"UL",{});var ms=i(Vt);Hd=r(ms,"LI",{});var Uw=i(Hd);Jr=r(Uw,"A",{href:!0,rel:!0});var Jw=i(Jr);Db=s(Jw,"Just-In-Time (JIT) compilation"),Jw.forEach(t),Uw.forEach(t),Vb=p(ms),Zd=r(ms,"LI",{});var Iw=i(Zd);Ir=r(Iw,"A",{href:!0,rel:!0});var Nw=i(Ir);Sb=s(Nw,"Automatic Differentiation"),Nw.forEach(t),Iw.forEach(t),Lb=p(ms),Bd=r(ms,"LI",{});var qw=i(Bd);Nr=r(qw,"A",{href:!0,rel:!0});var Ww=i(Nr);Xb=s(Ww,"Vectorization"),Ww.forEach(t),qw.forEach(t),Ob=p(ms),Rd=r(ms,"LI",{});var Aw=i(Rd);qr=r(Aw,"A",{href:!0,rel:!0});var Hw=i(qr);Qb=s(Hw,"Parallelization"),Hw.forEach(t),Aw.forEach(t),ms.forEach(t),Yb=p($t),qt=r($t,"DIV",{class:!0});var fs=i(qt);k(Wr.$$.fragment,fs),Kb=p(fs),Lo=r(fs,"P",{});var Oi=i(Lo);e2=s(Oi,"The "),Dd=r(Oi,"CODE",{});var Zw=i(Dd);t2=s(Zw,"FlaxGPT2PreTrainedModel"),Zw.forEach(t),o2=s(Oi," forward method, overrides the "),Vd=r(Oi,"CODE",{});var Bw=i(Vd);n2=s(Bw,"__call__"),Bw.forEach(t),s2=s(Oi," special method."),Oi.forEach(t),a2=p(fs),k(es.$$.fragment,fs),r2=p(fs),k(ts.$$.fragment,fs),fs.forEach(t),$t.forEach(t),this.h()},h(){u(d,"name","hf:doc:metadata"),u(d,"content",JSON.stringify(IM)),u(m,"id","openai-gpt2"),u(m,"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"),u(m,"href","#openai-gpt2"),u(f,"class","relative group"),u(re,"alt","Models"),Rw(re.src,E="https://img.shields.io/badge/All_model_pages-gpt2-blueviolet")||u(re,"src",E),u(O,"href","https://huggingface.co/models?filter=gpt2"),u(fe,"alt","Spaces"),Rw(fe.src,Se="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue")||u(fe,"src",Se),u(S,"href","https://huggingface.co/spaces/docs-demos/gpt2"),u(J,"class","flex flex-wrap space-x-1"),u(pe,"id","overview"),u(pe,"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"),u(pe,"href","#overview"),u(le,"class","relative group"),u(ue,"href","https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf"),u(ue,"rel","nofollow"),u(C,"href","https://huggingface.co/openai"),u(C,"rel","nofollow"),u(Le,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2Model.forward"),u(ie,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.TFGPT2Model.call"),u(gs,"href","https://github.com/stanford-crfm/mistral/"),u(gs,"rel","nofollow"),u(_s,"href","https://transformer.huggingface.co/doc/gpt2-large"),u(_s,"rel","nofollow"),u(Ts,"href","https://huggingface.co/thomwolf"),u(Ts,"rel","nofollow"),u(ys,"href","https://openai.com/blog/better-language-models/"),u(ys,"rel","nofollow"),u(Qo,"id","resources"),u(Qo,"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"),u(Qo,"href","#resources"),u(ho,"class","relative group"),u(ws,"href","https://www.philschmid.de/fine-tune-a-non-english-gpt-2-model-with-huggingface"),u(ws,"rel","nofollow"),u($s,"href","https://huggingface.co/blog/how-to-generate"),u($s,"rel","nofollow"),u(Gs,"href","https://huggingface.co/blog/codeparrot"),u(Gs,"rel","nofollow"),u(Es,"href","https://huggingface.co/blog/tf-xla-generate"),u(Es,"rel","nofollow"),u(zs,"href","https://huggingface.co/blog/megatron-training"),u(zs,"rel","nofollow"),u(Cs,"href","https://colab.research.google.com/github/AlekseyKorshuk/huggingartists/blob/master/huggingartists-demo.ipynb"),u(Cs,"rel","nofollow"),u(Js,"href","https://colab.research.google.com/github/borisdayma/huggingtweets/blob/master/huggingtweets-demo.ipynb"),u(Js,"rel","nofollow"),u(Is,"href","https://huggingface.co/course/en/chapter7/6?fw=pt#training-a-causal-language-model-from-scratch"),u(Is,"rel","nofollow"),u(Lr,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2LMHeadModel"),u(Ns,"href","https://github.com/huggingface/transformers/tree/main/examples/pytorch/language-modeling#gpt-2gpt-and-causal-language-modeling"),u(Ns,"rel","nofollow"),u(qs,"href","https://github.com/huggingface/transformers/tree/main/examples/pytorch/text-generation"),u(qs,"rel","nofollow"),u(Ws,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling.ipynb"),u(Ws,"rel","nofollow"),u(Xr,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.TFGPT2LMHeadModel"),u(As,"href","https://github.com/huggingface/transformers/tree/main/examples/tensorflow/language-modeling#run_clmpy"),u(As,"rel","nofollow"),u(Hs,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling-tf.ipynb"),u(Hs,"rel","nofollow"),u(Or,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.FlaxGPT2LMHeadModel"),u(Zs,"href","https://github.com/huggingface/transformers/tree/main/examples/flax/language-modeling#causal-language-modeling"),u(Zs,"rel","nofollow"),u(Bs,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/causal_language_modeling_flax.ipynb"),u(Bs,"rel","nofollow"),u(Qr,"href","../tasks/sequence_classification"),u(Yr,"href","../tasks/token_classification"),u(Kr,"href","../tasks/language_modeling"),u(Yo,"id","transformers.GPT2Config"),u(Yo,"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"),u(Yo,"href","#transformers.GPT2Config"),u(uo,"class","relative group"),u(ei,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2Model"),u(ti,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.TFGPT2Model"),u(Vs,"href","https://huggingface.co/gpt2"),u(Vs,"rel","nofollow"),u(oi,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),u(ni,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),u(Pt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(en,"id","transformers.GPT2Tokenizer"),u(en,"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"),u(en,"href","#transformers.GPT2Tokenizer"),u(fo,"class","relative group"),u(si,"href","/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer"),u(ai,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(be,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(nn,"id","transformers.GPT2TokenizerFast"),u(nn,"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"),u(nn,"href","#transformers.GPT2TokenizerFast"),u(go,"class","relative group"),u(ri,"href","/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast"),u(We,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(rn,"id","transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput"),u(rn,"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"),u(rn,"href","#transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput"),u(_o,"class","relative group"),u(To,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(yo,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(ln,"id","transformers.GPT2Model"),u(ln,"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"),u(ln,"href","#transformers.GPT2Model"),u(bo,"class","relative group"),u(ii,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),u(ca,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(ca,"rel","nofollow"),u(li,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2Model"),u(jt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(mt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(pn,"id","transformers.GPT2LMHeadModel"),u(pn,"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"),u(pn,"href","#transformers.GPT2LMHeadModel"),u(ko,"class","relative group"),u(di,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),u(ga,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(ga,"rel","nofollow"),u(ci,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2LMHeadModel"),u(zt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(ft,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(mn,"id","transformers.GPT2DoubleHeadsModel"),u(mn,"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"),u(mn,"href","#transformers.GPT2DoubleHeadsModel"),u(Mo,"class","relative group"),u(pi,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),u(ka,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(ka,"rel","nofollow"),u(hi,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel"),u(xt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(gt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(_n,"id","transformers.GPT2ForQuestionAnswering"),u(_n,"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"),u(_n,"href","#transformers.GPT2ForQuestionAnswering"),u(Po,"class","relative group"),u(ui,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),u(Fa,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Fa,"rel","nofollow"),u(mi,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2ForQuestionAnswering"),u(yt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(_t,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(vn,"id","transformers.GPT2ForSequenceClassification"),u(vn,"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"),u(vn,"href","#transformers.GPT2ForSequenceClassification"),u(Eo,"class","relative group"),u(gi,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2ForSequenceClassification"),u(_i,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),u(Ua,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Ua,"rel","nofollow"),u(Ti,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2ForSequenceClassification"),u(bt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Ae,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u($n,"id","transformers.GPT2ForTokenClassification"),u($n,"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"),u($n,"href","#transformers.GPT2ForTokenClassification"),u(zo,"class","relative group"),u(yi,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),u(Aa,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Aa,"rel","nofollow"),u(bi,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.GPT2ForTokenClassification"),u(Ct,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Tt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Fn,"id","transformers.TFGPT2Model"),u(Fn,"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"),u(Fn,"href","#transformers.TFGPT2Model"),u(Co,"class","relative group"),u(vi,"href","/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel"),u(Va,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),u(Va,"rel","nofollow"),u(ki,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.TFGPT2Model"),u(Ut,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Qe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(xn,"id","transformers.TFGPT2LMHeadModel"),u(xn,"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"),u(xn,"href","#transformers.TFGPT2LMHeadModel"),u(Jo,"class","relative group"),u(wi,"href","/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel"),u(Ya,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),u(Ya,"rel","nofollow"),u(Mi,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.TFGPT2LMHeadModel"),u(Jt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Ye,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(In,"id","transformers.TFGPT2DoubleHeadsModel"),u(In,"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"),u(In,"href","#transformers.TFGPT2DoubleHeadsModel"),u(No,"class","relative group"),u($i,"href","/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel"),u(sr,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),u(sr,"rel","nofollow"),u(Pi,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.TFGPT2DoubleHeadsModel"),u(It,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Ke,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(An,"id","transformers.TFGPT2ForSequenceClassification"),u(An,"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"),u(An,"href","#transformers.TFGPT2ForSequenceClassification"),u(Wo,"class","relative group"),u(Fi,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.TFGPT2ForSequenceClassification"),u(Ei,"href","/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel"),u(cr,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),u(cr,"rel","nofollow"),u(ji,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.TFGPT2ForSequenceClassification"),u(vt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(ve,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Dn,"id","transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast"),u(Dn,"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"),u(Dn,"href","#transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast"),u(Ho,"class","relative group"),u(Zo,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Vn,"id","transformers.TFGPT2Tokenizer"),u(Vn,"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"),u(Vn,"href","#transformers.TFGPT2Tokenizer"),u(Bo,"class","relative group"),u(Sn,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Yt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Kt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(et,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(On,"id","transformers.FlaxGPT2Model"),u(On,"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"),u(On,"href","#transformers.FlaxGPT2Model"),u(Do,"class","relative group"),u(zi,"href","/docs/transformers/main/en/main_classes/model#transformers.FlaxPreTrainedModel"),u(Mr,"href","https://flax.readthedocs.io/en/latest/_autosummary/flax.nn.module.html"),u(Mr,"rel","nofollow"),u($r,"href","https://jax.readthedocs.io/en/latest/jax.html#just-in-time-compilation-jit"),u($r,"rel","nofollow"),u(Pr,"href","https://jax.readthedocs.io/en/latest/jax.html#automatic-differentiation"),u(Pr,"rel","nofollow"),u(Gr,"href","https://jax.readthedocs.io/en/latest/jax.html#vectorization-vmap"),u(Gr,"rel","nofollow"),u(Fr,"href","https://jax.readthedocs.io/en/latest/jax.html#parallelization-pmap"),u(Fr,"rel","nofollow"),u(Nt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(He,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Kn,"id","transformers.FlaxGPT2LMHeadModel"),u(Kn,"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"),u(Kn,"href","#transformers.FlaxGPT2LMHeadModel"),u(So,"class","relative group"),u(xi,"href","/docs/transformers/main/en/main_classes/model#transformers.FlaxPreTrainedModel"),u(Ur,"href","https://flax.readthedocs.io/en/latest/_autosummary/flax.nn.module.html"),u(Ur,"rel","nofollow"),u(Jr,"href","https://jax.readthedocs.io/en/latest/jax.html#just-in-time-compilation-jit"),u(Jr,"rel","nofollow"),u(Ir,"href","https://jax.readthedocs.io/en/latest/jax.html#automatic-differentiation"),u(Ir,"rel","nofollow"),u(Nr,"href","https://jax.readthedocs.io/en/latest/jax.html#vectorization-vmap"),u(Nr,"rel","nofollow"),u(qr,"href","https://jax.readthedocs.io/en/latest/jax.html#parallelization-pmap"),u(qr,"rel","nofollow"),u(qt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Ze,"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,_){e(document.head,d),g(o,y,_),g(o,f,_),e(f,m),e(m,T),w(l,T,null),e(f,h),e(f,F),e(F,R),g(o,N,_),g(o,J,_),e(J,O),e(O,re),e(J,Ge),e(J,S),e(S,fe),g(o,Q,_),g(o,le,_),e(le,pe),e(pe,L),w(he,L,null),e(le,Fe),e(le,X),e(X,Ee),g(o,Me,_),g(o,H,_),e(H,je),e(H,ue),e(ue,me),e(H,x),e(H,C),e(C,ze),e(H,oe),g(o,$e,_),g(o,ge,_),e(ge,ne),g(o,Pe,_),g(o,_e,_),e(_e,U),e(U,xe),g(o,Y,_),g(o,Te,_),e(Te,Ce),g(o,K,_),g(o,ee,_),e(ee,ye),e(ye,D),e(ee,Ue),e(ee,V),e(V,Je),e(V,de),e(de,I),e(V,Ie),e(ee,W),e(ee,q),e(q,Ne),e(q,b),e(b,j),e(q,nt),e(q,ce),e(ce,st),e(q,at),e(q,z),e(z,rt),e(q,it),e(q,Xe),e(Xe,lt),e(q,dt),e(q,Z),e(Z,se),e(q,ct),e(q,Le),e(Le,ae),e(q,pt),e(q,Oe),e(Oe,qe),e(q,ht),e(q,ie),e(ie,ut),e(q,Th),e(ee,yh),e(ee,Bt),e(Bt,bh),e(Bt,Qi),e(Qi,vh),e(Bt,kh),e(Bt,Yi),e(Yi,wh),e(Bt,Mh),e(Bt,gs),e(gs,$h),e(Bt,Ph),g(o,kc,_),g(o,po,_),e(po,_s),e(_s,Gh),e(po,Fh),e(po,Ki),e(Ki,Eh),e(po,jh),g(o,wc,_),g(o,Xt,_),e(Xt,zh),e(Xt,Ts),e(Ts,xh),e(Xt,Ch),e(Xt,ys),e(ys,Uh),e(Xt,Jh),g(o,Mc,_),g(o,ho,_),e(ho,Qo),e(Qo,el),w(bs,el,null),e(ho,Ih),e(ho,tl),e(tl,Nh),g(o,$c,_),g(o,Vr,_),e(Vr,qh),g(o,Pc,_),w(vs,o,_),g(o,Gc,_),g(o,B,_),e(B,ks),e(ks,Wh),e(ks,ws),e(ws,Ah),e(ks,Hh),e(B,Zh),e(B,Ms),e(Ms,Bh),e(Ms,$s),e($s,Rh),e(Ms,Dh),e(B,Vh),e(B,Ps),e(Ps,Sh),e(Ps,Gs),e(Gs,Lh),e(Ps,Xh),e(B,Oh),e(B,Fs),e(Fs,Qh),e(Fs,Es),e(Es,Yh),e(Fs,Kh),e(B,eu),e(B,js),e(js,tu),e(js,zs),e(zs,ou),e(js,nu),e(B,su),e(B,xs),e(xs,au),e(xs,Cs),e(Cs,ru),e(xs,iu),e(B,lu),e(B,Us),e(Us,du),e(Us,Js),e(Js,cu),e(Us,pu),e(B,hu),e(B,Sr),e(Sr,Is),e(Is,uu),e(Sr,mu),e(B,fu),e(B,Et),e(Et,Lr),e(Lr,gu),e(Et,_u),e(Et,Ns),e(Ns,Tu),e(Et,yu),e(Et,qs),e(qs,bu),e(Et,vu),e(Et,Ws),e(Ws,ku),e(Et,wu),e(B,Mu),e(B,Ot),e(Ot,Xr),e(Xr,$u),e(Ot,Pu),e(Ot,As),e(As,Gu),e(Ot,Fu),e(Ot,Hs),e(Hs,Eu),e(Ot,ju),e(B,zu),e(B,Qt),e(Qt,Or),e(Or,xu),e(Qt,Cu),e(Qt,Zs),e(Zs,Uu),e(Qt,Ju),e(Qt,Bs),e(Bs,Iu),e(Qt,Nu),e(B,qu),e(B,ol),e(ol,Qr),e(Qr,Wu),e(B,Au),e(B,nl),e(nl,Yr),e(Yr,Hu),e(B,Zu),e(B,sl),e(sl,Kr),e(Kr,Bu),g(o,Fc,_),g(o,uo,_),e(uo,Yo),e(Yo,al),w(Rs,al,null),e(uo,Ru),e(uo,rl),e(rl,Du),g(o,Ec,_),g(o,Pt,_),w(Ds,Pt,null),e(Pt,Vu),e(Pt,Rt),e(Rt,Su),e(Rt,ei),e(ei,Lu),e(Rt,Xu),e(Rt,ti),e(ti,Ou),e(Rt,Qu),e(Rt,Vs),e(Vs,Yu),e(Rt,Ku),e(Pt,em),e(Pt,mo),e(mo,tm),e(mo,oi),e(oi,om),e(mo,nm),e(mo,ni),e(ni,sm),e(mo,am),e(Pt,rm),w(Ko,Pt,null),g(o,jc,_),g(o,fo,_),e(fo,en),e(en,il),w(Ss,il,null),e(fo,im),e(fo,ll),e(ll,lm),g(o,zc,_),g(o,be,_),w(Ls,be,null),e(be,dm),e(be,dl),e(dl,cm),e(be,pm),e(be,cl),e(cl,hm),e(be,um),w(tn,be,null),e(be,mm),e(be,Xs),e(Xs,fm),e(Xs,pl),e(pl,gm),e(Xs,_m),e(be,Tm),w(on,be,null),e(be,ym),e(be,Os),e(Os,bm),e(Os,si),e(si,vm),e(Os,km),e(be,wm),e(be,ai),w(Qs,ai,null),g(o,xc,_),g(o,go,_),e(go,nn),e(nn,hl),w(Ys,hl,null),e(go,Mm),e(go,ul),e(ul,$m),g(o,Cc,_),g(o,We,_),w(Ks,We,null),e(We,Pm),e(We,ea),e(ea,Gm),e(ea,ml),e(ml,Fm),e(ea,Em),e(We,jm),e(We,fl),e(fl,zm),e(We,xm),w(sn,We,null),e(We,Cm),e(We,ta),e(ta,Um),e(ta,gl),e(gl,Jm),e(ta,Im),e(We,Nm),w(an,We,null),e(We,qm),e(We,oa),e(oa,Wm),e(oa,ri),e(ri,Am),e(oa,Hm),g(o,Uc,_),g(o,_o,_),e(_o,rn),e(rn,_l),w(na,_l,null),e(_o,Zm),e(_o,Tl),e(Tl,Bm),g(o,Jc,_),g(o,To,_),w(sa,To,null),e(To,Rm),e(To,yl),e(yl,Dm),g(o,Ic,_),g(o,yo,_),w(aa,yo,null),e(yo,Vm),e(yo,bl),e(bl,Sm),g(o,Nc,_),g(o,bo,_),e(bo,ln),e(ln,vl),w(ra,vl,null),e(bo,Lm),e(bo,kl),e(kl,Xm),g(o,qc,_),g(o,mt,_),w(ia,mt,null),e(mt,Om),e(mt,wl),e(wl,Qm),e(mt,Ym),e(mt,la),e(la,Km),e(la,ii),e(ii,ef),e(la,tf),e(mt,of),e(mt,da),e(da,nf),e(da,ca),e(ca,sf),e(da,af),e(mt,rf),e(mt,jt),w(pa,jt,null),e(jt,lf),e(jt,vo),e(vo,df),e(vo,li),e(li,cf),e(vo,pf),e(vo,Ml),e(Ml,hf),e(vo,uf),e(jt,mf),w(dn,jt,null),e(jt,ff),w(cn,jt,null),g(o,Wc,_),g(o,ko,_),e(ko,pn),e(pn,$l),w(ha,$l,null),e(ko,gf),e(ko,Pl),e(Pl,_f),g(o,Ac,_),g(o,ft,_),w(ua,ft,null),e(ft,Tf),e(ft,Gl),e(Gl,yf),e(ft,bf),e(ft,ma),e(ma,vf),e(ma,di),e(di,kf),e(ma,wf),e(ft,Mf),e(ft,fa),e(fa,$f),e(fa,ga),e(ga,Pf),e(fa,Gf),e(ft,Ff),e(ft,zt),w(_a,zt,null),e(zt,Ef),e(zt,wo),e(wo,jf),e(wo,ci),e(ci,zf),e(wo,xf),e(wo,Fl),e(Fl,Cf),e(wo,Uf),e(zt,Jf),w(hn,zt,null),e(zt,If),w(un,zt,null),g(o,Hc,_),g(o,Mo,_),e(Mo,mn),e(mn,El),w(Ta,El,null),e(Mo,Nf),e(Mo,jl),e(jl,qf),g(o,Zc,_),g(o,gt,_),w(ya,gt,null),e(gt,Wf),e(gt,zl),e(zl,Af),e(gt,Hf),e(gt,ba),e(ba,Zf),e(ba,pi),e(pi,Bf),e(ba,Rf),e(gt,Df),e(gt,va),e(va,Vf),e(va,ka),e(ka,Sf),e(va,Lf),e(gt,Xf),e(gt,xt),w(wa,xt,null),e(xt,Of),e(xt,$o),e($o,Qf),e($o,hi),e(hi,Yf),e($o,Kf),e($o,xl),e(xl,eg),e($o,tg),e(xt,og),w(fn,xt,null),e(xt,ng),w(gn,xt,null),g(o,Bc,_),g(o,Po,_),e(Po,_n),e(_n,Cl),w(Ma,Cl,null),e(Po,sg),e(Po,Ul),e(Ul,ag),g(o,Rc,_),g(o,_t,_),w($a,_t,null),e(_t,rg),e(_t,Go),e(Go,ig),e(Go,Jl),e(Jl,lg),e(Go,dg),e(Go,Il),e(Il,cg),e(Go,pg),e(_t,hg),e(_t,Pa),e(Pa,ug),e(Pa,ui),e(ui,mg),e(Pa,fg),e(_t,gg),e(_t,Ga),e(Ga,_g),e(Ga,Fa),e(Fa,Tg),e(Ga,yg),e(_t,bg),e(_t,yt),w(Ea,yt,null),e(yt,vg),e(yt,Fo),e(Fo,kg),e(Fo,mi),e(mi,wg),e(Fo,Mg),e(Fo,Nl),e(Nl,$g),e(Fo,Pg),e(yt,Gg),w(Tn,yt,null),e(yt,Fg),w(yn,yt,null),e(yt,Eg),w(bn,yt,null),g(o,Dc,_),g(o,Eo,_),e(Eo,vn),e(vn,ql),w(ja,ql,null),e(Eo,jg),e(Eo,Wl),e(Wl,zg),g(o,Vc,_),g(o,Ae,_),w(za,Ae,null),e(Ae,xg),e(Ae,Al),e(Al,Cg),e(Ae,Ug),e(Ae,fi),e(fi,gi),e(gi,Jg),e(fi,Ig),e(Ae,Ng),e(Ae,Gt),e(Gt,qg),e(Gt,Hl),e(Hl,Wg),e(Gt,Ag),e(Gt,Zl),e(Zl,Hg),e(Gt,Zg),e(Gt,Bl),e(Bl,Bg),e(Gt,Rg),e(Gt,Rl),e(Rl,Dg),e(Gt,Vg),e(Ae,Sg),e(Ae,xa),e(xa,Lg),e(xa,_i),e(_i,Xg),e(xa,Og),e(Ae,Qg),e(Ae,Ca),e(Ca,Yg),e(Ca,Ua),e(Ua,Kg),e(Ca,e_),e(Ae,t_),e(Ae,bt),w(Ja,bt,null),e(bt,o_),e(bt,jo),e(jo,n_),e(jo,Ti),e(Ti,s_),e(jo,a_),e(jo,Dl),e(Dl,r_),e(jo,i_),e(bt,l_),w(kn,bt,null),e(bt,d_),w(wn,bt,null),e(bt,c_),w(Mn,bt,null),g(o,Sc,_),g(o,zo,_),e(zo,$n),e($n,Vl),w(Ia,Vl,null),e(zo,p_),e(zo,Sl),e(Sl,h_),g(o,Lc,_),g(o,Tt,_),w(Na,Tt,null),e(Tt,u_),e(Tt,Ll),e(Ll,m_),e(Tt,f_),e(Tt,qa),e(qa,g_),e(qa,yi),e(yi,__),e(qa,T_),e(Tt,y_),e(Tt,Wa),e(Wa,b_),e(Wa,Aa),e(Aa,v_),e(Wa,k_),e(Tt,w_),e(Tt,Ct),w(Ha,Ct,null),e(Ct,M_),e(Ct,xo),e(xo,$_),e(xo,bi),e(bi,P_),e(xo,G_),e(xo,Xl),e(Xl,F_),e(xo,E_),e(Ct,j_),w(Pn,Ct,null),e(Ct,z_),w(Gn,Ct,null),g(o,Xc,_),g(o,Co,_),e(Co,Fn),e(Fn,Ol),w(Za,Ol,null),e(Co,x_),e(Co,Ql),e(Ql,C_),g(o,Oc,_),g(o,Qe,_),w(Ba,Qe,null),e(Qe,U_),e(Qe,Yl),e(Yl,J_),e(Qe,I_),e(Qe,Ra),e(Ra,N_),e(Ra,vi),e(vi,q_),e(Ra,W_),e(Qe,A_),e(Qe,Da),e(Da,H_),e(Da,Va),e(Va,Z_),e(Da,B_),e(Qe,R_),w(En,Qe,null),e(Qe,D_),e(Qe,Ut),w(Sa,Ut,null),e(Ut,V_),e(Ut,Uo),e(Uo,S_),e(Uo,ki),e(ki,L_),e(Uo,X_),e(Uo,Kl),e(Kl,O_),e(Uo,Q_),e(Ut,Y_),w(jn,Ut,null),e(Ut,K_),w(zn,Ut,null),g(o,Qc,_),g(o,Jo,_),e(Jo,xn),e(xn,ed),w(La,ed,null),e(Jo,eT),e(Jo,td),e(td,tT),g(o,Yc,_),g(o,Ye,_),w(Xa,Ye,null),e(Ye,oT),e(Ye,od),e(od,nT),e(Ye,sT),e(Ye,Oa),e(Oa,aT),e(Oa,wi),e(wi,rT),e(Oa,iT),e(Ye,lT),e(Ye,Qa),e(Qa,dT),e(Qa,Ya),e(Ya,cT),e(Qa,pT),e(Ye,hT),w(Cn,Ye,null),e(Ye,uT),e(Ye,Jt),w(Ka,Jt,null),e(Jt,mT),e(Jt,Io),e(Io,fT),e(Io,Mi),e(Mi,gT),e(Io,_T),e(Io,nd),e(nd,TT),e(Io,yT),e(Jt,bT),w(Un,Jt,null),e(Jt,vT),w(Jn,Jt,null),g(o,Kc,_),g(o,No,_),e(No,In),e(In,sd),w(er,sd,null),e(No,kT),e(No,ad),e(ad,wT),g(o,ep,_),g(o,Ke,_),w(tr,Ke,null),e(Ke,MT),e(Ke,rd),e(rd,$T),e(Ke,PT),e(Ke,or),e(or,GT),e(or,$i),e($i,FT),e(or,ET),e(Ke,jT),e(Ke,nr),e(nr,zT),e(nr,sr),e(sr,xT),e(nr,CT),e(Ke,UT),w(Nn,Ke,null),e(Ke,JT),e(Ke,It),w(ar,It,null),e(It,IT),e(It,qo),e(qo,NT),e(qo,Pi),e(Pi,qT),e(qo,WT),e(qo,id),e(id,AT),e(qo,HT),e(It,ZT),w(qn,It,null),e(It,BT),w(Wn,It,null),g(o,tp,_),g(o,Wo,_),e(Wo,An),e(An,ld),w(rr,ld,null),e(Wo,RT),e(Wo,dd),e(dd,DT),g(o,op,_),g(o,ve,_),w(ir,ve,null),e(ve,VT),e(ve,cd),e(cd,ST),e(ve,LT),e(ve,Gi),e(Gi,Fi),e(Fi,XT),e(Gi,OT),e(ve,QT),e(ve,Ft),e(Ft,YT),e(Ft,pd),e(pd,KT),e(Ft,ey),e(Ft,hd),e(hd,ty),e(Ft,oy),e(Ft,ud),e(ud,ny),e(Ft,sy),e(Ft,md),e(md,ay),e(Ft,ry),e(ve,iy),e(ve,lr),e(lr,ly),e(lr,Ei),e(Ei,dy),e(lr,cy),e(ve,py),e(ve,dr),e(dr,hy),e(dr,cr),e(cr,uy),e(dr,my),e(ve,fy),w(Hn,ve,null),e(ve,gy),e(ve,vt),w(pr,vt,null),e(vt,_y),e(vt,Ao),e(Ao,Ty),e(Ao,ji),e(ji,yy),e(Ao,by),e(Ao,fd),e(fd,vy),e(Ao,ky),e(vt,wy),w(Zn,vt,null),e(vt,My),w(Bn,vt,null),e(vt,$y),w(Rn,vt,null),g(o,np,_),g(o,Ho,_),e(Ho,Dn),e(Dn,gd),w(hr,gd,null),e(Ho,Py),e(Ho,_d),e(_d,Gy),g(o,sp,_),g(o,Zo,_),w(ur,Zo,null),e(Zo,Fy),e(Zo,Td),e(Td,Ey),g(o,ap,_),g(o,Bo,_),e(Bo,Vn),e(Vn,yd),w(mr,yd,null),e(Bo,jy),e(Bo,bd),e(bd,zy),g(o,rp,_),g(o,et,_),w(fr,et,null),e(et,xy),e(et,Ro),e(Ro,Cy),e(Ro,vd),e(vd,Uy),e(Ro,Jy),e(Ro,kd),e(kd,Iy),e(Ro,Ny),e(et,qy),e(et,gr),e(gr,Wy),e(gr,wd),e(wd,Ay),e(gr,Hy),e(et,Zy),e(et,Sn),w(_r,Sn,null),e(Sn,By),e(Sn,Md),e(Md,Ry),e(et,Dy),e(et,Yt),w(Tr,Yt,null),e(Yt,Vy),e(Yt,$d),e($d,Sy),e(Yt,Ly),w(Ln,Yt,null),e(et,Xy),e(et,Kt),w(yr,Kt,null),e(Kt,Oy),e(Kt,Pd),e(Pd,Qy),e(Kt,Yy),w(Xn,Kt,null),g(o,ip,_),g(o,Do,_),e(Do,On),e(On,Gd),w(br,Gd,null),e(Do,Ky),e(Do,Fd),e(Fd,eb),g(o,lp,_),g(o,He,_),w(vr,He,null),e(He,tb),e(He,Ed),e(Ed,ob),e(He,nb),e(He,kr),e(kr,sb),e(kr,zi),e(zi,ab),e(kr,rb),e(He,ib),e(He,wr),e(wr,lb),e(wr,Mr),e(Mr,db),e(wr,cb),e(He,pb),e(He,jd),e(jd,hb),e(He,ub),e(He,Dt),e(Dt,zd),e(zd,$r),e($r,mb),e(Dt,fb),e(Dt,xd),e(xd,Pr),e(Pr,gb),e(Dt,_b),e(Dt,Cd),e(Cd,Gr),e(Gr,Tb),e(Dt,yb),e(Dt,Ud),e(Ud,Fr),e(Fr,bb),e(He,vb),e(He,Nt),w(Er,Nt,null),e(Nt,kb),e(Nt,Vo),e(Vo,wb),e(Vo,Jd),e(Jd,Mb),e(Vo,$b),e(Vo,Id),e(Id,Pb),e(Vo,Gb),e(Nt,Fb),w(Qn,Nt,null),e(Nt,Eb),w(Yn,Nt,null),g(o,dp,_),g(o,So,_),e(So,Kn),e(Kn,Nd),w(jr,Nd,null),e(So,jb),e(So,qd),e(qd,zb),g(o,cp,_),g(o,Ze,_),w(zr,Ze,null),e(Ze,xb),e(Ze,Wd),e(Wd,Cb),e(Ze,Ub),e(Ze,xr),e(xr,Jb),e(xr,xi),e(xi,Ib),e(xr,Nb),e(Ze,qb),e(Ze,Cr),e(Cr,Wb),e(Cr,Ur),e(Ur,Ab),e(Cr,Hb),e(Ze,Zb),e(Ze,Ad),e(Ad,Bb),e(Ze,Rb),e(Ze,Vt),e(Vt,Hd),e(Hd,Jr),e(Jr,Db),e(Vt,Vb),e(Vt,Zd),e(Zd,Ir),e(Ir,Sb),e(Vt,Lb),e(Vt,Bd),e(Bd,Nr),e(Nr,Xb),e(Vt,Ob),e(Vt,Rd),e(Rd,qr),e(qr,Qb),e(Ze,Yb),e(Ze,qt),w(Wr,qt,null),e(qt,Kb),e(qt,Lo),e(Lo,e2),e(Lo,Dd),e(Dd,t2),e(Lo,o2),e(Lo,Vd),e(Vd,n2),e(Lo,s2),e(qt,a2),w(es,qt,null),e(qt,r2),w(ts,qt,null),pp=!0},p(o,[_]){const Ar={};_&2&&(Ar.$$scope={dirty:_,ctx:o}),Ko.$set(Ar);const Sd={};_&2&&(Sd.$$scope={dirty:_,ctx:o}),tn.$set(Sd);const Ld={};_&2&&(Ld.$$scope={dirty:_,ctx:o}),on.$set(Ld);const Xd={};_&2&&(Xd.$$scope={dirty:_,ctx:o}),sn.$set(Xd);const Hr={};_&2&&(Hr.$$scope={dirty:_,ctx:o}),an.$set(Hr);const Od={};_&2&&(Od.$$scope={dirty:_,ctx:o}),dn.$set(Od);const Qd={};_&2&&(Qd.$$scope={dirty:_,ctx:o}),cn.$set(Qd);const Zr={};_&2&&(Zr.$$scope={dirty:_,ctx:o}),hn.$set(Zr);const Yd={};_&2&&(Yd.$$scope={dirty:_,ctx:o}),un.$set(Yd);const Kd={};_&2&&(Kd.$$scope={dirty:_,ctx:o}),fn.$set(Kd);const ec={};_&2&&(ec.$$scope={dirty:_,ctx:o}),gn.$set(ec);const Xo={};_&2&&(Xo.$$scope={dirty:_,ctx:o}),Tn.$set(Xo);const tc={};_&2&&(tc.$$scope={dirty:_,ctx:o}),yn.$set(tc);const oc={};_&2&&(oc.$$scope={dirty:_,ctx:o}),bn.$set(oc);const nc={};_&2&&(nc.$$scope={dirty:_,ctx:o}),kn.$set(nc);const sc={};_&2&&(sc.$$scope={dirty:_,ctx:o}),wn.$set(sc);const ac={};_&2&&(ac.$$scope={dirty:_,ctx:o}),Mn.$set(ac);const rc={};_&2&&(rc.$$scope={dirty:_,ctx:o}),Pn.$set(rc);const St={};_&2&&(St.$$scope={dirty:_,ctx:o}),Gn.$set(St);const ic={};_&2&&(ic.$$scope={dirty:_,ctx:o}),En.$set(ic);const Br={};_&2&&(Br.$$scope={dirty:_,ctx:o}),jn.$set(Br);const lc={};_&2&&(lc.$$scope={dirty:_,ctx:o}),zn.$set(lc);const ke={};_&2&&(ke.$$scope={dirty:_,ctx:o}),Cn.$set(ke);const dc={};_&2&&(dc.$$scope={dirty:_,ctx:o}),Un.$set(dc);const cc={};_&2&&(cc.$$scope={dirty:_,ctx:o}),Jn.$set(cc);const pc={};_&2&&(pc.$$scope={dirty:_,ctx:o}),Nn.$set(pc);const hc={};_&2&&(hc.$$scope={dirty:_,ctx:o}),qn.$set(hc);const uc={};_&2&&(uc.$$scope={dirty:_,ctx:o}),Wn.$set(uc);const mc={};_&2&&(mc.$$scope={dirty:_,ctx:o}),Hn.$set(mc);const fc={};_&2&&(fc.$$scope={dirty:_,ctx:o}),Zn.$set(fc);const gc={};_&2&&(gc.$$scope={dirty:_,ctx:o}),Bn.$set(gc);const Lt={};_&2&&(Lt.$$scope={dirty:_,ctx:o}),Rn.$set(Lt);const _c={};_&2&&(_c.$$scope={dirty:_,ctx:o}),Ln.$set(_c);const Tc={};_&2&&(Tc.$$scope={dirty:_,ctx:o}),Xn.$set(Tc);const yc={};_&2&&(yc.$$scope={dirty:_,ctx:o}),Qn.$set(yc);const os={};_&2&&(os.$$scope={dirty:_,ctx:o}),Yn.$set(os);const bc={};_&2&&(bc.$$scope={dirty:_,ctx:o}),es.$set(bc);const vc={};_&2&&(vc.$$scope={dirty:_,ctx:o}),ts.$set(vc)},i(o){pp||(M(l.$$.fragment,o),M(he.$$.fragment,o),M(bs.$$.fragment,o),M(vs.$$.fragment,o),M(Rs.$$.fragment,o),M(Ds.$$.fragment,o),M(Ko.$$.fragment,o),M(Ss.$$.fragment,o),M(Ls.$$.fragment,o),M(tn.$$.fragment,o),M(on.$$.fragment,o),M(Qs.$$.fragment,o),M(Ys.$$.fragment,o),M(Ks.$$.fragment,o),M(sn.$$.fragment,o),M(an.$$.fragment,o),M(na.$$.fragment,o),M(sa.$$.fragment,o),M(aa.$$.fragment,o),M(ra.$$.fragment,o),M(ia.$$.fragment,o),M(pa.$$.fragment,o),M(dn.$$.fragment,o),M(cn.$$.fragment,o),M(ha.$$.fragment,o),M(ua.$$.fragment,o),M(_a.$$.fragment,o),M(hn.$$.fragment,o),M(un.$$.fragment,o),M(Ta.$$.fragment,o),M(ya.$$.fragment,o),M(wa.$$.fragment,o),M(fn.$$.fragment,o),M(gn.$$.fragment,o),M(Ma.$$.fragment,o),M($a.$$.fragment,o),M(Ea.$$.fragment,o),M(Tn.$$.fragment,o),M(yn.$$.fragment,o),M(bn.$$.fragment,o),M(ja.$$.fragment,o),M(za.$$.fragment,o),M(Ja.$$.fragment,o),M(kn.$$.fragment,o),M(wn.$$.fragment,o),M(Mn.$$.fragment,o),M(Ia.$$.fragment,o),M(Na.$$.fragment,o),M(Ha.$$.fragment,o),M(Pn.$$.fragment,o),M(Gn.$$.fragment,o),M(Za.$$.fragment,o),M(Ba.$$.fragment,o),M(En.$$.fragment,o),M(Sa.$$.fragment,o),M(jn.$$.fragment,o),M(zn.$$.fragment,o),M(La.$$.fragment,o),M(Xa.$$.fragment,o),M(Cn.$$.fragment,o),M(Ka.$$.fragment,o),M(Un.$$.fragment,o),M(Jn.$$.fragment,o),M(er.$$.fragment,o),M(tr.$$.fragment,o),M(Nn.$$.fragment,o),M(ar.$$.fragment,o),M(qn.$$.fragment,o),M(Wn.$$.fragment,o),M(rr.$$.fragment,o),M(ir.$$.fragment,o),M(Hn.$$.fragment,o),M(pr.$$.fragment,o),M(Zn.$$.fragment,o),M(Bn.$$.fragment,o),M(Rn.$$.fragment,o),M(hr.$$.fragment,o),M(ur.$$.fragment,o),M(mr.$$.fragment,o),M(fr.$$.fragment,o),M(_r.$$.fragment,o),M(Tr.$$.fragment,o),M(Ln.$$.fragment,o),M(yr.$$.fragment,o),M(Xn.$$.fragment,o),M(br.$$.fragment,o),M(vr.$$.fragment,o),M(Er.$$.fragment,o),M(Qn.$$.fragment,o),M(Yn.$$.fragment,o),M(jr.$$.fragment,o),M(zr.$$.fragment,o),M(Wr.$$.fragment,o),M(es.$$.fragment,o),M(ts.$$.fragment,o),pp=!0)},o(o){$(l.$$.fragment,o),$(he.$$.fragment,o),$(bs.$$.fragment,o),$(vs.$$.fragment,o),$(Rs.$$.fragment,o),$(Ds.$$.fragment,o),$(Ko.$$.fragment,o),$(Ss.$$.fragment,o),$(Ls.$$.fragment,o),$(tn.$$.fragment,o),$(on.$$.fragment,o),$(Qs.$$.fragment,o),$(Ys.$$.fragment,o),$(Ks.$$.fragment,o),$(sn.$$.fragment,o),$(an.$$.fragment,o),$(na.$$.fragment,o),$(sa.$$.fragment,o),$(aa.$$.fragment,o),$(ra.$$.fragment,o),$(ia.$$.fragment,o),$(pa.$$.fragment,o),$(dn.$$.fragment,o),$(cn.$$.fragment,o),$(ha.$$.fragment,o),$(ua.$$.fragment,o),$(_a.$$.fragment,o),$(hn.$$.fragment,o),$(un.$$.fragment,o),$(Ta.$$.fragment,o),$(ya.$$.fragment,o),$(wa.$$.fragment,o),$(fn.$$.fragment,o),$(gn.$$.fragment,o),$(Ma.$$.fragment,o),$($a.$$.fragment,o),$(Ea.$$.fragment,o),$(Tn.$$.fragment,o),$(yn.$$.fragment,o),$(bn.$$.fragment,o),$(ja.$$.fragment,o),$(za.$$.fragment,o),$(Ja.$$.fragment,o),$(kn.$$.fragment,o),$(wn.$$.fragment,o),$(Mn.$$.fragment,o),$(Ia.$$.fragment,o),$(Na.$$.fragment,o),$(Ha.$$.fragment,o),$(Pn.$$.fragment,o),$(Gn.$$.fragment,o),$(Za.$$.fragment,o),$(Ba.$$.fragment,o),$(En.$$.fragment,o),$(Sa.$$.fragment,o),$(jn.$$.fragment,o),$(zn.$$.fragment,o),$(La.$$.fragment,o),$(Xa.$$.fragment,o),$(Cn.$$.fragment,o),$(Ka.$$.fragment,o),$(Un.$$.fragment,o),$(Jn.$$.fragment,o),$(er.$$.fragment,o),$(tr.$$.fragment,o),$(Nn.$$.fragment,o),$(ar.$$.fragment,o),$(qn.$$.fragment,o),$(Wn.$$.fragment,o),$(rr.$$.fragment,o),$(ir.$$.fragment,o),$(Hn.$$.fragment,o),$(pr.$$.fragment,o),$(Zn.$$.fragment,o),$(Bn.$$.fragment,o),$(Rn.$$.fragment,o),$(hr.$$.fragment,o),$(ur.$$.fragment,o),$(mr.$$.fragment,o),$(fr.$$.fragment,o),$(_r.$$.fragment,o),$(Tr.$$.fragment,o),$(Ln.$$.fragment,o),$(yr.$$.fragment,o),$(Xn.$$.fragment,o),$(br.$$.fragment,o),$(vr.$$.fragment,o),$(Er.$$.fragment,o),$(Qn.$$.fragment,o),$(Yn.$$.fragment,o),$(jr.$$.fragment,o),$(zr.$$.fragment,o),$(Wr.$$.fragment,o),$(es.$$.fragment,o),$(ts.$$.fragment,o),pp=!1},d(o){t(d),o&&t(y),o&&t(f),P(l),o&&t(N),o&&t(J),o&&t(Q),o&&t(le),P(he),o&&t(Me),o&&t(H),o&&t($e),o&&t(ge),o&&t(Pe),o&&t(_e),o&&t(Y),o&&t(Te),o&&t(K),o&&t(ee),o&&t(kc),o&&t(po),o&&t(wc),o&&t(Xt),o&&t(Mc),o&&t(ho),P(bs),o&&t($c),o&&t(Vr),o&&t(Pc),P(vs,o),o&&t(Gc),o&&t(B),o&&t(Fc),o&&t(uo),P(Rs),o&&t(Ec),o&&t(Pt),P(Ds),P(Ko),o&&t(jc),o&&t(fo),P(Ss),o&&t(zc),o&&t(be),P(Ls),P(tn),P(on),P(Qs),o&&t(xc),o&&t(go),P(Ys),o&&t(Cc),o&&t(We),P(Ks),P(sn),P(an),o&&t(Uc),o&&t(_o),P(na),o&&t(Jc),o&&t(To),P(sa),o&&t(Ic),o&&t(yo),P(aa),o&&t(Nc),o&&t(bo),P(ra),o&&t(qc),o&&t(mt),P(ia),P(pa),P(dn),P(cn),o&&t(Wc),o&&t(ko),P(ha),o&&t(Ac),o&&t(ft),P(ua),P(_a),P(hn),P(un),o&&t(Hc),o&&t(Mo),P(Ta),o&&t(Zc),o&&t(gt),P(ya),P(wa),P(fn),P(gn),o&&t(Bc),o&&t(Po),P(Ma),o&&t(Rc),o&&t(_t),P($a),P(Ea),P(Tn),P(yn),P(bn),o&&t(Dc),o&&t(Eo),P(ja),o&&t(Vc),o&&t(Ae),P(za),P(Ja),P(kn),P(wn),P(Mn),o&&t(Sc),o&&t(zo),P(Ia),o&&t(Lc),o&&t(Tt),P(Na),P(Ha),P(Pn),P(Gn),o&&t(Xc),o&&t(Co),P(Za),o&&t(Oc),o&&t(Qe),P(Ba),P(En),P(Sa),P(jn),P(zn),o&&t(Qc),o&&t(Jo),P(La),o&&t(Yc),o&&t(Ye),P(Xa),P(Cn),P(Ka),P(Un),P(Jn),o&&t(Kc),o&&t(No),P(er),o&&t(ep),o&&t(Ke),P(tr),P(Nn),P(ar),P(qn),P(Wn),o&&t(tp),o&&t(Wo),P(rr),o&&t(op),o&&t(ve),P(ir),P(Hn),P(pr),P(Zn),P(Bn),P(Rn),o&&t(np),o&&t(Ho),P(hr),o&&t(sp),o&&t(Zo),P(ur),o&&t(ap),o&&t(Bo),P(mr),o&&t(rp),o&&t(et),P(fr),P(_r),P(Tr),P(Ln),P(yr),P(Xn),o&&t(ip),o&&t(Do),P(br),o&&t(lp),o&&t(He),P(vr),P(Er),P(Qn),P(Yn),o&&t(dp),o&&t(So),P(jr),o&&t(cp),o&&t(Ze),P(zr),P(Wr),P(es),P(ts)}}}const IM={local:"openai-gpt2",sections:[{local:"overview",title:"Overview"},{local:"resources",title:"Resources"},{local:"transformers.GPT2Config",title:"GPT2Config"},{local:"transformers.GPT2Tokenizer",title:"GPT2Tokenizer"},{local:"transformers.GPT2TokenizerFast",title:"GPT2TokenizerFast"},{local:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput",title:"GPT2 specific outputs"},{local:"transformers.GPT2Model",title:"GPT2Model"},{local:"transformers.GPT2LMHeadModel",title:"GPT2LMHeadModel"},{local:"transformers.GPT2DoubleHeadsModel",title:"GPT2DoubleHeadsModel"},{local:"transformers.GPT2ForQuestionAnswering",title:"GPT2ForQuestionAnswering"},{local:"transformers.GPT2ForSequenceClassification",title:"GPT2ForSequenceClassification"},{local:"transformers.GPT2ForTokenClassification",title:"GPT2ForTokenClassification"},{local:"transformers.TFGPT2Model",title:"TFGPT2Model"},{local:"transformers.TFGPT2LMHeadModel",title:"TFGPT2LMHeadModel"},{local:"transformers.TFGPT2DoubleHeadsModel",title:"TFGPT2DoubleHeadsModel"},{local:"transformers.TFGPT2ForSequenceClassification",title:"TFGPT2ForSequenceClassification"},{local:"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast",title:"TFSequenceClassifierOutputWithPast"},{local:"transformers.TFGPT2Tokenizer",title:"TFGPT2Tokenizer"},{local:"transformers.FlaxGPT2Model",title:"FlaxGPT2Model"},{local:"transformers.FlaxGPT2LMHeadModel",title:"FlaxGPT2LMHeadModel"}],title:"OpenAI GPT2"};function NM(G){return Xw(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class DM extends Dw{constructor(d){super();Vw(this,d,NM,JM,Sw,{})}}export{DM as default,IM as metadata};
