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