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 Ze}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 E=i(f);m=s(E,"is_split_into_words=True"),E.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,E;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"),E=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),E=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,E)},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 E=i(f);m=s(E,"Module"),E.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 E=i(f);m=s(E,"Module"),E.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 E=i(f);m=s(E,"Module"),E.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 E=i(f);m=s(E,"Module"),E.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,E;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"),E=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),E=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,E)},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 E=i(f);m=s(E,"Module"),E.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 E=i(f);m=s(E,"Module"),E.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,E,R,N,J,O,re,F,Ge,S,fe,Se,Q,le,pe,L,he,Ee,X,Fe,Me,B,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"),E=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(),F=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()"),Ee=n(" and "),X=a("code"),Fe=n("predict()"),Me=n(`, such as when creating your own layers or models with
the Keras `),B=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);E=r(ce,"LI",{});var st=i(E);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),F=r(b,"P",{});var z=i(F);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),Ee=s(z," and "),X=r(z,"CODE",{});var lt=i(X);Fe=s(lt,"predict()"),lt.forEach(t),Me=s(z,`, such as when creating your own layers or models with
the Keras `),B=r(z,"CODE",{});var dt=i(B);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 H=i(x);C=r(H,"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(H),U=r(H,"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(H),D=r(H,"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),H.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,E),e(E,R),e(h,N),e(h,J),e(J,O),g(b,re,j),g(b,F,j),e(F,Ge),e(F,S),e(S,fe),e(F,Se),e(F,Q),e(Q,le),e(F,pe),e(F,L),e(L,he),e(F,Ee),e(F,X),e(X,Fe),e(F,Me),e(F,B),e(B,je),e(F,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(F),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 E=i(f);m=s(E,"Module"),E.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,E,R,N,J,O,re,F,Ge,S,fe,Se,Q,le,pe,L,he,Ee,X,Fe,Me,B,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"),E=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(),F=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()"),Ee=n(" and "),X=a("code"),Fe=n("predict()"),Me=n(`, such as when creating your own layers or models with
the Keras `),B=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);E=r(ce,"LI",{});var st=i(E);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),F=r(b,"P",{});var z=i(F);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),Ee=s(z," and "),X=r(z,"CODE",{});var lt=i(X);Fe=s(lt,"predict()"),lt.forEach(t),Me=s(z,`, such as when creating your own layers or models with
the Keras `),B=r(z,"CODE",{});var dt=i(B);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 H=i(x);C=r(H,"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(H),U=r(H,"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(H),D=r(H,"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),H.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,E),e(E,R),e(h,N),e(h,J),e(J,O),g(b,re,j),g(b,F,j),e(F,Ge),e(F,S),e(S,fe),e(F,Se),e(F,Q),e(Q,le),e(F,pe),e(F,L),e(L,he),e(F,Ee),e(F,X),e(X,Fe),e(F,Me),e(F,B),e(B,je),e(F,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(F),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 E=i(f);m=s(E,"Module"),E.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,E,R,N,J,O,re,F,Ge,S,fe,Se,Q,le,pe,L,he,Ee,X,Fe,Me,B,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"),E=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(),F=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()"),Ee=n(" and "),X=a("code"),Fe=n("predict()"),Me=n(`, such as when creating your own layers or models with
the Keras `),B=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);E=r(ce,"LI",{});var st=i(E);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),F=r(b,"P",{});var z=i(F);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),Ee=s(z," and "),X=r(z,"CODE",{});var lt=i(X);Fe=s(lt,"predict()"),lt.forEach(t),Me=s(z,`, such as when creating your own layers or models with
the Keras `),B=r(z,"CODE",{});var dt=i(B);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 H=i(x);C=r(H,"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(H),U=r(H,"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(H),D=r(H,"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),H.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,E),e(E,R),e(h,N),e(h,J),e(J,O),g(b,re,j),g(b,F,j),e(F,Ge),e(F,S),e(S,fe),e(F,Se),e(F,Q),e(Q,le),e(F,pe),e(F,L),e(L,he),e(F,Ee),e(F,X),e(X,Fe),e(F,Me),e(F,B),e(B,je),e(F,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(F),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 E=i(f);m=s(E,"Module"),E.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,E,R,N,J,O,re,F,Ge,S,fe,Se,Q,le,pe,L,he,Ee,X,Fe,Me,B,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"),E=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(),F=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()"),Ee=n(" and "),X=a("code"),Fe=n("predict()"),Me=n(`, such as when creating your own layers or models with
the Keras `),B=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);E=r(ce,"LI",{});var st=i(E);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),F=r(b,"P",{});var z=i(F);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),Ee=s(z," and "),X=r(z,"CODE",{});var lt=i(X);Fe=s(lt,"predict()"),lt.forEach(t),Me=s(z,`, such as when creating your own layers or models with
the Keras `),B=r(z,"CODE",{});var dt=i(B);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 H=i(x);C=r(H,"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(H),U=r(H,"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(H),D=r(H,"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),H.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,E),e(E,R),e(h,N),e(h,J),e(J,O),g(b,re,j),g(b,F,j),e(F,Ge),e(F,S),e(S,fe),e(F,Se),e(F,Q),e(Q,le),e(F,pe),e(F,L),e(L,he),e(F,Ee),e(F,X),e(X,Fe),e(F,Me),e(F,B),e(B,je),e(F,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(F),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 E=i(f);m=s(E,"Module"),E.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 EM(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 FM(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 E=i(f);m=s(E,"Module"),E.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 E=i(f);m=s(E,"Module"),E.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,E,R,N,J,O,re,F,Ge,S,fe,Se,Q,le,pe,L,he,Ee,X,Fe,Me,B,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,H,se,ct,Le,ae,pt,Oe,qe,ht,ie,ut,Th,yh,Zt,bh,Qi,vh,kh,Yi,wh,Mh,gs,$h,Ph,kc,po,_s,Gh,Eh,Ki,Fh,jh,wc,Xt,zh,Ts,xh,Ch,ys,Uh,Jh,Mc,ho,Qo,el,bs,Ih,tl,Nh,$c,Vr,qh,Pc,vs,Gc,Z,ks,Wh,ws,Ah,Bh,Hh,Ms,Zh,$s,Rh,Dh,Vh,Ps,Sh,Gs,Lh,Xh,Oh,Es,Qh,Fs,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,Ft,Lr,gu,_u,Ns,Tu,yu,qs,bu,vu,Ws,ku,wu,Mu,Ot,Xr,$u,Pu,As,Gu,Eu,Bs,Fu,ju,zu,Qt,Or,xu,Cu,Hs,Uu,Ju,Zs,Iu,Nu,qu,ol,Qr,Wu,Au,nl,Yr,Bu,Hu,sl,Kr,Zu,Ec,uo,Yo,al,Rs,Ru,rl,Du,Fc,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,Em,Fm,jm,fl,zm,xm,sn,Cm,ta,Um,gl,Jm,Im,Nm,an,qm,oa,Wm,ri,Am,Bm,Uc,_o,rn,_l,na,Hm,Tl,Zm,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,Ef,zt,_a,Ff,wo,jf,ci,zf,xf,El,Cf,Uf,Jf,hn,If,un,Bc,Mo,mn,Fl,Ta,Nf,jl,qf,Hc,gt,ya,Wf,zl,Af,Bf,ba,Hf,pi,Zf,Rf,Df,va,Vf,ka,Sf,Lf,Xf,xt,wa,Of,$o,Qf,hi,Yf,Kf,xl,eg,tg,og,fn,ng,gn,Zc,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,Ea,Tg,yg,bg,yt,Fa,vg,Eo,kg,mi,wg,Mg,Nl,$g,Pg,Gg,Tn,Eg,yn,Fg,bn,Dc,Fo,vn,ql,ja,jg,Wl,zg,Vc,Ae,za,xg,Al,Cg,Ug,fi,gi,Jg,Ig,Ng,Gt,qg,Bl,Wg,Ag,Hl,Bg,Hg,Zl,Zg,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,Ba,M_,xo,$_,bi,P_,G_,Xl,E_,F_,j_,Pn,z_,Gn,Xc,Co,En,Ol,Ha,x_,Ql,C_,Oc,Qe,Za,U_,Yl,J_,I_,Ra,N_,vi,q_,W_,A_,Da,B_,Va,H_,Z_,R_,Fn,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,ET,FT,jT,nr,zT,sr,xT,CT,UT,Nn,JT,It,ar,IT,qo,NT,Pi,qT,WT,id,AT,BT,HT,qn,ZT,Wn,tp,Wo,An,ld,rr,RT,dd,DT,op,ve,ir,VT,cd,ST,LT,Gi,Ei,XT,OT,QT,Et,YT,pd,KT,ey,hd,ty,oy,ud,ny,sy,md,ay,ry,iy,lr,ly,Fi,dy,cy,py,dr,hy,cr,uy,my,fy,Bn,gy,vt,pr,_y,Ao,Ty,ji,yy,by,fd,vy,ky,wy,Hn,My,Zn,$y,Rn,np,Bo,Dn,gd,hr,Py,_d,Gy,sp,Ho,ur,Ey,Td,Fy,ap,Zo,Vn,yd,mr,jy,bd,zy,rp,et,fr,xy,Ro,Cy,vd,Uy,Jy,kd,Iy,Ny,qy,gr,Wy,wd,Ay,By,Hy,Sn,_r,Zy,Md,Ry,Dy,Yt,Tr,Vy,$d,Sy,Ly,Ln,Xy,Kt,yr,Oy,Pd,Qy,Yy,Xn,ip,Do,On,Gd,br,Ky,Ed,eb,lp,Be,vr,tb,Fd,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,Er,bb,vb,Nt,Fr,kb,Vo,wb,Jd,Mb,$b,Id,Pb,Gb,Eb,Qn,Fb,Yn,dp,So,Kn,Nd,jr,jb,qd,zb,cp,He,zr,xb,Wd,Cb,Ub,xr,Jb,xi,Ib,Nb,qb,Cr,Wb,Ur,Ab,Bb,Hb,Ad,Zb,Rb,Vt,Bd,Jr,Db,Vb,Hd,Ir,Sb,Lb,Zd,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 Ze({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 Ze({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/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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 Ze({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/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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 Ze({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/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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 Ze({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"}}),Fa=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/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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 Ze({props:{$$slots:{default:[lM]},$$scope:{ctx:G}}}),yn=new Ze({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/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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 Ze({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"}}),Ba=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/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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 Ze({props:{$$slots:{default:[mM]},$$scope:{ctx:G}}}),Gn=new Re({props:{anchor:"transformers.GPT2ForTokenClassification.forward.example",$$slots:{default:[fM]},$$scope:{ctx:G}}}),Ha=new we({}),Za=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"}}),Fn=new Ze({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/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.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 Ze({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 Ze({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/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.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 Ze({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 Ze({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/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.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 Ze({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"}}),Bn=new Ze({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/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.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>
`}}),Hn=new Ze({props:{$$slots:{default:[PM]},$$scope:{ctx:G}}}),Zn=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:[EM]},$$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:[FM]},$$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"}}),Fr=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/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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 Ze({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/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.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 Ze({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(),E=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),Ee=c(),X=a("span"),Fe=n("Overview"),Me=c(),B=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 `),H=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(),Zt=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"),Eh=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"),Fh=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(),Z=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"),Bh=n("."),Hh=c(),Ms=a("li"),Zh=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(),Es=a("li"),Qh=n("A blog on "),Fs=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(),Ft=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"),Eu=n(" and "),Bs=a("a"),Fu=n("notebook"),ju=n("."),zu=c(),Qt=a("li"),Or=a("a"),xu=n("FlaxGPT2LMHeadModel"),Cu=n(" is supported by this "),Hs=a("a"),Uu=n("causal language modeling example script"),Ju=n(" and "),Zs=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"),Bu=n("Token classification task guide"),Hu=c(),sl=a("li"),Kr=a("a"),Zu=n("Causal language modeling task guide"),Ec=c(),uo=a("h2"),Yo=a("a"),al=a("span"),v(Rs.$$.fragment),Ru=c(),rl=a("span"),Du=n("GPT2Config"),Fc=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"),Em=n("tokenizers"),Fm=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"),Bm=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),Hm=c(),Tl=a("span"),Zm=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.`),Ef=c(),zt=a("div"),v(_a.$$.fragment),Ff=c(),wo=a("p"),jf=n("The "),ci=a("a"),zf=n("GPT2LMHeadModel"),xf=n(" forward method, overrides the "),El=a("code"),Cf=n("__call__"),Uf=n(" special method."),Jf=c(),v(hn.$$.fragment),If=c(),v(un.$$.fragment),Bc=c(),Mo=a("h2"),mn=a("a"),Fl=a("span"),v(Ta.$$.fragment),Nf=c(),jl=a("span"),qf=n("GPT2DoubleHeadsModel"),Hc=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).`),Bf=c(),ba=a("p"),Hf=n("This model inherits from "),pi=a("a"),Zf=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),Zc=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 "),Ea=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(Fa.$$.fragment),vg=c(),Eo=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),Eg=c(),v(yn.$$.fragment),Fg=c(),v(bn.$$.fragment),Dc=c(),Fo=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
`),Bl=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 `),Hl=a("code"),Bg=n("pad_token_id"),Hg=n(` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
padding tokens when `),Zl=a("code"),Zg=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(Ba.$$.fragment),M_=c(),xo=a("p"),$_=n("The "),bi=a("a"),P_=n("GPT2ForTokenClassification"),G_=n(" forward method, overrides the "),Xl=a("code"),E_=n("__call__"),F_=n(" special method."),j_=c(),v(Pn.$$.fragment),z_=c(),v(Gn.$$.fragment),Xc=c(),Co=a("h2"),En=a("a"),Ol=a("span"),v(Ha.$$.fragment),x_=c(),Ql=a("span"),C_=n("TFGPT2Model"),Oc=c(),Qe=a("div"),v(Za.$$.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"),B_=n("This model is also a "),Va=a("a"),H_=n("tf.keras.Model"),Z_=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(Fn.$$.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"),ET=n("TFPreTrainedModel"),FT=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__"),BT=n(" special method."),HT=c(),v(qn.$$.fragment),ZT=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"),Ei=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(),Et=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 "),Fi=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(Bn.$$.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(Hn.$$.fragment),My=c(),v(Zn.$$.fragment),$y=c(),v(Rn.$$.fragment),np=c(),Bo=a("h2"),Dn=a("a"),gd=a("span"),v(hr.$$.fragment),Py=c(),_d=a("span"),Gy=n("TFSequenceClassifierOutputWithPast"),sp=c(),Ho=a("div"),v(ur.$$.fragment),Ey=c(),Td=a("p"),Fy=n("Base class for outputs of sentence classification models."),ap=c(),Zo=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"),By=n(" inputs to outputs."),Hy=c(),Sn=a("div"),v(_r.$$.fragment),Zy=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(),Ed=a("span"),eb=n("FlaxGPT2Model"),lp=c(),Be=a("div"),v(vr.$$.fragment),tb=c(),Fd=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"),Er=a("a"),bb=n("Parallelization"),vb=c(),Nt=a("div"),v(Fr.$$.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."),Eb=c(),v(Qn.$$.fragment),Fb=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(),He=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"),Bb=n(` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),Hb=c(),Ad=a("p"),Zb=n("Finally, this model supports inherent JAX features such as:"),Rb=c(),Vt=a("ul"),Bd=a("li"),Jr=a("a"),Db=n("Just-In-Time (JIT) compilation"),Vb=c(),Hd=a("li"),Ir=a("a"),Sb=n("Automatic Differentiation"),Lb=c(),Zd=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),E=r(Ar,"SPAN",{});var Xd=i(E);R=s(Xd,"OpenAI GPT2"),Xd.forEach(t),Ar.forEach(t),N=p(o),J=r(o,"DIV",{class:!0});var Br=i(J);O=r(Br,"A",{href:!0});var Od=i(O);re=r(Od,"IMG",{alt:!0,src:!0}),Od.forEach(t),Ge=p(Br),S=r(Br,"A",{href:!0});var Qd=i(S);fe=r(Qd,"IMG",{alt:!0,src:!0}),Qd.forEach(t),Br.forEach(t),Q=p(o),le=r(o,"H2",{class:!0});var Hr=i(le);pe=r(Hr,"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),Ee=p(Hr),X=r(Hr,"SPAN",{});var ec=i(X);Fe=s(ec,"Overview"),ec.forEach(t),Hr.forEach(t),Me=p(o),B=r(o,"P",{});var Xo=i(B);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 Zr=i(V);Je=s(Zr,`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(Zr,"EM",{});var lc=i(de);I=s(lc,"run_generation.py"),lc.forEach(t),Ie=s(Zr," example script."),Zr.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 `),H=r(ke,"EM",{});var uc=i(H);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),Zt=r(St,"LI",{});var Lt=i(Zt);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),Eh=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);Fh=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),Z=r(o,"UL",{});var te=i(Z);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),Bh=s(up,"."),up.forEach(t),Hh=p(te),Ms=r(te,"LI",{});var mp=i(Ms);Zh=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),Es=r(te,"LI",{});var gp=i(Es);Qh=s(gp,"A blog on "),Fs=r(gp,"A",{href:!0,rel:!0});var y2=i(Fs);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),Ft=r(te,"LI",{});var Oo=i(Ft);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 E2=i(Xr);$u=s(E2,"TFGPT2LMHeadModel"),E2.forEach(t),Pu=s(Rr," is supported by this "),As=r(Rr,"A",{href:!0,rel:!0});var F2=i(As);Gu=s(F2,"causal language modeling example script"),F2.forEach(t),Eu=s(Rr," and "),Bs=r(Rr,"A",{href:!0,rel:!0});var j2=i(Bs);Fu=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 "),Hs=r(Dr,"A",{href:!0,rel:!0});var x2=i(Hs);Uu=s(x2,"causal language modeling example script"),x2.forEach(t),Ju=s(Dr," and "),Zs=r(Dr,"A",{href:!0,rel:!0});var C2=i(Zs);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);Bu=s(N2,"Token classification task guide"),N2.forEach(t),I2.forEach(t),Hu=p(te),sl=r(te,"LI",{});var q2=i(sl);Kr=r(q2,"A",{href:!0});var W2=i(Kr);Zu=s(W2,"Causal language modeling task guide"),W2.forEach(t),q2.forEach(t),te.forEach(t),Ec=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 B2=i(al);k(Rs.$$.fragment,B2),B2.forEach(t),A2.forEach(t),Ru=p(bp),rl=r(bp,"SPAN",{});var H2=i(rl);Du=s(H2,"GPT2Config"),H2.forEach(t),bp.forEach(t),Fc=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 Z2=i(ei);Lu=s(Z2,"GPT2Model"),Z2.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);Em=s(av,"tokenizers"),av.forEach(t),Fm=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),Bm=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 Ep=i(_o);rn=r(Ep,"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),Hm=p(Ep),Tl=r(Ep,"SPAN",{});var pv=i(Tl);Zm=s(pv,"GPT2 specific outputs"),pv.forEach(t),Ep.forEach(t),Jc=p(o),To=r(o,"DIV",{class:!0});var Fp=i(To);k(sa.$$.fragment,Fp),Rm=p(Fp),yl=r(Fp,"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),Fp.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),Ef=p(to),zt=r(to,"DIV",{class:!0});var rs=i(zt);k(_a.$$.fragment,rs),Ff=p(rs),wo=r(rs,"P",{});var Ii=i(wo);jf=s(Ii,"The "),ci=r(Ii,"A",{href:!0});var Ev=i(ci);zf=s(Ev,"GPT2LMHeadModel"),Ev.forEach(t),xf=s(Ii," forward method, overrides the "),El=r(Ii,"CODE",{});var Fv=i(El);Cf=s(Fv,"__call__"),Fv.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),Bc=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);Fl=r(jv,"SPAN",{});var zv=i(Fl);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),Hc=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),Bf=p(oo),ba=r(oo,"P",{});var qp=i(ba);Hf=s(qp,"This model inherits from "),pi=r(qp,"A",{href:!0});var Uv=i(pi);Zf=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),Zc=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 Bv=i(Jl);lg=s(Bv,"span start logits"),Bv.forEach(t),dg=s(qi," and "),Il=r(qi,"CODE",{});var Hv=i(Il);cg=s(Hv,"span end logits"),Hv.forEach(t),pg=s(qi,")."),qi.forEach(t),hg=p(no),Pa=r(no,"P",{});var Bp=i(Pa);ug=s(Bp,"This model inherits from "),ui=r(Bp,"A",{href:!0});var Zv=i(ui);mg=s(Zv,"PreTrainedModel"),Zv.forEach(t),fg=s(Bp,`. 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.)`),Bp.forEach(t),gg=p(no),Ga=r(no,"P",{});var Hp=i(Ga);_g=s(Hp,"This model is also a PyTorch "),Ea=r(Hp,"A",{href:!0,rel:!0});var Rv=i(Ea);Tg=s(Rv,"torch.nn.Module"),Rv.forEach(t),yg=s(Hp,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Hp.forEach(t),bg=p(no),yt=r(no,"DIV",{class:!0});var so=i(yt);k(Fa.$$.fragment,so),vg=p(so),Eo=r(so,"P",{});var Wi=i(Eo);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),Eg=p(so),k(yn.$$.fragment,so),Fg=p(so),k(bn.$$.fragment,so),so.forEach(t),no.forEach(t),Dc=p(o),Fo=r(o,"H2",{class:!0});var Zp=i(Fo);vn=r(Zp,"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(Zp),Wl=r(Zp,"SPAN",{});var Xv=i(Wl);zg=s(Xv,"GPT2ForSequenceClassification"),Xv.forEach(t),Zp.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
`),Bl=r(ao,"CODE",{});var Yv=i(Bl);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 `),Hl=r(ao,"CODE",{});var Kv=i(Hl);Bg=s(Kv,"pad_token_id"),Kv.forEach(t),Hg=s(ao,` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
padding tokens when `),Zl=r(ao,"CODE",{});var ek=i(Zl);Zg=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(Ba.$$.fragment,ls),M_=p(ls),xo=r(ls,"P",{});var Bi=i(xo);$_=s(Bi,"The "),bi=r(Bi,"A",{href:!0});var hk=i(bi);P_=s(hk,"GPT2ForTokenClassification"),hk.forEach(t),G_=s(Bi," forward method, overrides the "),Xl=r(Bi,"CODE",{});var uk=i(Xl);E_=s(uk,"__call__"),uk.forEach(t),F_=s(Bi," special method."),Bi.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);En=r(Xp,"A",{id:!0,class:!0,href:!0});var mk=i(En);Ol=r(mk,"SPAN",{});var fk=i(Ol);k(Ha.$$.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(Za.$$.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);B_=s(Qp,"This model is also a "),Va=r(Qp,"A",{href:!0,rel:!0});var yk=i(Va);H_=s(yk,"tf.keras.Model"),yk.forEach(t),Z_=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(Fn.$$.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 Hi=i(Uo);S_=s(Hi,"The "),ki=r(Hi,"A",{href:!0});var bk=i(ki);L_=s(bk,"TFGPT2Model"),bk.forEach(t),X_=s(Hi," forward method, overrides the "),Kl=r(Hi,"CODE",{});var vk=i(Kl);O_=s(vk,"__call__"),vk.forEach(t),Q_=s(Hi," special method."),Hi.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 Zi=i(Io);fT=s(Zi,"The "),Mi=r(Zi,"A",{href:!0});var Ek=i(Mi);gT=s(Ek,"TFGPT2LMHeadModel"),Ek.forEach(t),_T=s(Zi," forward method, overrides the "),nd=r(Zi,"CODE",{});var Fk=i(nd);TT=s(Fk,"__call__"),Fk.forEach(t),yT=s(Zi," special method."),Zi.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 Bt=i(Ke);k(tr.$$.fragment,Bt),MT=p(Bt),rd=r(Bt,"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(Bt),or=r(Bt,"P",{});var oh=i(or);GT=s(oh,"This model inherits from "),$i=r(oh,"A",{href:!0});var Uk=i($i);ET=s(Uk,"TFPreTrainedModel"),Uk.forEach(t),FT=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(Bt),nr=r(Bt,"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(Bt),k(Nn.$$.fragment,Bt),JT=p(Bt),It=r(Bt,"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),BT=s(Ri," special method."),Ri.forEach(t),HT=p(ps),k(qn.$$.fragment,ps),ZT=p(ps),k(Wn.$$.fragment,ps),ps.forEach(t),Bt.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 Bk=i(cd);ST=s(Bk,"The GPT2 Model transformer with a sequence classification head on top (linear layer)."),Bk.forEach(t),LT=p(ot),Gi=r(ot,"P",{});var d2=i(Gi);Ei=r(d2,"A",{href:!0});var Hk=i(Ei);XT=s(Hk,"TFGPT2ForSequenceClassification"),Hk.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),Et=r(ot,"P",{});var lo=i(Et);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 Zk=i(pd);KT=s(Zk,"pad_token_id"),Zk.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 "),Fi=r(ah,"A",{href:!0});var Sk=i(Fi);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(Bn.$$.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(Hn.$$.fragment,co),My=p(co),k(Zn.$$.fragment,co),$y=p(co),k(Rn.$$.fragment,co),co.forEach(t),ot.forEach(t),np=p(o),Bo=r(o,"H2",{class:!0});var ih=i(Bo);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),Ho=r(o,"DIV",{class:!0});var lh=i(Ho);k(ur.$$.fragment,lh),Ey=p(lh),Td=r(lh,"P",{});var ew=i(Td);Fy=s(ew,"Base class for outputs of sentence classification models."),ew.forEach(t),lh.forEach(t),ap=p(o),Zo=r(o,"H2",{class:!0});var dh=i(Zo);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 Ht=i(et);k(fr.$$.fragment,Ht),xy=p(Ht),Ro=r(Ht,"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(Ht),gr=r(Ht,"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),By=s(ch," inputs to outputs."),ch.forEach(t),Hy=p(Ht),Sn=r(Ht,"DIV",{class:!0});var ph=i(Sn);k(_r.$$.fragment,ph),Zy=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(Ht),Yt=r(Ht,"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(Ht),Kt=r(Ht,"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),Ht.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),Ed=r(hh,"SPAN",{});var hw=i(Ed);eb=s(hw,"FlaxGPT2Model"),hw.forEach(t),hh.forEach(t),lp=p(o),Be=r(o,"DIV",{class:!0});var Mt=i(Be);k(vr.$$.fragment,Mt),tb=p(Mt),Fd=r(Mt,"P",{});var uw=i(Fd);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);Er=r(ww,"A",{href:!0,rel:!0});var Mw=i(Er);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(Fr.$$.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),Eb=p(us),k(Qn.$$.fragment,us),Fb=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 Ew=i(Nd);k(jr.$$.fragment,Ew),Ew.forEach(t),Gw.forEach(t),jb=p(fh),qd=r(fh,"SPAN",{});var Fw=i(qd);zb=s(Fw,"FlaxGPT2LMHeadModel"),Fw.forEach(t),fh.forEach(t),cp=p(o),He=r(o,"DIV",{class:!0});var $t=i(He);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),Bb=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),Hb=p($t),Ad=r($t,"P",{});var Cw=i(Ad);Zb=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);Bd=r(ms,"LI",{});var Uw=i(Bd);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),Hd=r(ms,"LI",{});var Iw=i(Hd);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),Zd=r(ms,"LI",{});var qw=i(Zd);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 Bw=i(qr);Qb=s(Bw,"Parallelization"),Bw.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 Hw=i(Dd);t2=s(Hw,"FlaxGPT2PreTrainedModel"),Hw.forEach(t),o2=s(Oi," forward method, overrides the "),Vd=r(Oi,"CODE",{});var Zw=i(Vd);n2=s(Zw,"__call__"),Zw.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,F="https://img.shields.io/badge/All_model_pages-gpt2-blueviolet")||u(re,"src",F),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(Fs,"href","https://huggingface.co/blog/tf-xla-generate"),u(Fs,"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(Bs,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling-tf.ipynb"),u(Bs,"rel","nofollow"),u(Or,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.FlaxGPT2LMHeadModel"),u(Hs,"href","https://github.com/huggingface/transformers/tree/main/examples/flax/language-modeling#causal-language-modeling"),u(Hs,"rel","nofollow"),u(Zs,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/causal_language_modeling_flax.ipynb"),u(Zs,"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(Ea,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Ea,"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(Fo,"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(En,"id","transformers.TFGPT2Model"),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.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(Ei,"href","/docs/transformers/main/en/model_doc/gpt2#transformers.TFGPT2ForSequenceClassification"),u(Fi,"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(Bo,"class","relative group"),u(Ho,"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(Zo,"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(Er,"href","https://jax.readthedocs.io/en/latest/jax.html#parallelization-pmap"),u(Er,"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(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(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(He,"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,E),e(E,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,Ee),e(le,X),e(X,Fe),g(o,Me,_),g(o,B,_),e(B,je),e(B,ue),e(ue,me),e(B,x),e(B,C),e(C,ze),e(B,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,H),e(H,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,Zt),e(Zt,bh),e(Zt,Qi),e(Qi,vh),e(Zt,kh),e(Zt,Yi),e(Yi,wh),e(Zt,Mh),e(Zt,gs),e(gs,$h),e(Zt,Ph),g(o,kc,_),g(o,po,_),e(po,_s),e(_s,Gh),e(po,Eh),e(po,Ki),e(Ki,Fh),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,Z,_),e(Z,ks),e(ks,Wh),e(ks,ws),e(ws,Ah),e(ks,Bh),e(Z,Hh),e(Z,Ms),e(Ms,Zh),e(Ms,$s),e($s,Rh),e(Ms,Dh),e(Z,Vh),e(Z,Ps),e(Ps,Sh),e(Ps,Gs),e(Gs,Lh),e(Ps,Xh),e(Z,Oh),e(Z,Es),e(Es,Qh),e(Es,Fs),e(Fs,Yh),e(Es,Kh),e(Z,eu),e(Z,js),e(js,tu),e(js,zs),e(zs,ou),e(js,nu),e(Z,su),e(Z,xs),e(xs,au),e(xs,Cs),e(Cs,ru),e(xs,iu),e(Z,lu),e(Z,Us),e(Us,du),e(Us,Js),e(Js,cu),e(Us,pu),e(Z,hu),e(Z,Sr),e(Sr,Is),e(Is,uu),e(Sr,mu),e(Z,fu),e(Z,Ft),e(Ft,Lr),e(Lr,gu),e(Ft,_u),e(Ft,Ns),e(Ns,Tu),e(Ft,yu),e(Ft,qs),e(qs,bu),e(Ft,vu),e(Ft,Ws),e(Ws,ku),e(Ft,wu),e(Z,Mu),e(Z,Ot),e(Ot,Xr),e(Xr,$u),e(Ot,Pu),e(Ot,As),e(As,Gu),e(Ot,Eu),e(Ot,Bs),e(Bs,Fu),e(Ot,ju),e(Z,zu),e(Z,Qt),e(Qt,Or),e(Or,xu),e(Qt,Cu),e(Qt,Hs),e(Hs,Uu),e(Qt,Ju),e(Qt,Zs),e(Zs,Iu),e(Qt,Nu),e(Z,qu),e(Z,ol),e(ol,Qr),e(Qr,Wu),e(Z,Au),e(Z,nl),e(nl,Yr),e(Yr,Bu),e(Z,Hu),e(Z,sl),e(sl,Kr),e(Kr,Zu),g(o,Ec,_),g(o,uo,_),e(uo,Yo),e(Yo,al),w(Rs,al,null),e(uo,Ru),e(uo,rl),e(rl,Du),g(o,Fc,_),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,Em),e(ea,Fm),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,Bm),g(o,Uc,_),g(o,_o,_),e(_o,rn),e(rn,_l),w(na,_l,null),e(_o,Hm),e(_o,Tl),e(Tl,Zm),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,Ef),e(ft,zt),w(_a,zt,null),e(zt,Ff),e(zt,wo),e(wo,jf),e(wo,ci),e(ci,zf),e(wo,xf),e(wo,El),e(El,Cf),e(wo,Uf),e(zt,Jf),w(hn,zt,null),e(zt,If),w(un,zt,null),g(o,Bc,_),g(o,Mo,_),e(Mo,mn),e(mn,Fl),w(Ta,Fl,null),e(Mo,Nf),e(Mo,jl),e(jl,qf),g(o,Hc,_),g(o,gt,_),w(ya,gt,null),e(gt,Wf),e(gt,zl),e(zl,Af),e(gt,Bf),e(gt,ba),e(ba,Hf),e(ba,pi),e(pi,Zf),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,Zc,_),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,Ea),e(Ea,Tg),e(Ga,yg),e(_t,bg),e(_t,yt),w(Fa,yt,null),e(yt,vg),e(yt,Eo),e(Eo,kg),e(Eo,mi),e(mi,wg),e(Eo,Mg),e(Eo,Nl),e(Nl,$g),e(Eo,Pg),e(yt,Gg),w(Tn,yt,null),e(yt,Eg),w(yn,yt,null),e(yt,Fg),w(bn,yt,null),g(o,Dc,_),g(o,Fo,_),e(Fo,vn),e(vn,ql),w(ja,ql,null),e(Fo,jg),e(Fo,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,Bl),e(Bl,Wg),e(Gt,Ag),e(Gt,Hl),e(Hl,Bg),e(Gt,Hg),e(Gt,Zl),e(Zl,Zg),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(Ba,Ct,null),e(Ct,M_),e(Ct,xo),e(xo,$_),e(xo,bi),e(bi,P_),e(xo,G_),e(xo,Xl),e(Xl,E_),e(xo,F_),e(Ct,j_),w(Pn,Ct,null),e(Ct,z_),w(Gn,Ct,null),g(o,Xc,_),g(o,Co,_),e(Co,En),e(En,Ol),w(Ha,Ol,null),e(Co,x_),e(Co,Ql),e(Ql,C_),g(o,Oc,_),g(o,Qe,_),w(Za,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,B_),e(Da,Va),e(Va,H_),e(Da,Z_),e(Qe,R_),w(Fn,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,ET),e(or,FT),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,BT),e(It,HT),w(qn,It,null),e(It,ZT),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,Ei),e(Ei,XT),e(Gi,OT),e(ve,QT),e(ve,Et),e(Et,YT),e(Et,pd),e(pd,KT),e(Et,ey),e(Et,hd),e(hd,ty),e(Et,oy),e(Et,ud),e(ud,ny),e(Et,sy),e(Et,md),e(md,ay),e(Et,ry),e(ve,iy),e(ve,lr),e(lr,ly),e(lr,Fi),e(Fi,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(Bn,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(Hn,vt,null),e(vt,My),w(Zn,vt,null),e(vt,$y),w(Rn,vt,null),g(o,np,_),g(o,Bo,_),e(Bo,Dn),e(Dn,gd),w(hr,gd,null),e(Bo,Py),e(Bo,_d),e(_d,Gy),g(o,sp,_),g(o,Ho,_),w(ur,Ho,null),e(Ho,Ey),e(Ho,Td),e(Td,Fy),g(o,ap,_),g(o,Zo,_),e(Zo,Vn),e(Vn,yd),w(mr,yd,null),e(Zo,jy),e(Zo,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,By),e(et,Hy),e(et,Sn),w(_r,Sn,null),e(Sn,Zy),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,Ed),e(Ed,eb),g(o,lp,_),g(o,Be,_),w(vr,Be,null),e(Be,tb),e(Be,Fd),e(Fd,ob),e(Be,nb),e(Be,kr),e(kr,sb),e(kr,zi),e(zi,ab),e(kr,rb),e(Be,ib),e(Be,wr),e(wr,lb),e(wr,Mr),e(Mr,db),e(wr,cb),e(Be,pb),e(Be,jd),e(jd,hb),e(Be,ub),e(Be,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,Er),e(Er,bb),e(Be,vb),e(Be,Nt),w(Fr,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,Eb),w(Qn,Nt,null),e(Nt,Fb),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,He,_),w(zr,He,null),e(He,xb),e(He,Wd),e(Wd,Cb),e(He,Ub),e(He,xr),e(xr,Jb),e(xr,xi),e(xi,Ib),e(xr,Nb),e(He,qb),e(He,Cr),e(Cr,Wb),e(Cr,Ur),e(Ur,Ab),e(Cr,Bb),e(He,Hb),e(He,Ad),e(Ad,Zb),e(He,Rb),e(He,Vt),e(Vt,Bd),e(Bd,Jr),e(Jr,Db),e(Vt,Vb),e(Vt,Hd),e(Hd,Ir),e(Ir,Sb),e(Vt,Lb),e(Vt,Zd),e(Zd,Nr),e(Nr,Xb),e(Vt,Ob),e(Vt,Rd),e(Rd,qr),e(qr,Qb),e(He,Yb),e(He,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 Br={};_&2&&(Br.$$scope={dirty:_,ctx:o}),an.$set(Br);const Od={};_&2&&(Od.$$scope={dirty:_,ctx:o}),dn.$set(Od);const Qd={};_&2&&(Qd.$$scope={dirty:_,ctx:o}),cn.$set(Qd);const Hr={};_&2&&(Hr.$$scope={dirty:_,ctx:o}),hn.$set(Hr);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}),Fn.$set(ic);const Zr={};_&2&&(Zr.$$scope={dirty:_,ctx:o}),jn.$set(Zr);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}),Bn.$set(mc);const fc={};_&2&&(fc.$$scope={dirty:_,ctx:o}),Hn.$set(fc);const gc={};_&2&&(gc.$$scope={dirty:_,ctx:o}),Zn.$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(Fa.$$.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(Ba.$$.fragment,o),M(Pn.$$.fragment,o),M(Gn.$$.fragment,o),M(Ha.$$.fragment,o),M(Za.$$.fragment,o),M(Fn.$$.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(Bn.$$.fragment,o),M(pr.$$.fragment,o),M(Hn.$$.fragment,o),M(Zn.$$.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(Fr.$$.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),$(Fa.$$.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),$(Ba.$$.fragment,o),$(Pn.$$.fragment,o),$(Gn.$$.fragment,o),$(Ha.$$.fragment,o),$(Za.$$.fragment,o),$(Fn.$$.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),$(Bn.$$.fragment,o),$(pr.$$.fragment,o),$(Hn.$$.fragment,o),$(Zn.$$.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),$(Fr.$$.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(B),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(Z),o&&t(Ec),o&&t(uo),P(Rs),o&&t(Fc),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(Bc),o&&t(Mo),P(Ta),o&&t(Hc),o&&t(gt),P(ya),P(wa),P(fn),P(gn),o&&t(Zc),o&&t(Po),P(Ma),o&&t(Rc),o&&t(_t),P($a),P(Fa),P(Tn),P(yn),P(bn),o&&t(Dc),o&&t(Fo),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(Ba),P(Pn),P(Gn),o&&t(Xc),o&&t(Co),P(Ha),o&&t(Oc),o&&t(Qe),P(Za),P(Fn),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(Bn),P(pr),P(Hn),P(Zn),P(Rn),o&&t(np),o&&t(Bo),P(hr),o&&t(sp),o&&t(Ho),P(ur),o&&t(ap),o&&t(Zo),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(Be),P(vr),P(Fr),P(Qn),P(Yn),o&&t(dp),o&&t(So),P(jr),o&&t(cp),o&&t(He),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};
