id int64 0 328k | repository_name stringlengths 7 58 | file_path stringlengths 9 302 | class_name stringlengths 5 256 | human_written_code stringlengths 16 2.16M | class_skeleton stringlengths 18 1.49M ⌀ | total_program_units int64 1 1.76k | total_doc_str int64 0 771 | AvgCountLine float64 0 7.89k | AvgCountLineBlank float64 0 297 | AvgCountLineCode float64 0 7.89k | AvgCountLineComment float64 0 7.89k | AvgCyclomatic float64 0 130 | CommentToCodeRatio float64 0 168 | CountClassBase float64 0 40 | CountClassCoupled float64 0 583 | CountClassCoupledModified float64 0 575 | CountClassDerived float64 0 5.35k | CountDeclInstanceMethod float64 0 529 | CountDeclInstanceVariable float64 0 296 | CountDeclMethod float64 0 599 | CountDeclMethodAll float64 0 1.12k | CountLine float64 1 40.4k | CountLineBlank float64 0 8.16k | CountLineCode float64 1 25.7k | CountLineCodeDecl float64 1 8.15k | CountLineCodeExe float64 0 24.2k | CountLineComment float64 0 16.5k | CountStmt float64 1 9.71k | CountStmtDecl float64 1 8.15k | CountStmtExe float64 0 9.69k | MaxCyclomatic float64 0 759 | MaxInheritanceTree float64 0 16 | MaxNesting float64 0 34 | SumCyclomatic float64 0 2.9k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3,700 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/modeling_mbart.py | transformers.models.mbart.modeling_mbart.MBartAttention | from typing import Callable, Optional, Union
from ...modeling_flash_attention_utils import FlashAttentionKwargs
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from ...utils.deprecation import deprecate_kwarg
import torch
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from .c... |
class MBartAttention(nn.Module):
'''Multi-headed attention from 'Attention Is All You Need' paper'''
def __init__(self, embed_dim: int, num_heads: int, dropout: float=0.0, is_decoder: bool=False, bias: bool=True, is_causal: bool=False, config: Optional[MBartConfig]=None, layer_idx: Optional[int]=None):
... | 4 | 2 | 50 | 7 | 35 | 8 | 5 | 0.24 | 1 | 7 | 1 | 2 | 3 | 12 | 3 | 13 | 156 | 23 | 107 | 44 | 86 | 26 | 68 | 27 | 64 | 12 | 1 | 2 | 15 |
3,701 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/modeling_mbart.py | transformers.models.mbart.modeling_mbart.MBartClassificationHead | import torch
from torch import nn
class MBartClassificationHead(nn.Module):
"""Head for sentence-level classification tasks."""
def __init__(self, input_dim: int, inner_dim: int, num_classes: int, pooler_dropout: float):
super().__init__()
self.dense = nn.Linear(input_dim, inner_dim)
s... |
class MBartClassificationHead(nn.Module):
'''Head for sentence-level classification tasks.'''
def __init__(self, input_dim: int, inner_dim: int, num_classes: int, pooler_dropout: float):
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass | 3 | 1 | 9 | 0 | 9 | 0 | 1 | 0.05 | 1 | 4 | 0 | 0 | 2 | 3 | 2 | 12 | 22 | 2 | 19 | 12 | 10 | 1 | 13 | 6 | 10 | 1 | 1 | 0 | 2 |
3,702 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/modeling_mbart.py | transformers.models.mbart.modeling_mbart.MBartDecoder | from ...utils import auto_docstring, is_torch_flex_attn_available, is_torchdynamo_compiling, logging
import math
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentions, Seq2SeqLMOutput, Seq2SeqModelOutput, Seq2SeqQuestionAnsweringModelOutput, Seq2Se... |
class MBartDecoder(MBartPreTrainedModel):
'''
Transformer decoder consisting of *config.decoder_layers* layers. Each layer is a [`MBartDecoderLayer`]
Args:
config: MBartConfig
embed_tokens (nn.Embedding): output embedding
'''
def __init__(self, config: MBartConfig, embed_tokens: Op... | 3 | 2 | 68 | 9 | 42 | 18 | 12 | 0.45 | 1 | 13 | 5 | 0 | 4 | 11 | 4 | 6 | 285 | 41 | 168 | 45 | 149 | 76 | 88 | 31 | 83 | 43 | 2 | 3 | 48 |
3,703 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/modeling_mbart.py | transformers.models.mbart.modeling_mbart.MBartDecoderLayer | from typing import Callable, Optional, Union
from torch import nn
from .configuration_mbart import MBartConfig
from ...modeling_layers import GradientCheckpointingLayer
import torch
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from ...utils.deprecation import deprecate_kwarg
from ...activations i... |
class MBartDecoderLayer(GradientCheckpointingLayer):
def __init__(self, config: MBartConfig, layer_idx: Optional[int]=None):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=Non... | 4 | 1 | 58 | 6 | 40 | 13 | 4 | 0.31 | 1 | 4 | 1 | 0 | 2 | 11 | 2 | 12 | 118 | 12 | 81 | 32 | 67 | 25 | 44 | 21 | 41 | 6 | 1 | 1 | 7 |
3,704 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/modeling_mbart.py | transformers.models.mbart.modeling_mbart.MBartDecoderWrapper | class MBartDecoderWrapper(MBartPreTrainedModel):
"""
This wrapper class is a helper class to correctly load pretrained checkpoints when the causal language model is
used in combination with the [`EncoderDecoderModel`] framework.
"""
def __init__(self, config):
super().__init__(config)
... | class MBartDecoderWrapper(MBartPreTrainedModel):
'''
This wrapper class is a helper class to correctly load pretrained checkpoints when the causal language model is
used in combination with the [`EncoderDecoderModel`] framework.
'''
def __init__(self, config):
pass
def forward(self, *a... | 3 | 1 | 3 | 0 | 3 | 0 | 1 | 0.67 | 1 | 2 | 1 | 0 | 2 | 1 | 2 | 4 | 12 | 2 | 6 | 4 | 3 | 4 | 6 | 4 | 3 | 1 | 2 | 0 | 2 |
3,705 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/modeling_mbart.py | transformers.models.mbart.modeling_mbart.MBartEncoder | from typing import Callable, Optional, Union
import math
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentions, Seq2SeqLMOutput, Seq2SeqModelOutput, Seq2SeqQuestionAnsweringModelOutput, Seq2SeqSequenceClassifierOutput
from torch import nn
from .con... |
class MBartEncoder(MBartPreTrainedModel):
'''
Transformer encoder consisting of *config.encoder_layers* self attention layers. Each layer is a
[`MBartEncoderLayer`].
Args:
config: MBartConfig
embed_tokens (nn.Embedding): output embedding
'''
def __init__(self, config: MBartConf... | 4 | 2 | 58 | 8 | 36 | 14 | 11 | 0.44 | 1 | 12 | 5 | 0 | 3 | 11 | 3 | 5 | 186 | 29 | 110 | 35 | 97 | 48 | 71 | 26 | 67 | 27 | 2 | 3 | 32 |
3,706 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/modeling_mbart.py | transformers.models.mbart.modeling_mbart.MBartEncoderLayer | from ...activations import ACT2FN
from torch import nn
from .configuration_mbart import MBartConfig
from ...modeling_layers import GradientCheckpointingLayer
import torch
class MBartEncoderLayer(GradientCheckpointingLayer):
def __init__(self, config: MBartConfig):
super().__init__()
self.embed_dim... |
class MBartEncoderLayer(GradientCheckpointingLayer):
def __init__(self, config: MBartConfig):
pass
def forward(self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, layer_head_mask: torch.Tensor, output_attentions: bool=False) -> torch.Tensor:
'''
Args:
hidden_s... | 3 | 1 | 33 | 3 | 25 | 6 | 2 | 0.22 | 1 | 4 | 1 | 0 | 2 | 9 | 2 | 12 | 68 | 7 | 50 | 22 | 41 | 11 | 32 | 16 | 29 | 3 | 1 | 1 | 4 |
3,707 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/modeling_mbart.py | transformers.models.mbart.modeling_mbart.MBartForCausalLM | from typing import Callable, Optional, Union
from ...utils import auto_docstring, is_torch_flex_attn_available, is_torchdynamo_compiling, logging
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...generation import GenerationMixin
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWi... |
class MBartForCausalLM(MBartPreTrainedModel, GenerationMixin):
def __init__(self, config):
pass
def get_input_embeddings(self):
pass
def set_input_embeddings(self, value):
pass
def set_decoder(self, decoder):
pass
def get_decoder(self):
pass
@auto_do... | 8 | 1 | 19 | 3 | 9 | 8 | 2 | 0.84 | 2 | 6 | 2 | 0 | 8 | 2 | 9 | 11 | 186 | 33 | 83 | 37 | 56 | 70 | 42 | 20 | 32 | 7 | 2 | 1 | 16 |
3,708 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/modeling_mbart.py | transformers.models.mbart.modeling_mbart.MBartForConditionalGeneration | from typing import Callable, Optional, Union
from ...utils import auto_docstring, is_torch_flex_attn_available, is_torchdynamo_compiling, logging
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...generation import GenerationMixin
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWi... | @auto_docstring(custom_intro='\n The MBART Model with a language modeling head. Can be used for summarization, after fine-tuning the pretrained models.\n ')
class MBartForConditionalGeneration(MBartPreTrainedModel, GenerationMixin):
def __init__(self, config: MBartConfig):
pass
def get_encoder(s... | 10 | 1 | 12 | 1 | 10 | 1 | 2 | 0.08 | 2 | 8 | 3 | 0 | 9 | 3 | 10 | 12 | 135 | 18 | 108 | 50 | 73 | 9 | 54 | 27 | 43 | 8 | 2 | 2 | 19 |
3,709 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/modeling_mbart.py | transformers.models.mbart.modeling_mbart.MBartForQuestionAnswering | from typing import Callable, Optional, Union
from ...utils import auto_docstring, is_torch_flex_attn_available, is_torchdynamo_compiling, logging
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWi... | @auto_docstring
class MBartForQuestionAnswering(MBartPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.Tensor]=None, attention_mask: Optional[torch.Tensor]=None, decoder_input_ids: Optional[torch.LongTensor]=None, decoder_attention_mask: ... | 5 | 1 | 52 | 5 | 41 | 7 | 5 | 0.16 | 1 | 5 | 2 | 0 | 2 | 3 | 2 | 4 | 115 | 12 | 89 | 36 | 62 | 14 | 36 | 17 | 33 | 8 | 2 | 2 | 9 |
3,710 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/modeling_mbart.py | transformers.models.mbart.modeling_mbart.MBartForSequenceClassification | from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentions, Seq2SeqLMOutput, Seq2SeqModelOutput, Seq2SeqQuestionAnsweringModelOutput, Seq2SeqSequenceClassifierOutput
from .configuration_mbart import MBartConfig
import torch
from typing import Callable, ... | @auto_docstring(custom_intro='\n MBart model with a sequence classification/head on top (a linear layer on top of the pooled output) e.g. for GLUE\n tasks.\n ')
class MBartForSequenceClassification(MBartPreTrainedModel):
def __init__(self, config: MBartConfig, **kwargs):
pass
@auto_docstring
... | 5 | 1 | 55 | 4 | 48 | 4 | 8 | 0.08 | 1 | 10 | 4 | 0 | 2 | 2 | 2 | 4 | 120 | 10 | 103 | 32 | 77 | 8 | 41 | 14 | 38 | 15 | 2 | 3 | 16 |
3,711 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/modeling_mbart.py | transformers.models.mbart.modeling_mbart.MBartLearnedPositionalEmbedding | import torch
from torch import nn
from typing import Callable, Optional, Union
class MBartLearnedPositionalEmbedding(nn.Embedding):
"""
This module learns positional embeddings up to a fixed maximum size.
"""
def __init__(self, num_embeddings: int, embedding_dim: int):
self.offset = 2
... |
class MBartLearnedPositionalEmbedding(nn.Embedding):
'''
This module learns positional embeddings up to a fixed maximum size.
'''
def __init__(self, num_embeddings: int, embedding_dim: int):
pass
def forward(self, input_ids: torch.Tensor, past_key_values_length: int=0, position_ids: Optio... | 3 | 2 | 7 | 1 | 5 | 2 | 1 | 0.6 | 1 | 3 | 0 | 0 | 2 | 1 | 2 | 2 | 20 | 4 | 10 | 6 | 7 | 6 | 8 | 6 | 5 | 1 | 1 | 0 | 2 |
3,712 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/modeling_mbart.py | transformers.models.mbart.modeling_mbart.MBartModel | from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentions, Seq2SeqLMOutput, Seq2SeqModelOutput, Seq2SeqQuestionAnsweringModelOutput, Seq2SeqSequenceClassifierOutput
from .configuration_mbart import MBartConfig
import torch
from ...cache_utils import Ca... | @auto_docstring
class MBartModel(MBartPreTrainedModel):
def __init__(self, config: MBartConfig):
pass
def get_input_embeddings(self):
pass
def set_input_embeddings(self, value):
pass
def get_encoder(self):
pass
def _tie_weights(self):
pass
@auto_docst... | 9 | 1 | 15 | 1 | 13 | 1 | 3 | 0.05 | 1 | 9 | 6 | 0 | 7 | 3 | 7 | 9 | 119 | 15 | 99 | 33 | 67 | 5 | 38 | 15 | 30 | 11 | 2 | 1 | 19 |
3,713 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/modeling_mbart.py | transformers.models.mbart.modeling_mbart.MBartPreTrainedModel | from typing import Callable, Optional, Union
from ...modeling_attn_mask_utils import AttentionMaskConverter, _prepare_4d_attention_mask, _prepare_4d_attention_mask_for_sdpa
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from ...utils import auto_docstring, is_torch_flex_attn_available, is_torchd... | @auto_docstring
class MBartPreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
pass
@property
def dummy_inputs(self):
pass
def _update_full_mask(self, attention_mask: Union[torch.Tensor, None], inputs_embeds: torch.Tensor):
pass
def _update_causal_mask(self,... | 10 | 1 | 9 | 0 | 9 | 0 | 3 | 0 | 1 | 0 | 0 | 8 | 2 | 0 | 2 | 2 | 28 | 2 | 26 | 14 | 22 | 0 | 21 | 13 | 18 | 5 | 1 | 2 | 6 |
3,714 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/modeling_mbart.py | transformers.models.mbart.modeling_mbart.MBartScaledWordEmbedding | from torch import nn
from typing import Callable, Optional, Union
import torch
class MBartScaledWordEmbedding(nn.Embedding):
"""
This module overrides nn.Embeddings' forward by multiplying with embeddings scale.
"""
def __init__(self, num_embeddings: int, embedding_dim: int, padding_idx: int, embed_sc... |
class MBartScaledWordEmbedding(nn.Embedding):
'''
This module overrides nn.Embeddings' forward by multiplying with embeddings scale.
'''
def __init__(self, num_embeddings: int, embedding_dim: int, padding_idx: int, embed_scale: Optional[float]=1.0):
pass
def forward(self, input_ids: torch... | 3 | 1 | 3 | 0 | 3 | 0 | 1 | 0.5 | 1 | 4 | 0 | 0 | 2 | 1 | 2 | 2 | 11 | 2 | 6 | 4 | 3 | 3 | 6 | 4 | 3 | 1 | 1 | 0 | 2 |
3,715 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/tokenization_mbart.py | transformers.models.mbart.tokenization_mbart.MBartTokenizer | import os
from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer
from typing import Any, Optional
import sentencepiece as spm
from ...utils.import_utils import requires
from shutil import copyfile
@requires(backends=('sentencepiece',))
class MBartTokenizer(PreTrainedTokenizer):
"""
Co... | @requires(backends=('sentencepiece',))
class MBartTokenizer(PreTrainedTokenizer):
'''
Construct an MBART tokenizer.
Adapted from [`RobertaTokenizer`] and [`XLNetTokenizer`]. Based on
[SentencePiece](https://github.com/google/sentencepiece).
The tokenization method is `<tokens> <eos> <language code>`... | 26 | 10 | 12 | 1 | 8 | 3 | 2 | 0.41 | 1 | 10 | 1 | 0 | 21 | 14 | 21 | 110 | 302 | 56 | 175 | 88 | 119 | 72 | 116 | 53 | 94 | 5 | 3 | 2 | 38 |
3,716 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/tokenization_mbart_fast.py | transformers.models.mbart.tokenization_mbart_fast.MBartTokenizerFast | import os
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...tokenization_utils import AddedToken, BatchEncoding
from typing import Optional
from tokenizers import processors
from shutil import copyfile
class MBartTokenizerFast(PreTrainedTokenizerFast):
"""
Construct a "fast" MBART tokenize... |
class MBartTokenizerFast(PreTrainedTokenizerFast):
'''
Construct a "fast" MBART tokenizer (backed by HuggingFace's *tokenizers* library). Based on
[BPE](https://huggingface.co/docs/tokenizers/python/latest/components.html?highlight=BPE#models).
This tokenizer inherits from [`PreTrainedTokenizerFast`] w... | 15 | 6 | 14 | 2 | 10 | 3 | 2 | 0.36 | 1 | 8 | 1 | 0 | 13 | 5 | 13 | 101 | 229 | 42 | 137 | 65 | 92 | 50 | 75 | 34 | 61 | 5 | 3 | 1 | 24 |
3,717 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart50/tokenization_mbart50.py | transformers.models.mbart50.tokenization_mbart50.MBart50Tokenizer | from shutil import copyfile
from ...utils.import_utils import requires
import sentencepiece as spm
from typing import Any, Optional
import os
from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer
@requires(backends=('sentencepiece',))
class MBart50Tokenizer(PreTrainedTokenizer):
"""
... | @requires(backends=('sentencepiece',))
class MBart50Tokenizer(PreTrainedTokenizer):
'''
Construct a MBart50 tokenizer. Based on [SentencePiece](https://github.com/google/sentencepiece).
This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
th... | 25 | 9 | 12 | 1 | 8 | 2 | 2 | 0.57 | 1 | 9 | 1 | 0 | 20 | 13 | 20 | 109 | 319 | 53 | 170 | 81 | 120 | 97 | 120 | 51 | 99 | 5 | 3 | 3 | 38 |
3,718 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart50/tokenization_mbart50_fast.py | transformers.models.mbart50.tokenization_mbart50_fast.MBart50TokenizerFast | from tokenizers import processors
import os
from typing import Optional
from ...tokenization_utils import AddedToken, BatchEncoding
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from shutil import copyfile
class MBart50TokenizerFast(PreTrainedTokenizerFast):
"""
Construct a "fast" MBART tokeni... |
class MBart50TokenizerFast(PreTrainedTokenizerFast):
'''
Construct a "fast" MBART tokenizer for mBART-50 (backed by HuggingFace's *tokenizers* library). Based on
[BPE](https://huggingface.co/docs/tokenizers/python/latest/components.html?highlight=BPE#models).
This tokenizer inherits from [`PreTrainedTo... | 14 | 5 | 13 | 1 | 10 | 2 | 2 | 0.48 | 1 | 8 | 1 | 0 | 12 | 5 | 12 | 100 | 219 | 36 | 124 | 57 | 84 | 59 | 68 | 30 | 55 | 5 | 3 | 1 | 21 |
3,719 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/configuration_megatron_bert.py | transformers.models.megatron_bert.configuration_megatron_bert.MegatronBertConfig | from ...configuration_utils import PretrainedConfig
class MegatronBertConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`MegatronBertModel`]. It is used to instantiate a
MEGATRON_BERT model according to the specified arguments, defining the model architecture. I... |
class MegatronBertConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`MegatronBertModel`]. It is used to instantiate a
MEGATRON_BERT model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults w... | 2 | 1 | 35 | 1 | 34 | 0 | 1 | 1.56 | 1 | 1 | 0 | 0 | 1 | 14 | 1 | 1 | 103 | 11 | 36 | 35 | 16 | 56 | 18 | 17 | 16 | 1 | 1 | 0 | 1 |
3,720 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertAttention | import torch
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Optional, Union
from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer
from ...utils.deprecation import deprecate_kwarg
from torch import nn
class MegatronBertAttent... |
class MegatronBertAttention(nn.Module):
def __init__(self, config, layer_idx=None):
pass
def prune_heads(self, heads):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Floa... | 5 | 0 | 15 | 1 | 14 | 1 | 1 | 0.07 | 1 | 6 | 2 | 0 | 3 | 4 | 3 | 13 | 49 | 4 | 43 | 22 | 30 | 3 | 24 | 13 | 20 | 2 | 1 | 1 | 4 |
3,721 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertEmbeddings | import torch
from typing import Optional, Union
from torch import nn
class MegatronBertEmbeddings(nn.Module):
"""Construct the embeddings from word, position and token_type embeddings."""
def __init__(self, config):
super().__init__()
self.word_embeddings = nn.Embedding(config.vocab_size, conf... |
class MegatronBertEmbeddings(nn.Module):
'''Construct the embeddings from word, position and token_type embeddings.'''
def __init__(self, config):
pass
def forward(self, input_ids: Optional[torch.LongTensor]=None, token_type_ids: Optional[torch.LongTensor]=None, position_ids: Optional[torch.LongT... | 3 | 1 | 26 | 5 | 18 | 4 | 4 | 0.22 | 1 | 3 | 0 | 0 | 2 | 5 | 2 | 12 | 56 | 11 | 37 | 20 | 27 | 8 | 27 | 13 | 24 | 6 | 1 | 1 | 7 |
3,722 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertEncoder | from torch import nn
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, NextSentencePredictorOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifier... |
class MegatronBertEncoder(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, encoder_hidden_states: Optional[torch.FloatTensor]=None, encoder_attention_mask: Optiona... | 3 | 0 | 49 | 5 | 42 | 3 | 9 | 0.06 | 1 | 8 | 2 | 0 | 2 | 4 | 2 | 12 | 100 | 10 | 85 | 27 | 70 | 5 | 37 | 15 | 34 | 17 | 1 | 3 | 18 |
3,723 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertForCausalLM | from ...utils import ModelOutput, auto_docstring, logging
import torch
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Optional, Union
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, CausalLMOutputWithCrossAt... | @auto_docstring(custom_intro='\n MegatronBert Model with a `language modeling` head on top for CLM fine-tuning.\n ')
class MegatronBertForCausalLM(MegatronBertPreTrainedModel, GenerationMixin):
def __init__(self, config):
pass
def get_output_embeddings(self):
pass
def set_output_emb... | 7 | 1 | 25 | 3 | 15 | 7 | 2 | 0.41 | 2 | 7 | 3 | 0 | 5 | 2 | 5 | 6 | 134 | 21 | 80 | 34 | 55 | 33 | 33 | 16 | 27 | 6 | 2 | 1 | 12 |
3,724 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertForMaskedLM | import torch
from typing import Optional, Union
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, NextSentencePredictorOutput, QuestionAnsweringModelOutput, SequenceClassi... | @auto_docstring
class MegatronBertForMaskedLM(MegatronBertPreTrainedModel):
def __init__(self, config):
pass
def get_output_embeddings(self):
pass
def set_output_embeddings(self, new_embeddings):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=... | 8 | 1 | 18 | 2 | 14 | 2 | 2 | 0.12 | 1 | 6 | 3 | 0 | 5 | 2 | 5 | 6 | 102 | 16 | 78 | 33 | 52 | 9 | 36 | 18 | 30 | 5 | 2 | 1 | 11 |
3,725 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertForMultipleChoice | from torch import nn
import torch
from typing import Optional, Union
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, NextSentencePredictorOutput, QuestionAnsweringModelO... | @auto_docstring
class MegatronBertForMultipleChoice(MegatronBertPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.FloatTensor]=None, token_type_ids: Optional[torch.LongTensor]=None, positio... | 5 | 1 | 37 | 5 | 29 | 4 | 6 | 0.1 | 1 | 4 | 2 | 0 | 2 | 3 | 2 | 3 | 84 | 10 | 67 | 29 | 44 | 7 | 28 | 14 | 25 | 11 | 2 | 1 | 12 |
3,726 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertForNextSentencePrediction | import warnings
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...utils import ModelOutput, auto_docstring, logging
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, Multiple... | @auto_docstring(custom_intro='\n MegatronBert Model with a `next sentence prediction (classification)` head on top.\n ')
class MegatronBertForNextSentencePrediction(MegatronBertPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongT... | 5 | 1 | 46 | 9 | 27 | 11 | 4 | 0.38 | 1 | 6 | 3 | 0 | 2 | 2 | 2 | 3 | 95 | 18 | 56 | 25 | 38 | 21 | 22 | 11 | 19 | 6 | 2 | 1 | 7 |
3,727 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertForPreTraining | import torch
from typing import Optional, Union
from ...utils import ModelOutput, auto_docstring, logging
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
@auto_docstring(custom_intro='\n MegatronBert Model with two heads on top as done during the pretraining: a `masked language modeling` head and ... | @auto_docstring(custom_intro='\n MegatronBert Model with two heads on top as done during the pretraining: a `masked language modeling` head and a\n `next sentence prediction (classification)` head.\n ')
class MegatronBertForPreTraining(MegatronBertPreTrainedModel):
def __init__(self, config, add_binary_he... | 7 | 2 | 23 | 4 | 14 | 6 | 2 | 0.43 | 1 | 5 | 3 | 0 | 4 | 2 | 4 | 5 | 101 | 18 | 58 | 30 | 38 | 25 | 27 | 16 | 22 | 5 | 2 | 1 | 8 |
3,728 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertForPreTrainingOutput | from ...utils import ModelOutput, auto_docstring, logging
from dataclasses import dataclass
import torch
from typing import Optional, Union
@dataclass
@auto_docstring(custom_intro='\n Output type of [`MegatronBertForPreTraining`].\n ')
class MegatronBertForPreTrainingOutput(ModelOutput):
"""
loss (*optio... | @dataclass
@auto_docstring(custom_intro='\n Output type of [`MegatronBertForPreTraining`].\n ')
class MegatronBertForPreTrainingOutput(ModelOutput):
'''
loss (*optional*, returned when `labels` is provided, `torch.FloatTensor` of shape `(1,)`):
Total loss as the sum of the masked language modeling... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 31 | 4 | 6 | 6 | 5 | 21 | 6 | 6 | 5 | 0 | 1 | 0 | 0 |
3,729 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertForQuestionAnswering | from torch import nn
from ...utils import ModelOutput, auto_docstring, logging
import torch
from typing import Optional, Union
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, MultipleChoiceModelOu... | @auto_docstring
class MegatronBertForQuestionAnswering(MegatronBertPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.FloatTensor]=None, token_type_ids: Optional[torch.LongTensor]=None, posi... | 5 | 0 | 41 | 5 | 30 | 7 | 4 | 0.19 | 1 | 4 | 2 | 0 | 2 | 3 | 2 | 3 | 90 | 10 | 67 | 30 | 45 | 13 | 32 | 16 | 29 | 7 | 2 | 2 | 8 |
3,730 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertForSequenceClassification | from torch import nn
from ...utils import ModelOutput, auto_docstring, logging
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, Mul... | @auto_docstring(custom_intro='\n MegatronBert Model transformer with a sequence classification/regression head on top (a linear layer on top of the\n pooled output) e.g. for GLUE tasks.\n ')
class MegatronBertForSequenceClassification(MegatronBertPreTrainedModel):
def __init__(self, config):
pass
... | 5 | 1 | 40 | 4 | 33 | 4 | 7 | 0.1 | 1 | 5 | 2 | 0 | 2 | 4 | 2 | 3 | 88 | 9 | 72 | 26 | 51 | 7 | 34 | 13 | 31 | 12 | 2 | 3 | 13 |
3,731 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertForTokenClassification | import torch
from ...utils import ModelOutput, auto_docstring, logging
from typing import Optional, Union
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, NextSentencePre... | @auto_docstring
class MegatronBertForTokenClassification(MegatronBertPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.FloatTensor]=None, token_type_ids: Optional[torch.LongTensor]=None, po... | 5 | 1 | 31 | 4 | 24 | 3 | 3 | 0.09 | 1 | 4 | 2 | 0 | 2 | 4 | 2 | 3 | 69 | 9 | 55 | 26 | 34 | 5 | 22 | 13 | 19 | 5 | 2 | 1 | 6 |
3,732 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertIntermediate | from ...activations import ACT2FN
import torch
from torch import nn
class MegatronBertIntermediate(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.intermediate_size)
if isinstance(config.hidden_act, str):
self.interme... |
class MegatronBertIntermediate(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 6 | 0 | 6 | 0 | 2 | 0 | 1 | 3 | 0 | 0 | 2 | 2 | 2 | 12 | 13 | 1 | 12 | 5 | 9 | 0 | 11 | 5 | 8 | 2 | 1 | 1 | 3 |
3,733 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertLMPredictionHead | from torch import nn
import torch
class MegatronBertLMPredictionHead(nn.Module):
def __init__(self, config):
super().__init__()
self.transform = MegatronBertPredictionHeadTransform(config)
self.decoder = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
self.bias = nn.Pa... |
class MegatronBertLMPredictionHead(nn.Module):
def __init__(self, config):
pass
def _tie_weights(self):
pass
def forward(self, hidden_states):
pass | 4 | 0 | 6 | 1 | 4 | 1 | 1 | 0.23 | 1 | 2 | 1 | 0 | 3 | 3 | 3 | 13 | 21 | 5 | 13 | 7 | 9 | 3 | 13 | 7 | 9 | 1 | 1 | 0 | 3 |
3,734 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertLayer | import torch
from ...utils.deprecation import deprecate_kwarg
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Optional, Union
from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer
from ...modeling_layers import GradientCheckpo... |
class MegatronBertLayer(GradientCheckpointingLayer):
def __init__(self, config, layer_idx=None):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[... | 5 | 0 | 28 | 2 | 24 | 2 | 4 | 0.1 | 1 | 8 | 3 | 0 | 3 | 9 | 3 | 13 | 86 | 9 | 72 | 34 | 59 | 7 | 43 | 25 | 39 | 7 | 1 | 2 | 11 |
3,735 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertModel | import torch
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from typing import Optional, Union
from ...utils import ModelOutput, auto_docstring, logging
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, CausalLMOutputWithCrossAt... | @auto_docstring
class MegatronBertModel(MegatronBertPreTrainedModel):
'''
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 [Attention is
all you... | 8 | 3 | 29 | 3 | 19 | 7 | 5 | 0.41 | 1 | 8 | 4 | 0 | 5 | 4 | 5 | 6 | 168 | 23 | 103 | 39 | 76 | 42 | 51 | 23 | 45 | 17 | 2 | 2 | 23 |
3,736 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertOnlyMLMHead | from torch import nn
import torch
class MegatronBertOnlyMLMHead(nn.Module):
def __init__(self, config):
super().__init__()
self.predictions = MegatronBertLMPredictionHead(config)
def forward(self, sequence_output: torch.Tensor) -> torch.Tensor:
prediction_scores = self.predictions(seq... |
class MegatronBertOnlyMLMHead(nn.Module):
def __init__(self, config):
pass
def forward(self, sequence_output: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 3 | 1 | 0 | 2 | 1 | 2 | 12 | 8 | 1 | 7 | 5 | 4 | 0 | 7 | 5 | 4 | 1 | 1 | 0 | 2 |
3,737 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertOnlyNSPHead | from torch import nn
class MegatronBertOnlyNSPHead(nn.Module):
def __init__(self, config):
super().__init__()
self.seq_relationship = nn.Linear(config.hidden_size, 2)
def forward(self, pooled_output):
seq_relationship_score = self.seq_relationship(pooled_output)
return seq_rel... |
class MegatronBertOnlyNSPHead(nn.Module):
def __init__(self, config):
pass
def forward(self, pooled_output):
pass | 3 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 2 | 1 | 2 | 12 | 8 | 1 | 7 | 5 | 4 | 0 | 7 | 5 | 4 | 1 | 1 | 0 | 2 |
3,738 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertOutput | import torch
from torch import nn
class MegatronBertOutput(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.intermediate_size, config.hidden_size)
self.dropout = nn.Dropout(config.hidden_dropout_prob)
def forward(self, hidden_states: torch.Tenso... |
class MegatronBertOutput(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor, input_tensor: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 2 | 2 | 2 | 12 | 10 | 1 | 9 | 5 | 6 | 0 | 9 | 5 | 6 | 1 | 1 | 0 | 2 |
3,739 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertPooler | import torch
from torch import nn
class MegatronBertPooler(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.activation = nn.Tanh()
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
firs... |
class MegatronBertPooler(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 6 | 0 | 5 | 1 | 1 | 0.2 | 1 | 2 | 0 | 0 | 2 | 2 | 2 | 12 | 13 | 1 | 10 | 7 | 7 | 2 | 10 | 7 | 7 | 1 | 1 | 0 | 2 |
3,740 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertPreTrainedModel | from ...utils import ModelOutput, auto_docstring, logging
from ...modeling_utils import PreTrainedModel
from torch import nn
from .configuration_megatron_bert import MegatronBertConfig
@auto_docstring
class MegatronBertPreTrainedModel(PreTrainedModel):
config: MegatronBertConfig
base_model_prefix = 'bert'
... | @auto_docstring
class MegatronBertPreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
'''Initialize the weights'''
pass | 3 | 1 | 11 | 0 | 8 | 3 | 4 | 0.54 | 1 | 0 | 0 | 9 | 1 | 0 | 1 | 1 | 22 | 2 | 13 | 6 | 11 | 7 | 12 | 6 | 10 | 4 | 1 | 1 | 4 |
3,741 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertPreTrainingHeads | from torch import nn
class MegatronBertPreTrainingHeads(nn.Module):
def __init__(self, config):
super().__init__()
self.predictions = MegatronBertLMPredictionHead(config)
self.seq_relationship = nn.Linear(config.hidden_size, 2)
def forward(self, sequence_output, pooled_output):
... |
class MegatronBertPreTrainingHeads(nn.Module):
def __init__(self, config):
pass
def forward(self, sequence_output, pooled_output):
pass | 3 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 2 | 2 | 2 | 12 | 10 | 1 | 9 | 7 | 6 | 0 | 9 | 7 | 6 | 1 | 1 | 0 | 2 |
3,742 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertPredictionHeadTransform | from ...activations import ACT2FN
import torch
from torch import nn
class MegatronBertPredictionHeadTransform(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
if isinstance(config.hidden_act, str):
self.tr... |
class MegatronBertPredictionHeadTransform(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 7 | 0 | 7 | 0 | 2 | 0 | 1 | 3 | 0 | 0 | 2 | 3 | 2 | 12 | 15 | 1 | 14 | 6 | 11 | 0 | 13 | 6 | 10 | 2 | 1 | 1 | 3 |
3,743 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertSelfAttention | from ...utils.deprecation import deprecate_kwarg
import math
from torch import nn
from typing import Optional, Union
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
import torch
class MegatronBertSelfAttention(nn.Module):
def __init__(self, config, position_embedding_type=None, layer_idx=None)... |
class MegatronBertSelfAttention(nn.Module):
def __init__(self, config, position_embedding_type=None, layer_idx=None):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None,... | 4 | 0 | 43 | 7 | 31 | 6 | 6 | 0.19 | 1 | 5 | 0 | 0 | 3 | 11 | 3 | 13 | 132 | 22 | 93 | 44 | 80 | 18 | 72 | 35 | 68 | 13 | 1 | 2 | 17 |
3,744 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/megatron_bert/modeling_megatron_bert.py | transformers.models.megatron_bert.modeling_megatron_bert.MegatronBertSelfOutput | import torch
from torch import nn
class MegatronBertSelfOutput(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.dropout = nn.Dropout(config.hidden_dropout_prob)
def forward(self, hidden_states: torch.Tensor,... |
class MegatronBertSelfOutput(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor, residual: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 2 | 2 | 2 | 12 | 10 | 1 | 9 | 5 | 6 | 0 | 9 | 5 | 6 | 1 | 1 | 0 | 2 |
3,745 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mgp_str/configuration_mgp_str.py | transformers.models.mgp_str.configuration_mgp_str.MgpstrConfig | from ...configuration_utils import PretrainedConfig
class MgpstrConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of an [`MgpstrModel`]. It is used to instantiate an
MGP-STR model according to the specified arguments, defining the model architecture. Instantiating a c... |
class MgpstrConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of an [`MgpstrModel`]. It is used to instantiate an
MGP-STR model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a simi... | 2 | 1 | 44 | 1 | 43 | 0 | 1 | 1.24 | 1 | 1 | 0 | 0 | 1 | 19 | 1 | 1 | 111 | 10 | 45 | 44 | 21 | 56 | 23 | 22 | 21 | 1 | 1 | 0 | 1 |
3,746 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mgp_str/modeling_mgp_str.py | transformers.models.mgp_str.modeling_mgp_str.MgpstrA3Module | import torch
import torch.nn.functional as F
from .configuration_mgp_str import MgpstrConfig
from torch import nn
class MgpstrA3Module(nn.Module):
def __init__(self, config: MgpstrConfig):
super().__init__()
self.token_norm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
self... |
class MgpstrA3Module(nn.Module):
def __init__(self, config: MgpstrConfig):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 12 | 1 | 11 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 2 | 4 | 2 | 12 | 26 | 3 | 23 | 11 | 20 | 0 | 18 | 11 | 15 | 1 | 1 | 0 | 2 |
3,747 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mgp_str/modeling_mgp_str.py | transformers.models.mgp_str.modeling_mgp_str.MgpstrAttention | from .configuration_mgp_str import MgpstrConfig
from torch import nn
class MgpstrAttention(nn.Module):
def __init__(self, config: MgpstrConfig):
super().__init__()
self.num_heads = config.num_attention_heads
head_dim = config.hidden_size // config.num_attention_heads
self.scale = h... |
class MgpstrAttention(nn.Module):
def __init__(self, config: MgpstrConfig):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 14 | 2 | 12 | 1 | 1 | 0.04 | 1 | 2 | 1 | 0 | 2 | 6 | 2 | 12 | 29 | 4 | 25 | 15 | 22 | 1 | 21 | 15 | 18 | 1 | 1 | 0 | 2 |
3,748 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mgp_str/modeling_mgp_str.py | transformers.models.mgp_str.modeling_mgp_str.MgpstrDropPath | from typing import Optional, Union
import torch.nn.functional as F
import torch
from torch import nn
class MgpstrDropPath(nn.Module):
"""Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks)."""
def __init__(self, drop_prob: Optional[float]=None) -> None:
super().__in... |
class MgpstrDropPath(nn.Module):
'''Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).'''
def __init__(self, drop_prob: Optional[float]=None) -> None:
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass
def extra_repr(self) ... | 4 | 1 | 2 | 0 | 2 | 0 | 1 | 0.13 | 1 | 4 | 0 | 0 | 3 | 1 | 3 | 13 | 12 | 3 | 8 | 5 | 4 | 1 | 8 | 5 | 4 | 1 | 1 | 0 | 3 |
3,749 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mgp_str/modeling_mgp_str.py | transformers.models.mgp_str.modeling_mgp_str.MgpstrEmbeddings | from torch import nn
import torch.nn.functional as F
import collections.abc
from .configuration_mgp_str import MgpstrConfig
import torch
class MgpstrEmbeddings(nn.Module):
"""2D Image to Patch Embedding"""
def __init__(self, config: MgpstrConfig):
super().__init__()
image_size = config.image_s... |
class MgpstrEmbeddings(nn.Module):
'''2D Image to Patch Embedding'''
def __init__(self, config: MgpstrConfig):
pass
def forward(self, pixel_values):
pass | 3 | 1 | 20 | 3 | 17 | 1 | 3 | 0.06 | 1 | 4 | 1 | 0 | 2 | 9 | 2 | 12 | 44 | 8 | 35 | 18 | 32 | 2 | 25 | 18 | 22 | 4 | 1 | 1 | 6 |
3,750 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mgp_str/modeling_mgp_str.py | transformers.models.mgp_str.modeling_mgp_str.MgpstrEncoder | import torch.nn.functional as F
import torch
from .configuration_mgp_str import MgpstrConfig
from ...modeling_outputs import BaseModelOutput
from torch import nn
class MgpstrEncoder(nn.Module):
def __init__(self, config: MgpstrConfig):
super().__init__()
dpr = [x.item() for x in torch.linspace(0, ... |
class MgpstrEncoder(nn.Module):
def __init__(self, config: MgpstrConfig):
pass
def forward(self, hidden_states, output_attentions=False, output_hidden_states=False, return_dict=True):
pass | 3 | 0 | 16 | 3 | 13 | 1 | 5 | 0.04 | 1 | 7 | 3 | 0 | 2 | 1 | 2 | 12 | 34 | 7 | 26 | 9 | 23 | 1 | 20 | 9 | 17 | 8 | 1 | 2 | 9 |
3,751 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mgp_str/modeling_mgp_str.py | transformers.models.mgp_str.modeling_mgp_str.MgpstrForSceneTextRecognition | import torch.nn.functional as F
from ...utils import ModelOutput, auto_docstring, logging
import torch
from torch import nn
from typing import Optional, Union
from .configuration_mgp_str import MgpstrConfig
@auto_docstring(custom_intro='\n MGP-STR Model transformer with three classification heads on top (three A^3 ... | @auto_docstring(custom_intro='\n MGP-STR Model transformer with three classification heads on top (three A^3 modules and three linear layer on top\n of the transformer encoder output) for scene text recognition (STR) .\n ')
class MgpstrForSceneTextRecognition(MgpstrPreTrainedModel):
def __init__(self, con... | 5 | 1 | 44 | 8 | 24 | 13 | 4 | 0.48 | 1 | 7 | 4 | 0 | 2 | 8 | 2 | 3 | 95 | 18 | 52 | 32 | 40 | 25 | 31 | 24 | 28 | 6 | 2 | 1 | 7 |
3,752 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mgp_str/modeling_mgp_str.py | transformers.models.mgp_str.modeling_mgp_str.MgpstrLayer | from .configuration_mgp_str import MgpstrConfig
from torch import nn
class MgpstrLayer(nn.Module):
def __init__(self, config: MgpstrConfig, drop_path=None):
super().__init__()
self.norm1 = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
self.attn = MgpstrAttention(config)
... |
class MgpstrLayer(nn.Module):
def __init__(self, config: MgpstrConfig, drop_path=None):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 11 | 2 | 8 | 2 | 2 | 0.18 | 1 | 6 | 4 | 0 | 2 | 5 | 2 | 12 | 24 | 4 | 17 | 13 | 14 | 3 | 17 | 13 | 14 | 2 | 1 | 0 | 3 |
3,753 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mgp_str/modeling_mgp_str.py | transformers.models.mgp_str.modeling_mgp_str.MgpstrMlp | from .configuration_mgp_str import MgpstrConfig
from torch import nn
class MgpstrMlp(nn.Module):
"""MLP as used in Vision Transformer, MLP-Mixer and related networks"""
def __init__(self, config: MgpstrConfig, hidden_features):
super().__init__()
hidden_features = hidden_features or config.hid... |
class MgpstrMlp(nn.Module):
'''MLP as used in Vision Transformer, MLP-Mixer and related networks'''
def __init__(self, config: MgpstrConfig, hidden_features):
pass
def forward(self, hidden_states):
pass | 3 | 1 | 7 | 0 | 7 | 0 | 1 | 0.07 | 1 | 2 | 1 | 0 | 2 | 4 | 2 | 12 | 18 | 2 | 15 | 7 | 12 | 1 | 15 | 7 | 12 | 1 | 1 | 0 | 2 |
3,754 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mgp_str/modeling_mgp_str.py | transformers.models.mgp_str.modeling_mgp_str.MgpstrModel | from torch import nn
import torch.nn.functional as F
from ...modeling_outputs import BaseModelOutput
from typing import Optional, Union
from ...utils import ModelOutput, auto_docstring, logging
import torch
from .configuration_mgp_str import MgpstrConfig
@auto_docstring
class MgpstrModel(MgpstrPreTrainedModel):
d... | @auto_docstring
class MgpstrModel(MgpstrPreTrainedModel):
def __init__(self, config: MgpstrConfig):
pass
def get_input_embeddings(self) -> nn.Module:
pass
@auto_docstring
def forward(self, pixel_values: torch.FloatTensor, output_attentions: Optional[bool]=None, output_hidden_states: Op... | 6 | 0 | 13 | 1 | 12 | 0 | 3 | 0 | 1 | 7 | 4 | 0 | 3 | 3 | 3 | 4 | 43 | 6 | 37 | 16 | 26 | 0 | 19 | 9 | 15 | 6 | 2 | 1 | 8 |
3,755 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mgp_str/modeling_mgp_str.py | transformers.models.mgp_str.modeling_mgp_str.MgpstrModelOutput | from dataclasses import dataclass
from ...utils import ModelOutput, auto_docstring, logging
import torch.nn.functional as F
from typing import Optional, Union
import torch
@dataclass
@auto_docstring(custom_intro="\n Base class for vision model's outputs that also contains image embeddings of the pooling of the last... | @dataclass
@auto_docstring(custom_intro="\n Base class for vision model's outputs that also contains image embeddings of the pooling of the last hidden states.\n ")
class MgpstrModelOutput(ModelOutput):
'''
logits (`tuple(torch.FloatTensor)` of shape `(batch_size, config.num_character_labels)`):
T... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 4.8 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 35 | 6 | 5 | 5 | 4 | 24 | 5 | 5 | 4 | 0 | 1 | 0 | 0 |
3,756 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mgp_str/modeling_mgp_str.py | transformers.models.mgp_str.modeling_mgp_str.MgpstrPreTrainedModel | from ...modeling_utils import PreTrainedModel
from .configuration_mgp_str import MgpstrConfig
from torch import nn
from ...utils import ModelOutput, auto_docstring, logging
@auto_docstring
class MgpstrPreTrainedModel(PreTrainedModel):
config: MgpstrConfig
base_model_prefix = 'mgp_str'
_no_split_modules = [... | @auto_docstring
class MgpstrPreTrainedModel(PreTrainedModel):
def _init_weights(self, module: nn.Module) -> None:
'''Initialize the weights'''
pass | 3 | 1 | 12 | 0 | 11 | 1 | 5 | 0.33 | 1 | 1 | 1 | 2 | 1 | 0 | 1 | 1 | 22 | 2 | 15 | 5 | 13 | 5 | 13 | 5 | 11 | 5 | 1 | 2 | 5 |
3,757 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mgp_str/processing_mgp_str.py | transformers.models.mgp_str.processing_mgp_str.DecodeType | from transformers.utils.generic import ExplicitEnum
class DecodeType(ExplicitEnum):
CHARACTER = 'char'
BPE = 'bpe'
WORDPIECE = 'wp' |
class DecodeType(ExplicitEnum):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 116 | 4 | 0 | 4 | 4 | 3 | 0 | 4 | 4 | 3 | 0 | 5 | 0 | 0 |
3,758 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mgp_str/processing_mgp_str.py | transformers.models.mgp_str.processing_mgp_str.MgpstrProcessor | from ...processing_utils import ProcessorMixin
from transformers import AutoTokenizer
from ...utils.import_utils import requires
import warnings
@requires(backends=('sentencepiece',))
class MgpstrProcessor(ProcessorMixin):
"""
Constructs a MGP-STR processor which wraps an image processor and MGP-STR tokenizers... | @requires(backends=('sentencepiece',))
class MgpstrProcessor(ProcessorMixin):
'''
Constructs a MGP-STR processor which wraps an image processor and MGP-STR tokenizers into a single
[`MgpstrProcessor`] offers all the functionalities of `ViTImageProcessor`] and [`MgpstrTokenizer`]. See the
[`~MgpstrProces... | 9 | 7 | 24 | 3 | 13 | 8 | 3 | 0.68 | 1 | 6 | 1 | 0 | 7 | 3 | 7 | 24 | 192 | 28 | 98 | 47 | 90 | 67 | 89 | 47 | 81 | 7 | 2 | 1 | 23 |
3,759 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mgp_str/tokenization_mgp_str.py | transformers.models.mgp_str.tokenization_mgp_str.MgpstrTokenizer | from ...tokenization_utils import PreTrainedTokenizer
import os
import json
from typing import Optional
class MgpstrTokenizer(PreTrainedTokenizer):
"""
Construct a MGP-STR char tokenizer.
This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
... |
class MgpstrTokenizer(PreTrainedTokenizer):
'''
Construct a MGP-STR char tokenizer.
This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.
Args:
vocab_file (`str`):
... | 9 | 4 | 6 | 0 | 5 | 0 | 1 | 0.54 | 1 | 3 | 0 | 0 | 7 | 2 | 7 | 96 | 72 | 12 | 39 | 18 | 30 | 21 | 30 | 15 | 22 | 3 | 3 | 1 | 10 |
3,760 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/configuration_mimi.py | transformers.models.mimi.configuration_mimi.MimiConfig | from ...configuration_utils import PretrainedConfig
import math
import numpy as np
class MimiConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of an [`MimiModel`]. It is used to instantiate a
Mimi model according to the specified arguments, defining the model architec... |
class MimiConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of an [`MimiModel`]. It is used to instantiate a
Mimi model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a similar conf... | 10 | 1 | 30 | 0 | 29 | 0 | 2 | 1.13 | 1 | 3 | 0 | 0 | 3 | 37 | 3 | 3 | 207 | 11 | 92 | 85 | 46 | 104 | 48 | 43 | 44 | 4 | 1 | 1 | 6 |
3,761 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiAttention | import math
from ...cache_utils import Cache, DynamicCache, StaticCache
from ...utils.deprecation import deprecate_kwarg
from typing import Optional, Union
from .configuration_mimi import MimiConfig
import torch
from torch import nn
class MimiAttention(nn.Module):
"""Multi-headed attention from 'Attention Is All Y... |
class MimiAttention(nn.Module):
'''Multi-headed attention from 'Attention Is All You Need' paper'''
def __init__(self, config: MimiConfig, layer_idx: Optional[int]=None):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states: torch.... | 4 | 1 | 46 | 8 | 37 | 2 | 4 | 0.07 | 1 | 8 | 3 | 2 | 2 | 18 | 2 | 12 | 95 | 18 | 74 | 39 | 62 | 5 | 55 | 30 | 52 | 5 | 1 | 1 | 8 |
3,762 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiConv1d | from torch import nn
from typing import Optional, Union
import torch
class MimiConv1d(nn.Module):
"""Conv1d with asymmetric or causal padding and normalization."""
def __init__(self, config, in_channels: int, out_channels: int, kernel_size: int, stride: int=1, dilation: int=1, groups: int=1, pad_mode: Optiona... |
class MimiConv1d(nn.Module):
'''Conv1d with asymmetric or causal padding and normalization.'''
def __init__(self, config, in_channels: int, out_channels: int, kernel_size: int, stride: int=1, dilation: int=1, groups: int=1, pad_mode: Optional[str]=None, bias: bool=True, layer_idx: Optional[int]=None):
... | 9 | 4 | 15 | 2 | 12 | 1 | 2 | 0.15 | 1 | 6 | 0 | 0 | 5 | 6 | 6 | 16 | 101 | 17 | 73 | 39 | 51 | 11 | 50 | 23 | 43 | 3 | 1 | 1 | 12 |
3,763 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiConvTranspose1d | from torch import nn
import math
class MimiConvTranspose1d(nn.Module):
"""ConvTranspose1d with asymmetric or causal padding and normalization."""
def __init__(self, config, in_channels: int, out_channels: int, kernel_size: int, stride: int=1, groups: int=1, bias=True):
super().__init__()
self.... |
class MimiConvTranspose1d(nn.Module):
'''ConvTranspose1d with asymmetric or causal padding and normalization.'''
def __init__(self, config, in_channels: int, out_channels: int, kernel_size: int, stride: int=1, groups: int=1, bias=True):
pass
def apply_weight_norm(self):
pass
def remo... | 5 | 1 | 13 | 2 | 9 | 2 | 2 | 0.24 | 1 | 3 | 0 | 0 | 4 | 5 | 4 | 14 | 56 | 10 | 37 | 22 | 23 | 9 | 27 | 13 | 22 | 3 | 1 | 1 | 7 |
3,764 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiDecoder | from torch import nn
from .configuration_mimi import MimiConfig
class MimiDecoder(nn.Module):
"""SEANet decoder as used by Mimi."""
def __init__(self, config: MimiConfig):
super().__init__()
scaling = int(2 ** len(config.upsampling_ratios))
model = [MimiConv1d(config, config.hidden_siz... |
class MimiDecoder(nn.Module):
'''SEANet decoder as used by Mimi.'''
def __init__(self, config: MimiConfig):
pass
def forward(self, hidden_states):
pass | 3 | 1 | 13 | 1 | 10 | 2 | 3 | 0.29 | 1 | 7 | 4 | 0 | 2 | 1 | 2 | 12 | 31 | 4 | 21 | 10 | 18 | 6 | 19 | 10 | 16 | 3 | 1 | 2 | 5 |
3,765 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiDecoderOutput | from ...utils import ModelOutput, auto_docstring, logging
import torch
from typing import Optional, Union
from ...cache_utils import Cache, DynamicCache, StaticCache
from dataclasses import dataclass
@dataclass
@auto_docstring
class MimiDecoderOutput(ModelOutput):
"""
audio_values (`torch.FloatTensor` of shap... | @dataclass
@auto_docstring
class MimiDecoderOutput(ModelOutput):
'''
audio_values (`torch.FloatTensor` of shape `(batch_size, segment_length)`, *optional*):
Decoded audio values, obtained using the decoder part of Mimi.
decoder_past_key_values (`Cache`, *optional*):
Pre-computed hidden-stat... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.67 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 17 | 3 | 3 | 3 | 2 | 11 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
3,766 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiEncoder | from .configuration_mimi import MimiConfig
from torch import nn
class MimiEncoder(nn.Module):
"""SEANet encoder as used by Mimi."""
def __init__(self, config: MimiConfig):
super().__init__()
model = [MimiConv1d(config, config.audio_channels, config.num_filters, config.kernel_size)]
sca... |
class MimiEncoder(nn.Module):
'''SEANet encoder as used by Mimi.'''
def __init__(self, config: MimiConfig):
pass
def forward(self, hidden_states, padding_cache=None):
pass | 3 | 1 | 12 | 2 | 9 | 2 | 3 | 0.26 | 1 | 6 | 3 | 0 | 2 | 1 | 2 | 12 | 29 | 5 | 19 | 10 | 16 | 5 | 19 | 10 | 16 | 3 | 1 | 2 | 5 |
3,767 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiEncoderOutput | from dataclasses import dataclass
from ...cache_utils import Cache, DynamicCache, StaticCache
from typing import Optional, Union
import torch
from ...utils import ModelOutput, auto_docstring, logging
@dataclass
@auto_docstring
class MimiEncoderOutput(ModelOutput):
"""
audio_codes (`torch.LongTensor` of shape ... | @dataclass
@auto_docstring
class MimiEncoderOutput(ModelOutput):
'''
audio_codes (`torch.LongTensor` of shape `(batch_size, num_quantizers, codes_length)`, *optional*):
Discret code embeddings computed using `model.encode`.
encoder_past_key_values (`Cache`, *optional*):
Pre-computed hidden-... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.67 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 17 | 3 | 3 | 3 | 2 | 11 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
3,768 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiEuclideanCodebook | from torch import nn
import torch
from .configuration_mimi import MimiConfig
class MimiEuclideanCodebook(nn.Module):
"""Codebook with Euclidean distance."""
def __init__(self, config: MimiConfig, epsilon: float=1e-05):
super().__init__()
embed = torch.zeros(config.codebook_size, config.codeboo... |
class MimiEuclideanCodebook(nn.Module):
'''Codebook with Euclidean distance.'''
def __init__(self, config: MimiConfig, epsilon: float=1e-05):
pass
@property
def embed(self) -> torch.Tensor:
pass
def quantize(self, hidden_states):
pass
def encode(self, hidden_states):
... | 7 | 1 | 7 | 0 | 5 | 1 | 1 | 0.29 | 1 | 4 | 1 | 0 | 5 | 3 | 5 | 15 | 43 | 7 | 28 | 16 | 21 | 8 | 27 | 15 | 21 | 2 | 1 | 1 | 6 |
3,769 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiFlashAttention2 | from ...cache_utils import Cache, DynamicCache, StaticCache
from typing import Optional, Union
import torch
from ...utils.deprecation import deprecate_kwarg
from ...modeling_flash_attention_utils import flash_attn_supports_top_left_mask, is_flash_attn_available
class MimiFlashAttention2(MimiAttention):
"""
Mim... |
class MimiFlashAttention2(MimiAttention):
'''
Mimi flash attention module. This module inherits from `MimiAttention` as the weights of the module stays
untouched. The only required change would be on the forward pass where it needs to correctly call the public API of
flash attention and deal with paddi... | 4 | 1 | 50 | 9 | 34 | 8 | 5 | 0.29 | 1 | 6 | 2 | 0 | 2 | 2 | 2 | 14 | 108 | 19 | 69 | 25 | 57 | 20 | 40 | 15 | 37 | 8 | 2 | 2 | 9 |
3,770 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiLayerScale | from torch import nn
import torch
class MimiLayerScale(nn.Module):
"""Layer scale from [Touvron et al 2021] (https://huggingface.co/papers/2103.17239).
This rescales diagonally the residual outputs close to 0, with a learnt scale.
"""
def __init__(self, config):
super().__init__()
chan... |
class MimiLayerScale(nn.Module):
'''Layer scale from [Touvron et al 2021] (https://huggingface.co/papers/2103.17239).
This rescales diagonally the residual outputs close to 0, with a learnt scale.
'''
def __init__(self, config):
pass
def forward(self, x: torch.Tensor):
pass | 3 | 1 | 4 | 0 | 4 | 0 | 1 | 0.38 | 1 | 2 | 0 | 0 | 2 | 1 | 2 | 12 | 13 | 2 | 8 | 6 | 5 | 3 | 8 | 6 | 5 | 1 | 1 | 0 | 2 |
3,771 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiMLP | from ...activations import ACT2FN
from torch import nn
import torch
class MimiMLP(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.activation_fn = ACT2FN[config.hidden_act]
self.fc1 = nn.Linear(config.hidden_size, config.intermediate_size, bias=F... |
class MimiMLP(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 6 | 0 | 6 | 0 | 1 | 0.08 | 1 | 2 | 0 | 0 | 2 | 4 | 2 | 12 | 14 | 1 | 12 | 7 | 9 | 1 | 12 | 7 | 9 | 1 | 1 | 0 | 2 |
3,772 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiModel | import math
from ...utils import ModelOutput, auto_docstring, logging
import torch
from .configuration_mimi import MimiConfig
from typing import Optional, Union
from ...cache_utils import Cache, DynamicCache, StaticCache
@auto_docstring(custom_intro='\n The Mimi neural audio codec model.\n ')
class MimiModel(Mim... | @auto_docstring(custom_intro='\n The Mimi neural audio codec model.\n ')
class MimiModel(MimiPreTrainedModel):
def __init__(self, config: MimiConfig):
pass
def get_encoder(self):
pass
def _encode_frame(self, input_values: torch.Tensor, num_quantizers: int, padding_mask: int, past_ke... | 12 | 6 | 33 | 5 | 20 | 8 | 4 | 0.37 | 1 | 17 | 11 | 0 | 8 | 9 | 8 | 9 | 274 | 47 | 166 | 65 | 121 | 61 | 83 | 30 | 74 | 9 | 2 | 2 | 31 |
3,773 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiOutput | import torch
from dataclasses import dataclass
from ...cache_utils import Cache, DynamicCache, StaticCache
from ...utils import ModelOutput, auto_docstring, logging
from typing import Optional, Union
@dataclass
@auto_docstring
class MimiOutput(ModelOutput):
"""
audio_codes (`torch.LongTensor` of shape `(batch... | @dataclass
@auto_docstring
class MimiOutput(ModelOutput):
'''
audio_codes (`torch.LongTensor` of shape `(batch_size, num_quantizers, codes_length)`, *optional*):
Discret code embeddings computed using `model.encode`.
audio_values (`torch.FloatTensor` of shape `(batch_size, sequence_length)`, *optio... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.8 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 29 | 5 | 5 | 5 | 4 | 19 | 5 | 5 | 4 | 0 | 1 | 0 | 0 |
3,774 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiPreTrainedModel | import math
from .configuration_mimi import MimiConfig
from ...modeling_utils import PreTrainedModel
from torch import nn
from ...utils import ModelOutput, auto_docstring, logging
@auto_docstring
class MimiPreTrainedModel(PreTrainedModel):
config: MimiConfig
base_model_prefix = 'mimi'
main_input_name = 'in... | @auto_docstring
class MimiPreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
'''Initialize the weights'''
pass | 3 | 1 | 24 | 0 | 23 | 1 | 12 | 0.18 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 1 | 42 | 2 | 34 | 14 | 32 | 6 | 29 | 14 | 27 | 12 | 1 | 3 | 12 |
3,775 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiResidualVectorQuantizer | from .configuration_mimi import MimiConfig
import torch
from typing import Optional, Union
from torch import nn
class MimiResidualVectorQuantizer(nn.Module):
"""Residual Vector Quantizer."""
def __init__(self, config: MimiConfig, num_quantizers: Optional[int]=None):
super().__init__()
self.cod... |
class MimiResidualVectorQuantizer(nn.Module):
'''Residual Vector Quantizer.'''
def __init__(self, config: MimiConfig, num_quantizers: Optional[int]=None):
pass
def encode(self, embeddings: torch.Tensor, num_quantizers: Optional[int]=None) -> torch.Tensor:
'''
Encode a given input ... | 4 | 3 | 16 | 1 | 13 | 2 | 3 | 0.15 | 1 | 7 | 2 | 0 | 3 | 6 | 3 | 13 | 52 | 7 | 39 | 20 | 35 | 6 | 35 | 20 | 31 | 4 | 1 | 1 | 10 |
3,776 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiResnetBlock | from .configuration_mimi import MimiConfig
from torch import nn
class MimiResnetBlock(nn.Module):
"""
Residual block from SEANet model as used by Mimi.
"""
def __init__(self, config: MimiConfig, dim: int, dilations: list[int]):
super().__init__()
kernel_sizes = (config.residual_kernel_... |
class MimiResnetBlock(nn.Module):
'''
Residual block from SEANet model as used by Mimi.
'''
def __init__(self, config: MimiConfig, dim: int, dilations: list[int]):
pass
def forward(self, hidden_states, padding_cache=None):
pass | 3 | 1 | 13 | 2 | 11 | 0 | 4 | 0.13 | 1 | 7 | 2 | 0 | 2 | 2 | 2 | 12 | 31 | 5 | 23 | 13 | 20 | 3 | 22 | 13 | 19 | 6 | 1 | 1 | 8 |
3,777 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiRotaryEmbedding | from .configuration_mimi import MimiConfig
from ...modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
import torch
from torch import nn
class MimiRotaryEmbedding(nn.Module):
inv_freq: torch.Tensor
def __init__(self, config: MimiConfig, device=None):
super().__init__()
if hasat... |
class MimiRotaryEmbedding(nn.Module):
def __init__(self, config: MimiConfig, device=None):
pass
@torch.no_grad()
@dynamic_rope_update
def forward(self, x, position_ids):
pass | 5 | 0 | 18 | 2 | 13 | 5 | 3 | 0.35 | 1 | 4 | 1 | 0 | 3 | 7 | 3 | 13 | 59 | 8 | 40 | 21 | 35 | 14 | 38 | 20 | 34 | 3 | 1 | 1 | 8 |
3,778 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiSdpaAttention | from ...utils.deprecation import deprecate_kwarg
from typing import Optional, Union
import torch
from ...cache_utils import Cache, DynamicCache, StaticCache
class MimiSdpaAttention(MimiAttention):
"""
Mimi attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from
`M... |
class MimiSdpaAttention(MimiAttention):
'''
Mimi attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from
`MimiAttention` as the weights of the module stays untouched. The only changes are on the forward pass to adapt to
SDPA API.
'''
@deprecate_kwarg('... | 3 | 1 | 78 | 13 | 59 | 6 | 7 | 0.2 | 1 | 4 | 1 | 0 | 1 | 0 | 1 | 13 | 86 | 14 | 60 | 21 | 48 | 12 | 32 | 11 | 30 | 7 | 2 | 1 | 7 |
3,779 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiSplitResidualVectorQuantizer | from torch import nn
from typing import Optional, Union
import torch
from .configuration_mimi import MimiConfig
class MimiSplitResidualVectorQuantizer(nn.Module):
"""Split Residual Vector Quantizer."""
def __init__(self, config: MimiConfig):
super().__init__()
self.codebook_size = config.codeb... |
class MimiSplitResidualVectorQuantizer(nn.Module):
'''Split Residual Vector Quantizer.'''
def __init__(self, config: MimiConfig):
pass
def encode(self, embeddings: torch.Tensor, num_quantizers: Optional[float]=None) -> torch.Tensor:
'''
Encode a given input tensor with the specifi... | 4 | 3 | 16 | 3 | 10 | 3 | 3 | 0.28 | 1 | 6 | 2 | 0 | 3 | 7 | 3 | 13 | 54 | 13 | 32 | 14 | 28 | 9 | 26 | 14 | 22 | 5 | 1 | 1 | 8 |
3,780 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiTransformerLayer | from torch import nn
import torch
from .configuration_mimi import MimiConfig
from typing import Optional, Union
from ...utils.deprecation import deprecate_kwarg
from ...cache_utils import Cache, DynamicCache, StaticCache
from ...modeling_layers import GradientCheckpointingLayer
class MimiTransformerLayer(GradientCheck... |
class MimiTransformerLayer(GradientCheckpointingLayer):
def __init__(self, config: MimiConfig, layer_idx: int):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=None, position_i... | 4 | 1 | 37 | 5 | 22 | 11 | 2 | 0.48 | 1 | 8 | 4 | 0 | 2 | 7 | 2 | 12 | 75 | 10 | 44 | 23 | 31 | 21 | 25 | 13 | 22 | 3 | 1 | 1 | 4 |
3,781 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiTransformerModel | from ...cache_utils import Cache, DynamicCache, StaticCache
from ...modeling_outputs import BaseModelOutputWithPast
from typing import Optional, Union
from .configuration_mimi import MimiConfig
from ...masking_utils import create_causal_mask
import torch
from torch import nn
class MimiTransformerModel(nn.Module):
... |
class MimiTransformerModel(nn.Module):
'''
Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`MimiTransformerLayer`]
Args:
config: MimiConfig
'''
def __init__(self, config: MimiConfig):
pass
def forward(self, hidden_states: Optional[torch.Lo... | 3 | 2 | 80 | 9 | 50 | 22 | 10 | 0.47 | 1 | 15 | 8 | 0 | 3 | 4 | 4 | 14 | 335 | 40 | 202 | 61 | 168 | 95 | 94 | 32 | 89 | 23 | 1 | 3 | 41 |
3,782 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mimi/modeling_mimi.py | transformers.models.mimi.modeling_mimi.MimiVectorQuantization | from .configuration_mimi import MimiConfig
from torch import nn
class MimiVectorQuantization(nn.Module):
"""
Vector quantization implementation. Currently supports only euclidean distance.
"""
def __init__(self, config: MimiConfig):
super().__init__()
self.codebook = MimiEuclideanCodeb... |
class MimiVectorQuantization(nn.Module):
'''
Vector quantization implementation. Currently supports only euclidean distance.
'''
def __init__(self, config: MimiConfig):
pass
def encode(self, hidden_states):
pass
def decode(self, embed_ind):
pass | 4 | 1 | 4 | 0 | 4 | 0 | 1 | 0.25 | 1 | 3 | 2 | 0 | 3 | 1 | 3 | 13 | 18 | 3 | 12 | 7 | 8 | 3 | 12 | 7 | 8 | 1 | 1 | 0 | 3 |
3,783 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mistral/configuration_mistral.py | transformers.models.mistral.configuration_mistral.MistralConfig | from ...configuration_utils import PretrainedConfig
class MistralConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`MistralModel`]. It is used to instantiate an
Mistral model according to the specified arguments, defining the model architecture. Instantiating a ... |
class MistralConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`MistralModel`]. It is used to instantiate an
Mistral model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a sim... | 2 | 1 | 51 | 3 | 47 | 1 | 2 | 1.12 | 1 | 1 | 0 | 0 | 1 | 15 | 1 | 1 | 138 | 13 | 59 | 42 | 35 | 66 | 23 | 20 | 21 | 2 | 1 | 1 | 2 |
3,784 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mistral/modeling_mistral.py | transformers.models.mistral.modeling_mistral.MistralAttention | from ...cache_utils import Cache, DynamicCache
from typing import Callable, Optional, Union
from ...utils.deprecation import deprecate_kwarg
from torch import nn
from ...processing_utils import Unpack
from .configuration_mistral import MistralConfig
from ...modeling_flash_attention_utils import FlashAttentionKwargs
fro... |
class MistralAttention(nn.Module):
'''Multi-headed attention from 'Attention Is All You Need' paper'''
def __init__(self, config: MistralConfig, layer_idx: int):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states: torch.Tensor, p... | 4 | 1 | 31 | 3 | 28 | 1 | 3 | 0.05 | 1 | 6 | 3 | 2 | 2 | 11 | 2 | 12 | 66 | 8 | 56 | 31 | 45 | 3 | 34 | 23 | 31 | 5 | 1 | 2 | 6 |
3,785 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mistral/modeling_mistral.py | transformers.models.mistral.modeling_mistral.MistralDecoderLayer | from ...modeling_layers import GenericForQuestionAnswering, GenericForSequenceClassification, GenericForTokenClassification, GradientCheckpointingLayer
from typing import Callable, Optional, Union
from ...processing_utils import Unpack
from ...utils.deprecation import deprecate_kwarg
from .configuration_mistral import ... |
class MistralDecoderLayer(GradientCheckpointingLayer):
def __init__(self, config: MistralConfig, layer_idx: int):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=None, position... | 4 | 0 | 24 | 3 | 21 | 2 | 2 | 0.07 | 1 | 10 | 6 | 2 | 2 | 5 | 2 | 12 | 50 | 6 | 42 | 22 | 28 | 3 | 21 | 11 | 18 | 2 | 1 | 1 | 3 |
3,786 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mistral/modeling_mistral.py | transformers.models.mistral.modeling_mistral.MistralForCausalLM | import torch
from ...cache_utils import Cache, DynamicCache
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple
from ...processing_utils import Unpack
from typing import Callable, Optional, Union
from ...modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
from torch import nn
f... | @auto_docstring
class MistralForCausalLM(MistralPreTrainedModel, GenerationMixin):
def __init__(self, config):
pass
@can_return_tuple
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.Tensor]=None, position_ids: Optional[torch.LongTenso... | 6 | 1 | 14 | 2 | 9 | 4 | 2 | 0.38 | 2 | 9 | 4 | 3 | 8 | 3 | 8 | 9 | 123 | 21 | 74 | 36 | 47 | 28 | 36 | 20 | 27 | 8 | 2 | 1 | 15 |
3,787 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mistral/modeling_mistral.py | transformers.models.mistral.modeling_mistral.MistralForQuestionAnswering | from ...modeling_layers import GenericForQuestionAnswering, GenericForSequenceClassification, GenericForTokenClassification, GradientCheckpointingLayer
class MistralForQuestionAnswering(GenericForQuestionAnswering, MistralPreTrainedModel):
... |
class MistralForQuestionAnswering(GenericForQuestionAnswering, MistralPreTrainedModel):
pass | 1 | 0 | 18 | 2 | 13 | 3 | 2 | 0.22 | 1 | 5 | 3 | 1 | 4 | 2 | 4 | 5 | 77 | 11 | 55 | 28 | 36 | 12 | 26 | 14 | 21 | 5 | 2 | 1 | 8 |
3,788 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mistral/modeling_mistral.py | transformers.models.mistral.modeling_mistral.MistralForSequenceClassification | from ...modeling_layers import GenericForQuestionAnswering, GenericForSequenceClassification, GenericForTokenClassification, GradientCheckpointingLayer
class MistralForSequenceClassification(GenericForSequenceClassification, MistralPreTrainedModel):
pass |
class MistralForSequenceClassification(GenericForSequenceClassification, MistralPreTrainedModel):
pass | 1 | 0 | 21 | 2 | 17 | 2 | 3 | 0.11 | 1 | 7 | 3 | 3 | 4 | 3 | 4 | 5 | 90 | 11 | 71 | 31 | 53 | 8 | 36 | 18 | 31 | 9 | 2 | 1 | 12 |
3,789 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mistral/modeling_mistral.py | transformers.models.mistral.modeling_mistral.MistralForTokenClassification | from ...modeling_layers import GenericForQuestionAnswering, GenericForSequenceClassification, GenericForTokenClassification, GradientCheckpointingLayer
class MistralForTokenClassification(GenericForTokenClassification, MistralPreTrainedModel):
pass |
class MistralForTokenClassification(GenericForTokenClassification, MistralPreTrainedModel):
pass | 1 | 0 | 17 | 1 | 14 | 2 | 3 | 0.11 | 1 | 5 | 2 | 3 | 4 | 4 | 4 | 5 | 79 | 8 | 64 | 28 | 41 | 7 | 29 | 15 | 24 | 5 | 2 | 1 | 10 |
3,790 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mistral/modeling_mistral.py | transformers.models.mistral.modeling_mistral.MistralMLP | from ...activations import ACT2FN
from torch import nn
class MistralMLP(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.hidden_size = config.hidden_size
self.intermediate_size = config.intermediate_size
self.gate_proj = nn.Linear(self.hi... |
class MistralMLP(nn.Module):
def __init__(self, config):
pass
def forward(self, x):
pass | 3 | 0 | 6 | 0 | 6 | 0 | 1 | 0 | 1 | 1 | 0 | 1 | 2 | 7 | 2 | 12 | 14 | 1 | 13 | 11 | 10 | 0 | 13 | 11 | 10 | 1 | 1 | 0 | 2 |
3,791 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mistral/modeling_mistral.py | transformers.models.mistral.modeling_mistral.MistralModel | import torch
from ...cache_utils import Cache, DynamicCache
from .configuration_mistral import MistralConfig
from typing import Callable, Optional, Union
from ...masking_utils import create_causal_mask, create_sliding_window_causal_mask
from ...modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
fro... | @auto_docstring
class MistralModel(MistralPreTrainedModel):
def __init__(self, config: MistralConfig):
pass
@check_model_inputs
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.Tensor]=None, position_ids: Optional[torch.LongTensor]=Non... | 6 | 0 | 45 | 4 | 34 | 7 | 7 | 0.22 | 1 | 17 | 11 | 2 | 5 | 8 | 6 | 7 | 286 | 33 | 208 | 71 | 169 | 46 | 99 | 38 | 92 | 21 | 2 | 3 | 41 |
3,792 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mistral/modeling_mistral.py | transformers.models.mistral.modeling_mistral.MistralPreTrainedModel | from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from .configuration_mistral import MistralConfig
from ...utils import TransformersKwargs, auto_docstring, can_return_tuple
@auto_docstring
class MistralPreTrainedModel(PreTrainedModel):
config: MistralConfig
base_model_prefix = 'model'
... | @auto_docstring
class MistralPreTrainedModel(PreTrainedModel):
pass | 2 | 0 | 10 | 0 | 10 | 0 | 5 | 0 | 1 | 0 | 0 | 7 | 1 | 0 | 1 | 1 | 24 | 1 | 23 | 15 | 21 | 0 | 22 | 15 | 20 | 5 | 1 | 2 | 5 |
3,793 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mistral/modeling_mistral.py | transformers.models.mistral.modeling_mistral.MistralRMSNorm | from torch import nn
import torch
from ...integrations import use_kernel_forward_from_hub
@use_kernel_forward_from_hub('RMSNorm')
class MistralRMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-06):
"""
MistralRMSNorm is equivalent to T5LayerNorm
"""
super().__init__()
... | @use_kernel_forward_from_hub('RMSNorm')
class MistralRMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-06):
'''
MistralRMSNorm is equivalent to T5LayerNorm
'''
pass
def forward(self, hidden_states):
pass
def extra_repr(self):
pass | 5 | 1 | 5 | 0 | 4 | 1 | 1 | 0.23 | 1 | 2 | 0 | 1 | 3 | 2 | 3 | 13 | 18 | 2 | 13 | 8 | 9 | 3 | 13 | 8 | 9 | 1 | 1 | 0 | 3 |
3,794 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mistral/modeling_mistral.py | transformers.models.mistral.modeling_mistral.MistralRotaryEmbedding | from torch import nn
from .configuration_mistral import MistralConfig
from ...modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
import torch
class MistralRotaryEmbedding(nn.Module):
inv_freq: torch.Tensor
def __init__(self, config: MistralConfig, device=None):
super().__init__()
... |
class MistralRotaryEmbedding(nn.Module):
def __init__(self, config: MistralConfig, device=None):
pass
@torch.no_grad()
@dynamic_rope_update
def forward(self, x, position_ids):
pass | 5 | 0 | 18 | 2 | 13 | 5 | 3 | 0.35 | 1 | 4 | 1 | 2 | 3 | 7 | 3 | 13 | 59 | 8 | 40 | 21 | 35 | 14 | 38 | 20 | 34 | 3 | 1 | 1 | 8 |
3,795 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mistral/modular_mistral.py | transformers.models.mistral.modular_mistral.MistralAttention | from ...processing_utils import Unpack
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS
from ...modeling_flash_attention_utils import FlashAttentionKwargs
import torch
from typing import Callable, Optional
from ...utils.deprecation import deprecate_kwarg
from ..llama.modeling_llama import LlamaAttention, LlamaDeco... |
class MistralAttention(LlamaAttention):
def __init__(self, config: MistralConfig, layer_idx: int):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states: torch.Tensor, position_embeddings: tuple[torch.Tensor, torch.Tensor], attention_ma... | 4 | 0 | 28 | 3 | 24 | 1 | 3 | 0.04 | 1 | 6 | 3 | 0 | 2 | 7 | 2 | 14 | 57 | 7 | 49 | 26 | 38 | 2 | 27 | 16 | 24 | 5 | 2 | 2 | 6 |
3,796 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mistral/modular_mistral.py | transformers.models.mistral.modular_mistral.MistralDecoderLayer | from .configuration_mistral import MistralConfig
from ..llama.modeling_llama import LlamaAttention, LlamaDecoderLayer, LlamaForCausalLM, LlamaForSequenceClassification, LlamaForTokenClassification, LlamaMLP, LlamaModel, LlamaPreTrainedModel, apply_rotary_pos_emb, eager_attention_forward
class MistralDecoderLayer(Llama... |
class MistralDecoderLayer(LlamaDecoderLayer):
def __init__(self, config: MistralConfig, layer_idx: int):
pass | 2 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 5 | 3 | 0 | 1 | 2 | 1 | 13 | 5 | 0 | 5 | 4 | 3 | 0 | 5 | 4 | 3 | 1 | 2 | 0 | 1 |
3,797 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mistral/modular_mistral.py | transformers.models.mistral.modular_mistral.MistralForCausalLM | from ..llama.modeling_llama import LlamaAttention, LlamaDecoderLayer, LlamaForCausalLM, LlamaForSequenceClassification, LlamaForTokenClassification, LlamaMLP, LlamaModel, LlamaPreTrainedModel, apply_rotary_pos_emb, eager_attention_forward
class MistralForCausalLM(LlamaForCausalLM):
pass |
class MistralForCausalLM(LlamaForCausalLM):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 9 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 3 | 0 | 0 |
3,798 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mistral/modular_mistral.py | transformers.models.mistral.modular_mistral.MistralForQuestionAnswering | from ...modeling_layers import GenericForQuestionAnswering
class MistralForQuestionAnswering(GenericForQuestionAnswering, MistralPreTrainedModel):
... |
class MistralForQuestionAnswering(GenericForQuestionAnswering, MistralPreTrainedModel):
pass | 1 | 0 | 17 | 2 | 13 | 3 | 2 | 0.21 | 1 | 5 | 3 | 0 | 4 | 1 | 4 | 9 | 73 | 10 | 53 | 26 | 35 | 11 | 25 | 13 | 20 | 5 | 3 | 1 | 8 |
3,799 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/mistral/modular_mistral.py | transformers.models.mistral.modular_mistral.MistralForSequenceClassification | from ..llama.modeling_llama import LlamaAttention, LlamaDecoderLayer, LlamaForCausalLM, LlamaForSequenceClassification, LlamaForTokenClassification, LlamaMLP, LlamaModel, LlamaPreTrainedModel, apply_rotary_pos_emb, eager_attention_forward
class MistralForSequenceClassification(LlamaForSequenceClassification):
pass |
class MistralForSequenceClassification(LlamaForSequenceClassification):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 5 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 3 | 0 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.