# NAS-CRE: Neural Architecture Search for Context-Based Relation Extraction
## 3 Method
### Relational Feature Representation
Efficient Parameters and Computation: Fixed-structure models in relation extraction tasks may possess excessive parameters, leading to high computational complexity. NAS-RNN, however, can identify more precise and compact structures tailored to specific task requirements. During the search process, NAS-RNN eliminates structural components that are irrelevant or perform poorly for the task, thereby reducing the presence of redundant parameters. Additionally, NAS-RNN can select and configure appropriate structural components, enabling the model to better capture the semantics and contextual information between relationships, thus improving overall performance. 3. Improved Generalization Capability: By automatically searching for the optimal structure, NAS-RNN can adaptively learn network architectures suitable for specific tasks. This enhances its modeling capability for complex and noisy sequential data, increasing the model's applicability and value in real-world scenarios. NAS-RNN employs a controller composed of RNNs to randomly sample RNN structures that need optimization with a probability \(p\). Sub-networks are trained on the training set, and accuracy \(R\) is calculated on the validation set. The accuracy \(R\) serves as a feedback  
Figure 4: The structure of a recurrent neural network. signal, and NAS-RNN utilizes reinforcement learning as proposed by [PERSON] et al. [39]. The core idea of NAS-RNN is to learn to select RNN structures suitable for specific tasks through continuous trial and error. The parameters of the controller are continuously adjusted during the training process to generate better RNN structures, aiming to maximize performance metrics through reinforcement learning. This approach enables the automatic search and learning of RNN structures that are suitable for specific tasks, thereby enhancing the model's performance and generalization ability. Specifically, as shown in Figure 5, NAS-RNN uses the policy gradient algorithm to update the controller's parameters until model convergence. It learns to select appropriate RNN structures through interaction with the environment, maximizing a predefined performance metric via trial and error. To provide a detailed description of the NAS-RNN network, the following outlines its process. **Initialize the Controller Network and Target Network. ** First, initialize a controller network, which is a generative model used to produce action sequences for RNN network structures. The parameters of the controller network are denoted as \(\chi_{c}\). At the same time, initialize a target network, which is an RNN network to be optimized for training and evaluation on the training dataset. The initial parameters of the target network are \(\theta_{0}\). **Search and Training. ** In each iteration, use the current controller network and target network to generate a series of action sequences \(c_{1:T}\). Convert each generated action sequence \(c_{1:T}\) into the corresponding RNN network structure and train that network on the training dataset. Calculate the performance metric \(R(c_{1:T};\theta)\) corresponding to each generated RNN network structure. Use gradient descent to update the parameters of the target network \(\theta\) using the following formulas:  
\[\text{Loss}(D_{\text{train}},R(c_{1:T};\theta)) \tag{4}\] \[\theta_{\text{new}}=\theta_{\text{old}}-lr\cdot\
abla\text{Loss} (D_{\text{train}},R(c_{1:T};\theta)) \tag{5}\]  
where \(D_{\text{train}}\) is the training dataset, \(\theta_{\text{new}}\) is the updated parameter, \(\theta_{\text{old}}\) is the current parameter value, \(lr\) is the learning rate, and \(\
abla\text{Loss}(\theta_{\text{old}})\) is the gradient of the loss function with respect to the target network parameters \(\theta_{\text{old}}\). **Updating the Controller Network Parameters. ** Let the parameters of the controller network be denoted as \(\chi_{c}\).