Reimagining Self-Adaptation in the Age of Large Language Models (2024)

Raghav Donakanti, Prakhar Jain, Shubham Kulkarni, Karthik VaidhyanathanSoftware Engineering Research Center, IIIT Hyderabad, India
raghav.donakanti@students.iiit.ac.in, prakhar.jain@research.iiit.ac.in, shubham.kulkarni@research.iiit.ac.in,
karthik.vaidhyanathan@iiit.ac.in

Abstract

Modern software systems are subjected to various types of uncertainties arising from context, environment, etc. To this end, self-adaptation techniques have been sought out as potential solutions. Although recent advances in self-adaptation through the use of ML techniques have demonstrated promising results, the capabilities are limited by constraints imposed by the ML techniques, such as the need for training samples, the ability to generalize, etc.Recent advancements in Generative AI (GenAI) open up new possibilities as it is trained on massive amounts of data, potentially enabling the interpretation of uncertaintiesand synthesis of adaptation strategies.In this context, this paper presents a vision for using GenAI, particularly Large Language Models (LLMs), to enhance the effectiveness and efficiency of architectural adaptation.Drawing parallels with human operators,we propose that LLMs can autonomously generate similar, context-sensitive adaptation strategies through its advanced natural language processing capabilities. This method allows software systems to understand their operational state and implement adaptations that align with their architectural requirements and environmental changes.By integrating LLMs into the self-adaptive system architecture, we facilitate nuanced decision-making that mirrors human-like adaptive reasoning. A case study with the SWIM exemplar system provides promising results, indicating that LLMs can potentially handle different adaptation scenarios.Our findings suggest that GenAI has significant potential to improve software systems’ dynamic adaptability and resilience.

Index Terms:

Self-Adaptation, Software Architecture, Generative AI, LLM, Software Engineering

I Introduction

Software systems face uncertainties, such as componentfailures and variable user requests, affecting their Quality ofService (QoS). Over the years, self-adaptation has emerged asa potential solution to mitigate the uncertainties [1].

Off late, with advancements in computing and AI in general. Machine Learning (ML) has emerged as a key solutionfor self-adaptation [2], utilizing large datasets to identifypatterns and predict future states, thus enabling dynamic struc-ture/behavioral adjustments. Despite its benefits, ML’s applica-tion in self-adaptation requires extensive data and a thoroughunderstanding of ML principles. The rise of Generative AI(GenAI), especially through Large Language Models (LLMs),marks significant progress in this direction [3]. LLMs enhancemachine understanding and human-like text generation capa-bilities, showcasing their utility in diverse areas, especially forcomplex decision-making given adequate context [3, 4].

The concept of autonomic computing, as proposed byKephart and Chess [5], sought to enhance the autonomy ofsoftware systems through various strategies. Despite theseefforts, a persistent challenge has been the ability of systemsto dynamically generate new configurations and components.The advent of GenAI, particularly the capabilities of LLMs,introduces the possibility of developing adaptation strategiesdirectly. This is supplemented by the fact that modern softwaresystems generate vast amounts of data, including logs, metrics,and traces, which system administrators traditionally leveragefor tasks such as root cause analysis and resource allocation.This data, encompassing code, APIs, JSON, XML, and more,can be converted into various natural language formats, en-abling Large Language Models (LLMs) to interpret the dataand generate adaptive responses akin to those formulated byhuman experts. To this end, this paper introduces an innovativeframework, MSE-K (Monitor, Synthesize, Execute) that inte-grates Large Language Models (LLMs) into the self-adaptationprocess, enabling software systems to autonomously generateand implement contextually relevant and actionable architec-tural adaptation strategies aligned with their operational goals.This approach seeks to overcome the limitations of currentself-adaptation mechanisms, paving the way for more efficientand intelligent software systems [6].

As an initial validation, we performed evaluations of ourapproach on SWIM [7], an exemplar for simulating webinfrastructure through well-defined interfaces for monitoringruntime metrics and executing adaptation strategies. Our initialresults indicate that incorporating LLMs into self-adaptivesystems has immense potential to improve the self-adaptabilityof software systems and thereby guarantee performance in theevent of uncertainties.

II Related Works

