Views
No views yet
1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3from peft import PeftModel
4
5base = AutoModelForCausalLM.from_pretrained(
6 "meta-llama/Llama-3.1-8B-Instruct",
7 device_map="auto",
8 torch_dtype=torch.bfloat16
9)
10tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.1-8B-Instruct")
11model = PeftModel.from_pretrained(base, "Stergios/llama3.1-8b-instruct-lora")
12
13prompt = "Γράψε στην κυπριακή διάλεκτο: Πώς πάει η μέρα σου;"
14inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
15output = model.generate(**inputs, max_new_tokens=150, temperature=0.75)
16print(tokenizer.decode(output[0], skip_special_tokens=True))device_map="auto" for multi-GPU utilisationadapter_model.safetensors (~170 MB), tokenizer + chat template included for convenience