--- license: mit library_name: peft datasets: - maomao88/anime-waifu-personality-chat-with-questions language: - en base_model: - mistralai/Mistral-7B-Instruct-v0.1 pipeline_tag: text-generation tags: - lora - peft - mistral - anime - personality --- # Anime Personality LoRA for Mistral This repository contains a **LoRA adapter** trained with the [maomao88/anime-waifu-personality-chat-with-questions](https://huggingface.co/datasets/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: * tsundere(傲娇 / ツンデレ) * yandere(病娇 / ヤンデレ) * bakadere(笨蛋娇 / バカデレ) * himedere(公主娇 / ヒメデレ) * genki(元气型 / 元気系) * moe(萌系 / 萌え) 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 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: * Tsundere (傲娇) * Yandere (病娇) * Himedere (公主娇) * Genki (元气) * Moe (萌系) * Bakadere (笨蛋) ]