WorksComputer Science
Building LLM Agent Systems the Deep Learning Way: From Modular Design to Architecture Search
Abstract
Large Language Models (LLMs) have revolutionized AI research and enabled exciting agent systems. To build a complex LLM agent system, most existing research relies on insights from other domains or heuristics to manually build the agent system. However, this approach often requires heavy hand-engineering and fails to fully optimize for the downstream task of interest. Inspired by the tremendous success of deep learning, we propose to construct LLM agent systems in a modular manner, similar to building a deep neural network. Our key insight is to make analogies between LLM building blocks, such as retrievals, memories, and prompting strategies, and the successful deep learning modules, such as MLPs, attention, and recurrent modules. We further design forward inference and feedback mechanisms for LLMs, where prompts in LLMs are considered as the weights in deep models, and the prompt optimization from feedback is analogous to the back-propagation algorithm. We additionally leverage a search algorithm to search for the best configuration of LLM agent systems, similar to the neural architecture search (NAS) in deep learning research. Comprehensive experimental results demonstrate that the proposed deep learning recipe for LLM agent systems is highly effective, in particular: (1) Organizing LLM modules into deep-learning-style architectures yields noticeable performance gain; (2) Automatic prompt optimization, equivalent to backpropagation, is efficient in incorporating feedback from the task of interest and achieves at least 5% performance improvement; (3) NAS equivalent algorithm works well for further optimizing the LLM agent system architecture with 11% performance gain compared with randomly designed architectures. Overall, our research demonstrates the exciting opportunity of transferring the success of deep learning to building LLM agent systems.
Introduction
Large Language Models (LLMs) have demonstrated remarkable potential in achieving Artificial General Intelligence (AGI) due to their impressive planning and reasoning abilities [49, 7], which has sparked an upsurge in studies investigating sophisticated LLM agent systems [57, 47, 29]. LLM agent systems usually involve various LLM building blocks [27, 52, 41, 28, 14], such as retrieval [35, 13, 22], memory modules [57, 47], and prompting strategies [53]. We argue that the success of LLM agent systems relies on the integration of multiple LLM modules [57, 40, 48], which still receives limited attention from the community. Therefore, our paper aims to raise attention to the pressing research question: how to effectively and automatically construct LLM agent systems based on basic building blocks.
Constructing effective LLM agent systems often involves leveraging insights from various disciplines, such as neuroscience [51, 38, 20] and computer architecture [27, 40]. For example, MEMGPT [27] draws inspiration from hierarchical memory systems in traditional operating systems to construct an LLM agent system with several manually designed LLM building blocks. However, applying such interdisciplinary insights to LLM agent system construction has the following shortcomings: (1) The approach is often domain-specific and not generic, requiring heavy manual designs; (2) Designing the LLM agent system necessitates extensive trial and error, making the process both costly and inflexible.
The tremendous success of Deep Learning (DL) has brought us a new perspective on solving the above problems. In the area of DL, researchers have proposed various basic modules such as Recurrent Neural Network (RNN) [21, 36, 16] and Attention Network [45, 6, 11] to process various tasks. Constructing the basic modules into complicated architectures like Transformer [44, 10] and further leveraging the forward and back propagation [15, 3] to train such architectures have further contributed to the success of DL in tackling complex real-world applications.
Inspired by the success of DL, we propose to design LLM agent systems with a Deep Learning recipe. Our approach involves defining building blocks of LLMs analogous to the DL modules, constructing LLM agent systems similar to defining NN architectures, and developing the prompt optimization algorithm of LLMs similar to the backpropagation algorithm. Specifically, we explore LLM modules including: (1) vanilla LLM as a single layer MultiLayer Perceptron (MLP) [31]; (2) Memory processer [55, 27] as an RNN; (3) Retrieval [35, 13, 22] as an attention network [45, 6, 11]; (4) prompting strategies [2, 53] as Graph Neural Networks (GNNs) [56, 37, 17]. Based on the defined LLM modules, we could construct more complex LLM agent systems by referencing successful DL architectures, notably, Transformer [43]. Furthermore, we design a meta prompt module similar to the training parameters in DL to guide the forward inference, and a feedback-propagation module that incorporates the external feedback and iteratively updates the meta prompt similar to the backpropagation algorithm. We additionally leverage a search algorithm to search for the best configuration of LLM agent systems, similar to the neural architecture search (NAS) [23] in DL research. In summary, our main contributions are as follows:
The first work to investigate constructing LLM agent systems from the DL perspective and recipe, extending the science and engineering of LLM agent systems.
Proposing DL-style building blocks for LLMs and constructing a “Transformer” architecture for LLM agent systems. Observing at least 5% performance gain by “backpropagating” through the LLM agent system via a novel feedback-propagation algorithm.
An automatic search algorithm for the best configuration of LLM agent systems, similar to NAS in DL, brings an 11% performance gain compared to prior practice.
Related Works
In this section, we first revisit the basic DL modules and how they are used to build complex NN architectures. We then review the current approaches in building LLM agent systems and discuss how we can bring insights from the success of DL applications to LLM agent systems.
Modules of Deep Learning. In the area of DL, researchers have designed various basic modules to tackle different tasks. In the early period of DL design, researchers proposed MLP [31] to solve tasks such as classification, prediction, and regression. However, this basic architecture is less effective for complex input data. Consequently, researchers have developed specialized modules with various functionalities. RNNs [21, 36, 16] are tailored for sequential data, maintaining a hidden state to capture information across time steps. CNNs [18, 19] excel at capturing local patterns within images. Additionally, Attention mechanism [45, 6, 11] further refines model focus by emphasizing the most salient segments within the data. By combining and arranging these specialized modules, researchers have developed numerous powerful architectures. For instance, the Transformer ([44, 10]), one of the most popular architectures today, relies on the attention mechanism and simple feed-forward layers. It has demonstrated surprising results in generative AI. Additionally, some researchers have integrated the attention mechanism into RNNs, yielding very promising outcomes ([46, 26]). Researchers have further developed automated architecture engineering, such as Neural Architecture Search (NAS) ([23, 58, 30]), aiming to find the optimized design of our machine learning model.
Construction of LLM Agent Systems. Much of the current research on LLM agent systems relies on the insights and observations from other domains ([51, 38, 20, 4]). However, these designs are often problem-specific and do not offer a systematic approach to defining a good LLM agent system architecture. Recent efforts, like Langchain3 and LlamaIndex4, aim to offer standardized building blocks and modules for LLM agent systems. However, they still lack a systematic approach to designing different LLM agent systems for various tasks, providing limited guidance on their integration for sophisticated and meaningful architectural compositions. In response, we propose the development of standardized modules for LLM agent system design, inspired by the proven methodologies within the DL domain. In this work, we show that these basic building blocks can be synthesized into a coherent framework, offering a novel, modular approach to architectures in LLMs that builds a bridge between LLMs and DL.
The Deep Learning Recipe for LLM Agent Systems
To explore the deep learning recipe for LLM agent systems, we first introduce the basic building blocks of LLMs in Sec 3.1, which demonstrates the relationships between DL and LLM building blocks. Inspired by the success of DL’s training process, we then illustrate the forward inference and feedback propagation of LLMs in Sec 3.2. Finally, we introduce the instantiations of: building a “Transformer” with LLM building blocks in Sec 3.3.
Deep-Learning-Style Building Blocks of LLM Agent Systems
To introduce the basic building blocks of LLMs and the relationship between DL and LLMs, we “translate” the modules of LLMs into modules of DL as shown in Figure 1.
Figure 1. Basic Building Blocks of LLM agent systems. (a) A vanilla LLM can be translated into a single layer MLP, which receives a query and outputs a response ; (b) Memory processor can be regarded as RNN since they both utilize historical data for future planning; (c) Retrieval is analogous to the attention network of DL because they both extract the importance information of the corpus context; (d) Prompting strategies, such as Tree/Graph of thoughts, are translated to GNNs since they decompose query into interconnected thoughts, which are connected and related to each other.
Vanilla LLM as Single Layer MLP. As a basic component when constructing an LLM agent system, an LLM receives a query and outputs a response . It can be translated as a single layer MLP, as shown in Figure 1(a), which also plays a fundamental role in DL ([31]).
Memory Processor as Recurrent Neural Network. During the interaction process of the LLM, it will store the knowledge obtained by the interaction as memories and utilize these memories for future responses ([38, 20]) as shown in Figure 1(b). Similarly, Recurrent Neural Network (RNN) excels at processing sequential data due to its inherent structure that allows for the storage and utilization of previous information ([21, 36, 16]). It achieves this by maintaining hidden states that are updated at each time step , effectively encoding the history of the sequence up to that point. Therefore, we regard the memory processor as RNN.
Retrieval as Attention Network. When LLMs interact with factual knowledge stored in the corpus context , they utilize retrieval ([35, 13, 22]) to efficiently retrieve accurate context for future responses. As shown in the left part of Figure 1(c), to retrieve the accurate context, retrieval exploits the embedding similarity between query and corpus context and obtains the retrieved context of the top similarity ranking. This process is similar to the attention network shown in the right part of Figure 1(c). They both utilize the embedding similarity between query and corpus context to obtain an importance score , which determines the importance weights of each context. From this perspective, we translate the retrieval as an attention network. To be specific, single-query retrieval can be interpreted as single-head attention and multi-query retrieval can be regarded as multi-head attention [45, 6, 11].
Prompting Strategies as Graph Neural Network. As shown in Figure 1(d), common prompting strategies, such as Tree of Thoughts (ToT) [53] and Graph of Thoughts (GoT) [2] both decompose query into interconnected thoughts, which are connected and related to each other. These query and thought nodes and their relationships can be abstracted into nodes and edges of Graph Neural Networks, respectively. Since a tree is a special case of a graph, we treat both ToT and GoT as instances of the GNN analogy in the subsequent introduction, denoting the corresponding architectures as Tree and GNN, respectively.
Forward Inference and Feedback Propagation for LLM Agent Systems
The success of DL not only lies in the design of fundamental modules discussed in § 3.1, but also in the training process containing forward and back propagation [3] that brings external signals and feedback to the DL system. Inspired by this, we design the forward inference and feedback propagation of LLMs as shown in Figure 2.
Figure 2. Forward and Back Propagation Algorithms for Large Language Model. In this process, meta prompt is regarded as trainable parameters in DL. For the forward inference, the input query goes through the composition of LLM building blocks to obtain the response, which is guided through the meta prompt. For the feedback propagation, the feedback from the self-reflection updates the parameters (meta prompt) of LLM.
Parameters of the LLM agent system. The parameters can be divided into two categories: training parameters and hyperparameters. Here, the meta prompt in Figure 2 is equivalent to training parameters in deep learning, since it guides forward inference and can be updated through feedback propagation. Moreover, hyperparameters in LLM agent systems include max tokens of each LLM (size of MLP); number of retrievals (head number of attention network); retrieve number of each retrieval (mask); node number or depth of tree/graph of thoughts (node number or layer number of GNN); etc. These are predefined before using the LLM agent systems.
Forward Inference. In the forward inference process of DL, the input data passes through each block of the neural network to obtain the final output (Buscema, [3]; Prabhushankar & AlRegib, [32]). Similar to this, in the forward inference process of LLM, the input query goes through the composition of LLM building blocks to obtain the response as shown in Figure 2. Here we set up a meta prompt to guide the forward inference of LLM, which contains the input query, previous responses, and reflection returned by the self-reflection module.
Feedback Propagation. Many researchers attribute the success of DL to the feedback propagation process of DL (Buscema, [3]; Luft, [25]), which updates the parameters of DL through feedback of losses between outputs and ground truths. Inspired by this, as illustrated in Figure 2, we regard the meta prompt as parameters of LLM and design a self-reflection module as the loss function to evaluate the effect of response on input query and update the parameters of LLM. Specifically, the self-reflection contains LLM Evaluation and Metric Calculation. For some queries whose response quality has clear metrics, we will choose Metric Calculation. Otherwise, we utilize LLM Evaluation to make LLM judge the quality of the response. The generated reflections and responses will be used to update the meta prompt to guide the LLM response in the next round.
Case study: Building a “Transformer” with LLM Building Blocks
In this section, we introduce how to build a (cross-attention) Transformer with LLM building blocks. As illustrated in Figure 3, we show the correspondence between the main modules of the cross-attention transformer and LLM building blocks to illustrate how to utilize LLM building blocks to build a transformer. For the cross-attention transformer, the two different features of data will first go through a cross-attention network, and the output will be obtained through an MLP layer. To avoid the vanishing gradient problem or gradient explosion, researchers will also add the residual module to improve the training performance of the transformer ([44, 10]). The success of the transformer in integrating and processing information from different features has inspired the design of LLM. As shown in the right part of Figure 3, we analogize the raw query and the corpus context into two different features of data, like and . On this basis, we first design a meta prompt containing raw queries to guide the LLM to generate multiple queries. Then we propose a multi-query retrieval based on multiple queries to retrieve relevant context from corpus context, which is equivalent to the multi-head cross-attention network. Additionally, we add the raw query to the generated multiple queries to ensure the effectiveness of our LLM, which is similar to the design of the residual module. Finally, an LLM will output the response like an MLP based on the retrieved context and input query. We summarize the DL recipe for LLM agent systems as a user instruction manual in Table 4 and please refer to Appendix § 7 for details.
Figure 3. Build a Cross-attention Transformer with LLM Building Blocks. The multi-query retrieval is equivalent to the cross-attention network, and the LLM is translated to MLP in DL. Additionally, the process of appending the raw query to the generated multiple queries is equivalent to the residual.
| LLM agent systems | Deep Learning Architecture |
| Vanilla LLM | Single layer MLP |
| Memory processor | Recurrent neural network |
| Retrieval | Attention Network |
| Prompting strategies (ToT & GoT) | Graph neural network |
| Prompts | Training parameters |
| Max tokens of each LLM | Size of MLP |
| Number of retrievals | Head number of attention network |
| Node number or depth of tree/graph | Node number or layer number of GNN |
| Forward inference of LLMs | Forward inference |
| Feedback propagation | Back propagation |
| Self-reflection | Loss function |
| Retrieve number of each retrieval | Mask |
Table 4. Deep Learning Recipe for LLM Agent Systems.
Experimental Setup
Datasets and Tasks
We evaluate LLM agent systems on two major categories of tasks. They differ in whether the LLMs interact with external knowledge ([39]), such as external factual knowledge. Table 6 in Appendix § 7 summarizes the datasets and the number of cases used for evaluation.
| Dataset | Task Type | Cases |
| Without External Knowledge | ||
| TSP | Optimization | 1500 |
| GSM8K | Math Problem | 1,319 |
| With External Knowledge | ||
| StrategyQA | Commonsense Reasoning | 2,290 |
| Related-multi | Summary | 1000 |
Table 6. Overview of Datasets.
LLM without External Knowledge. We evaluate non-retrieval-based methods using two datasets: (1) Traveling Salesman Problem (TSP) ([9]), where we create instances by randomly generating nodes with and coordinates in the range. As a classic combinatorial optimization problem, performance is evaluated by the length of the best solution within the fixed exploration step. (2) GSM8k ([5]), which contains high-quality, linguistically diverse grade-school math word problems necessitating multi-step reasoning, crafted by expert problem writers. Each problem includes a detailed reasoning process and the correct final answer, with performance evaluated based on final answer accuracy.
LLM with External Knowledge. Our evaluation of retrieval-based frameworks utilizes two datasets: (1) StrategyQA ([8]), a benchmark for open-domain commonsense reasoning question-answering that highlights the importance of implicit reasoning. It involves retrieving pertinent evidence paragraphs from a corpus to correctly answer questions. We compare the retrieved paragraphs with the ground truth and obtain Precision, Recall, and F1 as evaluation metrics. (2) Related-multi (will be released after review), designed to assess a language model’s capability to effectively use extensive context from real-world academic papers for answering queries. Specifically, the task is to write a related work section based on the title and abstract of a target paper. LLM needs to use the title and abstract as the query to retrieve text chunks to complete this task. Text chunks depict the abstracts of several papers (each text chunk corresponds to the abstract of a paper), where some papers are cited in the related work section of the target paper, while others are randomly sampled from the same broader field. The retrieved text chunks are compared with the ground truth to obtain Precision, Recall, and F1 as evaluation metrics.
Models: Various Architectures for LLM Agent Systems
We delve into the detailed descriptions of the architectures we explored, with a particular emphasis on their implementations and the methods employed for backward propagation across various modules. For the two LLM datasets without external knowledge, we design the following four basic architectures: (1) MLP: a single LLM; (2) RNN-MLP: previous responses are appended to the meta prompt to guide the generation of response; (3) Tree-MLP: utilizes ToT to generate multiple thoughts for response generation; (4) GNN-MLP: GoT is exploited to develop various thoughts for response generation.
We also develop four basic architectures for LLM agent systems with external knowledge. In order to interact with external knowledge, the four architectures are supplemented with the attention to retrieve relevant information based on the above architectures: (1) Att-MLP: a single retrieval to retrieve relevant information for LLM; (2) RNN-Att-MLP: previous responses are appended into the meta prompt to change the query for retrieval; (3) Tree-Att-MLP: utilize ToT to generate new query for retrieval; (4) GNN-Att-MLP: GoT is exploited to develop new query to retrieve. More details about the basic architectures of LLM agent systems are introduced in Appendix C. Additionally, we have shown an example of the meta prompt used for RNN-MLP on the GSM8K dataset in Figure 4. Other meta prompts are also summarized in Appendix B.
Figure 4. An example of the meta prompt used for RNN-MLP on the GSM8K dataset. The blue text contains input questions and previous responses/evaluations. The purple text describes the output format instructions.
Results
Performance of Different Architectures of LLM Agent Systems
Different Tasks Call for Different LLM Architectures. Our results across two distinct types of datasets are illustrated in Tables 1 and Table 2, demonstrating that the integration of RNN, Tree, and GNN generally enhances the MLP’s performance across various tasks. Specifically, in reasoning (GSM8K) and optimization (TSP) problems that do not require external knowledge, GNN and Tree excel due to their strong logical capabilities. For tasks involving reasoning (StrategyQA) and long-context summary (Related-multi) that necessitate external knowledge, RNNs proved most effective, in line with our expectations. This effectiveness
| Type | With External Knowledge | |||||
| Dataset | StrategeyQA | Related-multi | ||||
| Method | Precision | Recall | F1 | Precision | Recall | F1 |
| Att-MLP | 0.45 | 0.40 | 0.42 | 0.31 | 0.17 | 0.22 |
| RNN-Att-MLP | 0.72 | 0.62 | 0.66 | 0.33 | 0.19 | 0.24 |
| Tree-Att-MLP | 0.53 | 0.47 | 0.50 | 0.34 | 0.20 | 0.25 |
| GNN-Att-MLP | 0.58 | 0.51 | 0.54 | 0.29 | 0.16 | 0.21 |
Table 2. Performance of Different LLM agent systems on StrategeyQA and Related-multi.
| Type | Without External Knowledge | |
| Dataset | TSP | GSM8k |
| Method | Length | Accuracy |
| MLP | 79.2 | 53.3% |
| RNN-MLP | 76.6 | 60.0% |
| Tree-MLP | 73.2 | 66.7% |
| GNN-MLP | 73.9 | 64.3% |
caption: Performance of Different LLM agent systems on TSP and GSM8k.
:::
is attributed to their capability to process and retain long sequences of information. Consistent with findings in DL, combining RNNs with attention mechanisms has been shown to yield promising results.
Feedback Propagation Effectively Optimizes LLM Agent System Performance without Human Intervention. Through our experiments, we discover that our automatic prompt optimization technique, akin to backward propagation, consistently improves the performance of the LLM agent systems in most scenarios. This verifies that LLM agent systems benefit from integrating past experiences and self-evaluations. Figure 6 presents the results at different steps on the TSP datasets, illustrating that feedback propagation can bring at least 5% performance gain for LLM agent systems. Moreover, we can also observe that GNN-MLP and Tree-MLP iterate faster than other architectures and obtain better results. This is because they explore more solutions at each step and improve the efficiency of optimization.
Figure 6. The performance of LLM agent systems on the TSP dataset will get better as the feedback propagation progresses.
Case Study: Results of ``Transformer-style'' LLM Agent Systems
We utilize variants of the transformer as an example to show the role of different LLM building blocks when building complex architectures. To be specific, we set up the following variants. (1) Transformer: It denotes transformer illustrated in § 3.3. (2) RNN-Transformer: We add previous responses to the meta prompt of the transformer to utilize its memory, which is commonly used in DL [50, 24] when processing historical data. (3) Tree-Transformer/GNN-Transformer: ToT/GoT is added to transformer to guide multi-query generation, which is similar to GraphTransformer [54, 12, 33] in DL. We compare their performance on two datasets with the same hyperparameters and report all the results in Figure 7. It can be observed that the Transformer performs best in StrategeyQA. This is because StrategeyQA’s tasks are relatively simple, and Transformer is already relatively complex, therefore other variants do not perform well. We can also observe that Tree-Transformer and GNN-Transformer perform relatively better than other variants on Related-multi. It is because writing related work requires more thinking and divergence of thoughts [34, 42].
Figure 7. Case Study: Using LLM Building Blocks to Build Variants of Transformer.
Automatic Architecture Search of LLM Agent Systems
To automatically optimize the LLM agent system architecture like NAS, we propose an optimization framework based on Optuna [1], which is an efficient and lightweight hyperparameter optimization software. To better illustrate our framework, we take the optimization of the transformer introduced in § 3.3 on Related-multi as an example. As shown in Figure 5, we optimize the hyperparameters of each module using Optuna. To be specific, we first conclude the hyperparameters and define their optimization range in Table 5 of Appendix § 10: Output size (max tokens) for LLM prompting, head num and retrieve num of each head for multi-retrieval, output size for output LLM, and output size for self-reflection. We utilize 30% of the dataset (training set) for searching for an optimization architecture and 70% for testing (testing set) and further define F1 as the optimization goal. For each set of hyperparameters , we calculate its F1 performance on training set. As illustrated in Figure 16 of Appendix § 10, we can obtain via trials (120 trials in our experiment) and optimize the architecture by maximizing F1. In addition, as shown in Table 3, we select some points to illustrate that the LLM agent system becomes better as the number of trials increases. Through the experiment, we obtain the optimized hyperparameters with F1 = 0.712 on the testing set, which has 11% better performance than randomly designed architectures (obtained by conducting experiments in which groups of hyperparameters were randomly selected and averaging the corresponding F1 scores).
Figure 5. Optimization on transformer to maximize F1.
| 0 | 7 | 43 | 78 | |
| F1 Score | 0.541 | 0.685 | 0.694 | 0.712 |
Table 3. As the number of LLM architecture searches increases, the LLM agent system is getting better.
| Range | |
| Output Size | [64, 128, 192, 256, 320] |
| Output Size | [64, 128, 192, 256, 320] |
| Output Size | [64, 128, 192, 256, 320] |
| Head Num | [1, 2, 3, 4, 5] |
| Retrieve Num | [1, 2, 3, 4, 5] |
Table 5. Optimization range of each hyperparameter.

