MCPcopy Create free account
hub / github.com/ModalityDance/Omni-R1 / PreTrainedModel

Class PreTrainedModel

src/transformers/src/transformers/modeling_utils.py:1273–4698  ·  view source on GitHub ↗

r""" Base class for all models. [`PreTrainedModel`] takes care of storing the configuration of the models and handles methods for loading, downloading and saving models as well as a few methods common to all models to: - resize the input embeddings, - prune heads in the

Source from the content-addressed store, hash-verified

1271
1272
1273class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMixin, PeftAdapterMixin):
1274 r"""
1275 Base class for all models.
1276
1277 [`PreTrainedModel`] takes care of storing the configuration of the models and handles methods for loading,
1278 downloading and saving models as well as a few methods common to all models to:
1279
1280 - resize the input embeddings,
1281 - prune heads in the self-attention heads.
1282
1283 Class attributes (overridden by derived classes):
1284
1285 - **config_class** ([`PretrainedConfig`]) -- A subclass of [`PretrainedConfig`] to use as configuration class
1286 for this model architecture.
1287 - **load_tf_weights** (`Callable`) -- A python *method* for loading a TensorFlow checkpoint in a PyTorch model,
1288 taking as arguments:
1289
1290 - **model** ([`PreTrainedModel`]) -- An instance of the model on which to load the TensorFlow checkpoint.
1291 - **config** ([`PreTrainedConfig`]) -- An instance of the configuration associated to the model.
1292 - **path** (`str`) -- A path to the TensorFlow checkpoint.
1293
1294 - **base_model_prefix** (`str`) -- A string indicating the attribute associated to the base model in derived
1295 classes of the same architecture adding modules on top of the base model.
1296 - **is_parallelizable** (`bool`) -- A flag indicating whether this model supports model parallelization.
1297 - **main_input_name** (`str`) -- The name of the principal input to the model (often `input_ids` for NLP
1298 models, `pixel_values` for vision models and `input_values` for speech models).
1299 """
1300
1301 config_class = None
1302 base_model_prefix = ""
1303 main_input_name = "input_ids"
1304 model_tags = None
1305
1306 _auto_class = None
1307 _no_split_modules = None
1308 _skip_keys_device_placement = None
1309 _keep_in_fp32_modules = None
1310
1311 # a list of `re` patterns of `state_dict` keys that should be removed from the list of missing
1312 # keys we find (keys inside the model but not in the checkpoint) and avoid unnecessary warnings.
1313 _keys_to_ignore_on_load_missing = None
1314 # a list of `re` patterns of `state_dict` keys that should be removed from the list of
1315 # unexpected keys we find (keys inside the checkpoint but not the model) and avoid unnecessary
1316 # warnings.
1317 _keys_to_ignore_on_load_unexpected = None
1318 # a list of `state_dict` keys to ignore when saving the model (useful for keys that aren't
1319 # trained, but which are either deterministic or tied variables)
1320 _keys_to_ignore_on_save = None
1321 # a list of `state_dict` keys that are potentially tied to another key in the state_dict.
1322 _tied_weights_keys = None
1323
1324 is_parallelizable = False
1325 supports_gradient_checkpointing = False
1326 _is_stateful = False
1327
1328 # Flash Attention 2 support
1329 _supports_flash_attn_2 = False
1330

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected