Character recognition method and device, neural network training method and device, equipment and medium

By using polar coordinate information and Gaussian layout information in document recognition, the layout information is integrated into the self-attention network, which solves the problem of the weakening role of layout information in document understanding and improves the accuracy and understanding of document recognition.

CN118799894APending Publication Date: 2024-10-18CHINA MOBILE COMM LTD RES INST +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311516535.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-14
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

In the process of text recognition in documents using the existing technology, the combination of layout information and text features will weaken the key role of layout information and affect the accuracy of document understanding.

Method used

By obtaining the polar coordinate information in the document to be recognized, the Gaussian layout information is determined and integrated into the self-attention network of the document pre-training model to enhance the model's ability to perceive layout information.

Benefits of technology

It improves the accuracy of document recognition results, enables the model to more comprehensively understand structured documents, enhances the perception of layout information, and thereby improves the performance of document understanding tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118799894A_ABST
    Figure CN118799894A_ABST
Patent Text Reader

Abstract

The invention provides a character recognition method and device, a neural network training method and device, equipment and a medium, and the method comprises the steps: obtaining a to-be-recognized document, and determining the polar coordinate information of characters in the to-be-recognized document; wherein the polar coordinate information is used for indicating a relative position relationship between any two characters; determining Gaussian layout information of each character based on the polar coordinate information; wherein the Gaussian layout information is used for indicating the association degree between any two characters; and fusing the Gaussian layout information to a self-attention network in a document pre-training model, and determining a document identification result of the to-be-identified document based on the fused document pre-training model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of computers, and in particular to a text recognition method, a neural network training method, a device, a equipment and a medium. Background Art

[0002] As an important information carrier in the digital economy era, document data has become one of the most important data assets in today's society. Automatically extracting and refining key information from massive document data to build data assets is an important part of the digital transformation of various industries.

[0003] In the related art, the layout information of the text in the document is usually encoded and then accumulated in the text features of the document, and the accumulated results are processed by a neural network model to obtain the recognition results of the text in the document. However, the combination of layout information and text features will weaken the key role of layout information in the document understanding task, thereby affecting the accuracy of document understanding. Summary of the invention

[0004] The embodiments of the present disclosure at least provide a text recognition method, a neural network training method, a device, a equipment and a medium.

[0005] In a first aspect, an embodiment of the present disclosure provides a document recognition method, comprising:

[0006] Acquire a document to be recognized, and determine polar coordinate information of characters in the document to be recognized; wherein the polar coordinate information is used to indicate the relative position relationship between any two characters;

[0007] Determine Gaussian layout information of each of the characters based on the polar coordinate information; wherein the Gaussian layout information is used to indicate the degree of association between any two characters;

[0008] The Gaussian layout information is fused into the self-attention network in the document pre-training model, and the document recognition result of the document to be recognized is determined based on the fused document pre-training model.

[0009] In an optional implementation manner, determining the polar coordinate information of the characters in the document to be recognized includes:

[0010] Determining layout information of each of the characters in the document to be recognized;

[0011] Based on the layout information, polar coordinate information between any two of the characters is determined.

[0012] In an optional implementation manner, determining polar coordinate information between any two characters based on the layout information includes:

[0013] Based on the layout information, determining the distance between the center points of the text areas of the arbitrary two characters;

[0014] Determine the relative direction between the center points of the character areas of the arbitrary two characters;

[0015] The polar coordinate information between any two of the characters is determined based on the distance and the relative direction.

[0016] In an optional implementation manner, determining Gaussian layout information of each of the characters based on the polar coordinate information includes:

[0017] The polar coordinate information is transformed by a Gaussian function to obtain a probability distribution; wherein the probability distribution is used to indicate the degree of association between the two arbitrary characters;

[0018] The probability distribution is determined as the Gaussian layout information.

[0019] In an optional implementation, the step of fusing the Gaussian layout information into a self-attention network of a document pre-training model includes:

[0020] Fusing the Gaussian layout information with the processing result of the first processing layer in the self-attention network to obtain a fusion result; wherein the first processing layer is a network layer that processes the query feature vector and the key feature vector;

[0021] The fusion result is input into the second processing layer of the self-attention network for processing; wherein the second processing layer is the remaining network layer except the first processing layer.

[0022] In an optional implementation, fusing the Gaussian layout information with the processing result of the first processing layer in the self-attention network to obtain a fusion result includes:

[0023] The Gaussian layout information and the processing result of the first processing layer are summed, and the fusion result is determined according to the summed processing result.

[0024] In an optional implementation, the Gaussian layout information includes a plurality of sub-layout information, and the self-attention network includes a plurality of sub-modules;

[0025] The step of fusing the Gaussian layout information with the processing result of the first processing layer in the self-attention network to obtain a fusion result includes:

[0026] For a current character, determine a target submodule associated with the current character and each character in the document to be recognized, and determine a subresult of a first processing layer of the target submodule; wherein the subresult is based on a first query feature vector and a first key feature vector, wherein the first query feature vector is determined based on the current character, and the first key feature vector is determined based on each character in the document to be recognized;

[0027] The sub-layout information between the current character and each character in the document to be recognized is fused with the sub-results to obtain the fused result.

[0028] In an optional implementation, when the self-attention network is a multi-head attention module, each attention head of the multi-head attention module corresponds to a Gaussian function; wherein the Gaussian function is used to determine corresponding Gaussian layout information for the corresponding attention head.

[0029] In an optional implementation manner, after determining the document recognition result of the document to be recognized based on the fused document pre-training model, the method further includes:

[0030] Determining a document processing task for the document to be identified;

[0031] According to the document processing task, the document recognition result is processed to obtain a task execution result of the document processing task.

[0032] In a second aspect, the present disclosure provides a neural network training method, including:

[0033] Acquire a document sample, and determine polar coordinate information of each character in the document sample; wherein the polar coordinate is used to indicate the relative position relationship between any two characters;

[0034] Determine Gaussian layout information of each of the characters based on the polar coordinate information; wherein the Gaussian layout information is used to indicate the degree of association between any two characters;

[0035] Fusion of the Gaussian layout information into a self-attention network in a document pre-training model to be trained, and determination of a document recognition result of the document sample based on the fused document pre-training model;

[0036] The document pre-training model is trained based on the document recognition result.

[0037] In an optional implementation, the training of the document pre-training model based on the document recognition result includes:

[0038] Calculate the target loss function value based on the document recognition result;

[0039] The training parameters of the document pre-training model are adjusted based on the target loss function value until a document pre-training model that meets the training accuracy requirements is obtained.

[0040] In an optional implementation, adjusting the training parameters of the document pre-training model based on the target loss function value until a document pre-training model that meets the training accuracy requirement is obtained includes:

