StructBERT Siamese-UniNLU 是一个基于 StructBERT 架构的通用信息抽取模型,采用 Siamese 网络结构和交叉注意力机制,支持实体识别、关系抽取、事件抽取等 NLU 任务。
| 指标 | 值 |
|---|---|
| Cosine Similarity | 0.999999 |
| MaxAbsErr | 0.006291 |
| Relative Error | 0.0677% |
| 平均延迟 | 7.87 ms |
| 峰值显存 | 0.38 GB |
| 参数量 | 102,267,648 |
| 推理精度 | float32 |
| 设备 | Ascend 910B4 |
| 组件 | 版本 |
|---|---|
| CANN | 8.5.1 |
| torch_npu | 2.9.0.post1 |
| PyTorch | 2.9.0 |
| Python | 3.11 |
# 设置环境
source setup_env.sh
# 运行推理 (CPU vs NPU 对比)
python3 inference.py --device npu:0 --dtype float32NPU 推理输出(float32, CLS token 对比):
模型: iic/nlp_structbert_siamese-uninlu_chinese-base
设备: npu:0
精度: float32
------------------------------------------------------------
[加载模型...]
[CPU] 推理中...
[NPU] 推理中 (npu:0)...
CPU emb shape: torch.Size([2, 768])
NPU emb shape: torch.Size([2, 768])
Cosine Similarity (per sample): [0.9999991655349731, 0.9999990463256836]
Cosine Similarity (mean): 0.999999
MaxAbsErr: 0.006291
Relative Error: 0.0677%
✓ 推理完成
[Perf] 测延迟...
平均延迟: 7.87 ms
峰值显存: 0.38 GB| 指标 | CPU (float32) | NPU (float32) | 误差 |
|---|---|---|---|
| Cosine Similarity | 基准 | 0.999999 | < 0.001% |
| MaxAbsErr | - | 0.006291 | - |
| Relative Error | - | 0.0677% | < 1% ✓ |
| 输出维度 | [2, 768] | [2, 768] | 一致 |
| NaN | False | False | 一致 |
详见 screenshots/verification.txt。
本适配由 Ascend NPU 适配 Agent Skill 自动完成。