import{S as Km,i as Ym,s as Xm,e as a,k as p,w as k,t as r,M as Zm,c as i,d as o,m as h,a as l,x as M,h as s,b as m,G as e,g as _,y as T,q as w,o as y,B as $,v as eu,L as oe}from"../../chunks/vendor-hf-doc-builder.js";import{T as De}from"../../chunks/Tip-hf-doc-builder.js";import{D as x}from"../../chunks/Docstring-hf-doc-builder.js";import{C as I}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as U}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as te}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function tu(B){let d,v,f,u,b;return u=new I({props:{code:`from transformers import MegatronBertConfig, MegatronBertModel

# Initializing a MEGATRON_BERT bert-base-uncased style configuration
configuration = MegatronBertConfig()

# Initializing a model (with random weights) from the bert-base-uncased style configuration
model = MegatronBertModel(configuration)

# Accessing the model configuration
configuration = model.config`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> MegatronBertConfig, MegatronBertModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a MEGATRON_BERT bert-base-uncased style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = MegatronBertConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the bert-base-uncased style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertModel(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`}}),{c(){d=a("p"),v=r("Examples:"),f=p(),k(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);v=s(c,"Examples:"),c.forEach(o),f=h(n),M(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,v),_(n,f,c),T(u,n,c),b=!0},p:oe,i(n){b||(w(u.$$.fragment,n),b=!0)},o(n){y(u.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(u,n)}}}function ou(B){let d,v,f,u,b;return{c(){d=a("p"),v=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),u=r("Module"),b=r(`
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=i(n,"P",{});var c=l(d);v=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=i(c,"CODE",{});var F=l(f);u=s(F,"Module"),F.forEach(o),b=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(o)},m(n,c){_(n,d,c),e(d,v),e(d,f),e(f,u),e(d,b)},d(n){n&&o(d)}}}function nu(B){let d,v,f,u,b;return u=new I({props:{code:`from transformers import AutoTokenizer, MegatronBertModel
import torch

tokenizer = AutoTokenizer.from_pretrained("nvidia/megatron-bert-cased-345m")
model = MegatronBertModel.from_pretrained("nvidia/megatron-bert-cased-345m")

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

last_hidden_states = outputs.last_hidden_state`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertModel
<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;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertModel.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&quot;</span>)

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

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

tokenizer = AutoTokenizer.from_pretrained("nvidia/megatron-bert-cased-345m")
model = MegatronBertForMaskedLM.from_pretrained("nvidia/megatron-bert-cased-345m")

inputs = tokenizer("The capital of France is [MASK].", return_tensors="pt")

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

# retrieve index of [MASK]
mask_token_index = (inputs.input_ids == tokenizer.mask_token_id)[0].nonzero(as_tuple=True)[0]

predicted_token_id = logits[0, mask_token_index].argmax(axis=-1)

labels = tokenizer("The capital of France is Paris.", return_tensors="pt")["input_ids"]
# mask labels of non-[MASK] tokens
labels = torch.where(inputs.input_ids == tokenizer.mask_token_id, labels, -100)

outputs = model(**inputs, labels=labels)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertForMaskedLM
<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;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForMaskedLM.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&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=a("p"),v=r("Example:"),f=p(),k(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);v=s(c,"Example:"),c.forEach(o),f=h(n),M(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,v),_(n,f,c),T(u,n,c),b=!0},p:oe,i(n){b||(w(u.$$.fragment,n),b=!0)},o(n){y(u.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(u,n)}}}function au(B){let d,v,f,u,b;return{c(){d=a("p"),v=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),u=r("Module"),b=r(`
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=i(n,"P",{});var c=l(d);v=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=i(c,"CODE",{});var F=l(f);u=s(F,"Module"),F.forEach(o),b=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(o)},m(n,c){_(n,d,c),e(d,v),e(d,f),e(f,u),e(d,b)},d(n){n&&o(d)}}}function iu(B){let d,v,f,u,b;return u=new I({props:{code:`from transformers import AutoTokenizer, MegatronBertForCausalLM, MegatronBertConfig
import torch

tokenizer = AutoTokenizer.from_pretrained("nvidia/megatron-bert-cased-345m")
model = MegatronBertForCausalLM.from_pretrained("nvidia/megatron-bert-cased-345m", is_decoder=True)

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

prediction_logits = outputs.logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertForCausalLM, MegatronBertConfig
<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;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForCausalLM.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&quot;</span>, is_decoder=<span class="hljs-literal">True</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>prediction_logits = outputs.logits`}}),{c(){d=a("p"),v=r("Example:"),f=p(),k(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);v=s(c,"Example:"),c.forEach(o),f=h(n),M(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,v),_(n,f,c),T(u,n,c),b=!0},p:oe,i(n){b||(w(u.$$.fragment,n),b=!0)},o(n){y(u.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(u,n)}}}function lu(B){let d,v,f,u,b;return{c(){d=a("p"),v=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),u=r("Module"),b=r(`
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=i(n,"P",{});var c=l(d);v=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=i(c,"CODE",{});var F=l(f);u=s(F,"Module"),F.forEach(o),b=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(o)},m(n,c){_(n,d,c),e(d,v),e(d,f),e(f,u),e(d,b)},d(n){n&&o(d)}}}function du(B){let d,v,f,u,b;return u=new I({props:{code:`from transformers import AutoTokenizer, MegatronBertForNextSentencePrediction
import torch

tokenizer = AutoTokenizer.from_pretrained("nvidia/megatron-bert-cased-345m")
model = MegatronBertForNextSentencePrediction.from_pretrained("nvidia/megatron-bert-cased-345m")

prompt = "In Italy, pizza served in formal settings, such as at a restaurant, is presented unsliced."
next_sentence = "The sky is blue due to the shorter wavelength of blue light."
encoding = tokenizer(prompt, next_sentence, return_tensors="pt")

outputs = model(**encoding, labels=torch.LongTensor([1]))
logits = outputs.logits
assert logits[0, 0] < logits[0, 1]  # next sentence was random`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertForNextSentencePrediction
<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;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForNextSentencePrediction.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&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>next_sentence = <span class="hljs-string">&quot;The sky is blue due to the shorter wavelength of blue light.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = tokenizer(prompt, next_sentence, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**encoding, labels=torch.LongTensor([<span class="hljs-number">1</span>]))
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">assert</span> logits[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>] &lt; logits[<span class="hljs-number">0</span>, <span class="hljs-number">1</span>]  <span class="hljs-comment"># next sentence was random</span>`}}),{c(){d=a("p"),v=r("Example:"),f=p(),k(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);v=s(c,"Example:"),c.forEach(o),f=h(n),M(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,v),_(n,f,c),T(u,n,c),b=!0},p:oe,i(n){b||(w(u.$$.fragment,n),b=!0)},o(n){y(u.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(u,n)}}}function cu(B){let d,v,f,u,b;return{c(){d=a("p"),v=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),u=r("Module"),b=r(`
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=i(n,"P",{});var c=l(d);v=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=i(c,"CODE",{});var F=l(f);u=s(F,"Module"),F.forEach(o),b=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(o)},m(n,c){_(n,d,c),e(d,v),e(d,f),e(f,u),e(d,b)},d(n){n&&o(d)}}}function pu(B){let d,v,f,u,b;return u=new I({props:{code:`from transformers import AutoTokenizer, MegatronBertForPreTraining
import torch

tokenizer = AutoTokenizer.from_pretrained("nvidia/megatron-bert-cased-345m")
model = MegatronBertForPreTraining.from_pretrained("nvidia/megatron-bert-cased-345m")

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

prediction_logits = outputs.prediction_logits
seq_relationship_logits = outputs.seq_relationship_logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertForPreTraining
<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;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForPreTraining.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&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>prediction_logits = outputs.prediction_logits
<span class="hljs-meta">&gt;&gt;&gt; </span>seq_relationship_logits = outputs.seq_relationship_logits`}}),{c(){d=a("p"),v=r("Example:"),f=p(),k(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);v=s(c,"Example:"),c.forEach(o),f=h(n),M(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,v),_(n,f,c),T(u,n,c),b=!0},p:oe,i(n){b||(w(u.$$.fragment,n),b=!0)},o(n){y(u.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(u,n)}}}function hu(B){let d,v,f,u,b;return{c(){d=a("p"),v=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),u=r("Module"),b=r(`
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=i(n,"P",{});var c=l(d);v=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=i(c,"CODE",{});var F=l(f);u=s(F,"Module"),F.forEach(o),b=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(o)},m(n,c){_(n,d,c),e(d,v),e(d,f),e(f,u),e(d,b)},d(n){n&&o(d)}}}function mu(B){let d,v,f,u,b;return u=new I({props:{code:`import torch
from transformers import AutoTokenizer, MegatronBertForSequenceClassification

tokenizer = AutoTokenizer.from_pretrained("nvidia/megatron-bert-cased-345m")
model = MegatronBertForSequenceClassification.from_pretrained("nvidia/megatron-bert-cased-345m")

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

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

predicted_class_id = logits.argmax().item()

# To train a model on \`num_labels\` classes, you can pass \`num_labels=num_labels\` to \`.from_pretrained(...)\`
num_labels = len(model.config.id2label)
model = MegatronBertForSequenceClassification.from_pretrained("nvidia/megatron-bert-cased-345m", num_labels=num_labels)

labels = torch.tensor([1])
loss = model(**inputs, labels=labels).loss`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&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 = MegatronBertForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&quot;</span>, num_labels=num_labels)

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

tokenizer = AutoTokenizer.from_pretrained("nvidia/megatron-bert-cased-345m")
model = MegatronBertForSequenceClassification.from_pretrained("nvidia/megatron-bert-cased-345m", problem_type="multi_label_classification")

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

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

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

# To train a model on \`num_labels\` classes, you can pass \`num_labels=num_labels\` to \`.from_pretrained(...)\`
num_labels = len(model.config.id2label)
model = MegatronBertForSequenceClassification.from_pretrained(
    "nvidia/megatron-bert-cased-345m", num_labels=num_labels, problem_type="multi_label_classification"
)

labels = torch.sum(
    torch.nn.functional.one_hot(predicted_class_ids[None, :].clone(), num_classes=num_labels), dim=1
).to(torch.float)
loss = model(**inputs, labels=labels).loss`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&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 = MegatronBertForSequenceClassification.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&quot;</span>, num_labels=num_labels, problem_type=<span class="hljs-string">&quot;multi_label_classification&quot;</span>
<span class="hljs-meta">... </span>)

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

tokenizer = AutoTokenizer.from_pretrained("nvidia/megatron-bert-cased-345m")
model = MegatronBertForMultipleChoice.from_pretrained("nvidia/megatron-bert-cased-345m")

prompt = "In Italy, pizza served in formal settings, such as at a restaurant, is presented unsliced."
choice0 = "It is eaten with a fork and a knife."
choice1 = "It is eaten while held in the hand."
labels = torch.tensor(0).unsqueeze(0)  # choice0 is correct (according to Wikipedia ;)), batch size 1

encoding = tokenizer([prompt, prompt], [choice0, choice1], return_tensors="pt", padding=True)
outputs = model(**{k: v.unsqueeze(0) for k, v in encoding.items()}, labels=labels)  # batch size is 1

# the linear classifier still needs to be trained
loss = outputs.loss
logits = outputs.logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertForMultipleChoice
<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;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForMultipleChoice.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&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=a("p"),v=r("Example:"),f=p(),k(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);v=s(c,"Example:"),c.forEach(o),f=h(n),M(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,v),_(n,f,c),T(u,n,c),b=!0},p:oe,i(n){b||(w(u.$$.fragment,n),b=!0)},o(n){y(u.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(u,n)}}}function _u(B){let d,v,f,u,b;return{c(){d=a("p"),v=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),u=r("Module"),b=r(`
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=i(n,"P",{});var c=l(d);v=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=i(c,"CODE",{});var F=l(f);u=s(F,"Module"),F.forEach(o),b=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(o)},m(n,c){_(n,d,c),e(d,v),e(d,f),e(f,u),e(d,b)},d(n){n&&o(d)}}}function bu(B){let d,v,f,u,b;return u=new I({props:{code:`from transformers import AutoTokenizer, MegatronBertForTokenClassification
import torch

tokenizer = AutoTokenizer.from_pretrained("nvidia/megatron-bert-cased-345m")
model = MegatronBertForTokenClassification.from_pretrained("nvidia/megatron-bert-cased-345m")

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

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

predicted_token_class_ids = logits.argmax(-1)

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

labels = predicted_token_class_ids
loss = model(**inputs, labels=labels).loss`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertForTokenClassification
<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;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForTokenClassification.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&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=a("p"),v=r("Example:"),f=p(),k(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);v=s(c,"Example:"),c.forEach(o),f=h(n),M(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,v),_(n,f,c),T(u,n,c),b=!0},p:oe,i(n){b||(w(u.$$.fragment,n),b=!0)},o(n){y(u.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(u,n)}}}function vu(B){let d,v,f,u,b;return{c(){d=a("p"),v=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),u=r("Module"),b=r(`
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=i(n,"P",{});var c=l(d);v=s(c,"Although the recipe for forward pass needs to be defined within this function, one should call the "),f=i(c,"CODE",{});var F=l(f);u=s(F,"Module"),F.forEach(o),b=s(c,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),c.forEach(o)},m(n,c){_(n,d,c),e(d,v),e(d,f),e(f,u),e(d,b)},d(n){n&&o(d)}}}function ku(B){let d,v,f,u,b;return u=new I({props:{code:`from transformers import AutoTokenizer, MegatronBertForQuestionAnswering
import torch

tokenizer = AutoTokenizer.from_pretrained("nvidia/megatron-bert-cased-345m")
model = MegatronBertForQuestionAnswering.from_pretrained("nvidia/megatron-bert-cased-345m")

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

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

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

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

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

outputs = model(**inputs, start_positions=target_start_index, end_positions=target_end_index)
loss = outputs.loss`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, MegatronBertForQuestionAnswering
<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;nvidia/megatron-bert-cased-345m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = MegatronBertForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;nvidia/megatron-bert-cased-345m&quot;</span>)

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

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

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

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

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

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, start_positions=target_start_index, end_positions=target_end_index)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss`}}),{c(){d=a("p"),v=r("Example:"),f=p(),k(u.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);v=s(c,"Example:"),c.forEach(o),f=h(n),M(u.$$.fragment,n)},m(n,c){_(n,d,c),e(d,v),_(n,f,c),T(u,n,c),b=!0},p:oe,i(n){b||(w(u.$$.fragment,n),b=!0)},o(n){y(u.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(u,n)}}}function Mu(B){let d,v,f,u,b,n,c,F,La,bs,ge,We,Xn,qt,Sa,Zn,Na,vs,Re,Ia,Et,Da,Wa,ks,on,Ra,Ms,nn,er,Ha,Ts,rn,Ua,ws,He,Qa,Ct,Ga,Va,ys,ne,Ja,At,Ka,Ya,jt,Xa,Za,$s,sn,ei,Bs,an,ti,Fs,Ot,zs,ln,oi,xs,Lt,Ps,dn,ni,qs,re,ri,tr,si,ai,or,ii,li,Es,St,Cs,Nt,As,se,di,It,ci,pi,Dt,hi,mi,js,fe,Ue,nr,Wt,ui,rr,gi,Os,q,sr,cn,fi,_i,ar,pn,bi,vi,ir,hn,ki,Mi,lr,mn,Ti,wi,dr,un,yi,$i,cr,gn,Bi,Ls,_e,Qe,pr,Rt,Fi,hr,zi,Ss,H,Ht,xi,be,Pi,fn,qi,Ei,Ut,Ci,Ai,ji,ve,Oi,_n,Li,Si,bn,Ni,Ii,Di,Ge,Ns,ke,Ve,mr,Qt,Wi,ur,Ri,Is,z,Gt,Hi,gr,Ui,Qi,Vt,Gi,vn,Vi,Ji,Ki,Jt,Yi,Kt,Xi,Zi,el,Yt,tl,Xt,ol,nl,rl,P,sl,fr,al,il,_r,ll,dl,br,cl,pl,vr,hl,ml,kr,ul,gl,Mr,fl,_l,bl,Q,Zt,vl,Me,kl,kn,Ml,Tl,Tr,wl,yl,$l,Je,Bl,Ke,Ds,Te,Ye,wr,eo,Fl,yr,zl,Ws,E,to,xl,oo,Pl,$r,ql,El,Cl,no,Al,Mn,jl,Ol,Ll,ro,Sl,so,Nl,Il,Dl,G,ao,Wl,we,Rl,Tn,Hl,Ul,Br,Ql,Gl,Vl,Xe,Jl,Ze,Rs,ye,et,Fr,io,Kl,zr,Yl,Hs,C,lo,Xl,co,Zl,xr,ed,td,od,po,nd,wn,rd,sd,ad,ho,id,mo,ld,dd,cd,V,uo,pd,$e,hd,yn,md,ud,Pr,gd,fd,_d,tt,bd,ot,Us,Be,nt,qr,go,vd,Er,kd,Qs,A,fo,Md,_o,Td,Cr,wd,yd,$d,bo,Bd,$n,Fd,zd,xd,vo,Pd,ko,qd,Ed,Cd,J,Mo,Ad,Fe,jd,Bn,Od,Ld,Ar,Sd,Nd,Id,rt,Dd,st,Gs,ze,at,jr,To,Wd,Or,Rd,Vs,j,wo,Hd,xe,Ud,Lr,Qd,Gd,Sr,Vd,Jd,Kd,yo,Yd,Fn,Xd,Zd,ec,$o,tc,Bo,oc,nc,rc,K,Fo,sc,Pe,ac,zn,ic,lc,Nr,dc,cc,pc,it,hc,lt,Js,qe,dt,Ir,zo,mc,Dr,uc,Ks,O,xo,gc,Wr,fc,_c,Po,bc,xn,vc,kc,Mc,qo,Tc,Eo,wc,yc,$c,D,Co,Bc,Ee,Fc,Pn,zc,xc,Rr,Pc,qc,Ec,ct,Cc,pt,Ac,ht,Ys,Ce,mt,Hr,Ao,jc,Ur,Oc,Xs,L,jo,Lc,Qr,Sc,Nc,Oo,Ic,qn,Dc,Wc,Rc,Lo,Hc,So,Uc,Qc,Gc,Y,No,Vc,Ae,Jc,En,Kc,Yc,Gr,Xc,Zc,ep,ut,tp,gt,Zs,je,ft,Vr,Io,op,Jr,np,ea,S,Do,rp,Kr,sp,ap,Wo,ip,Cn,lp,dp,cp,Ro,pp,Ho,hp,mp,up,X,Uo,gp,Oe,fp,An,_p,bp,Yr,vp,kp,Mp,_t,Tp,bt,ta,Le,vt,Xr,Qo,wp,Zr,yp,oa,N,Go,$p,Se,Bp,es,Fp,zp,ts,xp,Pp,qp,Vo,Ep,jn,Cp,Ap,jp,Jo,Op,Ko,Lp,Sp,Np,Z,Yo,Ip,Ne,Dp,On,Wp,Rp,os,Hp,Up,Qp,kt,Gp,Mt,na;return n=new U({}),qt=new U({}),Ot=new I({props:{code:`wget --content-disposition https://api.ngc.nvidia.com/v2/models/nvidia/megatron_bert_345m/versions/v0.1_uncased/zip
-O megatron_bert_345m_v0_1_uncased.zip`,highlighted:`wget --content-disposition https://api.ngc.nvidia.com/v2/models/nvidia/megatron_bert_345m/versions/v0.1_uncased/zip
-O megatron_bert_345m_v0_1_uncased.zip`}}),Lt=new I({props:{code:`wget --content-disposition https://api.ngc.nvidia.com/v2/models/nvidia/megatron_bert_345m/versions/v0.1_cased/zip -O
megatron_bert_345m_v0_1_cased.zip`,highlighted:`wget --content-disposition https://api.ngc.nvidia.com/v2/models/nvidia/megatron_bert_345m/versions/v0.1_cased/zip -O
megatron_bert_345m_v0_1_cased.zip`}}),St=new I({props:{code:"python3 $PATH_TO_TRANSFORMERS/models/megatron_bert/convert_megatron_bert_checkpoint.py megatron_bert_345m_v0_1_uncased.zip",highlighted:'python3 <span class="hljs-variable">$PATH_TO_TRANSFORMERS</span>/models/megatron_bert/convert_megatron_bert_checkpoint.py megatron_bert_345m_v0_1_uncased.zip'}}),Nt=new I({props:{code:"python3 $PATH_TO_TRANSFORMERS/models/megatron_bert/convert_megatron_bert_checkpoint.py megatron_bert_345m_v0_1_cased.zip",highlighted:'python3 <span class="hljs-variable">$PATH_TO_TRANSFORMERS</span>/models/megatron_bert/convert_megatron_bert_checkpoint.py megatron_bert_345m_v0_1_cased.zip'}}),Wt=new U({}),Rt=new U({}),Ht=new x({props:{name:"class transformers.MegatronBertConfig",anchor:"transformers.MegatronBertConfig",parameters:[{name:"vocab_size",val:" = 29056"},{name:"hidden_size",val:" = 1024"},{name:"num_hidden_layers",val:" = 24"},{name:"num_attention_heads",val:" = 16"},{name:"intermediate_size",val:" = 4096"},{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:" = 512"},{name:"type_vocab_size",val:" = 2"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-12"},{name:"pad_token_id",val:" = 0"},{name:"position_embedding_type",val:" = 'absolute'"},{name:"use_cache",val:" = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 29056) &#x2014;
Vocabulary size of the MEGATRON_BERT model. Defines the number of different tokens that can be represented
by the <code>inputs_ids</code> passed when calling <a href="/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertModel">MegatronBertModel</a>.`,name:"vocab_size"},{anchor:"transformers.MegatronBertConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
Dimensionality of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.MegatronBertConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 24) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"num_hidden_layers"},{anchor:"transformers.MegatronBertConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.MegatronBertConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 4096) &#x2014;
Dimensionality of the &#x201C;intermediate&#x201D; (often named feed-forward) layer in the Transformer encoder.`,name:"intermediate_size"},{anchor:"transformers.MegatronBertConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>Callable</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;silu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"hidden_act"},{anchor:"transformers.MegatronBertConfig.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.`,name:"hidden_dropout_prob"},{anchor:"transformers.MegatronBertConfig.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.MegatronBertConfig.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.MegatronBertConfig.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/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertModel">MegatronBertModel</a>.`,name:"type_vocab_size"},{anchor:"transformers.MegatronBertConfig.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.MegatronBertConfig.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.MegatronBertConfig.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>. For
positional embeddings use <code>&quot;absolute&quot;</code>. For more information on <code>&quot;relative_key&quot;</code>, please refer to
<a href="https://arxiv.org/abs/1803.02155" rel="nofollow">Self-Attention with Relative Position Representations (Shaw et al.)</a>.
For more information on <code>&quot;relative_key_query&quot;</code>, please refer to <em>Method 4</em> in <a href="https://arxiv.org/abs/2009.13658" rel="nofollow">Improve Transformer Models
with Better Relative Position Embeddings (Huang et al.)</a>.`,name:"position_embedding_type"},{anchor:"transformers.MegatronBertConfig.is_decoder",description:`<strong>is_decoder</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether the model is used as a decoder or not. If <code>False</code>, the model is used as an encoder.`,name:"is_decoder"},{anchor:"transformers.MegatronBertConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the model should return the last key/values attentions (not used by all models). Only
relevant if <code>config.is_decoder=True</code>.`,name:"use_cache"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/megatron_bert/configuration_megatron_bert.py#L28"}}),Ge=new te({props:{anchor:"transformers.MegatronBertConfig.example",$$slots:{default:[tu]},$$scope:{ctx:B}}}),Qt=new U({}),Gt=new x({props:{name:"class transformers.MegatronBertModel",anchor:"transformers.MegatronBertModel",parameters:[{name:"config",val:""},{name:"add_pooling_layer",val:" = True"}],parametersDescription:[{anchor:"transformers.MegatronBertModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L840"}}),Zt=new x({props:{name:"forward",anchor:"transformers.MegatronBertModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_hidden_states",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MegatronBertModel.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/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MegatronBertModel.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.MegatronBertModel.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.MegatronBertModel.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.MegatronBertModel.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.MegatronBertModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.MegatronBertModel.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.MegatronBertModel.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.MegatronBertModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MegatronBertModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong>  (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
the model is configured as a decoder.`,name:"encoder_hidden_states"},{anchor:"transformers.MegatronBertModel.forward.encoder_attention_mask",description:`<strong>encoder_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 the padding token indices of the encoder input. This mask is used in
the cross-attention if the model is configured as a decoder. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>`,name:"encoder_attention_mask"},{anchor:"transformers.MegatronBertModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code> of length <code>config.n_layers</code> with each tuple having 4 tensors of shape <code>(batch_size, num_heads, sequence_length - 1, embed_size_per_head)</code>) &#x2014;
Contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.MegatronBertModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L879",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</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>pooler_output</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, hidden_size)</code>) \u2014 Last layer hidden-state of the first token of the sequence (classification token) after further processing
through the layers used for the auxiliary pretraining task. E.g. for BERT-family of models, this returns
the classification token after processing through a linear layer and a tanh activation function. The linear
layer weights are trained from the next sentence prediction (classification) objective during pretraining.</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>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and optionally if
<code>config.is_encoder_decoder=True</code> 2 additional tensors of shape <code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if
<code>config.is_encoder_decoder=True</code> in the cross-attention blocks) that can be used (see <code>past_key_values</code>
input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Je=new De({props:{$$slots:{default:[ou]},$$scope:{ctx:B}}}),Ke=new te({props:{anchor:"transformers.MegatronBertModel.forward.example",$$slots:{default:[nu]},$$scope:{ctx:B}}}),eo=new U({}),to=new x({props:{name:"class transformers.MegatronBertForMaskedLM",anchor:"transformers.MegatronBertForMaskedLM",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertForMaskedLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1267"}}),ao=new x({props:{name:"forward",anchor:"transformers.MegatronBertForMaskedLM.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_hidden_states",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MegatronBertForMaskedLM.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/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MegatronBertForMaskedLM.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.MegatronBertForMaskedLM.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.MegatronBertForMaskedLM.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.MegatronBertForMaskedLM.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.MegatronBertForMaskedLM.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.MegatronBertForMaskedLM.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.MegatronBertForMaskedLM.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.MegatronBertForMaskedLM.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MegatronBertForMaskedLM.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/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1292",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.27.1/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/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</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/v4.27.1/en/main_classes/output#transformers.modeling_outputs.MaskedLMOutput"
>transformers.modeling_outputs.MaskedLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Xe=new De({props:{$$slots:{default:[ru]},$$scope:{ctx:B}}}),Ze=new te({props:{anchor:"transformers.MegatronBertForMaskedLM.forward.example",$$slots:{default:[su]},$$scope:{ctx:B}}}),io=new U({}),lo=new x({props:{name:"class transformers.MegatronBertForCausalLM",anchor:"transformers.MegatronBertForCausalLM",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertForCausalLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1122"}}),uo=new x({props:{name:"forward",anchor:"transformers.MegatronBertForCausalLM.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_hidden_states",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MegatronBertForCausalLM.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/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MegatronBertForCausalLM.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.MegatronBertForCausalLM.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.MegatronBertForCausalLM.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.MegatronBertForCausalLM.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.MegatronBertForCausalLM.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.MegatronBertForCausalLM.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.MegatronBertForCausalLM.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.MegatronBertForCausalLM.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MegatronBertForCausalLM.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong>  (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
the model is configured as a decoder.`,name:"encoder_hidden_states"},{anchor:"transformers.MegatronBertForCausalLM.forward.encoder_attention_mask",description:`<strong>encoder_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 the padding token indices of the encoder input. This mask is used in
the cross-attention if the model is configured as a decoder. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>`,name:"encoder_attention_mask"},{anchor:"transformers.MegatronBertForCausalLM.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 left-to-right language modeling loss (next word prediction). 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 n <code>[0, ..., config.vocab_size]</code>`,name:"labels"},{anchor:"transformers.MegatronBertForCausalLM.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code> of length <code>config.n_layers</code> with each tuple having 4 tensors of shape <code>(batch_size, num_heads, sequence_length - 1, embed_size_per_head)</code>) &#x2014;
Contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.</p>
<p>If <code>past_key_values</code> are used, the user can optionally input only the last <code>decoder_input_ids</code> (those that
don&#x2019;t have their past key value states given to this model) of shape <code>(batch_size, 1)</code> instead of all
<code>decoder_input_ids</code> of shape <code>(batch_size, sequence_length)</code>.`,name:"past_key_values"},{anchor:"transformers.MegatronBertForCausalLM.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1144",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Language modeling loss (for next-token prediction).</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) \u2014 Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Cross attentions weights after the attention softmax, used to compute the weighted average in the
cross-attention heads.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> tuples of length <code>config.n_layers</code>, with each tuple containing the cached key,
value states of the self-attention and the cross-attention layers if model is used in encoder-decoder
setting. Only relevant if <code>config.is_decoder = True</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
<code>past_key_values</code> input) to speed up sequential decoding.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),tt=new De({props:{$$slots:{default:[au]},$$scope:{ctx:B}}}),ot=new te({props:{anchor:"transformers.MegatronBertForCausalLM.forward.example",$$slots:{default:[iu]},$$scope:{ctx:B}}}),go=new U({}),fo=new x({props:{name:"class transformers.MegatronBertForNextSentencePrediction",anchor:"transformers.MegatronBertForNextSentencePrediction",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertForNextSentencePrediction.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1375"}}),Mo=new x({props:{name:"forward",anchor:"transformers.MegatronBertForNextSentencePrediction.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertForNextSentencePrediction.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/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MegatronBertForNextSentencePrediction.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.MegatronBertForNextSentencePrediction.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.MegatronBertForNextSentencePrediction.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.MegatronBertForNextSentencePrediction.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.MegatronBertForNextSentencePrediction.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.MegatronBertForNextSentencePrediction.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.MegatronBertForNextSentencePrediction.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.MegatronBertForNextSentencePrediction.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MegatronBertForNextSentencePrediction.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the next sequence prediction (classification) loss. Input should be a sequence pair
(see <code>input_ids</code> docstring). Indices should be in <code>[0, 1]</code>:</p>
<ul>
<li>0 indicates sequence B is a continuation of sequence A,</li>
<li>1 indicates sequence B is a random sequence.</li>
</ul>`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1387",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.modeling_outputs.NextSentencePredictorOutput"
>transformers.modeling_outputs.NextSentencePredictorOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</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>next_sentence_label</code> is provided) \u2014 Next sequence prediction (classification) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, 2)</code>) \u2014 Prediction scores of the next sequence prediction (classification) head (scores of True/False continuation
before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.modeling_outputs.NextSentencePredictorOutput"
>transformers.modeling_outputs.NextSentencePredictorOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),rt=new De({props:{$$slots:{default:[lu]},$$scope:{ctx:B}}}),st=new te({props:{anchor:"transformers.MegatronBertForNextSentencePrediction.forward.example",$$slots:{default:[du]},$$scope:{ctx:B}}}),To=new U({}),wo=new x({props:{name:"class transformers.MegatronBertForPreTraining",anchor:"transformers.MegatronBertForPreTraining",parameters:[{name:"config",val:""},{name:"add_binary_head",val:" = True"}],parametersDescription:[{anchor:"transformers.MegatronBertForPreTraining.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1016"}}),Fo=new x({props:{name:"forward",anchor:"transformers.MegatronBertForPreTraining.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"next_sentence_label",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MegatronBertForPreTraining.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/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MegatronBertForPreTraining.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.MegatronBertForPreTraining.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.MegatronBertForPreTraining.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.MegatronBertForPreTraining.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.MegatronBertForPreTraining.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.MegatronBertForPreTraining.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.MegatronBertForPreTraining.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.MegatronBertForPreTraining.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MegatronBertForPreTraining.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"},{anchor:"transformers.MegatronBertForPreTraining.forward.next_sentence_label",description:`<strong>next_sentence_label</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the next sequence prediction (classification) loss. Input should be a sequence pair
(see <code>input_ids</code> docstring) Indices should be in <code>[0, 1]</code>:</p>
<ul>
<li>0 indicates sequence B is a continuation of sequence A,</li>
<li>1 indicates sequence B is a random sequence.</li>
</ul>`,name:"next_sentence_label"},{anchor:"transformers.MegatronBertForPreTraining.forward.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, any]</code>, optional, defaults to <em>{}</em>) &#x2014;
Used to hide legacy arguments that have been deprecated.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1034",returnDescription:`
<p>A <code>transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertForPreTrainingOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<em>optional</em>, returned when <code>labels</code> is provided, <code>torch.FloatTensor</code> of shape <code>(1,)</code>) \u2014 Total loss as the sum of the masked language modeling loss and the next sequence prediction
(classification) loss.</p>
</li>
<li>
<p><strong>prediction_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>seq_relationship_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, 2)</code>) \u2014 Prediction scores of the next sequence prediction (classification) head (scores of True/False continuation
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 + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertForPreTrainingOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),it=new De({props:{$$slots:{default:[cu]},$$scope:{ctx:B}}}),lt=new te({props:{anchor:"transformers.MegatronBertForPreTraining.forward.example",$$slots:{default:[pu]},$$scope:{ctx:B}}}),zo=new U({}),xo=new x({props:{name:"class transformers.MegatronBertForSequenceClassification",anchor:"transformers.MegatronBertForSequenceClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertForSequenceClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1481"}}),Co=new x({props:{name:"forward",anchor:"transformers.MegatronBertForSequenceClassification.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MegatronBertForSequenceClassification.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/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MegatronBertForSequenceClassification.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.MegatronBertForSequenceClassification.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.MegatronBertForSequenceClassification.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.MegatronBertForSequenceClassification.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.MegatronBertForSequenceClassification.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.MegatronBertForSequenceClassification.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.MegatronBertForSequenceClassification.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.MegatronBertForSequenceClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MegatronBertForSequenceClassification.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the sequence classification/regression loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>. If <code>config.num_labels == 1</code> a regression loss is computed (Mean-Square loss), If
<code>config.num_labels &gt; 1</code> a classification loss is computed (Cross-Entropy).`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1493",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.27.1/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/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</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/v4.27.1/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ct=new De({props:{$$slots:{default:[hu]},$$scope:{ctx:B}}}),pt=new te({props:{anchor:"transformers.MegatronBertForSequenceClassification.forward.example",$$slots:{default:[mu]},$$scope:{ctx:B}}}),ht=new te({props:{anchor:"transformers.MegatronBertForSequenceClassification.forward.example-2",$$slots:{default:[uu]},$$scope:{ctx:B}}}),Ao=new U({}),jo=new x({props:{name:"class transformers.MegatronBertForMultipleChoice",anchor:"transformers.MegatronBertForMultipleChoice",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertForMultipleChoice.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1578"}}),No=new x({props:{name:"forward",anchor:"transformers.MegatronBertForMultipleChoice.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MegatronBertForMultipleChoice.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/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MegatronBertForMultipleChoice.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.MegatronBertForMultipleChoice.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.MegatronBertForMultipleChoice.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.MegatronBertForMultipleChoice.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.MegatronBertForMultipleChoice.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 <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.MegatronBertForMultipleChoice.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.MegatronBertForMultipleChoice.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.MegatronBertForMultipleChoice.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MegatronBertForMultipleChoice.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/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1589",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.27.1/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/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</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/v4.27.1/en/main_classes/output#transformers.modeling_outputs.MultipleChoiceModelOutput"
>transformers.modeling_outputs.MultipleChoiceModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ut=new De({props:{$$slots:{default:[gu]},$$scope:{ctx:B}}}),gt=new te({props:{anchor:"transformers.MegatronBertForMultipleChoice.forward.example",$$slots:{default:[fu]},$$scope:{ctx:B}}}),Io=new U({}),Do=new x({props:{name:"class transformers.MegatronBertForTokenClassification",anchor:"transformers.MegatronBertForTokenClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertForTokenClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1671"}}),Uo=new x({props:{name:"forward",anchor:"transformers.MegatronBertForTokenClassification.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MegatronBertForTokenClassification.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/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MegatronBertForTokenClassification.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.MegatronBertForTokenClassification.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.MegatronBertForTokenClassification.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.MegatronBertForTokenClassification.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.MegatronBertForTokenClassification.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.MegatronBertForTokenClassification.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.MegatronBertForTokenClassification.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.MegatronBertForTokenClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MegatronBertForTokenClassification.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/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1685",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided)  \u2014 Classification loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.num_labels)</code>) \u2014 Classification scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),_t=new De({props:{$$slots:{default:[_u]},$$scope:{ctx:B}}}),bt=new te({props:{anchor:"transformers.MegatronBertForTokenClassification.forward.example",$$slots:{default:[bu]},$$scope:{ctx:B}}}),Qo=new U({}),Go=new x({props:{name:"class transformers.MegatronBertForQuestionAnswering",anchor:"transformers.MegatronBertForQuestionAnswering",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.MegatronBertForQuestionAnswering.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig">MegatronBertConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1751"}}),Yo=new x({props:{name:"forward",anchor:"transformers.MegatronBertForQuestionAnswering.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"start_positions",val:": typing.Optional[torch.LongTensor] = None"},{name:"end_positions",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.MegatronBertForQuestionAnswering.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/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/v4.27.1/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__">PreTrainedTokenizer.<strong>call</strong>()</a> for details.</p>
<p><a href="../glossary#input-ids">What are input IDs?</a>`,name:"input_ids"},{anchor:"transformers.MegatronBertForQuestionAnswering.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.MegatronBertForQuestionAnswering.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.MegatronBertForQuestionAnswering.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.MegatronBertForQuestionAnswering.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.MegatronBertForQuestionAnswering.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <code>input_ids</code> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.MegatronBertForQuestionAnswering.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.MegatronBertForQuestionAnswering.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.MegatronBertForQuestionAnswering.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.MegatronBertForQuestionAnswering.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.MegatronBertForQuestionAnswering.forward.end_positions",description:`<strong>end_positions</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for position (index) of the end of the labelled span for computing the token classification loss.
Positions are clamped to the length of the sequence (<code>sequence_length</code>). Position outside of the sequence
are not taken into account for computing the loss.`,name:"end_positions"}],source:"https://github.com/huggingface/transformers/blob/v4.27.1/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1764",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertConfig"
>MegatronBertConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Total span extraction loss is the sum of a Cross-Entropy for the start and end positions.</p>
</li>
<li>
<p><strong>start_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) \u2014 Span-start scores (before SoftMax).</p>
</li>
<li>
<p><strong>end_logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>) \u2014 Span-end scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.27.1/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),kt=new De({props:{$$slots:{default:[vu]},$$scope:{ctx:B}}}),Mt=new te({props:{anchor:"transformers.MegatronBertForQuestionAnswering.forward.example",$$slots:{default:[ku]},$$scope:{ctx:B}}}),{c(){d=a("meta"),v=p(),f=a("h1"),u=a("a"),b=a("span"),k(n.$$.fragment),c=p(),F=a("span"),La=r("MegatronBERT"),bs=p(),ge=a("h2"),We=a("a"),Xn=a("span"),k(qt.$$.fragment),Sa=p(),Zn=a("span"),Na=r("Overview"),vs=p(),Re=a("p"),Ia=r("The MegatronBERT model was proposed in "),Et=a("a"),Da=r(`Megatron-LM: Training Multi-Billion Parameter Language Models Using Model
Parallelism`),Wa=r(` by Mohammad Shoeybi, Mostofa Patwary, Raul Puri, Patrick LeGresley,
Jared Casper and Bryan Catanzaro.`),ks=p(),on=a("p"),Ra=r("The abstract from the paper is the following:"),Ms=p(),nn=a("p"),er=a("em"),Ha=r(`Recent work in language modeling demonstrates that training large transformer models advances the state of the art in
Natural Language Processing applications. However, very large models can be quite difficult to train due to memory
constraints. In this work, we present our techniques for training very large transformer models and implement a simple,
efficient intra-layer model parallel approach that enables training transformer models with billions of parameters. Our
approach does not require a new compiler or library changes, is orthogonal and complimentary to pipeline model
parallelism, and can be fully implemented with the insertion of a few communication operations in native PyTorch. We
illustrate this approach by converging transformer based models up to 8.3 billion parameters using 512 GPUs. We sustain
15.1 PetaFLOPs across the entire application with 76% scaling efficiency when compared to a strong single GPU baseline
that sustains 39 TeraFLOPs, which is 30% of peak FLOPs. To demonstrate that large language models can further advance
the state of the art (SOTA), we train an 8.3 billion parameter transformer language model similar to GPT-2 and a 3.9
billion parameter model similar to BERT. We show that careful attention to the placement of layer normalization in
BERT-like models is critical to achieving increased performance as the model size grows. Using the GPT-2 model we
achieve SOTA results on the WikiText103 (10.8 compared to SOTA perplexity of 15.8) and LAMBADA (66.5% compared to SOTA
accuracy of 63.2%) datasets. Our BERT model achieves SOTA results on the RACE dataset (90.9% compared to SOTA accuracy
of 89.4%).`),Ts=p(),rn=a("p"),Ua=r("Tips:"),ws=p(),He=a("p"),Qa=r("We have provided pretrained "),Ct=a("a"),Ga=r("BERT-345M"),Va=r(` checkpoints
for use to evaluate or finetuning downstream tasks.`),ys=p(),ne=a("p"),Ja=r("To access these checkpoints, first "),At=a("a"),Ka=r("sign up"),Ya=r(` for and setup the NVIDIA GPU Cloud (NGC)
Registry CLI. Further documentation for downloading models can be found in the `),jt=a("a"),Xa=r("NGC documentation"),Za=r("."),$s=p(),sn=a("p"),ei=r("Alternatively, you can directly download the checkpoints using:"),Bs=p(),an=a("p"),ti=r("BERT-345M-uncased:"),Fs=p(),k(Ot.$$.fragment),zs=p(),ln=a("p"),oi=r("BERT-345M-cased:"),xs=p(),k(Lt.$$.fragment),Ps=p(),dn=a("p"),ni=r(`Once you have obtained the checkpoints from NVIDIA GPU Cloud (NGC), you have to convert them to a format that will
easily be loaded by Hugging Face Transformers and our port of the BERT code.`),qs=p(),re=a("p"),ri=r("The following commands allow you to do the conversion. We assume that the folder "),tr=a("code"),si=r("models/megatron_bert"),ai=r(` contains
`),or=a("code"),ii=r("megatron_bert_345m_v0_1_{cased, uncased}.zip"),li=r(" and that the commands are run from inside that folder:"),Es=p(),k(St.$$.fragment),Cs=p(),k(Nt.$$.fragment),As=p(),se=a("p"),di=r("This model was contributed by "),It=a("a"),ci=r("jdemouth"),pi=r(". The original code can be found "),Dt=a("a"),hi=r("here"),mi=r(`. That repository contains a multi-GPU and multi-node implementation of the
Megatron Language models. In particular, it contains a hybrid model parallel approach using \u201Ctensor parallel\u201D and
\u201Cpipeline parallel\u201D techniques.`),js=p(),fe=a("h2"),Ue=a("a"),nr=a("span"),k(Wt.$$.fragment),ui=p(),rr=a("span"),gi=r("Documentation resources"),Os=p(),q=a("ul"),sr=a("li"),cn=a("a"),fi=r("Text classification task guide"),_i=p(),ar=a("li"),pn=a("a"),bi=r("Token classification task guide"),vi=p(),ir=a("li"),hn=a("a"),ki=r("Question answering task guide"),Mi=p(),lr=a("li"),mn=a("a"),Ti=r("Causal language modeling task guide"),wi=p(),dr=a("li"),un=a("a"),yi=r("Masked language modeling task guide"),$i=p(),cr=a("li"),gn=a("a"),Bi=r("Multiple choice task guide"),Ls=p(),_e=a("h2"),Qe=a("a"),pr=a("span"),k(Rt.$$.fragment),Fi=p(),hr=a("span"),zi=r("MegatronBertConfig"),Ss=p(),H=a("div"),k(Ht.$$.fragment),xi=p(),be=a("p"),Pi=r("This is the configuration class to store the configuration of a "),fn=a("a"),qi=r("MegatronBertModel"),Ei=r(`. It is used to instantiate a
MEGATRON_BERT 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 MEGATRON_BERT
`),Ut=a("a"),Ci=r("nvidia/megatron-bert-uncased-345m"),Ai=r(" architecture."),ji=p(),ve=a("p"),Oi=r("Configuration objects inherit from "),_n=a("a"),Li=r("PretrainedConfig"),Si=r(` and can be used to control the model outputs. Read the
documentation from `),bn=a("a"),Ni=r("PretrainedConfig"),Ii=r(" for more information."),Di=p(),k(Ge.$$.fragment),Ns=p(),ke=a("h2"),Ve=a("a"),mr=a("span"),k(Qt.$$.fragment),Wi=p(),ur=a("span"),Ri=r("MegatronBertModel"),Is=p(),z=a("div"),k(Gt.$$.fragment),Hi=p(),gr=a("p"),Ui=r("The bare MegatronBert Model transformer outputting raw hidden-states without any specific head on top."),Qi=p(),Vt=a("p"),Gi=r("This model inherits from "),vn=a("a"),Vi=r("PreTrainedModel"),Ji=r(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Ki=p(),Jt=a("p"),Yi=r("This model is also a PyTorch "),Kt=a("a"),Xi=r("torch.nn.Module"),Zi=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),el=p(),Yt=a("p"),tl=r(`The model can behave as an encoder (with only self-attention) as well as a decoder, in which case a layer of
cross-attention is added between the self-attention layers, following the architecture described in `),Xt=a("a"),ol=r(`Attention is
all you need`),nl=r(` by Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit,
Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin.`),rl=p(),P=a("p"),sl=r("To behave as an decoder the model needs to be initialized with the "),fr=a("code"),al=r("is_decoder"),il=r(` argument of the configuration set
to `),_r=a("code"),ll=r("True"),dl=r(". To be used in a Seq2Seq model, the model needs to initialized with both "),br=a("code"),cl=r("is_decoder"),pl=r(` argument and
`),vr=a("code"),hl=r("add_cross_attention"),ml=r(" set to "),kr=a("code"),ul=r("True"),gl=r("; an "),Mr=a("code"),fl=r("encoder_hidden_states"),_l=r(" is then expected as an input to the forward pass."),bl=p(),Q=a("div"),k(Zt.$$.fragment),vl=p(),Me=a("p"),kl=r("The "),kn=a("a"),Ml=r("MegatronBertModel"),Tl=r(" forward method, overrides the "),Tr=a("code"),wl=r("__call__"),yl=r(" special method."),$l=p(),k(Je.$$.fragment),Bl=p(),k(Ke.$$.fragment),Ds=p(),Te=a("h2"),Ye=a("a"),wr=a("span"),k(eo.$$.fragment),Fl=p(),yr=a("span"),zl=r("MegatronBertForMaskedLM"),Ws=p(),E=a("div"),k(to.$$.fragment),xl=p(),oo=a("p"),Pl=r("MegatronBert Model with a "),$r=a("code"),ql=r("language modeling"),El=r(" head on top."),Cl=p(),no=a("p"),Al=r("This model inherits from "),Mn=a("a"),jl=r("PreTrainedModel"),Ol=r(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Ll=p(),ro=a("p"),Sl=r("This model is also a PyTorch "),so=a("a"),Nl=r("torch.nn.Module"),Il=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Dl=p(),G=a("div"),k(ao.$$.fragment),Wl=p(),we=a("p"),Rl=r("The "),Tn=a("a"),Hl=r("MegatronBertForMaskedLM"),Ul=r(" forward method, overrides the "),Br=a("code"),Ql=r("__call__"),Gl=r(" special method."),Vl=p(),k(Xe.$$.fragment),Jl=p(),k(Ze.$$.fragment),Rs=p(),ye=a("h2"),et=a("a"),Fr=a("span"),k(io.$$.fragment),Kl=p(),zr=a("span"),Yl=r("MegatronBertForCausalLM"),Hs=p(),C=a("div"),k(lo.$$.fragment),Xl=p(),co=a("p"),Zl=r("MegatronBert Model with a "),xr=a("code"),ed=r("language modeling"),td=r(" head on top for CLM fine-tuning."),od=p(),po=a("p"),nd=r("This model inherits from "),wn=a("a"),rd=r("PreTrainedModel"),sd=r(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),ad=p(),ho=a("p"),id=r("This model is also a PyTorch "),mo=a("a"),ld=r("torch.nn.Module"),dd=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),cd=p(),V=a("div"),k(uo.$$.fragment),pd=p(),$e=a("p"),hd=r("The "),yn=a("a"),md=r("MegatronBertForCausalLM"),ud=r(" forward method, overrides the "),Pr=a("code"),gd=r("__call__"),fd=r(" special method."),_d=p(),k(tt.$$.fragment),bd=p(),k(ot.$$.fragment),Us=p(),Be=a("h2"),nt=a("a"),qr=a("span"),k(go.$$.fragment),vd=p(),Er=a("span"),kd=r("MegatronBertForNextSentencePrediction"),Qs=p(),A=a("div"),k(fo.$$.fragment),Md=p(),_o=a("p"),Td=r("MegatronBert Model with a "),Cr=a("code"),wd=r("next sentence prediction (classification)"),yd=r(" head on top."),$d=p(),bo=a("p"),Bd=r("This model inherits from "),$n=a("a"),Fd=r("PreTrainedModel"),zd=r(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),xd=p(),vo=a("p"),Pd=r("This model is also a PyTorch "),ko=a("a"),qd=r("torch.nn.Module"),Ed=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Cd=p(),J=a("div"),k(Mo.$$.fragment),Ad=p(),Fe=a("p"),jd=r("The "),Bn=a("a"),Od=r("MegatronBertForNextSentencePrediction"),Ld=r(" forward method, overrides the "),Ar=a("code"),Sd=r("__call__"),Nd=r(" special method."),Id=p(),k(rt.$$.fragment),Dd=p(),k(st.$$.fragment),Gs=p(),ze=a("h2"),at=a("a"),jr=a("span"),k(To.$$.fragment),Wd=p(),Or=a("span"),Rd=r("MegatronBertForPreTraining"),Vs=p(),j=a("div"),k(wo.$$.fragment),Hd=p(),xe=a("p"),Ud=r("MegatronBert Model with two heads on top as done during the pretraining: a "),Lr=a("code"),Qd=r("masked language modeling"),Gd=r(` head and a
`),Sr=a("code"),Vd=r("next sentence prediction (classification)"),Jd=r(" head."),Kd=p(),yo=a("p"),Yd=r("This model inherits from "),Fn=a("a"),Xd=r("PreTrainedModel"),Zd=r(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),ec=p(),$o=a("p"),tc=r("This model is also a PyTorch "),Bo=a("a"),oc=r("torch.nn.Module"),nc=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),rc=p(),K=a("div"),k(Fo.$$.fragment),sc=p(),Pe=a("p"),ac=r("The "),zn=a("a"),ic=r("MegatronBertForPreTraining"),lc=r(" forward method, overrides the "),Nr=a("code"),dc=r("__call__"),cc=r(" special method."),pc=p(),k(it.$$.fragment),hc=p(),k(lt.$$.fragment),Js=p(),qe=a("h2"),dt=a("a"),Ir=a("span"),k(zo.$$.fragment),mc=p(),Dr=a("span"),uc=r("MegatronBertForSequenceClassification"),Ks=p(),O=a("div"),k(xo.$$.fragment),gc=p(),Wr=a("p"),fc=r(`MegatronBert Model transformer with a sequence classification/regression head on top (a linear layer on top of the
pooled output) e.g. for GLUE tasks.`),_c=p(),Po=a("p"),bc=r("This model inherits from "),xn=a("a"),vc=r("PreTrainedModel"),kc=r(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Mc=p(),qo=a("p"),Tc=r("This model is also a PyTorch "),Eo=a("a"),wc=r("torch.nn.Module"),yc=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),$c=p(),D=a("div"),k(Co.$$.fragment),Bc=p(),Ee=a("p"),Fc=r("The "),Pn=a("a"),zc=r("MegatronBertForSequenceClassification"),xc=r(" forward method, overrides the "),Rr=a("code"),Pc=r("__call__"),qc=r(" special method."),Ec=p(),k(ct.$$.fragment),Cc=p(),k(pt.$$.fragment),Ac=p(),k(ht.$$.fragment),Ys=p(),Ce=a("h2"),mt=a("a"),Hr=a("span"),k(Ao.$$.fragment),jc=p(),Ur=a("span"),Oc=r("MegatronBertForMultipleChoice"),Xs=p(),L=a("div"),k(jo.$$.fragment),Lc=p(),Qr=a("p"),Sc=r(`MegatronBert 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.`),Nc=p(),Oo=a("p"),Ic=r("This model inherits from "),qn=a("a"),Dc=r("PreTrainedModel"),Wc=r(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Rc=p(),Lo=a("p"),Hc=r("This model is also a PyTorch "),So=a("a"),Uc=r("torch.nn.Module"),Qc=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Gc=p(),Y=a("div"),k(No.$$.fragment),Vc=p(),Ae=a("p"),Jc=r("The "),En=a("a"),Kc=r("MegatronBertForMultipleChoice"),Yc=r(" forward method, overrides the "),Gr=a("code"),Xc=r("__call__"),Zc=r(" special method."),ep=p(),k(ut.$$.fragment),tp=p(),k(gt.$$.fragment),Zs=p(),je=a("h2"),ft=a("a"),Vr=a("span"),k(Io.$$.fragment),op=p(),Jr=a("span"),np=r("MegatronBertForTokenClassification"),ea=p(),S=a("div"),k(Do.$$.fragment),rp=p(),Kr=a("p"),sp=r(`MegatronBert 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.`),ap=p(),Wo=a("p"),ip=r("This model inherits from "),Cn=a("a"),lp=r("PreTrainedModel"),dp=r(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),cp=p(),Ro=a("p"),pp=r("This model is also a PyTorch "),Ho=a("a"),hp=r("torch.nn.Module"),mp=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),up=p(),X=a("div"),k(Uo.$$.fragment),gp=p(),Oe=a("p"),fp=r("The "),An=a("a"),_p=r("MegatronBertForTokenClassification"),bp=r(" forward method, overrides the "),Yr=a("code"),vp=r("__call__"),kp=r(" special method."),Mp=p(),k(_t.$$.fragment),Tp=p(),k(bt.$$.fragment),ta=p(),Le=a("h2"),vt=a("a"),Xr=a("span"),k(Qo.$$.fragment),wp=p(),Zr=a("span"),yp=r("MegatronBertForQuestionAnswering"),oa=p(),N=a("div"),k(Go.$$.fragment),$p=p(),Se=a("p"),Bp=r(`MegatronBert 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 `),es=a("code"),Fp=r("span start logits"),zp=r(" and "),ts=a("code"),xp=r("span end logits"),Pp=r(")."),qp=p(),Vo=a("p"),Ep=r("This model inherits from "),jn=a("a"),Cp=r("PreTrainedModel"),Ap=r(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),jp=p(),Jo=a("p"),Op=r("This model is also a PyTorch "),Ko=a("a"),Lp=r("torch.nn.Module"),Sp=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Np=p(),Z=a("div"),k(Yo.$$.fragment),Ip=p(),Ne=a("p"),Dp=r("The "),On=a("a"),Wp=r("MegatronBertForQuestionAnswering"),Rp=r(" forward method, overrides the "),os=a("code"),Hp=r("__call__"),Up=r(" special method."),Qp=p(),k(kt.$$.fragment),Gp=p(),k(Mt.$$.fragment),this.h()},l(t){const g=Zm('[data-svelte="svelte-1phssyn"]',document.head);d=i(g,"META",{name:!0,content:!0}),g.forEach(o),v=h(t),f=i(t,"H1",{class:!0});var Xo=l(f);u=i(Xo,"A",{id:!0,class:!0,href:!0});var ns=l(u);b=i(ns,"SPAN",{});var rs=l(b);M(n.$$.fragment,rs),rs.forEach(o),ns.forEach(o),c=h(Xo),F=i(Xo,"SPAN",{});var ss=l(F);La=s(ss,"MegatronBERT"),ss.forEach(o),Xo.forEach(o),bs=h(t),ge=i(t,"H2",{class:!0});var Zo=l(ge);We=i(Zo,"A",{id:!0,class:!0,href:!0});var as=l(We);Xn=i(as,"SPAN",{});var is=l(Xn);M(qt.$$.fragment,is),is.forEach(o),as.forEach(o),Sa=h(Zo),Zn=i(Zo,"SPAN",{});var ls=l(Zn);Na=s(ls,"Overview"),ls.forEach(o),Zo.forEach(o),vs=h(t),Re=i(t,"P",{});var en=l(Re);Ia=s(en,"The MegatronBERT model was proposed in "),Et=i(en,"A",{href:!0,rel:!0});var ds=l(Et);Da=s(ds,`Megatron-LM: Training Multi-Billion Parameter Language Models Using Model
Parallelism`),ds.forEach(o),Wa=s(en,` by Mohammad Shoeybi, Mostofa Patwary, Raul Puri, Patrick LeGresley,
Jared Casper and Bryan Catanzaro.`),en.forEach(o),ks=h(t),on=i(t,"P",{});var cs=l(on);Ra=s(cs,"The abstract from the paper is the following:"),cs.forEach(o),Ms=h(t),nn=i(t,"P",{});var ps=l(nn);er=i(ps,"EM",{});var hs=l(er);Ha=s(hs,`Recent work in language modeling demonstrates that training large transformer models advances the state of the art in
Natural Language Processing applications. However, very large models can be quite difficult to train due to memory
constraints. In this work, we present our techniques for training very large transformer models and implement a simple,
efficient intra-layer model parallel approach that enables training transformer models with billions of parameters. Our
approach does not require a new compiler or library changes, is orthogonal and complimentary to pipeline model
parallelism, and can be fully implemented with the insertion of a few communication operations in native PyTorch. We
illustrate this approach by converging transformer based models up to 8.3 billion parameters using 512 GPUs. We sustain
15.1 PetaFLOPs across the entire application with 76% scaling efficiency when compared to a strong single GPU baseline
that sustains 39 TeraFLOPs, which is 30% of peak FLOPs. To demonstrate that large language models can further advance
the state of the art (SOTA), we train an 8.3 billion parameter transformer language model similar to GPT-2 and a 3.9
billion parameter model similar to BERT. We show that careful attention to the placement of layer normalization in
BERT-like models is critical to achieving increased performance as the model size grows. Using the GPT-2 model we
achieve SOTA results on the WikiText103 (10.8 compared to SOTA perplexity of 15.8) and LAMBADA (66.5% compared to SOTA
accuracy of 63.2%) datasets. Our BERT model achieves SOTA results on the RACE dataset (90.9% compared to SOTA accuracy
of 89.4%).`),hs.forEach(o),ps.forEach(o),Ts=h(t),rn=i(t,"P",{});var ms=l(rn);Ua=s(ms,"Tips:"),ms.forEach(o),ws=h(t),He=i(t,"P",{});var tn=l(He);Qa=s(tn,"We have provided pretrained "),Ct=i(tn,"A",{href:!0,rel:!0});var us=l(Ct);Ga=s(us,"BERT-345M"),us.forEach(o),Va=s(tn,` checkpoints
for use to evaluate or finetuning downstream tasks.`),tn.forEach(o),ys=h(t),ne=i(t,"P",{});var Ie=l(ne);Ja=s(Ie,"To access these checkpoints, first "),At=i(Ie,"A",{href:!0,rel:!0});var gs=l(At);Ka=s(gs,"sign up"),gs.forEach(o),Ya=s(Ie,` for and setup the NVIDIA GPU Cloud (NGC)
Registry CLI. Further documentation for downloading models can be found in the `),jt=i(Ie,"A",{href:!0,rel:!0});var fs=l(jt);Xa=s(fs,"NGC documentation"),fs.forEach(o),Za=s(Ie,"."),Ie.forEach(o),$s=h(t),sn=i(t,"P",{});var _s=l(sn);ei=s(_s,"Alternatively, you can directly download the checkpoints using:"),_s.forEach(o),Bs=h(t),an=i(t,"P",{});var Vp=l(an);ti=s(Vp,"BERT-345M-uncased:"),Vp.forEach(o),Fs=h(t),M(Ot.$$.fragment,t),zs=h(t),ln=i(t,"P",{});var Jp=l(ln);oi=s(Jp,"BERT-345M-cased:"),Jp.forEach(o),xs=h(t),M(Lt.$$.fragment,t),Ps=h(t),dn=i(t,"P",{});var Kp=l(dn);ni=s(Kp,`Once you have obtained the checkpoints from NVIDIA GPU Cloud (NGC), you have to convert them to a format that will
easily be loaded by Hugging Face Transformers and our port of the BERT code.`),Kp.forEach(o),qs=h(t),re=i(t,"P",{});var Ln=l(re);ri=s(Ln,"The following commands allow you to do the conversion. We assume that the folder "),tr=i(Ln,"CODE",{});var Yp=l(tr);si=s(Yp,"models/megatron_bert"),Yp.forEach(o),ai=s(Ln,` contains
`),or=i(Ln,"CODE",{});var Xp=l(or);ii=s(Xp,"megatron_bert_345m_v0_1_{cased, uncased}.zip"),Xp.forEach(o),li=s(Ln," and that the commands are run from inside that folder:"),Ln.forEach(o),Es=h(t),M(St.$$.fragment,t),Cs=h(t),M(Nt.$$.fragment,t),As=h(t),se=i(t,"P",{});var Sn=l(se);di=s(Sn,"This model was contributed by "),It=i(Sn,"A",{href:!0,rel:!0});var Zp=l(It);ci=s(Zp,"jdemouth"),Zp.forEach(o),pi=s(Sn,". The original code can be found "),Dt=i(Sn,"A",{href:!0,rel:!0});var eh=l(Dt);hi=s(eh,"here"),eh.forEach(o),mi=s(Sn,`. That repository contains a multi-GPU and multi-node implementation of the
Megatron Language models. In particular, it contains a hybrid model parallel approach using \u201Ctensor parallel\u201D and
\u201Cpipeline parallel\u201D techniques.`),Sn.forEach(o),js=h(t),fe=i(t,"H2",{class:!0});var ra=l(fe);Ue=i(ra,"A",{id:!0,class:!0,href:!0});var th=l(Ue);nr=i(th,"SPAN",{});var oh=l(nr);M(Wt.$$.fragment,oh),oh.forEach(o),th.forEach(o),ui=h(ra),rr=i(ra,"SPAN",{});var nh=l(rr);gi=s(nh,"Documentation resources"),nh.forEach(o),ra.forEach(o),Os=h(t),q=i(t,"UL",{});var ee=l(q);sr=i(ee,"LI",{});var rh=l(sr);cn=i(rh,"A",{href:!0});var sh=l(cn);fi=s(sh,"Text classification task guide"),sh.forEach(o),rh.forEach(o),_i=h(ee),ar=i(ee,"LI",{});var ah=l(ar);pn=i(ah,"A",{href:!0});var ih=l(pn);bi=s(ih,"Token classification task guide"),ih.forEach(o),ah.forEach(o),vi=h(ee),ir=i(ee,"LI",{});var lh=l(ir);hn=i(lh,"A",{href:!0});var dh=l(hn);ki=s(dh,"Question answering task guide"),dh.forEach(o),lh.forEach(o),Mi=h(ee),lr=i(ee,"LI",{});var ch=l(lr);mn=i(ch,"A",{href:!0});var ph=l(mn);Ti=s(ph,"Causal language modeling task guide"),ph.forEach(o),ch.forEach(o),wi=h(ee),dr=i(ee,"LI",{});var hh=l(dr);un=i(hh,"A",{href:!0});var mh=l(un);yi=s(mh,"Masked language modeling task guide"),mh.forEach(o),hh.forEach(o),$i=h(ee),cr=i(ee,"LI",{});var uh=l(cr);gn=i(uh,"A",{href:!0});var gh=l(gn);Bi=s(gh,"Multiple choice task guide"),gh.forEach(o),uh.forEach(o),ee.forEach(o),Ls=h(t),_e=i(t,"H2",{class:!0});var sa=l(_e);Qe=i(sa,"A",{id:!0,class:!0,href:!0});var fh=l(Qe);pr=i(fh,"SPAN",{});var _h=l(pr);M(Rt.$$.fragment,_h),_h.forEach(o),fh.forEach(o),Fi=h(sa),hr=i(sa,"SPAN",{});var bh=l(hr);zi=s(bh,"MegatronBertConfig"),bh.forEach(o),sa.forEach(o),Ss=h(t),H=i(t,"DIV",{class:!0});var Tt=l(H);M(Ht.$$.fragment,Tt),xi=h(Tt),be=i(Tt,"P",{});var Nn=l(be);Pi=s(Nn,"This is the configuration class to store the configuration of a "),fn=i(Nn,"A",{href:!0});var vh=l(fn);qi=s(vh,"MegatronBertModel"),vh.forEach(o),Ei=s(Nn,`. It is used to instantiate a
MEGATRON_BERT 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 MEGATRON_BERT
`),Ut=i(Nn,"A",{href:!0,rel:!0});var kh=l(Ut);Ci=s(kh,"nvidia/megatron-bert-uncased-345m"),kh.forEach(o),Ai=s(Nn," architecture."),Nn.forEach(o),ji=h(Tt),ve=i(Tt,"P",{});var In=l(ve);Oi=s(In,"Configuration objects inherit from "),_n=i(In,"A",{href:!0});var Mh=l(_n);Li=s(Mh,"PretrainedConfig"),Mh.forEach(o),Si=s(In,` and can be used to control the model outputs. Read the
documentation from `),bn=i(In,"A",{href:!0});var Th=l(bn);Ni=s(Th,"PretrainedConfig"),Th.forEach(o),Ii=s(In," for more information."),In.forEach(o),Di=h(Tt),M(Ge.$$.fragment,Tt),Tt.forEach(o),Ns=h(t),ke=i(t,"H2",{class:!0});var aa=l(ke);Ve=i(aa,"A",{id:!0,class:!0,href:!0});var wh=l(Ve);mr=i(wh,"SPAN",{});var yh=l(mr);M(Qt.$$.fragment,yh),yh.forEach(o),wh.forEach(o),Wi=h(aa),ur=i(aa,"SPAN",{});var $h=l(ur);Ri=s($h,"MegatronBertModel"),$h.forEach(o),aa.forEach(o),Is=h(t),z=i(t,"DIV",{class:!0});var W=l(z);M(Gt.$$.fragment,W),Hi=h(W),gr=i(W,"P",{});var Bh=l(gr);Ui=s(Bh,"The bare MegatronBert Model transformer outputting raw hidden-states without any specific head on top."),Bh.forEach(o),Qi=h(W),Vt=i(W,"P",{});var ia=l(Vt);Gi=s(ia,"This model inherits from "),vn=i(ia,"A",{href:!0});var Fh=l(vn);Vi=s(Fh,"PreTrainedModel"),Fh.forEach(o),Ji=s(ia,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),ia.forEach(o),Ki=h(W),Jt=i(W,"P",{});var la=l(Jt);Yi=s(la,"This model is also a PyTorch "),Kt=i(la,"A",{href:!0,rel:!0});var zh=l(Kt);Xi=s(zh,"torch.nn.Module"),zh.forEach(o),Zi=s(la,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),la.forEach(o),el=h(W),Yt=i(W,"P",{});var da=l(Yt);tl=s(da,`The model can behave as an encoder (with only self-attention) as well as a decoder, in which case a layer of
cross-attention is added between the self-attention layers, following the architecture described in `),Xt=i(da,"A",{href:!0,rel:!0});var xh=l(Xt);ol=s(xh,`Attention is
all you need`),xh.forEach(o),nl=s(da,` by Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit,
Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin.`),da.forEach(o),rl=h(W),P=i(W,"P",{});var R=l(P);sl=s(R,"To behave as an decoder the model needs to be initialized with the "),fr=i(R,"CODE",{});var Ph=l(fr);al=s(Ph,"is_decoder"),Ph.forEach(o),il=s(R,` argument of the configuration set
to `),_r=i(R,"CODE",{});var qh=l(_r);ll=s(qh,"True"),qh.forEach(o),dl=s(R,". To be used in a Seq2Seq model, the model needs to initialized with both "),br=i(R,"CODE",{});var Eh=l(br);cl=s(Eh,"is_decoder"),Eh.forEach(o),pl=s(R,` argument and
`),vr=i(R,"CODE",{});var Ch=l(vr);hl=s(Ch,"add_cross_attention"),Ch.forEach(o),ml=s(R," set to "),kr=i(R,"CODE",{});var Ah=l(kr);ul=s(Ah,"True"),Ah.forEach(o),gl=s(R,"; an "),Mr=i(R,"CODE",{});var jh=l(Mr);fl=s(jh,"encoder_hidden_states"),jh.forEach(o),_l=s(R," is then expected as an input to the forward pass."),R.forEach(o),bl=h(W),Q=i(W,"DIV",{class:!0});var wt=l(Q);M(Zt.$$.fragment,wt),vl=h(wt),Me=i(wt,"P",{});var Dn=l(Me);kl=s(Dn,"The "),kn=i(Dn,"A",{href:!0});var Oh=l(kn);Ml=s(Oh,"MegatronBertModel"),Oh.forEach(o),Tl=s(Dn," forward method, overrides the "),Tr=i(Dn,"CODE",{});var Lh=l(Tr);wl=s(Lh,"__call__"),Lh.forEach(o),yl=s(Dn," special method."),Dn.forEach(o),$l=h(wt),M(Je.$$.fragment,wt),Bl=h(wt),M(Ke.$$.fragment,wt),wt.forEach(o),W.forEach(o),Ds=h(t),Te=i(t,"H2",{class:!0});var ca=l(Te);Ye=i(ca,"A",{id:!0,class:!0,href:!0});var Sh=l(Ye);wr=i(Sh,"SPAN",{});var Nh=l(wr);M(eo.$$.fragment,Nh),Nh.forEach(o),Sh.forEach(o),Fl=h(ca),yr=i(ca,"SPAN",{});var Ih=l(yr);zl=s(Ih,"MegatronBertForMaskedLM"),Ih.forEach(o),ca.forEach(o),Ws=h(t),E=i(t,"DIV",{class:!0});var ae=l(E);M(to.$$.fragment,ae),xl=h(ae),oo=i(ae,"P",{});var pa=l(oo);Pl=s(pa,"MegatronBert Model with a "),$r=i(pa,"CODE",{});var Dh=l($r);ql=s(Dh,"language modeling"),Dh.forEach(o),El=s(pa," head on top."),pa.forEach(o),Cl=h(ae),no=i(ae,"P",{});var ha=l(no);Al=s(ha,"This model inherits from "),Mn=i(ha,"A",{href:!0});var Wh=l(Mn);jl=s(Wh,"PreTrainedModel"),Wh.forEach(o),Ol=s(ha,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),ha.forEach(o),Ll=h(ae),ro=i(ae,"P",{});var ma=l(ro);Sl=s(ma,"This model is also a PyTorch "),so=i(ma,"A",{href:!0,rel:!0});var Rh=l(so);Nl=s(Rh,"torch.nn.Module"),Rh.forEach(o),Il=s(ma,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ma.forEach(o),Dl=h(ae),G=i(ae,"DIV",{class:!0});var yt=l(G);M(ao.$$.fragment,yt),Wl=h(yt),we=i(yt,"P",{});var Wn=l(we);Rl=s(Wn,"The "),Tn=i(Wn,"A",{href:!0});var Hh=l(Tn);Hl=s(Hh,"MegatronBertForMaskedLM"),Hh.forEach(o),Ul=s(Wn," forward method, overrides the "),Br=i(Wn,"CODE",{});var Uh=l(Br);Ql=s(Uh,"__call__"),Uh.forEach(o),Gl=s(Wn," special method."),Wn.forEach(o),Vl=h(yt),M(Xe.$$.fragment,yt),Jl=h(yt),M(Ze.$$.fragment,yt),yt.forEach(o),ae.forEach(o),Rs=h(t),ye=i(t,"H2",{class:!0});var ua=l(ye);et=i(ua,"A",{id:!0,class:!0,href:!0});var Qh=l(et);Fr=i(Qh,"SPAN",{});var Gh=l(Fr);M(io.$$.fragment,Gh),Gh.forEach(o),Qh.forEach(o),Kl=h(ua),zr=i(ua,"SPAN",{});var Vh=l(zr);Yl=s(Vh,"MegatronBertForCausalLM"),Vh.forEach(o),ua.forEach(o),Hs=h(t),C=i(t,"DIV",{class:!0});var ie=l(C);M(lo.$$.fragment,ie),Xl=h(ie),co=i(ie,"P",{});var ga=l(co);Zl=s(ga,"MegatronBert Model with a "),xr=i(ga,"CODE",{});var Jh=l(xr);ed=s(Jh,"language modeling"),Jh.forEach(o),td=s(ga," head on top for CLM fine-tuning."),ga.forEach(o),od=h(ie),po=i(ie,"P",{});var fa=l(po);nd=s(fa,"This model inherits from "),wn=i(fa,"A",{href:!0});var Kh=l(wn);rd=s(Kh,"PreTrainedModel"),Kh.forEach(o),sd=s(fa,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),fa.forEach(o),ad=h(ie),ho=i(ie,"P",{});var _a=l(ho);id=s(_a,"This model is also a PyTorch "),mo=i(_a,"A",{href:!0,rel:!0});var Yh=l(mo);ld=s(Yh,"torch.nn.Module"),Yh.forEach(o),dd=s(_a,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),_a.forEach(o),cd=h(ie),V=i(ie,"DIV",{class:!0});var $t=l(V);M(uo.$$.fragment,$t),pd=h($t),$e=i($t,"P",{});var Rn=l($e);hd=s(Rn,"The "),yn=i(Rn,"A",{href:!0});var Xh=l(yn);md=s(Xh,"MegatronBertForCausalLM"),Xh.forEach(o),ud=s(Rn," forward method, overrides the "),Pr=i(Rn,"CODE",{});var Zh=l(Pr);gd=s(Zh,"__call__"),Zh.forEach(o),fd=s(Rn," special method."),Rn.forEach(o),_d=h($t),M(tt.$$.fragment,$t),bd=h($t),M(ot.$$.fragment,$t),$t.forEach(o),ie.forEach(o),Us=h(t),Be=i(t,"H2",{class:!0});var ba=l(Be);nt=i(ba,"A",{id:!0,class:!0,href:!0});var em=l(nt);qr=i(em,"SPAN",{});var tm=l(qr);M(go.$$.fragment,tm),tm.forEach(o),em.forEach(o),vd=h(ba),Er=i(ba,"SPAN",{});var om=l(Er);kd=s(om,"MegatronBertForNextSentencePrediction"),om.forEach(o),ba.forEach(o),Qs=h(t),A=i(t,"DIV",{class:!0});var le=l(A);M(fo.$$.fragment,le),Md=h(le),_o=i(le,"P",{});var va=l(_o);Td=s(va,"MegatronBert Model with a "),Cr=i(va,"CODE",{});var nm=l(Cr);wd=s(nm,"next sentence prediction (classification)"),nm.forEach(o),yd=s(va," head on top."),va.forEach(o),$d=h(le),bo=i(le,"P",{});var ka=l(bo);Bd=s(ka,"This model inherits from "),$n=i(ka,"A",{href:!0});var rm=l($n);Fd=s(rm,"PreTrainedModel"),rm.forEach(o),zd=s(ka,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),ka.forEach(o),xd=h(le),vo=i(le,"P",{});var Ma=l(vo);Pd=s(Ma,"This model is also a PyTorch "),ko=i(Ma,"A",{href:!0,rel:!0});var sm=l(ko);qd=s(sm,"torch.nn.Module"),sm.forEach(o),Ed=s(Ma,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ma.forEach(o),Cd=h(le),J=i(le,"DIV",{class:!0});var Bt=l(J);M(Mo.$$.fragment,Bt),Ad=h(Bt),Fe=i(Bt,"P",{});var Hn=l(Fe);jd=s(Hn,"The "),Bn=i(Hn,"A",{href:!0});var am=l(Bn);Od=s(am,"MegatronBertForNextSentencePrediction"),am.forEach(o),Ld=s(Hn," forward method, overrides the "),Ar=i(Hn,"CODE",{});var im=l(Ar);Sd=s(im,"__call__"),im.forEach(o),Nd=s(Hn," special method."),Hn.forEach(o),Id=h(Bt),M(rt.$$.fragment,Bt),Dd=h(Bt),M(st.$$.fragment,Bt),Bt.forEach(o),le.forEach(o),Gs=h(t),ze=i(t,"H2",{class:!0});var Ta=l(ze);at=i(Ta,"A",{id:!0,class:!0,href:!0});var lm=l(at);jr=i(lm,"SPAN",{});var dm=l(jr);M(To.$$.fragment,dm),dm.forEach(o),lm.forEach(o),Wd=h(Ta),Or=i(Ta,"SPAN",{});var cm=l(Or);Rd=s(cm,"MegatronBertForPreTraining"),cm.forEach(o),Ta.forEach(o),Vs=h(t),j=i(t,"DIV",{class:!0});var de=l(j);M(wo.$$.fragment,de),Hd=h(de),xe=i(de,"P",{});var Un=l(xe);Ud=s(Un,"MegatronBert Model with two heads on top as done during the pretraining: a "),Lr=i(Un,"CODE",{});var pm=l(Lr);Qd=s(pm,"masked language modeling"),pm.forEach(o),Gd=s(Un,` head and a
`),Sr=i(Un,"CODE",{});var hm=l(Sr);Vd=s(hm,"next sentence prediction (classification)"),hm.forEach(o),Jd=s(Un," head."),Un.forEach(o),Kd=h(de),yo=i(de,"P",{});var wa=l(yo);Yd=s(wa,"This model inherits from "),Fn=i(wa,"A",{href:!0});var mm=l(Fn);Xd=s(mm,"PreTrainedModel"),mm.forEach(o),Zd=s(wa,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),wa.forEach(o),ec=h(de),$o=i(de,"P",{});var ya=l($o);tc=s(ya,"This model is also a PyTorch "),Bo=i(ya,"A",{href:!0,rel:!0});var um=l(Bo);oc=s(um,"torch.nn.Module"),um.forEach(o),nc=s(ya,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ya.forEach(o),rc=h(de),K=i(de,"DIV",{class:!0});var Ft=l(K);M(Fo.$$.fragment,Ft),sc=h(Ft),Pe=i(Ft,"P",{});var Qn=l(Pe);ac=s(Qn,"The "),zn=i(Qn,"A",{href:!0});var gm=l(zn);ic=s(gm,"MegatronBertForPreTraining"),gm.forEach(o),lc=s(Qn," forward method, overrides the "),Nr=i(Qn,"CODE",{});var fm=l(Nr);dc=s(fm,"__call__"),fm.forEach(o),cc=s(Qn," special method."),Qn.forEach(o),pc=h(Ft),M(it.$$.fragment,Ft),hc=h(Ft),M(lt.$$.fragment,Ft),Ft.forEach(o),de.forEach(o),Js=h(t),qe=i(t,"H2",{class:!0});var $a=l(qe);dt=i($a,"A",{id:!0,class:!0,href:!0});var _m=l(dt);Ir=i(_m,"SPAN",{});var bm=l(Ir);M(zo.$$.fragment,bm),bm.forEach(o),_m.forEach(o),mc=h($a),Dr=i($a,"SPAN",{});var vm=l(Dr);uc=s(vm,"MegatronBertForSequenceClassification"),vm.forEach(o),$a.forEach(o),Ks=h(t),O=i(t,"DIV",{class:!0});var ce=l(O);M(xo.$$.fragment,ce),gc=h(ce),Wr=i(ce,"P",{});var km=l(Wr);fc=s(km,`MegatronBert Model transformer with a sequence classification/regression head on top (a linear layer on top of the
pooled output) e.g. for GLUE tasks.`),km.forEach(o),_c=h(ce),Po=i(ce,"P",{});var Ba=l(Po);bc=s(Ba,"This model inherits from "),xn=i(Ba,"A",{href:!0});var Mm=l(xn);vc=s(Mm,"PreTrainedModel"),Mm.forEach(o),kc=s(Ba,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Ba.forEach(o),Mc=h(ce),qo=i(ce,"P",{});var Fa=l(qo);Tc=s(Fa,"This model is also a PyTorch "),Eo=i(Fa,"A",{href:!0,rel:!0});var Tm=l(Eo);wc=s(Tm,"torch.nn.Module"),Tm.forEach(o),yc=s(Fa,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Fa.forEach(o),$c=h(ce),D=i(ce,"DIV",{class:!0});var pe=l(D);M(Co.$$.fragment,pe),Bc=h(pe),Ee=i(pe,"P",{});var Gn=l(Ee);Fc=s(Gn,"The "),Pn=i(Gn,"A",{href:!0});var wm=l(Pn);zc=s(wm,"MegatronBertForSequenceClassification"),wm.forEach(o),xc=s(Gn," forward method, overrides the "),Rr=i(Gn,"CODE",{});var ym=l(Rr);Pc=s(ym,"__call__"),ym.forEach(o),qc=s(Gn," special method."),Gn.forEach(o),Ec=h(pe),M(ct.$$.fragment,pe),Cc=h(pe),M(pt.$$.fragment,pe),Ac=h(pe),M(ht.$$.fragment,pe),pe.forEach(o),ce.forEach(o),Ys=h(t),Ce=i(t,"H2",{class:!0});var za=l(Ce);mt=i(za,"A",{id:!0,class:!0,href:!0});var $m=l(mt);Hr=i($m,"SPAN",{});var Bm=l(Hr);M(Ao.$$.fragment,Bm),Bm.forEach(o),$m.forEach(o),jc=h(za),Ur=i(za,"SPAN",{});var Fm=l(Ur);Oc=s(Fm,"MegatronBertForMultipleChoice"),Fm.forEach(o),za.forEach(o),Xs=h(t),L=i(t,"DIV",{class:!0});var he=l(L);M(jo.$$.fragment,he),Lc=h(he),Qr=i(he,"P",{});var zm=l(Qr);Sc=s(zm,`MegatronBert 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.`),zm.forEach(o),Nc=h(he),Oo=i(he,"P",{});var xa=l(Oo);Ic=s(xa,"This model inherits from "),qn=i(xa,"A",{href:!0});var xm=l(qn);Dc=s(xm,"PreTrainedModel"),xm.forEach(o),Wc=s(xa,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),xa.forEach(o),Rc=h(he),Lo=i(he,"P",{});var Pa=l(Lo);Hc=s(Pa,"This model is also a PyTorch "),So=i(Pa,"A",{href:!0,rel:!0});var Pm=l(So);Uc=s(Pm,"torch.nn.Module"),Pm.forEach(o),Qc=s(Pa,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Pa.forEach(o),Gc=h(he),Y=i(he,"DIV",{class:!0});var zt=l(Y);M(No.$$.fragment,zt),Vc=h(zt),Ae=i(zt,"P",{});var Vn=l(Ae);Jc=s(Vn,"The "),En=i(Vn,"A",{href:!0});var qm=l(En);Kc=s(qm,"MegatronBertForMultipleChoice"),qm.forEach(o),Yc=s(Vn," forward method, overrides the "),Gr=i(Vn,"CODE",{});var Em=l(Gr);Xc=s(Em,"__call__"),Em.forEach(o),Zc=s(Vn," special method."),Vn.forEach(o),ep=h(zt),M(ut.$$.fragment,zt),tp=h(zt),M(gt.$$.fragment,zt),zt.forEach(o),he.forEach(o),Zs=h(t),je=i(t,"H2",{class:!0});var qa=l(je);ft=i(qa,"A",{id:!0,class:!0,href:!0});var Cm=l(ft);Vr=i(Cm,"SPAN",{});var Am=l(Vr);M(Io.$$.fragment,Am),Am.forEach(o),Cm.forEach(o),op=h(qa),Jr=i(qa,"SPAN",{});var jm=l(Jr);np=s(jm,"MegatronBertForTokenClassification"),jm.forEach(o),qa.forEach(o),ea=h(t),S=i(t,"DIV",{class:!0});var me=l(S);M(Do.$$.fragment,me),rp=h(me),Kr=i(me,"P",{});var Om=l(Kr);sp=s(Om,`MegatronBert 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.`),Om.forEach(o),ap=h(me),Wo=i(me,"P",{});var Ea=l(Wo);ip=s(Ea,"This model inherits from "),Cn=i(Ea,"A",{href:!0});var Lm=l(Cn);lp=s(Lm,"PreTrainedModel"),Lm.forEach(o),dp=s(Ea,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),Ea.forEach(o),cp=h(me),Ro=i(me,"P",{});var Ca=l(Ro);pp=s(Ca,"This model is also a PyTorch "),Ho=i(Ca,"A",{href:!0,rel:!0});var Sm=l(Ho);hp=s(Sm,"torch.nn.Module"),Sm.forEach(o),mp=s(Ca,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ca.forEach(o),up=h(me),X=i(me,"DIV",{class:!0});var xt=l(X);M(Uo.$$.fragment,xt),gp=h(xt),Oe=i(xt,"P",{});var Jn=l(Oe);fp=s(Jn,"The "),An=i(Jn,"A",{href:!0});var Nm=l(An);_p=s(Nm,"MegatronBertForTokenClassification"),Nm.forEach(o),bp=s(Jn," forward method, overrides the "),Yr=i(Jn,"CODE",{});var Im=l(Yr);vp=s(Im,"__call__"),Im.forEach(o),kp=s(Jn," special method."),Jn.forEach(o),Mp=h(xt),M(_t.$$.fragment,xt),Tp=h(xt),M(bt.$$.fragment,xt),xt.forEach(o),me.forEach(o),ta=h(t),Le=i(t,"H2",{class:!0});var Aa=l(Le);vt=i(Aa,"A",{id:!0,class:!0,href:!0});var Dm=l(vt);Xr=i(Dm,"SPAN",{});var Wm=l(Xr);M(Qo.$$.fragment,Wm),Wm.forEach(o),Dm.forEach(o),wp=h(Aa),Zr=i(Aa,"SPAN",{});var Rm=l(Zr);yp=s(Rm,"MegatronBertForQuestionAnswering"),Rm.forEach(o),Aa.forEach(o),oa=h(t),N=i(t,"DIV",{class:!0});var ue=l(N);M(Go.$$.fragment,ue),$p=h(ue),Se=i(ue,"P",{});var Kn=l(Se);Bp=s(Kn,`MegatronBert 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 `),es=i(Kn,"CODE",{});var Hm=l(es);Fp=s(Hm,"span start logits"),Hm.forEach(o),zp=s(Kn," and "),ts=i(Kn,"CODE",{});var Um=l(ts);xp=s(Um,"span end logits"),Um.forEach(o),Pp=s(Kn,")."),Kn.forEach(o),qp=h(ue),Vo=i(ue,"P",{});var ja=l(Vo);Ep=s(ja,"This model inherits from "),jn=i(ja,"A",{href:!0});var Qm=l(jn);Cp=s(Qm,"PreTrainedModel"),Qm.forEach(o),Ap=s(ja,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`),ja.forEach(o),jp=h(ue),Jo=i(ue,"P",{});var Oa=l(Jo);Op=s(Oa,"This model is also a PyTorch "),Ko=i(Oa,"A",{href:!0,rel:!0});var Gm=l(Ko);Lp=s(Gm,"torch.nn.Module"),Gm.forEach(o),Sp=s(Oa,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Oa.forEach(o),Np=h(ue),Z=i(ue,"DIV",{class:!0});var Pt=l(Z);M(Yo.$$.fragment,Pt),Ip=h(Pt),Ne=i(Pt,"P",{});var Yn=l(Ne);Dp=s(Yn,"The "),On=i(Yn,"A",{href:!0});var Vm=l(On);Wp=s(Vm,"MegatronBertForQuestionAnswering"),Vm.forEach(o),Rp=s(Yn," forward method, overrides the "),os=i(Yn,"CODE",{});var Jm=l(os);Hp=s(Jm,"__call__"),Jm.forEach(o),Up=s(Yn," special method."),Yn.forEach(o),Qp=h(Pt),M(kt.$$.fragment,Pt),Gp=h(Pt),M(Mt.$$.fragment,Pt),Pt.forEach(o),ue.forEach(o),this.h()},h(){m(d,"name","hf:doc:metadata"),m(d,"content",JSON.stringify(Tu)),m(u,"id","megatronbert"),m(u,"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"),m(u,"href","#megatronbert"),m(f,"class","relative group"),m(We,"id","overview"),m(We,"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"),m(We,"href","#overview"),m(ge,"class","relative group"),m(Et,"href","https://arxiv.org/abs/1909.08053"),m(Et,"rel","nofollow"),m(Ct,"href","https://ngc.nvidia.com/catalog/models/nvidia:megatron_bert_345m"),m(Ct,"rel","nofollow"),m(At,"href","https://ngc.nvidia.com/signup"),m(At,"rel","nofollow"),m(jt,"href","https://docs.nvidia.com/dgx/ngc-registry-cli-user-guide/index.html#topic_6_4_1"),m(jt,"rel","nofollow"),m(It,"href","https://huggingface.co/jdemouth"),m(It,"rel","nofollow"),m(Dt,"href","https://github.com/NVIDIA/Megatron-LM"),m(Dt,"rel","nofollow"),m(Ue,"id","documentation-resources"),m(Ue,"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"),m(Ue,"href","#documentation-resources"),m(fe,"class","relative group"),m(cn,"href","./tasks/sequence_classification"),m(pn,"href","./tasks/token_classification"),m(hn,"href","./tasks/question_answering"),m(mn,"href","./tasks/language_modeling"),m(un,"href","./tasks/masked_language_modeling"),m(gn,"href","./tasks/multiple_choice"),m(Qe,"id","transformers.MegatronBertConfig"),m(Qe,"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"),m(Qe,"href","#transformers.MegatronBertConfig"),m(_e,"class","relative group"),m(fn,"href","/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertModel"),m(Ut,"href","https://huggingface.co/nvidia/megatron-bert-uncased-345m"),m(Ut,"rel","nofollow"),m(_n,"href","/docs/transformers/v4.27.1/en/main_classes/configuration#transformers.PretrainedConfig"),m(bn,"href","/docs/transformers/v4.27.1/en/main_classes/configuration#transformers.PretrainedConfig"),m(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Ve,"id","transformers.MegatronBertModel"),m(Ve,"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"),m(Ve,"href","#transformers.MegatronBertModel"),m(ke,"class","relative group"),m(vn,"href","/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel"),m(Kt,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(Kt,"rel","nofollow"),m(Xt,"href","https://arxiv.org/abs/1706.03762"),m(Xt,"rel","nofollow"),m(kn,"href","/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertModel"),m(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Ye,"id","transformers.MegatronBertForMaskedLM"),m(Ye,"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"),m(Ye,"href","#transformers.MegatronBertForMaskedLM"),m(Te,"class","relative group"),m(Mn,"href","/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel"),m(so,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(so,"rel","nofollow"),m(Tn,"href","/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertForMaskedLM"),m(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(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(et,"id","transformers.MegatronBertForCausalLM"),m(et,"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"),m(et,"href","#transformers.MegatronBertForCausalLM"),m(ye,"class","relative group"),m(wn,"href","/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel"),m(mo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(mo,"rel","nofollow"),m(yn,"href","/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertForCausalLM"),m(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(nt,"id","transformers.MegatronBertForNextSentencePrediction"),m(nt,"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"),m(nt,"href","#transformers.MegatronBertForNextSentencePrediction"),m(Be,"class","relative group"),m($n,"href","/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel"),m(ko,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(ko,"rel","nofollow"),m(Bn,"href","/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertForNextSentencePrediction"),m(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(at,"id","transformers.MegatronBertForPreTraining"),m(at,"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"),m(at,"href","#transformers.MegatronBertForPreTraining"),m(ze,"class","relative group"),m(Fn,"href","/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel"),m(Bo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(Bo,"rel","nofollow"),m(zn,"href","/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertForPreTraining"),m(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(dt,"id","transformers.MegatronBertForSequenceClassification"),m(dt,"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"),m(dt,"href","#transformers.MegatronBertForSequenceClassification"),m(qe,"class","relative group"),m(xn,"href","/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel"),m(Eo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(Eo,"rel","nofollow"),m(Pn,"href","/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertForSequenceClassification"),m(D,"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,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(mt,"id","transformers.MegatronBertForMultipleChoice"),m(mt,"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"),m(mt,"href","#transformers.MegatronBertForMultipleChoice"),m(Ce,"class","relative group"),m(qn,"href","/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel"),m(So,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(So,"rel","nofollow"),m(En,"href","/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertForMultipleChoice"),m(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ft,"id","transformers.MegatronBertForTokenClassification"),m(ft,"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"),m(ft,"href","#transformers.MegatronBertForTokenClassification"),m(je,"class","relative group"),m(Cn,"href","/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel"),m(Ho,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(Ho,"rel","nofollow"),m(An,"href","/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertForTokenClassification"),m(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(vt,"id","transformers.MegatronBertForQuestionAnswering"),m(vt,"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"),m(vt,"href","#transformers.MegatronBertForQuestionAnswering"),m(Le,"class","relative group"),m(jn,"href","/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel"),m(Ko,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),m(Ko,"rel","nofollow"),m(On,"href","/docs/transformers/v4.27.1/en/model_doc/megatron-bert#transformers.MegatronBertForQuestionAnswering"),m(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,g){e(document.head,d),_(t,v,g),_(t,f,g),e(f,u),e(u,b),T(n,b,null),e(f,c),e(f,F),e(F,La),_(t,bs,g),_(t,ge,g),e(ge,We),e(We,Xn),T(qt,Xn,null),e(ge,Sa),e(ge,Zn),e(Zn,Na),_(t,vs,g),_(t,Re,g),e(Re,Ia),e(Re,Et),e(Et,Da),e(Re,Wa),_(t,ks,g),_(t,on,g),e(on,Ra),_(t,Ms,g),_(t,nn,g),e(nn,er),e(er,Ha),_(t,Ts,g),_(t,rn,g),e(rn,Ua),_(t,ws,g),_(t,He,g),e(He,Qa),e(He,Ct),e(Ct,Ga),e(He,Va),_(t,ys,g),_(t,ne,g),e(ne,Ja),e(ne,At),e(At,Ka),e(ne,Ya),e(ne,jt),e(jt,Xa),e(ne,Za),_(t,$s,g),_(t,sn,g),e(sn,ei),_(t,Bs,g),_(t,an,g),e(an,ti),_(t,Fs,g),T(Ot,t,g),_(t,zs,g),_(t,ln,g),e(ln,oi),_(t,xs,g),T(Lt,t,g),_(t,Ps,g),_(t,dn,g),e(dn,ni),_(t,qs,g),_(t,re,g),e(re,ri),e(re,tr),e(tr,si),e(re,ai),e(re,or),e(or,ii),e(re,li),_(t,Es,g),T(St,t,g),_(t,Cs,g),T(Nt,t,g),_(t,As,g),_(t,se,g),e(se,di),e(se,It),e(It,ci),e(se,pi),e(se,Dt),e(Dt,hi),e(se,mi),_(t,js,g),_(t,fe,g),e(fe,Ue),e(Ue,nr),T(Wt,nr,null),e(fe,ui),e(fe,rr),e(rr,gi),_(t,Os,g),_(t,q,g),e(q,sr),e(sr,cn),e(cn,fi),e(q,_i),e(q,ar),e(ar,pn),e(pn,bi),e(q,vi),e(q,ir),e(ir,hn),e(hn,ki),e(q,Mi),e(q,lr),e(lr,mn),e(mn,Ti),e(q,wi),e(q,dr),e(dr,un),e(un,yi),e(q,$i),e(q,cr),e(cr,gn),e(gn,Bi),_(t,Ls,g),_(t,_e,g),e(_e,Qe),e(Qe,pr),T(Rt,pr,null),e(_e,Fi),e(_e,hr),e(hr,zi),_(t,Ss,g),_(t,H,g),T(Ht,H,null),e(H,xi),e(H,be),e(be,Pi),e(be,fn),e(fn,qi),e(be,Ei),e(be,Ut),e(Ut,Ci),e(be,Ai),e(H,ji),e(H,ve),e(ve,Oi),e(ve,_n),e(_n,Li),e(ve,Si),e(ve,bn),e(bn,Ni),e(ve,Ii),e(H,Di),T(Ge,H,null),_(t,Ns,g),_(t,ke,g),e(ke,Ve),e(Ve,mr),T(Qt,mr,null),e(ke,Wi),e(ke,ur),e(ur,Ri),_(t,Is,g),_(t,z,g),T(Gt,z,null),e(z,Hi),e(z,gr),e(gr,Ui),e(z,Qi),e(z,Vt),e(Vt,Gi),e(Vt,vn),e(vn,Vi),e(Vt,Ji),e(z,Ki),e(z,Jt),e(Jt,Yi),e(Jt,Kt),e(Kt,Xi),e(Jt,Zi),e(z,el),e(z,Yt),e(Yt,tl),e(Yt,Xt),e(Xt,ol),e(Yt,nl),e(z,rl),e(z,P),e(P,sl),e(P,fr),e(fr,al),e(P,il),e(P,_r),e(_r,ll),e(P,dl),e(P,br),e(br,cl),e(P,pl),e(P,vr),e(vr,hl),e(P,ml),e(P,kr),e(kr,ul),e(P,gl),e(P,Mr),e(Mr,fl),e(P,_l),e(z,bl),e(z,Q),T(Zt,Q,null),e(Q,vl),e(Q,Me),e(Me,kl),e(Me,kn),e(kn,Ml),e(Me,Tl),e(Me,Tr),e(Tr,wl),e(Me,yl),e(Q,$l),T(Je,Q,null),e(Q,Bl),T(Ke,Q,null),_(t,Ds,g),_(t,Te,g),e(Te,Ye),e(Ye,wr),T(eo,wr,null),e(Te,Fl),e(Te,yr),e(yr,zl),_(t,Ws,g),_(t,E,g),T(to,E,null),e(E,xl),e(E,oo),e(oo,Pl),e(oo,$r),e($r,ql),e(oo,El),e(E,Cl),e(E,no),e(no,Al),e(no,Mn),e(Mn,jl),e(no,Ol),e(E,Ll),e(E,ro),e(ro,Sl),e(ro,so),e(so,Nl),e(ro,Il),e(E,Dl),e(E,G),T(ao,G,null),e(G,Wl),e(G,we),e(we,Rl),e(we,Tn),e(Tn,Hl),e(we,Ul),e(we,Br),e(Br,Ql),e(we,Gl),e(G,Vl),T(Xe,G,null),e(G,Jl),T(Ze,G,null),_(t,Rs,g),_(t,ye,g),e(ye,et),e(et,Fr),T(io,Fr,null),e(ye,Kl),e(ye,zr),e(zr,Yl),_(t,Hs,g),_(t,C,g),T(lo,C,null),e(C,Xl),e(C,co),e(co,Zl),e(co,xr),e(xr,ed),e(co,td),e(C,od),e(C,po),e(po,nd),e(po,wn),e(wn,rd),e(po,sd),e(C,ad),e(C,ho),e(ho,id),e(ho,mo),e(mo,ld),e(ho,dd),e(C,cd),e(C,V),T(uo,V,null),e(V,pd),e(V,$e),e($e,hd),e($e,yn),e(yn,md),e($e,ud),e($e,Pr),e(Pr,gd),e($e,fd),e(V,_d),T(tt,V,null),e(V,bd),T(ot,V,null),_(t,Us,g),_(t,Be,g),e(Be,nt),e(nt,qr),T(go,qr,null),e(Be,vd),e(Be,Er),e(Er,kd),_(t,Qs,g),_(t,A,g),T(fo,A,null),e(A,Md),e(A,_o),e(_o,Td),e(_o,Cr),e(Cr,wd),e(_o,yd),e(A,$d),e(A,bo),e(bo,Bd),e(bo,$n),e($n,Fd),e(bo,zd),e(A,xd),e(A,vo),e(vo,Pd),e(vo,ko),e(ko,qd),e(vo,Ed),e(A,Cd),e(A,J),T(Mo,J,null),e(J,Ad),e(J,Fe),e(Fe,jd),e(Fe,Bn),e(Bn,Od),e(Fe,Ld),e(Fe,Ar),e(Ar,Sd),e(Fe,Nd),e(J,Id),T(rt,J,null),e(J,Dd),T(st,J,null),_(t,Gs,g),_(t,ze,g),e(ze,at),e(at,jr),T(To,jr,null),e(ze,Wd),e(ze,Or),e(Or,Rd),_(t,Vs,g),_(t,j,g),T(wo,j,null),e(j,Hd),e(j,xe),e(xe,Ud),e(xe,Lr),e(Lr,Qd),e(xe,Gd),e(xe,Sr),e(Sr,Vd),e(xe,Jd),e(j,Kd),e(j,yo),e(yo,Yd),e(yo,Fn),e(Fn,Xd),e(yo,Zd),e(j,ec),e(j,$o),e($o,tc),e($o,Bo),e(Bo,oc),e($o,nc),e(j,rc),e(j,K),T(Fo,K,null),e(K,sc),e(K,Pe),e(Pe,ac),e(Pe,zn),e(zn,ic),e(Pe,lc),e(Pe,Nr),e(Nr,dc),e(Pe,cc),e(K,pc),T(it,K,null),e(K,hc),T(lt,K,null),_(t,Js,g),_(t,qe,g),e(qe,dt),e(dt,Ir),T(zo,Ir,null),e(qe,mc),e(qe,Dr),e(Dr,uc),_(t,Ks,g),_(t,O,g),T(xo,O,null),e(O,gc),e(O,Wr),e(Wr,fc),e(O,_c),e(O,Po),e(Po,bc),e(Po,xn),e(xn,vc),e(Po,kc),e(O,Mc),e(O,qo),e(qo,Tc),e(qo,Eo),e(Eo,wc),e(qo,yc),e(O,$c),e(O,D),T(Co,D,null),e(D,Bc),e(D,Ee),e(Ee,Fc),e(Ee,Pn),e(Pn,zc),e(Ee,xc),e(Ee,Rr),e(Rr,Pc),e(Ee,qc),e(D,Ec),T(ct,D,null),e(D,Cc),T(pt,D,null),e(D,Ac),T(ht,D,null),_(t,Ys,g),_(t,Ce,g),e(Ce,mt),e(mt,Hr),T(Ao,Hr,null),e(Ce,jc),e(Ce,Ur),e(Ur,Oc),_(t,Xs,g),_(t,L,g),T(jo,L,null),e(L,Lc),e(L,Qr),e(Qr,Sc),e(L,Nc),e(L,Oo),e(Oo,Ic),e(Oo,qn),e(qn,Dc),e(Oo,Wc),e(L,Rc),e(L,Lo),e(Lo,Hc),e(Lo,So),e(So,Uc),e(Lo,Qc),e(L,Gc),e(L,Y),T(No,Y,null),e(Y,Vc),e(Y,Ae),e(Ae,Jc),e(Ae,En),e(En,Kc),e(Ae,Yc),e(Ae,Gr),e(Gr,Xc),e(Ae,Zc),e(Y,ep),T(ut,Y,null),e(Y,tp),T(gt,Y,null),_(t,Zs,g),_(t,je,g),e(je,ft),e(ft,Vr),T(Io,Vr,null),e(je,op),e(je,Jr),e(Jr,np),_(t,ea,g),_(t,S,g),T(Do,S,null),e(S,rp),e(S,Kr),e(Kr,sp),e(S,ap),e(S,Wo),e(Wo,ip),e(Wo,Cn),e(Cn,lp),e(Wo,dp),e(S,cp),e(S,Ro),e(Ro,pp),e(Ro,Ho),e(Ho,hp),e(Ro,mp),e(S,up),e(S,X),T(Uo,X,null),e(X,gp),e(X,Oe),e(Oe,fp),e(Oe,An),e(An,_p),e(Oe,bp),e(Oe,Yr),e(Yr,vp),e(Oe,kp),e(X,Mp),T(_t,X,null),e(X,Tp),T(bt,X,null),_(t,ta,g),_(t,Le,g),e(Le,vt),e(vt,Xr),T(Qo,Xr,null),e(Le,wp),e(Le,Zr),e(Zr,yp),_(t,oa,g),_(t,N,g),T(Go,N,null),e(N,$p),e(N,Se),e(Se,Bp),e(Se,es),e(es,Fp),e(Se,zp),e(Se,ts),e(ts,xp),e(Se,Pp),e(N,qp),e(N,Vo),e(Vo,Ep),e(Vo,jn),e(jn,Cp),e(Vo,Ap),e(N,jp),e(N,Jo),e(Jo,Op),e(Jo,Ko),e(Ko,Lp),e(Jo,Sp),e(N,Np),e(N,Z),T(Yo,Z,null),e(Z,Ip),e(Z,Ne),e(Ne,Dp),e(Ne,On),e(On,Wp),e(Ne,Rp),e(Ne,os),e(os,Hp),e(Ne,Up),e(Z,Qp),T(kt,Z,null),e(Z,Gp),T(Mt,Z,null),na=!0},p(t,[g]){const Xo={};g&2&&(Xo.$$scope={dirty:g,ctx:t}),Ge.$set(Xo);const ns={};g&2&&(ns.$$scope={dirty:g,ctx:t}),Je.$set(ns);const rs={};g&2&&(rs.$$scope={dirty:g,ctx:t}),Ke.$set(rs);const ss={};g&2&&(ss.$$scope={dirty:g,ctx:t}),Xe.$set(ss);const Zo={};g&2&&(Zo.$$scope={dirty:g,ctx:t}),Ze.$set(Zo);const as={};g&2&&(as.$$scope={dirty:g,ctx:t}),tt.$set(as);const is={};g&2&&(is.$$scope={dirty:g,ctx:t}),ot.$set(is);const ls={};g&2&&(ls.$$scope={dirty:g,ctx:t}),rt.$set(ls);const en={};g&2&&(en.$$scope={dirty:g,ctx:t}),st.$set(en);const ds={};g&2&&(ds.$$scope={dirty:g,ctx:t}),it.$set(ds);const cs={};g&2&&(cs.$$scope={dirty:g,ctx:t}),lt.$set(cs);const ps={};g&2&&(ps.$$scope={dirty:g,ctx:t}),ct.$set(ps);const hs={};g&2&&(hs.$$scope={dirty:g,ctx:t}),pt.$set(hs);const ms={};g&2&&(ms.$$scope={dirty:g,ctx:t}),ht.$set(ms);const tn={};g&2&&(tn.$$scope={dirty:g,ctx:t}),ut.$set(tn);const us={};g&2&&(us.$$scope={dirty:g,ctx:t}),gt.$set(us);const Ie={};g&2&&(Ie.$$scope={dirty:g,ctx:t}),_t.$set(Ie);const gs={};g&2&&(gs.$$scope={dirty:g,ctx:t}),bt.$set(gs);const fs={};g&2&&(fs.$$scope={dirty:g,ctx:t}),kt.$set(fs);const _s={};g&2&&(_s.$$scope={dirty:g,ctx:t}),Mt.$set(_s)},i(t){na||(w(n.$$.fragment,t),w(qt.$$.fragment,t),w(Ot.$$.fragment,t),w(Lt.$$.fragment,t),w(St.$$.fragment,t),w(Nt.$$.fragment,t),w(Wt.$$.fragment,t),w(Rt.$$.fragment,t),w(Ht.$$.fragment,t),w(Ge.$$.fragment,t),w(Qt.$$.fragment,t),w(Gt.$$.fragment,t),w(Zt.$$.fragment,t),w(Je.$$.fragment,t),w(Ke.$$.fragment,t),w(eo.$$.fragment,t),w(to.$$.fragment,t),w(ao.$$.fragment,t),w(Xe.$$.fragment,t),w(Ze.$$.fragment,t),w(io.$$.fragment,t),w(lo.$$.fragment,t),w(uo.$$.fragment,t),w(tt.$$.fragment,t),w(ot.$$.fragment,t),w(go.$$.fragment,t),w(fo.$$.fragment,t),w(Mo.$$.fragment,t),w(rt.$$.fragment,t),w(st.$$.fragment,t),w(To.$$.fragment,t),w(wo.$$.fragment,t),w(Fo.$$.fragment,t),w(it.$$.fragment,t),w(lt.$$.fragment,t),w(zo.$$.fragment,t),w(xo.$$.fragment,t),w(Co.$$.fragment,t),w(ct.$$.fragment,t),w(pt.$$.fragment,t),w(ht.$$.fragment,t),w(Ao.$$.fragment,t),w(jo.$$.fragment,t),w(No.$$.fragment,t),w(ut.$$.fragment,t),w(gt.$$.fragment,t),w(Io.$$.fragment,t),w(Do.$$.fragment,t),w(Uo.$$.fragment,t),w(_t.$$.fragment,t),w(bt.$$.fragment,t),w(Qo.$$.fragment,t),w(Go.$$.fragment,t),w(Yo.$$.fragment,t),w(kt.$$.fragment,t),w(Mt.$$.fragment,t),na=!0)},o(t){y(n.$$.fragment,t),y(qt.$$.fragment,t),y(Ot.$$.fragment,t),y(Lt.$$.fragment,t),y(St.$$.fragment,t),y(Nt.$$.fragment,t),y(Wt.$$.fragment,t),y(Rt.$$.fragment,t),y(Ht.$$.fragment,t),y(Ge.$$.fragment,t),y(Qt.$$.fragment,t),y(Gt.$$.fragment,t),y(Zt.$$.fragment,t),y(Je.$$.fragment,t),y(Ke.$$.fragment,t),y(eo.$$.fragment,t),y(to.$$.fragment,t),y(ao.$$.fragment,t),y(Xe.$$.fragment,t),y(Ze.$$.fragment,t),y(io.$$.fragment,t),y(lo.$$.fragment,t),y(uo.$$.fragment,t),y(tt.$$.fragment,t),y(ot.$$.fragment,t),y(go.$$.fragment,t),y(fo.$$.fragment,t),y(Mo.$$.fragment,t),y(rt.$$.fragment,t),y(st.$$.fragment,t),y(To.$$.fragment,t),y(wo.$$.fragment,t),y(Fo.$$.fragment,t),y(it.$$.fragment,t),y(lt.$$.fragment,t),y(zo.$$.fragment,t),y(xo.$$.fragment,t),y(Co.$$.fragment,t),y(ct.$$.fragment,t),y(pt.$$.fragment,t),y(ht.$$.fragment,t),y(Ao.$$.fragment,t),y(jo.$$.fragment,t),y(No.$$.fragment,t),y(ut.$$.fragment,t),y(gt.$$.fragment,t),y(Io.$$.fragment,t),y(Do.$$.fragment,t),y(Uo.$$.fragment,t),y(_t.$$.fragment,t),y(bt.$$.fragment,t),y(Qo.$$.fragment,t),y(Go.$$.fragment,t),y(Yo.$$.fragment,t),y(kt.$$.fragment,t),y(Mt.$$.fragment,t),na=!1},d(t){o(d),t&&o(v),t&&o(f),$(n),t&&o(bs),t&&o(ge),$(qt),t&&o(vs),t&&o(Re),t&&o(ks),t&&o(on),t&&o(Ms),t&&o(nn),t&&o(Ts),t&&o(rn),t&&o(ws),t&&o(He),t&&o(ys),t&&o(ne),t&&o($s),t&&o(sn),t&&o(Bs),t&&o(an),t&&o(Fs),$(Ot,t),t&&o(zs),t&&o(ln),t&&o(xs),$(Lt,t),t&&o(Ps),t&&o(dn),t&&o(qs),t&&o(re),t&&o(Es),$(St,t),t&&o(Cs),$(Nt,t),t&&o(As),t&&o(se),t&&o(js),t&&o(fe),$(Wt),t&&o(Os),t&&o(q),t&&o(Ls),t&&o(_e),$(Rt),t&&o(Ss),t&&o(H),$(Ht),$(Ge),t&&o(Ns),t&&o(ke),$(Qt),t&&o(Is),t&&o(z),$(Gt),$(Zt),$(Je),$(Ke),t&&o(Ds),t&&o(Te),$(eo),t&&o(Ws),t&&o(E),$(to),$(ao),$(Xe),$(Ze),t&&o(Rs),t&&o(ye),$(io),t&&o(Hs),t&&o(C),$(lo),$(uo),$(tt),$(ot),t&&o(Us),t&&o(Be),$(go),t&&o(Qs),t&&o(A),$(fo),$(Mo),$(rt),$(st),t&&o(Gs),t&&o(ze),$(To),t&&o(Vs),t&&o(j),$(wo),$(Fo),$(it),$(lt),t&&o(Js),t&&o(qe),$(zo),t&&o(Ks),t&&o(O),$(xo),$(Co),$(ct),$(pt),$(ht),t&&o(Ys),t&&o(Ce),$(Ao),t&&o(Xs),t&&o(L),$(jo),$(No),$(ut),$(gt),t&&o(Zs),t&&o(je),$(Io),t&&o(ea),t&&o(S),$(Do),$(Uo),$(_t),$(bt),t&&o(ta),t&&o(Le),$(Qo),t&&o(oa),t&&o(N),$(Go),$(Yo),$(kt),$(Mt)}}}const Tu={local:"megatronbert",sections:[{local:"overview",title:"Overview"},{local:"documentation-resources",title:"Documentation resources"},{local:"transformers.MegatronBertConfig",title:"MegatronBertConfig"},{local:"transformers.MegatronBertModel",title:"MegatronBertModel"},{local:"transformers.MegatronBertForMaskedLM",title:"MegatronBertForMaskedLM"},{local:"transformers.MegatronBertForCausalLM",title:"MegatronBertForCausalLM"},{local:"transformers.MegatronBertForNextSentencePrediction",title:"MegatronBertForNextSentencePrediction"},{local:"transformers.MegatronBertForPreTraining",title:"MegatronBertForPreTraining"},{local:"transformers.MegatronBertForSequenceClassification",title:"MegatronBertForSequenceClassification"},{local:"transformers.MegatronBertForMultipleChoice",title:"MegatronBertForMultipleChoice"},{local:"transformers.MegatronBertForTokenClassification",title:"MegatronBertForTokenClassification"},{local:"transformers.MegatronBertForQuestionAnswering",title:"MegatronBertForQuestionAnswering"}],title:"MegatronBERT"};function wu(B){return eu(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Pu extends Km{constructor(d){super();Ym(this,d,wu,Mu,Xm,{})}}export{Pu as default,Tu as metadata};
