Views
No views yet
transformers:1
2import torch
3from peft import PeftModel, PeftConfig
4from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
5
6# Load peft config for pre-trained checkpoint etc.
7peft_model_id = "ArtifactAI/flant5-xxl-math-full-training-run-one"
8config = PeftConfig.from_pretrained(peft_model_id)
9
10# load base LLM model and tokenizer
11model = AutoModelForSeq2SeqLM.from_pretrained(config.base_model_name_or_path, load_in_8bit=True, device_map={"":0})
12tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
13
14# Load the Lora model
15model = PeftModel.from_pretrained(model, peft_model_id, device_map={"":0})
16model.eval()
17
18
19input_ids = tokenizer("What is the peak phase of T-eV?", return_tensors="pt", truncation=True).input_ids.cuda()
20# with torch.inference_mode():
21outputs = model.generate(input_ids=input_ids, max_new_tokens=1000, do_sample=True, top_p=0.9)
22
23print(f"summary: {tokenizer.batch_decode(outputs.detach().cpu().numpy(), skip_special_tokens=True)[0]}")@misc{flan-t5-xxl-arxiv-cs-ml-zeroshot-qa,
title={flan-t5-xxl-arxiv-cs-ml-zeroshot-qa},
author={Matthew Kenney},
year={2023}
}