CN113779202B - Named entity recognition method and device, computer equipment and storage medium - Google Patents

Named entity recognition method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN113779202B
CN113779202B CN202111350041.XA CN202111350041A CN113779202B CN 113779202 B CN113779202 B CN 113779202B CN 202111350041 A CN202111350041 A CN 202111350041A CN 113779202 B CN113779202 B CN 113779202B
Authority
CN
China
Prior art keywords
word
recognized
entity
named entity
vector
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111350041.XA
Other languages
Chinese (zh)
Other versions
CN113779202A (en
Inventor
费昊
周博通
郑孙聪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202111350041.XA priority Critical patent/CN113779202B/en
Publication of CN113779202A publication Critical patent/CN113779202A/en
Application granted granted Critical
Publication of CN113779202B publication Critical patent/CN113779202B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/36Creation of semantic tools, e.g. ontology or thesauri
    • G06F16/367Ontology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • G06F40/295Named entity recognition
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning

Abstract

The application relates to a named entity identification method, a named entity identification device, computer equipment and a storage medium. The method comprises the following steps: vectorizing each word to be identified in the text to be identified to obtain each word vector to be identified; carrying out recognition vector transformation on each word vector to be recognized to obtain a first vector and a second vector corresponding to each word to be recognized; enumerating based on the text to be recognized to determine each word to be recognized, determining a first vector corresponding to a starting character in each word to be recognized from each first vector, and determining a second vector corresponding to a terminating character in each word to be recognized from each second vector; and respectively carrying out named entity type recognition on each word to be recognized based on a first vector corresponding to the initial character in each word to be recognized and a second vector corresponding to the terminal character in each word to be recognized to obtain a named entity recognition result corresponding to each word to be recognized. By adopting the method, the accuracy of named entity identification can be improved, and the method can also be applied to vehicle-mounted scenes.

Description

Named entity recognition method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of internet technologies, and in particular, to a named entity identification method, apparatus, computer device, storage medium, and computer program product.
Background
With the development of natural language processing technology, Named Entity Recognition (NER), also called "proper name Recognition", is developed, which refers to recognizing entities with specific meaning in text, mainly including names of people, places, organizations, proper nouns, etc. Named entity identification is an important basic tool in application fields such as information extraction, question and answer systems, syntactic analysis, machine translation, Semantic Web-oriented metadata labeling and the like, and plays an important role in the process of bringing natural language processing technology into practical use. At present, when command entity identification is carried out, identification errors are often easily caused when entity types which are mutually nested are identified, for example, the subsidiary hospital of Beijing university only is often identified as the hospital entity type, but the subsidiary hospital of Beijing university is not identified as the school entity type, so that the accuracy of named entity identification is reduced.
Disclosure of Invention
In view of the above, there is a need to provide a named entity identifying method, apparatus, computer device and storage medium capable of improving accuracy of named entity identification.
A named entity identification method, the method comprising:
acquiring a text to be recognized, and dividing the text to be recognized into words to obtain each word to be recognized;
vectorizing each word to be identified to obtain each word vector to be identified;
performing identification vector transformation on each word vector to be identified to obtain a first vector corresponding to each word to be identified and a second vector corresponding to each word to be identified, wherein the first vector is used for representing a semantic vector corresponding to the word to be identified in a text obtained by taking the word to be identified as a starting word in the text to be identified, and the second vector is used for representing the semantic vector corresponding to the word to be identified in the text obtained by taking the word to be identified as a terminating word in the text to be identified;
enumerating based on the text to be recognized to determine each word to be recognized, determining a first vector corresponding to a starting word in each word to be recognized from a first vector corresponding to each word to be recognized, and determining a second vector corresponding to a terminating word in each word to be recognized from a second vector corresponding to each word to be recognized;
and respectively carrying out named entity type recognition on each word to be recognized based on a first vector corresponding to the initial character in each word to be recognized and a second vector corresponding to the terminal character in each word to be recognized to obtain a named entity recognition result corresponding to each word to be recognized.
A named entity recognition apparatus, the apparatus comprising:
the acquisition module is used for acquiring the text to be recognized and dividing the text to be recognized into words to obtain each word to be recognized;
the vectorization module is used for vectorizing each word to be identified to obtain each word vector to be identified;
the conversion module is used for performing identification vector conversion on each word vector to be identified to obtain a first vector corresponding to each word to be identified and a second vector corresponding to each word to be identified, wherein the first vector is used for representing a semantic vector corresponding to the word to be identified in a text obtained by taking the word to be identified as a starting word in the text to be identified, and the second vector is used for representing a semantic vector corresponding to the word to be identified in the text obtained by taking the word to be identified as a terminating word in the text to be identified;
the vector determining module is used for enumerating and determining each word to be recognized based on the text to be recognized, determining a first vector corresponding to a starting character in each word to be recognized from a first vector corresponding to each word to be recognized, and determining a second vector corresponding to a terminating character in each word to be recognized from a second vector corresponding to each word to be recognized;
and the recognition module is used for respectively carrying out named entity type recognition on each word to be recognized based on a first vector corresponding to the initial character in each word to be recognized and a second vector corresponding to the terminal character in each word to be recognized to obtain a named entity recognition result corresponding to each word to be recognized.
A computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
acquiring a text to be recognized, and dividing the text to be recognized into words to obtain each word to be recognized;
vectorizing each word to be identified to obtain each word vector to be identified;
performing identification vector transformation on each word vector to be identified to obtain a first vector corresponding to each word to be identified and a second vector corresponding to each word to be identified, wherein the first vector is used for representing a semantic vector corresponding to the word to be identified in a text obtained by taking the word to be identified as a starting word in the text to be identified, and the second vector is used for representing the semantic vector corresponding to the word to be identified in the text obtained by taking the word to be identified as a terminating word in the text to be identified;
enumerating based on the text to be recognized to determine each word to be recognized, determining a first vector corresponding to a starting word in each word to be recognized from a first vector corresponding to each word to be recognized, and determining a second vector corresponding to a terminating word in each word to be recognized from a second vector corresponding to each word to be recognized;
and respectively carrying out named entity type recognition on each word to be recognized based on a first vector corresponding to the initial character in each word to be recognized and a second vector corresponding to the terminal character in each word to be recognized to obtain a named entity recognition result corresponding to each word to be recognized.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
acquiring a text to be recognized, and dividing the text to be recognized into words to obtain each word to be recognized;
vectorizing each word to be identified to obtain each word vector to be identified;
performing identification vector transformation on each word vector to be identified to obtain a first vector corresponding to each word to be identified and a second vector corresponding to each word to be identified, wherein the first vector is used for representing a semantic vector corresponding to the word to be identified in a text obtained by taking the word to be identified as a starting word in the text to be identified, and the second vector is used for representing the semantic vector corresponding to the word to be identified in the text obtained by taking the word to be identified as a terminating word in the text to be identified;
enumerating based on the text to be recognized to determine each word to be recognized, determining a first vector corresponding to a starting word in each word to be recognized from a first vector corresponding to each word to be recognized, and determining a second vector corresponding to a terminating word in each word to be recognized from a second vector corresponding to each word to be recognized;
and respectively carrying out named entity type recognition on each word to be recognized based on a first vector corresponding to the initial character in each word to be recognized and a second vector corresponding to the terminal character in each word to be recognized to obtain a named entity recognition result corresponding to each word to be recognized.
The named entity recognition method, the device, the computer equipment and the storage medium obtain each vector of the words to be recognized in the text to be recognized, convert the vector of the words to be recognized to obtain the first vector corresponding to each word to be recognized and the second vector corresponding to each word to be recognized, then perform enumeration based on the text to be recognized to determine each word to be recognized, determine the first vector corresponding to the initial word in each word to be recognized from the first vector corresponding to each word to be recognized, determine the second vector corresponding to the terminal word in each word to be recognized from the second vector corresponding to each word to be recognized, finally perform named entity type recognition on each word to be recognized by using the first vector corresponding to the initial word in each word to be recognized and the second vector corresponding to the terminal word in each word to be recognized to obtain the named entity recognition result corresponding to each word to be recognized, the method and the device can obtain the recognition results of the named entities corresponding to all enumerated words to be recognized in the text to be recognized, prevent the entities nested with each other from being unrecognized, and respectively recognize the types of the named entities of the words to be recognized by using the first vector corresponding to the initial word in each word to be recognized and the second vector corresponding to the final word in each word to be recognized, so that the obtained recognition results of the named entities are more accurate, and the recognition accuracy of the named entities is improved.
Drawings
FIG. 1 is a diagram of an application environment for a named entity recognition methodology in one embodiment;
FIG. 2 is a flow diagram that illustrates a method for named entity recognition in one embodiment;
FIG. 3 is a flowchart illustrating obtaining a target entity recognition result in one embodiment;
FIG. 4 is a flow diagram illustrating entity linking in one embodiment;
FIG. 5 is a schematic diagram illustrating a process for obtaining a target entity recognition result according to another embodiment;
FIG. 6 is a flowchart illustrating obtaining a named entity recognition result in one embodiment;
FIG. 7 is a flowchart illustrating the process of obtaining a named entity recognition result in another embodiment;
FIG. 8 is a flowchart illustrating a process for obtaining a result of identifying a named entity in yet another embodiment;
FIG. 9 is a flowchart illustrating a process for obtaining a result of identifying a named entity in yet another embodiment;
FIG. 10 is a schematic flow diagram illustrating training of a named entity type single-task recognition model in one embodiment;
FIG. 11 is a schematic flow diagram illustrating the calculation of a named entity recognition result, under an embodiment;
FIG. 12 is a schematic diagram of a process for obtaining a first target vector and a second target vector according to an embodiment;
FIG. 13 is a flowchart illustrating a method for named entity recognition in one embodiment;
FIG. 14 is a block diagram that illustrates a single task recognition model for named entity types in an exemplary embodiment;
FIG. 15 is a diagram illustrating a naming recognition result as a classification matrix in the embodiment of FIG. 14;
FIG. 16 is a block diagram showing the structure of a named entity recognition apparatus according to an embodiment;
FIG. 17 is a diagram showing an internal structure of a computer device in one embodiment;
fig. 18 is an internal structural view of a computer device in still another embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
Natural Language Processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that enable efficient communication between humans and computers using natural language. Natural language processing is a science integrating linguistics, computer science and mathematics. Therefore, the research in this field will involve natural language, i.e. the language that people use everyday, so it is closely related to the research of linguistics. Natural language processing techniques typically include text processing, semantic understanding, machine translation, robotic question and answer, knowledge mapping, and the like.
The scheme provided by the embodiment of the application relates to the technologies of artificial intelligent text processing, robot question answering, knowledge graph, intelligent traffic and the like, and is specifically explained by the following embodiments:
the named entity identification method provided by the application can be applied to the application environment shown in FIG. 1. Wherein the terminal 102 communicates with the server 104 via a network. The server 104 may obtain the text to be recognized from the terminal 102, and perform word segmentation on the text to be recognized to obtain each word to be recognized; the server 104 vectorizes each word to be identified to obtain each word vector to be identified; the server 104 performs identification vector transformation on each word vector to be identified to obtain a first vector corresponding to each word to be identified and a second vector corresponding to each word to be identified, wherein the first vector is used for representing a semantic vector corresponding to a word to be identified in a text obtained by taking the word to be identified as a starting word in the text to be identified, and the second vector is used for representing a semantic vector corresponding to a word to be identified in a text obtained by taking the word to be identified as a terminating word in the text to be identified; the server 104 enumerates and determines each word to be recognized based on the text to be recognized, determines a first vector corresponding to a starting word in each word to be recognized from a first vector corresponding to each word to be recognized, and determines a second vector corresponding to a terminating word in each word to be recognized from a second vector corresponding to each word to be recognized; the server 104 performs named entity type recognition on each to-be-recognized word respectively based on a first vector corresponding to a start character in each to-be-recognized word and a second vector corresponding to an end character in each to-be-recognized word to obtain named entity recognition results corresponding to each to-be-recognized word respectively, and the server 104 may store the named entity recognition results corresponding to each to-be-recognized word in a data storage system or return the named entity recognition results corresponding to each to-be-recognized word to the terminal 102 for display. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, smart voice interaction devices, vehicle-mounted terminals, and portable wearable devices, and the server 104 may be implemented by an independent server or a server cluster formed by a plurality of servers.
In one embodiment, as shown in fig. 2, a named entity identification method is provided, which is described by taking the method as an example applied to the server in fig. 1, and it is understood that the method may also be applied to a terminal, and may also be applied to a system including a terminal and a server, and is implemented through interaction between the terminal and the server. In this embodiment, the method comprises the following steps:
step 202, obtaining a text to be recognized, and dividing the text to be recognized into words to obtain each word to be recognized.
The text to be recognized refers to a text which needs to be subjected to entity recognition, and the text to be recognized can be words, sentences, articles and the like. The text to be recognized may have a plurality of entities or may have entities nested with each other. The text to be recognized may also be text in different languages, for example, it may be chinese text or english text, or japanese text, etc. The text to be recognized may also be text in a different format. The word to be recognized is a word obtained after word segmentation in the text to be recognized.
Specifically, the server may directly obtain the text to be recognized from the database, may also obtain the text to be recognized last time by the terminal, and may also obtain the text to be recognized from a third-party server, where the third-party server may be a service server, a data server, or the like. The server may also collect the text to be recognized from the internet. And then dividing the text to be recognized according to each character to obtain each word to be recognized.
And 204, vectorizing each word to be identified to obtain each word vector to be identified.
The word vector to be identified refers to the semantic meaning of the word to be identified, wherein the vector corresponding to the word to be identified is used for representing the word to be identified.
Specifically, the server uses a vectorization algorithm to vectorize each word to be identified, so as to obtain each word vector to be identified. Wherein the vectorization algorithm may be a neural network algorithm. For example, a trained neural network model may be used to vectorize the words to be recognized.
And step 206, performing identification vector transformation on each vector of the words to be identified to obtain a first vector corresponding to each word to be identified and a second vector corresponding to each word to be identified, wherein the first vector is used for representing the semantic vector corresponding to the word to be identified in the text obtained by taking the word to be identified as the initial word in the text to be identified, and the second vector is used for representing the semantic vector corresponding to the word to be identified in the text obtained by taking the word to be identified as the final word in the text to be identified.
Wherein the identification vector transformation is used for transforming each word vector to be identified into a first vector and a second vector. The first vector is used for representing semantic vectors corresponding to the words to be identified in the text obtained by taking the words to be identified as initial words in the text to be identified, and the second vector is used for representing semantic vectors corresponding to the words to be identified in the text obtained by taking the words to be identified as final words in the text to be identified.
Specifically, the server may perform identification vector transformation on the word vectors to be identified to obtain a first vector corresponding to each word to be identified and a second vector corresponding to each word to be identified. The identification vector transformation can be performed through a logistic regression algorithm to obtain a first vector and a second vector.
And 208, enumerating based on the text to be recognized to determine each word to be recognized, determining a first vector corresponding to a starting word in each word to be recognized from a first vector corresponding to each word to be recognized, and determining a second vector corresponding to a terminating word in each word to be recognized from a second vector corresponding to each word to be recognized.
The word to be recognized refers to a continuous segment to be recognized in the text to be recognized, and may be composed of at least two characters.
Specifically, the server enumerates the text to be recognized to determine all continuous segments in the text to be recognized, and each word to be recognized is obtained. The words to be recognized in the text to be recognized can be traversed, and the continuous segments are sequentially selected to obtain the words to be recognized. And then selecting a first vector corresponding to the initial character in each word to be recognized from the first vectors corresponding to the words to be recognized. And determining a second vector corresponding to the stop word in each word to be recognized from the second vector corresponding to each word to be recognized. The method comprises the steps of matching initial characters in words to be recognized with all the words to be recognized, obtaining first vectors corresponding to the characters which are matched in a consistent mode when the initial characters are matched with all the words to be recognized, then matching terminal characters in the words to be recognized with all the words to be recognized, and obtaining second vectors corresponding to the characters which are matched in a consistent mode when the terminal characters are matched with all the words to be recognized.
And step 210, respectively carrying out named entity type recognition on each word to be recognized based on a first vector corresponding to a starting character in each word to be recognized and a second vector corresponding to a terminating character in each word to be recognized, and obtaining a named entity recognition result corresponding to each word to be recognized.
The named entity type refers to a specific type corresponding to the named entity, such as a name type, a place name type, an organization name type, a proper noun type, and the like, and may be preset according to requirements. The named entity type identifies a named entity for identifying whether a word to be identified is of the named entity type. The named entity recognition result is used for representing whether the word to be recognized is a named entity of the named entity type, for example, whether the word to be recognized is an entity of the name type.
Specifically, the server performs inter-vector operation by using a first vector corresponding to a start word and a second vector corresponding to an end word in each word to be recognized, that is, the probability that each word to be recognized belongs to the named entity type is calculated, so that the probability that each word to be recognized belongs to the named entity type is obtained, and the recognition result of each word to be recognized on the named entity type is determined according to the probability. And then obtaining the named entity recognition result corresponding to each word to be recognized respectively based on the recognition result of each word to be recognized to all the named entity types.
The named entity recognition method comprises the steps of obtaining vectors of words to be recognized in a text to be recognized, converting the vectors of the words to be recognized into recognition vectors, obtaining a first vector corresponding to each word to be recognized and a second vector corresponding to each word to be recognized, then performing enumeration on the text to be recognized to determine each word to be recognized, determining a first vector corresponding to a starting word in each word to be recognized from the first vector corresponding to each word to be recognized, determining a second vector corresponding to a stopping word in each word to be recognized from the second vector corresponding to each word to be recognized, finally performing named entity type recognition on each word to be recognized by using the first vector corresponding to the starting word in each word to be recognized and the second vector corresponding to the stopping word in each word to be recognized, obtaining named entity recognition results corresponding to each word to be recognized, and obtaining the named entity recognition results corresponding to all the words to be recognized in the text to be recognized, entities nested with each other are prevented from being unrecognized, and named entity type recognition is performed on each word to be recognized respectively by using a first vector corresponding to a start word in each word to be recognized and a second vector corresponding to an end word in each word to be recognized, so that the obtained named entity recognition result is more accurate, and the accuracy of named entity recognition is improved.
In an embodiment, as shown in fig. 3, after step 210, after performing named entity type recognition on each to-be-recognized word based on a first vector corresponding to a starting word in each to-be-recognized word and a second vector corresponding to a terminating word in each to-be-recognized word, and obtaining a named entity recognition result corresponding to each to-be-recognized word, the method further includes:
step 302, carrying out entity mention identification based on the text to be identified to obtain each entity mention.
The entity mention refers to a language segment expressing an entity in a text to be recognized, and the language segment is not related to the entity in the knowledge base. The same entity is referred to by different entities.
Specifically, the server performs entity mention identification on the text to be identified to obtain each entity mention. The server can use all names in a preset synonym table to perform character string search on the read text, and uses a character string matching algorithm to quickly identify and obtain the boundaries of all entity words so as to obtain the mention of all entities. The server may also identify individual entity mentions in the text to be identified using a sequence tagging algorithm.
And 304, performing entity recall from a preset knowledge base based on each entity mention to obtain a candidate entity set corresponding to each entity mention.
The candidate entity generation aims to detect entity mention sets from the text to be recognized and find candidate entity sets which can possibly correspond to each entity mention from a given knowledge graph. The preset knowledge base is a preset database for storing entity information. The candidate entities refer to entities in a preset knowledge base which may possibly correspond to the entities.
Specifically, the server recalls each entity mention from a preset knowledge base to obtain a candidate entity set corresponding to each entity mention.
And step 306, performing entity disambiguation on the basis of the candidate entity sets respectively corresponding to the entity mentions to obtain entities respectively corresponding to the entity mentions, and obtaining an entity link identification result corresponding to the text to be identified on the basis of the entities respectively corresponding to the entity mentions.
Wherein the entity disambiguation is used for sorting the candidate entities in the candidate entity set and selecting the most similar candidate entity as the result of the entity mention link
Specifically, the server may calculate the degrees of similarity between the entity mention and the candidate entities in the corresponding candidate entity set, and select the candidate entity with the highest degree of similarity as the entity mention corresponding entity. And carrying out entity disambiguation on each entity mention to obtain an entity corresponding to each entity mention, and then obtaining the named entity type of the entity corresponding to each entity mention from a preset knowledge base to obtain an entity link identification result corresponding to the text to be identified.
And 308, obtaining a target entity recognition result corresponding to the text to be recognized based on the entity link recognition result and the named entity recognition result.
And the target entity recognition result refers to a named entity in the text to be recognized, which is finally obtained by recognition.
Specifically, the server fuses the entity link recognition result and the named entity recognition result to obtain a target entity recognition result corresponding to the text to be recognized.
In a specific embodiment, as shown in fig. 4, in order to obtain a flow diagram of an entity link identification result, a server performs entity mention identification on a text to be identified, for example, who is the master of the "2017 edition hero transmission," to obtain an entity mention of "hero transmission of the shooting carving corresponding to the position 5," to recall a candidate entity, "to obtain various candidate entities such as" hero transmission of the shooting carving (novel), hero transmission of the shooting carving (2003 edition tv drama), hero transmission of the shooting carving (2008 edition tv drama), hero transmission of the shooting carving (2017 edition tv drama) "and the like, to perform entity disambiguation, to select a candidate entity" hero transmission of the shooting carving (2017 edition tv drama) "corresponding to the highest similarity (0.93), to obtain a named entity" hero transmission of the shooting carving (2017 edition tv drama) ".
In the embodiment, the candidate entity recall is performed through the identification entity mention, then the entity disambiguation is performed, so that the entity link identification result is obtained, and then the target entity identification result corresponding to the text to be identified is obtained according to the entity link identification result and the named entity identification result, so that the obtained target entity identification result is more accurate.
In one embodiment, the named entity recognition result comprises a named entity primary type and a named entity secondary type, and the entity link recognition result comprises an entity link primary type and an entity link secondary type;
as shown in fig. 5, in step 308, obtaining a target entity recognition result corresponding to the text to be recognized based on the entity link recognition result and the named entity recognition result includes:
step 502, obtaining a named entity recognition result of a target to-be-recognized word in each to-be-recognized word and an entity link recognition result of a target entity in each entity mention respectively corresponding to the target to-be-recognized word, wherein the target to-be-recognized word and the target entity are the same entity.
The named entity primary type refers to a specific type corresponding to a preset entity, and the named entity secondary type refers to a specific type associated with the preset named entity primary type, for example, the named entity primary type may be a character type, and the named entity secondary type may be a movie star type, a singer type, or the like. The first-level named entity type and the second-level named entity type related to the first-level named entity type are preset. Namely, the server obtains a preset fine-grained named entity type system which comprises a named entity primary type and a named entity secondary type. The entity link primary type refers to a named entity primary type corresponding to the entity obtained through entity link identification, and the entity link secondary type refers to a named entity secondary type associated with the entity link primary type. The entity link primary type and the entity link secondary type may also be set in advance in a knowledge base, and when an entity is obtained through entity link identification, the entity link primary type and the entity link secondary type corresponding to the entity can be directly obtained from the knowledge base. The target to-be-recognized word refers to a to-be-recognized word for determining a final named entity recognition result. The target to-be-recognized word and the target entity are the same entity.
Specifically, the server obtains a named entity recognition result of the target word to be recognized from the named entity recognition result, and obtains an entity link recognition result of the target entity from the entity link recognition result.
And 504, matching the primary type of the named entity in the named entity recognition result of the target word to be recognized with the primary type of the entity link in the entity link recognition result of the target word, and taking the primary type of the entity link and the secondary type of the entity link as the target entity recognition result corresponding to the target word to be recognized when the primary type of the named entity is the same as the primary type of the entity link.
Specifically, the primary type of the named entity corresponding to the target word to be recognized is matched with the primary type of the entity link corresponding to the target entity, and when the primary type of the named entity is matched with the primary type of the entity link, the primary type of the entity link and the secondary type of the entity link are used as the target entity recognition result corresponding to the target word to be recognized. For example, the named entity type of "first subsidiary hospital of Beijing university" is the organization name type, the entity link type is also the organization name type, and the matching is the same, so that the named entity type of "first subsidiary hospital of Beijing university" is the organization name-hospital type.
Step 506, when the matching of the primary type of the named entity and the primary type of the entity link is not the same, the primary type of the named entity and the recognition result of the named secondary type are used as the recognition result of the target entity corresponding to the target word to be recognized.
The target entity recognition result refers to a named entity recognition result corresponding to the target word to be recognized.
Specifically, the server judges that the matching of the primary type of the named entity and the primary type of the entity link is not the same, and then the primary type of the named entity and the secondary type of the named entity are used as a target entity recognition result corresponding to the target word to be recognized.
In the above embodiment, the target entity recognition result is obtained by comparing the named entity recognition result with the entity link recognition result. Therefore, the prior knowledge can be considered, and the accuracy of the obtained target entity identification result is improved.
In one embodiment, in step 206, performing identification vector transformation on each word vector to be identified to obtain a first vector corresponding to each word to be identified and a second vector corresponding to each word to be identified, including:
and acquiring trained identification vector transformation parameters, and performing identification vector transformation on each word vector to be identified by using the identification vector transformation parameters to obtain a first vector corresponding to each word to be identified and a second vector corresponding to each word to be identified.
The identification vector transformation parameters are used for transformation of identification vectors and are obtained by training in advance by using a machine learning algorithm.
Specifically, the server may train to obtain the identification vector transformation parameters by using a machine learning algorithm according to the labeled training data, and then store the trained identification vector transformation parameters. When the method needs to be used, the server obtains trained identification vector transformation parameters, and carries out identification vector transformation on each word vector to be identified by using the identification vector transformation parameters to obtain a first vector corresponding to each word to be identified and a second vector corresponding to each word to be identified. In a specific embodiment, the first vector and the second vector corresponding to the word to be recognized may be calculated by using formula (1) shown below.
Figure 471340DEST_PATH_IMAGE002
Formula (1)
Wherein W and b are trained identification vector transformation parameters,
Figure DEST_PATH_IMAGE003_17A
is shown as
Figure DEST_PATH_IMAGE003_18A
A named entity type. i represents the number of the ith to be assigned,
Figure 44273DEST_PATH_IMAGE005
a first vector is represented by a first vector,
Figure 824010DEST_PATH_IMAGE007
representing a second vector.
Figure 750378DEST_PATH_IMAGE009
Representing the ith word vector to be identified. By obtaining the vector code [ h1, h2, … hn ] of each word to be identified]By transformation, can obtain
Figure 95909DEST_PATH_IMAGE011
And
Figure 449530DEST_PATH_IMAGE013
that is, a first vector sequence and a second vector sequence are obtained, and the first vector sequence and the second vector sequence are used for identifying the second vector sequence
Figure DEST_PATH_IMAGE003_19A
A named entity type.
In one embodiment, as shown in fig. 6, the method further comprises:
step 602, inputting the text to be recognized into a named entity type multitask recognition model.
The named entity type multi-task recognition model is used for multi-task recognition of the named entity type and is obtained by performing multi-task learning training in advance through a machine learning algorithm, wherein the machine learning algorithm can be a neural network algorithm, a logistic regression algorithm and the like. Multitask learning refers to simultaneous parallel learning involving multiple related tasks, i.e., identifying different named entity types.
Specifically, the server obtains a named entity type multi-task recognition model through multi-task learning training in advance, and then deploys and uses the model. When the system is used, the server directly inputs the text to be recognized into the named entity type multi-task recognition model for multi-task processing.
Step 604, the named entity type multitask recognition model divides the text to be recognized into words to obtain words to be recognized, vectorizes the words to be recognized to obtain word vectors to be recognized, and performs recognition vector transformation on the word vectors to be recognized to obtain first vectors corresponding to the words to be recognized and second vectors corresponding to the words to be recognized.
Specifically, the named entity type multitask recognition model divides a text to be recognized into words to obtain words to be recognized, vectorizes the words to be recognized to obtain word vectors to be recognized, and performs recognition vector transformation on the word vectors to be recognized to obtain a first vector corresponding to each word to be recognized and a second vector corresponding to each word to be recognized. The word vectors to be identified obtained through vectorization are shared, and different named entity type identification tasks are subjected to different identification vector transformations.
Step 606, the named entity type multitask recognition model enumerates and determines each word to be recognized based on the text to be recognized, determines a first vector corresponding to a starting word in each word to be recognized from a first vector corresponding to each word to be recognized, determines a second vector corresponding to a terminating word in each word to be recognized from a second vector corresponding to each word to be recognized, and performs named entity type multitask recognition on each word to be recognized respectively based on the first vector corresponding to the starting word in each word to be recognized and the second vector corresponding to the terminating word in each word to be recognized to obtain a named entity recognition result corresponding to each word to be recognized respectively.
Specifically, each named entity type task in the named entity type multitask recognition model performs enumeration to determine each word to be recognized by using a text to be recognized during recognition, determines a first vector corresponding to a starting word in each word to be recognized from a first vector corresponding to each word to be recognized, determines a second vector corresponding to a terminating word in each word to be recognized from a second vector corresponding to each word to be recognized, and performs named entity type multitask recognition on each word to be recognized respectively based on the first vector corresponding to the starting word in each word to be recognized and the second vector corresponding to the terminating word in each word to be recognized to obtain a named entity recognition result corresponding to each word to be recognized respectively. Namely, each named entity type task can obtain the probability that each word to be recognized belongs to the named entity type, whether each word to be recognized is the named entity type is obtained based on the probability of the named entity type, and finally, when all the named entity type tasks are completed, the recognition result of each word to be recognized for each named entity type task is obtained.
In the embodiment, the named entity recognition is performed on the text to be recognized through the named entity type multitask recognition model, so that the named entity recognition results corresponding to the words to be recognized are obtained, and the efficiency of obtaining the named entity recognition results is improved.
In one embodiment, the named entity type multitask recognition model comprises a word vectorization network and a named entity type multitask recognition network;
as shown in fig. 7, step 602, inputting a text to be recognized into a named entity type multitask recognition model, including:
step 702, inputting a text to be recognized into a word vectorization network, dividing the text to be recognized by the word vectorization network to obtain each word to be recognized, and vectorizing each word to be recognized to obtain each word vector to be recognized;
the word vectorization network refers to a network for vectorizing the words to be identified, and the word vectorization network may be obtained by training in advance. For example, the word vectorization network may be a BERT (Bidirectional Encoder expressions from transforms) network. The word vectoring network is a shared network in the named entity type multitasking recognition model.
Specifically, the server inputs the text to be recognized into a word vectorization network, the word vectorization network divides the text to be recognized into words to obtain words to be recognized, and vectorizes the words to be recognized to obtain word vectors to be recognized. For example, a sentence of length n is input into BERT to obtain a vector code for each word [ h1, h2, … hn ].
Step 704, inputting each word vector to be identified into the named entity type multitask identification network, and inputting each word vector to be identified into each named entity type identification sub-network by the named entity type multitask identification network.
Wherein the named entity type identification subnetwork is used for identifying the corresponding named entity type. I.e. a named entity type recognition subnetwork handles a named entity type recognition task.
Specifically, the named entity type multitask identification network comprises at least two named entity type identification sub-networks, and the server inputs each word to be identified obtained through identification into each named entity type identification sub-network respectively.
Step 706, the named entity type recognition subnetwork performs recognition vector transformation on each word to be recognized to obtain a first vector corresponding to each word to be recognized and a second vector corresponding to each word to be recognized, performs enumeration on the basis of the text to be recognized to determine each word to be recognized, determines a first vector corresponding to a starting word in each word to be recognized from the first vector corresponding to each word to be recognized, and determines a second vector corresponding to a terminating word in each word to be recognized from the second vector corresponding to each word to be recognized;
step 708, the named entity type recognition sub-network performs named entity type recognition on each to-be-recognized word respectively based on a first vector corresponding to a start word in each to-be-recognized word and a second vector corresponding to an end word in each to-be-recognized word to obtain a sub-network named entity recognition result corresponding to each to-be-recognized word, and obtains a named entity recognition result corresponding to each to-be-recognized word respectively based on a sub-network named entity recognition result corresponding to each to-be-recognized word.
Specifically, the server uses each named entity type identifier network to identify the named entity type of each word to be identified, so as to obtain the probability that each word to be identified belongs to each named entity type, and the named entity type with the highest probability is selected as the named entity type finally identified by the word to be identified. And sequentially obtaining the type of the named entity finally identified by each word to be identified, and obtaining the identification result of the named entity.
In the embodiment, the named entity recognition result corresponding to each word to be recognized is obtained through parallel recognition of the named entity type recognition sub-networks, and the efficiency of obtaining the named entity recognition result is improved.
In one embodiment, as shown in fig. 8, the method further comprises:
step 802, inputting a text to be recognized into each named entity type single task recognition model; the named entity type single task recognition model divides words of a text to be recognized to obtain words to be recognized, vectorizes the words to be recognized to obtain word vectors to be recognized, and performs recognition vector transformation on the word vectors to be recognized to obtain first vectors corresponding to the words to be recognized and second vectors corresponding to the words to be recognized.
The named entity type single task recognition model is only used for recognizing one named entity type, for example, the named entity type single task recognition model is only used for recognizing a person type. Different named entity type identifications have different named entity type single task identification models, namely, a corresponding named entity type single task identification model is established for each named entity type identification.
Specifically, the server may train to obtain the single-task named entity type recognition model by using training data, where the training data includes named entities of the named entity type and named entities of other named entity types. When the named entity type single task recognition model needs to be used, the server calls the corresponding named entity type single task recognition model and inputs the text to be recognized into each named entity type single task recognition model; the named entity type single task recognition model divides words of a text to be recognized to obtain words to be recognized, vectorizes the words to be recognized to obtain word vectors to be recognized, and performs recognition vector transformation on the word vectors to be recognized to obtain first vectors corresponding to the words to be recognized and second vectors corresponding to the words to be recognized.
Step 804, the named entity type single task recognition model enumerates and determines each word to be recognized based on the text to be recognized, determines a first vector corresponding to a starting word in each word to be recognized from a first vector corresponding to each word to be recognized, determines a second vector corresponding to a terminating word in each word to be recognized from a second vector corresponding to each word to be recognized, performs named entity type single task recognition on each word to be recognized respectively based on the first vector corresponding to the starting word in each word to be recognized and the second vector corresponding to the terminating word in each word to be recognized, and outputs a single task recognition result corresponding to each word to be recognized respectively.
The single task recognition result refers to the recognition result of the named entity type corresponding to the single task recognition model of each word to be recognized to the named entity type, and the recognition result comprises the possibility that the word to be recognized is the named entity type. In a specific embodiment, the single-task recognition result may be represented by using a classification matrix, where different classification matrices represent different named entity types, and each classification matrix is used for obtaining a recognition result of a corresponding named entity type. A in the classification matrixijIndicating the likelihood that a word to be recognized starting from the i character and ending at the j character is recognized as the named entity type corresponding to the classification matrix, e.g. A01When the value of (1) is 1, the named entity type of the word to be recognized from the 0 th character to the 1 st character is the named entity type corresponding to the classification matrix.
Specifically, a named entity type single task recognition model in a server enumerates and determines each word to be recognized based on a text to be recognized, a first vector corresponding to an initial word in each word to be recognized is determined from a first vector corresponding to each word to be recognized, a second vector corresponding to a stop word in each word to be recognized is determined from a second vector corresponding to each word to be recognized, named entity type single task recognition is respectively performed on each word to be recognized based on the first vector corresponding to the initial word in each word to be recognized and the second vector corresponding to the stop word in each word to be recognized, and a single task recognition result corresponding to each word to be recognized is output.
Step 806, determining the named entity recognition result corresponding to each word to be recognized based on the single task recognition result corresponding to each word to be recognized output by each named entity type single task recognition model.
Specifically, the server may input the text to be recognized into each established named entity type single task recognition model to obtain a single task recognition result corresponding to each word to be recognized output by each named entity type single task recognition model, and then compare the single task recognition results corresponding to each word to be recognized output by each named entity type single task recognition model to determine the named entity type with the highest possibility corresponding to each word to be recognized, so as to obtain the named entity recognition result corresponding to each word to be recognized.
In the embodiment, the text to be recognized is input into each named entity type single task recognition model to obtain the single task recognition result corresponding to each word to be recognized, and finally, the named entity recognition result corresponding to each word to be recognized is determined according to the single task recognition result, so that the accuracy of the obtained named entity recognition result can be improved.
In one embodiment, the named entity type single task recognition model comprises a primary entity type single task recognition model and a secondary entity type single task recognition model;
as shown in fig. 9, inputting the text to be recognized into each named entity type single task recognition model includes:
and step 902, inputting the text to be recognized into each primary entity type single task recognition model.
The primary entity type single-task recognition model is a single-task recognition model used for recognizing the primary type of the named entity.
Specifically, the server may perform named entity primary type recognition on the text to be recognized first. Namely, the server can call each trained primary entity type single task recognition model first, and the text to be recognized is input into each primary entity type single task recognition model for primary type recognition of the named entity.
And 904, dividing the text to be recognized into words by the primary entity type single task recognition model to obtain each word to be recognized, vectorizing each word to be recognized to obtain each word vector to be recognized, and performing recognition vector transformation on each word vector to be recognized to obtain a first vector corresponding to each word to be recognized and a second vector corresponding to each word to be recognized.
Step 906, the primary entity type single task recognition model enumerates and determines each word to be recognized based on the text to be recognized, determines a first vector corresponding to a starting word in each word to be recognized from a first vector corresponding to each word to be recognized, determines a second vector corresponding to a terminating word in each word to be recognized from a second vector corresponding to each word to be recognized, and performs primary type recognition of the named entity on each word to be recognized respectively based on the first vector corresponding to the starting word in each word to be recognized and the second vector corresponding to the terminating word in each word to be recognized to obtain a primary type recognition result of the named entity corresponding to each word to be recognized respectively.
The named entity primary type recognition result is used for representing the possibility that each word to be recognized belongs to the named entity primary type.
Specifically, each primary entity type single task recognition model in the server performs primary type recognition on the named entity to obtain primary type recognition results of the named entity corresponding to each output word to be recognized, and then the primary type of the named entity with the highest possibility exceeding a preset possibility threshold is selected as the primary type of the named entity corresponding to the word to be recognized according to the primary type recognition results of the named entity corresponding to each output word to be recognized of each primary entity type single task recognition model. For example, three words to be recognized are input into three primary entity type single task recognition models, three groups of likelihood scores (10, 60, 98), (30, 92, 84) and (40, 94, 95) output by the three words to be recognized a, B and C are obtained, the score which exceeds the threshold value 90 and is the maximum is selected as the recognition result of the words to be recognized, and since all the scores of the words to be recognized a are lower than the threshold value 90, at this time, the words to be recognized a do not belong to the primary type of the named entity corresponding to the three primary entity type single task recognition models. And if the highest score of the word B to be recognized is 94, the primary type of the named entity corresponding to the word B to be recognized is the primary type of the named entity corresponding to the third primary entity type single-task recognition model. And if the highest score of the word C to be recognized is 98, the primary type of the named entity corresponding to the word C to be recognized is the primary type of the named entity corresponding to the first primary entity type single-task recognition model.
And 908, acquiring each secondary entity type single task recognition model associated with the named entity primary type recognition result, inputting the text to be recognized into each secondary entity type single task recognition model for named entity secondary type recognition, and obtaining the named entity secondary type recognition result corresponding to each word to be recognized.
And the named entity secondary type recognition result is used for representing the possibility that each word to be recognized belongs to the named entity secondary type.
Specifically, when determining a first-level type recognition result of a named entity corresponding to a word to be recognized, the server obtains the word to be recognized of the first-level type of the named entity corresponding to the word to be recognized, then performs second-level type recognition on the word to be recognized of the first-level type of the named entity corresponding to the word to be recognized, that is, obtains a second-level entity type single task recognition model corresponding to the second-level type of the named entity associated with the first-level type of the named entity, and then inputs a text to be recognized into each second-level entity type single task recognition model to perform second-level type recognition on the named entity, so as to obtain a second-level type recognition result of the named entity corresponding to each word to be recognized.
Step 910, obtaining a named entity recognition result corresponding to each word to be recognized based on the named entity primary type recognition result and the named entity secondary type recognition result.
Specifically, the server determines the primary type of the named entity and the secondary type of the named entity corresponding to the specific word to be recognized in each word to be recognized according to the primary type recognition result of the named entity and the secondary type recognition result of the named entity. Namely, the specific word to be recognized is a named entity primary type and a named entity secondary type which are corresponding to each other, and other words to be recognized do not belong to the named entities.
In the embodiment, the named entity primary type recognition is performed by using the primary entity type single task recognition model, the named entity secondary type recognition is performed by using the associated secondary entity type single task recognition model, and finally the named entity recognition results corresponding to the words to be recognized are obtained, so that the efficiency of obtaining the named entity recognition results is improved.
In one embodiment, as shown in fig. 10, the training step of the named entity type single task recognition model comprises the following steps:
step 1002, pre-training data is obtained, wherein the pre-training data comprises a pre-training text and pre-training type labels corresponding to named entities in the pre-training text, and the pre-training type labels are determined according to link texts of the named entities in the pre-training text.
The pre-training type labels comprise command entity labels and non-command entity labels. Command entity labels may be determined from link text of named entities in the pre-training text. The link text of the named entity can refer to anchor text of the named entity, for example, the command entity label can be derived from anchor text data of an encyclopedia. The pre-training data is large-scale noisy data.
Specifically, the server may obtain pre-training data from a database, which is large-scale data. The server may also collect the pre-training data directly from the internet. The server may also obtain pre-training data from a service provider that provides data services.
And 1004, inputting pre-training data into the initial named entity type single-task recognition model for pre-training to obtain a pre-training named entity type single-task recognition model.
The initial named entity type single-task recognition model refers to a named entity type single-task recognition model with initialized model parameters.
Specifically, the server inputs pre-training data into the initial named entity type single task recognition model for pre-training, and when a pre-training completion condition is met, the pre-training named entity type single task recognition model is obtained, wherein the number of iterations reaches an upper limit, a training error is smaller than a preset threshold value and the like when the pre-training completion condition is met.
Step 1006, training data is obtained, where the training data includes a training text and training type labels corresponding to named entities in the training text, and the training type labels are labeled in advance.
The training type label is labeled in advance and is accurate.
Specifically, the server obtains training data from a database. The training data is obtained by artificial labeling, and the data volume is smaller compared with the pre-training data.
And step 1008, inputting training data into the pre-training named entity type single task recognition model for training to obtain the named entity type single task recognition model.
Specifically, the server inputs training data into a pre-training named entity type single task recognition model for training, and when a training completion condition is met, the named entity type single task recognition model is obtained, wherein the training completion condition can be that the iteration number reaches an upper limit, the training error is smaller than a preset threshold value, and the like.
In the embodiment, the large-scale noisy data is used for pre-training, so that a large amount of priori knowledge can be mined from the obtained pre-trained named entity type single-task recognition model, and then the training data is used for further training the pre-trained named entity type single-task recognition model, so that the accuracy of named entity recognition is improved through the trained named entity type single-task recognition model.
In one embodiment, as shown in fig. 11, in step 210, based on a first vector corresponding to a start word in each to-be-recognized word and a second vector corresponding to an end word in each to-be-recognized word, performing named entity type recognition on each to-be-recognized word respectively to obtain a named entity recognition result corresponding to each to-be-recognized word, including:
step 1102, determining a current word to be recognized from each word to be recognized, and acquiring a current first vector corresponding to an initial word in the current word to be recognized and a current second vector corresponding to a final word in the current word to be recognized.
The current word to be recognized refers to the word to be recognized which needs to be transformed currently.
Specifically, the server sequentially determines a current word to be recognized from each word to be recognized, then obtains a current first vector corresponding to a starting word in the current word to be recognized from a first vector corresponding to each word to be recognized, and obtains a current second vector corresponding to a terminating word in the current word to be recognized from a second vector corresponding to each word to be recognized.
Step 1104, computing the transpose of the current first vector to obtain a current transpose vector.
Step 1106, calculating the product of the current transposed vector and the current second vector to obtain the possibility of the type of the named entity, and determining the recognition result of the named entity corresponding to the current word to be recognized based on the possibility of the type of the named entity.
Specifically, the server performs a transposition operation on the current first vector to obtain a transposed vector, that is, the current transposed vector. And then, carrying out vector product operation by using the current transposed vector and the current second vector to obtain the possibility of the type of the named entity. The named entity type likelihood represents a likelihood that the current word to be recognized is the named entity type. And comparing the possibility of the type of the named entity with a preset threshold, and determining that the current word to be recognized is the type of the named entity when the possibility of the type of the named entity exceeds the preset threshold and the possibility of the type of the named entity is the maximum among the possibilities of all the types of the named entity. And when the possibility of the type of the named entity does not exceed a preset threshold, indicating that the current word to be recognized is not the type of the named entity. In one particular embodiment, the named entity type likelihood can be calculated using equation (2) as shown below.
Figure 778880DEST_PATH_IMAGE015
Formula (2)
Wherein s represents that the continuous segment from the ith character to the jth character in the text to be recognized is the second character
Figure DEST_PATH_IMAGE016_53A
A score for a named entity type.
Figure 574185DEST_PATH_IMAGE018
Representing the current transposed vector as a function of time,
Figure 243064DEST_PATH_IMAGE020
representing the current second vector.
Step 1108, traversing each word to be recognized to obtain a named entity recognition result corresponding to each word to be recognized.
Specifically, the server traverses each word to be recognized, that is, determines the named entity type recognition result of each word to be recognized, and obtains the named entity recognition result corresponding to each word to be recognized.
In the above embodiment, the possibility of the type of the named entity is obtained by calculating the transpose of the current first vector and then calculating the product of the current transposed vector and the current second vector, so that the calculation is simplified, and the efficiency of obtaining the possibility of the type of the named entity is improved.
In one embodiment, as shown in fig. 12, after the step 206, after performing recognition vector transformation on each word to be recognized vector to obtain a first vector corresponding to each word to be recognized and a second vector corresponding to each word to be recognized, the method further includes:
and 1202, acquiring the position information of each word to be identified in the text to be identified, and coding the position information to obtain the position code corresponding to each word to be identified.
The position information is used for reflecting the specific position of the word to be recognized in the text to be recognized. For example, the word to be recognized may be the 5 th character in the text to be recognized. Position coding refers to a coded vector of position information. The position code is a rotary position code, which is a transformation matrix.
Specifically, the server determines the position information of each word to be identified in the text to be identified according to the text to be identified, and then codes the position information to obtain the position code corresponding to each word to be identified.
Step 1204, fusing the first vectors corresponding to the words to be identified with the position codes corresponding to the words to be identified, respectively, to obtain first target vectors corresponding to the words to be identified.
Specifically, the server performs vector operation on the first vector of each word to be identified and the corresponding position code, so as to perform fusion, and obtain a fused vector, that is, a first target vector corresponding to each word to be identified. The first target vector can be obtained by directly calculating the vector sum of the first vector of the word to be recognized and the position code of the word to be recognized, or the first vector of the word to be recognized and the position code of the word to be recognized can be spliced to obtain the first target vector, or the vector product of the first vector of the word to be recognized and the position code of the word to be recognized can be calculated to obtain the first target vector.
And 1206, fusing the second vectors corresponding to the words to be identified with the position codes corresponding to the words to be identified respectively to obtain second target vectors corresponding to the words to be identified.
And the server performs vector operation on the second vector of each word to be identified and the corresponding position code so as to perform fusion, and a fused vector is obtained, namely the second target vector corresponding to each word to be identified. The second target vector can be obtained by directly calculating the vector sum of the second vector of the word to be recognized and the position code of the word to be recognized, or the second vector of the word to be recognized and the position code of the word to be recognized can be spliced to obtain the second target vector, or the vector product of the second vector of the word to be recognized and the position code of the word to be recognized can be calculated to obtain the second target vector.
Step 200, namely, respectively carrying out named entity type recognition on each word to be recognized based on a first vector corresponding to a starting character in each word to be recognized and a second vector corresponding to a terminating character in each word to be recognized to obtain a named entity recognition result corresponding to each word to be recognized, and the method comprises the following steps:
and respectively carrying out named entity type recognition on each word to be recognized based on a first target vector corresponding to the initial character in each word to be recognized and a second target vector corresponding to the terminal character in each word to be recognized, and obtaining a target named entity recognition result corresponding to each word to be recognized.
The target named entity recognition result is a named entity recognition result obtained by adding position information and then recognizing the type of the named entity.
Specifically, the server may perform named entity type recognition on each to-be-recognized word according to a first target vector corresponding to a start word in each to-be-recognized word and a second target vector corresponding to an end word in each to-be-recognized word, for example, a score of a named entity type corresponding to the to-be-recognized word may be calculated by using formula (1), and the named entity type of the to-be-recognized word is determined according to the score of the named entity type. In one particular embodiment, the named entity type score for the word to be recognized may be determined using a calculation using equation (3) as shown below.
Figure 767586DEST_PATH_IMAGE022
Formula (3)
Wherein the content of the first and second substances,
Figure DEST_PATH_IMAGE023_5A
indicating the corresponding position code of the start word,
Figure 115391DEST_PATH_IMAGE025
indicating the position code corresponding to the stop word,
Figure 383561DEST_PATH_IMAGE027
indicating the relative position information between the start word and the stop word. I.e. the relative location information is used in calculating the named entity type score.
In the embodiment, the relative position information is added when the type of the named entity is identified, so that the degree and the span of the text to be identified when the type of the named entity is identified are more sensitive, and the accuracy of the obtained identification result of the target named entity is improved.
In a specific embodiment, as shown in fig. 13, a schematic flow chart of a named entity identification method is provided, which specifically includes the following steps:
step 1302, acquiring a text to be recognized, and inputting the text to be recognized into each primary entity type single task recognition model;
in step 1304, the text to be recognized is divided into words in the primary entity type single task recognition model to obtain words to be recognized, the words to be recognized are vectorized to obtain word vectors to be recognized, recognition vector transformation is performed on the word vectors to be recognized by using the recognition vector transformation parameters to obtain first vectors corresponding to the words to be recognized and second vectors corresponding to the words to be recognized.
Step 1306, the primary entity type single task recognition model performs enumeration on the basis of the text to be recognized to determine each word to be recognized, determines a first vector corresponding to a starting word in each word to be recognized from a first vector corresponding to each word to be recognized, and determines a second vector corresponding to a terminating word in each word to be recognized from a second vector corresponding to each word to be recognized.
Step 1308, the primary entity type single task recognition model acquires position information of each word to be recognized in the text to be recognized, codes the position information to obtain a position code corresponding to each word to be recognized, fuses the first vectors corresponding to each word to be recognized with the position codes corresponding to each word to be recognized respectively to obtain a first target vector corresponding to each word to be recognized, and fuses the second vectors corresponding to each word to be recognized with the position codes corresponding to each word to be recognized respectively to obtain a second target vector corresponding to each word to be recognized.
Step 1310, the primary entity type single task recognition model determines a current word to be recognized from each word to be recognized, and obtains a current first target vector corresponding to an initial word in the current word to be recognized and a current second target vector corresponding to a terminal word in the current word to be recognized; calculating the transposition of the current first target vector to obtain a current target transposition vector; calculating the product of the current target transposition vector and the current second target vector to obtain the primary type possibility of the named entity, and determining the primary type recognition result of the named entity corresponding to the current word to be recognized based on the primary type possibility of the named entity; and traversing each word to be recognized to obtain a primary type recognition result of the named entity corresponding to each word to be recognized.
And 1312, acquiring each secondary entity type single task recognition model associated with the named entity primary type recognition result, and inputting the text to be recognized into each secondary entity type single task recognition model for named entity secondary type recognition to obtain named entity secondary type recognition results corresponding to the words to be recognized respectively. And obtaining the named entity recognition result corresponding to each word to be recognized respectively based on the named entity primary type recognition result and the named entity secondary type recognition result.
And 1314, carrying out entity mention recognition based on the text to be recognized to obtain each entity mention. And carrying out entity recall from a preset knowledge base based on each entity mention to obtain a candidate entity set corresponding to each entity mention. And carrying out entity disambiguation on the basis of the candidate entity sets respectively corresponding to the entity mentions to obtain entities respectively corresponding to the entity mentions, and obtaining an entity link identification result corresponding to the text to be identified on the basis of the entities respectively corresponding to the entity mentions.
1316, matching the primary type of the named entity in the recognition result of the named entity of the target word to be recognized with the primary type of the entity link in the recognition result of the entity link of the target word, and when the primary type of the named entity is the same as the primary type of the entity link, taking the primary type of the entity link and the secondary type of the entity link as the recognition result of the target entity corresponding to the target word to be recognized; and when the matching of the primary type of the named entity and the primary type of the entity link is not the same, taking the primary type of the named entity and the secondary type of the named entity as a target entity recognition result corresponding to the target word to be recognized.
The application also provides an application scenario applying the named entity identification method. In particular, the amount of the solvent to be used,
in a voice question-answering scenario, a server acquires a question sent by a user terminal, takes the question as a text to be recognized, and then inputs the text to be recognized into a primary entity type single-task recognition model, as shown in fig. 14, which is a frame schematic diagram of the primary entity type single-task recognition model. The primary entity type single task recognition model divides the text to be recognized into words to obtain words to be recognized, namely w1, w2, w3, w4, w5 and the like. Vectorizing the words w1, w2, w3, w4 and w5 to be identified through a BERT network to obtain the word vectors to be identified. And performing identification vector transformation on each word vector to be identified to obtain a first vector corresponding to each word to be identified and a second vector corresponding to each word to be identified. Enumerating based on the text to be recognized to determine each word to be recognized, determining a first vector corresponding to a starting character w1 in the current word to be recognized from a first vector corresponding to each word to be recognized, and determining a second vector corresponding to a terminating character w3 in the current word to be recognized from a second vector corresponding to each word to be recognized. Carrying out named entity type recognition on a current word to be recognized w1w3 by using a formula (2) based on a first vector corresponding to a start word w1 in the current word to be recognized and a second vector corresponding to a stop word w3 in the current word to be recognized to obtain a named entity type score corresponding to the current word to be recognized w1w3, when the named entity type score exceeds a preset threshold and is the maximum value in all the named entity type scores, obtaining that the current word to be recognized w1w3 is the named entity type, and at the moment, the value of A13 in the named entity type matrix in a classification matrix output by a primary entity type single task recognition model is1. For example, as shown in fig. 15, a schematic diagram of a classification matrix is shown. When identifying 'Beijing university affiliated Hospital', each word to be identified does not belong to a name entity, and Beijing belongs to a place name entity, and A in a place name entity matrix output by the primary entity type single-task identification model01Has a value of 1. Beijing university belongs to organization name entity, and A in organization name entity matrix output by primary entity type single-task recognition model03Has a value of 1. At the moment, performing secondary entity type identification on the named entity of which the primary entity type is determined, namely obtaining each secondary entity type single task identification model associated with the primary entity type, and then inputting the text to be identified into each secondary entity type single task identification model to perform named entity secondary type identification to obtain a named entity secondary type identification result corresponding to each word to be identified. And obtaining the named entity recognition result corresponding to each word to be recognized respectively based on the named entity primary type recognition result and the named entity secondary type recognition result. And then acquiring a reply sentence corresponding to the question from a preset knowledge base according to the named entity recognition result and the question semantic, and returning the reply sentence to the user terminal for displaying, so that the question and answer accuracy can be improved. In a particular embodiment, the creation of a knowledge graph may also be used, i.e., the creation of a knowledge graph using named entity recognition results. In a specific embodiment, the named entity recognition method can also be applied to an intelligent traffic scene, for example, a vehicle-mounted terminal receives user voice, converts the user voice into a text to be recognized, performs named entity recognition on the text to be recognized according to the named entity recognition method in any embodiment to obtain a named entity recognition result, obtains a reply sentence based on the named entity recognition result, converts the reply sentence into voice, and plays the voice through the vehicle-mounted terminal, for example, how long the user needs to ask a certain place, obtains the place name through the named entity recognition, obtains the distance between the current vehicle place and the place corresponding to the place name to calculate time, and generates a reply text and converts the reply text into voice to play.
It should be understood that although the various steps in the flow charts in fig. 2-13 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in the flowcharts of fig. 2-13 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least some of the other steps or stages.
In one embodiment, as shown in fig. 16, there is provided a named entity recognition apparatus 1600, which may be a part of a computer device using a software module or a hardware module, or a combination of the two, the apparatus specifically includes: an acquisition module 1602, a vectorization module 1604, a transformation module 1606, a vector determination module 1608, and a recognition module 1610, wherein:
an obtaining module 1602, configured to obtain a text to be recognized, and perform word segmentation on the text to be recognized to obtain each word to be recognized;
the vectorization module 1604 is configured to vectorize each word to be identified to obtain each word vector to be identified;
a transformation module 1606, configured to perform identification vector transformation on each vector of words to be identified to obtain a first vector corresponding to each word to be identified and a second vector corresponding to each word to be identified, where the first vector is used to represent a semantic vector corresponding to a word to be identified in a text obtained by using a word to be identified as a start word in the text to be identified, and the second vector is used to represent a semantic vector corresponding to a word to be identified in a text obtained by using a word to be identified as a stop word in the text to be identified;
a vector determining module 1608, configured to enumerate and determine each word to be recognized based on the text to be recognized, determine a first vector corresponding to a starting word in each word to be recognized from a first vector corresponding to each word to be recognized, and determine a second vector corresponding to a terminating word in each word to be recognized from a second vector corresponding to each word to be recognized;
the identifying module 1610 is configured to perform named entity type identification on each to-be-identified word respectively based on a first vector corresponding to a start word in each to-be-identified word and a second vector corresponding to an end word in each to-be-identified word, so as to obtain a named entity identification result corresponding to each to-be-identified word.
In one embodiment, the named entity identifying apparatus 1600 further comprises:
and the entity linking module is used for carrying out entity mention identification on the basis of the text to be identified to obtain each entity mention. And carrying out entity recall from a preset knowledge base based on each entity mention to obtain a candidate entity set corresponding to each entity mention. And carrying out entity disambiguation on the basis of the candidate entity sets respectively corresponding to the entity mentions to obtain entities respectively corresponding to the entity mentions, and obtaining an entity link identification result corresponding to the text to be identified on the basis of the entities respectively corresponding to the entity mentions.
And the target result obtaining module is used for obtaining a target entity recognition result corresponding to the text to be recognized based on the entity link recognition result and the named entity recognition result.
In one embodiment, the named entity recognition result comprises a named entity primary type and a named entity secondary type, and the entity link recognition result comprises an entity link primary type and an entity link secondary type;
the target result obtaining module is also used for obtaining a named entity recognition result of a target to-be-recognized word in each to-be-recognized word and an entity link recognition result of a target entity in each entity mention corresponding entity respectively, and the target to-be-recognized word and the target entity are the same entity; matching a named entity primary type in a named entity recognition result of the target word to be recognized with an entity link primary type in an entity link recognition result of the target entity, and taking the entity link primary type and the entity link secondary type as a target entity recognition result corresponding to the target word to be recognized when the named entity primary type is matched with the entity link primary type; and when the matching of the primary type of the named entity and the primary type of the entity link is not the same, taking the primary type of the named entity and the secondary type of the named entity as a target entity recognition result corresponding to the target word to be recognized.
In one embodiment, the transformation module 1606 is further configured to obtain trained recognition vector transformation parameters, and perform recognition vector transformation on each word vector to be recognized by using the recognition vector transformation parameters to obtain a first vector corresponding to each word to be recognized and a second vector corresponding to each word to be recognized.
In one embodiment, the named entity identifying apparatus 1600 further comprises:
the multitask identification module is used for inputting the text to be identified into a named entity type multitask identification model; the named entity type multi-task recognition model divides the text to be recognized into words to obtain each word to be recognized; vectorizing each word to be identified to obtain each word vector to be identified, and performing identification vector transformation on each word vector to be identified to obtain a first vector corresponding to each word to be identified and a second vector corresponding to each word to be identified; the named entity type multitask recognition model performs enumeration on the basis of a text to be recognized to determine each word to be recognized, determines a first vector corresponding to a starting character in each word to be recognized from a first vector corresponding to each word to be recognized, determines a second vector corresponding to a terminating character in each word to be recognized from a second vector corresponding to each word to be recognized, and performs named entity type multitask recognition on each word to be recognized respectively on the basis of the first vector corresponding to the starting character in each word to be recognized and the second vector corresponding to the terminating character in each word to be recognized to obtain a named entity recognition result corresponding to each word to be recognized respectively.
In one embodiment, the named entity type multitask recognition model comprises a word vectorization network and a named entity type multitask recognition network;
the multitask identification module is also used for inputting the text to be identified into a word vectorization network, the word vectorization network divides the text to be identified into words to obtain words to be identified, and vectorizes the words to be identified to obtain word vectors to be identified; inputting each word vector to be identified into a named entity type multi-task identification network, and inputting each word vector to be identified into each named entity type identification sub-network by the named entity type multi-task identification network; the named entity type recognition sub-network carries out recognition vector transformation on each word vector to be recognized to obtain a first vector corresponding to each word to be recognized and a second vector corresponding to each word to be recognized, enumerates and determines each word to be recognized based on a text to be recognized, determines a first vector corresponding to an initial word in each word to be recognized from the first vector corresponding to each word to be recognized, and determines a second vector corresponding to a stop word in each word to be recognized from the second vector corresponding to each word to be recognized; the named entity type recognition sub-network respectively performs named entity type recognition on each word to be recognized based on a first vector corresponding to a starting character in each word to be recognized and a second vector corresponding to an ending character in each word to be recognized to obtain a sub-network named entity recognition result corresponding to each word to be recognized, and obtains a named entity recognition result corresponding to each word to be recognized based on the sub-network named entity recognition result corresponding to each word to be recognized.
In one embodiment, the named entity identifying apparatus 1600 further comprises:
the single task identification module is used for inputting the text to be identified into each named entity type single task identification model; the named entity type single task recognition model divides the text to be recognized into words to obtain words to be recognized, vectorizes the words to be recognized to obtain word vectors to be recognized, and performs recognition vector transformation on the word vectors to be recognized to obtain first vectors corresponding to the words to be recognized and second vectors corresponding to the words to be recognized; the named entity type single task recognition model enumerates and determines each word to be recognized based on a text to be recognized, determines a first vector corresponding to a starting character in each word to be recognized from a first vector corresponding to each word to be recognized, determines a second vector corresponding to a terminating character in each word to be recognized from a second vector corresponding to each word to be recognized, performs named entity type single task recognition on each word to be recognized respectively based on the first vector corresponding to the starting character in each word to be recognized and the second vector corresponding to the terminating character in each word to be recognized, and outputs a single task recognition result corresponding to each word to be recognized respectively; and determining the named entity recognition result corresponding to each word to be recognized based on the single task recognition result corresponding to each word to be recognized output by each named entity type single task recognition model.
In one embodiment, the named entity type single task recognition model comprises a primary entity type single task recognition model and a secondary entity type single task recognition model;
the single-task identification module is also used for inputting the text to be identified into each primary entity type single-task identification model; the method comprises the steps that a first-level entity type single-task recognition model divides a text to be recognized into words to obtain words to be recognized, vectorizes the words to be recognized to obtain word vectors to be recognized, and performs recognition vector transformation on the word vectors to be recognized to obtain first vectors corresponding to the words to be recognized and second vectors corresponding to the words to be recognized; the primary entity type single task recognition model enumerates and determines each word to be recognized based on a text to be recognized, determines a first vector corresponding to a starting character in each word to be recognized from a first vector corresponding to each word to be recognized, determines a second vector corresponding to a terminating character in each word to be recognized from a second vector corresponding to each word to be recognized, and performs primary type recognition of a named entity on each word to be recognized respectively based on the first vector corresponding to the starting character in each word to be recognized and the second vector corresponding to the terminating character in each word to be recognized to obtain a primary type recognition result of the named entity corresponding to each word to be recognized; acquiring each secondary entity type single task recognition model related to the named entity primary type recognition result, inputting the text to be recognized into each secondary entity type single task recognition model for named entity secondary type recognition, and acquiring named entity secondary type recognition results corresponding to each word to be recognized; and obtaining the named entity recognition result corresponding to each word to be recognized respectively based on the named entity primary type recognition result and the named entity secondary type recognition result.
In one embodiment, the named entity identifying apparatus 1600 further comprises:
the training module is used for acquiring pre-training data, the pre-training data comprises a pre-training text and pre-training type labels corresponding to named entities in the pre-training text, and the pre-training type labels are determined according to link texts of the named entities in the pre-training text; inputting pre-training data into the initial named entity type single task recognition model for pre-training to obtain a pre-training named entity type single task recognition model; acquiring training data, wherein the training data comprises a training text and training type labels corresponding to named entities in the training text, and the training type labels are labeled in advance; and inputting the training data into a pre-training named entity type single task recognition model for training to obtain the named entity type single task recognition model.
In one embodiment, the identifying module 1610 is further configured to determine a current word to be identified from each word to be identified, and obtain a current first vector corresponding to a starting word in the current word to be identified and a current second vector corresponding to a terminating word in the current word to be identified; calculating the transposition of the current first vector to obtain a current transposition vector; calculating the product of the current transposed vector and the current second vector to obtain the type possibility of the named entity, and determining the recognition result of the named entity corresponding to the current word to be recognized based on the type possibility of the named entity; and traversing each word to be recognized to obtain a named entity recognition result corresponding to each word to be recognized.
In one embodiment, the named entity identifying apparatus 1600 further comprises:
the position fusion module is used for acquiring position information of each word to be identified in the text to be identified, and coding the position information to obtain a position code corresponding to each word to be identified; fusing the first vectors corresponding to the words to be identified with the position codes corresponding to the words to be identified respectively to obtain first target vectors corresponding to the words to be identified; fusing the second vector corresponding to each word to be identified with the position code corresponding to each word to be identified respectively to obtain a second target vector corresponding to each word to be identified;
the identifying module 1610 is further configured to perform named entity type identification on each to-be-identified word based on a first target vector corresponding to a start word in each to-be-identified word and a second target vector corresponding to an end word in each to-be-identified word, so as to obtain a target named entity identification result corresponding to each to-be-identified word.
For the specific definition of the named entity recognition apparatus, reference may be made to the above definition of the named entity recognition method, which is not described herein again. The various modules in the named entity recognition apparatus described above may be implemented in whole or in part by software, hardware, and combinations thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 17. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing named entity recognition result data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a named entity recognition method.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 18. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless communication can be realized through WIFI, an operator network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a named entity recognition method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the configurations shown in fig. 17 or 18 are only block diagrams of some of the configurations relevant to the present application, and do not constitute a limitation on the computer apparatus to which the present application is applied, and a particular computer apparatus may include more or less components than those shown in the drawings, or may combine some components, or have a different arrangement of components.
In one embodiment, a computer device is further provided, which includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the above method embodiments when executing the computer program.
In an embodiment, a computer-readable storage medium is provided, in which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
In one embodiment, a computer program product or computer program is provided that includes computer instructions stored in a computer-readable storage medium. The computer instructions are read by a processor of a computer device from a computer-readable storage medium, and the computer instructions are executed by the processor to cause the computer device to perform the steps in the above-mentioned method embodiments.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (22)

