From 2536f9ec9b9470ab889d1dcd867a00345ad05d1e Mon Sep 17 00:00:00 2001 From: "xiangpeng.wxp" Date: Tue, 29 Nov 2022 13:44:06 +0800 Subject: [PATCH] [to #42322933] add en-zh en-es es-en base translation models MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add en-zh en-es es-en base translation models * add en-zh en-es es-en base translation models Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/10895782 * 新增英中/英西/西英-base机器翻译模型 * 新增英中/英西/西英-base机器翻译模型 --- tests/pipelines/test_csanmt_translation.py | 21 +++++++++++++++++++++ tests/trainers/test_translation_trainer.py | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/tests/pipelines/test_csanmt_translation.py b/tests/pipelines/test_csanmt_translation.py index 83827813..74e12bb6 100644 --- a/tests/pipelines/test_csanmt_translation.py +++ b/tests/pipelines/test_csanmt_translation.py @@ -26,6 +26,13 @@ class TranslationTest(unittest.TestCase, DemoCompatibilityCheck): pipeline_ins = pipeline(self.task, model=model_id) print(pipeline_ins(input=inputs)) + @unittest.skipUnless(test_level() >= 0, 'skip test in current test level') + def test_run_with_model_name_for_en2zh_base(self): + model_id = 'damo/nlp_csanmt_translation_en2zh_base' + inputs = 'Elon Musk, co-founder and chief executive officer of Tesla Motors.' + pipeline_ins = pipeline(self.task, model=model_id) + print(pipeline_ins(input=inputs)) + @unittest.skipUnless(test_level() >= 0, 'skip test in current test level') def test_run_with_model_name_for_en2fr(self): model_id = 'damo/nlp_csanmt_translation_en2fr' @@ -33,6 +40,13 @@ class TranslationTest(unittest.TestCase, DemoCompatibilityCheck): pipeline_ins = pipeline(self.task, model=model_id) print(pipeline_ins(input=inputs)) + @unittest.skipUnless(test_level() >= 0, 'skip test in current test level') + def test_run_with_model_name_for_en2es(self): + model_id = 'damo/nlp_csanmt_translation_en2es' + inputs = 'When I was in my 20s, I saw my very first psychotherapy client.' + pipeline_ins = pipeline(self.task, model=model_id) + print(pipeline_ins(input=inputs)) + @unittest.skipUnless(test_level() >= 0, 'skip test in current test level') def test_run_with_model_name_for_fr2en(self): model_id = 'damo/nlp_csanmt_translation_fr2en' @@ -40,6 +54,13 @@ class TranslationTest(unittest.TestCase, DemoCompatibilityCheck): pipeline_ins = pipeline(self.task, model=model_id) print(pipeline_ins(input=inputs)) + @unittest.skipUnless(test_level() >= 0, 'skip test in current test level') + def test_run_with_model_name_for_es2en(self): + model_id = 'damo/nlp_csanmt_translation_es2en' + inputs = 'Los físicos clasifican las partículas en dos categorías.' + pipeline_ins = pipeline(self.task, model=model_id) + print(pipeline_ins(input=inputs)) + @unittest.skipUnless(test_level() >= 2, 'skip test in current test level') def test_run_with_default_model(self): inputs = '声明补充说,沃伦的同事都深感震惊,并且希望他能够投案自首。' diff --git a/tests/trainers/test_translation_trainer.py b/tests/trainers/test_translation_trainer.py index 7be23145..ef0c6e76 100644 --- a/tests/trainers/test_translation_trainer.py +++ b/tests/trainers/test_translation_trainer.py @@ -19,6 +19,12 @@ class TranslationTest(unittest.TestCase): trainer = CsanmtTranslationTrainer(model=model_id) trainer.train() + @unittest.skipUnless(test_level() >= 0, 'skip test in current test level') + def test_run_with_model_name_for_en2es(self): + model_id = 'damo/nlp_csanmt_translation_en2es' + trainer = CsanmtTranslationTrainer(model=model_id) + trainer.train() + if __name__ == '__main__': unittest.main()