Spaces:
Sleeping
Sleeping
Commit
·
d29c54a
1
Parent(s):
feb67fb
well done now
Browse files
utils/__pycache__/utils_function.cpython-310.pyc
CHANGED
Binary files a/utils/__pycache__/utils_function.cpython-310.pyc and b/utils/__pycache__/utils_function.cpython-310.pyc differ
|
|
utils/utils_function.py
CHANGED
@@ -42,7 +42,13 @@ class Translator:
|
|
42 |
# Encodage du texte en tokens
|
43 |
tokens = self.model.encode(text)
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
# Décodage des tokens en traduction
|
46 |
-
|
47 |
|
48 |
-
return
|
|
|
42 |
# Encodage du texte en tokens
|
43 |
tokens = self.model.encode(text)
|
44 |
|
45 |
+
# Utilisation de la méthode generate avec le paramètre beam
|
46 |
+
translations = self.model.generate(tokens, beam=5)
|
47 |
+
print(type(translations))
|
48 |
+
print(translations[0])
|
49 |
+
best_translation_tokens = [translations[i]['tokens'].tolist() for i in range(5)]
|
50 |
+
|
51 |
# Décodage des tokens en traduction
|
52 |
+
translations = [self.model.decode(best_translation_tokens[i]) for i in range(5)]
|
53 |
|
54 |
+
return "\n".join(translations)
|