This is an Ascend NPU adaptation of WhereIsAI/UAE-Large-V1 (https://huggingface.co/WhereIsAI/UAE-Large-V1), an embedding model based on BertModel (1024 hidden, 24 layers, ~335M params) with CLS pooling.
Original model: WhereIsAI/UAE-Large-V1 - AnglE-based universal embedding model, sentence-transformers compatible (Transformer + Pooling(cls_token)).
BertModel), word_embedding_dimension 1024, pooling_mode_cls_token Truescripts/inspect_nlp_model.py -> embeddingtorch_npu (Ascend 910B, CANN 8.5.1, torch 2.9.0, torch_npu 2.9.0.post1)npu:0 (Ascend910_9362, 61 GiB HBM, 2 devices available)AutoModel.from_pretrained(local_dir, trust_remote_code=False).to("npu:0")1_Pooling/config.jsonnext(model.parameters()).device == npu:0, input_ids.device == npu:0, last_hidden_state.device == npu:0, embeddings.device == npu:0import torch, torch.nn.functional as F
from transformers import AutoTokenizer, AutoModel
model_id = "WhereIsAI/UAE-Large-V1"
device = torch.device("npu:0" if torch.npu.is_available() else "cpu")
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=False)
model = AutoModel.from_pretrained(model_id, trust_remote_code=False).to(device).eval()
sentences = ["What is the capital of France?", "Machine learning is AI."]
inputs = tokenizer(sentences, padding=True, truncation=True, max_length=512, return_tensors="pt")
inputs = {k: v.to(device) for k, v in inputs.items()}
with torch.no_grad():
hidden = model(**inputs).last_hidden_state
embeddings = F.normalize(hidden[:, 0], p=2, dim=1) # CLS pooling
print(embeddings.shape) # [2, 1024]
# similarity
print(F.cosine_similarity(embeddings[0].unsqueeze(0), embeddings[1].unsqueeze(0)))See inference.py for full example with torch.npu.synchronize() timing.

See requirements.txt. Core: torch, torch_npu, transformers, safetensors.