Error with pretrain T5 model for paraphrase
LeMoussel opened this issue · 2 comments
LeMoussel commented
On Colab environment, I pretrain T5 model on custom corpus.
When I make predictions with the pretrain T5 model, I got this error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
[<ipython-input-11-4e80e7f36013>](https://localhost:8080/#) in <cell line: 20>()
18 # https://simpletransformers.ai/docs/t5-model/#making-predictions-with-a-t5model
19 prefix = "paraphrase"
---> 20 pred = t5_trained_model.predict([f"{prefix}: Je mange du fromage."])
21 pprint(pred)
22
2 frames
[/usr/local/lib/python3.9/dist-packages/transformers/generation/utils.py](https://localhost:8080/#) in generate(self, inputs, generation_config, logits_processor, stopping_criteria, prefix_allowed_tokens_fn, synced_gpus, streamer, **kwargs)
1370 )
1371 is_beam_gen_mode = (
-> 1372 (generation_config.num_beams > 1)
1373 and (generation_config.num_beam_groups == 1)
1374 and generation_config.do_sample is False
TypeError: '>' not supported between instances of 'NoneType' and 'int'
Source code:
from pprint import pprint
args = {
"overwrite_output_dir": True,
"max_seq_length": 256,
"max_length": 50,
"top_k": 50,
"top_p": 0.95,
"num_return_sequences": 5,
}
# Initializing the T5 model
# https://simpletransformers.ai/docs/t5-model/
t5_trained_model = T5Model("t5","/content/drive/MyDrive/Colab Notebooks/Data_Paraphrase/T5_fr_paraphrase")
# Generating paraphrases using the trained model
# https://simpletransformers.ai/docs/t5-model/#making-predictions-with-a-t5model
prefix = "paraphrase"
pred = t5_trained_model.predict([f"{prefix}: Je mange du fromage."])
pprint(pred)
LeMoussel commented
Find the solution. I set args
like this :
args = {
"overwrite_output_dir": True,
"max_seq_length": 256,
"max_length": 50,
"top_k": 50,
"top_p": 0.95,
"num_return_sequences": 3,
"num_beams": 1,
}
and do:
# Initializing the T5 model
# https://simpletransformers.ai/docs/t5-model/
t5_trained_model = T5Model("t5","/content/drive/MyDrive/Colab Notebooks/Data_Paraphrase/T5_fr_paraphrase", args=args)``
Ch-rode commented
hi @LeMoussel ! Thanks a lot for sharing the solution. I was desperate to make it work and fortunately I saw your post. Unfortunately If I am using your same set of parameters I have the following error: ValueError: Greedy methods without beam search do not support "num_return_sequences" different than 1 (got 3).