Papers
Topics
Authors
Recent
Detailed Answer
Quick Answer
Concise responses based on abstracts only
Detailed Answer
Well-researched responses based on abstracts and relevant paper content.
Custom Instructions Pro
Preferences or requirements that you'd like Emergent Mind to consider when generating responses
Gemini 2.5 Flash
Gemini 2.5 Flash 84 tok/s
Gemini 2.5 Pro 45 tok/s Pro
GPT-5 Medium 28 tok/s Pro
GPT-5 High 21 tok/s Pro
GPT-4o 92 tok/s Pro
GPT OSS 120B 425 tok/s Pro
Kimi K2 157 tok/s Pro
2000 character limit reached

Emotional RAG: Enhancing Role-Playing Agents through Emotional Retrieval (2410.23041v1)

Published 30 Oct 2024 in cs.AI

Abstract: As LLMs exhibit a high degree of human-like capability, increasing attention has been paid to role-playing research areas in which responses generated by LLMs are expected to mimic human replies. This has promoted the exploration of role-playing agents in various applications, such as chatbots that can engage in natural conversations with users and virtual assistants that can provide personalized support and guidance. The crucial factor in the role-playing task is the effective utilization of character memory, which stores characters' profiles, experiences, and historical dialogues. Retrieval Augmented Generation (RAG) technology is used to access the related memory to enhance the response generation of role-playing agents. Most existing studies retrieve related information based on the semantic similarity of memory to maintain characters' personalized traits, and few attempts have been made to incorporate the emotional factor in the retrieval argument generation (RAG) of LLMs. Inspired by the Mood-Dependent Memory theory, which indicates that people recall an event better if they somehow reinstate during recall the original emotion they experienced during learning, we propose a novel emotion-aware memory retrieval framework, termed Emotional RAG, which recalls the related memory with consideration of emotional state in role-playing agents. Specifically, we design two kinds of retrieval strategies, i.e., combination strategy and sequential strategy, to incorporate both memory semantic and emotional states during the retrieval process. Extensive experiments on three representative role-playing datasets demonstrate that our Emotional RAG framework outperforms the method without considering the emotional factor in maintaining the personalities of role-playing agents. This provides evidence to further reinforce the Mood-Dependent Memory theory in psychology.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (37)
  1. Y. Shao, L. Li, J. Dai, and X. Qiu, “Character-llm: A trainable agent for role-playing,” arXiv preprint arXiv:2310.10158, 2023.
  2. J. Zhou, Z. Chen, D. Wan, B. Wen, Y. Song, J. Yu, Y. Huang, L. Peng, J. Yang, X. Xiao et al., “Characterglm: Customizing chinese conversational ai characters with large language models,” arXiv preprint arXiv:2311.16832, 2023.
  3. C. Li, Z. Leng, C. Yan, J. Shen, H. Wang, W. Mi, Y. Fei, X. Feng, S. Yan, H. Wang et al., “Chatharuhi: Reviving anime character in reality via large language model,” arXiv preprint arXiv:2308.09597, 2023.
  4. N. Chen, Y. Wang, H. Jiang, D. Cai, Y. Li, Z. Chen, L. Wang, and J. Li, “Large language models meet harry potter: A bilingual dataset for aligning dialogue agents with characters,” arXiv preprint arXiv:2211.06869, 2022.
  5. Z. M. Wang, Z. Peng, H. Que, J. Liu, W. Zhou, Y. Wu, H. Guo, R. Gan, Z. Ni, M. Zhang et al., “Rolellm: Benchmarking, eliciting, and enhancing role-playing abilities of large language models,” arXiv preprint arXiv:2310.00746, 2023.
  6. J. Chen, X. Wang, R. Xu, S. Yuan, Y. Zhang, W. Shi, J. Xie, S. Li, R. Yang, T. Zhu et al., “From persona to personalization: A survey on role-playing language agents,” arXiv preprint arXiv:2404.18231, 2024.
  7. K. Lu, B. Yu, C. Zhou, and J. Zhou, “Large language models are superpositions of all characters: Attaining arbitrary role-play via self-alignment,” arXiv preprint arXiv:2401.12474, 2024.
  8. M. Shanahan, K. McDonell, and L. Reynolds, “Role-play with large language models,” 2023. [Online]. Available: https://arxiv.org/abs/2305.16367
  9. M. Yan, R. Li, H. Zhang, H. Wang, Z. Yang, and J. Yan, “Larp: Language-agent role play for open-world games,” 2023. [Online]. Available: https://arxiv.org/abs/2312.17653
  10. W. Zhong, L. Guo, Q. Gao, H. Ye, and Y. Wang, “Memorybank: Enhancing large language models with long-term memory,” in Proceedings of the AAAI Conference on Artificial Intelligence, vol. 38, no. 17, 2024, pp. 19 724–19 731.
  11. K. Zhang, F. Zhao, Y. Kang, and X. Liu, “Memory-augmented llm personalization with short-and long-term memory coordination,” arXiv preprint arXiv:2309.11696, 2023.
  12. J. S. Park, J. O’Brien, C. J. Cai, M. R. Morris, P. Liang, and M. S. Bernstein, “Generative agents: Interactive simulacra of human behavior,” in Proceedings of the 36th Annual ACM Symposium on User Interface Software and Technology, 2023, pp. 1–22.
  13. Z. Wang, Y. Y. Chiu, and Y. C. Chiu, “Humanoid agents: Platform for simulating human-like generative agents,” 2023. [Online]. Available: https://arxiv.org/abs/2310.05418
  14. Z. Zhang, X. Bo, C. Ma, R. Li, X. Chen, Q. Dai, J. Zhu, Z. Dong, and J.-R. Wen, “A survey on the memory mechanism of large language model based agents,” arXiv preprint arXiv:2404.13501, 2024.
  15. S. Ge, C. Xiong, C. Rosset, A. Overwijk, J. Han, and P. Bennett, “Augmenting zero-shot dense retrievers with plug-in mixture-of-memories,” 2023. [Online]. Available: https://arxiv.org/abs/2302.03754
  16. B. Wang, X. Liang, J. Yang, H. Huang, S. Wu, P. Wu, L. Lu, Z. Ma, and Z. Li, “Enhancing large language model with self-controlled memory framework,” 2024. [Online]. Available: https://arxiv.org/abs/2304.13343
  17. Y. Yu, H. Li, Z. Chen, Y. Jiang, Y. Li, D. Zhang, R. Liu, J. W. Suchow, and K. Khashanah, “Finmem: A performance-enhanced llm trading agent with layered memory and character design,” 2023. [Online]. Available: https://arxiv.org/abs/2311.13743
  18. X. Zhu, Y. Chen, H. Tian, C. Tao, W. Su, C. Yang, G. Huang, B. Li, L. Lu, X. Wang, Y. Qiao, Z. Zhang, and J. Dai, “Ghost in the minecraft: Generally capable agents for open-world environments via large language models with text-based knowledge and memory,” 2023. [Online]. Available: https://arxiv.org/abs/2305.17144
  19. C. Xiao, P. Zhang, X. Han, G. Xiao, Y. Lin, Z. Zhang, Z. Liu, and M. Sun, “Infllm: Training-free long-context extrapolation for llms with an efficient context memory,” 2024. [Online]. Available: https://arxiv.org/abs/2402.04617
  20. C. Packer, S. Wooders, K. Lin, V. Fang, S. G. Patil, I. Stoica, and J. E. Gonzalez, “Memgpt: Towards llms as operating systems,” 2024. [Online]. Available: https://arxiv.org/abs/2310.08560
  21. A. Modarressi, A. Imani, M. Fayyaz, and H. Schütze, “Ret-llm: Towards a general read-write memory for large language models,” 2023. [Online]. Available: https://arxiv.org/abs/2305.14322
  22. J. Kang, R. Laroche, X. Yuan, A. Trischler, X. Liu, and J. Fu, “Think before you act: Decision transformers with working memory,” 2024. [Online]. Available: https://arxiv.org/abs/2305.16338
  23. L. Liu, X. Yang, Y. Shen, B. Hu, Z. Zhang, J. Gu, and G. Zhang, “Think-in-memory: Recalling and post-thinking enable llms with long-term memory,” 2023. [Online]. Available: https://arxiv.org/abs/2311.08719
  24. G. Wang, Y. Xie, Y. Jiang, A. Mandlekar, C. Xiao, Y. Zhu, L. Fan, and A. Anandkumar, “Voyager: An open-ended embodied agent with large language models,” 2023. [Online]. Available: https://arxiv.org/abs/2305.16291
  25. G. H. Bower, “Mood and memory.” American psychologist, vol. 36, no. 2, p. 129, 1981.
  26. S. Xiao, Z. Liu, P. Zhang, and N. Muennighoff, “C-pack: Packaged resources to advance general chinese embedding,” 2023.
  27. R. Plutchik, “A general psychoevolutionary theory of emotion,” in Theories of emotion.   Elsevier, 1980, pp. 3–33.
  28. X. Wang, Y. Xiao, J. tse Huang, S. Yuan, R. Xu, H. Guo, Q. Tu, Y. Fei, Z. Leng, W. Wang, J. Chen, C. Li, and Y. Xiao, “Incharacter: Evaluating personality fidelity in role-playing agents through psychological interviews,” 2024.
  29. Q. Tu, S. Fan, Z. Tian, and R. Yan, “Charactereval: A chinese benchmark for role-playing conversational agent evaluation,” arXiv preprint arXiv:2401.01275, 2024.
  30. O. P. John, L. P. Naumann, and C. J. Soto, “Paradigm shift to the integrative big five trait taxonomy: History, measurement, and conceptual issues.” 2008. [Online]. Available: https://api.semanticscholar.org/CorpusID:149343234
  31. Z. Du, Y. Qian, X. Liu, M. Ding, J. Qiu, Z. Yang, and J. Tang, “Glm: General language model pretraining with autoregressive blank infilling,” in Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), 2022, pp. 320–335.
  32. J. Bai, S. Bai, Y. Chu, Z. Cui, K. Dang, X. Deng, Y. Fan, W. Ge, Y. Han, F. Huang, B. Hui, L. Ji, M. Li, J. Lin, R. Lin, D. Liu, G. Liu, C. Lu, K. Lu, J. Ma, R. Men, X. Ren, X. Ren, C. Tan, S. Tan, J. Tu, P. Wang, S. Wang, W. Wang, S. Wu, B. Xu, J. Xu, A. Yang, H. Yang, J. Yang, S. Yang, Y. Yao, B. Yu, H. Yuan, Z. Yuan, J. Zhang, X. Zhang, Y. Zhang, Z. Zhang, C. Zhou, J. Zhou, X. Zhou, and T. Zhu, “Qwen technical report,” arXiv preprint arXiv:2309.16609, 2023.
  33. L. Ouyang, J. Wu, X. Jiang, D. Almeida, C. Wainwright, P. Mishkin, C. Zhang, S. Agarwal, K. Slama, A. Ray et al., “Training language models to follow instructions with human feedback,” Advances in neural information processing systems, vol. 35, pp. 27 730–27 744, 2022.
  34. C. Hu, J. Fu, C. Du, S. Luo, J. Zhao, and H. Zhao, “Chatdb: Augmenting llms with databases as their symbolic memory,” arXiv preprint arXiv:2306.03901, 2023.
  35. L. Wang, C. Ma, X. Feng, Z. Zhang, H. Yang, J. Zhang, Z. Chen, J. Tang, X. Chen, Y. Lin et al., “A survey on large language model based autonomous agents,” Frontiers of Computer Science, vol. 18, no. 6, p. 186345, 2024.
  36. Y. Wu, M. N. Rabe, D. Hutchins, and C. Szegedy, “Memorizing transformers,” arXiv preprint arXiv:2203.08913, 2022.
  37. W. Wang, L. Dong, H. Cheng, X. Liu, X. Yan, J. Gao, and F. Wei, “Augmenting language models with long-term memory,” Advances in Neural Information Processing Systems, vol. 36, 2024.
