UAE-Large-V1(WhereIsAI/UAE-Large-V1)是一个基于 BERT-large 架构的高性能文本嵌入模型,在 MTEB 榜单上长期位居前列。输出 1024 维语义嵌入向量,广泛应用于语义搜索、文本聚类、检索增强生成(RAG)等任务。
BertModel(1024 hidden, 24 layers, 16 heads)model.safetensors(1.34GB)| 组件 | 版本 | 说明 |
|---|---|---|
| 昇腾 NPU | Ascend910_9362 ×2(64GB HBM) | 推理硬件 |
| CANN | 8.5.1 | 昇腾计算框架 |
| torch | 2.9.0+cpu | PyTorch |
| torch_npu | 2.9.0.post1 | 昇腾 NPU 插件 |
| transformers | 4.57.6 | 模型加载 |
| numpy | 1.26.4 | 科学计算 |
安装依赖:
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simplenpu-smi info # 确认 NPU 健康与显存
python3 -c "import torch, torch_npu; print(torch.npu.device_count())"cd uae-large-v1-npu-deployment
ASCEND_RT_VISIBLE_DEVICES=0 python3 inference.pypython3 inference.py --texts "Hello world" "How are you" "Nice to meet you"python3 inference.py --device npu:0 --warmup 3 --runs 20测试输入(4 句):
| 编号 | 文本 | 语义类别 |
|---|---|---|
| [0] | The man is working on a computer | 工作/电脑 |
| [1] | The woman is reading a book | 阅读/书籍 |
| [2] | The weather is sunny today | 天气/晴天 |
| [3] | A person is typing on a keyboard | 打字/键盘 |
输出结果(昇腾 NPU,Ascend910_9362):
嵌入向量维度: (4, 1024)
推理耗时: 225.7 ms
余弦相似度矩阵:
[0] vs [0]: 1.000000 [0] vs [1]: 0.224143 [0] vs [2]: 0.346306 [0] vs [3]: 0.643179
[1] vs [0]: 0.224143 [1] vs [1]: 1.000000 [1] vs [2]: 0.308905 [1] vs [3]: 0.389080
[2] vs [0]: 0.346306 [2] vs [1]: 0.308905 [2] vs [2]: 1.000000 [2] vs [3]: 0.404843
[3] vs [0]: 0.643179 [3] vs [1]: 0.389080 [3] vs [2]: 0.404843 [3] vs [3]: 1.000000
性能基准 (warmup=3, runs=20):
平均耗时: 16.41 ms / 4 句语义验证:[0](电脑工作)与 [3](键盘打字)相似度 0.64,显著高于 [0] 与 [2](天气晴天)的 0.35,符合语义直觉。
验收结论:UAE-Large-V1(BERT-large 1024)在昇腾 NPU 上完整跑通前向传播,嵌入向量语义正确,无算子回退或崩溃。
uae-large-v1-npu-deployment/
├── inference.py # 推理脚本
├── readme.md # 部署说明
├── requirements.txt # 环境依赖
├── SKILL.md # 技能文档
├── model/ # 模型权重
└── assets/ # 截图素材
├── agent_workflow.png
├── npu_device_call.png
└── model_result.png