import ctranslate2 import sys model = sys.argv[1] file_name = sys.argv[2] file = open(file_name, 'r') translator = ctranslate2.Translator(model, device="cuda") #translator = ctranslate2.Translator(model, device="cpu") for line in file: line = line.strip() #line = line.split() # r = translator.translate_batch([line], beam_size=5, batch_type='examples') r = translator.translate_batch( [line.split()], replace_unknowns=True, beam_size=5, batch_type='examples' ) results =' '.join(r[0].hypotheses[0]) # results =' '.join(r[0][0]['tokens']) # print(results[0].hypotheses[0]) print(results)