Instructions to use akshat57/custom-gpt2-model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use akshat57/custom-gpt2-model with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("akshat57/custom-gpt2-model") model = AutoModel.from_pretrained("akshat57/custom-gpt2-model", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download custom_model.py from akshat57/custom-gpt2-model: direct link, hf CLI and curl.
- Browser
- Download file 447 Bytes
-
https://huggingface.co/akshat57/custom-gpt2-model/resolve/main/custom_model.py
- Command line
-
hf download hf://akshat57/custom-gpt2-model/custom_model.py
-
curl -L -o custom_model.py https://huggingface.co/akshat57/custom-gpt2-model/resolve/main/custom_model.py
447 Bytes
| from transformers import GPT2LMHeadModel | |
| class CustomGPT2Model(GPT2LMHeadModel): | |
| def __init__(self, config): | |
| super().__init__(config) | |
| def forward(self, input_ids=None, attention_mask=None, **kwargs): | |
| # Custom forward logic | |
| outputs = super().forward(input_ids=input_ids, attention_mask=attention_mask, **kwargs) | |
| # Modify the outputs as needed | |
| print('USING CUSTOM WRAPPER') | |
| return outputs | |