The integration of machine learning into self-adaptive systems has marked a significant advance in the field of software engineering.Gheibi et al. [2] have highlighted the use and key challenges of engineering ML-based adaptive systems. Approaches based on reinforcement learning for planning and adapting software systems were introduced in [8] and [9]. [10] combines ML for adaptation pattern selection and quantitative verification for decision feasibility. [6] emphasizes the bidirectional relationship between self-adaptation and AI to manage unanticipated changes. [11] proposes a novel approach to self-adaptation by integrating a lifelong ML layer into self-adaptive systems that use ML techniques, enabling dynamic tracking and updating of their learning models. This paper builds on existing research on integrating AI into self-adaptive systems by exploring the transformative potential of Generative AI, especially Large Language Models (LLMs), for managing uncertainties and devising adaptive strategies. It demonstrates LLMs’ potential to improve decision-making in architectural adaptation.

III LLM-Based Architecture for Self-Adaptation

The approach, as represented in Fig. 1, conforms to the conceptual model of a self-adaptive system. It consists of two subsystems, namely the Managed System and Managing System.The Managed System represents the operational software system equipped with probes for ongoing QoS monitoring and effectors for implementing adaptations.

The Managing System is responsible for handling the adaptations. It consists of different components that implement the adaptation control loop, similar to MAPE-K[5]. However, in a traditional MAPE-K-based control loop of adaptation, the analyze phase is responsible for constantly analyzing various aspects of the system to identify any possible deviations from the adaptation goals. Such deviation triggers the plan phase, which generates adaptation decisions. In our approach, the analyze and plan phases are abstracted by the Synthesize phase, which leverages LLM to interpret and generate adaptation decisions. This stems from the fact that modern-day LLMs have the ability to interpret information and further generate adaptation decisions. Hence, we envision an MSE-K loop as represented in Fig. 1. The rest of the section details the different components of the managing system.

Monitor: The monitor as in the case of the traditional MAPE-K approach is responsible for continuously monitoring the running software system. In our approach, the monitor activity is exploited to monitor and collect the system logs as well as the QoS metrics of the software system. To this end, it consists of two components logs collector, which is responsible for collecting the system logs and ametric collector, which collects different QoS metrics like response time, CPU utilization, etc. These data together form the context data, C𝐢Citalic_C, that represents the running state of the system at a given instant of time t𝑑titalic_t. Further, these data are ingested into the Knowledge base for further processing and future use.

For instance, with respect to our case study on SWIM, the context data, C𝐢Citalic_C is a set, such that C={Dt,A⁒St,Ut,Rt,A⁒Rt,t}𝐢subscript𝐷𝑑𝐴subscript𝑆𝑑subscriptπ‘ˆπ‘‘subscript𝑅𝑑𝐴subscript𝑅𝑑𝑑C=\{D_{t},AS_{t},U_{t},R_{t},AR_{t},t\}italic_C = { italic_D start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_A italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_U start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_R start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_A italic_R start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_t } where Dt,A⁒St,Ut,Rt⁒a⁒n⁒d⁒A⁒Rtsubscript𝐷𝑑𝐴subscript𝑆𝑑subscriptπ‘ˆπ‘‘subscriptπ‘…π‘‘π‘Žπ‘›π‘‘π΄subscript𝑅𝑑D_{t},\,AS_{t},\,U_{t},R_{t}\;and\;AR_{t}italic_D start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_A italic_S start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_U start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_R start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_a italic_n italic_d italic_A italic_R start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT represent dimmer value, active servers, server utilization. average response time and arrival rate at time t𝑑titalic_t respectively.

Knowledge/Memory: The Knowledge acts as a central storage for different types of knowledge required by different components of the managing system for performing the adaptations. It stores four types of information: i) Conversation History which comprises tuples of past context data (C𝐢Citalic_C) and adaptation decision (A⁒D𝐴𝐷ADitalic_A italic_D) pairs. Hence the conversation history at timestep t𝑑titalic_t, Ht=[(C1,A⁒D1),(C2,A⁒D2)⁒…⁒(Ct,A⁒Dt)]subscript𝐻𝑑subscript𝐢1𝐴subscript𝐷1subscript𝐢2𝐴subscript𝐷2…subscript𝐢𝑑𝐴subscript𝐷𝑑{H_{t}}=[(C_{1},AD_{1}),(C_{2},AD_{2})\ldots(C_{t},AD_{t})]italic_H start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT = [ ( italic_C start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_A italic_D start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) , ( italic_C start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT , italic_A italic_D start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) … ( italic_C start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_A italic_D start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT ) ]. The conversation history is updated with Ctsubscript𝐢𝑑C_{t}italic_C start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT and A⁒Dt𝐴subscript𝐷𝑑AD_{t}italic_A italic_D start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT at every execution of the Synthesize step.ii) Fine-tuned models consist of a set of LLMS that can be used for different tasks by leveraging the notion of multi-agents[4], where each LLM can be tasked with a role and responsibility. For instance, one LLM agent can be responsible for gathering insights from logs; another LLM agent can be responsible for interpreting and inferring information from system metrics and so on. These agents, as and when needed, can be leveraged by the LLM Engine in the Synthesize component; iii) System Config where the different configurations of the system are stored, such as the number of compute resources that are available, other hardware information, etc; iv) Prompts Consists of different system prompts that provide the LLM with instructions on how to interpret the various data and further how to generate decisions along with the objective, O𝑂Oitalic_O. They act as guidelines to ensure that the LLMs generate decisions that are relevant to the given context of a system and its objectives. Further, it also consists of a set of few-shot prompts which provide the LLM with a few examples of adaptation scenarios and the corresponding actions that need to be taken in such scenarios. These prompts further allow the LLM to learn how to generate an adaptation decision given a context. This also ensures that the LLM is more consistent when generating decisions.

