A device for extracting information from semi-structured text
By introducing the graph attention network and different granularity feature aggregation layers into the deep learning model, integrating structural features into character vectors, and using the CRF algorithm for sequence annotation, the problem of the inability of existing technology to effectively learn high-order structural features has been significantly improved. Data extraction accuracy in finance.
Patent Information
- Application Number
- CN202110414726.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-17
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2041-04-17
AI Technical Summary
Existing deep learning models cannot effectively learn and express high-order structural feature information when processing semi-structured text, resulting in limited data extraction accuracy in the financial field.
Use Albert or LSTM for character embedding, combine the graph attention network and different granularity feature aggregation layers, and integrate structural features into character vectors through word segmentation and structure extraction, encoding layer modules, graph attention network structure layers and decoding layers, and use CRF algorithm performs sequence annotation.
The accuracy of data extraction in the financial field has been significantly improved, increasing by more than 2%-5%.
Smart Images

Figure CN113326690B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of AI technology, and in particular to an information extraction device for semi-structured text. Background Art
[0002] In text processing, a common requirement is to extract valuable information from a text. For example, question-answering technology based on knowledge graphs needs to extract triples from unstructured text information in advance to form structured information of knowledge graphs. There is also such a requirement in various business scenarios in the financial field to extract valuable information from unstructured or semi-structured text information. There are a lot of semi-structured data in various fields. It is not completely structural information, but it has a certain structure. It is necessary to determine the category of elements based on the structure (row and column information of the text). For example, a transaction information of a bond bid in the financial field contains "bond name, guidance range, bond rating, marginal multiple, and the bid position and scalar of a trader of a certain institution". Through the content of the text, as well as their structure and location information, it is easy for people to identify.
[0003] However, the existing technical deep learning model framework mainly targets completely unstructured data. For the example in the figure above, the processing method is to "join all rows of data into one row", which to a certain extent loses the learning of "structure" information; secondly, although pre-trained models such as Bert can add position information. But it adds low-order position information, that is, "the order information of each character in the sentence after all data are joined into one row". It cannot express or learn the higher-order "structural feature" information of "table structure"; thirdly, the optimization models for Chinese, such as LGN, Graph4NER, etc., incorporate high-order "word" information. According to the boundaries of "words", they have a certain learning ability for position information, but they also do not "explicitly" add position structure information to the model. The information extraction effect of semi-structured data is limited. Summary of the invention
[0004] The purpose of the present invention is to provide an information extraction device for semi-structured text in view of the defects and shortcomings of the prior art, which can realize the learning of "structural features" in the text and improve the accuracy of data extraction in the financial field by more than 2%-5%.
[0005] To achieve the above purpose, the present invention adopts the following technical scheme: it includes the segmentation and structure extraction of sentences; the encoding layer module adopts Albert or LSTM to embed the characters of the text; the graph attention network structure layer is used to integrate the word vector that integrates the "structural features" into the expression of the "character" vector; the aggregation layer of features of different granularity adopts the decoder method of transformer for aggregation; the decoding layer adopts the mature CRF algorithm to decode the encoding result R to obtain the final sequence labeling result.
[0006] The word segmentation and structure extraction of the sentence includes: A. Using the existing word segmentation algorithm to segment the text in a paragraph to form individual words; B. By adopting three granularity word segmentation methods, three types of structural information can be correspondingly extracted; C. By using the line break "\n" to determine the line number of each word and the position information of each word in the line, the column number of the word is determined.
[0007] The encoding layer module includes: A. Using the AlBert model pre-trained based on financial dialogue data to perform feature encoding on characters; B. Building a set of word encoding layers based on graph networks through word encoding; C. Using the "structural information" of each word to build a word structural topology graph based on the K-NN neighbor algorithm; D. Forming three graphs, F-Encoding-Graph, M-Encoding-Graph, and C-Encoding-Graph, respectively, according to fine, medium, and coarse-grained word segmentation, which correspond to three symmetrical adjacency matrices, AF, AM, and AC. For M*N topological structures, we construct an M*N*M*N adjacency matrix, and determine the values in the adjacency matrix based on whether they are connected; E. Using the same encoding method based on fine, medium, and coarse-grained word segmentation, and using the GAT algorithm, feature learning is performed on the adjacency matrices AF, AM, and AC.
[0008] The graph attention network structure layer includes: if a "word" contains the character, the "word" is connected to the character; each character and "word" is connected to itself; the others are not connected.
[0009] The aggregation steps of the aggregation layer of the features of different granularities are as follows: A. Directly splice the graph features formed by different granularities to obtain G=[Q1||Q2||Q3]; B. Map G to obtain K and V, and map H to obtain Q; then R1=MultiHeadAttention(Q,K,V); C. Map H to obtain K and V, and map G to obtain Q, then R2=MultiHeadAttention(Q,K,V); D. Fuse the two features R1 and R2, R=α*R1+(1-α)*R2 to obtain the final feature vector, where α is the parameter to be trained.
[0010] The working principle of the present invention is as follows: by extracting the content features of the text, using the existing framework, integrating the learning ability of "structural features" into this framework, firstly, through the coding layer module, using Albert or LSTM to embed the characters of the text; at the same time, using a word segmenter to segment the characters in the text, using the line break "\n" in the characters to calibrate the position and structural information of the word segmentation, and using a graph structure to perform Graphattention on the word segmentation and structural information to obtain word-level embedding. At the upper level, multiple Graphattention structures are used to fuse and jointly learn the vector information of the characters, the vector information of the word segmentation, and the position and structural information of the words, and finally output the vector information of the characters, and then decode the character vectors with a series of annotations through the CRF algorithm.
[0011] After adopting the above technical solution, the beneficial effect of the present invention is that it can realize the learning of "structural features" in texts and can improve the accuracy of data extraction in the financial field by more than 2%-5%. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0013] Figure 1 This is a framework diagram of the information extraction model based on graph network and incorporating “structural features” in the present invention.
[0014] Figure 2 It is a schematic diagram of the "structural information" formed by coarse-grained cutting in the present invention.
[0015] Figure 3 It is the structural topology diagram of the word in the present invention.
[0016] Figure 4 It is a connection diagram of the network structure in the present invention.
[0017] Figure 5 It is a training and learning flow chart for financial data in the present invention. Specific implementation manner
[0018] Refer to Figure 1-Figure 5 As shown, the technical solution adopted in this specific implementation manner includes: word segmentation and structure extraction of sentences; an encoding layer module that uses Albert or LSTM to perform embedding on the characters of the text; a graph attention network structure layer for fusing the word vectors with "structural features" into the expression of "character" vectors; an aggregation layer for different granularity features that uses the decoder method of the transformer for aggregation; and a decoding layer that uses a mature CRF algorithm to decode the encoding result R to obtain the final sequence annotation result.
[0019] The word segmentation and structure extraction of the sentences include: A. For a text segment, using existing word segmentation algorithms, such as jieba word segmentation (including but not limited to) this word segmentation method, this solution adds a private domain dictionary (such as a word segmentation dictionary for financial rules such as financial bond codes and names). The text in a paragraph is segmented and cut to form individual words; B. Three granularity word segmentation methods are adopted, and correspondingly, three types of structure information can be extracted. Taking the bond name "19XX City Investment MTN002" as an example, the first is a fine-grained word segmentation and cutting method, which clearly distinguishes "numbers and Chinese characters" and will be cut into [19, XX, City Investment, MTN, 002]. The second is a medium-grained cutting method, which will be cut into [19, XX City Investment, MTN002]. The third is a coarse-grained cutting method, which is cut into [19XX City Investment MTN002]; C. Structure information extraction. By judging the line number where each word is located through the line break character "\n" and the position information of each word in that line, the column number of the word is determined. A text segment forms the following structure information, which includes the text information of each word and the position information of this word in the table. In the program, the position of each word in the table is marked in the form of (1-1, 1-2, 2-1, 2-2, 3-1, 3-2). The first number represents the line number, and the second number represents the column number. At the same time, it is associated with the word through the form of a word table (such as 19XX City Investment MTN002: 1-1). This solution adopts three different granularity word segmentation and cutting methods, so three types of "structure information" will be formed. For the specific form, refer to the appendix Figure 2 .
[0020] The encoding layer module includes: A. Using the AlBert model pre-trained based on financial dialogue data to perform feature encoding on characters. This character encoding module uses existing technology. Finally, each character ({c1, c2, ..., cm}) forms a feature vector SE with a length of 768 (including but not limited to); B. Word encoding. Based on the graph network, a set of word encoding layers is constructed. First, the words are vectorized through a pre-trained model such as word2vec to form a 300 (including but not limited to) dimensional word vector as the input vector of the lower topological map node; C. According to the K-NN neighbor algorithm, the "structural information" of each word is used to construct a structural topological map of the word. The structural topological map can be found in the attached figure. Figure 3 ; D. According to the fine, medium and coarse-grained word segmentation, three graphs are formed respectively, F-Encoding-Graph, M-Encoding-Graph and C-Encoding-Graph, which correspond to three symmetrical adjacency matrices, AF, AM and AC. For the M*N topological structure, we construct an M*N*M*N adjacency matrix and determine the value in the adjacency matrix according to whether it is connected or not. The generation method of AF, AM and AC is the same, but the dimension of the matrix is different. The value in the adjacency matrix is either 1, indicating connection, or 0, indicating disconnection. Taking the adjacency matrix AF as an example, AF[i,j]=1 means that position i and position j in the topological structure are connected, and AF[i,j]=0 means that position i and position j in the topological structure are not connected; E. In terms of encoding, the same encoding method is used for fine, medium and coarse-grained word segmentation. This scheme adopts the GAT algorithm to perform feature learning on the adjacency matrices AF, AM and AC. Taking the adjacency matrix AF as an example, in the GAT operation, the input of the tth layer is a point set, and there is an adjacency matrix G. The GAT operation with multiple heads is as follows:
[0021] (Formula 1)
[0022] (Formula 2) Among them, f′ i ∈R F represents the input feature of point i; f′ j ∈R F′ represents the output feature of point j; || represents the concatenation operation; σ represents the activation function, and a nonlinear activation function is selected; N i represents the adjacent vertices of i; represents the attention weight between point i and point j; M k ∈R F′×F represents a linear transformation matrix; and are the weights of a feedforward neural network respectively; the output of the last layer is obtained through t=1, 2, ..., N respectively, and then the result of the final AF corresponding to the GAT is calculated:
[0023] (Formula 3) Similarly, the feature results GAT(AM) and GAT(AC) of the corresponding graphs of the adjacency matrices AM and AC are obtained respectively. So far, the word segmentation of different granularities, through the above topological graph structure, uses the GAT formula to integrate the structural information of the text into the vector expression of each word.
[0024] The graph attention network structure layer constructs three graph network structures for word encodings of three different granularities, and fuses the word vector that integrates the "structural features" into the expression of the "character" vector, including: A. If a "word" contains the character, then the "word" is connected to the character; each character and "word" is connected to itself; the others are not connected. Taking the fine-grained word segmentation of 19XX City Investment MTN002 as an example, the connection method is as shown in the attached figure. Figure 4 As shown, when encoding the adjacency matrix, first concatenate words of different granularities to the back of the characters to form a point sequence. If two nodes are connected, the value is assigned to 1, otherwise it is assigned to 0. Assume that the adjacency matrix representing the graph is A. If A[i,j]=1, it means that node i and node j are connected. If A[i,j]=0, it means that node i and node j are not connected, thus forming an N*N standard positive adjacency matrix. Since there are three types of words of granularity, three adjacency matrices are formed, defined as AAF, AAM and AAC; B. According to (Formula 3), GAT(AAF), GAT(AAM), GAT(AAC) can be obtained, and then the final graph features are obtained by the following formula:
[0025] Q1=GAT(AAF)[0:m]
[0026] Q2=GAT(AAM)[0:m]
[0027] Q3=GAT(AAC)[0:m]
[0028] The aggregation layer of features of different granularities obtains three different feature expressions Q1, Q2 and Q3 through the graph attention network layer, and obtains the feature expression H of the character after training through the Albert network layer, and the aggregation is performed by the decoder method of the transformer. The aggregation steps are: A. Directly splicing the graph features formed by different granularities is performed directly to obtain G=[Q1||Q2||Q3]; B. G is mapped to obtain K and V, and H is mapped to obtain Q; then R1=MultiHeadAttention(Q,K,V); C. H is mapped to obtain K and V, and G is mapped to obtain Q, then R2=MultiHeadAttention(Q,K,V); D. The two features R1 and R2 are merged, R=α*R1+(1-α)*R2 to obtain the final feature vector, and α is the parameter to be trained.
[0029] Finally, the mature CRF algorithm is used through the decoding layer to decode the encoded result R to obtain the final sequence labeling result.
[0030] The working principle of the present invention is as follows: by extracting the content features of the text, using the existing framework, integrating the learning ability of "structural features" into this framework, firstly, through the coding layer module, using Albert or LSTM to embed the characters of the text; at the same time, using a word segmenter to segment the characters in the text, using the line break "\n" in the characters to calibrate the position and structural information of the word segmentation, and using a graph structure to perform Graphattention on the word segmentation and structural information to obtain word-level embedding. At the upper level, multiple Graphattention structures are used to fuse and jointly learn the vector information of the characters, the vector information of the word segmentation, and the position and structural information of the words, and finally output the vector information of the characters, and then decode the character vectors with a series of annotations through the CRF algorithm.
[0031] After adopting the above technical solution, the beneficial effect of the present invention is that it can realize the learning of "structural features" in texts and can improve the accuracy of data extraction in the financial field by more than 2%-5%.
[0032] The above description is only used to illustrate the technical solution of the present invention rather than to limit it. Other modifications or equivalent substitutions made to the technical solution of the present invention by ordinary technicians in this field should be included in the scope of the claims of the present invention as long as they do not depart from the spirit and scope of the technical solution of the present invention.
Claims
1. A device for extracting information from semi-structured text, characterized in that: It includes the word segmentation and structure extraction of sentences; the encoding layer module uses Albert or LSTM to embed the characters of the text; the graph attention network structure layer is used to integrate the word vector that integrates the "structural features" into the expression of the "character" vector; the aggregation layer of features of different granularity uses the transformer decoder method for aggregation; the decoding layer uses the mature CRF algorithm to decode the encoding result R to obtain the final sequence labeling result; The word segmentation and structure extraction of the sentence includes: A. using the existing word segmentation algorithm to segment the text in a paragraph to form individual words; B. using three word segmentation methods with three granularities to extract three structural information accordingly; C. judging the line number of each word and the position information of each word in the line through the line break character "\n", and determining the column number of the word; The encoding layer module includes: A. Using the AlBert model pre-trained based on financial dialogue data to perform feature encoding on characters; B. Building a set of word encoding layers based on graph networks through word encoding; C. Using the "structural information" of each word to build a word structural topological graph according to the K-NN neighbor algorithm; D. Forming three graphs, F-Encoding-Graph, M-Encoding-Graph, and C-Encoding-Graph, respectively, according to fine, medium, and coarse-grained word segmentation, which correspond to three symmetrical adjacency matrices AF, AM, and AC, respectively. For an M*N topological structure, an M*N*M*N adjacency matrix is constructed, and the value in the adjacency matrix is determined according to whether it is connected; E. Using the same encoding method according to fine, medium, and coarse-grained word segmentation, and using the GAT algorithm at the same time, feature learning is performed on the adjacency matrices AF, AM, and AC; Among them, in the adjacency matrix AF, in the GAT operation, the input of the tth layer is a point set, and there is an adjacency matrix G. The GAT operation with multiple heads is as follows: Formula 1: Formula 2: Among them, f′ i ∈R F represents the input feature of point i; || represents the concatenation operation; σ represents the activation function, and a nonlinear activation function is selected; N i represents the adjacent vertices of i; represents the attention weight between point i and point j; M k ∈R F′×F represents a linear transformation matrix; and are the weights of a feedforward neural network respectively; the output of the last layer is obtained by t=1, 2, ..., N respectively, and then the result of the final adjacency matrix AF corresponding to GAT is calculated: Formula 3: The graph attention network structure layer constructs three graph network structures for word encodings of three different granularities, and fuses the word vector that integrates the "structural features" into the expression of the "character" vector, including: A. If the word contains a corresponding character, the word is connected to the character; each character and word are connected to themselves; the others are not connected; B. Since there are three granularities of words, three adjacency matrices are formed, defined as AAF, AAM and AAC. According to formula 3, GAT(AAF), GAT(AAM) and GAT(AAC) are obtained, and then the final graph features are obtained by the following formula: Q1=GAT(AAF)[0:m] Q2=GAT(AAM)[0:m] Q3 = GAT(AAC)[0:m]; The aggregation layer of features of different granularities obtains three different feature expressions Q1, Q2 and Q3 through the graph attention network layer, and obtains the feature expression H of the character after training through the Albert network layer, and the aggregation is performed by the decoder method of the transformer. The aggregation steps are: A. Directly splicing the graph features formed by different granularities is performed directly to obtain G=[Q1||Q2||Q3]; B. G is mapped to obtain K′ and V, and H is mapped to obtain Q, then R1=MultiHeadAttention(Q,K′,V); C. H is mapped to obtain K″ and V′, and G is mapped to obtain Q′, then R2=MultiHeadAttention(Q′,K″,V′); D. The two features R1 and R2 are merged, R=α*R1+(1-α)*R2 to obtain the final feature vector, and α is the parameter to be trained.
