Views
No views yet
1import transformers
2from peft import PeftModel
3
4model_name = "google/flan-t5-xl"; peft_model_id = "reasonwang/flan-gpteacher-lora-xl"
5tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
6base_model = transformers.AutoModelForSeq2SeqLM.from_pretrained(model_name)
7peft_model = PeftModel.from_pretrained(base_model, peft_model_id)
8
9inputs = tokenizer("If you are the president of a developing country, what you will do to make your country better?", return_tensors="pt")
10outputs = peft_model.generate(**inputs, max_length=256, do_sample=True)
11print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
12
13# I will take immediate steps to improve education and infrastructure so that citizens thrive.
14# I will also invest in infrastructure upgrades such as hospitals and electricity distribution lines, as well as encouraging innovation in our resiliency infrastructure.
15# I will also focus on promoting trade and investment between countries, both for economic and cultural benefit.