Address recognition method, device, equipment and storage medium based on artificial intelligence
By using sequence-to-sequence model training and decoding tree constraints, the performance problem of address recognition models caused by diverse representations is solved, and more accurate and stable address recognition is achieved.
Patent Information
- Application Number
- CN202210817087.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-12
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2042-07-12
AI Technical Summary
Existing address recognition models suffer from low performance due to the diverse ways people express addresses.
A sequence-to-sequence model is used for training, and decoding tree constraints are applied during the training process. The target recognition model is obtained through data augmentation and contrastive learning, and the decoding results are limited using the decoding tree constraint method.
It improves the accuracy and robustness of address recognition, reduces the error probability of text recognition in traditional models, and enhances the artificial intelligence of the address recognition system.
Smart Images

Figure CN115099359B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an address recognition method, device, equipment and storage medium based on artificial intelligence. Background Art
[0002] With the development of e-commerce, electronic navigation, positioning and other technologies, many occasions involve the acquisition, identification and application of address information. For example, in the field of e-commerce, it is necessary to identify and process the communication addresses of customers, or the logistics system needs to identify, locate or plan the route of the address entered by the user.
[0003] The existing address recognition method is generally based on a recognition model of a deep learning model. The address recognition model is obtained through deep learning training and stored in a related device. When a user inputs address-related data, the address recognition model is used to recognize the address-related data input by the user, thereby improving the artificial intelligence of the system. However, the inventors have found that due to the diversity of people's expressions of addresses, this diverse expression interferes with the recognition of the address recognition model, resulting in low address recognition performance of the existing address recognition model. Summary of the invention
[0004] The present invention provides an address recognition method, device, equipment and storage medium based on artificial intelligence to solve the problem that the address recognition performance of the existing address recognition model is not high due to the diversity of people's expression of addresses.
[0005] Provided is an address recognition method based on artificial intelligence, comprising:
[0006] Obtain multiple address samples and a preset recognition model, where the preset recognition model is a sequence-to-sequence model;
[0007] Based on multiple address samples, a preset recognition model is trained, and during the training process, a decoding tree constraint is applied to the preset recognition model to obtain a model to be tested;
[0008] Testing the model to be tested until the performance of the model to be tested meets the preset performance conditions, and outputting the model to be tested that meets the preset performance conditions as a target recognition model;
[0009] When an address recognition instruction is received, the target recognition model is called to perform address recognition on the data to be recognized.
[0010] Furthermore, the preset recognition model is trained based on multiple address samples, and a decoding tree constraint is performed on the preset recognition model during the training process to obtain a model to be tested, including:
[0011] Perform data enhancement processing on multiple address samples to obtain positive address sample pairs corresponding to each address sample;
[0012] The positive address sample pairs corresponding to the address samples are input into the preset recognition model for contrastive learning training, and the preset recognition model is subjected to decoding tree constraints during the training process to obtain contrastive learning loss values of the positive address sample pairs;
[0013] Determine the total loss value based on the contrastive learning loss value;
[0014] When the total loss value does not reach the preset convergence condition, the initial parameters of the preset recognition model are iteratively updated until the total loss value reaches the preset convergence condition, and the converged preset recognition model is recorded as the model to be tested.
[0015] Furthermore, the positive address sample pair corresponding to the address sample is input into the preset recognition model for contrastive learning training, and the preset recognition model is subjected to decoding tree constraints during the training process to obtain the contrastive learning loss value of the positive address sample pair, including:
[0016] Obtaining a positive address sample pair obtained by performing data enhancement processing on the address sample, the positive address sample pair comprising a first enhanced address sample and a second enhanced address sample;
[0017] Inputting the first enhanced address sample into a preset recognition model to encode a first encoding vector, and performing a decoding tree constraint when decoding the first encoding vector to obtain a first predicted address;
[0018] Inputting the second enhanced address sample into a preset recognition model to encode a second encoding vector, and performing a decoding tree constraint when decoding the second encoding vector to obtain a second predicted address;
[0019] A contrastive learning loss between the first predicted address and the second predicted address is determined to obtain a contrastive learning loss value.
[0020] Furthermore, when decoding the first encoding vector, a decoding tree constraint is performed to obtain a first predicted address, including:
[0021] Performing a sequence search based on a beam search algorithm on the first coding vector to obtain a plurality of sequences to be constrained for decoding;
[0022] A pruning algorithm is used to constrain each decoding sequence to be constrained, and multiple candidate decoding sequences are obtained;
[0023] The candidate decoding sequences are scored based on the beam search algorithm, and the candidate decoding sequence with the largest score is selected as the first predicted address.
[0024] Furthermore, the total loss value is determined according to the contrastive learning loss value, including:
[0025] Calculate the loss value between the standard address label of the address sample and the first predicted address, and record it as the first loss value;
[0026] Calculate the loss value between the standard address label and the second predicted address, and record it as the second loss value;
[0027] A total loss value is determined based on the contrastive learning loss value, the first loss value, and the second loss value.
[0028] Furthermore, the model to be tested is tested, including:
[0029] Using the model to be tested to perform address recognition on the address sample, and obtaining the recognition address of the address sample by the model to be tested;
[0030] Calculate the similarity between the recognized address and the standard address label of the address sample;
[0031] Determine whether the similarity is greater than a preset similarity;
[0032] If the similarity is greater than the preset similarity, it is determined that the performance of the model to be tested meets the preset performance condition.
[0033] Further, when the address recognition instruction is received, the target recognition model is called to perform address recognition on the data to be recognized, including:
[0034] Compile and optimize the target recognition model to obtain the target code of the target recognition model;
[0035] The target code is deployed to the target device so that when the target device receives the address recognition instruction, it runs the target code to call the target recognition model to perform address recognition on the data to be recognized.
[0036] Provided is an address recognition device based on artificial intelligence, comprising:
[0037] An acquisition module, used for acquiring multiple address samples and a preset recognition model, where the preset recognition model is a sequence-to-sequence model;
[0038] A training module is used to perform model training on a preset recognition model based on multiple address samples, and to perform decoding tree constraints on the preset recognition model during the training process to obtain a model to be tested through training;
[0039] The testing module is used to test the model to be tested until the performance of the model to be tested meets the preset performance conditions, and then output the model to be tested that meets the preset performance conditions as a target recognition model;
[0040] The recognition module is used to call the target recognition model to perform address recognition on the data to be recognized when receiving the address recognition instruction.
[0041] A computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned artificial intelligence-based address recognition method when executing the computer program.
[0042] A computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and wherein the computer program implements the steps of the above-mentioned artificial intelligence-based address recognition method when executed by a processor.
[0043] In a solution provided by the above-mentioned artificial intelligence-based address recognition method, device, equipment and storage medium, multiple address samples and preset recognition models are obtained, the preset recognition model is a sequence-to-sequence model, and then the preset recognition model is trained based on multiple address samples, and the preset recognition model is subjected to decoding tree constraints during the training process, the model to be tested is trained to obtain the model to be tested, and the model to be tested is tested until the performance of the model to be tested meets the preset performance conditions, and the model to be tested that meets the preset performance conditions is output as a target recognition model, so that when an address recognition instruction is received, the target recognition model is called to perform address recognition on the data to be recognized; in the present invention, the target recognition model is obtained by sequence-to-sequence seq2seq structure training, so that when the target recognition model is subsequently used for data recognition, address resolution and recognition can be performed in an end-to-end manner, thereby improving the robustness of the target recognition model. At the same time, during the recognition process, the decoding result is constrained by the decoding tree constraint method, so that the decoding result is limited to address characters, reducing the probability of text recognition errors of the traditional seq2seq model, and improving the accuracy of address recognition by the target recognition model, thereby improving the performance of the target recognition model. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0045] Figure 1 is a schematic diagram of an application environment of an address recognition method based on artificial intelligence in one embodiment of the present invention;
[0046] Figure 2 is a flow chart of an address recognition method based on artificial intelligence in one embodiment of the present invention;
[0047] Figure 3 yes Figure 2 A schematic diagram of an implementation process of step S20;
[0048] Figure 4 yes Figure 3 A schematic diagram of an implementation process of step S22;
[0049] Figure 5 yes Figure 4 A schematic diagram of an implementation process of step S222;
[0050] Figure 6 yes Figure 3 A schematic diagram of an implementation process of step S23;
[0051] Figure 7 yes Figure 2 A schematic diagram of an implementation process of step S30;
[0052] Figure 8 yes Figure 2 A schematic diagram of an implementation process of step S40;
[0053] Fig. 9 is a structural schematic diagram of an address recognition device based on artificial intelligence in one embodiment of the present invention;
[0054] Fig.10 It is a structural diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0055] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0056] The address recognition method based on artificial intelligence provided by the embodiment of the present invention can be applied in Figure 1In an application environment, the terminal device communicates with the server through a network. The server obtains multiple address samples and a preset recognition model, the preset recognition model is a sequence-to-sequence model, and then trains the preset recognition model based on the multiple address samples, and performs decoding tree constraints on the preset recognition model during the training process, trains to obtain a model to be tested, and tests the model to be tested until the performance of the model to be tested meets the preset performance conditions, and then outputs the model to be tested that meets the preset performance conditions as a target recognition model; when the trained target recognition model is needed to perform an address recognition task, the user sends the data to be recognized to the server through the terminal device, and when the server receives the address recognition instruction, it calls the target recognition model to perform address recognition on the data to be recognized, and obtains the address. address recognition result; in this embodiment, the target recognition model is obtained by sequence-to-sequence seq2seq structure training, so that when the target recognition model is subsequently used for data recognition, address resolution and recognition can be performed in an end-to-end manner, thereby improving the robustness of the target recognition model. At the same time, during the recognition process, the decoding result is constrained by the decoding tree constraint method, so that the decoding result is limited to the address character, reducing the probability of text recognition error of the traditional seq2seq model, and improving the accuracy of address recognition by the target recognition model, thereby improving the performance of the target recognition model, and then improving the artificial intelligence of the address recognition system, providing strong support for subsequent decision-making, and enhancing the user experience.
[0057] In this embodiment, multiple address samples and preset recognition models, trained target recognition models and other data, as well as subsequent data to be recognized, can be stored in the database of the server, so that when the recognition model training task or address recognition task is subsequently executed, the relevant data can be directly obtained from the database according to the needs, so as to reduce the model training time or address recognition time, thereby improving the efficiency of model training or address recognition efficiency.
[0058] The database in this embodiment is stored in the blockchain network, and is used to store the data used and generated in the recognition model training method or the address recognition method, such as multiple address samples and preset recognition models, trained target recognition models, data to be recognized and other related data. The blockchain referred to in this application is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods, each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. The blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer. Deploying the database on the blockchain can improve the security of data storage.
[0059] The terminal device (client) may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices. The server may be implemented as an independent server or a server cluster consisting of multiple servers.
[0060] In one embodiment, if Figure 2 As shown, an address recognition method based on artificial intelligence is provided, and the method is applied in Figure 1 The server in the example is used as an example to illustrate the process, including the following steps:
[0061] S10: Acquire multiple address samples and a preset recognition model.
[0062] When receiving a model training task, the server needs to obtain multiple address samples and a preset recognition model, so as to train the preset recognition model according to the multiple address samples to obtain a target recognition model for address recognition. Among them, the preset recognition model is a sequence-to-sequence model, that is, a Sequence-to-Sequence model, referred to as a Seq2Seq model. The Seq2Seq model is an encoding-decoding neural network structure composed of a bidirectional recurrent neural network, which meets the situation where the input and output sequence lengths are different and realizes the conversion between one sequence and another sequence. For example, in the encoding stage, the encoding layer (Encoder) of the Seq2seq model encodes the input sequence (such as a Chinese sentence) into a hidden layer vector; in the decoding stage, the decoding layer (Decoder) of the Seq2seq model decodes the hidden layer vector into an output sequence (such as an English sentence). The target recognition model is obtained by training the Seq2seq model with multiple address samples, so that the target recognition model is also a Seq2seq model, which can directly input the data to be recognized into the target recognition model for encoding to decoding processing during the recognition process, thereby outputting the address recognition result, realizing an end-to-end address recognition process, and improving the robustness of the address recognition system.
[0063] Among them, multiple address samples are obtained by: obtaining historical address data input by the user, performing standardized address recognition on the historical address data, obtaining a standard address label corresponding to each historical address data, and then recording the historical address data as an address sample to obtain multiple address samples, each address sample corresponding to a standard address label.
[0064] For example, if the historical address data is: No. 20, Keji South 12th Road, XXXX City, then the standard address label of the historical address data is: No. 20, Keji South 12th Road, XXXX District, XXXX City.
[0065] S20: Performing model training on a preset recognition model based on multiple address samples, and performing decoding tree constraints on the preset recognition model during the training process to obtain a model to be tested through training.
[0066] After obtaining multiple address samples and a preset recognition model, model training is performed on the preset recognition model based on the multiple address samples, and during the training process, a decoding tree constraint is performed on the preset recognition model to obtain a to-be-tested model that meets convergence conditions.
[0067] S30: Testing the model to be tested until the performance of the model to be tested meets the preset performance conditions, and then outputting the model to be tested that meets the preset performance conditions as a target recognition model.
[0068] After obtaining the model to be tested, the model to be tested is tested until the performance of the model to be tested meets the preset performance conditions, and the model to be tested that meets the preset performance conditions is output as a target recognition model.
[0069] S40: When an address recognition instruction is received, a target recognition model is called to perform address recognition on the data to be recognized.
[0070] After obtaining the target recognition model, the server can keep the target recognition model in the database. When the user inputs the data to be recognized and needs to perform address recognition, the server sends an address recognition instruction to the server. When the server receives the address recognition instruction, it calls the target recognition model to perform address recognition on the data to be recognized and outputs the address recognition result.
[0071] After obtaining the target recognition model, the server can also deploy the target recognition model to the target device, so that when the user uses the target device to input the data to be recognized, an address recognition instruction is generated and sent to the target device. After the target device receives the address recognition instruction and the data to be recognized, it calls the target recognition model to perform address recognition on the data to be recognized; the target recognition model is deployed to the target device through offline deployment, so that the target device can directly call the target recognition model for address recognition, which integrates the address recognition system architecture, greatly reduces system components, improves offline deployability and reduces system complexity.
[0072] In one embodiment, if Figure 3 As shown, in step S20, the preset recognition model is trained based on multiple address samples, and the preset recognition model is subjected to decoding tree constraints during the training process to obtain a model to be tested, which specifically includes the following steps:
[0073] S21: Perform data enhancement processing on multiple address samples to obtain a positive address sample pair corresponding to each address sample.
[0074] After obtaining multiple address samples, data enhancement processing is performed on each address sample to obtain two different enhanced address samples: a first enhanced address sample and a second enhanced address sample. The first enhanced address sample and the second enhanced address sample are combined into a positive address sample pair. The positive address sample pair corresponding to the address sample is traversed through all address samples until a positive address sample pair corresponding to each address sample is obtained, so that the preset recognition model can be compared and learned based on the positive address sample pairs corresponding to each address sample. Among them, the data enhancement method can be random inactivation (dropout). By implementing data enhancement through dropout, multiple address samples can be quickly obtained for model training, which is conducive to improving the model training effect.
[0075] S22: Inputting the positive address sample pair corresponding to the address sample into the preset recognition model for contrastive learning training, and performing decoding tree constraints on the preset recognition model during the training process to obtain the contrastive learning loss value of the positive address sample pair.
[0076] After obtaining the positive address sample pair corresponding to each address sample, the positive address sample pair corresponding to an address sample is input into the preset recognition model for contrastive learning training to obtain the contrastive learning loss value of the positive address sample pair. In the contrastive learning training process, the preset recognition model needs to be subjected to decoding tree constraints so that the output decoding result is limited to a certain address range.
[0077] The contrastive learning loss value may be a distance function value obtained by calculating the distance between features corresponding to two enhanced address samples in an address sample pair using a distance algorithm.
[0078] S23: Determine a total loss value according to the contrastive learning loss value.
[0079] S24: When the total loss value does not reach the preset convergence condition, iteratively update the initial parameters of the preset recognition model until the total loss value reaches the preset convergence condition, and record the converged preset recognition model as the model to be tested.
[0080] The positive address sample pair corresponding to the address sample is input into the preset recognition model for comparative learning training, and the comparative learning loss value of the positive address sample pair is obtained, and it is determined whether the total loss value reaches the convergence condition. If the total loss value does not reach the convergence condition, it means that the model parameters do not meet the requirements, and the model needs to be trained further. The above steps (i.e., steps S22-S23) are repeated to iteratively update the initial parameters of the preset recognition model until the total loss value reaches the convergence condition, indicating that the model parameters meet the accuracy requirements, and the converged preset recognition model is recorded as the target recognition model.
[0081] In other embodiments, the model to be tested can also be trained in other ways. For example, the address sample can be input into a preset recognition model for context encoding to obtain a coding vector, and then the coding vector is decoded, and the decoding result is subjected to decoding tree constraints in the process, so as to complete the address recognition and obtain the predicted address of the address sample, and then calculate the classification loss of the predicted address and the standard address label of the address sample to obtain the total loss value, and then when the total loss value does not reach the preset convergence condition, the initial parameters of the preset recognition model are iteratively updated until the total loss value reaches the preset convergence condition, and the converged preset recognition model is recorded as the model to be tested.
[0082] In this embodiment, data enhancement processing is performed on the address samples to obtain positive address sample pairs corresponding to the address samples, and then the positive address sample pairs corresponding to the address samples are input into the preset recognition model for comparative learning training, and the preset recognition model is subjected to decoding tree constraints during the training process to obtain the comparative learning loss value of the positive address sample pairs, and the total loss value is determined based on the comparative learning loss value. When the total loss value does not reach the preset convergence condition, the initial parameters of the preset recognition model are iteratively updated until the total loss value reaches the preset convergence condition, and the converged preset recognition model is recorded as the model to be tested. The specific steps of training the preset recognition model based on multiple address samples, subjecting the preset recognition model to decoding tree constraints during the training process, and training to obtain the model to be tested are clarified. The preset recognition model is trained by comparative learning, which improves the training effect of the model, thereby improving the accuracy of the target recognition model.
[0083] In one embodiment, if Figure 4 As shown, in step S22, the positive address sample pair corresponding to the address sample is input into the preset recognition model for contrastive learning training, and the preset recognition model is subjected to decoding tree constraints during the training process to obtain the contrastive learning loss value of the positive address sample pair, which specifically includes the following steps:
[0084] S221: Obtain positive address sample pairs obtained by performing data enhancement processing on the address samples.
[0085] After performing data enhancement processing on the address sample, a positive address sample pair obtained by performing data enhancement processing on the address sample is obtained, wherein the positive address sample pair includes a first enhanced address sample and a second enhanced address sample.
[0086] S222: Input the first enhanced address sample into a preset recognition model to encode a first encoding vector, and perform decoding tree constraints when decoding the first encoding vector to obtain a first predicted address.
[0087] After obtaining a positive address sample pair obtained by performing data enhancement processing on the address sample, the first enhanced address sample is input into a preset recognition model to encode the obtained first encoding vector, and a decoding tree constraint is performed when decoding the first encoding vector to obtain a first predicted address.
[0088] Among them, the first enhanced address sample is input into the encoding layer of the preset recognition model, so that the first enhanced address sample is context-encoded in the encoding layer to obtain a first encoding vector, and then the first encoding vector output by the encoding layer is input into the decoding layer of the preset recognition model, so that the first encoding vector is decoded in the decoding layer and decoding tree constraints are performed during the decoding process to obtain a first predicted address.
[0089] S223: Input the second enhanced address sample into a preset recognition model to encode a second encoding vector, and perform decoding tree constraints when decoding the second encoding vector to obtain a second predicted address.
[0090] Then, the second enhanced address sample is input into a preset recognition model to encode a second encoding vector, and a decoding tree constraint is performed when decoding the second encoding vector to obtain a second predicted address.
[0091] Among them, the second enhanced address sample is input into the encoding layer of the preset recognition model, so that the second enhanced address sample is context-encoded in the encoding layer to obtain a second encoding vector, and then the second encoding vector output by the encoding layer is input into the decoding layer of the preset recognition model, so that the second encoding vector is decoded in the decoding layer and decoding tree constraints are performed during the decoding process to obtain a second predicted address.
[0092] S224: Determine a comparative learning loss between the first predicted address and the second predicted address to obtain a comparative learning loss value.
[0093] A contrastive learning loss between the first predicted address and the second predicted address is determined to obtain a contrastive learning loss value.
[0094] Among them, the contrastive learning loss value is calculated as follows:
[0095]
[0096] Where N represents the number of address samples, that is, for a batch of N address samples, N pairs of positive address samples are obtained through data enhancement, and there are 2N address samples in total; i is the first enhanced address sample, z j is the second enhanced address sample, z kis the second enhanced address sample except the second enhanced address sample, k is not equal to i, that is, for a given positive address sample pair, the remaining address sample pairs are all negative address samples. In the above formula, sim() represents the calculation formula of cosin similarity; T is the temperature coefficient.
[0097] It can be seen from the above formula that only the distance of the positive address sample pairs is calculated in the numerator, and the negative address sample pairs only appear in the denominator of the contrast loss. The smaller the direct distance of the positive address sample pairs and the larger the distance of the negative address sample pairs, the smaller the contrast learning loss value.
[0098] In this embodiment, a positive address sample pair is obtained by performing data enhancement processing on the address sample, the positive address sample pair includes a first enhanced address sample and a second enhanced address sample, and then the first enhanced address sample is input into a preset recognition model to encode a first encoding vector, and a decoding tree constraint is performed when decoding the first encoding vector to obtain a first predicted address, and the second enhanced address sample is input into the preset recognition model to encode a second encoding vector, and a decoding tree constraint is performed when decoding the second encoding vector to obtain a second predicted address, and finally the comparative learning loss between the first predicted address and the second predicted address is determined to obtain a comparative learning loss value, which clarifies the specific process of inputting the positive address sample pair corresponding to the address sample into the preset recognition model for comparative learning training to obtain the comparative learning loss value of the positive address sample pair, which provides a basis for training to obtain an accurate target recognition model.
[0099] In one embodiment, if Figure 5 As shown, in step S222, that is, performing decoding constraints when decoding the first coding vector to obtain the first predicted address, specifically includes the following steps:
[0100] S2221: performing a sequence search based on a beam search algorithm on the first coding vector to obtain a plurality of sequences to be constrained for decoding;
[0101] S2222: using a pruning algorithm to perform sequence constraints on each decoding sequence to be constrained, to obtain multiple candidate decoding sequences;
[0102] S2222: Score the candidate decoding sequences based on the beam search algorithm, and select the candidate decoding sequence with the largest score as the first predicted address.
[0103] After obtaining the positive address sample pair corresponding to the address sample (including the first enhanced address sample and the second enhanced address sample), the first enhanced address sample is input into the encoding layer of the preset recognition model to context-encode the first enhanced address sample in the encoding layer to obtain the first encoding vector, and then the first encoding vector output by the encoding layer is input into the decoding layer of the preset recognition model to decode the first encoding vector in the decoding layer and perform decoding tree constraints in the decoding process, wherein the decoding of the first encoding vector and the decoding tree constraints in the decoding process specifically include the following steps, namely, the following steps are implemented in the decoding layer: a sequence search based on a beam search algorithm (beamsearch) is performed on the first encoding vector to obtain multiple decoding sequences to be constrained; and a pruning algorithm is used to perform sequence constraints on each decoding sequence to be constrained to obtain multiple candidate decoding sequences; finally, the candidate decoding sequences are scored based on the beam search algorithm, and the candidate decoding sequence with the largest score is selected as the first predicted address. In addition, the acquisition process of the second predicted address is consistent with the acquisition process of the first predicted address, which will not be repeated here.
[0104] Among them, a pruning algorithm is used to constrain each decoding sequence to be constrained. In the process of obtaining multiple candidate decoding sequences, in order to restrict the address sequence obtained by decoding, it is necessary to prune each decoding sequence to be constrained according to the preset standard address pre-tree, so as to obtain multiple candidate decoding sequences after pruning. This process is called decoding tree pruning. Among them, the standard address in the preset standard address pre-tree is a standardized address obtained by subdividing the administrative regions of different countries. For example, taking China as an example, the administrative divisions include provinces (autonomous regions), cities, counties (districts), towns (roads), etc., then the standard address is a certain province (autonomous region), a certain city, a certain county (district), and a certain town (road).
[0105] Different from traditional decoding, this embodiment implements constraints on the decoding tree by pruning the decoding sequence, limiting the decoding sequence to text containing only standard addresses, ensuring the standardization of the output predicted address, and enabling the output of a standard address even if the address input by the user is in a different form. This is simple and convenient, and ensures that the target recognition model can output a standard address that meets the requirements, thereby improving the accuracy of address recognition.
[0106] In this embodiment, a sequence search based on a beam search algorithm is performed on the first coding vector to obtain multiple decoding sequences to be constrained, and then a pruning algorithm is used to perform sequence constraints on each decoding sequence to be constrained to obtain multiple candidate decoding sequences. The candidate decoding sequences are scored based on the beam search algorithm, and the candidate decoding sequence with the largest score is selected as the first prediction address. The process of performing decoding tree constraints when decoding the first coding vector to obtain the first prediction address is clarified, thereby ensuring the accuracy of the first prediction address and thus ensuring the performance of the target recognition model obtained by subsequent training.
[0107] In one embodiment, if Figure 6 As shown, in step S23, the total loss value is determined according to the contrastive learning loss value, which specifically includes the following steps:
[0108] S231: Calculate the loss value between the standard address label of the address sample and the first predicted address, and record it as the first loss value.
[0109] S232: Calculate the loss value between the standard address label and the second predicted address, and record it as the second loss value;
[0110] S233: Determine a total loss value according to the comparative learning loss value, the first loss value, and the second loss value.
[0111] In this embodiment, each address sample corresponds to a standard address label. After the address sample is subjected to data enhancement processing to obtain a positive address sample pair including a first enhanced address sample and a second enhanced address sample, the first enhanced address sample and the second enhanced address sample are respectively input into a preset recognition model for address prediction and recognition, and the first predicted address corresponding to the first enhanced address sample and the second predicted address of the second enhanced address sample are obtained; then, the loss value between the standard address label and the first predicted address of the address sample is calculated, recorded as the first loss value, and the loss value between the standard address label and the second predicted address is calculated, recorded as the second loss value; finally, the total loss value is determined based on the contrastive learning loss value, the first loss value, and the second loss value. Among them, the first loss value is the classification loss value between the standard address label and the first predicted address, and the second loss value is the classification loss value between the standard address label and the second predicted address, both of which can be calculated by the cross entropy loss function.
[0112] The total loss value is calculated by the following formula:
[0113]
[0114] Among them, L represents the total loss value; L1 represents the first loss value; 2 represents the second loss value; L0 represents the contrastive learning loss value; α represents the weight factor, which can be calibrated according to needs.
[0115] In this embodiment, the loss value between the standard address label of the address sample and the first predicted address is calculated, recorded as the first loss value, and the loss value between the standard address label and the second predicted address is calculated, recorded as the second loss value, and then the total loss value is determined based on the comparative learning loss value, the first loss value and the second loss value. The specific steps for determining the total loss value based on the comparative learning loss value are clarified, which provides a basis for obtaining a converged preset recognition model subsequently. The total loss value is determined by comparing the learning loss value, the first loss value and the second loss value, which improves the accuracy of the total loss value, thereby improving the accuracy of the target recognition model obtained by subsequent training.
[0116] In one embodiment, if Figure 7 As shown, in step S30, the model to be tested is tested, which specifically includes the following steps:
[0117] S31: using the model to be tested to perform address recognition on the address sample, and obtaining the recognition address of the address sample by the model to be tested;
[0118] S32: Calculate the similarity between the recognized address and the standard address label of the address sample;
[0119] S33: Determine whether the similarity is greater than a preset similarity;
[0120] S34: If the similarity is greater than a preset similarity, it is determined that the performance of the model to be tested meets a preset performance condition.
[0121] After obtaining the model to be tested, the address sample is identified by the model to be tested to obtain the identified address of the address sample by the model to be tested, and then the similarity between the identified address and the standard address label of the address sample is calculated, and it is determined whether the similarity is greater than the preset similarity. If the similarity is greater than the preset similarity, it is determined that the performance of the model to be tested meets the preset performance condition; if the similarity is less than or equal to the preset similarity, it is determined that the performance of the model to be tested does not meet the preset performance condition, and steps S20-S30 need to be repeated until the performance of the model to be tested meets the preset performance condition. The preset similarity can be 90.
[0122] The similarity can be calculated by performing an edit distance calculation on the standard address label of the identified address and the address sample, and the calculated edit distance is used as the similarity between the standard address label of the identified address and the address sample.
[0123] In this embodiment, the model to be tested is used to perform address recognition on the address sample to obtain the recognition address of the address sample by the model to be tested, and the similarity between the recognition address and the standard address label of the address sample is calculated to determine whether the similarity is greater than a preset similarity; if the similarity is greater than the preset similarity, it is determined that the performance of the model to be tested meets the preset performance conditions, and the specific steps for testing the model to be tested are clarified. Based on the similarity between the recognition address and the standard address label of the address sample, it is determined whether the model performance meets the preset performance conditions. On the basis of ensuring the model performance, the method is simple, effective and easy to execute.
[0124] In one embodiment, if Figure 8 As shown, in step S40, that is, when the address recognition instruction is received, the target recognition model is called to perform address recognition on the data to be recognized, which specifically includes the following steps:
[0125] S41: compile and optimize the target recognition model to obtain the target code of the target recognition model.
[0126] After obtaining the target recognition model, the server compiles and optimizes the target recognition model to obtain the target code of the target recognition model. The target recognition model can be input into a compiler, such as a Tensor Virtual Machine (TVM) or an Auto Tensor Virtual Machine (AutoTVM), to compile and optimize the face recognition model for deep learning through a compiler such as TVM or AutoTVM, and then obtain the compiled code output by the compiler as the target code of the face recognition model.
[0127] S42: deploying the target code to the target device, so that when the target device receives the address recognition instruction, it runs the target code to call the target recognition model to perform address recognition on the data to be recognized.
[0128] After the server deploys the target code to the target device, the target device needs to determine in real time whether it has received the face recognition command sent by the user. When receiving the face recognition command, the target device needs to obtain the address data entered by the user through the target device as the data to be recognized, and run the target code to call the face recognition model to perform address recognition on the data to be recognized to obtain the address recognition result.
[0129] It should be understood that, because address data is sensitive, most people hope to be able to perform address recognition tasks on terminal devices or even edge devices, so as to ensure that data does not go out, reduce the possibility of data leakage, and improve user privacy security. In this embodiment, a target recognition model obtained by training a sequence-to-sequence model is adopted. On the basis of ensuring the recognition accuracy, the target recognition model is compiled and optimized to obtain the target code of the target recognition model, which can reduce the amount of code, and then the target code is deployed to the target device, thereby reducing the operating cost of the target recognition model, solving the problem of cross-device deployment, so that data input, processing and output are all on the same target device, reducing the number of components of the address recognition system, and the additional cost is relatively cheap. It can also solve the problem of data leakage and improve the artificial intelligence of address recognition, thereby improving the efficiency of address recognition work.
[0130] In this embodiment, the target recognition model is compiled and optimized to obtain the target code of the target recognition model, and then the target code is deployed to the target device so that when the target device receives the address recognition instruction, it runs the target code to call the target recognition model to perform address recognition on the data to be recognized. This reduces the number of components of the address recognition system, the additional cost is relatively cheap, and it can solve the problem of data leakage and ensure the security of the address recognition process.
[0131] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0132] In one embodiment, an address recognition device based on artificial intelligence is provided, and the address recognition device based on artificial intelligence corresponds one-to-one with the address recognition method based on artificial intelligence in the above embodiment. Fig. 9 As shown, the address recognition device based on artificial intelligence includes an acquisition module 901, a training module 902, a test module 903 and a recognition module 904. The detailed description of each functional module is as follows:
[0133] An acquisition module 901 is used to acquire multiple address samples and a preset recognition model, where the preset recognition model is a sequence-to-sequence model;
[0134] A training module 902 is used to perform model training on a preset recognition model based on multiple address samples, and to perform decoding tree constraints on the preset recognition model during the training process to obtain a model to be tested through training;
[0135] The testing module 903 is used to test the model to be tested until the performance of the model to be tested meets the preset performance conditions, and then output the model to be tested that meets the preset performance conditions as a target recognition model;
[0136] The recognition module 904 is used to call the target recognition model to perform address recognition on the data to be recognized when receiving the address recognition instruction.
[0137] Furthermore, the training module 902 is specifically used for:
[0138] Perform data enhancement processing on multiple address samples to obtain positive address sample pairs corresponding to each address sample;
[0139] The positive address sample pairs corresponding to the address samples are input into the preset recognition model for contrastive learning training, and the preset recognition model is subjected to decoding tree constraints during the training process to obtain contrastive learning loss values of the positive address sample pairs;
[0140] Determine the total loss value based on the contrastive learning loss value;
[0141] When the total loss value does not reach the preset convergence condition, the initial parameters of the preset recognition model are iteratively updated until the total loss value reaches the preset convergence condition, and the converged preset recognition model is recorded as the model to be tested.
[0142] Furthermore, the training module 902 is also specifically used for:
[0143] Obtaining a positive address sample pair obtained by performing data enhancement processing on the address sample, the positive address sample pair comprising a first enhanced address sample and a second enhanced address sample;
[0144] Inputting the first enhanced address sample into a preset recognition model to encode a first encoding vector, and performing a decoding tree constraint when decoding the first encoding vector to obtain a first predicted address;
[0145] Inputting the second enhanced address sample into a preset recognition model to encode a second encoding vector, and performing a decoding tree constraint when decoding the second encoding vector to obtain a second predicted address;
[0146] A contrastive learning loss between the first predicted address and the second predicted address is determined to obtain a contrastive learning loss value.
[0147] Furthermore, the training module 902 is also specifically used for:
[0148] Performing a sequence search based on a beam search algorithm on the first coding vector to obtain a plurality of sequences to be constrained for decoding;
[0149] A pruning algorithm is used to constrain each decoding sequence to be constrained, and multiple candidate decoding sequences are obtained;
[0150] The candidate decoding sequences are scored based on the beam search algorithm, and the candidate decoding sequence with the largest score is selected as the first predicted address.
[0151] Furthermore, the training module 902 is also specifically used for:
[0152] Calculate the loss value between the standard address label of the address sample and the first predicted address, and record it as the first loss value;
[0153] Calculate the loss value between the standard address label and the second predicted address, and record it as the second loss value;
[0154] A total loss value is determined based on the contrastive learning loss value, the first loss value, and the second loss value.
[0155] Furthermore, the testing module 903 is specifically used for:
[0156] Using the model to be tested to perform address recognition on the address sample, and obtaining the recognition address of the address sample by the model to be tested;
[0157] Calculate the similarity between the recognized address and the standard address label of the address sample;
[0158] Determine whether the similarity is greater than a preset similarity;
[0159] If the similarity is greater than the preset similarity, it is determined that the performance of the model to be tested meets the preset performance condition.
[0160] Furthermore, the identification module 904 is specifically used for:
[0161] Compile and optimize the target recognition model to obtain the target code of the target recognition model;
[0162] The target code is deployed to the target device so that when the target device receives the address recognition instruction, it runs the target code to call the target recognition model to perform address recognition on the data to be recognized.
[0163] For the specific definition of the address recognition device based on artificial intelligence, please refer to the definition of the address recognition method based on artificial intelligence above, which will not be repeated here. Each module in the above-mentioned address recognition device based on artificial intelligence can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned 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 of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0164] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.10As shown. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. 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 for... (fill in the functional definition of the database). The network 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, an address recognition method based on artificial intelligence is implemented.
[0165] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0166] Obtain multiple address samples and a preset recognition model, where the preset recognition model is a sequence-to-sequence model;
[0167] Based on multiple address samples, a preset recognition model is trained, and during the training process, a decoding tree constraint is applied to the preset recognition model to obtain a model to be tested;
[0168] Testing the model to be tested until the performance of the model to be tested meets the preset performance conditions, and outputting the model to be tested that meets the preset performance conditions as a target recognition model;
[0169] When an address recognition instruction is received, the target recognition model is called to perform address recognition on the data to be recognized.
[0170] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0171] Obtain multiple address samples and a preset recognition model, where the preset recognition model is a sequence-to-sequence model;
[0172] Based on multiple address samples, a preset recognition model is trained, and during the training process, a decoding tree constraint is applied to the preset recognition model to obtain a model to be tested;
[0173] Testing the model to be tested until the performance of the model to be tested meets the preset performance conditions, and outputting the model to be tested that meets the preset performance conditions as a target recognition model;
[0174] When an address recognition instruction is received, the target recognition model is called to perform address recognition on the data to be recognized.
[0175] 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 memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0176] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0177] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. An address recognition method based on artificial intelligence, characterized in that: include: Acquire multiple address samples and a preset recognition model, wherein the preset recognition model is a sequence-to-sequence model; Performing model training on the preset recognition model based on the plurality of address samples, and performing decoding tree constraints on the preset recognition model during the training process, so as to obtain a model to be tested through training; Testing the model to be tested until the performance of the model to be tested meets a preset performance condition, and outputting the model to be tested that meets the preset performance condition as a target recognition model; When receiving the address recognition instruction, calling the target recognition model to perform address recognition on the data to be recognized; The step of training the preset recognition model based on the plurality of address samples and performing decoding tree constraints on the preset recognition model during the training process to obtain a model to be tested includes: Performing data enhancement processing on the plurality of address samples to obtain a positive address sample pair corresponding to each address sample; Inputting the positive address sample pair corresponding to the address sample into the preset recognition model for contrastive learning training, and performing decoding tree constraints on the preset recognition model during the training process to obtain a contrastive learning loss value of the positive address sample pair; Determining a total loss value according to the contrastive learning loss value; When the total loss value does not reach the preset convergence condition, iteratively updating the initial parameters of the preset recognition model until the total loss value reaches the preset convergence condition, and recording the converged preset recognition model as a model to be tested; The step of inputting the positive address sample pair corresponding to the address sample into the preset recognition model for contrastive learning training, and performing decoding tree constraints on the preset recognition model during the training process to obtain the contrastive learning loss value of the positive address sample pair includes: Obtaining a positive address sample pair obtained by performing data enhancement processing on the address sample, the positive address sample pair comprising a first enhanced address sample and a second enhanced address sample; Inputting the first enhanced address sample into the preset recognition model to encode a first encoding vector, and performing a decoding tree constraint when decoding the first encoding vector to obtain a first predicted address; Inputting the second enhanced address sample into the preset recognition model to encode a second encoding vector, and performing decoding tree constraints when decoding the second encoding vector to obtain a second predicted address; Determine the contrastive learning loss between the first predicted address and the second predicted address to obtain the contrastive learning loss value The performing of decoding tree constraints when decoding the first coding vector to obtain a first predicted address includes: Performing a sequence search based on a beam search algorithm on the first coding vector to obtain a plurality of sequences to be constrained for decoding; Using a pruning algorithm to perform sequence constraints on each of the decoding sequences to be constrained, to obtain multiple candidate decoding sequences; The candidate decoding sequences are scored based on the beam search algorithm, and the candidate decoding sequence with the largest score is selected as the first predicted address.
2. The address recognition method based on artificial intelligence as claimed in claim 1, characterized in that: The determining of the total loss value according to the contrastive learning loss value comprises: Calculating a loss value between a standard address label of the address sample and a first predicted address, recorded as a first loss value; Calculating a loss value between the standard address label and the second predicted address, recorded as a second loss value; The total loss value is determined according to the comparative learning loss value, the first loss value and the second loss value.
3. The artificial intelligence-based address recognition method according to claim 1, characterized in that: The testing of the model to be tested comprises: Using the model to be tested to perform address recognition on the address sample, and obtaining the recognition address of the address sample by the model to be tested; Calculating the similarity between the identified address and the standard address label of the address sample; Determining whether the similarity is greater than a preset similarity; If the similarity is greater than the preset similarity, it is determined that the performance of the model to be tested meets the preset performance condition.
4. The artificial intelligence-based address recognition method according to any one of claims 1 to 3, characterized in that: When receiving the address recognition instruction, calling the target recognition model to perform address recognition on the data to be recognized includes: Compiling and optimizing the target recognition model to obtain the target code of the target recognition model; The target code is deployed to a target device, so that when the target device receives the address recognition instruction, it runs the target code to call the target recognition model to perform address recognition on the data to be recognized.
5. An address recognition device based on artificial intelligence, characterized in that: include: An acquisition module, used to acquire multiple address samples and a preset recognition model, wherein the preset recognition model is a sequence-to-sequence model; A training module, used for performing model training on the preset recognition model based on the plurality of address samples, and performing decoding tree constraints on the preset recognition model during the training process, so as to obtain a model to be tested through training; A testing module, used for testing the model to be tested until the performance of the model to be tested meets a preset performance condition, and outputting the model to be tested that meets the preset performance condition as a target recognition model; A recognition module, configured to call the target recognition model to perform address recognition on the data to be recognized upon receiving an address recognition instruction; The step of training the preset recognition model based on the plurality of address samples and performing decoding tree constraints on the preset recognition model during the training process to obtain a model to be tested includes: Performing data enhancement processing on the plurality of address samples to obtain a positive address sample pair corresponding to each address sample; Inputting the positive address sample pair corresponding to the address sample into the preset recognition model for contrastive learning training, and performing decoding tree constraints on the preset recognition model during the training process to obtain a contrastive learning loss value of the positive address sample pair; Determining a total loss value according to the contrastive learning loss value; When the total loss value does not reach the preset convergence condition, iteratively updating the initial parameters of the preset recognition model until the total loss value reaches the preset convergence condition, and recording the converged preset recognition model as a model to be tested; The step of inputting the positive address sample pair corresponding to the address sample into the preset recognition model for contrastive learning training, and performing decoding tree constraints on the preset recognition model during the training process to obtain the contrastive learning loss value of the positive address sample pair includes: Obtaining a positive address sample pair obtained by performing data enhancement processing on the address sample, the positive address sample pair comprising a first enhanced address sample and a second enhanced address sample; Inputting the first enhanced address sample into the preset recognition model to encode a first encoding vector, and performing a decoding tree constraint when decoding the first encoding vector to obtain a first predicted address; Inputting the second enhanced address sample into the preset recognition model to encode a second encoding vector, and performing decoding tree constraints when decoding the second encoding vector to obtain a second predicted address; Determine the contrastive learning loss between the first predicted address and the second predicted address to obtain the contrastive learning loss value The performing of decoding tree constraints when decoding the first coding vector to obtain a first predicted address includes: Performing a sequence search based on a beam search algorithm on the first coding vector to obtain a plurality of sequences to be constrained for decoding; Using a pruning algorithm to perform sequence constraints on each of the decoding sequences to be constrained, to obtain multiple candidate decoding sequences; The candidate decoding sequences are scored based on the beam search algorithm, and the candidate decoding sequence with the largest score is selected as the first predicted address.
6. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the artificial intelligence-based address recognition method according to any one of claims 1 to 4 are implemented.
7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the artificial intelligence-based address recognition method according to any one of claims 1 to 4 are implemented.