[0041] The target variable parameters of the Gaussian function and the model parameters of the document pre-training model are adjusted based on the target loss function value until a document pre-training model that meets the training accuracy requirements is obtained; wherein the Gaussian function is a function used to determine the Gaussian layout information.

[0042] In an optional implementation, after training the document pre-training model based on the document recognition result, the method further includes:

[0043] Get the document understanding model to be trained;

[0044] Obtaining document recognition results of the trained document pre-training model for the document sample;

[0045] Based on the document recognition result, the document understanding model is trained.

[0046] In a third aspect, an embodiment of the present disclosure provides a text recognition device, including:

[0047] A first acquisition unit, used to acquire a document to be identified;

[0048] A first determining unit, used to determine polar coordinate information of each character in the document to be recognized; wherein the polar coordinates are used to indicate the relative position relationship between each character and the remaining characters in the document to be recognized;

[0049] A second determining unit, configured to determine Gaussian layout information of each of the characters based on the polar coordinate information; wherein the Gaussian layout information is used to indicate the degree of association between each of the characters and the remaining characters;

[0050] The first fusion recognition unit is used to fuse the Gaussian layout information into the self-attention network in the document pre-training model, and determine the document recognition result of the document to be recognized based on the fused document pre-training model.

[0051] In a fourth aspect, an embodiment of the present disclosure provides a neural network training device, comprising:

[0052] A second acquisition unit, used to acquire a document sample and determine polar coordinate information of each character in the document sample; wherein the polar coordinates are used to indicate a relative position relationship between each character and the remaining characters in the document sample;

[0053] A third determining unit, configured to determine Gaussian layout information of each of the characters based on the polar coordinate information; wherein the Gaussian layout information is used to indicate the degree of association between each of the characters and the remaining characters;

[0054] A second fusion recognition unit, used for fusing the Gaussian layout information into a self-attention network in a document pre-training model to be trained, and determining a document recognition result of the document sample based on the fused document pre-training model;

[0055] A training unit is used to train the document pre-training model based on the document recognition result.

[0056] In a fifth aspect, an embodiment of the present disclosure further provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps in the first aspect or the second aspect are performed.

[0057] In a sixth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the first aspect or the second aspect are executed.

[0058] Based on the above research, the present disclosure provides a method for text recognition. In an embodiment of the present application, first, the document to be recognized is obtained, and the polar coordinate information of each character in the document to be recognized is determined. Here, the polar coordinate information can indicate the relative position relationship between each character and the remaining characters in the document to be recognized. Then, the Gaussian layout information of each character can be determined based on the polar coordinate information. Here, the degree of association between each character and the remaining characters can be determined through the Gaussian layout information. Finally, the Gaussian layout information can be fused into the self-attention network in the document pre-training model to obtain the fused document pre-training model. At this time, the document recognition result of the document to be recognized can be determined based on the fused document pre-training model.

[0059] In the above implementation, by determining the polar coordinate information of each character in the document to be recognized and converting the polar coordinate information into Gaussian layout information that can be directly fused with the self-attention network, the layout information of the characters in the document to be recognized can be more intuitively utilized, forcing the document pre-training model to incorporate the layout information when learning the document feature representation, so that the document pre-training model can have a more comprehensive understanding of the structured document to be recognized, thereby enhancing the document pre-training model's perception of the layout information of the characters in the document to be recognized, thereby obtaining more accurate document recognition results and providing technical support for downstream text understanding tasks.

[0060] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.

[0062] Figure 1 A flowchart of a text recognition method provided by an embodiment of the present disclosure is shown;

[0063] Figure 2 A processing flow chart of a Self Attention module in a self-attention network provided by an embodiment of the present disclosure is shown;

[0064] Figure 3 A flow chart for determining polar coordinate information provided by an embodiment of the present disclosure is shown;

[0065] Figure 4 A flowchart for determining Gaussian layout information provided by an embodiment of the present disclosure is shown;

[0066] Figure 5 A schematic diagram of fusing Gaussian layout information into a self-attention network provided by an embodiment of the present disclosure is shown;

[0067] Figure 6 Another fusion schematic diagram of fusing Gaussian layout information into a self-attention network provided by an embodiment of the present disclosure is shown;

[0068] Figure 7A flowchart of a neural network training method provided by an embodiment of the present disclosure is shown;

[0069] Figure 8 A processing flow chart of a text recognition method provided by an embodiment of the present disclosure is shown;

[0070] Fig. 9 A schematic diagram of a text recognition device provided by an embodiment of the present disclosure is shown;

[0071] Fig.10 A schematic diagram of a neural network training device provided by an embodiment of the present disclosure is shown;

[0072] Fig.11 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0073] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.

[0074] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0075] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.

[0076] Research has found that document data, as an important information carrier in the digital economy era, has become one of the most important data assets in today's society. Automatically extracting and refining key information from massive document data to build data assets is an important part of the digital transformation of various industries. Unlike pure text data, document data usually has rich data content (such as text, images, tables) and diverse layout forms (such as typesetting, layout, columns, text format). Therefore, intelligent analysis of document data requires comprehensive consideration of multiple information such as text, images, typesetting layout, etc., and methods based on understanding pure text information are difficult to achieve satisfactory results.

[0077] In order to comprehensively consider the multimodal information of the document to improve the effect of the document intelligent model, in the related technology, a deep learning method based on a pre-trained model architecture is used to perform text recognition on the document. In the related technology, the multimodal features of the document can be introduced into the model input. For example, the encoded layout information is directly accumulated on the text features in the encoding layer of the model input, and then input into the pre-trained model based on the Transformer architecture, and finally the model is pre-trained based on the pre-training task on the text side. This type of method usually uses layout information as auxiliary information and encodes the layout information in a manner similar to the position information encoding in Bert. However, the combination of layout information and text features will weaken the key role of layout information in the document understanding task, thereby affecting the accuracy of document understanding.

[0078] Normally, the words contained in a document are clustered in a specific area of ​​the document, that is, in the same row or column of the document. For example, in the task of document information extraction, words that are closer in space usually have stronger associations. Such words are more likely to form an entity, while words that are farther away are less likely to form strong connections. Therefore, reasonable processing of layout information can effectively assist the neural network model in perceiving the associations between different semantic elements in the document and enhance the model's ability to understand the document content.

[0079] Based on the above research, the present disclosure provides a text recognition method. In an embodiment of the present application, first, the document to be recognized is obtained, and the polar coordinate information of each character in the document to be recognized is determined. Here, the polar coordinate information can indicate the relative position relationship between each character and the remaining characters in the document to be recognized. Then, the Gaussian layout information of each character can be determined based on the polar coordinate information. Here, the degree of association between each character and the remaining characters can be determined through the Gaussian layout information. Finally, the Gaussian layout information can be fused into the self-attention network of the document pre-training model to obtain the fused document pre-training model. At this time, the document recognition result of the document to be recognized can be determined based on the fused document pre-training model.

