nlp_raner_named-entity-recognition_multilingual-large-generic 在昇腾 NPU 上的适配
1. 简介
本文档记录 nlp_raner_named-entity-recognition_multilingual-large-generic(XLM-RoBERTa NER)在昇腾 NPU 上的适配验证结果。
- 模型来源:iic/nlp_raner_named-entity-recognition_multilingual-large-generic
- 架构:XLMRobertaForTokenClassification(24层,25类 NER 标签)
- 任务:Named Entity Recognition(多语言通用命名实体识别)
- 适配状态:SUCCESS
- 适配时间:2026-05-17
2. 验证环境
| 组件 | 版本 |
|---|
torch | 2.9.0 |
torch-npu | 2.9.0.post1 |
transformers | 4.57.6 |
CANN | 8.5.1 |
- NPU:Ascend 910B4
- 系统:Linux aarch64
3. 推理脚本
python inference.py
python evaluate.py
4. 推理输出证据
Model: iic/nlp_raner_named-entity-recognition_multilingual-large-generic
Device: npu:0
Output shape: [1, 10, 25]
Output sample: [0.6129149198532104, 0.39101675152778625, -0.07984325289726257, 0.8292377591133118, 0.2713736593723297]
Latency: 13.24ms
--- CPU vs NPU 精度对比 ---
Cosine Similarity: 0.999997
Max Abs Error: 0.004830
SUCCESS
5. 性能参考
6. CPU vs NPU 精度对比
| 指标 | 数值 |
|---|
| Cosine Similarity | 0.999997 |
| Max Abs Error | 0.004830 |
7. 评测材料
| 材料 | 文件 | 说明 |
|---|
| 推理脚本 | inference.py | 独立可运行的 NPU 推理代码 |
8. 注意事项
- 使用 transformers 库的
XLMRobertaForTokenClassification 模型定义
- 权重从 modelscope 加载,需重映射
encoder.* -> roberta.* 前缀
- 输入: "John works at Google in New York." (10 tokens)
- 输出: 25 类 NER 标签 logits (batch=1, seq_len=10, num_labels=25)
- NER 标签包括: O, B-CORP, S-CORP, B-CW, S-CW, B-GRP, S-GRP, B-LOC, S-LOC, B-PER, S-PER 等
贡献者: xujiashuai
参赛赛道: 模型适配赛道
提交时间: 2026-05-17