Skip to content

Commit 2ed4d69

Browse files
committed
新增readme
1 parent 2883a5f commit 2ed4d69

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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

0 commit comments

Comments
 (0)