CN113761917A - Named entity identification method and device - Google Patents

Named entity identification method and device Download PDF

Info

Publication number
CN113761917A
CN113761917A CN202010496481.5A CN202010496481A CN113761917A CN 113761917 A CN113761917 A CN 113761917A CN 202010496481 A CN202010496481 A CN 202010496481A CN 113761917 A CN113761917 A CN 113761917A
Authority
CN
China
Prior art keywords
character
text
graph
characters
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.)
Pending
Application number
CN202010496481.5A
Other languages
Chinese (zh)
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.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN202010496481.5A priority Critical patent/CN113761917A/en
Publication of CN113761917A publication Critical patent/CN113761917A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/126Character encoding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/049Temporal neural networks, e.g. delay elements, oscillating neurons or pulsed inputs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • General Engineering & Computer Science (AREA)
  • Biomedical Technology (AREA)
  • Evolutionary Computation (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Biophysics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and a device for identifying a named entity. Wherein, the method comprises the following steps: acquiring an association relation between a vector corresponding to a character in a text and each character; coding a vector of a first character and a vector of a second character at least once to obtain a coding result corresponding to the first character, wherein the first character is any one character in the text, and the second character is other characters in the text which have an association relation with the first character; and decoding the encoding result of the first character to obtain an identifier corresponding to the first character, wherein the identifier is used for indicating whether the first character is an entity in the text. The invention solves the technical problem that the entity recognition of a plurality of characters can not be carried out in parallel because the named entity recognition is carried out based on the time sequence of the characters in the prior art.

Description

Named entity identification method and device
Technical Field
The invention relates to the field of text processing, in particular to a method and a device for identifying a named entity.
Background
When various knowledge bases or various top-level services (such as conversation and search) are constructed, named entity recognition needs to be carried out on the text. At present, named entity recognition is generally carried out based on a supervised learning model, a named entity recognition model is learned from manually labeled training data, and then the model is used for carrying out named entity recognition on texts (called test data) of an actual scene.
A typical supervised model takes the input text as a linear chain time series, and the model structure is generally composed of an encoder and a decoder, the encoder being implemented by recurrent neural network elements (RNN, LSTM, GRU, etc.). Due to the time sequence of the input of the encoder, the output of one position needs to be used as the input when the output of the previous position is calculated every time, so that the model cannot realize parallel calculation, and the recognition needs to be carried out in sequence according to the sequence of characters in the text when the entity is recognized, so that the problems of long training time and long decoding time exist in practical application, and the problem of low efficiency of named entity recognition is caused.
Aiming at the problem that the named entity recognition in the prior art is based on the time sequence of characters, so that the entity recognition of a plurality of characters can not be carried out in parallel, an effective solution is not provided at present.
Disclosure of Invention
The embodiment of the invention provides a method and a device for identifying a named entity, which at least solve the technical problem that entity identification cannot be performed on a plurality of characters in parallel because the named entity identification is performed based on the time sequence of the characters in the prior art.
According to an aspect of the embodiments of the present invention, there is provided a method for identifying a named entity, including: acquiring an association relation between a vector corresponding to a character in a text and each character; coding a vector of a first character and a vector of a second character at least once to obtain a coding result corresponding to the first character, wherein the first character is any one character in the text, and the second character is other characters in the text which have an association relation with the first character; and decoding the encoding result of the first character to obtain an identifier corresponding to the first character, wherein the identifier is used for indicating whether the first character is an entity in the text.
According to another aspect of the embodiments of the present invention, there is also provided a method for identifying a named entity, including: acquiring an association relation between an initial vector corresponding to a character in a text and each character; determining an input graph corresponding to the text according to the initial vectors corresponding to the characters and the association relation, wherein nodes of the input graph represent the initial vectors corresponding to the characters, and directed edges between the nodes are determined according to the sequence of the characters in the text; carrying out graph coding on characters in the text through a graph neural network model based on the input graph to obtain a character coding result; and decoding the coded result of the character to obtain an identifier corresponding to the character, wherein the identifier is used for indicating whether the character is an entity in the text.
According to another aspect of the embodiments of the present invention, there is also provided a method for identifying a named entity, including: acquiring a sentence in a text to be recognized, wherein the sentence is composed of a plurality of characters; carrying out graph modeling on the sentence to obtain a graph structure of the sentence, wherein the graph structure is a structure for modeling the sentence into a time sequence; coding the graph structure of the sentence by using a graph neural network to obtain a coding result of each word in the sentence; and decoding the coding result of each word to obtain the recognition result of the named entity in the sentence, wherein the recognition result of the named entity is used for representing whether the character is the entity in the sentence or not.
According to another aspect of the embodiments of the present invention, there is also provided a method for identifying a named entity, including: acquiring an association relation between an initial vector corresponding to a character in a text and each character; determining an input graph corresponding to the text according to the initial vectors corresponding to the characters and the association relation, wherein nodes of the input graph represent the initial vectors corresponding to the characters, and directed edges between the nodes are determined according to the sequence of the characters in the text; carrying out graph coding on a plurality of characters in the text in parallel through a graph neural network model based on the input graph to obtain a character coding result; and decoding the coded result of the character to obtain an identifier corresponding to the character, wherein the identifier is used for indicating whether the character is an entity in the text.
According to another aspect of the embodiments of the present invention, there is also provided a method for identifying a named entity, including: receiving an input comment text, and acquiring a vector corresponding to a character in the comment text and an association relation between each character; coding a vector of a first character and a vector of a second character at least once to obtain a coding result corresponding to the first character, wherein the first character is any one character in the comment text, and the second character is other characters in the comment text, which have an association relation with the first character; decoding the encoding result of the first character to obtain an identifier corresponding to the first character, wherein the identifier is used for indicating whether the first character is an entity in the comment text; and extracting entities from the comment text according to the identification, and determining the extracted entities as comment subjects of the comment text.
According to another aspect of the embodiments of the present invention, there is also provided an apparatus for identifying a named entity, including: the acquisition module is used for acquiring the association relationship between the vector corresponding to the characters in the text and each character; the encoding module is used for encoding the vector of the first character and the vector of the second character at least once to obtain an encoding result corresponding to the first character, wherein the first character is any character in the text, and the second character is other characters in the text which have an association relationship with the first character; and the decoding module is used for decoding the encoding result of the first character to obtain an identifier corresponding to the first character, wherein the identifier is used for indicating whether the first character is an entity in the text.
According to another aspect of the embodiments of the present invention, there is also provided a non-volatile storage medium, where the non-volatile storage medium includes a stored program, and the following steps are performed by a device in which the non-volatile storage medium is controlled when the program runs: acquiring an association relation between a vector corresponding to a character in a text and each character; coding a vector of a first character and a vector of a second character at least once to obtain a coding result corresponding to the first character, wherein the first character is any one character in the text, and the second character is other characters in the text which have an association relation with the first character; and decoding the encoding result of the first character to obtain an identifier corresponding to the first character, wherein the identifier is used for indicating whether the first character is an entity in the text.
According to another aspect of the embodiments of the present invention, there is also provided a processor, configured to execute a program, where the program executes the following steps: acquiring an association relation between a vector corresponding to a character in a text and each character; coding a vector of a first character and a vector of a second character at least once to obtain a coding result corresponding to the first character, wherein the first character is any one character in the text, and the second character is other characters in the text which have an association relation with the first character; and decoding the encoding result of the first character to obtain an identifier corresponding to the first character, wherein the identifier is used for indicating whether the first character is an entity in the text.
In the embodiment of the invention, the incidence relation between the vector corresponding to the character in the text and each character is obtained; coding a vector of a first character and a vector of a second character at least once to obtain a coding result corresponding to the first character, wherein the first character is any one character in the text, and the second character is other characters in the text which have an association relation with the first character; and decoding the encoding result of the first character to obtain an identifier corresponding to the first character, wherein the identifier is used for indicating whether the first character is an entity in the text. According to the scheme, the vector of any character in the text and the vectors of other characters related to the character are coded to obtain the coding result of the character, and the process only depends on the initial vector of each character in the text and the result of the last coding, but does not depend on the coding result of the current coding, so that a plurality of characters in the text can be coded in parallel, the coding efficiency of the character can be improved, and the entity recognition efficiency of the character can be improved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
FIG. 1 illustrates a block diagram of a hardware architecture of a computing device for implementing a method for identifying a named entity;
fig. 2 is a flowchart of a method for identifying a named entity according to embodiment 1 of the present application;
FIG. 3 is a schematic diagram of a model for implementing named entity recognition based on a recurrent neural network;
FIG. 4 is a schematic diagram of the process by which the recurrent neural network of FIG. 3 implements named entity recognition;
FIG. 5 is a schematic representation of an encoding according to embodiment 1 of the present application;
FIG. 6 is a schematic diagram of an input diagram according to embodiment 1 of the present application;
fig. 7 is a schematic diagram of multiple-time encoding of an input map according to embodiment 1 of the present application;
FIG. 8 is a flowchart of a method for identifying a named entity according to embodiment 2 of the present application;
FIG. 9 is a schematic diagram of a named entity recognition apparatus according to embodiment 3 of the present application;
FIG. 10 is a schematic diagram of a named entity recognition apparatus according to embodiment 4 of the present application; and
FIG. 11 is a block diagram of a computing device according to embodiment 5 of the present application;
FIG. 12 is a flowchart of a method for identifying a named entity according to embodiment 7 of the present application;
FIG. 13 is a schematic diagram of a named entity recognition apparatus according to embodiment 8 of the present application;
FIG. 14 is a flowchart of a method for identifying a named entity according to embodiment 9 of the present application;
fig. 15 is a schematic diagram of a named entity recognition apparatus according to embodiment 10 of the present application; and
fig. 16 is a flowchart of a method for identifying a named entity according to embodiment 11 of the present application.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
First, some terms or terms appearing in the description of the embodiments of the present application are applicable to the following explanations:
naming an entity: words having an actual meaning such as a person's name, organization's name, place's name, and all other entities identified by name.
Named entity recognition: and through an automatic method, the computer automatically identifies the named entities in the text.
The following drawings: a data structure for modeling a set of objects (nodes) and their relationships (edges).
Graph neural network: the coding of the graph is realized based on a deep learning method, and the vector of each node in the learning graph represents a recurrent neural network: and coding the data structure of the time series based on a deep learning method.
Example 1
There is also provided, in accordance with an embodiment of the present invention, an embodiment of a method for named entity recognition, in which the steps illustrated in the flowchart of the figure may be performed in a computer system such as a set of computer-executable instructions, and where a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than here.
The method provided by the first embodiment of the present application may be executed in a mobile terminal, a computing device, or a similar computing device. Fig. 1 illustrates a block diagram of a hardware architecture of a computing device for implementing a method for identifying a named entity. As shown in fig. 1, computing device 10 may include one or more (shown as 102a, 102b, … …, 102 n) processors 102 (processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission module 106 for communication functions. Besides, the method can also comprise the following steps: a display, an input/output interface (I/O interface), a Universal Serial Bus (USB) port (which may be included as one of the ports of the I/O interface), a network interface, a power source, and/or a camera. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration and is not intended to limit the structure of the electronic device. For example, computing device 10 may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
It should be noted that the one or more processors 102 and/or other data processing circuitry described above may be referred to generally herein as "data processing circuitry". The data processing circuitry may be embodied in whole or in part in software, hardware, firmware, or any combination thereof. Further, the data processing circuitry may be a single, stand-alone processing module, or incorporated in whole or in part into any of the other elements in computing device 10. As referred to in the embodiments of the application, the data processing circuit acts as a processor control (e.g. selection of a variable resistance termination path connected to the interface).
The memory 104 may be used to store software programs and modules of application software, such as program instructions/data storage devices corresponding to the named entity identification method in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by executing the software programs and modules stored in the memory 104, that is, implementing the above-mentioned named entity identification method of the application program. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, memory 104 may further include memory located remotely from processor 102, which may be connected to computing device 10 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission module 106 is used to receive or transmit data via a network. Specific examples of such networks may include wireless networks provided by a communications provider of computing device 10. In one example, the transmission module 106 includes a Network adapter (NIC) that can be connected to other Network devices through a base station to communicate with the internet. In one example, the transmission module 106 may be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
The display may be, for example, a touch screen type Liquid Crystal Display (LCD) that may enable a user to interact with a user interface of the computing device 10 (or mobile device).
It should be noted here that in some alternative embodiments, the computing device shown in fig. 1 described above may include hardware elements (including circuitry), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware and software elements. It should be noted that FIG. 1 is only one example of a particular specific example and is intended to illustrate the types of components that may be present in a computing device as described above.
Under the above operating environment, the present application provides a named entity identification method as shown in fig. 2. Fig. 2 is a flowchart of a method for identifying a named entity according to embodiment 1 of the present application.
Step S21, obtaining the association relationship between the vector corresponding to the character in the text and each character.
Specifically, the text is a text to be subjected to named entity recognition, and may be a sentence in the text to be subjected to named entity recognition. In an alternative embodiment, in order to analyze the comment of the commodity, a comment text of the commodity can be collected and subjected to entity recognition, so that an object in question by the comment is determined. Entity identification can also be applied in other top-level services, which are not described herein.
The characters may be chinese characters, korean characters, or english words, etc., and the following embodiments are described by taking chinese characters as an example. The vector corresponding to the character can be a vector corresponding to the character obtained in a word2vec mode or the like, the association relationship between each character can be embodied by the arrangement sequence of the characters in the text, and a certain association relationship exists between adjacent characters.
In an alternative embodiment, the text "man basket first wars Tuniss" is taken as an example, wherein the character "basket" has an association relationship with "man" and "head".
Step S23, encoding the vector of the first character and the vector of the second character at least once to obtain an encoding result corresponding to the first character, where the first character is any one character in the text, and the second character is another character in the text that has an association relationship with the first character.
The first character is any character in the text, the second character has an association relation with the first character, and the text "men basket first warnius" is taken as an example, wherein when the first character is "basket", the second character is "men" and "head".
In the above scheme, the encoding result of the first character in the encoding is determined by encoding the vector of the first character and the vector of the second character, and in this process, the encoding process may be performed on all characters in the text at the same time, that is, each character in the text is encoded in parallel.
It is worth noting that when the first character is coded, the vector of the first character and the vector of the second character are used, and both the vector of the first character and the vector of the second character can be obtained before the coding, and do not depend on the result of the coding, so that serial coding in sequence according to the sequence of characters in the text is not needed, and parallel coding of all characters in the text can be realized.
In an alternative embodiment, if each character in the text is encoded once, the vector of the first character and the vector of the second character used may be vectors obtained by word2vec and the like, and if the nth encoding is performed on each character in the text, the vector of the first character and the vector of the second character used when the nth (N ≦ N) encoding is performed are encoding results obtained by the nth-1 encoding.
Step S25, decoding the encoding result of the first character to obtain an identifier corresponding to the first character, where the identifier is used to indicate whether the first character is an entity in the text.
Specifically, the identifier may indicate whether the first character is an entity in the text, and further, in the case that the character is an entity, may indicate which step (start, inside, end) the character is in the entity, and may identify the type (name, time, etc.) of the entity represented by the character.
In an alternative embodiment, after each character in the text is encoded and decoded, an identifier corresponding to each character is obtained, the character is labeled according to the obtained identifier, the identifier is composed of a prefix + type, a prefix B indicates that the character is the beginning of an entity, a prefix I indicates that the character is inside an entity, a prefix E indicates that the character is the end of an entity, and a prefix S indicates that the entity is a single word. The types are defined by different data sets, and can be TIME (TIME), Location (LOC), person name (PER), Organization (ORG), or other self-defined types, and each type set must contain other types (O) to represent words that are not classified into a predefined entity type set, such as the sentence "man basket first fighting Tunnis" is converted into a tag sequence "B-PER E-PER O B-LOC I-LOC E-LOC".
It should be noted here that the method for entity identification in the above embodiment of the present application may be applied to identification of information related to e-commerce products, for example, identification of names of goods, names of people in entertainment, names of places, or content of episodes, and the scheme provided in the embodiment of the present application may be used to encode vectors of any character and vectors of other characters related to any character in the information related to e-commerce products to obtain an encoded result of any character.
Fig. 3 is a schematic diagram of a model for implementing named entity recognition based on a recurrent neural network, and in conjunction with fig. 3, for each input sentence, firstly, a time series modeling is performed, that is, the sentence is modeled as a time series structure, and then, the time series is encoded by using the recurrent neural network, a vector representation of each word (word) in the sentence can be obtained through the recurrent neural network, and the vector is input to a decoder, so that a corresponding output can be obtained.
As can be seen from fig. 3, the output of each position of the recurrent neural network depends on the input of the current position and the output of the last position. When the recurrent neural network is LSTM, the process can be represented by FIG. 4, Ct=zf⊙Ct-1+zi⊙z,ht=zo⊙tanh(Ct),Yt=σ(W′ht)>Wherein h ist-1Hidden layer output, x, representing the last positiontInput representing current position, first using current input x of LSTMtAnd h passed by the last statet-1The splicing training obtains four states z, zf、zi、zoThen, the four states are used for calculating the hidden layer output h of the current positiontAnd current position output yt. Since this configuration cannot be parallelized, it is impossible to achieve an acceleration effect by enlarging the scale of the training machine.
Although the method of replacing the cyclic neural network by the convolutional neural network can perform parallel processing, the convolutional neural network has weak capability of extracting local semantic information and can damage the final entity identification effect, and the scheme provided by the embodiment of the application can solve the problem that the named entity identification model is difficult to parallelize and simultaneously ensures the identification effect.
The embodiment of the application obtains the association relationship between the vector corresponding to the character in the text and each character; coding a vector of a first character and a vector of a second character at least once to obtain a coding result corresponding to the first character, wherein the first character is any one character in the text, and the second character is other characters in the text which have an association relation with the first character; and decoding the encoding result of the first character to obtain an identifier corresponding to the first character, wherein the identifier is used for indicating whether the first character is an entity in the text. According to the scheme, the vector of any character in the text and the vectors of other characters related to the character are coded to obtain the coding result of the character, and the process only depends on the initial vector of each character in the text and the result of the last coding, but does not depend on the coding result of the current coding, so that a plurality of characters in the text can be coded in parallel, the coding efficiency of the character can be improved, and the entity recognition efficiency of the character can be improved.
As an alternative embodiment, obtaining an association relationship between a vector corresponding to a character in a text and each character includes: acquiring an initial vector of a character; and determining the association relation between each character according to the sequence of the characters in the text.
Specifically, the initial vector of the character refers to a vector corresponding to the character itself, that is, a vector independent of other characters. And determining characters with adjacent relations according to the sequence of the characters in the text, and determining that the characters with the adjacent relations have an association relation.
In an alternative embodiment, the initial vector for each character in the text may be obtained in parallel, since the initial vector for a character is obtained independent of the vectors for other characters.
As an optional embodiment, after obtaining the association relationship between the vector corresponding to the character in the text and each character, the method further includes: acquiring an input graph corresponding to a text, wherein the input graph represents a graph used for being input to an encoding layer for encoding, and the acquiring of the input graph corresponding to the text comprises the following steps: determining characters in a text as nodes of an input graph, wherein the characters corresponding to each node are different; directed edges between the nodes are constructed, wherein the directed edges point from the node of the previous character to the node of the next character.
In the above steps, taking a text as an example, determining characters in the text as nodes of the input graph. It should be noted that the corresponding characters of each node are different, that is, when a plurality of identical characters are included in one text, only one node is created for the character. The directional edge is a change with a direction for connecting nodes, and the directional property of the directional edge can be determined according to the sequence of characters in the text.
Fig. 5 is a schematic diagram of a code according to embodiment 1 of the present application, an input graph is shown on the left side of fig. 5, and as shown in fig. 5, for an example of a text "lie in the united kingdom", the text is graph-modeled to construct six nodes respectively representing characters "lie", "country", "flat", "visit", and "English", and directional edges between the nodes are determined according to an order of the characters in the text, that is, "lie" points to "country", "country" points to "flat", "flat" points to "visit", "visit" points to "visit", and "visit" points to "English", and "English" points to "country", so as to obtain the input graph shown in fig. 3. The above scheme models sentences as a graph rather than a time series, thereby enabling parallel encoding of multiple characters.
As an alternative embodiment, encoding the vector of the first character and the vector of the second character at least once to obtain an encoding result corresponding to the first character includes: and inputting the input graph into a graph neural network model, and encoding the first character at least once through the graph neural network model.
Specifically, a Graph Neural Network Model (GNN) maps nodes in an input Graph to an m-dimensional euclidean space through a function, and can directly process a plurality of applicable types of graphs, such as an acyclic Graph, a cyclic Graph, a directed Graph, an undirected Graph, and the like. The neural network model of the graph can be any one or more of the following combinations: graph attention mechanism, graph generation network, and graph spatio-temporal network. The method and the device use the graph neural network structure to replace the original recurrent neural network as the coding layer, achieve the effect similar to the mainstream model, and provide possibility for the parallel computation of the model, thereby achieving the purpose of reducing the training and decoding time of the model.
The input graph is graph-coded, and as shown in the right side of fig. 5, each node in an original network (the input graph on the left side of fig. 5 in this example) is coded (Encode nodes), and is mapped in a vector space (embedding space), so as to obtain a vector representation corresponding to each node.
As an alternative embodiment, inputting the input diagram into the neural network model, and encoding the first character at least once through the neural network model, includes: acquiring preset encoding times; inputting an input graph into a graph neural network model, coding a first character through the graph neural network model to obtain an intermediate coding result, and judging whether the coded times reach preset coding times; and if the coded times reach the preset coding times, determining that the intermediate coding result is the coding result of the first character, and if the coded times do not reach the preset coding times, continuously coding the input graph through the graph neural network model.
Specifically, the number of encoding times may be a designated number, and in an alternative embodiment, the preset number of encoding times may be set to four. After each coding, whether the preset coding times are reached is determined according to the current coding times, so that whether the coding is continued or the coding result is directly output is determined.
Taking the preset encoding times as an example, after the first to third encoding is finished, the encoding times reach the preset encoding times, so that the encoding is continued, and after the fourth encoding is finished, the encoding times reach the preset encoding times, so that the encoding of the text is finished, the fourth intermediate encoding result is output to a decoder as an encoding result of each character, and the decoder decodes the encoding result to perform entity identification on the text.
As an alternative embodiment, when the first character is encoded for the first time, the vector of the first character is an initial vector corresponding to the first character, the vector of the second character is an initial vector corresponding to the second character, and the initial vector is used to represent a vector corresponding to the character itself.
In the above scheme, when the first character is encoded for the first time, an initial vector of each character in the text is used for encoding.
Fig. 6 is a schematic diagram of an input graph according to embodiment 1 of the present application, and as shown in fig. 6, when encoding is performed for the first time, an initial vector is first given to each node, that is, an initial vector is given to each text amplitude, and this initial vector may be Word2vec corresponding to a character represented by the node, or may be other vectors. And then, respectively calculating the graph codes of each point by using a graph neural network model, namely realizing the coding of the characters corresponding to each point. For example, in FIG. 6, the A node and the B, C, D node are adjacent, then the graph encoding vector of the A node should be calculated from the initial vector of the A, B, C, D node. The principle is the same for other nodes.
The characters in the text can be coded by independently coding once, so that the entity recognition of the text is realized, but when the characters are coded once, the coding result of each character only carries the information of the adjacent character, and the information of the character farther away is difficult to carry, so that the accuracy of the final entity recognition result is not high. In order to enable each node to carry information of other nodes which are farther away, encoding can be carried out for multiple times, and therefore accuracy of entity identification is improved.
As an alternative embodiment, the input graph continues to be encoded by the graph neural network model, including: re-determining a vector corresponding to the first character and a vector corresponding to the second character, wherein the intermediate coding result obtained by coding the first character last time is determined as the vector corresponding to the first character during the coding, and the intermediate coding result obtained by coding the second character last time is determined as the vector corresponding to the second character during the coding; and coding the first character based on the vector of the redetermined first character and the vector of the redetermined second character to obtain an intermediate coding result of the first character during the coding.
In the above scheme, if the first character needs to be encoded continuously, the intermediate encoding result obtained in the last encoding may be used as the input of the encoding to update the vector of the first character and the vector of the second character, and the updated vectors are used for encoding again.
FIG. 7 is a schematic diagram of multiple times of encoding an input graph according to embodiment 1 of the present application, and is combined with FIG. 7 if it is required to be further separated from node AWhen the far node information is encoded to A, the encoding operation is repeated, that is, the first sub-picture encoding vector of A is obtained by the initial vector calculation of A, B, C, D, and when the encoding operation is repeated, the second sub-picture encoding vector of A is obtained by the first sub-picture encoding vector of A, B, C, D, since the first sub-picture encoding vector of C contains E, F information, the second sub-picture encoding vector of A also contains E, F information. The process of calculating the code follows the following formula, where t is used to represent the current code as the t-th code, H is used to represent the hidden layer output of the last code,
Figure BDA0002523058860000111
an input vector for indicating the node v at the t-th encoding, <' > for indicating a dot product,
Figure BDA0002523058860000112
for indicating an Update Gate (Update Gate),
Figure BDA0002523058860000113
for indicating a Reset Gate,
Figure BDA0002523058860000114
output for representing the t-th encoding:
Figure BDA0002523058860000115
Figure BDA0002523058860000116
Figure BDA0002523058860000117
Figure BDA0002523058860000118
Figure BDA0002523058860000119
Figure BDA00025230588600001110
since the graph encoding of each node depends only on the result of the last encoding, the computation of each point is independent and can be parallel.
As an alternative embodiment, decoding the encoding result of the first character to obtain an identifier corresponding to the first character includes: and carrying out conditional random field decoding on the encoding result of the first character to obtain the identifier corresponding to the first character.
Specifically, a Conditional Random Field (CRF) is a discriminative probability model, which is a kind of random field, and uses a conditional probability distribution model P (Y | X) to represent a markov random field of another set of output random variables Y given a set of input random variables X, that is, the CRF is characterized in that it is assumed that the output random field variables constitute the markov random field.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a non-volatile storage medium (such as ROM/RAM, magnetic disk, optical disk), and includes instructions for enabling a terminal device (which may be a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
Example 2
According to an embodiment of the present invention, there is also provided a method for identifying a named entity, and fig. 8 is a flowchart of a method for identifying a named entity according to embodiment 2 of the present application, and as shown in fig. 8, the method includes:
step S81, obtaining an association relationship between an initial vector corresponding to a character in the text and each character.
Specifically, the text is a text to be subjected to named entity recognition, and may be a sentence in the text to be subjected to entity recognition. In an alternative embodiment, in order to analyze the comment of the commodity, a comment text of the commodity can be collected and subjected to entity recognition, so that an object in question by the comment is determined. Entity identification can also be applied in other top-level services, which are not described herein.
The vector corresponding to the character can be a vector corresponding to the character obtained in a word2vec mode or the like, the association relationship between each character can be embodied by the arrangement sequence of the characters in the text, and a certain association relationship exists between adjacent characters.
In an alternative embodiment, the text "man basket first wars Tuniss" is taken as an example, wherein the character "basket" has an association relationship with "man" and "head".
And step S83, determining an input graph corresponding to the text according to the initial vectors corresponding to the characters and the association relation, wherein the nodes of the input graph represent the initial vectors corresponding to the characters, and the directed edges between the nodes are determined according to the sequence of the characters in the text.
In the above steps, taking a text as an example, determining characters in the text as nodes of the input graph. It should be noted that the corresponding characters of each node are different, that is, when a plurality of identical characters are included in one text, only one node is created for the character. The directional edge is a change with a direction for connecting nodes, and the directional property of the directional edge can be determined according to the sequence of characters in the text.
Fig. 5 is a schematic diagram of an input graph according to embodiment 1 of the present application, and in combination with fig. 5, for an example of a text "lie in the flat to visit uk", six nodes are constructed, which respectively represent characters "lie", "country", "flat", "visit", and "english", and directional edges between the nodes are determined according to an order of the characters in the text, that is, "lie" points to "country", "country" points to "flat", "flat" points to "visit", "visit" points to "visit", and "visit" points to "english", and "english" points to "country", so as to obtain the input graph shown in fig. 3. The above scheme models sentences as a graph rather than a time series, thereby enabling parallel encoding of multiple characters.
And step S85, carrying out graph coding on characters in the text through a graph neural network model based on the input graph to obtain a character coding result.
Specifically, a Graph Neural Network Model (GNN) maps nodes in an input Graph to an m-dimensional euclidean space through a function, and can be directly based on numerous types of graphs for Graph coding, such as an acyclic Graph, a cyclic Graph, a directed Graph, an undirected Graph, and the like. The neural network model of the graph can be any one or more of the following combinations: graph attention mechanism, graph generation network, and graph spatio-temporal network. The method and the device use the graph neural network structure to replace the original recurrent neural network as the coding layer, achieve the effect similar to the mainstream model, and provide possibility for the parallel computation of the model, thereby achieving the purpose of reducing the training and decoding time of the model.
And step S87, decoding the coded result of the character to obtain an identifier corresponding to the character, wherein the identifier is used for indicating whether the character is an entity in the text.
Specifically, the identifier may indicate whether the first character is an entity in the text, and further, in the case that the character is an entity, may indicate which step (start, inside, end) the character is in the entity, and may identify the type (name, time, etc.) of the entity represented by the character.
The method and the device use the graph neural network structure to replace the original recurrent neural network as the coding layer, achieve the effect similar to the mainstream model, and provide possibility for the parallel computation of the model, thereby achieving the purpose of reducing the training and decoding time of the model.
As an alternative embodiment, the graph coding of the characters in the text through the graph neural network model based on the input graph to obtain the coding result of the characters includes: and carrying out parallel coding on a plurality of characters in the text through a graph neural network model based on the input graph to obtain a character coding result.
Since the input graph corresponding to the text is encoded by using the graph neural network structure, the effect of encoding can be achieved, and therefore, in order to improve the encoding efficiency, a plurality of characters in the text can be encoded in parallel by using the graph neural network model based on the input graph, and the encoding result of the characters can be obtained.
As an alternative embodiment, the parallel encoding of multiple characters in a text through a graph neural network model based on an input graph to obtain an encoding result of the characters includes: carrying out primary parallel coding on a plurality of characters in a text through a graph neural network model based on an input graph to obtain a first coding result of the characters; updating the input graph according to the first coding result to obtain an updated input graph; and carrying out parallel coding on a plurality of characters in the text through a graph neural network model based on the updated input graph to obtain a second coding result of the characters.
In the above scheme, if the preset number of times of encoding is two, the second encoding result may be used as a final encoding result, and if the preset number of times of encoding is greater than two, the vector of the character needs to be updated in the same manner to continue encoding.
With reference to fig. 6, when encoding for the first time, an initial vector is first given to each node, that is, an initial vector is given to each text amplitude, and the initial vector may be Word2vec corresponding to the character represented by the node, or may be other vectors. And then, respectively calculating the graph codes of each point by using a graph neural network model, namely realizing the coding of the characters corresponding to each point. For example, in FIG. 6, the A node and the B, C, D node are adjacent, then the graph encoding vector of the A node should be calculated from the initial vector of the A, B, C, D node. The principle is the same for other nodes.
Referring to fig. 7 again, if it is required to encode the node information farther away from the node a into a, the encoding operation is repeated, that is, the first sub-picture encoding vector of a is calculated from the A, B, C, D initial vector, and when the encoding operation is repeated, the second sub-picture encoding vector of a is calculated by using the A, B, C, D first sub-picture encoding vector, and since the first sub-picture encoding vector of C contains E, F information, the second sub-picture encoding vector of a also contains E, F information.
As an alternative embodiment, updating the input graph according to the first encoding result to obtain an updated input graph includes: and keeping the directed edges in the input graph, and updating the nodes in the input graph by using the first coding result to obtain an updated input graph.
Example 3
According to an embodiment of the present invention, there is further provided a named entity recognition apparatus for implementing the named entity recognition method in embodiment 1, and fig. 9 is a schematic diagram of a named entity recognition apparatus according to embodiment 3 of the present application, as shown in fig. 9, the apparatus 900 includes:
an obtaining module 902, configured to obtain a vector corresponding to a character in a text and an association relationship between each character.
The encoding module 904 is configured to encode a vector of a first character and a vector of a second character at least once to obtain an encoding result corresponding to the first character, where the first character is any one character in the text, and the second character is another character in the text that has an association relationship with the first character.
The decoding module 906 is configured to decode an encoding result of the first character to obtain an identifier corresponding to the first character, where the identifier is used to indicate whether the first character is an entity in the text.
It should be noted here that the acquiring module 902, the encoding module 904, and the decoding module 906 correspond to steps S21 to S25 in embodiment 1, and the three modules are the same as the corresponding steps in the implementation example and application scenario, but are not limited to the disclosure in the first embodiment. It should be noted that the modules described above as part of the apparatus may be run in the computing device 10 provided in the first embodiment.
As an alternative embodiment, the obtaining module includes: the obtaining submodule is used for obtaining an initial vector of the character; and the first determining sub-module is used for determining the association relation between each character according to the sequence of the characters in the text.
As an alternative embodiment, the apparatus further comprises: an input graph obtaining module, configured to obtain an input graph corresponding to a text after obtaining an association relationship between a vector corresponding to a character in the text and each character, where the input graph represents a graph input to an encoding layer for encoding, and the input graph obtaining module includes: the second determining submodule is used for determining characters in the text as nodes of the input graph, wherein the characters corresponding to each node are different; and the construction submodule is used for constructing directed edges between the nodes, wherein the directed edges point to the nodes of the next character from the nodes of the previous character.
As an alternative embodiment, the encoding module comprises: and the encoding submodule is used for inputting the input diagram into the diagram neural network model and encoding the first character at least once through the diagram neural network model.
As an alternative embodiment, the encoding submodule includes: the device comprises an acquisition unit, a coding unit and a coding unit, wherein the acquisition unit is used for acquiring preset coding times; the input unit is used for inputting the input graph into the graph neural network model, obtaining an intermediate coding result after the first character is coded by the graph neural network model, and judging whether the coded times reach the preset coding times or not; and the determining unit is used for determining that the intermediate coding result is the coding result of the first character if the coded times reach the preset coding times, and continuing to code the input graph through the graph neural network model if the coded times do not reach the preset coding times.
As an alternative embodiment, when the first character is encoded for the first time, the vector of the first character is an initial vector corresponding to the first character, the vector of the second character is an initial vector corresponding to the second character, and the initial vector is used to represent a vector corresponding to the character itself.
As an alternative embodiment, the determining unit includes: the determining subunit is used for re-determining a vector corresponding to the first character and a vector corresponding to the second character, wherein the intermediate coding result obtained by performing the last coding on the first character is determined as the vector corresponding to the first character during the current coding, and the intermediate coding result obtained by performing the last coding on the second character is determined as the vector corresponding to the second character during the current coding; and the encoding subunit is used for encoding the first character based on the redetermined vector of the first character and the redetermined vector of the second character to obtain an intermediate encoding result of the first character during the encoding.
As an alternative embodiment, the decoding module comprises: and the decoding submodule is used for carrying out conditional random field decoding on the encoding result of the first character to obtain the identifier corresponding to the first character.
Example 4
According to an embodiment of the present invention, there is further provided a named entity recognition apparatus for implementing the named entity recognition method in embodiment 2, and fig. 10 is a schematic diagram of a named entity recognition apparatus according to embodiment 4 of the present application, as shown in fig. 10, the apparatus 1000 includes:
an obtaining module 1002, configured to obtain an association relationship between an initial vector corresponding to a character in a text and each character;
a determining module 1004, configured to determine an input graph corresponding to the text according to the initial vectors corresponding to the characters and the association relationship, where nodes of the input graph represent the initial vectors corresponding to the characters, and directed edges between the nodes are determined according to an order of the characters in the text;
the encoding module 1006 is configured to perform graph encoding on characters in the text through a graph neural network model based on the input graph to obtain an encoding result of the characters;
the decoding module 1008 is configured to decode the encoding result of the character to obtain an identifier corresponding to the character, where the identifier is used to indicate whether the character is an entity in the text.
It should be noted here that the obtaining module 1002, the determining module 1004, the encoding module 1006 and the decoding module 1008 correspond to steps S81 to S87 in embodiment 2, and the four modules are the same as the corresponding steps in the implementation example and the application scenario, but are not limited to the disclosure in the first embodiment. It should be noted that the modules described above as part of the apparatus may be run in the computing device 10 provided in the first embodiment.
As an alternative embodiment, the encoding module comprises: and the parallel coding submodule is used for carrying out parallel coding on a plurality of characters in the text through the graph neural network model based on the input graph to obtain a coding result of the characters.
As an alternative embodiment, the parallel coding sub-module comprises: the first-time coding unit is used for carrying out first-time parallel coding on a plurality of characters in the text through a graph neural network model based on the input graph to obtain a first coding result of the characters; the updating unit is used for updating the input graph according to the first coding result to obtain an updated input graph; and the secondary encoding unit is used for carrying out parallel encoding on a plurality of characters in the text through the graph neural network model based on the updated input graph to obtain a second encoding result of the characters.
As an alternative embodiment, the update unit includes: and the updating subunit is used for keeping the directed edges in the input graph, and updating the nodes in the input graph by using the first coding result to obtain the updated input graph.
Example 5
Embodiments of the invention may provide a computing device that may be any one of a group of computing devices. Optionally, in this embodiment, the computing device may also be replaced with a terminal device such as a mobile terminal.
Optionally, in this embodiment, the computing device may be located in at least one network device of a plurality of network devices of a computer network.
In this embodiment, the above-mentioned computing device may execute the program code of the following steps in the method for identifying a named entity: acquiring an association relation between a vector corresponding to a character in a text and each character; coding a vector of a first character and a vector of a second character at least once to obtain a coding result corresponding to the first character, wherein the first character is any one character in the text, and the second character is other characters in the text which have an association relation with the first character; and decoding the encoding result of the first character to obtain an identifier corresponding to the first character, wherein the identifier is used for indicating whether the first character is an entity in the text.
Alternatively, fig. 11 is a block diagram of a computing device according to embodiment 5 of the present application. As shown in fig. 11, the computing device a may include: one or more processors 1102 (only one of which is shown), a memory 1104, and a peripherals interface 1106.
The memory may be configured to store software programs and modules, such as program instructions/modules corresponding to the method and apparatus for identifying a named entity in the embodiment of the present invention, and the processor executes various functional applications and data processing by operating the software programs and modules stored in the memory, so as to implement the above-mentioned method for identifying an entity. The memory may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory may further include memory remotely located from the processor, and these remote memories may be connected to terminal a through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The processor can call the information and application program stored in the memory through the transmission device to execute the following steps: acquiring an association relation between a vector corresponding to a character in a text and each character; coding a vector of a first character and a vector of a second character at least once to obtain a coding result corresponding to the first character, wherein the first character is any one character in the text, and the second character is other characters in the text which have an association relation with the first character; and decoding the encoding result of the first character to obtain an identifier corresponding to the first character, wherein the identifier is used for indicating whether the first character is an entity in the text.
Optionally, the processor may further execute the program code of the following steps: acquiring an initial vector of a character; and determining the association relation between each character according to the sequence of the characters in the text.
Optionally, the processor may further execute the program code of the following steps: after acquiring the association relationship between the vector corresponding to the character in the text and each character, acquiring an input graph corresponding to the text, wherein the input graph represents a graph used for being input to an encoding layer for encoding, and the acquiring of the input graph corresponding to the text comprises the following steps: determining characters in a text as nodes of an input graph, wherein the characters corresponding to each node are different; directed edges between the nodes are constructed, wherein the directed edges point from the node of the previous character to the node of the next character.
Optionally, the processor may further execute the program code of the following steps: and inputting the input graph into a graph neural network model, and encoding the first character at least once through the graph neural network model.
Optionally, the processor may further execute the program code of the following steps: acquiring preset encoding times; inputting an input graph into a graph neural network model, coding a first character through the graph neural network model to obtain an intermediate coding result, and judging whether the coded times reach preset coding times; and if the coded times reach the preset coding times, determining that the intermediate coding result is the coding result of the first character, and if the coded times do not reach the preset coding times, continuously coding the input graph through the graph neural network model.
Optionally, when the first character is encoded for the first time, the vector of the first character is an initial vector corresponding to the first character, the vector of the second character is an initial vector corresponding to the second character, and the initial vector is used to represent a vector corresponding to the character itself.
Optionally, the processor may further execute the program code of the following steps: re-determining a vector corresponding to the first character and a vector corresponding to the second character, wherein the intermediate coding result obtained by coding the first character last time is determined as the vector corresponding to the first character during the coding, and the intermediate coding result obtained by coding the second character last time is determined as the vector corresponding to the second character during the coding; and coding the first character based on the vector of the redetermined first character and the vector of the redetermined second character to obtain an intermediate coding result of the first character during the coding.
Optionally, the processor may further execute the program code of the following steps: and carrying out conditional random field decoding on the encoding result of the first character to obtain the identifier corresponding to the first character.
The embodiment of the invention provides a scheme for identifying a named entity. Obtaining an association relation between a vector corresponding to a character in a text and each character; coding a vector of a first character and a vector of a second character at least once to obtain a coding result corresponding to the first character, wherein the first character is any one character in the text, and the second character is other characters in the text which have an association relation with the first character; and decoding the encoding result of the first character to obtain an identifier corresponding to the first character, wherein the identifier is used for indicating whether the first character is an entity in the text. According to the scheme, the vector of any character in the text and the vectors of other characters related to the character are coded to obtain the coding result of the character, and the process only depends on the initial vector of each character in the text and the result of the last coding, but does not depend on the coding result of the current coding, so that a plurality of characters in the text can be coded in parallel, the coding efficiency of the character can be improved, and the entity recognition efficiency of the character can be improved.
It will be understood by those skilled in the art that the structure shown in fig. 11 is merely an illustration, and the computing device may also be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palmtop computer, a Mobile Internet Device (MID), a PAD, and the like. Fig. 11 is a diagram illustrating a structure of the electronic device. For example, computing device A may also include more or fewer components (e.g., network interfaces, display devices, etc.) than shown in FIG. 11, or have a different configuration than shown in FIG. 11.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a computer-readable non-volatile storage medium, and the non-volatile storage medium may include: flash disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
Example 6
Embodiments of the present invention also provide a non-volatile storage medium. Optionally, in this embodiment, the nonvolatile storage medium may be configured to store program codes executed by the named entity identification method provided in the first embodiment.
Optionally, in this embodiment, the nonvolatile storage medium may be located in any one of computing devices in a computing device group in a computer network, or in any one of mobile terminals in a mobile terminal group.
Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for performing the following steps: acquiring an association relation between a vector corresponding to a character in a text and each character; coding a vector of a first character and a vector of a second character at least once to obtain a coding result corresponding to the first character, wherein the first character is any one character in the text, and the second character is other characters in the text which have an association relation with the first character; and decoding the encoding result of the first character to obtain an identifier corresponding to the first character, wherein the identifier is used for indicating whether the first character is an entity in the text.
Example 7
According to an embodiment of the present invention, there is also provided a method for identifying a named entity, and fig. 12 is a flowchart of a method for identifying a named entity according to embodiment 7 of the present application, and as shown in fig. 12, the method includes:
step S1201, obtaining an association relationship between an initial vector corresponding to a character in the text and each character.
Specifically, the text is a text to be subjected to named entity recognition, and may be a sentence in the text to be subjected to named entity recognition. In an alternative embodiment, in order to analyze the comment of the commodity, a comment text of the commodity can be collected and subjected to entity recognition, so that an object in question by the comment is determined. Entity identification can also be applied in other top-level services, which are not described herein.
The vector corresponding to the character can be a vector corresponding to the character obtained in a word2vec mode or the like, the association relationship between each character can be embodied by the arrangement sequence of the characters in the text, and a certain association relationship exists between adjacent characters.
In an alternative embodiment, the text "man basket first wars Tuniss" is taken as an example, wherein the character "basket" has an association relationship with "man" and "head".
Step S1203, determining an input graph corresponding to the text according to the initial vectors corresponding to the characters and the association relationship, where nodes of the input graph represent the initial vectors corresponding to the characters, and directional edges between the nodes are determined according to the order of the characters in the text.
In the above steps, taking a text as an example, determining characters in the text as nodes of the input graph. It should be noted that the corresponding characters of each node are different, that is, when a plurality of identical characters are included in one text, only one node is created for the character. The directional edge is a change with a direction for connecting nodes, and the directional property of the directional edge can be determined according to the sequence of characters in the text.
Still referring to fig. 5, for the text "lie flat accesses the uk" as an example, six nodes constructed here respectively represent characters "lie", "country", "flat", "access", "english", and directional edges between the nodes are determined according to the order of the characters in the text, that is, "lie" points to "country", "country" points to "flat", "flat" points to "access", "access" points to "english", and "english" points to "country", thereby obtaining the input graph shown in fig. 3. The above scheme models sentences as a graph rather than a time series, thereby enabling parallel encoding of multiple characters.
And step S1205, carrying out graph coding on a plurality of characters in the text in parallel through a graph neural network model based on the input graph to obtain a character coding result.
Specifically, a Graph Neural Network Model (GNN) maps nodes in an input Graph to an m-dimensional euclidean space through a function, and can be directly based on numerous types of graphs for Graph coding, such as an acyclic Graph, a cyclic Graph, a directed Graph, an undirected Graph, and the like. The neural network model of the graph can be any one or more of the following combinations: graph attention mechanism, graph generation network, and graph spatio-temporal network. The method and the device use the graph neural network structure to replace the original recurrent neural network as the coding layer, achieve the effect similar to the mainstream model, and provide possibility for the parallel computation of the model, so that the scheme can perform graph coding on a plurality of characters in the text in parallel, thereby achieving the purpose of reducing the training and decoding time of the model.
Step S1207, decoding the encoding result of the character to obtain an identifier corresponding to the character, where the identifier is used to indicate whether the character is an entity in the text.
Specifically, the identifier may indicate whether the first character is an entity in the text, and further, in the case that the character is an entity, may indicate which step (start, inside, end) the character is in the entity, and may identify the type (name, time, etc.) of the entity represented by the character.
The method and the device use the graph neural network structure to replace the original recurrent neural network as the coding layer, achieve the effect similar to the mainstream model, and provide possibility for the parallel computation of the model, thereby achieving the purpose of reducing the training and decoding time of the model. And because the used graph neural network structure carries out parallel graph coding on the input graph corresponding to the text, a plurality of characters in the text can be coded in parallel through the graph neural network model based on the input graph, thereby achieving the effect of improving the coding efficiency.
It should be noted that, in the case of no conflict, the scheme in embodiment 7 described above may further perform other steps of the entity identification methods in embodiments 1 and 2, and details are not described here again.
Example 8
According to an embodiment of the present invention, there is further provided a named entity recognition apparatus for implementing the named entity recognition method in embodiment 7, and fig. 13 is a schematic diagram of a named entity recognition apparatus according to embodiment 8 of the present application, as shown in fig. 13, the apparatus 1300 includes:
an obtaining module 1302, configured to obtain an association relationship between an initial vector corresponding to a character in a text and each character;
a determining module 1304, configured to determine an input graph corresponding to the text according to the initial vectors corresponding to the characters and the association relationship, where nodes of the input graph represent the initial vectors corresponding to the characters, and directed edges between the nodes are determined according to an order of the characters in the text;
the parallel coding module 1306 is used for carrying out graph coding on a plurality of characters in the text in parallel through a graph neural network model based on the input graph to obtain a character coding result;
the decoding module 1308 is configured to decode an encoding result of the character to obtain an identifier corresponding to the character, where the identifier is used to indicate whether the character is an entity in the text.
It should be noted here that the obtaining module 1302, the determining module 1304, the parallel encoding module 1306 and the decoding module 1308 correspond to steps S1201 to S1207 in embodiment 7, and the three modules are the same as the corresponding steps in the implementation example and the application scenario, but are not limited to the disclosure in the first embodiment. It should be noted that the modules described above as part of the apparatus may be run in the computing device 10 provided in the first embodiment.
Example 9
According to an embodiment of the present invention, there is further provided a method for identifying a named entity, and fig. 14 is a flowchart of a method for identifying a named entity according to embodiment 9 of the present application, and as shown in fig. 14, the method includes:
step 1401, receiving an input comment text, and obtaining an association relationship between a vector corresponding to a character in the comment text and each character.
The comment text may be a comment in an e-commerce platform. In an optional embodiment, in order to perform centralized analysis on the comments of the user, comment texts may be collected from the e-commerce platform, and the comment texts are input to a device for executing the entity recognition method, where the device receives the input comment texts and obtains an association relationship between a vector corresponding to a character in the comment texts and each character.
The characters may be chinese characters, korean characters, or english words, etc., and the following embodiments are described by taking chinese characters as an example. The vector corresponding to the character can be a vector corresponding to the character obtained in a word2vec mode or the like, the association relationship between each character can be embodied by the arrangement sequence of the characters in the text, and a certain association relationship exists between adjacent characters.
Step S1403, encode the vector of the first character and the vector of the second character at least once to obtain an encoding result corresponding to the first character, where the first character is any one character in the comment text, and the second character is another character in the comment text that has an association relationship with the first character.
In the above steps, taking the comment text as an example, determining characters in the comment text as nodes of the input graph. It should be noted that the corresponding characters of each node are different, that is, when a comment text includes a plurality of identical characters, only one node is created for the character. The directional edge is a change with a direction for connecting the nodes, and the directional property of the directional edge can be determined according to the sequence of characters in the comment text.
Step S1405, decoding the encoding result of the first character to obtain an identifier corresponding to the first character, where the identifier is used to indicate whether the first character is an entity in the comment text.
Specifically, a Graph Neural Network Model (GNN) maps nodes in an input Graph to an m-dimensional euclidean space through a function, and can be directly based on numerous types of graphs for Graph coding, such as an acyclic Graph, a cyclic Graph, a directed Graph, an undirected Graph, and the like. The neural network model of the graph can be any one or more of the following combinations: graph attention mechanism, graph generation network, and graph spatio-temporal network. The method and the device use the graph neural network structure to replace the original recurrent neural network as the coding layer, achieve the effect similar to the mainstream model, and provide possibility for the parallel computation of the model, so that the scheme can perform graph coding on a plurality of characters in the comment text in parallel, thereby achieving the purpose of reducing the model training and decoding time.
Step S1407, extracting the entity from the comment text according to the identification, and determining that the extracted entity is the comment subject of the comment text.
Specifically, the identifier may indicate whether the first character is an entity in the comment text, so that the entity of the comment text may be extracted according to the identifier of each character in the comment text. For the review papers, the entity contained in the review papers is the object of the evaluation, namely the review subject.
In an alternative embodiment, in order to use the comment text "you X ni better water absorption than flower X, but more expensive than flower X", through the recognition in the above manner, the entities in the comment text can be obtained to include "you X ni" and "flower X", so that the comment subjects of the comment text can be determined to be "you X ni" and "flower X". After the comment subjects in the comment text are identified, emotion analysis can be further performed on the comment text to determine the emotional tendency of the user on the product.
Further, in the case where a character is an entity, it can also be indicated which step (start, inside, end) the character is in the entity, and it is possible to identify the type (name, time, etc.) of the entity represented by the character.
The method and the device use the graph neural network structure to replace the original recurrent neural network as the coding layer, achieve the effect similar to the mainstream model, and provide possibility for the parallel computation of the model, thereby achieving the purpose of reducing the training and decoding time of the model. And because the used graph neural network structure carries out parallel graph coding on the input graph corresponding to the text, a plurality of characters in the text can be coded in parallel through the graph neural network model based on the input graph, thereby achieving the effect of improving the coding efficiency.
It should be noted that, in the case of no conflict, the scheme in embodiment 9 described above may also perform other steps of the entity identification methods in embodiments 1 and 2, and details are not described here again.
Example 10
According to an embodiment of the present invention, there is further provided a named entity recognition apparatus for implementing the method for recognizing a named entity in embodiment 9, where fig. 15 is a schematic diagram of a named entity recognition apparatus according to embodiment 10 of the present application, and as shown in fig. 15, the apparatus 1500 includes:
the receiving module 1502 is configured to receive an input comment text, and obtain an association relationship between a vector corresponding to a character in the comment text and each character.
The encoding module 1504 is configured to encode the vector of the first character and the vector of the second character at least once to obtain an encoding result corresponding to the first character, where the first character is any one character in the comment text, and the second character is another character in the comment text that has an association relationship with the first character.
The decoding module 1506 is configured to decode an encoding result of the first character to obtain an identifier corresponding to the first character, where the identifier is used to indicate whether the first character is an entity in the comment text;
and the determining module 1508 is configured to extract the entity from the comment text according to the identifier, and determine that the extracted entity is a comment subject of the comment text.
It should be noted here that the receiving module 1502, the encoding module 1504, the decoding module 1506, and the determining module 1508 correspond to steps S1401 to S1407 in embodiment 9, and the three modules are the same as the corresponding steps in the implementation example and application scenario, but are not limited to the disclosure in the first embodiment. It should be noted that the modules described above as part of the apparatus may be run in the computing device 10 provided in the first embodiment.
Example 11
According to an embodiment of the present invention, there is further provided a method for identifying a named entity, fig. 16 is a flowchart of a method for identifying a named entity according to embodiment 11 of the present application, and as shown in fig. 16, the method for identifying a named entity may include the following implementation steps:
step S1601, a sentence in the text to be recognized is obtained, wherein the sentence is composed of a plurality of characters.
The text to be recognized is the text to be subjected to named entity recognition, and the obtained data can be any sentence in the text to be subjected to named entity recognition. In an optional embodiment, in order to perform centralized analysis on the comments of the user, comment texts may be collected from the e-commerce platform, and the comment texts are input to a device for executing the entity recognition method, where the device receives the input comment texts and extracts sentences in the comment texts as analysis bases.
It should be noted that the characters composing the sentence may be characters of different languages, such as chinese characters, korean characters, or english words, and the following embodiments take chinese characters as an example for description. The vector corresponding to the character can be a vector corresponding to the character obtained in a word2vec or other manners, the association relationship between each character can be embodied by the arrangement sequence of the characters in the text, and a certain association relationship exists between adjacent characters.
Step S1603, performing graph modeling on the sentence to obtain a graph structure of the sentence, where the graph structure is a structure modeling the sentence as a time series.
In the above step, taking the comment text as an example of a sentence, the characters in the comment text sentence are arranged in a predetermined order, for example, the sentence is modeled as a time series, and the characters and the association relationship between the characters form a graph structure of the sentence, where in the case of the graph structure being an input graph, the characters may be nodes of the input graph. It should be noted that the corresponding characters of each node may be different, that is, when a comment text includes a plurality of identical characters, only one node is created for the character. The directional edge is a change with a direction for connecting the nodes, and the directional property of the directional edge can be determined according to the sequence of characters in the comment text.
Step S1605, the graph structure of the sentence is coded by the graph neural network, and the coding result of each word in the sentence is obtained.
Specifically, the Graph Neural Network Model (GNN) maps nodes in the input Graph to an m-dimensional euclidean space through a function, and can be directly based on many types of graphs for Graph coding, such as an acyclic Graph, a cyclic Graph, a directed Graph, and an undirected Graph. The neural network model of the graph can be any one or more of the following combinations: graph attention mechanism, graph generation network, and graph spatio-temporal network. The method and the device use the graph neural network structure to replace the original recurrent neural network as the coding layer, achieve the effect similar to the mainstream model, and provide possibility for the parallel computation of the model, so that the scheme can perform graph coding on a plurality of characters in the comment text in parallel, thereby achieving the purpose of reducing the model training and decoding time.
Step S1607, decoding the coding result of each word to obtain the recognition result of the named entity in the sentence, wherein the recognition result of the named entity is used for representing whether the character is the entity in the sentence or not.
Specifically, the identifier may indicate whether the first character is an entity in the comment text, so that the entity of the comment text may be extracted according to the identifier of each character in the comment text. For the review papers, the entity contained in the review papers is the object of the evaluation, namely the review subject.
In an alternative embodiment, in order to use the comment text "you X ni better water absorption than flower X, but more expensive than flower X", through the recognition in the above manner, the entities in the comment text can be obtained to include "you X ni" and "flower X", so that the comment subjects of the comment text can be determined to be "you X ni" and "flower X". After the comment subjects in the comment text are identified, emotion analysis can be further performed on the comment text to determine the emotional tendency of the user on the product.
The method and the device use the graph neural network structure to replace the original recurrent neural network as the coding layer, achieve the effect similar to the mainstream model, and provide possibility for the parallel computation of the model, thereby achieving the purpose of reducing the training and decoding time of the model. And because the used graph neural network structure carries out parallel graph coding on the input graph corresponding to the text, a plurality of characters in the text can be coded in parallel through the graph neural network model based on the input graph, thereby achieving the effect of improving the coding efficiency.
In an alternative embodiment, in the step implemented in step S1605, the step of performing graph modeling on the sentence to obtain the graph structure of the sentence may be implemented by the following alternatives:
in step S16051, a vector for each character in the sentence is acquired.
Step S16053, according to the sequence relation between each character in the text, determining the association relation between each character.
Step S16055, based on the vector of each character in the text and the association relationship between each character, a graph structure of the sentence is produced, wherein each character is a node on the graph structure, and the sequence relationship between each character is used as a directed edge between each node in the graph structure.
In the above embodiment, a chinese word is taken as an example for explanation, a vector corresponding to a character may be a vector corresponding to the character itself obtained in a word2vec manner or the like, an association relationship between each character may be represented by an arrangement order of characters in a text, and a certain association relationship exists between adjacent characters.
Taking an input graph provided in fig. 5 as an example, the input graph here is a schematic diagram of a graph structure obtained by graph modeling of a sentence, and with reference to fig. 5, for an example of a text "lie in the united kingdom", six nodes are constructed to respectively represent characters "lie", "country", "flat", "visit", and "English", and directional edges between the nodes are determined according to the order of the characters in the text, that is, "lie" points to "country", "country" points to "flat", "flat" points to "visit", "visit" points to "visit", and "visit" points to "English", and "English" points to "country", so as to obtain the modeled graph structure. The above scheme models sentences as a graph structure, rather than a time series, thereby enabling parallel encoding of multiple characters.
As an alternative embodiment, how to obtain the association relationship between the vector corresponding to the character in the text and each character may be implemented by the following alternatives: acquiring an initial vector of a character; and determining the association relation between each character according to the sequence of the characters in the text.
Specifically, the initial vector of the character refers to a vector corresponding to the character itself, that is, a vector independent of other characters. And determining characters with adjacent relations according to the sequence of the characters in the text, and determining that the characters with the adjacent relations have an association relation.
In an alternative embodiment, the initial vector for each character in the text may be obtained in parallel, since the initial vector for a character is obtained independent of the vectors for other characters.
It should be noted here that word2vec corresponding to the word represented by the first node may be used as the initial vector of the first node.
In another alternative, the scheme for encoding the graph structure of the sentence by using the graph neural network implemented in the step S1607 can be implemented by the following scheme: acquiring an initial vector set by each node in a graph structure; the first graph code of each node is calculated according to the initial vectors of the adjacent nodes.
Since the input graph corresponding to the text is encoded by using the graph neural network structure, the effect of encoding can be achieved, and therefore, in order to improve the encoding efficiency, a plurality of characters in the text can be encoded in parallel by using the graph neural network model based on the input graph, and the encoding result of the characters can be obtained.
As an alternative embodiment, how to encode a plurality of characters in a text in parallel through a graph neural network model based on an input graph to obtain an encoding result of the characters can be implemented by adopting the following alternatives: carrying out primary parallel coding on a plurality of characters in a text through a graph neural network model based on an input graph to obtain a first coding result of the characters; updating the input graph according to the first coding result to obtain an updated input graph; and carrying out parallel coding on a plurality of characters in the text through a graph neural network model based on the updated input graph to obtain a second coding result of the characters.
In the above scheme, if the preset number of times of encoding is two, the second encoding result may be used as a final encoding result, and if the preset number of times of encoding is greater than two, the vector of the character needs to be updated in the same manner to continue encoding.
As can be known from the example of fig. 6, when encoding for the first time, an initial vector may be first given to each node, that is, an initial vector is given to each text amplitude, and this initial vector may be Word2vec corresponding to the character represented by the node, or may be other vectors. And then, respectively calculating the graph codes of each point by using a graph neural network model, namely realizing the coding of the characters corresponding to each point. For example, in FIG. 6, the A node and the B, C, D node are adjacent, then the graph encoding vector of the A node should be calculated from the initial vector of the A, B, C, D node. The principle is the same for other nodes.
Referring to fig. 7 again, if it is required to encode the node information farther away from the node a into a, the encoding operation is repeated, that is, the first sub-picture encoding vector of a is calculated from the A, B, C, D initial vector, and when the encoding operation is repeated, the second sub-picture encoding vector of a is calculated by using the A, B, C, D first sub-picture encoding vector, and since the first sub-picture encoding vector of C contains E, F information, the second sub-picture encoding vector of a also contains E, F information.
As an alternative embodiment, the input graph may be updated according to the first encoding result to obtain an updated input graph, and the directed edges in the input graph may be maintained, and the nodes in the input graph are updated by using the first encoding result to obtain the updated input graph.
It should be further noted that, in an alternative solution provided by the present application, the nth graph code of each node in the above embodiments is calculated according to the nth-1 graph codes of its neighboring nodes, where N is a positive integer greater than or equal to 2.
It should be noted that, in the case of no conflict, the scheme in embodiment 11 described above may also perform other steps of the entity identification methods in embodiments 1 and 2, and details are not described here again.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of division of logical functions, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable non-volatile storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a non-volatile storage medium and includes instructions for causing a computing device (which may be a personal computer, a server, or a network device) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned nonvolatile storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (22)

1. A method of named entity recognition, comprising:
acquiring a sentence in a text to be recognized, wherein the sentence is composed of a plurality of characters;
carrying out graph modeling on the sentence to obtain a graph structure of the sentence, wherein the graph structure is a structure for modeling the sentence into a time sequence;
coding the graph structure of the sentence by using a graph neural network to obtain a coding result of each word in the sentence;
and decoding the coding result of each word to obtain the recognition result of the named entity in the sentence, wherein the recognition result of the named entity is used for representing whether the character is the entity in the sentence or not.
2. The method of claim 1, wherein graph modeling the sentence to obtain a graph structure of the sentence comprises:
obtaining a vector of each character in the sentence;
determining an incidence relation between each character according to the sequence relation between each character in the text;
and producing a graph structure of the sentence based on the vector of each character in the text and the association relationship between each character, wherein each character is a node on the graph structure, and the sequence relationship between each character is used as a directed edge between each node in the graph structure.
3. The method of claim 2, wherein encoding the graph structure of the sentence using a graph neural network comprises:
acquiring an initial vector set by each node in the graph structure;
the first graph code of each node is calculated according to the initial vectors of the adjacent nodes.
4. The method of claim 3, further comprising:
the nth graph code of each node is obtained by calculation according to the (N-1) th graph code of the adjacent node, wherein N is a positive integer greater than or equal to 2.
5. The method of claim 3 or 4, wherein obtaining an initial vector for each node setting in the graph structure comprises:
and using word2vec corresponding to the word represented by the first node as an initial vector of the first node.
6. A method of named entity recognition, comprising:
acquiring an association relation between a vector corresponding to a character in a text and each character;
encoding a vector of a first character and a vector of a second character at least once to obtain an encoding result corresponding to the first character, wherein the first character is any one character in the text, and the second character is other characters in the text, which have an association relationship with the first character;
and decoding the encoding result of the first character to obtain an identifier corresponding to the first character, wherein the identifier is used for indicating whether the first character is an entity in the text.
7. The method of claim 6, wherein obtaining the association relationship between the vector corresponding to the character in the text and each character comprises:
acquiring an initial vector of the character;
and determining the association relation between each character according to the sequence of the characters in the text.
8. The method according to claim 6, wherein after obtaining the association relationship between the vector corresponding to the character in the text and each character, the method further comprises: acquiring an input graph corresponding to the text, wherein the input graph represents a graph used for being input to an encoding layer for encoding, and the acquiring of the input graph corresponding to the text comprises the following steps:
determining characters in the text as nodes of the input graph, wherein the characters corresponding to each node are different;
and constructing directed edges between the nodes, wherein the directed edges point to the nodes of the next character from the nodes of the previous character.
9. The method of claim 8, wherein encoding the vector of the first character and the vector of the second character at least once to obtain an encoding result corresponding to the first character comprises:
inputting the input graph into a graph neural network model, and encoding the first character at least once through the graph neural network model.
10. The method of claim 9, wherein inputting the input map into a neural network model through which the first character is encoded at least once comprises:
acquiring preset encoding times;
inputting the input graph into a graph neural network model, coding the first character through the graph neural network model to obtain an intermediate coding result, and judging whether the coded times reach the preset coding times;
and if the coded times reach the preset coding times, determining that the intermediate coding result is the coding result of the first character, and if the coded times do not reach the preset coding times, continuing to code the input graph through the graph neural network model.
11. The method according to claim 10, wherein when the first character is encoded for the first time, the vector of the first character is an initial vector corresponding to the first character, and the vector of the second character is an initial vector corresponding to the second character, and the initial vector is used to represent a vector corresponding to a character itself.
12. The method of claim 10, wherein continuing to encode the input graph through the graph neural network model comprises:
re-determining a vector corresponding to the first character and a vector corresponding to a second character, wherein an intermediate coding result obtained by coding the first character last time is determined as the vector corresponding to the first character during the coding, and an intermediate coding result obtained by coding the second character last time is determined as the vector corresponding to the second character during the coding;
and coding the first character based on the re-determined vector of the first character and the re-determined vector of the second character to obtain an intermediate coding result of the first character during the coding.
13. The method of claim 6, wherein decoding the encoded result of the first character to obtain the identifier corresponding to the first character comprises: and carrying out conditional random field decoding on the encoding result of the first character to obtain a mark corresponding to the first character.
14. A method for identifying a named entity, comprising:
acquiring an association relation between an initial vector corresponding to a character in a text and each character;
determining an input graph corresponding to the text according to the initial vectors corresponding to the characters and the incidence relation, wherein nodes of the input graph represent the initial vectors corresponding to the characters, and directed edges between the nodes are determined according to the sequence of the characters in the text;
carrying out graph coding on characters in the text through a graph neural network model based on the input graph to obtain a coding result of the characters;
and decoding the encoding result of the character to obtain an identifier corresponding to the character, wherein the identifier is used for indicating whether the character is an entity in the text.
15. The method of claim 14, wherein the graph coding of the character in the text through the graph neural network model based on the input graph to obtain the coding result of the character comprises:
and carrying out parallel coding on a plurality of characters in the text through a graph neural network model based on the input graph to obtain a coding result of the characters.
16. The method of claim 15, wherein encoding a plurality of characters in the text in parallel through a graph neural network model based on the input graph to obtain an encoding result of the characters comprises:
carrying out primary parallel coding on a plurality of characters in the text through a graph neural network model based on the input graph to obtain a first coding result of the characters;
updating the input graph according to the first coding result to obtain an updated input graph;
and carrying out parallel coding on a plurality of characters in the text through a graph neural network model based on the updated input graph to obtain a second coding result of the characters.
17. The method of claim 16, wherein updating the input graph according to the first encoding result to obtain an updated input graph comprises:
and keeping the directed edges in the input graph, and updating the nodes in the input graph by using the first encoding result to obtain an updated input graph.
18. An apparatus for identifying named entities, comprising:
the acquisition module is used for acquiring the association relationship between the vector corresponding to the characters in the text and each character;
the encoding module is used for encoding a vector of a first character and a vector of a second character at least once to obtain an encoding result corresponding to the first character, wherein the first character is any one character in the text, and the second character is other characters in the text, which have an association relationship with the first character;
and the decoding module is used for decoding the encoding result of the first character to obtain an identifier corresponding to the first character, wherein the identifier is used for indicating whether the first character is an entity in the text.
19. A non-volatile storage medium, wherein the non-volatile storage medium includes a stored program, and wherein when the program runs, a device in which the non-volatile storage medium is located is controlled to perform the following steps: acquiring an association relation between a vector corresponding to a character in a text and each character; encoding a vector of a first character and a vector of a second character at least once to obtain an encoding result corresponding to the first character, wherein the first character is any one character in the text, and the second character is other characters in the text, which have an association relationship with the first character; and decoding the encoding result of the first character to obtain an identifier corresponding to the first character, wherein the identifier is used for indicating whether the first character is an entity in the text.
20. A processor, wherein the processor is configured to execute a program, wherein the program executes to perform the following steps: acquiring an association relation between a vector corresponding to a character in a text and each character; encoding a vector of a first character and a vector of a second character at least once to obtain an encoding result corresponding to the first character, wherein the first character is any one character in the text, and the second character is other characters in the text, which have an association relationship with the first character; and decoding the encoding result of the first character to obtain an identifier corresponding to the first character, wherein the identifier is used for indicating whether the first character is an entity in the text.
21. A method for identifying a named entity, comprising:
acquiring an association relation between an initial vector corresponding to a character in a text and each character;
determining an input graph corresponding to the text according to the initial vectors corresponding to the characters and the incidence relation, wherein nodes of the input graph represent the initial vectors corresponding to the characters, and directed edges between the nodes are determined according to the sequence of the characters in the text;
carrying out graph coding on a plurality of characters in the text in parallel through a graph neural network model based on the input graph to obtain a coding result of the characters;
and decoding the encoding result of the character to obtain an identifier corresponding to the character, wherein the identifier is used for indicating whether the character is an entity in the text.
22. A method for identifying a named entity, comprising:
receiving an input comment text, and acquiring a vector corresponding to characters in the comment text and an association relation between each character;
encoding a vector of a first character and a vector of a second character at least once to obtain an encoding result corresponding to the first character, wherein the first character is any one character in the comment text, and the second character is other characters in the comment text, which have an association relation with the first character;
decoding the encoding result of the first character to obtain an identifier corresponding to the first character, wherein the identifier is used for indicating whether the first character is an entity in the comment text;
and extracting entities from the comment text according to the identification, and determining that the extracted entities are comment subjects of the comment text.
CN202010496481.5A 2020-06-03 2020-06-03 Named entity identification method and device Pending CN113761917A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010496481.5A CN113761917A (en) 2020-06-03 2020-06-03 Named entity identification method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010496481.5A CN113761917A (en) 2020-06-03 2020-06-03 Named entity identification method and device

Publications (1)

Publication Number Publication Date
CN113761917A true CN113761917A (en) 2021-12-07

Family

ID=78783313

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010496481.5A Pending CN113761917A (en) 2020-06-03 2020-06-03 Named entity identification method and device

Country Status (1)

Country Link
CN (1) CN113761917A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114386410A (en) * 2022-01-11 2022-04-22 腾讯科技(深圳)有限公司 Training method and text processing method of pre-training model
CN114912450A (en) * 2022-07-18 2022-08-16 天津恒达文博科技股份有限公司 Information generation method and device, training method, electronic device and storage medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114386410A (en) * 2022-01-11 2022-04-22 腾讯科技(深圳)有限公司 Training method and text processing method of pre-training model
CN114386410B (en) * 2022-01-11 2023-07-11 腾讯科技(深圳)有限公司 Training method of pre-training model and text processing method
CN114912450A (en) * 2022-07-18 2022-08-16 天津恒达文博科技股份有限公司 Information generation method and device, training method, electronic device and storage medium
CN114912450B (en) * 2022-07-18 2022-09-27 天津恒达文博科技股份有限公司 Information generation method and device, training method, electronic device and storage medium

Similar Documents

Publication Publication Date Title
CN108595494A (en) The acquisition methods and device of reply message
CN110633458A (en) Method and device for generating referee document
CN110222328B (en) Method, device and equipment for labeling participles and parts of speech based on neural network and storage medium
CN114972823A (en) Data processing method, device, equipment and computer medium
CN108304376B (en) Text vector determination method and device, storage medium and electronic device
CN115062134B (en) Knowledge question-answering model training and knowledge question-answering method, device and computer equipment
CN108319888A (en) The recognition methods of video type and device, terminal
CN113486173B (en) Text labeling neural network model and labeling method thereof
CN113761917A (en) Named entity identification method and device
CN110991298B (en) Image processing method and device, storage medium and electronic device
CN114626380A (en) Entity identification method and device, electronic equipment and storage medium
CN116955646A (en) Knowledge graph generation method and device, storage medium and electronic equipment
CN111274813A (en) Language sequence marking method, device storage medium and computer equipment
CN110502236B (en) Front-end code generation method, system and equipment based on multi-scale feature decoding
CN112417874A (en) Named entity recognition method and device, storage medium and electronic device
CN115545035B (en) Text entity recognition model and construction method, device and application thereof
CN116561339A (en) Knowledge graph entity linking method, knowledge graph entity linking device, computer equipment and storage medium
CN115424725A (en) Data analysis method and device, storage medium and processor
CN114238622A (en) Key information extraction method and device, storage medium and electronic device
CN114818651A (en) Text similarity determination method and device, storage medium and electronic device
CN115510199A (en) Data processing method, device and system
CN114238587A (en) Reading understanding method and device, storage medium and computer equipment
CN110929504B (en) Statement diagnosis method, device and system
CN110956034B (en) Word acquisition method and device and commodity search method
CN115512693A (en) Audio recognition method, acoustic model training method, device and storage medium

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