Mistral_Test / PEFT.py
eesfeg's picture
Add fine-tuned Mistral model
3ac4614
raw
history blame contribute delete
395 Bytes
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
base_model = "mistralai/Mistral-7B-v0.1"
model = AutoModelForCausalLM.from_pretrained(
base_model,
torch_dtype=torch.float16,
device_map="auto"
)
model = PeftModel.from_pretrained(model, "your-username/mistral-finetuned-model")
tokenizer = AutoTokenizer.from_pretrained(base_model)