Entity identification method and device
By obtaining and preprocessing address information and key information, using pre-training models and feature extraction models combined with dual affine attention mechanism models, the problem of missing entities in the existing technology is solved, and accurate identification and differentiation of logistics address information is achieved. .
Patent Information
- Application Number
- CN202310301564.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-17
- Publication Date
- 2024-09-20
AI Technical Summary
Existing entity recognition models in the logistics industry may miss some entities in address information, resulting in low recognition accuracy and inability to effectively distinguish different address information.
By obtaining the target address information and related target key information, characters that do not meet the specifications are eliminated, and the processed information is input into the entity recognition model network, using the pre-training model, feature extraction model and double affine attention mechanism model. Identification, ensuring that all entities in the address information are identified.
It achieves accurate identification of all entities in address information, improves identification accuracy, and can effectively distinguish different address information.
Smart Images

Figure CN118673918A
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and in particular, relates to an entity recognition method and device. Background Art
[0002] In the logistics industry, a large amount of address information needs to be identified. Therefore, the correct logistics route is selected for delivery based on the identified address information. Since different address information (such as the address information of the recipient and the address information of the sender, etc.) contains the same entities (such as provinces, cities, and counties, etc.), it is necessary to identify the entities in the address information so as to effectively distinguish each address information.
[0003] Currently, entity recognition models are usually used to identify entities in address information. However, relevant entity recognition models may miss some entities in address information, resulting in low accuracy in entity recognition and inability to distinguish different address information. Summary of the invention
[0004] The embodiments of the present application provide an entity recognition method and device, which can accurately recognize all entities in address information, thereby accurately distinguishing different address information.
[0005] In a first aspect, an embodiment of the present application provides an entity recognition method, the entity recognition method comprising:
[0006] Acquire target address information and target key information related to the target address information;
[0007] Eliminate characters that do not conform to the specification in the target address information and the target key information to obtain processed target address information and processed target key information;
[0008] The processed target address information and the processed target key information are input into the entity recognition model network to obtain the entity recognition result. The entity recognition model network is used to recognize all entities in the address information according to the address information and the key information.
[0009] In a possible implementation, the entity recognition model network includes: a pre-training model, a first feature extraction model, a second feature extraction model and a dual affine attention mechanism model.
[0010] A pre-training model, used to obtain a first word encoding vector according to the processed target address information, and transmit the first word encoding vector to a first feature extraction model;
[0011] The pre-trained model is further used to obtain a second word encoding vector according to the processed target key information, and transmit the second word encoding vector to the second feature extraction model;
[0012] A first feature extraction model is used to obtain a first feature vector according to the first word encoding vector, and transmit the first feature vector to the dual affine attention mechanism model;
[0013] A second feature extraction model is used to obtain a second feature vector according to the second word encoding vector, and transmit the second feature vector to the dual affine attention mechanism model;
[0014] The dual affine attention mechanism model is used to obtain entity recognition results based on the first eigenvector and the second eigenvector.
[0015] In one possible implementation, the dual affine attention mechanism model is specifically used to obtain the score value and type of each entity in the target address information based on the first eigenvector and the second eigenvector, and to determine that the entity recognition result includes the entity corresponding to the maximum score value in each type.
[0016] In a possible implementation, generating an entity recognition model network includes:
[0017] Obtaining sample address information and sample key information related to the sample address information;
[0018] Perform sequence labeling on each entity in the sample address information to obtain a labeling result, where the labeling result is used to indicate the type of each entity in the sample address information;
[0019] According to the sample address information, labeling results and sample key information, the original model network is trained to obtain the entity recognition model network.
[0020] In a possible implementation, the original model network is trained according to the sample address information, the labeling result, and the sample key information to obtain the entity recognition model network, including:
[0021] According to the first hyperparameter, the sample address information, the labeling result, and the sample key information, the original model network is trained to obtain the first entity recognition model network and the training error of the first entity recognition model network;
[0022] When the preset number of training times is equal to 1, determining the entity recognition model network as the first entity recognition model network;
[0023] When the preset number of training times is greater than 1, the second hyperparameter is determined according to the first hyperparameter and the training error of the first entity recognition model network, the first hyperparameter is updated to the second hyperparameter, the original model network is updated to the first entity recognition model network, and the original model network is continued to be trained according to the first hyperparameter, sample address information, labeling results and sample key information to obtain the first entity recognition model network and the training error of the first entity recognition model network, until the preset number of training times is reached, the entity recognition model network is determined to be the first entity recognition model network trained for the preset number of training times.
[0024] In a possible implementation, the key information includes corporate business information and / or collection point information.
[0025] In a possible implementation, the entity in the address information includes at least one of a province, a municipality, a city, a district, a county, a street, a town, a township, and a detailed address.
[0026] The embodiment of the present application obtains target address information and target key information related to the target address information, and inputs the target address information and the target key information related to the target address information into an entity recognition model network for entity recognition. This solves the technical problem that the existing recognition method may miss some entities in the target address information, and thus cannot accurately distinguish different target address information based on the recognized entities. This achieves the technical effect of accurately identifying all entities in the target address information, having a high accuracy rate in identifying entities, and accurately distinguishing different target address information.
[0027] In a second aspect, an embodiment of the present application provides an entity recognition device, which is used to execute the method in the first aspect or any possible implementation of the first aspect. Specifically, the device may include a module for executing the entity recognition method in the first aspect or any possible implementation of the first aspect.
[0028] In a third aspect, an embodiment of the present application provides an electronic device, the device comprising a memory and a processor. The memory is used to store instructions; the processor executes the instructions stored in the memory, so that the electronic device executes the entity recognition method in the first aspect or any possible implementation of the first aspect.
[0029] In a fourth aspect, a readable storage medium is provided, wherein instructions are stored in the readable storage medium. When the instructions are executed on a computer, the computer executes the entity recognition method in the first aspect or any possible implementation of the first aspect.
[0030] In a fifth aspect, a computer program product comprising instructions is provided. When the instructions are executed on a mobile device, the mobile device executes the entity recognition method in the first aspect or any possible implementation manner of the first aspect.
[0031] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be 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 any creative work.
[0033] Figure 1 It is a flowchart of an entity recognition method provided in an embodiment of the present application;
[0034] Figure 2 is a schematic diagram of the structure of the entity recognition model network in the embodiment of the present application;
[0035] Figure 3 It is a schematic diagram of the process of generating an entity recognition model network in an embodiment of the present application;
[0036] Figure 4 It is a schematic diagram of the structure of the generated entity recognition model network in the embodiment of the present application;
[0037] Figure 5 It is a schematic diagram of the process of generating an entity recognition model network in an embodiment of the present application;
[0038] Figure 6 It is a schematic block diagram of an entity recognition device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0039] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0040] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0041] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0042] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0043] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0044] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0045] See also Figure 1 , Figure 1 FIG. 1 is a flow chart of an entity recognition method provided by an embodiment of the present application. Figure 1 As shown, the entity recognition method of the present application includes:
[0046] S101. Acquire target address information and target key information related to the target address information.
[0047] The target address information is the address information that needs to be entity identified among the multiple address information. The address information may include: the address information of the recipient and / or the address information of the sender, etc. The address information includes at least one entity. The entity in the address information may include: at least one of: province, municipality, city, district, county, street, town, township and detailed address. The detailed address may include: name of a person, company name and proper noun, etc.
[0048] The target key information is key information that assists in accurately identifying the entity in the target address information. The target key information may be one or more key information. The key information may include: business information of the enterprise and / or collection point information.
[0049] The business information of the enterprise includes: the business information of the recipient and the business information of the sender. The business information of the recipient may include: the name of the recipient's enterprise, the name of the person in charge of the recipient, and the registered address of the recipient, etc. The business information of the sender may include: the name of the sender's enterprise, the name of the person in charge of the sender, and the registered address of the sender, etc.
[0050] The collection point information includes: the collection point information of the recipient, the collection point information of the sender, and the collection point information of the transfer party between the recipient and the sender.
[0051] The recipient can be an enterprise or an individual. The sender can be an enterprise or an individual. The relationship between the recipient and the sender includes: enterprise-enterprise, enterprise-individual, individual-enterprise and individual-individual.
[0052] The electronic device can obtain the target address information pre-stored in other storage devices.
[0053] If the electronic device only obtains the target address information, it can only identify the entities in the target address information from the address dimension. Since the information obtained by the electronic device has a single dimension, some entities in the target address information may be omitted, resulting in a low accuracy rate of entity recognition.
[0054] Based on this, the electronic device also needs to obtain target key information related to the target address information pre-stored in other storage devices. In other words, the electronic device also needs to obtain information of other dimensions besides the address dimension, namely, target key information. Thus, the electronic device can obtain information of multiple dimensions and improve the accuracy of entity recognition.
[0055] The electronic device may be a processor (such as a CPU), a smart phone, a tablet computer, a desktop computer, a laptop computer, or a server, etc. The present application embodiment does not impose any restrictions on the specific type of the electronic device. Other storage devices may be memory, etc.
[0056] In some embodiments, the electronic device may obtain the target address information that needs to be identified by scanning the waybill.
[0057] In addition, the electronic device may receive target address information in response to the user's input operation. The electronic device may receive target key information related to the target address information in response to the user's input operation.
[0058] In summary, the electronic device can obtain the target address information and the target key information related to the target address information.
[0059] Considering that both the target address information and the target key information related to the target address information may contain information that interferes with the electronic device's identification of entities, before the electronic device identifies the target address information based on the target address information and the target key information, it is necessary to screen and eliminate the target address information and the target key information, so that the entity recognition model network can accurately identify all entities in the target address information.
[0060] S102, eliminating characters that do not conform to the specification in the target address information and the target key information, and obtaining processed target address information and processed target key information.
[0061] Among them, characters that do not meet the standards may include: illegal characters, repeated characters, and ambiguous characters, etc.
[0062] Illegal characters may include: non-Chinese characters and non-numeric symbols, etc. For example, illegal characters include space, @, #, and &.
[0063] Repeating characters are the same number or letter that appears multiple times.
[0064] Blurred characters are numbers or words that are not clearly written.
[0065] The electronic device can screen the target address information to obtain characters that do not conform to the specification in the target address information. Thus, the electronic device can remove the characters that do not conform to the specification in the target address information to obtain the target address information after removing the characters that do not conform to the specification, that is, the processed target address information.
[0066] In some embodiments, the electronic device may remove non-Chinese characters, non-numeric symbols, and repeated characters in the target address information. At the same time, the electronic device may replace Chinese numbers in the target address information with Arabic numbers.
[0067] The electronic device can screen the target key information to obtain characters that do not conform to the standard in the target key information. Thus, the electronic device can remove the characters that do not conform to the standard in the target key information to obtain the target key information after removing the characters that do not conform to the standard, that is, the processed target key information.
[0068] In some embodiments, the electronic device may remove non-Chinese characters of the corporate business information in the target key information.
[0069] In some embodiments, the electronic device may replace the space characters in the collection point information with characters that comply with the specification.
[0070] In some embodiments, the electronic device may remove non-Chinese characters and non-numeric symbols in the target address information and the target key information through regular expressions. The electronic device may also remove repeated characters in the target address information through regular expressions.
[0071] Regular expressions are used to clean irregular information. Regular expressions are a matching pattern that can perform character matching and position matching to match the information needed to identify entities.
[0072] S103: Input the processed target address information and the processed target key information into the entity recognition model network to obtain an entity recognition result. The entity recognition model network is used to recognize all entities in the address information according to the address information and the key information.
[0073] The entity recognition model network is a trained model pre-stored in the electronic device.
[0074] The electronic device inputs the processed target address information and the processed target key information into the entity recognition model network, and can output an entity recognition result. The entity recognition result output by the electronic device includes all entities in the target address information.
[0075] For example, the target address information obtained by the electronic device is "a company at the 67th Building, 45th Road, Nanshan District, Guangdong Province, Guangdong Province", and the target key information is "the collection point of the 67th Building#". The electronic device can remove repeated characters in the target address information, namely "Guangdong Province", and the processed target address information is "a company at the 67th Building, 45th Road, Nanshan District, Guangdong Province". The electronic device can remove illegal characters in the target key information, namely "#", and the processed target key information is "the collection point of the 67th Building". The electronic device inputs "a company at the 67th Building, 45th Road, Nanshan District, Guangdong Province" and "the collection point of the 67th Building" into the entity recognition model network, and the entity recognition results obtained are Guangdong Province, Nanshan District, 45th Road, 67th Building and a company.
[0076] The entity recognition method of the embodiment of the present application can obtain information of multiple dimensions by acquiring the target address information and the target key information related to the target address information, that is, the target address information of the address dimension and the target key information of other dimensions except the address dimension. By eliminating the non-standard characters in the target address information and the target key information, the processed target address information and the processed target key information can be obtained, which can avoid the interference of the non-standard characters in the target address information and the target key information on the entity recognition. The processed target address information and the processed target key information are input into the entity recognition model network to obtain the entity recognition result, and all entities in the target address information can be accurately identified according to the information of multiple dimensions, that is, the target address information and the target key information through the entity recognition model network. Thus, it is possible to accurately identify all entities in the address information from multiple dimensions. According to all the entities identified, different address information can be accurately distinguished, which improves the accuracy of entity recognition and speeds up the distinction rate of different address information.
[0077] Based on the above description, below, combined with Figure 2 , an example is given to illustrate a feasible implementation method of the entity recognition model network of the present application.
[0078] See also Figure 2 , Figure 2 FIG. 1 shows a schematic diagram of the structure of the entity recognition model network in the embodiment of the present application. Figure 2 As shown, the entity recognition model network of the present application may include: a pre-trained model, a first feature extraction model, a second feature extraction model and a biaffine attention mechanism (Biaffine) model.
[0079] The pre-trained model is communicated with the first feature extraction model and the second feature extraction model respectively. The first feature extraction model and the second feature extraction model are communicated with the dual affine attention mechanism model respectively.
[0080] The pre-trained model is used to perform word encoding on address information and key information related to the address information.
[0081] In some embodiments, the pre-trained model may be a K-BERT model, which includes a knowledge layer, an embedding layer, a seeing layer, and an encoding layer (mask-transformer encoder).
[0082] The knowledge layer is used to convert address information into a sentence tree based on the knowledge graph (KG). The knowledge layer is also used to transfer the sentence tree to the embedding layer.
[0083] The knowledge graph is used to represent the association between the triple information in each address information. The triple information includes three parts: subject, predicate and object.
[0084] For example, the address information obtained by the electronic device is the front desk staff A on the 67th floor of the 45th Road, Nanshan District, Guangdong Province. The electronic device can input the address information into the knowledge layer of the K-bert model. The knowledge layer can obtain triple information including "Subject-67th Floor, Unit, 45th Road, Nanshan District, Shenzhen City, Guangdong Province, Predicate-A Certain Company, Object-Receptionist" and "Subject-A Certain Company, Predicate-CFO, Object-A" based on the pre-set knowledge graph. The knowledge layer injects the obtained triple information into the sentence to obtain a sentence tree with rich logistics background knowledge.
[0085] The embedding layer is used to convert the sentence tree into a vector of the sentence tree. The embedding layer is also used to transfer the vector of the sentence tree to the visible layer.
[0086] The visible layer is used to construct the visible matrix of the sentence tree based on the vector of the sentence tree. The visible layer is also used to transmit the visible matrix of the sentence tree to the encoding layer. The attention mechanism of each word in the visible matrix comes from the same branch in the sentence tree. The attention mechanism of each word comes from the context of the same branch, which can avoid knowledge noise.
[0087] The encoding layer is used to encode the visible matrix of the sentence tree to obtain the word encoding vector.
[0088] The first feature extraction model is used to extract features from address information.
[0089] In some embodiments, the first feature extraction model may be a bidirectional long short-term memory (Bi-LSTM) model. Figure 2 As shown, the Bi-LSTM model is composed of a forward long short-term memory (LSTM) model and a backward long short-term memory (LSTM) model. The Bi-LSTM model can splice the results output by the forward LSTM model and the results output by the backward LSTM model. The Bi-LSTM model can better focus on the time series information in the address information, the position of the sentence in the address information, and the context information of the sentence. The second feature extraction model is used to extract features of key information related to the address information.
[0090] In some embodiments, the second feature extraction model may be a support vector machine (SVM) model. The SVM model may map the word encoding vector corresponding to the key information in the low-dimensional space to the feature vector in the high-dimensional space according to the kernel function. The direction of the SVM model mapping is Figure 2 The direction indicated by the arrow in . The SVM model can better mine the feature information of the sentences in the address information.
[0091] The dual affine attention mechanism model is used to identify all entities in the address information based on the address information and key information. The dual affine attention mechanism model can integrate the first and last token features of the entity to ensure information interaction between tokens. The dual affine attention mechanism model can transform the entity recognition problem into the span recognition problem formed by the first and last tokens, which can more accurately identify entities. In addition, the dual affine attention mechanism model can identify nested entities in the address information by identifying multiple spans.
[0092] The first feature extraction model and the second feature extraction model in the embodiment of the present application are both feature extraction models based on the "bagging" concept. The dual affine attention mechanism model in the embodiment of the present application is a model based on a similar "Boosting" concept.
[0093] Based on the above description, the electronic device can input the processed target address information and the processed target key information into the entity recognition model network. The pre-trained model in the entity recognition model network can word encode the processed target address information to obtain a first word encoding vector, and word encode the processed target key information to obtain a second word encoding vector.
[0094] The pre-trained model can transmit a first word encoding vector to a first feature extraction model, and transmit a second word encoding vector to a second feature extraction model.
[0095] Based on this, the first feature extraction model can perform feature extraction on the first word encoding vector to obtain a first feature vector. The first feature extraction model can transmit the first feature vector to the dual affine attention mechanism model.
[0096] The second feature extraction model can perform feature extraction on the second word encoding vector to obtain a second feature vector.
[0097] The second feature extraction model can transmit the second feature vector to the dual affine attention mechanism model.
[0098] Therefore, the dual affine attention mechanism model can obtain the entity recognition result based on the first eigenvector and the second eigenvector.
[0099] like Figure 2As shown, the electronic device needs to concatenate the first feature vector and the second feature vector before inputting them into the dual affine attention mechanism model. Thus, the dual affine attention mechanism model can process the concatenated first feature vector and second feature vector accordingly to obtain the entity recognition result.
[0100] In summary, the electronic device can obtain the entity recognition result output by the entity recognition model network.
[0101] In some embodiments, the dual affine attention mechanism model can obtain the score value and type of each entity in the target address information based on the first eigenvector and the second eigenvector, and determine that the entity recognition result includes the entity corresponding to the maximum score value in each type.
[0102] The entity recognition result also includes a maximum score value.
[0103] It should be understood that the first word encoding vector and the second word encoding vector are both vectors in a low-dimensional space, and the first feature vector and the second feature vector are both vectors in a high-dimensional space.
[0104] It should be understood that the entity recognition model network of the embodiment of the present application may also adopt other network structures. However, the models included in the entity recognition model networks of different network structures may be different, and the accuracy of identifying entities in address information may also be different.
[0105] Next, combine Figures 3 to 5 , an example is given to illustrate a feasible implementation method of generating an entity recognition model network in an embodiment of the present application.
[0106] See also Figure 3 , Figure 3 FIG. 2 shows a schematic diagram of a process for generating an entity recognition model network in an embodiment of the present application. Figure 3 As shown, the specific process of generating the entity recognition model network in the embodiment of the present application is as follows:
[0107] S301. Obtain sample address information and sample key information related to the sample address information.
[0108] The sample address information and the sample key information are both training sample data. The sample address information may include: the sample address information of the recipient and / or the sample address information of the sender, etc. The sample address information includes at least one entity.
[0109] The key information of the sample may include: sample enterprise business information and / or sample collection point information, etc.
[0110] The electronic device may obtain pre-stored training sample data from other storage devices, that is, obtain sample address information and sample key information related to the sample address information.
[0111] S302: Perform sequence labeling on each entity in the sample address information to obtain a labeling result, where the labeling result is used to indicate the type of each entity in the sample address information.
[0112] The electronic device may perform sequence labeling on each entity in the sample address information. After the electronic device performs sequence labeling on each entity in the plurality of entities, a labeling result may be obtained. In other words, the electronic device may obtain a type corresponding to each entity in the plurality of entities.
[0113] In some embodiments, the electronic device may perform sequence tagging on each entity in the plurality of entities using manual rules according to the BIO Chinese word segmentation system, thereby obtaining a tagging result.
[0114] The labeling result can be expressed by the formula:
[0115] label={Bv,Iv,Ov},v=(prov,city,district,town,poi).
[0116] label represents the labeling result, v represents the type of entity, prov represents province, city represents city, district represents district, town represents town, and poi represents the detailed address.
[0117] S303: Train the original model network according to the sample address information, the labeling results and the sample key information to obtain the entity recognition model network.
[0118] Among them, the original model network may include: an original pre-trained model, an original first feature extraction model, an original second feature extraction model and an original dual affine attention mechanism model.
[0119] The network structure of the original model network is the same as that of the entity recognition model network, which shows that the original pre-trained model is respectively communicated with the original first feature extraction model and the original second feature extraction model. The original first feature extraction model and the original second feature extraction model are respectively communicated with the original dual affine attention mechanism model.
[0120] like Figure 4 As shown, the electronic device can input the sample address information, labeling results and sample key information into the original model network, train the original model network, and obtain a trained entity recognition model network.
[0121] Specifically, the electronic device may train the original pre-trained model according to the sample address information, the labeling result and the sample key information to obtain the pre-trained model. The electronic device may train the original first feature extraction model according to the sample address information, the labeling result and the sample key information to obtain the first feature extraction model. The electronic device may train the original second feature extraction model according to the sample address information, the labeling result and the sample key information to obtain the second feature extraction model. The electronic device may train the original dual affine attention mechanism model according to the sample address information, the labeling result and the sample key information to obtain the dual affine attention mechanism model.
[0122] Considering that the original pre-trained model in the original model network is a trained model, the electronic device trains the original model network by training the original Bi-LSTM model, the original SVM model and the original Biaffine model in the original model network. The specific training process is as follows:
[0123] Assume that the first sample word encoding vector output by the original pre-trained model is The second sample word encoding vector output by the original pre-trained model is
[0124] Among them, x represents the first sample word encoding vector, i represents any address information in the training sample data, z represents the second sample word encoding vector, m represents the dimension of the first sample word encoding vector, m≥0, R is a real number, and n represents the dimension of the second sample word encoding vector, n≥0.
[0125] Based on this, the input of the original Bi-LSTM model is I1={(x1,y1),(x2,y2)...(x i ,y i )}.
[0126] Among them, I1 represents the training sample data of the original Bi-LSTM model, y i Indicates the index value corresponding to the entity's real type in the annotation result. The real type of each entity can be obtained after BIO sequence annotation. The index value is used to determine the real type corresponding to the entity.
[0127] The concept of "gate" proposed by the original LSTM model is mathematically expressed as:
[0128] g(t)=σ(Wx+b);
[0129] Where σ represents the activation function. The original LSTM model includes: input gate i i , forget gate f i and output gate o i .ii and f i Determine memory unit C i Information update, i Output the final result h i , the mathematical expression is:
[0130] i i =σ(W i [x i ,h i-1 ]+b i );
[0131] f i =σ(W f [x i ,h i-1 ]+b f );
[0132]
[0133]
[0134] o i =σ(W o [x i ,h i-1 ]+b o );
[0135]
[0136] Among them, W i , W f , W c and W o Both represent weight matrices, b i 、b f 、b c and b o Both represent deviation vectors.
[0137] The original forward LSTM model can encode the first sample word vector x i Calculate forward once from time 1 to time t to get the hidden state The original backward LSTM model can encode the first sample word vector x i Calculate backward from time t to time 1 once to get the hidden state
[0138] Thus, the original Bi-LSTM model can and Splice and output the first sample feature vector
[0139] The input of the original SVM model is I2 = {(z1, y1), (z2, y2) ... (z i ,y i )}.
[0140] Among them, I2 represents the training sample data of the original SVM model, z i Represents the second sample word encoding vector.
[0141] Considering that the sample key information may include one or more, when the sample key information includes multiple items, the corresponding second sample word encoding vector also includes multiple items.
[0142] In some embodiments, They are second sample word encoding vectors corresponding to multiple sample key information respectively.
[0143] For example, Indicates the business information of the sender. Indicates the recipient's business information. Indicates the collection point information.
[0144] The original SVM model can be used to transform z according to the kernel function Φ i Mapping: z i →Φ(z i ), that is, mapping the vector in the low-dimensional space to the vector output in the high-dimensional space. The original SVM model can output the second sample feature vector.
[0145] The first sample feature vector And the second sample feature vector Φ(z i ) The feature vectors need to be concatenated according to the direction of the feature vectors and then transferred to the original Biaffine model.
[0146] Based on this, the input of the original Biaffine model is α i =[h i ,Φ(z i )]∈R 2m+n The output of the original Biaffine model is x s (i) and x e (i).
[0147] x s (i) = FFNN_start(α i );
[0148] x e (i) = FFNN_end(α i );
[0149] Among them, x s(i) The header token representing the entity, x e (i) The tail token representing the entity.
[0150] The original Biaffine model can construct a Biaffine matrix (l*l*v), l=2m+n.
[0151] Among them, l is the hidden feature length.
[0152] The Biaffine matrix can associate the first token of an entity with the last token of an entity and calculate the score r of the corresponding span. m (i), the mathematical expression is as follows:
[0153]
[0154] Among them, r m (i) represents the score value, U m With W m are the weight parameters inside the original Biaffine model, b m For deviation.
[0155] The original Biaffine model can sort the span scores and determine the index value corresponding to the maximum score. The expression is as follows:
[0156] y i = argmax(r m (i));
[0157] Among them, y i The index value corresponding to the maximum score.
[0158] In summary, the electronic device can complete the training process of the original model network to obtain the entity recognition model network.
[0159] Based on the description of S303, below, combined with Figure 5 , a feasible implementation method of obtaining entity recognition model network from electronic devices is introduced in detail.
[0160] See also Figure 5 , Figure 5 FIG. 2 shows a schematic diagram of a process for generating an entity recognition model network in an embodiment of the present application. Figure 5 As shown, the specific implementation process of generating the entity recognition model network in the embodiment of the present application is as follows:
[0161] S401. Train the original model network according to the first hyperparameter, sample address information, labeling results, and sample key information to obtain a first entity recognition model network and a training error of the first entity recognition model network.
[0162] The first hyperparameter is a parameter of the original model network pre-set by the user. Specifically, the first hyperparameter includes: parameters of the original Bi-LSTM model and parameters of the original SVM model.
[0163] The first entity recognition model network is a model obtained after the original model network is trained once. The accuracy of the first entity recognition model network in recognizing entities is higher than the accuracy of the original model network in recognizing entities.
[0164] The electronic device may obtain a first hyperparameter of the original model network. The electronic device may input the sample address information, the labeling result, and the sample key information into the original model network provided with the first hyperparameter to train the original model network. After training the original model network, the electronic device may obtain the first entity recognition model network and the training error of the first entity recognition model network.
[0165] The electronic device can train the original model network once or multiple times according to different recognition scenarios. Thus, the electronic device can obtain multiple entity recognition model networks. The accuracy of the multiple entity recognition model networks in recognizing entities is different.
[0166] Specifically, the electronic device can obtain entity recognition model networks with different accuracy rates for recognizing entities by setting different preset training times.
[0167] S402: Determine whether the preset number of training times is equal to 1.
[0168] If yes, the electronic device may execute S403. If no, the electronic device may execute S404-S07.
[0169] S403: When the preset number of training times is equal to 1, determine that the entity recognition model network is the first entity recognition model network.
[0170] When it is determined that the preset number of training times is equal to 1, the electronic device may determine that the original model network has completed a training process after executing S401. At this time, the electronic device may determine that the entity recognition model network is the first entity recognition model network.
[0171] When the recognition accuracy requirement for the entity recognition model network is high, the electronic device can set the preset number of training times to any integer greater than 1.
[0172] S404. When the preset number of training times is greater than 1, determine the second hyperparameter according to the first hyperparameter and the training error of the first entity recognition model network, update the first hyperparameter to the second hyperparameter, and update the original model network to the first entity recognition model network.
[0173] When the preset number of training times is greater than 1, the electronic device may determine the second hyperparameter based on the first hyperparameter and the training error of the first entity recognition model network. At this time, the electronic device may update the first hyperparameter to the second hyperparameter and update the original model network to the first entity recognition model network.
[0174] S405. Continue to train the original model network according to the first hyperparameter, sample address information, labeling results, and sample key information to obtain a first entity recognition model network and a training error of the first entity recognition model network.
[0175] Based on this, the electronic device can perform a second training on the original model network. At this time, the electronic device can determine that the actual number of training times is equal to 2. The electronic device can continue to train the original model network according to the first hyperparameter, the sample address information, the labeling result, and the sample key information to obtain the first entity recognition model network and the training error of the first entity recognition model network.
[0176] S406: Determine whether the preset number of training times has been reached.
[0177] If yes, the electronic device may execute S407. If no, the electronic device may continue to execute S404-S407 until the preset number of training times is reached.
[0178] The electronic device may compare the actual training times with the preset training times. When the electronic device determines that the actual training times reach the preset training times, it may execute S407. When the electronic device determines that the actual training times are less than the preset training times, it may continue to execute S404-S407.
[0179] S407: Determine that the entity recognition model network is the first entity recognition model network trained for a preset number of training times.
[0180] When the electronic device determines that the actual number of training times is less than the preset number of training times, the electronic device may continue to determine the second hyperparameter based on the first hyperparameter and the training error of the first entity recognition model network. The electronic device may update the first hyperparameter to the second hyperparameter, and update the original model network to the first entity recognition model network, and continue to execute S405-S407 until the electronic device determines that the actual number of training times reaches the preset number of training times, and determines that the entity recognition model network is the first entity recognition model network trained for the preset number of training times.
[0181] In summary, the electronic device can determine that the entity recognition model network is the first entity recognition model network trained for a preset number of training times. The first hyperparameter of the first entity recognition model network is the optimal hyperparameter.
[0182] In some embodiments, the electronic device may use a Bayesian optimization algorithm (BOA) algorithm to update the first hyperparameter. The BOA algorithm can reduce the number of times the first hyperparameter is adjusted and updated, and quickly complete the optimization of the first hyperparameter.
[0183] The BOA algorithm is used for "black box" optimization when the objective function f(a) is unknown. The BOA algorithm approximates the objective function through a probabilistic proxy model and constructs a collection function to collect the next posterior distribution point. Thus, the posterior distribution points of the probabilistic proxy model are continuously updated iteratively to approximate the true objective function. The specific process of the electronic device using the BOA algorithm to update the first hyperparameter is as follows:
[0184] The electronic device can determine the relationship between the training error of the Gaussian process (GP) in the probabilistic proxy model and the entity recognition model network through the relationship between the training errors of the probabilistic proxy model and the entity recognition model network. The specific expression is as follows:
[0185] q=f(a)+ε;
[0186]
[0187] Among them, q is the training error of the entity recognition model network, f(a) is the probabilistic proxy model, a is the first hyperparameter, ε is the observation error, which conforms to the normal distribution, m(a) is the mean matrix, and g(a, a′) is the covariance matrix.
[0188] The electronic device can determine the point a that satisfies the maximum posterior distribution of the acquisition function based on the historical data set, that is, the set of historical first hyperparameters that have been obtained. t As the second hyperparameter, that is, the updated first hyperparameter, the expression is as follows:
[0189] a t = argmax a∈A u(a|D 1:t-1 );
[0190] Among them, u(a|D 1:t-1 ) represents the acquisition function, D 1:t-1 Represents a historical dataset.
[0191] The electronic device can determine the training error q of the first entity recognition model network t The expression is as follows:
[0192]
[0193]
[0194] Among them, rm (i v ) represents the score value of the span of type v, Represents the index value of the entity of the vth category.
[0195] Electronic devices can (a t ,q t ) is added to the historical dataset D 1:t-1 In the above example, we get the updated dataset D 1:t ={D 1:t-1 , (a t ,q t )}.
[0196] Because (a t ,q t ) and D 1:t-1 obey the joint Gaussian distribution, so according to D 1:t Update the Gaussian model and get the updated posterior distribution probability as:
[0197]
[0198] Based on the above description, the electronic device can determine the first hyperparameter to be a t+1 After determining that the actual number of training times of the original model network is equal to the preset number of training times, the electronic device may determine that the first entity recognition model network corresponding to the first hyperparameter is the optimal entity recognition model network.
[0199] In summary, the electronic device can obtain the optimal first hyperparameter and the first entity recognition model network with the highest entity recognition accuracy, thereby realizing accurate recognition of all entities in the address information and completing accurate parsing of the address information.
[0200] It should be understood that the characters without meaning in the embodiments of the present application are meaningless calculated intermediate values or are common knowledge to those skilled in the art.
[0201] See also Figure 6 , Figure 6 FIG. 1 is a schematic block diagram of an entity recognition device provided by an embodiment of the present application. Figure 6 As shown, the entity recognition device 400 of the embodiment of the present application may include: an acquisition module 401, a removal module 402 and a processing module 403;
[0202] The acquisition module 401 is used to acquire target address information and target key information related to the target address information;
[0203] A removal module 402 is used to remove characters that do not conform to the specification in the target address information and the target key information to obtain processed target address information and processed target key information;
[0204] The processing module 403 is used to input the processed target address information and the processed target key information into the entity recognition model network to obtain the entity recognition result. The entity recognition model network is used to recognize all entities in the address information according to the address information and the key information.
[0205] In some embodiments, the entity recognition model network includes: a pre-trained model, a first feature extraction model, a second feature extraction model, and a dual affine attention mechanism model;
[0206] A pre-training model, used to obtain a first word encoding vector according to the processed target address information, and transmit the first word encoding vector to a first feature extraction model;
[0207] The pre-trained model is further used to obtain a second word encoding vector according to the processed target key information, and transmit the second word encoding vector to the second feature extraction model;
[0208] A first feature extraction model is used to obtain a first feature vector according to the first word encoding vector, and transmit the first feature vector to the dual affine attention mechanism model;
[0209] A second feature extraction model is used to obtain a second feature vector according to the second word encoding vector, and transmit the second feature vector to the dual affine attention mechanism model;
[0210] The dual affine attention mechanism model is used to obtain entity recognition results based on the first eigenvector and the second eigenvector.
[0211] In some embodiments, the dual affine attention mechanism model is specifically used to obtain the score value and type of each entity in the target address information based on the first feature vector and the second feature vector, and determine that the entity recognition result includes the entity corresponding to the maximum score value in each type.
[0212] In some embodiments, the processing module 403 is further used to generate an entity recognition model network, including:
[0213] Obtain sample address information and sample key information related to the sample address information; perform sequence labeling on each entity in the sample address information to obtain labeling results, which are used to represent the type of each entity in the sample address information; train the original model network based on the sample address information, the labeling results and the sample key information to obtain an entity recognition model network.
[0214] In some embodiments, processing module 403 is also used to train the original model network according to the first hyperparameter, sample address information, labeling results and sample key information to obtain the first entity recognition model network and the training error of the first entity recognition model network; when the preset number of training times is equal to 1, determine the entity recognition model network as the first entity recognition model network; when the preset number of training times is greater than 1, determine the second hyperparameter according to the first hyperparameter and the training error of the first entity recognition model network, update the first hyperparameter to the second hyperparameter, update the original model network to the first entity recognition model network, and continue to train the original model network according to the first hyperparameter, sample address information, labeling results and sample key information to obtain the first entity recognition model network and the training error of the first entity recognition model network, until the preset number of training times is reached, determine the entity recognition model network as the first entity recognition model network trained the preset number of training times.
[0215] In some embodiments, the key information includes corporate business information and / or collection point information.
[0216] In some embodiments, the entity in the address information includes at least one of a province, a municipality, a city, a district, a county, a street, a town, a township, and a detailed address.
[0217] It should be understood that the device 400 of the embodiment of the present application can be implemented by an application-specific integrated circuit (ASIC) or a programmable logic device (PLD), and the PLD can be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof. It can also be implemented by software. Figure 1 The entity recognition method shown, when implemented by software Figure 1 When the entity identification method is shown, the device 400 and its various modules may also be software modules.
[0218] An embodiment of the present application further provides a readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0219] An embodiment of the present application provides a computer program product. When the computer program product runs on a mobile device, the mobile device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0220] It should be understood that the size of the serial numbers of the steps in the above embodiments does not 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 embodiments of the present application.
[0221] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0222] The technicians in the relevant field 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 for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the above-mentioned device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0223] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0224] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0225] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the above modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0226] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0227] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person 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 application, and should all be included in the protection scope of the present application.
Claims
1. An entity recognition method, characterized in that: The method comprises: Acquire target address information and target key information related to the target address information; Eliminate characters that do not conform to the specification in the target address information and the target key information to obtain processed target address information and processed target key information; The processed target address information and the processed target key information are input into an entity recognition model network to obtain an entity recognition result. The entity recognition model network is used to recognize all entities in the address information according to the address information and the key information.
2. The method according to claim 1, characterized in that The entity recognition model network includes: a pre-training model, a first feature extraction model, a second feature extraction model and a dual affine attention mechanism model. The pre-trained model is used to obtain a first word encoding vector according to the processed target address information, and transmit the first word encoding vector to the first feature extraction model; The pre-trained model is further used to obtain a second word encoding vector according to the processed target key information, and transmit the second word encoding vector to the second feature extraction model; The first feature extraction model is used to obtain a first feature vector according to the first word encoding vector, and transmit the first feature vector to the dual affine attention mechanism model; The second feature extraction model is used to obtain a second feature vector according to the second word encoding vector, and transmit the second feature vector to the dual affine attention mechanism model; The dual affine attention mechanism model is used to obtain the entity recognition result based on the first feature vector and the second feature vector.
3. The method according to claim 2, characterized in that The dual affine attention mechanism model is specifically used to obtain the score value and type of each entity in the target address information based on the first feature vector and the second feature vector, and to determine that the entity recognition result includes the entity corresponding to the maximum score value in each type.
4. The method according to any one of claims 1 to 3, characterized in that: Generating the entity recognition model network includes: Acquire sample address information and sample key information related to the sample address information; Performing sequence labeling on each entity in the sample address information to obtain a labeling result, wherein the labeling result is used to indicate the type of each entity in the sample address information; The original model network is trained according to the sample address information, the labeling result and the sample key information to obtain the entity recognition model network.
5. The method according to claim 4, characterized in that The training of the original model network according to the sample address information, the labeling result and the sample key information to obtain the entity recognition model network includes: Training the original model network according to the first hyperparameter, the sample address information, the labeling result, and the sample key information to obtain a first entity recognition model network and a training error of the first entity recognition model network; When the preset number of training times is equal to 1, determining that the entity recognition model network is the first entity recognition model network; When the preset number of training times is greater than 1, the second hyperparameter is determined according to the first hyperparameter and the training error of the first entity recognition model network, the first hyperparameter is updated to the second hyperparameter, the original model network is updated to the first entity recognition model network, and the original model network is continued to be trained according to the first hyperparameter, the sample address information, the labeling result and the sample key information to obtain the first entity recognition model network and the training error of the first entity recognition model network, until the preset number of training times is reached, the entity recognition model network is determined to be the first entity recognition model network trained for the preset number of training times.
6. The method according to any one of claims 1 to 3, characterized in that: Key information includes corporate business information and / or collection point information.
7. The method according to any one of claims 1 to 3, characterized in that: The entities in the address information include at least one of a province, a municipality directly under the Central Government, a city, a district, a county, a street, a town, a township and a detailed address.
8. An entity recognition device, characterized in that: The method comprises a module for executing the method according to any one of claims 1 to 7.
9. An electronic 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 method according to any one of claims 1 to 7 is implemented.
10. A readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
