z
zhangyuge147/bge-base-en-v1.5-npu
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

BAAI/bge-base-en-v1.5 - Ascend NPU Adapted

Base model: BAAI/bge-base-en-v1.5

This repository is an Ascend NPU adaptation of BGE base English v1.5 for sentence embedding. Verified on Ascend 910B (npu:0) with CPU-NPU consistency cosine >= 0.999.

Model Info

  • Architecture: BertModel (bert, 12 layers, hidden 768, 109M params)
  • Pooling: CLS token (pooling_mode_cls_token=true) + L2 normalize
  • Max length: 512
  • Dtype: float32
  • Route: embedding (sentence-transformers compatible)

NPU Inference

Device proof logged: model parameters on npu:0, input_ids/attention_mask on npu:0, output embeddings on npu:0.

from inference import load_model, encode

tokenizer, model, device = load_model()  # auto selects npu:0 if available
sentences = ["What is the capital of France?", "Paris is the capital of France."]
embeddings = encode(sentences, tokenizer, model, device)
print(embeddings.shape)  # [2, 768]

Or run directly:

python inference.py

Validation

  • CPU vs NPU cosine: 0.999991 mean (5 sentences), max diff 0.000467, threshold ≥0.999 ✅
  • Semantic check: similar pair (Q-A) cosine 0.8348 > unrelated 0.1969 ✅
  • Performance: ~660 sentences/s on Ascend 910B (batch 5, synchronize, stable avg), first compile ~0.20s
  • NPU proof: next(model.parameters()).device == npu:0, all tensors on npu:0

Requirements

torch>=2.0
torch_npu
transformers>=4.30.0
sentence-transformers
numpy

Evidence

  • Device and workflow logs captured via xterm.js renderer.

workflow device call results

Original Model

  • Model weight URL (for submission): https://huggingface.co/BAAI/bge-base-en-v1.5
  • License: MIT