Views
No views yet
1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2from peft import PeftModel
3
4# Load model
5tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-base")
6base_model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-base")
7model = PeftModel.from_pretrained(base_model, "YOUR_USERNAME/flan-t5-conversation-generator")
8
9# Generate
10prefix = "Generate a call center conversation from this summary: "
11summary = "The client called about a broken AC unit. The agent scheduled a technician."
12
13inputs = tokenizer(prefix + summary, return_tensors="pt", max_length=256, truncation=True)
14outputs = model.generate(**inputs, max_new_tokens=512, num_beams=4)
15print(tokenizer.decode(outputs[0], skip_special_tokens=True))The client called about an ongoing issue where the heater making burning smell. The agent scheduled a technician to inspect heating elements.
Client: Hi, I'm calling because my heater making burning smell.
Agent: Thanks for explaining. When did you first notice this happening?
Client: It started a couple days ago and keeps repeating.
Agent: Understood, we'll inspect heating elements during the service visit.