初始化项目,由ModelHub XC社区提供模型

Model: g023/Qwen3-1.77B-g023
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-04-13 16:37:05 +08:00
commit 81019c5698
12 changed files with 152297 additions and 0 deletions

22
model.py Normal file
View File

@@ -0,0 +1,22 @@
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model = AutoModelForCausalLM.from_pretrained(
"g023/Qwen3-1.77B-g023",
torch_dtype=torch.bfloat16,
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained("g023/Qwen3-1.77B-g023")
# Non-thinking mode
messages = [{"role": "user", "content": "What is the capital of France?"}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=False)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=100)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
# Thinking mode
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=500)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False))