espnet2.asr.decoder.hugging_face_transformers_decoder.get_hugging_face_model_network
Less than 1 minute
espnet2.asr.decoder.hugging_face_transformers_decoder.get_hugging_face_model_network
espnet2.asr.decoder.hugging_face_transformers_decoder.get_hugging_face_model_network(model)
Retrieve the network from a Hugging Face model.
This function checks for the presence of specific attributes in the provided model and returns the corresponding network. It is designed to support various model architectures available in the Hugging Face Transformers library.
- Parameters:model – A Hugging Face model instance from which the network is to be retrieved.
- Returns: The network component of the Hugging Face model.
- Raises:Exception – If the model does not contain a recognizable network attribute.
Examples
>>> from transformers import AutoModel
>>> model = AutoModel.from_pretrained("gpt2")
>>> network = get_hugging_face_model_network(model)
>>> print(network) # Should print the network component of the model.
NOTE
This function is used internally within the HuggingFaceTransformersDecoder class to facilitate the integration of various model architectures.