Views
No views yet
peft, or merge it into the base model if you need a standalone Transformers artifact.1import torch
2from peft import AutoPeftModelForCausalLM
3from transformers import AutoTokenizer
4
5model_id = "spanthee/qwen3-macos-clawdia-toolcalling-lora"
6
7tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
8model = AutoPeftModelForCausalLM.from_pretrained(
9 model_id,
10 torch_dtype=torch.bfloat16,
11 device_map="auto",
12 trust_remote_code=True,
13)
14
15messages = [
16 {
17 "role": "user",
18 "content": "Given these available tools, create a reminder for tomorrow at 9 AM.",
19 }
20]
21prompt = tokenizer.apply_chat_template(
22 messages,
23 tokenize=False,
24 add_generation_prompt=True,
25 enable_thinking=False,
26)
27inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
28output = model.generate(**inputs, max_new_tokens=256, do_sample=False)
29print(tokenizer.decode(output[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))1@software{vonwerra2020trl,
2 title = {{TRL: Transformers Reinforcement Learning}},
3 author = {von Werra, Leandro and Belkada, Younes and Tunstall, Lewis and Beeching, Edward and Thrush, Tristan and Lambert, Nathan and Huang, Shengyi and Rasul, Kashif and Gallouédec, Quentin},
4 license = {Apache-2.0},
5 url = {https://github.com/huggingface/trl},
6 year = {2020}
7}