Update app.py
Browse files
app.py
CHANGED
@@ -207,7 +207,7 @@ def beam_search_decode(model, src, src_mask, max_len, start_symbol, beam_size ,l
|
|
207 |
best_beam = beams[0][0]
|
208 |
return best_beam
|
209 |
|
210 |
-
def translate(
|
211 |
assert strategy in ['greedy','beam search'], 'the strategy for decoding has to be either greedy or beam search'
|
212 |
# Tokenize the source sentence
|
213 |
src = source_tokenizer(src_sentence, **token_config)['input_ids']
|
@@ -259,7 +259,7 @@ iface = gr.Interface(
|
|
259 |
gr.inputs.Number(label="Length Penalty (for beam search)", default=0.6)
|
260 |
],
|
261 |
outputs=gr.outputs.Textbox("Translation"),
|
262 |
-
title="Translation Interface",
|
263 |
description="Translate text using a pre-trained model.",
|
264 |
)
|
265 |
|
|
|
207 |
best_beam = beams[0][0]
|
208 |
return best_beam
|
209 |
|
210 |
+
def translate(src_sentence: str, strategy:str = 'greedy' , lenght_extend :int = 5, beam_size: int = 5, length_penalty:float = 0.6):
|
211 |
assert strategy in ['greedy','beam search'], 'the strategy for decoding has to be either greedy or beam search'
|
212 |
# Tokenize the source sentence
|
213 |
src = source_tokenizer(src_sentence, **token_config)['input_ids']
|
|
|
259 |
gr.inputs.Number(label="Length Penalty (for beam search)", default=0.6)
|
260 |
],
|
261 |
outputs=gr.outputs.Textbox("Translation"),
|
262 |
+
title="Translation Interface for English to Kabyle",
|
263 |
description="Translate text using a pre-trained model.",
|
264 |
)
|
265 |
|