import{S as em,i as tm,s as om,e as a,k as h,w as v,t as r,M as nm,c as i,d as o,m,a as l,x as M,h as s,b as u,G as e,g as _,y as T,q as w,o as y,B as $,v as rm,L as ee}from"../../chunks/vendor-hf-doc-builder.js";import{T as Se}from"../../chunks/Tip-hf-doc-builder.js";import{D as x}from"../../chunks/Docstring-hf-doc-builder.js";import{C as N}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as X}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Z}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function sm(B){let d,k,f,p,b;return p=new N({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"),k=r("Examples:"),f=h(),v(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);k=s(c,"Examples:"),c.forEach(o),f=m(n),M(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,k),_(n,f,c),T(p,n,c),b=!0},p:ee,i(n){b||(w(p.$$.fragment,n),b=!0)},o(n){y(p.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(p,n)}}}function am(B){let d,k,f,p,b;return{c(){d=a("p"),k=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),p=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);k=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);p=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,k),e(d,f),e(f,p),e(d,b)},d(n){n&&o(d)}}}function im(B){let d,k,f,p,b;return p=new N({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"),k=r("Example:"),f=h(),v(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);k=s(c,"Example:"),c.forEach(o),f=m(n),M(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,k),_(n,f,c),T(p,n,c),b=!0},p:ee,i(n){b||(w(p.$$.fragment,n),b=!0)},o(n){y(p.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(p,n)}}}function lm(B){let d,k,f,p,b;return{c(){d=a("p"),k=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),p=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);k=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);p=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,k),e(d,f),e(f,p),e(d,b)},d(n){n&&o(d)}}}function dm(B){let d,k,f,p,b;return p=new N({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"),k=r("Example:"),f=h(),v(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);k=s(c,"Example:"),c.forEach(o),f=m(n),M(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,k),_(n,f,c),T(p,n,c),b=!0},p:ee,i(n){b||(w(p.$$.fragment,n),b=!0)},o(n){y(p.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(p,n)}}}function cm(B){let d,k,f,p,b;return{c(){d=a("p"),k=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),p=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);k=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);p=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,k),e(d,f),e(f,p),e(d,b)},d(n){n&&o(d)}}}function pm(B){let d,k,f,p,b;return p=new N({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"),k=r("Example:"),f=h(),v(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);k=s(c,"Example:"),c.forEach(o),f=m(n),M(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,k),_(n,f,c),T(p,n,c),b=!0},p:ee,i(n){b||(w(p.$$.fragment,n),b=!0)},o(n){y(p.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(p,n)}}}function hm(B){let d,k,f,p,b;return{c(){d=a("p"),k=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),p=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);k=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);p=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,k),e(d,f),e(f,p),e(d,b)},d(n){n&&o(d)}}}function mm(B){let d,k,f,p,b;return p=new N({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"),k=r("Example:"),f=h(),v(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);k=s(c,"Example:"),c.forEach(o),f=m(n),M(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,k),_(n,f,c),T(p,n,c),b=!0},p:ee,i(n){b||(w(p.$$.fragment,n),b=!0)},o(n){y(p.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(p,n)}}}function um(B){let d,k,f,p,b;return{c(){d=a("p"),k=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),p=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);k=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);p=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,k),e(d,f),e(f,p),e(d,b)},d(n){n&&o(d)}}}function gm(B){let d,k,f,p,b;return p=new N({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"),k=r("Example:"),f=h(),v(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);k=s(c,"Example:"),c.forEach(o),f=m(n),M(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,k),_(n,f,c),T(p,n,c),b=!0},p:ee,i(n){b||(w(p.$$.fragment,n),b=!0)},o(n){y(p.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(p,n)}}}function fm(B){let d,k,f,p,b;return{c(){d=a("p"),k=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),p=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);k=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);p=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,k),e(d,f),e(f,p),e(d,b)},d(n){n&&o(d)}}}function _m(B){let d,k,f,p,b;return p=new N({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"),k=r("Example of single-label classification:"),f=h(),v(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);k=s(c,"Example of single-label classification:"),c.forEach(o),f=m(n),M(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,k),_(n,f,c),T(p,n,c),b=!0},p:ee,i(n){b||(w(p.$$.fragment,n),b=!0)},o(n){y(p.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(p,n)}}}function bm(B){let d,k,f,p,b;return p=new N({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"),k=r("Example of multi-label classification:"),f=h(),v(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);k=s(c,"Example of multi-label classification:"),c.forEach(o),f=m(n),M(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,k),_(n,f,c),T(p,n,c),b=!0},p:ee,i(n){b||(w(p.$$.fragment,n),b=!0)},o(n){y(p.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(p,n)}}}function km(B){let d,k,f,p,b;return{c(){d=a("p"),k=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),p=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);k=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);p=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,k),e(d,f),e(f,p),e(d,b)},d(n){n&&o(d)}}}function vm(B){let d,k,f,p,b;return p=new N({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"),k=r("Example:"),f=h(),v(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);k=s(c,"Example:"),c.forEach(o),f=m(n),M(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,k),_(n,f,c),T(p,n,c),b=!0},p:ee,i(n){b||(w(p.$$.fragment,n),b=!0)},o(n){y(p.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(p,n)}}}function Mm(B){let d,k,f,p,b;return{c(){d=a("p"),k=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),p=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);k=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);p=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,k),e(d,f),e(f,p),e(d,b)},d(n){n&&o(d)}}}function Tm(B){let d,k,f,p,b;return p=new N({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"),k=r("Example:"),f=h(),v(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);k=s(c,"Example:"),c.forEach(o),f=m(n),M(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,k),_(n,f,c),T(p,n,c),b=!0},p:ee,i(n){b||(w(p.$$.fragment,n),b=!0)},o(n){y(p.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(p,n)}}}function wm(B){let d,k,f,p,b;return{c(){d=a("p"),k=r("Although the recipe for forward pass needs to be defined within this function, one should call the "),f=a("code"),p=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);k=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);p=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,k),e(d,f),e(f,p),e(d,b)},d(n){n&&o(d)}}}function ym(B){let d,k,f,p,b;return p=new N({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"),k=r("Example:"),f=h(),v(p.$$.fragment)},l(n){d=i(n,"P",{});var c=l(d);k=s(c,"Example:"),c.forEach(o),f=m(n),M(p.$$.fragment,n)},m(n,c){_(n,d,c),e(d,k),_(n,f,c),T(p,n,c),b=!0},p:ee,i(n){b||(w(p.$$.fragment,n),b=!0)},o(n){y(p.$$.fragment,n),b=!1},d(n){n&&o(d),n&&o(f),$(p,n)}}}function $m(B){let d,k,f,p,b,n,c,F,ga,Zr,me,Ne,Dn,Ft,fa,Wn,_a,es,Ie,ba,zt,ka,va,ts,Yo,Ma,os,Xo,Rn,Ta,ns,Zo,wa,rs,De,ya,xt,$a,Ba,ss,te,Fa,Pt,za,xa,qt,Pa,qa,as,en,Ca,is,tn,Ea,ls,Ct,ds,on,Aa,cs,Et,ps,nn,ja,hs,oe,Oa,Hn,La,Sa,Un,Na,Ia,ms,At,us,jt,gs,ne,Da,Ot,Wa,Ra,Lt,Ha,Ua,fs,ue,We,Gn,St,Ga,Qn,Qa,_s,R,Nt,Va,ge,Ja,rn,Ka,Ya,It,Xa,Za,ei,fe,ti,sn,oi,ni,an,ri,si,ai,Re,bs,_e,He,Vn,Dt,ii,Jn,li,ks,z,Wt,di,Kn,ci,pi,Rt,hi,ln,mi,ui,gi,Ht,fi,Ut,_i,bi,ki,Gt,vi,Qt,Mi,Ti,wi,P,yi,Yn,$i,Bi,Xn,Fi,zi,Zn,xi,Pi,er,qi,Ci,tr,Ei,Ai,or,ji,Oi,Li,H,Vt,Si,be,Ni,dn,Ii,Di,nr,Wi,Ri,Hi,Ue,Ui,Ge,vs,ke,Qe,rr,Jt,Gi,sr,Qi,Ms,q,Kt,Vi,Yt,Ji,ar,Ki,Yi,Xi,Xt,Zi,cn,el,tl,ol,Zt,nl,eo,rl,sl,al,U,to,il,ve,ll,pn,dl,cl,ir,pl,hl,ml,Ve,ul,Je,Ts,Me,Ke,lr,oo,gl,dr,fl,ws,C,no,_l,ro,bl,cr,kl,vl,Ml,so,Tl,hn,wl,yl,$l,ao,Bl,io,Fl,zl,xl,G,lo,Pl,Te,ql,mn,Cl,El,pr,Al,jl,Ol,Ye,Ll,Xe,ys,we,Ze,hr,co,Sl,mr,Nl,$s,E,po,Il,ho,Dl,ur,Wl,Rl,Hl,mo,Ul,un,Gl,Ql,Vl,uo,Jl,go,Kl,Yl,Xl,Q,fo,Zl,ye,ed,gn,td,od,gr,nd,rd,sd,et,ad,tt,Bs,$e,ot,fr,_o,id,_r,ld,Fs,A,bo,dd,Be,cd,br,pd,hd,kr,md,ud,gd,ko,fd,fn,_d,bd,kd,vo,vd,Mo,Md,Td,wd,V,To,yd,Fe,$d,_n,Bd,Fd,vr,zd,xd,Pd,nt,qd,rt,zs,ze,st,Mr,wo,Cd,Tr,Ed,xs,j,yo,Ad,wr,jd,Od,$o,Ld,bn,Sd,Nd,Id,Bo,Dd,Fo,Wd,Rd,Hd,I,zo,Ud,xe,Gd,kn,Qd,Vd,yr,Jd,Kd,Yd,at,Xd,it,Zd,lt,Ps,Pe,dt,$r,xo,ec,Br,tc,qs,O,Po,oc,Fr,nc,rc,qo,sc,vn,ac,ic,lc,Co,dc,Eo,cc,pc,hc,J,Ao,mc,qe,uc,Mn,gc,fc,zr,_c,bc,kc,ct,vc,pt,Cs,Ce,ht,xr,jo,Mc,Pr,Tc,Es,L,Oo,wc,qr,yc,$c,Lo,Bc,Tn,Fc,zc,xc,So,Pc,No,qc,Cc,Ec,K,Io,Ac,Ee,jc,wn,Oc,Lc,Cr,Sc,Nc,Ic,mt,Dc,ut,As,Ae,gt,Er,Do,Wc,Ar,Rc,js,S,Wo,Hc,je,Uc,jr,Gc,Qc,Or,Vc,Jc,Kc,Ro,Yc,yn,Xc,Zc,ep,Ho,tp,Uo,op,np,rp,Y,Go,sp,Oe,ap,$n,ip,lp,Lr,dp,cp,pp,ft,hp,_t,Os;return n=new X({}),Ft=new X({}),Ct=new N({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`}}),Et=new N({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`}}),At=new N({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'}}),jt=new N({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'}}),St=new X({}),Nt=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/main/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/main/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/main/src/transformers/models/megatron_bert/configuration_megatron_bert.py#L28"}}),Re=new Z({props:{anchor:"transformers.MegatronBertConfig.example",$$slots:{default:[sm]},$$scope:{ctx:B}}}),Dt=new X({}),Wt=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/main/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/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L840"}}),Vt=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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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/main/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/main/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L879",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/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/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ue=new Se({props:{$$slots:{default:[am]},$$scope:{ctx:B}}}),Ge=new Z({props:{anchor:"transformers.MegatronBertModel.forward.example",$$slots:{default:[im]},$$scope:{ctx:B}}}),Jt=new X({}),Kt=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/main/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/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1268"}}),to=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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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/main/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/main/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1294",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.MaskedLMOutput"
>transformers.modeling_outputs.MaskedLMOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/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/main/en/main_classes/output#transformers.modeling_outputs.MaskedLMOutput"
>transformers.modeling_outputs.MaskedLMOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ve=new Se({props:{$$slots:{default:[lm]},$$scope:{ctx:B}}}),Je=new Z({props:{anchor:"transformers.MegatronBertForMaskedLM.forward.example",$$slots:{default:[dm]},$$scope:{ctx:B}}}),oo=new X({}),no=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/main/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/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1122"}}),lo=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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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/main/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/main/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1145",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/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/main/en/main_classes/output#transformers.modeling_outputs.CausalLMOutputWithCrossAttentions"
>transformers.modeling_outputs.CausalLMOutputWithCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Ye=new Se({props:{$$slots:{default:[cm]},$$scope:{ctx:B}}}),Xe=new Z({props:{anchor:"transformers.MegatronBertForCausalLM.forward.example",$$slots:{default:[pm]},$$scope:{ctx:B}}}),co=new X({}),po=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/main/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/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1377"}}),fo=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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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/main/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/main/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1390",returnDescription:`
<p>A <a
  href="/docs/transformers/main/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/main/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/main/en/main_classes/output#transformers.modeling_outputs.NextSentencePredictorOutput"
>transformers.modeling_outputs.NextSentencePredictorOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),et=new Se({props:{$$slots:{default:[hm]},$$scope:{ctx:B}}}),tt=new Z({props:{anchor:"transformers.MegatronBertForNextSentencePrediction.forward.example",$$slots:{default:[mm]},$$scope:{ctx:B}}}),_o=new X({}),bo=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/main/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/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1016"}}),To=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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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/main/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/main/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/main/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>
`}}),nt=new Se({props:{$$slots:{default:[um]},$$scope:{ctx:B}}}),rt=new Z({props:{anchor:"transformers.MegatronBertForPreTraining.forward.example",$$slots:{default:[gm]},$$scope:{ctx:B}}}),wo=new X({}),yo=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/main/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/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1484"}}),zo=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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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/main/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/main/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1496",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/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/main/en/main_classes/output#transformers.modeling_outputs.SequenceClassifierOutput"
>transformers.modeling_outputs.SequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),at=new Se({props:{$$slots:{default:[fm]},$$scope:{ctx:B}}}),it=new Z({props:{anchor:"transformers.MegatronBertForSequenceClassification.forward.example",$$slots:{default:[_m]},$$scope:{ctx:B}}}),lt=new Z({props:{anchor:"transformers.MegatronBertForSequenceClassification.forward.example-2",$$slots:{default:[bm]},$$scope:{ctx:B}}}),xo=new X({}),Po=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/main/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/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1581"}}),Ao=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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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/main/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/main/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1592",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.MultipleChoiceModelOutput"
>transformers.modeling_outputs.MultipleChoiceModelOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/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/main/en/main_classes/output#transformers.modeling_outputs.MultipleChoiceModelOutput"
>transformers.modeling_outputs.MultipleChoiceModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ct=new Se({props:{$$slots:{default:[km]},$$scope:{ctx:B}}}),pt=new Z({props:{anchor:"transformers.MegatronBertForMultipleChoice.forward.example",$$slots:{default:[vm]},$$scope:{ctx:B}}}),jo=new X({}),Oo=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/main/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/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1674"}}),Io=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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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/main/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/main/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1689",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/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/main/en/main_classes/output#transformers.modeling_outputs.TokenClassifierOutput"
>transformers.modeling_outputs.TokenClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),mt=new Se({props:{$$slots:{default:[Mm]},$$scope:{ctx:B}}}),ut=new Z({props:{anchor:"transformers.MegatronBertForTokenClassification.forward.example",$$slots:{default:[Tm]},$$scope:{ctx:B}}}),Do=new X({}),Wo=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/main/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/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1755"}}),Go=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/main/en/model_doc/auto#transformers.AutoTokenizer">AutoTokenizer</a>. See <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode">PreTrainedTokenizer.encode()</a> and
<a href="/docs/transformers/main/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/main/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/main/src/transformers/models/megatron_bert/modeling_megatron_bert.py#L1769",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/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/main/en/main_classes/output#transformers.modeling_outputs.QuestionAnsweringModelOutput"
>transformers.modeling_outputs.QuestionAnsweringModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ft=new Se({props:{$$slots:{default:[wm]},$$scope:{ctx:B}}}),_t=new Z({props:{anchor:"transformers.MegatronBertForQuestionAnswering.forward.example",$$slots:{default:[ym]},$$scope:{ctx:B}}}),{c(){d=a("meta"),k=h(),f=a("h1"),p=a("a"),b=a("span"),v(n.$$.fragment),c=h(),F=a("span"),ga=r("MegatronBERT"),Zr=h(),me=a("h2"),Ne=a("a"),Dn=a("span"),v(Ft.$$.fragment),fa=h(),Wn=a("span"),_a=r("Overview"),es=h(),Ie=a("p"),ba=r("The MegatronBERT model was proposed in "),zt=a("a"),ka=r(`Megatron-LM: Training Multi-Billion Parameter Language Models Using Model
Parallelism`),va=r(` by Mohammad Shoeybi, Mostofa Patwary, Raul Puri, Patrick LeGresley,
Jared Casper and Bryan Catanzaro.`),ts=h(),Yo=a("p"),Ma=r("The abstract from the paper is the following:"),os=h(),Xo=a("p"),Rn=a("em"),Ta=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%).`),ns=h(),Zo=a("p"),wa=r("Tips:"),rs=h(),De=a("p"),ya=r("We have provided pretrained "),xt=a("a"),$a=r("BERT-345M"),Ba=r(` checkpoints
for use to evaluate or finetuning downstream tasks.`),ss=h(),te=a("p"),Fa=r("To access these checkpoints, first "),Pt=a("a"),za=r("sign up"),xa=r(` for and setup the NVIDIA GPU Cloud (NGC)
Registry CLI. Further documentation for downloading models can be found in the `),qt=a("a"),Pa=r("NGC documentation"),qa=r("."),as=h(),en=a("p"),Ca=r("Alternatively, you can directly download the checkpoints using:"),is=h(),tn=a("p"),Ea=r("BERT-345M-uncased:"),ls=h(),v(Ct.$$.fragment),ds=h(),on=a("p"),Aa=r("BERT-345M-cased:"),cs=h(),v(Et.$$.fragment),ps=h(),nn=a("p"),ja=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.`),hs=h(),oe=a("p"),Oa=r("The following commands allow you to do the conversion. We assume that the folder "),Hn=a("code"),La=r("models/megatron_bert"),Sa=r(` contains
`),Un=a("code"),Na=r("megatron_bert_345m_v0_1_{cased, uncased}.zip"),Ia=r(" and that the commands are run from inside that folder:"),ms=h(),v(At.$$.fragment),us=h(),v(jt.$$.fragment),gs=h(),ne=a("p"),Da=r("This model was contributed by "),Ot=a("a"),Wa=r("jdemouth"),Ra=r(". The original code can be found "),Lt=a("a"),Ha=r("here"),Ua=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.`),fs=h(),ue=a("h2"),We=a("a"),Gn=a("span"),v(St.$$.fragment),Ga=h(),Qn=a("span"),Qa=r("MegatronBertConfig"),_s=h(),R=a("div"),v(Nt.$$.fragment),Va=h(),ge=a("p"),Ja=r("This is the configuration class to store the configuration of a "),rn=a("a"),Ka=r("MegatronBertModel"),Ya=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
`),It=a("a"),Xa=r("nvidia/megatron-bert-uncased-345m"),Za=r(" architecture."),ei=h(),fe=a("p"),ti=r("Configuration objects inherit from "),sn=a("a"),oi=r("PretrainedConfig"),ni=r(` and can be used to control the model outputs. Read the
documentation from `),an=a("a"),ri=r("PretrainedConfig"),si=r(" for more information."),ai=h(),v(Re.$$.fragment),bs=h(),_e=a("h2"),He=a("a"),Vn=a("span"),v(Dt.$$.fragment),ii=h(),Jn=a("span"),li=r("MegatronBertModel"),ks=h(),z=a("div"),v(Wt.$$.fragment),di=h(),Kn=a("p"),ci=r("The bare MegatronBert Model transformer outputting raw hidden-states without any specific head on top."),pi=h(),Rt=a("p"),hi=r("This model inherits from "),ln=a("a"),mi=r("PreTrainedModel"),ui=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.)`),gi=h(),Ht=a("p"),fi=r("This model is also a PyTorch "),Ut=a("a"),_i=r("torch.nn.Module"),bi=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ki=h(),Gt=a("p"),vi=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 `),Qt=a("a"),Mi=r(`Attention is
all you need`),Ti=r(` by Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit,
Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin.`),wi=h(),P=a("p"),yi=r("To behave as an decoder the model needs to be initialized with the "),Yn=a("code"),$i=r("is_decoder"),Bi=r(` argument of the configuration set
to `),Xn=a("code"),Fi=r("True"),zi=r(". To be used in a Seq2Seq model, the model needs to initialized with both "),Zn=a("code"),xi=r("is_decoder"),Pi=r(` argument and
`),er=a("code"),qi=r("add_cross_attention"),Ci=r(" set to "),tr=a("code"),Ei=r("True"),Ai=r("; an "),or=a("code"),ji=r("encoder_hidden_states"),Oi=r(" is then expected as an input to the forward pass."),Li=h(),H=a("div"),v(Vt.$$.fragment),Si=h(),be=a("p"),Ni=r("The "),dn=a("a"),Ii=r("MegatronBertModel"),Di=r(" forward method, overrides the "),nr=a("code"),Wi=r("__call__"),Ri=r(" special method."),Hi=h(),v(Ue.$$.fragment),Ui=h(),v(Ge.$$.fragment),vs=h(),ke=a("h2"),Qe=a("a"),rr=a("span"),v(Jt.$$.fragment),Gi=h(),sr=a("span"),Qi=r("MegatronBertForMaskedLM"),Ms=h(),q=a("div"),v(Kt.$$.fragment),Vi=h(),Yt=a("p"),Ji=r("MegatronBert Model with a "),ar=a("code"),Ki=r("language modeling"),Yi=r(" head on top."),Xi=h(),Xt=a("p"),Zi=r("This model inherits from "),cn=a("a"),el=r("PreTrainedModel"),tl=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.)`),ol=h(),Zt=a("p"),nl=r("This model is also a PyTorch "),eo=a("a"),rl=r("torch.nn.Module"),sl=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),al=h(),U=a("div"),v(to.$$.fragment),il=h(),ve=a("p"),ll=r("The "),pn=a("a"),dl=r("MegatronBertForMaskedLM"),cl=r(" forward method, overrides the "),ir=a("code"),pl=r("__call__"),hl=r(" special method."),ml=h(),v(Ve.$$.fragment),ul=h(),v(Je.$$.fragment),Ts=h(),Me=a("h2"),Ke=a("a"),lr=a("span"),v(oo.$$.fragment),gl=h(),dr=a("span"),fl=r("MegatronBertForCausalLM"),ws=h(),C=a("div"),v(no.$$.fragment),_l=h(),ro=a("p"),bl=r("MegatronBert Model with a "),cr=a("code"),kl=r("language modeling"),vl=r(" head on top for CLM fine-tuning."),Ml=h(),so=a("p"),Tl=r("This model inherits from "),hn=a("a"),wl=r("PreTrainedModel"),yl=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.)`),$l=h(),ao=a("p"),Bl=r("This model is also a PyTorch "),io=a("a"),Fl=r("torch.nn.Module"),zl=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),xl=h(),G=a("div"),v(lo.$$.fragment),Pl=h(),Te=a("p"),ql=r("The "),mn=a("a"),Cl=r("MegatronBertForCausalLM"),El=r(" forward method, overrides the "),pr=a("code"),Al=r("__call__"),jl=r(" special method."),Ol=h(),v(Ye.$$.fragment),Ll=h(),v(Xe.$$.fragment),ys=h(),we=a("h2"),Ze=a("a"),hr=a("span"),v(co.$$.fragment),Sl=h(),mr=a("span"),Nl=r("MegatronBertForNextSentencePrediction"),$s=h(),E=a("div"),v(po.$$.fragment),Il=h(),ho=a("p"),Dl=r("MegatronBert Model with a "),ur=a("code"),Wl=r("next sentence prediction (classification)"),Rl=r(" head on top."),Hl=h(),mo=a("p"),Ul=r("This model inherits from "),un=a("a"),Gl=r("PreTrainedModel"),Ql=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.)`),Vl=h(),uo=a("p"),Jl=r("This model is also a PyTorch "),go=a("a"),Kl=r("torch.nn.Module"),Yl=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Xl=h(),Q=a("div"),v(fo.$$.fragment),Zl=h(),ye=a("p"),ed=r("The "),gn=a("a"),td=r("MegatronBertForNextSentencePrediction"),od=r(" forward method, overrides the "),gr=a("code"),nd=r("__call__"),rd=r(" special method."),sd=h(),v(et.$$.fragment),ad=h(),v(tt.$$.fragment),Bs=h(),$e=a("h2"),ot=a("a"),fr=a("span"),v(_o.$$.fragment),id=h(),_r=a("span"),ld=r("MegatronBertForPreTraining"),Fs=h(),A=a("div"),v(bo.$$.fragment),dd=h(),Be=a("p"),cd=r("MegatronBert Model with two heads on top as done during the pretraining: a "),br=a("code"),pd=r("masked language modeling"),hd=r(` head and a
`),kr=a("code"),md=r("next sentence prediction (classification)"),ud=r(" head."),gd=h(),ko=a("p"),fd=r("This model inherits from "),fn=a("a"),_d=r("PreTrainedModel"),bd=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.)`),kd=h(),vo=a("p"),vd=r("This model is also a PyTorch "),Mo=a("a"),Md=r("torch.nn.Module"),Td=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),wd=h(),V=a("div"),v(To.$$.fragment),yd=h(),Fe=a("p"),$d=r("The "),_n=a("a"),Bd=r("MegatronBertForPreTraining"),Fd=r(" forward method, overrides the "),vr=a("code"),zd=r("__call__"),xd=r(" special method."),Pd=h(),v(nt.$$.fragment),qd=h(),v(rt.$$.fragment),zs=h(),ze=a("h2"),st=a("a"),Mr=a("span"),v(wo.$$.fragment),Cd=h(),Tr=a("span"),Ed=r("MegatronBertForSequenceClassification"),xs=h(),j=a("div"),v(yo.$$.fragment),Ad=h(),wr=a("p"),jd=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.`),Od=h(),$o=a("p"),Ld=r("This model inherits from "),bn=a("a"),Sd=r("PreTrainedModel"),Nd=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.)`),Id=h(),Bo=a("p"),Dd=r("This model is also a PyTorch "),Fo=a("a"),Wd=r("torch.nn.Module"),Rd=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Hd=h(),I=a("div"),v(zo.$$.fragment),Ud=h(),xe=a("p"),Gd=r("The "),kn=a("a"),Qd=r("MegatronBertForSequenceClassification"),Vd=r(" forward method, overrides the "),yr=a("code"),Jd=r("__call__"),Kd=r(" special method."),Yd=h(),v(at.$$.fragment),Xd=h(),v(it.$$.fragment),Zd=h(),v(lt.$$.fragment),Ps=h(),Pe=a("h2"),dt=a("a"),$r=a("span"),v(xo.$$.fragment),ec=h(),Br=a("span"),tc=r("MegatronBertForMultipleChoice"),qs=h(),O=a("div"),v(Po.$$.fragment),oc=h(),Fr=a("p"),nc=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.`),rc=h(),qo=a("p"),sc=r("This model inherits from "),vn=a("a"),ac=r("PreTrainedModel"),ic=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.)`),lc=h(),Co=a("p"),dc=r("This model is also a PyTorch "),Eo=a("a"),cc=r("torch.nn.Module"),pc=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),hc=h(),J=a("div"),v(Ao.$$.fragment),mc=h(),qe=a("p"),uc=r("The "),Mn=a("a"),gc=r("MegatronBertForMultipleChoice"),fc=r(" forward method, overrides the "),zr=a("code"),_c=r("__call__"),bc=r(" special method."),kc=h(),v(ct.$$.fragment),vc=h(),v(pt.$$.fragment),Cs=h(),Ce=a("h2"),ht=a("a"),xr=a("span"),v(jo.$$.fragment),Mc=h(),Pr=a("span"),Tc=r("MegatronBertForTokenClassification"),Es=h(),L=a("div"),v(Oo.$$.fragment),wc=h(),qr=a("p"),yc=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.`),$c=h(),Lo=a("p"),Bc=r("This model inherits from "),Tn=a("a"),Fc=r("PreTrainedModel"),zc=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.)`),xc=h(),So=a("p"),Pc=r("This model is also a PyTorch "),No=a("a"),qc=r("torch.nn.Module"),Cc=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Ec=h(),K=a("div"),v(Io.$$.fragment),Ac=h(),Ee=a("p"),jc=r("The "),wn=a("a"),Oc=r("MegatronBertForTokenClassification"),Lc=r(" forward method, overrides the "),Cr=a("code"),Sc=r("__call__"),Nc=r(" special method."),Ic=h(),v(mt.$$.fragment),Dc=h(),v(ut.$$.fragment),As=h(),Ae=a("h2"),gt=a("a"),Er=a("span"),v(Do.$$.fragment),Wc=h(),Ar=a("span"),Rc=r("MegatronBertForQuestionAnswering"),js=h(),S=a("div"),v(Wo.$$.fragment),Hc=h(),je=a("p"),Uc=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 `),jr=a("code"),Gc=r("span start logits"),Qc=r(" and "),Or=a("code"),Vc=r("span end logits"),Jc=r(")."),Kc=h(),Ro=a("p"),Yc=r("This model inherits from "),yn=a("a"),Xc=r("PreTrainedModel"),Zc=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.)`),ep=h(),Ho=a("p"),tp=r("This model is also a PyTorch "),Uo=a("a"),op=r("torch.nn.Module"),np=r(` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),rp=h(),Y=a("div"),v(Go.$$.fragment),sp=h(),Oe=a("p"),ap=r("The "),$n=a("a"),ip=r("MegatronBertForQuestionAnswering"),lp=r(" forward method, overrides the "),Lr=a("code"),dp=r("__call__"),cp=r(" special method."),pp=h(),v(ft.$$.fragment),hp=h(),v(_t.$$.fragment),this.h()},l(t){const g=nm('[data-svelte="svelte-1phssyn"]',document.head);d=i(g,"META",{name:!0,content:!0}),g.forEach(o),k=m(t),f=i(t,"H1",{class:!0});var Qo=l(f);p=i(Qo,"A",{id:!0,class:!0,href:!0});var Sr=l(p);b=i(Sr,"SPAN",{});var Nr=l(b);M(n.$$.fragment,Nr),Nr.forEach(o),Sr.forEach(o),c=m(Qo),F=i(Qo,"SPAN",{});var Ir=l(F);ga=s(Ir,"MegatronBERT"),Ir.forEach(o),Qo.forEach(o),Zr=m(t),me=i(t,"H2",{class:!0});var Vo=l(me);Ne=i(Vo,"A",{id:!0,class:!0,href:!0});var Dr=l(Ne);Dn=i(Dr,"SPAN",{});var Wr=l(Dn);M(Ft.$$.fragment,Wr),Wr.forEach(o),Dr.forEach(o),fa=m(Vo),Wn=i(Vo,"SPAN",{});var Rr=l(Wn);_a=s(Rr,"Overview"),Rr.forEach(o),Vo.forEach(o),es=m(t),Ie=i(t,"P",{});var Jo=l(Ie);ba=s(Jo,"The MegatronBERT model was proposed in "),zt=i(Jo,"A",{href:!0,rel:!0});var Hr=l(zt);ka=s(Hr,`Megatron-LM: Training Multi-Billion Parameter Language Models Using Model
Parallelism`),Hr.forEach(o),va=s(Jo,` by Mohammad Shoeybi, Mostofa Patwary, Raul Puri, Patrick LeGresley,
Jared Casper and Bryan Catanzaro.`),Jo.forEach(o),ts=m(t),Yo=i(t,"P",{});var Ur=l(Yo);Ma=s(Ur,"The abstract from the paper is the following:"),Ur.forEach(o),os=m(t),Xo=i(t,"P",{});var Gr=l(Xo);Rn=i(Gr,"EM",{});var Qr=l(Rn);Ta=s(Qr,`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%).`),Qr.forEach(o),Gr.forEach(o),ns=m(t),Zo=i(t,"P",{});var Vr=l(Zo);wa=s(Vr,"Tips:"),Vr.forEach(o),rs=m(t),De=i(t,"P",{});var Ko=l(De);ya=s(Ko,"We have provided pretrained "),xt=i(Ko,"A",{href:!0,rel:!0});var Jr=l(xt);$a=s(Jr,"BERT-345M"),Jr.forEach(o),Ba=s(Ko,` checkpoints
for use to evaluate or finetuning downstream tasks.`),Ko.forEach(o),ss=m(t),te=i(t,"P",{});var Le=l(te);Fa=s(Le,"To access these checkpoints, first "),Pt=i(Le,"A",{href:!0,rel:!0});var Kr=l(Pt);za=s(Kr,"sign up"),Kr.forEach(o),xa=s(Le,` for and setup the NVIDIA GPU Cloud (NGC)
Registry CLI. Further documentation for downloading models can be found in the `),qt=i(Le,"A",{href:!0,rel:!0});var Yr=l(qt);Pa=s(Yr,"NGC documentation"),Yr.forEach(o),qa=s(Le,"."),Le.forEach(o),as=m(t),en=i(t,"P",{});var Xr=l(en);Ca=s(Xr,"Alternatively, you can directly download the checkpoints using:"),Xr.forEach(o),is=m(t),tn=i(t,"P",{});var mp=l(tn);Ea=s(mp,"BERT-345M-uncased:"),mp.forEach(o),ls=m(t),M(Ct.$$.fragment,t),ds=m(t),on=i(t,"P",{});var up=l(on);Aa=s(up,"BERT-345M-cased:"),up.forEach(o),cs=m(t),M(Et.$$.fragment,t),ps=m(t),nn=i(t,"P",{});var gp=l(nn);ja=s(gp,`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.`),gp.forEach(o),hs=m(t),oe=i(t,"P",{});var Bn=l(oe);Oa=s(Bn,"The following commands allow you to do the conversion. We assume that the folder "),Hn=i(Bn,"CODE",{});var fp=l(Hn);La=s(fp,"models/megatron_bert"),fp.forEach(o),Sa=s(Bn,` contains
`),Un=i(Bn,"CODE",{});var _p=l(Un);Na=s(_p,"megatron_bert_345m_v0_1_{cased, uncased}.zip"),_p.forEach(o),Ia=s(Bn," and that the commands are run from inside that folder:"),Bn.forEach(o),ms=m(t),M(At.$$.fragment,t),us=m(t),M(jt.$$.fragment,t),gs=m(t),ne=i(t,"P",{});var Fn=l(ne);Da=s(Fn,"This model was contributed by "),Ot=i(Fn,"A",{href:!0,rel:!0});var bp=l(Ot);Wa=s(bp,"jdemouth"),bp.forEach(o),Ra=s(Fn,". The original code can be found "),Lt=i(Fn,"A",{href:!0,rel:!0});var kp=l(Lt);Ha=s(kp,"here"),kp.forEach(o),Ua=s(Fn,`. 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.`),Fn.forEach(o),fs=m(t),ue=i(t,"H2",{class:!0});var Ls=l(ue);We=i(Ls,"A",{id:!0,class:!0,href:!0});var vp=l(We);Gn=i(vp,"SPAN",{});var Mp=l(Gn);M(St.$$.fragment,Mp),Mp.forEach(o),vp.forEach(o),Ga=m(Ls),Qn=i(Ls,"SPAN",{});var Tp=l(Qn);Qa=s(Tp,"MegatronBertConfig"),Tp.forEach(o),Ls.forEach(o),_s=m(t),R=i(t,"DIV",{class:!0});var bt=l(R);M(Nt.$$.fragment,bt),Va=m(bt),ge=i(bt,"P",{});var zn=l(ge);Ja=s(zn,"This is the configuration class to store the configuration of a "),rn=i(zn,"A",{href:!0});var wp=l(rn);Ka=s(wp,"MegatronBertModel"),wp.forEach(o),Ya=s(zn,`. 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
`),It=i(zn,"A",{href:!0,rel:!0});var yp=l(It);Xa=s(yp,"nvidia/megatron-bert-uncased-345m"),yp.forEach(o),Za=s(zn," architecture."),zn.forEach(o),ei=m(bt),fe=i(bt,"P",{});var xn=l(fe);ti=s(xn,"Configuration objects inherit from "),sn=i(xn,"A",{href:!0});var $p=l(sn);oi=s($p,"PretrainedConfig"),$p.forEach(o),ni=s(xn,` and can be used to control the model outputs. Read the
documentation from `),an=i(xn,"A",{href:!0});var Bp=l(an);ri=s(Bp,"PretrainedConfig"),Bp.forEach(o),si=s(xn," for more information."),xn.forEach(o),ai=m(bt),M(Re.$$.fragment,bt),bt.forEach(o),bs=m(t),_e=i(t,"H2",{class:!0});var Ss=l(_e);He=i(Ss,"A",{id:!0,class:!0,href:!0});var Fp=l(He);Vn=i(Fp,"SPAN",{});var zp=l(Vn);M(Dt.$$.fragment,zp),zp.forEach(o),Fp.forEach(o),ii=m(Ss),Jn=i(Ss,"SPAN",{});var xp=l(Jn);li=s(xp,"MegatronBertModel"),xp.forEach(o),Ss.forEach(o),ks=m(t),z=i(t,"DIV",{class:!0});var D=l(z);M(Wt.$$.fragment,D),di=m(D),Kn=i(D,"P",{});var Pp=l(Kn);ci=s(Pp,"The bare MegatronBert Model transformer outputting raw hidden-states without any specific head on top."),Pp.forEach(o),pi=m(D),Rt=i(D,"P",{});var Ns=l(Rt);hi=s(Ns,"This model inherits from "),ln=i(Ns,"A",{href:!0});var qp=l(ln);mi=s(qp,"PreTrainedModel"),qp.forEach(o),ui=s(Ns,`. 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.)`),Ns.forEach(o),gi=m(D),Ht=i(D,"P",{});var Is=l(Ht);fi=s(Is,"This model is also a PyTorch "),Ut=i(Is,"A",{href:!0,rel:!0});var Cp=l(Ut);_i=s(Cp,"torch.nn.Module"),Cp.forEach(o),bi=s(Is,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Is.forEach(o),ki=m(D),Gt=i(D,"P",{});var Ds=l(Gt);vi=s(Ds,`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 `),Qt=i(Ds,"A",{href:!0,rel:!0});var Ep=l(Qt);Mi=s(Ep,`Attention is
all you need`),Ep.forEach(o),Ti=s(Ds,` by Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit,
Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin.`),Ds.forEach(o),wi=m(D),P=i(D,"P",{});var W=l(P);yi=s(W,"To behave as an decoder the model needs to be initialized with the "),Yn=i(W,"CODE",{});var Ap=l(Yn);$i=s(Ap,"is_decoder"),Ap.forEach(o),Bi=s(W,` argument of the configuration set
to `),Xn=i(W,"CODE",{});var jp=l(Xn);Fi=s(jp,"True"),jp.forEach(o),zi=s(W,". To be used in a Seq2Seq model, the model needs to initialized with both "),Zn=i(W,"CODE",{});var Op=l(Zn);xi=s(Op,"is_decoder"),Op.forEach(o),Pi=s(W,` argument and
`),er=i(W,"CODE",{});var Lp=l(er);qi=s(Lp,"add_cross_attention"),Lp.forEach(o),Ci=s(W," set to "),tr=i(W,"CODE",{});var Sp=l(tr);Ei=s(Sp,"True"),Sp.forEach(o),Ai=s(W,"; an "),or=i(W,"CODE",{});var Np=l(or);ji=s(Np,"encoder_hidden_states"),Np.forEach(o),Oi=s(W," is then expected as an input to the forward pass."),W.forEach(o),Li=m(D),H=i(D,"DIV",{class:!0});var kt=l(H);M(Vt.$$.fragment,kt),Si=m(kt),be=i(kt,"P",{});var Pn=l(be);Ni=s(Pn,"The "),dn=i(Pn,"A",{href:!0});var Ip=l(dn);Ii=s(Ip,"MegatronBertModel"),Ip.forEach(o),Di=s(Pn," forward method, overrides the "),nr=i(Pn,"CODE",{});var Dp=l(nr);Wi=s(Dp,"__call__"),Dp.forEach(o),Ri=s(Pn," special method."),Pn.forEach(o),Hi=m(kt),M(Ue.$$.fragment,kt),Ui=m(kt),M(Ge.$$.fragment,kt),kt.forEach(o),D.forEach(o),vs=m(t),ke=i(t,"H2",{class:!0});var Ws=l(ke);Qe=i(Ws,"A",{id:!0,class:!0,href:!0});var Wp=l(Qe);rr=i(Wp,"SPAN",{});var Rp=l(rr);M(Jt.$$.fragment,Rp),Rp.forEach(o),Wp.forEach(o),Gi=m(Ws),sr=i(Ws,"SPAN",{});var Hp=l(sr);Qi=s(Hp,"MegatronBertForMaskedLM"),Hp.forEach(o),Ws.forEach(o),Ms=m(t),q=i(t,"DIV",{class:!0});var re=l(q);M(Kt.$$.fragment,re),Vi=m(re),Yt=i(re,"P",{});var Rs=l(Yt);Ji=s(Rs,"MegatronBert Model with a "),ar=i(Rs,"CODE",{});var Up=l(ar);Ki=s(Up,"language modeling"),Up.forEach(o),Yi=s(Rs," head on top."),Rs.forEach(o),Xi=m(re),Xt=i(re,"P",{});var Hs=l(Xt);Zi=s(Hs,"This model inherits from "),cn=i(Hs,"A",{href:!0});var Gp=l(cn);el=s(Gp,"PreTrainedModel"),Gp.forEach(o),tl=s(Hs,`. 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.)`),Hs.forEach(o),ol=m(re),Zt=i(re,"P",{});var Us=l(Zt);nl=s(Us,"This model is also a PyTorch "),eo=i(Us,"A",{href:!0,rel:!0});var Qp=l(eo);rl=s(Qp,"torch.nn.Module"),Qp.forEach(o),sl=s(Us,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Us.forEach(o),al=m(re),U=i(re,"DIV",{class:!0});var vt=l(U);M(to.$$.fragment,vt),il=m(vt),ve=i(vt,"P",{});var qn=l(ve);ll=s(qn,"The "),pn=i(qn,"A",{href:!0});var Vp=l(pn);dl=s(Vp,"MegatronBertForMaskedLM"),Vp.forEach(o),cl=s(qn," forward method, overrides the "),ir=i(qn,"CODE",{});var Jp=l(ir);pl=s(Jp,"__call__"),Jp.forEach(o),hl=s(qn," special method."),qn.forEach(o),ml=m(vt),M(Ve.$$.fragment,vt),ul=m(vt),M(Je.$$.fragment,vt),vt.forEach(o),re.forEach(o),Ts=m(t),Me=i(t,"H2",{class:!0});var Gs=l(Me);Ke=i(Gs,"A",{id:!0,class:!0,href:!0});var Kp=l(Ke);lr=i(Kp,"SPAN",{});var Yp=l(lr);M(oo.$$.fragment,Yp),Yp.forEach(o),Kp.forEach(o),gl=m(Gs),dr=i(Gs,"SPAN",{});var Xp=l(dr);fl=s(Xp,"MegatronBertForCausalLM"),Xp.forEach(o),Gs.forEach(o),ws=m(t),C=i(t,"DIV",{class:!0});var se=l(C);M(no.$$.fragment,se),_l=m(se),ro=i(se,"P",{});var Qs=l(ro);bl=s(Qs,"MegatronBert Model with a "),cr=i(Qs,"CODE",{});var Zp=l(cr);kl=s(Zp,"language modeling"),Zp.forEach(o),vl=s(Qs," head on top for CLM fine-tuning."),Qs.forEach(o),Ml=m(se),so=i(se,"P",{});var Vs=l(so);Tl=s(Vs,"This model inherits from "),hn=i(Vs,"A",{href:!0});var eh=l(hn);wl=s(eh,"PreTrainedModel"),eh.forEach(o),yl=s(Vs,`. 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.)`),Vs.forEach(o),$l=m(se),ao=i(se,"P",{});var Js=l(ao);Bl=s(Js,"This model is also a PyTorch "),io=i(Js,"A",{href:!0,rel:!0});var th=l(io);Fl=s(th,"torch.nn.Module"),th.forEach(o),zl=s(Js,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Js.forEach(o),xl=m(se),G=i(se,"DIV",{class:!0});var Mt=l(G);M(lo.$$.fragment,Mt),Pl=m(Mt),Te=i(Mt,"P",{});var Cn=l(Te);ql=s(Cn,"The "),mn=i(Cn,"A",{href:!0});var oh=l(mn);Cl=s(oh,"MegatronBertForCausalLM"),oh.forEach(o),El=s(Cn," forward method, overrides the "),pr=i(Cn,"CODE",{});var nh=l(pr);Al=s(nh,"__call__"),nh.forEach(o),jl=s(Cn," special method."),Cn.forEach(o),Ol=m(Mt),M(Ye.$$.fragment,Mt),Ll=m(Mt),M(Xe.$$.fragment,Mt),Mt.forEach(o),se.forEach(o),ys=m(t),we=i(t,"H2",{class:!0});var Ks=l(we);Ze=i(Ks,"A",{id:!0,class:!0,href:!0});var rh=l(Ze);hr=i(rh,"SPAN",{});var sh=l(hr);M(co.$$.fragment,sh),sh.forEach(o),rh.forEach(o),Sl=m(Ks),mr=i(Ks,"SPAN",{});var ah=l(mr);Nl=s(ah,"MegatronBertForNextSentencePrediction"),ah.forEach(o),Ks.forEach(o),$s=m(t),E=i(t,"DIV",{class:!0});var ae=l(E);M(po.$$.fragment,ae),Il=m(ae),ho=i(ae,"P",{});var Ys=l(ho);Dl=s(Ys,"MegatronBert Model with a "),ur=i(Ys,"CODE",{});var ih=l(ur);Wl=s(ih,"next sentence prediction (classification)"),ih.forEach(o),Rl=s(Ys," head on top."),Ys.forEach(o),Hl=m(ae),mo=i(ae,"P",{});var Xs=l(mo);Ul=s(Xs,"This model inherits from "),un=i(Xs,"A",{href:!0});var lh=l(un);Gl=s(lh,"PreTrainedModel"),lh.forEach(o),Ql=s(Xs,`. 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.)`),Xs.forEach(o),Vl=m(ae),uo=i(ae,"P",{});var Zs=l(uo);Jl=s(Zs,"This model is also a PyTorch "),go=i(Zs,"A",{href:!0,rel:!0});var dh=l(go);Kl=s(dh,"torch.nn.Module"),dh.forEach(o),Yl=s(Zs,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),Zs.forEach(o),Xl=m(ae),Q=i(ae,"DIV",{class:!0});var Tt=l(Q);M(fo.$$.fragment,Tt),Zl=m(Tt),ye=i(Tt,"P",{});var En=l(ye);ed=s(En,"The "),gn=i(En,"A",{href:!0});var ch=l(gn);td=s(ch,"MegatronBertForNextSentencePrediction"),ch.forEach(o),od=s(En," forward method, overrides the "),gr=i(En,"CODE",{});var ph=l(gr);nd=s(ph,"__call__"),ph.forEach(o),rd=s(En," special method."),En.forEach(o),sd=m(Tt),M(et.$$.fragment,Tt),ad=m(Tt),M(tt.$$.fragment,Tt),Tt.forEach(o),ae.forEach(o),Bs=m(t),$e=i(t,"H2",{class:!0});var ea=l($e);ot=i(ea,"A",{id:!0,class:!0,href:!0});var hh=l(ot);fr=i(hh,"SPAN",{});var mh=l(fr);M(_o.$$.fragment,mh),mh.forEach(o),hh.forEach(o),id=m(ea),_r=i(ea,"SPAN",{});var uh=l(_r);ld=s(uh,"MegatronBertForPreTraining"),uh.forEach(o),ea.forEach(o),Fs=m(t),A=i(t,"DIV",{class:!0});var ie=l(A);M(bo.$$.fragment,ie),dd=m(ie),Be=i(ie,"P",{});var An=l(Be);cd=s(An,"MegatronBert Model with two heads on top as done during the pretraining: a "),br=i(An,"CODE",{});var gh=l(br);pd=s(gh,"masked language modeling"),gh.forEach(o),hd=s(An,` head and a
`),kr=i(An,"CODE",{});var fh=l(kr);md=s(fh,"next sentence prediction (classification)"),fh.forEach(o),ud=s(An," head."),An.forEach(o),gd=m(ie),ko=i(ie,"P",{});var ta=l(ko);fd=s(ta,"This model inherits from "),fn=i(ta,"A",{href:!0});var _h=l(fn);_d=s(_h,"PreTrainedModel"),_h.forEach(o),bd=s(ta,`. 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.)`),ta.forEach(o),kd=m(ie),vo=i(ie,"P",{});var oa=l(vo);vd=s(oa,"This model is also a PyTorch "),Mo=i(oa,"A",{href:!0,rel:!0});var bh=l(Mo);Md=s(bh,"torch.nn.Module"),bh.forEach(o),Td=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),wd=m(ie),V=i(ie,"DIV",{class:!0});var wt=l(V);M(To.$$.fragment,wt),yd=m(wt),Fe=i(wt,"P",{});var jn=l(Fe);$d=s(jn,"The "),_n=i(jn,"A",{href:!0});var kh=l(_n);Bd=s(kh,"MegatronBertForPreTraining"),kh.forEach(o),Fd=s(jn," forward method, overrides the "),vr=i(jn,"CODE",{});var vh=l(vr);zd=s(vh,"__call__"),vh.forEach(o),xd=s(jn," special method."),jn.forEach(o),Pd=m(wt),M(nt.$$.fragment,wt),qd=m(wt),M(rt.$$.fragment,wt),wt.forEach(o),ie.forEach(o),zs=m(t),ze=i(t,"H2",{class:!0});var na=l(ze);st=i(na,"A",{id:!0,class:!0,href:!0});var Mh=l(st);Mr=i(Mh,"SPAN",{});var Th=l(Mr);M(wo.$$.fragment,Th),Th.forEach(o),Mh.forEach(o),Cd=m(na),Tr=i(na,"SPAN",{});var wh=l(Tr);Ed=s(wh,"MegatronBertForSequenceClassification"),wh.forEach(o),na.forEach(o),xs=m(t),j=i(t,"DIV",{class:!0});var le=l(j);M(yo.$$.fragment,le),Ad=m(le),wr=i(le,"P",{});var yh=l(wr);jd=s(yh,`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.`),yh.forEach(o),Od=m(le),$o=i(le,"P",{});var ra=l($o);Ld=s(ra,"This model inherits from "),bn=i(ra,"A",{href:!0});var $h=l(bn);Sd=s($h,"PreTrainedModel"),$h.forEach(o),Nd=s(ra,`. 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.)`),ra.forEach(o),Id=m(le),Bo=i(le,"P",{});var sa=l(Bo);Dd=s(sa,"This model is also a PyTorch "),Fo=i(sa,"A",{href:!0,rel:!0});var Bh=l(Fo);Wd=s(Bh,"torch.nn.Module"),Bh.forEach(o),Rd=s(sa,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),sa.forEach(o),Hd=m(le),I=i(le,"DIV",{class:!0});var de=l(I);M(zo.$$.fragment,de),Ud=m(de),xe=i(de,"P",{});var On=l(xe);Gd=s(On,"The "),kn=i(On,"A",{href:!0});var Fh=l(kn);Qd=s(Fh,"MegatronBertForSequenceClassification"),Fh.forEach(o),Vd=s(On," forward method, overrides the "),yr=i(On,"CODE",{});var zh=l(yr);Jd=s(zh,"__call__"),zh.forEach(o),Kd=s(On," special method."),On.forEach(o),Yd=m(de),M(at.$$.fragment,de),Xd=m(de),M(it.$$.fragment,de),Zd=m(de),M(lt.$$.fragment,de),de.forEach(o),le.forEach(o),Ps=m(t),Pe=i(t,"H2",{class:!0});var aa=l(Pe);dt=i(aa,"A",{id:!0,class:!0,href:!0});var xh=l(dt);$r=i(xh,"SPAN",{});var Ph=l($r);M(xo.$$.fragment,Ph),Ph.forEach(o),xh.forEach(o),ec=m(aa),Br=i(aa,"SPAN",{});var qh=l(Br);tc=s(qh,"MegatronBertForMultipleChoice"),qh.forEach(o),aa.forEach(o),qs=m(t),O=i(t,"DIV",{class:!0});var ce=l(O);M(Po.$$.fragment,ce),oc=m(ce),Fr=i(ce,"P",{});var Ch=l(Fr);nc=s(Ch,`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.`),Ch.forEach(o),rc=m(ce),qo=i(ce,"P",{});var ia=l(qo);sc=s(ia,"This model inherits from "),vn=i(ia,"A",{href:!0});var Eh=l(vn);ac=s(Eh,"PreTrainedModel"),Eh.forEach(o),ic=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),lc=m(ce),Co=i(ce,"P",{});var la=l(Co);dc=s(la,"This model is also a PyTorch "),Eo=i(la,"A",{href:!0,rel:!0});var Ah=l(Eo);cc=s(Ah,"torch.nn.Module"),Ah.forEach(o),pc=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),hc=m(ce),J=i(ce,"DIV",{class:!0});var yt=l(J);M(Ao.$$.fragment,yt),mc=m(yt),qe=i(yt,"P",{});var Ln=l(qe);uc=s(Ln,"The "),Mn=i(Ln,"A",{href:!0});var jh=l(Mn);gc=s(jh,"MegatronBertForMultipleChoice"),jh.forEach(o),fc=s(Ln," forward method, overrides the "),zr=i(Ln,"CODE",{});var Oh=l(zr);_c=s(Oh,"__call__"),Oh.forEach(o),bc=s(Ln," special method."),Ln.forEach(o),kc=m(yt),M(ct.$$.fragment,yt),vc=m(yt),M(pt.$$.fragment,yt),yt.forEach(o),ce.forEach(o),Cs=m(t),Ce=i(t,"H2",{class:!0});var da=l(Ce);ht=i(da,"A",{id:!0,class:!0,href:!0});var Lh=l(ht);xr=i(Lh,"SPAN",{});var Sh=l(xr);M(jo.$$.fragment,Sh),Sh.forEach(o),Lh.forEach(o),Mc=m(da),Pr=i(da,"SPAN",{});var Nh=l(Pr);Tc=s(Nh,"MegatronBertForTokenClassification"),Nh.forEach(o),da.forEach(o),Es=m(t),L=i(t,"DIV",{class:!0});var pe=l(L);M(Oo.$$.fragment,pe),wc=m(pe),qr=i(pe,"P",{});var Ih=l(qr);yc=s(Ih,`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.`),Ih.forEach(o),$c=m(pe),Lo=i(pe,"P",{});var ca=l(Lo);Bc=s(ca,"This model inherits from "),Tn=i(ca,"A",{href:!0});var Dh=l(Tn);Fc=s(Dh,"PreTrainedModel"),Dh.forEach(o),zc=s(ca,`. 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.)`),ca.forEach(o),xc=m(pe),So=i(pe,"P",{});var pa=l(So);Pc=s(pa,"This model is also a PyTorch "),No=i(pa,"A",{href:!0,rel:!0});var Wh=l(No);qc=s(Wh,"torch.nn.Module"),Wh.forEach(o),Cc=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),Ec=m(pe),K=i(pe,"DIV",{class:!0});var $t=l(K);M(Io.$$.fragment,$t),Ac=m($t),Ee=i($t,"P",{});var Sn=l(Ee);jc=s(Sn,"The "),wn=i(Sn,"A",{href:!0});var Rh=l(wn);Oc=s(Rh,"MegatronBertForTokenClassification"),Rh.forEach(o),Lc=s(Sn," forward method, overrides the "),Cr=i(Sn,"CODE",{});var Hh=l(Cr);Sc=s(Hh,"__call__"),Hh.forEach(o),Nc=s(Sn," special method."),Sn.forEach(o),Ic=m($t),M(mt.$$.fragment,$t),Dc=m($t),M(ut.$$.fragment,$t),$t.forEach(o),pe.forEach(o),As=m(t),Ae=i(t,"H2",{class:!0});var ha=l(Ae);gt=i(ha,"A",{id:!0,class:!0,href:!0});var Uh=l(gt);Er=i(Uh,"SPAN",{});var Gh=l(Er);M(Do.$$.fragment,Gh),Gh.forEach(o),Uh.forEach(o),Wc=m(ha),Ar=i(ha,"SPAN",{});var Qh=l(Ar);Rc=s(Qh,"MegatronBertForQuestionAnswering"),Qh.forEach(o),ha.forEach(o),js=m(t),S=i(t,"DIV",{class:!0});var he=l(S);M(Wo.$$.fragment,he),Hc=m(he),je=i(he,"P",{});var Nn=l(je);Uc=s(Nn,`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 `),jr=i(Nn,"CODE",{});var Vh=l(jr);Gc=s(Vh,"span start logits"),Vh.forEach(o),Qc=s(Nn," and "),Or=i(Nn,"CODE",{});var Jh=l(Or);Vc=s(Jh,"span end logits"),Jh.forEach(o),Jc=s(Nn,")."),Nn.forEach(o),Kc=m(he),Ro=i(he,"P",{});var ma=l(Ro);Yc=s(ma,"This model inherits from "),yn=i(ma,"A",{href:!0});var Kh=l(yn);Xc=s(Kh,"PreTrainedModel"),Kh.forEach(o),Zc=s(ma,`. 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.)`),ma.forEach(o),ep=m(he),Ho=i(he,"P",{});var ua=l(Ho);tp=s(ua,"This model is also a PyTorch "),Uo=i(ua,"A",{href:!0,rel:!0});var Yh=l(Uo);op=s(Yh,"torch.nn.Module"),Yh.forEach(o),np=s(ua,` subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`),ua.forEach(o),rp=m(he),Y=i(he,"DIV",{class:!0});var Bt=l(Y);M(Go.$$.fragment,Bt),sp=m(Bt),Oe=i(Bt,"P",{});var In=l(Oe);ap=s(In,"The "),$n=i(In,"A",{href:!0});var Xh=l($n);ip=s(Xh,"MegatronBertForQuestionAnswering"),Xh.forEach(o),lp=s(In," forward method, overrides the "),Lr=i(In,"CODE",{});var Zh=l(Lr);dp=s(Zh,"__call__"),Zh.forEach(o),cp=s(In," special method."),In.forEach(o),pp=m(Bt),M(ft.$$.fragment,Bt),hp=m(Bt),M(_t.$$.fragment,Bt),Bt.forEach(o),he.forEach(o),this.h()},h(){u(d,"name","hf:doc:metadata"),u(d,"content",JSON.stringify(Bm)),u(p,"id","megatronbert"),u(p,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(p,"href","#megatronbert"),u(f,"class","relative group"),u(Ne,"id","overview"),u(Ne,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Ne,"href","#overview"),u(me,"class","relative group"),u(zt,"href","https://arxiv.org/abs/1909.08053"),u(zt,"rel","nofollow"),u(xt,"href","https://ngc.nvidia.com/catalog/models/nvidia:megatron_bert_345m"),u(xt,"rel","nofollow"),u(Pt,"href","https://ngc.nvidia.com/signup"),u(Pt,"rel","nofollow"),u(qt,"href","https://docs.nvidia.com/dgx/ngc-registry-cli-user-guide/index.html#topic_6_4_1"),u(qt,"rel","nofollow"),u(Ot,"href","https://huggingface.co/jdemouth"),u(Ot,"rel","nofollow"),u(Lt,"href","https://github.com/NVIDIA/Megatron-LM"),u(Lt,"rel","nofollow"),u(We,"id","transformers.MegatronBertConfig"),u(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"),u(We,"href","#transformers.MegatronBertConfig"),u(ue,"class","relative group"),u(rn,"href","/docs/transformers/main/en/model_doc/megatron-bert#transformers.MegatronBertModel"),u(It,"href","https://huggingface.co/nvidia/megatron-bert-uncased-345m"),u(It,"rel","nofollow"),u(sn,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),u(an,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),u(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(He,"id","transformers.MegatronBertModel"),u(He,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(He,"href","#transformers.MegatronBertModel"),u(_e,"class","relative group"),u(ln,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),u(Ut,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Ut,"rel","nofollow"),u(Qt,"href","https://arxiv.org/abs/1706.03762"),u(Qt,"rel","nofollow"),u(dn,"href","/docs/transformers/main/en/model_doc/megatron-bert#transformers.MegatronBertModel"),u(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Qe,"id","transformers.MegatronBertForMaskedLM"),u(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"),u(Qe,"href","#transformers.MegatronBertForMaskedLM"),u(ke,"class","relative group"),u(cn,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),u(eo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(eo,"rel","nofollow"),u(pn,"href","/docs/transformers/main/en/model_doc/megatron-bert#transformers.MegatronBertForMaskedLM"),u(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Ke,"id","transformers.MegatronBertForCausalLM"),u(Ke,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Ke,"href","#transformers.MegatronBertForCausalLM"),u(Me,"class","relative group"),u(hn,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),u(io,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(io,"rel","nofollow"),u(mn,"href","/docs/transformers/main/en/model_doc/megatron-bert#transformers.MegatronBertForCausalLM"),u(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Ze,"id","transformers.MegatronBertForNextSentencePrediction"),u(Ze,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Ze,"href","#transformers.MegatronBertForNextSentencePrediction"),u(we,"class","relative group"),u(un,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),u(go,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(go,"rel","nofollow"),u(gn,"href","/docs/transformers/main/en/model_doc/megatron-bert#transformers.MegatronBertForNextSentencePrediction"),u(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(ot,"id","transformers.MegatronBertForPreTraining"),u(ot,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(ot,"href","#transformers.MegatronBertForPreTraining"),u($e,"class","relative group"),u(fn,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),u(Mo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Mo,"rel","nofollow"),u(_n,"href","/docs/transformers/main/en/model_doc/megatron-bert#transformers.MegatronBertForPreTraining"),u(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(st,"id","transformers.MegatronBertForSequenceClassification"),u(st,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(st,"href","#transformers.MegatronBertForSequenceClassification"),u(ze,"class","relative group"),u(bn,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),u(Fo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Fo,"rel","nofollow"),u(kn,"href","/docs/transformers/main/en/model_doc/megatron-bert#transformers.MegatronBertForSequenceClassification"),u(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(dt,"id","transformers.MegatronBertForMultipleChoice"),u(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"),u(dt,"href","#transformers.MegatronBertForMultipleChoice"),u(Pe,"class","relative group"),u(vn,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),u(Eo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Eo,"rel","nofollow"),u(Mn,"href","/docs/transformers/main/en/model_doc/megatron-bert#transformers.MegatronBertForMultipleChoice"),u(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(ht,"id","transformers.MegatronBertForTokenClassification"),u(ht,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(ht,"href","#transformers.MegatronBertForTokenClassification"),u(Ce,"class","relative group"),u(Tn,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),u(No,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(No,"rel","nofollow"),u(wn,"href","/docs/transformers/main/en/model_doc/megatron-bert#transformers.MegatronBertForTokenClassification"),u(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(gt,"id","transformers.MegatronBertForQuestionAnswering"),u(gt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(gt,"href","#transformers.MegatronBertForQuestionAnswering"),u(Ae,"class","relative group"),u(yn,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),u(Uo,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),u(Uo,"rel","nofollow"),u($n,"href","/docs/transformers/main/en/model_doc/megatron-bert#transformers.MegatronBertForQuestionAnswering"),u(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(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(t,g){e(document.head,d),_(t,k,g),_(t,f,g),e(f,p),e(p,b),T(n,b,null),e(f,c),e(f,F),e(F,ga),_(t,Zr,g),_(t,me,g),e(me,Ne),e(Ne,Dn),T(Ft,Dn,null),e(me,fa),e(me,Wn),e(Wn,_a),_(t,es,g),_(t,Ie,g),e(Ie,ba),e(Ie,zt),e(zt,ka),e(Ie,va),_(t,ts,g),_(t,Yo,g),e(Yo,Ma),_(t,os,g),_(t,Xo,g),e(Xo,Rn),e(Rn,Ta),_(t,ns,g),_(t,Zo,g),e(Zo,wa),_(t,rs,g),_(t,De,g),e(De,ya),e(De,xt),e(xt,$a),e(De,Ba),_(t,ss,g),_(t,te,g),e(te,Fa),e(te,Pt),e(Pt,za),e(te,xa),e(te,qt),e(qt,Pa),e(te,qa),_(t,as,g),_(t,en,g),e(en,Ca),_(t,is,g),_(t,tn,g),e(tn,Ea),_(t,ls,g),T(Ct,t,g),_(t,ds,g),_(t,on,g),e(on,Aa),_(t,cs,g),T(Et,t,g),_(t,ps,g),_(t,nn,g),e(nn,ja),_(t,hs,g),_(t,oe,g),e(oe,Oa),e(oe,Hn),e(Hn,La),e(oe,Sa),e(oe,Un),e(Un,Na),e(oe,Ia),_(t,ms,g),T(At,t,g),_(t,us,g),T(jt,t,g),_(t,gs,g),_(t,ne,g),e(ne,Da),e(ne,Ot),e(Ot,Wa),e(ne,Ra),e(ne,Lt),e(Lt,Ha),e(ne,Ua),_(t,fs,g),_(t,ue,g),e(ue,We),e(We,Gn),T(St,Gn,null),e(ue,Ga),e(ue,Qn),e(Qn,Qa),_(t,_s,g),_(t,R,g),T(Nt,R,null),e(R,Va),e(R,ge),e(ge,Ja),e(ge,rn),e(rn,Ka),e(ge,Ya),e(ge,It),e(It,Xa),e(ge,Za),e(R,ei),e(R,fe),e(fe,ti),e(fe,sn),e(sn,oi),e(fe,ni),e(fe,an),e(an,ri),e(fe,si),e(R,ai),T(Re,R,null),_(t,bs,g),_(t,_e,g),e(_e,He),e(He,Vn),T(Dt,Vn,null),e(_e,ii),e(_e,Jn),e(Jn,li),_(t,ks,g),_(t,z,g),T(Wt,z,null),e(z,di),e(z,Kn),e(Kn,ci),e(z,pi),e(z,Rt),e(Rt,hi),e(Rt,ln),e(ln,mi),e(Rt,ui),e(z,gi),e(z,Ht),e(Ht,fi),e(Ht,Ut),e(Ut,_i),e(Ht,bi),e(z,ki),e(z,Gt),e(Gt,vi),e(Gt,Qt),e(Qt,Mi),e(Gt,Ti),e(z,wi),e(z,P),e(P,yi),e(P,Yn),e(Yn,$i),e(P,Bi),e(P,Xn),e(Xn,Fi),e(P,zi),e(P,Zn),e(Zn,xi),e(P,Pi),e(P,er),e(er,qi),e(P,Ci),e(P,tr),e(tr,Ei),e(P,Ai),e(P,or),e(or,ji),e(P,Oi),e(z,Li),e(z,H),T(Vt,H,null),e(H,Si),e(H,be),e(be,Ni),e(be,dn),e(dn,Ii),e(be,Di),e(be,nr),e(nr,Wi),e(be,Ri),e(H,Hi),T(Ue,H,null),e(H,Ui),T(Ge,H,null),_(t,vs,g),_(t,ke,g),e(ke,Qe),e(Qe,rr),T(Jt,rr,null),e(ke,Gi),e(ke,sr),e(sr,Qi),_(t,Ms,g),_(t,q,g),T(Kt,q,null),e(q,Vi),e(q,Yt),e(Yt,Ji),e(Yt,ar),e(ar,Ki),e(Yt,Yi),e(q,Xi),e(q,Xt),e(Xt,Zi),e(Xt,cn),e(cn,el),e(Xt,tl),e(q,ol),e(q,Zt),e(Zt,nl),e(Zt,eo),e(eo,rl),e(Zt,sl),e(q,al),e(q,U),T(to,U,null),e(U,il),e(U,ve),e(ve,ll),e(ve,pn),e(pn,dl),e(ve,cl),e(ve,ir),e(ir,pl),e(ve,hl),e(U,ml),T(Ve,U,null),e(U,ul),T(Je,U,null),_(t,Ts,g),_(t,Me,g),e(Me,Ke),e(Ke,lr),T(oo,lr,null),e(Me,gl),e(Me,dr),e(dr,fl),_(t,ws,g),_(t,C,g),T(no,C,null),e(C,_l),e(C,ro),e(ro,bl),e(ro,cr),e(cr,kl),e(ro,vl),e(C,Ml),e(C,so),e(so,Tl),e(so,hn),e(hn,wl),e(so,yl),e(C,$l),e(C,ao),e(ao,Bl),e(ao,io),e(io,Fl),e(ao,zl),e(C,xl),e(C,G),T(lo,G,null),e(G,Pl),e(G,Te),e(Te,ql),e(Te,mn),e(mn,Cl),e(Te,El),e(Te,pr),e(pr,Al),e(Te,jl),e(G,Ol),T(Ye,G,null),e(G,Ll),T(Xe,G,null),_(t,ys,g),_(t,we,g),e(we,Ze),e(Ze,hr),T(co,hr,null),e(we,Sl),e(we,mr),e(mr,Nl),_(t,$s,g),_(t,E,g),T(po,E,null),e(E,Il),e(E,ho),e(ho,Dl),e(ho,ur),e(ur,Wl),e(ho,Rl),e(E,Hl),e(E,mo),e(mo,Ul),e(mo,un),e(un,Gl),e(mo,Ql),e(E,Vl),e(E,uo),e(uo,Jl),e(uo,go),e(go,Kl),e(uo,Yl),e(E,Xl),e(E,Q),T(fo,Q,null),e(Q,Zl),e(Q,ye),e(ye,ed),e(ye,gn),e(gn,td),e(ye,od),e(ye,gr),e(gr,nd),e(ye,rd),e(Q,sd),T(et,Q,null),e(Q,ad),T(tt,Q,null),_(t,Bs,g),_(t,$e,g),e($e,ot),e(ot,fr),T(_o,fr,null),e($e,id),e($e,_r),e(_r,ld),_(t,Fs,g),_(t,A,g),T(bo,A,null),e(A,dd),e(A,Be),e(Be,cd),e(Be,br),e(br,pd),e(Be,hd),e(Be,kr),e(kr,md),e(Be,ud),e(A,gd),e(A,ko),e(ko,fd),e(ko,fn),e(fn,_d),e(ko,bd),e(A,kd),e(A,vo),e(vo,vd),e(vo,Mo),e(Mo,Md),e(vo,Td),e(A,wd),e(A,V),T(To,V,null),e(V,yd),e(V,Fe),e(Fe,$d),e(Fe,_n),e(_n,Bd),e(Fe,Fd),e(Fe,vr),e(vr,zd),e(Fe,xd),e(V,Pd),T(nt,V,null),e(V,qd),T(rt,V,null),_(t,zs,g),_(t,ze,g),e(ze,st),e(st,Mr),T(wo,Mr,null),e(ze,Cd),e(ze,Tr),e(Tr,Ed),_(t,xs,g),_(t,j,g),T(yo,j,null),e(j,Ad),e(j,wr),e(wr,jd),e(j,Od),e(j,$o),e($o,Ld),e($o,bn),e(bn,Sd),e($o,Nd),e(j,Id),e(j,Bo),e(Bo,Dd),e(Bo,Fo),e(Fo,Wd),e(Bo,Rd),e(j,Hd),e(j,I),T(zo,I,null),e(I,Ud),e(I,xe),e(xe,Gd),e(xe,kn),e(kn,Qd),e(xe,Vd),e(xe,yr),e(yr,Jd),e(xe,Kd),e(I,Yd),T(at,I,null),e(I,Xd),T(it,I,null),e(I,Zd),T(lt,I,null),_(t,Ps,g),_(t,Pe,g),e(Pe,dt),e(dt,$r),T(xo,$r,null),e(Pe,ec),e(Pe,Br),e(Br,tc),_(t,qs,g),_(t,O,g),T(Po,O,null),e(O,oc),e(O,Fr),e(Fr,nc),e(O,rc),e(O,qo),e(qo,sc),e(qo,vn),e(vn,ac),e(qo,ic),e(O,lc),e(O,Co),e(Co,dc),e(Co,Eo),e(Eo,cc),e(Co,pc),e(O,hc),e(O,J),T(Ao,J,null),e(J,mc),e(J,qe),e(qe,uc),e(qe,Mn),e(Mn,gc),e(qe,fc),e(qe,zr),e(zr,_c),e(qe,bc),e(J,kc),T(ct,J,null),e(J,vc),T(pt,J,null),_(t,Cs,g),_(t,Ce,g),e(Ce,ht),e(ht,xr),T(jo,xr,null),e(Ce,Mc),e(Ce,Pr),e(Pr,Tc),_(t,Es,g),_(t,L,g),T(Oo,L,null),e(L,wc),e(L,qr),e(qr,yc),e(L,$c),e(L,Lo),e(Lo,Bc),e(Lo,Tn),e(Tn,Fc),e(Lo,zc),e(L,xc),e(L,So),e(So,Pc),e(So,No),e(No,qc),e(So,Cc),e(L,Ec),e(L,K),T(Io,K,null),e(K,Ac),e(K,Ee),e(Ee,jc),e(Ee,wn),e(wn,Oc),e(Ee,Lc),e(Ee,Cr),e(Cr,Sc),e(Ee,Nc),e(K,Ic),T(mt,K,null),e(K,Dc),T(ut,K,null),_(t,As,g),_(t,Ae,g),e(Ae,gt),e(gt,Er),T(Do,Er,null),e(Ae,Wc),e(Ae,Ar),e(Ar,Rc),_(t,js,g),_(t,S,g),T(Wo,S,null),e(S,Hc),e(S,je),e(je,Uc),e(je,jr),e(jr,Gc),e(je,Qc),e(je,Or),e(Or,Vc),e(je,Jc),e(S,Kc),e(S,Ro),e(Ro,Yc),e(Ro,yn),e(yn,Xc),e(Ro,Zc),e(S,ep),e(S,Ho),e(Ho,tp),e(Ho,Uo),e(Uo,op),e(Ho,np),e(S,rp),e(S,Y),T(Go,Y,null),e(Y,sp),e(Y,Oe),e(Oe,ap),e(Oe,$n),e($n,ip),e(Oe,lp),e(Oe,Lr),e(Lr,dp),e(Oe,cp),e(Y,pp),T(ft,Y,null),e(Y,hp),T(_t,Y,null),Os=!0},p(t,[g]){const Qo={};g&2&&(Qo.$$scope={dirty:g,ctx:t}),Re.$set(Qo);const Sr={};g&2&&(Sr.$$scope={dirty:g,ctx:t}),Ue.$set(Sr);const Nr={};g&2&&(Nr.$$scope={dirty:g,ctx:t}),Ge.$set(Nr);const Ir={};g&2&&(Ir.$$scope={dirty:g,ctx:t}),Ve.$set(Ir);const Vo={};g&2&&(Vo.$$scope={dirty:g,ctx:t}),Je.$set(Vo);const Dr={};g&2&&(Dr.$$scope={dirty:g,ctx:t}),Ye.$set(Dr);const Wr={};g&2&&(Wr.$$scope={dirty:g,ctx:t}),Xe.$set(Wr);const Rr={};g&2&&(Rr.$$scope={dirty:g,ctx:t}),et.$set(Rr);const Jo={};g&2&&(Jo.$$scope={dirty:g,ctx:t}),tt.$set(Jo);const Hr={};g&2&&(Hr.$$scope={dirty:g,ctx:t}),nt.$set(Hr);const Ur={};g&2&&(Ur.$$scope={dirty:g,ctx:t}),rt.$set(Ur);const Gr={};g&2&&(Gr.$$scope={dirty:g,ctx:t}),at.$set(Gr);const Qr={};g&2&&(Qr.$$scope={dirty:g,ctx:t}),it.$set(Qr);const Vr={};g&2&&(Vr.$$scope={dirty:g,ctx:t}),lt.$set(Vr);const Ko={};g&2&&(Ko.$$scope={dirty:g,ctx:t}),ct.$set(Ko);const Jr={};g&2&&(Jr.$$scope={dirty:g,ctx:t}),pt.$set(Jr);const Le={};g&2&&(Le.$$scope={dirty:g,ctx:t}),mt.$set(Le);const Kr={};g&2&&(Kr.$$scope={dirty:g,ctx:t}),ut.$set(Kr);const Yr={};g&2&&(Yr.$$scope={dirty:g,ctx:t}),ft.$set(Yr);const Xr={};g&2&&(Xr.$$scope={dirty:g,ctx:t}),_t.$set(Xr)},i(t){Os||(w(n.$$.fragment,t),w(Ft.$$.fragment,t),w(Ct.$$.fragment,t),w(Et.$$.fragment,t),w(At.$$.fragment,t),w(jt.$$.fragment,t),w(St.$$.fragment,t),w(Nt.$$.fragment,t),w(Re.$$.fragment,t),w(Dt.$$.fragment,t),w(Wt.$$.fragment,t),w(Vt.$$.fragment,t),w(Ue.$$.fragment,t),w(Ge.$$.fragment,t),w(Jt.$$.fragment,t),w(Kt.$$.fragment,t),w(to.$$.fragment,t),w(Ve.$$.fragment,t),w(Je.$$.fragment,t),w(oo.$$.fragment,t),w(no.$$.fragment,t),w(lo.$$.fragment,t),w(Ye.$$.fragment,t),w(Xe.$$.fragment,t),w(co.$$.fragment,t),w(po.$$.fragment,t),w(fo.$$.fragment,t),w(et.$$.fragment,t),w(tt.$$.fragment,t),w(_o.$$.fragment,t),w(bo.$$.fragment,t),w(To.$$.fragment,t),w(nt.$$.fragment,t),w(rt.$$.fragment,t),w(wo.$$.fragment,t),w(yo.$$.fragment,t),w(zo.$$.fragment,t),w(at.$$.fragment,t),w(it.$$.fragment,t),w(lt.$$.fragment,t),w(xo.$$.fragment,t),w(Po.$$.fragment,t),w(Ao.$$.fragment,t),w(ct.$$.fragment,t),w(pt.$$.fragment,t),w(jo.$$.fragment,t),w(Oo.$$.fragment,t),w(Io.$$.fragment,t),w(mt.$$.fragment,t),w(ut.$$.fragment,t),w(Do.$$.fragment,t),w(Wo.$$.fragment,t),w(Go.$$.fragment,t),w(ft.$$.fragment,t),w(_t.$$.fragment,t),Os=!0)},o(t){y(n.$$.fragment,t),y(Ft.$$.fragment,t),y(Ct.$$.fragment,t),y(Et.$$.fragment,t),y(At.$$.fragment,t),y(jt.$$.fragment,t),y(St.$$.fragment,t),y(Nt.$$.fragment,t),y(Re.$$.fragment,t),y(Dt.$$.fragment,t),y(Wt.$$.fragment,t),y(Vt.$$.fragment,t),y(Ue.$$.fragment,t),y(Ge.$$.fragment,t),y(Jt.$$.fragment,t),y(Kt.$$.fragment,t),y(to.$$.fragment,t),y(Ve.$$.fragment,t),y(Je.$$.fragment,t),y(oo.$$.fragment,t),y(no.$$.fragment,t),y(lo.$$.fragment,t),y(Ye.$$.fragment,t),y(Xe.$$.fragment,t),y(co.$$.fragment,t),y(po.$$.fragment,t),y(fo.$$.fragment,t),y(et.$$.fragment,t),y(tt.$$.fragment,t),y(_o.$$.fragment,t),y(bo.$$.fragment,t),y(To.$$.fragment,t),y(nt.$$.fragment,t),y(rt.$$.fragment,t),y(wo.$$.fragment,t),y(yo.$$.fragment,t),y(zo.$$.fragment,t),y(at.$$.fragment,t),y(it.$$.fragment,t),y(lt.$$.fragment,t),y(xo.$$.fragment,t),y(Po.$$.fragment,t),y(Ao.$$.fragment,t),y(ct.$$.fragment,t),y(pt.$$.fragment,t),y(jo.$$.fragment,t),y(Oo.$$.fragment,t),y(Io.$$.fragment,t),y(mt.$$.fragment,t),y(ut.$$.fragment,t),y(Do.$$.fragment,t),y(Wo.$$.fragment,t),y(Go.$$.fragment,t),y(ft.$$.fragment,t),y(_t.$$.fragment,t),Os=!1},d(t){o(d),t&&o(k),t&&o(f),$(n),t&&o(Zr),t&&o(me),$(Ft),t&&o(es),t&&o(Ie),t&&o(ts),t&&o(Yo),t&&o(os),t&&o(Xo),t&&o(ns),t&&o(Zo),t&&o(rs),t&&o(De),t&&o(ss),t&&o(te),t&&o(as),t&&o(en),t&&o(is),t&&o(tn),t&&o(ls),$(Ct,t),t&&o(ds),t&&o(on),t&&o(cs),$(Et,t),t&&o(ps),t&&o(nn),t&&o(hs),t&&o(oe),t&&o(ms),$(At,t),t&&o(us),$(jt,t),t&&o(gs),t&&o(ne),t&&o(fs),t&&o(ue),$(St),t&&o(_s),t&&o(R),$(Nt),$(Re),t&&o(bs),t&&o(_e),$(Dt),t&&o(ks),t&&o(z),$(Wt),$(Vt),$(Ue),$(Ge),t&&o(vs),t&&o(ke),$(Jt),t&&o(Ms),t&&o(q),$(Kt),$(to),$(Ve),$(Je),t&&o(Ts),t&&o(Me),$(oo),t&&o(ws),t&&o(C),$(no),$(lo),$(Ye),$(Xe),t&&o(ys),t&&o(we),$(co),t&&o($s),t&&o(E),$(po),$(fo),$(et),$(tt),t&&o(Bs),t&&o($e),$(_o),t&&o(Fs),t&&o(A),$(bo),$(To),$(nt),$(rt),t&&o(zs),t&&o(ze),$(wo),t&&o(xs),t&&o(j),$(yo),$(zo),$(at),$(it),$(lt),t&&o(Ps),t&&o(Pe),$(xo),t&&o(qs),t&&o(O),$(Po),$(Ao),$(ct),$(pt),t&&o(Cs),t&&o(Ce),$(jo),t&&o(Es),t&&o(L),$(Oo),$(Io),$(mt),$(ut),t&&o(As),t&&o(Ae),$(Do),t&&o(js),t&&o(S),$(Wo),$(Go),$(ft),$(_t)}}}const Bm={local:"megatronbert",sections:[{local:"overview",title:"Overview"},{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 Fm(B){return rm(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Am extends em{constructor(d){super();tm(this,d,Fm,$m,om,{})}}export{Am as default,Bm as metadata};