List To Do Tasks Checklist Streamline Icon: https://streamlinehq.com

Collections

Sign up for free to add this paper to one or more collections.

Summary

  • The paper presents the Emotional RAG framework leveraging emotional memory retrieval based on mood-dependent memory to enrich agent interactions.
  • The methodology encodes both semantic and emotional states using advanced vector models and employs dual retrieval strategies for improved query relevance.
  • Experimental results show enhanced personalization and consistent character portrayal, notably in systems like ChatGLM-6B and Qwen-72B, outperforming traditional methods.

Emotional RAG: Enhancing Role-Playing Agents through Emotional Retrieval

Introduction

The paper "Emotional RAG: Enhancing Role-Playing Agents through Emotional Retrieval" introduces an advanced framework designed to augment LLMs with emotional memory retrieval capabilities. The Emotional RAG framework is motivated by the need for LLMs to not only retrieve semantically relevant memories but also memories consistent with emotional states, thus providing role-playing agents that can emulate more nuanced, human-like responses. This approach leverages psychological theories, specifically Mood-Dependent Memory, to enhance interactive conversations with emotional depth. Figure 1

Figure 1: The overview architecture of Emotional RAG framework. It contains four components: the query encoding component, the memory encoding component, the emotional retrieval component, and the response generation component.

