xujiashuai/timm-nlp_structbert_sentiment-classification_chinese-base
模型介绍文件和版本Pull Requests讨论分析
下载使用量0

nlp_structbert_sentiment-classification_chinese-base - 昇腾 NPU 适配

1. 模型简介

StructBERT 中文情感分类模型,基于 BERT 架构(hidden_size=768,12层)。

  • 原始模型:iic/nlp_structbert_sentiment-classification_chinese-base
  • 框架:PyTorch(HuggingFace Transformers)
  • 任务:情感分类(中文)

2. 昇腾 NPU 适配结果

指标值
余弦相似度1.000000
平均延迟6.87 ms
推理精度float32
设备Ascend 910B4

3. 快速使用

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

4. 推理输出证据

模型: iic/nlp_structbert_sentiment-classification_chinese-base
设备: npu:0
精度: float32
------------------------------------------------------------
  input_ids: shape=torch.Size([1, 8])
  logits: shape=torch.Size([1, 2])
  CPU pred: 1, NPU pred: 1

  Cosine Similarity (logits): 1.000000

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

5. CPU 与 NPU 精度对比

指标CPU (float32)NPU (float32)误差
余弦相似度基准1.0000000%
输出维度[1,2][1,2]一致
预测类别11一致

6. 智能体技能

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