File size: 1,923 Bytes
3807da3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ec20ccc
3807da3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b20494f
 
ec20ccc
 
3807da3
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
license: apache-2.0
language:
- zh
- en
pipeline_tag: token-classification
tags:
- punctuation-restoration
- fireredpunc
- axera
- ax650
---

# FireRedPunc.AXERA

FireRedPunc 中英标点恢复模型的 AX650N 量化部署包。

- 模型:`chinese-lert-base`(BERT-base,12 层,768 hidden)
- 输入:`[CLS] + tokens`,`input_ids [1,128] int32`,`attention_mask [1,128] float32`
- 输出:`logits [1,127,5]`,标签 `space / , / 。 / ? / !`
- 量化:Pulsar2 7.0,U16 激活 + S8 权重,Gather FP32
- AXMODEL:151.5 MiB

## 目录

```
├── config.json
├── models/       # punc.axmodel + tokenizer/vocab/out_dict
├── bin/          # fireredpunc_ax650 (aarch64)
├── python/       # punc_ax.py
└── run_ax650.sh
```

## C++ 运行

```bash
export LD_LIBRARY_PATH=/soc/lib:${LD_LIBRARY_PATH:-}
./run_ax650.sh --text "今天天气很好我们去公园散步吧"
```

输出:

```
IN : 今天天气很好我们去公园散步吧
OUT: 今天天气很好,我们去公园散步吧。
```

## Python 运行

```bash
pip3 install numpy transformers
# pip3 install axengine-<version>-py3-none-any.whl
./run_ax650.sh python --text "今天天气很好我们去公园散步吧"
```

## 指标(AX650N)

| 项 | 结果 |
|---|---|
| AXMODEL vs fp32 ONNX | 272 行 / 4523 token,100% |
| C++ vs Python | 272/272 text exact |
| 标点 F1(排除句末) | 0.9937 |
| Python 延迟 | median 23.2–23.5 ms |
| C++ 延迟 | median 21.1 ms |
| 等效 RTF(按 10 s VAD 段) | Python 0.0023 / C++ 0.0021 |

Punc 是文本模型,延迟按句基本固定;RTF 以每个 10 s 语音段折算。

## 源码

模型转换、C++ 源码和评测:
[ZY-2012/FireRedPunc.AXERA](https://github.com/ZY-2012/FireRedPunc.AXERA)

## 参考

- [FireRedPunc](https://huggingface.co/FireRedTeam/FireRedPunc)
- [Magnetar](https://github.com/AXERA-TECH/Magnetar)

## License

Apache-2.0。