import{S as Bw,i as Rw,s as Kw,e as a,k as c,w as k,t as n,M as Vw,c as r,d as t,m as p,a as i,x as b,h as s,b as u,N as Uw,G as e,g,y as w,q as $,o as P,B as F,v as Qw,L as Be}from"../../chunks/vendor-hf-doc-builder.js";import{T as We}from"../../chunks/Tip-hf-doc-builder.js";import{D as I}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Re}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as we}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Ue}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";import{P as Jw}from"../../chunks/PipelineTag-hf-doc-builder.js";function Xw(M){let d,v,f,m,T;return m=new Re({props:{code:`from transformers import GPT2Config, GPT2Model

# Initializing a GPT2 configuration
configuration = GPT2Config()

# Initializing a model (with random weights) from the configuration
model = GPT2Model(configuration)

# Accessing the model configuration
configuration = model.config`,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"),v=n("Example:"),f=c(),k(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);v=s(h,"Example:"),h.forEach(t),f=p(l),b(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,v),g(l,f,h),w(m,l,h),T=!0},p:Be,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),F(m,l)}}}function Yw(M){let d,v,f,m,T;return m=new Re({props:{code:`from transformers import GPT2Tokenizer

tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
tokenizer("Hello world")["input_ids"]

tokenizer(" Hello world")["input_ids"]`,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"),v=n("be encoded differently whether it is at the beginning of the sentence (without space) or not:"),f=c(),k(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);v=s(h,"be encoded differently whether it is at the beginning of the sentence (without space) or not:"),h.forEach(t),f=p(l),b(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,v),g(l,f,h),w(m,l,h),T=!0},p:Be,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),F(m,l)}}}function Zw(M){let d,v,f,m,T;return{c(){d=a("p"),v=n("When used with "),f=a("code"),m=n("is_split_into_words=True"),T=n(", this tokenizer will add a space before each word (even the first one).")},l(l){d=r(l,"P",{});var h=i(d);v=s(h,"When used with "),f=r(h,"CODE",{});var x=i(f);m=s(x,"is_split_into_words=True"),x.forEach(t),T=s(h,", this tokenizer will add a space before each word (even the first one)."),h.forEach(t)},m(l,h){g(l,d,h),e(d,v),e(d,f),e(f,m),e(d,T)},d(l){l&&t(d)}}}function e1(M){let d,v,f,m,T;return m=new Re({props:{code:`from transformers import GPT2TokenizerFast

tokenizer = GPT2TokenizerFast.from_pretrained("gpt2")
tokenizer("Hello world")["input_ids"]

tokenizer(" Hello world")["input_ids"]`,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"),v=n("be encoded differently whether it is at the beginning of the sentence (without space) or not:"),f=c(),k(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);v=s(h,"be encoded differently whether it is at the beginning of the sentence (without space) or not:"),h.forEach(t),f=p(l),b(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,v),g(l,f,h),w(m,l,h),T=!0},p:Be,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),F(m,l)}}}function t1(M){let d,v,f,m,T,l,h,x;return{c(){d=a("p"),v=n("When used with "),f=a("code"),m=n("is_split_into_words=True"),T=n(", this tokenizer needs to be instantiated with "),l=a("code"),h=n("add_prefix_space=True"),x=n(".")},l(U){d=r(U,"P",{});var L=i(d);v=s(L,"When used with "),f=r(L,"CODE",{});var A=i(f);m=s(A,"is_split_into_words=True"),A.forEach(t),T=s(L,", this tokenizer needs to be instantiated with "),l=r(L,"CODE",{});var J=i(l);h=s(J,"add_prefix_space=True"),J.forEach(t),x=s(L,"."),L.forEach(t)},m(U,L){g(U,d,L),e(d,v),e(d,f),e(f,m),e(d,T),e(d,l),e(l,h),e(d,x)},d(U){U&&t(d)}}}function o1(M){let d,v,f,m,T;return{c(){d=a("p"),v=n("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),m=n("Module"),T=n(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(l){d=r(l,"P",{});var h=i(d);v=s(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=r(h,"CODE",{});var x=i(f);m=s(x,"Module"),x.forEach(t),T=s(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(t)},m(l,h){g(l,d,h),e(d,v),e(d,f),e(f,m),e(d,T)},d(l){l&&t(d)}}}function n1(M){let d,v,f,m,T;return m=new Re({props:{code:`from transformers import AutoTokenizer, GPT2Model
import torch

