Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3
4# Load base model
5base_model = AutoModelForCausalLM.from_pretrained(
6 "NousResearch/Llama-2-7b-chat-hf",
7 torch_dtype=torch.float16,
8 device_map="auto"
9)
10
11# Load LoRA adapter
12model = PeftModel.from_pretrained(base_model, "misee/uk-fraud-chatbot-llama2")
13tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-chat-hf")
14
15# Generate response
16system_prompt = "You are a specialized UK fraud victim support assistant..."
17prompt = f"<s>[INST] <<SYS>>\n{system_prompt}\n<</SYS>>\n\nYour question here [/INST]"