tianrenmodel_finetuned_textile_modelscope
1. 简介
本文档记录 tianrenmodel/finetuned_textile_modelscope 在昇腾 NPU(Ascend910)环境的快速部署与验证结果。
相关获取地址:
2. 验证环境
| 组件 | 版本 |
|---|
| torch | ≥2.1.0 |
| torch_npu | ≥2.1.0 |
| transformers | ≥4.37.0 |
| CANN | 8.5.RC1 |
3. 快速部署
import torch
from transformers import AutoTokenizer, AutoModelForTokenClassification
device = torch.device("npu:0")
model_name = "tianrenmodel/finetuned_textile_modelscope"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModelForTokenClassification.from_pretrained(model_name, trust_remote_code=True).to(device).eval()
texts = ["Hello world"]
inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True, max_length=128)
inputs = {k: v.to(device) for k, v in inputs.items()}
with torch.no_grad():
outputs = model(**inputs)
print(f"logits shape: {outputs.logits.shape}")
4. 精度评测
| 指标 | 值 |
|---|
| Top-1 一致性 | 4/4 |
| Max Logit Diff Ratio | 0.003617 |
| Avg KL Divergence | 0.0 |
| 结论 | PASS |
5. 性能参考
| 指标 | 值 |
|---|
| 硬件 | Ascend 910B |
| 平均推理时间 | 6.94ms |