Downloads · 30 days
14
11% of all-time downloads
maomao88/anime-waifu-mistral-lora
anime-waifu-mistral-lora is a text generation model from maomao88. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as mit.
This repository contains a LoRA adapter trained with the maomao88/anime-waifu-personality-chat-with-questions dataset via Supervised Fine-Tuning (SFT) to add anime-style personalities to the Mistral-7B-Instruct model.
Downloads · 30 days
14
11% of all-time downloads
All-time downloads
133
Public
Repo size
54.6 MB
Likes
1
Public
Click a slice to open those files.
.safetensors54.6 MB · 100%
From the Hugging Face model README
This repository contains a LoRA adapter trained with the maomao88/anime-waifu-personality-chat-with-questions dataset via Supervised Fine-Tuning (SFT) to add anime-style personalities to the Mistral-7B-Instruct model.
The personalities supported are:
You can load this adapter with the following code:
from transformers import AutoModelForCausalLM
from peft import PeftModel
from transformers import AutoTokenizer
import torch
base_model = AutoModelForCausalLM.from_pretrained(
"mistralai/Mistral-7B-Instruct-v0.1"
)
tokenizer = AutoTokenizer.from_pretrained(
"mistralai/Mistral-7B-Instruct-v0.1"
)
model = PeftModel.from_pretrained(
base_model,
"maomao88/anime-waifu-mistral-lora"
)
def chat_with_personality(trait, user_input, max_new_tokens=100, temperature=0.8):
"""
Generate a response from the fine-tuned model using a given personality trait.
"""
messages = [
{
"role": "system",
"content": f"You are an anime character with the following personality: {trait}."
},
{
"role": "user",
"content": user_input
}
]
# Apply Mistral's chat template
prompt = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=max_new_tokens,
do_sample=True,
temperature=temperature,
top_p=0.9,
pad_token_id=tokenizer.eos_token_id,
repetition_penalty=1.1
)
# Decode only the generated text portion (skip <s> etc.)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
# Remove the prompt portion to keep only the assistant reply
if "[/INST]" in response:
response = response.split("[/INST]")[-1].strip()
return response
chat_with_personality("tsundere", "What do you think of the moon?")
# Response Example: It’s not like I care about the moon or anything… but it sure is pretty tonight!
The anime characters supported are as follows: