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,200
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/instructblipvideo/modular_instructblipvideo.py
transformers.models.instructblipvideo.modular_instructblipvideo.InstructBlipVideoForConditionalGenerationModelOutput
from transformers.models.instructblip.modeling_instructblip import InstructBlipForConditionalGeneration, InstructBlipForConditionalGenerationModelOutput, InstructBlipModel, InstructBlipPreTrainedModel, InstructBlipQFormerModel, InstructBlipVisionModel, TransformersKwargs class InstructBlipVideoForConditionalGeneration...
class InstructBlipVideoForConditionalGenerationModelOutput(InstructBlipForConditionalGenerationModelOutput): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
2
0
2
1
1
0
2
1
1
0
2
0
0
3,201
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/instructblipvideo/modular_instructblipvideo.py
transformers.models.instructblipvideo.modular_instructblipvideo.InstructBlipVideoQFormerConfig
from transformers.models.instructblip.configuration_instructblip import InstructBlipQFormerConfig, InstructBlipVisionConfig class InstructBlipVideoQFormerConfig(InstructBlipQFormerConfig): pass
class InstructBlipVideoQFormerConfig(InstructBlipQFormerConfig): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
2
0
2
1
1
0
2
1
1
0
2
0
0
3,202
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/instructblipvideo/modular_instructblipvideo.py
transformers.models.instructblipvideo.modular_instructblipvideo.InstructBlipVideoVisionConfig
from transformers.models.instructblip.configuration_instructblip import InstructBlipQFormerConfig, InstructBlipVisionConfig class InstructBlipVideoVisionConfig(InstructBlipVisionConfig): pass
class InstructBlipVideoVisionConfig(InstructBlipVisionConfig): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
2
0
2
1
1
0
2
1
1
0
2
0
0
3,203
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/instructblipvideo/processing_instructblipvideo.py
transformers.models.instructblipvideo.processing_instructblipvideo.InstructBlipVideoProcessor
from typing import Optional, Union from ...image_processing_utils import BatchFeature from ...tokenization_utils_base import AddedToken, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy import os from ...utils import TensorType, logging from ...video_utils import VideoInput from ...processing_utils imp...
class InstructBlipVideoProcessor(ProcessorMixin): ''' Constructs an InstructBLIPVideo processor which wraps a InstructBLIP image processor and a LLaMa/T5 tokenizer into a single processor. [`InstructBlipVideoProcessor`] offers all the functionalities of [`InstructBlipVideoImageProcessor`] and [`AutoTok...
8
2
23
2
18
3
3
0.29
1
13
4
0
6
2
7
24
197
22
137
51
108
40
68
30
60
9
2
3
20
3,204
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jamba/configuration_jamba.py
transformers.models.jamba.configuration_jamba.JambaConfig
from ...configuration_utils import PretrainedConfig import math class JambaConfig(PretrainedConfig): """ This is the configuration class to store the configuration of a [`JambaModel`]. It is used to instantiate a Jamba model according to the specified arguments, defining the model architecture. Instantiati...
class JambaConfig(PretrainedConfig): ''' This is the configuration class to store the configuration of a [`JambaModel`]. It is used to instantiate a Jamba model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a similar co...
7
1
25
2
23
0
2
0.95
1
5
0
0
4
30
4
4
208
17
98
75
55
93
46
37
41
3
1
1
9
3,205
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jamba/modeling_jamba.py
transformers.models.jamba.modeling_jamba.HybridMambaAttentionDynamicCache
import torch import torch.nn.functional as F from typing import Any, Optional, Union class HybridMambaAttentionDynamicCache: """ A dynamic cache that can handle both the attention cache (which has a seq_len dimension) and the mamba cache (which has a constant shape regardless of seq_len). This cache h...
null
5
3
11
1
10
1
2
0.27
1
7
0
0
5
8
6
37
85
10
60
28
46
16
47
21
40
3
3
2
12
3,206
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jamba/modeling_jamba.py
transformers.models.jamba.modeling_jamba.JambaAttention
from typing import Any, Optional, Union from ...utils.deprecation import deprecate_kwarg import torch import torch.nn.functional as F from .configuration_jamba import JambaConfig from torch import nn import math class JambaAttention(nn.Module): """ Multi-headed attention from 'Attention Is All You Need' paper....
class JambaAttention(nn.Module): ''' Multi-headed attention from 'Attention Is All You Need' paper. Modified to use sliding window attention: Longformer and "Generating Long Sequences with Sparse Transformers". ''' def __init__(self, config: JambaConfig, layer_idx: Optional[int]=None): pas...
4
1
41
7
33
2
4
0.11
1
7
2
2
2
13
2
12
88
16
66
32
54
7
47
23
44
5
1
1
8
3,207
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jamba/modeling_jamba.py
transformers.models.jamba.modeling_jamba.JambaAttentionDecoderLayer
from ...modeling_layers import GenericForSequenceClassification, GradientCheckpointingLayer from .configuration_jamba import JambaConfig import torch.nn.functional as F import torch from ...utils.deprecation import deprecate_kwarg from typing import Any, Optional, Union class JambaAttentionDecoderLayer(GradientCheckpo...
class JambaAttentionDecoderLayer(GradientCheckpointingLayer): def __init__(self, config: JambaConfig, 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, pos...
4
1
39
6
24
10
4
0.42
1
10
5
0
2
4
2
12
80
12
48
24
35
20
29
14
26
5
1
1
7
3,208
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jamba/modeling_jamba.py
transformers.models.jamba.modeling_jamba.JambaFlashAttention2
import torch from ...modeling_flash_attention_utils import flash_attn_supports_top_left_mask, is_flash_attn_available from typing import Any, Optional, Union import torch.nn.functional as F class JambaFlashAttention2(JambaAttention): """ Jamba flash attention module. This module inherits from `JambaAttention` ...
class JambaFlashAttention2(JambaAttention): ''' Jamba flash attention module. This module inherits from `JambaAttention` 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 p...
3
1
43
7
30
6
4
0.28
1
4
1
0
2
3
2
14
93
15
61
25
48
17
35
13
32
7
2
2
8
3,209
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jamba/modeling_jamba.py
transformers.models.jamba.modeling_jamba.JambaForCausalLM
from typing import Any, Optional, Union from ...modeling_outputs import MoeCausalLMOutputWithPast, MoeModelOutputWithPast from ...generation import GenerationMixin import torch from ...processing_utils import Unpack import torch.nn.functional as F from .configuration_jamba import JambaConfig from ...utils import Transf...
class JambaForCausalLM(JambaPreTrainedModel, GenerationMixin): def __init__(self, config: JambaConfig): 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.LongTensor]=Non...
6
1
21
2
15
4
3
0.29
2
9
4
0
9
8
9
10
204
29
140
55
100
40
63
26
53
13
2
2
27
3,210
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jamba/modeling_jamba.py
transformers.models.jamba.modeling_jamba.JambaForSequenceClassification
from ...modeling_layers import GenericForSequenceClassification, GradientCheckpointingLayer class JambaForSequenceClassification(GenericForSequenceClassification, JambaPreTrainedModel): ...
class JambaForSequenceClassification(GenericForSequenceClassification, JambaPreTrainedModel): pass
1
0
21
2
17
2
3
0.11
1
7
3
0
4
3
4
5
90
11
71
31
53
8
36
18
31
9
2
1
12
3,211
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jamba/modeling_jamba.py
transformers.models.jamba.modeling_jamba.JambaMLP
from torch import nn from ...activations import ACT2FN class JambaMLP(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.hidd...
class JambaMLP(nn.Module): def __init__(self, config): pass def forward(self, x): pass
3
0
6
0
6
0
1
0
1
1
0
0
2
7
2
12
14
1
13
11
10
0
13
11
10
1
1
0
2
3,212
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jamba/modeling_jamba.py
transformers.models.jamba.modeling_jamba.JambaMambaDecoderLayer
from typing import Any, Optional, Union from ...utils.deprecation import deprecate_kwarg import torch import torch.nn.functional as F from .configuration_jamba import JambaConfig from ...modeling_layers import GenericForSequenceClassification, GradientCheckpointingLayer class JambaMambaDecoderLayer(GradientCheckpointi...
class JambaMambaDecoderLayer(GradientCheckpointingLayer): def __init__(self, config: JambaConfig, 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, positio...
4
1
38
6
22
10
4
0.44
1
11
6
0
2
4
2
12
77
12
45
24
32
20
30
14
27
5
1
1
7
3,213
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jamba/modeling_jamba.py
transformers.models.jamba.modeling_jamba.JambaMambaMixer
from ...activations import ACT2FN from typing import Any, Optional, Union import torch import torch.nn.functional as F from .configuration_jamba import JambaConfig from torch import nn class JambaMambaMixer(nn.Module): """ Compute ∆, A, B, C, and D the state space parameters and compute the `contextualized_sta...
class JambaMambaMixer(nn.Module): ''' Compute ∆, A, B, C, and D the state space parameters and compute the `contextualized_states`. A, D are input independent (see Mamba paper [1] Section 3.5.2 "Interpretation of A" for why A isn't selective) ∆, B, C are input-dependent (this is a key difference betwee...
5
1
63
7
49
11
6
0.25
1
7
3
0
4
22
4
14
265
32
198
70
183
50
124
60
119
9
1
3
22
3,214
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jamba/modeling_jamba.py
transformers.models.jamba.modeling_jamba.JambaModel
import torch from ...modeling_attn_mask_utils import AttentionMaskConverter from ...modeling_outputs import MoeCausalLMOutputWithPast, MoeModelOutputWithPast from typing import Any, Optional, Union from torch import nn from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging from .configuratio...
@auto_docstring class JambaModel(JambaPreTrainedModel): ''' Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`JambaDecoderLayer`] Args: config: JambaConfig ''' def __init__(self, config: JambaConfig): pass @can_return_tuple @auto_docstrin...
8
2
32
4
25
2
7
0.13
1
12
6
0
6
7
6
7
203
33
152
49
131
19
95
35
88
27
2
3
40
3,215
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jamba/modeling_jamba.py
transformers.models.jamba.modeling_jamba.JambaPreTrainedModel
from ...modeling_utils import PreTrainedModel import torch import torch.nn.functional as F from .configuration_jamba import JambaConfig from ...utils import TransformersKwargs, auto_docstring, can_return_tuple, logging from torch import nn @auto_docstring class JambaPreTrainedModel(PreTrainedModel): config: JambaC...
@auto_docstring class JambaPreTrainedModel(PreTrainedModel): def _init_weights(self, module): pass
3
0
10
0
10
0
5
0.05
1
0
0
3
1
0
1
1
21
1
20
12
18
1
19
12
17
5
1
2
5
3,216
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jamba/modeling_jamba.py
transformers.models.jamba.modeling_jamba.JambaRMSNorm
from torch import nn import torch.nn.functional as F import torch class JambaRMSNorm(nn.Module): def __init__(self, hidden_size, eps=1e-06): """ JambaRMSNorm is equivalent to T5LayerNorm """ super().__init__() self.weight = nn.Parameter(torch.ones(hidden_size)) self...
class JambaRMSNorm(nn.Module): def __init__(self, hidden_size, eps=1e-06): ''' JambaRMSNorm is equivalent to T5LayerNorm ''' pass def forward(self, hidden_states): pass def extra_repr(self): pass
4
1
5
0
4
1
1
0.23
1
2
0
0
3
2
3
13
18
2
13
8
9
3
13
8
9
1
1
0
3
3,217
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jamba/modeling_jamba.py
transformers.models.jamba.modeling_jamba.JambaSdpaAttention
import torch from ...utils.deprecation import deprecate_kwarg from typing import Any, Optional, Union import torch.nn.functional as F class JambaSdpaAttention(JambaAttention): """ Jamba attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from `JambaAttention` as th...
class JambaSdpaAttention(JambaAttention): ''' Jamba attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from `JambaAttention` as the weights of the module stays untouched. The only changes are on the forward pass to adapt to SDPA API. ''' @deprecate_kwa...
3
1
72
12
54
6
7
0.22
1
4
1
0
1
0
1
13
80
13
55
18
44
12
29
9
27
7
2
1
7
3,218
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jamba/modeling_jamba.py
transformers.models.jamba.modeling_jamba.JambaSparseMoeBlock
import torch from .configuration_jamba import JambaConfig from torch import nn import torch.nn.functional as F class JambaSparseMoeBlock(nn.Module): """ This implementation is strictly equivalent to standard MoE with full capacity (no dropped tokens). It's faster since it formulates MoE operations ...
class JambaSparseMoeBlock(nn.Module): ''' This implementation is strictly equivalent to standard MoE with full capacity (no dropped tokens). It's faster since it formulates MoE operations in terms of block-sparse operations to accommodate imbalanced assignments of tokens to experts, whereas sta...
3
2
24
4
15
6
2
0.7
1
6
2
0
2
6
2
12
61
10
30
20
27
21
28
20
25
3
1
2
4
3,219
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jetmoe/configuration_jetmoe.py
transformers.models.jetmoe.configuration_jetmoe.JetMoeConfig
from ...configuration_utils import PretrainedConfig class JetMoeConfig(PretrainedConfig): """ This is the configuration class to store the configuration of a [`JetMoeModel`]. It is used to instantiate a JetMoe model according to the specified arguments, defining the model architecture. Instantiating a conf...
class JetMoeConfig(PretrainedConfig): ''' This is the configuration class to store the configuration of a [`JetMoeModel`]. It is used to instantiate a JetMoe model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a configu...
2
1
52
3
49
0
2
1.17
1
2
0
0
1
20
1
1
126
13
52
47
27
61
27
24
25
2
1
1
2
3,220
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jetmoe/modeling_jetmoe.py
transformers.models.jetmoe.modeling_jetmoe.JetMoeAttention
from ...utils.deprecation import deprecate_kwarg from .configuration_jetmoe import JetMoeConfig import torch from torch import nn from typing import Optional, Union from ...cache_utils import Cache, DynamicCache import math class JetMoeAttention(nn.Module): """ Multi-headed attention from 'Attention Is All You...
class JetMoeAttention(nn.Module): ''' Multi-headed attention from 'Attention Is All You Need' paper. ''' def __init__(self, config: JetMoeConfig, layer_idx: Optional[int]=None): ''' Initialize the JetMoeAttention module. Args: config: Configuration o...
4
2
46
9
31
6
4
0.24
1
9
4
2
2
12
2
12
97
20
63
32
51
15
47
23
44
5
1
1
7
3,221
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jetmoe/modeling_jetmoe.py
transformers.models.jetmoe.modeling_jetmoe.JetMoeBlock
import torch from ...modeling_layers import GenericForSequenceClassification, GradientCheckpointingLayer from ...cache_utils import Cache, DynamicCache from ...utils.deprecation import deprecate_kwarg from typing import Optional, Union from .configuration_jetmoe import JetMoeConfig class JetMoeBlock(GradientCheckpoint...
class JetMoeBlock(GradientCheckpointingLayer): def __init__(self, config: JetMoeConfig, layer_idx: Optional[int]=None): ''' Initialize the JetMoeBlock module. Args: config: Configuration object with model hyperparameters. ''' pass @deprecate_...
4
1
26
4
19
4
3
0.18
1
7
3
0
2
4
2
12
54
9
38
20
25
7
20
10
17
4
1
1
5
3,222
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jetmoe/modeling_jetmoe.py
transformers.models.jetmoe.modeling_jetmoe.JetMoeFlashAttention2
from ...modeling_flash_attention_utils import flash_attn_supports_top_left_mask, is_flash_attn_available from ...utils.deprecation import deprecate_kwarg from ...cache_utils import Cache, DynamicCache import torch from typing import Optional, Union class JetMoeFlashAttention2(JetMoeAttention): def __init__(self, ...
class JetMoeFlashAttention2(JetMoeAttention): def __init__(self, *args, **kwargs): pass @deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58') def forward(self, hidden_states: Optional[torch.FloatTensor], attention_mask: Optional[torch.FloatTensor]=None, position_ids: Optio...
4
1
56
9
33
14
4
0.42
1
4
1
0
2
1
2
14
113
19
67
26
52
28
40
14
37
7
2
2
8
3,223
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jetmoe/modeling_jetmoe.py
transformers.models.jetmoe.modeling_jetmoe.JetMoeForCausalLM
from ...cache_utils import Cache, DynamicCache from ...generation import GenerationMixin from ...modeling_outputs import MoeCausalLMOutputWithPast, MoeModelOutputWithPast from ...utils import auto_docstring, can_return_tuple, is_torch_flex_attn_available, logging from typing import Optional, Union from torch import nn ...
class JetMoeForCausalLM(JetMoePreTrainedModel, 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.LongTensor]=None, past_key...
5
1
16
1
12
3
2
0.28
2
7
2
0
8
5
8
9
145
18
100
41
72
28
50
24
41
12
2
2
19
3,224
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jetmoe/modeling_jetmoe.py
transformers.models.jetmoe.modeling_jetmoe.JetMoeForSequenceClassification
from ...modeling_layers import GenericForSequenceClassification, GradientCheckpointingLayer class JetMoeForSequenceClassification(GenericForSequenceClassification, JetMoePreTrainedModel): ...
class JetMoeForSequenceClassification(GenericForSequenceClassification, JetMoePreTrainedModel): pass
1
0
21
2
17
2
3
0.11
1
7
3
0
4
3
4
5
90
11
71
31
53
8
36
18
31
9
2
1
12
3,225
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jetmoe/modeling_jetmoe.py
transformers.models.jetmoe.modeling_jetmoe.JetMoeMoA
from torch import nn from .configuration_jetmoe import JetMoeConfig import torch class JetMoeMoA(nn.Module): """ A Sparsely gated mixture of attention layer with pairs of query- and output-projections as experts. Args: config: Configuration object with model hyperparameters. """ ...
class JetMoeMoA(nn.Module): ''' A Sparsely gated mixture of attention layer with pairs of query- and output-projections as experts. Args: config: Configuration object with model hyperparameters. ''' def __init__(self, config: JetMoeConfig): pass def map(self, layer...
5
3
16
2
10
5
1
0.6
1
5
3
0
4
8
4
14
74
14
42
26
37
25
36
26
31
1
1
0
4
3,226
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jetmoe/modeling_jetmoe.py
transformers.models.jetmoe.modeling_jetmoe.JetMoeMoE
from ...activations import ACT2FN import torch from torch import nn from .configuration_jetmoe import JetMoeConfig class JetMoeMoE(nn.Module): """ A Sparsely gated mixture of experts layer with 1-layer Feed-Forward networks as experts. Args: config: Configuration object with model hype...
class JetMoeMoE(nn.Module): ''' A Sparsely gated mixture of experts layer with 1-layer Feed-Forward networks as experts. Args: config: Configuration object with model hyperparameters. ''' def __init__(self, config: JetMoeConfig): pass def forward(self, layer_input)...
3
2
23
4
14
6
1
0.59
1
4
3
0
2
7
2
12
56
10
29
18
26
17
25
18
22
1
1
0
2
3,227
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jetmoe/modeling_jetmoe.py
transformers.models.jetmoe.modeling_jetmoe.JetMoeModel
from typing import Optional, Union from ...modeling_outputs import MoeCausalLMOutputWithPast, MoeModelOutputWithPast from ...utils import auto_docstring, can_return_tuple, is_torch_flex_attn_available, logging from torch import nn from ...cache_utils import Cache, DynamicCache from .configuration_jetmoe import JetMoeCo...
@auto_docstring class JetMoeModel(JetMoePreTrainedModel): ''' Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`JetMoeBlock`] Args: config: JetMoeConfig ''' def __init__(self, config: JetMoeConfig): pass @can_return_tuple @aut...
9
2
45
5
35
6
8
0.22
1
15
8
0
5
7
6
7
291
35
212
69
174
46
109
38
102
30
2
2
46
3,228
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jetmoe/modeling_jetmoe.py
transformers.models.jetmoe.modeling_jetmoe.JetMoeParallelExperts
from torch.nn import functional as F import torch from torch import nn class JetMoeParallelExperts(nn.Module): def __init__(self, num_experts: int, input_size: int, output_size: int) -> None: """ Initialize the JetMoeParallelExperts module. The experts weights are stored in [num_experts, o...
class JetMoeParallelExperts(nn.Module): def __init__(self, num_experts: int, input_size: int, output_size: int) -> None: ''' Initialize the JetMoeParallelExperts module. The experts weights are stored in [num_experts, output_size, input_size] format. Such that it's compatible with ...
3
2
21
2
7
13
2
1.79
1
3
0
0
2
4
2
12
43
4
14
11
11
25
14
11
11
2
1
1
3
3,229
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jetmoe/modeling_jetmoe.py
transformers.models.jetmoe.modeling_jetmoe.JetMoePreTrainedModel
from .configuration_jetmoe import JetMoeConfig from torch import nn from ...modeling_utils import PreTrainedModel from ...utils import auto_docstring, can_return_tuple, is_torch_flex_attn_available, logging @auto_docstring class JetMoePreTrainedModel(PreTrainedModel): config: JetMoeConfig base_model_prefix = '...
@auto_docstring class JetMoePreTrainedModel(PreTrainedModel): def _init_weights(self, module): '''Initialize the weights.''' pass
3
1
21
0
18
3
9
0.26
1
3
3
3
1
0
1
1
36
2
27
10
25
7
22
10
20
9
1
2
9
3,230
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jetmoe/modeling_jetmoe.py
transformers.models.jetmoe.modeling_jetmoe.JetMoeRMSNorm
from torch import nn import torch class JetMoeRMSNorm(nn.Module): def __init__(self, hidden_size, eps=1e-06): """ JetMoeRMSNorm is equivalent to T5LayerNorm """ super().__init__() self.weight = nn.Parameter(torch.ones(hidden_size)) self.variance_epsilon = eps d...
class JetMoeRMSNorm(nn.Module): def __init__(self, hidden_size, eps=1e-06): ''' JetMoeRMSNorm is equivalent to T5LayerNorm ''' pass def forward(self, hidden_states): pass def extra_repr(self): pass
4
1
5
0
4
1
1
0.23
1
2
0
0
3
2
3
13
18
2
13
8
9
3
13
8
9
1
1
0
3
3,231
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jetmoe/modeling_jetmoe.py
transformers.models.jetmoe.modeling_jetmoe.JetMoeRotaryEmbedding
from .configuration_jetmoe import JetMoeConfig from torch import nn from ...modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update import torch class JetMoeRotaryEmbedding(nn.Module): inv_freq: torch.Tensor def __init__(self, config: JetMoeConfig, device=None): super().__init__() ...
class JetMoeRotaryEmbedding(nn.Module): def __init__(self, config: JetMoeConfig, 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,232
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jetmoe/modeling_jetmoe.py
transformers.models.jetmoe.modeling_jetmoe.JetMoeSdpaAttention
from ...utils.deprecation import deprecate_kwarg import torch from typing import Optional, Union from ...cache_utils import Cache, DynamicCache class JetMoeSdpaAttention(JetMoeAttention): """ JetMoe attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from `JetMoeAt...
class JetMoeSdpaAttention(JetMoeAttention): ''' JetMoe attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from `JetMoeAttention` as the weights of the module stays untouched. The only changes are on the forward pass to adapt to SDPA API. ''' @deprecate...
3
1
78
13
58
7
7
0.22
1
4
1
0
1
0
1
13
86
14
59
19
48
13
32
10
30
7
2
1
7
3,233
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/jetmoe/modeling_jetmoe.py
transformers.models.jetmoe.modeling_jetmoe.JetMoeTopKGating
from torch import nn import torch class JetMoeTopKGating(nn.Module): def __init__(self, input_size: int, num_experts: int, top_k: int): """ Initialize the top-k gating mechanism. Args: input_size (`int`): Size of the input. num_experts (`int`): ...
class JetMoeTopKGating(nn.Module): def __init__(self, input_size: int, num_experts: int, top_k: int): ''' Initialize the top-k gating mechanism. Args: input_size (`int`): Size of the input. num_experts (`int`): Number of experts. ...
3
1
23
4
11
14
1
1.17
1
2
0
0
2
4
2
12
47
8
23
17
20
27
21
17
18
1
1
0
2
3,234
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/configuration_kosmos2.py
transformers.models.kosmos2.configuration_kosmos2.Kosmos2Config
from ...configuration_utils import PretrainedConfig class Kosmos2Config(PretrainedConfig): """ This is the configuration class to store the configuration of a [`Kosmos2Model`]. It is used to instantiate a KOSMOS-2 model according to the specified arguments, defining the model architecture. Instantiating a ...
class Kosmos2Config(PretrainedConfig): ''' This is the configuration class to store the configuration of a [`Kosmos2Model`]. It is used to instantiate a KOSMOS-2 model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a sim...
2
1
21
4
17
0
3
1.2
1
3
2
0
1
3
1
1
56
12
20
13
12
24
14
7
12
3
1
1
3
3,235
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/configuration_kosmos2.py
transformers.models.kosmos2.configuration_kosmos2.Kosmos2TextConfig
from ...configuration_utils import PretrainedConfig class Kosmos2TextConfig(PretrainedConfig): """ This is the configuration class to store the configuration of a [`Kosmos2TextModel`]. It is used to instantiate a KOSMOS-2 text decoder according to the specified arguments, defining the model architecture. I...
class Kosmos2TextConfig(PretrainedConfig): ''' This is the configuration class to store the configuration of a [`Kosmos2TextModel`]. It is used to instantiate a KOSMOS-2 text decoder according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults w...
2
1
44
1
43
0
1
0.94
1
1
0
0
1
15
1
1
106
5
52
42
29
49
22
21
20
1
1
0
1
3,236
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/configuration_kosmos2.py
transformers.models.kosmos2.configuration_kosmos2.Kosmos2VisionConfig
from ...configuration_utils import PretrainedConfig class Kosmos2VisionConfig(PretrainedConfig): """ This is the configuration class to store the configuration of a [`Kosmos2VisionModel`]. It is used to instantiate a KOSMOS-2 vision encoder according to the specified arguments, defining the model architect...
class Kosmos2VisionConfig(PretrainedConfig): ''' This is the configuration class to store the configuration of a [`Kosmos2VisionModel`]. It is used to instantiate a KOSMOS-2 vision encoder according to the specified arguments, defining the model architecture. Instantiating a configuration with the defa...
2
1
30
1
29
0
1
1.09
1
1
0
0
1
12
1
1
72
5
32
31
15
35
17
16
15
1
1
0
1
3,237
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2ForConditionalGeneration
from .configuration_kosmos2 import Kosmos2Config, Kosmos2TextConfig, Kosmos2VisionConfig from ...processing_utils import Unpack from torch import nn import torch from ...generation import GenerationMixin from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache from typing import Any, Callable, Optional, Unio...
@auto_docstring(custom_intro='\n KOSMOS-2 Model for generating text and bounding boxes given an image. The model consists of a vision encoder and a\n language model.\n ') class Kosmos2ForConditionalGeneration(Kosmos2PreTrainedModel, GenerationMixin): def __init__(self, config: Kosmos2Config): pass...
12
1
24
3
15
6
2
0.37
2
10
5
0
7
3
7
8
184
28
114
47
80
42
49
22
41
7
2
2
16
3,238
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2ForConditionalGenerationModelOutput
from dataclasses import dataclass import torch from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache from typing import Any, Callable, Optional, Union from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPooling, CausalLMOutputWithCrossAttentions f...
@dataclass @auto_docstring(custom_intro='\n Model output class for `Kosmos2ForConditionalGeneration`.\n ') class Kosmos2ForConditionalGenerationModelOutput(ModelOutput): ''' loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided): Language modeling loss (for next...
4
1
5
0
5
0
2
2.43
1
2
0
0
1
0
1
1
55
7
14
10
12
34
11
10
9
2
1
0
2
3,239
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2ImageToTextProjection
import torch from torch import nn from .configuration_kosmos2 import Kosmos2Config, Kosmos2TextConfig, Kosmos2VisionConfig class Kosmos2ImageToTextProjection(nn.Module): """The layer that transforms the image model's output to part of the text model's input (namely, image features)""" def __init__(self, confi...
class Kosmos2ImageToTextProjection(nn.Module): '''The layer that transforms the image model's output to part of the text model's input (namely, image features)''' def __init__(self, config: Kosmos2Config): pass def forward(self, features): pass
3
1
15
2
12
1
1
0.08
1
3
2
0
2
3
2
12
33
6
25
10
22
2
12
10
9
1
1
0
2
3,240
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2Model
from ...processing_utils import Unpack from torch import nn from ...modeling_flash_attention_utils import FlashAttentionKwargs import torch from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache from typing import Any, Callable, Optional, Union from ...utils import ModelOutput, TransformersKwargs, auto_doc...
@auto_docstring(custom_intro='\n KOSMOS-2 Model for generating text and image features. The model consists of a vision encoder and a language model.\n ') class Kosmos2Model(Kosmos2PreTrainedModel): def __init__(self, config: Kosmos2Config): pass def get_input_embeddings(self) -> nn.Module: ...
9
2
29
4
18
7
3
0.37
1
10
5
0
4
3
4
5
125
18
78
30
55
29
31
13
26
7
2
2
10
3,241
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2ModelOutput
import torch from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache from typing import Any, Callable, Optional, Union from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPooling, CausalLMOutputWithCrossAttentions from ...utils import ModelOutput, T...
@dataclass @auto_docstring(custom_intro="\n Base class for text model's outputs that also contains a pooling of the last hidden states.\n ") class Kosmos2ModelOutput(ModelOutput): ''' past_key_values (`Cache`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`): I...
4
1
5
0
5
0
2
2.46
1
2
0
0
1
0
1
1
52
7
13
9
11
32
10
9
8
2
1
0
2
3,242
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2PreTrainedModel
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel from torch import nn from ...utils import ModelOutput, TransformersKwargs, auto_docstring, can_return_tuple, logging, torch_int from .configuration_kosmos2 import Kosmos2Config, Kosmos2TextConfig, Kosmos2VisionConfig @auto_docstring class Kosmos2Pr...
@auto_docstring class Kosmos2PreTrainedModel(PreTrainedModel): def _init_weights(self, module: nn.Module): '''Initialize the weights''' pass
3
1
82
2
79
1
30
0.06
1
14
14
5
1
0
1
1
92
4
83
10
81
5
72
10
70
30
1
2
30
3,243
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2TextBlock
from .configuration_kosmos2 import Kosmos2Config, Kosmos2TextConfig, Kosmos2VisionConfig from ...modeling_layers import GradientCheckpointingLayer from torch import nn from ...utils.deprecation import deprecate_kwarg import torch from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache from typing import Any...
class Kosmos2TextBlock(GradientCheckpointingLayer): def __init__(self, config: Kosmos2TextConfig, 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.Tensor]=None, encoder...
4
0
54
9
41
4
5
0.1
1
7
3
0
2
8
2
12
109
19
82
29
68
8
41
18
38
7
1
2
9
3,244
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2TextFFN
from torch import nn from ...activations import ACT2FN from .configuration_kosmos2 import Kosmos2Config, Kosmos2TextConfig, Kosmos2VisionConfig class Kosmos2TextFFN(nn.Module): def __init__(self, config: Kosmos2TextConfig): super().__init__() self.dropout = config.dropout self.activation_f...
class Kosmos2TextFFN(nn.Module): def __init__(self, config: Kosmos2TextConfig): pass def forward(self, hidden_states): pass
3
0
10
2
8
0
1
0
1
2
1
0
2
6
2
12
21
5
16
9
13
0
16
9
13
1
1
0
2
3,245
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2TextForCausalLM
from ...processing_utils import Unpack from torch import nn import torch from ...generation import GenerationMixin from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache from typing import Any, Callable, Optional, Union from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttenti...
@auto_docstring(custom_intro='\n The text model from KOSMOS-2 with a language modeling head on top (linear layer with weights tied to the input\n embeddings).\n ') class Kosmos2TextForCausalLM(Kosmos2PreTrainedModel, GenerationMixin): def __init__(self, config: Kosmos2TextConfig): pass def ge...
9
1
19
2
16
2
2
0.13
2
7
3
0
7
2
8
9
170
22
131
56
92
17
55
27
46
7
2
2
18
3,246
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2TextModel
from ...processing_utils import Unpack from torch import nn from ...modeling_flash_attention_utils import FlashAttentionKwargs import torch from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache from typing import Any, Callable, Optional, Union from ...modeling_outputs import BaseModelOutput, BaseModelOutp...
class Kosmos2TextModel(Kosmos2PreTrainedModel): def __init__(self, config: Kosmos2TextConfig): pass def get_input_embeddings(self) -> nn.Module: pass @can_return_tuple @auto_docstring def forward(self, input_ids: Optional[torch.Tensor]=None, attention_mask: Optional[torch.Tensor]=...
6
1
12
0
11
1
1
0.09
1
6
3
0
4
1
4
5
56
5
47
25
23
4
12
7
7
1
2
0
4
3,247
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2TextSinusoidalPositionalEmbedding
import math from typing import Any, Callable, Optional, Union import torch from torch import nn class Kosmos2TextSinusoidalPositionalEmbedding(nn.Module): """This module produces sinusoidal positional embeddings of any length.""" def __init__(self, num_positions: int, embedding_dim: int, padding_idx: Optional...
class Kosmos2TextSinusoidalPositionalEmbedding(nn.Module): '''This module produces sinusoidal positional embeddings of any length.''' def __init__(self, num_positions: int, embedding_dim: int, padding_idx: Optional[int]=None): pass def make_weights(self, num_embeddings: int, embedding_dim: int, p...
11
4
15
2
10
3
2
0.38
1
3
0
0
4
3
5
15
86
13
53
25
39
20
40
17
34
5
1
2
12
3,248
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2TextTransformer
from torch import nn import math from ...modeling_flash_attention_utils import FlashAttentionKwargs import torch from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache from typing import Any, Callable, Optional, Union from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttention...
class Kosmos2TextTransformer(nn.Module): ''' Transformer decoder consisting of `config.layers` layers. Each layer is a [`Kosmos2TextBlock`]. Args: config: Kosmos2TextConfig ''' def __init__(self, config: Kosmos2TextConfig): pass def _prepare_decoder_attention_mask(self, attent...
5
1
59
8
48
4
11
0.1
1
13
4
0
4
9
4
14
246
36
191
55
161
19
87
30
82
36
1
3
45
3,249
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2VisionAttention
from typing import Any, Callable, Optional, Union import torch from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel from torch import nn class Kosmos2VisionAttention(nn.Module): """Multi-headed attention from 'Attention Is All You Need' paper""" def __init__(self, config): super().__...
class Kosmos2VisionAttention(nn.Module): '''Multi-headed attention from 'Attention Is All You Need' paper''' def __init__(self, config): pass def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=None, causal_attention_mask: Optional[torch.Tensor]=None, output_atte...
3
2
32
5
25
2
4
0.11
1
5
0
0
3
10
3
13
102
19
75
30
65
8
54
24
50
8
1
2
11
3,250
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2VisionEmbeddings
import torch from torch import nn from ...utils import ModelOutput, TransformersKwargs, auto_docstring, can_return_tuple, logging, torch_int from .configuration_kosmos2 import Kosmos2Config, Kosmos2TextConfig, Kosmos2VisionConfig class Kosmos2VisionEmbeddings(nn.Module): def __init__(self, config: Kosmos2VisionCo...
class Kosmos2VisionEmbeddings(nn.Module): def __init__(self, config: Kosmos2VisionConfig): pass def interpolate_pos_encoding(self, embeddings: torch.Tensor, height: int, width: int) -> torch.Tensor: ''' This method allows to interpolate the pre-trained position encodings, to be able t...
4
1
26
5
19
3
2
0.16
1
5
1
0
3
9
3
13
81
16
57
27
53
9
43
27
39
3
1
1
6
3,251
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2VisionEncoder
from torch import nn import torch from typing import Any, Callable, Optional, Union from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPooling, CausalLMOutputWithCrossAttentions from ...utils import ModelOutput, TransformersKwargs, auto_docstring, can_return_t...
class Kosmos2VisionEncoder(nn.Module): ''' Transformer encoder consisting of `config.num_hidden_layers` self attention layers. Each layer is a [`Kosmos2VisionEncoderLayer`]. Args: config: Kosmos2VisionConfig ''' def __init__(self, config: Kosmos2VisionConfig): pass @can_ret...
4
2
43
5
25
13
7
0.61
1
9
3
0
2
3
2
12
95
13
51
19
40
31
27
11
24
12
1
2
13
3,252
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2VisionEncoderLayer
from .configuration_kosmos2 import Kosmos2Config, Kosmos2TextConfig, Kosmos2VisionConfig from ...modeling_layers import GradientCheckpointingLayer from torch import nn import torch from typing import Any, Callable, Optional, Union class Kosmos2VisionEncoderLayer(GradientCheckpointingLayer): def __init__(self, con...
class Kosmos2VisionEncoderLayer(GradientCheckpointingLayer): def __init__(self, config: Kosmos2VisionConfig): pass def forward(self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, causal_attention_mask: torch.Tensor, output_attentions: Optional[bool]=False) -> tuple[torch.FloatTensor]: ...
3
1
23
3
16
5
2
0.31
1
6
3
0
2
5
2
12
48
6
32
17
23
10
21
11
18
2
1
1
3
3,253
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2VisionMLP
from ...activations import ACT2FN import torch from torch import nn class Kosmos2VisionMLP(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_siz...
class Kosmos2VisionMLP(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
1
2
0
0
2
4
2
12
13
1
12
7
9
0
12
7
9
1
1
0
2
3,254
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2VisionModel
from torch import nn import torch from typing import Any, Callable, Optional, Union from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPooling, CausalLMOutputWithCrossAttentions from ...utils import ModelOutput, TransformersKwargs, auto_docstring, can_return_t...
class Kosmos2VisionModel(Kosmos2PreTrainedModel): def __init__(self, config: Kosmos2VisionConfig): pass def get_input_embeddings(self) -> nn.Module: pass @auto_docstring def forward(self, pixel_values: Optional[torch.FloatTensor]=None, output_attentions: Optional[bool]=None, output_hi...
5
0
9
0
7
1
1
0.23
1
5
3
0
3
1
3
4
36
4
26
15
13
6
11
7
7
1
2
0
3
3,255
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.Kosmos2VisionTransformer
from typing import Any, Callable, Optional, Union from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPooling, CausalLMOutputWithCrossAttentions from .configuration_kosmos2 import Kosmos2Config, Kosmos2TextConfig, Kosmos2VisionConfig from torch import nn import...
class Kosmos2VisionTransformer(nn.Module): def __init__(self, config: Kosmos2VisionConfig): pass def forward(self, pixel_values: Optional[torch.FloatTensor]=None, output_attentions: Optional[bool]=None, output_hidden_states: Optional[bool]=None, interpolate_pos_encoding: bool=False, return_dict: Opti...
3
0
25
4
21
0
4
0.02
1
7
4
0
2
5
2
12
52
8
43
20
33
1
24
13
21
6
1
1
7
3,256
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/modeling_kosmos2.py
transformers.models.kosmos2.modeling_kosmos2.KosmosTextAttention
from torch import nn from ...utils.deprecation import deprecate_kwarg import torch from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache from typing import Any, Callable, Optional, Union class KosmosTextAttention(nn.Module): """Mu...
class KosmosTextAttention(nn.Module): '''Multi-headed attention from 'Attention Is All You Need' paper''' def __init__(self, config, embed_dim: int, num_heads: int, dropout: float=0.0, is_decoder: Optional[bool]=False, add_inner_attn_layernorm: Optional[bool]=False, bias: Optional[bool]=True, layer_idx: Optio...
4
2
37
5
25
7
4
0.29
1
6
0
0
3
11
3
13
117
19
76
44
55
22
53
27
49
9
1
2
13
3,257
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/processing_kosmos2.py
transformers.models.kosmos2.processing_kosmos2.Kosmos2ImagesKwargs
from typing import Optional, Union from ...processing_utils import ImagesKwargs, ProcessingKwargs, ProcessorMixin, TextKwargs, Unpack class Kosmos2ImagesKwargs(ImagesKwargs, total=False): bboxes: Optional[list[float]] num_image_tokens: Optional[int] first_image_token_id: Optional[int]
class Kosmos2ImagesKwargs(ImagesKwargs, total=False): pass
1
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
4
0
4
1
3
0
4
1
3
0
2
0
0
3,258
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/processing_kosmos2.py
transformers.models.kosmos2.processing_kosmos2.Kosmos2Processor
from ...image_utils import ImageInput from ...processing_utils import ImagesKwargs, ProcessingKwargs, ProcessorMixin, TextKwargs, Unpack from ...tokenization_utils_base import BatchEncoding, TextInput from ...tokenization_utils import AddedToken import copy from typing import Optional, Union import math from ...image_p...
class Kosmos2Processor(ProcessorMixin): ''' Constructs an KOSMOS-2 processor which wraps a KOSMOS-2 image processor and a KOSMOS-2 tokenizer into a single processor. [`Kosmos2Processor`] offers all the functionalities of [`CLIPImageProcessor`] and some functionalities of [`XLMRobertaTokenizerFast`]...
12
5
34
4
23
7
5
0.37
1
14
3
0
12
13
12
29
446
66
277
95
248
103
195
79
182
19
2
4
60
3,259
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/processing_kosmos2.py
transformers.models.kosmos2.processing_kosmos2.Kosmos2ProcessorKwargs
from ...processing_utils import ImagesKwargs, ProcessingKwargs, ProcessorMixin, TextKwargs, Unpack class Kosmos2ProcessorKwargs(ProcessingKwargs, total=False): text_kwargs: Kosmos2TextKwargs images_kwargs: Kosmos2ImagesKwargs _defaults = {'text_kwargs': {'add_special_tokens': True, 'padding': False, 'strid...
class Kosmos2ProcessorKwargs(ProcessingKwargs, total=False): pass
1
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
19
0
19
2
18
0
4
2
3
0
3
0
0
3,260
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/kosmos2/processing_kosmos2.py
transformers.models.kosmos2.processing_kosmos2.Kosmos2TextKwargs
from typing import Optional, Union from ...processing_utils import ImagesKwargs, ProcessingKwargs, ProcessorMixin, TextKwargs, Unpack class Kosmos2TextKwargs(TextKwargs, total=False): add_eos_token: Optional[bool]
class Kosmos2TextKwargs(TextKwargs, total=False): pass
1
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
2
0
2
1
1
0
2
1
1
0
2
0
0
3,261
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/configuration_layoutlm.py
transformers.models.layoutlm.configuration_layoutlm.LayoutLMConfig
from ... import PretrainedConfig, PreTrainedTokenizer class LayoutLMConfig(PretrainedConfig): """ This is the configuration class to store the configuration of a [`LayoutLMModel`]. It is used to instantiate a LayoutLM model according to the specified arguments, defining the model architecture. Instantiatin...
class LayoutLMConfig(PretrainedConfig): ''' This is the configuration class to store the configuration of a [`LayoutLMModel`]. It is used to instantiate a LayoutLM model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a s...
2
1
36
0
36
0
1
1.55
1
1
0
0
1
15
1
1
107
10
38
37
17
59
19
18
17
1
1
0
1
3,262
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/configuration_layoutlm.py
transformers.models.layoutlm.configuration_layoutlm.LayoutLMOnnxConfig
from collections import OrderedDict from collections.abc import Mapping from ...utils import is_torch_available, logging from typing import Any, Optional from ... import PretrainedConfig, PreTrainedTokenizer from ...onnx import OnnxConfig, PatchingSpec class LayoutLMOnnxConfig(OnnxConfig): def __init__(self, conf...
class LayoutLMOnnxConfig(OnnxConfig): def __init__(self, config: PretrainedConfig, task: str='default', patching_specs: Optional[list[PatchingSpec]]=None): pass @property def inputs(self) -> Mapping[str, Mapping[int, str]]: pass def generate_dummy_inputs(self, tokenizer: PreTrainedTok...
5
1
19
2
12
4
2
0.31
1
8
0
0
3
1
3
3
60
9
39
21
21
12
17
8
12
3
1
1
5
3,263
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMAttention
import torch from torch import nn from typing import Callable, Optional, Union from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer class LayoutLMAttention(nn.Module): def __init__(self, config): super().__init__() self.self = LayoutLMSelfAtt...
class LayoutLMAttention(nn.Module): def __init__(self, config): pass def prune_heads(self, heads): pass def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, output_attentions: Optional[bool]=False, *...
4
0
15
1
14
1
1
0.07
1
5
1
0
3
3
3
13
49
4
43
20
30
3
22
11
18
2
1
1
4
3,264
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMEmbeddings
import torch from torch import nn class LayoutLMEmbeddings(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, config.hidden_size, padding_idx=config.pad_...
class LayoutLMEmbeddings(nn.Module): '''Construct the embeddings from word, position and token_type embeddings.''' def __init__(self, config): pass def forward(self, input_ids=None, bbox=None, token_type_ids=None, position_ids=None, inputs_embeds=None): pass
3
1
35
5
30
0
4
0.02
1
2
0
0
2
9
2
12
74
12
61
33
51
1
41
25
38
7
1
1
8
3,265
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMEncoder
from torch import nn from ...utils import auto_docstring, can_return_tuple, logging from typing import Callable, Optional, Union import torch from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, MaskedLMOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput class ...
class LayoutLMEncoder(nn.Module): def __init__(self, config): pass @can_return_tuple def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, output_attentions: Optional[bool]=False, output_hidden_states: Optional...
4
0
45
4
41
0
9
0
1
8
2
0
2
3
2
12
91
8
83
26
68
0
35
14
32
17
1
3
18
3,266
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMForMaskedLM
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...utils import auto_docstring, can_return_tuple, logging from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, MaskedLMOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput from typing import C...
@auto_docstring class LayoutLMForMaskedLM(LayoutLMPreTrainedModel): def __init__(self, config): pass def get_input_embeddings(self): pass def get_output_embeddings(self): pass def set_output_embeddings(self, new_embeddings): pass @can_return_tuple @auto_docstr...
9
1
23
3
12
7
2
0.55
1
5
3
0
5
2
5
6
123
22
65
31
42
36
27
15
21
5
2
1
9
3,267
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMForQuestionAnswering
from ...utils import auto_docstring, can_return_tuple, logging import torch from typing import Callable, Optional, Union from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, MaskedLMOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput from torch import nn from to...
@auto_docstring class LayoutLMForQuestionAnswering(LayoutLMPreTrainedModel): def __init__(self, config, has_visual_segment_embedding=True): ''' has_visual_segment_embedding (`bool`, *optional*, defaults to `True`): Whether or not to add visual segment embeddings. ''' pas...
7
2
43
6
21
16
3
0.73
1
4
2
0
3
3
3
4
134
20
66
32
47
48
34
17
30
7
2
2
9
3,268
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMForSequenceClassification
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, MaskedLMOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput from torch import nn from typing import Callable, Optional, Union from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...utils imp...
@auto_docstring(custom_intro='\n LayoutLM Model with a sequence classification head on top (a linear layer on top of the pooled output) e.g. for\n document image classification tasks such as the [RVL-CDIP](https://www.cs.cmu.edu/~aharley/rvl-cdip/) dataset.\n ') class LayoutLMForSequenceClassification(LayoutLM...
7
1
41
5
23
12
5
0.51
1
5
2
0
3
4
3
4
127
18
72
28
53
37
36
14
32
12
2
3
14
3,269
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMForTokenClassification
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, MaskedLMOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput from torch import nn from ...utils import auto_docstring, can_return_tuple, logging from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss...
@auto_docstring(custom_intro='\n LayoutLM Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for\n sequence labeling (information extraction) tasks such as the [FUNSD](https://guillaumejaume.github.io/FUNSD/)\n dataset and the [SROIE](https://rrc.cvc.uab.es/?...
7
1
34
5
17
12
2
0.64
1
4
2
0
3
4
3
4
108
18
55
28
36
35
24
14
20
5
2
1
7
3,270
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMIntermediate
import torch from ...activations import ACT2FN from torch import nn class LayoutLMIntermediate(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.intermediat...
class LayoutLMIntermediate(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,271
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMLMPredictionHead
from torch import nn import torch class LayoutLMLMPredictionHead(nn.Module): def __init__(self, config): super().__init__() self.transform = LayoutLMPredictionHeadTransform(config) self.decoder = nn.Linear(config.hidden_size, config.vocab_size, bias=False) self.bias = nn.Parameter(...
class LayoutLMLMPredictionHead(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,272
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMLayer
from typing import Callable, Optional, Union import torch from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer from ...modeling_layers import GradientCheckpointingLayer class LayoutLMLayer(GradientCheckpointingLayer): def __init__(self, config): supe...
class LayoutLMLayer(GradientCheckpointingLayer): def __init__(self, config): pass def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, output_attentions: Optional[bool]=False, **kwargs) -> tuple[torch.Tensor]: ...
4
0
27
2
23
2
4
0.1
1
7
3
0
3
8
3
13
84
9
70
32
57
7
41
23
37
7
1
2
11
3,273
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMModel
import torch from typing import Callable, Optional, Union from ...utils import auto_docstring, can_return_tuple, logging from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, MaskedLMOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput @auto_docstring class Layou...
@auto_docstring class LayoutLMModel(LayoutLMPreTrainedModel): def __init__(self, config): pass def get_input_embeddings(self): pass def set_input_embeddings(self, value): pass def _prune_heads(self, heads_to_prune): ''' Prunes heads of the model. heads_to_prun...
9
2
28
4
18
6
4
0.34
1
7
4
0
5
4
5
6
146
24
91
33
69
31
49
18
43
15
2
2
20
3,274
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMOnlyMLMHead
import torch from torch import nn class LayoutLMOnlyMLMHead(nn.Module): def __init__(self, config): super().__init__() self.predictions = LayoutLMLMPredictionHead(config) def forward(self, sequence_output: torch.Tensor) -> torch.Tensor: prediction_scores = self.predictions(sequence_ou...
class LayoutLMOnlyMLMHead(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,275
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMOutput
import torch from torch import nn class LayoutLMOutput(nn.Module): def __init__(self, config): super().__init__() self.dense = nn.Linear(config.intermediate_size, config.hidden_size) self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps) self.dropout = nn.Drop...
class LayoutLMOutput(nn.Module): def __init__(self, config): pass def forward(self, hidden_states: torch.Tensor, input_tensor: torch.Tensor) -> torch.Tensor: pass
3
0
5
0
5
0
1
0
1
2
0
0
2
3
2
12
12
1
11
6
8
0
11
6
8
1
1
0
2
3,276
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMPooler
import torch from torch import nn class LayoutLMPooler(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: first_to...
class LayoutLMPooler(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,277
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMPreTrainedModel
from ...utils import auto_docstring, can_return_tuple, logging from .configuration_layoutlm import LayoutLMConfig from torch import nn from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel @auto_docstring class LayoutLMPreTrainedModel(PreTrainedModel): config: LayoutLMConfig base_model_prefix ...
@auto_docstring class LayoutLMPreTrainedModel(PreTrainedModel): def _init_weights(self, module): '''Initialize the weights''' pass
3
1
15
0
12
3
6
0.44
1
0
0
5
1
0
1
1
25
2
16
5
14
7
14
5
12
6
1
2
6
3,278
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMPredictionHeadTransform
import torch from ...activations import ACT2FN from torch import nn class LayoutLMPredictionHeadTransform(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.transf...
class LayoutLMPredictionHeadTransform(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,279
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMSelfAttention
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel import torch from typing import Callable, Optional, Union from torch import nn class LayoutLMSelfAttention(nn.Module): def __init__(self, config): super().__init__() if config.hidden_size % config.num_attention_heads != 0 and (...
class LayoutLMSelfAttention(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, output_attentions: Optional[bool]=False, **kwargs) -> tuple[torch.Tensor]: pas...
3
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,280
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/modeling_layoutlm.py
transformers.models.layoutlm.modeling_layoutlm.LayoutLMSelfOutput
import torch from torch import nn class LayoutLMSelfOutput(nn.Module): def __init__(self, config): super().__init__() self.dense = nn.Linear(config.hidden_size, config.hidden_size) self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps) self.dropout = nn.Dropou...
class LayoutLMSelfOutput(nn.Module): def __init__(self, config): pass def forward(self, hidden_states: torch.Tensor, input_tensor: torch.Tensor) -> torch.Tensor: pass
3
0
5
0
5
0
1
0
1
2
0
0
2
3
2
12
12
1
11
6
8
0
11
6
8
1
1
0
2
3,281
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/tokenization_layoutlm.py
transformers.models.layoutlm.tokenization_layoutlm.LayoutLMTokenizer
import os from ...tokenization_utils import PreTrainedTokenizer, _is_control, _is_punctuation, _is_whitespace from typing import Optional import collections class LayoutLMTokenizer(PreTrainedTokenizer): """ Construct a LayoutLM tokenizer. Based on WordPiece. This tokenizer inherits from [`PreTrainedTokeni...
class LayoutLMTokenizer(PreTrainedTokenizer): ''' Construct a LayoutLM tokenizer. Based on WordPiece. 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...
14
6
15
1
10
4
2
0.72
1
9
2
0
12
5
12
101
236
29
121
53
85
87
65
29
52
6
3
3
27
3,282
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlm/tokenization_layoutlm_fast.py
transformers.models.layoutlm.tokenization_layoutlm_fast.LayoutLMTokenizerFast
from typing import Optional from ...tokenization_utils_fast import PreTrainedTokenizerFast from tokenizers import normalizers from .tokenization_layoutlm import LayoutLMTokenizer import json class LayoutLMTokenizerFast(PreTrainedTokenizerFast): """ Construct a "fast" LayoutLM tokenizer (backed by HuggingFace's...
class LayoutLMTokenizerFast(PreTrainedTokenizerFast): ''' Construct a "fast" LayoutLM tokenizer (backed by HuggingFace's *tokenizers* library). Based on WordPiece. This tokenizer inherits from [`PreTrainedTokenizerFast`] which contains most of the main methods. Users should refer to this superclass for...
4
2
24
3
14
7
2
1.12
1
4
0
0
4
1
4
92
141
18
58
29
38
65
27
14
22
2
3
1
7
3,283
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/configuration_layoutlmv2.py
transformers.models.layoutlmv2.configuration_layoutlmv2.LayoutLMv2Config
from ...configuration_utils import PretrainedConfig class LayoutLMv2Config(PretrainedConfig): """ This is the configuration class to store the configuration of a [`LayoutLMv2Model`]. It is used to instantiate an LayoutLMv2 model according to the specified arguments, defining the model architecture. Instant...
class LayoutLMv2Config(PretrainedConfig): ''' This is the configuration class to store the configuration of a [`LayoutLMv2Model`]. It is used to instantiate an LayoutLMv2 model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yi...
5
1
34
0
34
0
2
0.72
1
1
0
0
2
14
3
3
191
12
104
55
69
75
29
24
25
3
1
2
6
3,284
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/feature_extraction_layoutlmv2.py
transformers.models.layoutlmv2.feature_extraction_layoutlmv2.LayoutLMv2FeatureExtractor
from ...utils.import_utils import requires import warnings from .image_processing_layoutlmv2 import LayoutLMv2ImageProcessor @requires(backends=('vision',)) class LayoutLMv2FeatureExtractor(LayoutLMv2ImageProcessor): def __init__(self, *args, **kwargs) -> None: warnings.warn('The class LayoutLMv2FeatureEx...
@requires(backends=('vision',)) class LayoutLMv2FeatureExtractor(LayoutLMv2ImageProcessor): def __init__(self, *args, **kwargs) -> None: pass
3
0
7
0
7
0
1
0
1
2
0
0
1
0
1
24
8
0
8
2
6
0
4
2
2
1
4
0
1
3,285
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/image_processing_layoutlmv2.py
transformers.models.layoutlmv2.image_processing_layoutlmv2.LayoutLMv2ImageProcessor
from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from typing import Optional, Union from ...utils import TensorType, filter_out_non_signature_kwargs, is_pytesseract_available, is_vision_available, logging, requires_backends from ...image_utils import ChannelDimension, ImageInput, PI...
@requires(backends=('vision',)) class LayoutLMv2ImageProcessor(BaseImageProcessor): ''' Constructs a LayoutLMv2 image processor. Args: do_resize (`bool`, *optional*, defaults to `True`): Whether to resize the image's (height, width) dimensions to `(size["height"], size["width"])`. Can be...
6
3
56
4
32
20
6
0.82
1
7
2
1
3
6
3
23
198
18
99
46
65
81
50
16
46
13
3
2
17
3,286
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py
transformers.models.layoutlmv2.modeling_layoutlmv2.LayoutLMv2Attention
from torch import nn class LayoutLMv2Attention(nn.Module): def __init__(self, config): super().__init__() self.self = LayoutLMv2SelfAttention(config) self.output = LayoutLMv2SelfOutput(config) def forward(self, hidden_states, attention_mask=None, head_mask=None, output_attentions=Fals...
class LayoutLMv2Attention(nn.Module): def __init__(self, config): pass def forward(self, hidden_states, attention_mask=None, head_mask=None, output_attentions=False, rel_pos=None, rel_2d_pos=None): pass
3
0
12
0
12
1
1
0.04
1
3
2
0
2
2
2
12
26
1
25
16
14
1
10
8
7
1
1
0
2
3,287
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py
transformers.models.layoutlmv2.modeling_layoutlmv2.LayoutLMv2Embeddings
from torch import nn import torch class LayoutLMv2Embeddings(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, config.hidden_size, padding_idx=config.pa...
class LayoutLMv2Embeddings(nn.Module): '''Construct the embeddings from word, position and token_type embeddings.''' def __init__(self, config): pass def _calc_spatial_position_embeddings(self, bbox): pass
3
1
21
3
18
0
2
0.03
1
2
0
0
2
9
2
12
45
7
37
20
34
1
25
19
22
2
1
1
3
3,288
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py
transformers.models.layoutlmv2.modeling_layoutlmv2.LayoutLMv2Encoder
from torch import nn import torch from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput class LayoutLMv2Encoder(nn.Module): def __init__(self, config): super().__init__() self.config = config ...
class LayoutLMv2Encoder(nn.Module): def __init__(self, config): pass def _calculate_1d_position_embeddings(self, position_ids): pass def _calculate_2d_position_embeddings(self, bbox): pass def forward(self, hidden_states, attention_mask=None, head_mask=None, output_attention...
5
0
32
3
27
2
4
0.07
1
6
2
0
4
12
4
14
130
14
108
43
93
8
58
33
53
12
1
2
17
3,289
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py
transformers.models.layoutlmv2.modeling_layoutlmv2.LayoutLMv2ForQuestionAnswering
from torch import nn from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput from ...utils import auto_docstring, is_detectron2_available, logging, requires_backends from typing import Optional, Union import torch from to...
@auto_docstring class LayoutLMv2ForQuestionAnswering(LayoutLMv2PreTrainedModel): def __init__(self, config, has_visual_segment_embedding=True): ''' has_visual_segment_embedding (`bool`, *optional*, defaults to `True`): Whether or not to add visual segment embeddings. ''' ...
6
2
47
6
24
17
3
0.67
1
4
2
0
3
3
3
4
146
21
75
35
54
50
39
19
35
8
2
2
10
3,290
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py
transformers.models.layoutlmv2.modeling_layoutlmv2.LayoutLMv2ForSequenceClassification
from typing import Optional, Union from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from torch import nn from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput from ...utils import auto_docstring, is_det...
@auto_docstring(custom_intro='\n LayoutLMv2 Model with a sequence classification head on top (a linear layer on top of the concatenation of the\n final hidden state of the [CLS] token, average-pooled initial visual embeddings and average-pooled final visual\n embeddings, e.g. for document image classification ...
6
1
55
8
36
11
6
0.29
1
7
2
0
3
4
3
4
171
26
112
40
92
33
60
25
56
17
2
3
19
3,291
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py
transformers.models.layoutlmv2.modeling_layoutlmv2.LayoutLMv2ForTokenClassification
from ...utils import auto_docstring, is_detectron2_available, logging, requires_backends from torch import nn from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput import torch from typing import Optional, Union from to...
@auto_docstring(custom_intro='\n LayoutLMv2 Model with a token classification head on top (a linear layer on top of the text part of the hidden\n states) e.g. for sequence labeling (information extraction) tasks such as\n [FUNSD](https://guillaumejaume.github.io/FUNSD/), [SROIE](https://rrc.cvc.uab.es/?ch=13),...
6
1
39
5
20
14
3
0.66
1
4
2
0
3
4
3
4
121
18
62
31
42
41
28
16
24
6
2
1
8
3,292
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py
transformers.models.layoutlmv2.modeling_layoutlmv2.LayoutLMv2Intermediate
from ...activations import ACT2FN import torch from torch import nn class LayoutLMv2Intermediate(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.intermedi...
class LayoutLMv2Intermediate(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,293
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py
transformers.models.layoutlmv2.modeling_layoutlmv2.LayoutLMv2Layer
from ...pytorch_utils import apply_chunking_to_forward from ...modeling_layers import GradientCheckpointingLayer class LayoutLMv2Layer(GradientCheckpointingLayer): def __init__(self, config): super().__init__() self.chunk_size_feed_forward = config.chunk_size_feed_forward self.seq_len_dim ...
class LayoutLMv2Layer(GradientCheckpointingLayer): def __init__(self, config): pass def forward(self, hidden_states, attention_mask=None, head_mask=None, output_attentions=False, rel_pos=None, rel_2d_pos=None): pass def feed_forward_chunk(self, attention_output): pass
4
0
13
1
12
0
1
0.03
1
4
3
0
3
5
3
13
41
5
36
23
24
1
19
15
15
1
1
0
3
3,294
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py
transformers.models.layoutlmv2.modeling_layoutlmv2.LayoutLMv2Model
from typing import Optional, Union from torch import nn import torch from ...utils import auto_docstring, is_detectron2_available, logging, requires_backends from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput @auto_...
@auto_docstring class LayoutLMv2Model(LayoutLMv2PreTrainedModel): def __init__(self, config): pass def get_input_embeddings(self): pass def set_input_embeddings(self, value): pass def _calc_text_embeddings(self, input_ids, bbox, position_ids, token_type_ids, inputs_embeds=Non...
11
1
30
4
23
3
4
0.12
1
10
5
0
8
10
8
9
250
42
185
64
161
23
108
50
99
13
2
2
29
3,295
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py
transformers.models.layoutlmv2.modeling_layoutlmv2.LayoutLMv2Output
import torch from torch import nn class LayoutLMv2Output(nn.Module): def __init__(self, config): super().__init__() self.dense = nn.Linear(config.intermediate_size, config.hidden_size) self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps) self.dropout = nn.Dr...
class LayoutLMv2Output(nn.Module): def __init__(self, config): pass def forward(self, hidden_states: torch.Tensor, input_tensor: torch.Tensor) -> torch.Tensor: pass
3
0
5
0
5
0
1
0
1
2
0
0
2
3
2
12
12
1
11
6
8
0
11
6
8
1
1
0
2
3,296
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py
transformers.models.layoutlmv2.modeling_layoutlmv2.LayoutLMv2Pooler
from torch import nn class LayoutLMv2Pooler(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): first_token_tensor = hidden_states[:, 0] ...
class LayoutLMv2Pooler(nn.Module): def __init__(self, config): pass def forward(self, hidden_states): pass
3
0
6
0
5
1
1
0.2
1
1
0
0
2
2
2
12
13
1
10
7
7
2
10
7
7
1
1
0
2
3,297
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py
transformers.models.layoutlmv2.modeling_layoutlmv2.LayoutLMv2PreTrainedModel
from torch import nn from .configuration_layoutlmv2 import LayoutLMv2Config from ...utils import auto_docstring, is_detectron2_available, logging, requires_backends from ...modeling_utils import PreTrainedModel @auto_docstring class LayoutLMv2PreTrainedModel(PreTrainedModel): config: LayoutLMv2Config base_mode...
@auto_docstring class LayoutLMv2PreTrainedModel(PreTrainedModel): def _init_weights(self, module): '''Initialize the weights''' pass
3
1
18
0
15
3
8
0.39
1
1
1
4
1
0
1
1
27
2
18
4
16
7
15
4
13
8
1
2
8
3,298
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py
transformers.models.layoutlmv2.modeling_layoutlmv2.LayoutLMv2SelfAttention
import math import torch from torch import nn class LayoutLMv2SelfAttention(nn.Module): def __init__(self, config): super().__init__() if config.hidden_size % config.num_attention_heads != 0 and (not hasattr(config, 'embedding_size')): raise ValueError(f'The hidden size ({config.hidden...
class LayoutLMv2SelfAttention(nn.Module): def __init__(self, config): pass def compute_qkv(self, hidden_states): pass def forward(self, hidden_states, attention_mask=None, head_mask=None, output_attentions=False, rel_pos=None, rel_2d_pos=None): pass
4
0
22
2
19
1
3
0.07
1
4
0
0
4
13
4
14
91
11
75
39
62
5
59
31
54
5
1
2
12
3,299
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py
transformers.models.layoutlmv2.modeling_layoutlmv2.LayoutLMv2SelfOutput
from torch import nn class LayoutLMv2SelfOutput(nn.Module): def __init__(self, config): super().__init__() self.dense = nn.Linear(config.hidden_size, config.hidden_size) self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps) self.dropout = nn.Dropout(config.hi...
class LayoutLMv2SelfOutput(nn.Module): def __init__(self, config): pass def forward(self, hidden_states, input_tensor): pass
3
0
5
0
5
0
1
0
1
1
0
0
2
3
2
12
12
1
11
6
8
0
11
6
8
1
1
0
2