Views
No views yet
1model_name = "EdwardYu/llama-2-7b-MedQuAD-merged"
2
3tokenizer = AutoTokenizer.from_pretrained(model_name)
4
5model = AutoModelForCausalLM.from_pretrained(
6 model_name,
7 load_in_4bit=True,
8 torch_dtype=torch.bfloat16,
9 device_map="auto",
10 quantization_config=BitsAndBytesConfig(
11 load_in_4bit=True,
12 bnb_4bit_compute_dtype=torch.bfloat16,
13 bnb_4bit_use_double_quant=True,
14 bnb_4bit_quant_type='nf4'
15 ),
16)
17
18question = 'What are the side effects or risks of Glucagon?'
19inputs = tokenizer(question, return_tensors="pt").to("cuda")
20outputs = model.generate(inputs=inputs.input_ids, max_length=1024)
21print(tokenizer.decode(outputs[0], skip_special_tokens=True))1model = AutoModelForCausalLM.from_pretrained(
2 model_name,
3 torch_dtype=torch.bfloat16,
4 device_map="auto",
5)
6model = PeftModel.from_pretrained(model, adapter)