1. A named entity recognition method, comprising:
acquiring a text to be recognized, and inputting the text to be recognized into a named entity type multitask recognition model, wherein the named entity type multitask recognition model divides the text to be recognized into words to obtain each word to be recognized;
the named entity recognition type multi-task recognition model vectorizes the words to be recognized to obtain vectors of the words to be recognized;
the named entity recognition type multitask recognition model performs recognition vector transformation on each word vector to be recognized to obtain a first vector corresponding to each word to be recognized and a second vector corresponding to each word to be recognized, the first vector is used for representing a semantic vector corresponding to the word to be recognized in a text obtained by taking the word to be recognized as a starting word in the text to be recognized, and the second vector is used for representing the semantic vector corresponding to the word to be recognized in the text obtained by taking the word to be recognized as a stopping word in the text to be recognized;
the named entity recognition type multitask recognition model enumerates and determines each word to be recognized based on the text to be recognized, determines a first vector corresponding to a starting word in each word to be recognized from a first vector corresponding to each word to be recognized, and determines a second vector corresponding to a terminating word in each word to be recognized from a second vector corresponding to each word to be recognized;
and the named entity recognition type multitask recognition model respectively carries out named entity type recognition on each word to be recognized on the basis of a first vector corresponding to a starting character in each word to be recognized and a second vector corresponding to a terminating character in each word to be recognized, so as to obtain a named entity recognition result corresponding to each word to be recognized.
2. The method according to claim 1, wherein after performing named entity type recognition on each word to be recognized based on a first vector corresponding to a starting word in each word to be recognized and a second vector corresponding to a terminating word in each word to be recognized, respectively, to obtain a named entity recognition result corresponding to each word to be recognized, the method further comprises:
carrying out entity mention identification on the basis of the text to be identified to obtain each entity mention;
performing entity recall from a preset knowledge base based on each entity mention to obtain a candidate entity set corresponding to each entity mention;
performing entity disambiguation on the candidate entity sets respectively corresponding to the entity mentions to obtain entities respectively corresponding to the entity mentions, and obtaining entity link identification results corresponding to the text to be identified on the basis of the entities respectively corresponding to the entity mentions;
and obtaining a target entity recognition result corresponding to the text to be recognized based on the entity link recognition result and the named entity recognition result.
3. The method according to claim 2, wherein the named entity recognition result comprises a named entity primary type and a named entity secondary type, and the entity link recognition result comprises an entity link primary type and an entity link secondary type;
the obtaining of the target entity recognition result corresponding to the text to be recognized based on the entity link recognition result and the named entity recognition result includes:
acquiring a named entity recognition result of a target to-be-recognized word in each to-be-recognized word and an entity link recognition result of a target entity in each entity mention respectively corresponding to the target to-be-recognized word, wherein the target to-be-recognized word and the target entity are the same entity;
matching a named entity primary type in a named entity recognition result of the target word to be recognized with an entity link primary type in an entity link recognition result of the target entity, and taking the entity link primary type and the entity link secondary type as a target entity recognition result corresponding to the target word to be recognized when the named entity primary type is matched with the entity link primary type;
and when the matching of the primary type of the named entity and the primary type of the entity link is not the same, taking the primary type of the named entity and the secondary type of the named entity as a target entity recognition result corresponding to the target word to be recognized.
4. The method according to claim 1, wherein performing recognition vector transformation on each vector of words to be recognized to obtain a first vector corresponding to each word to be recognized and a second vector corresponding to each word to be recognized comprises:
and acquiring trained identification vector transformation parameters, and performing identification vector transformation on each word vector to be identified by using the identification vector transformation parameters to obtain a first vector corresponding to each word to be identified and a second vector corresponding to each word to be identified.
5. The method of claim 1, wherein the named entity type multitasking identification model comprises a word vectorization network and a named entity type multitasking identification network;
the step of inputting the text to be recognized into the named entity type multi-task recognition model comprises the following steps:
inputting the text to be recognized into the word vectorization network, dividing the text to be recognized by the word vectorization network to obtain each word to be recognized, and vectorizing each word to be recognized to obtain each word vector to be recognized;
inputting each word vector to be identified into the named entity type multitask identification network, and inputting each word vector to be identified into each named entity type identification sub-network by the named entity type multitask identification network;
the named entity type recognition sub-network performs recognition vector transformation on each word to be recognized to obtain a first vector corresponding to each word to be recognized and a second vector corresponding to each word to be recognized, performs enumeration on the basis of the text to be recognized to determine each word to be recognized, determines a first vector corresponding to a starting word in each word to be recognized from the first vector corresponding to each word to be recognized, and determines a second vector corresponding to a terminating word in each word to be recognized from the second vector corresponding to each word to be recognized;
the named entity type recognition sub-network respectively performs named entity type recognition on each word to be recognized based on a first vector corresponding to a starting word in each word to be recognized and a second vector corresponding to a terminating word in each word to be recognized to obtain a sub-network named entity recognition result corresponding to each word to be recognized, and obtains a named entity recognition result corresponding to each word to be recognized based on the sub-network named entity recognition result corresponding to each word to be recognized.
6. The method of claim 1, further comprising:
inputting the text to be recognized into each named entity type single task recognition model;
the named entity type single task recognition model divides the text to be recognized into words to obtain words to be recognized, vectorizes the words to be recognized to obtain word vectors to be recognized, and performs recognition vector transformation on the word vectors to be recognized to obtain first vectors corresponding to the words to be recognized and second vectors corresponding to the words to be recognized;
the named entity type single task recognition model performs enumeration on the basis of the text to be recognized to determine each word to be recognized, determines a first vector corresponding to an initial word in each word to be recognized from a first vector corresponding to each word to be recognized, determines a second vector corresponding to a stop word in each word to be recognized from a second vector corresponding to each word to be recognized, performs named entity type single task recognition on each word to be recognized respectively on the basis of the first vector corresponding to the initial word in each word to be recognized and the second vector corresponding to the stop word in each word to be recognized, and outputs a single task recognition result corresponding to each word to be recognized respectively;
and determining the named entity recognition result corresponding to each word to be recognized based on the single task recognition result corresponding to each word to be recognized output by each named entity type single task recognition model.
7. The method of claim 6, wherein the named entity type single task recognition model comprises a primary entity type single task recognition model and a secondary entity type single task recognition model;
inputting the text to be recognized into each named entity type single task recognition model, wherein the steps comprise:
inputting the text to be recognized into each primary entity type single task recognition model;
the primary entity type single task recognition model divides the text to be recognized into words to obtain words to be recognized, vectorizes the words to be recognized to obtain word vectors to be recognized, and performs recognition vector transformation on the word vectors to be recognized to obtain first vectors corresponding to the words to be recognized and second vectors corresponding to the words to be recognized;
the primary entity type single task recognition model performs enumeration on the basis of the text to be recognized to determine each word to be recognized, determines a first vector corresponding to an initial word in each word to be recognized from a first vector corresponding to each word to be recognized, determines a second vector corresponding to a stop word in each word to be recognized from a second vector corresponding to each word to be recognized, and performs named entity primary type recognition on each word to be recognized respectively on the basis of the first vector corresponding to the initial word in each word to be recognized and the second vector corresponding to the stop word in each word to be recognized to obtain a named entity primary type recognition result corresponding to each word to be recognized;
acquiring each secondary entity type single task recognition model associated with the named entity primary type recognition result, inputting the text to be recognized into each secondary entity type single task recognition model for named entity secondary type recognition, and acquiring named entity secondary type recognition results corresponding to the words to be recognized respectively;
and obtaining the named entity recognition results corresponding to the words to be recognized respectively based on the named entity primary type recognition result and the named entity secondary type recognition result.
8. The method according to claim 6, wherein the training step of the named entity type single task recognition model comprises the steps of:
acquiring pre-training data, wherein the pre-training data comprises a pre-training text and pre-training type labels corresponding to named entities in the pre-training text, and the pre-training type labels are determined according to link texts of the named entities in the pre-training text;
inputting the pre-training data into an initial named entity type single task recognition model for pre-training to obtain a pre-training named entity type single task recognition model;
acquiring training data, wherein the training data comprises a training text and training type labels corresponding to named entities in the training text, and the training type labels are labeled in advance;
and inputting the training data into the pre-training named entity type single task recognition model for training to obtain the named entity type single task recognition model.
9. The method according to claim 1, wherein the obtaining the named entity recognition result corresponding to each word to be recognized based on the first vector corresponding to the start word in each word to be recognized and the second vector corresponding to the end word in each word to be recognized by performing named entity type recognition on each word to be recognized respectively comprises:
determining a current word to be recognized from each word to be recognized, and acquiring a current first vector corresponding to an initial word in the current word to be recognized and a current second vector corresponding to a final word in the current word to be recognized;
calculating the transposition of the current first vector to obtain a current transposition vector;
calculating the product of the current transposed vector and the current second vector to obtain the possibility of the type of the named entity, and determining the recognition result of the named entity corresponding to the current word to be recognized based on the possibility of the type of the named entity;
and traversing each word to be recognized to obtain a named entity recognition result corresponding to each word to be recognized.
10. The method according to claim 1, wherein after performing recognition vector transformation on each vector of words to be recognized to obtain a first vector corresponding to each word to be recognized and a second vector corresponding to each word to be recognized, the method further comprises:
acquiring position information of each word to be identified in the text to be identified, and coding the position information to obtain a position code corresponding to each word to be identified;
fusing the first vectors corresponding to the words to be identified with the position codes corresponding to the words to be identified respectively to obtain first target vectors corresponding to the words to be identified;
fusing the second vector corresponding to each word to be identified with the position code corresponding to each word to be identified respectively to obtain a second target vector corresponding to each word to be identified;
the method for recognizing the type of the named entity of each word to be recognized based on the first vector corresponding to the initial character in each word to be recognized and the second vector corresponding to the terminal character in each word to be recognized respectively obtains the recognition result of the named entity corresponding to each word to be recognized respectively, and comprises the following steps:
and respectively carrying out named entity type recognition on each word to be recognized based on a first target vector corresponding to the initial character in each word to be recognized and a second target vector corresponding to the terminal character in each word to be recognized, and obtaining a target named entity recognition result corresponding to each word to be recognized.
11. An apparatus for named entity recognition, the apparatus comprising:
the system comprises an acquisition module, a recognition module and a recognition module, wherein the acquisition module is used for acquiring a text to be recognized and inputting the text to be recognized into a named entity type multitask recognition model, and the named entity type multitask recognition model divides the text to be recognized into words to obtain each word to be recognized;
the vectorization module is used for vectorizing each word to be identified to obtain each word vector to be identified;
a transformation module, configured to perform, by the named entity recognition type multitask recognition model, recognition vector transformation on each vector of the words to be recognized to obtain a first vector corresponding to each word to be recognized and a second vector corresponding to each word to be recognized, where the first vector is used to represent a semantic vector corresponding to the word to be recognized in a text obtained by using the word to be recognized as a start word in the text to be recognized, and the second vector is used to represent a semantic vector corresponding to the word to be recognized in a text obtained by using the word to be recognized as a stop word in the text to be recognized;
a vector determination module, configured to perform enumeration on the named entity recognition type multitask recognition model based on the text to be recognized to determine each word to be recognized, determine a first vector corresponding to a starting word in each word to be recognized from a first vector corresponding to each word to be recognized, and determine a second vector corresponding to a terminating word in each word to be recognized from a second vector corresponding to each word to be recognized;
and the recognition module is used for the named entity recognition type multitask recognition model to respectively recognize the named entity types of the words to be recognized on the basis of the first vector corresponding to the initial character in the words to be recognized and the second vector corresponding to the terminal character in the words to be recognized, so as to obtain the named entity recognition results corresponding to the words to be recognized.
12. The apparatus of claim 11, further comprising:
the entity linking module is used for carrying out entity mention identification on the basis of the text to be identified to obtain each entity mention; performing entity recall from a preset knowledge base based on each entity mention to obtain a candidate entity set corresponding to each entity mention; performing entity disambiguation on the candidate entity sets respectively corresponding to the entity mentions to obtain entities respectively corresponding to the entity mentions, and obtaining entity link identification results corresponding to the text to be identified on the basis of the entities respectively corresponding to the entity mentions;
and the target result obtaining module is used for obtaining a target entity recognition result corresponding to the text to be recognized based on the entity link recognition result and the named entity recognition result.
13. The apparatus of claim 12, wherein the named entity recognition result comprises a named entity primary type and a named entity secondary type, and wherein the entity link recognition result comprises an entity link primary type and an entity link secondary type;
the target result obtaining module is further configured to obtain a named entity recognition result of a target to-be-recognized word in each to-be-recognized word and an entity link recognition result of a target entity in each entity mention respectively corresponding to the target to-be-recognized word, where the target to-be-recognized word and the target entity are the same entity; matching a named entity primary type in a named entity recognition result of the target word to be recognized with an entity link primary type in an entity link recognition result of the target entity, and taking the entity link primary type and the entity link secondary type as a target entity recognition result corresponding to the target word to be recognized when the named entity primary type is matched with the entity link primary type; and when the matching of the primary type of the named entity and the primary type of the entity link is not the same, taking the primary type of the named entity and the secondary type of the named entity as a target entity recognition result corresponding to the target word to be recognized.
14. The apparatus according to claim 11, wherein the transformation module is further configured to obtain trained recognition vector transformation parameters, and perform recognition vector transformation on the vectors of the words to be recognized by using the recognition vector transformation parameters to obtain a first vector corresponding to each word to be recognized and a second vector corresponding to each word to be recognized.
15. The apparatus of claim 11, wherein the named entity type multitasking recognition model comprises a word vectorization network and a named entity type multitasking recognition network; the device, still include:
the multitask identification module is used for inputting the text to be identified into the word vectorization network, the word vectorization network divides the text to be identified into words to obtain words to be identified, and vectorizes the words to be identified to obtain word vectors to be identified; inputting each word vector to be identified into the named entity type multitask identification network, and inputting each word vector to be identified into each named entity type identification sub-network by the named entity type multitask identification network; the named entity type recognition sub-network performs recognition vector transformation on each word to be recognized to obtain a first vector corresponding to each word to be recognized and a second vector corresponding to each word to be recognized, performs enumeration on the basis of the text to be recognized to determine each word to be recognized, determines a first vector corresponding to a starting word in each word to be recognized from the first vector corresponding to each word to be recognized, and determines a second vector corresponding to a terminating word in each word to be recognized from the second vector corresponding to each word to be recognized; the named entity type recognition sub-network respectively performs named entity type recognition on each word to be recognized based on a first vector corresponding to a starting word in each word to be recognized and a second vector corresponding to a terminating word in each word to be recognized to obtain a sub-network named entity recognition result corresponding to each word to be recognized, and obtains a named entity recognition result corresponding to each word to be recognized based on the sub-network named entity recognition result corresponding to each word to be recognized.
16. The apparatus of claim 11, further comprising:
the single task identification module is used for inputting the text to be identified into each named entity type single task identification model; the named entity type single task recognition model divides the text to be recognized into words to obtain words to be recognized, vectorizes the words to be recognized to obtain word vectors to be recognized, and performs recognition vector transformation on the word vectors to be recognized to obtain first vectors corresponding to the words to be recognized and second vectors corresponding to the words to be recognized; the named entity type single task recognition model performs enumeration on the basis of the text to be recognized to determine each word to be recognized, determines a first vector corresponding to an initial word in each word to be recognized from a first vector corresponding to each word to be recognized, determines a second vector corresponding to a stop word in each word to be recognized from a second vector corresponding to each word to be recognized, performs named entity type single task recognition on each word to be recognized respectively on the basis of the first vector corresponding to the initial word in each word to be recognized and the second vector corresponding to the stop word in each word to be recognized, and outputs a single task recognition result corresponding to each word to be recognized respectively; and determining the named entity recognition result corresponding to each word to be recognized based on the single task recognition result corresponding to each word to be recognized output by each named entity type single task recognition model.
17. The apparatus of claim 16, wherein the named entity type single task recognition model comprises a primary entity type single task recognition model and a secondary entity type single task recognition model;
the single task identification module is also used for inputting the text to be identified into each primary entity type single task identification model; the primary entity type single task recognition model divides the text to be recognized into words to obtain words to be recognized, vectorizes the words to be recognized to obtain word vectors to be recognized, and performs recognition vector transformation on the word vectors to be recognized to obtain first vectors corresponding to the words to be recognized and second vectors corresponding to the words to be recognized; the primary entity type single task recognition model performs enumeration on the basis of the text to be recognized to determine each word to be recognized, determines a first vector corresponding to an initial word in each word to be recognized from a first vector corresponding to each word to be recognized, determines a second vector corresponding to a stop word in each word to be recognized from a second vector corresponding to each word to be recognized, and performs named entity primary type recognition on each word to be recognized respectively on the basis of the first vector corresponding to the initial word in each word to be recognized and the second vector corresponding to the stop word in each word to be recognized to obtain a named entity primary type recognition result corresponding to each word to be recognized; acquiring each secondary entity type single task recognition model associated with the named entity primary type recognition result, inputting the text to be recognized into each secondary entity type single task recognition model for named entity secondary type recognition, and acquiring named entity secondary type recognition results corresponding to the words to be recognized respectively; and obtaining the named entity recognition results corresponding to the words to be recognized respectively based on the named entity primary type recognition result and the named entity secondary type recognition result.
18. The apparatus of claim 16, further comprising:
the training module is used for acquiring pre-training data, wherein the pre-training data comprises a pre-training text and pre-training type labels corresponding to named entities in the pre-training text, and the pre-training type labels are determined according to link texts of the named entities in the pre-training text; inputting the pre-training data into an initial named entity type single task recognition model for pre-training to obtain a pre-training named entity type single task recognition model; acquiring training data, wherein the training data comprises a training text and training type labels corresponding to named entities in the training text, and the training type labels are labeled in advance; and inputting the training data into the pre-training named entity type single task recognition model for training to obtain the named entity type single task recognition model.
19. The apparatus according to claim 11, wherein the recognition module is further configured to determine a current word to be recognized from the words to be recognized, and obtain a current first vector corresponding to a starting word in the current word to be recognized and a current second vector corresponding to a terminating word in the current word to be recognized; calculating the transposition of the current first vector to obtain a current transposition vector; calculating the product of the current transposed vector and the current second vector to obtain the possibility of the type of the named entity, and determining the recognition result of the named entity corresponding to the current word to be recognized based on the possibility of the type of the named entity; and traversing each word to be recognized to obtain a named entity recognition result corresponding to each word to be recognized.
20. The apparatus of claim 11, further comprising:
the position fusion module is used for acquiring position information of each word to be identified in the text to be identified, and coding the position information to obtain a position code corresponding to each word to be identified; fusing the first vectors corresponding to the words to be identified with the position codes corresponding to the words to be identified respectively to obtain first target vectors corresponding to the words to be identified; fusing the second vector corresponding to each word to be identified with the position code corresponding to each word to be identified respectively to obtain a second target vector corresponding to each word to be identified;
the recognition module is further used for respectively carrying out named entity type recognition on each word to be recognized based on a first target vector corresponding to a starting character in each word to be recognized and a second target vector corresponding to a terminating character in each word to be recognized, and obtaining a target named entity recognition result corresponding to each word to be recognized.
21. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor realizes the steps of the method of any one of claims 1 to 10 when executing the computer program.
22. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 10.
CN202111350041.XA 2021-11-15 2021-11-15 Named entity recognition method and device, computer equipment and storage medium Active CN113779202B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111350041.XA CN113779202B (en) 2021-11-15 2021-11-15 Named entity recognition method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111350041.XA CN113779202B (en) 2021-11-15 2021-11-15 Named entity recognition method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113779202A CN113779202A (en) 2021-12-10
CN113779202B true CN113779202B (en) 2022-02-08

Family

ID=78873906

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111350041.XA Active CN113779202B (en) 2021-11-15 2021-11-15 Named entity recognition method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113779202B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116757216B (en) * 2023-08-15 2023-11-07 之江实验室 Small sample entity identification method and device based on cluster description and computer equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109918506A (en) * 2019-03-07 2019-06-21 安徽省泰岳祥升软件有限公司 A kind of file classification method and device
CN111062215A (en) * 2019-12-10 2020-04-24 金蝶软件(中国)有限公司 Named entity recognition method and device based on semi-supervised learning training
CN112711948A (en) * 2020-12-22 2021-04-27 北京邮电大学 Named entity recognition method and device for Chinese sentences
CN112860855A (en) * 2021-02-04 2021-05-28 京东数字科技控股股份有限公司 Information extraction method and device and electronic equipment
CN113011186A (en) * 2021-01-25 2021-06-22 腾讯科技(深圳)有限公司 Named entity recognition method, device, equipment and computer readable storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109918506A (en) * 2019-03-07 2019-06-21 安徽省泰岳祥升软件有限公司 A kind of file classification method and device
CN111062215A (en) * 2019-12-10 2020-04-24 金蝶软件(中国)有限公司 Named entity recognition method and device based on semi-supervised learning training
CN112711948A (en) * 2020-12-22 2021-04-27 北京邮电大学 Named entity recognition method and device for Chinese sentences
CN113011186A (en) * 2021-01-25 2021-06-22 腾讯科技(深圳)有限公司 Named entity recognition method, device, equipment and computer readable storage medium
CN112860855A (en) * 2021-02-04 2021-05-28 京东数字科技控股股份有限公司 Information extraction method and device and electronic equipment

