初始化项目,由ModelHub XC社区提供模型
Model: karthik-2905/AL1-model-B Source: Original Platform
This commit is contained in:
22
mlb/verify_base.py
Normal file
22
mlb/verify_base.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import os
|
||||
HERE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
os.environ["HF_HOME"] = os.path.join(HERE, "hf_cache")
|
||||
|
||||
import torch
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
MODEL = "Qwen/Qwen3-0.6B"
|
||||
device = "mps" if torch.backends.mps.is_available() else "cpu"
|
||||
|
||||
tok = AutoTokenizer.from_pretrained(MODEL)
|
||||
model = AutoModelForCausalLM.from_pretrained(MODEL, dtype=torch.float32).to(device)
|
||||
|
||||
print("device:", device)
|
||||
print("params:", sum(p.numel() for p in model.parameters()))
|
||||
print("chat_template set:", tok.chat_template is not None)
|
||||
|
||||
msgs = [{"role": "user", "content": "Reply with exactly: pong"}]
|
||||
text = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True, enable_thinking=False)
|
||||
ids = tok(text, return_tensors="pt").to(device)
|
||||
out = model.generate(**ids, max_new_tokens=16, do_sample=False)
|
||||
print("OUT:", tok.decode(out[0][ids.input_ids.shape[1]:], skip_special_tokens=True))
|
||||
Reference in New Issue
Block a user