[0080] In the above implementation, by determining the polar coordinate information of each character in the document to be recognized and converting the polar coordinate information into Gaussian layout information that can be directly fused with the self-attention network, the layout information of the characters in the document to be recognized can be more intuitively utilized, forcing the document pre-training model to incorporate the layout information when learning the document feature representation, so that the document pre-training model can have a more comprehensive understanding of the structured document to be recognized, thereby enhancing the document pre-training model's perception of the layout information of the characters in the document to be recognized, thereby obtaining more accurate document recognition results and providing technical support for downstream text understanding tasks.

[0081] To facilitate understanding of this embodiment, a text recognition method disclosed in the embodiment of the present disclosure is first introduced in detail. The execution subject of the text recognition method provided in the embodiment of the present disclosure is generally a computer device with certain computing capabilities, and the computer device includes, for example, a terminal device or a server or other processing device. In some possible implementations, the text recognition method can be implemented by a processor calling a computer-readable instruction stored in a memory.

[0082] See also Figure 1 FIG. 1 is a flowchart of a text recognition method provided by an embodiment of the present disclosure, wherein the method includes steps S101 to S103, wherein:

[0083] S101: Acquire a document to be recognized, and determine polar coordinate information of characters in the document to be recognized; wherein the polar coordinate information is used to indicate the relative position relationship between any two characters.

[0084] Here, the document to be identified may contain text, images, and tables, and the document to be identified may be laid out in a variety of layout methods, which is not specifically limited in this application.

[0085] Here, the characters in the document to be recognized are associated with the type of the characters in the document to be recognized. For example, if the character type is English, each character can be an English word; for another example, if the character type is Chinese, each character can be a Chinese character.

[0086] Here, for each character in the document to be recognized, corresponding polar coordinate information can be calculated, wherein the polar coordinate information includes the relative position relationship between any two characters.

[0087] S102: Determine Gaussian layout information of each of the characters based on the polar coordinate information; wherein the Gaussian layout information is used to indicate the degree of association between any two characters.

[0088] Here, the degree of association between any two characters can be determined based on the polar coordinate information, thereby obtaining Gaussian layout information, wherein the Gaussian layout information can be a value in the range of 0-1.

[0089] In the embodiment of the present application, the degree of association between any two characters can be determined based on the relative position information (ie, polar coordinate information) of the any two characters.

[0090] S103: Fusing the Gaussian layout information into the self-attention network of the document pre-training model, and determining a document recognition result of the document to be recognized based on the fused document pre-training model.

[0091] Here, the self-attention network can be a Transformer model. The Transformer network can perform parallel feature learning through multiple attention heads, which is conducive to extracting more features and thus improving the document understanding accuracy of the document pre-training model.

[0092] The Transformer model includes multiple encoders and multiple decoders, where each encoder includes a Feed Forward module and a Self Attention module, and each decoder includes a Feed Forward module, an Encoder-Decoder Attention module, and a Self Attention module.

[0093] In the embodiment of the present application, the Gaussian layout information can be integrated into the calculation process of the SelfAttention module in the Transformer model. At this time, the self-attention module can combine the Gaussian layout information to process the data in the process of processing the data, so as to achieve more intuitive use of the layout information of the text in the document to be recognized, forcing the Transformer model to incorporate the layout information when learning the document feature representation.