Also Published As

Publication number Publication date
CN113779202A (en) 2021-12-10

Similar Documents

Publication Publication Date Title
JP7302022B2 (en) A text classification method, apparatus, computer readable storage medium and text classification program.
CN111914568B (en) Method, device and equipment for generating text sentence and readable storage medium
CN110727779A (en) Question-answering method and system based on multi-model fusion
CN111046656B (en) Text processing method, text processing device, electronic equipment and readable storage medium
CN111460807A (en) Sequence labeling method and device, computer equipment and storage medium
CN110569332B (en) Sentence feature extraction processing method and device
CN111274829B (en) Sequence labeling method utilizing cross-language information
EP4113357A1 (en) Method and apparatus for recognizing entity, electronic device and storage medium
CN114298121A (en) Multi-mode-based text generation method, model training method and device
CN111274822A (en) Semantic matching method, device, equipment and storage medium
CN113657105A (en) Medical entity extraction method, device, equipment and medium based on vocabulary enhancement
CN112632258A (en) Text data processing method and device, computer equipment and storage medium
CN115062134A (en) Knowledge question-answering model training and knowledge question-answering method, device and computer equipment
CN113779202B (en) Named entity recognition method and device, computer equipment and storage medium
CN114925702A (en) Text similarity recognition method and device, electronic equipment and storage medium
CN113220854B (en) Intelligent dialogue method and device for machine reading and understanding
CN113536784A (en) Text processing method and device, computer equipment and storage medium
CN114398903B (en) Intention recognition method, device, electronic equipment and storage medium
CN114417891B (en) Reply statement determination method and device based on rough semantics and electronic equipment
CN114611529B (en) Intention recognition method and device, electronic equipment and storage medium
CN116414958A (en) Text corpus generation method and device, storage medium and electronic equipment
CN111339760A (en) Method and device for training lexical analysis model, electronic equipment and storage medium
CN114398482A (en) Dictionary construction method and device, electronic equipment and storage medium
CN112749251B (en) Text processing method, device, computer equipment and storage medium
CN114548314A (en) Text matching method and device, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant