import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
base = "Qwen/Qwen3-1.7B-Base"
adapter = "DeliVali/AIDAM_MATH_1.7B_V1.0.0"
tokenizer = AutoTokenizer.from_pretrained(adapter)
model = AutoModelForCausalLM.from_pretrained(
base,
quantization_config=BitsAndBytesConfig(
load_in_4bit=True, bnb_4bit_compute_dtype=torch.bfloat16,
bnb_4bit_quant_type="nf4", bnb_4bit_use_double_quant=True,
),
device_map="cuda",
)
model = PeftModel.from_pretrained(model, adapter).eval()
prompt = (
"Natalia sold clips to 48 of her friends in April, and then she sold "
"half as many clips in May. How many clips did Natalia sell altogether "
"in April and May?\n\nPlease reason step by step, and put your final "
"answer within \\boxed{}."
)
enc = tokenizer(prompt, return_tensors="pt").to(model.device)
out = model.generate(**enc, max_new_tokens=512, do_sample=False,
pad_token_id=tokenizer.pad_token_id)
print(tokenizer.decode(out[0][enc["input_ids"].shape[1]:], skip_special_tokens=True))