Text information extraction method, device, equipment and readable storage medium
By using the information extraction model in text information extraction for feature extraction, classification and association mapping, and building an undirected graph for extremely large cluster screening association, the problem of being unable to directly extract specific information in the existing technology is solved, and the efficiency of text information extraction is improved.
Patent Information
- Application Number
- CN202110377541.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-08
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2041-04-08
AI Technical Summary
Existing text information extraction methods cannot directly extract specific information, such as each fruit and the corresponding unit price, which is inefficient.
By receiving the text to be extracted, position information marking is performed, and using the feature extraction layer, text classification layer and text matching layer in the information extraction model, feature extraction, classification and association mapping of the text, undirected graphs are constructed and massive screening associations are performed to obtain the target information text.
It improves the efficiency of text information extraction and can directly extract the required information, such as each fruit and the corresponding unit price.
Smart Images

Figure CN112860905B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent decision-making, and in particular to a text information extraction method, device, electronic device and readable storage medium. Background Art
[0002] Text information extraction is an extremely important technology in the field of natural language processing. Its main function is to extract the required information from the text and classify specific information.
[0003] However, the current text information extraction method can only extract specific information or classify information, and cannot directly obtain the required information. For example, it is necessary to extract each type of fruit and the corresponding unit price in the text, but the current text extraction can only extract the fruit and the unit price or classify different fruits and the corresponding unit prices, and cannot directly extract each type of fruit and the corresponding unit price, so the efficiency of information extraction is low. Summary of the invention
[0004] The present invention provides a text information extraction method, device, electronic device and computer-readable storage medium, the main purpose of which is to improve the efficiency of text information extraction.
[0005] To achieve the above object, the present invention provides a text information extraction method, comprising:
[0006] Receiving a text to be extracted, marking position information of the text to be extracted, and obtaining a standard text sequence;
[0007] Using the feature extraction layer in the information extraction model to extract features from the standard text sequence to obtain a text feature matrix;
[0008] Using the text classification layer in the information extraction model to classify the text feature matrix, obtaining a text information classification result;
[0009] Using the text matching layer in the information extraction model to classify the elements of the text feature matrix, obtaining a text feature map matrix;
[0010] Perform association mapping according to the text feature map matrix to obtain a text information association result;
[0011] According to the text information classification results and the text information association results, an undirected graph is constructed and a maximum clique is screened and associated to obtain the target information text.
[0012] Optionally, before extracting information from the standard text sequence using the information extraction model to obtain the text information classification result and the text information association result, the method further includes:
[0013] Obtain a historical text set, perform multi-label labeling on the historical text set, and obtain a training sample set;
[0014] The pre-built deep learning model is trained using the training sample set to obtain the information extraction model.
[0015] Optionally, the acquiring of a historical text set and multi-label marking of the historical text set to obtain a training sample set includes:
[0016] Marking each historical text in the historical text set with an information category label, a character coordinate label, and an information category association label to obtain a corresponding training sample;
[0017] Performing word segmentation processing on the training samples to obtain word segmentation sequence samples;
[0018] All the word segmentation sequence samples are aggregated to obtain the training sample set.
[0019] Optionally, information features are extracted from the standard text sequence using a feature extraction layer in an information extraction model to obtain a text feature matrix, including:
[0020] Using a feature extraction layer of an information extraction model to convert each word in the standard text sequence into a word vector;
[0021] All the converted word vectors are combined according to the order of the corresponding words in the standard text sequence to obtain the text feature matrix.
[0022] Optionally, the using the text matching layer in the information extraction model to classify the elements of the text feature matrix to obtain a text feature map matrix includes:
[0023] Transposing the text feature matrix to obtain a text feature row matrix;
[0024] Perform matrix multiplication calculation on the text feature row matrix and the text feature matrix to obtain an initial text feature map matrix;
[0025] Each element in the text feature map matrix is classified using a preset classification function to obtain the text feature map matrix.
[0026] Optionally, performing association mapping according to the text feature map matrix to obtain a text information association result includes:
[0027] Filter the row and column numbers corresponding to each element of a preset numerical value in the text feature map matrix to obtain an associative array corresponding to each element of a preset numerical value;
[0028] Select words of corresponding order in the standard text sequence according to the association array to mark the association relationship, and obtain the associated text;
[0029] All the associated texts are collected to obtain the text information association result.
[0030] Optionally, the step of constructing an undirected graph and performing maximum clique screening and association according to the text information classification result and the text information association result to obtain the target information text includes:
[0031] Constructing an undirected graph according to the text information association result to obtain an associated undirected graph;
[0032] Selecting a maximal clique in the associated undirected graph to obtain the corresponding associated matching group;
[0033] Each of the associated matching groups is associated with the text information classification result to obtain the target information text.
[0034] In order to solve the above problem, the present invention also provides a text information extraction device, the device comprising:
[0035] A sample processing module is used to receive the text to be extracted, mark the position information of the text to be extracted, and obtain a standard text sequence;
[0036] The model extraction module is used to extract features from the standard text sequence using the feature extraction layer in the information extraction model to obtain a text feature matrix; classify the text feature matrix using the text classification layer in the information extraction model to obtain a text information classification result; classify elements of the text feature matrix using the text matching layer in the information extraction model to obtain a text feature map matrix; and perform association mapping based on the text feature map matrix to obtain a text information association result;
[0037] The extraction result processing module is used to construct an undirected graph and perform maximum clique screening and association according to the text information classification results and the text information association results to obtain the target information text.
[0038] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:
[0039] a memory storing at least one computer program; and
[0040] The processor executes the computer program stored in the memory to implement the above-mentioned text information extraction method.
[0041] In order to solve the above problem, the present invention also provides a computer-readable storage medium, in which at least one computer program is stored. The at least one computer program is executed by a processor in an electronic device to implement the above-mentioned text information extraction method.
[0042] The embodiment of the present invention marks the position information of the text to be extracted to obtain a standard text sequence; uses the information extraction model to perform text classification and matching association on the standard text sequence to obtain text information classification results and text information association results, and uses one model to simultaneously realize information extraction and information association classification, thereby improving efficiency; performs undirected graph construction and maximum clique screening association based on the text information classification results and the text information association results to obtain the target information text, and post-processes the model extraction results, uses the undirected graph for screening, associates the information of the two dimensions, associates and classifies the extracted information, and directly obtains the required information, thereby improving the efficiency of information extraction. Therefore, the text information extraction method, device, electronic device, and computer-readable storage medium proposed in the embodiment of the present invention improve the efficiency of text information extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 A flowchart of a text information extraction method provided by an embodiment of the present invention;
[0044] Figure 2 A schematic diagram of a process for obtaining an information extraction model in one embodiment of the present invention;
[0045] Figure 3 A schematic diagram of a module of a text information extraction device provided by an embodiment of the present invention;
[0046] Figure 4 A schematic diagram of the internal structure of an electronic device for implementing a text information extraction method provided by an embodiment of the present invention;
[0047] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0048] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0049] The embodiment of the present invention provides a method for extracting text information. The execution subject of the text information extraction method includes but is not limited to at least one of the electronic devices such as a server and a terminal that can be configured to execute the method provided by the embodiment of the present application. In other words, the text information extraction method can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc.
[0050] Reference Figure 1 FIG. 1 is a flow chart of a text information extraction method provided by an embodiment of the present invention. In the embodiment of the present invention, the text information extraction method includes:
[0051] S1, receiving a text to be extracted, marking the position information of the text to be extracted, and obtaining a standard text sequence;
[0052] In an embodiment of the present invention, the text to be extracted is a document text of different formats, such as a document text in doc format and a document text in picture format. In order to extract information more accurately, the position information of the characters is used as an auxiliary feature to mark the character coordinates of each character in the text to be extracted to obtain a marked text, wherein the character coordinates are marked by using a marking tool to mark the horizontal and vertical coordinates of each character in the text to be extracted in the document where the text to be extracted is located. Furthermore, the marked text is segmented to obtain a standard text sequence.
[0053] In another embodiment of the present invention, in order to ensure the privacy of data, the standard text sequence can be stored in a blockchain node.
[0054] S2, extracting features from the standard text sequence using a feature extraction layer in an information extraction model to obtain a text feature matrix;
[0055] Optionally, the information extraction model in the embodiment of the present invention includes: a feature extraction layer, a text classification layer and a text matching layer. The text classification layer is used to classify text information, and the text matching layer is used to associate text information. The text classification layer in the information extraction model outputs the text information classification result, and the text matching layer in the information extraction model outputs the text information association result. Furthermore, the text information classification result is the information category corresponding to different information texts, and the text information association result is the association relationship between different information texts in the standard text sequence.
[0056] Optionally, the feature extraction layer is a layoutLM model, the text classification layer is a softmax classification network, and the text matching layer is a graph network model.
[0057] In detail, in the embodiment of the present invention, each word in the standard text sequence is converted into a word vector using the feature extraction layer of the information extraction model; further, in the embodiment of the present invention, all the converted word vectors are combined according to the order of the corresponding words in the standard text sequence to obtain the text feature matrix, such as: the standard text sequence is [China, United States], "China" is converted into word vector b, and "United States" is converted into word vector a, then the text feature matrix is [b, a]. Optionally, the word vector is a column vector.
[0058] Further, in the embodiment of the present invention, refer to Figure 2 As shown, before extracting features from the standard text sequence using the feature extraction layer in the information extraction model, it also includes:
[0059] S21, obtaining a historical text set, and performing multi-label labeling on the historical text set to obtain a training sample set;
[0060] In an embodiment of the present invention, the historical text set is a collection of multiple historical texts, and the historical text is a text of the same type as the text to be extracted but with different contents, such as a doc format document text or a picture format document.
[0061] Specifically, in the embodiments of the present invention, in order to accurately extract information from the model, each historical text in the historical text set is marked with an information category label, a character coordinate label, and an information category association label to obtain corresponding training samples. The training samples are subjected to word segmentation processing to obtain a word segmentation sequence sample. Optionally, in the embodiments of the present invention, the training samples are subjected to stop word deletion processing to obtain an initial word segmentation sample, where the stop words include words without practical meanings such as function words, modal particles, and auxiliary words, such as: "de", "a"; the initial word segmentation sample is segmented using a preset word segmentation dictionary to obtain the word segmentation sequence sample, where the word segmentation dictionary is a dictionary containing multiple words. Further, the word segmentation processing does not affect the labels corresponding to the training samples. All the word segmentation sequence samples are aggregated to obtain a training sample set. Among them, the information category label marking is to mark the text of the information category to be extracted in the historical text. For example, if the information category labels to be marked are fruit types and fruit unit prices, and the historical text is "Bought 5 catties of apples today, 10 yuan per catty", "apples" is marked as the fruit type, and "10 yuan" is marked as the fruit unit price; the character coordinate label marking is to use a labeling tool to label the horizontal and vertical coordinate labels of each character in the historical text in the document where the historical text is located. The information category association label marking is to perform association marking on the texts of mutually related information categories. For example, the historical text is "Bought some apples and bananas today. Bananas are quite cheap, 3 yuan per catty, but apples are a bit expensive, 15 yuan per catty". The information category labels to be marked are fruit types and fruit unit prices. "Apples" and "bananas" are marked as fruit types, and "15 yuan" and "3 yuan" are marked as fruit unit prices; "apples" and "15 yuan" are marked with an information category label association, and "bananas" and "3 yuan" are marked with an information category label association.
[0062] In the embodiments of the present invention, by performing multi-label marking on the historical text set, the feature dimension extracted by the model is increased, and the robustness of the model is enhanced.
[0063] S22. Use the training sample set to train a pre-constructed deep learning model to obtain the information extraction model;
[0064] In the embodiments of the present invention, the training sample set is used to train the pre-constructed deep learning model until the deep learning model converges to obtain the information extraction model.
[0065] Optionally, in the embodiments of the present invention, the information extraction model is obtained by training the deep learning model. Therefore, the information extraction model has the same structure as the deep learning model, which will not be elaborated here.
[0066] In detail, in an embodiment of the present invention, the pre-constructed deep learning model is trained using the training sample set until the deep learning model converges to obtain the information extraction model, including:
[0067] Step A: using the feature extraction layer of the deep learning model to convert each word of the word segmentation sequence sample in the training sample set into a word vector to obtain a feature matrix, using the first activation function preset in the text classification layer of the deep learning model to calculate the classification probability value corresponding to the feature matrix, and determining the classification true value corresponding to the feature matrix according to the information category label of the word segmentation sequence sample;
[0068] Step B: According to the classification true value and the classification probability value, a classification loss value is calculated using a preset first loss function;
[0069] Step C: using the text matching layer of the deep learning model to perform matrix transposition on the feature matrix to obtain a feature row matrix, performing matrix multiplication calculation on the feature row matrix and the feature matrix to obtain a feature graph matrix, using a preset second activation function to calculate the associated probability value corresponding to each element of the feature graph matrix, and determining the associated true value corresponding to each element of the feature graph matrix according to the information category associated label of the word segmentation sequence sample;
[0070] In detail, in the embodiment of the present invention, the feature row matrix is m*1 dimensional, the feature matrix is 1*m dimensional, and the feature graph matrix is n*n dimensional; each column in the feature matrix and each row in the feature row matrix respectively represent different word features in the word segmentation sequence sample, and each element in the feature graph matrix represents the product of the feature row matrix and the different word features of the feature row matrix, so as to represent the association relationship between different words in the word segmentation sequence sample;
[0071] Optionally, in another embodiment of the present invention, in order to reduce the amount of calculation, the maximum value of each column in the feature matrix can be screened as the column eigenvalue corresponding to each column; the column eigenvalues corresponding to each column of the feature matrix are combined according to the order of columns in the feature matrix to obtain the feature column matrix, thereby achieving dimensional compression, and then the feature row matrix and the feature column matrix are subjected to matrix multiplication to obtain a feature graph matrix; for example, the feature matrix is 768*512 dimensional, and after dimensional compression, it becomes a 1*512 feature row matrix, and the element of each column of the feature row matrix is the maximum value of the corresponding column of the feature matrix.
[0072] Step D: According to the association probability value and the association true value, a preset second loss function is used to calculate to obtain an association loss value;
[0073] Step E: Calculate the target loss value based on the classification loss value and the association loss value. When the target loss value is greater than or equal to a preset threshold, update the model parameters of the deep learning model and return to the above step A until the target loss value is less than the preset threshold to obtain the information extraction model.
[0074] Optionally, the first activation function and the second activation function are relu functions, and the first loss function and the second loss function are logarithmic loss functions.
[0075] Furthermore, since the information extraction model is obtained by training the deep learning model, the information extraction model also includes a feature extraction layer, a text classification layer and a text matching layer. The standard text sequence is input into the information extraction model, the text classification layer in the information extraction model outputs the text information classification result, and the text matching layer in the information extraction model outputs the text information association result. Furthermore, the text information classification result is the information category corresponding to different information texts, and the text information association result is the association relationship between different information texts in the standard text sequence.
[0076] S3, classifying the text feature matrix using the text classification layer in the information extraction model to obtain a text information classification result;
[0077] Optionally, the text classification layer in the information extraction model in the embodiment of the present invention is a softmax classification network.
[0078] S4, using the text matching layer in the information extraction model to classify the elements of the text feature matrix to obtain a text feature map matrix;
[0079] In detail, in an embodiment of the present invention, the text feature matrix is transposed to obtain a text feature row matrix. For example, if the text feature matrix is m*n dimensional, the text feature matrix is transposed to obtain a text feature row matrix of n*m dimensional.
[0080] Furthermore, an embodiment of the present invention performs matrix multiplication on the text feature row matrix and the text feature matrix to obtain an initial text feature map matrix; for example: if the text feature row matrix is n*m dimensional and the text feature matrix is m*n dimensional, then the initial text feature map matrix is n*n dimensional, where n is consistent with the number of words in the standard text sequence.
[0081] In detail, in an embodiment of the present invention, a preset classification function is used to classify each element in the text feature map matrix to obtain the text feature map matrix, wherein each element in the text feature map matrix represents the product of a text feature row matrix and different word features in the text feature matrix. Each element is classified by using a preset classification function. If the classification result of the element is associated, the element is replaced with 1; if the classification result of the element is unassociated, the element is replaced with 0 to obtain the text feature map matrix composed of 0 and 1. Optionally, the classification function is a softmax function.
[0082] S5, performing association mapping according to the text feature map matrix to obtain a text information association result;
[0083] In detail, in the embodiment of the present invention, the row and column numbers corresponding to each element of a preset numerical size in the text feature map matrix are screened to obtain an associative array corresponding to each element of the preset numerical size.
[0084] Optionally, the preset numerical value in the embodiment of the present invention is 1, therefore, the two words corresponding to the elements with a numerical value of 1 in the text feature map matrix are associated, such as: the element in the 5th row and 6th column is 1, then the associated array corresponding to the element is [5,6].
[0085] Furthermore, in an embodiment of the present invention, words of corresponding order in the standard text sequence are selected according to the association array to mark the association relationship to obtain associated text; for example, if the association array is [5,6], then the 5th word A and the 6th word B in the standard text sequence are selected, the association relationship is marked, and the associated text obtained is that word A is associated with word B.
[0086] Furthermore, the embodiment of the present invention aggregates all the associated texts to obtain the text information association result.
[0087] S6. Construct an undirected graph and perform maximum clique screening and association according to the text information classification result and the text information association result to obtain the target information text.
[0088] In detail, the embodiment of the present invention constructs an undirected graph according to the text information association result to obtain the association undirected graph; optionally, the embodiment of the present invention uses each word in the text information association result as a node; uses the association relationship in the text information association result as an edge to construct an undirected graph to obtain the association undirected graph, such as: the text information association result has a total of 4 words "apple", "banana", "15 yuan", and "3 yuan", the word "apple" has an association relationship with "15 yuan", and the word "banana" has an association relationship with "3 yuan", then the 4 words are used as nodes, and the two association relationships are used as edges. as an edge; further, the embodiment of the present invention selects the maximal clique in the associated undirected graph to obtain the corresponding associated matching group; associates each of the associated matching groups with the text information classification result to obtain the target information text, such as: the information text corresponding to the fruit types in the information classification result is "apple" and "banana", and the information text corresponding to the fruit unit price is "15 yuan" and "3 yuan"; the associated matching group is "apple" and "15 yuan" as a group, and "banana" and "3 yuan" as a group, then the associated target information text is the unit price of apple is 15 yuan and the unit price of banana is 3 yuan.
[0089] The embodiment of the present invention marks the position information of the text to be extracted to obtain a standard text sequence; uses the information extraction model to perform text classification and matching association on the standard text sequence to obtain text information classification results and text information association results, and uses one model to simultaneously realize information extraction and information association classification, thereby improving efficiency; performs undirected graph construction and maximum clique screening association based on the text information classification results and the text information association results to obtain the target information text, and post-processes the model extraction results, uses the undirected graph for screening, associates the information of the two dimensions, associates and classifies the extracted information, and directly obtains the required information, thereby improving the efficiency of information extraction. Therefore, the text information extraction method, device, electronic device, and computer-readable storage medium proposed in the embodiment of the present invention improve the efficiency of text information extraction.
[0090] like Figure 3 The figure shows a functional module diagram of the text information extraction device of the present invention.
[0091] The text information extraction device 100 of the present invention can be installed in an electronic device. According to the functions to be implemented, the text information extraction device can include a sample processing module 101, a model extraction module 102, and an extraction result processing module 103. The modules described in the present invention can also be referred to as units, which refer to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, and are stored in the memory of the electronic device.
[0092] In this embodiment, the functions of each module / unit are as follows:
[0093] The sample processing module 101 is used to receive the text to be extracted, mark the position information of the text to be extracted, and obtain a standard text sequence;
[0094] In the embodiment of the present invention, the text to be extracted is a document text of different formats, such as a document text in doc format and a document text in picture format. In order to extract information more accurately, the sample processing module 101 uses the position information of the characters as an auxiliary feature to mark the character coordinates of each character in the text to be extracted to obtain a marked text, wherein the character coordinates are marked by using a marking tool to mark the horizontal and vertical coordinates of each character in the text to be extracted in the document where the text to be extracted is located. Furthermore, the sample processing module 101 performs word segmentation processing on the marked text to obtain a standard text sequence.
[0095] In another embodiment of the present invention, in order to ensure the privacy of data, the standard text sequence can be stored in a blockchain node.
[0096] The model extraction module 102 is used to extract features from the standard text sequence using the feature extraction layer in the information extraction model to obtain a text feature matrix; classify the text feature matrix using the text classification layer in the information extraction model to obtain a text information classification result; classify elements of the text feature matrix using the text matching layer in the information extraction model to obtain a text feature map matrix; perform association mapping based on the text feature map matrix to obtain a text information association result;
[0097] Optionally, the information extraction model in the embodiment of the present invention includes: a feature extraction layer, a text classification layer and a text matching layer. The text classification layer is used to classify text information, and the text matching layer is used to associate text information. The text classification layer in the information extraction model outputs the text information classification result, and the text matching layer in the information extraction model outputs the text information association result. Furthermore, the text information classification result is the information category corresponding to different information texts, and the text information association result is the association relationship between different information texts in the standard text sequence.
[0098] Optionally, the feature extraction layer is a layoutLM model, the text classification layer is a softmax classification network, and the text matching layer is a graph network model.
[0099] In detail, the model extraction module 102 in the embodiment of the present invention uses the feature extraction layer of the information extraction model to convert each word in the standard text sequence into a word vector; further, the embodiment of the present invention combines all the converted word vectors according to the order of the corresponding words in the standard text sequence to obtain the text feature matrix, such as: the standard text sequence is [China, United States], "China" is converted into word vector b, and "United States" is converted into word vector a, then the text feature matrix is [b, a]. Optionally, the word vector is a column vector.
[0100] Furthermore, in the embodiment of the present invention, before the model extraction module 102 uses the feature extraction layer in the information extraction model to extract features from the standard text sequence, it also includes the following steps:
[0101] Obtain a historical text set, perform multi-label labeling on the historical text set, and obtain a training sample set;
[0102] In an embodiment of the present invention, the historical text set is a collection of multiple historical texts, and the historical text is a text of the same type as the text to be extracted but with different contents, such as a doc format document text or a picture format document.
[0103] Specifically, in the embodiments of the present invention, in order to accurately extract information from the model, each historical text in the historical text set is marked with an information category label, a character coordinate label, and an information category association label to obtain corresponding training samples. The training samples are subjected to word segmentation processing to obtain word segmentation sequence samples. Optionally, in the embodiments of the present invention, the training samples are subjected to stop word deletion processing to obtain initial word segmentation samples, where the stop words include words without practical meanings such as function words, modal particles, and auxiliary words, such as "de" (of), "a"; the initial word segmentation samples are segmented using a preset word segmentation dictionary to obtain the word segmentation sequence samples, where the word segmentation dictionary is a dictionary containing multiple words. Further, the word segmentation processing does not affect the labels corresponding to the training samples. All the word segmentation sequence samples are aggregated to obtain a training sample set. Among them, the information category label marking is to mark the text of the information category that needs to be extracted in the historical text. For example, if the information category labels to be marked are fruit types and fruit unit prices, and the historical text is "Bought 5 catties of apples today, 10 yuan per catty", "apples" is marked as the fruit type, and "10 yuan" is marked as the fruit unit price; the character coordinate label marking is to use a labeling tool to label the horizontal and vertical coordinate labels of each character in the historical text in the document where the historical text is located. The information category association label marking is to associate and mark the texts of mutually related information categories. For example, the historical text is "Bought some apples and bananas today. Bananas are quite cheap, 3 yuan per catty, but apples are a bit expensive, 15 yuan per catty". The information category labels to be marked are fruit types and fruit unit prices. "Apples" and "bananas" are marked as fruit types, and "15 yuan" and "3 yuan" are marked as fruit unit prices; "apples" and "15 yuan" are marked with information category label association, and "bananas" and "3 yuan" are marked with information category label association.
[0104] In the embodiments of the present invention, by performing multi-label marking on the historical text set, the feature dimension extracted by the model is increased, and the robustness of the model is enhanced.
[0105] The pre-constructed deep learning model is trained using the training sample set to obtain the information extraction model;
[0106] In the embodiments of the present invention, the pre-constructed deep learning model is trained using the training sample set until the deep learning model converges to obtain the information extraction model.
[0107] Optionally, in the embodiments of the present invention, since the information extraction model is obtained by training the deep learning model, the information extraction model has the same structure as the deep learning model, which will not be elaborated here.
[0108] In detail, in the embodiment of the present invention, the model extraction module 102 obtains the information extraction model using the following steps, including:
[0109] Step A: using the feature extraction layer of the deep learning model to convert each word of the word segmentation sequence sample in the training sample set into a word vector to obtain a feature matrix, using the first activation function preset in the text classification layer of the deep learning model to calculate the classification probability value corresponding to the feature matrix, and determining the classification true value corresponding to the feature matrix according to the information category label of the word segmentation sequence sample;
[0110] Step B: According to the classification true value and the classification probability value, a classification loss value is calculated using a preset first loss function;
[0111] Step C: using the text matching layer of the deep learning model to perform matrix transposition on the feature matrix to obtain a feature row matrix, performing matrix multiplication calculation on the feature row matrix and the feature matrix to obtain a feature graph matrix, using a preset second activation function to calculate the associated probability value corresponding to each element of the feature graph matrix, and determining the associated true value corresponding to each element of the feature graph matrix according to the information category associated label of the word segmentation sequence sample;
[0112] In detail, in the embodiment of the present invention, the feature row matrix is m*1 dimensional, the feature matrix is 1*m dimensional, and the feature graph matrix is n*n dimensional; each column in the feature matrix and each row in the feature row matrix respectively represent different word features in the word segmentation sequence sample, and each element in the feature graph matrix represents the product of the feature row matrix and the different word features of the feature row matrix, so as to represent the association relationship between different words in the word segmentation sequence sample;
[0113] Optionally, in another embodiment of the present invention, in order to reduce the amount of calculation, the model extraction module 102 can also select the maximum value of each column in the feature matrix as the column eigenvalue corresponding to each column; combine the column eigenvalues corresponding to each column of the feature matrix according to the order of columns in the feature matrix to obtain the feature column matrix, realize dimensional compression, and then perform matrix multiplication on the feature row matrix and the feature column matrix to obtain a feature graph matrix; for example: the feature matrix is 768*512 dimensional, and after dimensional compression it becomes a 1*512 feature row matrix, and the element of each column of the feature row matrix is the maximum value of the corresponding column of the feature matrix.
[0114] Step D: According to the association probability value and the association true value, a preset second loss function is used to calculate to obtain an association loss value;
[0115] Step E: Calculate the target loss value based on the classification loss value and the association loss value. When the target loss value is greater than or equal to a preset threshold, update the model parameters of the deep learning model and return to the above step A until the target loss value is less than the preset threshold to obtain the information extraction model.
[0116] Optionally, the first activation function and the second activation function are relu functions, and the first loss function and the second loss function are logarithmic loss functions.
[0117] Optionally, the text classification layer in the information extraction model in the embodiment of the present invention is a softmax classification network.
[0118] In detail, the model extraction module 102 in the embodiment of the present invention performs a matrix transposition on the text feature matrix to obtain a text feature row matrix. For example, if the text feature matrix is m*n dimensional, the text feature matrix is transposed to obtain a text feature row matrix of n*m dimensional.
[0119] Furthermore, the model extraction module 102 described in the embodiment of the present invention performs matrix multiplication on the text feature row matrix and the text feature matrix to obtain an initial text feature map matrix; for example: the text feature row matrix is n*m dimensional and the text feature matrix is m*n dimensional, then the initial text feature map matrix is n*n dimensional, where n is consistent with the number of words in the standard text sequence.
[0120] In detail, the model extraction module 102 in the embodiment of the present invention uses a preset classification function to classify each element in the text feature map matrix to obtain the text feature map matrix, wherein each element in the text feature map matrix represents the product of the text feature row matrix and the different word features of the text feature matrix. Each element is classified by using a preset classification function. If the classification result of the element is associated, the element is replaced with 1; if the classification result of the element is unassociated, the element is replaced with 0 to obtain the text feature map matrix composed of 0 and 1. Optionally, the classification function is a softmax function.
[0121] In detail, the model extraction module 102 in the embodiment of the present invention screens the row and column numbers corresponding to each element of a preset numerical size in the text feature map matrix to obtain an associative array corresponding to each element of a preset numerical size.
[0122] Optionally, the preset numerical value in the embodiment of the present invention is 1, therefore, the two words corresponding to the elements with a numerical value of 1 in the text feature map matrix are associated, such as: the element in the 5th row and 6th column is 1, then the associated array corresponding to the element is [5,6].
[0123] Furthermore, the model extraction module 102 selects words of corresponding order in the standard text sequence according to the association array to mark the association relationship to obtain the associated text; for example, if the association array is [5,6], then the 5th word A and the 6th word B in the standard text sequence are selected, the association relationship is marked, and the associated text obtained is that word A is associated with word B.
[0124] Furthermore, the embodiment of the present invention collects all the related texts to obtain the text information related results. The extraction result processing module 103 is used to construct an undirected graph and perform maximum clique screening and association according to the text information classification results and the text information related results to obtain the target information text.
[0125] In detail, in the embodiment of the present invention, the extraction result processing module 103 constructs an undirected graph according to the text information association result to obtain an associated undirected graph; optionally, in the embodiment of the present invention, each word in the text information association result is used as a node; the associated relationship in the text information association result is used as an edge to construct an undirected graph to obtain the associated undirected graph, such as: the text information association result has a total of 4 words "apple", "banana", "15 yuan", and "3 yuan", the word "apple" has an associated relationship with "15 yuan", and the word "banana" has an associated relationship with "3 yuan", then the 4 words are used as nodes, and two association relationships as edges; further, the embodiment of the present invention selects the maximal clique in the association undirected graph to obtain the corresponding association matching group; associates each of the association matching groups with the text information classification result to obtain the target information text, such as: the information text corresponding to the fruit type in the information classification result is "apple" and "banana", and the information text corresponding to the fruit unit price is "15 yuan" and "3 yuan"; the association matching group is "apple" and "15 yuan" as a group, and "banana" and "3 yuan" as a group, then the associated target information text is apple unit price 15 yuan and banana unit price 3 yuan.
[0126] like Figure 4 FIG. 1 is a schematic diagram of the structure of an electronic device for implementing the text information extraction method of the present invention.
[0127] The electronic device 1 may include a processor 10 , a memory 11 and a bus, and may also include a computer program stored in the memory 11 and executable on the processor 10 , such as a text information extraction program 12 .
[0128] The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. The memory 11 may be an internal storage unit of the electronic device 1 in some embodiments, such as a mobile hard disk of the electronic device 1. The memory 11 may also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 1. Further, the memory 11 may also include both an internal storage unit of the electronic device 1 and an external storage device. The memory 11 may not only be used to store application software and various types of data installed in the electronic device 1, such as the code of a text information extraction program, etc., but may also be used to temporarily store data that has been output or is to be output.
[0129] The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips, etc. The processor 10 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules (such as text information extraction programs, etc.) stored in the memory 11, and calls data stored in the memory 11 to execute various functions of the electronic device 1 and process data.
[0130] The bus may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize connection and communication between the memory 11 and at least one processor 10, etc.
[0131] Figure 4 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 4The structure shown does not constitute a limitation on the electronic device 1, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0132] For example, although not shown, the electronic device 1 may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include any components such as one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, etc. The electronic device 1 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0133] Furthermore, the electronic device 1 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device 1 and other electronic devices.
[0134] Optionally, the electronic device 1 may further include a user interface, which may be a display, an input unit (such as a keyboard), or a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device 1 and to display a visual user interface.
[0135] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0136] The text information extraction program 12 stored in the memory 11 of the electronic device 1 is a combination of multiple computer programs. When running in the processor 10, it can achieve:
[0137] Receiving a text to be extracted, marking position information of the text to be extracted, and obtaining a standard text sequence;
[0138] Using the feature extraction layer in the information extraction model to extract features from the standard text sequence to obtain a text feature matrix;
[0139] Using the text classification layer in the information extraction model to classify the text feature matrix, obtaining a text information classification result;
[0140] Using the text matching layer in the information extraction model to classify the elements of the text feature matrix, obtaining a text feature map matrix;
[0141] Perform association mapping according to the text feature map matrix to obtain a text information association result;
[0142] According to the text information classification results and the text information association results, an undirected graph is constructed and a maximum clique is screened and associated to obtain the target information text.
[0143] Specifically, the specific implementation method of the processor 10 for the above computer program can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0144] Furthermore, if the module / unit integrated in the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable medium can be non-volatile or volatile. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).
[0145] An embodiment of the present invention may further provide a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor of an electronic device, the computer program may implement:
[0146] Receiving a text to be extracted, marking position information of the text to be extracted, and obtaining a standard text sequence;
[0147] Using the feature extraction layer in the information extraction model to extract features from the standard text sequence to obtain a text feature matrix;
[0148] Using the text classification layer in the information extraction model to classify the text feature matrix, obtaining a text information classification result;
[0149] Using the text matching layer in the information extraction model to classify the elements of the text feature matrix, obtaining a text feature map matrix;
[0150] Perform association mapping according to the text feature map matrix to obtain a text information association result;
[0151] According to the text information classification results and the text information association results, an undirected graph is constructed and a maximum clique is screened and associated to obtain the target information text.
[0152] Furthermore, the computer-usable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0153] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0154] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0155] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0156] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0157] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0158] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0159] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the system claim can also be implemented by one unit or device through software or hardware. The second and other words are used to indicate names, but not to indicate any particular order.
[0160] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A text information extraction method, characterized in that: The method comprises: Receiving a text to be extracted, marking position information of the text to be extracted, and obtaining a standard text sequence; Acquire a historical text set, perform multi-label labeling on the historical text set to obtain a training sample set, and use the training sample set to train a pre-built deep learning model to obtain an information extraction model; Using the feature extraction layer in the information extraction model to extract features from the standard text sequence to obtain a text feature matrix; Using the text classification layer in the information extraction model to classify the text feature matrix, obtaining a text information classification result; Using the text matching layer in the information extraction model to classify the elements of the text feature matrix, obtaining a text feature map matrix; Perform association mapping according to the text feature map matrix to obtain a text information association result; According to the text information classification result and the text information association result, an undirected graph is constructed and a maximum clique is screened and associated to obtain a target information text; The training process of the information extraction model includes: Step A: using the feature extraction layer of the deep learning model to convert each word of the word segmentation sequence sample in the training sample set into a word vector to obtain a feature matrix, using the first activation function preset in the text classification layer of the deep learning model to calculate the classification probability value corresponding to the feature matrix, and determining the classification true value corresponding to the feature matrix according to the information category label of the word segmentation sequence sample; Step B: According to the classification true value and the classification probability value, a classification loss value is calculated using a preset first loss function; Step C: using the text matching layer of the deep learning model to perform matrix transposition on the feature matrix to obtain a feature row matrix, performing matrix multiplication calculation on the feature row matrix and the feature matrix to obtain a feature graph matrix, using a preset second activation function to calculate the associated probability value corresponding to each element of the feature graph matrix, and determining the associated true value corresponding to each element of the feature graph matrix according to the information category associated label of the word segmentation sequence sample; Step D: According to the association probability value and the association true value, a preset second loss function is used to calculate to obtain an association loss value; Step E: Calculate the target loss value based on the classification loss value and the association loss value. When the target loss value is greater than or equal to a preset threshold, update the model parameters of the deep learning model and return to the above step A until the target loss value is less than the preset threshold to obtain the information extraction model.
2. The text information extraction method according to claim 1, characterized in that: The step of obtaining a historical text set and performing multi-label labeling on the historical text set to obtain a training sample set includes: Marking each historical text in the historical text set with an information category label, a character coordinate label, and an information category association label to obtain a corresponding training sample; Performing word segmentation processing on the training samples to obtain word segmentation sequence samples; All the word segmentation sequence samples are aggregated to obtain the training sample set.
3. The text information extraction method according to claim 1, characterized in that: The step of extracting features from the standard text sequence using the feature extraction layer in the information extraction model to obtain a text feature matrix includes: Using a feature extraction layer of an information extraction model to convert each word in the standard text sequence into a word vector; All the converted word vectors are combined according to the order of the corresponding words in the standard text sequence to obtain the text feature matrix.
4. The text information extraction method according to claim 3, characterized in that: The method of using the text matching layer in the information extraction model to classify the elements of the text feature matrix to obtain a text feature map matrix includes: Transposing the text feature matrix to obtain a text feature row matrix; Perform matrix multiplication calculation on the text feature row matrix and the text feature matrix to obtain an initial text feature map matrix; Each element in the initial text feature map matrix is classified using a preset classification function to obtain the text feature map matrix.
5. The text information extraction method according to claim 4, characterized in that: The performing association mapping according to the text feature map matrix to obtain a text information association result includes: Filter the row and column numbers corresponding to each element of a preset numerical value in the text feature map matrix to obtain an associative array corresponding to each element of a preset numerical value; Select words of corresponding order in the standard text sequence according to the association array to mark the association relationship, and obtain the associated text; All the associated texts are collected to obtain the text information association result.
6. The text information extraction method according to any one of claims 1 to 5, characterized in that: The step of constructing an undirected graph and performing maximum clique screening and association according to the text information classification result and the text information association result to obtain the target information text includes: Constructing an undirected graph according to the text information association result to obtain an associated undirected graph; Selecting a maximal clique in the associated undirected graph to obtain a corresponding associated matching group; Each of the associated matching groups is associated with the text information classification result to obtain the target information text.
7. A text information extraction device, used to execute the text information extraction method according to any one of claims 1 to 6, characterized in that: include: A sample processing module is used to receive the text to be extracted, mark the position information of the text to be extracted, and obtain a standard text sequence; The model extraction module is used to extract features from the standard text sequence using the feature extraction layer in the information extraction model to obtain a text feature matrix; classify the text feature matrix using the text classification layer in the information extraction model to obtain a text information classification result; classify elements of the text feature matrix using the text matching layer in the information extraction model to obtain a text feature map matrix; and perform association mapping based on the text feature map matrix to obtain a text information association result; The extraction result processing module is used to construct an undirected graph and perform maximum clique screening and association according to the text information classification results and the text information association results to obtain the target information text.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores computer program instructions that can be executed by the at least one processor, and the computer program instructions are executed by the at least one processor to enable the at least one processor to perform the text information extraction method according to any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the text information extraction method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Image text detection method and system, user terminal and server
CN107977592A
Word vector model based on point mutual information and text classification method based on CNN
CN109189925A
Image information auditing method and device, electronic equipment and readable storage medium
CN112507936A