text stringlengths 31 243k | type stringclasses 1
value | start int64 36 275k | end int64 286 280k | depth int64 0 1 | filepath stringlengths 85 188 | parent_class stringclasses 3
values | class_index int64 0 10.8k |
|---|---|---|---|---|---|---|---|
class TFCLIPEncoderLayer(keras.layers.Layer):
def __init__(self, config: CLIPConfig, **kwargs):
super().__init__(**kwargs)
self.embed_dim = config.hidden_size
self.self_attn = TFCLIPAttention(config, name="self_attn")
self.layer_norm1 = keras.layers.LayerNormalization(epsilon=config... | class_definition | 16,740 | 19,753 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_tf_clip.py | null | 4,800 |
class TFCLIPEncoder(keras.layers.Layer):
"""
Transformer encoder consisting of `config.num_hidden_layers` self attention layers. Each layer is a
[`TFCLIPEncoderLayer`].
Args:
config: CLIPConfig
"""
def __init__(self, config: CLIPConfig, **kwargs):
super().__init__(**kwargs)
... | class_definition | 19,756 | 21,943 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_tf_clip.py | null | 4,801 |
class TFCLIPTextTransformer(keras.layers.Layer):
def __init__(self, config: CLIPTextConfig, **kwargs):
super().__init__(**kwargs)
self.embeddings = TFCLIPTextEmbeddings(config, name="embeddings")
self.encoder = TFCLIPEncoder(config, name="encoder")
self.final_layer_norm = keras.laye... | class_definition | 21,946 | 27,185 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_tf_clip.py | null | 4,802 |
class TFCLIPTextMainLayer(keras.layers.Layer):
config_class = CLIPTextConfig
def __init__(self, config: CLIPTextConfig, **kwargs):
super().__init__(**kwargs)
self.config = config
self.text_model = TFCLIPTextTransformer(config, name="text_model")
def get_input_embeddings(self) -> ke... | class_definition | 27,208 | 29,107 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_tf_clip.py | null | 4,803 |
class TFCLIPVisionTransformer(keras.layers.Layer):
def __init__(self, config: CLIPVisionConfig, **kwargs):
super().__init__(**kwargs)
self.embeddings = TFCLIPVisionEmbeddings(config, name="embeddings")
self.pre_layernorm = keras.layers.LayerNormalization(epsilon=config.layer_norm_eps, name=... | class_definition | 29,110 | 31,710 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_tf_clip.py | null | 4,804 |
class TFCLIPVisionMainLayer(keras.layers.Layer):
config_class = CLIPVisionConfig
def __init__(self, config: CLIPVisionConfig, **kwargs):
super().__init__(**kwargs)
self.config = config
self.vision_model = TFCLIPVisionTransformer(config, name="vision_model")
def get_input_embeddings... | class_definition | 31,733 | 33,148 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_tf_clip.py | null | 4,805 |
class TFCLIPMainLayer(keras.layers.Layer):
config_class = CLIPConfig
def __init__(self, config: CLIPConfig, **kwargs):
super().__init__(**kwargs)
if not isinstance(config.text_config, CLIPTextConfig):
raise TypeError(
"config.text_config is expected to be of type CL... | class_definition | 33,171 | 40,780 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_tf_clip.py | null | 4,806 |
class TFCLIPPreTrainedModel(TFPreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = CLIPConfig
base_model_prefix = "clip"
_keys_to_ignore_on_load_missing = [r"position_ids"]
_keys... | class_definition | 40,783 | 41,152 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_tf_clip.py | null | 4,807 |
class TFCLIPTextModel(TFCLIPPreTrainedModel):
config_class = CLIPTextConfig
def __init__(self, config: CLIPTextConfig, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.clip = TFCLIPTextMainLayer(config, name="clip")
@unpack_inputs
@add_start_docstrings_to_model_for... | class_definition | 50,054 | 52,204 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_tf_clip.py | null | 4,808 |
class TFCLIPVisionModel(TFCLIPPreTrainedModel):
config_class = CLIPVisionConfig
main_input_name = "pixel_values"
def __init__(self, config: CLIPVisionConfig, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.clip = TFCLIPVisionMainLayer(config, name="clip")
@unpack_... | class_definition | 52,207 | 54,332 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_tf_clip.py | null | 4,809 |
class TFCLIPModel(TFCLIPPreTrainedModel):
config_class = CLIPConfig
def __init__(self, config: CLIPConfig, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.clip = TFCLIPMainLayer(config, name="clip")
@unpack_inputs
@add_start_docstrings_to_model_forward(CLIP_TEXT_I... | class_definition | 54,379 | 60,357 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_tf_clip.py | null | 4,810 |
class FlaxCLIPTextModelOutput(ModelOutput):
"""
Base class for text model's outputs that also contains a pooling of the last hidden states.
Args:
text_embeds (`jnp.ndarray` of shape `(batch_size, output_dim`):
The text embeddings obtained by applying the projection layer to the pooled o... | class_definition | 8,125 | 9,729 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,811 |
class FlaxCLIPOutput(ModelOutput):
"""
Args:
logits_per_image:(`jnp.ndarray` of shape `(image_batch_size, text_batch_size)`):
The scaled dot product scores between `image_embeds` and `text_embeds`. This represents the image-text
similarity scores.
logits_per_text:(`jnp.nd... | class_definition | 9,755 | 11,421 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,812 |
class FlaxCLIPVisionEmbeddings(nn.Module):
config: CLIPVisionConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
embed_dim = self.config.hidden_size
image_size = self.config.image_size
patch_size = self.config.patch_size
self.class_embedding = self.param("class_embedding... | class_definition | 11,424 | 12,995 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,813 |
class FlaxCLIPTextEmbeddings(nn.Module):
config: CLIPTextConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
embed_dim = self.config.hidden_size
self.token_embedding = nn.Embed(self.config.vocab_size, embed_dim, embedding_init=jax.nn.initializers.normal())
self.position_embeddin... | class_definition | 12,998 | 13,862 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,814 |
class FlaxCLIPAttention(nn.Module):
config: Union[CLIPTextConfig, CLIPVisionConfig]
dtype: jnp.dtype = jnp.float32
def setup(self):
self.embed_dim = self.config.hidden_size
self.num_heads = self.config.num_attention_heads
self.head_dim = self.embed_dim // self.num_heads
if s... | class_definition | 13,865 | 17,635 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,815 |
class FlaxCLIPMLP(nn.Module):
config: Union[CLIPTextConfig, CLIPVisionConfig]
dtype: jnp.dtype = jnp.float32
def setup(self):
self.activation_fn = ACT2FN[self.config.hidden_act]
self.fc1 = nn.Dense(
self.config.intermediate_size,
dtype=self.dtype,
kernel_... | class_definition | 17,638 | 18,346 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,816 |
class FlaxCLIPEncoderLayer(nn.Module):
config: Union[CLIPTextConfig, CLIPVisionConfig]
dtype: jnp.dtype = jnp.float32
def setup(self):
self.self_attn = FlaxCLIPAttention(self.config, dtype=self.dtype)
self.layer_norm1 = nn.LayerNorm(epsilon=self.config.layer_norm_eps, dtype=self.dtype)
... | class_definition | 18,349 | 19,704 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,817 |
class FlaxCLIPLayerCollection(nn.Module):
config: Union[CLIPTextConfig, CLIPVisionConfig]
dtype: jnp.dtype = jnp.float32
def setup(self):
self.layers = [
FlaxCLIPEncoderLayer(self.config, name=str(i), dtype=self.dtype)
for i in range(self.config.num_hidden_layers)
]
... | class_definition | 19,707 | 21,181 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,818 |
class FlaxCLIPEncoder(nn.Module):
config: Union[CLIPTextConfig, CLIPVisionConfig]
dtype: jnp.dtype = jnp.float32
def setup(self):
self.layers = FlaxCLIPLayerCollection(self.config, dtype=self.dtype)
def __call__(
self,
inputs_embeds,
attention_mask=None,
determi... | class_definition | 21,184 | 21,954 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,819 |
class FlaxCLIPTextTransformer(nn.Module):
config: CLIPTextConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
self.embeddings = FlaxCLIPTextEmbeddings(self.config, dtype=self.dtype)
self.encoder = FlaxCLIPEncoder(self.config, dtype=self.dtype)
self.final_layer_norm = nn.LayerNorm... | class_definition | 21,957 | 24,821 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,820 |
class FlaxCLIPVisionTransformer(nn.Module):
config: CLIPVisionConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
self.embeddings = FlaxCLIPVisionEmbeddings(self.config, dtype=self.dtype)
self.pre_layrnorm = nn.LayerNorm(epsilon=self.config.layer_norm_eps, dtype=self.dtype)
self.... | class_definition | 24,824 | 26,764 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,821 |
class FlaxCLIPTextPreTrainedModel(FlaxPreTrainedModel):
config_class = CLIPTextConfig
module_class: nn.Module = None
def __init__(
self,
config: CLIPTextConfig,
input_shape=(1, 1),
seed: int = 0,
dtype: jnp.dtype = jnp.float32,
_do_init: bool = True,
... | class_definition | 26,767 | 29,718 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,822 |
class FlaxCLIPVisionPreTrainedModel(FlaxPreTrainedModel):
config_class = CLIPVisionConfig
main_input_name = "pixel_values"
module_class: nn.Module = None
def __init__(
self,
config: CLIPVisionConfig,
input_shape: Optional[Tuple] = None,
seed: int = 0,
dtype: jnp.... | class_definition | 29,721 | 32,349 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,823 |
class FlaxCLIPPreTrainedModel(FlaxPreTrainedModel):
config_class = CLIPConfig
module_class: nn.Module = None
def __init__(
self,
config: CLIPConfig,
input_shape: Optional[Tuple] = None,
seed: int = 0,
dtype: jnp.dtype = jnp.float32,
_do_init: bool = True,
... | class_definition | 32,352 | 40,285 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,824 |
class FlaxCLIPTextModule(nn.Module):
config: CLIPTextConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
self.text_model = FlaxCLIPTextTransformer(self.config, dtype=self.dtype)
def __call__(
self,
input_ids,
attention_mask,
position_ids,
deterministi... | class_definition | 40,288 | 41,088 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,825 |
class FlaxCLIPTextModel(FlaxCLIPTextPreTrainedModel):
module_class = FlaxCLIPTextModule | class_definition | 41,091 | 41,182 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,826 |
class FlaxCLIPTextModelWithProjectionModule(nn.Module):
config: CLIPTextConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
self.text_model = FlaxCLIPTextTransformer(self.config, dtype=self.dtype)
self.text_projection = nn.Dense(self.config.projection_dim, use_bias=False, dtype=self.dtyp... | class_definition | 42,015 | 43,393 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,827 |
class FlaxCLIPTextModelWithProjection(FlaxCLIPTextPreTrainedModel):
module_class = FlaxCLIPTextModelWithProjectionModule | class_definition | 43,396 | 43,520 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,828 |
class FlaxCLIPVisionModule(nn.Module):
config: CLIPVisionConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
self.vision_model = FlaxCLIPVisionTransformer(self.config, dtype=self.dtype)
def __call__(
self,
pixel_values,
deterministic: bool = True,
output_atte... | class_definition | 44,353 | 45,044 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,829 |
class FlaxCLIPVisionModel(FlaxCLIPVisionPreTrainedModel):
module_class = FlaxCLIPVisionModule | class_definition | 45,047 | 45,144 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,830 |
class FlaxCLIPModule(nn.Module):
config: CLIPConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
text_config = self.config.text_config
vision_config = self.config.vision_config
self.projection_dim = self.config.projection_dim
self.text_embed_dim = text_config.hidden_size... | class_definition | 46,132 | 49,287 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,831 |
class FlaxCLIPModel(FlaxCLIPPreTrainedModel):
module_class = FlaxCLIPModule | class_definition | 49,334 | 49,413 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_flax_clip.py | null | 4,832 |
class CLIPImageProcessor(BaseImageProcessor):
r"""
Constructs a CLIP image processor.
Args:
do_resize (`bool`, *optional*, defaults to `True`):
Whether to resize the image's (height, width) dimensions to the specified `size`. Can be overridden by
`do_resize` in the `preproce... | class_definition | 1,413 | 16,767 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/image_processing_clip.py | null | 4,833 |
class CLIPProcessor(ProcessorMixin):
r"""
Constructs a CLIP processor which wraps a CLIP image processor and a CLIP tokenizer into a single processor.
[`CLIPProcessor`] offers all the functionalities of [`CLIPImageProcessor`] and [`CLIPTokenizerFast`]. See the
[`~CLIPProcessor.__call__`] and [`~CLIPPro... | class_definition | 769 | 7,147 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/processing_clip.py | null | 4,834 |
class CLIPVisionModelOutput(ModelOutput):
"""
Base class for vision model's outputs that also contains image embeddings of the pooling of the last hidden states.
Args:
image_embeds (`torch.FloatTensor` of shape `(batch_size, output_dim)` *optional* returned when model is initialized with `with_proj... | class_definition | 2,880 | 4,664 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,835 |
class CLIPTextModelOutput(ModelOutput):
"""
Base class for text model's outputs that also contains a pooling of the last hidden states.
Args:
text_embeds (`torch.FloatTensor` of shape `(batch_size, output_dim)` *optional* returned when model is initialized with `with_projection=True`):
... | class_definition | 4,678 | 6,433 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,836 |
class CLIPOutput(ModelOutput):
"""
Args:
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `return_loss` is `True`):
Contrastive loss for image-text similarity.
logits_per_image (`torch.FloatTensor` of shape `(image_batch_size, text_batch_size)`):
The s... | class_definition | 6,447 | 8,309 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,837 |
class CLIPVisionEmbeddings(nn.Module):
def __init__(self, config: CLIPVisionConfig):
super().__init__()
self.config = config
self.embed_dim = config.hidden_size
self.image_size = config.image_size
self.patch_size = config.patch_size
self.class_embedding = nn.Paramete... | class_definition | 8,312 | 12,138 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,838 |
class CLIPTextEmbeddings(nn.Module):
def __init__(self, config: CLIPTextConfig):
super().__init__()
embed_dim = config.hidden_size
self.token_embedding = nn.Embedding(config.vocab_size, embed_dim)
self.position_embedding = nn.Embedding(config.max_position_embeddings, embed_dim)
... | class_definition | 12,141 | 13,719 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,839 |
class CLIPAttention(nn.Module):
"""Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(self, config):
super().__init__()
self.config = config
self.embed_dim = config.hidden_size
self.num_heads = config.num_attention_heads
self.head_dim = self.em... | class_definition | 13,722 | 18,452 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,840 |
class CLIPFlashAttention2(CLIPAttention):
"""
CLIPAttention flash attention module. This module inherits from `CLIPAttention` 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 wi... | class_definition | 18,455 | 22,575 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,841 |
class CLIPSdpaAttention(CLIPAttention):
"""
SDPA attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from
`CLIPAttention` as the weights of the module stays untouched. The only changes are on the forward pass to adapt to
SDPA API.
"""
# Adapted from CLI... | class_definition | 22,578 | 26,043 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,842 |
class CLIPMLP(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)
self.fc2 = nn.Linear(config.intermediate_size, config.hidden_size)
... | class_definition | 26,182 | 26,752 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,843 |
class CLIPEncoderLayer(nn.Module):
def __init__(self, config: CLIPConfig):
super().__init__()
self.embed_dim = config.hidden_size
self.self_attn = CLIP_ATTENTION_CLASSES[config._attn_implementation](config)
self.layer_norm1 = nn.LayerNorm(self.embed_dim, eps=config.layer_norm_eps)
... | class_definition | 26,755 | 28,738 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,844 |
class CLIPPreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = CLIPConfig
base_model_prefix = "clip"
supports_gradient_checkpointing = True
_supports_sdpa = True
... | class_definition | 28,741 | 32,150 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,845 |
class CLIPEncoder(nn.Module):
"""
Transformer encoder consisting of `config.num_hidden_layers` self attention layers. Each layer is a
[`CLIPEncoderLayer`].
Args:
config: CLIPConfig
"""
def __init__(self, config: CLIPConfig):
super().__init__()
self.config = config
... | class_definition | 37,987 | 42,375 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,846 |
class CLIPTextTransformer(nn.Module):
def __init__(self, config: CLIPTextConfig):
super().__init__()
self.config = config
embed_dim = config.hidden_size
self.embeddings = CLIPTextEmbeddings(config)
self.encoder = CLIPEncoder(config)
self.final_layer_norm = nn.LayerNor... | class_definition | 42,378 | 47,213 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,847 |
class CLIPTextModel(CLIPPreTrainedModel):
config_class = CLIPTextConfig
_no_split_modules = ["CLIPTextEmbeddings", "CLIPEncoderLayer"]
def __init__(self, config: CLIPTextConfig):
super().__init__(config)
self.text_model = CLIPTextTransformer(config)
# Initialize weights and apply f... | class_definition | 47,342 | 49,468 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,848 |
class CLIPVisionTransformer(nn.Module):
def __init__(self, config: CLIPVisionConfig):
super().__init__()
self.config = config
embed_dim = config.hidden_size
self.embeddings = CLIPVisionEmbeddings(config)
self.pre_layrnorm = nn.LayerNorm(embed_dim, eps=config.layer_norm_eps)
... | class_definition | 49,471 | 51,846 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,849 |
class CLIPVisionModel(CLIPPreTrainedModel):
config_class = CLIPVisionConfig
main_input_name = "pixel_values"
_no_split_modules = ["CLIPEncoderLayer"]
def __init__(self, config: CLIPVisionConfig):
super().__init__(config)
self.vision_model = CLIPVisionTransformer(config)
# Initia... | class_definition | 51,977 | 54,126 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,850 |
class CLIPModel(CLIPPreTrainedModel):
config_class = CLIPConfig
_no_split_modules = ["CLIPTextEmbeddings", "CLIPEncoderLayer", "CLIPVisionEmbeddings"]
def __init__(self, config: CLIPConfig):
super().__init__(config)
if not isinstance(config.text_config, CLIPTextConfig):
raise T... | class_definition | 54,173 | 63,913 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,851 |
class CLIPTextModelWithProjection(CLIPPreTrainedModel):
config_class = CLIPTextConfig
_no_split_modules = ["CLIPTextEmbeddings", "CLIPEncoderLayer"]
def __init__(self, config: CLIPTextConfig):
super().__init__(config)
text_model = CLIPTextModel._from_config(config)
self.text_model... | class_definition | 64,081 | 66,827 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,852 |
class CLIPVisionModelWithProjection(CLIPPreTrainedModel):
config_class = CLIPVisionConfig
main_input_name = "pixel_values"
def __init__(self, config: CLIPVisionConfig):
super().__init__(config)
vision_model = CLIPVisionModel._from_config(config)
self.vision_model = vision_model.vis... | class_definition | 66,997 | 69,782 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,853 |
class CLIPForImageClassification(CLIPPreTrainedModel):
main_input_name = "pixel_values"
def __init__(self, config: CLIPConfig) -> None:
super().__init__(config)
self.num_labels = config.num_labels
vision_model = CLIPVisionModel._from_config(config.vision_config)
self.vision_mod... | class_definition | 70,019 | 74,045 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/modeling_clip.py | null | 4,854 |
class BasicTokenizer:
"""
Constructs a BasicTokenizer that will run basic tokenization (punctuation splitting, lower casing, etc.).
Args:
do_lower_case (`bool`, *optional*, defaults to `True`):
Whether or not to lowercase the input when tokenizing.
never_split (`Iterable`, *opti... | class_definition | 2,830 | 9,578 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/tokenization_clip.py | null | 4,855 |
class CLIPTokenizer(PreTrainedTokenizer):
"""
Construct a CLIP tokenizer. Based on byte-level Byte-Pair-Encoding.
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:
... | class_definition | 9,581 | 20,575 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/tokenization_clip.py | null | 4,856 |
class CLIPTokenizerFast(PreTrainedTokenizerFast):
"""
Construct a "fast" CLIP tokenizer (backed by HuggingFace's *tokenizers* library). Based on byte-level
Byte-Pair-Encoding.
This tokenizer inherits from [`PreTrainedTokenizerFast`] which contains most of the main methods. Users should
refer to thi... | class_definition | 1,053 | 6,745 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/tokenization_clip_fast.py | null | 4,857 |
class CLIPFeatureExtractor(CLIPImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class CLIPFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please"
" use CLIPImageProcessor instead.",
FutureWarning,
)... | class_definition | 809 | 1,171 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/clip/feature_extraction_clip.py | null | 4,858 |
class Qwen2MLP(LlamaMLP):
def __init__(self, config):
super().__init__(config)
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
self.down_proj = nn.Linear(self.intermediate_... | class_definition | 709 | 1,064 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modular_qwen2.py | null | 4,859 |
class Qwen2Attention(LlamaAttention):
def __init__(self, config: Qwen2Config, layer_idx: int):
super().__init__(config, layer_idx)
self.q_proj = nn.Linear(config.hidden_size, config.num_attention_heads * self.head_dim, bias=True)
self.k_proj = nn.Linear(config.hidden_size, config.num_key_val... | class_definition | 1,067 | 4,395 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modular_qwen2.py | null | 4,860 |
class Qwen2DecoderLayer(LlamaDecoderLayer):
def __init__(self, config: Qwen2Config, layer_idx: int):
super().__init__()
self.self_attn = Qwen2Attention(config=config, layer_idx=layer_idx)
self.mlp = Qwen2MLP(config)
if config.sliding_window and config._attn_implementation != "flash_a... | class_definition | 4,398 | 4,947 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modular_qwen2.py | null | 4,861 |
class Qwen2Model(LlamaModel):
pass | class_definition | 4,950 | 4,988 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modular_qwen2.py | null | 4,862 |
class Qwen2ForCausalLM(LlamaForCausalLM):
pass | class_definition | 4,991 | 5,041 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modular_qwen2.py | null | 4,863 |
class Qwen2ForSequenceClassification(LlamaForSequenceClassification):
pass | class_definition | 5,044 | 5,122 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modular_qwen2.py | null | 4,864 |
class Qwen2ForTokenClassification(LlamaForTokenClassification):
pass | class_definition | 5,125 | 5,197 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modular_qwen2.py | null | 4,865 |
class Qwen2ForQuestionAnswering(LlamaForQuestionAnswering):
pass | class_definition | 5,200 | 5,268 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modular_qwen2.py | null | 4,866 |
class Qwen2Tokenizer(PreTrainedTokenizer):
"""
Construct a Qwen2 tokenizer. Based on byte-level Byte-Pair-Encoding.
Same with GPT2Tokenizer, this tokenizer has been trained to treat spaces like parts of the tokens so a word will
be encoded differently whether it is at the beginning of the sentence (wit... | class_definition | 2,674 | 13,912 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/tokenization_qwen2.py | null | 4,867 |
class Qwen2Config(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`Qwen2Model`]. It is used to instantiate a
Qwen2 model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a similar co... | class_definition | 873 | 10,516 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/configuration_qwen2.py | null | 4,868 |
class Qwen2MLP(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.hidden_size, self.intermediate_size, bias=False)
self... | class_definition | 1,886 | 2,554 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modeling_qwen2.py | null | 4,869 |
class Qwen2Attention(nn.Module):
"""Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(self, config: Qwen2Config, layer_idx: int):
super().__init__()
self.config = config
self.layer_idx = layer_idx
self.head_dim = getattr(config, "head_dim", config.hid... | class_definition | 5,833 | 9,602 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modeling_qwen2.py | null | 4,870 |
class Qwen2RMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-6):
"""
Qwen2RMSNorm is equivalent to T5LayerNorm
"""
super().__init__()
self.weight = nn.Parameter(torch.ones(hidden_size))
self.variance_epsilon = eps
def forward(self, hidden_states):
... | class_definition | 9,605 | 10,325 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modeling_qwen2.py | null | 4,871 |
class Qwen2DecoderLayer(nn.Module):
def __init__(self, config: Qwen2Config, layer_idx: int):
super().__init__()
self.hidden_size = config.hidden_size
self.self_attn = Qwen2Attention(config=config, layer_idx=layer_idx)
self.mlp = Qwen2MLP(config)
self.input_layernorm = Qwen2RM... | class_definition | 10,328 | 12,702 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modeling_qwen2.py | null | 4,872 |
class Qwen2RotaryEmbedding(nn.Module):
def __init__(self, config: Qwen2Config, device=None):
super().__init__()
# BC: "rope_type" was originally "type"
if hasattr(config, "rope_scaling") and config.rope_scaling is not None:
self.rope_type = config.rope_scaling.get("rope_type", co... | class_definition | 12,705 | 15,900 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modeling_qwen2.py | null | 4,873 |
class Qwen2PreTrainedModel(PreTrainedModel):
config_class = Qwen2Config
base_model_prefix = "model"
supports_gradient_checkpointing = True
_no_split_modules = ["Qwen2DecoderLayer"]
_skip_keys_device_placement = ["past_key_values"]
_supports_flash_attn_2 = True
_supports_sdpa = True
_supp... | class_definition | 16,922 | 17,845 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modeling_qwen2.py | null | 4,874 |
class Qwen2Model(Qwen2PreTrainedModel):
"""
Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`Qwen2DecoderLayer`]
Args:
config: Qwen2Config
"""
def __init__(self, config: Qwen2Config):
super().__init__(config)
self.padding_idx = config.p... | class_definition | 22,649 | 33,874 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modeling_qwen2.py | null | 4,875 |
class KwargsForCausalLM(FlashAttentionKwargs, LossKwargs): ... | class_definition | 33,877 | 33,939 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modeling_qwen2.py | null | 4,876 |
class Qwen2ForCausalLM(Qwen2PreTrainedModel, GenerationMixin):
_tied_weights_keys = ["lm_head.weight"]
_tp_plan = {"lm_head": "colwise_rep"}
def __init__(self, config):
super().__init__(config)
self.model = Qwen2Model(config)
self.vocab_size = config.vocab_size
self.lm_head ... | class_definition | 33,942 | 39,069 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modeling_qwen2.py | null | 4,877 |
class Qwen2ForSequenceClassification(Qwen2PreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.num_labels = config.num_labels
self.model = Qwen2Model(config)
self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
# Initialize weights a... | class_definition | 39,862 | 43,674 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modeling_qwen2.py | null | 4,878 |
class Qwen2ForTokenClassification(Qwen2PreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.num_labels = config.num_labels
self.model = Qwen2Model(config)
if getattr(config, "classifier_dropout", None) is not None:
classifier_dropout = config.classi... | class_definition | 43,921 | 47,133 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modeling_qwen2.py | null | 4,879 |
class Qwen2ForQuestionAnswering(Qwen2PreTrainedModel):
base_model_prefix = "transformer"
def __init__(self, config):
super().__init__(config)
self.transformer = Qwen2Model(config)
self.qa_outputs = nn.Linear(config.hidden_size, 2)
# Initialize weights and apply final processing... | class_definition | 47,429 | 50,821 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/modeling_qwen2.py | null | 4,880 |
class Qwen2TokenizerFast(PreTrainedTokenizerFast):
"""
Construct a "fast" Qwen2 tokenizer (backed by HuggingFace's *tokenizers* library). Based on byte-level
Byte-Pair-Encoding.
Same with GPT2Tokenizer, this tokenizer has been trained to treat spaces like parts of the tokens so a word will
be encod... | class_definition | 1,147 | 5,181 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/qwen2/tokenization_qwen2_fast.py | null | 4,881 |
class CTRLTokenizer(PreTrainedTokenizer):
"""
Construct a CTRL tokenizer. Based on Byte-Pair-Encoding.
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:
voc... | class_definition | 2,540 | 8,056 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/ctrl/tokenization_ctrl.py | null | 4,882 |
class MultiHeadAttention(nn.Module):
def __init__(self, d_model_size, num_heads):
super().__init__()
self.num_heads = num_heads
self.d_model_size = d_model_size
self.depth = int(d_model_size / self.num_heads)
self.Wq = nn.Linear(d_model_size, d_model_size)
self.Wk =... | class_definition | 2,873 | 5,503 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/ctrl/modeling_ctrl.py | null | 4,883 |
class EncoderLayer(nn.Module):
def __init__(self, d_model_size, num_heads, dff, rate=0.1):
super().__init__()
self.multi_head_attention = MultiHeadAttention(d_model_size, num_heads)
self.ffn = point_wise_feed_forward_network(d_model_size, dff)
self.layernorm1 = nn.LayerNorm(d_model... | class_definition | 5,660 | 6,993 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/ctrl/modeling_ctrl.py | null | 4,884 |
class CTRLPreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = CTRLConfig
base_model_prefix = "transformer"
def _init_weights(self, module):
"""Initialize th... | class_definition | 6,996 | 8,075 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/ctrl/modeling_ctrl.py | null | 4,885 |
class CTRLModel(CTRLPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.d_model_size = config.n_embd
self.num_layers = config.n_layer
self.pos_encoding = positional_encoding(config.n_positions, self.d_model_size, torch.float)
self.w = nn.Embedding(c... | class_definition | 12,802 | 20,912 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/ctrl/modeling_ctrl.py | null | 4,886 |
class CTRLLMHeadModel(CTRLPreTrainedModel, GenerationMixin):
_tied_weights_keys = ["lm_head.weight"]
def __init__(self, config):
super().__init__(config)
self.transformer = CTRLModel(config)
self.lm_head = nn.Linear(config.n_embd, config.vocab_size, bias=True)
# Initialize weig... | class_definition | 21,113 | 26,947 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/ctrl/modeling_ctrl.py | null | 4,887 |
class CTRLForSequenceClassification(CTRLPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.num_labels = config.num_labels
self.transformer = CTRLModel(config)
self.classifier = nn.Linear(config.n_embd, self.num_labels, bias=False)
# Initialize weight... | class_definition | 27,731 | 35,724 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/ctrl/modeling_ctrl.py | null | 4,888 |
class CTRLConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`CTRLModel`] or a [`TFCTRLModel`]. It is used to
instantiate a CTRL model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will y... | class_definition | 838 | 4,656 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/ctrl/configuration_ctrl.py | null | 4,889 |
class TFMultiHeadAttention(keras.layers.Layer):
def __init__(self, d_model_size, num_heads, output_attentions=False, **kwargs):
super().__init__(**kwargs)
self.num_heads = num_heads
self.d_model_size = d_model_size
self.output_attentions = output_attentions
self.depth = int(... | class_definition | 3,001 | 5,693 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/ctrl/modeling_tf_ctrl.py | null | 4,890 |
class TFPointWiseFeedForwardLayer(keras.layers.Layer):
def __init__(self, d_model_size, dff, **kwargs):
super().__init__(**kwargs)
self.dense_0 = keras.layers.Dense(dff, activation="relu", name="0")
self.dense_2 = keras.layers.Dense(d_model_size, name="2")
self.d_model_size = d_mode... | class_definition | 5,696 | 6,669 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/ctrl/modeling_tf_ctrl.py | null | 4,891 |
class TFEncoderLayer(keras.layers.Layer):
def __init__(
self, d_model_size, num_heads, dff, rate=0.1, layer_norm_epsilon=1e-6, output_attentions=False, **kwargs
):
super().__init__(**kwargs)
self.output_attentions = output_attentions
self.multi_head_attention = TFMultiHeadAtten... | class_definition | 6,672 | 9,170 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/ctrl/modeling_tf_ctrl.py | null | 4,892 |
class TFCTRLMainLayer(keras.layers.Layer):
config_class = CTRLConfig
def __init__(self, config, **kwargs):
super().__init__(**kwargs)
self.config = config
self.output_hidden_states = config.output_hidden_states
self.output_attentions = config.output_attentions
self.use_... | class_definition | 9,193 | 18,106 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/ctrl/modeling_tf_ctrl.py | null | 4,893 |
class TFCTRLPreTrainedModel(TFPreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = CTRLConfig
base_model_prefix = "transformer" | class_definition | 18,109 | 18,370 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/ctrl/modeling_tf_ctrl.py | null | 4,894 |
class TFCTRLModel(TFCTRLPreTrainedModel):
def __init__(self, config, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.transformer = TFCTRLMainLayer(config, name="transformer")
@unpack_inputs
@add_start_docstrings_to_model_forward(CTRL_INPUTS_DOCSTRING)
@add_code_samp... | class_definition | 25,204 | 27,235 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/ctrl/modeling_tf_ctrl.py | null | 4,895 |
class TFCTRLBiasLayer(keras.layers.Layer):
"""
Bias as a layer. It is used for serialization purposes: `keras.Model.save_weights` stores on a per-layer basis,
so all weights have to be registered in a layer.
"""
def __init__(self, shape, initializer, trainable, name, **kwargs):
super().__in... | class_definition | 27,238 | 27,952 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/ctrl/modeling_tf_ctrl.py | null | 4,896 |
class TFCTRLLMHeadModel(TFCTRLPreTrainedModel, TFCausalLanguageModelingLoss):
def __init__(self, config, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.transformer = TFCTRLMainLayer(config, name="transformer")
self.bias_layer = TFCTRLBiasLayer(
name="lm_head... | class_definition | 28,153 | 33,536 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/ctrl/modeling_tf_ctrl.py | null | 4,897 |
class TFCTRLForSequenceClassification(TFCTRLPreTrainedModel, TFSequenceClassificationLoss):
def __init__(self, config, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.num_labels = config.num_labels
self.classifier = keras.layers.Dense(
config.num_labels,
... | class_definition | 34,335 | 39,634 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/ctrl/modeling_tf_ctrl.py | null | 4,898 |
class BertweetTokenizer(PreTrainedTokenizer):
"""
Constructs a BERTweet tokenizer, using Byte-Pair-Encoding.
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:
... | class_definition | 1,410 | 15,659 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bertweet/tokenization_bertweet.py | null | 4,899 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.