tokenizer = AutoTokenizer.from_pretrained("gpt2")
model = GPT2Model.from_pretrained("gpt2")

inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs)

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

tokenizer = AutoTokenizer.from_pretrained("gpt2")
model = GPT2LMHeadModel.from_pretrained("gpt2")

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

tokenizer = AutoTokenizer.from_pretrained("gpt2")
model = GPT2DoubleHeadsModel.from_pretrained("gpt2")

# Add a [CLS] to the vocabulary (we should train it also!)
num_added_tokens = tokenizer.add_special_tokens({"cls_token": "[CLS]"})
# Update the model embeddings with the new vocabulary size
embedding_layer = model.resize_token_embeddings(len(tokenizer))

choices = ["Hello, my dog is cute [CLS]", "Hello, my cat is cute [CLS]"]
encoded_choices = [tokenizer.encode(s) for s in choices]
cls_token_location = [tokens.index(tokenizer.cls_token_id) for tokens in encoded_choices]

input_ids = torch.tensor(encoded_choices).unsqueeze(0)  # Batch size: 1, number of choices: 2
mc_token_ids = torch.tensor([cls_token_location])  # Batch size: 1

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

tokenizer = AutoTokenizer.from_pretrained("gpt2")
model = GPT2ForQuestionAnswering.from_pretrained("gpt2")

question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"

inputs = tokenizer(question, text, return_tensors="pt")
with torch.no_grad():
    outputs = model(**inputs)

answer_start_index = outputs.start_logits.argmax()
answer_end_index = outputs.end_logits.argmax()

predict_answer_tokens = inputs.input_ids[0, answer_start_index : answer_end_index + 1]

# target is "nice puppet"
target_start_index = torch.tensor([14])
target_end_index = torch.tensor([15])

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

tokenizer = AutoTokenizer.from_pretrained("microsoft/DialogRPT-updown")
model = GPT2ForSequenceClassification.from_pretrained("microsoft/DialogRPT-updown")

inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")

with torch.no_grad():
    logits = model(**inputs).logits

predicted_class_id = logits.argmax().item()

# To train a model on \`num_labels\` classes, you can pass \`num_labels=num_labels\` to \`.from_pretrained(...)\`
num_labels = len(model.config.id2label)
model = GPT2ForSequenceClassification.from_pretrained("microsoft/DialogRPT-updown", num_labels=num_labels)

labels = torch.tensor([1])
loss = model(**inputs, labels=labels).loss`,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"),v=n("Example of single-label classification:"),f=c(),k(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);v=s(h,"Example of single-label classification:"),h.forEach(t),f=p(l),b(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,v),g(l,f,h),w(m,l,h),T=!0},p:Be,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),F(m,l)}}}function u1(M){let d,v,f,m,T;return m=new Re({props:{code:`import torch
from transformers import AutoTokenizer, GPT2ForSequenceClassification

tokenizer = AutoTokenizer.from_pretrained("microsoft/DialogRPT-updown")
model = GPT2ForSequenceClassification.from_pretrained("microsoft/DialogRPT-updown", problem_type="multi_label_classification")

inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")

with torch.no_grad():
    logits = model(**inputs).logits

predicted_class_ids = torch.arange(0, logits.shape[-1])[torch.sigmoid(logits).squeeze(dim=0) > 0.5]

# To train a model on \`num_labels\` classes, you can pass \`num_labels=num_labels\` to \`.from_pretrained(...)\`
num_labels = len(model.config.id2label)
model = GPT2ForSequenceClassification.from_pretrained(
    "microsoft/DialogRPT-updown", num_labels=num_labels, problem_type="multi_label_classification"
)

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

tokenizer = AutoTokenizer.from_pretrained("brad1141/gpt2-finetuned-comp2")
model = GPT2ForTokenClassification.from_pretrained("brad1141/gpt2-finetuned-comp2")

inputs = tokenizer(
    "HuggingFace is a company based in Paris and New York", add_special_tokens=False, return_tensors="pt"
)

with torch.no_grad():
    logits = model(**inputs).logits

