ZhangLingzhe/ThinkFL-Qwen2.5-0.5B 是基于 Qwen2.5 0.5B 的文本生成模型。该模型依托 HuggingFace transformers 构建,支持一键加载并进行推理。 权重来源:ModelScope
import torch; from transformers import AutoTokenizer, AutoModelForCausalLM
device = torch.device("npu:0" if torch.npu.is_available() else "cpu")
tokenizer = AutoTokenizer.from_pretrained("ZhangLingzhe/ThinkFL-Qwen2.5-0.5B", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("ZhangLingzhe/ThinkFL-Qwen2.5-0.5B", torch_dtype=torch.float16, trust_remote_code=True).to(device).eval()
messages = [{"role": "user", "content": "什么是机器学习?"}]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(device)
outputs = model.generate(**inputs, max_new_tokens=128, do_sample=False)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))| 指标 | 值 |
|---|---|
| Top-1 一致性 | 4/4 |
| Max Logit Diff Ratio | 3e-05 |
| Avg KL Divergence | -0.0 |
| 结论 | PASS |
NPU: 1722.85 ms(生成 64 个 tokens,fp16)