Named entity identification methods, apparatus, computer equipment, and storage media
By constructing a word pair matrix and using a word pair relation constraint and a binary relation predictor, the accuracy problem of nested, hierarchical, or cross-entity structures in the named entity recognition task is solved, achieving higher accuracy in named entity recognition and supporting precise analysis and management in the financial field.
Patent Information
- Application Number
- CN202411723934.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2044-11-27
AI Technical Summary
Existing named entity recognition tasks have poor accuracy when dealing with nested, hierarchical, or overlapping entity structures, which affects the accuracy of natural language processing.
By constructing a word pair matrix, using a word pair relation constraint and a binary relation predictor, the initial word pair representation matrix is constrained and relation is predicted. Probability values of proximity and skip relations are obtained and encoded to improve the accuracy of named entity recognition.
It improves the accuracy of named entity recognition for nested, hierarchical, or cross-structured entities, enabling more precise identification of entities such as companies and individuals, and assisting financial institutions in conducting more accurate analysis and management.
Smart Images

Figure CN119647474B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method, apparatus, computer device, and storage medium for identifying named entities. Background Technology
[0002] With the widespread adoption of Natural Language Processing (NLP), Named Entity Recognition (NER), a crucial task within NLP, has become increasingly important. For example, in the financial sector, the accuracy of NER helps to more precisely identify entities such as companies and individuals, enabling more accurate analysis and prediction of market dynamics and public opinion trends. This, in turn, assists financial institutions in making more accurate analyses, assessments, and management decisions.
[0003] Named Entity Recognition (NER) identifies and classifies named entities from text to help understand important information, relationships between entities, and contextual information. Common entity categories include names of people, places, organizations, dates, times, currencies, percentages, product names, and technical terms. NER tasks are typically accomplished using sequence labeling models, which assign individual labels to specific tokens. However, this approach struggles to capture nested, hierarchical, or overlapping entity structures.
[0004] In existing technologies, named entity recognition (NER) requires the integration of other methods or models to better capture the relationships between entities when dealing with complex entity structures and nested entities. For example, word pair models can be used to capture nested, hierarchical, or intersecting entity structures. However, current word pair models cannot accurately filter out reasonable entity relationships between word pairs. In other words, existing NER tasks suffer from poor accuracy when identifying nested, hierarchical, or intersecting entity structures, thus affecting the accuracy of subsequent natural language processing and leading to excessively large errors in the final prediction results. Summary of the Invention
[0005] This invention provides a method, apparatus, computer device, and storage medium for identifying named entities, which solves the problem that existing named entity recognition tasks have poor accuracy when identifying nested, hierarchical, or intersecting entity structures.
[0006] This invention provides a method for identifying named entities, including:
[0007] Obtain the text data to be recognized;
[0008] A word pair matrix is constructed from the text data to be identified to obtain an initial word pair representation matrix;
[0009] A word pair relation constraint is used to constrain the initial word pair representation matrix to obtain a constrained word pair representation matrix.
[0010] A binary relation predictor is used to predict the relation between the initial word pair representation matrix and the constraint word pair representation matrix, and to obtain the probability values of adjacent relation and skip relation.
[0011] The proximity probability value and the skip probability value are encoded to obtain the named entity recognition result.
[0012] This invention also provides a named entity identification device, comprising:
[0013] The text data acquisition module is used to acquire the text data to be recognized.
[0014] The initial word pair representation matrix acquisition module is used to construct a word pair matrix from the text data to be identified and obtain the initial word pair representation matrix.
[0015] The constraint word pair representation matrix acquisition module is used to perform constraint processing on the initial word pair representation matrix using a word pair relation constraint mechanism to obtain the constraint word pair representation matrix.
[0016] The relation probability value acquisition module is used to use a binary relation predictor to predict the relation between the initial word pair representation matrix and the constraint word pair representation matrix, and to obtain the neighbor relation probability value and the neighbor relation probability value.
[0017] The named entity recognition result acquisition module is used to encode the proximity relationship probability value and the skip relationship probability value to obtain the named entity recognition result.
[0018] This invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the aforementioned method for identifying named entities.
[0019] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned method for identifying named entities.
[0020] The aforementioned named entity recognition method, apparatus, computer equipment, and storage medium perform named entity recognition on the text data to be recognized. First, an initial word pair representation matrix containing all word pair relationships is constructed from the text data. Then, a word pair relationship constraint is used to constrain the initial word pair representation matrix, thereby filtering out useless word pair relationships and reducing the impact of noise, resulting in a constrained word pair representation matrix. Finally, a binary relation predictor is used to predict the relationships between the initial and constrained word pair representation matrices, obtaining proximity relationship probability values and jump relationship probability values. After encoding, a more accurate named entity recognition result is obtained, thus improving the accuracy of named entity recognition when identifying nested, hierarchical, or intersecting entity structures. This improved accuracy in named entity recognition facilitates more precise identification of entities such as companies and individuals, enabling more accurate analysis and prediction of market dynamics and public opinion trends, thereby assisting financial institutions in making more accurate analyses, assessments, and management. Attached Figure Description
[0021] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 This is a schematic diagram of an application environment for a named entity recognition method according to an embodiment of the present invention;
[0023] Figure 2 This is a flowchart of a named entity recognition method according to an embodiment of the present invention;
[0024] Figure 3 This is a flowchart of step S202 of the named entity recognition method in one embodiment of the present invention;
[0025] Figure 4 This is a flowchart of step S203 of the named entity recognition method in one embodiment of the present invention;
[0026] Figure 5 This is a flowchart of step S204 of the named entity recognition method in one embodiment of the present invention;
[0027] Figure 6 This is a flowchart of step S501 of the named entity recognition method in one embodiment of the present invention;
[0028] Figure 7 This is a flowchart of step S205 of the named entity recognition method in one embodiment of the present invention;
[0029] Figure 8 This is a flowchart of a named entity identification method according to another embodiment of the present invention;
[0030] Figure 9 This is a schematic diagram of a named entity recognition device according to an embodiment of the present invention;
[0031] Figure 10 This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation
[0032] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0033] The named entity recognition method provided in this embodiment of the invention can be applied to, for example... Figure 1 The application environment shown. Figure 1 As shown, the client (computer device) communicates with the server via a network. The client, also known as the user terminal, refers to the program that provides local services to the client, corresponding to the server. Client (computer device) includes, but is not limited to, various personal computers, laptops, smartphones, tablets, cameras, and portable wearable devices. The server can be a standalone server or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0034] The named entity recognition method provided in this embodiment of the invention can be applied to, for example... Figure 1 The application environment shown. Specifically, this named entity recognition method is applied in a named entity recognition system, which includes, for example,... Figure 1 The client and server shown communicate with each other over a network to implement the named entity recognition method provided in this embodiment of the invention.
[0035] Understandably, in the financial sector, NER can accurately build financial information retrieval systems, conduct sentiment analysis, and forecast markets by tagging and classifying entity information such as company names, stock codes, personal names, and dates in financial news, announcements, and reports. NER can also be used to identify and analyze potential risk factors, such as legal proceedings, market fluctuations, and economic indicators, to assist financial institutions in risk assessment and management. Furthermore, in financial transactions, NER can be used to verify customer identity information, prevent fraudulent activities, and ensure transaction security.
[0036] It should be noted that the named entity recognition method provided in this invention is explained and illustrated using entity types in the financial field, and is not only applicable to named entity recognition in the financial field.
[0037] In one embodiment, such as Figure 2 As shown, a method for identifying named entities is provided, which can be applied to... Figure 1 Taking the server in the example, the following steps are included:
[0038] S201: Obtain the text data to be recognized;
[0039] S202: Construct a word pair matrix from the text data to be recognized to obtain the initial word pair representation matrix;
[0040] S203: Use a word pair relation constraint to constrain the initial word pair representation matrix and obtain the constrained word pair representation matrix;
[0041] S204: A binary relation predictor is used to predict the relation between the initial word pair representation matrix and the constraint word pair representation matrix, and to obtain the probability values of adjacent relation and skip relation.
[0042] S205: Encode the probability values of proximity relationships and skip relationships to obtain the named entity recognition results.
[0043] As an example, in step S201, the server receives the text data to be recognized input by the user or the natural language processing model, and processes the text data to be recognized.
[0044] In this example, in the financial field, when used for tasks such as financial analysis, information extraction, and risk management, common text data to be identified includes, but is not limited to, the following common text types: stock codes, financial indicators, market events, economic indicators, and product names, in addition to personal names, geographical locations, organizational information, time and date.
[0045] Among these, stock codes are frequently used in financial texts; financial indicators are commonly used in the financial field, such as stock prices, market capitalization, and financial metrics; market events are various events in the financial market, such as stock trading, acquisitions, and financing; economic indicators are related to economic data in the financial field, such as GDP and inflation rates; and commodity names are also common in commodity trading in the financial market, and NER can label commodity names, contract types, etc. The above-mentioned common text data represent the types of entities that NER tasks in the financial field commonly need to identify.
[0046] As an example, in step S202, after the server obtains the text data to be recognized, it constructs a word pair matrix for the representation corresponding to the text data to be recognized. Based on each word in the text data to be recognized, a two-dimensional word pair matrix is constructed to obtain the initial word pair representation matrix.
[0047] In this example, the initial word pair representation matrix is the word pair representation matrix that has not been filtered for specific associations of word pairs. The N words in the text data to be identified are extracted in pairs to form an N*N word pair representation matrix Hw, forming a two-dimensional word pair matrix, which serves as the initial word pair representation matrix.
[0048] As an example, in step S203, after obtaining the initial word pair representation matrix after matrix construction, the server inputs the initial word pair representation matrix into the word pair relation constraint generator to constrain the initial word pair representation matrix. That is, entity relation filtering is performed on each word pair representation in the input initial word pair representation matrix to determine the word pair representations with existing entity relations, thus forming the final constrained word pair representation matrix. By filtering the word pair representations for entity relations, the noise impact of word pair representations without entity relations is reduced, thereby improving the accuracy of the named entity recognition task.
[0049] In this example, the word pair relation constraint is used to determine whether each word pair represents an entity relationship. It is obtained after training a binary classifier based on a Multilayer Perceptron (MLP). The Multilayer Perceptron (MLP) is an artificial neural network architecture with strong non-linear modeling capabilities. Especially in entity relationship recognition tasks that handle complex relationships and abstract features, MLPs can capture higher-level abstract features, thus better modeling and filtering word pair entity relationships.
[0050] As an example, in step S204, after obtaining the constraint word pair representation matrix of the constraint processing, the server inputs the initial word pair representation matrix and the constraint word pair representation matrix into the binary relation predictor. The server calculates the probability values of the two types of relations (neighborhood relation and skip relation) for each word pair representation (the representations corresponding to the two matched words in the word pair representation) in the initial word pair representation matrix and the two types of relations (neighborhood relation and skip relation) for each corresponding word pair representation in the constraint word pair representation matrix, and obtains the probability values of the neighbor relation and the skip relation corresponding to the identified text data.
[0051] In this context, "proximity" refers to the state where two entities are adjacent in the text, while "skip" refers to the state where two entities are not adjacent. The relationship probability value represents the probability that a relationship type might exist between any two entities. The probability value for proximity is the probability value corresponding to the proximity relationship, and the probability value for skip relationship is the probability value corresponding to the skip relationship. For example, the probability (proximity probability value) that two entities have a proximity relationship is 0.7, the probability (skip relationship probability value) is 0.2, and the probability (no relationship) is 0.1.
[0052] In this example, the binary relation predictor is used to determine whether there is a proximity or skip relationship between two entities. It is built based on a multilayer perceptron (MLP) and a dual affine linear layer, which improves the sensitivity of capturing complex nonlinear relationships between entities when processing relation prediction. The dual affine linear layer is a neural network technique that combines two affine linear transformations to map the input to another space through a linear transformation. In this example, it is used to reduce the dimensionality of the relationships between entities, and mapping to the affine layer avoids overfitting, thus achieving binary relation classification.
[0053] As an example, in step S205, after obtaining the probability values of proximity relationships and jump relationships, the server constructs a relationship structure between entities based on the probability values of proximity relationships and jump relationships, such as constructing a sentence relationship graph, thereby realizing the recognition of nested and discontinuous entities and obtaining the named entity recognition result.
[0054] In this example, the loss can be calculated based on the named entity recognition results output by the named entity recognition method and the correct named entity labels. For example, cross-entropy can be used as the cost function to adjust the word pair relation constrainer and the binary relation predictor.
[0055] In this example, an initial word pair representation matrix with all word pair relationships is obtained by constructing a word pair matrix from the text data to be recognized. A word pair relationship constraint is then applied to constrain the initial word pair representation matrix, filtering out useless word pair relationships and reducing the impact of noise, resulting in a constrained word pair representation matrix. A binary relation predictor is then used to predict relationships between the initial and constrained word pair representation matrices, obtaining proximity relationship probability values and skip relationship probability values. After encoding, a more accurate named entity recognition result is obtained, thus improving the accuracy of named entity recognition when identifying nested, hierarchical, or intersecting entity structures. This improved accuracy in named entity recognition facilitates more precise identification of entities such as companies and individuals, enabling more accurate analysis and prediction of market dynamics and public opinion trends, thereby assisting financial institutions in making more accurate analyses, assessments, and management.
[0056] In one embodiment, such as Figure 3 As shown, in step S202, a word pair matrix is constructed from the text data to be recognized to obtain an initial word pair representation matrix, including:
[0057] S301: Perform labeling processing on the text data to be recognized to obtain the target context representation;
[0058] S302: Construct a word pair matrix for the target context representation to obtain the initial word pair representation matrix.
[0059] As an example, in step S301, after receiving the text data to be identified input by the user or the natural language processing model, the server obtains the target context representation by tokenizing the text data to be identified.
[0060] In this example, based on business requirements, text content in the financial field is used as the text data to be identified, X{X1,X2……X}. The text data to be identified, X{X1,X2……X}, is input into BERT+BiLSTM to obtain the target context representation.
[0061] As an example, in step S302, after obtaining the target context representation, the server extracts N (N is a positive integer) words from the target context representation in pairs to form a two-dimensional N*N initial word pair representation matrix, thus constructing N*N word pair representations of N words for subsequent entity relationship prediction. In this example, each word pair representation can be represented as (hi, hj), where hi and hj are two words in the context representation, respectively.
[0062] In one embodiment, such as Figure 4As shown, in step S203, a word pair relation constraint is used to constrain the initial word pair representation matrix to obtain a constrained word pair representation matrix, including:
[0063] S401: Extract the representation from the initial word pair representation matrix to obtain the first word pair representation;
[0064] S402: Perform constraint processing on the representation of the first word pair to obtain the representation of the second word pair;
[0065] S403: Merge the first word pair representation and the second word pair representation to obtain the constraint word pair representation matrix.
[0066] As an example, in step S401, after obtaining the initial word pair representation matrix, the server extracts a one-dimensional first word pair representation from the initial word pair representation matrix for processing by the word pair relation constraint. In this example, each word pair representation in the initial word pair representation matrix is extracted sequentially from top to bottom and from left to right, and the N*N word pair representations are concatenated.
[0067] As an example, in step S402, after obtaining the first word pair representation, the server performs constraint processing on the N*N word pair representations in the first word pair representation. That is, after identifying the entity relationship of each word pair representation, it filters out the word pair representations with entity relationships to obtain the second word pair representation. In this example, word pair representations with entity relationships are retained, and word pair representations without entity relationships are assigned 0. The second word pair representation is formed based on the entity relationship identification results (word pair representation or 0) corresponding to the order of each word pair representation in the first word pair representation.
[0068] As an example, in step S403, after obtaining the second word pair representation, the server multiplies and fuses the second word pair representation with the first word pair representation, which has entity relationship recognition results, to obtain the constrained word pair representation matrix. Specifically, the second word pair representation filters out word pairs in the first word pair representation that have entity relationships; word pairs without entity relationships are represented by 0.
[0069] In this example, after processing the initial word pair representation matrix into one dimension, entity relationship recognition is performed on the first word pair representation resulting from the one-dimensional processing. Based on the entity relationship recognition result, a second word pair representation is obtained. After fusing the first and second word pair representations, a constrained word pair representation matrix is obtained. This matrix filters out word pairs that can be used for the task, thus avoiding the use of word pairs without entity relationships. Compared to directly using all word pair representations for the task, this reduces noise interference and improves task processing performance.
[0070] In one embodiment, such as Figure 5As shown, in step S204, a binary relation predictor is used to predict the relation between the initial word pair representation matrix and the constraint word pair representation matrix, obtaining the probability values of adjacent relations and skip relations, including:
[0071] S501: A binary relation predictor is used to predict the relation between the initial word pair representation matrix and the constraint word pair representation matrix, and to obtain the initial relation score corresponding to the initial word pair representation matrix and the constraint relation score corresponding to the constraint word pair representation matrix.
[0072] S502: Add the residuals of the initial relation score and the constraint relation score to obtain the merged relation score;
[0073] S503: Classify the merged relationship scores to obtain the neighbor relationship scores and jump relationship scores;
[0074] S504: Vectorize the neighbor relationship score and the jump relationship score to obtain the neighbor relationship vector corresponding to the neighbor relationship score and the jump relationship vector corresponding to the jump relationship score.
[0075] S505: Normalize the neighbor relationship vector and the jump relationship vector to obtain the neighbor relationship probability value corresponding to the neighbor relationship vector and the jump relationship probability value corresponding to the jump relationship vector.
[0076] As an example, in step S501, after receiving the initial word pair representation matrix and the constraint word pair representation matrix, the server inputs the initial word pair representation matrix and the constraint word pair representation matrix into the binary relation predictor, respectively, performs relation score prediction based on the initial word pair representation matrix, outputs the corresponding initial relation score, and then performs relation score prediction based on the constraint word pair representation matrix, outputs the corresponding constraint relation score.
[0077] In this example, the initial relation score includes the jump relation score and the neighbor relation score corresponding to each word pair representation in the initial word pair representation matrix, and the constraint relation score includes the jump relation score and the neighbor relation score corresponding to each word pair representation in the constraint word pair representation matrix. It is important to note that this process outputs the scores of the initial word pair representation matrix in both relation dimensions separately, i.e., the initial relation scores; while the output constraint relation scores are the scores of the constraint word pair representation matrix in both relation dimensions.
[0078] As an example, in step S502, after obtaining the initial relation score and constraint relation score, the server adds the residuals of the initial relation score and constraint relation score to obtain a total merged relation score. Using the initial relation score and constraint relation score together avoids errors caused by the loss of contextual information.
[0079] In this example, the initial relation score, constraint relation score, and merge relation score are all in matrix form. Since there are two dimensions of relations (adjacent relations and jump relations), the matrix dimension corresponding to the relation score is N*N*2 (where 2 represents adjacent relations and jump relations).
[0080] As an example, in step S503, after obtaining the merge relationship score, the server classifies the merge relationship score into relationships, that is, according to the different relationships, it divides the scores corresponding to the neighboring relationship and the jump relationship in the merge relationship score, thereby obtaining the neighboring relationship score and the jump relationship score.
[0081] As an example, in step S504, after obtaining the neighbor relationship score and the jump relationship score, the server performs vectorization processing on the neighbor relationship score and the jump relationship score through the MLP layer, and obtains the neighbor relationship vector corresponding to the neighbor relationship score and the jump relationship vector corresponding to the jump relationship score.
[0082] As an example, in step S505, after the server obtains the neighbor relationship vector and the jump relationship vector, it performs an exponential operation on the neighbor relationship vector and the jump relationship vector to obtain the exponential result, which is then used for normalization processing in the softmax layer, thereby obtaining the neighbor relationship probability value corresponding to the neighbor relationship vector and the jump relationship probability value corresponding to the jump relationship vector.
[0083] In one embodiment, such as Figure 6 As shown, in step S501, a binary relation predictor is used to predict the relation between the initial word pair representation matrix and the constraint word pair representation matrix, obtaining the initial relation score corresponding to the initial word pair representation matrix and the constraint relation score corresponding to the constraint word pair representation matrix, including:
[0084] S601: The initial word pair representation matrix includes an initial first word representation and an initial second word representation; the initial first word representation and the initial second word representation are respectively mapped to obtain the initial first mapping feature;
[0085] S602: Concatenate the initial first lexical representation and the initial second lexical representation to obtain the initial concatenated lexical representation; perform mapping processing on the concatenated lexical representation to obtain the initial second mapping feature;
[0086] S603: Merge the initial first mapping feature and the initial second mapping feature to obtain the initial relation score corresponding to the initial word pair representation matrix;
[0087] S604: The constraint word pair representation matrix includes the first constraint word representation and the second constraint word representation; the first constraint word representation and the second constraint word representation are respectively mapped to obtain the first constraint mapping feature;
[0088] S605: Concatenate the first constraint lexical representation and the second constraint lexical representation to obtain the constraint concatenated lexical representation; perform mapping processing on the concatenated lexical representation to obtain the constraint second mapping feature;
[0089] S606: Merge the first constraint mapping feature and the second constraint mapping feature to obtain the constraint relationship score corresponding to the constraint word pair representation matrix.
[0090] In this context, the first and second lexical representations in the word pair representation matrix are the lexical representations corresponding to the two words in a word pair. Therefore, the initial first and second lexical representations are the representations corresponding to the two words in the word pair representations in the initial word pair representation matrix; the constrained first and second lexical representations are the representations corresponding to the two words in the word pair representations in the constrained word pair representation matrix.
[0091] As an example, in step S601, after the server obtains the initial word pair representation matrix and the constraint word pair representation matrix, it performs mapping processing on the dimensionality-reduced initial first word representation through the dual ray-like layer in the binary relation predictor, and performs transpose processing to obtain the initial first word representation; it then performs mapping processing on the dimensionality-reduced initial second word representation to obtain the corresponding initial first mapping features between the initial second word representations.
[0092] In this example, the mapping process includes taking the dimensionality-reduced initial first lexical representation and the dimensionality-reduced initial second lexical representation, inputting the pre-selected training first linear transformation matrix, and thus outputting the first mapping feature.
[0093] As an example, in step S602, after the server obtains the initial first vocabulary representation and the initial second vocabulary representation, it concatenates the initial first vocabulary representation and the initial second vocabulary representation, and then maps the concatenated initial vocabulary representation to obtain the initial second mapped feature.
[0094] In this example, the mapping process involves taking the concatenated initial concatenated vocabulary representation as input to the pre-trained second linear transformation matrix, thereby outputting a second mapping feature.
[0095] As an example, in step S603, after obtaining the initial first mapping feature and the initial second mapping feature, the server simultaneously obtains the bias value obtained after pre-training, and merges the bias value obtained after pre-training, the initial first mapping feature and the initial second mapping feature to obtain the initial relation score corresponding to the initial word pair representation matrix.
[0096] As an example, in step S604, after obtaining the constraint word pair representation matrix and the constraint word pair representation matrix, the server performs mapping processing on the dimensionality-reduced constraint first word representation through the dual ray-like layer in the binary relation predictor, and performs transpose processing to obtain the constraint first word representation; and performs mapping processing on the dimensionality-reduced constraint second word representation to obtain the corresponding constraint first mapping feature between the constraint second word representations.
[0097] In this example, the mapping process includes taking the first constrained vocabulary representation after dimensionality reduction and the second constrained vocabulary representation after dimensionality reduction, inputting the first linear transformation matrix after pre-selected training, and thus outputting the first mapping feature.
[0098] As an example, in step S604, after obtaining the first constraint vocabulary representation and the second constraint vocabulary representation, the server concatenates the first constraint vocabulary representation and the second constraint vocabulary representation, and then maps the concatenated constraint vocabulary representation to obtain the second constraint mapping feature.
[0099] In this example, the mapping process includes concatenating the concatenated constraint vocabulary representation, inputting the pre-trained second linear transformation matrix, and outputting the second mapping feature.
[0100] As an example, in step S605, after obtaining the first constraint mapping feature and the second constraint mapping feature, the server simultaneously obtains the bias value obtained after pre-training, and merges the bias value obtained after pre-training, the first constraint mapping feature and the second constraint mapping feature to obtain the constraint relation score corresponding to the constraint word pair representation matrix.
[0101] In this example, a binary relation predictor based on MLP and dual affine layers is used to predict the relation between the initial word pair representation matrix and the constraint word pair representation matrix. The data is dimensionality reduced and overfitting is avoided by mapping to the affine layer, thereby obtaining the initial relation score corresponding to the initial word pair representation matrix and the constraint relation score corresponding to the constraint word pair representation matrix.
[0102] In one embodiment, such as Figure 7 As shown, in step S205, a word pair relation constraint is used to constrain the initial word pair representation matrix to obtain a constrained word pair representation matrix, including:
[0103] S701: Analyze the probability values of proximity relationships and jump relationships to obtain sentence relationship results;
[0104] S702: Based on the word proximity relationships in the sentence relationship results, perform entity path prediction processing to obtain the first prediction result;
[0105] S703: Based on the word jump relationships in the sentence relationship results, perform entity type and boundary prediction processing to obtain the second prediction result;
[0106] S704: Obtain the named entity recognition result based on the first prediction result and the second prediction result.
[0107] As an example, in step S701, after obtaining the probability values of proximity relationships and jump relationships, the server analyzes these probabilities to obtain the sentence relationship results. In this example, the sentence relationship results represent the relationship structure within each word representation. For instance, in the text data to be identified, "Shanghai is a worthwhile tourist attraction," the sentence relationship results show that the two characters "Shanghai" are adjacent, and "Shanghai" and "attraction" are jump relationships. The relationship trends between words can also be illustrated using a sentence relationship diagram.
[0108] As an example, in step S702, after obtaining the sentence relationship results, the server performs entity path prediction processing based on the word proximity relationships in the sentence relationship results to obtain a first prediction result. In this example, entity paths are predicted based on proximity relationships, that is, by analyzing the proximity relationships between words to predict the possible relationship paths between them, and the prediction result is used as the first prediction result.
[0109] As an example, in step S703, after obtaining the sentence relationship results, the server performs entity type and boundary prediction processing based on the word jump relationships in the sentence relationship results, thereby obtaining a second prediction result. In this example, entity types and boundaries are determined based on jump relationships, that is, their types and boundaries in the text are determined by analyzing the jump relationships between words.
[0110] As an example, in step S704, after the server obtains the first prediction result corresponding to the entity path prediction and the second prediction result corresponding to the entity type and boundary prediction, it predicts the entity path based on the proximity relationship, and determines the entity type and boundary through the jump relationship, thereby realizing nested and discontinuous entity recognition and obtaining the named entity recognition result.
[0111] In this example, by predicting entity paths based on proximity relationships and determining entity types and boundaries through jump relationships, the accurate identification of nested and discontinuous entities is achieved, improving the accuracy of named entity recognition when identifying nested, hierarchical, or intersecting entity structures.
[0112] In another embodiment, such as Figure 8 As shown, in step S203, a word pair relation constraint is used to constrain the initial word pair representation matrix. Before obtaining the constrained word pair representation matrix, the named entity recognition method further includes:
[0113] S801: Obtain sample data based on entity prior relationships;
[0114] S802: Perform feature extraction processing on the sample data to obtain the sample context representation;
[0115] S803: Construct a word pair matrix from the sample context representation to obtain the sample word pair representation matrix;
[0116] S804: Input the sample word pair representation matrix into the multilayer perceptron for classification processing to obtain the sample recognition result corresponding to the sample data;
[0117] S805: Perform loss calculation on the sample identification results corresponding to the sample data and the real label data corresponding to the sample data to obtain the relationship prediction loss value;
[0118] S806: Based on the relationship prediction loss value, update the multilayer perceptron to obtain the word pair relationship constraint.
[0119] As an example, in step S801, the server receives sample data for training input by the user or the natural language processing model. This sample data is formed based on prior entity relationships, that is, real sample data obtained through annotation or recognition.
[0120] As an example, in step S802, after receiving sample data input by the receiving user or the natural language processing model, the server obtains a sample context representation by tokenizing the sample text data.
[0121] In this example, based on business requirements, sample content in the financial field is used as sample text data X{X1,X2……X}, and the sample text data X{X1,X2……X} is input into BERT+BiLSTM to obtain the sample context representation.
[0122] As an example, in step S803, after obtaining the sample context representation, the server extracts N (N is a positive integer) words from the sample context representation in pairs to form a two-dimensional N*N sample word pair representation matrix, so as to construct N*N word pair representations of N words for subsequent entity relationship prediction.
[0123] As an example, in step S804, after obtaining the sample word pair representation matrix, the server inputs the sample word pair representation matrix into a multilayer perceptron for prediction and classification processing to obtain the sample recognition result corresponding to the sample data. In this example, for each word pair representation in the sample word pair representation matrix, classification prediction is performed. When the word pair representation has an entity relationship, the word pair representation with an entity relationship is labeled as 1, and the word pair representation without an entity relationship is labeled as 0. After all the word pair representations in the sample word pair representation matrix have been classified, the sample recognition result is obtained.
[0124] As an example, in step S805, after obtaining the sample recognition result corresponding to the sample data, the server performs loss calculation based on the sample recognition result and the real label data corresponding to the sample data to obtain the relationship prediction loss value. In this example, the cross-entropy of the sample recognition result and the real label data corresponding to the sample data is used to obtain the corresponding relationship prediction loss value, which is then used to train the word pair relationship constraint.
[0125] As an example, in step S806, the server updates the multilayer perceptron based on the relation prediction loss value to obtain a word pair relation constraint. In this example, the multilayer perceptron is updated according to preset conditions. When the relation prediction loss value reaches the preset conditions, the multilayer perceptron is used as the word pair relation constraint and optimized in subsequent use.
[0126] In this example, the binary classifier of the Multilayer Perceptron (MLP) is trained using sample data to obtain a word pair relation constraint. This leverages the strong nonlinear modeling capability to determine whether each word pair represents an entity relationship, improving the filtering of word pair relations and thus filtering out useless word pair relations, reducing the impact of noise.
[0127] It should be understood that the sequence number of each step in the above embodiments does not imply 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 invention.
[0128] In one embodiment, a named entity identification device is provided, which corresponds one-to-one with the named entity identification methods in the above embodiments. For example... Figure 9 As shown, the named entity recognition device includes a text data acquisition module 901, an initial word pair representation matrix acquisition module 902, a constraint word pair representation matrix acquisition module 903, a relation probability value acquisition module 904, and a named entity recognition result acquisition module 905. Detailed descriptions of each functional module are as follows:
[0129] The text data acquisition module 901 is used to acquire the text data to be recognized.
[0130] The initial word pair representation matrix acquisition module 902 is used to construct a word pair matrix from the text data to be recognized and obtain the initial word pair representation matrix.
[0131] The constraint word pair representation matrix acquisition module 903 is used to perform constraint processing on the initial word pair representation matrix using a word pair relation constraint mechanism to obtain the constraint word pair representation matrix.
[0132] The relation probability value acquisition module 904 is used to use a binary relation predictor to predict the relation between the initial word pair representation matrix and the constraint word pair representation matrix, and to obtain the probability value of the neighboring relation and the probability value of the neighboring relation.
[0133] The named entity recognition result acquisition module 905 is used to encode the probability values of proximity relationships and jump relationships to obtain the named entity recognition results.
[0134] In one embodiment, the initial word pair representation matrix acquisition module 902 includes:
[0135] The target context representation acquisition unit is used to perform labeling processing on the text data to be recognized and acquire the target context representation.
[0136] The initial word pair representation matrix acquisition unit is used to construct a word pair representation matrix from the target context representation and obtain the initial word pair representation matrix.
[0137] In one embodiment, the constraint term pair representation matrix acquisition module 903 includes:
[0138] The first word pair representation acquisition unit is used to extract the representation from the initial word pair representation matrix and obtain the first word pair representation.
[0139] The second word pair representation acquisition unit is used to perform constraint processing on the first word pair representation to acquire the second word pair representation;
[0140] The constraint word pair representation matrix acquisition unit is used to fuse the first word pair representation and the second word pair representation to obtain the constraint word pair representation matrix.
[0141] In one embodiment, the relationship probability value acquisition module 904 includes:
[0142] The initial relation score and constraint relation score acquisition unit is used to use a binary relation predictor to predict the relation between the initial word pair representation matrix and the constraint word pair representation matrix, and to obtain the initial relation score corresponding to the initial word pair representation matrix and the constraint relation score corresponding to the constraint word pair representation matrix.
[0143] The merge relation score acquisition unit is used to add the residuals of the initial relation score and the constraint relation score to obtain the merge relation score;
[0144] The neighbor relationship score and jump relationship score acquisition unit is used to classify the merged relationship score and obtain the neighbor relationship score and jump relationship score;
[0145] The neighbor relationship vector and jump relationship vector acquisition unit is used to vectorize the neighbor relationship score and jump relationship score to obtain the neighbor relationship vector corresponding to the neighbor relationship score and the jump relationship vector corresponding to the jump relationship score.
[0146] The neighbor relationship probability value and jump relationship probability value acquisition unit is used to normalize the neighbor relationship vector and jump relationship vector to obtain the neighbor relationship probability value corresponding to the neighbor relationship vector and the jump relationship probability value corresponding to the jump relationship vector.
[0147] In one embodiment, the initial relation score and constraint relation score acquisition subunit includes:
[0148] The initial first mapping feature acquisition subunit is used to initialize the word pair representation matrix, which includes the initial first vocabulary representation and the initial second vocabulary representation; the initial first vocabulary representation and the initial second vocabulary representation are respectively mapped to obtain the initial first mapping feature.
[0149] The initial second mapping feature acquisition subunit is used to concatenate the initial first lexical representation and the initial second lexical representation to obtain the initial concatenated lexical representation; and to perform mapping processing on the concatenated lexical representation to obtain the initial second mapping feature.
[0150] The initial relation score acquisition sub-unit is used to merge the initial first mapping feature and the initial second mapping feature to obtain the initial relation score corresponding to the initial word pair representation matrix;
[0151] The first constraint mapping feature acquisition subunit is used to constrain the word pair representation matrix, which includes the first constraint vocabulary representation and the second constraint vocabulary representation; the first constraint vocabulary representation and the second constraint vocabulary representation are respectively mapped to obtain the first constraint mapping feature.
[0152] The second constraint mapping feature acquisition subunit is used to concatenate the first constraint lexical representation and the second constraint lexical representation to obtain the concatenated constraint lexical representation; and to perform mapping processing on the concatenated lexical representation to obtain the second constraint mapping feature.
[0153] The constraint relationship score acquisition sub-unit is used to merge the first constraint mapping feature and the second constraint mapping feature to obtain the constraint relationship score corresponding to the constraint word pair representation matrix.
[0154] In one embodiment, the named entity recognition result acquisition module 905 includes:
[0155] The sentence relationship result acquisition unit is used to analyze the probability values of proximity relationships and jump relationships to obtain sentence relationship results;
[0156] The first prediction result acquisition unit is used to perform entity path prediction processing based on the word proximity relationship in the sentence relationship result to obtain the first prediction result;
[0157] The second prediction result acquisition unit is used to perform entity type and boundary prediction processing based on the word jump relationship in the sentence relationship result, and to obtain the second prediction result;
[0158] The named entity recognition result acquisition unit is used to acquire the named entity recognition result based on the first prediction result and the second prediction result.
[0159] In another embodiment, the named entity identification device further includes:
[0160] The sample data acquisition module is used to acquire sample data based on prior relationships between entities;
[0161] The sample context representation acquisition module is used to perform feature extraction processing on sample data and acquire sample context representation.
[0162] The sample word pair representation matrix acquisition module is used to construct a word pair matrix from the sample context representation and obtain the sample word pair representation matrix.
[0163] The sample recognition result acquisition module is used to input the sample word pair representation matrix into the multilayer perceptron for classification processing and to obtain the sample recognition result corresponding to the sample data.
[0164] The relationship prediction loss value acquisition module is used to calculate the loss between the sample recognition result corresponding to the sample data and the real label data corresponding to the sample data, and to obtain the relationship prediction loss value.
[0165] The word pair relation constraint acquisition module is used to update the multilayer perceptron based on the relation prediction loss value and acquire the word pair relation constraint.
[0166] Specific limitations regarding the named entity recognition device can be found in the limitations of the named entity recognition method described above, and will not be repeated here. Each module in the aforementioned named entity recognition device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0167] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 10 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database is used to store data employed or generated during the execution of a named entity recognition method. The network interface is used to communicate with external terminals via a network connection. When executed by the processor, the computer program implements a named entity recognition method.
[0168] 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. When the processor executes the computer program, it implements the named entity recognition method described in the above embodiments, for example... Figure 2 As shown in S201-S205, or Figures 3 to 8 As shown, to avoid repetition, it will not be described again here. Alternatively, when the processor executes a computer program, it implements the functions of each module / unit in this embodiment of the named entity recognition device, for example... Figure 9 The functions of the following modules are shown: text data acquisition module 901, initial word pair representation matrix acquisition module 902, constraint word pair representation matrix acquisition module 903, relation probability value acquisition module 904, and named entity recognition result acquisition module 905. To avoid repetition, these functions will not be described again here.
[0169] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When executed by a processor, the computer program implements the named entity recognition method described in the above embodiment, for example... Figure 2 As shown in S201-S205, or Figures 3 to 8 As shown, to avoid repetition, it will not be described again here. Alternatively, when the computer program is executed by the processor, it implements the functions of each module / unit in this embodiment of the named entity recognition device, for example... Figure 9 The functions of the following modules are shown: text data acquisition module 901, initial word pair representation matrix acquisition module 902, constraint word pair representation matrix acquisition module 903, relation probability value acquisition module 904, and named entity recognition result acquisition module 905. To avoid repetition, these functions will not be described again here.
[0170] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided by this invention can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAM bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0171] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to 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.
[0172] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A method for recognizing named entities, characterized in that, include: Obtain the text data to be recognized; A word pair matrix is constructed from the text data to be identified to obtain an initial word pair representation matrix; A word pair relationship constraint is used to constrain the initial word pair representation matrix to obtain a constrained word pair representation matrix. This includes: inputting the initial word pair representation matrix into the word pair relationship constraint, filtering entity relationships for each word pair representation in the input initial word pair representation matrix, determining the word pair representations with existing entity relationships, and constructing the final constrained word pair representation matrix. A binary relation predictor is used to predict the relation between the initial word pair representation matrix and the constraint word pair representation matrix, and to obtain the initial relation score corresponding to the initial word pair representation matrix and the constraint relation score corresponding to the constraint word pair representation matrix. The residuals of the initial relation score and the constraint relation score are added together to obtain the merged relation score; The merged relationship scores are classified to obtain the neighbor relationship scores and skip relationship scores; The proximity score and the jump score are vectorized to obtain the proximity vector corresponding to the proximity score and the jump vector corresponding to the jump score; The proximity relationship vector and the jump relationship vector are normalized to obtain the proximity relationship probability value corresponding to the proximity relationship vector and the jump relationship probability value corresponding to the jump relationship vector. The proximity probability value and the skip probability value are encoded to obtain the named entity recognition result.
2. The named entity recognition method as described in claim 1, characterized in that, The step of constructing a word pair matrix from the text data to be identified to obtain an initial word pair representation matrix includes: The text data to be identified is labeled to obtain a target context representation; A word pair matrix is constructed on the target context representation to obtain the initial word pair representation matrix.
3. The named entity recognition method as described in claim 1, characterized in that, The step of constraining the initial word pair representation matrix to obtain a constrained word pair representation matrix includes: The initial word pair representation matrix is subjected to representation extraction to obtain the first word pair representation; The first word pair representation is constrained to obtain the second word pair representation. The first word pair representation and the second word pair representation are fused to obtain the constrained word pair representation matrix.
4. The named entity recognition method as described in claim 1, characterized in that, The step of performing relation prediction on the initial word pair representation matrix and the constraint word pair representation matrix to obtain the initial relation score corresponding to the initial word pair representation matrix and the constraint relation score corresponding to the constraint word pair representation matrix includes: The initial word pair representation matrix includes an initial first word representation and an initial second word representation; the initial first word representation and the initial second word representation are respectively mapped to obtain an initial first mapping feature; The initial first lexical representation and the initial second lexical representation are concatenated to obtain an initial concatenated lexical representation; the concatenated lexical representation is then mapped to obtain an initial second mapped feature. The initial first mapping feature and the initial second mapping feature are merged to obtain the initial relation score corresponding to the initial word pair representation matrix; The constraint word pair representation matrix includes a first constraint word representation and a second constraint word representation; the first constraint word representation and the second constraint word representation are respectively mapped to obtain the first constraint mapping feature; The first constraint lexical representation and the second constraint lexical representation are concatenated to obtain a concatenated constraint lexical representation; the concatenated lexical representation is then mapped to obtain a second constraint mapping feature. The constraint first mapping feature and the constraint second mapping feature are merged to obtain the constraint relationship score corresponding to the constraint word pair representation matrix.
5. The named entity recognition method as described in claim 1, characterized in that, The process of encoding the proximity probability value and the skip probability value to obtain the named entity recognition result includes: Analyze the proximity relationship probability value and the skip relationship probability value to obtain the sentence relationship result; Based on the word proximity relationships in the sentence relationship results, entity path prediction processing is performed to obtain the first prediction result; Based on the word jump relationships in the sentence relationship results, entity type and boundary prediction processing is performed to obtain a second prediction result; Based on the first prediction result and the second prediction result, the named entity recognition result is obtained.
6. The named entity recognition method as described in claim 1, characterized in that, Before applying a word pair relation constraint to constrain the initial word pair representation matrix and obtaining the constrained word pair representation matrix, the named entity recognition method further includes: Obtain sample data based on prior relationships between entities; The sample data is subjected to feature extraction processing to obtain the sample context representation; The sample context representation is used to construct a word pair matrix to obtain the sample word pair representation matrix; The sample word pair representation matrix is input into a multilayer perceptron for classification processing to obtain the sample recognition result corresponding to the sample data. Loss calculation is performed on the sample identification results corresponding to the sample data and the real label data corresponding to the sample data to obtain the relationship prediction loss value; Based on the relationship prediction loss value, the multilayer perceptron is updated to obtain the word pair relationship constraint.
7. A named entity identification device, characterized in that, include: The text data acquisition module is used to acquire the text data to be recognized. The initial word pair representation matrix acquisition module is used to construct a word pair matrix from the text data to be identified and obtain the initial word pair representation matrix. The constraint word pair representation matrix acquisition module is used to perform constraint processing on the initial word pair representation matrix using a word pair relation constraint device to obtain the constraint word pair representation matrix; the constraint word pair representation matrix acquisition module includes: inputting the initial word pair representation matrix into the word pair relation constraint device, performing entity relation filtering on each word pair representation in the input initial word pair representation matrix, determining the word pair representations with existing entity relations, and constructing the final constraint word pair representation matrix; The relation probability value acquisition module is used to predict relations on the initial word pair representation matrix and the constraint word pair representation matrix using a binary relation predictor, and to obtain the initial relation score corresponding to the initial word pair representation matrix and the constraint relation score corresponding to the constraint word pair representation matrix; to sum the residuals of the initial relation score and the constraint relation score to obtain the merged relation score; to classify the merged relation score to obtain the neighbor relation score and the jump relation score; to vectorize the neighbor relation score and the jump relation score to obtain the neighbor relation vector corresponding to the neighbor relation score and the jump relation vector corresponding to the jump relation score; and to normalize the neighbor relation vector and the jump relation vector to obtain the neighbor relation probability value corresponding to the neighbor relation vector and the jump relation probability value corresponding to the jump relation vector. The named entity recognition result acquisition module is used to encode the proximity relationship probability value and the skip relationship probability value to obtain the named entity recognition result.
8. 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, it implements the named entity identification method as described in any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the named entity identification method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Named entity identification method and device, electronic equipment and storage medium
CN116341553A
Named entity recognition method and recognition device, electronic equipment and storage medium
CN116432648A