Methodology

The proposed framework, Emotional RAG, incorporates several key components to retrieve and utilize emotional memory, enhancing an agent's conversational capabilities.

Overview Architecture

The Emotional RAG framework comprises four core components:

  1. Query Encoding Component: Encodes both semantic and emotional state vectors of incoming queries.
  2. Memory Encoding Component: Stores and encodes historical conversation data similarly in terms of semantic and emotional vectors.
  3. Emotional Retrieval Component: Retrieves memory fragments based on both semantic relevance and emotional congruity, utilizing multiple retrieval strategies, including combination and sequential strategies.
  4. Response Generation Component: Utilizes a prompt that integrates the query, character profiles, and retrieved emotional memory to generate responses, using templates like those depicted below. Figure 2

    Figure 2: Emotion scoring prompt template in LLMs.

Technical Implementation

The framework employs advanced vector embedding models and utilizes the Semantic Enhanced Embedding (bge-base-zh-v1.5) and GPT-3.5 for emotion scoring. Emotional retrieval is implemented through two retrieval strategies—combination (C-A/C-M) and sequential (S-S/S-E)—to determine the emotional and semantic relevance of memory fragments, ensuring that the emotion-congruity criterion is preserved. Figure 3

Figure 3: An example of response generation prompt template in the CharacterEval dataset.

