Skip to content

Code and Data for EMNLP 2024 Paper "Neeko: Leveraging Dynamic LoRA for Efficient Multi-Character Role-Playing Agent"

License

Notifications You must be signed in to change notification settings

weiyifan1023/Neeko

Repository files navigation

Neeko: Leveraging Dynamic LoRA for Efficient Multi-Character Role-Playing Agent

🔔 Code • 📃 Paper • 🤗 Dataset

Abstract

Large Language Models (LLMs) have revolutionized open-domain dialogue agents but encounter challenges in multi-character role-playing (MCRP) scenarios. To address the issue, we present Neeko, an innovative framework designed for efficient multiple characters imitation. Unlike existing methods, Neeko employs a dynamic low-rank adapter (LoRA) strategy, enabling it to adapt seamlessly to diverse characters. Our framework breaks down the role-playing process into agent pre-training, multiple characters playing, and character incremental learning, effectively handling both seen and unseen roles. This dynamic approach, coupled with distinct LoRA blocks for each character, enhances Neeko's adaptability to unique attributes, personalities, and speaking patterns. As a result, Neeko demonstrates superior performance in MCRP over most existing methods, offering more engaging and versatile user interaction experiences.

Framework

Image text

Getting Started

git clone https://github.com/weiyifan1023/Neeko.git
cd Neeko

1. Shuffle data from multiple roles.

python shuffle_data.py \
    --data_dir /path/to/your/character-llm-data/ \
    --out_path /path/to/your/character-llm-data/prompted/shuffle.jsonl

2. Use a pretrained transformer encoder model to generate role embeddings

Here, we take S-Bert as an example.

python embd_roles.py \
    --encoder_path /path/to/your/s-bert \
    --seed_data_path /path/to/your/seed_data \
    --save_path /path/to/save/your/role_embds

3. Training Neeko

We take Llama-2-7b as an example, replace some paths in neeko.sh, and then execute:

bash neeko.sh

Demonstration

Image text

Citation

If you find our paper inspiring and have utilized it in your work, please cite our paper.

@inproceedings{yu-etal-2024-neeko,
    title = "Neeko: Leveraging Dynamic {L}o{RA} for Efficient Multi-Character Role-Playing Agent",
    author = "Yu, Xiaoyan  and
      Luo, Tongxu  and
      Wei, Yifan  and
      Lei, Fangyu  and
      Huang, Yiming  and
      Peng, Hao  and
      Zhu, Liehuang",
    booktitle = "Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing",
    month = nov,
    year = "2024",
    address = "Miami, Florida, USA",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2024.emnlp-main.697",
    pages = "12540--12557",
}

Contact

xiaoyan.yu@bit.edu.cn && 2748113810@qq.com (Tongxu Luo) && weiyifan2021@ia.ac.cn (Preferred)

About

Code and Data for EMNLP 2024 Paper "Neeko: Leveraging Dynamic LoRA for Efficient Multi-Character Role-Playing Agent"

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •