def fairseq_generate()

in access/fairseq/base.py [0:0]


def fairseq_generate(complex_filepath,
                     output_pred_filepath,
                     exp_dir,
                     beam=1,
                     hypothesis_num=1,
                     lenpen=1.,
                     diverse_beam_groups=None,
                     diverse_beam_strength=0.5,
                     sampling=False,
                     batch_size=128):
    exp_dir = Path(exp_dir)
    checkpoint_path = exp_dir / 'checkpoints/checkpoint_best.pt'
    assert checkpoint_path.exists(), f'Generation failed, no checkpoint at {checkpoint_path}'
    complex_dictionary_path = exp_dir / 'dict.complex.txt'
    simple_dictionary_path = exp_dir / 'dict.simple.txt'
    _fairseq_generate(complex_filepath,
                      output_pred_filepath, [checkpoint_path],
                      complex_dictionary_path=complex_dictionary_path,
                      simple_dictionary_path=simple_dictionary_path,
                      beam=beam,
                      hypothesis_num=hypothesis_num,
                      lenpen=lenpen,
                      diverse_beam_groups=diverse_beam_groups,
                      diverse_beam_strength=diverse_beam_strength,
                      sampling=sampling,
                      batch_size=batch_size)