S
Solis_caser/nvidia-llama-nemotron-embed-1b-v2-ascend-npu
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

llama-nemotron-embed-1b-v2 昇腾 NPU 适配

模型介绍

本仓库提供 nvidia/llama-nemotron-embed-1b-v2 在昇腾 NPU 上的真实文本嵌入推理适配。模型输出 2048 维向量,脚本按 attention mask 平均池化并做 L2 归一化,再计算余弦相似度。

模型与 checkpoint 绑定

  • 模型 ID:nvidia/llama-nemotron-embed-1b-v2
  • 固定 revision:113abe4acafa848e77ead9c0623205e511932348
  • checkpoint:model.safetensors
  • checkpoint SHA-256:45f8440682a89ac577cc8d53b1bb345804772adb7b34e0573562e2fca4e62b0d

本比赛交付仓库不包含模型权重。运行时由 snapshot_download 按上述模型 ID 和 revision 从 Hugging Face 官方源下载;比赛环境也可通过 HF_ENDPOINT 使用允许的镜像。脚本随后校验 checkpoint SHA-256,校验失败立即停止,不会静默替换模型或 checkpoint。

依赖安装

昇腾环境需预装彼此匹配的 CANN、torch 和 torch_npu。应用层依赖:

python3 -m pip install -r requirements.txt

运行命令

flock -x -w 1800 /tmp/npu-adapt.lock python3 -u inference.py

真实输入

The weather is lovely today.
It's so sunny outside!
He drove to the stadium.

真实昇腾 NPU 结果

  • device:npu:0
  • embedding shape:[3, 2048]
  • embedding dtype:torch.float32
  • similarity matrix shape:[3, 3]
  • model load:5.232s
  • forward pass:0.238s
  • 结果文件:outputs/inference_results.json

真实结果来自固定 checkpoint 和上述样本;参数、输入张量和输出隐藏状态均通过 NPU device 断言,没有 CPU 回退。

文件结构

README.md
inference.py
requirements.txt
outputs/inference_results.json
assets/agent_workflow.png
assets/npu_device_call.png
assets/model_result.png

截图证据

  • 适配工作流与交付状态:适配工作流
  • NPU 设备与调用证据:NPU 设备调用
  • 真实模型推理结果:模型结果

三张图片均由用户在真实比赛终端中人工截取,未经裁剪或编辑。

限制

本次验证覆盖三条英文样本、单批次文本嵌入和余弦相似度,不代表完整检索基准、跨语言质量或生产吞吐。首次运行需要下载固定 revision 的 checkpoint。

许可证

上游模型采用 NVIDIA Open Model License。使用模型、权重和衍生结果前,请遵守上游许可证与使用条件。