Embodiments of the invention generation relate to natural language processing, more particularly to the usage of capsule networks for named entity recognition.
Semantic parsing is the task of transforming natural language text into a machine-readable formal representation. Natural language processing (NLP) involves the use of artificial intelligence to process and analyze large amounts of natural language data. Named Entity Recognition (NER) is the identification and classification of named entities within a document. Traditionally, an NER model identifies the named entity (NE) as belonging to a class in a predefined set of classes. Possible classifications of named entities in different NER models include person, location, artifact, award, media, team, time, monetary value, etc.
An NER model helps identify key information to understand what a document is about, either as text summarization or as a starting point for additional processing. Additionally, NER can be used to identify how to correctly handle data in a given document based on a specific named entity or named entity class. For example, if the primary named entity in a document is a person, certain security measures may need to be taken for the data.
Common NER models utilize a Bidirectional Long Short Term Memory (BiLSTM) encoder and Conditional Random Field (CRF) decoder. Bidirectional LSTMs consist of a pair of LSTMs, where one is trained from left-to-right (forward), and the other is trained from right-to-left (backward). However, because they are two separate LSTMs, neither of them look at both directions at the same time and thus are not truly bidirectional. Each LSTM can only consider the context on one side of the NE at a time. The model is not able to consider the full context of the named entity to efficiently determine the correct class that the named entity belongs to. Other previous methods include contextual word embeddings from Bidirectional Encoder Representations from Transformers (BERT), Embeddings from Language Models (ELMo), and Flair. Further shortcomings of these models include their inability to consider and understand semantic features and being limited to a small set of named entity classes.
Capsule Neural Networks (CapsNet) are machine learning systems that model hierarchical relationships. CapsNets were introduced in the image classification domain, where they are configured to receive as input an image and to process the image to perform image classification or object detection tasks. CapsNet improves on Convolutional Neural Networks (CNN) through the addition of the capsule structure and is better suited to outputting the orientation of an observation and pose of an observation compared to CNN. Thus, it can train on a comparatively lesser number of data points with a better performance in solving the same problem. The dynamic routing algorithm groups capsules together to activate higher level parent capsules. Over the course of iterations, each parents' outputs may converge with the predictions of some children and diverge from those of others, thus removing a lot of unnecessary activations in the network, ultimately until the capsules reach an agreement.
Named Entity Recognition is the identification and classification of named entities within a document. The disclosed invention leverages the CapsNet architecture for improved NE identification and classification. This includes deriving the features of an input text. The derived features are used to identify and classify any named entities in the text. The system is further configured to identify named entities in the text and perform clustering to group named entities. The disclosed CapsNet considers the context of the whole text to activate higher capsule layers in order to identify the named entities and classify them.
A computer-implemented method for identifying and classifying named entities in a natural language text is provided. This includes receiving, into a neural capsule embedding network as input, an embedding vector, where the embedding vector contains embeddings representing words in a natural language text, analyzing, by the neural capsule embedding network, the context of each word within the embedding vector considering tokens to the left and right of the word, through dynamic routing of capsules, by the neural capsule embedding network, converging to a final capsule layer mapping to each word in the input vector, and generating, from the neural capsule embedding network, an output vector, wherein each output vector value identifies if a word in the input is a named entity or not a named entity and if the word is a named entity, identifies what class the named entity belongs to. The classes can be a predefined set of named entity classes or clusters determined by the neural capsule embedding network.
The input can be a natural language text, where the words in the natural language text are converted into embeddings and inserted into an embedding vector during preprocessing. The target word in the natural language text can be identified during preprocessing. The features of the natural language text can be identified during preprocessing. The features can be included in the embedding vector as feature embeddings. The features can also be identified by the Neural Capsule Embedding Network.
The accompanying drawings taken in conjunction with the detailed description will assist in making the advantages and aspects of the disclosure more apparent.
Reference will now be made in detail to the present embodiments discussed herein, illustrated in the accompanying drawings. The embodiments are described below to explain the disclosed method, system, apparatus, and program by referring to the figures using like numerals.
The subject matter is presented in the general context of program modules and/or in computer hardware, including the structures disclosed in this specification and their structural equivalents, or in combinations of one or more of them. Those skilled in the art will recognize that other implementations may be performed in combination with other types of program and hardware modules that may include different data structures, components, or routines that perform similar tasks. The invention can be practiced using various computer system configurations and across one or more computers, including, but not limited to, clients and servers in a client-server relationship. Computers encompass all kinds of apparatus, devices, and machines for processing data, including by way of example one or more programmable processors, memory, and can optionally include, in addition to hardware, computer programs and the ability to receive data from or transfer data to, or both, mass storage devices. A computer program, which may also be referred to or described as a program, software, a software application, an app, a module, a software module, a script, or code, can be written in any form of programming language, including compiled or interpreted languages, or declarative or procedural languages; it can be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment deployed or executed on one or more computers.
Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one having ordinary skill in the art to which this invention belongs. In describing the invention, it will be understood that a number of techniques and steps are disclosed. Each of these has individual benefits, and each can also be used in conjunction with one or more, or in some cases all, of the other disclosed techniques. Accordingly, for the sake of clarity, this description will refrain from repeating every possible combination of the individual steps in an unnecessary fashion. The specification and claims should be read with the understanding that such combinations are entirely within the scope of the invention and the claims.
It will nevertheless be understood that no limitation of the scope is thereby intended, such alterations and further modifications in the illustrated invention, and such further applications of the principles as illustrated therein being contemplated as would normally occur to one skilled in the art to which the embodiments relate. The present disclosure is to be considered as an exemplification of the invention, and is not intended to limit the invention to the specific embodiments illustrated by the figures or description below.
System, method, apparatus, and program instruction for Named Entity Recognition using Capsule Networks is provided. Such an invention allows for the more efficient processing of natural language data. The disclosed invention leverages the CapsNet architecture for improved NE identification and classification. This is done by deriving the features of an input text. The derived features are used to identify and classify any named entities in the text. The system is further configured to identify named entities in the text and perform clustering to group named entities. Clustering allows for the creation of new classes that might have been previously missed and the splitting of existing classes to classify named entities more specifically. An explanation for identifying and classifying named entities in the context of a text using CapsNet follows.
As illustrated in
In the preferred embodiment, the input is pre-processed 110 using different NLP libraries to identify features of the natural language text that will be provided to and used by the CapsNet. This includes linguistic and semantic features of the text. Instead of assuming that the model can pick up all features on its own, the inclusion of linguistic features in the capsules ensures that the model can use all of the features to better identify and classify named entities in the text. The text is fed through parsers to determine these NER features, which can be divided into two subsets of features: features for NE identification and features for NE classification. NE identification features include, but are not limited to, part of speech tags, constituency parsing, relations between words, and conjunctions. NE classification features include, but are not limited to, dependency relations, prepositions, and object types.
The Neural Capsule Embedding Network 115, after receiving the input, considers the context of the whole text to activate higher capsule layers in order to identify the named entities and classify them. The Neural Network Layer 120 performs post-processing on the output vector. The system output 125 contains each word in the input text tagged as either 0, not a named entity, or an integer corresponding to the class that the named entity is grouped with.
While the disclosed model supports a predefined set of named entity classes, the preferred embodiment supports up to 1000 undefined classes, termed clusters in this disclosure, such that the output vector values of named entities are set as an integer 1 to 1000 corresponding to the clusters. A smaller maximum number of clusters will result in clusters similar to traditional NER models. A larger maximum number of clusters will result in a finer level of granularity in the classification of named entities, as compared to traditional NER models. No limitation on the maximum number of clusters is intended.
As illustrated in
The Neural Capsule Embedding Network 205 is a CapsNet configured to receive a natural language text 210 as input in the depicted embodiment. Natural language text is comprised of one or more words, exemplified by the sentence, “John lives in California.” Because neural networks cannot read and understand text, the data is converted into numerical representations called embeddings 215. As illustrated in
Embodiments can vary in whether the features, to be evaluated by the Neural Capsule Embedding Network, are identified during pre-processing or by the Neural Capsule Embedding Network itself. In the preferred embodiment, the features of the text are identified during pre-processing and fed into the NER model. The features are converted to numerical representations and included with each word embedding that the feature is relevant to, as feature embeddings, such that each embedding in the embedding vector is itself a vector. For each word, any feature embeddings for features that are not relevant to a word are populated with the value of zero in order for the embedding vector for each word to be the same dimension. Alternatively, the linguistic features can be identified in the first step in the CapsNet.
A Neural Capsule Embedding Network 205 is comprised of stacked layers of capsules, where each capsule is initially linked to every other capsule in the adjacent layers, though these connections are pared down as a result of dynamic routing. The Neural Capsule Embedding Network 205 is a true CapsNet and not merely a limited number of capsule layers. Because increasing the number of layers above certain thresholds can saturate the network, in the preferred embodiment, the maximum number of layers is 30. This disclosure contemplates Neural Capsule Embedding Networks of other sizes and across one or more computers. The network is configured, for each word, to analyze and consider the tokens on both the left and right sides of the word to fully understand the context within the sentence. In the preferred embodiment, 10 tokens to the left (before) and 10 tokens to the right (after) of each word are considered, via capsule connections, in order to determine if the word is a named entity and group an identified named entity into clusters. This is an improvement over prior art processes which do not look at the words in both directions or, in implementations using Bidirectional LSTMs, which look to the left and right of the word separately and are not truly bidirectional. In the preferred embodiment, each capsule layer in the network has a hidden size of 2048 (HL), though other sizes may be contemplated. Upon receiving the input, an intermediate hidden neural layer converts the input embedding size of IL to the hidden size of HL and projects it to the hidden capsule layers. The final layer 220 of the Neural Capsule Embedding Network is a Fully Connected Capsule Layer. The hidden layer before the Fully Connected Capsule Layer produces a matrix of dimension IL×HL. The matrix is flattened (all matrix elements placed in a single row) to a vector of dimension 1×IL*HL and passed to the Fully Connected Capsule Layer. The Fully Connected Capsule Layer converts the 1×IL*HL vector to one having dimensions of 1×IL, the 1×IL output vector 225 corresponding to the input embedding vector.
The capsule network is trained on a corpus of text to produce this output. Training is done by passing a known input, generating an output using the capsule network as it currently is, then comparing it to the known correct output and modifying the parameters (weights) accordingly to improve the accuracy of the results. In the preferred embodiment, the capsules and capsule connections are randomly initialized. Over time, the network is trained to generate the known output for all natural language data input. Training can be supervised, whereby there is a predefined set of named entity classes, and the system is configured to group any recognized named entities into the appropriate class. In the preferred embodiment, training is unsupervised, whereby there is a maximum number of clusters, and the system is configured to group any recognized named entities into as yet unidentified clusters. The clusters can later be identified during some form of post-processing.
As depicted in
CapsNets are commonly employed in image recognition and classification due to their understanding of the spatial relationships of features in an image. For the image recognition process, CapsNet architecture involves capsules that take into consideration things like color, gradients, edges, shapes, and spatial orientation to identify object features and recognize the position and location of the features. As capsules agree on the features of the image, the output is routed to subsequent layers to the eventual identification of the image.
For Named Entity Recognition, the disclosed CapsNet is trained to analyze the input by evaluating linguistic features of a token in the context of the natural language text, such features including, but not limited to, part of speech tags, constituency parsing, relations between words, and conjunctions. The disclosed CapsNet is further trained to group a named entity into clusters by evaluating linguistic features of the named entity in the context of the text, such features including, but not limited to, dependency relations, prepositions, and object types. As capsules agree on the relevant features for identifying a named entity, the output of whether a word is a named entity or not a named entity is routed to subsequent layers. The capsules further agree on the relevant features used to classify a named entity and route the output of clustering of a named entity to subsequent layers. At the final capsule layer 220, the Neural Capsule Embedding Network 205 outputs a vector 225, corresponding to the input text in the depicted embodiment, though the Neural Capsule Embedding Network 205 can be configured to produce other outputs.
As illustrated in
As depicted in
The output 240 of the NER Capsule Network is a vector, corresponding to the input text. In the preferred embodiment, each entry in the vector is tagged as either 0, indicating that the word is not a named entity, or an integer between 1 and 1000, specifying the cluster to which the named entity belongs. In the output 240 produced from the example sentence, “John lives in California,” the value XXX identifies a person cluster, the value YYY indicates a location cluster, and the value 0 identifies that the word is not a named entity. In some embodiments the clusters are limited to a predefined, smaller set of broad named entity classes. Alternatively, the clusters are groupings where the classes are later identified through post-processing.
Post-processing can be further performed on the output vector. As depicted in
The preceding description contains embodiments of the invention and no limitation of the scope is thereby intended. It will be further apparent to those skilled in the art that various modifications and variations can be made in the present invention without departing from the spirit or scope of the invention.
This application claims priority from provisional U.S. patent application No. 63/116,048 filed on Nov. 19, 2020.
| Filing Document | Filing Date | Country | Kind |
|---|---|---|---|
| PCT/US21/59992 | 11/18/2021 | WO |