import{S as ll,i as dl,s as cl,e as s,k as f,w as M,t as i,M as pl,c as a,d as t,m as g,a as r,x as w,h as l,b as h,N as hl,G as e,g as _,y as T,q as k,o as v,B as $,v as ml,L as Pe}from"../../chunks/vendor-hf-doc-builder.js";import{T as Mt}from"../../chunks/Tip-hf-doc-builder.js";import{D as F}from"../../chunks/Docstring-hf-doc-builder.js";import{C as He}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Q}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Le}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function ul(j){let d,b,m,p,y;return p=new He({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFlvc29Db25maWclMkMlMjBZb3NvTW9kZWwlMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwWU9TTyUyMHV3LW1hZGlzb24lMkZ5b3NvLTQwOTYlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwWW9zb0NvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjB1dy1tYWRpc29uJTJGeW9zby00MDk2JTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBZb3NvTW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> YosoConfig, YosoModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a YOSO uw-madison/yoso-4096 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = YosoConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the uw-madison/yoso-4096 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = YosoModel(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`}}),{c(){d=s("p"),b=i("Example:"),m=f(),M(p.$$.fragment)},l(n){d=a(n,"P",{});var c=r(d);b=l(c,"Example:"),c.forEach(t),m=g(n),w(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,m,c),T(p,n,c),y=!0},p:Pe,i(n){y||(k(p.$$.fragment,n),y=!0)},o(n){v(p.$$.fragment,n),y=!1},d(n){n&&t(d),n&&t(m),$(p,n)}}}function fl(j){let d,b,m,p,y;return{c(){d=s("p"),b=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=s("code"),p=i("Module"),y=i(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(n){d=a(n,"P",{});var c=r(d);b=l(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(c,"CODE",{});var Y=r(m);p=l(Y,"Module"),Y.forEach(t),y=l(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(t)},m(n,c){_(n,d,c),e(d,b),e(d,m),e(m,p),e(d,y)},d(n){n&&t(d)}}}function gl(j){let d,b,m,p,y;return p=new He({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBZb3NvTW9kZWwlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMnV3LW1hZGlzb24lMkZ5b3NvLTQwOTYlMjIpJTBBbW9kZWwlMjAlM0QlMjBZb3NvTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMnV3LW1hZGlzb24lMkZ5b3NvLTQwOTYlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMkhlbGxvJTJDJTIwbXklMjBkb2clMjBpcyUyMGN1dGUlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyklMEElMEFsYXN0X2hpZGRlbl9zdGF0ZXMlMjAlM0QlMjBvdXRwdXRzLmxhc3RfaGlkZGVuX3N0YXRl",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, YosoModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;uw-madison/yoso-4096&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = YosoModel.from_pretrained(<span class="hljs-string">&quot;uw-madison/yoso-4096&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state`}}),{c(){d=s("p"),b=i("Example:"),m=f(),M(p.$$.fragment)},l(n){d=a(n,"P",{});var c=r(d);b=l(c,"Example:"),c.forEach(t),m=g(n),w(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,m,c),T(p,n,c),y=!0},p:Pe,i(n){y||(k(p.$$.fragment,n),y=!0)},o(n){v(p.$$.fragment,n),y=!1},d(n){n&&t(d),n&&t(m),$(p,n)}}}function _l(j){let d,b,m,p,y;return{c(){d=s("p"),b=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=s("code"),p=i("Module"),y=i(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(n){d=a(n,"P",{});var c=r(d);b=l(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(c,"CODE",{});var Y=r(m);p=l(Y,"Module"),Y.forEach(t),y=l(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(t)},m(n,c){_(n,d,c),e(d,b),e(d,m),e(m,p),e(d,y)},d(n){n&&t(d)}}}function yl(j){let d,b,m,p,y;return p=new He({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBZb3NvRm9yTWFza2VkTE0lMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMnV3LW1hZGlzb24lMkZ5b3NvLTQwOTYlMjIpJTBBbW9kZWwlMjAlM0QlMjBZb3NvRm9yTWFza2VkTE0uZnJvbV9wcmV0cmFpbmVkKCUyMnV3LW1hZGlzb24lMkZ5b3NvLTQwOTYlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMlRoZSUyMGNhcGl0YWwlMjBvZiUyMEZyYW5jZSUyMGlzJTIwJTVCTUFTSyU1RC4lMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBJTBBJTIzJTIwcmV0cmlldmUlMjBpbmRleCUyMG9mJTIwJTVCTUFTSyU1RCUwQW1hc2tfdG9rZW5faW5kZXglMjAlM0QlMjAoaW5wdXRzLmlucHV0X2lkcyUyMCUzRCUzRCUyMHRva2VuaXplci5tYXNrX3Rva2VuX2lkKSU1QjAlNUQubm9uemVybyhhc190dXBsZSUzRFRydWUpJTVCMCU1RCUwQSUwQXByZWRpY3RlZF90b2tlbl9pZCUyMCUzRCUyMGxvZ2l0cyU1QjAlMkMlMjBtYXNrX3Rva2VuX2luZGV4JTVELmFyZ21heChheGlzJTNELTEpJTBBJTBBbGFiZWxzJTIwJTNEJTIwdG9rZW5pemVyKCUyMlRoZSUyMGNhcGl0YWwlMjBvZiUyMEZyYW5jZSUyMGlzJTIwUGFyaXMuJTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklNUIlMjJpbnB1dF9pZHMlMjIlNUQlMEElMjMlMjBtYXNrJTIwbGFiZWxzJTIwb2YlMjBub24tJTVCTUFTSyU1RCUyMHRva2VucyUwQWxhYmVscyUyMCUzRCUyMHRvcmNoLndoZXJlKGlucHV0cy5pbnB1dF9pZHMlMjAlM0QlM0QlMjB0b2tlbml6ZXIubWFza190b2tlbl9pZCUyQyUyMGxhYmVscyUyQyUyMC0xMDApJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzJTJDJTIwbGFiZWxzJTNEbGFiZWxzKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, YosoForMaskedLM
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;uw-madison/yoso-4096&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = YosoForMaskedLM.from_pretrained(<span class="hljs-string">&quot;uw-madison/yoso-4096&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;The capital of France is [MASK].&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    logits = model(**inputs).logits

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># retrieve index of [MASK]</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>mask_token_index = (inputs.input_ids == tokenizer.mask_token_id)[<span class="hljs-number">0</span>].nonzero(as_tuple=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_token_id = logits[<span class="hljs-number">0</span>, mask_token_index].argmax(axis=-<span class="hljs-number">1</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>labels = tokenizer(<span class="hljs-string">&quot;The capital of France is Paris.&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># mask labels of non-[MASK] tokens</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = torch.where(inputs.input_ids == tokenizer.mask_token_id, labels, -<span class="hljs-number">100</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, labels=labels)`}}),{c(){d=s("p"),b=i("Example:"),m=f(),M(p.$$.fragment)},l(n){d=a(n,"P",{});var c=r(d);b=l(c,"Example:"),c.forEach(t),m=g(n),w(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,m,c),T(p,n,c),y=!0},p:Pe,i(n){y||(k(p.$$.fragment,n),y=!0)},o(n){v(p.$$.fragment,n),y=!1},d(n){n&&t(d),n&&t(m),$(p,n)}}}function bl(j){let d,b,m,p,y;return{c(){d=s("p"),b=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=s("code"),p=i("Module"),y=i(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(n){d=a(n,"P",{});var c=r(d);b=l(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(c,"CODE",{});var Y=r(m);p=l(Y,"Module"),Y.forEach(t),y=l(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(t)},m(n,c){_(n,d,c),e(d,b),e(d,m),e(m,p),e(d,y)},d(n){n&&t(d)}}}function Ml(j){let d,b,m,p,y;return p=new He({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMFlvc29Gb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIydXctbWFkaXNvbiUyRnlvc28tNDA5NiUyMiklMEFtb2RlbCUyMCUzRCUyMFlvc29Gb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJ1dy1tYWRpc29uJTJGeW9zby00MDk2JTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplciglMjJIZWxsbyUyQyUyMG15JTIwZG9nJTIwaXMlMjBjdXRlJTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cyUwQSUwQXByZWRpY3RlZF9jbGFzc19pZCUyMCUzRCUyMGxvZ2l0cy5hcmdtYXgoKS5pdGVtKCklMEElMEElMjMlMjBUbyUyMHRyYWluJTIwYSUyMG1vZGVsJTIwb24lMjAlNjBudW1fbGFiZWxzJTYwJTIwY2xhc3NlcyUyQyUyMHlvdSUyMGNhbiUyMHBhc3MlMjAlNjBudW1fbGFiZWxzJTNEbnVtX2xhYmVscyU2MCUyMHRvJTIwJTYwLmZyb21fcHJldHJhaW5lZCguLi4pJTYwJTBBbnVtX2xhYmVscyUyMCUzRCUyMGxlbihtb2RlbC5jb25maWcuaWQybGFiZWwpJTBBbW9kZWwlMjAlM0QlMjBZb3NvRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIydXctbWFkaXNvbiUyRnlvc28tNDA5NiUyMiUyQyUyMG51bV9sYWJlbHMlM0RudW1fbGFiZWxzKSUwQSUwQWxhYmVscyUyMCUzRCUyMHRvcmNoLnRlbnNvciglNUIxJTVEKSUwQWxvc3MlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyUyQyUyMGxhYmVscyUzRGxhYmVscykubG9zcw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, YosoForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;uw-madison/yoso-4096&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = YosoForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;uw-madison/yoso-4096&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    logits = model(**inputs).logits

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_class_id = logits.argmax().item()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># To train a model on \`num_labels\` classes, you can pass \`num_labels=num_labels\` to \`.from_pretrained(...)\`</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_labels = <span class="hljs-built_in">len</span>(model.config.id2label)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = YosoForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;uw-madison/yoso-4096&quot;</span>, num_labels=num_labels)

<span class="hljs-meta">&gt;&gt;&gt; </span>labels = torch.tensor([<span class="hljs-number">1</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = model(**inputs, labels=labels).loss`}}),{c(){d=s("p"),b=i("Example of single-label classification:"),m=f(),M(p.$$.fragment)},l(n){d=a(n,"P",{});var c=r(d);b=l(c,"Example of single-label classification:"),c.forEach(t),m=g(n),w(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,m,c),T(p,n,c),y=!0},p:Pe,i(n){y||(k(p.$$.fragment,n),y=!0)},o(n){v(p.$$.fragment,n),y=!1},d(n){n&&t(d),n&&t(m),$(p,n)}}}function wl(j){let d,b,m,p,y;return p=new He({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMFlvc29Gb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIydXctbWFkaXNvbiUyRnlvc28tNDA5NiUyMiklMEFtb2RlbCUyMCUzRCUyMFlvc29Gb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJ1dy1tYWRpc29uJTJGeW9zby00MDk2JTIyJTJDJTIwcHJvYmxlbV90eXBlJTNEJTIybXVsdGlfbGFiZWxfY2xhc3NpZmljYXRpb24lMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMkhlbGxvJTJDJTIwbXklMjBkb2clMjBpcyUyMGN1dGUlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBJTBBcHJlZGljdGVkX2NsYXNzX2lkcyUyMCUzRCUyMHRvcmNoLmFyYW5nZSgwJTJDJTIwbG9naXRzLnNoYXBlJTVCLTElNUQpJTVCdG9yY2guc2lnbW9pZChsb2dpdHMpLnNxdWVlemUoZGltJTNEMCklMjAlM0UlMjAwLjUlNUQlMEElMEElMjMlMjBUbyUyMHRyYWluJTIwYSUyMG1vZGVsJTIwb24lMjAlNjBudW1fbGFiZWxzJTYwJTIwY2xhc3NlcyUyQyUyMHlvdSUyMGNhbiUyMHBhc3MlMjAlNjBudW1fbGFiZWxzJTNEbnVtX2xhYmVscyU2MCUyMHRvJTIwJTYwLmZyb21fcHJldHJhaW5lZCguLi4pJTYwJTBBbnVtX2xhYmVscyUyMCUzRCUyMGxlbihtb2RlbC5jb25maWcuaWQybGFiZWwpJTBBbW9kZWwlMjAlM0QlMjBZb3NvRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIydXctbWFkaXNvbiUyRnlvc28tNDA5NiUyMiUyQyUyMG51bV9sYWJlbHMlM0RudW1fbGFiZWxzJTJDJTIwcHJvYmxlbV90eXBlJTNEJTIybXVsdGlfbGFiZWxfY2xhc3NpZmljYXRpb24lMjIlMEEpJTBBJTBBbGFiZWxzJTIwJTNEJTIwdG9yY2guc3VtKCUwQSUyMCUyMCUyMCUyMHRvcmNoLm5uLmZ1bmN0aW9uYWwub25lX2hvdChwcmVkaWN0ZWRfY2xhc3NfaWRzJTVCTm9uZSUyQyUyMCUzQSU1RC5jbG9uZSgpJTJDJTIwbnVtX2NsYXNzZXMlM0RudW1fbGFiZWxzKSUyQyUyMGRpbSUzRDElMEEpLnRvKHRvcmNoLmZsb2F0KSUwQWxvc3MlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyUyQyUyMGxhYmVscyUzRGxhYmVscykubG9zcw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, YosoForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;uw-madison/yoso-4096&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = YosoForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;uw-madison/yoso-4096&quot;</span>, problem_type=<span class="hljs-string">&quot;multi_label_classification&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    logits = model(**inputs).logits

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_class_ids = torch.arange(<span class="hljs-number">0</span>, logits.shape[-<span class="hljs-number">1</span>])[torch.sigmoid(logits).squeeze(dim=<span class="hljs-number">0</span>) &gt; <span class="hljs-number">0.5</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># To train a model on \`num_labels\` classes, you can pass \`num_labels=num_labels\` to \`.from_pretrained(...)\`</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_labels = <span class="hljs-built_in">len</span>(model.config.id2label)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = YosoForSequenceClassification.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;uw-madison/yoso-4096&quot;</span>, num_labels=num_labels, problem_type=<span class="hljs-string">&quot;multi_label_classification&quot;</span>
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>labels = torch.<span class="hljs-built_in">sum</span>(
<span class="hljs-meta">... </span>    torch.nn.functional.one_hot(predicted_class_ids[<span class="hljs-literal">None</span>, :].clone(), num_classes=num_labels), dim=<span class="hljs-number">1</span>
<span class="hljs-meta">... </span>).to(torch.<span class="hljs-built_in">float</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = model(**inputs, labels=labels).loss`}}),{c(){d=s("p"),b=i("Example of multi-label classification:"),m=f(),M(p.$$.fragment)},l(n){d=a(n,"P",{});var c=r(d);b=l(c,"Example of multi-label classification:"),c.forEach(t),m=g(n),w(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,m,c),T(p,n,c),y=!0},p:Pe,i(n){y||(k(p.$$.fragment,n),y=!0)},o(n){v(p.$$.fragment,n),y=!1},d(n){n&&t(d),n&&t(m),$(p,n)}}}function Tl(j){let d,b,m,p,y;return{c(){d=s("p"),b=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=s("code"),p=i("Module"),y=i(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(n){d=a(n,"P",{});var c=r(d);b=l(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(c,"CODE",{});var Y=r(m);p=l(Y,"Module"),Y.forEach(t),y=l(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(t)},m(n,c){_(n,d,c),e(d,b),e(d,m),e(m,p),e(d,y)},d(n){n&&t(d)}}}function kl(j){let d,b,m,p,y;return p=new He({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBZb3NvRm9yTXVsdGlwbGVDaG9pY2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMnV3LW1hZGlzb24lMkZ5b3NvLTQwOTYlMjIpJTBBbW9kZWwlMjAlM0QlMjBZb3NvRm9yTXVsdGlwbGVDaG9pY2UuZnJvbV9wcmV0cmFpbmVkKCUyMnV3LW1hZGlzb24lMkZ5b3NvLTQwOTYlMjIpJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIySW4lMjBJdGFseSUyQyUyMHBpenphJTIwc2VydmVkJTIwaW4lMjBmb3JtYWwlMjBzZXR0aW5ncyUyQyUyMHN1Y2glMjBhcyUyMGF0JTIwYSUyMHJlc3RhdXJhbnQlMkMlMjBpcyUyMHByZXNlbnRlZCUyMHVuc2xpY2VkLiUyMiUwQWNob2ljZTAlMjAlM0QlMjAlMjJJdCUyMGlzJTIwZWF0ZW4lMjB3aXRoJTIwYSUyMGZvcmslMjBhbmQlMjBhJTIwa25pZmUuJTIyJTBBY2hvaWNlMSUyMCUzRCUyMCUyMkl0JTIwaXMlMjBlYXRlbiUyMHdoaWxlJTIwaGVsZCUyMGluJTIwdGhlJTIwaGFuZC4lMjIlMEFsYWJlbHMlMjAlM0QlMjB0b3JjaC50ZW5zb3IoMCkudW5zcXVlZXplKDApJTIwJTIwJTIzJTIwY2hvaWNlMCUyMGlzJTIwY29ycmVjdCUyMChhY2NvcmRpbmclMjB0byUyMFdpa2lwZWRpYSUyMCUzQikpJTJDJTIwYmF0Y2glMjBzaXplJTIwMSUwQSUwQWVuY29kaW5nJTIwJTNEJTIwdG9rZW5pemVyKCU1QnByb21wdCUyQyUyMHByb21wdCU1RCUyQyUyMCU1QmNob2ljZTAlMkMlMjBjaG9pY2UxJTVEJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUyQyUyMHBhZGRpbmclM0RUcnVlKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKiU3QmslM0ElMjB2LnVuc3F1ZWV6ZSgwKSUyMGZvciUyMGslMkMlMjB2JTIwaW4lMjBlbmNvZGluZy5pdGVtcygpJTdEJTJDJTIwbGFiZWxzJTNEbGFiZWxzKSUyMCUyMCUyMyUyMGJhdGNoJTIwc2l6ZSUyMGlzJTIwMSUwQSUwQSUyMyUyMHRoZSUyMGxpbmVhciUyMGNsYXNzaWZpZXIlMjBzdGlsbCUyMG5lZWRzJTIwdG8lMjBiZSUyMHRyYWluZWQlMEFsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTBBbG9naXRzJTIwJTNEJTIwb3V0cHV0cy5sb2dpdHM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, YosoForMultipleChoice
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;uw-madison/yoso-4096&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = YosoForMultipleChoice.from_pretrained(<span class="hljs-string">&quot;uw-madison/yoso-4096&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;In Italy, pizza served in formal settings, such as at a restaurant, is presented unsliced.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>choice0 = <span class="hljs-string">&quot;It is eaten with a fork and a knife.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>choice1 = <span class="hljs-string">&quot;It is eaten while held in the hand.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = torch.tensor(<span class="hljs-number">0</span>).unsqueeze(<span class="hljs-number">0</span>)  <span class="hljs-comment"># choice0 is correct (according to Wikipedia ;)), batch size 1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = tokenizer([prompt, prompt], [choice0, choice1], return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, padding=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**{k: v.unsqueeze(<span class="hljs-number">0</span>) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> encoding.items()}, labels=labels)  <span class="hljs-comment"># batch size is 1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># the linear classifier still needs to be trained</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),{c(){d=s("p"),b=i("Example:"),m=f(),M(p.$$.fragment)},l(n){d=a(n,"P",{});var c=r(d);b=l(c,"Example:"),c.forEach(t),m=g(n),w(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,m,c),T(p,n,c),y=!0},p:Pe,i(n){y||(k(p.$$.fragment,n),y=!0)},o(n){v(p.$$.fragment,n),y=!1},d(n){n&&t(d),n&&t(m),$(p,n)}}}function vl(j){let d,b,m,p,y;return{c(){d=s("p"),b=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=s("code"),p=i("Module"),y=i(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(n){d=a(n,"P",{});var c=r(d);b=l(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(c,"CODE",{});var Y=r(m);p=l(Y,"Module"),Y.forEach(t),y=l(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(t)},m(n,c){_(n,d,c),e(d,b),e(d,m),e(m,p),e(d,y)},d(n){n&&t(d)}}}function $l(j){let d,b,m,p,y;return p=new He({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBZb3NvRm9yVG9rZW5DbGFzc2lmaWNhdGlvbiUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIydXctbWFkaXNvbiUyRnlvc28tNDA5NiUyMiklMEFtb2RlbCUyMCUzRCUyMFlvc29Gb3JUb2tlbkNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJ1dy1tYWRpc29uJTJGeW9zby00MDk2JTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplciglMEElMjAlMjAlMjAlMjAlMjJIdWdnaW5nRmFjZSUyMGlzJTIwYSUyMGNvbXBhbnklMjBiYXNlZCUyMGluJTIwUGFyaXMlMjBhbmQlMjBOZXclMjBZb3JrJTIyJTJDJTIwYWRkX3NwZWNpYWxfdG9rZW5zJTNERmFsc2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTBBKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBJTBBcHJlZGljdGVkX3Rva2VuX2NsYXNzX2lkcyUyMCUzRCUyMGxvZ2l0cy5hcmdtYXgoLTEpJTBBJTBBJTIzJTIwTm90ZSUyMHRoYXQlMjB0b2tlbnMlMjBhcmUlMjBjbGFzc2lmaWVkJTIwcmF0aGVyJTIwdGhlbiUyMGlucHV0JTIwd29yZHMlMjB3aGljaCUyMG1lYW5zJTIwdGhhdCUwQSUyMyUyMHRoZXJlJTIwbWlnaHQlMjBiZSUyMG1vcmUlMjBwcmVkaWN0ZWQlMjB0b2tlbiUyMGNsYXNzZXMlMjB0aGFuJTIwd29yZHMuJTBBJTIzJTIwTXVsdGlwbGUlMjB0b2tlbiUyMGNsYXNzZXMlMjBtaWdodCUyMGFjY291bnQlMjBmb3IlMjB0aGUlMjBzYW1lJTIwd29yZCUwQXByZWRpY3RlZF90b2tlbnNfY2xhc3NlcyUyMCUzRCUyMCU1Qm1vZGVsLmNvbmZpZy5pZDJsYWJlbCU1QnQuaXRlbSgpJTVEJTIwZm9yJTIwdCUyMGluJTIwcHJlZGljdGVkX3Rva2VuX2NsYXNzX2lkcyU1QjAlNUQlNUQlMEElMEFsYWJlbHMlMjAlM0QlMjBwcmVkaWN0ZWRfdG9rZW5fY2xhc3NfaWRzJTBBbG9zcyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzJTJDJTIwbGFiZWxzJTNEbGFiZWxzKS5sb3Nz",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, YosoForTokenClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;uw-madison/yoso-4096&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = YosoForTokenClassification.from_pretrained(<span class="hljs-string">&quot;uw-madison/yoso-4096&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;HuggingFace is a company based in Paris and New York&quot;</span>, add_special_tokens=<span class="hljs-literal">False</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    logits = model(**inputs).logits

<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_token_class_ids = logits.argmax(-<span class="hljs-number">1</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Note that tokens are classified rather then input words which means that</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># there might be more predicted token classes than words.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Multiple token classes might account for the same word</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_tokens_classes = [model.config.id2label[t.item()] <span class="hljs-keyword">for</span> t <span class="hljs-keyword">in</span> predicted_token_class_ids[<span class="hljs-number">0</span>]]

<span class="hljs-meta">&gt;&gt;&gt; </span>labels = predicted_token_class_ids
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = model(**inputs, labels=labels).loss`}}),{c(){d=s("p"),b=i("Example:"),m=f(),M(p.$$.fragment)},l(n){d=a(n,"P",{});var c=r(d);b=l(c,"Example:"),c.forEach(t),m=g(n),w(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,m,c),T(p,n,c),y=!0},p:Pe,i(n){y||(k(p.$$.fragment,n),y=!0)},o(n){v(p.$$.fragment,n),y=!1},d(n){n&&t(d),n&&t(m),$(p,n)}}}function jl(j){let d,b,m,p,y;return{c(){d=s("p"),b=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=s("code"),p=i("Module"),y=i(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(n){d=a(n,"P",{});var c=r(d);b=l(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(c,"CODE",{});var Y=r(m);p=l(Y,"Module"),Y.forEach(t),y=l(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(t)},m(n,c){_(n,d,c),e(d,b),e(d,m),e(m,p),e(d,y)},d(n){n&&t(d)}}}function Yl(j){let d,b,m,p,y;return p=new He({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBZb3NvRm9yUXVlc3Rpb25BbnN3ZXJpbmclMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMnV3LW1hZGlzb24lMkZ5b3NvLTQwOTYlMjIpJTBBbW9kZWwlMjAlM0QlMjBZb3NvRm9yUXVlc3Rpb25BbnN3ZXJpbmcuZnJvbV9wcmV0cmFpbmVkKCUyMnV3LW1hZGlzb24lMkZ5b3NvLTQwOTYlMjIpJTBBJTBBcXVlc3Rpb24lMkMlMjB0ZXh0JTIwJTNEJTIwJTIyV2hvJTIwd2FzJTIwSmltJTIwSGVuc29uJTNGJTIyJTJDJTIwJTIySmltJTIwSGVuc29uJTIwd2FzJTIwYSUyMG5pY2UlMjBwdXBwZXQlMjIlMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIocXVlc3Rpb24lMkMlMjB0ZXh0JTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQSUwQWFuc3dlcl9zdGFydF9pbmRleCUyMCUzRCUyMG91dHB1dHMuc3RhcnRfbG9naXRzLmFyZ21heCgpJTBBYW5zd2VyX2VuZF9pbmRleCUyMCUzRCUyMG91dHB1dHMuZW5kX2xvZ2l0cy5hcmdtYXgoKSUwQSUwQXByZWRpY3RfYW5zd2VyX3Rva2VucyUyMCUzRCUyMGlucHV0cy5pbnB1dF9pZHMlNUIwJTJDJTIwYW5zd2VyX3N0YXJ0X2luZGV4JTIwJTNBJTIwYW5zd2VyX2VuZF9pbmRleCUyMCUyQiUyMDElNUQlMEElMEElMjMlMjB0YXJnZXQlMjBpcyUyMCUyMm5pY2UlMjBwdXBwZXQlMjIlMEF0YXJnZXRfc3RhcnRfaW5kZXglMjAlM0QlMjB0b3JjaC50ZW5zb3IoJTVCMTQlNUQpJTBBdGFyZ2V0X2VuZF9pbmRleCUyMCUzRCUyMHRvcmNoLnRlbnNvciglNUIxNSU1RCklMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMlMkMlMjBzdGFydF9wb3NpdGlvbnMlM0R0YXJnZXRfc3RhcnRfaW5kZXglMkMlMjBlbmRfcG9zaXRpb25zJTNEdGFyZ2V0X2VuZF9pbmRleCklMEFsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3Nz",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, YosoForQuestionAnswering
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;uw-madison/yoso-4096&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = YosoForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;uw-madison/yoso-4096&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>question, text = <span class="hljs-string">&quot;Who was Jim Henson?&quot;</span>, <span class="hljs-string">&quot;Jim Henson was a nice puppet&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(question, text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>answer_start_index = outputs.start_logits.argmax()
<span class="hljs-meta">&gt;&gt;&gt; </span>answer_end_index = outputs.end_logits.argmax()

<span class="hljs-meta">&gt;&gt;&gt; </span>predict_answer_tokens = inputs.input_ids[<span class="hljs-number">0</span>, answer_start_index : answer_end_index + <span class="hljs-number">1</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># target is &quot;nice puppet&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>target_start_index = torch.tensor([<span class="hljs-number">14</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>target_end_index = torch.tensor([<span class="hljs-number">15</span>])

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, start_positions=target_start_index, end_positions=target_end_index)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss`}}),{c(){d=s("p"),b=i("Example:"),m=f(),M(p.$$.fragment)},l(n){d=a(n,"P",{});var c=r(d);b=l(c,"Example:"),c.forEach(t),m=g(n),w(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,b),_(n,m,c),T(p,n,c),y=!0},p:Pe,i(n){y||(k(p.$$.fragment,n),y=!0)},o(n){v(p.$$.fragment,n),y=!1},d(n){n&&t(d),n&&t(m),$(p,n)}}}function Jl(j){let d,b,m,p,y,n,c,Y,ts,_n,L,ge,wt,De,ns,Tt,ss,yn,P,as,Ke,rs,is,ls,bn,Zo,ds,Mn,Bo,kt,cs,wn,No,ps,Tn,R,vt,hs,ms,H,us,$t,fs,gs,jt,_s,ys,bs,D,Ms,Yt,ws,Ts,Jt,ks,vs,kn,_e,Qr,vn,ye,$s,qo,js,Ys,$n,V,Js,eo,Us,Cs,oo,Fs,zs,jn,K,be,Ut,to,Es,Ct,Ws,Yn,J,Ft,So,xs,Is,zt,Go,Zs,Bs,Et,Ao,Ns,qs,Wt,Ro,Ss,Gs,xt,Vo,As,Jn,ee,Me,It,no,Rs,Zt,Vs,Un,C,so,Xs,oe,Os,Xo,Qs,Ls,ao,Ps,Hs,Ds,te,Ks,Oo,ea,oa,Qo,ta,na,sa,we,Cn,ne,Te,Bt,ro,aa,Nt,ra,Fn,Z,io,ia,lo,la,co,da,ca,pa,z,po,ha,se,ma,Lo,ua,fa,qt,ga,_a,ya,ke,ba,ve,zn,ae,$e,St,ho,Ma,Gt,wa,En,B,mo,Ta,re,ka,At,va,$a,uo,ja,Ya,Ja,E,fo,Ua,ie,Ca,Po,Fa,za,Rt,Ea,Wa,xa,je,Ia,Ye,Wn,le,Je,Vt,go,Za,Xt,Ba,xn,N,_o,Na,yo,qa,bo,Sa,Ga,Aa,U,Mo,Ra,de,Va,Ho,Xa,Oa,Ot,Qa,La,Pa,Ue,Ha,Ce,Da,Fe,In,ce,ze,Qt,wo,Ka,Lt,er,Zn,q,To,or,ko,tr,vo,nr,sr,ar,W,$o,rr,pe,ir,Do,lr,dr,Pt,cr,pr,hr,Ee,mr,We,Bn,he,xe,Ht,jo,ur,Dt,fr,Nn,S,Yo,gr,Jo,_r,Uo,yr,br,Mr,x,Co,wr,me,Tr,Ko,kr,vr,Kt,$r,jr,Yr,Ie,Jr,Ze,qn,ue,Be,en,Fo,Ur,on,Cr,Sn,G,zo,Fr,A,zr,tn,Er,Wr,nn,xr,Ir,Eo,Zr,Br,Nr,I,Wo,qr,fe,Sr,et,Gr,Ar,sn,Rr,Vr,Xr,Ne,Or,qe,Gn;return n=new Q({}),De=new Q({}),to=new Q({}),no=new Q({}),so=new F({props:{name:"class transformers.YosoConfig",anchor:"transformers.YosoConfig",parameters:[{name:"vocab_size",val:" = 50265"},{name:"hidden_size",val:" = 768"},{name:"num_hidden_layers",val:" = 12"},{name:"num_attention_heads",val:" = 12"},{name:"intermediate_size",val:" = 3072"},{name:"hidden_act",val:" = 'gelu'"},{name:"hidden_dropout_prob",val:" = 0.1"},{name:"attention_probs_dropout_prob",val:" = 0.1"},{name:"max_position_embeddings",val:" = 4096"},{name:"type_vocab_size",val:" = 1"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-12"},{name:"position_embedding_type",val:" = 'absolute'"},{name:"use_expectation",val:" = True"},{name:"hash_code_len",val:" = 9"},{name:"num_hash",val:" = 64"},{name:"conv_window",val:" = None"},{name:"use_fast_hash",val:" = True"},{name:"lsh_backward",val:" = True"},{name:"pad_token_id",val:" = 1"},{name:"bos_token_id",val:" = 0"},{name:"eos_token_id",val:" = 2"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.YosoConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 50265) &#x2014;
Vocabulary size of the YOSO model. Defines the number of different tokens that can be represented by the
<code>inputs_ids</code> passed when calling <a href="/docs/transformers/main/en/model_doc/yoso#transformers.YosoModel">YosoModel</a>.`,name:"vocab_size"},{anchor:"transformers.YosoConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimension of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.YosoConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"num_hidden_layers"},{anchor:"transformers.YosoConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.YosoConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 3072) &#x2014;
Dimension of the &#x201C;intermediate&#x201D; (i.e., feed-forward) layer in the Transformer encoder.`,name:"intermediate_size"},{anchor:"transformers.YosoConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder and pooler. If string, <code>&quot;gelu&quot;</code>,
<code>&quot;relu&quot;</code>, <code>&quot;selu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"hidden_act"},{anchor:"transformers.YosoConfig.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probabilitiy for all fully connected layers in the embeddings, encoder, and pooler.`,name:"hidden_dropout_prob"},{anchor:"transformers.YosoConfig.attention_probs_dropout_prob",description:`<strong>attention_probs_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_probs_dropout_prob"},{anchor:"transformers.YosoConfig.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 512) &#x2014;
The maximum sequence length that this model might ever be used with. Typically set this to something large
just in case (e.g., 512 or 1024 or 2048).`,name:"max_position_embeddings"},{anchor:"transformers.YosoConfig.type_vocab_size",description:`<strong>type_vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
The vocabulary size of the <code>token_type_ids</code> passed when calling <a href="/docs/transformers/main/en/model_doc/yoso#transformers.YosoModel">YosoModel</a>.`,name:"type_vocab_size"},{anchor:"transformers.YosoConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.YosoConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-12) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.YosoConfig.position_embedding_type",description:`<strong>position_embedding_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;absolute&quot;</code>) &#x2014;
Type of position embedding. Choose one of <code>&quot;absolute&quot;</code>, <code>&quot;relative_key&quot;</code>, <code>&quot;relative_key_query&quot;</code>.`,name:"position_embedding_type"},{anchor:"transformers.YosoConfig.use_expectation",description:`<strong>use_expectation</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to use YOSO Expectation. Overrides any effect of num_hash.`,name:"use_expectation"},{anchor:"transformers.YosoConfig.hash_code_len",description:`<strong>hash_code_len</strong> (<code>int</code>, <em>optional</em>, defaults to 9) &#x2014;
The length of hashes generated by the hash functions.`,name:"hash_code_len"},{anchor:"transformers.YosoConfig.num_hash",description:`<strong>num_hash</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
Number of hash functions used in <code>YosoSelfAttention</code>.`,name:"num_hash"},{anchor:"transformers.YosoConfig.conv_window",description:`<strong>conv_window</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Kernel size of depth-wise convolution.`,name:"conv_window"},{anchor:"transformers.YosoConfig.use_fast_hash",description:`<strong>use_fast_hash</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use custom cuda kernels which perform fast random projection via hadamard transform.`,name:"use_fast_hash"},{anchor:"transformers.YosoConfig.lsh_backward",description:`<strong>lsh_backward</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to perform backpropagation using Locality Sensitive Hashing.`,name:"lsh_backward"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/yoso/configuration_yoso.py#L29"}}),we=new Le({props:{anchor:"transformers.YosoConfig.example",$$slots:{default:[ul]},$$scope:{ctx:j}}}),ro=new Q({}),io=new F({props:{name:"class transformers.YosoModel",anchor:"transformers.YosoModel",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.YosoModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/yoso#transformers.YosoConfig">YosoConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/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/main/src/transformers/models/yoso/modeling_yoso.py#L741"}}),po=new F({props:{name:"forward",anchor:"transformers.YosoModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.Tensor] = 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.YosoModel.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.YosoModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.YosoModel.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.YosoModel.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.YosoModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.YosoModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.YosoModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.YosoModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.YosoModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/yoso/modeling_yoso.py#L766",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithCrossAttentions</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/main/en/model_doc/yoso#transformers.YosoConfig"
>YosoConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> and <code>config.add_cross_attention=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ke=new Mt({props:{$$slots:{default:[fl]},$$scope:{ctx:j}}}),ve=new Le({props:{anchor:"transformers.YosoModel.forward.example",$$slots:{default:[gl]},$$scope:{ctx:j}}}),ho=new Q({}),mo=new F({props:{name:"class transformers.YosoForMaskedLM",anchor:"transformers.YosoForMaskedLM",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.YosoForMaskedLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/yoso#transformers.YosoConfig">YosoConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/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/main/src/transformers/models/yoso/modeling_yoso.py#L853"}}),fo=new F({props:{name:"forward",anchor:"transformers.YosoForMaskedLM.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"labels",val:": typing.Optional[torch.Tensor] = 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.YosoForMaskedLM.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.YosoForMaskedLM.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.YosoForMaskedLM.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.YosoForMaskedLM.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.YosoForMaskedLM.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.YosoForMaskedLM.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.YosoForMaskedLM.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.YosoForMaskedLM.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.YosoForMaskedLM.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.YosoForMaskedLM.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the masked language modeling loss. Indices should be in <code>[-100, 0, ..., config.vocab_size]</code> (see <code>input_ids</code> docstring) Tokens with indices set to <code>-100</code> are ignored (masked), the
loss is only computed for the tokens with labels in <code>[0, ..., config.vocab_size]</code>.`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/yoso/modeling_yoso.py#L871",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.MaskedLMOutput"
>transformers.modeling_outputs.MaskedLMOutput</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/main/en/model_doc/yoso#transformers.YosoConfig"
>YosoConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Masked language modeling (MLM) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.MaskedLMOutput"
>transformers.modeling_outputs.MaskedLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),je=new Mt({props:{$$slots:{default:[_l]},$$scope:{ctx:j}}}),Ye=new Le({props:{anchor:"transformers.YosoForMaskedLM.forward.example",$$slots:{default:[yl]},$$scope:{ctx:j}}}),go=new Q({}),_o=new F({props:{name:"class transformers.YosoForSequenceClassification",anchor:"transformers.YosoForSequenceClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.YosoForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/yoso#transformers.YosoConfig">YosoConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/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/main/src/transformers/models/yoso/modeling_yoso.py#L956"}}),Mo=new F({props:{name:"forward",anchor:"transformers.YosoForSequenceClassification.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"labels",val:": typing.Optional[torch.Tensor] = 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.YosoForSequenceClassification.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.YosoForSequenceClassification.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.YosoForSequenceClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.YosoForSequenceClassification.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.YosoForSequenceClassification.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.YosoForSequenceClassification.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.YosoForSequenceClassification.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.YosoForSequenceClassification.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.YosoForSequenceClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.YosoForSequenceClassification.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the sequence classification/regression loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>. If <code>config.num_labels == 1</code> a regression loss is computed (Mean-Square loss), If
<code>config.num_labels &gt; 1</code> a classification loss is computed (Cross-Entropy).`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/yoso/modeling_yoso.py#L966",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</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/main/en/model_doc/yoso#transformers.YosoConfig"
>YosoConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Classification (or regression if config.num_labels==1) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.num_labels)</code>) \u2014 Classification (or regression if config.num_labels==1) scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ue=new Mt({props:{$$slots:{default:[bl]},$$scope:{ctx:j}}}),Ce=new Le({props:{anchor:"transformers.YosoForSequenceClassification.forward.example",$$slots:{default:[Ml]},$$scope:{ctx:j}}}),Fe=new Le({props:{anchor:"transformers.YosoForSequenceClassification.forward.example-2",$$slots:{default:[wl]},$$scope:{ctx:j}}}),wo=new Q({}),To=new F({props:{name:"class transformers.YosoForMultipleChoice",anchor:"transformers.YosoForMultipleChoice",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.YosoForMultipleChoice.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/yoso#transformers.YosoConfig">YosoConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/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/main/src/transformers/models/yoso/modeling_yoso.py#L1047"}}),$o=new F({props:{name:"forward",anchor:"transformers.YosoForMultipleChoice.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"labels",val:": typing.Optional[torch.Tensor] = 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.YosoForMultipleChoice.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_choices, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.YosoForMultipleChoice.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.YosoForMultipleChoice.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_choices, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.YosoForMultipleChoice.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, num_choices, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.YosoForMultipleChoice.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.YosoForMultipleChoice.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.YosoForMultipleChoice.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.YosoForMultipleChoice.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.YosoForMultipleChoice.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.YosoForMultipleChoice.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the multiple choice classification loss. Indices should be in <code>[0, ..., num_choices-1]</code> where <code>num_choices</code> is the size of the second dimension of the input tensors. (See
<code>input_ids</code> above)`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/yoso/modeling_yoso.py#L1058",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.MultipleChoiceModelOutput"
>transformers.modeling_outputs.MultipleChoiceModelOutput</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/main/en/model_doc/yoso#transformers.YosoConfig"
>YosoConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <em>(1,)</em>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Classification loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_choices)</code>) \u2014 <em>num_choices</em> is the second dimension of the input tensors. (see <em>input_ids</em> above).</p>
<p>Classification scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.MultipleChoiceModelOutput"
>transformers.modeling_outputs.MultipleChoiceModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ee=new Mt({props:{$$slots:{default:[Tl]},$$scope:{ctx:j}}}),We=new Le({props:{anchor:"transformers.YosoForMultipleChoice.forward.example",$$slots:{default:[kl]},$$scope:{ctx:j}}}),jo=new Q({}),Yo=new F({props:{name:"class transformers.YosoForTokenClassification",anchor:"transformers.YosoForTokenClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.YosoForTokenClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/yoso#transformers.YosoConfig">YosoConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/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/main/src/transformers/models/yoso/modeling_yoso.py#L1138"}}),Co=new F({props:{name:"forward",anchor:"transformers.YosoForTokenClassification.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"labels",val:": typing.Optional[torch.Tensor] = 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.YosoForTokenClassification.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.YosoForTokenClassification.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.YosoForTokenClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.YosoForTokenClassification.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.YosoForTokenClassification.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.YosoForTokenClassification.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.YosoForTokenClassification.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.YosoForTokenClassification.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.YosoForTokenClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.YosoForTokenClassification.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for computing the token classification loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>.`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/yoso/modeling_yoso.py#L1150",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/en/model_doc/yoso#transformers.YosoConfig"
>YosoConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided)  \u2014 Classification loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.num_labels)</code>) \u2014 Classification scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ie=new Mt({props:{$$slots:{default:[vl]},$$scope:{ctx:j}}}),Ze=new Le({props:{anchor:"transformers.YosoForTokenClassification.forward.example",$$slots:{default:[$l]},$$scope:{ctx:j}}}),Fo=new Q({}),zo=new F({props:{name:"class transformers.YosoForQuestionAnswering",anchor:"transformers.YosoForQuestionAnswering",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.YosoForQuestionAnswering.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/yoso#transformers.YosoConfig">YosoConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/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/main/src/transformers/models/yoso/modeling_yoso.py#L1223"}}),Wo=new F({props:{name:"forward",anchor:"transformers.YosoForQuestionAnswering.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"position_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"start_positions",val:": typing.Optional[torch.Tensor] = None"},{name:"end_positions",val:": typing.Optional[torch.Tensor] = 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.YosoForQuestionAnswering.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.</p>
<p>Indices can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.YosoForQuestionAnswering.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.YosoForQuestionAnswering.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:</p>
<ul>
<li>0 corresponds to a <em>sentence A</em> token,</li>
<li>1 corresponds to a <em>sentence B</em> token.</li>
</ul>
<p><a href="../glossary#token-type-ids">What are token type IDs?</a>`,name:"token_type_ids"},{anchor:"transformers.YosoForQuestionAnswering.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range <code>[0, config.max_position_embeddings - 1]</code>.</p>
<p><a href="../glossary#position-ids">What are position IDs?</a>`,name:"position_ids"},{anchor:"transformers.YosoForQuestionAnswering.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.YosoForQuestionAnswering.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.YosoForQuestionAnswering.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.YosoForQuestionAnswering.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.YosoForQuestionAnswering.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.YosoForQuestionAnswering.forward.start_positions",description:`<strong>start_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for position (index) of the start of the labelled span for computing the token classification loss.
Positions are clamped to the length of the sequence (<code>sequence_length</code>). Position outside of the sequence
are not taken into account for computing the loss.`,name:"start_positions"},{anchor:"transformers.YosoForQuestionAnswering.forward.end_positions",description:`<strong>end_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for position (index) of the end of the labelled span for computing the token classification loss.
Positions are clamped to the length of the sequence (<code>sequence_length</code>). Position outside of the sequence
are not taken into account for computing the loss.`,name:"end_positions"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/yoso/modeling_yoso.py#L1236",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/en/model_doc/yoso#transformers.YosoConfig"
>YosoConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Total span extraction loss is the sum of a Cross-Entropy for the start and end positions.</p>
</li>
<li>
<p><strong>start_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) \u2014 Span-start scores (before SoftMax).</p>
</li>
<li>
<p><strong>end_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) \u2014 Span-end scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ne=new Mt({props:{$$slots:{default:[jl]},$$scope:{ctx:j}}}),qe=new Le({props:{anchor:"transformers.YosoForQuestionAnswering.forward.example",$$slots:{default:[Yl]},$$scope:{ctx:j}}}),{c(){d=s("meta"),b=f(),m=s("h1"),p=s("a"),y=s("span"),M(n.$$.fragment),c=f(),Y=s("span"),ts=i("YOSO"),_n=f(),L=s("h2"),ge=s("a"),wt=s("span"),M(De.$$.fragment),ns=f(),Tt=s("span"),ss=i("Overview"),yn=f(),P=s("p"),as=i("The YOSO model was proposed in "),Ke=s("a"),rs=i("You Only Sample (Almost) Once: Linear Cost Self-Attention Via Bernoulli Sampling"),is=s("br"),ls=i(`
by Zhanpeng Zeng, Yunyang Xiong, Sathya N. Ravi, Shailesh Acharya, Glenn Fung, Vikas Singh. YOSO approximates standard softmax self-attention
via a Bernoulli sampling scheme based on Locality Sensitive Hashing (LSH). In principle, all the Bernoulli random variables can be sampled with
a single hash.`),bn=f(),Zo=s("p"),ds=i("The abstract from the paper is the following:"),Mn=f(),Bo=s("p"),kt=s("em"),cs=i(`Transformer-based models are widely used in natural language processing (NLP). Central to the transformer model is
the self-attention mechanism, which captures the interactions of token pairs in the input sequences and depends quadratically
on the sequence length. Training such models on longer sequences is expensive. In this paper, we show that a Bernoulli sampling
attention mechanism based on Locality Sensitive Hashing (LSH), decreases the quadratic complexity of such models to linear.
We bypass the quadratic cost by considering self-attention as a sum of individual tokens associated with Bernoulli random
variables that can, in principle, be sampled at once by a single hash (although in practice, this number may be a small constant).
This leads to an efficient sampling scheme to estimate self-attention which relies on specific modifications of
LSH (to enable deployment on GPU architectures). We evaluate our algorithm on the GLUE benchmark with standard 512 sequence
length where we see favorable performance relative to a standard pretrained Transformer. On the Long Range Arena (LRA) benchmark,
for evaluating performance on long sequences, our method achieves results consistent with softmax self-attention but with sizable
speed-ups and memory savings and often outperforms other efficient self-attention methods. Our code is available at this https URL`),wn=f(),No=s("p"),ps=i("Tips:"),Tn=f(),R=s("ul"),vt=s("li"),hs=i(`The YOSO attention algorithm is implemented through custom CUDA kernels, functions written in CUDA C++ that can be executed multiple times
in parallel on a GPU.`),ms=f(),H=s("li"),us=i("The kernels provide a "),$t=s("code"),fs=i("fast_hash"),gs=i(` function, which approximates the random projections of the queries and keys using the Fast Hadamard Transform. Using these
hash codes, the `),jt=s("code"),_s=i("lsh_cumulation"),ys=i(" function approximates self-attention via LSH-based Bernoulli sampling."),bs=f(),D=s("li"),Ms=i("To use the custom kernels, the user should set "),Yt=s("code"),ws=i("config.use_expectation = False"),Ts=i(`. To ensure that the kernels are compiled successfully,
the user must install the correct version of PyTorch and cudatoolkit. By default, `),Jt=s("code"),ks=i("config.use_expectation = True"),vs=i(`, which uses YOSO-E and
does not require compiling CUDA kernels.`),kn=f(),_e=s("img"),vn=f(),ye=s("small"),$s=i("YOSO Attention Algorithm. Taken from the "),qo=s("a"),js=i("original paper"),Ys=i("."),$n=f(),V=s("p"),Js=i("This model was contributed by "),eo=s("a"),Us=i("novice03"),Cs=i(". The original code can be found "),oo=s("a"),Fs=i("here"),zs=i("."),jn=f(),K=s("h2"),be=s("a"),Ut=s("span"),M(to.$$.fragment),Es=f(),Ct=s("span"),Ws=i("Documentation resources"),Yn=f(),J=s("ul"),Ft=s("li"),So=s("a"),xs=i("Text classification task guide"),Is=f(),zt=s("li"),Go=s("a"),Zs=i("Token classification task guide"),Bs=f(),Et=s("li"),Ao=s("a"),Ns=i("Question answering task guide"),qs=f(),Wt=s("li"),Ro=s("a"),Ss=i("Masked language modeling task guide"),Gs=f(),xt=s("li"),Vo=s("a"),As=i("Multiple choice task guide"),Jn=f(),ee=s("h2"),Me=s("a"),It=s("span"),M(no.$$.fragment),Rs=f(),Zt=s("span"),Vs=i("YosoConfig"),Un=f(),C=s("div"),M(so.$$.fragment),Xs=f(),oe=s("p"),Os=i("This is the configuration class to store the configuration of a "),Xo=s("a"),Qs=i("YosoModel"),Ls=i(`. It is used to instantiate an YOSO
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 YOSO
`),ao=s("a"),Ps=i("uw-madison/yoso-4096"),Hs=i(" architecture."),Ds=f(),te=s("p"),Ks=i("Configuration objects inherit from "),Oo=s("a"),ea=i("PretrainedConfig"),oa=i(` and can be used to control the model outputs. Read the
documentation from `),Qo=s("a"),ta=i("PretrainedConfig"),na=i(" for more information."),sa=f(),M(we.$$.fragment),Cn=f(),ne=s("h2"),Te=s("a"),Bt=s("span"),M(ro.$$.fragment),aa=f(),Nt=s("span"),ra=i("YosoModel"),Fn=f(),Z=s("div"),M(io.$$.fragment),ia=f(),lo=s("p"),la=i(`The bare YOSO Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),co=s("a"),da=i("torch.nn.Module"),ca=i(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),pa=f(),z=s("div"),M(po.$$.fragment),ha=f(),se=s("p"),ma=i("The "),Lo=s("a"),ua=i("YosoModel"),fa=i(" forward method, overrides the "),qt=s("code"),ga=i("__call__"),_a=i(" special method."),ya=f(),M(ke.$$.fragment),ba=f(),M(ve.$$.fragment),zn=f(),ae=s("h2"),$e=s("a"),St=s("span"),M(ho.$$.fragment),Ma=f(),Gt=s("span"),wa=i("YosoForMaskedLM"),En=f(),B=s("div"),M(mo.$$.fragment),Ta=f(),re=s("p"),ka=i("YOSO Model with a "),At=s("code"),va=i("language modeling"),$a=i(` head on top.
This model is a PyTorch `),uo=s("a"),ja=i("torch.nn.Module"),Ya=i(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Ja=f(),E=s("div"),M(fo.$$.fragment),Ua=f(),ie=s("p"),Ca=i("The "),Po=s("a"),Fa=i("YosoForMaskedLM"),za=i(" forward method, overrides the "),Rt=s("code"),Ea=i("__call__"),Wa=i(" special method."),xa=f(),M(je.$$.fragment),Ia=f(),M(Ye.$$.fragment),Wn=f(),le=s("h2"),Je=s("a"),Vt=s("span"),M(go.$$.fragment),Za=f(),Xt=s("span"),Ba=i("YosoForSequenceClassification"),xn=f(),N=s("div"),M(_o.$$.fragment),Na=f(),yo=s("p"),qa=i(`YOSO Model transformer with a sequence classification/regression head on top (a linear layer on top of
the pooled output) e.g. for GLUE tasks.
This model is a PyTorch `),bo=s("a"),Sa=i("torch.nn.Module"),Ga=i(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Aa=f(),U=s("div"),M(Mo.$$.fragment),Ra=f(),de=s("p"),Va=i("The "),Ho=s("a"),Xa=i("YosoForSequenceClassification"),Oa=i(" forward method, overrides the "),Ot=s("code"),Qa=i("__call__"),La=i(" special method."),Pa=f(),M(Ue.$$.fragment),Ha=f(),M(Ce.$$.fragment),Da=f(),M(Fe.$$.fragment),In=f(),ce=s("h2"),ze=s("a"),Qt=s("span"),M(wo.$$.fragment),Ka=f(),Lt=s("span"),er=i("YosoForMultipleChoice"),Zn=f(),q=s("div"),M(To.$$.fragment),or=f(),ko=s("p"),tr=i(`YOSO Model with a multiple choice classification head on top (a linear layer on top of
the pooled output and a softmax) e.g. for RocStories/SWAG tasks.
This model is a PyTorch `),vo=s("a"),nr=i("torch.nn.Module"),sr=i(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),ar=f(),W=s("div"),M($o.$$.fragment),rr=f(),pe=s("p"),ir=i("The "),Do=s("a"),lr=i("YosoForMultipleChoice"),dr=i(" forward method, overrides the "),Pt=s("code"),cr=i("__call__"),pr=i(" special method."),hr=f(),M(Ee.$$.fragment),mr=f(),M(We.$$.fragment),Bn=f(),he=s("h2"),xe=s("a"),Ht=s("span"),M(jo.$$.fragment),ur=f(),Dt=s("span"),fr=i("YosoForTokenClassification"),Nn=f(),S=s("div"),M(Yo.$$.fragment),gr=f(),Jo=s("p"),_r=i(`YOSO 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.
This model is a PyTorch `),Uo=s("a"),yr=i("torch.nn.Module"),br=i(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Mr=f(),x=s("div"),M(Co.$$.fragment),wr=f(),me=s("p"),Tr=i("The "),Ko=s("a"),kr=i("YosoForTokenClassification"),vr=i(" forward method, overrides the "),Kt=s("code"),$r=i("__call__"),jr=i(" special method."),Yr=f(),M(Ie.$$.fragment),Jr=f(),M(Ze.$$.fragment),qn=f(),ue=s("h2"),Be=s("a"),en=s("span"),M(Fo.$$.fragment),Ur=f(),on=s("span"),Cr=i("YosoForQuestionAnswering"),Sn=f(),G=s("div"),M(zo.$$.fragment),Fr=f(),A=s("p"),zr=i(`YOSO Model with a span classification head on top for extractive question-answering tasks like SQuAD (a linear
layers on top of the hidden-states output to compute `),tn=s("code"),Er=i("span start logits"),Wr=i(" and "),nn=s("code"),xr=i("span end logits"),Ir=i(`).
This model is a PyTorch `),Eo=s("a"),Zr=i("torch.nn.Module"),Br=i(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Nr=f(),I=s("div"),M(Wo.$$.fragment),qr=f(),fe=s("p"),Sr=i("The "),et=s("a"),Gr=i("YosoForQuestionAnswering"),Ar=i(" forward method, overrides the "),sn=s("code"),Rr=i("__call__"),Vr=i(" special method."),Xr=f(),M(Ne.$$.fragment),Or=f(),M(qe.$$.fragment),this.h()},l(o){const u=pl('[data-svelte="svelte-1phssyn"]',document.head);d=a(u,"META",{name:!0,content:!0}),u.forEach(t),b=g(o),m=a(o,"H1",{class:!0});var xo=r(m);p=a(xo,"A",{id:!0,class:!0,href:!0});var an=r(p);y=a(an,"SPAN",{});var rn=r(y);w(n.$$.fragment,rn),rn.forEach(t),an.forEach(t),c=g(xo),Y=a(xo,"SPAN",{});var ln=r(Y);ts=l(ln,"YOSO"),ln.forEach(t),xo.forEach(t),_n=g(o),L=a(o,"H2",{class:!0});var Io=r(L);ge=a(Io,"A",{id:!0,class:!0,href:!0});var dn=r(ge);wt=a(dn,"SPAN",{});var cn=r(wt);w(De.$$.fragment,cn),cn.forEach(t),dn.forEach(t),ns=g(Io),Tt=a(Io,"SPAN",{});var pn=r(Tt);ss=l(pn,"Overview"),pn.forEach(t),Io.forEach(t),yn=g(o),P=a(o,"P",{});var Se=r(P);as=l(Se,"The YOSO model was proposed in "),Ke=a(Se,"A",{href:!0,rel:!0});var hn=r(Ke);rs=l(hn,"You Only Sample (Almost) Once: Linear Cost Self-Attention Via Bernoulli Sampling"),hn.forEach(t),is=a(Se,"BR",{}),ls=l(Se,`
by Zhanpeng Zeng, Yunyang Xiong, Sathya N. Ravi, Shailesh Acharya, Glenn Fung, Vikas Singh. YOSO approximates standard softmax self-attention
via a Bernoulli sampling scheme based on Locality Sensitive Hashing (LSH). In principle, all the Bernoulli random variables can be sampled with
a single hash.`),Se.forEach(t),bn=g(o),Zo=a(o,"P",{});var mn=r(Zo);ds=l(mn,"The abstract from the paper is the following:"),mn.forEach(t),Mn=g(o),Bo=a(o,"P",{});var un=r(Bo);kt=a(un,"EM",{});var fn=r(kt);cs=l(fn,`Transformer-based models are widely used in natural language processing (NLP). Central to the transformer model is
the self-attention mechanism, which captures the interactions of token pairs in the input sequences and depends quadratically
on the sequence length. Training such models on longer sequences is expensive. In this paper, we show that a Bernoulli sampling
attention mechanism based on Locality Sensitive Hashing (LSH), decreases the quadratic complexity of such models to linear.
We bypass the quadratic cost by considering self-attention as a sum of individual tokens associated with Bernoulli random
variables that can, in principle, be sampled at once by a single hash (although in practice, this number may be a small constant).
This leads to an efficient sampling scheme to estimate self-attention which relies on specific modifications of
LSH (to enable deployment on GPU architectures). We evaluate our algorithm on the GLUE benchmark with standard 512 sequence
length where we see favorable performance relative to a standard pretrained Transformer. On the Long Range Arena (LRA) benchmark,
for evaluating performance on long sequences, our method achieves results consistent with softmax self-attention but with sizable
speed-ups and memory savings and often outperforms other efficient self-attention methods. Our code is available at this https URL`),fn.forEach(t),un.forEach(t),wn=g(o),No=a(o,"P",{});var gn=r(No);ps=l(gn,"Tips:"),gn.forEach(t),Tn=g(o),R=a(o,"UL",{});var ot=r(R);vt=a(ot,"LI",{});var Lr=r(vt);hs=l(Lr,`The YOSO attention algorithm is implemented through custom CUDA kernels, functions written in CUDA C++ that can be executed multiple times
in parallel on a GPU.`),Lr.forEach(t),ms=g(ot),H=a(ot,"LI",{});var tt=r(H);us=l(tt,"The kernels provide a "),$t=a(tt,"CODE",{});var Pr=r($t);fs=l(Pr,"fast_hash"),Pr.forEach(t),gs=l(tt,` function, which approximates the random projections of the queries and keys using the Fast Hadamard Transform. Using these
hash codes, the `),jt=a(tt,"CODE",{});var Hr=r(jt);_s=l(Hr,"lsh_cumulation"),Hr.forEach(t),ys=l(tt," function approximates self-attention via LSH-based Bernoulli sampling."),tt.forEach(t),bs=g(ot),D=a(ot,"LI",{});var nt=r(D);Ms=l(nt,"To use the custom kernels, the user should set "),Yt=a(nt,"CODE",{});var Dr=r(Yt);ws=l(Dr,"config.use_expectation = False"),Dr.forEach(t),Ts=l(nt,`. To ensure that the kernels are compiled successfully,
the user must install the correct version of PyTorch and cudatoolkit. By default, `),Jt=a(nt,"CODE",{});var Kr=r(Jt);ks=l(Kr,"config.use_expectation = True"),Kr.forEach(t),vs=l(nt,`, which uses YOSO-E and
does not require compiling CUDA kernels.`),nt.forEach(t),ot.forEach(t),kn=g(o),_e=a(o,"IMG",{src:!0,alt:!0,width:!0}),vn=g(o),ye=a(o,"SMALL",{});var An=r(ye);$s=l(An,"YOSO Attention Algorithm. Taken from the "),qo=a(An,"A",{href:!0});var ei=r(qo);js=l(ei,"original paper"),ei.forEach(t),Ys=l(An,"."),An.forEach(t),$n=g(o),V=a(o,"P",{});var st=r(V);Js=l(st,"This model was contributed by "),eo=a(st,"A",{href:!0,rel:!0});var oi=r(eo);Us=l(oi,"novice03"),oi.forEach(t),Cs=l(st,". The original code can be found "),oo=a(st,"A",{href:!0,rel:!0});var ti=r(oo);Fs=l(ti,"here"),ti.forEach(t),zs=l(st,"."),st.forEach(t),jn=g(o),K=a(o,"H2",{class:!0});var Rn=r(K);be=a(Rn,"A",{id:!0,class:!0,href:!0});var ni=r(be);Ut=a(ni,"SPAN",{});var si=r(Ut);w(to.$$.fragment,si),si.forEach(t),ni.forEach(t),Es=g(Rn),Ct=a(Rn,"SPAN",{});var ai=r(Ct);Ws=l(ai,"Documentation resources"),ai.forEach(t),Rn.forEach(t),Yn=g(o),J=a(o,"UL",{});var X=r(J);Ft=a(X,"LI",{});var ri=r(Ft);So=a(ri,"A",{href:!0});var ii=r(So);xs=l(ii,"Text classification task guide"),ii.forEach(t),ri.forEach(t),Is=g(X),zt=a(X,"LI",{});var li=r(zt);Go=a(li,"A",{href:!0});var di=r(Go);Zs=l(di,"Token classification task guide"),di.forEach(t),li.forEach(t),Bs=g(X),Et=a(X,"LI",{});var ci=r(Et);Ao=a(ci,"A",{href:!0});var pi=r(Ao);Ns=l(pi,"Question answering task guide"),pi.forEach(t),ci.forEach(t),qs=g(X),Wt=a(X,"LI",{});var hi=r(Wt);Ro=a(hi,"A",{href:!0});var mi=r(Ro);Ss=l(mi,"Masked language modeling task guide"),mi.forEach(t),hi.forEach(t),Gs=g(X),xt=a(X,"LI",{});var ui=r(xt);Vo=a(ui,"A",{href:!0});var fi=r(Vo);As=l(fi,"Multiple choice task guide"),fi.forEach(t),ui.forEach(t),X.forEach(t),Jn=g(o),ee=a(o,"H2",{class:!0});var Vn=r(ee);Me=a(Vn,"A",{id:!0,class:!0,href:!0});var gi=r(Me);It=a(gi,"SPAN",{});var _i=r(It);w(no.$$.fragment,_i),_i.forEach(t),gi.forEach(t),Rs=g(Vn),Zt=a(Vn,"SPAN",{});var yi=r(Zt);Vs=l(yi,"YosoConfig"),yi.forEach(t),Vn.forEach(t),Un=g(o),C=a(o,"DIV",{class:!0});var Ge=r(C);w(so.$$.fragment,Ge),Xs=g(Ge),oe=a(Ge,"P",{});var at=r(oe);Os=l(at,"This is the configuration class to store the configuration of a "),Xo=a(at,"A",{href:!0});var bi=r(Xo);Qs=l(bi,"YosoModel"),bi.forEach(t),Ls=l(at,`. It is used to instantiate an YOSO
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 YOSO
`),ao=a(at,"A",{href:!0,rel:!0});var Mi=r(ao);Ps=l(Mi,"uw-madison/yoso-4096"),Mi.forEach(t),Hs=l(at," architecture."),at.forEach(t),Ds=g(Ge),te=a(Ge,"P",{});var rt=r(te);Ks=l(rt,"Configuration objects inherit from "),Oo=a(rt,"A",{href:!0});var wi=r(Oo);ea=l(wi,"PretrainedConfig"),wi.forEach(t),oa=l(rt,` and can be used to control the model outputs. Read the
documentation from `),Qo=a(rt,"A",{href:!0});var Ti=r(Qo);ta=l(Ti,"PretrainedConfig"),Ti.forEach(t),na=l(rt," for more information."),rt.forEach(t),sa=g(Ge),w(we.$$.fragment,Ge),Ge.forEach(t),Cn=g(o),ne=a(o,"H2",{class:!0});var Xn=r(ne);Te=a(Xn,"A",{id:!0,class:!0,href:!0});var ki=r(Te);Bt=a(ki,"SPAN",{});var vi=r(Bt);w(ro.$$.fragment,vi),vi.forEach(t),ki.forEach(t),aa=g(Xn),Nt=a(Xn,"SPAN",{});var $i=r(Nt);ra=l($i,"YosoModel"),$i.forEach(t),Xn.forEach(t),Fn=g(o),Z=a(o,"DIV",{class:!0});var it=r(Z);w(io.$$.fragment,it),ia=g(it),lo=a(it,"P",{});var On=r(lo);la=l(On,`The bare YOSO Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),co=a(On,"A",{href:!0,rel:!0});var ji=r(co);da=l(ji,"torch.nn.Module"),ji.forEach(t),ca=l(On,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),On.forEach(t),pa=g(it),z=a(it,"DIV",{class:!0});var Ae=r(z);w(po.$$.fragment,Ae),ha=g(Ae),se=a(Ae,"P",{});var lt=r(se);ma=l(lt,"The "),Lo=a(lt,"A",{href:!0});var Yi=r(Lo);ua=l(Yi,"YosoModel"),Yi.forEach(t),fa=l(lt," forward method, overrides the "),qt=a(lt,"CODE",{});var Ji=r(qt);ga=l(Ji,"__call__"),Ji.forEach(t),_a=l(lt," special method."),lt.forEach(t),ya=g(Ae),w(ke.$$.fragment,Ae),ba=g(Ae),w(ve.$$.fragment,Ae),Ae.forEach(t),it.forEach(t),zn=g(o),ae=a(o,"H2",{class:!0});var Qn=r(ae);$e=a(Qn,"A",{id:!0,class:!0,href:!0});var Ui=r($e);St=a(Ui,"SPAN",{});var Ci=r(St);w(ho.$$.fragment,Ci),Ci.forEach(t),Ui.forEach(t),Ma=g(Qn),Gt=a(Qn,"SPAN",{});var Fi=r(Gt);wa=l(Fi,"YosoForMaskedLM"),Fi.forEach(t),Qn.forEach(t),En=g(o),B=a(o,"DIV",{class:!0});var dt=r(B);w(mo.$$.fragment,dt),Ta=g(dt),re=a(dt,"P",{});var ct=r(re);ka=l(ct,"YOSO Model with a "),At=a(ct,"CODE",{});var zi=r(At);va=l(zi,"language modeling"),zi.forEach(t),$a=l(ct,` head on top.
This model is a PyTorch `),uo=a(ct,"A",{href:!0,rel:!0});var Ei=r(uo);ja=l(Ei,"torch.nn.Module"),Ei.forEach(t),Ya=l(ct,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),ct.forEach(t),Ja=g(dt),E=a(dt,"DIV",{class:!0});var Re=r(E);w(fo.$$.fragment,Re),Ua=g(Re),ie=a(Re,"P",{});var pt=r(ie);Ca=l(pt,"The "),Po=a(pt,"A",{href:!0});var Wi=r(Po);Fa=l(Wi,"YosoForMaskedLM"),Wi.forEach(t),za=l(pt," forward method, overrides the "),Rt=a(pt,"CODE",{});var xi=r(Rt);Ea=l(xi,"__call__"),xi.forEach(t),Wa=l(pt," special method."),pt.forEach(t),xa=g(Re),w(je.$$.fragment,Re),Ia=g(Re),w(Ye.$$.fragment,Re),Re.forEach(t),dt.forEach(t),Wn=g(o),le=a(o,"H2",{class:!0});var Ln=r(le);Je=a(Ln,"A",{id:!0,class:!0,href:!0});var Ii=r(Je);Vt=a(Ii,"SPAN",{});var Zi=r(Vt);w(go.$$.fragment,Zi),Zi.forEach(t),Ii.forEach(t),Za=g(Ln),Xt=a(Ln,"SPAN",{});var Bi=r(Xt);Ba=l(Bi,"YosoForSequenceClassification"),Bi.forEach(t),Ln.forEach(t),xn=g(o),N=a(o,"DIV",{class:!0});var ht=r(N);w(_o.$$.fragment,ht),Na=g(ht),yo=a(ht,"P",{});var Pn=r(yo);qa=l(Pn,`YOSO Model transformer with a sequence classification/regression head on top (a linear layer on top of
the pooled output) e.g. for GLUE tasks.
This model is a PyTorch `),bo=a(Pn,"A",{href:!0,rel:!0});var Ni=r(bo);Sa=l(Ni,"torch.nn.Module"),Ni.forEach(t),Ga=l(Pn,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Pn.forEach(t),Aa=g(ht),U=a(ht,"DIV",{class:!0});var O=r(U);w(Mo.$$.fragment,O),Ra=g(O),de=a(O,"P",{});var mt=r(de);Va=l(mt,"The "),Ho=a(mt,"A",{href:!0});var qi=r(Ho);Xa=l(qi,"YosoForSequenceClassification"),qi.forEach(t),Oa=l(mt," forward method, overrides the "),Ot=a(mt,"CODE",{});var Si=r(Ot);Qa=l(Si,"__call__"),Si.forEach(t),La=l(mt," special method."),mt.forEach(t),Pa=g(O),w(Ue.$$.fragment,O),Ha=g(O),w(Ce.$$.fragment,O),Da=g(O),w(Fe.$$.fragment,O),O.forEach(t),ht.forEach(t),In=g(o),ce=a(o,"H2",{class:!0});var Hn=r(ce);ze=a(Hn,"A",{id:!0,class:!0,href:!0});var Gi=r(ze);Qt=a(Gi,"SPAN",{});var Ai=r(Qt);w(wo.$$.fragment,Ai),Ai.forEach(t),Gi.forEach(t),Ka=g(Hn),Lt=a(Hn,"SPAN",{});var Ri=r(Lt);er=l(Ri,"YosoForMultipleChoice"),Ri.forEach(t),Hn.forEach(t),Zn=g(o),q=a(o,"DIV",{class:!0});var ut=r(q);w(To.$$.fragment,ut),or=g(ut),ko=a(ut,"P",{});var Dn=r(ko);tr=l(Dn,`YOSO Model with a multiple choice classification head on top (a linear layer on top of
the pooled output and a softmax) e.g. for RocStories/SWAG tasks.
This model is a PyTorch `),vo=a(Dn,"A",{href:!0,rel:!0});var Vi=r(vo);nr=l(Vi,"torch.nn.Module"),Vi.forEach(t),sr=l(Dn,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Dn.forEach(t),ar=g(ut),W=a(ut,"DIV",{class:!0});var Ve=r(W);w($o.$$.fragment,Ve),rr=g(Ve),pe=a(Ve,"P",{});var ft=r(pe);ir=l(ft,"The "),Do=a(ft,"A",{href:!0});var Xi=r(Do);lr=l(Xi,"YosoForMultipleChoice"),Xi.forEach(t),dr=l(ft," forward method, overrides the "),Pt=a(ft,"CODE",{});var Oi=r(Pt);cr=l(Oi,"__call__"),Oi.forEach(t),pr=l(ft," special method."),ft.forEach(t),hr=g(Ve),w(Ee.$$.fragment,Ve),mr=g(Ve),w(We.$$.fragment,Ve),Ve.forEach(t),ut.forEach(t),Bn=g(o),he=a(o,"H2",{class:!0});var Kn=r(he);xe=a(Kn,"A",{id:!0,class:!0,href:!0});var Qi=r(xe);Ht=a(Qi,"SPAN",{});var Li=r(Ht);w(jo.$$.fragment,Li),Li.forEach(t),Qi.forEach(t),ur=g(Kn),Dt=a(Kn,"SPAN",{});var Pi=r(Dt);fr=l(Pi,"YosoForTokenClassification"),Pi.forEach(t),Kn.forEach(t),Nn=g(o),S=a(o,"DIV",{class:!0});var gt=r(S);w(Yo.$$.fragment,gt),gr=g(gt),Jo=a(gt,"P",{});var es=r(Jo);_r=l(es,`YOSO 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.
This model is a PyTorch `),Uo=a(es,"A",{href:!0,rel:!0});var Hi=r(Uo);yr=l(Hi,"torch.nn.Module"),Hi.forEach(t),br=l(es,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),es.forEach(t),Mr=g(gt),x=a(gt,"DIV",{class:!0});var Xe=r(x);w(Co.$$.fragment,Xe),wr=g(Xe),me=a(Xe,"P",{});var _t=r(me);Tr=l(_t,"The "),Ko=a(_t,"A",{href:!0});var Di=r(Ko);kr=l(Di,"YosoForTokenClassification"),Di.forEach(t),vr=l(_t," forward method, overrides the "),Kt=a(_t,"CODE",{});var Ki=r(Kt);$r=l(Ki,"__call__"),Ki.forEach(t),jr=l(_t," special method."),_t.forEach(t),Yr=g(Xe),w(Ie.$$.fragment,Xe),Jr=g(Xe),w(Ze.$$.fragment,Xe),Xe.forEach(t),gt.forEach(t),qn=g(o),ue=a(o,"H2",{class:!0});var os=r(ue);Be=a(os,"A",{id:!0,class:!0,href:!0});var el=r(Be);en=a(el,"SPAN",{});var ol=r(en);w(Fo.$$.fragment,ol),ol.forEach(t),el.forEach(t),Ur=g(os),on=a(os,"SPAN",{});var tl=r(on);Cr=l(tl,"YosoForQuestionAnswering"),tl.forEach(t),os.forEach(t),Sn=g(o),G=a(o,"DIV",{class:!0});var yt=r(G);w(zo.$$.fragment,yt),Fr=g(yt),A=a(yt,"P",{});var Oe=r(A);zr=l(Oe,`YOSO Model with a span classification head on top for extractive question-answering tasks like SQuAD (a linear
layers on top of the hidden-states output to compute `),tn=a(Oe,"CODE",{});var nl=r(tn);Er=l(nl,"span start logits"),nl.forEach(t),Wr=l(Oe," and "),nn=a(Oe,"CODE",{});var sl=r(nn);xr=l(sl,"span end logits"),sl.forEach(t),Ir=l(Oe,`).
This model is a PyTorch `),Eo=a(Oe,"A",{href:!0,rel:!0});var al=r(Eo);Zr=l(al,"torch.nn.Module"),al.forEach(t),Br=l(Oe,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Oe.forEach(t),Nr=g(yt),I=a(yt,"DIV",{class:!0});var Qe=r(I);w(Wo.$$.fragment,Qe),qr=g(Qe),fe=a(Qe,"P",{});var bt=r(fe);Sr=l(bt,"The "),et=a(bt,"A",{href:!0});var rl=r(et);Gr=l(rl,"YosoForQuestionAnswering"),rl.forEach(t),Ar=l(bt," forward method, overrides the "),sn=a(bt,"CODE",{});var il=r(sn);Rr=l(il,"__call__"),il.forEach(t),Vr=l(bt," special method."),bt.forEach(t),Xr=g(Qe),w(Ne.$$.fragment,Qe),Or=g(Qe),w(qe.$$.fragment,Qe),Qe.forEach(t),yt.forEach(t),this.h()},h(){h(d,"name","hf:doc:metadata"),h(d,"content",JSON.stringify(Ul)),h(p,"id","yoso"),h(p,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(p,"href","#yoso"),h(m,"class","relative group"),h(ge,"id","overview"),h(ge,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(ge,"href","#overview"),h(L,"class","relative group"),h(Ke,"href","https://arxiv.org/abs/2111.09714"),h(Ke,"rel","nofollow"),hl(_e.src,Qr="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/yoso_architecture.jpg")||h(_e,"src",Qr),h(_e,"alt","drawing"),h(_e,"width","600"),h(qo,"href","https://arxiv.org/abs/2111.09714"),h(eo,"href","https://huggingface.co/novice03"),h(eo,"rel","nofollow"),h(oo,"href","https://github.com/mlpen/YOSO"),h(oo,"rel","nofollow"),h(be,"id","documentation-resources"),h(be,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(be,"href","#documentation-resources"),h(K,"class","relative group"),h(So,"href","../tasks/sequence_classification"),h(Go,"href","../tasks/token_classification"),h(Ao,"href","../tasks/question_answering"),h(Ro,"href","../tasks/masked_language_modeling"),h(Vo,"href","../tasks/multiple_choice"),h(Me,"id","transformers.YosoConfig"),h(Me,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(Me,"href","#transformers.YosoConfig"),h(ee,"class","relative group"),h(Xo,"href","/docs/transformers/main/en/model_doc/yoso#transformers.YosoModel"),h(ao,"href","https://huggingface.co/uw-madison/yoso-4096"),h(ao,"rel","nofollow"),h(Oo,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),h(Qo,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),h(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(Te,"id","transformers.YosoModel"),h(Te,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(Te,"href","#transformers.YosoModel"),h(ne,"class","relative group"),h(co,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),h(co,"rel","nofollow"),h(Lo,"href","/docs/transformers/main/en/model_doc/yoso#transformers.YosoModel"),h(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h($e,"id","transformers.YosoForMaskedLM"),h($e,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h($e,"href","#transformers.YosoForMaskedLM"),h(ae,"class","relative group"),h(uo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),h(uo,"rel","nofollow"),h(Po,"href","/docs/transformers/main/en/model_doc/yoso#transformers.YosoForMaskedLM"),h(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(Je,"id","transformers.YosoForSequenceClassification"),h(Je,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(Je,"href","#transformers.YosoForSequenceClassification"),h(le,"class","relative group"),h(bo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),h(bo,"rel","nofollow"),h(Ho,"href","/docs/transformers/main/en/model_doc/yoso#transformers.YosoForSequenceClassification"),h(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(ze,"id","transformers.YosoForMultipleChoice"),h(ze,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(ze,"href","#transformers.YosoForMultipleChoice"),h(ce,"class","relative group"),h(vo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),h(vo,"rel","nofollow"),h(Do,"href","/docs/transformers/main/en/model_doc/yoso#transformers.YosoForMultipleChoice"),h(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(xe,"id","transformers.YosoForTokenClassification"),h(xe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(xe,"href","#transformers.YosoForTokenClassification"),h(he,"class","relative group"),h(Uo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),h(Uo,"rel","nofollow"),h(Ko,"href","/docs/transformers/main/en/model_doc/yoso#transformers.YosoForTokenClassification"),h(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(Be,"id","transformers.YosoForQuestionAnswering"),h(Be,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(Be,"href","#transformers.YosoForQuestionAnswering"),h(ue,"class","relative group"),h(Eo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),h(Eo,"rel","nofollow"),h(et,"href","/docs/transformers/main/en/model_doc/yoso#transformers.YosoForQuestionAnswering"),h(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(o,u){e(document.head,d),_(o,b,u),_(o,m,u),e(m,p),e(p,y),T(n,y,null),e(m,c),e(m,Y),e(Y,ts),_(o,_n,u),_(o,L,u),e(L,ge),e(ge,wt),T(De,wt,null),e(L,ns),e(L,Tt),e(Tt,ss),_(o,yn,u),_(o,P,u),e(P,as),e(P,Ke),e(Ke,rs),e(P,is),e(P,ls),_(o,bn,u),_(o,Zo,u),e(Zo,ds),_(o,Mn,u),_(o,Bo,u),e(Bo,kt),e(kt,cs),_(o,wn,u),_(o,No,u),e(No,ps),_(o,Tn,u),_(o,R,u),e(R,vt),e(vt,hs),e(R,ms),e(R,H),e(H,us),e(H,$t),e($t,fs),e(H,gs),e(H,jt),e(jt,_s),e(H,ys),e(R,bs),e(R,D),e(D,Ms),e(D,Yt),e(Yt,ws),e(D,Ts),e(D,Jt),e(Jt,ks),e(D,vs),_(o,kn,u),_(o,_e,u),_(o,vn,u),_(o,ye,u),e(ye,$s),e(ye,qo),e(qo,js),e(ye,Ys),_(o,$n,u),_(o,V,u),e(V,Js),e(V,eo),e(eo,Us),e(V,Cs),e(V,oo),e(oo,Fs),e(V,zs),_(o,jn,u),_(o,K,u),e(K,be),e(be,Ut),T(to,Ut,null),e(K,Es),e(K,Ct),e(Ct,Ws),_(o,Yn,u),_(o,J,u),e(J,Ft),e(Ft,So),e(So,xs),e(J,Is),e(J,zt),e(zt,Go),e(Go,Zs),e(J,Bs),e(J,Et),e(Et,Ao),e(Ao,Ns),e(J,qs),e(J,Wt),e(Wt,Ro),e(Ro,Ss),e(J,Gs),e(J,xt),e(xt,Vo),e(Vo,As),_(o,Jn,u),_(o,ee,u),e(ee,Me),e(Me,It),T(no,It,null),e(ee,Rs),e(ee,Zt),e(Zt,Vs),_(o,Un,u),_(o,C,u),T(so,C,null),e(C,Xs),e(C,oe),e(oe,Os),e(oe,Xo),e(Xo,Qs),e(oe,Ls),e(oe,ao),e(ao,Ps),e(oe,Hs),e(C,Ds),e(C,te),e(te,Ks),e(te,Oo),e(Oo,ea),e(te,oa),e(te,Qo),e(Qo,ta),e(te,na),e(C,sa),T(we,C,null),_(o,Cn,u),_(o,ne,u),e(ne,Te),e(Te,Bt),T(ro,Bt,null),e(ne,aa),e(ne,Nt),e(Nt,ra),_(o,Fn,u),_(o,Z,u),T(io,Z,null),e(Z,ia),e(Z,lo),e(lo,la),e(lo,co),e(co,da),e(lo,ca),e(Z,pa),e(Z,z),T(po,z,null),e(z,ha),e(z,se),e(se,ma),e(se,Lo),e(Lo,ua),e(se,fa),e(se,qt),e(qt,ga),e(se,_a),e(z,ya),T(ke,z,null),e(z,ba),T(ve,z,null),_(o,zn,u),_(o,ae,u),e(ae,$e),e($e,St),T(ho,St,null),e(ae,Ma),e(ae,Gt),e(Gt,wa),_(o,En,u),_(o,B,u),T(mo,B,null),e(B,Ta),e(B,re),e(re,ka),e(re,At),e(At,va),e(re,$a),e(re,uo),e(uo,ja),e(re,Ya),e(B,Ja),e(B,E),T(fo,E,null),e(E,Ua),e(E,ie),e(ie,Ca),e(ie,Po),e(Po,Fa),e(ie,za),e(ie,Rt),e(Rt,Ea),e(ie,Wa),e(E,xa),T(je,E,null),e(E,Ia),T(Ye,E,null),_(o,Wn,u),_(o,le,u),e(le,Je),e(Je,Vt),T(go,Vt,null),e(le,Za),e(le,Xt),e(Xt,Ba),_(o,xn,u),_(o,N,u),T(_o,N,null),e(N,Na),e(N,yo),e(yo,qa),e(yo,bo),e(bo,Sa),e(yo,Ga),e(N,Aa),e(N,U),T(Mo,U,null),e(U,Ra),e(U,de),e(de,Va),e(de,Ho),e(Ho,Xa),e(de,Oa),e(de,Ot),e(Ot,Qa),e(de,La),e(U,Pa),T(Ue,U,null),e(U,Ha),T(Ce,U,null),e(U,Da),T(Fe,U,null),_(o,In,u),_(o,ce,u),e(ce,ze),e(ze,Qt),T(wo,Qt,null),e(ce,Ka),e(ce,Lt),e(Lt,er),_(o,Zn,u),_(o,q,u),T(To,q,null),e(q,or),e(q,ko),e(ko,tr),e(ko,vo),e(vo,nr),e(ko,sr),e(q,ar),e(q,W),T($o,W,null),e(W,rr),e(W,pe),e(pe,ir),e(pe,Do),e(Do,lr),e(pe,dr),e(pe,Pt),e(Pt,cr),e(pe,pr),e(W,hr),T(Ee,W,null),e(W,mr),T(We,W,null),_(o,Bn,u),_(o,he,u),e(he,xe),e(xe,Ht),T(jo,Ht,null),e(he,ur),e(he,Dt),e(Dt,fr),_(o,Nn,u),_(o,S,u),T(Yo,S,null),e(S,gr),e(S,Jo),e(Jo,_r),e(Jo,Uo),e(Uo,yr),e(Jo,br),e(S,Mr),e(S,x),T(Co,x,null),e(x,wr),e(x,me),e(me,Tr),e(me,Ko),e(Ko,kr),e(me,vr),e(me,Kt),e(Kt,$r),e(me,jr),e(x,Yr),T(Ie,x,null),e(x,Jr),T(Ze,x,null),_(o,qn,u),_(o,ue,u),e(ue,Be),e(Be,en),T(Fo,en,null),e(ue,Ur),e(ue,on),e(on,Cr),_(o,Sn,u),_(o,G,u),T(zo,G,null),e(G,Fr),e(G,A),e(A,zr),e(A,tn),e(tn,Er),e(A,Wr),e(A,nn),e(nn,xr),e(A,Ir),e(A,Eo),e(Eo,Zr),e(A,Br),e(G,Nr),e(G,I),T(Wo,I,null),e(I,qr),e(I,fe),e(fe,Sr),e(fe,et),e(et,Gr),e(fe,Ar),e(fe,sn),e(sn,Rr),e(fe,Vr),e(I,Xr),T(Ne,I,null),e(I,Or),T(qe,I,null),Gn=!0},p(o,[u]){const xo={};u&2&&(xo.$$scope={dirty:u,ctx:o}),we.$set(xo);const an={};u&2&&(an.$$scope={dirty:u,ctx:o}),ke.$set(an);const rn={};u&2&&(rn.$$scope={dirty:u,ctx:o}),ve.$set(rn);const ln={};u&2&&(ln.$$scope={dirty:u,ctx:o}),je.$set(ln);const Io={};u&2&&(Io.$$scope={dirty:u,ctx:o}),Ye.$set(Io);const dn={};u&2&&(dn.$$scope={dirty:u,ctx:o}),Ue.$set(dn);const cn={};u&2&&(cn.$$scope={dirty:u,ctx:o}),Ce.$set(cn);const pn={};u&2&&(pn.$$scope={dirty:u,ctx:o}),Fe.$set(pn);const Se={};u&2&&(Se.$$scope={dirty:u,ctx:o}),Ee.$set(Se);const hn={};u&2&&(hn.$$scope={dirty:u,ctx:o}),We.$set(hn);const mn={};u&2&&(mn.$$scope={dirty:u,ctx:o}),Ie.$set(mn);const un={};u&2&&(un.$$scope={dirty:u,ctx:o}),Ze.$set(un);const fn={};u&2&&(fn.$$scope={dirty:u,ctx:o}),Ne.$set(fn);const gn={};u&2&&(gn.$$scope={dirty:u,ctx:o}),qe.$set(gn)},i(o){Gn||(k(n.$$.fragment,o),k(De.$$.fragment,o),k(to.$$.fragment,o),k(no.$$.fragment,o),k(so.$$.fragment,o),k(we.$$.fragment,o),k(ro.$$.fragment,o),k(io.$$.fragment,o),k(po.$$.fragment,o),k(ke.$$.fragment,o),k(ve.$$.fragment,o),k(ho.$$.fragment,o),k(mo.$$.fragment,o),k(fo.$$.fragment,o),k(je.$$.fragment,o),k(Ye.$$.fragment,o),k(go.$$.fragment,o),k(_o.$$.fragment,o),k(Mo.$$.fragment,o),k(Ue.$$.fragment,o),k(Ce.$$.fragment,o),k(Fe.$$.fragment,o),k(wo.$$.fragment,o),k(To.$$.fragment,o),k($o.$$.fragment,o),k(Ee.$$.fragment,o),k(We.$$.fragment,o),k(jo.$$.fragment,o),k(Yo.$$.fragment,o),k(Co.$$.fragment,o),k(Ie.$$.fragment,o),k(Ze.$$.fragment,o),k(Fo.$$.fragment,o),k(zo.$$.fragment,o),k(Wo.$$.fragment,o),k(Ne.$$.fragment,o),k(qe.$$.fragment,o),Gn=!0)},o(o){v(n.$$.fragment,o),v(De.$$.fragment,o),v(to.$$.fragment,o),v(no.$$.fragment,o),v(so.$$.fragment,o),v(we.$$.fragment,o),v(ro.$$.fragment,o),v(io.$$.fragment,o),v(po.$$.fragment,o),v(ke.$$.fragment,o),v(ve.$$.fragment,o),v(ho.$$.fragment,o),v(mo.$$.fragment,o),v(fo.$$.fragment,o),v(je.$$.fragment,o),v(Ye.$$.fragment,o),v(go.$$.fragment,o),v(_o.$$.fragment,o),v(Mo.$$.fragment,o),v(Ue.$$.fragment,o),v(Ce.$$.fragment,o),v(Fe.$$.fragment,o),v(wo.$$.fragment,o),v(To.$$.fragment,o),v($o.$$.fragment,o),v(Ee.$$.fragment,o),v(We.$$.fragment,o),v(jo.$$.fragment,o),v(Yo.$$.fragment,o),v(Co.$$.fragment,o),v(Ie.$$.fragment,o),v(Ze.$$.fragment,o),v(Fo.$$.fragment,o),v(zo.$$.fragment,o),v(Wo.$$.fragment,o),v(Ne.$$.fragment,o),v(qe.$$.fragment,o),Gn=!1},d(o){t(d),o&&t(b),o&&t(m),$(n),o&&t(_n),o&&t(L),$(De),o&&t(yn),o&&t(P),o&&t(bn),o&&t(Zo),o&&t(Mn),o&&t(Bo),o&&t(wn),o&&t(No),o&&t(Tn),o&&t(R),o&&t(kn),o&&t(_e),o&&t(vn),o&&t(ye),o&&t($n),o&&t(V),o&&t(jn),o&&t(K),$(to),o&&t(Yn),o&&t(J),o&&t(Jn),o&&t(ee),$(no),o&&t(Un),o&&t(C),$(so),$(we),o&&t(Cn),o&&t(ne),$(ro),o&&t(Fn),o&&t(Z),$(io),$(po),$(ke),$(ve),o&&t(zn),o&&t(ae),$(ho),o&&t(En),o&&t(B),$(mo),$(fo),$(je),$(Ye),o&&t(Wn),o&&t(le),$(go),o&&t(xn),o&&t(N),$(_o),$(Mo),$(Ue),$(Ce),$(Fe),o&&t(In),o&&t(ce),$(wo),o&&t(Zn),o&&t(q),$(To),$($o),$(Ee),$(We),o&&t(Bn),o&&t(he),$(jo),o&&t(Nn),o&&t(S),$(Yo),$(Co),$(Ie),$(Ze),o&&t(qn),o&&t(ue),$(Fo),o&&t(Sn),o&&t(G),$(zo),$(Wo),$(Ne),$(qe)}}}const Ul={local:"yoso",sections:[{local:"overview",title:"Overview"},{local:"documentation-resources",title:"Documentation resources"},{local:"transformers.YosoConfig",title:"YosoConfig"},{local:"transformers.YosoModel",title:"YosoModel"},{local:"transformers.YosoForMaskedLM",title:"YosoForMaskedLM"},{local:"transformers.YosoForSequenceClassification",title:"YosoForSequenceClassification"},{local:"transformers.YosoForMultipleChoice",title:"YosoForMultipleChoice"},{local:"transformers.YosoForTokenClassification",title:"YosoForTokenClassification"},{local:"transformers.YosoForQuestionAnswering",title:"YosoForQuestionAnswering"}],title:"YOSO"};function Cl(j){return ml(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Zl extends ll{constructor(d){super();dl(this,d,Cl,Jl,cl,{})}}export{Zl as default,Ul as metadata};
