I was able to redo everything locally until the peft_trainer.train().
I did save this trained version locally as well, and I trying to use it for the last steps (section 3.3 - Evaluate the Model Qualitatively).
In the lab, the original_model, the instruct_model and peft_model are used for inference, and the results are compared. However, the way that the output are got are slightly diferent than in previous sections. I’m doing the same as before because it works for the original model and instruct model (the new way doesn’t). Unfortunately, for the peft_model I’m getting an error and I’m not sure how to solve it (and/or why I am getting it).
Here is a section of the code I am refering to:
from peft import PeftModel, PeftConfig
peft_model_base = AutoModelForSeq2SeqLM.from_pretrained(“google/flan-t5-base”, torch_dtype=torch.bfloat16)
peft_model_base.to(torch.device(“cuda:0”))
tokenizer = AutoTokenizer.from_pretrained(“google/flan-t5-base”)
peft_model = PeftModel.from_pretrained(peft_model_base,
‘./peft-dialogue-summary-checkpoint-local’,
torch_dtype=torch.bfloat16,
is_trainable=False)
peft_model.to(torch.device(“cuda:0”))
index = 200
dialogue = dataset[‘test’][index][‘dialogue’]
baseline_human_summary = dataset[‘test’][index][‘summary’]
prompt = f"“”\nSummarize the following conversation.\n\n{dialogue}\n\nSummary: “”"
input_ids = tokenizer(prompt, return_tensors=“pt”)
inputs = input_ids.to(torch.device(“cuda:0”))
original_model.to(torch.device(“cuda:0”))
original_model_outputs = original_model.generate(inputs[“input_ids”], max_new_tokens=200,)
original_model_text_output = tokenizer.decode(original_model_outputs[0], skip_special_tokens=True)
instruct_model_outputs = instruct_model.generate(inputs[“input_ids”], max_new_tokens=200,)
instruct_model_text_output = tokenizer.decode(instruct_model_outputs[0], skip_special_tokens=True)
Neither options here work:
#peft_model_outputs = peft_model .generate(input_ids=input_ids, generation_config=GenerationConfig(max_new_tokens=200, num_beams=1))
peft_model_outputs = peft_model.generate(inputs[“input_ids”], max_new_tokens=200,)
peft_model_text_output = tokenizer.decode(peft_model_outputs[0], skip_special_tokens=True)
Here is the error I get:
peft_model_outputs = peft_model.generate(inputs[“input_ids”], max_new_tokens=200,)
Traceback (most recent call last):
File “”, line 1, in
TypeError: PeftModelForSeq2SeqLM.generate() takes 1 positional argument but 2 were given
generation_config = GenerationConfig(max_new_tokens=200, num_beams=1)
peft_model_outputs = peft_model.generate(inputs[“input_ids”], generation_config)
Traceback (most recent call last):
File “”, line 1, in
TypeError: PeftModelForSeq2SeqLM.generate() takes 1 positional argument but 3 were given