import{S as Qk,i as Zk,s as ew,e as a,k as p,w as y,t as n,M as tw,c as r,d as t,m as h,a as i,x as k,h as s,b as f,G as e,g,y as w,q as $,o as P,B as G,v as ow,L as de}from"../../chunks/vendor-hf-doc-builder.js";import{T as nt}from"../../chunks/Tip-hf-doc-builder.js";import{D as H}from"../../chunks/Docstring-hf-doc-builder.js";import{C as ce}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Ge}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as le}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";import{P as nw}from"../../chunks/PipelineTag-hf-doc-builder.js";function sw(M){let d,v,u,m,T;return m=new ce({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:"),u=p(),y(m.$$.fragment)},l(l){d=r(l,"P",{});var c=i(d);v=s(c,"Example:"),c.forEach(t),u=h(l),k(m.$$.fragment,l)},m(l,c){g(l,d,c),e(d,v),g(l,u,c),w(m,l,c),T=!0},p:de,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(u),G(m,l)}}}function aw(M){let d,v,u,m,T;return m=new ce({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:"),u=p(),y(m.$$.fragment)},l(l){d=r(l,"P",{});var c=i(d);v=s(c,"be encoded differently whether it is at the beginning of the sentence (without space) or not:"),c.forEach(t),u=h(l),k(m.$$.fragment,l)},m(l,c){g(l,d,c),e(d,v),g(l,u,c),w(m,l,c),T=!0},p:de,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(u),G(m,l)}}}function rw(M){let d,v,u,m,T;return{c(){d=a("p"),v=n("When used with "),u=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 c=i(d);v=s(c,"When used with "),u=r(c,"CODE",{});var z=i(u);m=s(z,"is_split_into_words=True"),z.forEach(t),T=s(c,", this tokenizer will add a space before each word (even the first one)."),c.forEach(t)},m(l,c){g(l,d,c),e(d,v),e(d,u),e(u,m),e(d,T)},d(l){l&&t(d)}}}function iw(M){let d,v,u,m,T;return m=new ce({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:"),u=p(),y(m.$$.fragment)},l(l){d=r(l,"P",{});var c=i(d);v=s(c,"be encoded differently whether it is at the beginning of the sentence (without space) or not:"),c.forEach(t),u=h(l),k(m.$$.fragment,l)},m(l,c){g(l,d,c),e(d,v),g(l,u,c),w(m,l,c),T=!0},p:de,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(u),G(m,l)}}}function lw(M){let d,v,u,m,T,l,c,z;return{c(){d=a("p"),v=n("When used with "),u=a("code"),m=n("is_split_into_words=True"),T=n(", this tokenizer needs to be instantiated with "),l=a("code"),c=n("add_prefix_space=True"),z=n(".")},l(ae){d=r(ae,"P",{});var K=i(d);v=s(K,"When used with "),u=r(K,"CODE",{});var N=i(u);m=s(N,"is_split_into_words=True"),N.forEach(t),T=s(K,", this tokenizer needs to be instantiated with "),l=r(K,"CODE",{});var J=i(l);c=s(J,"add_prefix_space=True"),J.forEach(t),z=s(K,"."),K.forEach(t)},m(ae,K){g(ae,d,K),e(d,v),e(d,u),e(u,m),e(d,T),e(d,l),e(l,c),e(d,z)},d(ae){ae&&t(d)}}}function dw(M){let d,v,u,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 "),u=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 c=i(d);v=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=r(c,"CODE",{});var z=i(u);m=s(z,"Module"),z.forEach(t),T=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(t)},m(l,c){g(l,d,c),e(d,v),e(d,u),e(u,m),e(d,T)},d(l){l&&t(d)}}}function cw(M){let d,v,u,m,T;return m=new ce({props:{code:`from transformers import GPT2Tokenizer, GPT2Model
import torch

tokenizer = GPT2Tokenizer.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> GPT2Tokenizer, 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 = GPT2Tokenizer.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:"),u=p(),y(m.$$.fragment)},l(l){d=r(l,"P",{});var c=i(d);v=s(c,"Example:"),c.forEach(t),u=h(l),k(m.$$.fragment,l)},m(l,c){g(l,d,c),e(d,v),g(l,u,c),w(m,l,c),T=!0},p:de,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(u),G(m,l)}}}function pw(M){let d,v,u,m,T;return m=new ce({props:{code:`# Here is an example of a device map on a machine with 4 GPUs using gpt2-xl, which has a total of 48 attention modules:
model = GPT2LMHeadModel.from_pretrained("gpt2-xl")
device_map = {
    0: [0, 1, 2, 3, 4, 5, 6, 7, 8],
    1: [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],
    2: [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34],
    3: [35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47],
}
model.parallelize(device_map)`,highlighted:`<span class="hljs-comment"># Here is an example of a device map on a machine with 4 GPUs using gpt2-xl, which has a total of 48 attention modules:</span>
model = GPT2LMHeadModel.from_pretrained(<span class="hljs-string">&quot;gpt2-xl&quot;</span>)
device_map = {
    <span class="hljs-number">0</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>],
    <span class="hljs-number">1</span>: [<span class="hljs-number">9</span>, <span class="hljs-number">10</span>, <span class="hljs-number">11</span>, <span class="hljs-number">12</span>, <span class="hljs-number">13</span>, <span class="hljs-number">14</span>, <span class="hljs-number">15</span>, <span class="hljs-number">16</span>, <span class="hljs-number">17</span>, <span class="hljs-number">18</span>, <span class="hljs-number">19</span>, <span class="hljs-number">20</span>, <span class="hljs-number">21</span>],
    <span class="hljs-number">2</span>: [<span class="hljs-number">22</span>, <span class="hljs-number">23</span>, <span class="hljs-number">24</span>, <span class="hljs-number">25</span>, <span class="hljs-number">26</span>, <span class="hljs-number">27</span>, <span class="hljs-number">28</span>, <span class="hljs-number">29</span>, <span class="hljs-number">30</span>, <span class="hljs-number">31</span>, <span class="hljs-number">32</span>, <span class="hljs-number">33</span>, <span class="hljs-number">34</span>],
    <span class="hljs-number">3</span>: [<span class="hljs-number">35</span>, <span class="hljs-number">36</span>, <span class="hljs-number">37</span>, <span class="hljs-number">38</span>, <span class="hljs-number">39</span>, <span class="hljs-number">40</span>, <span class="hljs-number">41</span>, <span class="hljs-number">42</span>, <span class="hljs-number">43</span>, <span class="hljs-number">44</span>, <span class="hljs-number">45</span>, <span class="hljs-number">46</span>, <span class="hljs-number">47</span>],
}
model.parallelize(device_map)`}}),{c(){d=a("p"),v=n("Example:"),u=p(),y(m.$$.fragment)},l(l){d=r(l,"P",{});var c=i(d);v=s(c,"Example:"),c.forEach(t),u=h(l),k(m.$$.fragment,l)},m(l,c){g(l,d,c),e(d,v),g(l,u,c),w(m,l,c),T=!0},p:de,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(u),G(m,l)}}}function hw(M){let d,v,u,m,T;return m=new ce({props:{code:`# On a 4 GPU machine with gpt2-large:
model = GPT2LMHeadModel.from_pretrained("gpt2-large")
device_map = {
    0: [0, 1, 2, 3, 4, 5, 6, 7],
    1: [8, 9, 10, 11, 12, 13, 14, 15],
    2: [16, 17, 18, 19, 20, 21, 22, 23],
    3: [24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35],
}
model.parallelize(device_map)  # Splits the model across several devices
model.deparallelize()  # Put the model back on cpu and cleans memory by calling torch.cuda.empty_cache()`,highlighted:`<span class="hljs-comment"># On a 4 GPU machine with gpt2-large:</span>
model = GPT2LMHeadModel.from_pretrained(<span class="hljs-string">&quot;gpt2-large&quot;</span>)
device_map = {
    <span class="hljs-number">0</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>],
    <span class="hljs-number">1</span>: [<span class="hljs-number">8</span>, <span class="hljs-number">9</span>, <span class="hljs-number">10</span>, <span class="hljs-number">11</span>, <span class="hljs-number">12</span>, <span class="hljs-number">13</span>, <span class="hljs-number">14</span>, <span class="hljs-number">15</span>],
    <span class="hljs-number">2</span>: [<span class="hljs-number">16</span>, <span class="hljs-number">17</span>, <span class="hljs-number">18</span>, <span class="hljs-number">19</span>, <span class="hljs-number">20</span>, <span class="hljs-number">21</span>, <span class="hljs-number">22</span>, <span class="hljs-number">23</span>],
    <span class="hljs-number">3</span>: [<span class="hljs-number">24</span>, <span class="hljs-number">25</span>, <span class="hljs-number">26</span>, <span class="hljs-number">27</span>, <span class="hljs-number">28</span>, <span class="hljs-number">29</span>, <span class="hljs-number">30</span>, <span class="hljs-number">31</span>, <span class="hljs-number">32</span>, <span class="hljs-number">33</span>, <span class="hljs-number">34</span>, <span class="hljs-number">35</span>],
}
model.parallelize(device_map)  <span class="hljs-comment"># Splits the model across several devices</span>
model.deparallelize()  <span class="hljs-comment"># Put the model back on cpu and cleans memory by calling torch.cuda.empty_cache()</span>`}}),{c(){d=a("p"),v=n("Example:"),u=p(),y(m.$$.fragment)},l(l){d=r(l,"P",{});var c=i(d);v=s(c,"Example:"),c.forEach(t),u=h(l),k(m.$$.fragment,l)},m(l,c){g(l,d,c),e(d,v),g(l,u,c),w(m,l,c),T=!0},p:de,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(u),G(m,l)}}}function uw(M){let d,v,u,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 "),u=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 c=i(d);v=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=r(c,"CODE",{});var z=i(u);m=s(z,"Module"),z.forEach(t),T=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(t)},m(l,c){g(l,d,c),e(d,v),e(d,u),e(u,m),e(d,T)},d(l){l&&t(d)}}}function mw(M){let d,v,u,m,T;return m=new ce({props:{code:`import torch
from transformers import GPT2Tokenizer, GPT2LMHeadModel

tokenizer = GPT2Tokenizer.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> GPT2Tokenizer, GPT2LMHeadModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>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:"),u=p(),y(m.$$.fragment)},l(l){d=r(l,"P",{});var c=i(d);v=s(c,"Example:"),c.forEach(t),u=h(l),k(m.$$.fragment,l)},m(l,c){g(l,d,c),e(d,v),g(l,u,c),w(m,l,c),T=!0},p:de,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(u),G(m,l)}}}function fw(M){let d,v,u,m,T;return m=new ce({props:{code:`# Here is an example of a device map on a machine with 4 GPUs using gpt2-xl, which has a total of 48 attention modules:
model = GPT2LMHeadModel.from_pretrained("gpt2-xl")
device_map = {
    0: [0, 1, 2, 3, 4, 5, 6, 7, 8],
    1: [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],
    2: [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34],
    3: [35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47],
}
model.parallelize(device_map)`,highlighted:`<span class="hljs-comment"># Here is an example of a device map on a machine with 4 GPUs using gpt2-xl, which has a total of 48 attention modules:</span>
model = GPT2LMHeadModel.from_pretrained(<span class="hljs-string">&quot;gpt2-xl&quot;</span>)
device_map = {
    <span class="hljs-number">0</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>],
    <span class="hljs-number">1</span>: [<span class="hljs-number">9</span>, <span class="hljs-number">10</span>, <span class="hljs-number">11</span>, <span class="hljs-number">12</span>, <span class="hljs-number">13</span>, <span class="hljs-number">14</span>, <span class="hljs-number">15</span>, <span class="hljs-number">16</span>, <span class="hljs-number">17</span>, <span class="hljs-number">18</span>, <span class="hljs-number">19</span>, <span class="hljs-number">20</span>, <span class="hljs-number">21</span>],
    <span class="hljs-number">2</span>: [<span class="hljs-number">22</span>, <span class="hljs-number">23</span>, <span class="hljs-number">24</span>, <span class="hljs-number">25</span>, <span class="hljs-number">26</span>, <span class="hljs-number">27</span>, <span class="hljs-number">28</span>, <span class="hljs-number">29</span>, <span class="hljs-number">30</span>, <span class="hljs-number">31</span>, <span class="hljs-number">32</span>, <span class="hljs-number">33</span>, <span class="hljs-number">34</span>],
    <span class="hljs-number">3</span>: [<span class="hljs-number">35</span>, <span class="hljs-number">36</span>, <span class="hljs-number">37</span>, <span class="hljs-number">38</span>, <span class="hljs-number">39</span>, <span class="hljs-number">40</span>, <span class="hljs-number">41</span>, <span class="hljs-number">42</span>, <span class="hljs-number">43</span>, <span class="hljs-number">44</span>, <span class="hljs-number">45</span>, <span class="hljs-number">46</span>, <span class="hljs-number">47</span>],
}
model.parallelize(device_map)`}}),{c(){d=a("p"),v=n("Example:"),u=p(),y(m.$$.fragment)},l(l){d=r(l,"P",{});var c=i(d);v=s(c,"Example:"),c.forEach(t),u=h(l),k(m.$$.fragment,l)},m(l,c){g(l,d,c),e(d,v),g(l,u,c),w(m,l,c),T=!0},p:de,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(u),G(m,l)}}}function gw(M){let d,v,u,m,T;return m=new ce({props:{code:`# On a 4 GPU machine with gpt2-large:
model = GPT2LMHeadModel.from_pretrained("gpt2-large")
device_map = {
    0: [0, 1, 2, 3, 4, 5, 6, 7],
    1: [8, 9, 10, 11, 12, 13, 14, 15],
    2: [16, 17, 18, 19, 20, 21, 22, 23],
    3: [24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35],
}
model.parallelize(device_map)  # Splits the model across several devices
model.deparallelize()  # Put the model back on cpu and cleans memory by calling torch.cuda.empty_cache()`,highlighted:`<span class="hljs-comment"># On a 4 GPU machine with gpt2-large:</span>
model = GPT2LMHeadModel.from_pretrained(<span class="hljs-string">&quot;gpt2-large&quot;</span>)
device_map = {
    <span class="hljs-number">0</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>],
    <span class="hljs-number">1</span>: [<span class="hljs-number">8</span>, <span class="hljs-number">9</span>, <span class="hljs-number">10</span>, <span class="hljs-number">11</span>, <span class="hljs-number">12</span>, <span class="hljs-number">13</span>, <span class="hljs-number">14</span>, <span class="hljs-number">15</span>],
    <span class="hljs-number">2</span>: [<span class="hljs-number">16</span>, <span class="hljs-number">17</span>, <span class="hljs-number">18</span>, <span class="hljs-number">19</span>, <span class="hljs-number">20</span>, <span class="hljs-number">21</span>, <span class="hljs-number">22</span>, <span class="hljs-number">23</span>],
    <span class="hljs-number">3</span>: [<span class="hljs-number">24</span>, <span class="hljs-number">25</span>, <span class="hljs-number">26</span>, <span class="hljs-number">27</span>, <span class="hljs-number">28</span>, <span class="hljs-number">29</span>, <span class="hljs-number">30</span>, <span class="hljs-number">31</span>, <span class="hljs-number">32</span>, <span class="hljs-number">33</span>, <span class="hljs-number">34</span>, <span class="hljs-number">35</span>],
}
model.parallelize(device_map)  <span class="hljs-comment"># Splits the model across several devices</span>
model.deparallelize()  <span class="hljs-comment"># Put the model back on cpu and cleans memory by calling torch.cuda.empty_cache()</span>`}}),{c(){d=a("p"),v=n("Example:"),u=p(),y(m.$$.fragment)},l(l){d=r(l,"P",{});var c=i(d);v=s(c,"Example:"),c.forEach(t),u=h(l),k(m.$$.fragment,l)},m(l,c){g(l,d,c),e(d,v),g(l,u,c),w(m,l,c),T=!0},p:de,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(u),G(m,l)}}}function _w(M){let d,v,u,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 "),u=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 c=i(d);v=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=r(c,"CODE",{});var z=i(u);m=s(z,"Module"),z.forEach(t),T=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(t)},m(l,c){g(l,d,c),e(d,v),e(d,u),e(u,m),e(d,T)},d(l){l&&t(d)}}}function Tw(M){let d,v,u,m,T;return m=new ce({props:{code:`import torch
from transformers import GPT2Tokenizer, GPT2DoubleHeadsModel

tokenizer = GPT2Tokenizer.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> GPT2Tokenizer, GPT2DoubleHeadsModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>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:"),u=p(),y(m.$$.fragment)},l(l){d=r(l,"P",{});var c=i(d);v=s(c,"Example:"),c.forEach(t),u=h(l),k(m.$$.fragment,l)},m(l,c){g(l,d,c),e(d,v),g(l,u,c),w(m,l,c),T=!0},p:de,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(u),G(m,l)}}}function vw(M){let d,v,u,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 "),u=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 c=i(d);v=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=r(c,"CODE",{});var z=i(u);m=s(z,"Module"),z.forEach(t),T=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(t)},m(l,c){g(l,d,c),e(d,v),e(d,u),e(u,m),e(d,T)},d(l){l&&t(d)}}}function bw(M){let d,v,u,m,T;return m=new ce({props:{code:`import torch
from transformers import GPT2Tokenizer, GPT2ForSequenceClassification

tokenizer = GPT2Tokenizer.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()
model.config.id2label[predicted_class_id]`,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> GPT2Tokenizer, GPT2ForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.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>model.config.id2label[predicted_class_id]
<span class="hljs-string">&#x27;LABEL_0&#x27;</span>`}}),{c(){d=a("p"),v=n("Example of single-label classification:"),u=p(),y(m.$$.fragment)},l(l){d=r(l,"P",{});var c=i(d);v=s(c,"Example of single-label classification:"),c.forEach(t),u=h(l),k(m.$$.fragment,l)},m(l,c){g(l,d,c),e(d,v),g(l,u,c),w(m,l,c),T=!0},p:de,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(u),G(m,l)}}}function yw(M){let d,v;return d=new ce({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 = GPT2ForSequenceClassification.from_pretrained("microsoft/DialogRPT-updown", num_labels=num_labels)\n\nlabels = torch.tensor([1])\nloss = model(**inputs, labels=labels).loss\nround(loss.item(), 2)',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>
<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
<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">5.28</span>`}}),{c(){y(d.$$.fragment)},l(u){k(d.$$.fragment,u)},m(u,m){w(d,u,m),v=!0},p:de,i(u){v||($(d.$$.fragment,u),v=!0)},o(u){P(d.$$.fragment,u),v=!1},d(u){G(d,u)}}}function kw(M){let d,v,u,m,T;return m=new ce({props:{code:`import torch
from transformers import GPT2Tokenizer, GPT2ForSequenceClassification

tokenizer = GPT2Tokenizer.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_id = logits.argmax().item()
model.config.id2label[predicted_class_id]`,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> GPT2Tokenizer, GPT2ForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.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_id = logits.argmax().item()
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.id2label[predicted_class_id]
<span class="hljs-string">&#x27;LABEL_0&#x27;</span>`}}),{c(){d=a("p"),v=n("Example of multi-label classification:"),u=p(),y(m.$$.fragment)},l(l){d=r(l,"P",{});var c=i(d);v=s(c,"Example of multi-label classification:"),c.forEach(t),u=h(l),k(m.$$.fragment,l)},m(l,c){g(l,d,c),e(d,v),g(l,u,c),w(m,l,c),T=!0},p:de,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(u),G(m,l)}}}function ww(M){let d,v;return d=new ce({props:{code:`# 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.nn.functional.one_hot(torch.tensor([predicted_class_id]), num_classes=num_labels).to(
    torch.float
)
loss = model(**inputs, labels=labels).loss
loss.backward()`,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>
<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.nn.functional.one_hot(torch.tensor([predicted_class_id]), num_classes=num_labels).to(
<span class="hljs-meta">... </span>    torch.<span class="hljs-built_in">float</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = model(**inputs, labels=labels).loss
<span class="hljs-meta">&gt;&gt;&gt; </span>loss.backward()`}}),{c(){y(d.$$.fragment)},l(u){k(d.$$.fragment,u)},m(u,m){w(d,u,m),v=!0},p:de,i(u){v||($(d.$$.fragment,u),v=!0)},o(u){P(d.$$.fragment,u),v=!1},d(u){G(d,u)}}}function $w(M){let d,v,u,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 "),u=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 c=i(d);v=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=r(c,"CODE",{});var z=i(u);m=s(z,"Module"),z.forEach(t),T=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(t)},m(l,c){g(l,d,c),e(d,v),e(d,u),e(u,m),e(d,T)},d(l){l&&t(d)}}}function Pw(M){let d,v,u,m,T;return m=new ce({props:{code:`from transformers import GPT2Tokenizer, GPT2ForTokenClassification
import torch

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

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

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

tokenizer = GPT2Tokenizer.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> GPT2Tokenizer, TFGPT2DoubleHeadsModel

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

tokenizer = GPT2Tokenizer.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])
model.config.id2label[predicted_class_id]
`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer, 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 = GPT2Tokenizer.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>])
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.id2label[predicted_class_id]
`}}),{c(){d=a("p"),v=n("Example:"),u=p(),y(m.$$.fragment)},l(l){d=r(l,"P",{});var c=i(d);v=s(c,"Example:"),c.forEach(t),u=h(l),k(m.$$.fragment,l)},m(l,c){g(l,d,c),e(d,v),g(l,u,c),w(m,l,c),T=!0},p:de,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(u),G(m,l)}}}function Nw(M){let d,v;return d=new ce({props:{code:`# 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 = TFGPT2ForSequenceClassification.from_pretrained("microsoft/DialogRPT-updown", num_labels=num_labels)

labels = tf.constant(1)
loss = model(**inputs, labels=labels).loss
round(float(loss), 2)
`,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>
<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 = TFGPT2ForSequenceClassification.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 = tf.constant(<span class="hljs-number">1</span>)
<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>(<span class="hljs-built_in">float</span>(loss), <span class="hljs-number">2</span>)
`}}),{c(){y(d.$$.fragment)},l(u){k(d.$$.fragment,u)},m(u,m){w(d,u,m),v=!0},p:de,i(u){v||($(d.$$.fragment,u),v=!0)},o(u){P(d.$$.fragment,u),v=!1},d(u){G(d,u)}}}function Aw(M){let d,v,u,m,T;return m=new ce({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:"),u=p(),y(m.$$.fragment)},l(l){d=r(l,"P",{});var c=i(d);v=s(c,"Examples:"),c.forEach(t),u=h(l),k(m.$$.fragment,l)},m(l,c){g(l,d,c),e(d,v),g(l,u,c),w(m,l,c),T=!0},p:de,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(u),G(m,l)}}}function Iw(M){let d,v,u,m,T;return m=new ce({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:"),u=p(),y(m.$$.fragment)},l(l){d=r(l,"P",{});var c=i(d);v=s(c,"Examples:"),c.forEach(t),u=h(l),k(m.$$.fragment,l)},m(l,c){g(l,d,c),e(d,v),g(l,u,c),w(m,l,c),T=!0},p:de,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(u),G(m,l)}}}function Sw(M){let d,v,u,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 "),u=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 c=i(d);v=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=r(c,"CODE",{});var z=i(u);m=s(z,"Module"),z.forEach(t),T=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(t)},m(l,c){g(l,d,c),e(d,v),e(d,u),e(u,m),e(d,T)},d(l){l&&t(d)}}}function Ww(M){let d,v,u,m,T;return m=new ce({props:{code:`from transformers import GPT2Tokenizer, FlaxGPT2Model

tokenizer = GPT2Tokenizer.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> GPT2Tokenizer, FlaxGPT2Model

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>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:"),u=p(),y(m.$$.fragment)},l(l){d=r(l,"P",{});var c=i(d);v=s(c,"Example:"),c.forEach(t),u=h(l),k(m.$$.fragment,l)},m(l,c){g(l,d,c),e(d,v),g(l,u,c),w(m,l,c),T=!0},p:de,i(l){T||($(m.$$.fragment,l),T=!0)},o(l){P(m.$$.fragment,l),T=!1},d(l){l&&t(d),l&&t(u),G(m,l)}}}function Uw(M){let d,v,u,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 "),u=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 c=i(d);v=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),u=r(c,"CODE",{});var z=i(u);m=s(z,"Module"),z.forEach(t),T=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(t)},m(l,c){g(l,d,c),e(d,v),e(d,u),e(u,m),e(d,T)},d(l){l&&t(d)}}}function Bw(M){let d,v,u,m,T;return m=new ce({props:{code:`from transformers import GPT2Tokenizer, FlaxGPT2LMHeadModel

tokenizer = GPT2Tokenizer.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> GPT2Tokenizer, FlaxGPT2LMHeadModel

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