import{S as oa,i as na,s as aa,e as n,k as h,w as k,t as s,M as ra,c as a,d as o,m as u,a as r,x as y,h as i,b as l,G as t,g as f,y as T,q as w,o as $,B,v as sa,L as mn}from"../../chunks/vendor-hf-doc-builder.js";import{T as ta}from"../../chunks/Tip-hf-doc-builder.js";import{D as Pe}from"../../chunks/Docstring-hf-doc-builder.js";import{C as fn}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Ke}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as un}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function ia(z){let c,b;return c=new fn({props:{code:`from transformers import BioGptModel, BioGptConfig

# Initializing a BioGPT microsoft/biogpt style configuration
configuration = BioGptConfig()

# Initializing a model from the microsoft/biogpt style configuration
model = BioGptModel(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> BioGptModel, BioGptConfig

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a BioGPT microsoft/biogpt style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = BioGptConfig()

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

tokenizer = AutoTokenizer.from_pretrained("microsoft/biogpt")
model = BioGptModel.from_pretrained("microsoft/biogpt")

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, BioGptModel
<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;microsoft/biogpt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = BioGptModel.from_pretrained(<span class="hljs-string">&quot;microsoft/biogpt&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(){c=n("p"),b=s("Example:"),m=h(),k(g.$$.fragment)},l(d){c=a(d,"P",{});var _=r(c);b=i(_,"Example:"),_.forEach(o),m=u(d),y(g.$$.fragment,d)},m(d,_){f(d,c,_),t(c,b),f(d,m,_),T(g,d,_),v=!0},p:mn,i(d){v||(w(g.$$.fragment,d),v=!0)},o(d){$(g.$$.fragment,d),v=!1},d(d){d&&o(c),d&&o(m),B(g,d)}}}function ca(z){let c,b,m,g,v;return{c(){c=n("p"),b=s("Although the recipe for forward pass needs to be defined within this function, one should call the "),m=n("code"),g=s("Module"),v=s(`
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(d){c=a(d,"P",{});var _=r(c);b=i(_,"Although the recipe for forward pass needs to be defined within this function, one should call the "),m=a(_,"CODE",{});var C=r(m);g=i(C,"Module"),C.forEach(o),v=i(_,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),_.forEach(o)},m(d,_){f(d,c,_),t(c,b),t(c,m),t(m,g),t(c,v)},d(d){d&&o(c)}}}function pa(z){let c,b,m,g,v;return g=new fn({props:{code:`import torch
from transformers import AutoTokenizer, BioGptForCausalLM

tokenizer = AutoTokenizer.from_pretrained("microsoft/biogpt")
model = BioGptForCausalLM.from_pretrained("microsoft/biogpt")

inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs, labels=inputs["input_ids"])
loss = outputs.loss
logits = outputs.logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, BioGptForCausalLM

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;microsoft/biogpt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = BioGptForCausalLM.from_pretrained(<span class="hljs-string">&quot;microsoft/biogpt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, labels=inputs[<span class="hljs-string">&quot;input_ids&quot;</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>loss = outputs.loss
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),{c(){c=n("p"),b=s("Example:"),m=h(),k(g.$$.fragment)},l(d){c=a(d,"P",{});var _=r(c);b=i(_,"Example:"),_.forEach(o),m=u(d),y(g.$$.fragment,d)},m(d,_){f(d,c,_),t(c,b),f(d,m,_),T(g,d,_),v=!0},p:mn,i(d){v||(w(g.$$.fragment,d),v=!0)},o(d){$(g.$$.fragment,d),v=!1},d(d){d&&o(c),d&&o(m),B(g,d)}}}function ha(z){let c,b,m,g,v,d,_,C,St,bt,L,U,Xe,ie,Wt,Ze,Rt,vt,V,Ht,de,Ut,Vt,kt,Ce,Qt,yt,Ee,Je,Yt,Tt,qe,Kt,wt,F,et,Xt,Zt,tt,Jt,eo,le,to,ot,oo,no,$t,A,ao,ce,ro,so,pe,io,lo,Bt,j,Q,nt,he,co,at,po,Gt,G,ue,ho,O,uo,Fe,mo,fo,me,go,_o,bo,I,vo,Ae,ko,yo,Le,To,wo,$o,Y,xt,D,K,rt,fe,Bo,st,Go,zt,x,ge,xo,it,zo,Mo,_e,Po,je,Co,Eo,qo,Oe,be,Mt,N,X,dt,ve,Fo,lt,Ao,Pt,E,ke,Lo,ye,jo,Te,Oo,Io,Do,M,we,No,S,So,Ie,Wo,Ro,ct,Ho,Uo,Vo,Z,Qo,J,Ct,W,ee,pt,$e,Yo,ht,Ko,Et,q,Be,Xo,R,Zo,ut,Jo,en,Ge,tn,on,nn,P,xe,an,H,rn,De,sn,dn,mt,ln,cn,pn,te,hn,oe,qt;return d=new Ke({}),ie=new Ke({}),he=new Ke({}),ue=new Pe({props:{name:"class transformers.BioGptConfig",anchor:"transformers.BioGptConfig",parameters:[{name:"vocab_size",val:" = 42384"},{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:" = 1024"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-12"},{name:"scale_embedding",val:" = True"},{name:"use_cache",val:" = True"},{name:"is_encoder_decoder",val:" = False"},{name:"layerdrop",val:" = 0.0"},{name:"activation_dropout",val:" = 0.0"},{name:"pad_token_id",val:" = 1"},{name:"bos_token_id",val:" = 0"},{name:"eos_token_id",val:" = 2"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.BioGptConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 42384) &#x2014;
Vocabulary size of the BioGPT 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/biogpt#transformers.BioGptModel">BioGptModel</a>.`,name:"vocab_size"},{anchor:"transformers.BioGptConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
Dimension of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.BioGptConfig.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.BioGptConfig.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.BioGptConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 4096) &#x2014;
Dimension of the &#x201C;intermediate&#x201D; (i.e., feed-forward) layer in the Transformer encoder.`,name:"intermediate_size"},{anchor:"transformers.BioGptConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder and pooler. If string, <code>&quot;gelu&quot;</code>,
<code>&quot;relu&quot;</code>, <code>&quot;selu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"hidden_act"},{anchor:"transformers.BioGptConfig.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probabilitiy for all fully connected layers in the embeddings, encoder, and pooler.`,name:"hidden_dropout_prob"},{anchor:"transformers.BioGptConfig.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.BioGptConfig.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
The maximum sequence length that this model might ever be used with. Typically set this to something large
just in case (e.g., 512 or 1024 or 2048).`,name:"max_position_embeddings"},{anchor:"transformers.BioGptConfig.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.BioGptConfig.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.BioGptConfig.scale_embedding",description:`<strong>scale_embedding</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Scale embeddings by diving by sqrt(d_model).`,name:"scale_embedding"},{anchor:"transformers.BioGptConfig.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"},{anchor:"transformers.BioGptConfig.is_encoder_decoder",description:`<strong>is_encoder_decoder</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether this is an encoder/decoder model.`,name:"is_encoder_decoder"},{anchor:"transformers.BioGptConfig.layerdrop",description:`<strong>layerdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Please refer to the paper about LayerDrop: <a href="https://arxiv.org/abs/1909.11556" rel="nofollow">https://arxiv.org/abs/1909.11556</a> for further details`,name:"layerdrop"},{anchor:"transformers.BioGptConfig.activation_dropout",description:`<strong>activation_dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for activations inside the fully connected layer.`,name:"activation_dropout"},{anchor:"transformers.BioGptConfig.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Padding token id.`,name:"pad_token_id"},{anchor:"transformers.BioGptConfig.bos_token_id",description:`<strong>bos_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
Beginning of stream token id.`,name:"bos_token_id"},{anchor:"transformers.BioGptConfig.eos_token_id",description:`<strong>eos_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
End of stream token id.
Example &#x2014;`,name:"eos_token_id"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/biogpt/configuration_biogpt.py#L29"}}),Y=new un({props:{anchor:"transformers.BioGptConfig.example",$$slots:{default:[ia]},$$scope:{ctx:z}}}),fe=new Ke({}),ge=new Pe({props:{name:"class transformers.BioGptTokenizer",anchor:"transformers.BioGptTokenizer",parameters:[{name:"vocab_file",val:""},{name:"merges_file",val:""},{name:"unk_token",val:" = '<unk>'"},{name:"bos_token",val:" = '<s>'"},{name:"eos_token",val:" = '</s>'"},{name:"sep_token",val:" = '</s>'"},{name:"pad_token",val:" = '<pad>'"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.BioGptTokenizer.vocab_file",description:`<strong>vocab_file</strong> (<code>str</code>) &#x2014;
Path to the vocabulary file.`,name:"vocab_file"},{anchor:"transformers.BioGptTokenizer.merges_file",description:`<strong>merges_file</strong> (<code>str</code>) &#x2014;
Merges file.`,name:"merges_file"},{anchor:"transformers.BioGptTokenizer.unk_token",description:`<strong>unk_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;unk&gt;&quot;</code>) &#x2014;
The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
token instead.`,name:"unk_token"},{anchor:"transformers.BioGptTokenizer.bos_token",description:`<strong>bos_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;s&gt;&quot;</code>) &#x2014;
The beginning of sequence token that was used during pretraining. Can be used a sequence classifier token.</p>
<div class="course-tip  bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400">
						
<p>When building a sequence using special tokens, this is not the token that is used for the beginning of
sequence. The token used is the <code>cls_token</code>.</p>

					</div>`,name:"bos_token"},{anchor:"transformers.BioGptTokenizer.eos_token",description:`<strong>eos_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;/s&gt;&quot;</code>) &#x2014;
The end of sequence token.</p>
<div class="course-tip  bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400">
						
<p>When building a sequence using special tokens, this is not the token that is used for the end of sequence.
The token used is the <code>sep_token</code>.</p>

					</div>`,name:"eos_token"},{anchor:"transformers.BioGptTokenizer.sep_token",description:`<strong>sep_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;/s&gt;&quot;</code>) &#x2014;
The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences for
sequence classification or for a text and a question for question answering. It is also used as the last
token of a sequence built with special tokens.`,name:"sep_token"},{anchor:"transformers.BioGptTokenizer.pad_token",description:`<strong>pad_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&lt;pad&gt;&quot;</code>) &#x2014;
The token used for padding, for example when batching sequences of different lengths.`,name:"pad_token"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/biogpt/tokenization_biogpt.py#L56"}}),be=new Pe({props:{name:"save_vocabulary",anchor:"transformers.BioGptTokenizer.save_vocabulary",parameters:[{name:"save_directory",val:": str"},{name:"filename_prefix",val:": typing.Optional[str] = None"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/biogpt/tokenization_biogpt.py#L326"}}),ve=new Ke({}),ke=new Pe({props:{name:"class transformers.BioGptModel",anchor:"transformers.BioGptModel",parameters:[{name:"config",val:": BioGptConfig"}],parametersDescription:[{anchor:"transformers.BioGptModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/biogpt#transformers.BioGptConfig">~BioGptConfig</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/biogpt/modeling_biogpt.py#L440"}}),we=new Pe({props:{name:"forward",anchor:"transformers.BioGptModel.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",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.BioGptModel.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.BioGptModel.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.BioGptModel.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.BioGptModel.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.BioGptModel.forward.past_key_values",description:`<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>) &#x2014;
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 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 in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential 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>. inputs_embeds (<code>torch.FloatTensor</code> of shape
<code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>): Optionally, instead of passing <code>input_ids</code> you
can choose to directly pass an embedded representation. This is useful if you want more control over how to
convert <code>input_ids</code> indices into associated vectors than the model&#x2019;s internal embedding lookup matrix.`,name:"past_key_values"},{anchor:"transformers.BioGptModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.BioGptModel.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.BioGptModel.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.BioGptModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/biogpt/modeling_biogpt.py#L487",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/biogpt#transformers.BioGptConfig"
>BioGptConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
<p>If <code>past_key_values</code> is used only the last hidden-state of the sequences of shape <code>(batch_size, 1, hidden_size)</code> is output.</p>
</li>
<li>
<p><strong>past_key_values</strong> (<code>tuple(tuple(torch.FloatTensor))</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) \u2014 Tuple of <code>tuple(torch.FloatTensor)</code> of length <code>config.n_layers</code>, with each tuple having 2 tensors of shape
<code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>) and optionally if
<code>config.is_encoder_decoder=True</code> 2 additional tensors of shape <code>(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)</code>.</p>
<p>Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if
<code>config.is_encoder_decoder=True</code> in the cross-attention blocks) that can be used (see <code>past_key_values</code>
input) to speed up sequential decoding.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
<li>
<p><strong>cross_attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> and <code>config.add_cross_attention=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights of the decoder\u2019s cross-attention layer, after the attention softmax, used to compute the
weighted average in the cross-attention heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions"
>transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Z=new ta({props:{$$slots:{default:[da]},$$scope:{ctx:z}}}),J=new un({props:{anchor:"transformers.BioGptModel.forward.example",$$slots:{default:[la]},$$scope:{ctx:z}}}),$e=new Ke({}),Be=new Pe({props:{name:"class transformers.BioGptForCausalLM",anchor:"transformers.BioGptForCausalLM",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.BioGptForCausalLM.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/biogpt#transformers.BioGptConfig">~BioGptConfig</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/biogpt/modeling_biogpt.py#L625"}}),xe=new Pe({props:{name:"forward",anchor:"transformers.BioGptForCausalLM.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.BioGptForCausalLM.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.BioGptForCausalLM.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.BioGptForCausalLM.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.BioGptForCausalLM.forward.inputs_embeds",description:`<strong>inputs_embeds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>) &#x2014;
Optionally, instead of passing <code>input_ids</code> you can choose to directly pass an embedded representation. This
is useful if you want more control over how to convert <em>input_ids</em> indices into associated vectors than the
model&#x2019;s internal embedding lookup matrix.`,name:"inputs_embeds"},{anchor:"transformers.BioGptForCausalLM.forward.past_key_values",description:`<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>) &#x2014;
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 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 in the cross-attention
blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential 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>. inputs_embeds (<code>torch.FloatTensor</code> of shape
<code>(batch_size, sequence_length, hidden_size)</code>, <em>optional</em>): Optionally, instead of passing <code>input_ids</code> you
can choose to directly pass an embedded representation. This is useful if you want more control over how to
convert <code>input_ids</code> indices into associated vectors than the model&#x2019;s internal embedding lookup matrix.`,name:"past_key_values"},{anchor:"transformers.BioGptForCausalLM.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.BioGptForCausalLM.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.BioGptForCausalLM.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.BioGptForCausalLM.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.BioGptForCausalLM.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Labels for language modeling. Note that the labels <strong>are shifted</strong> inside the model, i.e. you can set
<code>labels = input_ids</code> Indices are selected in <code>[-100, 0, ..., config.vocab_size]</code> All labels set to <code>-100</code>
are ignored (masked), the loss is only computed for labels in <code>[0, ..., config.vocab_size]</code>`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/biogpt/modeling_biogpt.py#L643",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/biogpt#transformers.BioGptConfig"
>BioGptConfig</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>
`}}),te=new ta({props:{$$slots:{default:[ca]},$$scope:{ctx:z}}}),oe=new un({props:{anchor:"transformers.BioGptForCausalLM.forward.example",$$slots:{default:[pa]},$$scope:{ctx:z}}}),{c(){c=n("meta"),b=h(),m=n("h1"),g=n("a"),v=n("span"),k(d.$$.fragment),_=h(),C=n("span"),St=s("BioGPT"),bt=h(),L=n("h2"),U=n("a"),Xe=n("span"),k(ie.$$.fragment),Wt=h(),Ze=n("span"),Rt=s("Overview"),vt=h(),V=n("p"),Ht=s("The BioGPT model was proposed in "),de=n("a"),Ut=s("BioGPT: generative pre-trained transformer for biomedical text generation and mining"),Vt=s(" by Renqian Luo, Liai Sun, Yingce Xia, Tao Qin, Sheng Zhang, Hoifung Poon and Tie-Yan Liu. BioGPT is a domain-specific generative pre-trained Transformer language model for biomedical text generation and mining. BioGPT follows the Transformer language model backbone, and is pre-trained on 15M PubMed abstracts from scratch."),kt=h(),Ce=n("p"),Qt=s("The abstract from the paper is the following:"),yt=h(),Ee=n("p"),Je=n("em"),Yt=s("Pre-trained language models have attracted increasing attention in the biomedical domain, inspired by their great success in the general natural language domain. Among the two main branches of pre-trained language models in the general language domain, i.e. BERT (and its variants) and GPT (and its variants), the first one has been extensively studied in the biomedical domain, such as BioBERT and PubMedBERT. While they have achieved great success on a variety of discriminative downstream biomedical tasks, the lack of generation ability constrains their application scope. In this paper, we propose BioGPT, a domain-specific generative Transformer language model pre-trained on large-scale biomedical literature. We evaluate BioGPT on six biomedical natural language processing tasks and demonstrate that our model outperforms previous models on most tasks. Especially, we get 44.98%, 38.42% and 40.76% F1 score on BC5CDR, KD-DTI and DDI end-to-end relation extraction tasks, respectively, and 78.2% accuracy on PubMedQA, creating a new record. Our case study on text generation further demonstrates the advantage of BioGPT on biomedical literature to generate fluent descriptions for biomedical terms."),Tt=h(),qe=n("p"),Kt=s("Tips:"),wt=h(),F=n("ul"),et=n("li"),Xt=s("BioGPT is a model with absolute position embeddings so it\u2019s usually advised to pad the inputs on the right rather than the left."),Zt=h(),tt=n("li"),Jt=s("BioGPT was trained with a causal language modeling (CLM) objective and is therefore powerful at predicting the next token in a sequence. Leveraging this feature allows BioGPT to generate syntactically coherent text as it can be observed in the run_generation.py example script."),eo=h(),le=n("li"),to=s("The model can take the "),ot=n("code"),oo=s("past_key_values"),no=s(" (for PyTorch) as input, which is the previously computed key/value attention pairs. Using this (past_key_values or past) value prevents the model from re-computing pre-computed values in the context of text generation. For PyTorch, see past_key_values argument of the BioGptForCausalLM.forward() method for more information on its usage."),$t=h(),A=n("p"),ao=s("This model was contributed by "),ce=n("a"),ro=s("kamalkraj"),so=s(". The original code can be found "),pe=n("a"),io=s("here"),lo=s("."),Bt=h(),j=n("h2"),Q=n("a"),nt=n("span"),k(he.$$.fragment),co=h(),at=n("span"),po=s("BioGptConfig"),Gt=h(),G=n("div"),k(ue.$$.fragment),ho=h(),O=n("p"),uo=s("This is the configuration class to store the configuration of a "),Fe=n("a"),mo=s("BioGptModel"),fo=s(`. It is used to instantiate an
BioGPT 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 BioGPT
`),me=n("a"),go=s("microsoft/biogpt"),_o=s(" architecture."),bo=h(),I=n("p"),vo=s("Configuration objects inherit from "),Ae=n("a"),ko=s("PretrainedConfig"),yo=s(` and can be used to control the model outputs. Read the
documentation from `),Le=n("a"),To=s("PretrainedConfig"),wo=s(" for more information."),$o=h(),k(Y.$$.fragment),xt=h(),D=n("h2"),K=n("a"),rt=n("span"),k(fe.$$.fragment),Bo=h(),st=n("span"),Go=s("BioGptTokenizer"),zt=h(),x=n("div"),k(ge.$$.fragment),xo=h(),it=n("p"),zo=s("Construct an FAIRSEQ Transformer tokenizer. Moses tokenization followed by Byte-Pair Encoding."),Mo=h(),_e=n("p"),Po=s("This tokenizer inherits from "),je=n("a"),Co=s("PreTrainedTokenizer"),Eo=s(` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),qo=h(),Oe=n("div"),k(be.$$.fragment),Mt=h(),N=n("h2"),X=n("a"),dt=n("span"),k(ve.$$.fragment),Fo=h(),lt=n("span"),Ao=s("BioGptModel"),Pt=h(),E=n("div"),k(ke.$$.fragment),Lo=h(),ye=n("p"),jo=s(`The bare BioGPT Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),Te=n("a"),Oo=s("torch.nn.Module"),Io=s(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Do=h(),M=n("div"),k(we.$$.fragment),No=h(),S=n("p"),So=s("The "),Ie=n("a"),Wo=s("BioGptModel"),Ro=s(" forward method, overrides the "),ct=n("code"),Ho=s("__call__"),Uo=s(" special method."),Vo=h(),k(Z.$$.fragment),Qo=h(),k(J.$$.fragment),Ct=h(),W=n("h2"),ee=n("a"),pt=n("span"),k($e.$$.fragment),Yo=h(),ht=n("span"),Ko=s("BioGptForCausalLM"),Et=h(),q=n("div"),k(Be.$$.fragment),Xo=h(),R=n("p"),Zo=s("BioGPT Model with a "),ut=n("code"),Jo=s("language modeling"),en=s(` head on top for CLM fine-tuning.
This model is a PyTorch `),Ge=n("a"),tn=s("torch.nn.Module"),on=s(` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),nn=h(),P=n("div"),k(xe.$$.fragment),an=h(),H=n("p"),rn=s("The "),De=n("a"),sn=s("BioGptForCausalLM"),dn=s(" forward method, overrides the "),mt=n("code"),ln=s("__call__"),cn=s(" special method."),pn=h(),k(te.$$.fragment),hn=h(),k(oe.$$.fragment),this.h()},l(e){const p=ra('[data-svelte="svelte-1phssyn"]',document.head);c=a(p,"META",{name:!0,content:!0}),p.forEach(o),b=u(e),m=a(e,"H1",{class:!0});var ze=r(m);g=a(ze,"A",{id:!0,class:!0,href:!0});var ft=r(g);v=a(ft,"SPAN",{});var gt=r(v);y(d.$$.fragment,gt),gt.forEach(o),ft.forEach(o),_=u(ze),C=a(ze,"SPAN",{});var _t=r(C);St=i(_t,"BioGPT"),_t.forEach(o),ze.forEach(o),bt=u(e),L=a(e,"H2",{class:!0});var Me=r(L);U=a(Me,"A",{id:!0,class:!0,href:!0});var gn=r(U);Xe=a(gn,"SPAN",{});var _n=r(Xe);y(ie.$$.fragment,_n),_n.forEach(o),gn.forEach(o),Wt=u(Me),Ze=a(Me,"SPAN",{});var bn=r(Ze);Rt=i(bn,"Overview"),bn.forEach(o),Me.forEach(o),vt=u(e),V=a(e,"P",{});var Ft=r(V);Ht=i(Ft,"The BioGPT model was proposed in "),de=a(Ft,"A",{href:!0,rel:!0});var vn=r(de);Ut=i(vn,"BioGPT: generative pre-trained transformer for biomedical text generation and mining"),vn.forEach(o),Vt=i(Ft," by Renqian Luo, Liai Sun, Yingce Xia, Tao Qin, Sheng Zhang, Hoifung Poon and Tie-Yan Liu. BioGPT is a domain-specific generative pre-trained Transformer language model for biomedical text generation and mining. BioGPT follows the Transformer language model backbone, and is pre-trained on 15M PubMed abstracts from scratch."),Ft.forEach(o),kt=u(e),Ce=a(e,"P",{});var kn=r(Ce);Qt=i(kn,"The abstract from the paper is the following:"),kn.forEach(o),yt=u(e),Ee=a(e,"P",{});var yn=r(Ee);Je=a(yn,"EM",{});var Tn=r(Je);Yt=i(Tn,"Pre-trained language models have attracted increasing attention in the biomedical domain, inspired by their great success in the general natural language domain. Among the two main branches of pre-trained language models in the general language domain, i.e. BERT (and its variants) and GPT (and its variants), the first one has been extensively studied in the biomedical domain, such as BioBERT and PubMedBERT. While they have achieved great success on a variety of discriminative downstream biomedical tasks, the lack of generation ability constrains their application scope. In this paper, we propose BioGPT, a domain-specific generative Transformer language model pre-trained on large-scale biomedical literature. We evaluate BioGPT on six biomedical natural language processing tasks and demonstrate that our model outperforms previous models on most tasks. Especially, we get 44.98%, 38.42% and 40.76% F1 score on BC5CDR, KD-DTI and DDI end-to-end relation extraction tasks, respectively, and 78.2% accuracy on PubMedQA, creating a new record. Our case study on text generation further demonstrates the advantage of BioGPT on biomedical literature to generate fluent descriptions for biomedical terms."),Tn.forEach(o),yn.forEach(o),Tt=u(e),qe=a(e,"P",{});var wn=r(qe);Kt=i(wn,"Tips:"),wn.forEach(o),wt=u(e),F=a(e,"UL",{});var Ne=r(F);et=a(Ne,"LI",{});var $n=r(et);Xt=i($n,"BioGPT is a model with absolute position embeddings so it\u2019s usually advised to pad the inputs on the right rather than the left."),$n.forEach(o),Zt=u(Ne),tt=a(Ne,"LI",{});var Bn=r(tt);Jt=i(Bn,"BioGPT was trained with a causal language modeling (CLM) objective and is therefore powerful at predicting the next token in a sequence. Leveraging this feature allows BioGPT to generate syntactically coherent text as it can be observed in the run_generation.py example script."),Bn.forEach(o),eo=u(Ne),le=a(Ne,"LI",{});var At=r(le);to=i(At,"The model can take the "),ot=a(At,"CODE",{});var Gn=r(ot);oo=i(Gn,"past_key_values"),Gn.forEach(o),no=i(At," (for PyTorch) as input, which is the previously computed key/value attention pairs. Using this (past_key_values or past) value prevents the model from re-computing pre-computed values in the context of text generation. For PyTorch, see past_key_values argument of the BioGptForCausalLM.forward() method for more information on its usage."),At.forEach(o),Ne.forEach(o),$t=u(e),A=a(e,"P",{});var Se=r(A);ao=i(Se,"This model was contributed by "),ce=a(Se,"A",{href:!0,rel:!0});var xn=r(ce);ro=i(xn,"kamalkraj"),xn.forEach(o),so=i(Se,". The original code can be found "),pe=a(Se,"A",{href:!0,rel:!0});var zn=r(pe);io=i(zn,"here"),zn.forEach(o),lo=i(Se,"."),Se.forEach(o),Bt=u(e),j=a(e,"H2",{class:!0});var Lt=r(j);Q=a(Lt,"A",{id:!0,class:!0,href:!0});var Mn=r(Q);nt=a(Mn,"SPAN",{});var Pn=r(nt);y(he.$$.fragment,Pn),Pn.forEach(o),Mn.forEach(o),co=u(Lt),at=a(Lt,"SPAN",{});var Cn=r(at);po=i(Cn,"BioGptConfig"),Cn.forEach(o),Lt.forEach(o),Gt=u(e),G=a(e,"DIV",{class:!0});var ne=r(G);y(ue.$$.fragment,ne),ho=u(ne),O=a(ne,"P",{});var We=r(O);uo=i(We,"This is the configuration class to store the configuration of a "),Fe=a(We,"A",{href:!0});var En=r(Fe);mo=i(En,"BioGptModel"),En.forEach(o),fo=i(We,`. It is used to instantiate an
BioGPT 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 BioGPT
`),me=a(We,"A",{href:!0,rel:!0});var qn=r(me);go=i(qn,"microsoft/biogpt"),qn.forEach(o),_o=i(We," architecture."),We.forEach(o),bo=u(ne),I=a(ne,"P",{});var Re=r(I);vo=i(Re,"Configuration objects inherit from "),Ae=a(Re,"A",{href:!0});var Fn=r(Ae);ko=i(Fn,"PretrainedConfig"),Fn.forEach(o),yo=i(Re,` and can be used to control the model outputs. Read the
documentation from `),Le=a(Re,"A",{href:!0});var An=r(Le);To=i(An,"PretrainedConfig"),An.forEach(o),wo=i(Re," for more information."),Re.forEach(o),$o=u(ne),y(Y.$$.fragment,ne),ne.forEach(o),xt=u(e),D=a(e,"H2",{class:!0});var jt=r(D);K=a(jt,"A",{id:!0,class:!0,href:!0});var Ln=r(K);rt=a(Ln,"SPAN",{});var jn=r(rt);y(fe.$$.fragment,jn),jn.forEach(o),Ln.forEach(o),Bo=u(jt),st=a(jt,"SPAN",{});var On=r(st);Go=i(On,"BioGptTokenizer"),On.forEach(o),jt.forEach(o),zt=u(e),x=a(e,"DIV",{class:!0});var ae=r(x);y(ge.$$.fragment,ae),xo=u(ae),it=a(ae,"P",{});var In=r(it);zo=i(In,"Construct an FAIRSEQ Transformer tokenizer. Moses tokenization followed by Byte-Pair Encoding."),In.forEach(o),Mo=u(ae),_e=a(ae,"P",{});var Ot=r(_e);Po=i(Ot,"This tokenizer inherits from "),je=a(Ot,"A",{href:!0});var Dn=r(je);Co=i(Dn,"PreTrainedTokenizer"),Dn.forEach(o),Eo=i(Ot,` which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.`),Ot.forEach(o),qo=u(ae),Oe=a(ae,"DIV",{class:!0});var Nn=r(Oe);y(be.$$.fragment,Nn),Nn.forEach(o),ae.forEach(o),Mt=u(e),N=a(e,"H2",{class:!0});var It=r(N);X=a(It,"A",{id:!0,class:!0,href:!0});var Sn=r(X);dt=a(Sn,"SPAN",{});var Wn=r(dt);y(ve.$$.fragment,Wn),Wn.forEach(o),Sn.forEach(o),Fo=u(It),lt=a(It,"SPAN",{});var Rn=r(lt);Ao=i(Rn,"BioGptModel"),Rn.forEach(o),It.forEach(o),Pt=u(e),E=a(e,"DIV",{class:!0});var He=r(E);y(ke.$$.fragment,He),Lo=u(He),ye=a(He,"P",{});var Dt=r(ye);jo=i(Dt,`The bare BioGPT Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),Te=a(Dt,"A",{href:!0,rel:!0});var Hn=r(Te);Oo=i(Hn,"torch.nn.Module"),Hn.forEach(o),Io=i(Dt,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Dt.forEach(o),Do=u(He),M=a(He,"DIV",{class:!0});var re=r(M);y(we.$$.fragment,re),No=u(re),S=a(re,"P",{});var Ue=r(S);So=i(Ue,"The "),Ie=a(Ue,"A",{href:!0});var Un=r(Ie);Wo=i(Un,"BioGptModel"),Un.forEach(o),Ro=i(Ue," forward method, overrides the "),ct=a(Ue,"CODE",{});var Vn=r(ct);Ho=i(Vn,"__call__"),Vn.forEach(o),Uo=i(Ue," special method."),Ue.forEach(o),Vo=u(re),y(Z.$$.fragment,re),Qo=u(re),y(J.$$.fragment,re),re.forEach(o),He.forEach(o),Ct=u(e),W=a(e,"H2",{class:!0});var Nt=r(W);ee=a(Nt,"A",{id:!0,class:!0,href:!0});var Qn=r(ee);pt=a(Qn,"SPAN",{});var Yn=r(pt);y($e.$$.fragment,Yn),Yn.forEach(o),Qn.forEach(o),Yo=u(Nt),ht=a(Nt,"SPAN",{});var Kn=r(ht);Ko=i(Kn,"BioGptForCausalLM"),Kn.forEach(o),Nt.forEach(o),Et=u(e),q=a(e,"DIV",{class:!0});var Ve=r(q);y(Be.$$.fragment,Ve),Xo=u(Ve),R=a(Ve,"P",{});var Qe=r(R);Zo=i(Qe,"BioGPT Model with a "),ut=a(Qe,"CODE",{});var Xn=r(ut);Jo=i(Xn,"language modeling"),Xn.forEach(o),en=i(Qe,` head on top for CLM fine-tuning.
This model is a PyTorch `),Ge=a(Qe,"A",{href:!0,rel:!0});var Zn=r(Ge);tn=i(Zn,"torch.nn.Module"),Zn.forEach(o),on=i(Qe,` sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Qe.forEach(o),nn=u(Ve),P=a(Ve,"DIV",{class:!0});var se=r(P);y(xe.$$.fragment,se),an=u(se),H=a(se,"P",{});var Ye=r(H);rn=i(Ye,"The "),De=a(Ye,"A",{href:!0});var Jn=r(De);sn=i(Jn,"BioGptForCausalLM"),Jn.forEach(o),dn=i(Ye," forward method, overrides the "),mt=a(Ye,"CODE",{});var ea=r(mt);ln=i(ea,"__call__"),ea.forEach(o),cn=i(Ye," special method."),Ye.forEach(o),pn=u(se),y(te.$$.fragment,se),hn=u(se),y(oe.$$.fragment,se),se.forEach(o),Ve.forEach(o),this.h()},h(){l(c,"name","hf:doc:metadata"),l(c,"content",JSON.stringify(ua)),l(g,"id","biogpt"),l(g,"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"),l(g,"href","#biogpt"),l(m,"class","relative group"),l(U,"id","overview"),l(U,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(U,"href","#overview"),l(L,"class","relative group"),l(de,"href","https://academic.oup.com/bib/advance-article/doi/10.1093/bib/bbac409/6713511?guestAccessKey=a66d9b5d-4f83-4017-bb52-405815c907b9"),l(de,"rel","nofollow"),l(ce,"href","https://huggingface.co/kamalkraj"),l(ce,"rel","nofollow"),l(pe,"href","https://github.com/microsoft/BioGPT"),l(pe,"rel","nofollow"),l(Q,"id","transformers.BioGptConfig"),l(Q,"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"),l(Q,"href","#transformers.BioGptConfig"),l(j,"class","relative group"),l(Fe,"href","/docs/transformers/main/en/model_doc/biogpt#transformers.BioGptModel"),l(me,"href","https://huggingface.co/microsoft/biogpt"),l(me,"rel","nofollow"),l(Ae,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),l(Le,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),l(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(K,"id","transformers.BioGptTokenizer"),l(K,"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"),l(K,"href","#transformers.BioGptTokenizer"),l(D,"class","relative group"),l(je,"href","/docs/transformers/main/en/main_classes/tokenizer#transformers.PreTrainedTokenizer"),l(Oe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(X,"id","transformers.BioGptModel"),l(X,"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"),l(X,"href","#transformers.BioGptModel"),l(N,"class","relative group"),l(Te,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(Te,"rel","nofollow"),l(Ie,"href","/docs/transformers/main/en/model_doc/biogpt#transformers.BioGptModel"),l(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ee,"id","transformers.BioGptForCausalLM"),l(ee,"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"),l(ee,"href","#transformers.BioGptForCausalLM"),l(W,"class","relative group"),l(Ge,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),l(Ge,"rel","nofollow"),l(De,"href","/docs/transformers/main/en/model_doc/biogpt#transformers.BioGptForCausalLM"),l(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,p){t(document.head,c),f(e,b,p),f(e,m,p),t(m,g),t(g,v),T(d,v,null),t(m,_),t(m,C),t(C,St),f(e,bt,p),f(e,L,p),t(L,U),t(U,Xe),T(ie,Xe,null),t(L,Wt),t(L,Ze),t(Ze,Rt),f(e,vt,p),f(e,V,p),t(V,Ht),t(V,de),t(de,Ut),t(V,Vt),f(e,kt,p),f(e,Ce,p),t(Ce,Qt),f(e,yt,p),f(e,Ee,p),t(Ee,Je),t(Je,Yt),f(e,Tt,p),f(e,qe,p),t(qe,Kt),f(e,wt,p),f(e,F,p),t(F,et),t(et,Xt),t(F,Zt),t(F,tt),t(tt,Jt),t(F,eo),t(F,le),t(le,to),t(le,ot),t(ot,oo),t(le,no),f(e,$t,p),f(e,A,p),t(A,ao),t(A,ce),t(ce,ro),t(A,so),t(A,pe),t(pe,io),t(A,lo),f(e,Bt,p),f(e,j,p),t(j,Q),t(Q,nt),T(he,nt,null),t(j,co),t(j,at),t(at,po),f(e,Gt,p),f(e,G,p),T(ue,G,null),t(G,ho),t(G,O),t(O,uo),t(O,Fe),t(Fe,mo),t(O,fo),t(O,me),t(me,go),t(O,_o),t(G,bo),t(G,I),t(I,vo),t(I,Ae),t(Ae,ko),t(I,yo),t(I,Le),t(Le,To),t(I,wo),t(G,$o),T(Y,G,null),f(e,xt,p),f(e,D,p),t(D,K),t(K,rt),T(fe,rt,null),t(D,Bo),t(D,st),t(st,Go),f(e,zt,p),f(e,x,p),T(ge,x,null),t(x,xo),t(x,it),t(it,zo),t(x,Mo),t(x,_e),t(_e,Po),t(_e,je),t(je,Co),t(_e,Eo),t(x,qo),t(x,Oe),T(be,Oe,null),f(e,Mt,p),f(e,N,p),t(N,X),t(X,dt),T(ve,dt,null),t(N,Fo),t(N,lt),t(lt,Ao),f(e,Pt,p),f(e,E,p),T(ke,E,null),t(E,Lo),t(E,ye),t(ye,jo),t(ye,Te),t(Te,Oo),t(ye,Io),t(E,Do),t(E,M),T(we,M,null),t(M,No),t(M,S),t(S,So),t(S,Ie),t(Ie,Wo),t(S,Ro),t(S,ct),t(ct,Ho),t(S,Uo),t(M,Vo),T(Z,M,null),t(M,Qo),T(J,M,null),f(e,Ct,p),f(e,W,p),t(W,ee),t(ee,pt),T($e,pt,null),t(W,Yo),t(W,ht),t(ht,Ko),f(e,Et,p),f(e,q,p),T(Be,q,null),t(q,Xo),t(q,R),t(R,Zo),t(R,ut),t(ut,Jo),t(R,en),t(R,Ge),t(Ge,tn),t(R,on),t(q,nn),t(q,P),T(xe,P,null),t(P,an),t(P,H),t(H,rn),t(H,De),t(De,sn),t(H,dn),t(H,mt),t(mt,ln),t(H,cn),t(P,pn),T(te,P,null),t(P,hn),T(oe,P,null),qt=!0},p(e,[p]){const ze={};p&2&&(ze.$$scope={dirty:p,ctx:e}),Y.$set(ze);const ft={};p&2&&(ft.$$scope={dirty:p,ctx:e}),Z.$set(ft);const gt={};p&2&&(gt.$$scope={dirty:p,ctx:e}),J.$set(gt);const _t={};p&2&&(_t.$$scope={dirty:p,ctx:e}),te.$set(_t);const Me={};p&2&&(Me.$$scope={dirty:p,ctx:e}),oe.$set(Me)},i(e){qt||(w(d.$$.fragment,e),w(ie.$$.fragment,e),w(he.$$.fragment,e),w(ue.$$.fragment,e),w(Y.$$.fragment,e),w(fe.$$.fragment,e),w(ge.$$.fragment,e),w(be.$$.fragment,e),w(ve.$$.fragment,e),w(ke.$$.fragment,e),w(we.$$.fragment,e),w(Z.$$.fragment,e),w(J.$$.fragment,e),w($e.$$.fragment,e),w(Be.$$.fragment,e),w(xe.$$.fragment,e),w(te.$$.fragment,e),w(oe.$$.fragment,e),qt=!0)},o(e){$(d.$$.fragment,e),$(ie.$$.fragment,e),$(he.$$.fragment,e),$(ue.$$.fragment,e),$(Y.$$.fragment,e),$(fe.$$.fragment,e),$(ge.$$.fragment,e),$(be.$$.fragment,e),$(ve.$$.fragment,e),$(ke.$$.fragment,e),$(we.$$.fragment,e),$(Z.$$.fragment,e),$(J.$$.fragment,e),$($e.$$.fragment,e),$(Be.$$.fragment,e),$(xe.$$.fragment,e),$(te.$$.fragment,e),$(oe.$$.fragment,e),qt=!1},d(e){o(c),e&&o(b),e&&o(m),B(d),e&&o(bt),e&&o(L),B(ie),e&&o(vt),e&&o(V),e&&o(kt),e&&o(Ce),e&&o(yt),e&&o(Ee),e&&o(Tt),e&&o(qe),e&&o(wt),e&&o(F),e&&o($t),e&&o(A),e&&o(Bt),e&&o(j),B(he),e&&o(Gt),e&&o(G),B(ue),B(Y),e&&o(xt),e&&o(D),B(fe),e&&o(zt),e&&o(x),B(ge),B(be),e&&o(Mt),e&&o(N),B(ve),e&&o(Pt),e&&o(E),B(ke),B(we),B(Z),B(J),e&&o(Ct),e&&o(W),B($e),e&&o(Et),e&&o(q),B(Be),B(xe),B(te),B(oe)}}}const ua={local:"biogpt",sections:[{local:"overview",title:"Overview"},{local:"transformers.BioGptConfig",title:"BioGptConfig"},{local:"transformers.BioGptTokenizer",title:"BioGptTokenizer"},{local:"transformers.BioGptModel",title:"BioGptModel"},{local:"transformers.BioGptForCausalLM",title:"BioGptForCausalLM"}],title:"BioGPT"};function ma(z){return sa(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ya extends oa{constructor(c){super();na(this,c,ma,ha,aa,{})}}export{ya as default,ua as metadata};
