Text vectorization model optimization method and device based on arm architecture
By iteratively adjusting the layers and dimensions of the ARM text vectorization model and migrating the soft labels of the trained model, the problem of the degradation of the inference speed of text vectorization models on the ARM architecture is solved, and efficient text vectorization effect is achieved to meet the real-time processing needs. .
Patent Information
- Application Number
- CN202411242349.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2024-11-29
AI Technical Summary
When the traditional text vectorization model migrates to ARM architecture with weak computing power, the inference speed has dropped significantly and cannot meet the real-time processing needs of business systems.
By obtaining the trained text vectorized model and transferring sample data, the initial ARM text vectorized model is designed, and the number of layers and dimensions of the model is adjusted by iteratively, the soft label of the trained model is migrated until the preset recognition speed and accuracy are met. Spend.
Effectively reduce computing overhead on ARM devices, ensure real-time processing requirements, and improve inference speed and efficiency to ensure the best performance of the model in different application scenarios.
Smart Images

Figure CN119047427A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a text vectorization model optimization method and device based on ARM architecture. Background Art
[0002] With the development of artificial intelligence technology, text vectorization technology has emerged. Text vectorization is an important part of the field of natural language processing (NLP), which involves converting text data into numerical vectors so that computer systems can understand and process them. This process is essential for performing a variety of tasks such as text classification, sentiment analysis, machine translation, question-answering systems, recommendation systems, etc.
[0003] Text vectorization models in traditional technologies are usually developed and optimized on high-performance x86 architecture processors or GPUs. These platforms have high computing power and specific optimized instruction sets, and can efficiently perform complex matrix operations and deep learning tasks. However, when these models are migrated to the ARM architecture with relatively weak computing power, the reasoning speed of the model will drop significantly due to the low main frequency of the ARM processor and the lack of advanced optimized instruction sets, resulting in increased system response time and failure to meet the real-time processing requirements of business systems. Summary of the invention
[0004] Based on this, it is necessary to provide an ARM architecture-based text vectorization model optimization method, device, computer equipment, computer-readable storage medium and computer program product that can meet the real-time processing requirements of business systems in response to the above technical problems.
[0005] In a first aspect, the present application provides a text vectorization model optimization method based on the ARM architecture, comprising:
[0006] Get the trained text vectorization model and sample data for transfer;
[0007] According to the computing power of the arm architecture, an initial arm text vectorization model is designed; the initial arm text vectorization model includes an initial model layer number and an initial model dimension;
[0008] Inputting the transfer sample data into the trained text vectorization model to obtain a text vector recognition result;
[0009] According to the text vector recognition result, the soft label of the trained text vectorization model is migrated to the initial arm text vectorization model;
[0010] When the recognition speed and / or recognition accuracy of the initial arm text vectorization model cannot meet the preset value, the number of layers of the initial model and the dimension of the initial model are adjusted according to the recognition speed and the recognition accuracy to obtain an adjusted arm text vectorization model;
[0011] The adjusted arm text vectorization model is used as the initial arm text vectorization model, and the step of migrating the soft labels of the trained text vectorization model to the initial arm text vectorization model according to the text vector recognition result is returned to execute until the recognition speed and / or the recognition accuracy of the initial arm text vectorization model meet the preset values, thereby obtaining the target arm text vectorization model.
[0012] In a second aspect, the present application also provides a text vectorization model optimization device based on the ARM architecture, comprising:
[0013] A data acquisition module is used to obtain the trained text vectorization model and sample data for transfer;
[0014] A model design module, used to design an initial arm text vectorization model according to the computing power of the arm architecture; the initial arm text vectorization model includes an initial model layer number and an initial model dimension;
[0015] A model training module, used for inputting the transfer sample data into the trained text vectorization model to obtain a text vector recognition result;
[0016] A model migration module, used for migrating the soft labels of the trained text vectorization model to the initial arm text vectorization model according to the text vector recognition result;
[0017] The model training module is also used to adjust the number of layers of the initial model and the dimension of the initial model according to the recognition speed and the recognition accuracy when the recognition speed and / or the recognition accuracy of the initial arm text vectorization model cannot meet the preset value, so as to obtain an adjusted arm text vectorization model;
[0018] The model training module is also used to use the adjusted arm text vectorization model as the initial arm text vectorization model, return to execute the step of migrating the soft label of the trained text vectorization model to the initial arm text vectorization model according to the text vector recognition result, until the recognition speed and / or the recognition accuracy of the initial arm text vectorization model meets the preset value, thereby obtaining the target arm text vectorization model.
[0019] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0020] Get the trained text vectorization model and sample data for transfer;
[0021] According to the computing power of the arm architecture, an initial arm text vectorization model is designed; the initial arm text vectorization model includes an initial model layer number and an initial model dimension;
[0022] Inputting the transfer sample data into the trained text vectorization model to obtain a text vector recognition result;
[0023] According to the text vector recognition result, the soft label of the trained text vectorization model is migrated to the initial arm text vectorization model;
[0024] When the recognition speed and / or recognition accuracy of the initial arm text vectorization model cannot meet the preset value, the number of layers of the initial model and the dimension of the initial model are adjusted according to the recognition speed and the recognition accuracy to obtain an adjusted arm text vectorization model;
[0025] The adjusted arm text vectorization model is used as the initial arm text vectorization model, and the step of migrating the soft labels of the trained text vectorization model to the initial arm text vectorization model according to the text vector recognition result is returned to execute until the recognition speed and / or the recognition accuracy of the initial arm text vectorization model meet the preset values, thereby obtaining the target arm text vectorization model.
[0026] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0027] Get the trained text vectorization model and sample data for transfer;
[0028] According to the computing power of the arm architecture, an initial arm text vectorization model is designed; the initial arm text vectorization model includes an initial model layer number and an initial model dimension;
[0029] Inputting the transfer sample data into the trained text vectorization model to obtain a text vector recognition result;
[0030] According to the text vector recognition result, the soft label of the trained text vectorization model is migrated to the initial arm text vectorization model;
[0031] When the recognition speed and / or recognition accuracy of the initial arm text vectorization model cannot meet the preset value, the number of layers of the initial model and the dimension of the initial model are adjusted according to the recognition speed and the recognition accuracy to obtain an adjusted arm text vectorization model;
[0032] The adjusted arm text vectorization model is used as the initial arm text vectorization model, and the step of migrating the soft labels of the trained text vectorization model to the initial arm text vectorization model according to the text vector recognition result is returned to execute until the recognition speed and / or the recognition accuracy of the initial arm text vectorization model meet the preset values, thereby obtaining the target arm text vectorization model.
[0033] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0034] Get the trained text vectorization model and sample data for transfer;
[0035] According to the computing power of the arm architecture, an initial arm text vectorization model is designed; the initial arm text vectorization model includes an initial model layer number and an initial model dimension;
[0036] Inputting the transfer sample data into the trained text vectorization model to obtain a text vector recognition result;
[0037] According to the text vector recognition result, the soft label of the trained text vectorization model is migrated to the initial arm text vectorization model;
[0038] When the recognition speed and / or recognition accuracy of the initial arm text vectorization model cannot meet the preset value, the number of layers of the initial model and the dimension of the initial model are adjusted according to the recognition speed and the recognition accuracy to obtain an adjusted arm text vectorization model;
[0039] The adjusted arm text vectorization model is used as the initial arm text vectorization model, and the step of migrating the soft labels of the trained text vectorization model to the initial arm text vectorization model according to the text vector recognition result is returned to execute until the recognition speed and / or the recognition accuracy of the initial arm text vectorization model meet the preset values, thereby obtaining the target arm text vectorization model.
[0040] The above-mentioned text vectorization model optimization method, device, computer equipment, storage medium and computer program product based on the arm architecture obtain a trained text vectorization model and sample data for transfer; design an initial arm text vectorization model according to the computing power of the arm architecture; the initial arm text vectorization model includes an initial model number of layers and an initial model dimension; input the sample data for transfer into the trained text vectorization model to obtain a text vector recognition result; according to the text vector recognition result, migrate the soft label of the trained text vectorization model to the initial arm text vectorization model; when the recognition speed and / or recognition accuracy of the initial arm text vectorization model cannot meet the preset value, adjust the initial model number of layers and the initial model dimension according to the recognition speed and recognition accuracy to obtain an adjusted arm text vectorization model; use the adjusted arm text vectorization model as the initial arm text vectorization model, return to execute the step of migrating the soft label of the trained text vectorization model to the initial arm text vectorization model according to the text vector recognition result, until the recognition speed and / or recognition accuracy of the initial arm text vectorization model meet the preset value, and obtain the target arm text vectorization model.
[0041] By migrating the soft labels of the trained text vectorization model to the initial arm text vectorization model, combined with the characteristics of the arm architecture, the number of layers and dimensions of the model are gradually adjusted to ensure that the recognition speed and accuracy of the model on the arm device meet the preset performance standards. This dynamic optimization process can not only effectively reduce the computing overhead of the model on resource-constrained arm devices to ensure that the real-time processing requirements of the business system are met, but also improve the reasoning speed and efficiency of the model while maintaining accuracy. In addition, by continuously iteratively adjusting the model structure, it is possible to tailor optimization solutions for different application scenarios and needs to ensure the best text vectorization effect on the arm architecture, thereby enhancing the practicality and adaptability of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0043] FIG1 is an application environment diagram of a text vectorization model optimization method based on an ARM architecture in one embodiment;
[0044] FIG2 is a flow chart of a text vectorization model optimization method based on an ARM architecture in one embodiment;
[0045] FIG3 is a schematic flow chart of a first method for adjusting an arm text vectorization model in one embodiment;
[0046] FIG4 is a schematic flow chart of a second method for adjusting an arm text vectorization model in one embodiment;
[0047] FIG5 is a schematic diagram of a flow chart of a third method for adjusting an arm text vectorization model in one embodiment;
[0048] FIG6 is a schematic diagram of a flow chart of a method for obtaining a reconstructed text vectorization model in one embodiment;
[0049] FIG7 is a schematic diagram of a flow chart of a soft label migration method in one embodiment;
[0050] FIG8 is a structural block diagram of a text vectorization model optimization device based on an ARM architecture in one embodiment;
[0051] FIG. 9 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0053] The text vectorization model optimization method based on the arm architecture provided in the embodiment of the present application can be applied to the application environment shown in Figure 1. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The server 104 obtains the trained text vectorization model and the sample data for transfer through the terminal 102; designs the initial arm text vectorization model according to the computing power of the arm architecture; the initial arm text vectorization model includes the initial model layer number and the initial model dimension; inputs the sample data for transfer into the trained text vectorization model to obtain the text vector recognition result; according to the text vector recognition result, migrates the soft label of the trained text vectorization model to the initial arm text vectorization model; when the recognition speed and / or recognition accuracy of the initial arm text vectorization model cannot meet the preset value, adjusts the initial model layer number and the initial model dimension according to the recognition speed and recognition accuracy to obtain the adjusted arm text vectorization model; uses the adjusted arm text vectorization model as the initial arm text vectorization model, and returns to execute the step of migrating the soft label of the trained text vectorization model to the initial arm text vectorization model according to the text vector recognition result, until the recognition speed and / or recognition accuracy of the initial arm text vectorization model meet the preset value, and obtains the target arm text vectorization model. The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. The portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. The server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.
[0054] In an exemplary embodiment, as shown in FIG2 , a text vectorization model optimization method based on an ARM architecture is provided, and the method is applied to the server in FIG1 as an example for explanation, including the following steps 202 to 212. Among them:
[0055] Step 202, obtain the trained text vectorization model and sample data for transfer.
[0056] The trained text vectorization model may be a pre-trained machine learning model that can convert text data into a numerical vector representation. This vector representation captures the semantic information in the text, so that different texts can be compared and analyzed through their vector representations.
[0057] The sample data for transfer may be a data set used to be input into a trained text vectorization model for recognition.
[0058] Specifically, it is necessary to derive a trained text vectorization model from the source model, which may be pre-trained based on a large corpus and has good text representation capabilities. Then, sample data related to the target task is selected as transfer sample data, which is used for subsequent actual recognition by the trained text vectorization model.
[0059] Among them, for the trained text vectorization model, the design is as follows:
[0060] 1. Input layer:
[0061] The input is a text sequence after tokenization, where each word or character is converted to its corresponding vocabulary ID.
[0062] The vocabulary ID of each input is added with the position embedding and possibly the segment embedding (if applicable) to form the final input embedding.
[0063] 2. Encoder Layers:
[0064] The model contains multiple layers of Transformer encoders. Each layer of encoder consists of two sub-layers: Self-Attention Mechanism and Feed-Forward Network.
[0065] The self-attention mechanism allows the model to consider information about other tokens in the entire sequence when processing each input token, thereby capturing long-range dependencies.
[0066] The feedforward neural network is used to perform nonlinear transformation on the output of the self-attention layer to increase the expressive power of the model.
[0067] Each sub-layer is usually followed by Layer Normalization and Residual Connection to facilitate gradient flow and reduce training difficulty.
[0068] 3. Output layer:
[0069] The output of the last layer can be used to generate a vector representation of the text. In the model, the hidden state of the [CLS] tag is used as a fixed-length vector representation of the entire sequence.
[0070] This vector representation can be used for downstream tasks such as semantic similarity calculation, information retrieval, classification, etc.
[0071] Step 204, designing an initial arm text vectorization model according to the computing capability of the arm architecture.
[0072] The initial arm text vectorization model can be a basic model designed according to the hardware characteristics and computing power of the arm architecture, which is used to convert text data into numerical vector representation. The model is designed taking into account the resource limitations of the arm device, such as processing power and memory, and therefore usually adopts a simplified or lightweight network structure.
[0073] Specifically, when designing the initial arm text vectorization model, it is necessary to evaluate the computing power of the arm architecture, including the number of processor cores, clock frequency, memory capacity, and bandwidth. According to the limitations of these hardware resources, select the appropriate model architecture and parameters, such as reducing the number of model layers, reducing the dimension of each layer, or using a lightweight network structure (such as MobileNet or TinyBERT). Then initialize the model weights and adjust the model's activation function and optimizer to ensure that the model can run efficiently on the arm architecture. Perform basic tests on this initial model to verify its inference speed and memory usage on the arm device.
[0074] Step 206, input the transfer sample data into the trained text vectorization model to obtain the text vector recognition result.
[0075] Among them, the text vector recognition result can be a numerical vector generated after being processed by a text vectorization model, and these vectors represent the semantic features and information content of the input text.
[0076] Specifically, when the sample data for transfer is input into the trained text vectorization model, the trained text vectorization model needs to preprocess the sample data, including text cleaning, word segmentation, and converting the text into the input format required by the model (such as word embedding or token sequence). Then, the preprocessed sample data is processed one by one or in batches through its learned weights and structures to generate the text vector recognition results represented by the corresponding text vectors.
[0077] Step 208, based on the text vector recognition result, the soft labels of the trained text vectorization model are migrated to the initial arm text vectorization model.
[0078] The soft label can be the probability distribution or similarity score of each category.
[0079] Specifically, since the text vector recognition results contain the soft labels of the model, that is, the probability distribution or similarity score of each category, these soft labels are used as targets to guide the training of the initial arm text vectorization model so that it can learn the knowledge and feature representations in the trained model. By gradually optimizing the parameters of the initial model, it gradually approaches or reaches the performance of the trained model on the arm architecture, thereby completing the knowledge transfer process and obtaining the migrated initial arm text vectorization model.
[0080] Step 210, when the recognition speed and / or recognition accuracy of the initial arm text vectorization model cannot meet the preset values, the number of initial model layers and the initial model dimensions are adjusted according to the recognition speed and recognition accuracy to obtain an adjusted arm text vectorization model.
[0081] The initial model number of layers and the initial model dimension may be the model number of layers and the model dimension preset by the initial arm text vectorization model.
[0082] Among them, the adjusted arm text vectorization model can be a model obtained by adjusting the number of model layers or model dimensions of the arm text vectorization model in response to a situation where the recognition speed and / or recognition accuracy do not meet the standards.
[0083] Specifically, if the recognition speed and / or recognition accuracy of the initial arm text vectorization model cannot meet the preset values, analyze the bottleneck of the initial arm text vectorization model to determine whether the recognition speed or accuracy does not meet the requirements. In the case of insufficient recognition speed, the number of model layers can be reduced or the dimension of each layer can be reduced according to the recognition speed and recognition accuracy, thereby reducing the amount of calculation and speeding up the reasoning speed; if the accuracy is insufficient, the number of layers or dimensions may need to be increased according to the recognition speed and recognition accuracy to enhance the expressive power of the model. After each adjustment, retrain and evaluate the model, and iterate the adjustment until the recognition speed and accuracy of the model meet the preset values to obtain the adjusted arm text vectorization model.
[0084] Step 212, the adjusted arm text vectorization model is used as the initial arm text vectorization model, and the step of migrating the soft labels of the trained text vectorization model to the initial arm text vectorization model according to the text vector recognition results is returned to execute until the recognition speed and / or recognition accuracy of the initial arm text vectorization model meets the preset value, thereby obtaining the target arm text vectorization model.
[0085] Among them, the target arm text vectorization model can be an arm architecture-based text vectorization model that finally meets the preset recognition speed and accuracy requirements after multiple rounds of iterative optimization and adjustment.
[0086] Specifically, after completing the adjustment of the arm text vectorization model, the adjusted arm text vectorization model is used as the initial arm text vectorization model, and the soft label migration step is continued, that is, the soft labels of the trained text vectorization model are used again to train and optimize the adjusted arm text vectorization model. This process uses soft labels to guide the training of the initial arm text vectorization model so that it can learn the knowledge and feature representations in the trained model. By gradually optimizing the parameters of the initial model, the performance of the trained model is gradually approached or reached on the arm architecture, thereby completing the knowledge transfer process and further improving the performance of the model. Through this iterative training and adjustment, the recognition speed and accuracy of the model are gradually improved, and this is repeated until the performance of the model meets the preset requirements, and finally the optimal target arm text vectorization model is obtained.
[0087] In the above-mentioned text vectorization model optimization method based on the arm architecture, a trained text vectorization model and sample data for transfer are obtained; an initial arm text vectorization model is designed according to the computing power of the arm architecture; the initial arm text vectorization model includes an initial model number of layers and an initial model dimension; the sample data for transfer is input into the trained text vectorization model to obtain a text vector recognition result; according to the text vector recognition result, the soft label of the trained text vectorization model is migrated to the initial arm text vectorization model; when the recognition speed and / or recognition accuracy of the initial arm text vectorization model cannot meet the preset values, the initial model number of layers and the initial model dimension are adjusted according to the recognition speed and recognition accuracy to obtain an adjusted arm text vectorization model; the adjusted arm text vectorization model is used as the initial arm text vectorization model, and the step of migrating the soft label of the trained text vectorization model to the initial arm text vectorization model according to the text vector recognition result is returned to execute until the recognition speed and / or recognition accuracy of the initial arm text vectorization model meet the preset values to obtain the target arm text vectorization model.
[0088] By migrating the soft labels of the trained text vectorization model to the initial arm text vectorization model, combined with the characteristics of the arm architecture, the number of layers and dimensions of the model are gradually adjusted to ensure that the recognition speed and accuracy of the model on the arm device meet the preset performance standards. This dynamic optimization process can not only effectively reduce the computing overhead of the model on resource-constrained arm devices to ensure that the real-time processing requirements of the business system are met, but also improve the reasoning speed and efficiency of the model while maintaining accuracy. In addition, by continuously iteratively adjusting the model structure, it is possible to tailor optimization solutions for different application scenarios and needs to ensure the best text vectorization effect on the arm architecture, thereby enhancing the practicality and adaptability of the model.
[0089] In an exemplary embodiment, as shown in FIG3 , the number of initial model layers and the initial model dimensions are adjusted according to the recognition speed and the recognition accuracy to obtain an adjusted arm text vectorization model, including steps 302 to 304. Among them:
[0090] Step 302, input the recognition speed and recognition accuracy into the text model design optimization algorithm to determine the model layer adjustment amount and model dimension adjustment amount of the arm text vectorization model.
[0091] Among them, the text model design optimization algorithm can be an algorithm for automatically adjusting the structure of the text vectorization model, searching for the optimal solution for the adjustment amount of the model layer number and the model dimension adjustment amount.
[0092] The model layer number adjustment amount and the model dimension adjustment amount may be the amounts that need to be adjusted simultaneously for adjusting the model layer number and the model dimension of the arm text vectorization model.
[0093] Specifically, the recognition speed and recognition accuracy of the current model are provided as input parameters to the text model design optimization algorithm. The text model design optimization algorithm searches for the optimal solution of the model layer adjustment amount and the model dimension adjustment amount according to the deviation of the recognition speed and / or recognition accuracy from the preset target, and automatically calculates the model layer adjustment amount and model dimension adjustment amount that need to be adjusted.
[0094] Step 304, adjusting the number of initial model layers according to the model layer number adjustment amount, and adjusting the initial model dimension according to the model dimension adjustment amount, to obtain an adjusted arm text vectorization model.
[0095] Specifically, the number of layers of the initial model and the initial model dimension of each layer are modified by using the model layer adjustment amount and model dimension adjustment amount provided by the text model design optimization algorithm. For the initial model layer adjustment, the network layer may be increased or decreased to change the complexity of the model; for the initial model dimension adjustment, the number of neurons in each layer or the dimension of the embedding vector may be increased or decreased to optimize the representation ability of the model. After the adjustment is completed, the model of the new structure is retrained and verified to obtain the adjusted arm text vectorization model.
[0096] In the present embodiment, by inputting the recognition speed and recognition accuracy into the text model design optimization algorithm, the optimal model layer number adjustment amount and model dimension adjustment amount are automatically searched out, thereby realizing the accurate optimization of the model structure. Through this automated optimization process, the performance of the arm text vectorization model can be effectively improved, so that it can significantly improve the recognition speed and computing efficiency while maintaining high accuracy. Ultimately, this method can generate a highly optimized model on the arm architecture, which not only meets the needs of resource-constrained environments, but also ensures the accuracy and practicality of the model.
[0097] In an exemplary embodiment, as shown in FIG4 , the number of initial model layers is adjusted according to the model layer number adjustment amount, and the initial model dimension is adjusted according to the model dimension adjustment amount, to obtain an adjusted arm text vectorization model, including steps 402 to 406. Wherein:
[0098] Step 402, adjusting the number of initial model layers according to the model layer number adjustment amount, and adjusting the initial model dimension according to the model dimension adjustment amount, to obtain an intermediate arm text vectorization model.
[0099] Among them, the intermediate arm text vectorization model can be the arm text vectorization model obtained after the first adjustment of the model layers and model dimensions.
[0100] Specifically, when the initial model is adjusted according to the model layer number adjustment amount and the model dimension adjustment amount, the number of initial model layers needs to be modified according to the model layer number adjustment amount, which may be to increase or decrease the number of model layers to optimize its depth. Subsequently, the dimension of the initial model dimension is adjusted according to the model dimension adjustment amount, that is, the number of neurons in each layer or the dimension of the embedding vector is modified to optimize the representation ability of the model. After completing these adjustments, the intermediate arm text vectorization model is obtained.
[0101] Step 404, testing the model performance of the intermediate ARM text vectorization model to obtain model test data.
[0102] Among them, the model test data can be a set of data obtained after the performance test of the model. These data reflect the performance of the model in a specific task, including recognition speed, recognition accuracy, inference time, memory usage, precision, recall rate and other indicators.
[0103] Specifically, the test data set is input into the intermediate arm text vectorization model, and the intermediate arm text vectorization model performs the inference process to evaluate the key performance indicators of the model, such as recognition speed and recognition accuracy. During the test, the inference time, memory usage, accuracy, precision, recall rate and other related data of the intermediate arm text vectorization model on the arm architecture are recorded as a direct reflection of the model performance. Finally, these performance data are summarized to form model test data.
[0104] Step 406, according to the model test data, the model layers and model dimensions of the intermediate arm text vectorization model are optimized to obtain an adjusted arm text vectorization model.
[0105] Specifically, analyze the model test data, identify the bottlenecks that affect performance, and make specific adjustments to the model layers and model dimensions of the intermediate arm text vectorization model: if the test data shows that the model depth is insufficient and the accuracy is low, the model layers can be increased; if the model complexity is too high and affects the speed, the model layers can be reduced. For model dimension adjustment, you can balance performance and computational efficiency by increasing or decreasing the number of neurons in each layer or the dimension of the embedding vector. After completing these optimization adjustments, retrain the model and verify whether its performance has improved, so as to obtain the optimized and adjusted arm text vectorization model.
[0106] In this embodiment, by gradually adjusting and optimizing the number of model layers and dimensions, feedback is provided in combination with intermediate performance test data to ensure that each step of the adjustment is carried out in the direction of improving model performance. Through this iterative optimization process, the recognition accuracy and speed of the arm text vectorization model can be effectively improved while avoiding unnecessary computational overhead. Ultimately, this method can generate a model with optimal performance on the arm architecture, which not only makes full use of hardware resources, but also ensures the actual application effect of the model, and is suitable for efficient operation in a resource-constrained environment.
[0107] In an exemplary embodiment, as shown in FIG5 , after optimizing the model layers and model dimensions of the intermediate arm text vectorization model according to the model test data to obtain the step of adjusting the arm text vectorization model, the process includes steps 502 to 506. Among them:
[0108] Step 502, prune and adjust the network connections in the arm text vectorization model whose weights are less than a first threshold to obtain a weight-pruned text vectorization model.
[0109] The first threshold may be a specific value set during the model weight pruning process to determine which network connection weights should be pruned.
[0110] Among them, the weight-pruned text vectorization model can be a model obtained after a weight-pruning operation, in which the network connection weights below a certain set threshold have been pruned.
[0111] Specifically, when weight pruning is performed on the adjusted arm text vectorization model, all network connection weights of the adjusted arm text vectorization model are first evaluated to identify those connections whose weights are less than a set first threshold. These low-weight connections are then pruned from the adjusted arm text vectorization model to reduce the complexity and computational complexity of the model, thereby obtaining a weight-pruned text vectorization model.
[0112] Step 504, pruning neurons whose weights are less than a second threshold in the weight-pruned text vectorization model to obtain a neuron-pruned text vectorization model.
[0113] The second threshold may be a value set during the neuron pruning process to determine which neurons should be pruned.
[0114] Among them, the neuron pruning text vectorization model can be a model obtained after a neuron pruning operation, in which neurons whose overall weight or importance is lower than a set threshold have been pruned.
[0115] Specifically, when performing neuron pruning on the weight-pruned text vectorization model, the weight sum or importance score of each neuron in the weight-pruned text vectorization model is first calculated and compared with the set second threshold. For neurons in the weight-pruned text vectorization model whose weight sum or importance score is lower than the second threshold, it is considered that they contribute less to the weight-pruned text vectorization model and are pruned. By pruning these neurons of the weight-pruned text vectorization model, the structure and computational complexity of the model are further simplified, and a more efficient neuron-pruned text vectorization model is obtained.
[0116] Step 506: Use the neuron pruning text vectorization model as the adjusted arm text vectorization model.
[0117] Specifically, when the neuron pruned text vectorization model is used as the adjusted arm text vectorization model, it is confirmed that the model after neuron pruning has completed the pruning of unimportant neurons and has a lighter structure. Then, this pruned neuron pruning text vectorization model is used as the new adjusted arm text vectorization model to replace the previous version for further testing, optimization and deployment.
[0118] In this embodiment, by first pruning the low-weight network connections in the adjusted arm text vectorization model, and then further pruning the low-weight neurons, the computational complexity and memory usage of the model are gradually reduced. This phased pruning strategy not only significantly reduces the scale of the model, but also retains the core features and performance of the model to the greatest extent. Finally, by using the model after neuron pruning as the adjusted arm text vectorization model, a more efficient model operation on the arm architecture is achieved, ensuring good recognition accuracy and speed in a resource-constrained environment.
[0119] In an exemplary embodiment, as shown in FIG6 , after obtaining the target arm text vectorization model, the method further includes steps 602 to 604. Among them:
[0120] Step 602, generating model adjustment data corresponding to the trained text vectorization model according to the target arm text vectorization model.
[0121] Among them, the model adjustment data can be a model code that guides the trained text vectorization model to be deployed or further optimized according to the target arm text vectorization model on the arm architecture to achieve similar performance improvement and resource optimization.
[0122] Specifically, the structural differences between the target arm text vectorization model and the trained text vectorization model are compared, including changes in the number of layers, dimensions, weight distribution, etc. Then, these differences are analyzed to generate a set of model adjustment data, which records in detail the optimization strategy and adjustment parameters of the target arm model, such as the number of pruned layers, changes in the number of neurons, and weight adjustment methods.
[0123] Step 604, reconstructing the model parameters of the trained text vectorization model according to the model adjustment data to obtain a reconstructed text vectorization model.
[0124] Among them, the reconstructed text vectorization model can be a text vectorization model that implements any model function of a trained text vectorization model or a target arm text vectorization model.
[0125] Specifically, the information in the model adjustment data is used to gradually train the structure and parameters of the text vectorization model, that is, to modify the model code of the trained text vectorization model, such as adjusting the number of layers, the number of neurons, and the weight distribution. Then the trained text vectorization model is retrained or fine-tuned to ensure that it can maintain or approach the original performance under the new configuration. Through this reconstruction process, an optimized reconstructed text vectorization model is obtained, which can better adapt to the computing limitations of the target hardware architecture (such as arm) while maintaining a high text processing capability.
[0126] In this embodiment, by generating model adjustment data of the target arm text vectorization model, and using these data to reconstruct the trained model, the reconstructed model can achieve the same function as the original model in different hardware environments (including arm architecture). This process effectively bridges the model performance differences between different architectures, so that the reconstructed text vectorization model not only has efficient operation capabilities, but also can flexibly adapt to a variety of hardware platforms, improves the versatility and applicability of the model, and ensures that a high level of text processing capabilities can be maintained on various devices.
[0127] In an exemplary embodiment, as shown in FIG7 , according to the text vector recognition result, the soft label of the trained text vectorization model is migrated to the initial arm text vectorization model, including steps 702 to 704. Among them:
[0128] Step 702: According to the text vector recognition result, the soft labels of the trained text vectorization model are converted into corresponding label probability distribution information.
[0129] The label probability distribution information may be a set of probability values predicted by the model, which represent the model's confidence level in predicting different labels.
[0130] Specifically, the text vector recognition result obtained by inference of the trained text vectorization model and usually expressed in the form of logits or unnormalized scores is converted into a probability distribution through the softmax function to represent the probability of each possible label, thereby obtaining the label probability distribution information.
[0131] Step 704, applying the label probability distribution information to the initial arm text vectorization model.
[0132] Specifically, the converted label probability distribution information is used as a supervisory signal to train or fine-tune the initial arm text vectorization model. Specifically, these probability distribution information are used as target outputs and compared with the prediction results of the initial arm text vectorization model. By calculating the loss function (such as cross entropy loss), the parameters of the initial arm text vectorization model are gradually adjusted. Through this process, the initial arm model can learn the knowledge in the trained model and achieve similar text vectorization performance on the arm architecture.
[0133] In this embodiment, by converting the soft labels of the trained text vectorization model into label probability distribution information and applying it to the initial arm text vectorization model, effective knowledge transfer is achieved. Using this rich probability distribution information, the initial arm model can learn complex semantic features faster, thereby improving the recognition accuracy and generalization ability of the model. This method not only speeds up the training process of the arm model, but also ensures that on resource-constrained arm devices, the model can maintain a performance level close to the original model, improving the practicality and efficiency of the model.
[0134] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0135] Based on the same inventive concept, the embodiment of the present application also provides a text vectorization model optimization device based on the arm architecture for implementing the text vectorization model optimization method based on the arm architecture involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the embodiments of one or more text vectorization model optimization devices based on the arm architecture provided below can refer to the limitations of a text vectorization model optimization method based on the arm architecture above, and will not be repeated here.
[0136] In an exemplary embodiment, as shown in FIG8 , a text vectorization model optimization device based on an ARM architecture is provided, comprising: a data acquisition module 802 , a model design module 804 , a model training module 806 and a model migration module 808 , wherein:
[0137] A data acquisition module 802 is used to acquire a trained text vectorization model and sample data for transfer;
[0138] The model design module 804 is used to design an initial arm text vectorization model according to the computing power of the arm architecture; the initial arm text vectorization model includes an initial model layer number and an initial model dimension;
[0139] A model training module 806 is used to input the transfer sample data into the trained text vectorization model to obtain a text vector recognition result;
[0140] A model migration module 808 is used to migrate the soft labels of the trained text vectorization model to the initial arm text vectorization model according to the text vector recognition result;
[0141] The model training module 806 is also used to adjust the number of initial model layers and the initial model dimensions according to the recognition speed and the recognition accuracy to obtain an adjusted arm text vectorization model when the recognition speed and / or the recognition accuracy of the initial arm text vectorization model cannot meet the preset value;
[0142] The model training module 806 is also used to use the adjusted arm text vectorization model as the initial arm text vectorization model, and return to execute the step of migrating the soft labels of the trained text vectorization model to the initial arm text vectorization model according to the text vector recognition results, until the recognition speed and / or recognition accuracy of the initial arm text vectorization model meets the preset values, thereby obtaining the target arm text vectorization model.
[0143] In one embodiment, the model training module 806 is also used to input the recognition speed and recognition accuracy into the text model design optimization algorithm to determine the model layer adjustment amount and the model dimension adjustment amount of the arm text vectorization model; the text model design optimization algorithm is used to search for the optimal solution of the model layer adjustment amount and the model dimension adjustment amount; adjust the initial model layer number according to the model layer adjustment amount, and adjust the initial model dimension according to the model dimension adjustment amount to obtain the adjusted arm text vectorization model.
[0144] In one embodiment, the model training module 806 is also used to adjust the initial model layer number according to the model layer number adjustment amount, and adjust the initial model dimension according to the model dimension adjustment amount to obtain an intermediate arm text vectorization model; test the model performance of the intermediate arm text vectorization model to obtain model test data; and optimize the model layer number and model dimension of the intermediate arm text vectorization model according to the model test data to obtain an adjusted arm text vectorization model.
[0145] In one embodiment, the model training module 806 is also used to prune network connections whose weights are less than a first threshold in the adjusted arm text vectorization model to obtain a weight-pruned text vectorization model; prune neurons whose weights are less than a second threshold in the weight-pruned text vectorization model to obtain a neuron-pruned text vectorization model; and use the neuron-pruned text vectorization model as the adjusted arm text vectorization model.
[0146] In one embodiment, the model training module 806 is also used to generate model adjustment data corresponding to the trained text vectorization model according to the target arm text vectorization model; reconstruct the model parameters of the trained text vectorization model according to the model adjustment data to obtain a reconstructed text vectorization model; the reconstructed text vectorization model is any text vectorization model that implements the model function of the trained text vectorization model or the target arm text vectorization model.
[0147] In one embodiment, the model migration module 808 is also used to convert the soft labels of the trained text vectorization model into corresponding label probability distribution information according to the text vector recognition results; and apply the label probability distribution information to the initial arm text vectorization model.
[0148] Each module in the above-mentioned text vectorization model optimization device based on ARM architecture can be implemented in whole or in part by software, hardware and their combination. Each of the above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0149] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG9. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store server data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a text vectorization model optimization method based on the arm architecture is implemented.
[0150] Those skilled in the art will understand that the structure shown in FIG. 9 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0151] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0152] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0153] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-mentioned method embodiments.
[0154] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0155] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0156] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0157] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A text vectorization model optimization method based on arm architecture, characterized in that: The method comprises: Get the trained text vectorization model and sample data for transfer; According to the computing power of the arm architecture, an initial arm text vectorization model is designed; the initial arm text vectorization model includes an initial model layer number and an initial model dimension; Inputting the transfer sample data into the trained text vectorization model to obtain a text vector recognition result; According to the text vector recognition result, the soft label of the trained text vectorization model is migrated to the initial arm text vectorization model; When the recognition speed and / or recognition accuracy of the initial arm text vectorization model cannot meet the preset value, the number of layers of the initial model and the dimension of the initial model are adjusted according to the recognition speed and the recognition accuracy to obtain an adjusted arm text vectorization model; The adjusted arm text vectorization model is used as the initial arm text vectorization model, and the step of migrating the soft labels of the trained text vectorization model to the initial arm text vectorization model according to the text vector recognition result is returned to execute until the recognition speed and / or the recognition accuracy of the initial arm text vectorization model meet the preset values, thereby obtaining the target arm text vectorization model.
2. The method according to claim 1, characterized in that The step of adjusting the number of layers of the initial model and the dimension of the initial model according to the recognition speed and the recognition accuracy to obtain an adjusted arm text vectorization model includes: The recognition speed and the recognition accuracy are input into a text model design optimization algorithm to determine the model layer number adjustment amount and the model dimension adjustment amount of the arm text vectorization model; the text model design optimization algorithm is used to search for the optimal solution of the model layer number adjustment amount and the model dimension adjustment amount; The number of initial model layers is adjusted according to the model layer number adjustment amount, and the initial model dimension is adjusted according to the model dimension adjustment amount to obtain the adjusted arm text vectorization model.
3. The method according to claim 2, characterized in that The step of adjusting the number of initial model layers according to the model layer number adjustment amount, and adjusting the initial model dimension according to the model dimension adjustment amount, to obtain the adjusted arm text vectorization model, includes: Adjusting the number of initial model layers according to the model layer number adjustment amount, and adjusting the initial model dimension according to the model dimension adjustment amount, to obtain an intermediate arm text vectorization model; Testing the model performance of the intermediate arm text vectorization model to obtain model test data; According to the model test data, the model layers and model dimensions of the intermediate arm text vectorization model are optimized to obtain the adjusted arm text vectorization model.
4. The method according to claim 3, characterized in that After optimizing the number of model layers and model dimensions of the intermediate arm text vectorization model according to the model test data to obtain the step of adjusting the arm text vectorization model, the method further includes: Pruning the network connections whose weights are less than the first threshold in the adjusted arm text vectorization model to obtain a weight-pruned text vectorization model; Pruning neurons whose weights are less than a second threshold in the weight-pruned text vectorization model to obtain a neuron-pruned text vectorization model; The neuron pruning text vectorization model is used as the adjusted arm text vectorization model.
5. The method according to claim 1, characterized in that After obtaining the target arm text vectorization model, the method further includes: Generate model adjustment data corresponding to the trained text vectorization model according to the target arm text vectorization model; The model parameters of the trained text vectorization model are reconstructed according to the model adjustment data to obtain a reconstructed text vectorization model; the reconstructed text vectorization model is any text vectorization model that implements the model function of the trained text vectorization model or the target arm text vectorization model.
6. The method according to any one of claims 1 to 5, characterized in that: The step of migrating the soft label of the trained text vectorization model to the initial arm text vectorization model according to the text vector recognition result includes: According to the text vector recognition result, the soft label of the trained text vectorization model is converted into corresponding label probability distribution information; The label probability distribution information is applied to the initial arm text vectorization model.
7. A text vectorization model optimization device based on arm architecture, characterized in that: The device comprises: A data acquisition module is used to obtain the trained text vectorization model and sample data for transfer; A model design module, used to design an initial arm text vectorization model according to the computing power of the arm architecture; the initial arm text vectorization model includes an initial model layer number and an initial model dimension; A model training module, used for inputting the transfer sample data into the trained text vectorization model to obtain a text vector recognition result; A model migration module, used for migrating the soft labels of the trained text vectorization model to the initial arm text vectorization model according to the text vector recognition result; The model training module is also used to adjust the number of layers of the initial model and the dimension of the initial model according to the recognition speed and the recognition accuracy when the recognition speed and / or the recognition accuracy of the initial arm text vectorization model cannot meet the preset value, so as to obtain an adjusted arm text vectorization model; The model training module is also used to use the adjusted arm text vectorization model as the initial arm text vectorization model, return to execute the step of migrating the soft label of the trained text vectorization model to the initial arm text vectorization model according to the text vector recognition result, until the recognition speed and / or the recognition accuracy of the initial arm text vectorization model meets the preset value, thereby obtaining the target arm text vectorization model.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
