Update app.py
Browse files
app.py
CHANGED
@@ -222,7 +222,7 @@ def translate(src_sentence: str, strategy:str = 'greedy' , lenght_extend :int =
|
|
222 |
else:
|
223 |
assert length_penalty >= 0 , 'lenght penelity must be superior or equal to zero'
|
224 |
assert beam_size >= 1, 'beam size must superior or equal to one'
|
225 |
-
tgt_tokens = beam_search_decode(model, src, src_mask,
|
226 |
# Decode the target tokens and clean up the result
|
227 |
return target_tokenizer.decode(tgt_tokens, clean_up_tokenization_spaces=True, skip_special_tokens=True)
|
228 |
|
|
|
222 |
else:
|
223 |
assert length_penalty >= 0 , 'lenght penelity must be superior or equal to zero'
|
224 |
assert beam_size >= 1, 'beam size must superior or equal to one'
|
225 |
+
tgt_tokens = beam_search_decode(model, src, src_mask, max_len=num_tokens + lenght_extend, start_symbol=target_tokenizer.bos_token_id, beam_size=beam_size,length_penalty=length_penalty).flatten()
|
226 |
# Decode the target tokens and clean up the result
|
227 |
return target_tokenizer.decode(tgt_tokens, clean_up_tokenization_spaces=True, skip_special_tokens=True)
|
228 |
|