ArissBandoss commited on
Commit
065813f
·
verified ·
1 Parent(s): 4302c2b

Update goai_helpers/goai_traduction.py

Browse files
Files changed (1) hide show
  1. goai_helpers/goai_traduction.py +3 -2
goai_helpers/goai_traduction.py CHANGED
@@ -30,6 +30,7 @@ def goai_traduction(text, src_lang, tgt_lang):
30
 
31
  # Tokenisation du texte d'entrée
32
  inputs = tokenizer(text, return_tensors="pt").to(device)
 
33
 
34
  # Utilisation de convert_tokens_to_ids au lieu de lang_code_to_id
35
  tgt_lang_id = tokenizer.convert_tokens_to_ids(tgt_lang)
@@ -39,7 +40,8 @@ def goai_traduction(text, src_lang, tgt_lang):
39
  **inputs,
40
  forced_bos_token_id=tgt_lang_id,
41
  max_new_tokens=1024,
42
- bad_words_ids=None, # Évite de bloquer des tokens spécifiques
 
43
  no_repeat_ngram_size=0 # Désactive la pénalité pour les répétitions
44
  )
45
 
@@ -47,7 +49,6 @@ def goai_traduction(text, src_lang, tgt_lang):
47
  translation = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
48
  print("ici translation")
49
  print(translation)
50
- translation = unicodedata.normalize('NFC', translation)
51
  return translation
52
 
53
 
 
30
 
31
  # Tokenisation du texte d'entrée
32
  inputs = tokenizer(text, return_tensors="pt").to(device)
33
+ print(inputs)
34
 
35
  # Utilisation de convert_tokens_to_ids au lieu de lang_code_to_id
36
  tgt_lang_id = tokenizer.convert_tokens_to_ids(tgt_lang)
 
40
  **inputs,
41
  forced_bos_token_id=tgt_lang_id,
42
  max_new_tokens=1024,
43
+ min_length=10,
44
+ length_penalty=1.0,
45
  no_repeat_ngram_size=0 # Désactive la pénalité pour les répétitions
46
  )
47
 
 
49
  translation = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
50
  print("ici translation")
51
  print(translation)
 
52
  return translation
53
 
54