Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3
4# Load base model
5model = AutoModelForCausalLM.from_pretrained(
6 "meta-llama/Llama-2-7b-hf",
7 load_in_8bit=True,
8 device_map="auto"
9)
10tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-hf")
11
12# Load adapter
13model = PeftModel.from_pretrained(model, "Thamirawaran/llama2-7b-medical-lora")
14
15# Generate
16prompt = 'What are the symptoms of diabetes?'
17inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
18outputs = model.generate(**inputs, max_length=256, temperature=0.7)
19print(tokenizer.decode(outputs[0], skip_special_tokens=True))1@misc{llama2-medical-lora,
2 author = {Team RAISE},
3 title = {LLaMA-2-7B Medical LoRA Adapter},
4 year = {2026},
5 publisher = {HuggingFace},
6 howpublished = {\url{https://huggingface.co/Thamirawaran/llama2-7b-medical-lora}}
7}