From cd57355d05285dfd6b391b175463a895df173732 Mon Sep 17 00:00:00 2001 From: JINO ROHIT Date: Mon, 15 Apr 2024 16:09:10 +0530 Subject: [PATCH] Set pad_token in run_glue_no_trainer.py #28534 (#30234) --- examples/pytorch/text-classification/run_glue_no_trainer.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/pytorch/text-classification/run_glue_no_trainer.py b/examples/pytorch/text-classification/run_glue_no_trainer.py index 24c983145d6b7e..d679a6a63c7c66 100644 --- a/examples/pytorch/text-classification/run_glue_no_trainer.py +++ b/examples/pytorch/text-classification/run_glue_no_trainer.py @@ -327,6 +327,9 @@ def main(): tokenizer = AutoTokenizer.from_pretrained( args.model_name_or_path, use_fast=not args.use_slow_tokenizer, trust_remote_code=args.trust_remote_code ) + if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + config.pad_token_id = tokenizer.pad_token_id model = AutoModelForSequenceClassification.from_pretrained( args.model_name_or_path, from_tf=bool(".ckpt" in args.model_name_or_path),