Spontaneous Emergence of Agent Individuality Through Social Interactions in Large Language Model-Based Communities Authors: Ryosuke Takata, Atsushi Masumori, Takashi Ikegami Published: 2024 ABSTRACT We study the emergence of agency from scratch by using Large Language Model (LLM)-based agents. In previous studies of LLM-based agents, each agent’s characteristics, including personality and memory, have traditionally been predefined. We focused on how individuality, such as behavior, personality, and memory, can be differentiated from an undifferentiated state. The present LLM agents engage in cooperative communication within a group simulation, exchanging context-based messages in natural language. By analyzing this multi-agent simulation, we report valuable new insights into how social norms, cooperation, and personality traits can emerge spontaneously. This paper demonstrates that autonomously interacting LLM-powered agents generate hallucinations and hashtags to sustain communication, which, in turn, increases the diversity of words within their interactions. Each agent’s emotions shift through communication, and as they form communities, the personalities of the agents emerge and evolve accordingly. This computational modeling approach and its findings will provide a new method for analyzing collective artificial intelligence. 1. Introduction With the advent of Large Language Models (LLMs) such as GPT-4 [1], generative agents are rapidly evolving towards powerful ones manipulating natural language interfaces when interacting with other agents. Those agents can even intervene in people’s daily lives, as AI-coding, searching, reviewing, translation, etc. [2]. Those agents are not only for human users, but also for manipulating motor commands in robots, and for other machines that connect language, movement, and embodiment in general [3,4]. Unlike humans, LLMs can passively acquire much of their knowledge and skills through exposure to symbolic information alone [5]. Despite these differences, LLMs have been reported to possess higher-order cognitive abilities, such as theory of mind and social reasoning capabilities [6,7,8]. While research on LLMs draws analogies with humans, studies also explore LLM-specific capabilities, such as their ability to communicate in languages incomprehensible to humans or in non-natural language formats [9,10]. Recent research has shown that semantic structures of language are embedded in the internal representational structure of LLMs [11], and at the mesoscale level, they show similarities to human brain regions [12]. Specific connection weights that significantly alter generated content have been discovered [13]. These studies are actively working to understand LLMs’ internal mechanisms. Furthermore, there is increasing focus on the diversity of LLM-generated content, as evidenced by studies showing how using LLM-generated data for training can alter model distribution and reduce output diversity [14], reports that aligned LLMs show decreased content diversity [15], and development of LLMs capable of efficiently generating diverse content [16]. Many applied research studies are being conducted to make LLMs practical for real-world use. For example, research is being carried out on creating human avatars using LLMs [17,18,19], and on applications of LLMs for high-speed communication [20]. Furthermore, intellectual activities in specific domains, such as chess [21] and recommendation systems [22], as well as scientific research activities like conducting surveys and writing papers [23,24], are becoming achievable through LLMs. In contrast to individual intelligence, which focuses on the capabilities of individual agents, collective intelligence refers to that which emerges from a group, as seen in many social insects, social animals, drones, and all other assembly robots. Collective intelligence requires the ability to process information in a distributed manner and integrate it in adaptive ways [25]. The field of LLM-based multi-agents has seen explosive growth in recent years, with researchers exploring various approaches to agent architectures and interaction paradigms [26,27,28,29,30]. Other-agent cognition and social reasoning abilities in groups of LLM agents have been verified [31,32], and autonomous cooperation between agents has been reported [33]. Additionally, studies have shown that evaluations from LLM agents with diverse perspectives improve group performance [34], and discussions are ongoing about cooperative tasks in settings where agents engaging in deceptive debates are mixed into the group [35]. From a practical application standpoint, research is being conducted on achieving accurate and lengthy code generation through multi-agent systems [36,37], and studies have shown that multi-agent models are effective in handling long contexts [38]. Furthermore, it has been reported that methods for generating groups of LLM agents while maintaining diversity can achieve high scores across various tasks [39]. While these recent works have demonstrated capabilities in task-oriented agent systems [40], the fundamental question of how agent individuality and social behaviors emerge from collective interactions remains understudied. In this context, investigating the mechanisms through which collective intelligence emerges from LLM-based agents contributes to understanding their behavioral dynamics and underlying processes. Recently, researchers have been recreating markets through group simulations of LLM agents with various personas [41], and conducting large-scale LLM agent group simulations [42]. These studies on creating artificial societies using LLM agents originated from a research known as Generative Agents [43]. Generative Agents simulated by Stanford University and DeepMind start simulating the emergence of complex and rich collective behavior, such as scheduling daily tasks, planning parties, and so on. Using this Generative Agents framework, societies in different domains have been simulated, such as a software company [44], a translation and publishing company [45], a hospital [46], and so on. In these Generative Agent set ups, the personality of each agent was assigned initially and fixed overtime. Recently we proposed the Community First theory [47], based on the studies of actual animal communities; the gathering of agents comes first, then the evolution of individuality follows in the collective. Instead of preparing individual diversity in advance, we see how individuality emerges from a conversation among agents. Group communication and the resulting behavioral complexity will be analyzed in detail. The emergence of social norms and behavioral patterns in agent communities has been studied extensively [48,49], but the role of language-based interactions in this process present new research opportunities. In this paper, we show that (i) LLM agents differentiate behavior, emotions, and personality types through interactions with other LLM agents, (ii) these differentiations vary with spatial scale, (iii) LLM agents spontaneously generate hallucinations and hashtags, and (iv) by sharing these hallucinations, they start using a wider variety of words in their conversations. 2. LLM Agents Simulation 2.1. Simulation Environment We prepare 10 LLM agents in a 50×50 grid two-dimensional space (Figure 1) with a periodic boundary condition. The initial positions of the agents are assigned randomly. These LLM agents can move freely in this space and send messages to each other. It should be noted that LLM agents are homogeneous in the sense that they have no initial personality or memories. To examine how the individuality emerges in this society is our main purpose of this study. 2.2. LLM Based Agent The LLM agents are expected to perform three actions in each time step:Send messages to other nearby agents;Store a situational summary of their own recent activities;Choose the next movement from (“x+1”, “x-1”, “y+1”, “y-1”, “stay”). Send messages to other nearby agents; Send messages to other nearby agents; Store a situational summary of their own recent activities; Store a situational summary of their own recent activities; Choose the next movement from (“x+1”, “x-1”, “y+1”, “y-1”, “stay”). Choose the next movement from (“x+1”, “x-1”, “y+1”, “y-1”, “stay”). The above three instructions are given in the form of the “prompt” shown in Figure 2. The three prompts commonly include each agent’s current state, instructions, and the agent’s memory (situational summary). Additionally, the prompts for generating messages and memories also include all messages received from the nearby agents. These prompts have up to two “[ ]”: one contains memories generated by the agent itself in the previous step, and the other contains all messages generated by agents within message reach during that step. Through these prompt embeddings, the agent keeps its previous step memories and receives messages. All prompts also include the agent’s own name (agent ID) and its own coordinates. We used the Llama 2 model (Llama-2-7b-chat-hf) [50] released by Meta in July 2023 as the LLM in this study. Llama 2 is an open-source program, and in addition to pretraining on a large corpus, it has undergone reinforcement learning from human feedback (RLHF). As a result, it achieves top scores among currently published LLMs for English text responses. The main parameters related to the LLM are shown in Table 1. The LLM agents receive messages from their surrounding agents. In practice, each one receives messages from other LLM agents within a distance of up to five Chebyshev distances centered on the agent’s own position. If there are no agents within the range and no messages was delivered, it receives “No Messages” messages from a system. All agents share and use a single common LLM. No context is shared internally in the LLM among agents. The initial differences between individual agents comes from their spatial positions, as shown in Figure 1. When an agent’s position changes, the description of its current state in the prompts shown in Figure 2 also changes. If there are other LLM agents nearby, the messages received from those agents are included in the prompt. As a result, the LLM’s responses change, which generates different actions and memories for each agent. Instead of predetermining personalities, the interactions within the group will generate different personalities. 2.3. Simulation Step The simulation was conducted for several time steps, and we recorded the coordinates, generated messages, memory, and movement commands of each LLM agent at each step. Within a single step, the following six procedures, as shown in Figure 3, are performed. First, all LLM agents generate new messages based on their own memory and the messages received from their surroundings. Next, for all LLM agents, it is checked whether other LLM agents within the range mentioned in the previous section have sent messages, and if there are any, they are received. The received messages are embedded in prompts from this point until the next message reception. Then, all LLM agents generate and update their own memory based on their own memory and the messages received from their surroundings. The memory is instructed to generate a summary of the situation. After the memory update phase, the messages become embedded in all prompts until the next memory update. Subsequently, all LLM agents generate movement commands from their own memory (summary of the situation). The movement commands generated in natural language are converted to either movement in the right, left, up, or down direction (“x+1”, “x-1”, “y+1”, “y-1”) or staying still (“stay”), and the LLM agents act according to those movement commands. 3. Results and Analysis 3.1. Differentiation of Generated Behaviors Move commands are not equally generated (Figure 4); there is a bias in the actions generated by the LLM agents. This bias could be attributed to various factors, such as the training data and architecture of the LLM, the prompts given to the agents, or the setup of the simulation environment. (This bias of move commands was observed not only in Llama 2, but also in GPT-4. It was also found that some actions were generated more frequently when the movement command was set to “right”/“left”/“up”/“down” and when the command was set to “east”/“west”/“north”/“south” respectively). Further investigation is needed to identify the primary sources of this bias and develop strategies to mitigate it. In this simulation, content generation bias remains constant across all agents, as they are based on the same Llama 2 model. Under this condition, we focus on how generated behaviors are characterized for each agent. We also investigated when and where the “stay” command was generated (Figure 5). The trajectory of each agent is shown in a different color, with their initial positions marked by circle and the positions where the “stay” command was generated marked by cross. In the timeline data of each agent’s “stay” command generation, the background colors represent the clusters to which the agents belong at each time step. Agents sharing the same color belong to the same cluster at that time step. For cluster analysis of agent groupings, we used DBSCAN [51]. DBSCAN remains effective and practical when used with appropriate parameters and spatial indices [52], particularly for cases requiring clear density-based cluster identification. The DBSCAN algorithm [51] forms clusters based on the density of data points. First, if a point has at least MinPts points within its neighborhood (radius Eps), these points are registered as a cluster. The process is then repeated for each point in the cluster, adding all density-reachable points to the cluster. Finally, points that do not belong to any cluster are classified as noise. DBSCAN suits this research, as it allows clustering based on message exchange distances. We set MinPts = 1 and Eps = 5 Chebyshev distance (message reach range), clustering agents together when they are within each other’s message reach range. The analysis showed that there are agents that frequently generate “stay” commands, and agents that do not. Agents 0, 1, 2, 9, etc. frequently generate “stay” commands, while Agents 3 and 7 do not. Agents 5 and 8 also do not generate “stay” commands until they were aggregated, and then they generate “stay” commands after they were aggregated. Agent 9 clustered in the first step, and has not clustered since then, but generates “stay” commands frequently. These results suggest that agents with clustering experience generate “stay” commands, while agents without clustering experience do not generate “stay” commands. Many “stay” commands are generated at the points where the agents’ trajectories intersect. 3.2. Differentiation of Generated Memories and Messages Agents’ states and behaviors are most reflected on their messages and memories. To analyze them, we used Sentence-BERT [53] to transform the agent’s memory string and the agent’s message string at each step into vectors. They were compressed and embedded into a two-dimensional space using Uniform Manifold Approximation and Projection (UMAP) [54]. Comparing (A) and (B) in Figure 6, memory as an agent’s internal state is distributed, while messages generated by agents are similar. Messages with close content were generated by agents exchanging messages in the same cluster. When an agent’s message is generated, the agent’s memory is the source of its generation, but it is also the input for the message that the surrounding agents have given. In other words, messages, unlike memories, are open sources of information that are sent to and received from outside the agent. It is suggested that messages, as an open source of information, easily self-organize when agents group together, while memories, as a closed source of information, are less likely to self-organize. 3.3. Communication and Hallucination One of the advantages of LLM agents is that we can analyze their behavior by Natural Language Processing (NLP) analysis. In order to obtain a dynamic picture of the content of messages generated by agents, we performed a word cloud analysis (Figure 7), which extracts up to 100 frequent words in the messages generated throughout all steps for each agent. The larger the font size, the more frequent the word is used. It is clear that each agent generates messages with different content. Some of the agent groups have similar structures, e.g., Agents 0, 1, 2, and 8 generate the word “field” more frequently, while Agents 2 and 6 generate the word “think” more frequently. It is noteworthy that there are several occurrences of words that are not mentioned in the LLM agent prompts, and are unrelated to the content of the prompts. For example, Agent 6 frequently produces the word “hill”, and Agent 9 frequently produces the word “cave system”. Such content deviating from the prompt input is called a hallucination in the LLM [55]. In the context of this study, hallucination refers to the generation of contents that are not explicitly present in the prompts or the simulated environment. This phenomenon is significant, as it highlights the potential for LLM-based agents to introduce novel, unintended ideas, which could either enhance creativity or introduce challenges in ensuring accuracy [56]. In this 2D experimental environment, since no objects were placed initially, we defined “words about features or objects in the environment” as hallucinations, and counted their occurrences by inputting this definition and agent-generated messages into GPT-4o [57]. In the word cloud analysis (Figure 7), we can see which words frequently appear; however, these may simply be words used in the prompt. To focus on the dynamics of truly newly generated words, it is beneficial to examine hallucinations. Using hallucinated words extracted by GPT, we aim to analyze the flow of information within the community. Interestingly, the analysis of LLM agents’ conversation content revealed that hallucinations were transmitted and spread within the community. We can see that the spread of four representative examples of hallucinations: “cave”, “hill”, “treasure”, and “trees” (Figure 8). The plot of each icon represents the timing of the appearance of that hallucination. We see the relationship between the state in which an agent belongs to a cluster and the occurrence of hallucinations. In addition to the spread of hallucinations, we also observed the emergence and propagation of hashtags among the LLM agents (Figure 9). Interestingly, the use of hashtags originated from a single agent and then spread to other agents within the same cluster. For example, Agent 0 introduced the three hashtags “#agent0”, “#cooperation”, and “#competition” in step 1, which were subsequently adopted by Agent 1 in the same cluster. The hashtags were then used in the cluster until step 34, and the same hashtags were adopted by Agent 8, who joined the cluster in the process. The emergence and propagation of hashtags among the LLM agents suggest their ability to develop and share common themes or topics within their conversations, which can be interpreted as a form of social norm formation. This phenomenon emphasizes the potential for collective behavior and the development of shared narratives among the agents, even without explicit instructions or predefined rules governing their interactions. The shared use of hashtags represents an example of the formation of a common language or behavioral norms within the group, serving as a basis for the agents to engage in collective behaviors. 3.4. Sentiment Analysis and Personality Assessments As Marsella et al. [58] argue, emotions are crucial for realistic agent behavior, so we tracked the emotional state of LLM agents. Since the messages uttered by the agent are in natural language, emotion extraction can be performed by natural language analysis. We used a BERT-base-uncased-emotion model [59] to extract the emotions contained in the messages uttered by the agent at each step. In this model, when a natural language sentence is input, six degrees of emotional intensity can be obtained: Sadness, Joy, Love, Anger, Fear, and Surprise. We evaluated how each agent’s six emotions changed throughout the simulation (Figure 10). Overall, it can be seen that the agents’ emotions are high in Joy. If we look at Agents 0 and 1, which belong to the same cluster, there are several areas where Joy decreases and Fear increases synchronously. On the other hand, Agents 2, 4, and 6 also belong to the same cluster, but they do not experience the same synchronous changes as Agents 0 and 1. In other words, depending on the cluster, the emotions of LLM agents may or may not be affected synchronously. Some agents showed different emotional expression than others, such as Agent 4 with Love rising around step 90, Agent 5 with Sadness rising in some places, and Agent 6 with Anger rising around step 50. Similar to human psychological experiments, several personality tests have shown that LLM personality can be classified by administering QA-type tests to LLMs [60,61,62]. We used the Myers–Briggs Type Indicator (MBTI) [63] test to analyze whether the personality of each LLM agent changed throughout the simulation. The MBTI test is a method that uses 93 questions to classify 16 personality types. The MBTI personality factors are made up of four scales: Extraversion/Introversion (E/I), Sensing/Intuition (S/N), Thinking/Feeling (T/F), and Judging/Perceiving (J/P). We tested the MBTI on the LLM agent in the initial state and on the LLM agent after all simulation steps, using the methodology of prior studies that have conducted MBTI tests on a variety of LLMs [60]. For the prompts as input to the LLM agents, we used the part of the instruction for each LLM agent’s movement generation prompt shown in Figure 2, replacing the 93-choice type questions provided in the previous study. These question items were, for example, “A. Do you often act or speak very quickly without thinking?” or “B. Do you often act according to reason, think logically, and then make a decision, not letting your emotions interfere with the decision?” which asked for a choice of A or B. Table 2 summarizes the results for each LLM agent for the MBTI type in the initial state (at step 0) and the MBTI type at the end state (at step 100). Figure A3 in the Appendix B also shows more detailed MBTI test results. In the initial state at step 0, only Agent 9 is an INTJ type, all other agents are INFJ types. This is mostly consistent with the results of the MBTI test conducted on various LLMs in a previous study, which showed that the MBTI type of Llama2 was INFJ type [60]. Initially in step 0, all agents are listed in the prompt as “no memory”, and the only difference between agents is their name and initial position in the “Current state of each agent itself” section of Figure 2. These factors could be the reason why only Agent 9 differed in MBTI type. In fact, from Figure A3, Agents 0 through 7 gave the same answers to all questions, but Agents 8 and 9 gave slightly different answers to the questions corresponding to T/F than the other agents. Since the E/I, S/N, and T/F items are overall neutral around 50%, it is likely that the slight difference in responses led to the differences in the final type decisions. On the other hand, the results at step 100 showed that the agents had differentiated into five distinct MBTI types: ESFJ, ISTJ, ENTJ, ESTJ, and ISFJ. The most common types were four ISTJ types and three ENTJ types. The ISTJ type, also called inspector type, tend to be modest and practical, but loyal, orderly, and traditional. On the other hand, the ENTJ type, also called the commander type, is outspoken, confident, and good at planning and organizing projects through leadership. This differentiation into broadly leader-like and follower-like personalities suggests that the agents may have naturally taken on different roles within the group dynamics. In Appendix B, we see that agents of the same MBTI type did not give exactly the same responses (Figure A3). In other words, all agents acquired different personality traits. These personality differences among the agents emerged naturally as a result of their interactions and experiences within the simulation. The agents, who had nearly identical personalities in the initial state, developed their own unique personality traits through communication within the group. This finding implies that in multi-agent simulations using LLMs, individuality can emerge through interactions between agents, even without predefined personalities. It also demonstrates that group dynamics can influence the development of individual agents’ personalities. 3.5. A Phase Transition in Agent Behavior We investigated how a spatial scale influence the agent dynamics. We analyzed and summarized the distribution of generated movements, cumulative progression of unique hashtag generation, hashtag lifespan, message proximity, and differentiation of MBTI personality types as a function of spatial scale (Figure 11). Each range condition was tested ten times. The overall trend of moving towards the upper right in the generated movement patterns did not significantly change with spatial variations. However, notable characteristics were observed in the “stay” behavior. Stationary behavior is considered an effective strategy for remaining in place to exchange messages with others. The results show that agents rarely exhibited “stay” behavior when unable to exchange messages with others (range 0), while frequently generating “stay” behavior under conditions where message exchange was possible (ranges 5 to 25). Interestingly, increasing the range did not necessarily lead to more “stay” behavior; excessively wide ranges actually made it less likely for “stay” behavior to occur. This suggests that appropriate bounded rationality induces stationary behavior, while broadcast messages have a weaker ability to halt the movement of others. The growth rate of unique hashtags and the lifespan of hashtags are also influenced by the limitations in message reach. Notably, under conditions where all messages are broadcast, there is minimal emergence of new hashtags. Furthermore, regarding hashtag lifespan, in the ‘range 0’ condition where no message exchange occurs with surroundings, hashtags disappear quickly. In conditions where message exchange is possible, the more limited the range, the more likely it is for long-lasting hashtags to appear. This indicates that hashtags are used for communication within spatially constrained environments and have a tendency to survive longer within the context of message exchanges in these spatially limited contexts. Focusing on the similarity of messages generated by agents, we observe that as the range of message exchange expands, the diversity of generated topics increases. Simultaneously, the variance of messages within each topic among agents decreases. This suggests that broader communication ranges lead to a wider array of topics being discussed, while also promoting greater consensus or similarity in how agents express themselves within each topic. Finally, examining the MBTI personality types, we find that ENTJ remains the most popular personality type across all conditions. However, in conditions where message exchange is possible, there is a greater number of differentiated personality types compared to the condition where no messages are exchanged (range 0). This suggests that communication facilitates a broader diversity of personality expressions within the agent population. As the spatial scale for message exchange expanded, message diversity increased, showing different trends in the emergence of hashtags and hallucinations (Figure 12). While the number of hallucinations increased with spatial scale, the number of unique hashtags decreased as the underlying message content grew more diverse. Hallucinations may serve as a mechanism for agents to maintain creative and diverse conversations even when communicating across larger distances. This contrasts with hashtags, which decreased in frequency with increasing spatial scale, indicating their different functional roles in agent communications. 4. Discussion and Conclusions In this study, we conducted a multi-agent simulation using LLM-based agents to investigate the emergence of personality and the collective behaviors without predefined personalities or initial memories. The simulation involved 10 homogeneous LLM agents interacting with each other in a 2D space over the course of 100 steps. The LLM agent generates messages, memories, and movements based on its own memories and messages from other agents, which are embedded in three prompts (Figure 2). The simulation execution time for 10 agents over 100 steps was approximately 6 h (using an A100 GPU). Since this computation time increases proportionally with the number of agents and the number of steps, computational optimizations such as parallelization would be necessary when conducting simulations with large-scale populations or over extended steps. The results showed that the agents’ spatial positioning and interactions led to the differentiation of their behaviors (Figure 5), memories (Figure 6A), and messages (Figure 6B and Figure 7). Despite using the same LLM, agents developed unique characteristics, such as the frequency of generating rare actions like “stay” commands, which was influenced by their clustering experiences (Figure 5B). The agents’ internal state, memory, is distributed, while the message as its representation is biased (Figure 6). Messages, unlike memories, are open sources of information that are sent to and received from outside the agent. This suggests that messages, as an open source of information, more readily self-organize when agents are grouped together, while memories, as a closed source of information, are less likely to self-organize, even when agents are clustered. Sentiment analysis revealed that the synchronicity of emotions varied among agent clusters, with some agents exhibiting distinct emotional expressions (Figure 10). The study also observed the emergence and propagation of synchronized emotions, hallucinations, and hashtags within agent clusters, demonstrating the formation of shared narratives among agents when they are grouped together. These findings suggest that agent interactions within clusters can lead to the development of collective emotional states and the spread of common themes or topics, even without explicit instructions or predefined rules governing their interactions. Additionally, we observed the emergence of hallucinations and hashtags as mechanisms for social norm formation within the agent community (Figure 8 and Figure 9). Social norms are often highlighted as one mechanism for maintaining cooperation in the absence of formal institutions or enforcement frameworks [64,65]. In our simulation, these norms emerged spontaneously, as we imposed no specific tasks or constraints on the agents. As the spatial scale and communication range expanded, the diversity of agent messages increased (Figure 12). Our analysis indicates that hallucinations contributed to maintaining this message diversity and creativity in agent communications. While hashtags functioned as a summarization mechanism for these messages, their effectiveness decreased with increasing message diversity, demonstrating a limitation in their capacity to capture varied conversations. Personality assessment using the MBTI test showed that the agents, initially having nearly identical personalities, differentiated into distinct personality types through their group interactions (Table 2). This suggests that personality traits such as extroversion and introversion develop spontaneously in this agent society. These findings demonstrate that in multi-agent LLM simulations, individuality and collective behaviors can emerge through agent interactions, even without predefined individual characteristics. Although all agents start from the same initial state, their personalities diverge through interactions, similar to MBTI test results. Even agents classified under the same MBTI type do not produce identical statements. This can be understood as a phenomenon of personality differentiation through interaction, rather than a sensitivity to initial conditions like in dynamical systems. In the future, we can expect further personality differentiation by dramatically increasing the number of agents and preparing more complex environments. Moreover, previous game theory and agent models could not handle the complexity of the real world because they could not generate decision-making processes that account for the historical and customary cognitive dependencies of past societies. Only with the emergence of LLM-based agent models has it become possible to handle decision-making based on historical context in a more flexible manner.