xujiashuai/timm-nlp_structbert_siamese-aoe_chinese-base
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

nlp_structbert_siamese-aoe_chinese-base - Ascend NPU 适配

1. 模型简介

StructBERT Siamese UIE 模型,基于 BERT 架构(6 层),用于中文信息抽取任务。

  • 原始模型: iic/nlp_structbert_siamese-aoe_chinese-base
  • 框架: PyTorch
  • 任务: Siamese UIE (Universal Information Extraction)

2. 昇腾 NPU 适配结果

指标值
Cosine Similarity (hidden)0.999999
Cosine Similarity (pooler)1.000000
平均延迟3.65 ms
参数量~85M
推理精度float32
设备Ascend 910B4

3. 环境要求

组件版本
CANN8.5.1
torch_npu2.9.0.post1
PyTorch2.9.0
Python3.11
transformersrequired

4. 快速使用

export ASCEND_HOME_PATH=/usr/local/Ascend/cann
export LD_LIBRARY_PATH=/usr/local/Ascend/cann/lib64:$LD_LIBRARY_PATH

python inference.py --device npu:0 --dtype float32

5. 推理输出证据

NPU 推理输出(float32):

模型: iic/nlp_structbert_siamese-aoe_chinese-base
设备: npu:0
精度: float32
------------------------------------------------------------
  last_hidden_state: shape=torch.Size([1, 27, 768])
  pooler_output: shape=torch.Size([1, 768])
  pooler (first 10): [0.3297, 0.3021, 0.1032, -0.0049, 0.1991, 0.5550, -0.1100, 0.0395, 0.2218, -0.4406]

  Cosine Similarity (hidden): 0.999999
  Cosine Similarity (pooler): 1.000000

✓ 推理完成
  平均延迟: 3.65 ms

6. CPU vs NPU 精度对比

指标CPU (float32)NPU (float32)误差
Cosine Similarity (hidden)基准0.999999< 0.001%
Cosine Similarity (pooler)基准1.0000000
输出维度[1,27,768][1,27,768]一致

7. 模型结构

  • Backbone: BERT (6 layers, 768 hidden, 12 attention heads)
  • Cross-Attention: 6 layers
  • Classification Heads: head_clsf + tail_clsf
  • 输入: 中文文本
  • 输出: last_hidden_state + pooler_output

8. Agent Skill

本适配由 batch-adapter 自动完成。