Instructions to use AbdulElahGwaith/transformers with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AbdulElahGwaith/transformers with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("AbdulElahGwaith/transformers", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download examples/modular-transformers/modular_roberta.py from AbdulElahGwaith/transformers: direct link, hf CLI and curl.
- Browser
- Download file 527 Bytes
-
https://huggingface.co/AbdulElahGwaith/transformers/resolve/main/examples/modular-transformers/modular_roberta.py
- Command line
-
hf download hf://AbdulElahGwaith/transformers/examples/modular-transformers/modular_roberta.py
-
curl -L -o modular_roberta.py https://huggingface.co/AbdulElahGwaith/transformers/resolve/main/examples/modular-transformers/modular_roberta.py
527 Bytes
| import torch.nn as nn | |
| from transformers.models.bert.modeling_bert import BertEmbeddings, BertModel | |
| class RobertaEmbeddings(BertEmbeddings): | |
| def __init__(self, config): | |
| super().__init__(config) | |
| self.pad_token_id = config.pad_token_id | |
| self.position_embeddings = nn.Embedding( | |
| config.max_position_embeddings, config.hidden_size, config.pad_token_id | |
| ) | |
| class RobertaModel(BertModel): | |
| def __init__(self, config, add_pooling_layer=True): | |
| super().__init__(self, config) | |