A text recognition method and system based on multi-level semantics

By adopting a two-layer text semantic extraction method based on the attention mechanism in text recognition technology, the global semantic information of the text is extracted, which solves the problems of single perspective and insufficient semantics in the existing technology, and improves the accuracy of text recognition.

CN113836910BInactive Publication Date: 2024-10-22SHANDONG NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111094473.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-17
Publication Date
2024-10-22
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing text recognition technology ignores the global semantic information of the text, has a single extraction perspective, and cannot effectively distinguish between semantic similarity and description correlation, resulting in insufficient extraction of text semantic features.

Method used

A two-layer text semantic extraction method based on the attention mechanism is used to extract word-level local semantics and sentence-level global semantic information through a bidirectional long-short-term memory network and attention network, and convert the single vector expression of semantics into a feature matrix form. Highlight the contribution of important words and sentences.

Benefits of technology

It improves the accuracy of text recognition, extracts text semantics from multiple perspectives, and enhances the ability to express the subject content of the text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113836910B_ABST
    Figure CN113836910B_ABST
Patent Text Reader

Abstract

The present disclosure provides a text recognition method and system based on multi-level semantics, which obtain text data to be recognized; extract words from the text data to obtain word vectors of each word; obtain word feature representation based on the obtained word vectors and a first bidirectional long short-term memory network, and obtain word-level local sentence semantic representation from different perspectives in combination with a first attention network; obtain sentence feature representation based on the obtained sentence semantic representation from different perspectives at the word level and a second bidirectional long short-term memory network, and obtain sentence-level global sentence semantic representation from different perspectives in combination with a second attention network; obtain text recognition results based on the obtained global sentence semantic representation; the present disclosure not only highlights the contribution of important words and sentences to text semantics, but also expands text semantic extraction from a single perspective to multi-perspective perspectives, thereby improving the accuracy of text recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of text data processing, and in particular to a text recognition method and system based on multi-level semantics. Background Art

[0002] The statements in this section merely provide background art related to the present disclosure and do not necessarily constitute prior art.

[0003] Text recognition is a technology that processes printed text, handwritten text, or pictures containing text in the real world and converts them into machine-encoded text. With the development and application of computer and artificial intelligence technology, text recognition has been widely used in many fields. For example, the security level confirmation of government documents must first be performed on text recognition. Text recognition technology is an important part of computer vision, the basis for machine cognition of the world, and a hot spot in artificial intelligence research.

[0004] Text feature extraction is the core of text recognition. Currently, the most widely used methods for text feature extraction are document frequency method, information gain method, mutual information method and statistical method. These algorithms all adopt the idea of ​​word frequency statistical information, which results in the lack of semantic relationship between words as an important reference indicator in the feature extraction process, so that some text features extracted by such methods cannot effectively represent the subject content to be expressed by the text. The word embedding model proposed by some researchers is a new word vector representation method, which establishes semantic connection for the relationship between words, but it cannot distinguish between semantic similarity and description relevance. With the help of word vectors, some researchers proposed an improved TextRank method, which extracts and generates keywords from scientific publications based on pre-trained word vectors, but because its low-level feature layer is separated from the high-level feature layer, it does not fully extract the overall semantics of the text. For social short text information, some researchers proposed to use deep recursive neural networks to learn keywords and their contextual information, so as to extract keywords in tweets.

[0005] The inventors found that these methods ignore the global semantic information of the text, have a single extraction perspective, and do not take into account the contribution of different words and sentences to the text semantics, thus resulting in insufficient extraction of text semantic features. Summary of the invention

[0006] In order to address the deficiencies in the prior art, the present disclosure provides a text recognition method and system based on multi-level semantics, which takes into account the deep semantic relationship between words when extracting text semantic features, uses a two-layer text semantic extraction method based on an attention mechanism, extracts forward and backward semantic sequences, extracts local semantics at the word level and global semantic information at the sentence level, and converts a single vector expression of semantics into a feature matrix form, which not only highlights the contribution of important words and sentences to text semantics, but also expands text semantic extraction from a single perspective to multi-perspective, thereby improving the accuracy of text recognition.

[0007] In order to achieve the above objectives, the present disclosure adopts the following technical solutions:

[0008] A first aspect of the present disclosure provides a text recognition method based on multi-level semantics.

[0009] A text recognition method based on multi-level semantics includes the following processes:

[0010] Obtain text data to be recognized;

[0011] Extract words from text data and obtain word vectors for each word;

[0012] Based on the obtained word vector and the first bidirectional long short-term memory network, the feature representation of the word is obtained, and combined with the first attention network, the word-level local sentence semantic representation from different perspectives is obtained;

[0013] Based on the obtained sentence semantic representations from different perspectives at the word level and the second bidirectional long short-term memory network, the feature representation of the sentence is obtained, and combined with the second attention network, the sentence-level global sentence semantic representation from different perspectives is obtained;

[0014] Based on the obtained global sentence semantic representation, the text recognition result is obtained.

[0015] Furthermore, the Skip-gram model is used for word embedding to obtain the word vectors of each word.

[0016] Furthermore, in the first bidirectional long short-term memory network and the second bidirectional long short-term memory network, each part of the feature vector is generated by connecting the forward long short-term memory network and the backward long short-term memory network.

[0017] Furthermore, the first attention network is used to describe the word weights in a sentence as a two-dimensional weight matrix, where different rows of the matrix represent information from different perspectives of the sentence.

[0018] Furthermore, the word-level sentence semantics from different perspectives is represented as the product of the feature representation of the word and the weight matrix of the first attention mechanism network, and the weight matrix includes the constraints: Where A is the weight matrix and I is the identity matrix.

[0019] Furthermore, the word-level local sentence semantic representation and word feature representation use the dropout method to eliminate the impact of overfitting.

[0020] Furthermore, based on the feature representation of the sentence, the second attention network is used to obtain a weight matrix representing the relationship between sentences from multiple perspectives, which is multiplied by the sentence features to obtain the global sentence semantic representation matrix of the text.

[0021] A second aspect of the present disclosure provides a text recognition system based on multi-level semantics.

[0022] A text recognition system based on multi-level semantics, comprising:

[0023] The data acquisition module is configured to: acquire text data to be recognized;

[0024] The word vector extraction module is configured to: extract words from the text data and obtain word vectors for each word;

[0025] The local sentence semantic representation acquisition module is configured to: obtain the feature representation of the word according to the obtained word vector and the first bidirectional long short-term memory network, and obtain the word-level local sentence semantic representation under different perspectives in combination with the first attention network;

[0026] The global sentence semantic representation acquisition module is configured to: obtain a feature representation of the sentence based on the obtained word-level sentence semantic representations from different perspectives and the second bidirectional long short-term memory network, and obtain a sentence-level global sentence semantic representation from different perspectives in combination with the second attention network;

[0027] The text recognition module is configured to obtain a text recognition result according to the obtained global sentence semantic representation.

[0028] A third aspect of the present disclosure provides a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the steps in the multi-level semantics-based text recognition method as described in the first aspect of the present disclosure.

[0029] The fourth aspect of the present disclosure provides an electronic device, including a memory, a processor, and a program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in the multi-level semantics-based text recognition method as described in the first aspect of the present disclosure are implemented.

[0030] Compared with the prior art, the beneficial effects of the present invention are:

[0031] The method, system, medium or electronic device disclosed in the present invention takes into account the deep semantic relationship between words when extracting text semantic features, uses a two-layer text semantic extraction method based on an attention mechanism, extracts forward and backward semantic sequences, extracts local semantics at the word level and global semantic information at the sentence level, and converts a single vector expression of semantics into a feature matrix form, which not only highlights the contribution of important words and sentences to text semantics, but also expands text semantic extraction from a single perspective to multi-perspective, thereby improving the accuracy of text recognition.

[0032] Advantages of additional aspects of the present disclosure will be given in part in the following description, and in part will become apparent from the following description, or will be learned through practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] The accompanying drawings constituting a part of the present disclosure are used to provide a further understanding of the present disclosure. The illustrative embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation on the present disclosure.

[0034] Figure 1 A schematic diagram of the framework of the multi-level semantics-based text recognition method provided in Example 1 of the present disclosure. DETAILED DESCRIPTION

[0035] The present disclosure is further described below in conjunction with the accompanying drawings and embodiments.

[0036] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present disclosure. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present disclosure belongs.

[0037] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present disclosure. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.

[0038] In the absence of conflict, the embodiments in the present disclosure and the features in the embodiments may be combined with each other.

[0039] Embodiment 1:

[0040] Embodiment 1 of the present disclosure provides a text recognition method based on multi-level semantics, including the following process:

[0041] Obtain text data to be recognized;

[0042] Extract words from text data and obtain word vectors for each word;

[0043] Based on the obtained word vector and the first bidirectional long short-term memory network, the feature representation of the word is obtained, and combined with the first attention network, the word-level local sentence semantic representation from different perspectives is obtained;

[0044] Based on the obtained sentence semantic representations from different perspectives at the word level and the second bidirectional long short-term memory network, the feature representation of the sentence is obtained, and combined with the second attention network, the sentence-level global sentence semantic representation from different perspectives is obtained;

[0045] Based on the obtained global sentence semantic representation, the text recognition result is obtained.

[0046] In this embodiment, an attention model and a two-layer bidirectional LSTM deep network are used to extract word embeddings with local feature information and sentence embedding matrices with global feature information. In order to extract more valuable text semantic information, a two-layer BiLSTM module is integrated into the output of the word vector layer to learn the deep semantic relationship between words, and an attention mechanism is introduced at the output of the two-layer bidirectional LSTM layer to learn local semantic information in a multi-perspective manner; sentence features are input into the two-layer BiLSTM network to learn the deep semantic relationship between sentences, and the global semantic information of the text description is obtained through sentence-level attention. The whole process includes four stages: word encoding, word attention, sentence encoding, and sentence attention. Figure 1 shown.

[0047] Specifically, the process includes the following:

[0048] S1: Context-sensitive word vector construction

[0049] Bidirectional neural networks learn the feature information of sentences by accepting vectorized representations of text. Generally, word embedding is used to map each word to a vector space. The Skip-gram model performs word embedding and predicts the context words corresponding to a given central word. The semantic information of the word is quantified in the embedding vector. Its learning objective can be written as a maximum likelihood function:

[0050]

[0051] Where w is any word in the corpus, u is a word in the context of w, Assume that each multiplier in p(u|w) is an independent logistic regression and The value of is 0 or 1, then the objective function can be rewritten as:

[0052]

[0053] For a given training instance w, u is fixed, then formula (2) has two variables v(w) and For v(w) and Calculate the partial derivatives and get v(w) and The update expression is:

[0054]

[0055]

[0056] Among them, η is the learning rate. After multiple update iterations, we get the sentence s = {w 1 , w 2 ,…,w n}The word vector for each word in .

[0057] S2: Extracting word-level text semantic information

[0058] The deep structure can obtain high-level representations of text layer by layer. Based on the word vectors obtained by the Skip-gram model, a deep bidirectional long short-term memory model is obtained by stacking the forward sequence and reverse sequence hidden layers in a BiLSTM network.

[0059] Forward calculation Scan from the first word to the last word in the sentence. Assuming there are n words in total, t traverses from 1 to n, and the backward inference part It starts from the last word, that is, t traverses from n to 1. In BiLSTM, the hidden layer output is usually represented as text:

[0060]

[0061] in, It means that the forward propagation integrates the above information. It represents the backward propagation fusion of the following information representation.

[0062] In the feature fusion layer, each part of the feature vector is generated by the forward and backward LSTM connections, and the connection between the two represents the text semantic representation of the BiLSTM model at the t-th step input vector fusion context.

[0063] After stacking BiLSTM layer by layer, a deep network structure is formed. In this deep network structure, after normalization, the feature representation of a word is H = (h 1 ,h 2 ,…,h n ),in || represents a vector concatenation operation.

[0064] In recent years, the attention mechanism has been widely used in natural language processing. It can learn the weights of each word in the sentence representation sequence and pay more attention to the more important word information in the text. The attention mechanism is introduced into the sentence expression, mapped into a two-dimensional matrix, and a multi-perspective method is used to obtain the matrix-level sentence semantic representation. The weight matrix A of the word-level attention model is:

[0065] A=softmax(W s2 tanh(W s1 H T )) (6)

[0066] Among them, W s1 and W s2 Represents the training parameters of the model.

[0067] In order to avoid the same weights learned from multiple angles, the attention weight matrix A is constrained to satisfy:

[0068]