For instance, in the case of SWIM, we utilize Prompts and Conversation History. Our Prompts, PS⁒W⁒I⁒Msubscriptπ‘ƒπ‘†π‘ŠπΌπ‘€P_{SWIM}italic_P start_POSTSUBSCRIPT italic_S italic_W italic_I italic_M end_POSTSUBSCRIPT (refer Figure 3), consist of a description of what an adaptation manager is and what actions the LLM will be capable of performing, which contextualizes the LLM in our setting. This is paired with the objective the LLM needs to optimize for, followed by a brief description of various metrics in C𝐢Citalic_C (refer Figure 2). Finally, a few-shot examples are provided.

Reimagining Self-Adaptation in the Age of Large Language Models (1)

Synthesize: The Synthesize activity encompasses the Analyze and Plan phase of the traditional MAPE-K loop by interpreting the output of the Prompt Generator, P𝑃Pitalic_P to generate the adaptation decision which is sent to the execute phase. It consists of three major components:

i) Prompt Generator: It is responsible for integrating the context, C𝐢Citalic_C into the conversation history, H𝐻Hitalic_H. It then compiles H𝐻Hitalic_H and other long-term data stored in Knowledge into a single prompt, P𝑃Pitalic_P. Overall the prompt generator pulls together everything needed for the LLM to generate a decision, P={C,H,long term data}𝑃𝐢𝐻long term dataP=\{C,H,\textit{long term data}\}italic_P = { italic_C , italic_H , long term data } Sometimes P𝑃Pitalic_P can lead to the LLMs context length being exceeded. This occurs because of how the transformer architecture can only process a finite number of tokens at once. To this, the Prompt Generator may use strategies such as summarizing past decisions or truncating older context. It is then passed to the LLM Engine.

ii) LLM Engine: Understands the prompt P𝑃Pitalic_P passed into it and generates adaptation decisions. The conversation history, H𝐻Hitalic_H gives information pertaining to how previous A⁒Dt𝐴subscript𝐷𝑑AD_{t}italic_A italic_D start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT and Ctsubscript𝐢𝑑C_{t}italic_C start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT variated through timesteps. The objective, O𝑂Oitalic_O, helps in choosing adaptation decisions that build towards it. Using this data, the LLM will be able to generate an adaptation decision A⁒D𝐴𝐷ADitalic_A italic_D (refer Figure 2) which is then pushed into H𝐻Hitalic_H and passed to Response Parser. Each A⁒D𝐴𝐷ADitalic_A italic_D may in turn consist of multiple actions.

iii) Response Parser Parses the A⁒D𝐴𝐷ADitalic_A italic_D given and formats it. This formatting is necessary since the adaptation needs to comply with the communication format of the managed system. It also extracts arguments that the managed system may need from A⁒D𝐴𝐷ADitalic_A italic_D.

For example, the P𝑃Pitalic_P that was provided at a timestep was of the form P={C,H,PS⁒W⁒I⁒M}𝑃𝐢𝐻subscriptπ‘ƒπ‘†π‘ŠπΌπ‘€P=\{C,H,P_{SWIM}\}italic_P = { italic_C , italic_H , italic_P start_POSTSUBSCRIPT italic_S italic_W italic_I italic_M end_POSTSUBSCRIPT }. The LLM generated response 1 0.8, which was further parsed by the Response Parser to produce 1111 as the adaptation action and 0.80.80.80.8 as the argument (dimmer value) for the action.





