Update goai_helpers/goai_traduction.py
Browse files
goai_helpers/goai_traduction.py
CHANGED
@@ -30,9 +30,6 @@ def goai_traduction(text, src_lang, tgt_lang):
|
|
30 |
inputs = tokenizer(text, return_tensors="pt", truncation=False).to(device)
|
31 |
input_length = inputs["input_ids"].shape[1]
|
32 |
|
33 |
-
# Estimation intelligente de la longueur de sortie attendue
|
34 |
-
# Pour le mooré vers français, un facteur de 1.2-1.5 est généralement bon
|
35 |
-
expected_output_length = int(input_length * 1.3)
|
36 |
|
37 |
# ID du token de langue cible
|
38 |
tgt_lang_id = tokenizer.convert_tokens_to_ids(tgt_lang)
|
@@ -45,13 +42,10 @@ def goai_traduction(text, src_lang, tgt_lang):
|
|
45 |
**inputs,
|
46 |
forced_bos_token_id=tgt_lang_id,
|
47 |
max_new_tokens=1024,
|
48 |
-
min_length=expected_output_length,
|
49 |
num_beams=5,
|
50 |
no_repeat_ngram_size=4,
|
51 |
repetition_penalty=2.0,
|
52 |
-
length_penalty=1.5,
|
53 |
-
diversity_penalty=0.5,
|
54 |
-
num_beam_groups=5
|
55 |
)
|
56 |
|
57 |
# Décodage
|
|
|
30 |
inputs = tokenizer(text, return_tensors="pt", truncation=False).to(device)
|
31 |
input_length = inputs["input_ids"].shape[1]
|
32 |
|
|
|
|
|
|
|
33 |
|
34 |
# ID du token de langue cible
|
35 |
tgt_lang_id = tokenizer.convert_tokens_to_ids(tgt_lang)
|
|
|
42 |
**inputs,
|
43 |
forced_bos_token_id=tgt_lang_id,
|
44 |
max_new_tokens=1024,
|
|
|
45 |
num_beams=5,
|
46 |
no_repeat_ngram_size=4,
|
47 |
repetition_penalty=2.0,
|
48 |
+
length_penalty=1.5,
|
|
|
|
|
49 |
)
|
50 |
|
51 |
# Décodage
|