[0069] Under the constraint of formula (7), the attention weights are more concentrated on the words that have a greater impact on the text semantics extraction, and the attention weight distribution of different perspectives is as different as possible. The final synthesized sentence semantics is represented as M = AH. The word-level attention model describes the word weights in the sentence as a two-dimensional matrix. Different rows of the matrix represent different levels of information in the sentence, that is, interpreting the sentence semantics from multiple different perspectives, and then obtaining a matrix-level semantic representation, which makes the sentence express richer information and solves the problem of information loss when the sentence is compressed into a one-dimensional vector.

[0070] The sentence semantic matrix M and word semantic representation H use the dropout method to eliminate the influence of overfitting. Some nodes in the network are randomly removed during the training phase, while all nodes are used during the test phase. The introduction of the hyperparameter p means that each node in the network is retained with a probability of p and removed with a probability of 1-p in the iteration. Therefore, in each iteration of the network, only the sub-network composed of the retained nodes is trained, that is, only the node parameters in the sub-network will be updated, and the remaining node parameters retain the results of the previous iteration. This can not only improve the generalization ability of the model, but also accelerate the training process.

[0071] S3: Extracting text semantic information at the sentence level

[0072] The sentence semantics of the attention mechanism is represented as a two-dimensional matrix, which describes the contribution of words to the text semantics from different perspectives. In the extraction of global semantic information at the sentence level, the sentence is encoded from each perspective.

[0073] Assume that in the i-th perspective, sentence s jThe vector corresponding to (j=1, 2, ..., m) is Using the BiLSTM network to input the semantic vectors of m sentences under perspective i (i=1,…,r), the forward and reverse context information are combined to obtain the hidden layer output, and the semantic representation is Where r represents the number of viewing angles, h i Represents the semantics of m sentences from the i-th perspective.

[0074] The sentence-level attention model is introduced to measure the importance of a sentence in the text and calculate h i and h j Similarity metric function:

[0075]

[0076] Among them, M ij For position encoding, forward encoding can be used and backward position encoding

[0077] For the similarity measure matrix f(h i ,h j ) performs softmax normalization operation to obtain weights, and further obtains the weight matrix of the relationship between sentences from r perspectives Multiplying with the sentence features to get the global feature matrix representation of the text

[0078] Embodiment 2:

[0079] Embodiment 2 of the present disclosure provides a text recognition system based on multi-level semantics, including:

[0080] The data acquisition module is configured to: acquire text data to be recognized;

[0081] The word vector extraction module is configured to: extract words from the text data and obtain word vectors for each word;

[0082] The local sentence semantic representation acquisition module is configured to: obtain the feature representation of the word according to the obtained word vector and the first bidirectional long short-term memory network, and obtain the word-level local sentence semantic representation under different perspectives in combination with the first attention network;

[0083] The global sentence semantic representation acquisition module is configured to: obtain a feature representation of the sentence based on the obtained word-level sentence semantic representations from different perspectives and the second bidirectional long short-term memory network, and obtain a sentence-level global sentence semantic representation from different perspectives in combination with the second attention network;

[0084] The text recognition module is configured to obtain a text recognition result according to the obtained global sentence semantic representation.

[0085] The working method of the system is the same as the multi-level semantics-based text recognition method provided in Example 1, and will not be described in detail here.

[0086] Embodiment 3:

[0087] Embodiment 3 of the present disclosure provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the steps in the text recognition method based on multi-level semantics as described in Embodiment 1 of the present disclosure are implemented. The steps are:

[0088] Obtain text data to be recognized;

[0089] Extract words from text data and obtain word vectors for each word;

[0090] Based on the obtained word vector and the first bidirectional long short-term memory network, the feature representation of the word is obtained, and combined with the first attention network, the word-level local sentence semantic representation from different perspectives is obtained;

[0091] Based on the obtained sentence semantic representations from different perspectives at the word level and the second bidirectional long short-term memory network, the feature representation of the sentence is obtained, and combined with the second attention network, the sentence-level global sentence semantic representation from different perspectives is obtained;

[0092] Based on the obtained global sentence semantic representation, the text recognition result is obtained.

[0093] The detailed steps are the same as those of the text recognition method based on multi-level semantics provided in Example 1, and will not be repeated here.

[0094] Embodiment 4:

[0095] Embodiment 4 of the present disclosure provides an electronic device, including a memory, a processor, and a program stored in the memory and executable on the processor. When the processor executes the program, the steps in the text recognition method based on multi-level semantics as described in Embodiment 1 of the present disclosure are implemented, and the steps are:

[0096] Obtain text data to be recognized;

[0097] Extract words from text data and obtain word vectors for each word;

[0098] Based on the obtained word vector and the first bidirectional long short-term memory network, the feature representation of the word is obtained, and combined with the first attention network, the word-level local sentence semantic representation from different perspectives is obtained;

[0099] Based on the obtained sentence semantic representations from different perspectives at the word level and the second bidirectional long short-term memory network, the feature representation of the sentence is obtained, and combined with the second attention network, the sentence-level global sentence semantic representation from different perspectives is obtained;

[0100] Based on the obtained global sentence semantic representation, the text recognition result is obtained.

[0101] The detailed steps are the same as those of the text recognition method based on multi-level semantics provided in Example 1, and will not be repeated here.

[0102] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.

[0103] The present disclosure is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present disclosure. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0104] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0105] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0106] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0107] The above description is only a preferred embodiment of the present disclosure and is not intended to limit the present disclosure. For those skilled in the art, the present disclosure may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A text recognition method based on multi-level semantics, characterized by: The process includes: Obtain text data to be recognized; Extract words from text data and obtain word vectors for each word; Based on the obtained word vector and the first bidirectional long short-term memory network, the feature representation of the word is obtained, and combined with the first attention network, the word-level local sentence semantic representation from different perspectives is obtained; Based on the obtained sentence semantic representations from different perspectives at the word level and the second bidirectional long short-term memory network, the feature representation of the sentence is obtained, and combined with the second attention network, the sentence-level global sentence semantic representation from different perspectives is obtained; According to the obtained global sentence semantic representation, the text recognition result is obtained; Using the first attention network, the word weights in the sentence are described as a two-dimensional weight matrix, where different rows of the matrix represent information from different perspectives of the sentence; The word-level sentence semantics from different perspectives is represented as the product of the feature representation of the word and the weight matrix of the first attention mechanism network, and the weight matrix includes constraints: ,in A is the weight matrix, I is the identity matrix; According to the feature representation of the sentence, the second attention network is used to obtain the weight matrix representing the relationship between sentences from multiple perspectives, and multiply it with the sentence features to obtain the global sentence semantic representation matrix of the text.

2. The text recognition method based on multi-level semantics as claimed in claim 1, characterized in that: The Skip-gram model is used for word embedding to obtain the word vectors of each word.

3. The text recognition method based on multi-level semantics as claimed in claim 1, characterized in that: In the first bidirectional long short-term memory network and the second bidirectional long short-term memory network, each part of the feature vector is generated by connecting the forward long short-term memory network and the backward long short-term memory network.

4. The text recognition method based on multi-level semantics as claimed in claim 1, characterized in that: The word-level local sentence semantic representation and word feature representation use the dropout method to eliminate the impact of overfitting.

5. A text recognition system based on multi-level semantics, characterized by: When executed, the method for text recognition based on multi-level semantics as described in any one of claims 1 to 4 is implemented, including: The data acquisition module is configured to: acquire text data to be recognized; The word vector extraction module is configured to: extract words from the text data and obtain word vectors for each word; The local sentence semantic representation acquisition module is configured to: obtain the feature representation of the word according to the obtained word vector and the first bidirectional long short-term memory network, and obtain the word-level local sentence semantic representation under different perspectives in combination with the first attention network; The global sentence semantic representation acquisition module is configured to: obtain a feature representation of the sentence based on the obtained word-level sentence semantic representations from different perspectives and the second bidirectional long short-term memory network, and obtain a sentence-level global sentence semantic representation from different perspectives in combination with the second attention network; The text recognition module is configured to obtain a text recognition result according to the obtained global sentence semantic representation.

6. A computer-readable storage medium having a program stored thereon, characterized in that: When the program is executed by a processor, the steps of the text recognition method based on multi-level semantics as described in any one of claims 1 to 4 are implemented.

7. An electronic device comprising a memory, a processor, and a program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the text recognition method based on multi-level semantics as described in any one of claims 1 to 4 are implemented.