[0094] Combine the following Figure 2 The calculation process of the self-attention module is introduced, such as Figure 2 As shown, the self-attention module includes: a first MatMul (matrix multiplication) module, a Scale (scale adjustment) module, a softmax module and a second MatMul (matrix multiplication) module. Figure 2As shown, the query feature vector (abbreviated as vector Q) and the key feature vector (hereinafter referred to as vector K) are subjected to matrix multiplication calculation by the first MatMul (matrix multiplication) module to obtain a multiplication result, and the multiplication result is processed by the Scale (scale adjustment) module to obtain a processing result a ( Figure 2 (not shown), then the processing result a is processed by the softmax module to obtain the processing result b ( Figure 2 (not shown); the processing result b is then subjected to matrix multiplication calculation with the value feature vector (referred to as vector V) through the second MatMul (matrix multiplication) module to obtain the result of the self-attention module and input it into the next layer of the Transformer model for processing.

[0095] In the above implementation, by determining the polar coordinate information of each character in the document to be recognized and converting the polar coordinate information into Gaussian layout information that can be directly fused with the self-attention network, the layout information of the characters in the document to be recognized can be more intuitively utilized, forcing the document pre-training model to incorporate the layout information when learning the document feature representation, so that the document pre-training model can have a more comprehensive understanding of the structured document to be recognized, thereby enhancing the document pre-training model's perception of the layout information of the characters in the document to be recognized, thereby obtaining more accurate document recognition results and providing technical support for downstream text understanding tasks.

[0096] In an optional implementation, the above step S101 of determining the polar coordinate information of each character in the document to be recognized specifically includes the following steps:

[0097] Step S11: determining the layout information of each character in the document to be recognized;

[0098] Step S12: Based on the layout information, determine the polar coordinate information between any two of the characters.

[0099] In the embodiment of the present application, after the document to be recognized is obtained, optical character recognition (OCR) may be performed on the document to be recognized, thereby obtaining an OCR recognition result.

[0100] Through the OCR recognition result, each character in the document to be recognized can be obtained, wherein the character can be understood as the character in the document to be recognized. For example, English words, or Chinese characters; in addition, the layout information of each character in the document to be recognized can also be obtained. Among them, the layout information can be understood as the area information of the character in the document page of the document to be recognized. Usually, the layout information is expressed as the coordinates of the upper left corner and the lower right corner of the area where the character is located (that is, the area information). Through the layout information, the position information of each character in the document to be recognized in the document can be determined.

[0101] After the layout information is obtained, the layout information may be processed by a polar coordinate algorithm to obtain polar coordinate information of each character.

[0102] Here, the polar coordinate information between any two characters may be determined based on the position information of the any two characters.

[0103] In the above implementation, by determining the polar coordinate information of the text based on the layout information, not only can the layout information be integrated into the document recognition process of the self-attention network in the document pre-training model, but the relative position relationship between the text can also be integrated into the document recognition result to improve the accuracy of the document recognition result.

[0104] In an optional implementation, the above step of determining the polar coordinate information of each of the characters based on the layout information specifically includes the following steps:

[0105] First, based on the layout information, determine the distance between the center points of the text areas of the arbitrary two characters;

[0106] Secondly, determining the relative direction between the center points of the character areas of the arbitrary two characters;

[0107] Finally, the polar coordinate information between any two of the characters is determined based on the distance and the relative direction.

[0108] From the above description, it can be seen that in the related technology, text and layout information are usually considered at the same time, and after encoding the layout position, the encoding result of the layout information and the text information are represented as vectors in a unified feature space to participate in the subsequent calculation of the model. However, this processing method lacks direct modeling of the relative layout relationship of the text in the document, which makes it difficult for the model to intuitively perceive the relative positions of different texts in the layout space.

[0109] Here, in response to the above problems, it is proposed to use polar coordinate information to express the relative spatial position relationship between any two characters, wherein the polar coordinate information can simultaneously decouple distance and direction, thereby accurately describing the position relationship between different characters in a document.

[0110] The specific process is as follows Figure 3 As shown, after obtaining the layout information, in order to avoid the influence of the size of the document page on the document recognition results, first, the layout information of each character is normalized, and the coordinates of the center point of the text area of ​​each character are determined based on the normalized layout information. Then, the relative polar coordinates are calculated based on the coordinates of the center points of the text areas of any two characters to obtain the polar coordinate information.

[0111] Assume that, given the coordinates (x i ,y i ) and (x j ,y j ), polar coordinate information (ρ ij ,θ ij ) can be calculated by the following formula:

[0112]

[0113] Among them, ρ ij Represents the distance between the center points of two text areas, θ ij Indicates the relative direction between the center points of two text areas. In the above way, the discrete two-dimensional coordinates are converted into polar coordinates that can represent distance and direction, thereby obtaining the relative position relationship between any two characters in the document.

[0114] Here, although the polar coordinate information can represent the relative position relationship between different text areas, the polar coordinate information is still a discrete representation and is difficult to be directly applied to the calculation process of the deep learning model. To address the above problem, the Gaussian layout information of each text can be determined based on the polar coordinate information.

[0115] In an optional implementation, the above step S102 determines the Gaussian layout information of each of the characters based on the polar coordinate information, and specifically includes the following steps:

[0116] Step S21: transforming the polar coordinate information by a Gaussian function to obtain a probability distribution; wherein the probability distribution is used to indicate the degree of association between any two characters;

[0117] Step S22: Determine the probability distribution as the Gaussian layout information.

[0118] In an embodiment of the present application, the polar coordinate information can be converted into an influencing factor (ie, Gaussian layout information) that can directly affect the update of model parameters through a learnable Gaussian function.

[0119] like Figure 4As shown, after obtaining the polar coordinate information, the polar coordinate information can be transformed by a Gaussian function, wherein the Gaussian function can transform the relative position relationship between different text areas into a Gaussian distribution (i.e., a probability distribution). This processing method not only helps the model to converge quickly, but also can adjust the impact of different layout relationships on the document content understanding results.

[0120] For a specific text, it is usually assumed that the texts related to the current text are all in the area close to the current text words, while it is more difficult to form a strong connection with the texts that are farther away. Therefore, when modeling the contextual semantic information of the current text, more attention should be paid to the influence of the texts in the neighboring area. The Gaussian function can meet the above assumptions, that is, the closer the distance, the higher the relationship weight (that is, the higher the probability value of the probability distribution), and the farther the distance, the lower the relationship weight (that is, the lower the probability value of the probability distribution).

[0121] Considering that the polar coordinate information contains both distance and relative direction attributes, in the embodiment of the present application, a binary Gaussian function can be used to convert the polar coordinate information into a probability distribution, that is, Gaussian layout information. The specific calculation formula of the Gaussian layout information is as follows:

[0122]

[0123] Among them, ∑ represents the covariance matrix of the two-dimensional Gaussian function, μ represents the mean of distance and direction, x represents the polar coordinate information, and ∑ and μ are parameters to be learned. The mean value ranges of the distance and relative direction dimensions are [0,1] and [-π,π] respectively, and the variance ranges are [0,1]. Here, if the text area of ​​a certain text is taken as the center, its Gaussian layout information relative to itself cannot be obtained through the above method. However, assuming that the influence of a specific text area on itself is usually greater, its Gaussian layout information on itself can be directly set to 1.

[0124] In an optional implementation, the Gaussian layout information in step S103 is fused into the self-attention network of the document pre-training model, specifically comprising the following steps:

[0125] Step S31: Fusing the Gaussian layout information with the processing result of the first processing layer in the self-attention network to obtain a fusion result; wherein the first processing layer is a network layer that processes the query feature vector and the key feature vector;

[0126] Step S32: input the fusion result to the second processing layer of the self-attention network for processing; wherein the second processing layer is the remaining network layer except the first processing layer.

[0127] In order to utilize the positional dependency between different text regions in the process of document understanding, the technical solution of this application proposes a self-attention mechanism based on Gaussian layout perception to fuse Gaussian layout information and update the calculation method of the self-attention module in the original Transformer model. The calculation method of the updated self-attention module is as follows: Figure 5 shown.

[0128] In the embodiments of the present application, Figure 5 As shown, the first processing layer in the self-attention module can be the first MatMul (matrix multiplication) module and the Scale (scale adjustment) module. At this time, the Gaussian layout information and the processing results of the first processing layer can be The fusion is performed to obtain the fusion result.

[0129] like Figure 5 As shown, after the vector Q and the vector K are subjected to matrix multiplication calculation by the first MatMul (matrix multiplication) module, a multiplication calculation result is obtained, and after the multiplication calculation result is processed by the Scale (scale adjustment) module, a processing result is obtained. At this time, the Gaussian layout information and the processing results can be The fusion is performed to obtain the fusion result.

[0130] like Figure 5 As shown, after obtaining the fusion result, the fusion result can be input into the second processing layer for processing, wherein the second processing layer can be a softmax module and a second MatMul (matrix multiplication) module; after processing by the second processing layer, the processing result of the self-attention network can be obtained.

[0131] Here, the Gaussian layout information and the processing result of the first processing layer in the self-attention network are fused to obtain a fusion result, specifically including the following methods:

[0132] The Gaussian layout information and the processing result of the first processing layer are summed, and the fusion result is determined according to the summed processing result.

[0133] like Figure 5 As shown, the Gaussian layout information p and the processing result a of the first processing layer can be ij T After the summation process, a fusion result is obtained, and the fusion result is input into the second processing layer for processing.

[0134] The self-attention network updated in the above manner directly introduces the relative layout relationship between different text areas in the document, making the document pre-training model more targeted when updating text features, that is, texts with strong spatial dependencies usually have stronger semantic associations.

[0135] In the above method, there is no need to change the basic structure of the Transformer architecture, and only the Gaussian layout information needs to be introduced in the process of calculating self-attention. Therefore, the implementation process of this method is simple and can be applied to any model based on the Transformer architecture, including adding Gaussian layout information to pre-trained language models, such as BERT and RoBERTa's Transformer models to enable them to understand structured documents. Gaussian layout information can also be introduced into existing document understanding pre-trained models to further enhance the structured perception ability of existing document understanding models.

[0136] In an optional implementation, when the Gaussian layout information includes multiple sub-layout information and the self-attention network includes multiple sub-modules, the above steps fuse the Gaussian layout information with the processing result of the first processing layer in the self-attention network to obtain a fusion result, specifically including the following steps:

[0137] First, for a current character, a target submodule associated with the current character and each character in the document to be recognized is determined, and a subresult of a first processing layer of the target submodule is determined; wherein the subresult is based on a first query feature vector and a first key feature vector, wherein the first query feature vector is determined based on the current character, and the first key feature vector is determined based on each character in the document to be recognized;

[0138] Then, the sub-layout information between the current character and each character in the document to be recognized is fused with the sub-results to obtain the fused result.

[0139] In an embodiment of the present application, the same processing method is used for each character in the document to be recognized, and the Gaussian layout information of the character is fused into the self-attention network for fusion calculation processing.

[0140] Here, for the current character i, the sub-layout information between the character i and each character in the document to be recognized can be determined, denoted as p ij ; Wherein, j ranges from 1 to n, and n is the number of characters in the document to be recognized. The current character i and each character in the document to be recognized can correspond to a submodule, through which the submodule can be used to fuse the sub-layout information of the current character i and each character into the self-attention network for fusion calculation and processing. The following takes a character as an example to introduce the above fusion process.

[0141] like Figure 6 As shown, suppose there are n characters, namely X1, X2, X3, ..., X n Among them, Q1, K1 and V1 are determined based on X1, Q2, K2 and V2 are determined based on X2, Q3, K3 and V3 are determined based on X3, ..., Qn, Kn and Vn are determined based on X n OK. The sub-layout information between X1 and itself is p 11 , the sub-layout information between X1 and X2 is p 12 , the sub-layout information between X1 and X3 is p 13 , X1 and X n The sub-layout information between is p 1n .

[0142] like Figure 6 As shown, for submodule 1, first, the sub-result a of Q1 and K1 is calculated 11 , then, the sub-result a 11 With sub-layout information p 11 Perform summation to obtain the fusion result a1'1. For submodule 2, first, calculate the sub-result a of Q1 and K2 12 , then, the sub-result a 12 With sub-layout information p 12 The summation is performed to obtain the fusion result a1'2. For submodule 3, first, the sub-result a of Q1 and K3 is calculated. 13 , then, the sub-result a 13 With sub-layout information p 13 The summation is performed to obtain the fusion result a1'3. For submodule n, first, the sub-result a of Q1 and Kn is calculated. 1n , then, the sub-result a 1n With sub-layout information p 1n Perform summation to obtain the fusion result a1' n .

[0143] Among them, Q1 is the first query feature vector, and K1, K2, K3, ..., Kn are the first key feature vectors.

[0144] like Figure 6 As shown, after calculating the fusion results a1'1, a1'2, a1'3, ..., a1' n After that, the above fusion result a1'1 can be multiplied by K1 to obtain result A1; the above fusion result a1'2 can be multiplied by K2 to obtain result A2; the above fusion result a1'3 can be multiplied by K3 to obtain result A3; ...; the above fusion result a1' nMultiply it by Kn to get the result An. At this point, A1, A2, A3, ..., An can be determined as the processing result of the self-attention network.

[0145] In an embodiment of the present application, when the self-attention network is a multi-head attention module, each attention head of the multi-head attention module corresponds to a Gaussian function; wherein the Gaussian function is used to determine corresponding Gaussian layout information for the corresponding attention head.

[0146] Here, similarly, for the multi-head self-attention network, a multi-kernel Gaussian function will be used, that is, each attention head corresponds to a binary Gaussian function, and the Gaussian functions between different heads are not shared. In the multi-layer stacked attention model, the polar coordinate information between text regions can be shared between different layers.

[0147] In an optional implementation, after determining the document recognition result of the document to be recognized based on the fused document pre-training model, the method further includes the following steps:

[0148] First, determining the document processing task of the document to be identified;

[0149] Secondly, according to the document processing task, the document recognition result is processed to obtain the task execution result of the document processing task.

[0150] Here, the document recognition result can be used to indicate the text feature representation of the document to be recognized, and the document processing task can be performed through the text feature representation, wherein the document processing task may include but is not limited to the following tasks: document classification task, document intelligent question and answer task, document information extraction task. The present disclosure does not make specific limitations on the document processing tasks, which are subject to achievable performance.

[0151] After determining the document processing task, a task adaptation layer (i.e., document understanding model) matching the document processing task may be determined, wherein the task adaptation layer may be a neural network model for executing the corresponding document processing task. Afterwards, the document processing task may be executed through the task adaptation layer, thereby obtaining a task execution result.

[0152] For specific document processing tasks, it is usually necessary to add different task adaptation layers on this basis. For example, adding a classification layer can realize the document classification task; adding a sequence labeling classification layer can realize the document information extraction task.

[0153] In an embodiment of the present application, the self-attention calculation process of the layout information intervention model is integrated into the Transformer architecture of the basic pre-trained model to enhance the model's perception of layout information, promote efficient learning of downstream document intelligent understanding tasks including document information extraction, document classification, and document question and answer, and improve the performance indicators of downstream document understanding tasks.

[0154] See also Figure 7 FIG. 1 is a flowchart of a neural network training method provided by an embodiment of the present disclosure, wherein the method includes steps S701 to S704, wherein:

[0155] Step S701: Obtain a document sample, and determine polar coordinate information of each character in the document sample; wherein the polar coordinates are used to indicate the relative position relationship between any two characters.

[0156] Here, the document sample may include text, images, and tables, and the document sample may be laid out in a variety of layout modes, which is not specifically limited in this application.

[0157] Here, the characters in the document sample are associated with the type of the characters in the document sample. For example, if the character type is English, each character can be an English word; for another example, if the character type is Chinese, each character can be a Chinese character.

[0158] Here, for each character in the document sample, corresponding polar coordinate information can be calculated, wherein the polar coordinate information includes the relative position relationship between any two characters.

[0159] Step S702: determining Gaussian layout information of each of the characters based on the polar coordinate information; wherein the Gaussian layout information is used to indicate the degree of association between any two characters.

[0160] Here, the degree of association between any two characters can be determined based on the polar coordinate information, thereby obtaining Gaussian layout information, wherein the Gaussian layout information can be a value in the range of 0-1.

[0161] In the embodiment of the present application, the degree of association between any two characters can be determined based on the relative position information (ie, polar coordinate information) of the any two characters.

[0162] Step S703: Fusing the Gaussian layout information into the self-attention network in the document pre-training model to be trained, and determining the document recognition result of the document sample based on the fused document pre-training model.

[0163] Here, the self-attention network can be a Transformer model. The Transformer model includes multiple encoders and multiple decoders, wherein each encoder includes a Feed Forward module and a Self Attention module, and each decoder includes: a Feed Forward module and an Encoder-Decoder Attention module, and a Self Attention module.

[0164] In an embodiment of the present application, the Gaussian layout information can be integrated into the calculation process of the Self Attention module in the Transformer model to be trained. At this time, the self-attention module can combine the Gaussian layout information to process the data during data processing, thereby realizing a more intuitive use of the layout information of the text in the document, forcing the Transformer model to incorporate the layout information when learning the document feature representation.

[0165] Step S704: training the document pre-training model based on the document recognition result.

[0166] In an optional implementation, the above step of training the document pre-training model based on the document recognition result specifically includes the following steps:

[0167] First, a target loss function value is calculated based on the document recognition result;

[0168] Secondly, the training parameters of the document pre-training model are adjusted based on the target loss function value until a document pre-training model that meets the training accuracy requirements is obtained.

[0169] In an embodiment of the present application, the target loss function value can be calculated based on the document recognition result and the true value of the result output by the document pre-training model to be trained, and then the training parameters of the document pre-training model can be adjusted according to the target loss function value until a document pre-training model that meets the training accuracy requirements is obtained.

[0170] In specific implementation, the target variable parameters of the Gaussian function and the model parameters of the document pre-training model can be adjusted based on the target loss function value until a document pre-training model that meets the training accuracy requirements is obtained; wherein the Gaussian function is a function used to determine the Gaussian layout information.

[0171] Here, the target variable parameters can be understood as ∑ and μ described in the above implementation; wherein ∑ represents the covariance matrix of the two-dimensional Gaussian function, and μ represents the mean of the distance and direction.

[0172] In an optional implementation, after training the document pre-training model based on the document recognition result, the method further includes the following steps:

[0173] First, obtain the document understanding model to be trained;

[0174] Secondly, obtaining the document recognition result of the document sample by the trained document pre-training model;

[0175] Finally, based on the document recognition results, the document understanding model is trained.

[0176] In the embodiment of the present application, the learning of the document understanding model includes two stages, namely: learning the basic framework of the document understanding model based on the self-supervised method and learning based on specific task data. In the basic framework learning stage, the document understanding model is based on large-scale unlabeled document data and self-supervised learning optimization objectives to train the basic model and obtain the basic understanding ability of the document understanding model for document data.

[0177] In the process of learning specific tasks, the document understanding model mainly focuses on learning the task adaptation layer based on task-specific data and fine-tuning the basic model parameters to further enhance the model's ability to understand the document content and layout structure. In the above two stages of learning, the self-attention mechanism based on Gaussian layout information can effectively model the layout position information and association relationship of text words in the document, thereby enhancing the model's perception of layout information.

[0178] In the above implementation, during the training process of the document pre-training model, by converting the polar coordinate information of each character in the sample document into Gaussian layout information that can be directly fused with the self-attention network, the layout information of the characters in the document can be more intuitively utilized, forcing the document pre-training model to incorporate the layout information when learning the document feature representation, so that the document pre-training model can have a more comprehensive understanding of the structured document to be identified, thereby enhancing the document pre-training model's perception of the layout information of the characters in the document to be identified, thereby obtaining more accurate document recognition results, and providing technical support for downstream text understanding tasks.

[0179] The following will be combined Figure 8 The above process is introduced.

[0180] First, obtain the document to be recognized, and perform optical character recognition (OCR) on the document to be recognized, so as to obtain the OCR recognition result. Through the OCR recognition result, the various characters in the document to be recognized can be obtained, wherein the characters can be understood as the characters in the document to be recognized. For example, English words, or Chinese characters; in addition, the layout information of each character in the document to be recognized can also be obtained. Among them, the layout information can be understood as the area information of the characters in the document page of the document to be recognized. Usually, the layout information is expressed as the upper left corner and lower right corner coordinates of the area where the characters are located (that is, the area information). Through the layout information, the position information of each character in the document to be recognized in the document can be determined.

[0181] Afterwards, the polar coordinate information between any two characters can be determined based on the layout information, and the Gaussian layout information of each character can be determined based on the polar coordinate information. Then, according to the following Figure 5 and Figure 6 In the manner shown, the Gaussian layout information is fused into the self-attention module of the Transformer model, and the document recognition result of the document to be recognized, that is, the text feature representation of the document, is determined based on the fused Transformer model; thereafter, the document processing task can be performed, wherein the document processing task may include but is not limited to the following tasks: document classification task, document intelligent question and answer task, document information extraction task. The present disclosure does not make specific limitations on the document processing task, which is subject to what can be implemented.

[0182] After determining the document processing task, a task adaptation layer (i.e., document understanding model) matching the document processing task may be determined, wherein the task adaptation layer may be a neural network model for executing the corresponding document processing task. Afterwards, the document processing task may be executed through the task adaptation layer, thereby obtaining a task execution result.

[0183] From the above description, it can be seen that existing document understanding technical solutions are usually unable to intuitively model layout position relationships. The technical solution of this application proposes to determine the polar coordinate information between any two characters. In this way, the distance and relative direction between any two text areas can be determined, and the distance and relative direction can be converted into influencing factors in continuous space (i.e., Gaussian layout information) using Gaussian functions. The interaction and fusion of text and layout information in existing methods are almost all performed outside the training model infrastructure. The technical solution of this application proposes a self-attention mechanism based on Gaussian layout perception, which integrates Gaussian layout information into the Transformer architecture of the basic pre-training model to intervene in the model's self-attention calculation process, so as to enhance the model's perception of layout information.

[0184] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0185] Based on the same inventive concept, a text recognition device corresponding to the text recognition method is also provided in the embodiment of the present disclosure. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned text recognition method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0186] Reference Fig. 9 , which is a schematic diagram of a text recognition device provided by an embodiment of the present disclosure, the device includes: a first acquisition unit 91, a first determination unit 92, a second determination unit 93 and a first fusion recognition unit 94; wherein,

[0187] A first acquisition unit 91, used to acquire a document to be identified;

[0188] A first determining unit 92 is used to determine polar coordinate information of each character in the document to be recognized; wherein the polar coordinates are used to indicate the relative position relationship between each character and the remaining characters in the document to be recognized;

[0189] A second determining unit 93 is used to determine Gaussian layout information of each of the characters based on the polar coordinate information; wherein the Gaussian layout information is used to indicate the degree of association between each of the characters and the remaining characters;

[0190] The first fusion recognition unit 94 is used to fuse the Gaussian layout information into the self-attention network in the document pre-training model, and determine the document recognition result of the document to be recognized based on the fused document pre-training model.

[0191] In a possible implementation manner, the first determining unit is further configured to:

[0192] Determining layout information of each of the characters in the document to be recognized;

[0193] Based on the layout information, polar coordinate information between any two of the characters is determined.

[0194] In a possible implementation manner, the first determining unit is further configured to:

[0195] Based on the layout information, determining the distance between the center points of the text areas of the arbitrary two characters;

[0196] Determine the relative direction between the center points of the character areas of the arbitrary two characters;

[0197] The polar coordinate information between any two of the characters is determined based on the distance and the relative direction.

[0198] In a possible implementation manner, the second determining unit is further configured to:

[0199] The polar coordinate information is transformed by a Gaussian function to obtain a probability distribution; wherein the probability distribution is used to indicate the degree of association between the two arbitrary characters;

