Background
In the world today, with the explosion of mobile internet, people are not publishing information on social media all the time, and the information constitutes a huge amount of social media data. Compared with the traditional news private line manuscript data, the data on the social media are more time-efficient, contain rich information and gradually become a plurality of application potential information sources, such as news hotspot tracking, user public opinion analysis, potential violence incident early warning and the like. Therefore, how to mine potential information from social media data becomes an important task. The entity extraction is a basic task of information extraction, and a powerful entity extraction system is indispensable to the construction of the applications, and has extremely high social and economic values.
In recent years, with the rise of deep neural network models, end-to-end neural network-based models have become the mainstream method for named entity recognition. These methods can be broadly classified into the following categories: word-based representations, character-based representations, phrase-based representations, or any combination of the foregoing. Although these methods have achieved good performance on news text, the performance of such methods is dramatically reduced when confronted with social media data due to the inherent features of social media, such as informal expressions, irregular noun abbreviations, non-grammatical expressions, more unknown words, etc.
Applicants have discovered that affixes, as morphemes with certain semantics, can assist in identifying to some extent whether a word is part of an entity. For simplicity, only the most common prefixes and suffixes of affixes are considered. Two benefits can be brought about by introducing affix-feature representations, one is that words with the same affix tend to have similar meanings, and introducing affix representations can enrich semantic representations of words, e.g., "autopen", "automat", etc., words with the same prefix "auto-" all have "automatic" meaning; the second is that some affixes themselves have the semantics of named entities, for example, the suffix "-ie" is derived from ancient english and is commonly found in related names, names of people, children's words, or colloquial languages, so that the word whose "-ie" ends is likely to be a name of a person.
Disclosure of Invention
The invention aims to overcome the defects of the prior art and provides a social media named entity identification method based on affix perception. The method can combine word embedding, word character level representation, word prefix characteristic representation and word suffix characteristic representation, capture word affix characteristic representation by utilizing the bidirectional cyclic neural network, well enrich semantic representation of words by introducing the affix characteristic representation, relieve the problem of unknown words in social media data and improve the effect of named entity recognition. The method has certain generalization and is also suitable for named entity identification in the fields of news and the like.
The purpose of the invention can be realized by the following technical scheme:
a social media named entity recognition method based on affix perception comprises the following steps:
collecting a social media data set marked with named entities, wherein each piece of data comprises an original text and is marked with the named entities;
preprocessing texts in the data set, and constructing index vector representation of the texts at a word level and index vector representation of the texts at a character level;
capturing embedding representation, character level representation and affix characteristic representation of a word by adopting a recurrent neural network and a word embedding technology, and fusing the word embedding representation, the character level representation and the affix characteristic representation to be used as final representation of the word;
inputting the final representation of the obtained word into a bidirectional convolution neural network and a conditional random field, predicting a tag sequence and calculating a loss value;
training the model by adopting a random gradient descent algorithm according to the obtained loss value;
and inputting the text into the trained model, and identifying the named entity in the text.
Compared with the prior art, the invention has the following beneficial effects:
the method for recognizing the named entity of the social media based on affix perception introduces affix characteristic representation of words on the basis of word embedding and character level representation of the words, enriches semantic representation of the words, relieves the problem of unknown words in social media data, improves the effect of recognizing the named entity, has certain generalization, and is also suitable for recognizing the named entity in the fields of news and the like.
Examples
The embodiment provides a method for identifying a social media named entity based on affix perception, and a flowchart of the method is shown in fig. 1, and the method comprises the following steps:
(1) and collecting a social media data set marked with the named entity, wherein each piece of data comprises original text and is marked with the named entity.
The collected social media data set is used as a training set.
(2) And preprocessing the texts in the data set, and constructing the index vector representation of the texts at the word level and the index vector representation of the texts at the character level.
Specifically, the pretreatment comprises:
replacing all lower case letters in the text with corresponding upper case letters;
all the numbers in the text are replaced by 0.
Specifically, the constructing the index representation of the text at a word level and a character level comprises:
(2-1) traversing all texts of the social media data set, and constructing a word dictionary and a character dictionary;
specifically, the word dictionary is constructed by traversing each word of each text in the data set, adding the word to a word list when different words are encountered, and assigning an index to each word according to the adding sequence, wherein the index value is 0, 1, 2 and so on. And the vocabulary obtained after traversing is a word dictionary.
The method of character dictionary construction is as above except that each character of each word of each text is traversed.
And (2-2) using the word dictionary and the character dictionary obtained in the step (2-1) to sequence the text at a word level and a character level.
The text is serialized at a word level and a character level, namely, each word in each sentence is subjected to one-hot coding, and corresponding vectors are formed according to the word level and the character level.
(3) Capturing embedded representation, character level representation and affix characteristic representation of a word by adopting a recurrent neural network and a word embedding technology, and fusing the embedded representation, the character level representation and the affix characteristic representation of the word to be used as final representation of the word, wherein the steps comprise:
(3-1) the serialization of texts at the word level is expressed as s ═ w
1,w
2,…,w
nWhere n denotes the number of words in the text,
representing the one-hot encoding of the ith word of the sentence, v being the number of words in the word dictionary. Inputting s into the word embedding layer to obtain a corresponding word embedding representation:
wherein,
representing trainable parameters of the word embedding layer and d representing the dimensions of the word embedding vector.
(3-2) let the character serialization of the ith word in the text be represented as column w
i={c
i,1,c
i,2,…,c
i,mWhere m denotes the number of characters contained in the ith word,
the ith word in the sentenceOne-hot encoding of j characters, v
cIs the number of characters in the character dictionary. Extracting character level representation of word by bidirectional cyclic neural network, firstly inputting each character of word into character embedding layer to obtain corresponding character embedding
Wherein, W
cParameter matrix representing character embedding layer with size d
c×v
c. Then the character is embedded and input into a bidirectional cyclic neural network to respectively obtain the forward hidden state vector of each character
And reverse implicit state vector
Finally, the last implicit state vector of the forward cyclic neural network and the last implicit state vector of the reverse cyclic neural network are spliced to represent the character-level representation of the word
(3-3) for simplicity, the first t characters of each word are considered as the prefix of the word, and similarly, the last t words of each word are considered as the suffix of the word, t being the hyperparameter. Let the character serialization of the ith word in the text be represented as column w
i={c
i,1,c
i,2,…,c
i,mTherein of
One-hot encoding of the jth character representing the ith word in a sentence, v
cIs the character dictionary size. Extracting character level representation of the word by adopting a bidirectional cyclic neural network, firstly inputting each character of the word into a character embedding layer to obtain corresponding character embedding
Wherein, W
cMoments of parameters representing embedded layers of charactersMatrix size d
c×v
c. Then the character is embedded and input into a bidirectional cyclic neural network to respectively obtain the forward hidden state vector of each character
And reverse implicit state vector
Finally, the implicit state vectors of the first k characters are spliced to obtain a matrix, and the dimensionality of the matrix is d
vX t, this matrix contains prefix information. Specially, if the length of a word is less than t, the hidden state vectors of all time steps are spliced together, and the dimension of the obtained matrix is d
vX m. In order to ensure consistent dimensionality of prefix features of all words, an averaging operation is performed on the implicit state matrices, namely, averaging is performed on the second dimensionality of the matrices, and finally prefix feature representations are obtained
Similarly, the implicit state vector corresponding to the last t characters of the word is operated in the same way to obtain the suffix feature representation of the word
(3-4) splicing the word embedded representation, the character level representation, the prefix feature representation and the suffix feature representation of the word obtained in the steps (3-1) - (3-3) to obtain a final representation of the word
(4) Inputting the final representation of the obtained word into a bidirectional convolutional neural network and a conditional random field, predicting a label sequence and calculating a loss value, wherein the steps comprise:
(4-1) inputting the final representation of the word obtained in step (3) intoIn the bidirectional cyclic neural network, the obtained forward hidden state and the reverse hidden state are spliced to obtain word sequence representation
(4-2) inputting the word sequence representation obtained in the step (4-1) into a full-connection layer, and obtaining the score of each word on all labels: pi=Whi+ b, where W and b are trainable parameters;
(4-3) y ═ y1,y2,…,ynDenotes the predicted tag sequence corresponding to the input text s, y(s) denotes the set of all possible tag sequences for the input sentence s. The P obtained in the step (4-2)iWhen the random field is input into the conditional random field, the score of each possible sequence is calculated according to the following formula:
wherein A represents a state transition score matrix, the size of A is k × k, A
i,jRepresenting a score for a transition from label i to label j,
indicating the tag y in the predicted sequence
iFollowed by label y
i+1Score (likelihood), y
iRepresenting the ith tag in the predicted tag sequence y.
The label of the i-th word representing the input text s is y
iScore (likelihood).
Represents the predicted tag sequence, with the highest scoring tag sequence as the final prediction:
finally, the loss value is calculated as follows:
(5) training the model by adopting a random gradient descent algorithm according to the loss value obtained in the step (4) to obtain a trained model;
when the loss value of the model is not reduced any more, the training is completed.
(6) And (5) inputting the text into the trained model obtained in the step (5), and identifying the named entity in the text.
Fig. 2 is a schematic diagram of a model used for extracting the affix feature representation.
The above embodiments are preferred embodiments of the present invention, but the present invention is not limited to the above embodiments, and any other changes, modifications, substitutions, combinations, and simplifications which do not depart from the spirit and principle of the present invention should be construed as equivalents thereof, and all such changes, modifications, substitutions, combinations, and simplifications are intended to be included in the scope of the present invention.