predicted_token_class_ids = logits.argmax(-1)

# Note that tokens are classified rather then input words which means that
# there might be more predicted token classes than words.
# Multiple token classes might account for the same word
predicted_tokens_classes = [model.config.id2label[t.item()] for t in predicted_token_class_ids[0]]
predicted_tokens_classes

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

tokenizer = AutoTokenizer.from_pretrained("gpt2")
model = TFGPT2Model.from_pretrained("gpt2")

inputs = tokenizer("Hello, my dog is cute", return_tensors="tf")
outputs = model(inputs)

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

tokenizer = AutoTokenizer.from_pretrained("gpt2")
model = TFGPT2LMHeadModel.from_pretrained("gpt2")

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

tokenizer = AutoTokenizer.from_pretrained("gpt2")
model = TFGPT2DoubleHeadsModel.from_pretrained("gpt2")

# Add a [CLS] to the vocabulary (we should train it also!)
num_added_tokens = tokenizer.add_special_tokens({"cls_token": "[CLS]"})

embedding_layer = model.resize_token_embeddings(
    len(tokenizer)
)  # Update the model embeddings with the new vocabulary size

choices = ["Hello, my dog is cute [CLS]", "Hello, my cat is cute [CLS]"]
encoded_choices = [tokenizer.encode(s) for s in choices]
cls_token_location = [tokens.index(tokenizer.cls_token_id) for tokens in encoded_choices]

input_ids = tf.constant(encoded_choices)[None, :]  # Batch size: 1, number of choices: 2
mc_token_ids = tf.constant([cls_token_location])  # Batch size: 1

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

tokenizer = AutoTokenizer.from_pretrained("microsoft/DialogRPT-updown")
model = TFGPT2ForSequenceClassification.from_pretrained("microsoft/DialogRPT-updown")

inputs = tokenizer("Hello, my dog is cute", return_tensors="tf")

logits = model(**inputs).logits

predicted_class_id = int(tf.math.argmax(logits, axis=-1)[0])`,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"),v=n("Example:"),f=c(),k(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);v=s(h,"Example:"),h.forEach(t),f=p(l),b(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,v),g(l,f,h),w(m,l,h),T=!0},p:Be,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),F(m,l)}}}function x1(M){let d,v;return d=new Re({props:{code:'# To train a model on `num_labels` classes, you can pass `num_labels=num_labels` to `.from_pretrained(...)`\nnum_labels = len(model.config.id2label)\nmodel = TFGPT2ForSequenceClassification.from_pretrained("microsoft/DialogRPT-updown", num_labels=num_labels)\n\nlabels = tf.constant(1)\nloss = model(**inputs, labels=labels).loss',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(){k(d.$$.fragment)},l(f){b(d.$$.fragment,f)},m(f,m){w(d,f,m),v=!0},p:Be,i(f){v||($(d.$$.fragment,f),v=!0)},o(f){P(d.$$.fragment,f),v=!1},d(f){F(d,f)}}}function G1(M){let d,v,f,m,T;return m=new Re({props:{code:`from transformers import TFGPT2Tokenizer

tf_tokenizer = TFGPT2Tokenizer.from_pretrained("gpt2")`,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"),v=n("Examples:"),f=c(),k(m.$$.fragment)},l(l){d=r(l,"P",{});var h=i(d);v=s(h,"Examples:"),h.forEach(t),f=p(l),b(m.$$.fragment,l)},m(l,h){g(l,d,h),e(d,v),g(l,f,h),w(m,l,h),T=!0},p:Be,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(f),F(m,l)}}}function z1(M){let d,v,f,m,T;return m=new Re({props:{code:`from transformers import AutoTokenizer, TFGPT2Tokenizer

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

tokenizer = AutoTokenizer.from_pretrained("gpt2")
model = FlaxGPT2Model.from_pretrained("gpt2")

inputs = tokenizer("Hello, my dog is cute", return_tensors="jax")
outputs = model(**inputs)

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

tokenizer = AutoTokenizer.from_pretrained("gpt2")
model = FlaxGPT2LMHeadModel.from_pretrained("gpt2")

inputs = tokenizer("Hello, my dog is cute", return_tensors="np")
outputs = model(**inputs)

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