[0200] The probability distribution is determined as the Gaussian layout information.

[0201] In a possible implementation manner, the first fusion identification unit is further configured to:

[0202] Fusing the Gaussian layout information with the processing result of the first processing layer in the self-attention network to obtain a fusion result; wherein the first processing layer is a network layer that processes the query feature vector and the key feature vector;

[0203] The fusion result is input into the second processing layer of the self-attention network for processing; wherein the second processing layer is the remaining network layer except the first processing layer.

[0204] In a possible implementation manner, the first fusion identification unit is further configured to:

[0205] The Gaussian layout information and the processing result of the first processing layer are summed, and the fusion result is determined according to the summed processing result.

[0206] In a possible implementation, when the Gaussian layout information includes multiple sub-layout information and the self-attention network includes multiple sub-modules, the first fusion recognition unit is further used to:

[0207] For a current character, determine a target submodule associated with the current character and each character in the document to be recognized, and determine a subresult of a first processing layer of the target submodule; wherein the subresult is based on a first query feature vector and a first key feature vector, wherein the first query feature vector is determined based on the current character, and the first key feature vector is determined based on each character in the document to be recognized;

[0208] The sub-layout information between the current character and each character in the document to be recognized is fused with the sub-results to obtain the fused result.

[0209] In one possible implementation, when the self-attention network is a multi-head attention module, each attention head of the multi-head attention module corresponds to a Gaussian function; wherein the Gaussian function is used to determine corresponding Gaussian layout information for the corresponding attention head.

[0210] In a possible implementation manner, after determining the document recognition result of the document to be recognized based on the fused document pre-training model, the device is further used to:

[0211] Determining a document processing task for the document to be identified;

[0212] According to the document processing task, the document recognition result is processed to obtain a task execution result of the document processing task.

[0213] Based on the same inventive concept, the embodiments of the present disclosure also provide a neural network training device corresponding to the neural network training method. Since the principle of solving the problem by the device in the embodiments of the present disclosure is similar to the above-mentioned neural network training method in the embodiments of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0214] Reference Fig.10 , which is a schematic diagram of a neural network training device provided by an embodiment of the present disclosure, the device comprises: a second acquisition unit 101, a third determination unit 102, a second fusion identification unit 103 and a training unit 104; wherein,

[0215] The second acquisition unit 101 is used to acquire a document sample and determine polar coordinate information of each character in the document sample; wherein the polar coordinates are used to indicate the relative position relationship between each character and the remaining characters in the document sample;

[0216] A third determining unit 102 is used to determine Gaussian layout information of each of the characters based on the polar coordinate information; wherein the Gaussian layout information is used to indicate the degree of association between each of the characters and the remaining characters;

[0217] A second fusion recognition unit 103 is used to fuse the Gaussian layout information into the self-attention network in the document pre-training model to be trained, and determine the document recognition result of the document sample based on the fused document pre-training model;

[0218] The training unit 104 is used to train the document pre-training model based on the document recognition result.

[0219] In a possible implementation manner, the training unit 104 is further configured to:

[0220] Calculate the target loss function value based on the document recognition result;

[0221] The training parameters of the document pre-training model are adjusted based on the target loss function value until a document pre-training model that meets the training accuracy requirements is obtained.

[0222] In a possible implementation manner, the training unit 104 is further configured to:

[0223] The target variable parameters of the Gaussian function and the model parameters of the document pre-training model are adjusted based on the target loss function value until a document pre-training model that meets the training accuracy requirements is obtained; wherein the Gaussian function is a function used to determine the Gaussian layout information.

[0224] In a possible implementation manner, after training the document pre-training model based on the document recognition result, the device is further used to:

[0225] Get the document understanding model to be trained;

[0226] Obtaining document recognition results of the trained document pre-training model for the document sample;

[0227] Based on the document recognition result, the document understanding model is trained.

[0228] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0229] Corresponds to Figure 1 and Figure 7 The present disclosure also provides an electronic device 1100, such as Fig.11 FIG. 1 is a schematic diagram of the structure of an electronic device 1100 provided in an embodiment of the present disclosure, including:

[0230] Processor 111, memory 112, and bus 113; memory 112 is used to store execution instructions, including internal memory 1121 and external memory 1122; the internal memory 1121 is also called internal memory, which is used to temporarily store the operation data in the processor 111 and the data exchanged with the external memory 1122 such as a hard disk. The processor 111 exchanges data with the external memory 1122 through the internal memory 1121. When the electronic device 1100 is running, the processor 111 communicates with the memory 112 through the bus 113, so that the processor 111 executes the following instructions:

[0231] Acquire a document to be recognized, and determine polar coordinate information of characters in the document to be recognized; wherein the polar coordinate information is used to indicate the relative position relationship between any two characters;

[0232] Determine Gaussian layout information of each of the characters based on the polar coordinate information; wherein the Gaussian layout information is used to indicate the degree of association between any two characters;

[0233] The Gaussian layout information is fused into the self-attention network in the document pre-training model, and the document recognition result of the document to be recognized is determined based on the fused document pre-training model.

[0234] The processor 111 may also execute the following instructions:

[0235] Acquire a document sample, and determine polar coordinate information of each character in the document sample; wherein the polar coordinate is used to indicate the relative position relationship between any two characters;

[0236] Determine Gaussian layout information of each of the characters based on the polar coordinate information; wherein the Gaussian layout information is used to indicate the degree of association between any two characters;

[0237] Fusing the Gaussian layout information into a self-attention network in a document pre-training model to be trained, and determining a document recognition result of the document to be recognized based on the fused document pre-training model;

[0238] The document pre-training model is trained based on the document recognition result.

[0239] The present disclosure also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the document recognition method or the neural network training method described in the above method embodiment are executed. The storage medium may be a volatile or non-volatile computer-readable storage medium.

[0240] The embodiments of the present disclosure also provide a computer program product, which carries a program code. The instructions included in the program code can be used to execute the steps of the document recognition method or the neural network training method described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.

[0241] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).

[0242] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.

[0243] The units described as separate components may or may not be physically separated, and the components shown as units 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 units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0244] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0245] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0246] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A document recognition method, characterized in that: include: Acquire a document to be recognized, and determine polar coordinate information of characters in the document to be recognized; wherein the polar coordinate information is used to indicate the relative position relationship between any two characters; Determine Gaussian layout information of each of the characters based on the polar coordinate information; wherein the Gaussian layout information is used to indicate the degree of association between any two characters; The Gaussian layout information is fused into the self-attention network in the document pre-training model, and the document recognition result of the document to be recognized is determined based on the fused document pre-training model.

2. The method according to claim 1, characterized in that: The step of determining polar coordinate information of characters in the document to be recognized includes: Determining layout information of each of the characters in the document to be recognized; Based on the layout information, polar coordinate information between any two of the characters is determined.

3. The method according to claim 2, characterized in that The step of determining polar coordinate information between any two characters based on the layout information includes: Based on the layout information, determining the distance between the center points of the text areas of the arbitrary two characters; Determine the relative direction between the center points of the character areas of the arbitrary two characters; The polar coordinate information between any two of the characters is determined based on the distance and the relative direction.

4. The method according to claim 1, characterized in that: The determining of Gaussian layout information of each of the characters based on the polar coordinate information includes: The polar coordinate information is transformed by a Gaussian function to obtain a probability distribution; wherein the probability distribution is used to indicate the degree of association between the two arbitrary characters; The probability distribution is determined as the Gaussian layout information.

5. The method according to claim 1, characterized in that The self-attention network that fuses the Gaussian layout information into the document pre-training model includes: Fusing the Gaussian layout information with the processing result of the first processing layer in the self-attention network to obtain a fusion result; wherein the first processing layer is a network layer that processes the query feature vector and the key feature vector; The fusion result is input into the second processing layer of the self-attention network for processing; wherein the second processing layer is the remaining network layer except the first processing layer.

6. The method according to claim 5, characterized in that The step of fusing the Gaussian layout information with the processing result of the first processing layer in the self-attention network to obtain a fusion result includes: The Gaussian layout information and the processing result of the first processing layer are summed, and the fusion result is determined according to the summed processing result.

7. The method according to claim 6, characterized in that The Gaussian layout information includes a plurality of sub-layout information, and the self-attention network includes a plurality of sub-modules; The step of fusing the Gaussian layout information with the processing result of the first processing layer in the self-attention network to obtain a fusion result includes: For a current character, determine a target submodule associated with the current character and each character in the document to be recognized, and determine a subresult of a first processing layer of the target submodule; wherein the subresult is based on a first query feature vector and a first key feature vector, wherein the first query feature vector is determined based on the current character, and the first key feature vector is determined based on each character in the document to be recognized; The sub-layout information between the current character and each character in the document to be recognized is fused with the sub-results to obtain the fused result.

8. The method according to claim 5, characterized in that In the case where the self-attention network is a multi-head attention module, each attention head of the multi-head attention module corresponds to a Gaussian function; wherein the Gaussian function is used to determine corresponding Gaussian layout information for the corresponding attention head.

9. The method according to claim 1, characterized in that: After determining the document recognition result of the document to be recognized based on the fused document pre-training model, the method further includes: Determining a document processing task for the document to be identified; According to the document processing task, the document recognition result is processed to obtain a task execution result of the document processing task.

10. A method for training a neural network, characterized in that: include: Acquire a document sample, and determine polar coordinate information of each character in the document sample; wherein the polar coordinate is used to indicate the relative position relationship between any two characters; Determine Gaussian layout information of each of the characters based on the polar coordinate information; wherein the Gaussian layout information is used to indicate the degree of association between any two characters; Fusion of the Gaussian layout information into a self-attention network in a document pre-training model to be trained, and determination of a document recognition result of the document sample based on the fused document pre-training model; The document pre-training model is trained based on the document recognition result.

11. The method according to claim 10, characterized in that The training of the document pre-training model based on the document recognition result includes: Calculate the target loss function value based on the document recognition result; The training parameters of the document pre-training model are adjusted based on the target loss function value until a document pre-training model that meets the training accuracy requirements is obtained.

12. The method according to claim 11, characterized in that The step of adjusting the training parameters of the document pre-training model based on the target loss function value until a document pre-training model that meets the training accuracy requirement is obtained includes: The target variable parameters of the Gaussian function and the model parameters of the document pre-training model are adjusted based on the target loss function value until a document pre-training model that meets the training accuracy requirements is obtained; wherein the Gaussian function is a function used to determine the Gaussian layout information.

13. The method according to claim 10, characterized in that After training the document pre-training model based on the document recognition result, the method further includes: Get the document understanding model to be trained; Obtaining document recognition results of the trained document pre-training model for the document sample; Based on the document recognition result, the document understanding model is trained.

14. A text recognition device, characterized in that: include: A first acquisition unit, used to acquire a document to be identified; A first determining unit, used to determine polar coordinate information of each character in the document to be recognized; wherein the polar coordinates are used to indicate the relative position relationship between each character and the remaining characters in the document to be recognized; A second determining unit, configured to determine Gaussian layout information of each of the characters based on the polar coordinate information; wherein the Gaussian layout information is used to indicate the degree of association between each of the characters and the remaining characters; The first fusion recognition unit is used to fuse the Gaussian layout information into the self-attention network in the document pre-training model, and determine the document recognition result of the document to be recognized based on the fused document pre-training model.

15. A neural network training device, characterized in that: include: A second acquisition unit, used to acquire a document sample and determine polar coordinate information of each character in the document sample; wherein the polar coordinates are used to indicate a relative position relationship between each character and the remaining characters in the document sample; A third determining unit, configured to determine Gaussian layout information of each of the characters based on the polar coordinate information; wherein the Gaussian layout information is used to indicate the degree of association between each of the characters and the remaining characters; A second fusion recognition unit, used for fusing the Gaussian layout information into a self-attention network in a document pre-training model to be trained, and determining a document recognition result of the document sample based on the fused document pre-training model; A training unit is used to train the document pre-training model based on the document recognition result.

16. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the document recognition method as described in any one of claims 1 to 9 are executed, or the steps of the neural network training method as described in any one of claims 10 to 13 are executed.

17. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the steps of the document recognition method as described in any one of claims 1 to 9, or executes the steps of the neural network training method as described in any one of claims 10 to 13.