Named entity recognition methods, model training methods, devices and storage media
By using semantically similar sample texts to train and optimize the model, the problem of high training cost of named entity recognition models is solved, and low-cost model optimization and recognition effect are achieved.
Patent Information
- Application Number
- CN202210344549.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-31
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2042-03-31
AI Technical Summary
The training of existing named entity recognition models requires a large amount of manually labeled data, resulting in high training costs.
The model is trained using two semantically similar sample texts, and optimized based on the differences in recognition results. Only some sample texts need to be labeled with entity category labels, while other sample texts only need to be labeled with semantic similarity. The model is trained using weak supervision signals.
It effectively reduces the training cost of named entity recognition models and achieves efficient model optimization by training data with weakly supervised signals.
Smart Images

Figure CN114662494B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a named entity recognition method, model training method, device and storage medium. Background Technology
[0002] With the rapid development of big data technology, natural language understanding (NLE) technology based on machine learning has been widely applied. Named Entity Recognition (NER) plays a crucial role in various NLE applications. NER is a form of information extraction, its main task being to classify words in text into entity types such as person names, place names, and organization names. This task is essential for search engines, question-answering systems, and machine translation, and forms the foundation for more complex information extraction tasks.
[0003] Currently, training machine learning-based named entity recognition models requires a large amount of labeled data. This labeled data is usually obtained manually. Therefore, the training cost of existing named entity recognition models is relatively high. Summary of the Invention
[0004] In view of the above problems, this application is made to provide a named entity recognition method, model training method, device and storage medium that solves or at least partially solves the above problems.
[0005] Therefore, in one embodiment of this application, a named entity recognition method is provided, comprising:
[0006] Obtain the text to be recognized;
[0007] The text to be recognized is input into a trained named entity recognition model to obtain the recognition result of the text to be recognized; wherein, the training process of the named entity recognition model includes:
[0008] The first sample text, the second sample text, and the third sample text are input into the named entity recognition model to obtain the recognition results for each of the three sample texts; the second sample text and the third sample text are semantically similar.
[0009] The named entity recognition model is optimized based on the first difference between the recognition result of the first sample text and its expected recognition result, and the second difference between the recognition result of the second sample text and the recognition result of the third sample text.
[0010] In another embodiment of this application, a model training method is provided, comprising:
[0011] The first sample text, the second sample text, and the third sample text are input into the named entity recognition model to obtain the recognition results for each of the three sample texts; the second sample text and the third sample text are semantically similar.
[0012] The named entity recognition model is optimized based on the first difference between the recognition result of the first sample text and its expected recognition result, and the second difference between the recognition result of the second sample text and the recognition result of the third sample text.
[0013] In another embodiment of this application, a search method is provided, comprising:
[0014] Get the query text entered by the user;
[0015] The query text is input into a trained named entity recognition model to obtain a tag sequence corresponding to the query text;
[0016] The query results are determined based on the tag sequence and the query text;
[0017] The training process of the named entity recognition model includes:
[0018] The first sample text, the second sample text, and the third sample text are input into the named entity recognition model to obtain the recognition results for each of the three sample texts; the second sample text and the third sample text are semantically similar.
[0019] The named entity recognition model is optimized based on the first difference between the recognition result of the first sample text and its expected recognition result, and the second difference between the recognition result of the second sample text and the recognition result of the third sample text.
[0020] In another embodiment of this application, an electronic device is provided. The electronic device includes: a memory and a processor, wherein,
[0021] The memory is used to store programs;
[0022] The processor, coupled to the memory, is used to execute the program stored in the memory to implement the named entity recognition method, model training method, or search method described above.
[0023] In another embodiment of this application, a computer-readable storage medium storing a computer program is provided, wherein when the computer program is executed by a computer, it can implement the named entity recognition method, model training method, or search method described above.
[0024] The technical solution provided in this application uses two semantically similar sample texts to train the model, and optimizes the model based on the differences in the recognition results of these two sample texts. In this way, only some sample texts need to be labeled with entity category tags to define their expected recognition results; other sample texts only need to be labeled with pairwise semantic similarity, without the need for entity category tagging, effectively reducing labeling costs. The technical solution provided in this application can utilize training data from weakly supervised signals to train the entity recognition model, effectively reducing training costs. Attached Figure Description
[0025] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0026] Figure 1 A schematic flowchart illustrating a model training method provided in an embodiment of this application;
[0027] Figure 2 A flowchart illustrating a named entity recognition method provided in an embodiment of this application;
[0028] Figure 3 A flowchart illustrating a search method provided in an embodiment of this application;
[0029] Figure 4 This is a structural block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0030] Currently, named entity recognition (NER) models are needed in search scenarios (or query scenarios), intelligent question answering, machine translation, and other scenarios to identify the entity category of each word in the text to be recognized. Currently, the training data for NER models mostly requires manual annotation, which is costly and time-consuming. Taking e-commerce search scenarios as an example, a large amount of search text needs to be collected or created, and then each text unit in the search text needs to be manually labeled with the corresponding entity category tag.
[0031] To address or partially address the aforementioned technical problems, this application proposes a novel training method for a named entity recognition model. Specifically, the model is trained using two semantically similar sample texts, and optimized based on the differences in recognition results between these two sample texts. This way, only a subset of sample texts needs entity category labeling to define their expected recognition results; other sample texts only need to be labeled with pairwise semantic similarities, eliminating the need for entity category labeling and effectively reducing labeling costs. The technical solution provided in this application utilizes training data with weakly supervised signals to train the entity recognition model, effectively reducing training costs.
[0032] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative effort are within the scope of protection of the present application.
[0033] Furthermore, some processes described in the specification, claims, and accompanying drawings of this application include multiple operations that appear in a specific order. These operations may be performed out of order or in parallel. Operation numbers such as 101, 102, etc., are merely used to distinguish different operations and do not represent any execution order. Additionally, these processes may include more or fewer operations, and these operations may be performed sequentially or in parallel. It should be noted that the terms "first," "second," etc., used herein are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.
[0034] Before introducing the named entity recognition method provided in the embodiments of this application, the training process of the named entity recognition model required in the named entity recognition method will be introduced first.
[0035] Figure 1 This illustration shows a flowchart of a model training method provided in an embodiment of this application. The execution entity of this method can be a client or a server. The client can be hardware with embedded programs integrated on a terminal, application software installed on the terminal, or utility software embedded in the terminal's operating system, etc., and this embodiment does not limit its scope. The terminal can be any terminal device, including mobile phones, tablets, and in-vehicle terminal devices. The server can be a conventional server, a cloud server, or a virtual server, etc., and this embodiment does not specifically limit its scope. Figure 1As shown, the method includes:
[0036] 101. Input the first sample text, the second sample text, and the third sample text into the named entity recognition model to obtain the recognition results of the first sample text, the second sample text, and the third sample text respectively.
[0037] The second sample text is semantically similar to the third sample text.
[0038] 102. Optimize the named entity recognition model based on the first difference between the recognition result of the first sample text and its expected recognition result, and the second difference between the recognition result of the second sample text and the recognition result of the third sample text.
[0039] In the above 101, the named entity recognition model can be based on a deep learning model, such as a neural network model. In a specific example, the named entity recognition model can be based on an LSTM (Long Short-Term Memory) network.
[0040] The first, second, and third sample texts mentioned above are all composed of at least one text unit in sequence. Each text unit can be a word or a single character; this application does not impose specific limitations on this and it can be set according to actual needs. For example, when the sample text is in Chinese, the text unit can refer to a single character; when the sample text is in English, the text unit can refer to a word.
[0041] The number of text units in the second and third sample texts can be the same or different; this embodiment does not specifically limit this. The second and third sample texts form a similar sample text pair. In actual training, multiple similar sample text pairs can be used to optimize the named entity recognition model. In one example, multiple collected texts can be paired to obtain similar sample texts. Whether two sample texts are similar can be determined by the user or by using an existing calculation model for calculating the semantic similarity between two texts. In another example, the collected texts can be manually modified to obtain modified texts, and the unmodified texts and modified texts can be combined to form a similar sample text pair. Specifically, the third sample text is obtained by manually modifying the second sample text. The modification method can be one or more of the following:
[0042] Method 1: The entities in the second sample text can be replaced with similar entities that are semantically similar to the entity unit.
[0043] For example, if the second sample text is "curved screen of mobile phone", then the entity "mobile phone" can be replaced with the semantically similar "smartphone", and the resulting third sample text will be "curved screen of smartphone".
[0044] Method 2: The positional order of multiple entities in the second sample text can be adjusted.
[0045] Using the previous example, the positions of "phone" and "curved screen" can be interchanged.
[0046] Method 3: Add new text units to the second sample text.
[0047] Using the same example as before, adding "HD camera" to the second sample text results in the third sample text being "mobile phone curved screen HD camera".
[0048] Method 4: Delete text units in the second sample text.
[0049] Continuing with the previous example, deleting "curved screen" from the second sample text results in "mobile phone" as the third sample text.
[0050] In practical applications, named entity recognition models can combine semantic context to extract features from each text unit in the input sample text, obtaining a text vector for each text unit. Then, based on the text vector of each text unit, the probability of each text unit belonging to multiple possible tags is determined. Based on the sample text and multiple possible tags, a sequence of multiple possible tags corresponding to the sample text is determined. Based on the probability of each text unit in the sample text belonging to multiple possible tags, the probability of the sample text belonging to each possible tag sequence within the multiple possible tag sequences is determined, thus obtaining the recognition result of the sample text. The multiple possible tags can include at least one entity tag and one non-entity tag. Entity tags can include: person names, place names, organization names, product names, etc. The number of possible tags can be set according to actual needs, for example, 20.
[0051] The specific implementation of the above feature extraction process and the process of determining the probability based on the text vector can be found in existing technologies, and will not be described in detail here.
[0052] In step 102 above, the first difference between the recognition result of the first sample text and the expected recognition result can be calculated using a loss function. The specific form of the loss function can be selected according to actual needs, and this application embodiment does not impose specific limitations on it.
[0053] The second difference between the recognition results of the second sample text and the recognition results of the third sample text reflects the degree of consistency between them. A smaller second difference indicates a higher degree of consistency between the recognition results of the second and third sample texts. The calculation method for the second difference between the recognition results of the second and third sample texts can be designed according to actual needs, and this application embodiment does not specifically limit it.
[0054] The purpose of optimizing the named entity recognition model is to reduce the first and second differences, so that the recognition result of the first sample text gets closer and closer to the expected recognition result of the first sample text, and the recognition result of the second sample text gets closer and closer to the recognition result of the third sample text.
[0055] In practical applications, the first and second differences can be weighted and summed to obtain the total difference; the named entity recognition model can then be optimized based on this total difference. The weights corresponding to the first and second differences can be equal or unequal. The weights of the first and second differences can be set according to actual needs, and this embodiment does not impose specific limitations on this. Specifically, the stochastic gradient descent algorithm can be used to optimize the relevant parameters in the model. The implementation principle of the stochastic gradient descent algorithm can be found in existing technologies and will not be elaborated here.
[0056] The technical solution provided in this application uses two semantically similar sample texts to train the model, and optimizes the model based on the differences in the recognition results of these two sample texts. In this way, only some sample texts need to be labeled with entity category tags to define their expected recognition results; other sample texts only need to be labeled with pairwise semantic similarity, without the need for entity category tagging, effectively reducing labeling costs. The technical solution provided in this application can utilize training data from weakly supervised signals to train the entity recognition model, effectively reducing training costs.
[0057] In one feasible scheme, the recognition result of the second sample text may include: multiple first possible label sequences corresponding to the second sample text and the probability that the second sample text belongs to each first possible label sequence; the recognition result of the third sample text includes: multiple second possible label sequences corresponding to the third sample text and the probability that the third sample text belongs to each second possible label sequence. The above method may further include:
[0058] 103. Based on the recognition results of the second sample text and the recognition results of the third sample text, determine possible label sequence pairs.
[0059] 104. Determine the degree of consistency of the possible label sequence pairs based on the first possible label sequence and the second possible label sequence in the possible label sequence pairs.
[0060] 105. Based on the degree of consistency of the possible label sequence pairs, determine the second difference between the recognition result of the second sample text and the recognition result of the third sample text.
[0061] In the above 103, the number of possible label sequence pairs can be one or more.
[0062] When there is only one possible label sequence pair:
[0063] In section 103 above, "based on the recognition results of the second sample text and the recognition results of the third sample text, determine possible label sequence pairs," this can be achieved in the following way:
[0064] 1031a. Based on the probability that the second sample text belongs to each of the first possible label sequences, determine the target first possible label sequence to which the second sample text belongs from the plurality of first possible label sequences.
[0065] 1032a. Based on the probability that the third sample text belongs to each of the second possible label sequences, determine the target second possible label sequence to which the third sample text belongs from the plurality of second possible label sequences.
[0066] 1033a. The first possible label sequence of the target and the second possible label sequence of the target are combined to form the possible label sequence pair.
[0067] In the above 1031a, the first possible label sequence with the highest probability can be used as the first possible label sequence of the target.
[0068] In the above 1032a, the second possible label sequence with the highest probability can be used as the target second possible label sequence.
[0069] In other words, in this embodiment, the second difference between the recognition results of the second sample text and the recognition results of the third sample text is determined only based on the degree of consistency of the most probable set of possible label sequence pairs, which is simple to calculate.
[0070] When there are multiple possible label sequence pairs:
[0071] In a specific example, the phrase "determine possible label sequence pairs based on the recognition results of the second sample text and the recognition results of the third sample text" in step 103 above can be implemented in the following way:
[0072] 1031b. Combine multiple first possible label sequences and multiple second possible label sequences to obtain multiple possible label sequence pairs.
[0073] Each possible label sequence pair includes a first possible label sequence and a second possible label sequence. Specifically, the multiple possible label sequence pairs include multiple first possible label sequences and multiple second possible label sequences, each forming a possible label sequence pair.
[0074] For example: if there are M possible first label sequences and N possible second label sequences, then the number of possible label sequence pairs is M*N.
[0075] In other words, in this embodiment of the application, all possible tag sequence pairs are considered when calculating the second difference, making the calculation more comprehensive.
[0076] In another specific example, the phrase "determine possible label sequence pairs based on the recognition results of the second sample text and the recognition results of the third sample text" in step 103 above can be implemented in the following way:
[0077] 1031c. Based on the probability that the second sample text belongs to each of the first possible label sequences, select multiple target first possible label sequences from the multiple first possible label sequences.
[0078] The probability that the second sample text belongs to any of the multiple target first possible label sequences is greater than the probability that the second sample text belongs to the unselected first possible label sequence among the multiple first possible label sequences.
[0079] Specifically, based on the probability that the second sample text belongs to each of the first possible label sequences, the multiple first possible label sequences can be sorted in descending order, and the top m first possible label sequences can be used as multiple target first possible label sequences.
[0080] 1032c. Based on the probability that the third sample text belongs to each of the second possible label sequences, select multiple target second possible label sequences from the multiple second possible label sequences.
[0081] Among them, the probability that the third sample text belongs to any one of the multiple target second possible label sequences is greater than the probability that the third sample text belongs to the unselected second possible label sequence among the multiple second possible label sequences.
[0082] Specifically, based on the probability that the third sample text belongs to each second possible label sequence, the multiple second possible label sequences can be sorted in descending order, and the top n second possible label sequences can be used as multiple target second possible label sequences.
[0083] 1033c. Combine multiple first possible label sequences of targets and multiple second possible label sequences of targets to obtain multiple possible label sequence pairs.
[0084] Each possible label sequence pair includes a first possible label sequence and a second possible label sequence. Specifically, the multiple possible label sequence pairs include multiple target first possible label sequences, each target first possible label sequence, and multiple target second possible label sequences, each target second possible label sequence.
[0085] For example: if there are m possible first label sequences for multiple targets and n possible second label sequences for multiple targets, then the number of possible label sequence pairs is m*n.
[0086] In other words, in the embodiments of this application, only some possible tag sequence pairs with higher probability are considered when calculating the second difference.
[0087] When there are multiple possible label sequence pairs, the aforementioned step 105, "determining the second difference between the recognition result of the second sample text and the recognition result of the third sample text based on the consistency degree corresponding to the possible label sequence pairs," can be implemented using the following steps:
[0088] 1051. Determine the probability corresponding to the first possible label sequence pair based on the product of the probability that the second sample text belongs to the first possible label sequence pair and the probability that the third sample text belongs to the second possible label sequence pair.
[0089] 1052. Determine the second difference based on the probability corresponding to each of the multiple possible label sequence pairs and the degree of consistency of each of the multiple possible label sequence pairs.
[0090] In the above 1051, the plurality of possible label sequence pairs includes the first possible label sequence pair. The first possible label sequence pair refers to any one of the plurality of possible label sequence pairs.
[0091] Specifically, the product of the probability that the second sample text belongs to the first possible label sequence in the first possible label sequence pair and the probability that the third sample text belongs to the second possible label sequence in the first possible label sequence pair can be used as the probability corresponding to the first possible label sequence pair. The probability corresponding to the first possible label sequence pair is used to represent the possibility that the second sample text belongs to the first possible label sequence in the first possible label sequence pair and the third sample text belongs to the second possible label sequence in the first possible label sequence pair.
[0092] In one example, the step 1052 above, "determining the second difference based on the probabilities corresponding to each of the plurality of possible label sequence pairs and the degree of consistency of each of the plurality of possible label sequence pairs," can be achieved by the following steps:
[0093] S11. Based on the probabilities corresponding to each of the multiple possible label sequence pairs and the degree of consistency of each of the multiple possible label sequence pairs, determine the expected value of the degree of consistency of each of the multiple possible label sequence pairs under the probability distribution corresponding to the multiple possible label sequence pairs.
[0094] S12. Determine the second difference based on the expected value.
[0095] The larger the expected value, the smaller the second difference.
[0096] Specifically, the expected value E can be calculated using the following formula 1. y,y′~p(y,y′|x,x′) R(y, y′):
[0097] E y,y′~p(y,y′|x,x′) R(y, y′)=∑ y,y′ p(y,y′|x,x′)R(y,y′) (1)
[0098] Where y and y′ can be considered as a pair of possible label sequences, where y is the first possible label sequence and y′ is the second possible label sequence; x and x′ are pairs of similar sample texts, where x is the second sample text and x′ is the third sample text; p(y, y′|x, x′) is the probability corresponding to the possible label sequence pair, and p(y, y′|x, x′) can be decomposed into p(y|x)*p(y′|x′), where p(y|x) is the probability that the second sample text x belongs to y, and p(y′|x′) is the probability that the third sample text x′ belongs to y′; R() can be understood as a reward function, used to calculate the degree of consistency between the first possible label sequence y and the second possible label sequence y′. Where E y,y′~p(y,y′|x,x′) R(y, y′) is the expected value of the consistency degree of the multiple possible label sequence pairs under the probability distribution corresponding to the multiple possible label sequence pairs.
[0099] According to Formula 1, the above expected value is equal to the sum of the products of the probability and the degree of consistency of each possible label sequence pair among the multiple possible label sequence pairs.
[0100] In one feasible solution, the phrase "determining the consistency degree of the possible label sequence pair based on the first possible label sequence and the second possible label sequence in the possible label sequence pair" in step 104 above includes:
[0101] 1041a. Determine the first entity label set corresponding to the first possible label sequence and the second entity label set corresponding to the second possible label sequence in the first possible label sequence pair.
[0102] 1042a. Determine the consistency degree of the first possible tag sequence pair based on the overlap between the first entity tag set and the second entity tag set.
[0103] In the above 1041a, non-entity labels in the first possible label sequence of the first possible label sequence pair can be deleted, and the remaining entity labels can be used to form the first entity label set.
[0104] Non-entity labels in the second possible label sequence of the first possible label sequence pair can be deleted, and the remaining entity labels can be used to form the second entity label set.
[0105] For example: if the first possible tag sequence is "B-pro OO B-per", where B-pro is the product name tag, O is the non-entity tag, and B-per is the person name tag, then the first entity tag set includes B-pro and B-per.
[0106] Specifically, in 1042a above, the consistency level of the first possible tag sequence pair can be determined based on the degree of overlap between the first entity tag set and the second entity tag set. The degree of overlap can be used as the consistency level. The greater the overlap, the greater the consistency level.
[0107] For example: the first entity tag set contains Q entity tags, and the second entity tag set contains P entity tags, where Q is greater than or equal to P. If there are T entity tags in the first entity tag set that match T entity tags in the second entity tag set one-to-one, then the degree of overlap is T / Q.
[0108] Of course, in practical applications, the degree of consistency can also be determined based on whether the two sets overlap. For example, if the two sets overlap, the degree of consistency is set to the first preset value; if the two sets do not overlap, the degree of consistency is set to the second preset value. The first preset value is greater than the second preset value.
[0109] In another feasible implementation, the phrase "determining the degree of consistency of the possible label sequence pairs based on the first and second possible label sequences in the possible label sequence pairs" in step 104 above includes:
[0110] 1041b. Determine the reward function.
[0111] 1042b. Input the first possible label sequence and the second possible label sequence in the first possible label sequence pair into the reward function to obtain the consistency degree corresponding to the first possible label sequence pair.
[0112] The reward function is used to: determine the first entity label set corresponding to the first possible label sequence and the second entity label set corresponding to the second possible label sequence in the first possible label sequence pair; and determine the consistency degree corresponding to the first possible label sequence pair based on the overlap between the first entity label set and the second entity label set.
[0113] The specific implementation of the reward function can be found in the corresponding content of the above embodiments, and will not be repeated here.
[0114] In the above embodiments, the similarity between the first sample text and the second sample text is not considered. Logically, the higher the similarity between the first sample text and the second sample text, the greater the reliability of the second difference; conversely, the lower the similarity between the first sample text and the second sample text, the lower the reliability of the second difference. Therefore, the step 102 above, "optimizing the named entity recognition model based on the first difference between the recognition result of the first sample text and its expected recognition result, and the second difference between the recognition result of the second sample text and the recognition result of the third sample text," can be implemented using the following steps:
[0115] 1021. Obtain the similarity between the second sample text and the second sample text.
[0116] 1022. Based on the similarity and the second difference, determine the updated second difference.
[0117] The named entity recognition model is optimized based on the first difference and the updated second difference.
[0118] The product of the similarity and the second difference can be used as the updated second difference.
[0119] The aforementioned similarity level can be set by the user based on experience, or it can be calculated by the calculation model mentioned in the above embodiments. This application does not specifically limit this aspect.
[0120] Figure 2This illustration shows a flowchart of a named entity recognition method provided in an embodiment of this application. The execution entity of this method can be a client or a server. The client can be hardware with embedded programs integrated on a terminal, application software installed on the terminal, or utility software embedded in the terminal's operating system, etc., and this embodiment does not limit its scope. The terminal can be any terminal device, including mobile phones, tablets, and in-vehicle terminal devices. The server can be a conventional server, a cloud server, or a virtual server, etc., and this embodiment does not specifically limit its scope. Figure 2 As shown, the method includes:
[0121] 201. Obtain the text to be recognized;
[0122] 202. Input the text to be recognized into the trained named entity recognition model to obtain the recognition result of the text to be recognized.
[0123] The training process of the named entity recognition model can be found in the corresponding content of the above embodiments, and will not be repeated here.
[0124] The text to be recognized can be the query text entered by the user, or it can be the speech text obtained by speech recognition of the user's input.
[0125] The processing procedure of the named entity recognition model for the text to be recognized is the same as that for the sample text mentioned above. For details, please refer to the corresponding content in the above embodiments, which will not be described in detail here.
[0126] Figure 3 A flowchart illustrating a search method provided in an embodiment of this application is shown. The execution entity of this method can be a client or a server. The client can be hardware with embedded programs integrated on a terminal, application software installed on the terminal, or utility software embedded in the terminal's operating system, etc., and this embodiment does not limit its scope. The terminal can be any terminal device, including mobile phones, tablets, and in-vehicle terminal devices. The server can be a conventional server, a cloud server, or a virtual server, etc., and this embodiment does not specifically limit its scope. Figure 3 As shown, the method includes:
[0127] 301. Obtain the query text entered by the user;
[0128] 302. Input the query text into the trained named entity recognition model to obtain the tag sequence corresponding to the query text;
[0129] 303. Determine the query result based on the tag sequence and the query text.
[0130] The training process of the named entity recognition model includes:
[0131] The first sample text, the second sample text, and the third sample text are input into the named entity recognition model to obtain the recognition results for each of the three sample texts; the second sample text and the third sample text are semantically similar.
[0132] The named entity recognition model is optimized based on the first difference between the recognition result of the first sample text and its expected recognition result, and the second difference between the recognition result of the second sample text and the recognition result of the third sample text.
[0133] The first sample text, second sample text, and third sample text mentioned above can all be sample query texts. For the specific training process, please refer to the corresponding content in the above embodiments, which will not be repeated here.
[0134] In the aforementioned 303 error, taking e-commerce as an example, the product name can be determined from the query text based on the tag sequence; the product category can be determined based on the product name; all product information under that product category can be obtained; other entities can be determined from the query text based on the tag sequence; and the query results can be determined based on the matching results of other entities in all product information under that product category. The query results can then be provided to the user.
[0135] In international e-commerce search scenarios, a common challenge is understanding short query texts, and labeled data requires complex manual annotation to construct high-quality labeled data. Named Entity Recognition (NER) can significantly improve various downstream tasks in search scenarios, including category prediction, query rewriting, and relevance modeling. Query rewriting involves transforming a query into a semantically similar query. This solution leverages massive amounts of weakly supervised signals to enhance the structured understanding of query text. This proposal suggests a technical approach to improve Query NER performance by utilizing rewritten query text data. This method is effectively applicable to named entity recognition tasks on various e-commerce platforms. System experiments have shown that this method improves recognition accuracy.
[0136] Our solution's main idea is to leverage massive amounts of weakly supervised data to improve the structured recognition capability of e-commerce queries. One potential weakly supervised signal is semantically similar query pairs. Here, semantically similar query pairs refer to two queries with identical meanings. This solution can effectively utilize abundant rewritten data for structured query analysis; this solution is applicable to any e-commerce platform.
[0137] Figure 4 A schematic diagram of the structure of an electronic device according to an embodiment of this application is shown. Figure 4 As shown, the electronic device includes a memory 1101 and a processor 1102. The memory 1101 can be configured to store various other data to support operation on the electronic device. Examples of such data include instructions for any application or method used to operate on the electronic device. The memory 1101 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0138] The memory 1101 is used to store programs;
[0139] The processor 1102 is coupled to the memory 1101 and is used to execute the program stored in the memory 1101 to implement the named entity recognition method, model training method or search method provided in the above method embodiments.
[0140] Furthermore, such as Figure 4 As shown, the electronic device also includes other components such as a communication component 1103, a display 1104, a power supply component 1105, and an audio component 1106. Figure 4 The diagram only shows some components and does not mean that the electronic device includes only these components. Figure 4 The components shown.
[0141] Accordingly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a computer, can implement the steps or functions of the named entity recognition method, model training method, or search method provided in the above-described method embodiments.
[0142] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0143] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0144] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application 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 this application.
Claims
1. A named entity recognition method, wherein, include: Obtain the text to be recognized; The text to be recognized is input into a trained named entity recognition model to obtain the recognition result of the text to be recognized; wherein, the training process of the named entity recognition model includes: The first sample text, the second sample text, and the third sample text are input into the named entity recognition model to obtain the recognition results for each of the three sample texts; the second sample text and the third sample text are semantically similar. The named entity recognition model is optimized based on a first difference between the recognition result of the first sample text and its expected recognition result, and a second difference between the recognition result of the second sample text and the recognition result of the third sample text. The optimization includes: determining an updated second difference based on the similarity between the second sample text and the third sample text and the second difference; and optimizing the named entity recognition model based on the first difference and the updated second difference.
2. The method according to claim 1, wherein, The recognition result of the second sample text includes: multiple first possible label sequences corresponding to the second sample text and the probability that the second sample text belongs to each first possible label sequence; the recognition result of the third sample text includes: multiple second possible label sequences corresponding to the third sample text and the probability that the third sample text belongs to each second possible label sequence; the method further includes: Based on the recognition results of the second sample text and the recognition results of the third sample text, possible label sequence pairs are determined; Based on the first and second possible label sequences in the possible label sequence pairs, determine the degree of consistency of the possible label sequence pairs; Based on the degree of consistency between the possible label sequence pairs, a second difference is determined between the recognition result of the second sample text and the recognition result of the third sample text.
3. The method according to claim 2, wherein, There are multiple possible label sequence pairs; Based on the consistency level corresponding to the possible label sequence pairs, a second difference is determined between the recognition results of the second sample text and the recognition results of the third sample text, including: The probability corresponding to the first possible label sequence pair is determined by multiplying the probability that the second sample text belongs to the first possible label sequence pair in the first possible label sequence pair with the probability that the third sample text belongs to the second possible label sequence pair in the first possible label sequence pair; the first possible label sequence pair is included among the multiple possible label sequence pairs. The second difference is determined based on the probability corresponding to each of the multiple possible label sequence pairs and the degree of consistency of each of the multiple possible label sequence pairs.
4. The method according to claim 3, wherein, The second difference is determined based on the probabilities corresponding to each of the multiple possible label sequence pairs and the degree of consistency among the multiple possible label sequence pairs, including: Based on the probability corresponding to each of the multiple possible label sequence pairs and the degree of consistency of the multiple possible label sequence pairs, determine the expected value of the degree of consistency of the multiple possible label sequence pairs under the probability distribution corresponding to the multiple possible label sequence pairs; The second difference is determined based on the expected value; The larger the expected value, the smaller the second difference.
5. The method according to claim 2, wherein, Based on the recognition results of the second sample text and the third sample text, possible tag sequence pairs are determined, including: Based on the probability that the second sample text belongs to each of the first possible label sequences, the target first possible label sequence to which the second sample text belongs is determined from the plurality of first possible label sequences; Based on the probability that the third sample text belongs to each of the second possible label sequences, the target second possible label sequence to which the third sample text belongs is determined from the plurality of second possible label sequences; The first possible label sequence of the target and the second possible label sequence of the target are combined to form the possible label sequence pair.
6. The method according to any one of claims 2 to 5, wherein, Based on the first and second possible label sequences in the possible label sequence pair, determine the degree of consistency corresponding to the possible label sequence pair, including: Determine the first entity label set corresponding to the first possible label sequence and the second entity label set corresponding to the second possible label sequence in the first possible label sequence pair; The degree of consistency of the first possible tag sequence pair is determined based on the overlap between the first entity tag set and the second entity tag set.
7. A model training method, wherein, include: The first sample text, the second sample text, and the third sample text are input into the named entity recognition model to obtain the recognition results for each of the three sample texts; the second sample text and the third sample text are semantically similar. The named entity recognition model is optimized based on a first difference between the recognition result of the first sample text and its expected recognition result, and a second difference between the recognition result of the second sample text and the recognition result of the third sample text. The optimization includes determining an updated second difference based on the similarity between the second sample text and the third sample text and the second difference. The named entity recognition model is optimized based on the first difference and the updated second difference.
8. The method according to claim 7, wherein, The recognition result of the second sample text includes: multiple first possible label sequences corresponding to the second sample text and the probability that the second sample text belongs to each first possible label sequence; the recognition result of the third sample text includes: multiple second possible label sequences corresponding to the third sample text and the probability that the third sample text belongs to each second possible label sequence; the method further includes: Based on the recognition results of the second sample text and the recognition results of the third sample text, possible label sequence pairs are determined; Based on the first and second possible label sequences in the possible label sequence pairs, determine the degree of consistency of the possible label sequence pairs; Based on the degree of consistency between the possible label sequence pairs, a second difference is determined between the recognition result of the second sample text and the recognition result of the third sample text.
9. A search method, wherein, include: Get the query text entered by the user; The query text is input into a trained named entity recognition model to obtain a tag sequence corresponding to the query text; The query results are determined based on the tag sequence and the query text; The training process of the named entity recognition model includes: The first sample text, the second sample text, and the third sample text are input into the named entity recognition model to obtain the recognition results for each of the three sample texts; the second sample text and the third sample text are semantically similar. The named entity recognition model is optimized based on a first difference between the recognition result of the first sample text and its expected recognition result, and a second difference between the recognition result of the second sample text and the recognition result of the third sample text. The optimization includes: determining an updated second difference based on the similarity between the second sample text and the third sample text and the second difference; and optimizing the named entity recognition model based on the first difference and the updated second difference.
10. An electronic device, wherein, include: Memory and processor, among which, The memory is used to store programs; The processor, coupled to the memory, is configured to execute the program stored in the memory to implement the method of any one of claims 1 to 9.
11. A computer-readable storage medium storing a computer program, wherein, When the computer program is executed by a computer, it can implement the method of any one of claims 1 to 9.
Citation Information
Patent Citations
Semi-supervised three-dimensional shape recognition method based on consistency training
CN113408650A