Buckets:
| import{s as Kn,o as eo,n as N}from"../chunks/scheduler.01eeda35.js";import{S as to,i as no,g as p,s as r,r as f,A as oo,h as u,f as a,c as i,j as B,u as _,x as g,k as L,l as so,y as l,a as c,v as T,d as y,t as b,w as M}from"../chunks/index.6dd51b66.js";import{T as gt}from"../chunks/Tip.de9bae2b.js";import{D as X}from"../chunks/Docstring.76e6b3cf.js";import{C as qe}from"../chunks/CodeBlock.864da1b0.js";import{F as ao,M as On}from"../chunks/Markdown.3138439e.js";import{E as ft}from"../chunks/ExampleCodeBlock.6a36fb6b.js";import{P as ro}from"../chunks/PipelineTag.5efc345e.js";import{H as re,E as io}from"../chunks/EditOnGithub.7faefd25.js";function lo(x){let e,m="Example:",o,s,k;return s=new qe({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEdQVDJDb25maWclMkMlMjBHUFQyTW9kZWwlMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwR1BUMiUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwR1BUMkNvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBHUFQyTW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Config, GPT2Model | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a GPT2 configuration</span> | |
| <span class="hljs-meta">>>> </span>configuration = GPT2Config() | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a model (with random weights) from the configuration</span> | |
| <span class="hljs-meta">>>> </span>model = GPT2Model(configuration) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Accessing the model configuration</span> | |
| <span class="hljs-meta">>>> </span>configuration = model.config`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-11lpom8"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function co(x){let e,m="be encoded differently whether it is at the beginning of the sentence (without space) or not:",o,s,k;return s=new qe({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEdQVDJUb2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBHUFQyVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJvcGVuYWktY29tbXVuaXR5JTJGZ3B0MiUyMiklMEF0b2tlbml6ZXIoJTIySGVsbG8lMjB3b3JsZCUyMiklNUIlMjJpbnB1dF9pZHMlMjIlNUQlMEElMEF0b2tlbml6ZXIoJTIyJTIwSGVsbG8lMjB3b3JsZCUyMiklNUIlMjJpbnB1dF9pZHMlMjIlNUQ=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer | |
| <span class="hljs-meta">>>> </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>tokenizer(<span class="hljs-string">"Hello world"</span>)[<span class="hljs-string">"input_ids"</span>] | |
| [<span class="hljs-number">15496</span>, <span class="hljs-number">995</span>] | |
| <span class="hljs-meta">>>> </span>tokenizer(<span class="hljs-string">" Hello world"</span>)[<span class="hljs-string">"input_ids"</span>] | |
| [<span class="hljs-number">18435</span>, <span class="hljs-number">995</span>]`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-12atnao"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function po(x){let e,m="When used with <code>is_split_into_words=True</code>, this tokenizer will add a space before each word (even the first one).";return{c(){e=p("p"),e.innerHTML=m},l(o){e=u(o,"P",{"data-svelte-h":!0}),g(e)!=="svelte-jhmxzm"&&(e.innerHTML=m)},m(o,s){c(o,e,s)},p:N,d(o){o&&a(e)}}}function uo(x){let e,m="be encoded differently whether it is at the beginning of the sentence (without space) or not:",o,s,k;return s=new qe({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEdQVDJUb2tlbml6ZXJGYXN0JTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwR1BUMlRva2VuaXplckZhc3QuZnJvbV9wcmV0cmFpbmVkKCUyMm9wZW5haS1jb21tdW5pdHklMkZncHQyJTIyKSUwQXRva2VuaXplciglMjJIZWxsbyUyMHdvcmxkJTIyKSU1QiUyMmlucHV0X2lkcyUyMiU1RCUwQSUwQXRva2VuaXplciglMjIlMjBIZWxsbyUyMHdvcmxkJTIyKSU1QiUyMmlucHV0X2lkcyUyMiU1RA==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2TokenizerFast | |
| <span class="hljs-meta">>>> </span>tokenizer = GPT2TokenizerFast.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>tokenizer(<span class="hljs-string">"Hello world"</span>)[<span class="hljs-string">"input_ids"</span>] | |
| [<span class="hljs-number">15496</span>, <span class="hljs-number">995</span>] | |
| <span class="hljs-meta">>>> </span>tokenizer(<span class="hljs-string">" Hello world"</span>)[<span class="hljs-string">"input_ids"</span>] | |
| [<span class="hljs-number">18435</span>, <span class="hljs-number">995</span>]`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-12atnao"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function mo(x){let e,m="When used with <code>is_split_into_words=True</code>, this tokenizer needs to be instantiated with <code>add_prefix_space=True</code>.";return{c(){e=p("p"),e.innerHTML=m},l(o){e=u(o,"P",{"data-svelte-h":!0}),g(e)!=="svelte-9gg91e"&&(e.innerHTML=m)},m(o,s){c(o,e,s)},p:N,d(o){o&&a(e)}}}function ho(x){let e,m=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code> | |
| instance afterwards instead of this since the former takes care of running the pre and post processing steps while | |
| the latter silently ignores them.`;return{c(){e=p("p"),e.innerHTML=m},l(o){e=u(o,"P",{"data-svelte-h":!0}),g(e)!=="svelte-fincs2"&&(e.innerHTML=m)},m(o,s){c(o,e,s)},p:N,d(o){o&&a(e)}}}function go(x){let e,m="Example:",o,s,k;return s=new qe({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBHUFQyTW9kZWwlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMm9wZW5haS1jb21tdW5pdHklMkZncHQyJTIyKSUwQW1vZGVsJTIwJTNEJTIwR1BUMk1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJvcGVuYWktY29tbXVuaXR5JTJGZ3B0MiUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIySGVsbG8lMkMlMjBteSUyMGRvZyUyMGlzJTIwY3V0ZSUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQSUwQWxhc3RfaGlkZGVuX3N0YXRlcyUyMCUzRCUyMG91dHB1dHMubGFzdF9oaWRkZW5fc3RhdGU=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, GPT2Model | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>model = GPT2Model.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>inputs = tokenizer(<span class="hljs-string">"Hello, my dog is cute"</span>, return_tensors=<span class="hljs-string">"pt"</span>) | |
| <span class="hljs-meta">>>> </span>outputs = model(**inputs) | |
| <span class="hljs-meta">>>> </span>last_hidden_states = outputs.last_hidden_state`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-11lpom8"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function fo(x){let e,m=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code> | |
| instance afterwards instead of this since the former takes care of running the pre and post processing steps while | |
| the latter silently ignores them.`;return{c(){e=p("p"),e.innerHTML=m},l(o){e=u(o,"P",{"data-svelte-h":!0}),g(e)!=="svelte-fincs2"&&(e.innerHTML=m)},m(o,s){c(o,e,s)},p:N,d(o){o&&a(e)}}}function _o(x){let e,m="Example:",o,s,k;return s=new qe({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMEdQVDJMTUhlYWRNb2RlbCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMm9wZW5haS1jb21tdW5pdHklMkZncHQyJTIyKSUwQW1vZGVsJTIwJTNEJTIwR1BUMkxNSGVhZE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJvcGVuYWktY29tbXVuaXR5JTJGZ3B0MiUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIySGVsbG8lMkMlMjBteSUyMGRvZyUyMGlzJTIwY3V0ZSUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzJTJDJTIwbGFiZWxzJTNEaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVEKSUwQWxvc3MlMjAlM0QlMjBvdXRwdXRzLmxvc3MlMEFsb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cw==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, GPT2LMHeadModel | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>model = GPT2LMHeadModel.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>inputs = tokenizer(<span class="hljs-string">"Hello, my dog is cute"</span>, return_tensors=<span class="hljs-string">"pt"</span>) | |
| <span class="hljs-meta">>>> </span>outputs = model(**inputs, labels=inputs[<span class="hljs-string">"input_ids"</span>]) | |
| <span class="hljs-meta">>>> </span>loss = outputs.loss | |
| <span class="hljs-meta">>>> </span>logits = outputs.logits`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-11lpom8"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function To(x){let e,m=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code> | |
| instance afterwards instead of this since the former takes care of running the pre and post processing steps while | |
| the latter silently ignores them.`;return{c(){e=p("p"),e.innerHTML=m},l(o){e=u(o,"P",{"data-svelte-h":!0}),g(e)!=="svelte-fincs2"&&(e.innerHTML=m)},m(o,s){c(o,e,s)},p:N,d(o){o&&a(e)}}}function yo(x){let e,m="Example:",o,s,k;return s=new qe({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMEdQVDJEb3VibGVIZWFkc01vZGVsJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyb3BlbmFpLWNvbW11bml0eSUyRmdwdDIlMjIpJTBBbW9kZWwlMjAlM0QlMjBHUFQyRG91YmxlSGVhZHNNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyb3BlbmFpLWNvbW11bml0eSUyRmdwdDIlMjIpJTBBJTBBJTIzJTIwQWRkJTIwYSUyMCU1QkNMUyU1RCUyMHRvJTIwdGhlJTIwdm9jYWJ1bGFyeSUyMCh3ZSUyMHNob3VsZCUyMHRyYWluJTIwaXQlMjBhbHNvISklMEFudW1fYWRkZWRfdG9rZW5zJTIwJTNEJTIwdG9rZW5pemVyLmFkZF9zcGVjaWFsX3Rva2VucyglN0IlMjJjbHNfdG9rZW4lMjIlM0ElMjAlMjIlNUJDTFMlNUQlMjIlN0QpJTBBJTIzJTIwVXBkYXRlJTIwdGhlJTIwbW9kZWwlMjBlbWJlZGRpbmdzJTIwd2l0aCUyMHRoZSUyMG5ldyUyMHZvY2FidWxhcnklMjBzaXplJTBBZW1iZWRkaW5nX2xheWVyJTIwJTNEJTIwbW9kZWwucmVzaXplX3Rva2VuX2VtYmVkZGluZ3MobGVuKHRva2VuaXplcikpJTBBJTBBY2hvaWNlcyUyMCUzRCUyMCU1QiUyMkhlbGxvJTJDJTIwbXklMjBkb2clMjBpcyUyMGN1dGUlMjAlNUJDTFMlNUQlMjIlMkMlMjAlMjJIZWxsbyUyQyUyMG15JTIwY2F0JTIwaXMlMjBjdXRlJTIwJTVCQ0xTJTVEJTIyJTVEJTBBZW5jb2RlZF9jaG9pY2VzJTIwJTNEJTIwJTVCdG9rZW5pemVyLmVuY29kZShzKSUyMGZvciUyMHMlMjBpbiUyMGNob2ljZXMlNUQlMEFjbHNfdG9rZW5fbG9jYXRpb24lMjAlM0QlMjAlNUJ0b2tlbnMuaW5kZXgodG9rZW5pemVyLmNsc190b2tlbl9pZCklMjBmb3IlMjB0b2tlbnMlMjBpbiUyMGVuY29kZWRfY2hvaWNlcyU1RCUwQSUwQWlucHV0X2lkcyUyMCUzRCUyMHRvcmNoLnRlbnNvcihlbmNvZGVkX2Nob2ljZXMpLnVuc3F1ZWV6ZSgwKSUyMCUyMCUyMyUyMEJhdGNoJTIwc2l6ZSUzQSUyMDElMkMlMjBudW1iZXIlMjBvZiUyMGNob2ljZXMlM0ElMjAyJTBBbWNfdG9rZW5faWRzJTIwJTNEJTIwdG9yY2gudGVuc29yKCU1QmNsc190b2tlbl9sb2NhdGlvbiU1RCklMjAlMjAlMjMlMjBCYXRjaCUyMHNpemUlM0ElMjAxJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKGlucHV0X2lkcyUyQyUyMG1jX3Rva2VuX2lkcyUzRG1jX3Rva2VuX2lkcyklMEFsbV9sb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cyUwQW1jX2xvZ2l0cyUyMCUzRCUyMG91dHB1dHMubWNfbG9naXRz",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, GPT2DoubleHeadsModel | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>model = GPT2DoubleHeadsModel.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Add a [CLS] to the vocabulary (we should train it also!)</span> | |
| <span class="hljs-meta">>>> </span>num_added_tokens = tokenizer.add_special_tokens({<span class="hljs-string">"cls_token"</span>: <span class="hljs-string">"[CLS]"</span>}) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Update the model embeddings with the new vocabulary size</span> | |
| <span class="hljs-meta">>>> </span>embedding_layer = model.resize_token_embeddings(<span class="hljs-built_in">len</span>(tokenizer)) | |
| <span class="hljs-meta">>>> </span>choices = [<span class="hljs-string">"Hello, my dog is cute [CLS]"</span>, <span class="hljs-string">"Hello, my cat is cute [CLS]"</span>] | |
| <span class="hljs-meta">>>> </span>encoded_choices = [tokenizer.encode(s) <span class="hljs-keyword">for</span> s <span class="hljs-keyword">in</span> choices] | |
| <span class="hljs-meta">>>> </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">>>> </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">>>> </span>mc_token_ids = torch.tensor([cls_token_location]) <span class="hljs-comment"># Batch size: 1</span> | |
| <span class="hljs-meta">>>> </span>outputs = model(input_ids, mc_token_ids=mc_token_ids) | |
| <span class="hljs-meta">>>> </span>lm_logits = outputs.logits | |
| <span class="hljs-meta">>>> </span>mc_logits = outputs.mc_logits`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-11lpom8"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function bo(x){let e,m=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code> | |
| instance afterwards instead of this since the former takes care of running the pre and post processing steps while | |
| the latter silently ignores them.`;return{c(){e=p("p"),e.innerHTML=m},l(o){e=u(o,"P",{"data-svelte-h":!0}),g(e)!=="svelte-fincs2"&&(e.innerHTML=m)},m(o,s){c(o,e,s)},p:N,d(o){o&&a(e)}}}function Mo(x){let e,m=`This example uses a random model as the real ones are all very big. To get proper results, you should use | |
| openai-community/gpt2 instead of openai-community/gpt2. If you get out-of-memory when loading that checkpoint, you can try | |
| adding <code>device_map="auto"</code> in the <code>from_pretrained</code> call.`;return{c(){e=p("p"),e.innerHTML=m},l(o){e=u(o,"P",{"data-svelte-h":!0}),g(e)!=="svelte-1nao4uz"&&(e.innerHTML=m)},m(o,s){c(o,e,s)},p:N,d(o){o&&a(e)}}}function ko(x){let e,m="Example:",o,s,k;return s=new qe({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBHUFQyRm9yUXVlc3Rpb25BbnN3ZXJpbmclMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMm9wZW5haS1jb21tdW5pdHklMkZncHQyJTIyKSUwQW1vZGVsJTIwJTNEJTIwR1BUMkZvclF1ZXN0aW9uQW5zd2VyaW5nLmZyb21fcHJldHJhaW5lZCglMjJvcGVuYWktY29tbXVuaXR5JTJGZ3B0MiUyMiklMEElMEFxdWVzdGlvbiUyQyUyMHRleHQlMjAlM0QlMjAlMjJXaG8lMjB3YXMlMjBKaW0lMjBIZW5zb24lM0YlMjIlMkMlMjAlMjJKaW0lMjBIZW5zb24lMjB3YXMlMjBhJTIwbmljZSUyMHB1cHBldCUyMiUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcihxdWVzdGlvbiUyQyUyMHRleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpJTBBJTBBYW5zd2VyX3N0YXJ0X2luZGV4JTIwJTNEJTIwb3V0cHV0cy5zdGFydF9sb2dpdHMuYXJnbWF4KCklMEFhbnN3ZXJfZW5kX2luZGV4JTIwJTNEJTIwb3V0cHV0cy5lbmRfbG9naXRzLmFyZ21heCgpJTBBJTBBcHJlZGljdF9hbnN3ZXJfdG9rZW5zJTIwJTNEJTIwaW5wdXRzLmlucHV0X2lkcyU1QjAlMkMlMjBhbnN3ZXJfc3RhcnRfaW5kZXglMjAlM0ElMjBhbnN3ZXJfZW5kX2luZGV4JTIwJTJCJTIwMSU1RCUwQSUwQSUyMyUyMHRhcmdldCUyMGlzJTIwJTIybmljZSUyMHB1cHBldCUyMiUwQXRhcmdldF9zdGFydF9pbmRleCUyMCUzRCUyMHRvcmNoLnRlbnNvciglNUIxNCU1RCklMEF0YXJnZXRfZW5kX2luZGV4JTIwJTNEJTIwdG9yY2gudGVuc29yKCU1QjE1JTVEKSUwQSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyUyQyUyMHN0YXJ0X3Bvc2l0aW9ucyUzRHRhcmdldF9zdGFydF9pbmRleCUyQyUyMGVuZF9wb3NpdGlvbnMlM0R0YXJnZXRfZW5kX2luZGV4KSUwQWxvc3MlMjAlM0QlMjBvdXRwdXRzLmxvc3M=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, GPT2ForQuestionAnswering | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>model = GPT2ForQuestionAnswering.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>question, text = <span class="hljs-string">"Who was Jim Henson?"</span>, <span class="hljs-string">"Jim Henson was a nice puppet"</span> | |
| <span class="hljs-meta">>>> </span>inputs = tokenizer(question, text, return_tensors=<span class="hljs-string">"pt"</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">with</span> torch.no_grad(): | |
| <span class="hljs-meta">... </span> outputs = model(**inputs) | |
| <span class="hljs-meta">>>> </span>answer_start_index = outputs.start_logits.argmax() | |
| <span class="hljs-meta">>>> </span>answer_end_index = outputs.end_logits.argmax() | |
| <span class="hljs-meta">>>> </span>predict_answer_tokens = inputs.input_ids[<span class="hljs-number">0</span>, answer_start_index : answer_end_index + <span class="hljs-number">1</span>] | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># target is "nice puppet"</span> | |
| <span class="hljs-meta">>>> </span>target_start_index = torch.tensor([<span class="hljs-number">14</span>]) | |
| <span class="hljs-meta">>>> </span>target_end_index = torch.tensor([<span class="hljs-number">15</span>]) | |
| <span class="hljs-meta">>>> </span>outputs = model(**inputs, start_positions=target_start_index, end_positions=target_end_index) | |
| <span class="hljs-meta">>>> </span>loss = outputs.loss`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-11lpom8"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function vo(x){let e,m=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code> | |
| instance afterwards instead of this since the former takes care of running the pre and post processing steps while | |
| the latter silently ignores them.`;return{c(){e=p("p"),e.innerHTML=m},l(o){e=u(o,"P",{"data-svelte-h":!0}),g(e)!=="svelte-fincs2"&&(e.innerHTML=m)},m(o,s){c(o,e,s)},p:N,d(o){o&&a(e)}}}function wo(x){let e,m="Example of single-label classification:",o,s,k;return s=new qe({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMEdQVDJGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGRGlhbG9nUlBULXVwZG93biUyMiklMEFtb2RlbCUyMCUzRCUyMEdQVDJGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZEaWFsb2dSUFQtdXBkb3duJTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplciglMjJIZWxsbyUyQyUyMG15JTIwZG9nJTIwaXMlMjBjdXRlJTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cyUwQSUwQXByZWRpY3RlZF9jbGFzc19pZCUyMCUzRCUyMGxvZ2l0cy5hcmdtYXgoKS5pdGVtKCklMEElMEElMjMlMjBUbyUyMHRyYWluJTIwYSUyMG1vZGVsJTIwb24lMjAlNjBudW1fbGFiZWxzJTYwJTIwY2xhc3NlcyUyQyUyMHlvdSUyMGNhbiUyMHBhc3MlMjAlNjBudW1fbGFiZWxzJTNEbnVtX2xhYmVscyU2MCUyMHRvJTIwJTYwLmZyb21fcHJldHJhaW5lZCguLi4pJTYwJTBBbnVtX2xhYmVscyUyMCUzRCUyMGxlbihtb2RlbC5jb25maWcuaWQybGFiZWwpJTBBbW9kZWwlMjAlM0QlMjBHUFQyRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGRGlhbG9nUlBULXVwZG93biUyMiUyQyUyMG51bV9sYWJlbHMlM0RudW1fbGFiZWxzKSUwQSUwQWxhYmVscyUyMCUzRCUyMHRvcmNoLnRlbnNvciglNUIxJTVEKSUwQWxvc3MlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyUyQyUyMGxhYmVscyUzRGxhYmVscykubG9zcw==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, GPT2ForSequenceClassification | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"microsoft/DialogRPT-updown"</span>) | |
| <span class="hljs-meta">>>> </span>model = GPT2ForSequenceClassification.from_pretrained(<span class="hljs-string">"microsoft/DialogRPT-updown"</span>) | |
| <span class="hljs-meta">>>> </span>inputs = tokenizer(<span class="hljs-string">"Hello, my dog is cute"</span>, return_tensors=<span class="hljs-string">"pt"</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">with</span> torch.no_grad(): | |
| <span class="hljs-meta">... </span> logits = model(**inputs).logits | |
| <span class="hljs-meta">>>> </span>predicted_class_id = logits.argmax().item() | |
| <span class="hljs-meta">>>> </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">>>> </span>num_labels = <span class="hljs-built_in">len</span>(model.config.id2label) | |
| <span class="hljs-meta">>>> </span>model = GPT2ForSequenceClassification.from_pretrained(<span class="hljs-string">"microsoft/DialogRPT-updown"</span>, num_labels=num_labels) | |
| <span class="hljs-meta">>>> </span>labels = torch.tensor([<span class="hljs-number">1</span>]) | |
| <span class="hljs-meta">>>> </span>loss = model(**inputs, labels=labels).loss`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-ykxpe4"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function $o(x){let e,m="Example of multi-label classification:",o,s,k;return s=new qe({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMEdQVDJGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGRGlhbG9nUlBULXVwZG93biUyMiklMEFtb2RlbCUyMCUzRCUyMEdQVDJGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZEaWFsb2dSUFQtdXBkb3duJTIyJTJDJTIwcHJvYmxlbV90eXBlJTNEJTIybXVsdGlfbGFiZWxfY2xhc3NpZmljYXRpb24lMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMkhlbGxvJTJDJTIwbXklMjBkb2clMjBpcyUyMGN1dGUlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBJTBBcHJlZGljdGVkX2NsYXNzX2lkcyUyMCUzRCUyMHRvcmNoLmFyYW5nZSgwJTJDJTIwbG9naXRzLnNoYXBlJTVCLTElNUQpJTVCdG9yY2guc2lnbW9pZChsb2dpdHMpLnNxdWVlemUoZGltJTNEMCklMjAlM0UlMjAwLjUlNUQlMEElMEElMjMlMjBUbyUyMHRyYWluJTIwYSUyMG1vZGVsJTIwb24lMjAlNjBudW1fbGFiZWxzJTYwJTIwY2xhc3NlcyUyQyUyMHlvdSUyMGNhbiUyMHBhc3MlMjAlNjBudW1fbGFiZWxzJTNEbnVtX2xhYmVscyU2MCUyMHRvJTIwJTYwLmZyb21fcHJldHJhaW5lZCguLi4pJTYwJTBBbnVtX2xhYmVscyUyMCUzRCUyMGxlbihtb2RlbC5jb25maWcuaWQybGFiZWwpJTBBbW9kZWwlMjAlM0QlMjBHUFQyRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIybWljcm9zb2Z0JTJGRGlhbG9nUlBULXVwZG93biUyMiUyQyUyMG51bV9sYWJlbHMlM0RudW1fbGFiZWxzJTJDJTIwcHJvYmxlbV90eXBlJTNEJTIybXVsdGlfbGFiZWxfY2xhc3NpZmljYXRpb24lMjIlMEEpJTBBJTBBbGFiZWxzJTIwJTNEJTIwdG9yY2guc3VtKCUwQSUyMCUyMCUyMCUyMHRvcmNoLm5uLmZ1bmN0aW9uYWwub25lX2hvdChwcmVkaWN0ZWRfY2xhc3NfaWRzJTVCTm9uZSUyQyUyMCUzQSU1RC5jbG9uZSgpJTJDJTIwbnVtX2NsYXNzZXMlM0RudW1fbGFiZWxzKSUyQyUyMGRpbSUzRDElMEEpLnRvKHRvcmNoLmZsb2F0KSUwQWxvc3MlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyUyQyUyMGxhYmVscyUzRGxhYmVscykubG9zcw==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, GPT2ForSequenceClassification | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"microsoft/DialogRPT-updown"</span>) | |
| <span class="hljs-meta">>>> </span>model = GPT2ForSequenceClassification.from_pretrained(<span class="hljs-string">"microsoft/DialogRPT-updown"</span>, problem_type=<span class="hljs-string">"multi_label_classification"</span>) | |
| <span class="hljs-meta">>>> </span>inputs = tokenizer(<span class="hljs-string">"Hello, my dog is cute"</span>, return_tensors=<span class="hljs-string">"pt"</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">with</span> torch.no_grad(): | |
| <span class="hljs-meta">... </span> logits = model(**inputs).logits | |
| <span class="hljs-meta">>>> </span>predicted_class_ids = torch.arange(<span class="hljs-number">0</span>, logits.shape[-<span class="hljs-number">1</span>])[torch.sigmoid(logits).squeeze(dim=<span class="hljs-number">0</span>) > <span class="hljs-number">0.5</span>] | |
| <span class="hljs-meta">>>> </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">>>> </span>num_labels = <span class="hljs-built_in">len</span>(model.config.id2label) | |
| <span class="hljs-meta">>>> </span>model = GPT2ForSequenceClassification.from_pretrained( | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"microsoft/DialogRPT-updown"</span>, num_labels=num_labels, problem_type=<span class="hljs-string">"multi_label_classification"</span> | |
| <span class="hljs-meta">... </span>) | |
| <span class="hljs-meta">>>> </span>labels = torch.<span class="hljs-built_in">sum</span>( | |
| <span class="hljs-meta">... </span> torch.nn.functional.one_hot(predicted_class_ids[<span class="hljs-literal">None</span>, :].clone(), num_classes=num_labels), dim=<span class="hljs-number">1</span> | |
| <span class="hljs-meta">... </span>).to(torch.<span class="hljs-built_in">float</span>) | |
| <span class="hljs-meta">>>> </span>loss = model(**inputs, labels=labels).loss`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-1l8e32d"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function xo(x){let e,m=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code> | |
| instance afterwards instead of this since the former takes care of running the pre and post processing steps while | |
| the latter silently ignores them.`;return{c(){e=p("p"),e.innerHTML=m},l(o){e=u(o,"P",{"data-svelte-h":!0}),g(e)!=="svelte-fincs2"&&(e.innerHTML=m)},m(o,s){c(o,e,s)},p:N,d(o){o&&a(e)}}}function Go(x){let e,m="Example:",o,s,k;return s=new qe({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBHUFQyRm9yVG9rZW5DbGFzc2lmaWNhdGlvbiUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyYnJhZDExNDElMkZncHQyLWZpbmV0dW5lZC1jb21wMiUyMiklMEFtb2RlbCUyMCUzRCUyMEdQVDJGb3JUb2tlbkNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJicmFkMTE0MSUyRmdwdDItZmluZXR1bmVkLWNvbXAyJTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplciglMEElMjAlMjAlMjAlMjAlMjJIdWdnaW5nRmFjZSUyMGlzJTIwYSUyMGNvbXBhbnklMjBiYXNlZCUyMGluJTIwUGFyaXMlMjBhbmQlMjBOZXclMjBZb3JrJTIyJTJDJTIwYWRkX3NwZWNpYWxfdG9rZW5zJTNERmFsc2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTBBKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBJTBBcHJlZGljdGVkX3Rva2VuX2NsYXNzX2lkcyUyMCUzRCUyMGxvZ2l0cy5hcmdtYXgoLTEpJTBBJTBBJTIzJTIwTm90ZSUyMHRoYXQlMjB0b2tlbnMlMjBhcmUlMjBjbGFzc2lmaWVkJTIwcmF0aGVyJTIwdGhlbiUyMGlucHV0JTIwd29yZHMlMjB3aGljaCUyMG1lYW5zJTIwdGhhdCUwQSUyMyUyMHRoZXJlJTIwbWlnaHQlMjBiZSUyMG1vcmUlMjBwcmVkaWN0ZWQlMjB0b2tlbiUyMGNsYXNzZXMlMjB0aGFuJTIwd29yZHMuJTBBJTIzJTIwTXVsdGlwbGUlMjB0b2tlbiUyMGNsYXNzZXMlMjBtaWdodCUyMGFjY291bnQlMjBmb3IlMjB0aGUlMjBzYW1lJTIwd29yZCUwQXByZWRpY3RlZF90b2tlbnNfY2xhc3NlcyUyMCUzRCUyMCU1Qm1vZGVsLmNvbmZpZy5pZDJsYWJlbCU1QnQuaXRlbSgpJTVEJTIwZm9yJTIwdCUyMGluJTIwcHJlZGljdGVkX3Rva2VuX2NsYXNzX2lkcyU1QjAlNUQlNUQlMEFwcmVkaWN0ZWRfdG9rZW5zX2NsYXNzZXMlMEElMEFsYWJlbHMlMjAlM0QlMjBwcmVkaWN0ZWRfdG9rZW5fY2xhc3NfaWRzJTBBbG9zcyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzJTJDJTIwbGFiZWxzJTNEbGFiZWxzKS5sb3NzJTBBcm91bmQobG9zcy5pdGVtKCklMkMlMjAyKQ==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, GPT2ForTokenClassification | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"brad1141/gpt2-finetuned-comp2"</span>) | |
| <span class="hljs-meta">>>> </span>model = GPT2ForTokenClassification.from_pretrained(<span class="hljs-string">"brad1141/gpt2-finetuned-comp2"</span>) | |
| <span class="hljs-meta">>>> </span>inputs = tokenizer( | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"HuggingFace is a company based in Paris and New York"</span>, add_special_tokens=<span class="hljs-literal">False</span>, return_tensors=<span class="hljs-string">"pt"</span> | |
| <span class="hljs-meta">... </span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">with</span> torch.no_grad(): | |
| <span class="hljs-meta">... </span> logits = model(**inputs).logits | |
| <span class="hljs-meta">>>> </span>predicted_token_class_ids = logits.argmax(-<span class="hljs-number">1</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Note that tokens are classified rather then input words which means that</span> | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># there might be more predicted token classes than words.</span> | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Multiple token classes might account for the same word</span> | |
| <span class="hljs-meta">>>> </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">>>> </span>predicted_tokens_classes | |
| [<span class="hljs-string">'Lead'</span>, <span class="hljs-string">'Lead'</span>, <span class="hljs-string">'Lead'</span>, <span class="hljs-string">'Position'</span>, <span class="hljs-string">'Lead'</span>, <span class="hljs-string">'Lead'</span>, <span class="hljs-string">'Lead'</span>, <span class="hljs-string">'Lead'</span>, <span class="hljs-string">'Lead'</span>, <span class="hljs-string">'Lead'</span>, <span class="hljs-string">'Lead'</span>, <span class="hljs-string">'Lead'</span>] | |
| <span class="hljs-meta">>>> </span>labels = predicted_token_class_ids | |
| <span class="hljs-meta">>>> </span>loss = model(**inputs, labels=labels).loss | |
| <span class="hljs-meta">>>> </span><span class="hljs-built_in">round</span>(loss.item(), <span class="hljs-number">2</span>) | |
| <span class="hljs-number">0.25</span>`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-11lpom8"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function Po(x){let e,m,o,s,k,t,w="The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top.",be,z,C=`This model inherits from <a href="/docs/transformers/pr_36839/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. 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.)`,ue,F,J=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass. | |
| Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage | |
| and behavior.`,me,v,j,ve,ie,gn='The <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2Model">GPT2Model</a> forward method, overrides the <code>__call__</code> special method.',lt,O,_t,Me,je,Ze,Tt,W,Ae,q,Le,dt=`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input | |
| embeddings).`,Ce,S,Ne=`This model inherits from <a href="/docs/transformers/pr_36839/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. 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.)`,Ct,Ee,Ft=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass. | |
| Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage | |
| and behavior.`,ct,ae,pt,$e,et,Fe='The <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2LMHeadModel">GPT2LMHeadModel</a> forward method, overrides the <code>__call__</code> special method.',ze,xe,Qe,yt,tt,fe,At,H,he,nt,ke,ge=`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).`,Je,Be,bt=`This model inherits from <a href="/docs/transformers/pr_36839/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. 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.)`,Ue,ot,P=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass. | |
| Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage | |
| and behavior.`,U,V,R,He,Ve,en='The <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a> forward method, overrides the <code>__call__</code> special method.',fn,le,It,st,tn,Et,qt,_e,Zt,at,Lt,Mt=`The GPT-2 Model transformer with a span classification head on top for extractive question-answering tasks like | |
| SQuAD (a linear layer on top of the hidden-states output to compute <code>span start logits</code> and <code>span end logits</code>).`,kn,D,kt=`This model inherits from <a href="/docs/transformers/pr_36839/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. 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.)`,Cn,vt,dn=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass. | |
| Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage | |
| and behavior.`,_n,de,cn,Tn,De,Fn='The <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2ForQuestionAnswering">GPT2ForQuestionAnswering</a> forward method, overrides the <code>__call__</code> special method.',Qt,wt,vn,rt,Dt,ut,wn,Oe,Nt,I,We,zn,$t,pn="The GPT2 Model transformer with a sequence classification head on top (linear layer).",yn,ce,nn=`<a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2ForSequenceClassification">GPT2ForSequenceClassification</a> uses the last token in order to do the classification, as other causal models | |
| (e.g. GPT-1) do.`,Bt,zt,on=`Since it does classification on the last token, it requires to know the position of the last token. If a | |
| <code>pad_token_id</code> is defined in the configuration, it finds the last token that is not a padding token in each row. If | |
| no <code>pad_token_id</code> is defined, it simply takes the last value in each row of the batch. Since it cannot guess the | |
| padding tokens when <code>inputs_embeds</code> are passed instead of <code>input_ids</code>, it does the same (take the last value in | |
| each row of the batch).`,bn,Ye,Jn=`This model inherits from <a href="/docs/transformers/pr_36839/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. Check the superclass documentation for the generic methods the | |
| library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads | |
| etc.)`,Jt,Ie,$n=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass. | |
| Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage | |
| and behavior.`,xt,Re,A,mt,Ot,Te='The <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2ForSequenceClassification">GPT2ForSequenceClassification</a> forward method, overrides the <code>__call__</code> special method.',sn,Vt,Ut,an,xn,Ge,Gn,Gt,Rt,ye,it,rn,Xt,Hn=`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.`,Pt,Ke,ln=`This model inherits from <a href="/docs/transformers/pr_36839/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. 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.)`,Yt,Ht,Pn=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass. | |
| Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage | |
| and behavior.`,Y,Pe,Xe,jt,un,mn='The <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2ForTokenClassification">GPT2ForTokenClassification</a> forward method, overrides the <code>__call__</code> special method.',hn,Kt,St,Se,h;return e=new re({props:{title:"GPT2Model",local:"transformers.GPT2Model",headingTag:"h2"}}),s=new X({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/pr_36839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) — 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/pr_36839/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/vr_36839/src/transformers/models/gpt2/modeling_gpt2.py#L677"}}),j=new X({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>) — | |
| <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/pr_36839/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_36839/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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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’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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_36839/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/vr_36839/src/transformers/models/gpt2/modeling_gpt2.py#L762",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_36839/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/pr_36839/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>) — 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>) — 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>) — 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>) — 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>) — 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’s cross-attention layer, after the attention softmax, used to compute the | |
| weighted average in the cross-attention heads.</p> | |
| </li> | |
| </ul> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_36839/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions" | |
| >transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p> | |
| `}}),O=new gt({props:{$$slots:{default:[ho]},$$scope:{ctx:x}}}),Me=new ft({props:{anchor:"transformers.GPT2Model.forward.example",$$slots:{default:[go]},$$scope:{ctx:x}}}),Ze=new re({props:{title:"GPT2LMHeadModel",local:"transformers.GPT2LMHeadModel",headingTag:"h2"}}),Ae=new X({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/pr_36839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) — 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/pr_36839/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/vr_36839/src/transformers/models/gpt2/modeling_gpt2.py#L971"}}),pt=new X({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"},{name:"**kwargs",val:""}],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>) — | |
| <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/pr_36839/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_36839/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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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’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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_36839/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>) — | |
| 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/vr_36839/src/transformers/models/gpt2/modeling_gpt2.py#L1030",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_36839/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/pr_36839/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) — 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>) — 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>) — 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>) — 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>) — 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>) — 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:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_36839/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions" | |
| >transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p> | |
| `}}),xe=new gt({props:{$$slots:{default:[fo]},$$scope:{ctx:x}}}),yt=new ft({props:{anchor:"transformers.GPT2LMHeadModel.forward.example",$$slots:{default:[_o]},$$scope:{ctx:x}}}),fe=new re({props:{title:"GPT2DoubleHeadsModel",local:"transformers.GPT2DoubleHeadsModel",headingTag:"h2"}}),he=new X({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/pr_36839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) — 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/pr_36839/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/vr_36839/src/transformers/models/gpt2/modeling_gpt2.py#L1124"}}),R=new X({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>) — | |
| <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/pr_36839/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_36839/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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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’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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_36839/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) — | |
| 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>) — | |
| 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>) — | |
| 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/vr_36839/src/transformers/models/gpt2/modeling_gpt2.py#L1189",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_36839/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/pr_36839/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) — 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) — 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>) — 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>) — 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>) — 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>) — 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>) — 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:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput" | |
| >transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p> | |
| `}}),le=new gt({props:{$$slots:{default:[To]},$$scope:{ctx:x}}}),st=new ft({props:{anchor:"transformers.GPT2DoubleHeadsModel.forward.example",$$slots:{default:[yo]},$$scope:{ctx:x}}}),Et=new re({props:{title:"GPT2ForQuestionAnswering",local:"transformers.GPT2ForQuestionAnswering",headingTag:"h2"}}),Zt=new X({props:{name:"class transformers.GPT2ForQuestionAnswering",anchor:"transformers.GPT2ForQuestionAnswering",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.GPT2ForQuestionAnswering.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) — 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/pr_36839/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/vr_36839/src/transformers/models/gpt2/modeling_gpt2.py#L1560"}}),cn=new X({props:{name:"forward",anchor:"transformers.GPT2ForQuestionAnswering.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"start_positions",val:": typing.Optional[torch.LongTensor] = None"},{name:"end_positions",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.GPT2ForQuestionAnswering.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>) — | |
| <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/pr_36839/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_36839/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.GPT2ForQuestionAnswering.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code> of length <code>config.n_layers</code>) — | |
| Contains precomputed hidden-states (key and values in the attention blocks) as computed by the model (see | |
| <code>past_key_values</code> output below). Can be used to speed up sequential decoding. The <code>input_ids</code> which have | |
| their past given to this model should not be passed as <code>input_ids</code> as they have already been computed.`,name:"past_key_values"},{anchor:"transformers.GPT2ForQuestionAnswering.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p> | |
| <ul> | |
| <li>1 for tokens that are <strong>not masked</strong>,</li> | |
| <li>0 for tokens that are <strong>masked</strong>.</li> | |
| </ul> | |
| <p>If <code>past_key_values</code> is used, <code>attention_mask</code> needs to contain the masking strategy that was used for | |
| <code>past_key_values</code>. In other words, the <code>attention_mask</code> always has to have the length: | |
| <code>len(past_key_values) + len(input_ids)</code></p> | |
| <p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.GPT2ForQuestionAnswering.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, input_ids_length)</code>, <em>optional</em>) — | |
| Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p> | |
| <ul> | |
| <li>0 corresponds to a <em>sentence A</em> token,</li> | |
| <li>1 corresponds to a <em>sentence B</em> token.</li> | |
| </ul> | |
| <p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.GPT2ForQuestionAnswering.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) — | |
| Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p> | |
| <p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.GPT2ForQuestionAnswering.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) — | |
| Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p> | |
| <ul> | |
| <li>1 indicates the head is <strong>not masked</strong>,</li> | |
| <li>0 indicates the head is <strong>masked</strong>.</li> | |
| </ul>`,name:"head_mask"},{anchor:"transformers.GPT2ForQuestionAnswering.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) — | |
| 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’s internal embedding lookup matrix.</p> | |
| <p>If <code>past_key_values</code> is used, optionally only the last <code>inputs_embeds</code> have to be input (see | |
| <code>past_key_values</code>).`,name:"inputs_embeds"},{anchor:"transformers.GPT2ForQuestionAnswering.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) — | |
| If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see | |
| <code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.GPT2ForQuestionAnswering.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned | |
| tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.GPT2ForQuestionAnswering.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for | |
| more detail.`,name:"output_hidden_states"},{anchor:"transformers.GPT2ForQuestionAnswering.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_36839/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.GPT2ForQuestionAnswering.forward.start_positions",description:`<strong>start_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) — | |
| Labels for position (index) of the start of the labelled span for computing the token classification loss. | |
| Positions are clamped to the length of the sequence (<code>sequence_length</code>). Position outside of the sequence | |
| are not taken into account for computing the loss.`,name:"start_positions"},{anchor:"transformers.GPT2ForQuestionAnswering.forward.end_positions",description:`<strong>end_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) — | |
| Labels for position (index) of the end of the labelled span for computing the token classification loss. | |
| Positions are clamped to the length of the sequence (<code>sequence_length</code>). Position outside of the sequence | |
| are not taken into account for computing the loss.`,name:"end_positions"}],source:"https://github.com/huggingface/transformers/blob/vr_36839/src/transformers/models/gpt2/modeling_gpt2.py#L1581",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_36839/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput" | |
| >transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or a tuple of | |
| <code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various | |
| elements depending on the configuration (<a | |
| href="/docs/transformers/pr_36839/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) — Total span extraction loss is the sum of a Cross-Entropy for the start and end positions.</p> | |
| </li> | |
| <li> | |
| <p><strong>start_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) — Span-start scores (before SoftMax).</p> | |
| </li> | |
| <li> | |
| <p><strong>end_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) — Span-end scores (before SoftMax).</p> | |
| </li> | |
| <li> | |
| <p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — 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>) — 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:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_36839/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput" | |
| >transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p> | |
| `}}),wt=new gt({props:{$$slots:{default:[bo]},$$scope:{ctx:x}}}),rt=new gt({props:{warning:!0,$$slots:{default:[Mo]},$$scope:{ctx:x}}}),ut=new ft({props:{anchor:"transformers.GPT2ForQuestionAnswering.forward.example",$$slots:{default:[ko]},$$scope:{ctx:x}}}),Oe=new re({props:{title:"GPT2ForSequenceClassification",local:"transformers.GPT2ForSequenceClassification",headingTag:"h2"}}),We=new X({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/pr_36839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) — 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/pr_36839/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/vr_36839/src/transformers/models/gpt2/modeling_gpt2.py#L1317"}}),A=new X({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>) — | |
| <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/pr_36839/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_36839/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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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’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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_36839/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>) — | |
| 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 > 1</code> a classification loss is computed (Cross-Entropy).`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/vr_36839/src/transformers/models/gpt2/modeling_gpt2.py#L1346",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <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/pr_36839/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) — 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>) — 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>) — 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>) — 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>) — 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:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>transformers.modeling_outputs.SequenceClassifierOutputWithPast</code> or <code>tuple(torch.FloatTensor)</code></p> | |
| `}}),Vt=new gt({props:{$$slots:{default:[vo]},$$scope:{ctx:x}}}),an=new ft({props:{anchor:"transformers.GPT2ForSequenceClassification.forward.example",$$slots:{default:[wo]},$$scope:{ctx:x}}}),Ge=new ft({props:{anchor:"transformers.GPT2ForSequenceClassification.forward.example-2",$$slots:{default:[$o]},$$scope:{ctx:x}}}),Gt=new re({props:{title:"GPT2ForTokenClassification",local:"transformers.GPT2ForTokenClassification",headingTag:"h2"}}),it=new X({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/pr_36839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) — 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/pr_36839/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/vr_36839/src/transformers/models/gpt2/modeling_gpt2.py#L1449"}}),Xe=new X({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>) — | |
| <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/pr_36839/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_36839/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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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’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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_36839/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>) — | |
| 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 > 1</code> a classification loss is computed (Cross-Entropy).`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/vr_36839/src/transformers/models/gpt2/modeling_gpt2.py#L1478",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_36839/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/pr_36839/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) — Classification loss.</p> | |
| </li> | |
| <li> | |
| <p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.num_labels)</code>) — 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>) — 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>) — 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:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_36839/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput" | |
| >transformers.modeling_outputs.TokenClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p> | |
| `}}),Kt=new gt({props:{$$slots:{default:[xo]},$$scope:{ctx:x}}}),Se=new ft({props:{anchor:"transformers.GPT2ForTokenClassification.forward.example",$$slots:{default:[Go]},$$scope:{ctx:x}}}),{c(){f(e.$$.fragment),m=r(),o=p("div"),f(s.$$.fragment),k=r(),t=p("p"),t.textContent=w,be=r(),z=p("p"),z.innerHTML=C,ue=r(),F=p("p"),F.innerHTML=J,me=r(),v=p("div"),f(j.$$.fragment),ve=r(),ie=p("p"),ie.innerHTML=gn,lt=r(),f(O.$$.fragment),_t=r(),f(Me.$$.fragment),je=r(),f(Ze.$$.fragment),Tt=r(),W=p("div"),f(Ae.$$.fragment),q=r(),Le=p("p"),Le.textContent=dt,Ce=r(),S=p("p"),S.innerHTML=Ne,Ct=r(),Ee=p("p"),Ee.innerHTML=Ft,ct=r(),ae=p("div"),f(pt.$$.fragment),$e=r(),et=p("p"),et.innerHTML=Fe,ze=r(),f(xe.$$.fragment),Qe=r(),f(yt.$$.fragment),tt=r(),f(fe.$$.fragment),At=r(),H=p("div"),f(he.$$.fragment),nt=r(),ke=p("p"),ke.textContent=ge,Je=r(),Be=p("p"),Be.innerHTML=bt,Ue=r(),ot=p("p"),ot.innerHTML=P,U=r(),V=p("div"),f(R.$$.fragment),He=r(),Ve=p("p"),Ve.innerHTML=en,fn=r(),f(le.$$.fragment),It=r(),f(st.$$.fragment),tn=r(),f(Et.$$.fragment),qt=r(),_e=p("div"),f(Zt.$$.fragment),at=r(),Lt=p("p"),Lt.innerHTML=Mt,kn=r(),D=p("p"),D.innerHTML=kt,Cn=r(),vt=p("p"),vt.innerHTML=dn,_n=r(),de=p("div"),f(cn.$$.fragment),Tn=r(),De=p("p"),De.innerHTML=Fn,Qt=r(),f(wt.$$.fragment),vn=r(),f(rt.$$.fragment),Dt=r(),f(ut.$$.fragment),wn=r(),f(Oe.$$.fragment),Nt=r(),I=p("div"),f(We.$$.fragment),zn=r(),$t=p("p"),$t.textContent=pn,yn=r(),ce=p("p"),ce.innerHTML=nn,Bt=r(),zt=p("p"),zt.innerHTML=on,bn=r(),Ye=p("p"),Ye.innerHTML=Jn,Jt=r(),Ie=p("p"),Ie.innerHTML=$n,xt=r(),Re=p("div"),f(A.$$.fragment),mt=r(),Ot=p("p"),Ot.innerHTML=Te,sn=r(),f(Vt.$$.fragment),Ut=r(),f(an.$$.fragment),xn=r(),f(Ge.$$.fragment),Gn=r(),f(Gt.$$.fragment),Rt=r(),ye=p("div"),f(it.$$.fragment),rn=r(),Xt=p("p"),Xt.textContent=Hn,Pt=r(),Ke=p("p"),Ke.innerHTML=ln,Yt=r(),Ht=p("p"),Ht.innerHTML=Pn,Y=r(),Pe=p("div"),f(Xe.$$.fragment),jt=r(),un=p("p"),un.innerHTML=mn,hn=r(),f(Kt.$$.fragment),St=r(),f(Se.$$.fragment),this.h()},l(d){_(e.$$.fragment,d),m=i(d),o=u(d,"DIV",{class:!0});var G=B(o);_(s.$$.fragment,G),k=i(G),t=u(G,"P",{"data-svelte-h":!0}),g(t)!=="svelte-4bubxi"&&(t.textContent=w),be=i(G),z=u(G,"P",{"data-svelte-h":!0}),g(z)!=="svelte-1k92amr"&&(z.innerHTML=C),ue=i(G),F=u(G,"P",{"data-svelte-h":!0}),g(F)!=="svelte-hswkmf"&&(F.innerHTML=J),me=i(G),v=u(G,"DIV",{class:!0});var te=B(v);_(j.$$.fragment,te),ve=i(te),ie=u(te,"P",{"data-svelte-h":!0}),g(ie)!=="svelte-h0fxcp"&&(ie.innerHTML=gn),lt=i(te),_(O.$$.fragment,te),_t=i(te),_(Me.$$.fragment,te),te.forEach(a),G.forEach(a),je=i(d),_(Ze.$$.fragment,d),Tt=i(d),W=u(d,"DIV",{class:!0});var E=B(W);_(Ae.$$.fragment,E),q=i(E),Le=u(E,"P",{"data-svelte-h":!0}),g(Le)!=="svelte-jjb0s"&&(Le.textContent=dt),Ce=i(E),S=u(E,"P",{"data-svelte-h":!0}),g(S)!=="svelte-1k92amr"&&(S.innerHTML=Ne),Ct=i(E),Ee=u(E,"P",{"data-svelte-h":!0}),g(Ee)!=="svelte-hswkmf"&&(Ee.innerHTML=Ft),ct=i(E),ae=u(E,"DIV",{class:!0});var ne=B(ae);_(pt.$$.fragment,ne),$e=i(ne),et=u(ne,"P",{"data-svelte-h":!0}),g(et)!=="svelte-fbg1yx"&&(et.innerHTML=Fe),ze=i(ne),_(xe.$$.fragment,ne),Qe=i(ne),_(yt.$$.fragment,ne),ne.forEach(a),E.forEach(a),tt=i(d),_(fe.$$.fragment,d),At=i(d),H=u(d,"DIV",{class:!0});var K=B(H);_(he.$$.fragment,K),nt=i(K),ke=u(K,"P",{"data-svelte-h":!0}),g(ke)!=="svelte-1q8023u"&&(ke.textContent=ge),Je=i(K),Be=u(K,"P",{"data-svelte-h":!0}),g(Be)!=="svelte-1k92amr"&&(Be.innerHTML=bt),Ue=i(K),ot=u(K,"P",{"data-svelte-h":!0}),g(ot)!=="svelte-hswkmf"&&(ot.innerHTML=P),U=i(K),V=u(K,"DIV",{class:!0});var Q=B(V);_(R.$$.fragment,Q),He=i(Q),Ve=u(Q,"P",{"data-svelte-h":!0}),g(Ve)!=="svelte-10kqw29"&&(Ve.innerHTML=en),fn=i(Q),_(le.$$.fragment,Q),It=i(Q),_(st.$$.fragment,Q),Q.forEach(a),K.forEach(a),tn=i(d),_(Et.$$.fragment,d),qt=i(d),_e=u(d,"DIV",{class:!0});var ee=B(_e);_(Zt.$$.fragment,ee),at=i(ee),Lt=u(ee,"P",{"data-svelte-h":!0}),g(Lt)!=="svelte-11dadc6"&&(Lt.innerHTML=Mt),kn=i(ee),D=u(ee,"P",{"data-svelte-h":!0}),g(D)!=="svelte-1k92amr"&&(D.innerHTML=kt),Cn=i(ee),vt=u(ee,"P",{"data-svelte-h":!0}),g(vt)!=="svelte-hswkmf"&&(vt.innerHTML=dn),_n=i(ee),de=u(ee,"DIV",{class:!0});var pe=B(de);_(cn.$$.fragment,pe),Tn=i(pe),De=u(pe,"P",{"data-svelte-h":!0}),g(De)!=="svelte-x5awrx"&&(De.innerHTML=Fn),Qt=i(pe),_(wt.$$.fragment,pe),vn=i(pe),_(rt.$$.fragment,pe),Dt=i(pe),_(ut.$$.fragment,pe),pe.forEach(a),ee.forEach(a),wn=i(d),_(Oe.$$.fragment,d),Nt=i(d),I=u(d,"DIV",{class:!0});var Z=B(I);_(We.$$.fragment,Z),zn=i(Z),$t=u(Z,"P",{"data-svelte-h":!0}),g($t)!=="svelte-1o27avp"&&($t.textContent=pn),yn=i(Z),ce=u(Z,"P",{"data-svelte-h":!0}),g(ce)!=="svelte-116y8v9"&&(ce.innerHTML=nn),Bt=i(Z),zt=u(Z,"P",{"data-svelte-h":!0}),g(zt)!=="svelte-10ugs3m"&&(zt.innerHTML=on),bn=i(Z),Ye=u(Z,"P",{"data-svelte-h":!0}),g(Ye)!=="svelte-1k92amr"&&(Ye.innerHTML=Jn),Jt=i(Z),Ie=u(Z,"P",{"data-svelte-h":!0}),g(Ie)!=="svelte-hswkmf"&&(Ie.innerHTML=$n),xt=i(Z),Re=u(Z,"DIV",{class:!0});var oe=B(Re);_(A.$$.fragment,oe),mt=i(oe),Ot=u(oe,"P",{"data-svelte-h":!0}),g(Ot)!=="svelte-194g48t"&&(Ot.innerHTML=Te),sn=i(oe),_(Vt.$$.fragment,oe),Ut=i(oe),_(an.$$.fragment,oe),xn=i(oe),_(Ge.$$.fragment,oe),oe.forEach(a),Z.forEach(a),Gn=i(d),_(Gt.$$.fragment,d),Rt=i(d),ye=u(d,"DIV",{class:!0});var se=B(ye);_(it.$$.fragment,se),rn=i(se),Xt=u(se,"P",{"data-svelte-h":!0}),g(Xt)!=="svelte-1m7sify"&&(Xt.textContent=Hn),Pt=i(se),Ke=u(se,"P",{"data-svelte-h":!0}),g(Ke)!=="svelte-1k92amr"&&(Ke.innerHTML=ln),Yt=i(se),Ht=u(se,"P",{"data-svelte-h":!0}),g(Ht)!=="svelte-hswkmf"&&(Ht.innerHTML=Pn),Y=i(se),Pe=u(se,"DIV",{class:!0});var we=B(Pe);_(Xe.$$.fragment,we),jt=i(we),un=u(we,"P",{"data-svelte-h":!0}),g(un)!=="svelte-13wepaf"&&(un.innerHTML=mn),hn=i(we),_(Kt.$$.fragment,we),St=i(we),_(Se.$$.fragment,we),we.forEach(a),se.forEach(a),this.h()},h(){L(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(o,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(ae,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(de,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(_e,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(Re,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(Pe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(ye,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(d,G){T(e,d,G),c(d,m,G),c(d,o,G),T(s,o,null),l(o,k),l(o,t),l(o,be),l(o,z),l(o,ue),l(o,F),l(o,me),l(o,v),T(j,v,null),l(v,ve),l(v,ie),l(v,lt),T(O,v,null),l(v,_t),T(Me,v,null),c(d,je,G),T(Ze,d,G),c(d,Tt,G),c(d,W,G),T(Ae,W,null),l(W,q),l(W,Le),l(W,Ce),l(W,S),l(W,Ct),l(W,Ee),l(W,ct),l(W,ae),T(pt,ae,null),l(ae,$e),l(ae,et),l(ae,ze),T(xe,ae,null),l(ae,Qe),T(yt,ae,null),c(d,tt,G),T(fe,d,G),c(d,At,G),c(d,H,G),T(he,H,null),l(H,nt),l(H,ke),l(H,Je),l(H,Be),l(H,Ue),l(H,ot),l(H,U),l(H,V),T(R,V,null),l(V,He),l(V,Ve),l(V,fn),T(le,V,null),l(V,It),T(st,V,null),c(d,tn,G),T(Et,d,G),c(d,qt,G),c(d,_e,G),T(Zt,_e,null),l(_e,at),l(_e,Lt),l(_e,kn),l(_e,D),l(_e,Cn),l(_e,vt),l(_e,_n),l(_e,de),T(cn,de,null),l(de,Tn),l(de,De),l(de,Qt),T(wt,de,null),l(de,vn),T(rt,de,null),l(de,Dt),T(ut,de,null),c(d,wn,G),T(Oe,d,G),c(d,Nt,G),c(d,I,G),T(We,I,null),l(I,zn),l(I,$t),l(I,yn),l(I,ce),l(I,Bt),l(I,zt),l(I,bn),l(I,Ye),l(I,Jt),l(I,Ie),l(I,xt),l(I,Re),T(A,Re,null),l(Re,mt),l(Re,Ot),l(Re,sn),T(Vt,Re,null),l(Re,Ut),T(an,Re,null),l(Re,xn),T(Ge,Re,null),c(d,Gn,G),T(Gt,d,G),c(d,Rt,G),c(d,ye,G),T(it,ye,null),l(ye,rn),l(ye,Xt),l(ye,Pt),l(ye,Ke),l(ye,Yt),l(ye,Ht),l(ye,Y),l(ye,Pe),T(Xe,Pe,null),l(Pe,jt),l(Pe,un),l(Pe,hn),T(Kt,Pe,null),l(Pe,St),T(Se,Pe,null),h=!0},p(d,G){const te={};G&2&&(te.$$scope={dirty:G,ctx:d}),O.$set(te);const E={};G&2&&(E.$$scope={dirty:G,ctx:d}),Me.$set(E);const ne={};G&2&&(ne.$$scope={dirty:G,ctx:d}),xe.$set(ne);const K={};G&2&&(K.$$scope={dirty:G,ctx:d}),yt.$set(K);const Q={};G&2&&(Q.$$scope={dirty:G,ctx:d}),le.$set(Q);const ee={};G&2&&(ee.$$scope={dirty:G,ctx:d}),st.$set(ee);const pe={};G&2&&(pe.$$scope={dirty:G,ctx:d}),wt.$set(pe);const Z={};G&2&&(Z.$$scope={dirty:G,ctx:d}),rt.$set(Z);const oe={};G&2&&(oe.$$scope={dirty:G,ctx:d}),ut.$set(oe);const se={};G&2&&(se.$$scope={dirty:G,ctx:d}),Vt.$set(se);const we={};G&2&&(we.$$scope={dirty:G,ctx:d}),an.$set(we);const Mn={};G&2&&(Mn.$$scope={dirty:G,ctx:d}),Ge.$set(Mn);const In={};G&2&&(In.$$scope={dirty:G,ctx:d}),Kt.$set(In);const Un={};G&2&&(Un.$$scope={dirty:G,ctx:d}),Se.$set(Un)},i(d){h||(y(e.$$.fragment,d),y(s.$$.fragment,d),y(j.$$.fragment,d),y(O.$$.fragment,d),y(Me.$$.fragment,d),y(Ze.$$.fragment,d),y(Ae.$$.fragment,d),y(pt.$$.fragment,d),y(xe.$$.fragment,d),y(yt.$$.fragment,d),y(fe.$$.fragment,d),y(he.$$.fragment,d),y(R.$$.fragment,d),y(le.$$.fragment,d),y(st.$$.fragment,d),y(Et.$$.fragment,d),y(Zt.$$.fragment,d),y(cn.$$.fragment,d),y(wt.$$.fragment,d),y(rt.$$.fragment,d),y(ut.$$.fragment,d),y(Oe.$$.fragment,d),y(We.$$.fragment,d),y(A.$$.fragment,d),y(Vt.$$.fragment,d),y(an.$$.fragment,d),y(Ge.$$.fragment,d),y(Gt.$$.fragment,d),y(it.$$.fragment,d),y(Xe.$$.fragment,d),y(Kt.$$.fragment,d),y(Se.$$.fragment,d),h=!0)},o(d){b(e.$$.fragment,d),b(s.$$.fragment,d),b(j.$$.fragment,d),b(O.$$.fragment,d),b(Me.$$.fragment,d),b(Ze.$$.fragment,d),b(Ae.$$.fragment,d),b(pt.$$.fragment,d),b(xe.$$.fragment,d),b(yt.$$.fragment,d),b(fe.$$.fragment,d),b(he.$$.fragment,d),b(R.$$.fragment,d),b(le.$$.fragment,d),b(st.$$.fragment,d),b(Et.$$.fragment,d),b(Zt.$$.fragment,d),b(cn.$$.fragment,d),b(wt.$$.fragment,d),b(rt.$$.fragment,d),b(ut.$$.fragment,d),b(Oe.$$.fragment,d),b(We.$$.fragment,d),b(A.$$.fragment,d),b(Vt.$$.fragment,d),b(an.$$.fragment,d),b(Ge.$$.fragment,d),b(Gt.$$.fragment,d),b(it.$$.fragment,d),b(Xe.$$.fragment,d),b(Kt.$$.fragment,d),b(Se.$$.fragment,d),h=!1},d(d){d&&(a(m),a(o),a(je),a(Tt),a(W),a(tt),a(At),a(H),a(tn),a(qt),a(_e),a(wn),a(Nt),a(I),a(Gn),a(Rt),a(ye)),M(e,d),M(s),M(j),M(O),M(Me),M(Ze,d),M(Ae),M(pt),M(xe),M(yt),M(fe,d),M(he),M(R),M(le),M(st),M(Et,d),M(Zt),M(cn),M(wt),M(rt),M(ut),M(Oe,d),M(We),M(A),M(Vt),M(an),M(Ge),M(Gt,d),M(it),M(Xe),M(Kt),M(Se)}}}function jo(x){let e,m;return e=new On({props:{$$slots:{default:[Po]},$$scope:{ctx:x}}}),{c(){f(e.$$.fragment)},l(o){_(e.$$.fragment,o)},m(o,s){T(e,o,s),m=!0},p(o,s){const k={};s&2&&(k.$$scope={dirty:s,ctx:o}),e.$set(k)},i(o){m||(y(e.$$.fragment,o),m=!0)},o(o){b(e.$$.fragment,o),m=!1},d(o){M(e,o)}}}function Co(x){let e,m="TensorFlow models and layers in <code>transformers</code> accept two formats as input:",o,s,k="<li>having all inputs as keyword arguments (like PyTorch models), or</li> <li>having all inputs as a list, tuple or dict in the first positional argument.</li>",t,w,be=`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 <code>model.fit()</code> things should “just work” for you - just | |
| pass your inputs and labels in any format that <code>model.fit()</code> supports! If, however, you want to use the second | |
| format outside of Keras methods like <code>fit()</code> and <code>predict()</code>, such as when creating your own layers or models with | |
| the Keras <code>Functional</code> API, there are three possibilities you can use to gather all the input Tensors in the first | |
| positional argument:`,z,C,ue=`<li>a single Tensor with <code>input_ids</code> only and nothing else: <code>model(input_ids)</code></li> <li>a list of varying length with one or several input Tensors IN THE ORDER given in the docstring: | |
| <code>model([input_ids, attention_mask])</code> or <code>model([input_ids, attention_mask, token_type_ids])</code></li> <li>a dictionary with one or several input Tensors associated to the input names given in the docstring: | |
| <code>model({"input_ids": input_ids, "token_type_ids": token_type_ids})</code></li>`,F,J,me=`Note that when creating models and layers with | |
| <a href="https://keras.io/guides/making_new_layers_and_models_via_subclassing/" rel="nofollow">subclassing</a> then you don’t need to worry | |
| about any of this, as you can just pass inputs like you would to any other Python function!`;return{c(){e=p("p"),e.innerHTML=m,o=r(),s=p("ul"),s.innerHTML=k,t=r(),w=p("p"),w.innerHTML=be,z=r(),C=p("ul"),C.innerHTML=ue,F=r(),J=p("p"),J.innerHTML=me},l(v){e=u(v,"P",{"data-svelte-h":!0}),g(e)!=="svelte-1ajbfxg"&&(e.innerHTML=m),o=i(v),s=u(v,"UL",{"data-svelte-h":!0}),g(s)!=="svelte-qm1t26"&&(s.innerHTML=k),t=i(v),w=u(v,"P",{"data-svelte-h":!0}),g(w)!=="svelte-1v9qsc5"&&(w.innerHTML=be),z=i(v),C=u(v,"UL",{"data-svelte-h":!0}),g(C)!=="svelte-15scerc"&&(C.innerHTML=ue),F=i(v),J=u(v,"P",{"data-svelte-h":!0}),g(J)!=="svelte-1an3odd"&&(J.innerHTML=me)},m(v,j){c(v,e,j),c(v,o,j),c(v,s,j),c(v,t,j),c(v,w,j),c(v,z,j),c(v,C,j),c(v,F,j),c(v,J,j)},p:N,d(v){v&&(a(e),a(o),a(s),a(t),a(w),a(z),a(C),a(F),a(J))}}}function Fo(x){let e,m=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code> | |
| instance afterwards instead of this since the former takes care of running the pre and post processing steps while | |
| the latter silently ignores them.`;return{c(){e=p("p"),e.innerHTML=m},l(o){e=u(o,"P",{"data-svelte-h":!0}),g(e)!=="svelte-fincs2"&&(e.innerHTML=m)},m(o,s){c(o,e,s)},p:N,d(o){o&&a(e)}}}function zo(x){let e,m="Example:",o,s,k;return s=new qe({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkdQVDJNb2RlbCUwQWltcG9ydCUyMHRlbnNvcmZsb3clMjBhcyUyMHRmJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyb3BlbmFpLWNvbW11bml0eSUyRmdwdDIlMjIpJTBBbW9kZWwlMjAlM0QlMjBURkdQVDJNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyb3BlbmFpLWNvbW11bml0eSUyRmdwdDIlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMkhlbGxvJTJDJTIwbXklMjBkb2clMjBpcyUyMGN1dGUlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbChpbnB1dHMpJTBBJTBBbGFzdF9oaWRkZW5fc3RhdGVzJTIwJTNEJTIwb3V0cHV0cy5sYXN0X2hpZGRlbl9zdGF0ZQ==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFGPT2Model | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>model = TFGPT2Model.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>inputs = tokenizer(<span class="hljs-string">"Hello, my dog is cute"</span>, return_tensors=<span class="hljs-string">"tf"</span>) | |
| <span class="hljs-meta">>>> </span>outputs = model(inputs) | |
| <span class="hljs-meta">>>> </span>last_hidden_states = outputs.last_hidden_state`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-11lpom8"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function Jo(x){let e,m="TensorFlow models and layers in <code>transformers</code> accept two formats as input:",o,s,k="<li>having all inputs as keyword arguments (like PyTorch models), or</li> <li>having all inputs as a list, tuple or dict in the first positional argument.</li>",t,w,be=`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 <code>model.fit()</code> things should “just work” for you - just | |
| pass your inputs and labels in any format that <code>model.fit()</code> supports! If, however, you want to use the second | |
| format outside of Keras methods like <code>fit()</code> and <code>predict()</code>, such as when creating your own layers or models with | |
| the Keras <code>Functional</code> API, there are three possibilities you can use to gather all the input Tensors in the first | |
| positional argument:`,z,C,ue=`<li>a single Tensor with <code>input_ids</code> only and nothing else: <code>model(input_ids)</code></li> <li>a list of varying length with one or several input Tensors IN THE ORDER given in the docstring: | |
| <code>model([input_ids, attention_mask])</code> or <code>model([input_ids, attention_mask, token_type_ids])</code></li> <li>a dictionary with one or several input Tensors associated to the input names given in the docstring: | |
| <code>model({"input_ids": input_ids, "token_type_ids": token_type_ids})</code></li>`,F,J,me=`Note that when creating models and layers with | |
| <a href="https://keras.io/guides/making_new_layers_and_models_via_subclassing/" rel="nofollow">subclassing</a> then you don’t need to worry | |
| about any of this, as you can just pass inputs like you would to any other Python function!`;return{c(){e=p("p"),e.innerHTML=m,o=r(),s=p("ul"),s.innerHTML=k,t=r(),w=p("p"),w.innerHTML=be,z=r(),C=p("ul"),C.innerHTML=ue,F=r(),J=p("p"),J.innerHTML=me},l(v){e=u(v,"P",{"data-svelte-h":!0}),g(e)!=="svelte-1ajbfxg"&&(e.innerHTML=m),o=i(v),s=u(v,"UL",{"data-svelte-h":!0}),g(s)!=="svelte-qm1t26"&&(s.innerHTML=k),t=i(v),w=u(v,"P",{"data-svelte-h":!0}),g(w)!=="svelte-1v9qsc5"&&(w.innerHTML=be),z=i(v),C=u(v,"UL",{"data-svelte-h":!0}),g(C)!=="svelte-15scerc"&&(C.innerHTML=ue),F=i(v),J=u(v,"P",{"data-svelte-h":!0}),g(J)!=="svelte-1an3odd"&&(J.innerHTML=me)},m(v,j){c(v,e,j),c(v,o,j),c(v,s,j),c(v,t,j),c(v,w,j),c(v,z,j),c(v,C,j),c(v,F,j),c(v,J,j)},p:N,d(v){v&&(a(e),a(o),a(s),a(t),a(w),a(z),a(C),a(F),a(J))}}}function Uo(x){let e,m=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code> | |
| instance afterwards instead of this since the former takes care of running the pre and post processing steps while | |
| the latter silently ignores them.`;return{c(){e=p("p"),e.innerHTML=m},l(o){e=u(o,"P",{"data-svelte-h":!0}),g(e)!=="svelte-fincs2"&&(e.innerHTML=m)},m(o,s){c(o,e,s)},p:N,d(o){o&&a(e)}}}function Ho(x){let e,m="Example:",o,s,k;return s=new qe({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkdQVDJMTUhlYWRNb2RlbCUwQWltcG9ydCUyMHRlbnNvcmZsb3clMjBhcyUyMHRmJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyb3BlbmFpLWNvbW11bml0eSUyRmdwdDIlMjIpJTBBbW9kZWwlMjAlM0QlMjBURkdQVDJMTUhlYWRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyb3BlbmFpLWNvbW11bml0eSUyRmdwdDIlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMkhlbGxvJTJDJTIwbXklMjBkb2clMjBpcyUyMGN1dGUlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbChpbnB1dHMpJTBBbG9naXRzJTIwJTNEJTIwb3V0cHV0cy5sb2dpdHM=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFGPT2LMHeadModel | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>model = TFGPT2LMHeadModel.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>inputs = tokenizer(<span class="hljs-string">"Hello, my dog is cute"</span>, return_tensors=<span class="hljs-string">"tf"</span>) | |
| <span class="hljs-meta">>>> </span>outputs = model(inputs) | |
| <span class="hljs-meta">>>> </span>logits = outputs.logits`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-11lpom8"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function Wo(x){let e,m="TensorFlow models and layers in <code>transformers</code> accept two formats as input:",o,s,k="<li>having all inputs as keyword arguments (like PyTorch models), or</li> <li>having all inputs as a list, tuple or dict in the first positional argument.</li>",t,w,be=`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 <code>model.fit()</code> things should “just work” for you - just | |
| pass your inputs and labels in any format that <code>model.fit()</code> supports! If, however, you want to use the second | |
| format outside of Keras methods like <code>fit()</code> and <code>predict()</code>, such as when creating your own layers or models with | |
| the Keras <code>Functional</code> API, there are three possibilities you can use to gather all the input Tensors in the first | |
| positional argument:`,z,C,ue=`<li>a single Tensor with <code>input_ids</code> only and nothing else: <code>model(input_ids)</code></li> <li>a list of varying length with one or several input Tensors IN THE ORDER given in the docstring: | |
| <code>model([input_ids, attention_mask])</code> or <code>model([input_ids, attention_mask, token_type_ids])</code></li> <li>a dictionary with one or several input Tensors associated to the input names given in the docstring: | |
| <code>model({"input_ids": input_ids, "token_type_ids": token_type_ids})</code></li>`,F,J,me=`Note that when creating models and layers with | |
| <a href="https://keras.io/guides/making_new_layers_and_models_via_subclassing/" rel="nofollow">subclassing</a> then you don’t need to worry | |
| about any of this, as you can just pass inputs like you would to any other Python function!`;return{c(){e=p("p"),e.innerHTML=m,o=r(),s=p("ul"),s.innerHTML=k,t=r(),w=p("p"),w.innerHTML=be,z=r(),C=p("ul"),C.innerHTML=ue,F=r(),J=p("p"),J.innerHTML=me},l(v){e=u(v,"P",{"data-svelte-h":!0}),g(e)!=="svelte-1ajbfxg"&&(e.innerHTML=m),o=i(v),s=u(v,"UL",{"data-svelte-h":!0}),g(s)!=="svelte-qm1t26"&&(s.innerHTML=k),t=i(v),w=u(v,"P",{"data-svelte-h":!0}),g(w)!=="svelte-1v9qsc5"&&(w.innerHTML=be),z=i(v),C=u(v,"UL",{"data-svelte-h":!0}),g(C)!=="svelte-15scerc"&&(C.innerHTML=ue),F=i(v),J=u(v,"P",{"data-svelte-h":!0}),g(J)!=="svelte-1an3odd"&&(J.innerHTML=me)},m(v,j){c(v,e,j),c(v,o,j),c(v,s,j),c(v,t,j),c(v,w,j),c(v,z,j),c(v,C,j),c(v,F,j),c(v,J,j)},p:N,d(v){v&&(a(e),a(o),a(s),a(t),a(w),a(z),a(C),a(F),a(J))}}}function Io(x){let e,m=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code> | |
| instance afterwards instead of this since the former takes care of running the pre and post processing steps while | |
| the latter silently ignores them.`;return{c(){e=p("p"),e.innerHTML=m},l(o){e=u(o,"P",{"data-svelte-h":!0}),g(e)!=="svelte-fincs2"&&(e.innerHTML=m)},m(o,s){c(o,e,s)},p:N,d(o){o&&a(e)}}}function qo(x){let e,m="Examples:",o,s,k;return s=new qe({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMFRGR1BUMkRvdWJsZUhlYWRzTW9kZWwlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJvcGVuYWktY29tbXVuaXR5JTJGZ3B0MiUyMiklMEFtb2RlbCUyMCUzRCUyMFRGR1BUMkRvdWJsZUhlYWRzTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMm9wZW5haS1jb21tdW5pdHklMkZncHQyJTIyKSUwQSUwQSUyMyUyMEFkZCUyMGElMjAlNUJDTFMlNUQlMjB0byUyMHRoZSUyMHZvY2FidWxhcnklMjAod2UlMjBzaG91bGQlMjB0cmFpbiUyMGl0JTIwYWxzbyEpJTBBbnVtX2FkZGVkX3Rva2VucyUyMCUzRCUyMHRva2VuaXplci5hZGRfc3BlY2lhbF90b2tlbnMoJTdCJTIyY2xzX3Rva2VuJTIyJTNBJTIwJTIyJTVCQ0xTJTVEJTIyJTdEKSUwQSUwQWVtYmVkZGluZ19sYXllciUyMCUzRCUyMG1vZGVsLnJlc2l6ZV90b2tlbl9lbWJlZGRpbmdzKCUwQSUyMCUyMCUyMCUyMGxlbih0b2tlbml6ZXIpJTBBKSUyMCUyMCUyMyUyMFVwZGF0ZSUyMHRoZSUyMG1vZGVsJTIwZW1iZWRkaW5ncyUyMHdpdGglMjB0aGUlMjBuZXclMjB2b2NhYnVsYXJ5JTIwc2l6ZSUwQSUwQWNob2ljZXMlMjAlM0QlMjAlNUIlMjJIZWxsbyUyQyUyMG15JTIwZG9nJTIwaXMlMjBjdXRlJTIwJTVCQ0xTJTVEJTIyJTJDJTIwJTIySGVsbG8lMkMlMjBteSUyMGNhdCUyMGlzJTIwY3V0ZSUyMCU1QkNMUyU1RCUyMiU1RCUwQWVuY29kZWRfY2hvaWNlcyUyMCUzRCUyMCU1QnRva2VuaXplci5lbmNvZGUocyklMjBmb3IlMjBzJTIwaW4lMjBjaG9pY2VzJTVEJTBBY2xzX3Rva2VuX2xvY2F0aW9uJTIwJTNEJTIwJTVCdG9rZW5zLmluZGV4KHRva2VuaXplci5jbHNfdG9rZW5faWQpJTIwZm9yJTIwdG9rZW5zJTIwaW4lMjBlbmNvZGVkX2Nob2ljZXMlNUQlMEElMEFpbnB1dF9pZHMlMjAlM0QlMjB0Zi5jb25zdGFudChlbmNvZGVkX2Nob2ljZXMpJTVCTm9uZSUyQyUyMCUzQSU1RCUyMCUyMCUyMyUyMEJhdGNoJTIwc2l6ZSUzQSUyMDElMkMlMjBudW1iZXIlMjBvZiUyMGNob2ljZXMlM0ElMjAyJTBBbWNfdG9rZW5faWRzJTIwJTNEJTIwdGYuY29uc3RhbnQoJTVCY2xzX3Rva2VuX2xvY2F0aW9uJTVEKSUyMCUyMCUyMyUyMEJhdGNoJTIwc2l6ZSUzQSUyMDElMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoaW5wdXRfaWRzJTJDJTIwbWNfdG9rZW5faWRzJTNEbWNfdG9rZW5faWRzKSUwQWxtX3ByZWRpY3Rpb25fc2NvcmVzJTJDJTIwbWNfcHJlZGljdGlvbl9zY29yZXMlMjAlM0QlMjBvdXRwdXRzJTVCJTNBMiU1RA==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFGPT2DoubleHeadsModel | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>model = TFGPT2DoubleHeadsModel.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Add a [CLS] to the vocabulary (we should train it also!)</span> | |
| <span class="hljs-meta">>>> </span>num_added_tokens = tokenizer.add_special_tokens({<span class="hljs-string">"cls_token"</span>: <span class="hljs-string">"[CLS]"</span>}) | |
| <span class="hljs-meta">>>> </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">>>> </span>choices = [<span class="hljs-string">"Hello, my dog is cute [CLS]"</span>, <span class="hljs-string">"Hello, my cat is cute [CLS]"</span>] | |
| <span class="hljs-meta">>>> </span>encoded_choices = [tokenizer.encode(s) <span class="hljs-keyword">for</span> s <span class="hljs-keyword">in</span> choices] | |
| <span class="hljs-meta">>>> </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">>>> </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">>>> </span>mc_token_ids = tf.constant([cls_token_location]) <span class="hljs-comment"># Batch size: 1</span> | |
| <span class="hljs-meta">>>> </span>outputs = model(input_ids, mc_token_ids=mc_token_ids) | |
| <span class="hljs-meta">>>> </span>lm_prediction_scores, mc_prediction_scores = outputs[:<span class="hljs-number">2</span>]`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-kvfsh7"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function Zo(x){let e,m="TensorFlow models and layers in <code>transformers</code> accept two formats as input:",o,s,k="<li>having all inputs as keyword arguments (like PyTorch models), or</li> <li>having all inputs as a list, tuple or dict in the first positional argument.</li>",t,w,be=`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 <code>model.fit()</code> things should “just work” for you - just | |
| pass your inputs and labels in any format that <code>model.fit()</code> supports! If, however, you want to use the second | |
| format outside of Keras methods like <code>fit()</code> and <code>predict()</code>, such as when creating your own layers or models with | |
| the Keras <code>Functional</code> API, there are three possibilities you can use to gather all the input Tensors in the first | |
| positional argument:`,z,C,ue=`<li>a single Tensor with <code>input_ids</code> only and nothing else: <code>model(input_ids)</code></li> <li>a list of varying length with one or several input Tensors IN THE ORDER given in the docstring: | |
| <code>model([input_ids, attention_mask])</code> or <code>model([input_ids, attention_mask, token_type_ids])</code></li> <li>a dictionary with one or several input Tensors associated to the input names given in the docstring: | |
| <code>model({"input_ids": input_ids, "token_type_ids": token_type_ids})</code></li>`,F,J,me=`Note that when creating models and layers with | |
| <a href="https://keras.io/guides/making_new_layers_and_models_via_subclassing/" rel="nofollow">subclassing</a> then you don’t need to worry | |
| about any of this, as you can just pass inputs like you would to any other Python function!`;return{c(){e=p("p"),e.innerHTML=m,o=r(),s=p("ul"),s.innerHTML=k,t=r(),w=p("p"),w.innerHTML=be,z=r(),C=p("ul"),C.innerHTML=ue,F=r(),J=p("p"),J.innerHTML=me},l(v){e=u(v,"P",{"data-svelte-h":!0}),g(e)!=="svelte-1ajbfxg"&&(e.innerHTML=m),o=i(v),s=u(v,"UL",{"data-svelte-h":!0}),g(s)!=="svelte-qm1t26"&&(s.innerHTML=k),t=i(v),w=u(v,"P",{"data-svelte-h":!0}),g(w)!=="svelte-1v9qsc5"&&(w.innerHTML=be),z=i(v),C=u(v,"UL",{"data-svelte-h":!0}),g(C)!=="svelte-15scerc"&&(C.innerHTML=ue),F=i(v),J=u(v,"P",{"data-svelte-h":!0}),g(J)!=="svelte-1an3odd"&&(J.innerHTML=me)},m(v,j){c(v,e,j),c(v,o,j),c(v,s,j),c(v,t,j),c(v,w,j),c(v,z,j),c(v,C,j),c(v,F,j),c(v,J,j)},p:N,d(v){v&&(a(e),a(o),a(s),a(t),a(w),a(z),a(C),a(F),a(J))}}}function Lo(x){let e,m=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code> | |
| instance afterwards instead of this since the former takes care of running the pre and post processing steps while | |
| the latter silently ignores them.`;return{c(){e=p("p"),e.innerHTML=m},l(o){e=u(o,"P",{"data-svelte-h":!0}),g(e)!=="svelte-fincs2"&&(e.innerHTML=m)},m(o,s){c(o,e,s)},p:N,d(o){o&&a(e)}}}function No(x){let e,m="Example:",o,s,k;return s=new qe({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkdQVDJGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uJTBBaW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZEaWFsb2dSUFQtdXBkb3duJTIyKSUwQW1vZGVsJTIwJTNEJTIwVEZHUFQyRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGRGlhbG9nUlBULXVwZG93biUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIySGVsbG8lMkMlMjBteSUyMGRvZyUyMGlzJTIwY3V0ZSUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIpJTBBJTBBbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cyUwQSUwQXByZWRpY3RlZF9jbGFzc19pZCUyMCUzRCUyMGludCh0Zi5tYXRoLmFyZ21heChsb2dpdHMlMkMlMjBheGlzJTNELTEpJTVCMCU1RCk=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFGPT2ForSequenceClassification | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"microsoft/DialogRPT-updown"</span>) | |
| <span class="hljs-meta">>>> </span>model = TFGPT2ForSequenceClassification.from_pretrained(<span class="hljs-string">"microsoft/DialogRPT-updown"</span>) | |
| <span class="hljs-meta">>>> </span>inputs = tokenizer(<span class="hljs-string">"Hello, my dog is cute"</span>, return_tensors=<span class="hljs-string">"tf"</span>) | |
| <span class="hljs-meta">>>> </span>logits = model(**inputs).logits | |
| <span class="hljs-meta">>>> </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>])`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-11lpom8"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function Bo(x){let e,m;return e=new qe({props:{code:"JTIzJTIwVG8lMjB0cmFpbiUyMGElMjBtb2RlbCUyMG9uJTIwJTYwbnVtX2xhYmVscyU2MCUyMGNsYXNzZXMlMkMlMjB5b3UlMjBjYW4lMjBwYXNzJTIwJTYwbnVtX2xhYmVscyUzRG51bV9sYWJlbHMlNjAlMjB0byUyMCU2MC5mcm9tX3ByZXRyYWluZWQoLi4uKSU2MCUwQW51bV9sYWJlbHMlMjAlM0QlMjBsZW4obW9kZWwuY29uZmlnLmlkMmxhYmVsKSUwQW1vZGVsJTIwJTNEJTIwVEZHUFQyRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGRGlhbG9nUlBULXVwZG93biUyMiUyQyUyMG51bV9sYWJlbHMlM0RudW1fbGFiZWxzKSUwQSUwQWxhYmVscyUyMCUzRCUyMHRmLmNvbnN0YW50KDEpJTBBbG9zcyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzJTJDJTIwbGFiZWxzJTNEbGFiZWxzKS5sb3Nz",highlighted:'<span class="hljs-meta">>>> </span><span class="hljs-comment"># To train a model on `num_labels` classes, you can pass `num_labels=num_labels` to `.from_pretrained(...)`</span>\n<span class="hljs-meta">>>> </span>num_labels = <span class="hljs-built_in">len</span>(model.config.id2label)\n<span class="hljs-meta">>>> </span>model = TFGPT2ForSequenceClassification.from_pretrained(<span class="hljs-string">"microsoft/DialogRPT-updown"</span>, num_labels=num_labels)\n\n<span class="hljs-meta">>>> </span>labels = tf.constant(<span class="hljs-number">1</span>)\n<span class="hljs-meta">>>> </span>loss = model(**inputs, labels=labels).loss',wrap:!1}}),{c(){f(e.$$.fragment)},l(o){_(e.$$.fragment,o)},m(o,s){T(e,o,s),m=!0},p:N,i(o){m||(y(e.$$.fragment,o),m=!0)},o(o){b(e.$$.fragment,o),m=!1},d(o){M(e,o)}}}function Vo(x){let e,m="Examples:",o,s,k;return s=new qe({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGR1BUMlRva2VuaXplciUwQSUwQXRmX3Rva2VuaXplciUyMCUzRCUyMFRGR1BUMlRva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyb3BlbmFpLWNvbW11bml0eSUyRmdwdDIlMjIp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFGPT2Tokenizer | |
| tf_tokenizer = TFGPT2Tokenizer.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>)`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-kvfsh7"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function Ro(x){let e,m="Examples:",o,s,k;return s=new qe({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkdQVDJUb2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJvcGVuYWktY29tbXVuaXR5JTJGZ3B0MiUyMiklMEF0Zl90b2tlbml6ZXIlMjAlM0QlMjBURkdQVDJUb2tlbml6ZXIuZnJvbV90b2tlbml6ZXIodG9rZW5pemVyKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFGPT2Tokenizer | |
| tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| tf_tokenizer = TFGPT2Tokenizer.from_tokenizer(tokenizer)`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-kvfsh7"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function Xo(x){let e,m,o,s,k,t,w="The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top.",be,z,C=`This model inherits from <a href="/docs/transformers/pr_36839/en/main_classes/model#transformers.TFPreTrainedModel">TFPreTrainedModel</a>. 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.)`,ue,F,J=`This model is also a <a href="https://www.tensorflow.org/api_docs/python/tf/keras/Model" rel="nofollow">keras.Model</a> 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.`,me,v,j,ve,ie,gn,lt,O='The <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.TFGPT2Model">TFGPT2Model</a> forward method, overrides the <code>__call__</code> special method.',_t,Me,je,Ze,Tt,W,Ae,q,Le,dt,Ce,S=`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input | |
| embeddings).`,Ne,Ct,Ee=`This model inherits from <a href="/docs/transformers/pr_36839/en/main_classes/model#transformers.TFPreTrainedModel">TFPreTrainedModel</a>. 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,ct,ae=`This model is also a <a href="https://www.tensorflow.org/api_docs/python/tf/keras/Model" rel="nofollow">keras.Model</a> 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.`,pt,$e,et,Fe,ze,xe,Qe,yt='The <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.TFGPT2LMHeadModel">TFGPT2LMHeadModel</a> forward method, overrides the <code>__call__</code> special method.',tt,fe,At,H,he,nt,ke,ge,Je,Be,bt,Ue=`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).`,ot,P,U=`This model inherits from <a href="/docs/transformers/pr_36839/en/main_classes/model#transformers.TFPreTrainedModel">TFPreTrainedModel</a>. Check the superclass documentation for the generic methods the | |
| library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads | |
| etc.)`,V,R,He=`This model is also a <a href="https://www.tensorflow.org/api_docs/python/tf/keras/Model" rel="nofollow">keras.Model</a> 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.`,Ve,en,fn,le,It,st,tn,Et='The <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.TFGPT2DoubleHeadsModel">TFGPT2DoubleHeadsModel</a> forward method, overrides the <code>__call__</code> special method.',qt,_e,Zt,at,Lt,Mt,kn,D,kt,Cn,vt,dn="The GPT2 Model transformer with a sequence classification head on top (linear layer).",_n,de,cn=`<a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.TFGPT2ForSequenceClassification">TFGPT2ForSequenceClassification</a> uses the last token in order to do the classification, as other causal models | |
| (e.g. GPT-1) do.`,Tn,De,Fn=`Since it does classification on the last token, it requires to know the position of the last token. If a | |
| <code>pad_token_id</code> is defined in the configuration, it finds the last token that is not a padding token in each row. If | |
| no <code>pad_token_id</code> is defined, it simply takes the last value in each row of the batch. Since it cannot guess the | |
| padding tokens when <code>inputs_embeds</code> are passed instead of <code>input_ids</code>, it does the same (take the last value in | |
| each row of the batch).`,Qt,wt,vn=`This model inherits from <a href="/docs/transformers/pr_36839/en/main_classes/model#transformers.TFPreTrainedModel">TFPreTrainedModel</a>. 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.)`,rt,Dt,ut=`This model is also a <a href="https://www.tensorflow.org/api_docs/python/tf/keras/Model" rel="nofollow">keras.Model</a> 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.`,wn,Oe,Nt,I,We,zn,$t,pn='The <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.TFGPT2ForSequenceClassification">TFGPT2ForSequenceClassification</a> forward method, overrides the <code>__call__</code> special method.',yn,ce,nn,Bt,zt,on,bn,Ye,Jn,Jt,Ie,$n,xt,Re="Base class for outputs of sentence classification models.",A,mt,Ot,Te,sn,Vt,Ut,an=`This is an in-graph tokenizer for GPT2. It should be initialized similarly to other tokenizers, using the | |
| <code>from_pretrained()</code> method. It can also be initialized with the <code>from_tokenizer()</code> method, which imports settings | |
| from an existing standard tokenizer object.`,xn,Ge,Gn=`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 <code>tf.string</code> inputs to outputs.`,Gt,Rt,ye,it,rn,Xt="Creates TFGPT2Tokenizer from configurations",Hn,Pt,Ke,ln,Yt,Ht="Creates TFGPT2Tokenizer from pretrained GPT2Tokenizer",Pn,Y,Pe,Xe,jt,un,mn,hn="Creates TFGPT2Tokenizer from GPT2Tokenizer",Kt,St,Se;return e=new re({props:{title:"TFGPT2Model",local:"transformers.TFGPT2Model",headingTag:"h2"}}),s=new X({props:{name:"class transformers.TFGPT2Model",anchor:"transformers.TFGPT2Model",parameters:[{name:"config",val:""},{name:"*inputs",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFGPT2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) — 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/pr_36839/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/vr_36839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L748"}}),v=new gt({props:{$$slots:{default:[Co]},$$scope:{ctx:x}}}),ie=new X({props:{name:"call",anchor:"transformers.TFGPT2Model.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"past_key_values",val:": Optional[Tuple[Tuple[Union[np.ndarray, tf.Tensor]]]] = None"},{name:"attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"token_type_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"position_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"head_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"inputs_embeds",val:": np.ndarray | tf.Tensor | None = None"},{name:"encoder_hidden_states",val:": np.ndarray | tf.Tensor | None = None"},{name:"encoder_attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"use_cache",val:": Optional[bool] = None"},{name:"output_attentions",val:": Optional[bool] = None"},{name:"output_hidden_states",val:": Optional[bool] = None"},{name:"return_dict",val:": Optional[bool] = None"},{name:"training",val:": Optional[bool] = False"}],parametersDescription:[{anchor:"transformers.TFGPT2Model.call.input_ids",description:`<strong>input_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(batch_size, input_ids_length)</code>) — | |
| <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/pr_36839/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and | |
| <a href="/docs/transformers/pr_36839/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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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’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>) — | |
| 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>) — | |
| 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>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_36839/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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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’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>) — | |
| 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/vr_36839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L757",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_36839/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/pr_36839/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>) — 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>) — 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>) — 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>) — 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>) — 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’s cross-attention layer, after the attention softmax, used to compute the | |
| weighted average in the cross-attention heads.</p> | |
| </li> | |
| </ul> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_36839/en/main_classes/output#transformers.modeling_tf_outputs.TFBaseModelOutputWithPastAndCrossAttentions" | |
| >transformers.modeling_tf_outputs.TFBaseModelOutputWithPastAndCrossAttentions</a> or <code>tuple(tf.Tensor)</code></p> | |
| `}}),Me=new gt({props:{$$slots:{default:[Fo]},$$scope:{ctx:x}}}),Ze=new ft({props:{anchor:"transformers.TFGPT2Model.call.example",$$slots:{default:[zo]},$$scope:{ctx:x}}}),W=new re({props:{title:"TFGPT2LMHeadModel",local:"transformers.TFGPT2LMHeadModel",headingTag:"h2"}}),Le=new X({props:{name:"class transformers.TFGPT2LMHeadModel",anchor:"transformers.TFGPT2LMHeadModel",parameters:[{name:"config",val:""},{name:"*inputs",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFGPT2LMHeadModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) — 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/pr_36839/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/vr_36839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L830"}}),$e=new gt({props:{$$slots:{default:[Jo]},$$scope:{ctx:x}}}),ze=new X({props:{name:"call",anchor:"transformers.TFGPT2LMHeadModel.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"past_key_values",val:": Optional[Tuple[Tuple[Union[np.ndarray, tf.Tensor]]]] = None"},{name:"attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"token_type_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"position_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"head_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"inputs_embeds",val:": np.ndarray | tf.Tensor | None = None"},{name:"encoder_hidden_states",val:": np.ndarray | tf.Tensor | None = None"},{name:"encoder_attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"use_cache",val:": Optional[bool] = None"},{name:"output_attentions",val:": Optional[bool] = None"},{name:"output_hidden_states",val:": Optional[bool] = None"},{name:"return_dict",val:": Optional[bool] = None"},{name:"labels",val:": np.ndarray | tf.Tensor | None = None"},{name:"training",val:": Optional[bool] = False"}],parametersDescription:[{anchor:"transformers.TFGPT2LMHeadModel.call.input_ids",description:`<strong>input_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(batch_size, input_ids_length)</code>) — | |
| <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/pr_36839/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and | |
| <a href="/docs/transformers/pr_36839/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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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’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>) — | |
| 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>) — | |
| 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>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_36839/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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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’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>) — | |
| 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>) — | |
| 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/vr_36839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L873",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_36839/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/pr_36839/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) — 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>) — 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>) — 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>) — 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>) — 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’s 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>) — 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:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_36839/en/main_classes/output#transformers.modeling_tf_outputs.TFCausalLMOutputWithCrossAttentions" | |
| >transformers.modeling_tf_outputs.TFCausalLMOutputWithCrossAttentions</a> or <code>tuple(tf.Tensor)</code></p> | |
| `}}),fe=new gt({props:{$$slots:{default:[Uo]},$$scope:{ctx:x}}}),H=new ft({props:{anchor:"transformers.TFGPT2LMHeadModel.call.example",$$slots:{default:[Ho]},$$scope:{ctx:x}}}),nt=new re({props:{title:"TFGPT2DoubleHeadsModel",local:"transformers.TFGPT2DoubleHeadsModel",headingTag:"h2"}}),Je=new X({props:{name:"class transformers.TFGPT2DoubleHeadsModel",anchor:"transformers.TFGPT2DoubleHeadsModel",parameters:[{name:"config",val:""},{name:"*inputs",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFGPT2DoubleHeadsModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) — 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/pr_36839/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/vr_36839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L970"}}),en=new gt({props:{$$slots:{default:[Wo]},$$scope:{ctx:x}}}),It=new X({props:{name:"call",anchor:"transformers.TFGPT2DoubleHeadsModel.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"past_key_values",val:": Optional[Tuple[Tuple[Union[np.ndarray, tf.Tensor]]]] = None"},{name:"attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"token_type_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"position_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"head_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"inputs_embeds",val:": np.ndarray | tf.Tensor | None = None"},{name:"mc_token_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"use_cache",val:": Optional[bool] = None"},{name:"output_attentions",val:": Optional[bool] = None"},{name:"output_hidden_states",val:": Optional[bool] = None"},{name:"return_dict",val:": Optional[bool] = None"},{name:"training",val:": Optional[bool] = False"}],parametersDescription:[{anchor:"transformers.TFGPT2DoubleHeadsModel.call.input_ids",description:`<strong>input_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(batch_size, input_ids_length)</code>) — | |
| <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/pr_36839/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and | |
| <a href="/docs/transformers/pr_36839/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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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’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>) — | |
| 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>) — | |
| 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>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_36839/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>) — | |
| 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) — | |
| 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/vr_36839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L988",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_36839/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/pr_36839/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>) — 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>) — 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>) — 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>) — 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>) — 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:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_36839/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> | |
| `}}),_e=new gt({props:{$$slots:{default:[Io]},$$scope:{ctx:x}}}),at=new ft({props:{anchor:"transformers.TFGPT2DoubleHeadsModel.call.example",$$slots:{default:[qo]},$$scope:{ctx:x}}}),Mt=new re({props:{title:"TFGPT2ForSequenceClassification",local:"transformers.TFGPT2ForSequenceClassification",headingTag:"h2"}}),kt=new X({props:{name:"class transformers.TFGPT2ForSequenceClassification",anchor:"transformers.TFGPT2ForSequenceClassification",parameters:[{name:"config",val:""},{name:"*inputs",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFGPT2ForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) — 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/pr_36839/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/vr_36839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L1110"}}),Oe=new gt({props:{$$slots:{default:[Zo]},$$scope:{ctx:x}}}),We=new X({props:{name:"call",anchor:"transformers.TFGPT2ForSequenceClassification.call",parameters:[{name:"input_ids",val:": TFModelInputType | None = None"},{name:"past_key_values",val:": Optional[Tuple[Tuple[Union[np.ndarray, tf.Tensor]]]] = None"},{name:"attention_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"token_type_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"position_ids",val:": np.ndarray | tf.Tensor | None = None"},{name:"head_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"inputs_embeds",val:": np.ndarray | tf.Tensor | None = None"},{name:"use_cache",val:": Optional[bool] = None"},{name:"output_attentions",val:": Optional[bool] = None"},{name:"output_hidden_states",val:": Optional[bool] = None"},{name:"return_dict",val:": Optional[bool] = None"},{name:"labels",val:": np.ndarray | tf.Tensor | None = None"},{name:"training",val:": Optional[bool] = False"}],parametersDescription:[{anchor:"transformers.TFGPT2ForSequenceClassification.call.input_ids",description:`<strong>input_ids</strong> (<code>Numpy array</code> or <code>tf.Tensor</code> of shape <code>(batch_size, input_ids_length)</code>) — | |
| <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/pr_36839/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> and | |
| <a href="/docs/transformers/pr_36839/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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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’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>) — | |
| 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>) — | |
| 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>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_36839/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>) — | |
| 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>) — | |
| 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/vr_36839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L1138",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_36839/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/pr_36839/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) — 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>) — 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>) — 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>) — 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>) — 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:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast" | |
| >transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast</a> or <code>tuple(tf.Tensor)</code></p> | |
| `}}),ce=new gt({props:{$$slots:{default:[Lo]},$$scope:{ctx:x}}}),Bt=new ft({props:{anchor:"transformers.TFGPT2ForSequenceClassification.call.example",$$slots:{default:[No]},$$scope:{ctx:x}}}),on=new ft({props:{anchor:"transformers.TFGPT2ForSequenceClassification.call.example-2",$$slots:{default:[Bo]},$$scope:{ctx:x}}}),Ye=new re({props:{title:"TFSequenceClassifierOutputWithPast",local:"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast",headingTag:"h2"}}),Ie=new X({props:{name:"class transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast",anchor:"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast",parameters:[{name:"loss",val:": tf.Tensor | None = None"},{name:"logits",val:": tf.Tensor = None"},{name:"past_key_values",val:": List[tf.Tensor] | None = None"},{name:"hidden_states",val:": Tuple[tf.Tensor] | None = None"},{name:"attentions",val:": Tuple[tf.Tensor] | None = None"}],parametersDescription:[{anchor:"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast.loss",description:`<strong>loss</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, )</code>, <em>optional</em>, returned when <code>labels</code> is provided) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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/vr_36839/src/transformers/modeling_tf_outputs.py#L900"}}),mt=new re({props:{title:"TFGPT2Tokenizer",local:"transformers.TFGPT2Tokenizer",headingTag:"h2"}}),sn=new X({props:{name:"class transformers.TFGPT2Tokenizer",anchor:"transformers.TFGPT2Tokenizer",parameters:[{name:"vocab",val:": typing.Dict[str, int]"},{name:"merges",val:": typing.List[str]"},{name:"max_length",val:": int = None"},{name:"pad_token_id",val:": int = None"}],parametersDescription:[{anchor:"transformers.TFGPT2Tokenizer.vocab",description:"<strong>vocab</strong> (Dict[str, int]) — Vocabulary dict for Byte Pair Tokenizer",name:"vocab"},{anchor:"transformers.TFGPT2Tokenizer.merges",description:"<strong>merges</strong> (List[str]) — Merges list for Byte Pair Tokenizer",name:"merges"}],source:"https://github.com/huggingface/transformers/blob/vr_36839/src/transformers/models/gpt2/tokenization_gpt2_tf.py#L12"}}),ye=new X({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) — Dictionary with keys such as stated in <code>get_config</code>.",name:"config"}],source:"https://github.com/huggingface/transformers/blob/vr_36839/src/transformers/models/gpt2/tokenization_gpt2_tf.py#L74"}}),Ke=new X({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]) — Path to pretrained model",name:"pretrained_model_name_or_path"}],source:"https://github.com/huggingface/transformers/blob/vr_36839/src/transformers/models/gpt2/tokenization_gpt2_tf.py#L56"}}),Y=new ft({props:{anchor:"transformers.TFGPT2Tokenizer.from_pretrained.example",$$slots:{default:[Vo]},$$scope:{ctx:x}}}),jt=new X({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) —",name:"tokenizer"}],source:"https://github.com/huggingface/transformers/blob/vr_36839/src/transformers/models/gpt2/tokenization_gpt2_tf.py#L36"}}),St=new ft({props:{anchor:"transformers.TFGPT2Tokenizer.from_tokenizer.example",$$slots:{default:[Ro]},$$scope:{ctx:x}}}),{c(){f(e.$$.fragment),m=r(),o=p("div"),f(s.$$.fragment),k=r(),t=p("p"),t.textContent=w,be=r(),z=p("p"),z.innerHTML=C,ue=r(),F=p("p"),F.innerHTML=J,me=r(),f(v.$$.fragment),j=r(),ve=p("div"),f(ie.$$.fragment),gn=r(),lt=p("p"),lt.innerHTML=O,_t=r(),f(Me.$$.fragment),je=r(),f(Ze.$$.fragment),Tt=r(),f(W.$$.fragment),Ae=r(),q=p("div"),f(Le.$$.fragment),dt=r(),Ce=p("p"),Ce.textContent=S,Ne=r(),Ct=p("p"),Ct.innerHTML=Ee,Ft=r(),ct=p("p"),ct.innerHTML=ae,pt=r(),f($e.$$.fragment),et=r(),Fe=p("div"),f(ze.$$.fragment),xe=r(),Qe=p("p"),Qe.innerHTML=yt,tt=r(),f(fe.$$.fragment),At=r(),f(H.$$.fragment),he=r(),f(nt.$$.fragment),ke=r(),ge=p("div"),f(Je.$$.fragment),Be=r(),bt=p("p"),bt.textContent=Ue,ot=r(),P=p("p"),P.innerHTML=U,V=r(),R=p("p"),R.innerHTML=He,Ve=r(),f(en.$$.fragment),fn=r(),le=p("div"),f(It.$$.fragment),st=r(),tn=p("p"),tn.innerHTML=Et,qt=r(),f(_e.$$.fragment),Zt=r(),f(at.$$.fragment),Lt=r(),f(Mt.$$.fragment),kn=r(),D=p("div"),f(kt.$$.fragment),Cn=r(),vt=p("p"),vt.textContent=dn,_n=r(),de=p("p"),de.innerHTML=cn,Tn=r(),De=p("p"),De.innerHTML=Fn,Qt=r(),wt=p("p"),wt.innerHTML=vn,rt=r(),Dt=p("p"),Dt.innerHTML=ut,wn=r(),f(Oe.$$.fragment),Nt=r(),I=p("div"),f(We.$$.fragment),zn=r(),$t=p("p"),$t.innerHTML=pn,yn=r(),f(ce.$$.fragment),nn=r(),f(Bt.$$.fragment),zt=r(),f(on.$$.fragment),bn=r(),f(Ye.$$.fragment),Jn=r(),Jt=p("div"),f(Ie.$$.fragment),$n=r(),xt=p("p"),xt.textContent=Re,A=r(),f(mt.$$.fragment),Ot=r(),Te=p("div"),f(sn.$$.fragment),Vt=r(),Ut=p("p"),Ut.innerHTML=an,xn=r(),Ge=p("p"),Ge.innerHTML=Gn,Gt=r(),Rt=p("div"),f(ye.$$.fragment),it=r(),rn=p("p"),rn.textContent=Xt,Hn=r(),Pt=p("div"),f(Ke.$$.fragment),ln=r(),Yt=p("p"),Yt.textContent=Ht,Pn=r(),f(Y.$$.fragment),Pe=r(),Xe=p("div"),f(jt.$$.fragment),un=r(),mn=p("p"),mn.textContent=hn,Kt=r(),f(St.$$.fragment),this.h()},l(h){_(e.$$.fragment,h),m=i(h),o=u(h,"DIV",{class:!0});var d=B(o);_(s.$$.fragment,d),k=i(d),t=u(d,"P",{"data-svelte-h":!0}),g(t)!=="svelte-4bubxi"&&(t.textContent=w),be=i(d),z=u(d,"P",{"data-svelte-h":!0}),g(z)!=="svelte-1pln4c3"&&(z.innerHTML=C),ue=i(d),F=u(d,"P",{"data-svelte-h":!0}),g(F)!=="svelte-1be7e3c"&&(F.innerHTML=J),me=i(d),_(v.$$.fragment,d),j=i(d),ve=u(d,"DIV",{class:!0});var G=B(ve);_(ie.$$.fragment,G),gn=i(G),lt=u(G,"P",{"data-svelte-h":!0}),g(lt)!=="svelte-rssljt"&&(lt.innerHTML=O),_t=i(G),_(Me.$$.fragment,G),je=i(G),_(Ze.$$.fragment,G),G.forEach(a),d.forEach(a),Tt=i(h),_(W.$$.fragment,h),Ae=i(h),q=u(h,"DIV",{class:!0});var te=B(q);_(Le.$$.fragment,te),dt=i(te),Ce=u(te,"P",{"data-svelte-h":!0}),g(Ce)!=="svelte-jjb0s"&&(Ce.textContent=S),Ne=i(te),Ct=u(te,"P",{"data-svelte-h":!0}),g(Ct)!=="svelte-1pln4c3"&&(Ct.innerHTML=Ee),Ft=i(te),ct=u(te,"P",{"data-svelte-h":!0}),g(ct)!=="svelte-1be7e3c"&&(ct.innerHTML=ae),pt=i(te),_($e.$$.fragment,te),et=i(te),Fe=u(te,"DIV",{class:!0});var E=B(Fe);_(ze.$$.fragment,E),xe=i(E),Qe=u(E,"P",{"data-svelte-h":!0}),g(Qe)!=="svelte-1b0j9r9"&&(Qe.innerHTML=yt),tt=i(E),_(fe.$$.fragment,E),At=i(E),_(H.$$.fragment,E),E.forEach(a),te.forEach(a),he=i(h),_(nt.$$.fragment,h),ke=i(h),ge=u(h,"DIV",{class:!0});var ne=B(ge);_(Je.$$.fragment,ne),Be=i(ne),bt=u(ne,"P",{"data-svelte-h":!0}),g(bt)!=="svelte-1q8023u"&&(bt.textContent=Ue),ot=i(ne),P=u(ne,"P",{"data-svelte-h":!0}),g(P)!=="svelte-1pln4c3"&&(P.innerHTML=U),V=i(ne),R=u(ne,"P",{"data-svelte-h":!0}),g(R)!=="svelte-1be7e3c"&&(R.innerHTML=He),Ve=i(ne),_(en.$$.fragment,ne),fn=i(ne),le=u(ne,"DIV",{class:!0});var K=B(le);_(It.$$.fragment,K),st=i(K),tn=u(K,"P",{"data-svelte-h":!0}),g(tn)!=="svelte-1nuvbsh"&&(tn.innerHTML=Et),qt=i(K),_(_e.$$.fragment,K),Zt=i(K),_(at.$$.fragment,K),K.forEach(a),ne.forEach(a),Lt=i(h),_(Mt.$$.fragment,h),kn=i(h),D=u(h,"DIV",{class:!0});var Q=B(D);_(kt.$$.fragment,Q),Cn=i(Q),vt=u(Q,"P",{"data-svelte-h":!0}),g(vt)!=="svelte-1o27avp"&&(vt.textContent=dn),_n=i(Q),de=u(Q,"P",{"data-svelte-h":!0}),g(de)!=="svelte-1khd9yp"&&(de.innerHTML=cn),Tn=i(Q),De=u(Q,"P",{"data-svelte-h":!0}),g(De)!=="svelte-10ugs3m"&&(De.innerHTML=Fn),Qt=i(Q),wt=u(Q,"P",{"data-svelte-h":!0}),g(wt)!=="svelte-1pln4c3"&&(wt.innerHTML=vn),rt=i(Q),Dt=u(Q,"P",{"data-svelte-h":!0}),g(Dt)!=="svelte-1be7e3c"&&(Dt.innerHTML=ut),wn=i(Q),_(Oe.$$.fragment,Q),Nt=i(Q),I=u(Q,"DIV",{class:!0});var ee=B(I);_(We.$$.fragment,ee),zn=i(ee),$t=u(ee,"P",{"data-svelte-h":!0}),g($t)!=="svelte-1ic2d6h"&&($t.innerHTML=pn),yn=i(ee),_(ce.$$.fragment,ee),nn=i(ee),_(Bt.$$.fragment,ee),zt=i(ee),_(on.$$.fragment,ee),ee.forEach(a),Q.forEach(a),bn=i(h),_(Ye.$$.fragment,h),Jn=i(h),Jt=u(h,"DIV",{class:!0});var pe=B(Jt);_(Ie.$$.fragment,pe),$n=i(pe),xt=u(pe,"P",{"data-svelte-h":!0}),g(xt)!=="svelte-o4u80u"&&(xt.textContent=Re),pe.forEach(a),A=i(h),_(mt.$$.fragment,h),Ot=i(h),Te=u(h,"DIV",{class:!0});var Z=B(Te);_(sn.$$.fragment,Z),Vt=i(Z),Ut=u(Z,"P",{"data-svelte-h":!0}),g(Ut)!=="svelte-18v5559"&&(Ut.innerHTML=an),xn=i(Z),Ge=u(Z,"P",{"data-svelte-h":!0}),g(Ge)!=="svelte-p9g6"&&(Ge.innerHTML=Gn),Gt=i(Z),Rt=u(Z,"DIV",{class:!0});var oe=B(Rt);_(ye.$$.fragment,oe),it=i(oe),rn=u(oe,"P",{"data-svelte-h":!0}),g(rn)!=="svelte-wncode"&&(rn.textContent=Xt),oe.forEach(a),Hn=i(Z),Pt=u(Z,"DIV",{class:!0});var se=B(Pt);_(Ke.$$.fragment,se),ln=i(se),Yt=u(se,"P",{"data-svelte-h":!0}),g(Yt)!=="svelte-gkux83"&&(Yt.textContent=Ht),Pn=i(se),_(Y.$$.fragment,se),se.forEach(a),Pe=i(Z),Xe=u(Z,"DIV",{class:!0});var we=B(Xe);_(jt.$$.fragment,we),un=i(we),mn=u(we,"P",{"data-svelte-h":!0}),g(mn)!=="svelte-12t17yb"&&(mn.textContent=hn),Kt=i(we),_(St.$$.fragment,we),we.forEach(a),Z.forEach(a),this.h()},h(){L(ve,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(o,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(Fe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(le,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(ge,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(Jt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(Rt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(Pt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(Xe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(Te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(h,d){T(e,h,d),c(h,m,d),c(h,o,d),T(s,o,null),l(o,k),l(o,t),l(o,be),l(o,z),l(o,ue),l(o,F),l(o,me),T(v,o,null),l(o,j),l(o,ve),T(ie,ve,null),l(ve,gn),l(ve,lt),l(ve,_t),T(Me,ve,null),l(ve,je),T(Ze,ve,null),c(h,Tt,d),T(W,h,d),c(h,Ae,d),c(h,q,d),T(Le,q,null),l(q,dt),l(q,Ce),l(q,Ne),l(q,Ct),l(q,Ft),l(q,ct),l(q,pt),T($e,q,null),l(q,et),l(q,Fe),T(ze,Fe,null),l(Fe,xe),l(Fe,Qe),l(Fe,tt),T(fe,Fe,null),l(Fe,At),T(H,Fe,null),c(h,he,d),T(nt,h,d),c(h,ke,d),c(h,ge,d),T(Je,ge,null),l(ge,Be),l(ge,bt),l(ge,ot),l(ge,P),l(ge,V),l(ge,R),l(ge,Ve),T(en,ge,null),l(ge,fn),l(ge,le),T(It,le,null),l(le,st),l(le,tn),l(le,qt),T(_e,le,null),l(le,Zt),T(at,le,null),c(h,Lt,d),T(Mt,h,d),c(h,kn,d),c(h,D,d),T(kt,D,null),l(D,Cn),l(D,vt),l(D,_n),l(D,de),l(D,Tn),l(D,De),l(D,Qt),l(D,wt),l(D,rt),l(D,Dt),l(D,wn),T(Oe,D,null),l(D,Nt),l(D,I),T(We,I,null),l(I,zn),l(I,$t),l(I,yn),T(ce,I,null),l(I,nn),T(Bt,I,null),l(I,zt),T(on,I,null),c(h,bn,d),T(Ye,h,d),c(h,Jn,d),c(h,Jt,d),T(Ie,Jt,null),l(Jt,$n),l(Jt,xt),c(h,A,d),T(mt,h,d),c(h,Ot,d),c(h,Te,d),T(sn,Te,null),l(Te,Vt),l(Te,Ut),l(Te,xn),l(Te,Ge),l(Te,Gt),l(Te,Rt),T(ye,Rt,null),l(Rt,it),l(Rt,rn),l(Te,Hn),l(Te,Pt),T(Ke,Pt,null),l(Pt,ln),l(Pt,Yt),l(Pt,Pn),T(Y,Pt,null),l(Te,Pe),l(Te,Xe),T(jt,Xe,null),l(Xe,un),l(Xe,mn),l(Xe,Kt),T(St,Xe,null),Se=!0},p(h,d){const G={};d&2&&(G.$$scope={dirty:d,ctx:h}),v.$set(G);const te={};d&2&&(te.$$scope={dirty:d,ctx:h}),Me.$set(te);const E={};d&2&&(E.$$scope={dirty:d,ctx:h}),Ze.$set(E);const ne={};d&2&&(ne.$$scope={dirty:d,ctx:h}),$e.$set(ne);const K={};d&2&&(K.$$scope={dirty:d,ctx:h}),fe.$set(K);const Q={};d&2&&(Q.$$scope={dirty:d,ctx:h}),H.$set(Q);const ee={};d&2&&(ee.$$scope={dirty:d,ctx:h}),en.$set(ee);const pe={};d&2&&(pe.$$scope={dirty:d,ctx:h}),_e.$set(pe);const Z={};d&2&&(Z.$$scope={dirty:d,ctx:h}),at.$set(Z);const oe={};d&2&&(oe.$$scope={dirty:d,ctx:h}),Oe.$set(oe);const se={};d&2&&(se.$$scope={dirty:d,ctx:h}),ce.$set(se);const we={};d&2&&(we.$$scope={dirty:d,ctx:h}),Bt.$set(we);const Mn={};d&2&&(Mn.$$scope={dirty:d,ctx:h}),on.$set(Mn);const In={};d&2&&(In.$$scope={dirty:d,ctx:h}),Y.$set(In);const Un={};d&2&&(Un.$$scope={dirty:d,ctx:h}),St.$set(Un)},i(h){Se||(y(e.$$.fragment,h),y(s.$$.fragment,h),y(v.$$.fragment,h),y(ie.$$.fragment,h),y(Me.$$.fragment,h),y(Ze.$$.fragment,h),y(W.$$.fragment,h),y(Le.$$.fragment,h),y($e.$$.fragment,h),y(ze.$$.fragment,h),y(fe.$$.fragment,h),y(H.$$.fragment,h),y(nt.$$.fragment,h),y(Je.$$.fragment,h),y(en.$$.fragment,h),y(It.$$.fragment,h),y(_e.$$.fragment,h),y(at.$$.fragment,h),y(Mt.$$.fragment,h),y(kt.$$.fragment,h),y(Oe.$$.fragment,h),y(We.$$.fragment,h),y(ce.$$.fragment,h),y(Bt.$$.fragment,h),y(on.$$.fragment,h),y(Ye.$$.fragment,h),y(Ie.$$.fragment,h),y(mt.$$.fragment,h),y(sn.$$.fragment,h),y(ye.$$.fragment,h),y(Ke.$$.fragment,h),y(Y.$$.fragment,h),y(jt.$$.fragment,h),y(St.$$.fragment,h),Se=!0)},o(h){b(e.$$.fragment,h),b(s.$$.fragment,h),b(v.$$.fragment,h),b(ie.$$.fragment,h),b(Me.$$.fragment,h),b(Ze.$$.fragment,h),b(W.$$.fragment,h),b(Le.$$.fragment,h),b($e.$$.fragment,h),b(ze.$$.fragment,h),b(fe.$$.fragment,h),b(H.$$.fragment,h),b(nt.$$.fragment,h),b(Je.$$.fragment,h),b(en.$$.fragment,h),b(It.$$.fragment,h),b(_e.$$.fragment,h),b(at.$$.fragment,h),b(Mt.$$.fragment,h),b(kt.$$.fragment,h),b(Oe.$$.fragment,h),b(We.$$.fragment,h),b(ce.$$.fragment,h),b(Bt.$$.fragment,h),b(on.$$.fragment,h),b(Ye.$$.fragment,h),b(Ie.$$.fragment,h),b(mt.$$.fragment,h),b(sn.$$.fragment,h),b(ye.$$.fragment,h),b(Ke.$$.fragment,h),b(Y.$$.fragment,h),b(jt.$$.fragment,h),b(St.$$.fragment,h),Se=!1},d(h){h&&(a(m),a(o),a(Tt),a(Ae),a(q),a(he),a(ke),a(ge),a(Lt),a(kn),a(D),a(bn),a(Jn),a(Jt),a(A),a(Ot),a(Te)),M(e,h),M(s),M(v),M(ie),M(Me),M(Ze),M(W,h),M(Le),M($e),M(ze),M(fe),M(H),M(nt,h),M(Je),M(en),M(It),M(_e),M(at),M(Mt,h),M(kt),M(Oe),M(We),M(ce),M(Bt),M(on),M(Ye,h),M(Ie),M(mt,h),M(sn),M(ye),M(Ke),M(Y),M(jt),M(St)}}}function So(x){let e,m;return e=new On({props:{$$slots:{default:[Xo]},$$scope:{ctx:x}}}),{c(){f(e.$$.fragment)},l(o){_(e.$$.fragment,o)},m(o,s){T(e,o,s),m=!0},p(o,s){const k={};s&2&&(k.$$scope={dirty:s,ctx:o}),e.$set(k)},i(o){m||(y(e.$$.fragment,o),m=!0)},o(o){b(e.$$.fragment,o),m=!1},d(o){M(e,o)}}}function Ao(x){let e,m=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code> | |
| instance afterwards instead of this since the former takes care of running the pre and post processing steps while | |
| the latter silently ignores them.`;return{c(){e=p("p"),e.innerHTML=m},l(o){e=u(o,"P",{"data-svelte-h":!0}),g(e)!=="svelte-fincs2"&&(e.innerHTML=m)},m(o,s){c(o,e,s)},p:N,d(o){o&&a(e)}}}function Eo(x){let e,m="Example:",o,s,k;return s=new qe({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBGbGF4R1BUMk1vZGVsJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyb3BlbmFpLWNvbW11bml0eSUyRmdwdDIlMjIpJTBBbW9kZWwlMjAlM0QlMjBGbGF4R1BUMk1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJvcGVuYWktY29tbXVuaXR5JTJGZ3B0MiUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIySGVsbG8lMkMlMjBteSUyMGRvZyUyMGlzJTIwY3V0ZSUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIyamF4JTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyklMEElMEFsYXN0X2hpZGRlbl9zdGF0ZXMlMjAlM0QlMjBvdXRwdXRzLmxhc3RfaGlkZGVuX3N0YXRl",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, FlaxGPT2Model | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>model = FlaxGPT2Model.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>inputs = tokenizer(<span class="hljs-string">"Hello, my dog is cute"</span>, return_tensors=<span class="hljs-string">"jax"</span>) | |
| <span class="hljs-meta">>>> </span>outputs = model(**inputs) | |
| <span class="hljs-meta">>>> </span>last_hidden_states = outputs.last_hidden_state`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-11lpom8"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function Qo(x){let e,m=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code> | |
| instance afterwards instead of this since the former takes care of running the pre and post processing steps while | |
| the latter silently ignores them.`;return{c(){e=p("p"),e.innerHTML=m},l(o){e=u(o,"P",{"data-svelte-h":!0}),g(e)!=="svelte-fincs2"&&(e.innerHTML=m)},m(o,s){c(o,e,s)},p:N,d(o){o&&a(e)}}}function Do(x){let e,m="Example:",o,s,k;return s=new qe({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBGbGF4R1BUMkxNSGVhZE1vZGVsJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyb3BlbmFpLWNvbW11bml0eSUyRmdwdDIlMjIpJTBBbW9kZWwlMjAlM0QlMjBGbGF4R1BUMkxNSGVhZE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJvcGVuYWktY29tbXVuaXR5JTJGZ3B0MiUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIySGVsbG8lMkMlMjBteSUyMGRvZyUyMGlzJTIwY3V0ZSUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIybnAlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQSUwQSUyMyUyMHJldHJpZXZlJTIwbG9ndHMlMjBmb3IlMjBuZXh0JTIwdG9rZW4lMEFuZXh0X3Rva2VuX2xvZ2l0cyUyMCUzRCUyMG91dHB1dHMubG9naXRzJTVCJTNBJTJDJTIwLTElNUQ=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, FlaxGPT2LMHeadModel | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>model = FlaxGPT2LMHeadModel.from_pretrained(<span class="hljs-string">"openai-community/gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>inputs = tokenizer(<span class="hljs-string">"Hello, my dog is cute"</span>, return_tensors=<span class="hljs-string">"np"</span>) | |
| <span class="hljs-meta">>>> </span>outputs = model(**inputs) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># retrieve logts for next token</span> | |
| <span class="hljs-meta">>>> </span>next_token_logits = outputs.logits[:, -<span class="hljs-number">1</span>]`,wrap:!1}}),{c(){e=p("p"),e.textContent=m,o=r(),f(s.$$.fragment)},l(t){e=u(t,"P",{"data-svelte-h":!0}),g(e)!=="svelte-11lpom8"&&(e.textContent=m),o=i(t),_(s.$$.fragment,t)},m(t,w){c(t,e,w),c(t,o,w),T(s,t,w),k=!0},p:N,i(t){k||(y(s.$$.fragment,t),k=!0)},o(t){b(s.$$.fragment,t),k=!1},d(t){t&&(a(e),a(o)),M(s,t)}}}function Oo(x){let e,m,o,s,k,t,w="The bare GPT2 Model transformer outputting raw hidden-states without any specific head on top.",be,z,C=`This model inherits from <a href="/docs/transformers/pr_36839/en/main_classes/model#transformers.FlaxPreTrainedModel">FlaxPreTrainedModel</a>. 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.)`,ue,F,J=`This model is also a Flax Linen | |
| <a href="https://flax.readthedocs.io/en/latest/_autosummary/flax.nn.module.html" rel="nofollow">flax.nn.Module</a> subclass. Use it as a | |
| regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`,me,v,j="Finally, this model supports inherent JAX features such as:",ve,ie,gn='<li><a href="https://jax.readthedocs.io/en/latest/jax.html#just-in-time-compilation-jit" rel="nofollow">Just-In-Time (JIT) compilation</a></li> <li><a href="https://jax.readthedocs.io/en/latest/jax.html#automatic-differentiation" rel="nofollow">Automatic Differentiation</a></li> <li><a href="https://jax.readthedocs.io/en/latest/jax.html#vectorization-vmap" rel="nofollow">Vectorization</a></li> <li><a href="https://jax.readthedocs.io/en/latest/jax.html#parallelization-pmap" rel="nofollow">Parallelization</a></li>',lt,O,_t,Me,je,Ze="The <code>FlaxGPT2PreTrainedModel</code> forward method, overrides the <code>__call__</code> special method.",Tt,W,Ae,q,Le,dt,Ce,S,Ne,Ct,Ee,Ft=`The GPT2 Model transformer with a language modeling head on top (linear layer with weights tied to the input | |
| embeddings).`,ct,ae,pt=`This model inherits from <a href="/docs/transformers/pr_36839/en/main_classes/model#transformers.FlaxPreTrainedModel">FlaxPreTrainedModel</a>. 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.)`,$e,et,Fe=`This model is also a Flax Linen | |
| <a href="https://flax.readthedocs.io/en/latest/_autosummary/flax.nn.module.html" rel="nofollow">flax.nn.Module</a> subclass. Use it as a | |
| regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.`,ze,xe,Qe="Finally, this model supports inherent JAX features such as:",yt,tt,fe='<li><a href="https://jax.readthedocs.io/en/latest/jax.html#just-in-time-compilation-jit" rel="nofollow">Just-In-Time (JIT) compilation</a></li> <li><a href="https://jax.readthedocs.io/en/latest/jax.html#automatic-differentiation" rel="nofollow">Automatic Differentiation</a></li> <li><a href="https://jax.readthedocs.io/en/latest/jax.html#vectorization-vmap" rel="nofollow">Vectorization</a></li> <li><a href="https://jax.readthedocs.io/en/latest/jax.html#parallelization-pmap" rel="nofollow">Parallelization</a></li>',At,H,he,nt,ke,ge="The <code>FlaxGPT2PreTrainedModel</code> forward method, overrides the <code>__call__</code> special method.",Je,Be,bt,Ue,ot;return e=new re({props:{title:"FlaxGPT2Model",local:"transformers.FlaxGPT2Model",headingTag:"h2"}}),s=new X({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/pr_36839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) — 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/pr_36839/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>) — | |
| 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/pr_36839/en/main_classes/model#transformers.FlaxPreTrainedModel.to_fp16">to_fp16()</a> and | |
| <a href="/docs/transformers/pr_36839/en/main_classes/model#transformers.FlaxPreTrainedModel.to_bf16">to_bf16()</a>.`,name:"dtype"}],source:"https://github.com/huggingface/transformers/blob/vr_36839/src/transformers/models/gpt2/modeling_flax_gpt2.py#L661"}}),_t=new X({props:{name:"__call__",anchor:"transformers.FlaxGPT2Model.__call__",parameters:[{name:"input_ids",val:""},{name:"attention_mask",val:" = None"},{name:"position_ids",val:" = None"},{name:"encoder_hidden_states",val:": typing.Optional[jax.Array] = None"},{name:"encoder_attention_mask",val:": typing.Optional[jax.Array] = None"},{name:"params",val:": dict = None"},{name:"past_key_values",val:": dict = None"},{name:"dropout_rng",val:": <function PRNGKey at 0x7f37c3379510> = 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>) — | |
| <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/pr_36839/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_36839/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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_36839/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/vr_36839/src/transformers/models/gpt2/modeling_flax_gpt2.py#L456",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_36839/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/pr_36839/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>) — 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>) — 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>) — 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>) — 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>) — 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’s cross-attention layer, after the attention softmax, used to compute the | |
| weighted average in the cross-attention heads.</p> | |
| </li> | |
| </ul> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_36839/en/main_classes/output#transformers.modeling_flax_outputs.FlaxBaseModelOutputWithPastAndCrossAttentions" | |
| >transformers.modeling_flax_outputs.FlaxBaseModelOutputWithPastAndCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p> | |
| `}}),W=new gt({props:{$$slots:{default:[Ao]},$$scope:{ctx:x}}}),q=new ft({props:{anchor:"transformers.FlaxGPT2Model.__call__.example",$$slots:{default:[Eo]},$$scope:{ctx:x}}}),dt=new re({props:{title:"FlaxGPT2LMHeadModel",local:"transformers.FlaxGPT2LMHeadModel",headingTag:"h2"}}),Ne=new X({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/pr_36839/en/model_doc/gpt2#transformers.GPT2Config">GPT2Config</a>) — 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/pr_36839/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>) — | |
| 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/pr_36839/en/main_classes/model#transformers.FlaxPreTrainedModel.to_fp16">to_fp16()</a> and | |
| <a href="/docs/transformers/pr_36839/en/main_classes/model#transformers.FlaxPreTrainedModel.to_bf16">to_bf16()</a>.`,name:"dtype"}],source:"https://github.com/huggingface/transformers/blob/vr_36839/src/transformers/models/gpt2/modeling_flax_gpt2.py#L735"}}),he=new X({props:{name:"__call__",anchor:"transformers.FlaxGPT2LMHeadModel.__call__",parameters:[{name:"input_ids",val:""},{name:"attention_mask",val:" = None"},{name:"position_ids",val:" = None"},{name:"encoder_hidden_states",val:": typing.Optional[jax.Array] = None"},{name:"encoder_attention_mask",val:": typing.Optional[jax.Array] = None"},{name:"params",val:": dict = None"},{name:"past_key_values",val:": dict = None"},{name:"dropout_rng",val:": <function PRNGKey at 0x7f37c3379510> = 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>) — | |
| <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/pr_36839/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/pr_36839/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and | |
| <a href="/docs/transformers/pr_36839/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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| Whether or not to return a <a href="/docs/transformers/pr_36839/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/vr_36839/src/transformers/models/gpt2/modeling_flax_gpt2.py#L456",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A <a | |
| href="/docs/transformers/pr_36839/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/pr_36839/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>) — 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>) — 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>) — 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>) — 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>) — 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:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/transformers/pr_36839/en/main_classes/output#transformers.modeling_flax_outputs.FlaxCausalLMOutputWithCrossAttentions" | |
| >transformers.modeling_flax_outputs.FlaxCausalLMOutputWithCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p> | |
| `}}),Be=new gt({props:{$$slots:{default:[Qo]},$$scope:{ctx:x}}}),Ue=new ft({props:{anchor:"transformers.FlaxGPT2LMHeadModel.__call__.example",$$slots:{default:[Do]},$$scope:{ctx:x}}}),{c(){f(e.$$.fragment),m=r(),o=p("div"),f(s.$$.fragment),k=r(),t=p("p"),t.textContent=w,be=r(),z=p("p"),z.innerHTML=C,ue=r(),F=p("p"),F.innerHTML=J,me=r(),v=p("p"),v.textContent=j,ve=r(),ie=p("ul"),ie.innerHTML=gn,lt=r(),O=p("div"),f(_t.$$.fragment),Me=r(),je=p("p"),je.innerHTML=Ze,Tt=r(),f(W.$$.fragment),Ae=r(),f(q.$$.fragment),Le=r(),f(dt.$$.fragment),Ce=r(),S=p("div"),f(Ne.$$.fragment),Ct=r(),Ee=p("p"),Ee.textContent=Ft,ct=r(),ae=p("p"),ae.innerHTML=pt,$e=r(),et=p("p"),et.innerHTML=Fe,ze=r(),xe=p("p"),xe.textContent=Qe,yt=r(),tt=p("ul"),tt.innerHTML=fe,At=r(),H=p("div"),f(he.$$.fragment),nt=r(),ke=p("p"),ke.innerHTML=ge,Je=r(),f(Be.$$.fragment),bt=r(),f(Ue.$$.fragment),this.h()},l(P){_(e.$$.fragment,P),m=i(P),o=u(P,"DIV",{class:!0});var U=B(o);_(s.$$.fragment,U),k=i(U),t=u(U,"P",{"data-svelte-h":!0}),g(t)!=="svelte-4bubxi"&&(t.textContent=w),be=i(U),z=u(U,"P",{"data-svelte-h":!0}),g(z)!=="svelte-ik86s7"&&(z.innerHTML=C),ue=i(U),F=u(U,"P",{"data-svelte-h":!0}),g(F)!=="svelte-idybz1"&&(F.innerHTML=J),me=i(U),v=u(U,"P",{"data-svelte-h":!0}),g(v)!=="svelte-1pplc4a"&&(v.textContent=j),ve=i(U),ie=u(U,"UL",{"data-svelte-h":!0}),g(ie)!=="svelte-1w7z84m"&&(ie.innerHTML=gn),lt=i(U),O=u(U,"DIV",{class:!0});var V=B(O);_(_t.$$.fragment,V),Me=i(V),je=u(V,"P",{"data-svelte-h":!0}),g(je)!=="svelte-1dafdvs"&&(je.innerHTML=Ze),Tt=i(V),_(W.$$.fragment,V),Ae=i(V),_(q.$$.fragment,V),V.forEach(a),U.forEach(a),Le=i(P),_(dt.$$.fragment,P),Ce=i(P),S=u(P,"DIV",{class:!0});var R=B(S);_(Ne.$$.fragment,R),Ct=i(R),Ee=u(R,"P",{"data-svelte-h":!0}),g(Ee)!=="svelte-jjb0s"&&(Ee.textContent=Ft),ct=i(R),ae=u(R,"P",{"data-svelte-h":!0}),g(ae)!=="svelte-ik86s7"&&(ae.innerHTML=pt),$e=i(R),et=u(R,"P",{"data-svelte-h":!0}),g(et)!=="svelte-idybz1"&&(et.innerHTML=Fe),ze=i(R),xe=u(R,"P",{"data-svelte-h":!0}),g(xe)!=="svelte-1pplc4a"&&(xe.textContent=Qe),yt=i(R),tt=u(R,"UL",{"data-svelte-h":!0}),g(tt)!=="svelte-1w7z84m"&&(tt.innerHTML=fe),At=i(R),H=u(R,"DIV",{class:!0});var He=B(H);_(he.$$.fragment,He),nt=i(He),ke=u(He,"P",{"data-svelte-h":!0}),g(ke)!=="svelte-1dafdvs"&&(ke.innerHTML=ge),Je=i(He),_(Be.$$.fragment,He),bt=i(He),_(Ue.$$.fragment,He),He.forEach(a),R.forEach(a),this.h()},h(){L(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(o,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(P,U){T(e,P,U),c(P,m,U),c(P,o,U),T(s,o,null),l(o,k),l(o,t),l(o,be),l(o,z),l(o,ue),l(o,F),l(o,me),l(o,v),l(o,ve),l(o,ie),l(o,lt),l(o,O),T(_t,O,null),l(O,Me),l(O,je),l(O,Tt),T(W,O,null),l(O,Ae),T(q,O,null),c(P,Le,U),T(dt,P,U),c(P,Ce,U),c(P,S,U),T(Ne,S,null),l(S,Ct),l(S,Ee),l(S,ct),l(S,ae),l(S,$e),l(S,et),l(S,ze),l(S,xe),l(S,yt),l(S,tt),l(S,At),l(S,H),T(he,H,null),l(H,nt),l(H,ke),l(H,Je),T(Be,H,null),l(H,bt),T(Ue,H,null),ot=!0},p(P,U){const V={};U&2&&(V.$$scope={dirty:U,ctx:P}),W.$set(V);const R={};U&2&&(R.$$scope={dirty:U,ctx:P}),q.$set(R);const He={};U&2&&(He.$$scope={dirty:U,ctx:P}),Be.$set(He);const Ve={};U&2&&(Ve.$$scope={dirty:U,ctx:P}),Ue.$set(Ve)},i(P){ot||(y(e.$$.fragment,P),y(s.$$.fragment,P),y(_t.$$.fragment,P),y(W.$$.fragment,P),y(q.$$.fragment,P),y(dt.$$.fragment,P),y(Ne.$$.fragment,P),y(he.$$.fragment,P),y(Be.$$.fragment,P),y(Ue.$$.fragment,P),ot=!0)},o(P){b(e.$$.fragment,P),b(s.$$.fragment,P),b(_t.$$.fragment,P),b(W.$$.fragment,P),b(q.$$.fragment,P),b(dt.$$.fragment,P),b(Ne.$$.fragment,P),b(he.$$.fragment,P),b(Be.$$.fragment,P),b(Ue.$$.fragment,P),ot=!1},d(P){P&&(a(m),a(o),a(Le),a(Ce),a(S)),M(e,P),M(s),M(_t),M(W),M(q),M(dt,P),M(Ne),M(he),M(Be),M(Ue)}}}function Yo(x){let e,m;return e=new On({props:{$$slots:{default:[Oo]},$$scope:{ctx:x}}}),{c(){f(e.$$.fragment)},l(o){_(e.$$.fragment,o)},m(o,s){T(e,o,s),m=!0},p(o,s){const k={};s&2&&(k.$$scope={dirty:s,ctx:o}),e.$set(k)},i(o){m||(y(e.$$.fragment,o),m=!0)},o(o){b(e.$$.fragment,o),m=!1},d(o){M(e,o)}}}function Ko(x){let e,m,o,s,k,t,w,be='<a href="https://huggingface.co/models?filter=gpt2"><img alt="Models" src="https://img.shields.io/badge/All_model_pages-gpt2-blueviolet"/></a> <a href="https://huggingface.co/spaces/docs-demos/gpt2"><img alt="Spaces" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue"/></a>',z,C,ue,F,J=`OpenAI GPT-2 model was proposed in <a href="https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf" rel="nofollow">Language Models are Unsupervised Multitask Learners</a> by Alec | |
| Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei and Ilya Sutskever from <a href="https://huggingface.co/openai" rel="nofollow">OpenAI</a>. It’s a causal (unidirectional) | |
| transformer pretrained using language modeling on a very large corpus of ~40 GB of text data.`,me,v,j="The abstract from the paper is the following:",ve,ie,gn=`<em>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.</em>`,lt,O,_t=`<a href="https://transformer.huggingface.co/doc/gpt2-large" rel="nofollow">Write With Transformer</a> 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: <em>distilgpt-2</em>.`,Me,je,Ze='This model was contributed by <a href="https://huggingface.co/thomwolf" rel="nofollow">thomwolf</a>. The original code can be found <a href="https://openai.com/blog/better-language-models/" rel="nofollow">here</a>.',Tt,W,Ae,q,Le=`<li>GPT-2 is a model with absolute position embeddings so it’s usually advised to pad the inputs on the right rather than | |
| the left.</li> <li>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 <em>run_generation.py</em> example script.</li> <li>The model can take the <em>past_key_values</em> (for PyTorch) or <em>past</em> (for TF) as input, which is the previously computed | |
| key/value attention pairs. Using this (<em>past_key_values</em> or <em>past</em>) value prevents the model from re-computing | |
| pre-computed values in the context of text generation. For PyTorch, see <em>past_key_values</em> argument of the | |
| <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2Model.forward">GPT2Model.forward()</a> method, or for TF the <em>past</em> argument of the | |
| <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.TFGPT2Model.call">TFGPT2Model.call()</a> method for more information on its usage.</li> <li>Enabling the <em>scale_attn_by_inverse_layer_idx</em> and <em>reorder_and_upcast_attn</em> flags will apply the training stability | |
| improvements from <a href="https://github.com/stanford-crfm/mistral/" rel="nofollow">Mistral</a> (for PyTorch only).</li>`,dt,Ce,S,Ne,Ct="The <code>generate()</code> method can be used to generate text using GPT2 model.",Ee,Ft,ct,ae,pt,$e,et="Flash Attention 2 is a faster, optimized version of the attention scores computation which relies on <code>cuda</code> kernels.",Fe,ze,xe,Qe,yt='First, check whether your hardware is compatible with Flash Attention 2. The latest list of compatible hardware can be found in the <a href="https://github.com/Dao-AILab/flash-attention#installation-and-features" rel="nofollow">official documentation</a>. If your hardware is not compatible with Flash Attention 2, you can still benefit from attention kernel optimisations through Better Transformer support covered <a href="https://huggingface.co/docs/transformers/main/en/model_doc/bark#using-better-transformer" rel="nofollow">above</a>.',tt,fe,At='Next, <a href="https://github.com/Dao-AILab/flash-attention#installation-and-features" rel="nofollow">install</a> the latest version of Flash Attention 2:',H,he,nt,ke,ge,Je,Be='To load a model using Flash Attention 2, we can pass the argument <code>attn_implementation="flash_attention_2"</code> to <a href="https://huggingface.co/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained" rel="nofollow"><code>.from_pretrained</code></a>. We’ll also load the model in half-precision (e.g. <code>torch.float16</code>), since it results in almost no degradation to audio quality but significantly lower memory usage and faster inference:',bt,Ue,ot,P,U,V,R="Below is an expected speedup diagram that compares pure inference time between the native implementation in transformers using <code>gpt2</code> checkpoint and the Flash Attention 2 version of the model using a sequence length of 512.",He,Ve,en='<img src="https://huggingface.co/datasets/EduardoPacheco/documentation-images/resolve/main/gpt2_flash_attention_2_speedup.jpg"/>',fn,le,It,st,tn=`PyTorch includes a native scaled dot-product attention (SDPA) operator as part of <code>torch.nn.functional</code>. This function | |
| encompasses several implementations that can be applied depending on the inputs and the hardware in use. See the | |
| <a href="https://pytorch.org/docs/stable/generated/torch.nn.functional.scaled_dot_product_attention.html" rel="nofollow">official documentation</a> | |
| or the <a href="https://huggingface.co/docs/transformers/main/en/perf_infer_gpu_one#pytorch-scaled-dot-product-attention" rel="nofollow">GPU Inference</a> | |
| page for more information.`,Et,qt,_e=`SDPA is used by default for <code>torch>=2.1.1</code> when an implementation is available, but you may also set | |
| <code>attn_implementation="sdpa"</code> in <code>from_pretrained()</code> to explicitly request SDPA to be used.`,Zt,at,Lt,Mt,kn="For the best speedups, we recommend loading the model in half-precision (e.g. <code>torch.float16</code> or <code>torch.bfloat16</code>).",D,kt,Cn=`On a local benchmark (rtx3080ti-16GB, PyTorch 2.2.1, OS Ubuntu 22.04) using <code>float16</code> with | |
| <a href="https://huggingface.co/openai-community/gpt2-large" rel="nofollow">gpt2-large</a>, we saw the | |
| following speedups during training and inference.`,vt,dn,_n,de,cn='<thead><tr><th align="right">Batch size</th> <th align="right">Seq len</th> <th align="right">Time per batch (Eager - s)</th> <th align="right">Time per batch (SDPA - s)</th> <th align="right">Speedup (%)</th> <th align="right">Eager peak mem (MB)</th> <th align="right">SDPA peak mem (MB)</th> <th align="right">Mem saving (%)</th></tr></thead> <tbody><tr><td align="right">1</td> <td align="right">128</td> <td align="right">0.039</td> <td align="right">0.032</td> <td align="right">23.042</td> <td align="right">3482.32</td> <td align="right">3494.62</td> <td align="right">-0.352</td></tr> <tr><td align="right">1</td> <td align="right">256</td> <td align="right">0.073</td> <td align="right">0.059</td> <td align="right">25.15</td> <td align="right">3546.66</td> <td align="right">3552.6</td> <td align="right">-0.167</td></tr> <tr><td align="right">1</td> <td align="right">512</td> <td align="right">0.155</td> <td align="right">0.118</td> <td align="right">30.96</td> <td align="right">4230.1</td> <td align="right">3665.59</td> <td align="right">15.4</td></tr> <tr><td align="right">1</td> <td align="right">1024</td> <td align="right">0.316</td> <td align="right">0.209</td> <td align="right">50.839</td> <td align="right">8682.26</td> <td align="right">4881.09</td> <td align="right">77.875</td></tr> <tr><td align="right">2</td> <td align="right">128</td> <td align="right">0.07</td> <td align="right">0.06</td> <td align="right">15.324</td> <td align="right">3557.8</td> <td align="right">3545.91</td> <td align="right">0.335</td></tr> <tr><td align="right">2</td> <td align="right">256</td> <td align="right">0.143</td> <td align="right">0.122</td> <td align="right">16.53</td> <td align="right">3901.5</td> <td align="right">3657.68</td> <td align="right">6.666</td></tr> <tr><td align="right">2</td> <td align="right">512</td> <td align="right">0.267</td> <td align="right">0.213</td> <td align="right">25.626</td> <td align="right">7062.21</td> <td align="right">4876.47</td> <td align="right">44.822</td></tr> <tr><td align="right">2</td> <td align="right">1024</td> <td align="right">OOM</td> <td align="right">0.404</td> <td align="right">/</td> <td align="right">OOM</td> <td align="right">8096.35</td> <td align="right">SDPA does not OOM</td></tr> <tr><td align="right">4</td> <td align="right">128</td> <td align="right">0.134</td> <td align="right">0.128</td> <td align="right">4.412</td> <td align="right">3675.79</td> <td align="right">3648.72</td> <td align="right">0.742</td></tr> <tr><td align="right">4</td> <td align="right">256</td> <td align="right">0.243</td> <td align="right">0.217</td> <td align="right">12.292</td> <td align="right">6129.76</td> <td align="right">4871.12</td> <td align="right">25.839</td></tr> <tr><td align="right">4</td> <td align="right">512</td> <td align="right">0.494</td> <td align="right">0.406</td> <td align="right">21.687</td> <td align="right">12466.6</td> <td align="right">8102.64</td> <td align="right">53.858</td></tr> <tr><td align="right">4</td> <td align="right">1024</td> <td align="right">OOM</td> <td align="right">0.795</td> <td align="right">/</td> <td align="right">OOM</td> <td align="right">14568.2</td> <td align="right">SDPA does not OOM</td></tr></tbody>',Tn,De,Fn,Qt,wt='<thead><tr><th align="right">Batch size</th> <th align="right">Seq len</th> <th align="right">Per token latency Eager (ms)</th> <th align="right">Per token latency SDPA (ms)</th> <th align="right">Speedup (%)</th> <th align="right">Mem Eager (MB)</th> <th align="right">Mem SDPA (MB)</th> <th align="right">Mem saved (%)</th></tr></thead> <tbody><tr><td align="right">1</td> <td align="right">128</td> <td align="right">7.991</td> <td align="right">6.968</td> <td align="right">14.681</td> <td align="right">1685.2</td> <td align="right">1701.32</td> <td align="right">-0.947</td></tr> <tr><td align="right">1</td> <td align="right">256</td> <td align="right">8.462</td> <td align="right">7.199</td> <td align="right">17.536</td> <td align="right">1745.49</td> <td align="right">1770.78</td> <td align="right">-1.428</td></tr> <tr><td align="right">1</td> <td align="right">512</td> <td align="right">8.68</td> <td align="right">7.853</td> <td align="right">10.529</td> <td align="right">1907.69</td> <td align="right">1921.29</td> <td align="right">-0.708</td></tr> <tr><td align="right">1</td> <td align="right">768</td> <td align="right">9.101</td> <td align="right">8.365</td> <td align="right">8.791</td> <td align="right">2032.93</td> <td align="right">2068.12</td> <td align="right">-1.701</td></tr> <tr><td align="right">2</td> <td align="right">128</td> <td align="right">9.169</td> <td align="right">9.001</td> <td align="right">1.861</td> <td align="right">1803.84</td> <td align="right">1811.4</td> <td align="right">-0.418</td></tr> <tr><td align="right">2</td> <td align="right">256</td> <td align="right">9.907</td> <td align="right">9.78</td> <td align="right">1.294</td> <td align="right">1907.72</td> <td align="right">1921.44</td> <td align="right">-0.714</td></tr> <tr><td align="right">2</td> <td align="right">512</td> <td align="right">11.519</td> <td align="right">11.644</td> <td align="right">-1.071</td> <td align="right">2176.86</td> <td align="right">2197.75</td> <td align="right">-0.951</td></tr> <tr><td align="right">2</td> <td align="right">768</td> <td align="right">13.022</td> <td align="right">13.407</td> <td align="right">-2.873</td> <td align="right">2464.3</td> <td align="right">2491.06</td> <td align="right">-1.074</td></tr> <tr><td align="right">4</td> <td align="right">128</td> <td align="right">10.097</td> <td align="right">9.831</td> <td align="right">2.709</td> <td align="right">1942.25</td> <td align="right">1985.13</td> <td align="right">-2.16</td></tr> <tr><td align="right">4</td> <td align="right">256</td> <td align="right">11.599</td> <td align="right">11.398</td> <td align="right">1.764</td> <td align="right">2177.28</td> <td align="right">2197.86</td> <td align="right">-0.937</td></tr> <tr><td align="right">4</td> <td align="right">512</td> <td align="right">14.653</td> <td align="right">14.45</td> <td align="right">1.411</td> <td align="right">2753.16</td> <td align="right">2772.57</td> <td align="right">-0.7</td></tr> <tr><td align="right">4</td> <td align="right">768</td> <td align="right">17.846</td> <td align="right">17.617</td> <td align="right">1.299</td> <td align="right">3327.04</td> <td align="right">3343.97</td> <td align="right">-0.506</td></tr></tbody>',vn,rt,Dt,ut,wn="A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with GPT2. If you’re interested in submitting a resource to be included here, please feel free to open a Pull Request and we’ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource.",Oe,Nt,I,We,zn='<li>A blog on how to <a href="https://www.philschmid.de/fine-tune-a-non-english-gpt-2-model-with-huggingface" rel="nofollow">Finetune a non-English GPT-2 Model with Hugging Face</a>.</li> <li>A blog on <a href="https://huggingface.co/blog/how-to-generate" rel="nofollow">How to generate text: using different decoding methods for language generation with Transformers</a> with GPT-2.</li> <li>A blog on <a href="https://huggingface.co/blog/codeparrot" rel="nofollow">Training CodeParrot 🦜 from Scratch</a>, a large GPT-2 model.</li> <li>A blog on <a href="https://huggingface.co/blog/tf-xla-generate" rel="nofollow">Faster Text Generation with TensorFlow and XLA</a> with GPT-2.</li> <li>A blog on <a href="https://huggingface.co/blog/megatron-training" rel="nofollow">How to train a Language Model with Megatron-LM</a> with a GPT-2 model.</li> <li>A notebook on how to <a href="https://colab.research.google.com/github/AlekseyKorshuk/huggingartists/blob/master/huggingartists-demo.ipynb" rel="nofollow">finetune GPT2 to generate lyrics in the style of your favorite artist</a>. 🌎</li> <li>A notebook on how to <a href="https://colab.research.google.com/github/borisdayma/huggingtweets/blob/master/huggingtweets-demo.ipynb" rel="nofollow">finetune GPT2 to generate tweets in the style of your favorite Twitter user</a>. 🌎</li> <li><a href="https://huggingface.co/course/en/chapter7/6?fw=pt#training-a-causal-language-model-from-scratch" rel="nofollow">Causal language modeling</a> chapter of the 🤗 Hugging Face Course.</li> <li><a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2LMHeadModel">GPT2LMHeadModel</a> is supported by this <a href="https://github.com/huggingface/transformers/tree/main/examples/pytorch/language-modeling#gpt-2gpt-and-causal-language-modeling" rel="nofollow">causal language modeling example script</a>, <a href="https://github.com/huggingface/transformers/tree/main/examples/pytorch/text-generation" rel="nofollow">text generation example script</a>, and <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling.ipynb" rel="nofollow">notebook</a>.</li> <li><a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.TFGPT2LMHeadModel">TFGPT2LMHeadModel</a> is supported by this <a href="https://github.com/huggingface/transformers/tree/main/examples/tensorflow/language-modeling#run_clmpy" rel="nofollow">causal language modeling example script</a> and <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling-tf.ipynb" rel="nofollow">notebook</a>.</li> <li><a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.FlaxGPT2LMHeadModel">FlaxGPT2LMHeadModel</a> is supported by this <a href="https://github.com/huggingface/transformers/tree/main/examples/flax/language-modeling#causal-language-modeling" rel="nofollow">causal language modeling example script</a> and <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/causal_language_modeling_flax.ipynb" rel="nofollow">notebook</a>.</li> <li><a href="../tasks/sequence_classification">Text classification task guide</a></li> <li><a href="../tasks/token_classification">Token classification task guide</a></li> <li><a href="../tasks/language_modeling">Causal language modeling task guide</a></li>',$t,pn,yn,ce,nn,Bt,zt,on=`This is the configuration class to store the configuration of a <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2Model">GPT2Model</a> or a <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.TFGPT2Model">TFGPT2Model</a>. 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 | |
| <a href="https://huggingface.co/openai-community/gpt2" rel="nofollow">openai-community/gpt2</a> architecture.`,bn,Ye,Jn=`Configuration objects inherit from <a href="/docs/transformers/pr_36839/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> and can be used to control the model outputs. Read the | |
| documentation from <a href="/docs/transformers/pr_36839/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,Jt,Ie,$n,xt,Re,A,mt,Ot,Te,sn="Construct a GPT-2 tokenizer. Based on byte-level Byte-Pair-Encoding.",Vt,Ut,an="This tokenizer has been trained to treat spaces like parts of the tokens (a bit like sentencepiece) so a word will",xn,Ge,Gn,Gt,Rt=`You can get around that behavior by passing <code>add_prefix_space=True</code> 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.`,ye,it,rn,Xt,Hn=`This tokenizer inherits from <a href="/docs/transformers/pr_36839/en/main_classes/tokenizer#transformers.PreTrainedTokenizer">PreTrainedTokenizer</a> which contains most of the main methods. Users should refer to | |
| this superclass for more information regarding those methods.`,Pt,Ke,ln,Yt,Ht,Pn,Y,Pe,Xe,jt,un=`Construct a “fast” GPT-2 tokenizer (backed by HuggingFace’s <em>tokenizers</em> library). Based on byte-level | |
| Byte-Pair-Encoding.`,mn,hn,Kt="This tokenizer has been trained to treat spaces like parts of the tokens (a bit like sentencepiece) so a word will",St,Se,h,d,G=`You can get around that behavior by passing <code>add_prefix_space=True</code> when instantiating this tokenizer, but since | |
| the model was not pretrained this way, it might yield a decrease in performance.`,te,E,ne,K,Q=`This tokenizer inherits from <a href="/docs/transformers/pr_36839/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast">PreTrainedTokenizerFast</a> which contains most of the main methods. Users should | |
| refer to this superclass for more information regarding those methods.`,ee,pe,Z,oe,se,we,Mn,In="Base class for outputs of models predicting if two sentences are consecutive or not.",Un,Wn,Zn,Dn,Vn,Yn="Base class for outputs of models predicting if two sentences are consecutive or not.",Sn,qn,An,Ln,En,Rn,Qn;return k=new re({props:{title:"OpenAI GPT2",local:"openai-gpt2",headingTag:"h1"}}),C=new re({props:{title:"Overview",local:"overview",headingTag:"h2"}}),W=new re({props:{title:"Usage tips",local:"usage-tips",headingTag:"h2"}}),Ce=new re({props:{title:"Usage example",local:"usage-example",headingTag:"h2"}}),Ft=new qe({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMmdwdDIlMjIpJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJHUFQyJTIwaXMlMjBhJTIwbW9kZWwlMjBkZXZlbG9wZWQlMjBieSUyME9wZW5BSS4lMjIlMEElMEFpbnB1dF9pZHMlMjAlM0QlMjB0b2tlbml6ZXIocHJvbXB0JTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikuaW5wdXRfaWRzJTBBJTBBZ2VuX3Rva2VucyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCUwQSUyMCUyMCUyMCUyMGlucHV0X2lkcyUyQyUwQSUyMCUyMCUyMCUyMGRvX3NhbXBsZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjB0ZW1wZXJhdHVyZSUzRDAuOSUyQyUwQSUyMCUyMCUyMCUyMG1heF9sZW5ndGglM0QxMDAlMkMlMEEpJTBBZ2VuX3RleHQlMjAlM0QlMjB0b2tlbml6ZXIuYmF0Y2hfZGVjb2RlKGdlbl90b2tlbnMpJTVCMCU1RA==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer | |
| <span class="hljs-meta">>>> </span>model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">"gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>prompt = <span class="hljs-string">"GPT2 is a model developed by OpenAI."</span> | |
| <span class="hljs-meta">>>> </span>input_ids = tokenizer(prompt, return_tensors=<span class="hljs-string">"pt"</span>).input_ids | |
| <span class="hljs-meta">>>> </span>gen_tokens = model.generate( | |
| <span class="hljs-meta">... </span> input_ids, | |
| <span class="hljs-meta">... </span> do_sample=<span class="hljs-literal">True</span>, | |
| <span class="hljs-meta">... </span> temperature=<span class="hljs-number">0.9</span>, | |
| <span class="hljs-meta">... </span> max_length=<span class="hljs-number">100</span>, | |
| <span class="hljs-meta">... </span>) | |
| <span class="hljs-meta">>>> </span>gen_text = tokenizer.batch_decode(gen_tokens)[<span class="hljs-number">0</span>]`,wrap:!1}}),ae=new re({props:{title:"Using Flash Attention 2",local:"using-flash-attention-2",headingTag:"h2"}}),ze=new re({props:{title:"Installation",local:"installation",headingTag:"h3"}}),he=new qe({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1VJTIwZmxhc2gtYXR0biUyMC0tbm8tYnVpbGQtaXNvbGF0aW9u",highlighted:"pip install -U flash-attn --no-build-isolation",wrap:!1}}),ke=new re({props:{title:"Usage",local:"usage",headingTag:"h3"}}),Ue=new qe({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMkMlMjBBdXRvVG9rZW5pemVyJTBBZGV2aWNlJTIwJTNEJTIwJTIyY3VkYSUyMiUyMCUyMyUyMHRoZSUyMGRldmljZSUyMHRvJTIwbG9hZCUyMHRoZSUyMG1vZGVsJTIwb250byUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMmdwdDIlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjBhdHRuX2ltcGxlbWVudGF0aW9uJTNEJTIyZmxhc2hfYXR0ZW50aW9uXzIlMjIpJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJkZWYlMjBoZWxsb193b3JsZCgpJTNBJTIyJTBBJTBBbW9kZWxfaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCU1QnByb21wdCU1RCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpLnRvKGRldmljZSklMEFtb2RlbC50byhkZXZpY2UpJTBBJTBBZ2VuZXJhdGVkX2lkcyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqbW9kZWxfaW5wdXRzJTJDJTIwbWF4X25ld190b2tlbnMlM0QxMDAlMkMlMjBkb19zYW1wbGUlM0RUcnVlKSUwQXRva2VuaXplci5iYXRjaF9kZWNvZGUoZ2VuZXJhdGVkX2lkcyklNUIwJTVE",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer | |
| <span class="hljs-meta">>>> </span>device = <span class="hljs-string">"cuda"</span> <span class="hljs-comment"># the device to load the model onto</span> | |
| <span class="hljs-meta">>>> </span>model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">"gpt2"</span>, torch_dtype=torch.float16, attn_implementation=<span class="hljs-string">"flash_attention_2"</span>) | |
| <span class="hljs-meta">>>> </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"gpt2"</span>) | |
| <span class="hljs-meta">>>> </span>prompt = <span class="hljs-string">"def hello_world():"</span> | |
| <span class="hljs-meta">>>> </span>model_inputs = tokenizer([prompt], return_tensors=<span class="hljs-string">"pt"</span>).to(device) | |
| <span class="hljs-meta">>>> </span>model.to(device) | |
| <span class="hljs-meta">>>> </span>generated_ids = model.generate(**model_inputs, max_new_tokens=<span class="hljs-number">100</span>, do_sample=<span class="hljs-literal">True</span>) | |
| <span class="hljs-meta">>>> </span>tokenizer.batch_decode(generated_ids)[<span class="hljs-number">0</span>]`,wrap:!1}}),P=new re({props:{title:"Expected speedups",local:"expected-speedups",headingTag:"h3"}}),le=new re({props:{title:"Using Scaled Dot Product Attention (SDPA)",local:"using-scaled-dot-product-attention-sdpa",headingTag:"h2"}}),at=new qe({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMGF0dG5faW1wbGVtZW50YXRpb24lM0QlMjJzZHBhJTIyKSUwQS4uLg==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM | |
| model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">"gpt2"</span>, torch_dtype=torch.float16, attn_implementation=<span class="hljs-string">"sdpa"</span>) | |
| ...`,wrap:!1}}),dn=new re({props:{title:"Training",local:"training",headingTag:"h3"}}),De=new re({props:{title:"Inference",local:"inference",headingTag:"h3"}}),rt=new re({props:{title:"Resources",local:"resources",headingTag:"h2"}}),Nt=new ro({props:{pipeline:"text-generation"}}),pn=new re({props:{title:"GPT2Config",local:"transformers.GPT2Config",headingTag:"h2"}}),nn=new X({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) — | |
| 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/pr_36839/en/model_doc/gpt2#transformers.GPT2Model">GPT2Model</a> or <a href="/docs/transformers/pr_36839/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) — | |
| 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) — | |
| 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) — | |
| 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) — | |
| 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>) — | |
| 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>"gelu_new"</code>) — | |
| Activation function, to be selected in the list <code>["relu", "silu", "gelu", "tanh", "gelu_new"]</code>.`,name:"activation_function"},{anchor:"transformers.GPT2Config.resid_pdrop",description:`<strong>resid_pdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) — | |
| The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.`,name:"resid_pdrop"},{anchor:"transformers.GPT2Config.embd_pdrop",description:`<strong>embd_pdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) — | |
| 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) — | |
| 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-05) — | |
| 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) — | |
| 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>"cls_index"</code>) — | |
| Argument used when doing sequence summary, used in the models <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a> and | |
| <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.TFGPT2DoubleHeadsModel">TFGPT2DoubleHeadsModel</a>.</p> | |
| <p>Has to be one of the following options:</p> | |
| <ul> | |
| <li><code>"last"</code>: Take the last token hidden state (like XLNet).</li> | |
| <li><code>"first"</code>: Take the first token hidden state (like BERT).</li> | |
| <li><code>"mean"</code>: Take the mean of all tokens hidden states.</li> | |
| <li><code>"cls_index"</code>: Supply a Tensor of classification token position (like GPT/GPT-2).</li> | |
| <li><code>"attn"</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>) — | |
| Argument used when doing sequence summary, used in the models <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a> and | |
| <a href="/docs/transformers/pr_36839/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>) — | |
| Argument used when doing sequence summary. Used in for the multiple choice head in | |
| <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a>.</p> | |
| <p>Pass <code>"tanh"</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>) — | |
| Argument used when doing sequence summary, used in the models <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a> and | |
| <a href="/docs/transformers/pr_36839/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) — | |
| Argument used when doing sequence summary, used in the models <a href="/docs/transformers/pr_36839/en/model_doc/gpt2#transformers.GPT2DoubleHeadsModel">GPT2DoubleHeadsModel</a> and | |
| <a href="/docs/transformers/pr_36839/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>) — | |
| 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>) — | |
| Whether or not the model should return the last key/values attentions (not used by all models).`,name:"use_cache"},{anchor:"transformers.GPT2Config.bos_token_id",description:`<strong>bos_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 50256) — | |
| Id of the beginning of sentence token in the vocabulary.`,name:"bos_token_id"},{anchor:"transformers.GPT2Config.eos_token_id",description:`<strong>eos_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 50256) — | |
| Id of the end of sentence token in the vocabulary.`,name:"eos_token_id"},{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>) — | |
| 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>) — | |
| 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/vr_36839/src/transformers/models/gpt2/configuration_gpt2.py#L30"}}),Ie=new ft({props:{anchor:"transformers.GPT2Config.example",$$slots:{default:[lo]},$$scope:{ctx:x}}}),xt=new re({props:{title:"GPT2Tokenizer",local:"transformers.GPT2Tokenizer",headingTag:"h2"}}),mt=new X({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>) — | |
| Path to the vocabulary file.`,name:"vocab_file"},{anchor:"transformers.GPT2Tokenizer.merges_file",description:`<strong>merges_file</strong> (<code>str</code>) — | |
| 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>"replace"</code>) — | |
| 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>"<|endoftext|>"</code>) — | |
| 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>"<|endoftext|>"</code>) — | |
| 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>"<|endoftext|>"</code>) — | |
| The end of sequence token.`,name:"eos_token"},{anchor:"transformers.GPT2Tokenizer.pad_token",description:`<strong>pad_token</strong> (<code>str</code>, <em>optional</em>) — | |
| The token used for padding, for example when batching sequences of different lengths.`,name:"pad_token"},{anchor:"transformers.GPT2Tokenizer.add_prefix_space",description:`<strong>add_prefix_space</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| 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.GPT2Tokenizer.add_bos_token",description:`<strong>add_bos_token</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not to add an initial beginning of sentence token to the input. This allows to treat the leading | |
| word just as any other word.`,name:"add_bos_token"}],source:"https://github.com/huggingface/transformers/blob/vr_36839/src/transformers/models/gpt2/tokenization_gpt2.py#L75"}}),Ge=new ft({props:{anchor:"transformers.GPT2Tokenizer.example",$$slots:{default:[co]},$$scope:{ctx:x}}}),it=new gt({props:{$$slots:{default:[po]},$$scope:{ctx:x}}}),ln=new X({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/vr_36839/src/transformers/models/gpt2/tokenization_gpt2.py#L298"}}),Ht=new re({props:{title:"GPT2TokenizerFast",local:"transformers.GPT2TokenizerFast",headingTag:"h2"}}),Pe=new X({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>, <em>optional</em>) — | |
| Path to the vocabulary file.`,name:"vocab_file"},{anchor:"transformers.GPT2TokenizerFast.merges_file",description:`<strong>merges_file</strong> (<code>str</code>, <em>optional</em>) — | |
| Path to the merges file.`,name:"merges_file"},{anchor:"transformers.GPT2TokenizerFast.tokenizer_file",description:`<strong>tokenizer_file</strong> (<code>str</code>, <em>optional</em>) — | |
| Path to <a href="https://github.com/huggingface/tokenizers" rel="nofollow">tokenizers</a> file (generally has a .json extension) that | |
| contains everything needed to load the tokenizer.`,name:"tokenizer_file"},{anchor:"transformers.GPT2TokenizerFast.unk_token",description:`<strong>unk_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"<|endoftext|>"</code>) — | |
| 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>"<|endoftext|>"</code>) — | |
| 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>"<|endoftext|>"</code>) — | |
| 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>) — | |
| 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/vr_36839/src/transformers/models/gpt2/tokenization_gpt2_fast.py#L30"}}),Se=new ft({props:{anchor:"transformers.GPT2TokenizerFast.example",$$slots:{default:[uo]},$$scope:{ctx:x}}}),E=new gt({props:{$$slots:{default:[mo]},$$scope:{ctx:x}}}),pe=new re({props:{title:"GPT2 specific outputs",local:"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput",headingTag:"h2"}}),se=new X({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) — | |
| 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) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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/vr_36839/src/transformers/models/gpt2/modeling_gpt2.py#L500"}}),Zn=new X({props:{name:"class transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput",anchor:"transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput",parameters:[{name:"logits",val:": tf.Tensor = None"},{name:"mc_logits",val:": tf.Tensor = None"},{name:"past_key_values",val:": List[tf.Tensor] | None = None"},{name:"hidden_states",val:": Tuple[tf.Tensor] | None = None"},{name:"attentions",val:": Tuple[tf.Tensor] | None = None"}],parametersDescription:[{anchor:"transformers.models.gpt2.modeling_tf_gpt2.TFGPT2DoubleHeadsModelOutput.logits",description:`<strong>logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, num_choices, sequence_length, config.vocab_size)</code>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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/vr_36839/src/transformers/models/gpt2/modeling_tf_gpt2.py#L602"}}),qn=new ao({props:{pytorch:!0,tensorflow:!0,jax:!0,$$slots:{jax:[Yo],tensorflow:[So],pytorch:[jo]},$$scope:{ctx:x}}}),Ln=new io({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/gpt2.md"}}),{c(){e=p("meta"),m=r(),o=p("p"),s=r(),f(k.$$.fragment),t=r(),w=p("div"),w.innerHTML=be,z=r(),f(C.$$.fragment),ue=r(),F=p("p"),F.innerHTML=J,me=r(),v=p("p"),v.textContent=j,ve=r(),ie=p("p"),ie.innerHTML=gn,lt=r(),O=p("p"),O.innerHTML=_t,Me=r(),je=p("p"),je.innerHTML=Ze,Tt=r(),f(W.$$.fragment),Ae=r(),q=p("ul"),q.innerHTML=Le,dt=r(),f(Ce.$$.fragment),S=r(),Ne=p("p"),Ne.innerHTML=Ct,Ee=r(),f(Ft.$$.fragment),ct=r(),f(ae.$$.fragment),pt=r(),$e=p("p"),$e.innerHTML=et,Fe=r(),f(ze.$$.fragment),xe=r(),Qe=p("p"),Qe.innerHTML=yt,tt=r(),fe=p("p"),fe.innerHTML=At,H=r(),f(he.$$.fragment),nt=r(),f(ke.$$.fragment),ge=r(),Je=p("p"),Je.innerHTML=Be,bt=r(),f(Ue.$$.fragment),ot=r(),f(P.$$.fragment),U=r(),V=p("p"),V.innerHTML=R,He=r(),Ve=p("div"),Ve.innerHTML=en,fn=r(),f(le.$$.fragment),It=r(),st=p("p"),st.innerHTML=tn,Et=r(),qt=p("p"),qt.innerHTML=_e,Zt=r(),f(at.$$.fragment),Lt=r(),Mt=p("p"),Mt.innerHTML=kn,D=r(),kt=p("p"),kt.innerHTML=Cn,vt=r(),f(dn.$$.fragment),_n=r(),de=p("table"),de.innerHTML=cn,Tn=r(),f(De.$$.fragment),Fn=r(),Qt=p("table"),Qt.innerHTML=wt,vn=r(),f(rt.$$.fragment),Dt=r(),ut=p("p"),ut.textContent=wn,Oe=r(),f(Nt.$$.fragment),I=r(),We=p("ul"),We.innerHTML=zn,$t=r(),f(pn.$$.fragment),yn=r(),ce=p("div"),f(nn.$$.fragment),Bt=r(),zt=p("p"),zt.innerHTML=on,bn=r(),Ye=p("p"),Ye.innerHTML=Jn,Jt=r(),f(Ie.$$.fragment),$n=r(),f(xt.$$.fragment),Re=r(),A=p("div"),f(mt.$$.fragment),Ot=r(),Te=p("p"),Te.textContent=sn,Vt=r(),Ut=p("p"),Ut.textContent=an,xn=r(),f(Ge.$$.fragment),Gn=r(),Gt=p("p"),Gt.innerHTML=Rt,ye=r(),f(it.$$.fragment),rn=r(),Xt=p("p"),Xt.innerHTML=Hn,Pt=r(),Ke=p("div"),f(ln.$$.fragment),Yt=r(),f(Ht.$$.fragment),Pn=r(),Y=p("div"),f(Pe.$$.fragment),Xe=r(),jt=p("p"),jt.innerHTML=un,mn=r(),hn=p("p"),hn.textContent=Kt,St=r(),f(Se.$$.fragment),h=r(),d=p("p"),d.innerHTML=G,te=r(),f(E.$$.fragment),ne=r(),K=p("p"),K.innerHTML=Q,ee=r(),f(pe.$$.fragment),Z=r(),oe=p("div"),f(se.$$.fragment),we=r(),Mn=p("p"),Mn.textContent=In,Un=r(),Wn=p("div"),f(Zn.$$.fragment),Dn=r(),Vn=p("p"),Vn.textContent=Yn,Sn=r(),f(qn.$$.fragment),An=r(),f(Ln.$$.fragment),En=r(),Rn=p("p"),this.h()},l(n){const $=oo("svelte-u9bgzb",document.head);e=u($,"META",{name:!0,content:!0}),$.forEach(a),m=i(n),o=u(n,"P",{}),B(o).forEach(a),s=i(n),_(k.$$.fragment,n),t=i(n),w=u(n,"DIV",{class:!0,"data-svelte-h":!0}),g(w)!=="svelte-4g1z5g"&&(w.innerHTML=be),z=i(n),_(C.$$.fragment,n),ue=i(n),F=u(n,"P",{"data-svelte-h":!0}),g(F)!=="svelte-c6xejo"&&(F.innerHTML=J),me=i(n),v=u(n,"P",{"data-svelte-h":!0}),g(v)!=="svelte-vfdo9a"&&(v.textContent=j),ve=i(n),ie=u(n,"P",{"data-svelte-h":!0}),g(ie)!=="svelte-pd1qkn"&&(ie.innerHTML=gn),lt=i(n),O=u(n,"P",{"data-svelte-h":!0}),g(O)!=="svelte-n4e01i"&&(O.innerHTML=_t),Me=i(n),je=u(n,"P",{"data-svelte-h":!0}),g(je)!=="svelte-8g2i8b"&&(je.innerHTML=Ze),Tt=i(n),_(W.$$.fragment,n),Ae=i(n),q=u(n,"UL",{"data-svelte-h":!0}),g(q)!=="svelte-rkazgq"&&(q.innerHTML=Le),dt=i(n),_(Ce.$$.fragment,n),S=i(n),Ne=u(n,"P",{"data-svelte-h":!0}),g(Ne)!=="svelte-5ekzko"&&(Ne.innerHTML=Ct),Ee=i(n),_(Ft.$$.fragment,n),ct=i(n),_(ae.$$.fragment,n),pt=i(n),$e=u(n,"P",{"data-svelte-h":!0}),g($e)!=="svelte-1oyivwb"&&($e.innerHTML=et),Fe=i(n),_(ze.$$.fragment,n),xe=i(n),Qe=u(n,"P",{"data-svelte-h":!0}),g(Qe)!=="svelte-ib5l43"&&(Qe.innerHTML=yt),tt=i(n),fe=u(n,"P",{"data-svelte-h":!0}),g(fe)!=="svelte-1pp3dkd"&&(fe.innerHTML=At),H=i(n),_(he.$$.fragment,n),nt=i(n),_(ke.$$.fragment,n),ge=i(n),Je=u(n,"P",{"data-svelte-h":!0}),g(Je)!=="svelte-10jrnsm"&&(Je.innerHTML=Be),bt=i(n),_(Ue.$$.fragment,n),ot=i(n),_(P.$$.fragment,n),U=i(n),V=u(n,"P",{"data-svelte-h":!0}),g(V)!=="svelte-1mk05d1"&&(V.innerHTML=R),He=i(n),Ve=u(n,"DIV",{style:!0,"data-svelte-h":!0}),g(Ve)!=="svelte-v5am47"&&(Ve.innerHTML=en),fn=i(n),_(le.$$.fragment,n),It=i(n),st=u(n,"P",{"data-svelte-h":!0}),g(st)!=="svelte-1cid2pe"&&(st.innerHTML=tn),Et=i(n),qt=u(n,"P",{"data-svelte-h":!0}),g(qt)!=="svelte-1x11lxg"&&(qt.innerHTML=_e),Zt=i(n),_(at.$$.fragment,n),Lt=i(n),Mt=u(n,"P",{"data-svelte-h":!0}),g(Mt)!=="svelte-djb2w0"&&(Mt.innerHTML=kn),D=i(n),kt=u(n,"P",{"data-svelte-h":!0}),g(kt)!=="svelte-1dt1azc"&&(kt.innerHTML=Cn),vt=i(n),_(dn.$$.fragment,n),_n=i(n),de=u(n,"TABLE",{"data-svelte-h":!0}),g(de)!=="svelte-1q2wftc"&&(de.innerHTML=cn),Tn=i(n),_(De.$$.fragment,n),Fn=i(n),Qt=u(n,"TABLE",{"data-svelte-h":!0}),g(Qt)!=="svelte-f39rfi"&&(Qt.innerHTML=wt),vn=i(n),_(rt.$$.fragment,n),Dt=i(n),ut=u(n,"P",{"data-svelte-h":!0}),g(ut)!=="svelte-1h22540"&&(ut.textContent=wn),Oe=i(n),_(Nt.$$.fragment,n),I=i(n),We=u(n,"UL",{"data-svelte-h":!0}),g(We)!=="svelte-1lr2kxy"&&(We.innerHTML=zn),$t=i(n),_(pn.$$.fragment,n),yn=i(n),ce=u(n,"DIV",{class:!0});var jn=B(ce);_(nn.$$.fragment,jn),Bt=i(jn),zt=u(jn,"P",{"data-svelte-h":!0}),g(zt)!=="svelte-iu8htm"&&(zt.innerHTML=on),bn=i(jn),Ye=u(jn,"P",{"data-svelte-h":!0}),g(Ye)!=="svelte-4potwj"&&(Ye.innerHTML=Jn),Jt=i(jn),_(Ie.$$.fragment,jn),jn.forEach(a),$n=i(n),_(xt.$$.fragment,n),Re=i(n),A=u(n,"DIV",{class:!0});var ht=B(A);_(mt.$$.fragment,ht),Ot=i(ht),Te=u(ht,"P",{"data-svelte-h":!0}),g(Te)!=="svelte-1tnpexf"&&(Te.textContent=sn),Vt=i(ht),Ut=u(ht,"P",{"data-svelte-h":!0}),g(Ut)!=="svelte-1s077p3"&&(Ut.textContent=an),xn=i(ht),_(Ge.$$.fragment,ht),Gn=i(ht),Gt=u(ht,"P",{"data-svelte-h":!0}),g(Gt)!=="svelte-1jfcabo"&&(Gt.innerHTML=Rt),ye=i(ht),_(it.$$.fragment,ht),rn=i(ht),Xt=u(ht,"P",{"data-svelte-h":!0}),g(Xt)!=="svelte-hglat1"&&(Xt.innerHTML=Hn),Pt=i(ht),Ke=u(ht,"DIV",{class:!0});var Xn=B(Ke);_(ln.$$.fragment,Xn),Xn.forEach(a),ht.forEach(a),Yt=i(n),_(Ht.$$.fragment,n),Pn=i(n),Y=u(n,"DIV",{class:!0});var Wt=B(Y);_(Pe.$$.fragment,Wt),Xe=i(Wt),jt=u(Wt,"P",{"data-svelte-h":!0}),g(jt)!=="svelte-115toia"&&(jt.innerHTML=un),mn=i(Wt),hn=u(Wt,"P",{"data-svelte-h":!0}),g(hn)!=="svelte-1s077p3"&&(hn.textContent=Kt),St=i(Wt),_(Se.$$.fragment,Wt),h=i(Wt),d=u(Wt,"P",{"data-svelte-h":!0}),g(d)!=="svelte-1afeqmz"&&(d.innerHTML=G),te=i(Wt),_(E.$$.fragment,Wt),ne=i(Wt),K=u(Wt,"P",{"data-svelte-h":!0}),g(K)!=="svelte-a9mnn5"&&(K.innerHTML=Q),Wt.forEach(a),ee=i(n),_(pe.$$.fragment,n),Z=i(n),oe=u(n,"DIV",{class:!0});var Nn=B(oe);_(se.$$.fragment,Nn),we=i(Nn),Mn=u(Nn,"P",{"data-svelte-h":!0}),g(Mn)!=="svelte-1bm2i0r"&&(Mn.textContent=In),Nn.forEach(a),Un=i(n),Wn=u(n,"DIV",{class:!0});var Bn=B(Wn);_(Zn.$$.fragment,Bn),Dn=i(Bn),Vn=u(Bn,"P",{"data-svelte-h":!0}),g(Vn)!=="svelte-1bm2i0r"&&(Vn.textContent=Yn),Bn.forEach(a),Sn=i(n),_(qn.$$.fragment,n),An=i(n),_(Ln.$$.fragment,n),En=i(n),Rn=u(n,"P",{}),B(Rn).forEach(a),this.h()},h(){L(e,"name","hf:doc:metadata"),L(e,"content",es),L(w,"class","flex flex-wrap space-x-1"),so(Ve,"text-align","center"),L(ce,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(Ke,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(oe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(Wn,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(n,$){l(document.head,e),c(n,m,$),c(n,o,$),c(n,s,$),T(k,n,$),c(n,t,$),c(n,w,$),c(n,z,$),T(C,n,$),c(n,ue,$),c(n,F,$),c(n,me,$),c(n,v,$),c(n,ve,$),c(n,ie,$),c(n,lt,$),c(n,O,$),c(n,Me,$),c(n,je,$),c(n,Tt,$),T(W,n,$),c(n,Ae,$),c(n,q,$),c(n,dt,$),T(Ce,n,$),c(n,S,$),c(n,Ne,$),c(n,Ee,$),T(Ft,n,$),c(n,ct,$),T(ae,n,$),c(n,pt,$),c(n,$e,$),c(n,Fe,$),T(ze,n,$),c(n,xe,$),c(n,Qe,$),c(n,tt,$),c(n,fe,$),c(n,H,$),T(he,n,$),c(n,nt,$),T(ke,n,$),c(n,ge,$),c(n,Je,$),c(n,bt,$),T(Ue,n,$),c(n,ot,$),T(P,n,$),c(n,U,$),c(n,V,$),c(n,He,$),c(n,Ve,$),c(n,fn,$),T(le,n,$),c(n,It,$),c(n,st,$),c(n,Et,$),c(n,qt,$),c(n,Zt,$),T(at,n,$),c(n,Lt,$),c(n,Mt,$),c(n,D,$),c(n,kt,$),c(n,vt,$),T(dn,n,$),c(n,_n,$),c(n,de,$),c(n,Tn,$),T(De,n,$),c(n,Fn,$),c(n,Qt,$),c(n,vn,$),T(rt,n,$),c(n,Dt,$),c(n,ut,$),c(n,Oe,$),T(Nt,n,$),c(n,I,$),c(n,We,$),c(n,$t,$),T(pn,n,$),c(n,yn,$),c(n,ce,$),T(nn,ce,null),l(ce,Bt),l(ce,zt),l(ce,bn),l(ce,Ye),l(ce,Jt),T(Ie,ce,null),c(n,$n,$),T(xt,n,$),c(n,Re,$),c(n,A,$),T(mt,A,null),l(A,Ot),l(A,Te),l(A,Vt),l(A,Ut),l(A,xn),T(Ge,A,null),l(A,Gn),l(A,Gt),l(A,ye),T(it,A,null),l(A,rn),l(A,Xt),l(A,Pt),l(A,Ke),T(ln,Ke,null),c(n,Yt,$),T(Ht,n,$),c(n,Pn,$),c(n,Y,$),T(Pe,Y,null),l(Y,Xe),l(Y,jt),l(Y,mn),l(Y,hn),l(Y,St),T(Se,Y,null),l(Y,h),l(Y,d),l(Y,te),T(E,Y,null),l(Y,ne),l(Y,K),c(n,ee,$),T(pe,n,$),c(n,Z,$),c(n,oe,$),T(se,oe,null),l(oe,we),l(oe,Mn),c(n,Un,$),c(n,Wn,$),T(Zn,Wn,null),l(Wn,Dn),l(Wn,Vn),c(n,Sn,$),T(qn,n,$),c(n,An,$),T(Ln,n,$),c(n,En,$),c(n,Rn,$),Qn=!0},p(n,[$]){const jn={};$&2&&(jn.$$scope={dirty:$,ctx:n}),Ie.$set(jn);const ht={};$&2&&(ht.$$scope={dirty:$,ctx:n}),Ge.$set(ht);const Xn={};$&2&&(Xn.$$scope={dirty:$,ctx:n}),it.$set(Xn);const Wt={};$&2&&(Wt.$$scope={dirty:$,ctx:n}),Se.$set(Wt);const Nn={};$&2&&(Nn.$$scope={dirty:$,ctx:n}),E.$set(Nn);const Bn={};$&2&&(Bn.$$scope={dirty:$,ctx:n}),qn.$set(Bn)},i(n){Qn||(y(k.$$.fragment,n),y(C.$$.fragment,n),y(W.$$.fragment,n),y(Ce.$$.fragment,n),y(Ft.$$.fragment,n),y(ae.$$.fragment,n),y(ze.$$.fragment,n),y(he.$$.fragment,n),y(ke.$$.fragment,n),y(Ue.$$.fragment,n),y(P.$$.fragment,n),y(le.$$.fragment,n),y(at.$$.fragment,n),y(dn.$$.fragment,n),y(De.$$.fragment,n),y(rt.$$.fragment,n),y(Nt.$$.fragment,n),y(pn.$$.fragment,n),y(nn.$$.fragment,n),y(Ie.$$.fragment,n),y(xt.$$.fragment,n),y(mt.$$.fragment,n),y(Ge.$$.fragment,n),y(it.$$.fragment,n),y(ln.$$.fragment,n),y(Ht.$$.fragment,n),y(Pe.$$.fragment,n),y(Se.$$.fragment,n),y(E.$$.fragment,n),y(pe.$$.fragment,n),y(se.$$.fragment,n),y(Zn.$$.fragment,n),y(qn.$$.fragment,n),y(Ln.$$.fragment,n),Qn=!0)},o(n){b(k.$$.fragment,n),b(C.$$.fragment,n),b(W.$$.fragment,n),b(Ce.$$.fragment,n),b(Ft.$$.fragment,n),b(ae.$$.fragment,n),b(ze.$$.fragment,n),b(he.$$.fragment,n),b(ke.$$.fragment,n),b(Ue.$$.fragment,n),b(P.$$.fragment,n),b(le.$$.fragment,n),b(at.$$.fragment,n),b(dn.$$.fragment,n),b(De.$$.fragment,n),b(rt.$$.fragment,n),b(Nt.$$.fragment,n),b(pn.$$.fragment,n),b(nn.$$.fragment,n),b(Ie.$$.fragment,n),b(xt.$$.fragment,n),b(mt.$$.fragment,n),b(Ge.$$.fragment,n),b(it.$$.fragment,n),b(ln.$$.fragment,n),b(Ht.$$.fragment,n),b(Pe.$$.fragment,n),b(Se.$$.fragment,n),b(E.$$.fragment,n),b(pe.$$.fragment,n),b(se.$$.fragment,n),b(Zn.$$.fragment,n),b(qn.$$.fragment,n),b(Ln.$$.fragment,n),Qn=!1},d(n){n&&(a(m),a(o),a(s),a(t),a(w),a(z),a(ue),a(F),a(me),a(v),a(ve),a(ie),a(lt),a(O),a(Me),a(je),a(Tt),a(Ae),a(q),a(dt),a(S),a(Ne),a(Ee),a(ct),a(pt),a($e),a(Fe),a(xe),a(Qe),a(tt),a(fe),a(H),a(nt),a(ge),a(Je),a(bt),a(ot),a(U),a(V),a(He),a(Ve),a(fn),a(It),a(st),a(Et),a(qt),a(Zt),a(Lt),a(Mt),a(D),a(kt),a(vt),a(_n),a(de),a(Tn),a(Fn),a(Qt),a(vn),a(Dt),a(ut),a(Oe),a(I),a(We),a($t),a(yn),a(ce),a($n),a(Re),a(A),a(Yt),a(Pn),a(Y),a(ee),a(Z),a(oe),a(Un),a(Wn),a(Sn),a(An),a(En),a(Rn)),a(e),M(k,n),M(C,n),M(W,n),M(Ce,n),M(Ft,n),M(ae,n),M(ze,n),M(he,n),M(ke,n),M(Ue,n),M(P,n),M(le,n),M(at,n),M(dn,n),M(De,n),M(rt,n),M(Nt,n),M(pn,n),M(nn),M(Ie),M(xt,n),M(mt),M(Ge),M(it),M(ln),M(Ht,n),M(Pe),M(Se),M(E),M(pe,n),M(se),M(Zn),M(qn,n),M(Ln,n)}}}const es='{"title":"OpenAI GPT2","local":"openai-gpt2","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Usage tips","local":"usage-tips","sections":[],"depth":2},{"title":"Usage example","local":"usage-example","sections":[],"depth":2},{"title":"Using Flash Attention 2","local":"using-flash-attention-2","sections":[{"title":"Installation","local":"installation","sections":[],"depth":3},{"title":"Usage","local":"usage","sections":[],"depth":3},{"title":"Expected speedups","local":"expected-speedups","sections":[],"depth":3}],"depth":2},{"title":"Using Scaled Dot Product Attention (SDPA)","local":"using-scaled-dot-product-attention-sdpa","sections":[{"title":"Training","local":"training","sections":[],"depth":3},{"title":"Inference","local":"inference","sections":[],"depth":3}],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2},{"title":"GPT2Config","local":"transformers.GPT2Config","sections":[],"depth":2},{"title":"GPT2Tokenizer","local":"transformers.GPT2Tokenizer","sections":[],"depth":2},{"title":"GPT2TokenizerFast","local":"transformers.GPT2TokenizerFast","sections":[],"depth":2},{"title":"GPT2 specific outputs","local":"transformers.models.gpt2.modeling_gpt2.GPT2DoubleHeadsModelOutput","sections":[],"depth":2},{"title":"GPT2Model","local":"transformers.GPT2Model","sections":[],"depth":2},{"title":"GPT2LMHeadModel","local":"transformers.GPT2LMHeadModel","sections":[],"depth":2},{"title":"GPT2DoubleHeadsModel","local":"transformers.GPT2DoubleHeadsModel","sections":[],"depth":2},{"title":"GPT2ForQuestionAnswering","local":"transformers.GPT2ForQuestionAnswering","sections":[],"depth":2},{"title":"GPT2ForSequenceClassification","local":"transformers.GPT2ForSequenceClassification","sections":[],"depth":2},{"title":"GPT2ForTokenClassification","local":"transformers.GPT2ForTokenClassification","sections":[],"depth":2},{"title":"TFGPT2Model","local":"transformers.TFGPT2Model","sections":[],"depth":2},{"title":"TFGPT2LMHeadModel","local":"transformers.TFGPT2LMHeadModel","sections":[],"depth":2},{"title":"TFGPT2DoubleHeadsModel","local":"transformers.TFGPT2DoubleHeadsModel","sections":[],"depth":2},{"title":"TFGPT2ForSequenceClassification","local":"transformers.TFGPT2ForSequenceClassification","sections":[],"depth":2},{"title":"TFSequenceClassifierOutputWithPast","local":"transformers.modeling_tf_outputs.TFSequenceClassifierOutputWithPast","sections":[],"depth":2},{"title":"TFGPT2Tokenizer","local":"transformers.TFGPT2Tokenizer","sections":[],"depth":2},{"title":"FlaxGPT2Model","local":"transformers.FlaxGPT2Model","sections":[],"depth":2},{"title":"FlaxGPT2LMHeadModel","local":"transformers.FlaxGPT2LMHeadModel","sections":[],"depth":2}],"depth":1}';function ts(x){return eo(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ps extends to{constructor(e){super(),no(this,e,ts,Ko,Kn,{})}}export{ps as component}; | |
Xet Storage Details
- Size:
- 323 kB
- Xet hash:
- f199bb9755bbd74b58deac05fdc16e343c5bd56b0760cd8863bffbd76013aa68
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.