xujiashuai/timm-nlp_corom_sentence-embedding_chinese-base-ecom
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

nlp_corom_sentence-embedding_chinese-base-ecom - Ascend NPU 适配

1. 模型简介

基于 CoRoM (Context-aware Robust Model) 的中文电商领域句子嵌入模型,基于 BERT-base 架构,用于电商场景的语义相似度和检索任务。

  • 原始模型: iic/nlp_corom_sentence-embedding_chinese-base-ecom
  • 框架: PyTorch + Transformers
  • 任务: Sentence Embedding (电商领域)
  • Backbone: BERT-base (12 layers, 768 hidden)

2. 昇腾 NPU 适配结果

指标值
Cosine Similarity0.999992
Max Abs Error0.008105
平均延迟6.96ms
输出维度(1, T, 768)
推理精度float32
设备Ascend 910B4

3. 环境要求

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

4. 快速使用

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

python inference.py
python evaluate.py

5. 推理输出证据

Model: iic/nlp_corom_sentence-embedding_chinese-base-ecom
Device: npu:0
Output shape: [1, 25, 768]
Output sample: [0.3923669755458832, -0.1256464123725891, -0.12140969187021255, 0.31653329730033875, 0.42105892300605774]
Latency: 6.96ms

--- CPU vs NPU 精度对比 ---
Cosine Similarity: 0.999992
Max Abs Error: 0.008105
SUCCESS

6. CPU vs NPU 精度对比

指标CPU (float32)NPU (float32)误差
Cosine Similarity基准0.999992< 0.00001
Max Abs Error-0.008105-
输出维度(1, 25, 768)(1, 25, 768)一致

7. 模型结构

  • Backbone: BERT-base (12 layers)
  • Hidden Size: 768
  • Attention Heads: 12
  • Max Position: 512
  • Vocab Size: 21128
  • Pooler: first_token_transform