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

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

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

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