Figure 16. The optimization process on transformer. The x-axis represents the number of trials. For each trial, we will get a set of , ; the y-axis represents the value.
Conclusion and Discussion
Conclusion. In conclusion, our work introduces a pioneering modular approach to the construction of LLM agent systems, establishing parallels with DL. We provide comprehensive methods and insights into viewing and assembling LLM building blocks in a manner analogous to DL architectures. Through extensive experimentation, we demonstrate that specific classic LLM modules are optimized for distinct tasks, similar to those in DL, and can be integrated in a manner reminiscent of DL configurations. Moreover, our feedback system enhances the performance of LLMs, paralleling the training mechanisms in DL. Finally, we propose an automatic optimization method for identifying the most effective LLM architectures, presenting a promising avenue for future research.
Discussion. This work represents a pioneering effort in the development of systematic and scientifically grounded LLM agent systems, drawing upon DL insights to inaugurate a new era of efficiency and standardization in the research and application of LLMs. By establishing fundamental LLM agent systems, our objective is to reconcile the existing diversity of paradigms within LLM research and, akin to DL, introduce classic and standardized modules that enhance scientific rigor, effectiveness, and innovation within the academic community. In the industrial context, the adoption of foundational and systematic architectures enables the creation of more efficient LLM building blocks, thus establishing a solid basis for the field of LLM agent systems. These advanced LLM building blocks possess the potential to streamline the deployment of LLM products, thereby enabling significant real-world impact and facilitating transformative changes across various sectors. Inspired by the progression of DL, this work introduces a suite of standardized modules within the LLM agent system, setting a foundation for future research to explore multi-LLM settings, integrate more established DL modules and architectures like CNN, and adopt self-exploration algorithms akin to NAS to revolutionize the optimization of LLM agent systems, potentially accelerating the discovery of innovative solutions.
User Instruction Manual
Prompts
Figure 8. An example of the meta prompt used for RNN-MLP on the TSP dataset. The blue text contains input questions and previous responses/evaluations. The purple text describes the output format instructions.
Figure 9. An example of the meta prompt used for Tree-MLP/GNN-MLP on the TSP dataset. The blue text contains input questions and previous responses/evaluations. The purple text describes the output format instructions.
Figure 10. An example of the meta prompt used for RNN-MLP on GSM8K dataset. The blue text contains input questions and previous responses/evaluations. The purple text describes the output format instructions.
Vector (PDF)text: ToT/GoT Strategy:
Given a question and past strategy with evaluations, your task is to provide 5 different potential strategies to solve it.
Question: {question};
Previous Strategy: {past_stra};
Evaluation for the Past Strategy: {eval}
Please format your response by listing the strategies separately.
Here is an example:
Original Question: Every tree that Bart cuts down gives him 75 pieces of firewood. If he burns 5 logs a day from November 1 through February 28, how many trees will he need to cut down?
Strategy: November has 30 days, December has 31 days, January has 31 days and February has 28 days for a total of 30+31+31+28 = <<30+31+31+28=120>>120 days\nHe burns 5 pieces of wood every day so 1205 = <<1205=600>>600 pieces of wood\nEvery tree he cuts down supplies 75 pieces of firewood and he will burn 600 pieces so he needs 600/75 = <<600/75=8>>8 trees
ToT/GoT Vote:
Given a question and 5 proposed strategies, please determine the most promising strategy as your output.
Question:{question};
Strategies: {strategies};
Please output use the following format:
To solve the question, we should <Content Of The Best Strategy>
Figure 11. An example of the meta prompt used for Tree-MLP/GNN-MLP on GSM8K dataset. The blue text contains input questions and previous responses/evaluations. The purple text describes the output format instructions.
Vector (PDF)text: Given an original question and the past responses, your task is to enhance the original question for better retrieval outcomes.
Question: {question};
Previous Resposnes for references: {past_stra};
Evaluation on the Last Response: {past_eval};
Here is an example:
Original Question: Is Christmas celebrated during winter?
Response: What is the date of Christmas, and does it occur in winter?
Figure 12. An example of the meta prompt used for RNN-Att-MLP on StrategeyQA dataset. The blue text contains input questions and previous responses/evaluations. The purple text describes the output format instructions.
Figure 13. An example of the meta prompt used for Tree-Att-MLP/GNN-Att-MLP on StrategyQA dataset. The blue text contains input questions and previous responses/evaluations. The purple text describes the output format instructions.
Figure 14. An example of the meta prompt used for RNN-Att-MLP on Related-multi dataset. The blue text contains input questions and previous responses/evaluations. The purple text describes the output format instructions.
Figure 15. An example of the meta prompt used for Tree-Att-MLP/GNN-Att-MLP on Related-multi dataset. The blue text contains input questions and previous responses/evaluations. The purple text describes the output format instructions.
Details of Architectures for LLM Agent Systems
MLP. For the single-layer MLP setup, as previously defined, the LLM processes an input query and generates a corresponding output response . Subsequently, through a process of backpropagation, the LLM undertakes a self-evaluation mechanism. The outcomes of this self-evaluation and response are then integrated into the original , facilitating an updated .
RNN-MLP. In this RNN+MLP framework, the model processes a query and a sequence of past experiences with evaluations . At each step, the latest three experiences and evaluations are integrated into the query . This enriched query is then utilized to generate the next response . After that, we evaluate it to get . and are then fed back through backward propagation for subsequent iterations. Figure 4 shows the example meta prompt for how RNN+MLP works on GSM8K.
Tree-MLP. In this setting, we use zero-shot ToT. Specifically, a query and a meta prompt for decomposing into interconnected thoughts are used to construct a comprehensive prompt . This prompt serves as input for an LLM, yielding a response . During backward propagation, a self-evaluation is performed, and the resulting evaluation is utilized to refine into an updated version , leading to the formation of an updated prompt .
GNN-MLP. This is similar to the Tree-MLP architecture, with the key difference that we allow for deeper graph-based thoughts.
Att-MLP. In our single retrieval Att-MLP model, an initial input query and a meta query are used to generate an enhanced query . Information is retrieved from context based on , and both and are inputted into an LLM (MLP) to generate a response . A feedback system evaluates this response, producing an evaluation . Both and are then fed to which is then utilized to update .
RNN-Att-MLP. In single retrieval with RNN, the model processes an input query , a meta query , and a sequence of past experiences alongside their evaluations . At each step, the latest three experiences and their evaluations , combined with the input query , are integrated into the meta query to generate an enhanced query . Information is then retrieved from context based on , and both and are fed into an LLM (MLP) to produce a response . This response is evaluated by a feedback system, generating an evaluation . Both and are stored for future use.
Tree-Att-MLP. The Tree-Att-MLP configuration implements zero-shot ToT before the attention module. A query , a meta prompt , and a meta query are provided. Initially, is processed through to decompose into interconnected thoughts . Then we vote for the best thought as our strategy . This strategy along with are inputted into to produce an enhanced query . Based on , information is retrieved from the context , and both and are fed into an LLM (MLP) to generate a response . A feedback system then evaluates , yielding an evaluation . This evaluation is subsequently fed to for updated strategy in the next iteration.
GNN-Att-MLP. The GNN-Att-MLP setup is similar to the Tree-Att-MLP configuration but introduces the capability to develop deeper graph-based strategies based on previous ones. Initially, for a given query , we generate a series of thoughts and identify the best one among them, denoted as . Subsequently, we construct a second layer of thoughts based on the initial set . The most effective strategy is then selected from among and . This chosen strategy undergoes the same procedure as described in the Tree-Att-MLP setting.
Automatic Optimization
References
- [1]Takuya Akiba, Shotaro Sano, Toshihiko Yanase, Takeru Ohta, and Masanori Koyama. Optuna: A next-generation hyperparameter optimization framework. In Proceedings of the 25th ACM SIGKDD international conference on knowledge discovery & data mining, pp. 2623–2631, 2019.arxiv.org/abs/1907.10902
- [2]Maciej Besta, Nils Blach, Ales Kubicek, Robert Gerstenberger, Lukas Gianinazzi, Joanna Gajda, Tomasz Lehmann, Michal Podstawski, Hubert Niewiadomski, Piotr Nyczyk, et al. Graph of thoughts: Solving elaborate problems with large language models. arXiv preprint arXiv:2308.09687, 2023.DOI
- [3]Massimo Buscema. Back propagation neural networks. Substance use & misuse, 33(2):233–270, 1998.pubmed.ncbi.nlm.nih.gov/9516725
- [4]Weize Chen, Yusheng Su, Jingwei Zuo, Cheng Yang, Chenfei Yuan, Chen Qian, Chi-Min Chan, Yujia Qin, Yaxi Lu, Ruobing Xie, et al. Agentverse: Facilitating multi-agent collaboration and exploring emergent behaviors in agents. arXiv preprint arXiv:2308.10848, 2023.arxiv.org/abs/2308.10848
- [5]Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Mark Chen, Heewoo Jun, Lukasz Kaiser, Matthias Plappert, Jerry Tworek, Jacob Hilton, Reiichiro Nakano, et al. Training verifiers to solve math word problems, 2021. URL https://arxiv.org/abs/2110.14168, 2021.
- [6]Jun Fu, Jing Liu, Haijie Tian, Yong Li, Yongjun Bao, Zhiwei Fang, and Hanqing Lu. Dual attention network for scene segmentation. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 3146–3154, 2019.arxiv.org/abs/1809.02983
- [7]Yingqiang Ge, Yujie Ren, Wen yue Hua, Shuyuan Xu, Juntao Tan, and Yongfeng Zhang. Llm as os (llmao), agents as apps: Envisioning aios, agents and the aios-agent ecosystem. arXiv preprint arXiv:2312.03815, 2023.
- [8]Mor Geva, Daniel Khashabi, Elad Segal, Tushar Khot, Dan Roth, and Jonathan Berant. Did aristotle use a laptop? a question answering benchmark with implicit reasoning strategies. Transactions of the Association for Computational Linguistics, 9:346–361, 2021.
- [9]Michael Hahsler and Kurt Hornik. Tsp-infrastructure for the traveling salesperson problem. Journal of Statistical Software, 23(2):1–21, 2007.
- [10]Kai Han, An Xiao, Enhua Wu, Jianyuan Guo, Chunjing Xu, and Yunhe Wang. Transformer in transformer. Advances in neural information processing systems, 34:15908–15919, 2021.arxiv.org/abs/2103.00112
- [11]Ruibing Hou, Hong Chang, Bingpeng Ma, Shiguang Shan, and Xilin Chen. Cross attention network for few-shot classification. Advances in neural information processing systems, 32, 2019.arxiv.org/abs/1910.07677
- [12]Ziniu Hu, Yuxiao Dong, Kuansan Wang, and Yizhou Sun. Heterogeneous graph transformer. In Proceedings of the web conference 2020, pp. 2704–2710, 2020.arxiv.org/abs/2003.01332
- [13]Gautier Izacard, Mathilde Caron, Lucas Hosseini, Sebastian Riedel, Piotr Bojanowski, Armand Joulin, and Edouard Grave. Unsupervised dense information retrieval with contrastive learning, 2022.arxiv.org/abs/2112.09118
- [14]Cheonsu Jeong. Generative ai service implementation using llm application architecture: based on rag model and langchain framework. Journal of Intelligence and Information Systems, 29(4):129–164, 2023.
- [15]Erik M Johansson, Farid U Dowla, and Dennis M Goodman. Backpropagation learning for multilayer feed-forward neural networks using the conjugate gradient method. International Journal of Neural Systems, 2 (04):291–301, 1991.DOI
- [16]Michael I Jordan. Serial order: A parallel distributed processing approach. In Advances in psychology, volume 121, pp. 471–495. Elsevier, 1997.DOI
- [17]Michael Kenning, Jingjing Deng, Michael Edwards, and Xianghua Xie. A directed graph convolutional neural network for edge-structured signals in link-fault detection. Pattern Recognition Letters, 153:100–106, 2022.DOI
- [18]Serkan Kiranyaz, Turker Ince, and Moncef Gabbouj. Real-time patient-specific ecg classification by 1-d convolutional neural networks. IEEE transactions on biomedical engineering, 63(3):664–675, 2015.
- [19]Serkan Kiranyaz, Turker Ince, Osama Abdeljaber, Onur Avci, and Moncef Gabbouj. 1-d convolutional neural networks for signal processing applications. In ICASSP 2019-2019 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 8360–8364. IEEE, 2019.DOI
- [20]Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph Gonzalez, Hao Zhang, and Ion Stoica. Efficient memory management for large language model serving with pagedattention. In Proceedings of the 29th Symposium on Operating Systems Principles, pp. 611–626, 2023.arxiv.org/abs/2309.06180
- [21]Yuanjun Li, Ruixiao Sun, and Roland Horne. Deep learning for well data history analysis. In SPE Annual Technical Conference and Exhibition?, pp. D011S008R002. SPE, 2019.
- [22]Sheng-Chieh Lin, Akari Asai, Minghan Li, Barlas Oguz, Jimmy Lin, Yashar Mehdad, Wen-tau Yih, and Xilun Chen. How to train your dragon: Diverse augmentation towards generalizable dense retrieval. arXiv preprint arXiv:2302.07452, 2023.
- [23]Chenxi Liu, Barret Zoph, Maxim Neumann, Jonathon Shlens, Wei Hua, Li-Jia Li, Li Fei-Fei, Alan Yuille, Jonathan Huang, and Kevin Murphy. Progressive neural architecture search. In Proceedings of the European conference on computer vision (ECCV), pp. 19–34, 2018.
- [24]Shanshan Liu, Sheng Zhang, Xin Zhang, and Hui Wang. R-trans: Rnn transformer network for chinese machine reading comprehension. IEEE Access, 7:27736–27745, 2019.
- [25]Caroline Di Bernardi Luft. Learning from feedback: The neural mechanisms of feedback processing facilitating better performance. Behavioural brain research, 261:356–368, 2014.
- [26]Stephen Merity. Single headed attention rnn: Stop thinking with your head. arXiv preprint arXiv:1911.11423, 2019.arxiv.org/abs/1911.11423
- [27]Charles Packer, Vivian Fang, Shishir G Patil, Kevin Lin, Sarah Wooders, and Joseph E Gonzalez. Memgpt: Towards llms as operating systems. arXiv preprint arXiv:2310.08560, 2023.arxiv.org/abs/2310.08560
- [28]Keivalya Pandya and Mehfuza Holia. Automating customer service using langchain: Building custom open-source gpt chatbot for organizations. arXiv preprint arXiv:2310.05421, 2023.
- [29]Baolin Peng, Michel Galley, Pengcheng He, Hao Cheng, Yujia Xie, Yu Hu, Qiuyuan Huang, Lars Liden, Zhou Yu, Weizhu Chen, et al. Check your facts and try again: Improving large language models with external knowledge and automated feedback. arXiv preprint arXiv:2302.12813, 2023.
- [30]Hieu Pham, Melody Guan, Barret Zoph, Quoc Le, and Jeff Dean. Efficient neural architecture search via parameters sharing. In International conference on machine learning, pp. 4095–4104. PMLR, 2018.
- [31]Marius-Constantin Popescu, Valentina E Balas, Liliana Perescu-Popescu, and Nikos Mastorakis. Multilayer perceptron and neural networks. WSEAS Transactions on Circuits and Systems, 8(7):579–588, 2009.
- [32]Mohit Prabhushankar and Ghassan AlRegib. Introspective learning: A two-stage approach for inference in neural networks. Advances in Neural Information Processing Systems, 35:12126–12140, 2022.
- [33]Ladislav Rampášek, Michael Galkin, Vijay Prakash Dwivedi, Anh Tuan Luu, Guy Wolf, and Dominique Beaini. Recipe for a general, powerful, scalable graph transformer. Advances in Neural Information Processing Systems, 35:14501–14515, 2022.arxiv.org/abs/2205.12454
- [34]Justus Randolph. A guide to writing the dissertation literature review. Practical assessment, research, and evaluation, 14(1):13, 2019.
- [35]Stephen Robertson, Hugo Zaragoza, et al. The probabilistic relevance framework: Bm25 and beyond. Foundations and Trends® in Information Retrieval, 3(4):333–389, 2009.
- [36]Srelekshmy Selvin, R Vinayakumar, EA Gopalakrishnan, Vijay Krishna Menon, and KP Soman. Stock price prediction using lstm, rnn and cnn-sliding window model. In 2017 international conference on advances in computing, communications and informatics (icacci), pp. 1643–1647. IEEE, 2017.DOI
- [37]Lei Shi, Yifan Zhang, Jian Cheng, and Hanqing Lu. Skeleton-based action recognition with directed graph neural networks. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 7912–7921, 2019.DOI
- [38]Noah Shinn, Beck Labash, and Ashwin Gopinath. Reflexion: an autonomous agent with dynamic memory and self-reflection. arXiv preprint arXiv:2303.11366, 2023.
- [39]Kai Sun, Yifan Ethan Xu, Hanwen Zha, Yue Liu, and Xin Luna Dong. Head-to-tail: How knowledgeable are large language models (llm)? aka will llms replace knowledge graphs? arXiv preprint arXiv:2308.10168, 2023.arxiv.org/abs/2308.10168
- [40]Yashar Talebirad and Amirhossein Nadiri. Multi-agent collaboration: Harnessing the power of intelligent llm agents. arXiv preprint arXiv:2306.03314, 2023.arxiv.org/abs/2306.03314
- [41]Oguzhan Topsakal and Tahir Cetin Akinci. Creating large language model applications utilizing langchain: A primer on developing llm apps fast. In International Conference on Applied Engineering and Natural Sciences, volume 1, pp. 1050–1056, 2023.DOI
- [42]Richard J Torraco. Writing integrative literature reviews: Guidelines and examples. Human resource development review, 4(3):356–367, 2005.DOI
- [43]Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017a. URL https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf.arxiv.org/abs/1706.03762
- [44]Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017b.arxiv.org/abs/1706.03762
- [45]Fei Wang, Mengqing Jiang, Chen Qian, Shuo Yang, Cheng Li, Honggang Zhang, Xiaogang Wang, and Xiaoou Tang. Residual attention network for image classification. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 3156–3164, 2017.arxiv.org/abs/1704.06904
- [46]Feng Wang and David MJ Tax. Survey on the attention based rnn model and its applications in computer vision. arXiv preprint arXiv:1601.06823, 2016.arxiv.org/abs/1601.06823
- [47]Lei Wang, Chen Ma, Xueyang Feng, Zeyu Zhang, Hao Yang, Jingsen Zhang, Zhiyuan Chen, Jiakai Tang, Xu Chen, Yankai Lin, et al. A survey on large language model based autonomous agents. arXiv preprint arXiv:2308.11432, 2023.DOI
- [48]Qingyun Wu, Gagan Bansal, Jieyu Zhang, Yiran Wu, Shaokun Zhang, Erkang Zhu, Beibin Li, Li Jiang, Xiaoyun Zhang, and Chi Wang. Autogen: Enabling next-gen llm applications via multi-agent conversation framework. arXiv preprint arXiv:2308.08155, 2023a.arxiv.org/abs/2308.08155
- [49]Yue Wu, Xuan Tang, Tom M Mitchell, and Yuanzhi Li. Smartplay: A benchmark for llms as intelligent agents. arXiv preprint arXiv:2310.01557, 2023b.arxiv.org/abs/2310.01557
- [50]Rui Xia, Mengran Zhang, and Zixiang Ding. Rthn: A rnn-transformer hierarchical network for emotion cause extraction. arXiv preprint arXiv:1906.01236, 2019.arxiv.org/abs/1906.01236
- [51]Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao. React: Synergizing reasoning and acting in language models. arXiv preprint arXiv:2210.03629, 2022.arxiv.org/abs/2210.03629
- [52]Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao. React: Synergizing reasoning and acting in language models. (2023). arXiv preprint arXiv:2210.03629, 2023.arxiv.org/abs/2210.03629
- [53]Shunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran, Tom Griffiths, Yuan Cao, and Karthik Narasimhan. Tree of thoughts: Deliberate problem solving with large language models. Advances in Neural Information Processing Systems, 36, 2024.arxiv.org/abs/2305.10601
- [54]Seongjun Yun, Minbyul Jeong, Raehyun Kim, Jaewoo Kang, and Hyunwoo J Kim. Graph transformer networks. Advances in neural information processing systems, 32, 2019.
- [55]Kai Zhang, Fubang Zhao, Yangyang Kang, and Xiaozhong Liu. Memory-augmented llm personalization with short-and long-term memory coordination. arXiv preprint arXiv:2309.11696, 2023.arxiv.org/abs/2309.11696
- [56]Xitong Zhang, Yixuan He, Nathan Brugnone, Michael Perlmutter, and Matthew Hirn. Magnet: A neural network for directed graphs. Advances in neural information processing systems, 34:27003–27015, 2021.
- [57]Andrew Zhao, Daniel Huang, Quentin Xu, Matthieu Lin, Yong-Jin Liu, and Gao Huang. Expel: Llm agents are experiential learners. arXiv preprint arXiv:2308.10144, 2023.arxiv.org/abs/2308.10144
- [58]Barret Zoph and Quoc V Le. Neural architecture search with reinforcement learning. arXiv preprint arXiv:1611.01578, 2016.arxiv.org/abs/1611.01578
AI tools statement
No AI-use declaration is available for this version in Valency.
The available record does not establish whether AI systems or models contributed to this work.












