peft_model_id = "/finetuned_deep_seek/transformers/deepseek_finetuned/1"
peft_model = AutoModelForCausalLM.from_pretrained(peft_model_id)
peft_model = PeftModel.from_pretrained(model, peft_model_id)
peft_model=peft_model.merge_and_unload()
here is code for tokenizing and generating text.
text="Role:You are an advanced Mathematical System who can solve complex mathematical problems given in Latex format.nInstruction : n 1.Read the problem and Analyze carefully.n 2.Think a step by step solution recheck logic in every step mapping back to question clearly beform moving to next step.n 3. After getting answer recheck it with question again if it seems not fit repeat whole process again. n 4.put your final integer answer at the end.n problem:There exists a unique increasing geometric sequence of six 3-digit positive integers. What is their sum? n Solution: Let's think step by step"
inputs= tokenizer(text, return_tensors="pt").input_ids
inputs=inputs.to(device)
print("generating")
outputs = peft_model.generate(inputs,pad_token_id=tokenizer.pad_token_id, max_new_tokens=1024)
solution=tokenizer.decode(outputs[0], skip_special_tokens=False)
print(solution)