Views
No views yet
1from transformers import AutoTokenizer, AutoModelForCausalLM
2from peft import PeftModel
3
4# Load base model and tokenizer
5base_model = AutoModelForCausalLM.from_pretrained("microsoft/DialoGPT-small")
6tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-small")
7
8# Load LoRA adapter
9model = PeftModel.from_pretrained(base_model, "rohitnagareddy/seal-aethelgard-knowledge")
10
11# Test the knowledge
12prompt = "Instruction: Answer the following question based on the given context.\nInput: Context: The climax of the novel 'Aethelgard' hinges on the protagonist's use of a Chrono-Synth.\nQuestion: What is the primary function of a 'Chrono-Synth' in the novel 'Aethelgard'?\nOutput:"
13
14inputs = tokenizer(prompt, return_tensors="pt")
15outputs = model.generate(**inputs, max_new_tokens=50)
16response = tokenizer.decode(outputs[0], skip_special_tokens=True)
17print(response)