Inference problem after loading a fine tuned T5 model for seq2seq method in question answering
spiece.model file is not present upon saving the model after training .I used thispython run_seq2seq_qa.py --model_name_or_path t5-small --dataset_name squad_v2 --context_column context --question_column question --answer_column answers --do_train --do_eval --per_device_train_batch_size 12 --learning_rate 3e-5 --num_train_epochs 1 --max_seq_length 384 --doc_stride 128 --output_dir /trained_model/debug_seq2seq_squad/ --max_train_samples 50 --max_eval_samples 50to run the run_seq2seq_qa.py from transformers git examples but cannot be used for inferencing.Files saved after training :generation_config.jsonconfig.jsonall_results.jsontrain_results.jsonspecial_tokens_map.jsoneval_results.jsontokenizer.jsontokenizer_config.jsonrunspytorch_model.bintraining_args.bintrainer_state.jsoncode used :from transformers import T5ForConditionalGeneration, T5Tokenizerdef run_t5_squad_example(model_dir, question, context):# Load the T5 model and tokenizermodel = T5ForConditionalGeneration.from_pretrained(model_dir)tokenizer = T5Tokenizer.from_pretrained(model_dir)# Prepare the input
input_text = f"question: {question} context: {context}"
input_ids = tokenizer.encode(input_text, return_tensors="pt")

# Generate the answer
output = model.generate(input_ids)
answer = tokenizer.decode(output[0], skip_special_tokens=True)

return answermodel_directory = “t5_model”print(type(model_directory))question = “What is the capital of France?”context = “Paris is the capital of France.”answer = run_t5_squad_example(model_directory, question, context)print(“Answer:”, answer)ERROR received:<class ‘str’>┌───────────────────── Traceback (most recent call last) ─────────────────────┐│ C:\Users\admin\Desktop\True_Vision\NLP\Question_Answering\question-answerin ││ g-transformers-git\model_testing.py:23 in                           ││                                                                             ││   20 question = “What is the capital of France?”                            ││   21 context = “Paris is the capital of France.”                            ││   22                                                                        ││ > 23 answer = run_t5_squad_example(model_directory, question, context)      ││   24 print(“Answer:”, answer)                                               ││   25                                                                        ││   26 from transformers import T5ForConditionalGeneration, T5Tokenizer       ││                                                                             ││ C:\Users\admin\Desktop\True_Vision\NLP\Question_Answering\question-answerin ││ g-transformers-git\model_testing.py:6 in run_t5_squad_example               ││                                                                             ││    3 def run_t5_squad_example(model_dir, question, context):                ││    4 │   # Load the T5 model and tokenizer                                  ││    5 │   model = T5ForConditionalGeneration.from_pretrained(model_dir)      ││ >  6 │   tokenizer = T5Tokenizer.from_pretrained(model_dir)                 ││    7 │                                                                      ││    8 │   # Prepare the input                                                ││    9 │   input_text = f"question: {question} context: {context}"            ││                                                                             ││ C:\Users\admin\Desktop\env\lib\site-packages\transformers\tokenization_util ││ s_base.py:1825 in from_pretrained                                           ││                                                                             ││   1822 │   │   │   else:                                                    ││   1823 │   │   │   │   logger.info(f"loading file {file_path} from cache at ││   1824 │   │                                                                ││ > 1825 │   │   return cls._from_pretrained(                                 ││   1826 │   │   │   resolved_vocab_files,                                    ││   1827 │   │   │   pretrained_model_name_or_path,                           ││   1828 │   │   │   init_configuration,                                      ││                                                                             ││ C:\Users\admin\Desktop\env\lib\site-packages\transformers\tokenization_util ││ s_base.py:1988 in _from_pretrained                                          ││                                                                             ││   1985 │   │                                                                ││   1986 │   │   # Instantiate tokenizer.                                     ││   1987 │   │   try:                                                         ││ > 1988 │   │   │   tokenizer = cls(*init_inputs, **init_kwargs)             ││   1989 │   │   except OSError:                                              ││   1990 │   │   │   raise OSError(                                           ││   1991 │   │   │   │   "Unable to load vocabulary from file. "              ││                                                                             ││ C:\Users\admin\Desktop\env\lib\site-packages\transformers\models\t5\tokeniz ││ ation_t5.py:154 ininit││                                                                             ││   151 │   │   self._extra_ids = extra_ids                                   ││   152 │   │                                                                 ││   153 │   │   self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kw ││ > 154 │   │   self.sp_model.Load(vocab_file)                                ││   155 │                                                                     ││   156 │@staticmethod││   157 │   defeventually_correct_t5_max_length(pretrained_model_name_or_pa ││                                                                             ││ C:\Users\admin\Desktop\env\lib\site-packages\sentencepiece_init.py:905  ││ in Load                                                                     ││                                                                             ││    902 │   │   raise RuntimeError('model_file and model_proto must be exclu ││    903 │     if model_proto:                                                ││    904 │   │   return self.LoadFromSerializedProto(model_proto)             ││ >  905 │     return self.LoadFromFile(model_file)                           ││    906                                                                      ││    907                                                                      ││    908 # Register SentencePieceProcessor insentencepiece:                 ││                                                                             ││ C:\Users\admin\Desktop\env\lib\site-packages\sentencepiece_init.py:310  ││ in LoadFromFile                                                             ││                                                                             ││    307 │   │   return _sentencepiece.SentencePieceProcessor_serialized_mode ││    308 │                                                                    ││    309 │   def LoadFromFile(self, arg):                                     ││ >  310 │   │   return _sentencepiece.SentencePieceProcessor_LoadFromFile(se ││    311 │                                                                    ││    312 │   def _EncodeAsIds(self, text, enable_sampling, nbest_size, alpha, ││    313 │   │   return _sentencepiece.SentencePieceProcessor__EncodeAsIds(se │└─────────────────────────────────────────────────────────────────────────────┘TypeError: not a stringmodel directory is not a string.i have checked that the model directory is of string type .