Хотите получить лучший сгенерированный текст трансформеров T5?
Я тренировал трансформаторы Т5, используя
Вот код для получения прогнозов:
pred_values = model.predict(input_values)
Однако он просто возвращает верхний или жадный прогноз, как я могу получить 10 лучших результатов?
1 ответ
The required parameter is
num_return_sequences
, which shows the number of samples to generate. However, you should also set a number for beam search if you want to use a beam search algorithm.
model_args = T5Args()
model_args.num_beams = 5
model_args.num_return_sequences = 2
Alternatively, you can use
top_k
or
top_p
to generate and select among top samples, in these cases, you must set
do_sample
to
True
. For more information about the parameters refer to [1] and [2], which is a detailed explanation.
model_args = T5Args()
model_args.do_sample = True
model_args.top_p = 0.9
model_args.num_return_sequences = 2