Experimental Evaluation

The effectiveness of Emotional RAG was evaluated across three datasets: InCharacter, CharacterEval, and Character-LLM, using BFI and MBTI as evaluation metrics. The results indicated that:

  • Performance Improvements: Emotional RAG consistently outperformed traditional RAG methods, particularly in full personality type evaluations, by leveraging emotional retrieval to maintain and reflect character personalities more accurately.
  • Robustness Across Models: While improvements were seen in all models, the largest gains were in systems like ChatGLM-6B and Qwen-72B, suggesting the importance of emotional congruity when semantic capabilities are otherwise robust. Figure 4

    Figure 4: An example of the prompt template for dimension Extroversion (E) vs. Introversion (I) in MBTI evaluation.

Analysis and Discussion

RAG Strategy Analysis

The paper analyzes the impact of different retrieval strategies in Emotional RAG, indicating that varying approaches have advantages depending on the evaluation criteria used (e.g., BFI vs. MBTI). The preference for sequential emotional prioritization in particular contexts highlights the role of emotion in personalization tasks.

Case Studies

Case studies illustrate how Emotional RAG enables agents to produce responses better aligned emotionally with queries, resulting in interactions that are more coherent and contextually appropriate when managing emotionally loaded dialogues.

(Figure 5 and Figure 6)

Figure 5: Different RAG strategies on BFI evaluation.

Figure 6: Two examples that Emotional RAG generates better results.

Implications and Future Work

This research underscores the significant potential of integrating emotional awareness into memory retrieval processes for AI agents. The development of the Emotional RAG framework is a step toward achieving nuanced, empathetic AI-driven interactions across domain applications like virtual customer service and interactive entertainment. Future research could focus on optimizing memory architecture and exploring adaptive learning mechanisms to further refine the emotional alignment of role-playing agents.

Conclusion

Emotional RAG framework represents a significant advancement in role-playing agents, demonstrating that incorporating emotional retrieval strategies significantly enhances LLM's ability to generate personified, emotionally resonant conversations. This augmentation validates mood-dependent memory from psychology, paving the way for more sophisticated solutions in human-computer interaction domains.

Ai Generate Text Spark Streamline Icon: https://streamlinehq.com

Paper Prompts

Sign up for free to create and run prompts on this paper using GPT-5.

X Twitter Logo Streamline Icon: https://streamlinehq.com