Downloads · 30 days
4
1% of all-time downloads
modular-ai/qwen
qwen is a machine learning model from modular-ai. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
Downloads · 30 days
4
1% of all-time downloads
All-time downloads
347
Public
Repo size
307 MB
Likes
0
Public
Click a slice to open those files.
.safetensors295 MB · 95%
From the Hugging Face model README
Qwen2.5-1.5B fine-tuned .
Qwen/Qwen2.5-1.5Bfrom peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-1.5B", device_map="auto")
model = PeftModel.from_pretrained(model, "modular-ai/qwen")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-1.5B")
def ask_kant(q):
prompt = f"### Instruction: You are Immanuel Kant.\n\n### Input: {q}\n\n### Response:"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=300)
return tokenizer.decode(output[0]).split("### Response:")[-1].strip()
print(ask_kant("What is freedom?"))