import{S as Vk,i as Dk,s as Sk,e as a,k as c,w as v,t as n,M as Lk,c as r,d as t,m as p,a as l,x as w,h as s,b as u,N as Rk,G as e,g,y as k,q as M,o as $,B as P,v as Xk,L as Ve}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 De}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as ke}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Re}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";import{P as Ok}from"../../chunks/PipelineTag-hf-doc-builder.js";function Qk(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 Yk(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 Kk(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 e1(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 t1(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 o1(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 n1(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 s1(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 a1(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 r1(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 l1(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 i1(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 d1(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 c1(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 p1(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 h1(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 u1(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 m1(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 f1(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 g1(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,V,Ue,D,Je,de,I,Ie,q,W,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(),V=a("li"),Ue=n(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),D=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
`),q=a("a"),W=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),V=r(Z,"LI",{});var We=l(V);Ue=s(We,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),D=r(We,"CODE",{});var ht=l(D);Je=s(ht,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),ht.forEach(t),We.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
`),q=r(le,"A",{href:!0,rel:!0});var ut=l(q);W=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(q,"href","https://keras.io/guides/making_new_layers_and_models_via_subclassing/"),u(q,"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,V),e(V,Ue),e(V,D),e(D,Je),g(b,de,j),g(b,I,j),e(I,Ie),e(I,q),e(q,W),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 _1(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 T1(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 y1(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,V,Ue,D,Je,de,I,Ie,q,W,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(),V=a("li"),Ue=n(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),D=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
`),q=a("a"),W=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),V=r(Z,"LI",{});var We=l(V);Ue=s(We,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),D=r(We,"CODE",{});var ht=l(D);Je=s(ht,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),ht.forEach(t),We.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
`),q=r(le,"A",{href:!0,rel:!0});var ut=l(q);W=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(q,"href","https://keras.io/guides/making_new_layers_and_models_via_subclassing/"),u(q,"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,V),e(V,Ue),e(V,D),e(D,Je),g(b,de,j),g(b,I,j),e(I,Ie),e(I,q),e(q,W),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 b1(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 v1(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 w1(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,V,Ue,D,Je,de,I,Ie,q,W,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(),V=a("li"),Ue=n(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),D=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
`),q=a("a"),W=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),V=r(Z,"LI",{});var We=l(V);Ue=s(We,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),D=r(We,"CODE",{});var ht=l(D);Je=s(ht,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),ht.forEach(t),We.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
`),q=r(le,"A",{href:!0,rel:!0});var ut=l(q);W=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(q,"href","https://keras.io/guides/making_new_layers_and_models_via_subclassing/"),u(q,"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,V),e(V,Ue),e(V,D),e(D,Je),g(b,de,j),g(b,I,j),e(I,Ie),e(I,q),e(q,W),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 k1(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 M1(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 $1(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,V,Ue,D,Je,de,I,Ie,q,W,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(),V=a("li"),Ue=n(`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),D=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
`),q=a("a"),W=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),V=r(Z,"LI",{});var We=l(V);Ue=s(We,`a dictionary with one or several input Tensors associated to the input names given in the docstring:
`),D=r(We,"CODE",{});var ht=l(D);Je=s(ht,'model({"input_ids": input_ids, "token_type_ids": token_type_ids})'),ht.forEach(t),We.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
`),q=r(le,"A",{href:!0,rel:!0});var ut=l(q);W=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(q,"href","https://keras.io/guides/making_new_layers_and_models_via_subclassing/"),u(q,"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,V),e(V,Ue),e(V,D),e(D,Je),g(b,de,j),g(b,I,j),e(I,Ie),e(I,q),e(q,W),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 P1(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 G1(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 E1(G){let d,y;return d=new De({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){w(d.$$.fragment,f)},m(f,m){k(d,f,m),y=!0},p:Ve,i(f){y||(M(d.$$.fragment,f),y=!0)},o(f){$(d.$$.fragment,f),y=!1},d(f){P(d,f)}}}function F1(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 j1(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 z1(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 x1(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 C1(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 U1(G){let d,y,f,m,T;return m=new De({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),w(m.$$.fragment,i)},m(i,h){g(i,d,h),e(d,y),g(i,f,h),k(m,i,h),T=!0},p:Ve,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 J1(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,V,Ue,D,Je,de,I,Ie,q,W,Ne,b,j,nt,ce,st,at,z,rt,lt,Xe,it,dt,Z,se,ct,Le,ae,pt,Oe,We,ht,le,ut,Th,yh,Bt,bh,Ql,vh,wh,Yl,kh,Mh,gs,$h,Ph,wc,po,_s,Gh,Eh,Kl,Fh,jh,kc,Xt,zh,Ts,xh,Ch,ys,Uh,Jh,Mc,ho,Qo,ei,bs,Ih,ti,Nh,$c,Dr,Wh,Pc,vs,Gc,B,ws,qh,ks,Ah,Hh,Zh,Ms,Bh,$s,Rh,Vh,Dh,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,Ws,bu,vu,qs,wu,ku,Mu,Ot,Xr,$u,Pu,As,Gu,Eu,Hs,Fu,ju,zu,Qt,Or,xu,Cu,Zs,Uu,Ju,Bs,Iu,Nu,Wu,oi,Qr,qu,Au,ni,Yr,Hu,Zu,si,Kr,Bu,Ec,uo,Yo,ai,Rs,Ru,ri,Vu,Fc,Pt,Vs,Du,Rt,Su,el,Lu,Xu,tl,Ou,Qu,Ds,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,wm,km,al,Qs,xc,go,nn,hi,Ys,Mm,ui,$m,Cc,qe,Ks,Pm,ea,Gm,mi,Em,Fm,jm,fi,zm,xm,sn,Cm,ta,Um,gi,Jm,Im,Nm,an,Wm,oa,qm,rl,Am,Hm,Uc,_o,rn,_i,na,Zm,Ti,Bm,Jc,To,sa,Rm,yi,Vm,Ic,yo,aa,Dm,bi,Sm,Nc,bo,ln,vi,ra,Lm,wi,Xm,Wc,mt,la,Om,ki,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,qc,wo,pn,$i,ha,gf,Pi,_f,Ac,ft,ua,Tf,Gi,yf,bf,ma,vf,dl,wf,kf,Mf,fa,$f,ga,Pf,Gf,Ef,zt,_a,Ff,ko,jf,cl,zf,xf,Ei,Cf,Uf,Jf,hn,If,un,Hc,Mo,mn,Fi,Ta,Nf,ji,Wf,Zc,gt,ya,qf,zi,Af,Hf,ba,Zf,pl,Bf,Rf,Vf,va,Df,wa,Sf,Lf,Xf,xt,ka,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,wg,ml,kg,Mg,Ni,$g,Pg,Gg,Tn,Eg,yn,Fg,bn,Vc,Fo,vn,Wi,ja,jg,qi,zg,Dc,Ae,za,xg,Ai,Cg,Ug,fl,gl,Jg,Ig,Ng,Gt,Wg,Hi,qg,Ag,Zi,Hg,Zg,Bi,Bg,Rg,Ri,Vg,Dg,Sg,xa,Lg,_l,Xg,Og,Qg,Ca,Yg,Ua,Kg,e_,t_,bt,Ja,o_,jo,n_,Tl,s_,a_,Vi,r_,l_,i_,wn,d_,kn,c_,Mn,Sc,zo,$n,Di,Ia,p_,Si,h_,Lc,Tt,Na,u_,Li,m_,f_,Wa,g_,yl,__,T_,y_,qa,b_,Aa,v_,w_,k_,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,W_,q_,A_,Va,H_,Da,Z_,B_,R_,Fn,V_,Ut,Sa,D_,Uo,S_,wl,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,kl,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,wT,ad,kT,ep,Ke,tr,MT,rd,$T,PT,or,GT,$l,ET,FT,jT,nr,zT,sr,xT,CT,UT,Nn,JT,It,ar,IT,Wo,NT,Pl,WT,qT,ld,AT,HT,ZT,Wn,BT,qn,tp,qo,An,id,rr,RT,dd,VT,op,ve,lr,DT,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,wy,ky,Zn,My,Bn,$y,Rn,np,Ho,Vn,gd,hr,Py,_d,Gy,sp,Zo,ur,Ey,Td,Fy,ap,Bo,Dn,yd,mr,jy,bd,zy,rp,et,fr,xy,Ro,Cy,vd,Uy,Jy,wd,Iy,Ny,Wy,gr,qy,kd,Ay,Hy,Zy,Sn,_r,By,Md,Ry,Vy,Yt,Tr,Dy,$d,Sy,Ly,Ln,Xy,Kt,yr,Oy,Pd,Qy,Yy,Xn,lp,Vo,On,Gd,br,Ky,Ed,e2,ip,He,vr,t2,Fd,o2,n2,wr,s2,zl,a2,r2,l2,kr,i2,Mr,d2,c2,p2,jd,h2,u2,Vt,zd,$r,m2,f2,xd,Pr,g2,_2,Cd,Gr,T2,y2,Ud,Er,b2,v2,Nt,Fr,w2,Do,k2,Jd,M2,$2,Id,P2,G2,E2,Qn,F2,Yn,dp,So,Kn,Nd,jr,j2,Wd,z2,cp,Ze,zr,x2,qd,C2,U2,xr,J2,xl,I2,N2,W2,Cr,q2,Ur,A2,H2,Z2,Ad,B2,R2,Dt,Hd,Jr,V2,D2,Zd,Ir,S2,L2,Bd,Nr,X2,O2,Rd,Wr,Q2,Y2,Wt,qr,K2,Lo,eb,Vd,tb,ob,Dd,nb,sb,ab,es,rb,ts,pp;return i=new ke({}),he=new ke({}),bs=new ke({}),vs=new Ok({props:{pipeline:"text-generation"}}),Rs=new ke({}),Vs=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.31.0/en/model_doc/gpt2#transformers.GPT2Model">GPT2Model</a> or <a href="/docs/transformers/v4.31.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.31.0/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a> and
<a href="/docs/transformers/v4.31.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.31.0/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a> and
<a href="/docs/transformers/v4.31.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.31.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.31.0/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a> and
<a href="/docs/transformers/v4.31.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.31.0/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a> and
<a href="/docs/transformers/v4.31.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.31.0/src/transformers/models/gpt2/configuration_gpt2.py#L37"}}),Ko=new Re({props:{anchor:"transformers.GPT2Config.example",$$slots:{default:[Qk]},$$scope:{ctx:G}}}),Ss=new ke({}),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.31.0/src/transformers/models/gpt2/tokenization_gpt2.py#L104"}}),tn=new Re({props:{anchor:"transformers.GPT2Tokenizer.example",$$slots:{default:[Yk]},$$scope:{ctx:G}}}),on=new Be({props:{$$slots:{default:[Kk]},$$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.31.0/src/transformers/models/gpt2/tokenization_gpt2.py#L322"}}),Ys=new ke({}),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.31.0/src/transformers/models/gpt2/tokenization_gpt2_fast.py#L70"}}),sn=new Re({props:{anchor:"transformers.GPT2TokenizerFast.example",$$slots:{default:[e1]},$$scope:{ctx:G}}}),an=new Be({props:{$$slots:{default:[t1]},$$scope:{ctx:G}}}),na=new ke({}),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.31.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.31.0/src/transformers/models/gpt2/modeling_tf_gpt2.py#L526"}}),ra=new ke({}),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.31.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.31.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.31.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.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__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.31.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.31.0/src/transformers/models/gpt2/modeling_gpt2.py#L748",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.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.31.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:[o1]},$$scope:{ctx:G}}}),cn=new Re({props:{anchor:"transformers.GPT2Model.forward.example",$$slots:{default:[n1]},$$scope:{ctx:G}}}),ha=new ke({}),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.31.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.31.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.31.0/src/transformers/models/gpt2/modeling_gpt2.py#L956"}}),_a=new A({props:{name:"forward",anchor:"transformers.GPT2LMHeadModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_hidden_states",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.GPT2LMHeadModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past_key_values</code> is <code>None</code> else
<code>past_key_values[0][0].shape[-2]</code> (<code>sequence_length</code> of input past key value states). Indices of input
sequence tokens in the vocabulary.</p>
<p>If <code>past_key_values</code> is used, only <code>input_ids</code> that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__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.31.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.31.0/src/transformers/models/gpt2/modeling_gpt2.py#L1045",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.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.31.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:[s1]},$$scope:{ctx:G}}}),un=new Re({props:{anchor:"transformers.GPT2LMHeadModel.forward.example",$$slots:{default:[a1]},$$scope:{ctx:G}}}),Ta=new ke({}),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.31.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.31.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.31.0/src/transformers/models/gpt2/modeling_gpt2.py#L1148"}}),ka=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.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__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.31.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.31.0/src/transformers/models/gpt2/modeling_gpt2.py#L1233",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.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.31.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:[r1]},$$scope:{ctx:G}}}),gn=new Re({props:{anchor:"transformers.GPT2DoubleHeadsModel.forward.example",$$slots:{default:[l1]},$$scope:{ctx:G}}}),Ma=new ke({}),$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.31.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.31.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.31.0/src/transformers/models/gpt2/modeling_gpt2.py#L1597"}}),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.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__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.31.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.31.0/src/transformers/models/gpt2/modeling_gpt2.py#L1612",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.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.31.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:[i1]},$$scope:{ctx:G}}}),yn=new Be({props:{warning:!0,$$slots:{default:[d1]},$$scope:{ctx:G}}}),bn=new Re({props:{anchor:"transformers.GPT2ForQuestionAnswering.forward.example",$$slots:{default:[c1]},$$scope:{ctx:G}}}),ja=new ke({}),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.31.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.31.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.31.0/src/transformers/models/gpt2/modeling_gpt2.py#L1376"}}),Ja=new A({props:{name:"forward",anchor:"transformers.GPT2ForSequenceClassification.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.GPT2ForSequenceClassification.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code> if <code>past_key_values</code> is <code>None</code> else
<code>past_key_values[0][0].shape[-2]</code> (<code>sequence_length</code> of input past key value states). Indices of input
sequence tokens in the vocabulary.</p>
<p>If <code>past_key_values</code> is used, only <code>input_ids</code> that do not have their past calculated should be passed as
<code>input_ids</code>.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__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.31.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.31.0/src/transformers/models/gpt2/modeling_gpt2.py#L1390",returnDescription:`
<p>A <code>transformers.modeling_outputs.SequenceClassifierOutputWithPast</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.31.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>
`}}),wn=new Be({props:{$$slots:{default:[p1]},$$scope:{ctx:G}}}),kn=new Re({props:{anchor:"transformers.GPT2ForSequenceClassification.forward.example",$$slots:{default:[h1]},$$scope:{ctx:G}}}),Mn=new Re({props:{anchor:"transformers.GPT2ForSequenceClassification.forward.example-2",$$slots:{default:[u1]},$$scope:{ctx:G}}}),Ia=new ke({}),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.31.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.31.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.31.0/src/transformers/models/gpt2/modeling_gpt2.py#L1499"}}),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.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__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.31.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.31.0/src/transformers/models/gpt2/modeling_gpt2.py#L1521",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.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.31.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:[m1]},$$scope:{ctx:G}}}),Gn=new Re({props:{anchor:"transformers.GPT2ForTokenClassification.forward.example",$$slots:{default:[f1]},$$scope:{ctx:G}}}),Za=new ke({}),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.31.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.31.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.31.0/src/transformers/models/gpt2/modeling_tf_gpt2.py#L675"}}),Fn=new Be({props:{$$slots:{default:[g1]},$$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.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/v4.31.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.31.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.31.0/src/transformers/models/gpt2/modeling_tf_gpt2.py#L680",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.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.31.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:[_1]},$$scope:{ctx:G}}}),zn=new Re({props:{anchor:"transformers.TFGPT2Model.call.example",$$slots:{default:[T1]},$$scope:{ctx:G}}}),La=new ke({}),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.31.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.31.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.31.0/src/transformers/models/gpt2/modeling_tf_gpt2.py#L752"}}),Cn=new Be({props:{$$slots:{default:[y1]},$$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.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/v4.31.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.31.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.31.0/src/transformers/models/gpt2/modeling_tf_gpt2.py#L788",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.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.31.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:[b1]},$$scope:{ctx:G}}}),Jn=new Re({props:{anchor:"transformers.TFGPT2LMHeadModel.call.example",$$slots:{default:[v1]},$$scope:{ctx:G}}}),er=new ke({}),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.31.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.31.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.31.0/src/transformers/models/gpt2/modeling_tf_gpt2.py#L886"}}),Nn=new Be({props:{$$slots:{default:[w1]},$$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.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/v4.31.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.31.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.31.0/src/transformers/models/gpt2/modeling_tf_gpt2.py#L895",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.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.31.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>
`}}),Wn=new Be({props:{$$slots:{default:[k1]},$$scope:{ctx:G}}}),qn=new Re({props:{anchor:"transformers.TFGPT2DoubleHeadsModel.call.example",$$slots:{default:[M1]},$$scope:{ctx:G}}}),rr=new ke({}),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.31.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.31.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.31.0/src/transformers/models/gpt2/modeling_tf_gpt2.py#L1021"}}),Hn=new Be({props:{$$slots:{default:[$1]},$$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.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and
<a href="/docs/transformers/v4.31.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.31.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.31.0/src/transformers/models/gpt2/modeling_tf_gpt2.py#L1033",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.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.31.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:[P1]},$$scope:{ctx:G}}}),Bn=new Re({props:{anchor:"transformers.TFGPT2ForSequenceClassification.call.example",$$slots:{default:[G1]},$$scope:{ctx:G}}}),Rn=new Re({props:{anchor:"transformers.TFGPT2ForSequenceClassification.call.example-2",$$slots:{default:[E1]},$$scope:{ctx:G}}}),hr=new ke({}),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.31.0/src/transformers/modeling_tf_outputs.py#L901"}}),mr=new ke({}),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.31.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.31.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.31.0/src/transformers/models/gpt2/tokenization_gpt2_tf.py#L55"}}),Ln=new Re({props:{anchor:"transformers.TFGPT2Tokenizer.from_pretrained.example",$$slots:{default:[F1]},$$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.31.0/src/transformers/models/gpt2/tokenization_gpt2_tf.py#L35"}}),Xn=new Re({props:{anchor:"transformers.TFGPT2Tokenizer.from_tokenizer.example",$$slots:{default:[j1]},$$scope:{ctx:G}}}),br=new ke({}),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.31.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.31.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.31.0/en/main_classes/model#transformers.FlaxPreTrainedModel.to_fp16">to_fp16()</a> and
<a href="/docs/transformers/v4.31.0/en/main_classes/model#transformers.FlaxPreTrainedModel.to_bf16">to_bf16()</a>.`,name:"dtype"}],source:"https://github.com/huggingface/transformers/blob/v4.31.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.Array] = None"},{name:"encoder_attention_mask",val:": typing.Optional[jax.Array] = None"},{name:"params",val:": dict = None"},{name:"past_key_values",val:": dict = None"},{name:"dropout_rng",val:": PRNGKey = None"},{name:"train",val:": bool = False"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.FlaxGPT2Model.__call__.input_ids",description:`<strong>input_ids</strong> (<code>numpy.ndarray</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code>. Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__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.31.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.31.0/src/transformers/models/gpt2/modeling_flax_gpt2.py#L456",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.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.31.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:[z1]},$$scope:{ctx:G}}}),Yn=new Re({props:{anchor:"transformers.FlaxGPT2Model.__call__.example",$$slots:{default:[x1]},$$scope:{ctx:G}}}),jr=new ke({}),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.31.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.31.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.31.0/en/main_classes/model#transformers.FlaxPreTrainedModel.to_fp16">to_fp16()</a> and
<a href="/docs/transformers/v4.31.0/en/main_classes/model#transformers.FlaxPreTrainedModel.to_bf16">to_bf16()</a>.`,name:"dtype"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/gpt2/modeling_flax_gpt2.py#L742"}}),qr=new A({props:{name:"__call__",anchor:"transformers.FlaxGPT2LMHeadModel.__call__",parameters:[{name:"input_ids",val:""},{name:"attention_mask",val:" = None"},{name:"position_ids",val:" = None"},{name:"encoder_hidden_states",val:": typing.Optional[jax.Array] = None"},{name:"encoder_attention_mask",val:": typing.Optional[jax.Array] = None"},{name:"params",val:": dict = None"},{name:"past_key_values",val:": dict = None"},{name:"dropout_rng",val:": PRNGKey = None"},{name:"train",val:": bool = False"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.FlaxGPT2LMHeadModel.__call__.input_ids",description:`<strong>input_ids</strong> (<code>numpy.ndarray</code> of shape <code>(batch_size, input_ids_length)</code>) &#x2014;
<code>input_ids_length</code> = <code>sequence_length</code>. Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/v4.31.0/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.31.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.31.0/en/model_doc/wav2vec2#transformers.Wav2Vec2CTCTokenizer.__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.31.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.31.0/src/transformers/models/gpt2/modeling_flax_gpt2.py#L456",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.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.31.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:[C1]},$$scope:{ctx:G}}}),ts=new Re({props:{anchor:"transformers.FlaxGPT2LMHeadModel.__call__.example",$$slots:{default:[U1]},$$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"),V=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(),D=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."),q=c(),W=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"),We=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"),wh=n(" and "),Yl=a("em"),kh=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)."),wc=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("."),kc=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(),Dr=a("p"),Wh=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"),ws=a("li"),qh=n("A blog on how to "),ks=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"),Vh=n(" with GPT-2."),Dh=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(", "),Ws=a("a"),bu=n("text generation example script"),vu=n(", and "),qs=a("a"),wu=n("notebook"),ku=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("."),Wu=c(),oi=a("li"),Qr=a("a"),qu=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"),Vu=n("GPT2Config"),Fc=c(),Pt=a("div"),v(Vs.$$.fragment),Du=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
`),Ds=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"),wm=n(` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),km=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(),qe=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),Wm=c(),oa=a("p"),qm=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"),Vm=n("Base class for outputs of models predicting if two sentences are consecutive or not."),Ic=c(),yo=a("div"),v(aa.$$.fragment),Dm=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(),wi=a("span"),Xm=n("GPT2Model"),Wc=c(),mt=a("div"),v(la.$$.fragment),Om=c(),ki=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),qc=c(),wo=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"),wf=n("PreTrainedModel"),kf=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(),ko=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"),Wf=n("GPT2DoubleHeadsModel"),Zc=c(),gt=a("div"),v(ya.$$.fragment),qf=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.)`),Vf=c(),va=a("p"),Df=n("This model is also a PyTorch "),wa=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(ka.$$.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"),wg=n("The "),ml=a("a"),kg=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),Vc=c(),Fo=a("h2"),vn=a("a"),Wi=a("span"),v(ja.$$.fragment),jg=c(),qi=a("span"),zg=n("GPT2ForSequenceClassification"),Dc=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"),Wg=n(`Since it does classification on the last token, it requires to know the position of the last token. If a
`),Hi=a("code"),qg=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"),Vg=n("input_ids"),Dg=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 "),Vi=a("code"),r_=n("__call__"),l_=n(" special method."),i_=c(),v(wn.$$.fragment),d_=c(),v(kn.$$.fragment),c_=c(),v(Mn.$$.fragment),Sc=c(),zo=a("h2"),$n=a("a"),Di=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(),Wa=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(),qa=a("p"),b_=n("This model is also a PyTorch "),Aa=a("a"),v_=n("torch.nn.Module"),w_=n(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),k_=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"),W_=n("TFPreTrainedModel"),q_=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(),Va=a("p"),H_=n("This model is also a "),Da=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),V_=c(),Ut=a("div"),v(Sa.$$.fragment),D_=c(),Uo=a("p"),S_=n("The "),wl=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 "),kl=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),wT=c(),ad=a("span"),kT=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(),Wo=a("p"),NT=n("The "),Pl=a("a"),WT=n("TFGPT2DoubleHeadsModel"),qT=n(" forward method, overrides the "),ld=a("code"),AT=n("__call__"),HT=n(" special method."),ZT=c(),v(Wn.$$.fragment),BT=c(),v(qn.$$.fragment),tp=c(),qo=a("h2"),An=a("a"),id=a("span"),v(rr.$$.fragment),RT=c(),dd=a("span"),VT=n("TFGPT2ForSequenceClassification"),op=c(),ve=a("div"),v(lr.$$.fragment),DT=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__"),wy=n(" special method."),ky=c(),v(Zn.$$.fragment),My=c(),v(Bn.$$.fragment),$y=c(),v(Rn.$$.fragment),np=c(),Ho=a("h2"),Vn=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"),Dn=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 "),wd=a("code"),Iy=n("from_tokenizer()"),Ny=n(` method, which imports settings
from an existing standard tokenizer object.`),Wy=c(),gr=a("p"),qy=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 `),kd=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"),Vy=c(),Yt=a("div"),v(Tr.$$.fragment),Dy=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(),Vo=a("h2"),On=a("a"),Gd=a("span"),v(br.$$.fragment),Ky=c(),Ed=a("span"),e2=n("FlaxGPT2Model"),ip=c(),He=a("div"),v(vr.$$.fragment),t2=c(),Fd=a("p"),o2=n("The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top."),n2=c(),wr=a("p"),s2=n("This model inherits from "),zl=a("a"),a2=n("FlaxPreTrainedModel"),r2=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.)`),l2=c(),kr=a("p"),i2=n(`This model is also a Flax Linen
`),Mr=a("a"),d2=n("flax.nn.Module"),c2=n(` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),p2=c(),jd=a("p"),h2=n("Finally, this model supports inherent JAX features such as:"),u2=c(),Vt=a("ul"),zd=a("li"),$r=a("a"),m2=n("Just-In-Time (JIT) compilation"),f2=c(),xd=a("li"),Pr=a("a"),g2=n("Automatic Differentiation"),_2=c(),Cd=a("li"),Gr=a("a"),T2=n("Vectorization"),y2=c(),Ud=a("li"),Er=a("a"),b2=n("Parallelization"),v2=c(),Nt=a("div"),v(Fr.$$.fragment),w2=c(),Do=a("p"),k2=n("The "),Jd=a("code"),M2=n("FlaxGPT2PreTrainedModel"),$2=n(" forward method, overrides the "),Id=a("code"),P2=n("__call__"),G2=n(" special method."),E2=c(),v(Qn.$$.fragment),F2=c(),v(Yn.$$.fragment),dp=c(),So=a("h2"),Kn=a("a"),Nd=a("span"),v(jr.$$.fragment),j2=c(),Wd=a("span"),z2=n("FlaxGPT2LMHeadModel"),cp=c(),Ze=a("div"),v(zr.$$.fragment),x2=c(),qd=a("p"),C2=n(`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input
embeddings).`),U2=c(),xr=a("p"),J2=n("This model inherits from "),xl=a("a"),I2=n("FlaxPreTrainedModel"),N2=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.)`),W2=c(),Cr=a("p"),q2=n(`This model is also a Flax Linen
`),Ur=a("a"),A2=n("flax.nn.Module"),H2=n(` subclass. Use it as a
regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`),Z2=c(),Ad=a("p"),B2=n("Finally, this model supports inherent JAX features such as:"),R2=c(),Dt=a("ul"),Hd=a("li"),Jr=a("a"),V2=n("Just-In-Time (JIT) compilation"),D2=c(),Zd=a("li"),Ir=a("a"),S2=n("Automatic Differentiation"),L2=c(),Bd=a("li"),Nr=a("a"),X2=n("Vectorization"),O2=c(),Rd=a("li"),Wr=a("a"),Q2=n("Parallelization"),Y2=c(),Wt=a("div"),v(qr.$$.fragment),K2=c(),Lo=a("p"),eb=n("The "),Vd=a("code"),tb=n("FlaxGPT2PreTrainedModel"),ob=n(" forward method, overrides the "),Dd=a("code"),nb=n("__call__"),sb=n(" special method."),ab=c(),v(es.$$.fragment),rb=c(),v(ts.$$.fragment),this.h()},l(o){const _=Lk('[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);w(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);w(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);V=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),D=r(St,"LI",{});var Br=l(D);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),q=p(St),W=r(St,"LI",{});var we=l(W);Ne=s(we,"The model can take the "),b=r(we,"EM",{});var dc=l(b);j=s(dc,"past_key_values"),dc.forEach(t),nt=s(we," (for PyTorch) or "),ce=r(we,"EM",{});var cc=l(ce);st=s(cc,"past"),cc.forEach(t),at=s(we,` (for TF) as input, which is the previously computed
key/value attention pairs. Using this (`),z=r(we,"EM",{});var pc=l(z);rt=s(pc,"past_key_values"),pc.forEach(t),lt=s(we," or "),Xe=r(we,"EM",{});var hc=l(Xe);it=s(hc,"past"),hc.forEach(t),dt=s(we,`) value prevents the model from re-computing
pre-computed values in the context of text generation. For PyTorch, see `),Z=r(we,"EM",{});var uc=l(Z);se=s(uc,"past_key_values"),uc.forEach(t),ct=s(we,` argument of the
`),Le=r(we,"A",{href:!0});var mc=l(Le);ae=s(mc,"GPT2Model.forward()"),mc.forEach(t),pt=s(we," method, or for TF the "),Oe=r(we,"EM",{});var fc=l(Oe);We=s(fc,"past"),fc.forEach(t),ht=s(we,` argument of the
`),le=r(we,"A",{href:!0});var gc=l(le);ut=s(gc,"TFGPT2Model.call()"),gc.forEach(t),Th=s(we," method for more information on its usage."),we.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),wh=s(Lt," and "),Yl=r(Lt,"EM",{});var Tc=l(Yl);kh=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),wc=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),kc=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 cb=l(Ts);xh=s(cb,"thomwolf"),cb.forEach(t),Ch=s(Cl,". The original code can be found "),ys=r(Cl,"A",{href:!0,rel:!0});var pb=l(ys);Uh=s(pb,"here"),pb.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 hb=l(Qo);ei=r(hb,"SPAN",{});var ub=l(ei);w(bs.$$.fragment,ub),ub.forEach(t),hb.forEach(t),Ih=p(hp),ti=r(hp,"SPAN",{});var mb=l(ti);Nh=s(mb,"Resources"),mb.forEach(t),hp.forEach(t),$c=p(o),Dr=r(o,"P",{});var fb=l(Dr);Wh=s(fb,"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."),fb.forEach(t),Pc=p(o),w(vs.$$.fragment,o),Gc=p(o),B=r(o,"UL",{});var te=l(B);ws=r(te,"LI",{});var up=l(ws);qh=s(up,"A blog on how to "),ks=r(up,"A",{href:!0,rel:!0});var gb=l(ks);Ah=s(gb,"Finetune a non-English GPT-2 Model with Hugging Face"),gb.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 _b=l($s);Rh=s(_b,"How to generate text: using different decoding methods for language generation with Transformers"),_b.forEach(t),Vh=s(mp," with GPT-2."),mp.forEach(t),Dh=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 Tb=l(Gs);Lh=s(Tb,"Training CodeParrot \u{1F99C} from Scratch"),Tb.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 yb=l(Fs);Yh=s(yb,"Faster Text Generation with TensorFlow and XLA"),yb.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 bb=l(zs);ou=s(bb,"How to train a Language Model with Megatron-LM"),bb.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 vb=l(Cs);ru=s(vb,"finetune GPT2 to generate lyrics in the style of your favorite artist"),vb.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 wb=l(Js);cu=s(wb,"finetune GPT2 to generate tweets in the style of your favorite Twitter user"),wb.forEach(t),pu=s(yp,". \u{1F30E}"),yp.forEach(t),hu=p(te),Sr=r(te,"LI",{});var lb=l(Sr);Is=r(lb,"A",{href:!0,rel:!0});var kb=l(Is);uu=s(kb,"Causal language modeling"),kb.forEach(t),mu=s(lb," chapter of the \u{1F917} Hugging Face Course."),lb.forEach(t),fu=p(te),Ft=r(te,"LI",{});var Oo=l(Ft);Lr=r(Oo,"A",{href:!0});var Mb=l(Lr);gu=s(Mb,"GPT2LMHeadModel"),Mb.forEach(t),_u=s(Oo," is supported by this "),Ns=r(Oo,"A",{href:!0,rel:!0});var $b=l(Ns);Tu=s($b,"causal language modeling example script"),$b.forEach(t),yu=s(Oo,", "),Ws=r(Oo,"A",{href:!0,rel:!0});var Pb=l(Ws);bu=s(Pb,"text generation example script"),Pb.forEach(t),vu=s(Oo,", and "),qs=r(Oo,"A",{href:!0,rel:!0});var Gb=l(qs);wu=s(Gb,"notebook"),Gb.forEach(t),ku=s(Oo,"."),Oo.forEach(t),Mu=p(te),Ot=r(te,"LI",{});var Rr=l(Ot);Xr=r(Rr,"A",{href:!0});var Eb=l(Xr);$u=s(Eb,"TFGPT2LMHeadModel"),Eb.forEach(t),Pu=s(Rr," is supported by this "),As=r(Rr,"A",{href:!0,rel:!0});var Fb=l(As);Gu=s(Fb,"causal language modeling example script"),Fb.forEach(t),Eu=s(Rr," and "),Hs=r(Rr,"A",{href:!0,rel:!0});var jb=l(Hs);Fu=s(jb,"notebook"),jb.forEach(t),ju=s(Rr,"."),Rr.forEach(t),zu=p(te),Qt=r(te,"LI",{});var Vr=l(Qt);Or=r(Vr,"A",{href:!0});var zb=l(Or);xu=s(zb,"FlaxGPT2LMHeadModel"),zb.forEach(t),Cu=s(Vr," is supported by this "),Zs=r(Vr,"A",{href:!0,rel:!0});var xb=l(Zs);Uu=s(xb,"causal language modeling example script"),xb.forEach(t),Ju=s(Vr," and "),Bs=r(Vr,"A",{href:!0,rel:!0});var Cb=l(Bs);Iu=s(Cb,"notebook"),Cb.forEach(t),Nu=s(Vr,"."),Vr.forEach(t),Wu=p(te),oi=r(te,"LI",{});var Ub=l(oi);Qr=r(Ub,"A",{href:!0});var Jb=l(Qr);qu=s(Jb,"Text classification task guide"),Jb.forEach(t),Ub.forEach(t),Au=p(te),ni=r(te,"LI",{});var Ib=l(ni);Yr=r(Ib,"A",{href:!0});var Nb=l(Yr);Hu=s(Nb,"Token classification task guide"),Nb.forEach(t),Ib.forEach(t),Zu=p(te),si=r(te,"LI",{});var Wb=l(si);Kr=r(Wb,"A",{href:!0});var qb=l(Kr);Bu=s(qb,"Causal language modeling task guide"),qb.forEach(t),Wb.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 Ab=l(Yo);ai=r(Ab,"SPAN",{});var Hb=l(ai);w(Rs.$$.fragment,Hb),Hb.forEach(t),Ab.forEach(t),Ru=p(bp),ri=r(bp,"SPAN",{});var Zb=l(ri);Vu=s(Zb,"GPT2Config"),Zb.forEach(t),bp.forEach(t),Fc=p(o),Pt=r(o,"DIV",{class:!0});var ns=l(Pt);w(Vs.$$.fragment,ns),Du=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 Bb=l(el);Lu=s(Bb,"GPT2Model"),Bb.forEach(t),Xu=s(ss," or a "),tl=r(ss,"A",{href:!0});var Rb=l(tl);Ou=s(Rb,"TFGPT2Model"),Rb.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
`),Ds=r(ss,"A",{href:!0,rel:!0});var Vb=l(Ds);Yu=s(Vb,"gpt2"),Vb.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 Db=l(ol);om=s(Db,"PretrainedConfig"),Db.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 Sb=l(nl);sm=s(Sb,"PretrainedConfig"),Sb.forEach(t),am=s(Ul," for more information."),Ul.forEach(t),rm=p(ns),w(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 Lb=l(en);li=r(Lb,"SPAN",{});var Xb=l(li);w(Ss.$$.fragment,Xb),Xb.forEach(t),Lb.forEach(t),lm=p(vp),ii=r(vp,"SPAN",{});var Ob=l(ii);im=s(Ob,"GPT2Tokenizer"),Ob.forEach(t),vp.forEach(t),zc=p(o),be=r(o,"DIV",{class:!0});var tt=l(be);w(Ls.$$.fragment,tt),dm=p(tt),di=r(tt,"P",{});var Qb=l(di);cm=s(Qb,"Construct a GPT-2 tokenizer. Based on byte-level Byte-Pair-Encoding."),Qb.forEach(t),pm=p(tt),ci=r(tt,"P",{});var Yb=l(ci);hm=s(Yb,"This tokenizer has been trained to treat spaces like parts of the tokens (a bit like sentencepiece) so a word will"),Yb.forEach(t),um=p(tt),w(tn.$$.fragment,tt),mm=p(tt),Xs=r(tt,"P",{});var wp=l(Xs);fm=s(wp,"You can get around that behavior by passing "),pi=r(wp,"CODE",{});var Kb=l(pi);gm=s(Kb,"add_prefix_space=True"),Kb.forEach(t),_m=s(wp,` 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.`),wp.forEach(t),Tm=p(tt),w(on.$$.fragment,tt),ym=p(tt),Os=r(tt,"P",{});var kp=l(Os);bm=s(kp,"This tokenizer inherits from "),sl=r(kp,"A",{href:!0});var ev=l(sl);vm=s(ev,"PreTrainedTokenizer"),ev.forEach(t),wm=s(kp,` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),kp.forEach(t),km=p(tt),al=r(tt,"DIV",{class:!0});var tv=l(al);w(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);w(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),qe=r(o,"DIV",{class:!0});var wt=l(qe);w(Ks.$$.fragment,wt),Pm=p(wt),ea=r(wt,"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(wt),fi=r(wt,"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(wt),w(sn.$$.fragment,wt),Cm=p(wt),ta=r(wt,"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(wt),w(an.$$.fragment,wt),Wm=p(wt),oa=r(wt,"P",{});var Gp=l(oa);qm=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),wt.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);w(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);w(sa.$$.fragment,Fp),Rm=p(Fp),yi=r(Fp,"P",{});var hv=l(yi);Vm=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);w(aa.$$.fragment,jp),Dm=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);w(ra.$$.fragment,fv),fv.forEach(t),mv.forEach(t),Lm=p(zp),wi=r(zp,"SPAN",{});var gv=l(wi);Xm=s(gv,"GPT2Model"),gv.forEach(t),zp.forEach(t),Wc=p(o),mt=r(o,"DIV",{class:!0});var eo=l(mt);w(la.$$.fragment,eo),Om=p(eo),ki=r(eo,"P",{});var _v=l(ki);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);w(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),w(dn.$$.fragment,as),ff=p(as),w(cn.$$.fragment,as),as.forEach(t),eo.forEach(t),qc=p(o),wo=r(o,"H2",{class:!0});var Up=l(wo);pn=r(Up,"A",{id:!0,class:!0,href:!0});var wv=l(pn);$i=r(wv,"SPAN",{});var kv=l($i);w(ha.$$.fragment,kv),kv.forEach(t),wv.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);w(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);wf=s(Pv,"PreTrainedModel"),Pv.forEach(t),kf=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);w(_a.$$.fragment,rs),Ff=p(rs),ko=r(rs,"P",{});var Il=l(ko);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),w(hn.$$.fragment,rs),If=p(rs),w(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);w(Ta.$$.fragment,zv),zv.forEach(t),jv.forEach(t),Nf=p(Np),ji=r(Np,"SPAN",{});var xv=l(ji);Wf=s(xv,"GPT2DoubleHeadsModel"),xv.forEach(t),Np.forEach(t),Zc=p(o),gt=r(o,"DIV",{class:!0});var oo=l(gt);w(ya.$$.fragment,oo),qf=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 Wp=l(ba);Zf=s(Wp,"This model inherits from "),pl=r(Wp,"A",{href:!0});var Uv=l(pl);Bf=s(Uv,"PreTrainedModel"),Uv.forEach(t),Rf=s(Wp,`. 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.)`),Wp.forEach(t),Vf=p(oo),va=r(oo,"P",{});var qp=l(va);Df=s(qp,"This model is also a PyTorch "),wa=r(qp,"A",{href:!0,rel:!0});var Jv=l(wa);Sf=s(Jv,"torch.nn.Module"),Jv.forEach(t),Lf=s(qp,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),qp.forEach(t),Xf=p(oo),xt=r(oo,"DIV",{class:!0});var ls=l(xt);w(ka.$$.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),w(fn.$$.fragment,ls),ng=p(ls),w(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 Wv=l(_n);Ci=r(Wv,"SPAN",{});var qv=l(Ci);w(Ma.$$.fragment,qv),qv.forEach(t),Wv.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);w($a.$$.fragment,no),rg=p(no),Go=r(no,"P",{});var Wl=l(Go);lg=s(Wl,`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(Wl,"CODE",{});var Hv=l(Ji);ig=s(Hv,"span start logits"),Hv.forEach(t),dg=s(Wl," and "),Ii=r(Wl,"CODE",{});var Zv=l(Ii);cg=s(Zv,"span end logits"),Zv.forEach(t),pg=s(Wl,")."),Wl.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);w(Fa.$$.fragment,so),vg=p(so),Eo=r(so,"P",{});var ql=l(Eo);wg=s(ql,"The "),ml=r(ql,"A",{href:!0});var Vv=l(ml);kg=s(Vv,"GPT2ForQuestionAnswering"),Vv.forEach(t),Mg=s(ql," forward method, overrides the "),Ni=r(ql,"CODE",{});var Dv=l(Ni);$g=s(Dv,"__call__"),Dv.forEach(t),Pg=s(ql," special method."),ql.forEach(t),Gg=p(so),w(Tn.$$.fragment,so),Eg=p(so),w(yn.$$.fragment,so),Fg=p(so),w(bn.$$.fragment,so),so.forEach(t),no.forEach(t),Vc=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);Wi=r(Sv,"SPAN",{});var Lv=l(Wi);w(ja.$$.fragment,Lv),Lv.forEach(t),Sv.forEach(t),jg=p(Bp),qi=r(Bp,"SPAN",{});var Xv=l(qi);zg=s(Xv,"GPT2ForSequenceClassification"),Xv.forEach(t),Bp.forEach(t),Dc=p(o),Ae=r(o,"DIV",{class:!0});var kt=l(Ae);w(za.$$.fragment,kt),xg=p(kt),Ai=r(kt,"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(kt),fl=r(kt,"P",{});var ib=l(fl);gl=r(ib,"A",{href:!0});var Qv=l(gl);Jg=s(Qv,"GPT2ForSequenceClassification"),Qv.forEach(t),Ig=s(ib,` uses the last token in order to do the classification, as other causal models
(e.g. GPT-1) do.`),ib.forEach(t),Ng=p(kt),Gt=r(kt,"P",{});var ao=l(Gt);Wg=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);qg=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 ew=l(Bi);Bg=s(ew,"inputs_embeds"),ew.forEach(t),Rg=s(ao," are passed instead of "),Ri=r(ao,"CODE",{});var tw=l(Ri);Vg=s(tw,"input_ids"),tw.forEach(t),Dg=s(ao,`, it does the same (take the last value in
each row of the batch).`),ao.forEach(t),Sg=p(kt),xa=r(kt,"P",{});var Rp=l(xa);Lg=s(Rp,"This model inherits from "),_l=r(Rp,"A",{href:!0});var ow=l(_l);Xg=s(ow,"PreTrainedModel"),ow.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(kt),Ca=r(kt,"P",{});var Vp=l(Ca);Yg=s(Vp,"This model is also a PyTorch "),Ua=r(Vp,"A",{href:!0,rel:!0});var nw=l(Ua);Kg=s(nw,"torch.nn.Module"),nw.forEach(t),e_=s(Vp,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Vp.forEach(t),t_=p(kt),bt=r(kt,"DIV",{class:!0});var ro=l(bt);w(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 sw=l(Tl);s_=s(sw,"GPT2ForSequenceClassification"),sw.forEach(t),a_=s(Al," forward method, overrides the "),Vi=r(Al,"CODE",{});var aw=l(Vi);r_=s(aw,"__call__"),aw.forEach(t),l_=s(Al," special method."),Al.forEach(t),i_=p(ro),w(wn.$$.fragment,ro),d_=p(ro),w(kn.$$.fragment,ro),c_=p(ro),w(Mn.$$.fragment,ro),ro.forEach(t),kt.forEach(t),Sc=p(o),zo=r(o,"H2",{class:!0});var Dp=l(zo);$n=r(Dp,"A",{id:!0,class:!0,href:!0});var rw=l($n);Di=r(rw,"SPAN",{});var lw=l(Di);w(Ia.$$.fragment,lw),lw.forEach(t),rw.forEach(t),p_=p(Dp),Si=r(Dp,"SPAN",{});var iw=l(Si);h_=s(iw,"GPT2ForTokenClassification"),iw.forEach(t),Dp.forEach(t),Lc=p(o),Tt=r(o,"DIV",{class:!0});var lo=l(Tt);w(Na.$$.fragment,lo),u_=p(lo),Li=r(lo,"P",{});var dw=l(Li);m_=s(dw,`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.`),dw.forEach(t),f_=p(lo),Wa=r(lo,"P",{});var Sp=l(Wa);g_=s(Sp,"This model inherits from "),yl=r(Sp,"A",{href:!0});var cw=l(yl);__=s(cw,"PreTrainedModel"),cw.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),qa=r(lo,"P",{});var Lp=l(qa);b_=s(Lp,"This model is also a PyTorch "),Aa=r(Lp,"A",{href:!0,rel:!0});var pw=l(Aa);v_=s(pw,"torch.nn.Module"),pw.forEach(t),w_=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),k_=p(lo),Ct=r(lo,"DIV",{class:!0});var is=l(Ct);w(Ha.$$.fragment,is),M_=p(is),xo=r(is,"P",{});var Hl=l(xo);$_=s(Hl,"The "),bl=r(Hl,"A",{href:!0});var hw=l(bl);P_=s(hw,"GPT2ForTokenClassification"),hw.forEach(t),G_=s(Hl," forward method, overrides the "),Xi=r(Hl,"CODE",{});var uw=l(Xi);E_=s(uw,"__call__"),uw.forEach(t),F_=s(Hl," special method."),Hl.forEach(t),j_=p(is),w(Pn.$$.fragment,is),z_=p(is),w(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 mw=l(En);Oi=r(mw,"SPAN",{});var fw=l(Oi);w(Za.$$.fragment,fw),fw.forEach(t),mw.forEach(t),x_=p(Xp),Qi=r(Xp,"SPAN",{});var gw=l(Qi);C_=s(gw,"TFGPT2Model"),gw.forEach(t),Xp.forEach(t),Oc=p(o),Qe=r(o,"DIV",{class:!0});var qt=l(Qe);w(Ba.$$.fragment,qt),U_=p(qt),Yi=r(qt,"P",{});var _w=l(Yi);J_=s(_w,"The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top."),_w.forEach(t),I_=p(qt),Ra=r(qt,"P",{});var Op=l(Ra);N_=s(Op,"This model inherits from "),vl=r(Op,"A",{href:!0});var Tw=l(vl);W_=s(Tw,"TFPreTrainedModel"),Tw.forEach(t),q_=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(qt),Va=r(qt,"P",{});var Qp=l(Va);H_=s(Qp,"This model is also a "),Da=r(Qp,"A",{href:!0,rel:!0});var yw=l(Da);Z_=s(yw,"tf.keras.Model"),yw.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(qt),w(Fn.$$.fragment,qt),V_=p(qt),Ut=r(qt,"DIV",{class:!0});var ds=l(Ut);w(Sa.$$.fragment,ds),D_=p(ds),Uo=r(ds,"P",{});var Zl=l(Uo);S_=s(Zl,"The "),wl=r(Zl,"A",{href:!0});var bw=l(wl);L_=s(bw,"TFGPT2Model"),bw.forEach(t),X_=s(Zl," forward method, overrides the "),Ki=r(Zl,"CODE",{});var vw=l(Ki);O_=s(vw,"__call__"),vw.forEach(t),Q_=s(Zl," special method."),Zl.forEach(t),Y_=p(ds),w(jn.$$.fragment,ds),K_=p(ds),w(zn.$$.fragment,ds),ds.forEach(t),qt.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 ww=l(xn);ed=r(ww,"SPAN",{});var kw=l(ed);w(La.$$.fragment,kw),kw.forEach(t),ww.forEach(t),eT=p(Yp),td=r(Yp,"SPAN",{});var Mw=l(td);tT=s(Mw,"TFGPT2LMHeadModel"),Mw.forEach(t),Yp.forEach(t),Yc=p(o),Ye=r(o,"DIV",{class:!0});var At=l(Ye);w(Xa.$$.fragment,At),oT=p(At),od=r(At,"P",{});var $w=l(od);nT=s($w,`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input
embeddings).`),$w.forEach(t),sT=p(At),Oa=r(At,"P",{});var Kp=l(Oa);aT=s(Kp,"This model inherits from "),kl=r(Kp,"A",{href:!0});var Pw=l(kl);rT=s(Pw,"TFPreTrainedModel"),Pw.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 Gw=l(Ya);cT=s(Gw,"tf.keras.Model"),Gw.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),w(Cn.$$.fragment,At),uT=p(At),Jt=r(At,"DIV",{class:!0});var cs=l(Jt);w(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 Ew=l(Ml);gT=s(Ew,"TFGPT2LMHeadModel"),Ew.forEach(t),_T=s(Bl," forward method, overrides the "),nd=r(Bl,"CODE",{});var Fw=l(nd);TT=s(Fw,"__call__"),Fw.forEach(t),yT=s(Bl," special method."),Bl.forEach(t),bT=p(cs),w(Un.$$.fragment,cs),vT=p(cs),w(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 jw=l(In);sd=r(jw,"SPAN",{});var zw=l(sd);w(er.$$.fragment,zw),zw.forEach(t),jw.forEach(t),wT=p(th),ad=r(th,"SPAN",{});var xw=l(ad);kT=s(xw,"TFGPT2DoubleHeadsModel"),xw.forEach(t),th.forEach(t),ep=p(o),Ke=r(o,"DIV",{class:!0});var Ht=l(Ke);w(tr.$$.fragment,Ht),MT=p(Ht),rd=r(Ht,"P",{});var Cw=l(rd);$T=s(Cw,`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).`),Cw.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 Uw=l($l);ET=s(Uw,"TFPreTrainedModel"),Uw.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 Jw=l(sr);xT=s(Jw,"tf.keras.Model"),Jw.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),w(Nn.$$.fragment,Ht),JT=p(Ht),It=r(Ht,"DIV",{class:!0});var ps=l(It);w(ar.$$.fragment,ps),IT=p(ps),Wo=r(ps,"P",{});var Rl=l(Wo);NT=s(Rl,"The "),Pl=r(Rl,"A",{href:!0});var Iw=l(Pl);WT=s(Iw,"TFGPT2DoubleHeadsModel"),Iw.forEach(t),qT=s(Rl," forward method, overrides the "),ld=r(Rl,"CODE",{});var Nw=l(ld);AT=s(Nw,"__call__"),Nw.forEach(t),HT=s(Rl," special method."),Rl.forEach(t),ZT=p(ps),w(Wn.$$.fragment,ps),BT=p(ps),w(qn.$$.fragment,ps),ps.forEach(t),Ht.forEach(t),tp=p(o),qo=r(o,"H2",{class:!0});var sh=l(qo);An=r(sh,"A",{id:!0,class:!0,href:!0});var Ww=l(An);id=r(Ww,"SPAN",{});var qw=l(id);w(rr.$$.fragment,qw),qw.forEach(t),Ww.forEach(t),RT=p(sh),dd=r(sh,"SPAN",{});var Aw=l(dd);VT=s(Aw,"TFGPT2ForSequenceClassification"),Aw.forEach(t),sh.forEach(t),op=p(o),ve=r(o,"DIV",{class:!0});var ot=l(ve);w(lr.$$.fragment,ot),DT=p(ot),cd=r(ot,"P",{});var Hw=l(cd);ST=s(Hw,"The GPT2 Model transformer with a sequence classification head on top (linear layer)."),Hw.forEach(t),LT=p(ot),Gl=r(ot,"P",{});var db=l(Gl);El=r(db,"A",{href:!0});var Zw=l(El);XT=s(Zw,"TFGPT2ForSequenceClassification"),Zw.forEach(t),OT=s(db,` uses the last token in order to do the classification, as other causal models
(e.g. GPT-1) do.`),db.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 Bw=l(pd);KT=s(Bw,"pad_token_id"),Bw.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 Rw=l(hd);ty=s(Rw,"pad_token_id"),Rw.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 Vw=l(ud);ny=s(Vw,"inputs_embeds"),Vw.forEach(t),sy=s(io," are passed instead of "),md=r(io,"CODE",{});var Dw=l(md);ay=s(Dw,"input_ids"),Dw.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 Sw=l(Fl);dy=s(Sw,"TFPreTrainedModel"),Sw.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 Lw=l(cr);uy=s(Lw,"tf.keras.Model"),Lw.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),w(Hn.$$.fragment,ot),gy=p(ot),vt=r(ot,"DIV",{class:!0});var co=l(vt);w(pr.$$.fragment,co),_y=p(co),Ao=r(co,"P",{});var Vl=l(Ao);Ty=s(Vl,"The "),jl=r(Vl,"A",{href:!0});var Xw=l(jl);yy=s(Xw,"TFGPT2ForSequenceClassification"),Xw.forEach(t),by=s(Vl," forward method, overrides the "),fd=r(Vl,"CODE",{});var Ow=l(fd);vy=s(Ow,"__call__"),Ow.forEach(t),wy=s(Vl," special method."),Vl.forEach(t),ky=p(co),w(Zn.$$.fragment,co),My=p(co),w(Bn.$$.fragment,co),$y=p(co),w(Rn.$$.fragment,co),co.forEach(t),ot.forEach(t),np=p(o),Ho=r(o,"H2",{class:!0});var lh=l(Ho);Vn=r(lh,"A",{id:!0,class:!0,href:!0});var Qw=l(Vn);gd=r(Qw,"SPAN",{});var Yw=l(gd);w(hr.$$.fragment,Yw),Yw.forEach(t),Qw.forEach(t),Py=p(lh),_d=r(lh,"SPAN",{});var Kw=l(_d);Gy=s(Kw,"TFSequenceClassifierOutputWithPast"),Kw.forEach(t),lh.forEach(t),sp=p(o),Zo=r(o,"DIV",{class:!0});var ih=l(Zo);w(ur.$$.fragment,ih),Ey=p(ih),Td=r(ih,"P",{});var ek=l(Td);Fy=s(ek,"Base class for outputs of sentence classification models."),ek.forEach(t),ih.forEach(t),ap=p(o),Bo=r(o,"H2",{class:!0});var dh=l(Bo);Dn=r(dh,"A",{id:!0,class:!0,href:!0});var tk=l(Dn);yd=r(tk,"SPAN",{});var ok=l(yd);w(mr.$$.fragment,ok),ok.forEach(t),tk.forEach(t),jy=p(dh),bd=r(dh,"SPAN",{});var nk=l(bd);zy=s(nk,"TFGPT2Tokenizer"),nk.forEach(t),dh.forEach(t),rp=p(o),et=r(o,"DIV",{class:!0});var Zt=l(et);w(fr.$$.fragment,Zt),xy=p(Zt),Ro=r(Zt,"P",{});var Dl=l(Ro);Cy=s(Dl,`This is an in-graph tokenizer for GPT2. It should be initialized similarly to other tokenizers, using the
`),vd=r(Dl,"CODE",{});var sk=l(vd);Uy=s(sk,"from_pretrained()"),sk.forEach(t),Jy=s(Dl," method. It can also be initialized with the "),wd=r(Dl,"CODE",{});var ak=l(wd);Iy=s(ak,"from_tokenizer()"),ak.forEach(t),Ny=s(Dl,` method, which imports settings
from an existing standard tokenizer object.`),Dl.forEach(t),Wy=p(Zt),gr=r(Zt,"P",{});var ch=l(gr);qy=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 `),kd=r(ch,"CODE",{});var rk=l(kd);Ay=s(rk,"tf.string"),rk.forEach(t),Hy=s(ch," inputs to outputs."),ch.forEach(t),Zy=p(Zt),Sn=r(Zt,"DIV",{class:!0});var ph=l(Sn);w(_r.$$.fragment,ph),By=p(ph),Md=r(ph,"P",{});var lk=l(Md);Ry=s(lk,"Creates TFGPT2Tokenizer from configurations"),lk.forEach(t),ph.forEach(t),Vy=p(Zt),Yt=r(Zt,"DIV",{class:!0});var Sl=l(Yt);w(Tr.$$.fragment,Sl),Dy=p(Sl),$d=r(Sl,"P",{});var ik=l($d);Sy=s(ik,"Creates TFGPT2Tokenizer from pretrained GPT2Tokenizer"),ik.forEach(t),Ly=p(Sl),w(Ln.$$.fragment,Sl),Sl.forEach(t),Xy=p(Zt),Kt=r(Zt,"DIV",{class:!0});var Ll=l(Kt);w(yr.$$.fragment,Ll),Oy=p(Ll),Pd=r(Ll,"P",{});var dk=l(Pd);Qy=s(dk,"Creates TFGPT2Tokenizer from GPT2Tokenizer"),dk.forEach(t),Yy=p(Ll),w(Xn.$$.fragment,Ll),Ll.forEach(t),Zt.forEach(t),lp=p(o),Vo=r(o,"H2",{class:!0});var hh=l(Vo);On=r(hh,"A",{id:!0,class:!0,href:!0});var ck=l(On);Gd=r(ck,"SPAN",{});var pk=l(Gd);w(br.$$.fragment,pk),pk.forEach(t),ck.forEach(t),Ky=p(hh),Ed=r(hh,"SPAN",{});var hk=l(Ed);e2=s(hk,"FlaxGPT2Model"),hk.forEach(t),hh.forEach(t),ip=p(o),He=r(o,"DIV",{class:!0});var Mt=l(He);w(vr.$$.fragment,Mt),t2=p(Mt),Fd=r(Mt,"P",{});var uk=l(Fd);o2=s(uk,"The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top."),uk.forEach(t),n2=p(Mt),wr=r(Mt,"P",{});var uh=l(wr);s2=s(uh,"This model inherits from "),zl=r(uh,"A",{href:!0});var mk=l(zl);a2=s(mk,"FlaxPreTrainedModel"),mk.forEach(t),r2=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),l2=p(Mt),kr=r(Mt,"P",{});var mh=l(kr);i2=s(mh,`This model is also a Flax Linen
`),Mr=r(mh,"A",{href:!0,rel:!0});var fk=l(Mr);d2=s(fk,"flax.nn.Module"),fk.forEach(t),c2=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),p2=p(Mt),jd=r(Mt,"P",{});var gk=l(jd);h2=s(gk,"Finally, this model supports inherent JAX features such as:"),gk.forEach(t),u2=p(Mt),Vt=r(Mt,"UL",{});var hs=l(Vt);zd=r(hs,"LI",{});var _k=l(zd);$r=r(_k,"A",{href:!0,rel:!0});var Tk=l($r);m2=s(Tk,"Just-In-Time (JIT) compilation"),Tk.forEach(t),_k.forEach(t),f2=p(hs),xd=r(hs,"LI",{});var yk=l(xd);Pr=r(yk,"A",{href:!0,rel:!0});var bk=l(Pr);g2=s(bk,"Automatic Differentiation"),bk.forEach(t),yk.forEach(t),_2=p(hs),Cd=r(hs,"LI",{});var vk=l(Cd);Gr=r(vk,"A",{href:!0,rel:!0});var wk=l(Gr);T2=s(wk,"Vectorization"),wk.forEach(t),vk.forEach(t),y2=p(hs),Ud=r(hs,"LI",{});var kk=l(Ud);Er=r(kk,"A",{href:!0,rel:!0});var Mk=l(Er);b2=s(Mk,"Parallelization"),Mk.forEach(t),kk.forEach(t),hs.forEach(t),v2=p(Mt),Nt=r(Mt,"DIV",{class:!0});var us=l(Nt);w(Fr.$$.fragment,us),w2=p(us),Do=r(us,"P",{});var Xl=l(Do);k2=s(Xl,"The "),Jd=r(Xl,"CODE",{});var $k=l(Jd);M2=s($k,"FlaxGPT2PreTrainedModel"),$k.forEach(t),$2=s(Xl," forward method, overrides the "),Id=r(Xl,"CODE",{});var Pk=l(Id);P2=s(Pk,"__call__"),Pk.forEach(t),G2=s(Xl," special method."),Xl.forEach(t),E2=p(us),w(Qn.$$.fragment,us),F2=p(us),w(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 Gk=l(Kn);Nd=r(Gk,"SPAN",{});var Ek=l(Nd);w(jr.$$.fragment,Ek),Ek.forEach(t),Gk.forEach(t),j2=p(fh),Wd=r(fh,"SPAN",{});var Fk=l(Wd);z2=s(Fk,"FlaxGPT2LMHeadModel"),Fk.forEach(t),fh.forEach(t),cp=p(o),Ze=r(o,"DIV",{class:!0});var $t=l(Ze);w(zr.$$.fragment,$t),x2=p($t),qd=r($t,"P",{});var jk=l(qd);C2=s(jk,`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input
embeddings).`),jk.forEach(t),U2=p($t),xr=r($t,"P",{});var gh=l(xr);J2=s(gh,"This model inherits from "),xl=r(gh,"A",{href:!0});var zk=l(xl);I2=s(zk,"FlaxPreTrainedModel"),zk.forEach(t),N2=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),W2=p($t),Cr=r($t,"P",{});var _h=l(Cr);q2=s(_h,`This model is also a Flax Linen
`),Ur=r(_h,"A",{href:!0,rel:!0});var xk=l(Ur);A2=s(xk,"flax.nn.Module"),xk.forEach(t),H2=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),Z2=p($t),Ad=r($t,"P",{});var Ck=l(Ad);B2=s(Ck,"Finally, this model supports inherent JAX features such as:"),Ck.forEach(t),R2=p($t),Dt=r($t,"UL",{});var ms=l(Dt);Hd=r(ms,"LI",{});var Uk=l(Hd);Jr=r(Uk,"A",{href:!0,rel:!0});var Jk=l(Jr);V2=s(Jk,"Just-In-Time (JIT) compilation"),Jk.forEach(t),Uk.forEach(t),D2=p(ms),Zd=r(ms,"LI",{});var Ik=l(Zd);Ir=r(Ik,"A",{href:!0,rel:!0});var Nk=l(Ir);S2=s(Nk,"Automatic Differentiation"),Nk.forEach(t),Ik.forEach(t),L2=p(ms),Bd=r(ms,"LI",{});var Wk=l(Bd);Nr=r(Wk,"A",{href:!0,rel:!0});var qk=l(Nr);X2=s(qk,"Vectorization"),qk.forEach(t),Wk.forEach(t),O2=p(ms),Rd=r(ms,"LI",{});var Ak=l(Rd);Wr=r(Ak,"A",{href:!0,rel:!0});var Hk=l(Wr);Q2=s(Hk,"Parallelization"),Hk.forEach(t),Ak.forEach(t),ms.forEach(t),Y2=p($t),Wt=r($t,"DIV",{class:!0});var fs=l(Wt);w(qr.$$.fragment,fs),K2=p(fs),Lo=r(fs,"P",{});var Ol=l(Lo);eb=s(Ol,"The "),Vd=r(Ol,"CODE",{});var Zk=l(Vd);tb=s(Zk,"FlaxGPT2PreTrainedModel"),Zk.forEach(t),ob=s(Ol," forward method, overrides the "),Dd=r(Ol,"CODE",{});var Bk=l(Dd);nb=s(Bk,"__call__"),Bk.forEach(t),sb=s(Ol," special method."),Ol.forEach(t),ab=p(fs),w(es.$$.fragment,fs),rb=p(fs),w(ts.$$.fragment,fs),fs.forEach(t),$t.forEach(t),this.h()},h(){u(d,"name","hf:doc:metadata"),u(d,"content",JSON.stringify(I1)),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"),Rk(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"),Rk(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.31.0/en/model_doc/gpt2#transformers.GPT2Model.forward"),u(le,"href","/docs/transformers/v4.31.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(ks,"href","https://www.philschmid.de/fine-tune-a-non-english-gpt-2-model-with-huggingface"),u(ks,"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.31.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(Ws,"href","https://github.com/huggingface/transformers/tree/main/examples/pytorch/text-generation"),u(Ws,"rel","nofollow"),u(qs,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling.ipynb"),u(qs,"rel","nofollow"),u(Xr,"href","/docs/transformers/v4.31.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.31.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.31.0/en/model_doc/gpt2#transformers.GPT2Model"),u(tl,"href","/docs/transformers/v4.31.0/en/model_doc/gpt2#transformers.TFGPT2Model"),u(Ds,"href","https://huggingface.co/gpt2"),u(Ds,"rel","nofollow"),u(ol,"href","/docs/transformers/v4.31.0/en/main_classes/configuration#transformers.PretrainedConfig"),u(nl,"href","/docs/transformers/v4.31.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.31.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.31.0/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast"),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(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.31.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.31.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(wo,"class","relative group"),u(dl,"href","/docs/transformers/v4.31.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.31.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.31.0/en/main_classes/model#transformers.PreTrainedModel"),u(wa,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(wa,"rel","nofollow"),u(hl,"href","/docs/transformers/v4.31.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.31.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.31.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.31.0/en/model_doc/gpt2#transformers.GPT2ForSequenceClassification"),u(_l,"href","/docs/transformers/v4.31.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.31.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.31.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.31.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.31.0/en/main_classes/model#transformers.TFPreTrainedModel"),u(Da,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),u(Da,"rel","nofollow"),u(wl,"href","/docs/transformers/v4.31.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(kl,"href","/docs/transformers/v4.31.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.31.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.31.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.31.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(qo,"class","relative group"),u(El,"href","/docs/transformers/v4.31.0/en/model_doc/gpt2#transformers.TFGPT2ForSequenceClassification"),u(Fl,"href","/docs/transformers/v4.31.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.31.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(Vn,"id","transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast"),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.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(Dn,"id","transformers.TFGPT2Tokenizer"),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.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(Vo,"class","relative group"),u(zl,"href","/docs/transformers/v4.31.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.31.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(Wr,"href","https://jax.readthedocs.io/en/latest/jax.html#parallelization-pmap"),u(Wr,"rel","nofollow"),u(Wt,"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),k(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),k(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,V),e(ee,Ue),e(ee,D),e(D,Je),e(D,de),e(de,I),e(D,Ie),e(ee,q),e(ee,W),e(W,Ne),e(W,b),e(b,j),e(W,nt),e(W,ce),e(ce,st),e(W,at),e(W,z),e(z,rt),e(W,lt),e(W,Xe),e(Xe,it),e(W,dt),e(W,Z),e(Z,se),e(W,ct),e(W,Le),e(Le,ae),e(W,pt),e(W,Oe),e(Oe,We),e(W,ht),e(W,le),e(le,ut),e(W,Th),e(ee,yh),e(ee,Bt),e(Bt,bh),e(Bt,Ql),e(Ql,vh),e(Bt,wh),e(Bt,Yl),e(Yl,kh),e(Bt,Mh),e(Bt,gs),e(gs,$h),e(Bt,Ph),g(o,wc,_),g(o,po,_),e(po,_s),e(_s,Gh),e(po,Eh),e(po,Kl),e(Kl,Fh),e(po,jh),g(o,kc,_),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),k(bs,ei,null),e(ho,Ih),e(ho,ti),e(ti,Nh),g(o,$c,_),g(o,Dr,_),e(Dr,Wh),g(o,Pc,_),k(vs,o,_),g(o,Gc,_),g(o,B,_),e(B,ws),e(ws,qh),e(ws,ks),e(ks,Ah),e(ws,Hh),e(B,Zh),e(B,Ms),e(Ms,Bh),e(Ms,$s),e($s,Rh),e(Ms,Vh),e(B,Dh),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,Ws),e(Ws,bu),e(Ft,vu),e(Ft,qs),e(qs,wu),e(Ft,ku),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,Wu),e(B,oi),e(oi,Qr),e(Qr,qu),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),k(Rs,ai,null),e(uo,Ru),e(uo,ri),e(ri,Vu),g(o,Fc,_),g(o,Pt,_),k(Vs,Pt,null),e(Pt,Du),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,Ds),e(Ds,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),k(Ko,Pt,null),g(o,jc,_),g(o,fo,_),e(fo,en),e(en,li),k(Ss,li,null),e(fo,lm),e(fo,ii),e(ii,im),g(o,zc,_),g(o,be,_),k(Ls,be,null),e(be,dm),e(be,di),e(di,cm),e(be,pm),e(be,ci),e(ci,hm),e(be,um),k(tn,be,null),e(be,mm),e(be,Xs),e(Xs,fm),e(Xs,pi),e(pi,gm),e(Xs,_m),e(be,Tm),k(on,be,null),e(be,ym),e(be,Os),e(Os,bm),e(Os,sl),e(sl,vm),e(Os,wm),e(be,km),e(be,al),k(Qs,al,null),g(o,xc,_),g(o,go,_),e(go,nn),e(nn,hi),k(Ys,hi,null),e(go,Mm),e(go,ui),e(ui,$m),g(o,Cc,_),g(o,qe,_),k(Ks,qe,null),e(qe,Pm),e(qe,ea),e(ea,Gm),e(ea,mi),e(mi,Em),e(ea,Fm),e(qe,jm),e(qe,fi),e(fi,zm),e(qe,xm),k(sn,qe,null),e(qe,Cm),e(qe,ta),e(ta,Um),e(ta,gi),e(gi,Jm),e(ta,Im),e(qe,Nm),k(an,qe,null),e(qe,Wm),e(qe,oa),e(oa,qm),e(oa,rl),e(rl,Am),e(oa,Hm),g(o,Uc,_),g(o,_o,_),e(_o,rn),e(rn,_i),k(na,_i,null),e(_o,Zm),e(_o,Ti),e(Ti,Bm),g(o,Jc,_),g(o,To,_),k(sa,To,null),e(To,Rm),e(To,yi),e(yi,Vm),g(o,Ic,_),g(o,yo,_),k(aa,yo,null),e(yo,Dm),e(yo,bi),e(bi,Sm),g(o,Nc,_),g(o,bo,_),e(bo,ln),e(ln,vi),k(ra,vi,null),e(bo,Lm),e(bo,wi),e(wi,Xm),g(o,Wc,_),g(o,mt,_),k(la,mt,null),e(mt,Om),e(mt,ki),e(ki,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),k(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),k(dn,jt,null),e(jt,ff),k(cn,jt,null),g(o,qc,_),g(o,wo,_),e(wo,pn),e(pn,$i),k(ha,$i,null),e(wo,gf),e(wo,Pi),e(Pi,_f),g(o,Ac,_),g(o,ft,_),k(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,wf),e(ma,kf),e(ft,Mf),e(ft,fa),e(fa,$f),e(fa,ga),e(ga,Pf),e(fa,Gf),e(ft,Ef),e(ft,zt),k(_a,zt,null),e(zt,Ff),e(zt,ko),e(ko,jf),e(ko,cl),e(cl,zf),e(ko,xf),e(ko,Ei),e(Ei,Cf),e(ko,Uf),e(zt,Jf),k(hn,zt,null),e(zt,If),k(un,zt,null),g(o,Hc,_),g(o,Mo,_),e(Mo,mn),e(mn,Fi),k(Ta,Fi,null),e(Mo,Nf),e(Mo,ji),e(ji,Wf),g(o,Zc,_),g(o,gt,_),k(ya,gt,null),e(gt,qf),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,Vf),e(gt,va),e(va,Df),e(va,wa),e(wa,Sf),e(va,Lf),e(gt,Xf),e(gt,xt),k(ka,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),k(fn,xt,null),e(xt,ng),k(gn,xt,null),g(o,Bc,_),g(o,Po,_),e(Po,_n),e(_n,Ci),k(Ma,Ci,null),e(Po,sg),e(Po,Ui),e(Ui,ag),g(o,Rc,_),g(o,_t,_),k($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),k(Fa,yt,null),e(yt,vg),e(yt,Eo),e(Eo,wg),e(Eo,ml),e(ml,kg),e(Eo,Mg),e(Eo,Ni),e(Ni,$g),e(Eo,Pg),e(yt,Gg),k(Tn,yt,null),e(yt,Eg),k(yn,yt,null),e(yt,Fg),k(bn,yt,null),g(o,Vc,_),g(o,Fo,_),e(Fo,vn),e(vn,Wi),k(ja,Wi,null),e(Fo,jg),e(Fo,qi),e(qi,zg),g(o,Dc,_),g(o,Ae,_),k(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,Wg),e(Gt,Hi),e(Hi,qg),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,Vg),e(Gt,Dg),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),k(Ja,bt,null),e(bt,o_),e(bt,jo),e(jo,n_),e(jo,Tl),e(Tl,s_),e(jo,a_),e(jo,Vi),e(Vi,r_),e(jo,l_),e(bt,i_),k(wn,bt,null),e(bt,d_),k(kn,bt,null),e(bt,c_),k(Mn,bt,null),g(o,Sc,_),g(o,zo,_),e(zo,$n),e($n,Di),k(Ia,Di,null),e(zo,p_),e(zo,Si),e(Si,h_),g(o,Lc,_),g(o,Tt,_),k(Na,Tt,null),e(Tt,u_),e(Tt,Li),e(Li,m_),e(Tt,f_),e(Tt,Wa),e(Wa,g_),e(Wa,yl),e(yl,__),e(Wa,T_),e(Tt,y_),e(Tt,qa),e(qa,b_),e(qa,Aa),e(Aa,v_),e(qa,w_),e(Tt,k_),e(Tt,Ct),k(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_),k(Pn,Ct,null),e(Ct,z_),k(Gn,Ct,null),g(o,Xc,_),g(o,Co,_),e(Co,En),e(En,Oi),k(Za,Oi,null),e(Co,x_),e(Co,Qi),e(Qi,C_),g(o,Oc,_),g(o,Qe,_),k(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,W_),e(Ra,q_),e(Qe,A_),e(Qe,Va),e(Va,H_),e(Va,Da),e(Da,Z_),e(Va,B_),e(Qe,R_),k(Fn,Qe,null),e(Qe,V_),e(Qe,Ut),k(Sa,Ut,null),e(Ut,D_),e(Ut,Uo),e(Uo,S_),e(Uo,wl),e(wl,L_),e(Uo,X_),e(Uo,Ki),e(Ki,O_),e(Uo,Q_),e(Ut,Y_),k(jn,Ut,null),e(Ut,K_),k(zn,Ut,null),g(o,Qc,_),g(o,Jo,_),e(Jo,xn),e(xn,ed),k(La,ed,null),e(Jo,eT),e(Jo,td),e(td,tT),g(o,Yc,_),g(o,Ye,_),k(Xa,Ye,null),e(Ye,oT),e(Ye,od),e(od,nT),e(Ye,sT),e(Ye,Oa),e(Oa,aT),e(Oa,kl),e(kl,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),k(Cn,Ye,null),e(Ye,uT),e(Ye,Jt),k(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),k(Un,Jt,null),e(Jt,vT),k(Jn,Jt,null),g(o,Kc,_),g(o,No,_),e(No,In),e(In,sd),k(er,sd,null),e(No,wT),e(No,ad),e(ad,kT),g(o,ep,_),g(o,Ke,_),k(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),k(Nn,Ke,null),e(Ke,JT),e(Ke,It),k(ar,It,null),e(It,IT),e(It,Wo),e(Wo,NT),e(Wo,Pl),e(Pl,WT),e(Wo,qT),e(Wo,ld),e(ld,AT),e(Wo,HT),e(It,ZT),k(Wn,It,null),e(It,BT),k(qn,It,null),g(o,tp,_),g(o,qo,_),e(qo,An),e(An,id),k(rr,id,null),e(qo,RT),e(qo,dd),e(dd,VT),g(o,op,_),g(o,ve,_),k(lr,ve,null),e(ve,DT),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),k(Hn,ve,null),e(ve,gy),e(ve,vt),k(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,wy),e(vt,ky),k(Zn,vt,null),e(vt,My),k(Bn,vt,null),e(vt,$y),k(Rn,vt,null),g(o,np,_),g(o,Ho,_),e(Ho,Vn),e(Vn,gd),k(hr,gd,null),e(Ho,Py),e(Ho,_d),e(_d,Gy),g(o,sp,_),g(o,Zo,_),k(ur,Zo,null),e(Zo,Ey),e(Zo,Td),e(Td,Fy),g(o,ap,_),g(o,Bo,_),e(Bo,Dn),e(Dn,yd),k(mr,yd,null),e(Bo,jy),e(Bo,bd),e(bd,zy),g(o,rp,_),g(o,et,_),k(fr,et,null),e(et,xy),e(et,Ro),e(Ro,Cy),e(Ro,vd),e(vd,Uy),e(Ro,Jy),e(Ro,wd),e(wd,Iy),e(Ro,Ny),e(et,Wy),e(et,gr),e(gr,qy),e(gr,kd),e(kd,Ay),e(gr,Hy),e(et,Zy),e(et,Sn),k(_r,Sn,null),e(Sn,By),e(Sn,Md),e(Md,Ry),e(et,Vy),e(et,Yt),k(Tr,Yt,null),e(Yt,Dy),e(Yt,$d),e($d,Sy),e(Yt,Ly),k(Ln,Yt,null),e(et,Xy),e(et,Kt),k(yr,Kt,null),e(Kt,Oy),e(Kt,Pd),e(Pd,Qy),e(Kt,Yy),k(Xn,Kt,null),g(o,lp,_),g(o,Vo,_),e(Vo,On),e(On,Gd),k(br,Gd,null),e(Vo,Ky),e(Vo,Ed),e(Ed,e2),g(o,ip,_),g(o,He,_),k(vr,He,null),e(He,t2),e(He,Fd),e(Fd,o2),e(He,n2),e(He,wr),e(wr,s2),e(wr,zl),e(zl,a2),e(wr,r2),e(He,l2),e(He,kr),e(kr,i2),e(kr,Mr),e(Mr,d2),e(kr,c2),e(He,p2),e(He,jd),e(jd,h2),e(He,u2),e(He,Vt),e(Vt,zd),e(zd,$r),e($r,m2),e(Vt,f2),e(Vt,xd),e(xd,Pr),e(Pr,g2),e(Vt,_2),e(Vt,Cd),e(Cd,Gr),e(Gr,T2),e(Vt,y2),e(Vt,Ud),e(Ud,Er),e(Er,b2),e(He,v2),e(He,Nt),k(Fr,Nt,null),e(Nt,w2),e(Nt,Do),e(Do,k2),e(Do,Jd),e(Jd,M2),e(Do,$2),e(Do,Id),e(Id,P2),e(Do,G2),e(Nt,E2),k(Qn,Nt,null),e(Nt,F2),k(Yn,Nt,null),g(o,dp,_),g(o,So,_),e(So,Kn),e(Kn,Nd),k(jr,Nd,null),e(So,j2),e(So,Wd),e(Wd,z2),g(o,cp,_),g(o,Ze,_),k(zr,Ze,null),e(Ze,x2),e(Ze,qd),e(qd,C2),e(Ze,U2),e(Ze,xr),e(xr,J2),e(xr,xl),e(xl,I2),e(xr,N2),e(Ze,W2),e(Ze,Cr),e(Cr,q2),e(Cr,Ur),e(Ur,A2),e(Cr,H2),e(Ze,Z2),e(Ze,Ad),e(Ad,B2),e(Ze,R2),e(Ze,Dt),e(Dt,Hd),e(Hd,Jr),e(Jr,V2),e(Dt,D2),e(Dt,Zd),e(Zd,Ir),e(Ir,S2),e(Dt,L2),e(Dt,Bd),e(Bd,Nr),e(Nr,X2),e(Dt,O2),e(Dt,Rd),e(Rd,Wr),e(Wr,Q2),e(Ze,Y2),e(Ze,Wt),k(qr,Wt,null),e(Wt,K2),e(Wt,Lo),e(Lo,eb),e(Lo,Vd),e(Vd,tb),e(Lo,ob),e(Lo,Dd),e(Dd,nb),e(Lo,sb),e(Wt,ab),k(es,Wt,null),e(Wt,rb),k(ts,Wt,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}),wn.$set(nc);const sc={};_&2&&(sc.$$scope={dirty:_,ctx:o}),kn.$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 we={};_&2&&(we.$$scope={dirty:_,ctx:o}),Cn.$set(we);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}),Wn.$set(hc);const uc={};_&2&&(uc.$$scope={dirty:_,ctx:o}),qn.$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(Vs.$$.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(ka.$$.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(wn.$$.fragment,o),M(kn.$$.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(Wn.$$.fragment,o),M(qn.$$.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(qr.$$.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),$(Vs.$$.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),$(ka.$$.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),$(wn.$$.fragment,o),$(kn.$$.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),$(Wn.$$.fragment,o),$(qn.$$.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),$(qr.$$.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(wc),o&&t(po),o&&t(kc),o&&t(Xt),o&&t(Mc),o&&t(ho),P(bs),o&&t($c),o&&t(Dr),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(Vs),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(qe),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(Wc),o&&t(mt),P(la),P(pa),P(dn),P(cn),o&&t(qc),o&&t(wo),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(ka),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(Vc),o&&t(Fo),P(ja),o&&t(Dc),o&&t(Ae),P(za),P(Ja),P(wn),P(kn),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(Wn),P(qn),o&&t(tp),o&&t(qo),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(Vo),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(qr),P(es),P(ts)}}}const I1={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 N1(G){return Xk(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class V1 extends Vk{constructor(d){super();Dk(this,d,N1,J1,Sk,{})}}export{V1 as default,I1 as metadata};
