coutant commited on
Commit
637f402
1 Parent(s): 69c70a2

with both target and back translation

Browse files
Files changed (4) hide show
  1. .gitignore +1 -0
  2. README.md +15 -1
  3. app.py +28 -0
  4. requirements.txt +4 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .idea
README.md CHANGED
@@ -10,4 +10,18 @@ pinned: false
10
  license: afl-3.0
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  license: afl-3.0
11
  ---
12
 
13
+ # Back translation
14
+
15
+ Small translation check demo, computing chained translations En->Fr->En.
16
+
17
+ The better meaning similarities the better is the intermediate translation, no?
18
+
19
+ Double translation method check : The final outcome in English should match the original as closely as possible in a quality translation job.
20
+
21
+ Showcasing difference if any between original and computed outcome.
22
+
23
+ using an open Natural Language Processing model.
24
+ Helsinki-NLP Opus MT model : https://github.com/Helsinki-NLP
25
+
26
+
27
+
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ en_fr_model = pipeline("translation", model="Helsinki-NLP/opus-mt-en-fr")
5
+ fr_en_model = pipeline("translation", model="Helsinki-NLP/opus-mt-fr-en")
6
+
7
+ def translate(text, model):
8
+ translations = model(text)
9
+ output = translations[0]['translation_text']
10
+ return output
11
+
12
+ def check(en):
13
+ fr = translate(en, en_fr_model)
14
+ en2 = translate(fr,fr_en_model)
15
+ return fr,en2
16
+
17
+ gr.Interface(
18
+ fn=check,
19
+ inputs = gr.Textbox(label="EN - original"),
20
+ outputs = [ gr.Textbox(label="FR - target"), gr.Textbox(label="EN - back") ],
21
+ title="Back translation : insights in target translation quality",
22
+ description="Translating back to source language is one mean to measure the quality of the target translation. Can be useful when you need to check the translation to a language you hardly understand... The loop feedback may even guide you to rewrite original text enabling a better translation. Translations using Helsinki-NLP Opus MT models.",
23
+ examples= [
24
+ "Translating a language is a very complex problem and yet this Helsinki-NLP model does it both well and quickly, do you agree?",
25
+ "Reverse translation, is the process of translating content from the target language back to its source language. The final outcome in English should match the original as closely as possible in a quality translation job."
26
+ ],
27
+ allow_flagging="never"
28
+ ).launch(debug=True, enable_queue=True)
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ transformers
3
+ transformers[sentencepiece]
4
+ torch