How can I change the forward function of BertForSequenceClassification

I run the code in /examples/pytorch/text-classification/run_glue_no_trainer.py. I want to change the forward funtion of BertForSequenceClassification.
My model is :
model = AutoModelForSequenceClassification.from_pretrained(
args.model_name_or_path,
from_tf=bool(".ckpt" in args.model_name_or_path),
config=config,
)
I change the code of class BertForSequenceClassification(BertPreTrainedModel) in src/transformers/models/bert/modeling_bert.py. But nothing happens, the forward function is still the same as the origin. I want to know how to change the code to change the forward function? Thanks!

1 Like