Upload custom_model.py
Browse files- custom_model.py +14 -0
custom_model.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import GPT2LMHeadModel
|
2 |
+
|
3 |
+
class CustomGPT2Model(GPT2LMHeadModel):
|
4 |
+
def __init__(self, config):
|
5 |
+
super().__init__(config)
|
6 |
+
|
7 |
+
def forward(self, input_ids=None, attention_mask=None, **kwargs):
|
8 |
+
# Custom forward logic
|
9 |
+
outputs = super().forward(input_ids=input_ids, attention_mask=attention_mask, **kwargs)
|
10 |
+
# Modify the outputs as needed
|
11 |
+
|
12 |
+
print('USING CUSTOM WRAPPER')
|
13 |
+
return outputs
|
14 |
+
|