Execute is responsible for executing the adaptations on the running system. It further consists of two components. i) Verifier : which verifies the given A⁒D𝐴𝐷ADitalic_A italic_D by leveraging formal verification techniques to check quantitative properties on the system to determine if the proposed A⁒D𝐴𝐷ADitalic_A italic_D aligns with our objective. If so the Executor will execute the given A⁒D𝐴𝐷ADitalic_A italic_D otherwise Synthesizer will generate an alternative adaptation decision. ii) Executor : Once the A⁒D𝐴𝐷ADitalic_A italic_D is verified, the Executor is responsible for the execution of the A⁒D𝐴𝐷ADitalic_A italic_D within the managed system by modifying the system configuration or resources as specified by the A⁒D𝐴𝐷ADitalic_A italic_D.

For instance, if the LLM Engine decides to add a server to handle higher traffic, the Verifier first confirms this action A𝐴Aitalic_A aligns with the objectives O𝑂Oitalic_O. Upon verification, the Executor would allocate an additional server to accommodate the increased load. We have outlined the Executor phase but haven’t used the Verifier component in our approach for SWIM yet.

IV Preliminary Results and Discussion

The SWIM simulation was run in a dockerized environment, on a machine running a distribution of Ubuntu 22.04 LTS: AMD Ryzen 7 PRO 5850U at 4.5GHz and 16GB of RAM. The SWIM simulation was run with the world cup trace, starting with three servers and a dimmer value of 0.9, for the full length of the simulation (105 minutes). The adaptation manager was a python file, consisting of the interfaces to communicate with SWIM and the GPT-4 API (LLM). It interacts with SWIM through a TCP interface. Python version used for running the adaptation manager was 3.10.12.The adaptation manager runs the M⁒S⁒E𝑀𝑆𝐸MSEitalic_M italic_S italic_E loop every 200 seconds in our case. In this case, the objective given to the LLM is to keep the response time as low as possible.

Reimagining Self-Adaptation in the Age of Large Language Models (2)

Our experiment 111https://github.com/Raghav010/llm_selfAdapt involving SWIM demonstrates the potential of LLMs to enhance self-adaptation in software systems. As illustrated in Figure4, employing LLMs ensured stable response times below 0.1 seconds, even with varying workloads, achieving a utility score that exceeds a value of 2500250025002500. When compared to the traditional reactive adaptation managers in SWIM[7], which although reaching a utility score exceeding a value of 3500350035003500 struggled to maintain stable response times with spikes of more than 6666 seconds. The LLM-based adaptation manager attained a utility score that is roughly 71% of the reactive adaptation manager. An increase in requests triggered the adaptation manager to efficiently scale server resources and decrease the dimmer value, thus minimizing the response time. These results effectively address our primary objective of reducing response time, highlighting the potential of LLMs to optimize resource allocation and system performance in real-time, as well as manage system behaviour dynamically.

V Vision for the Future and Further Research

Exploring LLMs in self-adaptation marks the beginning of a promising research area with vast potential. Future efforts should focus on enhancing LLMs’ understanding of complex system dynamics. While LLMs effectively grasp the qualitative effects of adaptations on system performance, their grasp of complex equations detailing adaptation impacts is limited. Integrating knowledge infusion techniques could provide LLMs with deeper insights into system operations and effects. Expanding to multiple LLMs or multi-agent LLM architectures[4] offers scalability and improved decision-making for comprehensive software applications, potentially reducing errors and improving adaptation quality. This setup could distribute system components across LLM agents or organize them hierarchically for deeper analysis.

Addressing long context challenges in production environments might benefit from advanced technologies like MemGPT111https://github.com/cpacker/MemGPT or StreamingLLM [12], focusing on optimizing scenario storage for better adaptation strategies. Fine-tuning LLMs, particularly for domain-specific applications, and employing Reinforcement Learning using System Feedback (RLSF) to adjust model parameters based on the system objectives, represent critical areas for future research. This approach could significantly enhance LLM performance and reliability.

Another challenge is the ever-discussed issue of hallucination which may result in incorrect decisions produced by the LLM. This is where we believe that LLMs combined with formal verification techniques similar to the approach presented by Camara et al.[10] can improve the guarantees on the decisions generated.

Despite the list of aforementioned challenges, this paper underscores the transformative impact of integrating LLMs into self-adaptive systems, paving the way for more resilient, intelligent, and efficient software solutions.

VI Conclusion

