File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ # opus-mt-en-zh-axera
2+ 基于 [ opus-mt-en-zh] ( https://huggingface.co/Helsinki-NLP/opus-mt-en-zh ) 模型的 英文->中文 翻译模型。
3+
4+ ## 编译
5+ ``` shell
6+ ./build.sh # 本地编译
7+ ./build_aarch64.sh # aarch64 交叉编译
8+ ```
9+
10+ ## 用例
11+
12+ 详细代码见 [ test_translate.cpp] ( tests/test_translate.cpp )
13+ ``` C++
14+ std::string text = " Hello, Who are you" ;
15+ std::string model_path = " opus-mt-en-zh.axmodel" ;
16+ std::string tokenizer_dir = " tests/opus-mt-en-zh" ;
17+
18+ Translator translator;
19+ int ret = translator.Init(model_path, tokenizer_dir);
20+ if (ret != 0 )
21+ {
22+ printf ("init translator failed\n");
23+ return;
24+ }
25+ std::string output = translator.Translate(text);
26+ printf ("output: %s\n", output.c_str()); // 你好,你是谁
27+ ```
28+
29+ ## 参考资料
30+ * [sentencepiece](https://github.com/google/sentencepiece)
31+ * [opus-mt-en-zh](https://huggingface.co/Helsinki-NLP/opus-mt-en-zh)
32+
33+ ## 社区
34+ QQ 群: 139953715
You can’t perform that action at this time.
0 commit comments