In this work, we have presented a novel self-adaptation approach that makes use of an MSE-K loop for dynamic architectural adaptation by leveraging the capabilities of LLMs.Our initial findings through evaluations on an exemplar system highlight LLMs’ transformative impact on software engineering, enabling complex, human-like decision-making and strategies for software to autonomously adapt their architecture with reduced human intervention.This research sets a foundation for further exploration into LLMs’ capabilities, striving for software that is increasingly adaptive, resilient, and efficient in an ever-evolving technological landscape.

References

  • [1]D.Weyns, An introduction to self-adaptive systems: A contemporarysoftware engineering perspective.John Wiley & Sons, 2020.
  • [2]O.Gheibi, D.Weyns, and F.Quin, β€œApplying machine learning in self-adaptivesystems: A systematic literature review,” ACM Trans. Auton. Adapt.Syst., vol.15, no.3, aug 2021. [Online]. Available:https://doi.org/10.1145/3469440
  • [3]X.Hou, Y.Zhao, Y.Liu, Z.Yang, K.Wang, L.Li, X.Luo, D.Lo, J.Grundy, andH.Wang, β€œLarge language models for software engineering: A systematicl*terature review,” arXiv preprint arXiv:2308.10620, 2023.
  • [4]Q.Wu, G.Bansal, J.Zhang, Y.Wu, S.Zhang, E.E. Zhu, B.Li, L.Jiang,X.Zhang, and C.Wang, β€œAutogen: Enabling next-gen llm applications viamulti-agent conversation,” Microsoft, Tech. Rep., August 2023.
  • [5]J.Kephart and D.Chess, β€œThe vision of autonomic computing,”Computer, vol.36, no.1, pp. 41–50, Jan 2003.
  • [6]T.BureΕ‘, β€œSelf-adaptation 2.0,” in 2021 International Symposium onSoftware Engineering for Adaptive and Self-Managing Systems (SEAMS), May2021, pp. 262–263.
  • [7]G.A. Moreno, B.Schmerl, and D.Garlan, β€œSwim: an exemplar for evaluation andcomparison of self-adaptation approaches for web applications,” inProceedings of the 13th International Conference on SoftwareEngineering for Adaptive and Self-Managing Systems, ser. SEAMS ’18.New York, NY, USA: Association for ComputingMachinery, 2018, p. 137–143. [Online]. Available:https://doi.org/10.1145/3194133.3194163
  • [8]D.Kim and S.Park, β€œReinforcement learning-based dynamic adaptation planningmethod for architecture-based self-managed software,” in 2009 ICSEWorkshop on Software Engineering for Adaptive and Self-Managing Systems, May2009, pp. 76–85.
  • [9]H.N. Ho and E.Lee, β€œModel-based reinforcement learning approach for planningin self-adaptive software system,” in Proceedings of the 9thInternational Conference on Ubiquitous Information Management andCommunication, ser. IMCOM ’15.NewYork, NY, USA: Association for Computing Machinery, 2015. [Online].Available: https://doi.org/10.1145/2701126.2701191
  • [10]J.CΓ‘mara, H.Muccini, and K.Vaidhyanathan, β€œQuantitative verification-aidedmachine learning: A tandem approach for architecting self-adaptive iotsystems,” in 2020 IEEE International Conference on SoftwareArchitecture (ICSA), March 2020, pp. 11–22.
  • [11]O.Gheibi and D.Weyns, β€œLifelong self-adaptation: self-adaptation meetslifelong machine learning,” in Proceedings of the 17th Symposium onSoftware Engineering for Adaptive and Self-Managing Systems, ser. SEAMS’22.New York, NY, USA: Associationfor Computing Machinery, 2022, p. 1–12. [Online]. Available:https://doi.org/10.1145/3524844.3528052
  • [12]G.Xiao, Y.Tian, B.Chen, S.Han, and M.Lewis, β€œEfficient streaming languagemodels with attention sinks,” 2023.
Reimagining Self-Adaptation in the Age of Large Language Models (2024)
Top Articles
Latest Posts
Article information

Author: Lilliana Bartoletti

Last Updated:

Views: 5659

Rating: 4.2 / 5 (73 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Lilliana Bartoletti

Birthday: 1999-11-18

Address: 58866 Tricia Spurs, North Melvinberg, HI 91346-3774

Phone: +50616620367928

Job: Real-Estate Liaison

Hobby: Graffiti, Astronomy, Handball, Magic, Origami, Fashion, Foreign language learning

Introduction: My name is Lilliana Bartoletti, I am a adventurous, pleasant, shiny, beautiful, handsome, zealous, tasty person who loves writing and wants to share my knowledge and understanding with you.