Document processing method and device, model training method and device, equipment and storage medium
Through the staggered arrangement of vectorized layout information and text information, combined with layout awareness technology, the problem of input length and computing power caused by the increase of layout information in document understanding is solved, and the model's document understanding accuracy and recognition ability of non-standard text sequences are improved. .
Patent Information
- Application Number
- CN202410866994.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-10-01
AI Technical Summary
In the existing technology, in document understanding, adding layout information will lead to an increase in input length, additional computing power, and failure to effectively utilize the autoregressive characteristics of the language model, affecting model accuracy.
By vectorizing layout information, layout vectors are generated, interleaved with text vectors, and input into the language model. Combined with layout-aware next word prediction technology, layout and text information are integrated to reduce the input length and make full use of model autoregression. characteristic.
It improves the accuracy of document understanding without adding additional computing power, reduces the input length, and enhances the model's ability to recognize non-standard text sequences.
Smart Images

Figure CN118734949A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a document processing method, a model training method, an apparatus, a device and a storage medium. Background Art
[0002] In recent years, the rapid development of computer technology has promoted significant progress in document understanding technology, especially in combination with the use of language models. Usually, language models rely on high-quality text recognition technology and spatial analysis technology of document layout to extract and interpret information from visually rich documents. However, the increase of layout information has an impact on the input length of the model. For example, increasing the input length will increase additional computing power, and controlling the input length will affect the accuracy of the model. Therefore, there is an urgent need to provide a document processing method that can ensure the accuracy of model understanding without increasing the additional input length. Summary of the invention
[0003] In order to solve the above technical problems, the embodiments of the present disclosure provide a document processing method, a model training method, an apparatus, a device and a storage medium, which improve the accuracy of document processing without increasing the additional input length.
[0004] In a first aspect, an embodiment of the present disclosure provides a model training method for document processing, the method comprising:
[0005] Obtaining text information corresponding to the document sample, layout information of the text information in the document sample, question samples, and reference answers corresponding to the question samples; wherein the layout information is used to characterize the position of the text information;
[0006] Vectorizing the layout information to generate a layout vector, and vectorizing the text information to generate a text vector;
[0007] Based on the correspondence between the text information and the layout information, the layout vectors and the text vectors are arranged alternately, and the alternately arranged layout vectors and the text vectors, as well as the question sample, are input into the initial document processing model to determine the predicted answer corresponding to the question sample;
[0008] Based on the predicted answers and reference answers, the initial document processing model is iteratively trained to generate a target document processing model.
[0009] Optionally, vectorization is performed on the layout information to generate a layout vector, including:
[0010] The layout information is processed based on a weight matrix to generate a layout vector; wherein the weight matrix is a real number matrix having a preset embedding dimension and a coordinate dimension corresponding to the layout information.
[0011] Optionally, the layout information is processed based on the weight matrix to generate a layout vector, including:
[0012] Based on the weight matrix and auxiliary information, the layout information is processed to generate a layout vector; wherein the auxiliary information includes a bias matrix and / or an activation layer; and the bias matrix is a real number matrix with a preset embedding dimension.
[0013] Optionally, based on the predicted answers and the reference answers, the initial document processing model is iteratively trained to generate a target document processing model, including:
[0014] Based on the predicted answers and the reference answers, the initial document processing model, the weight matrix and the auxiliary information matrix are iteratively trained to generate the target document processing model, the updated weight matrix and the updated auxiliary information.
[0015] Optionally, the interleaved layout vectors and text vectors, as well as the question sample, are input into an initial document processing model to determine a predicted answer corresponding to the question sample, including:
[0016] Based on a preset ratio, each group of interleaved vectors sequentially arranged according to the order of each text information in the document sample is subjected to random processing to obtain each group of reordered interleaved vectors; wherein a group of interleaved vectors includes interleaved layout vectors and corresponding text vectors;
[0017] The reordered groups of interleaved vectors and question samples are input into the initial document processing model to determine the predicted answer.
[0018] Optionally, the preset ratio is less than or equal to 20%.
[0019] Optionally, obtaining text information corresponding to the document sample and layout information of the text information in the document sample includes:
[0020] Perform optical character recognition on the document sample to determine the text information and layout information.
[0021] In a second aspect, the present disclosure also provides a document processing method, the method comprising:
[0022] Obtaining text information in the document to be processed, layout information of the text information in the document to be processed, and a target question;
[0023] Vectorizing the layout information to generate a layout vector, and vectorizing the text information to generate a text vector;
[0024] Based on the correspondence between text information and layout information, the layout vectors and text vectors are arranged alternately, and the alternately arranged layout vectors and text vectors, as well as the target question, are input into the target document processing model to determine the answer to the target question.
[0025] Optionally, the target document processing model is pre-trained using the document processing model training method described above.
[0026] In a third aspect, the present disclosure also provides a model training device for document processing, the device comprising:
[0027] The first information acquisition module is used to acquire text information corresponding to the document sample, layout information of the text information in the document sample, question samples and reference answers corresponding to the question samples; wherein the layout information is used to represent the position of the text information;
[0028] A first vectorization module is used to perform vectorization processing on the layout information to generate a layout vector, and to perform vectorization processing on the text information to generate a text vector;
[0029] A first vector interleaving module is used to interleave the layout vector and the text vector based on the correspondence between the text information and the layout information, and input the interleaved layout vector and the text vector, as well as the question sample, into the initial document processing model to determine the predicted answer corresponding to the question sample;
[0030] The model training module is used to iteratively train the initial document processing model based on the predicted answers and reference answers to generate a target document processing model.
[0031] In a fourth aspect, an embodiment of the present disclosure further provides a document processing device, the device comprising:
[0032] The second information acquisition module is used to acquire text information in the document to be processed, layout information of the text information in the document to be processed, and target questions;
[0033] A second vectorization module is used to perform vectorization processing on the layout information to generate a layout vector, and to perform vectorization processing on the text information to generate a text vector;
[0034] The answer determination module is used to interleave layout vectors and text vectors based on the correspondence between text information and layout information, and input the interleaved layout vectors and text vectors, as well as the target question, into the target document processing model to determine the answer to the target question.
[0035] In a fifth aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:
[0036] processor;
[0037] A memory for storing executable instructions;
[0038] Among them, the processor is used to read executable instructions from the memory and execute the executable instructions to implement the model training method and document processing method for document processing described in any embodiment of the present disclosure.
[0039] In a sixth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the processor implements the model training method and document processing method for document processing described in any embodiment of the present disclosure.
[0040] In a seventh aspect, the embodiments of the present disclosure further provide a computer program product, which is used to execute the model training method and document processing method for document processing described in any embodiment of the present disclosure.
[0041] The model training method for document processing of the embodiment of the present disclosure obtains text information corresponding to a document sample, layout information of the text information in the document sample, a question sample and a reference answer corresponding to the question sample, wherein the layout information is used to characterize the position of the text information, and based on the layout information, a spatial layout between the text information can be established to improve the accuracy of document processing; then, the layout information is vectorized to generate a layout vector, and the text information is vectorized to generate a text vector, and by converting the coordinates of the layout information into a vector, the input length that is additionally increased by introducing the layout information is greatly reduced; based on the correspondence between the text information and the layout information, the layout vector and the text vector are arranged in an interlaced manner, and the interlaced arrangement effectively integrates the layout information and the text information into a unified sequence, so that the model can better coordinate multimodality; then, the interlaced layout vector and text vector, as well as the question sample, are input into the initial document processing model to determine the predicted answer corresponding to the question sample; based on the predicted answer and the reference answer, the initial document processing model is iteratively trained to generate a target document processing model, and the trained document processing model has a high document processing capability and does not increase additional computing power for reasoning. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that components and elements are not necessarily drawn to scale.
[0043] Figure 1 A flowchart of a model training method for document processing provided in some embodiments of the present disclosure;
[0044] Figure 2 A schematic diagram of the structure of text processing provided by some embodiments of the present disclosure;
[0045] Figure 3 A schematic diagram of a document image provided for some embodiments of the present disclosure;
[0046] Figure 4 A schematic diagram of the structure of word prediction provided by some embodiments of the present disclosure;
[0047] Figure 5 A flowchart of a document processing method provided in some embodiments of the present disclosure;
[0048] Figure 6 A schematic diagram of the structure of a model training device for document processing provided in some embodiments of the present disclosure;
[0049] Figure 7 A schematic diagram of the structure of a document processing device provided in some embodiments of the present disclosure;
[0050] Figure 8 A schematic diagram of the structure of an electronic device provided for some embodiments of the present disclosure. DETAILED DESCRIPTION
[0051] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0052] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0053] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0054] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0055] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0056] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0057] At present, language models are particularly prominent in applications such as visual question answering and key information extraction. The document understanding solution implemented by the language model based on the visual modality mainly extracts visual features from the document image through a visual device, and inputs the extracted visual features into the language model for processing document tasks. However, this solution is easily affected by the resolution of the document image. For example, the recognition accuracy of images with lower resolution is insufficient, and the computing power required for images with higher resolution is relatively large. In addition, the solution that integrates layout information as lightweight visual information into the language model for document understanding mainly extracts the text on the document and the layout information corresponding to the text through a recognition device, and then inputs the extracted information into the language model for processing document tasks. However, this solution mostly uses text to express the layout, which results in a relatively long input length and additional computing power. In addition, the method of limiting the input length by integrating layout information does not utilize the autoregressive features of the language model, and the accuracy of document understanding is insufficient.
[0058] Based on the above situation, an embodiment of the present disclosure provides a document processing solution that can be used for document understanding. Specifically, layout information is introduced, and the input length input into the model is controlled by vectorizing the layout information without adding additional computing power. The layout vector and the text vector are arranged in an interlaced manner, which fully utilizes the autoregressive characteristics of the model and effectively improves the accuracy of document understanding.
[0059] The document processing method provided by the embodiment of the present disclosure can be applied to the scenario of understanding the document to answer questions. The method can be performed by a document processing device, which can be implemented by software and / or hardware, and the device can be integrated in an electronic device. Among them, the electronic device can include but is not limited to mobile terminals such as smart phones, laptops, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (Tablet Personal Computers, Tablet PCs), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), wearable devices, etc., and fixed terminals such as digital televisions, desktop computers, smart home devices, etc.
[0060] It is understandable that the document processing method is implemented based on the trained target document processing model. Before describing the document processing method, the model training method for document processing is described first. The method is executed by a model training device for document processing, which can be implemented by software and / or hardware, and the device can also be integrated in the above-mentioned electronic device.
[0061] Figure 1 A flowchart of a model training method for document processing provided in some embodiments of the present disclosure. Figure 1 As shown, the model training method for document processing may include the following steps:
[0062] S101. Obtain text information corresponding to a document sample, layout information of the text information in the document sample, a question sample, and a reference answer corresponding to the question sample.
[0063] The layout information is used to represent the position of the text information.
[0064] It can be understood that a document sample is obtained. The document sample can be in the form of image, text, audio and / or video. The document sample includes at least one text. The text information corresponding to the document sample, the layout information of the text information in the document sample, the question sample and the reference answer corresponding to the question sample are obtained. The text information refers to at least one text included in the identified document sample. The text information can be recorded in the form of text lines, for example, in the form of text lines such as "aaaa" and "bbbb". The text information can also be recorded in the form of a preset number of texts, such as a single text such as "a" and "a", or in the form of three texts such as "aaa" and "abb". Layout information refers to the position of text information in a document sample. Layout information can be in the form of multi-dimensional coordinates. For example, layout information is a 4-dimensional coordinate [x1, y1, x2, y2]. Layout information can be the pixel coordinates of the text box that selects the text information. Further, the 4-dimensional coordinates can be the normalized coordinates of the two corners of the text box. Alternatively, layout information can be a 6-dimensional coordinate. The 6-dimensional coordinates can be the coordinates of the two diagonal corners of the text box and the coordinates of any pixel, or the coordinates of the three corners. The coordinate dimensions included in the layout information can be determined by the user according to user needs and are not limited here. Question samples refer to samples that ask questions about the content recorded in the document sample. For example, the document sample records the content "a equals b", and the question sample can be "the relationship between a and b". The reference answer corresponding to the text sample refers to the standard answer to the question sample, which can be used as the true value for model training described below, so as to train the model based on the predicted value and true value output by the model. Based on the above example, the reference answer can be "equal to".
[0065] Optionally, the above-mentioned obtaining of text information corresponding to the document sample and layout information of the text information in the document sample can be specifically implemented through the following steps:
[0066] Perform optical character recognition on the document sample to determine the text information and layout information.
[0067] It is understandable that a document sample is obtained and the format of the document sample is determined. Different text and layout information recognition methods can be used in different document sample formats. For example, for a document sample in image format, optical character recognition processing or other text recognition methods can be used for recognition to obtain text information and layout information. A possible implementation process is to perform text recognition on the document sample in the form of text lines to obtain text information, and select each text line, and generate layout information based on the normalized coordinates of at least two diagonals of the text box. The layout information reflects the position of the text line in the document. If the document sample is in video format, multiple frames of images can be captured at a preset frequency, and optical character recognition processing can be performed on the multiple frames of images to determine the text information and layout information. Methods for determining text information and layout information in other document sample formats are not described in detail.
[0068] S102: Perform vectorization processing on the layout information to generate a layout vector, and perform vectorization processing on the text information to generate a text vector.
[0069] It is understandable that, based on the above S101, the layout information is vectorized to generate a layout vector, that is, the multidimensional coordinates in the layout information are mapped to the vector dimension, wherein the layout information includes at least one set of coordinates, each set of coordinates is composed of multidimensional coordinates, and each set of coordinates is used to characterize the position of the text in the document sample, and each set of coordinates can be mapped to a position (token) through vectorization. Specifically, a coordinate mapping module can be set, and the coordinate mapping module is used to map the multidimensional coordinates to the dimension of the vector (embedding) of the language model. For example, the dimension of the embedding can be 4096. The coordinate mapping module can use a pre-trained embedding module, or an embedding module jointly trained with a document processing model. It is understandable that the length of the layout vector is much shorter than the length of the text coordinates, and the length of the layout vector (token) can be set to 1. Therefore, vectorizing the layout information can effectively control the input length.
[0070] It is understandable that the text information is also vectorized to generate a text vector, which can be understood as dimension mapping of the text information as the embedding of the language model. The specific mapping method is not limited.
[0071] It is understandable that the layout information is vectorized to generate the layout vector, which can be implemented through the following steps:
[0072] The layout information is processed based on a weight matrix to generate a layout vector; wherein the weight matrix is a real number matrix having a preset embedding dimension and a coordinate dimension corresponding to the layout information.
[0073] It can be understood that the process of vectorizing the layout information is the process of converting the layout information into a bounding box position (bounding box token) in a vector format that can be processed by the language model. The layout information refers to the position information of the bounding box in a coordinate format. The bounding box can be understood as a text detection box, wherein the bounding box is represented by multi-dimensional coordinates. The following embodiment takes the bounding box represented by 4-dimensional coordinates [x1, y1, x2, y2] as an example for explanation. The 4-dimensional coordinates represent the normalized coordinates of the upper left corner (x1, y1,) and the lower right corner (x2, y2) of the bounding box. The 4-dimensional coordinates are mapped to a high-dimensional space, that is, the discrete 4-dimensional layout information is converted into a continuous layout vector of a preset embedding dimension through a weight matrix, so that the initial document processing model can process the coordinate information in the form of embedding. Among them, the weight matrix is a real number matrix with a preset embedding dimension and a coordinate dimension included in the layout information, and the layout information is a real number matrix with a coordinate dimension, which can also be understood as a vector matrix of bounding box coordinates. The bounding box refers to the text detection box.
[0074] Optionally, the above-mentioned processing of the layout information based on the weight matrix to generate the layout vector can be specifically implemented through the following steps:
[0075] Based on the weight matrix and auxiliary information, the layout information is processed to generate a layout vector; wherein the auxiliary information includes a bias matrix and / or an activation layer; and the bias matrix is a real number matrix with a preset embedding dimension.
[0076] It is understandable that when the local information is dimensionalized, it can also be implemented based on the weight matrix and auxiliary information, where the auxiliary information refers to the bias matrix and / or activation layer. For example, in order to further improve the conversion accuracy, the layout information is converted into a layout vector based on the weight matrix and the bias matrix. The bias matrix can be used to make more precise adjustments to the layout vector obtained based on the weight matrix, where the bias matrix is a real number matrix with a preset embedding dimension, and the layout vector is a bounding box token with a preset embedding dimension. Alternatively, the layout information is converted into a layout vector based on the weight matrix, the bias matrix and the activation layer, further ensuring that the discrete multi-dimensional layout information is accurately converted into a continuous layout vector with a preset embedding dimension.
[0077] Specifically, the above-mentioned process of vectorization based on the weight matrix and the bias matrix can be expressed as follows: perform dot multiplication on the layout information and the weight matrix to obtain the dot multiplication result, add the dot multiplication result and the bias matrix to generate the layout vector, perform vectorization on the layout information, and generate the layout vector. The specific implementation formula is shown in formula (1):
[0078] z=W·c+b Formula (1)
[0079] Where c is the layout information, c∈R^4, R is a real number, 4 is the coordinate dimension included in the layout information, W is the weight matrix, W∈Rd×4, d is the preset embedding dimension, b is the bias matrix, b∈Rd×1, z is the layout vector, which is the d-dimensional embedded bounding box token, where the weight matrix and bias matrix can be set in advance or determined through model training.
[0080] S103. Based on the correspondence between text information and layout information, the layout vectors and the text vectors are arranged alternately, and the alternately arranged layout vectors and text vectors, as well as the question sample, are input into the initial document processing model to determine the predicted answer corresponding to the question sample.
[0081] It can be understood that, based on the above S102, the layout information reflects the position of the text information in the document sample, so there is a corresponding relationship between the text information and the layout information. For example, there is corresponding layout information 1 for text information 1, and layout information 1 represents the normalized coordinates of the upper left corner and the lower right corner of the text detection box 1 that can select the text information 1 in the entire document sample. Based on the correspondence between text information and layout information, the layout vectors and text vectors are arranged in an interlaced manner. Based on the above example, layout vector 1, text vector 1, and layout vector 2 and text vector 2 are arranged in an interlaced manner. It can be understood that layout vector 1 is recorded as token0, text information 1 includes all texts selected by text detection box 1, text vector 1 includes the vector of a single text, and the vector of a single text is recorded as a token, and all text tokens are arranged sequentially in the interlaced arrangement. For example, text information 1 is "aa bb cc", which includes 3 texts, among which the vectors of "aa", "bb" and "cc" are recorded as token1, token2 and token3 respectively, and the interlaced layout vectors and text vectors are token0, token1, token2 and token3, followed by layout vector 2 and text vector 2 of layout information 2 corresponding to text information 2, and so on, to complete the interlaced arrangement of all layout information and text information. Subsequently, the staggered layout vectors and text vectors, as well as the question samples and reference answers are input into the initial document processing model, and the answer to the question sample is predicted by the initial document processing model, and the predicted answer is output. The initial document processing model may be a language model or other models that can be predicted based on vectors, which will not be elaborated here.
[0082] For example, see Figure 2 , Figure 2 A structural schematic diagram of text processing provided by some embodiments of the present disclosure, taking a document sample in image format as an example, the document sample is identified and two text detection boxes are shown. The text selected by text detection box 1 is text information 1, and text information 1 includes three texts such as "aa bb cc", wherein the vectors of "aa", "bb" and "cc" are recorded as t2, t3 and t4 respectively; the text selected by text detection box 2 is text information 2, and text information 2 includes two texts such as "dd ee", wherein the vectors of "dd" and "ee" are recorded as t6 and t7 respectively; the layout information 1 corresponding to text information 1 is [x1, y1, x2, y2], the layout vector 1 of layout information 1 is b1, the layout information 2 corresponding to text information 2 is [x3, y3, x4, y4], the layout vector 2 of layout information 2 is b5, the layout vector 1, text information 1, layout vector 2 and text vector 2 are alternately arranged with the question sample as the input sequence of the document processing model, and the subsequent document processing model predicts the predicted answer to the question sample.
[0083] Optionally, the above-mentioned interlaced layout vectors and text vectors, as well as the question sample, are input into the initial document processing model to determine the predicted answer corresponding to the question sample, which can be specifically implemented by the following steps:
[0084] Based on a preset ratio, groups of interleaved vectors arranged in sequence according to the order of each text information in a document sample are shuffled to obtain reordered groups of interleaved vectors; wherein a group of interleaved vectors includes an interleaved layout vector and a corresponding text vector; the reordered groups of interleaved vectors and the question sample are input into an initial document processing model to determine a predicted answer.
[0085] It is understandable that when optical character recognition is used to determine the text information in a document sample and the layout information of the text information in the document sample, optical character recognition usually recognizes text from top to bottom and from left to right. This recognition order is often directly used as the input sequence of the language model, but different language models may show inductive characteristics of the token position in the input sequence. Specifically, tokens that are close to each other in the input sequence often get higher attention scores, which is beneficial for processing standard text sequences, but it will be misleading for non-standard text sequences that appear in most scenarios, seriously affecting the accuracy of the language model. For example, see Figure 3 , Figure 3 A schematic diagram of a document image provided in some embodiments of the present disclosure, wherein the text sequence obtained by optical character recognition is generally: "aa, 1.3, bb, cc, dd, 6, 17, 18". Figure 3 In the document image shown, if the question is "What is the value of aa", the model can easily recognize the answer as "1.3". In the text sequence, the marker positions of "aa" and "1.3" are relatively close, and the model can easily recognize the answer. For example, if the question is "What is the value of dd", the model usually finds it difficult to answer the correct answer when the marker positions are far apart and "dd" is followed by a string of consecutive numbers. Regarding the model's sequence induction problem, on the one hand, by integrating layout vectors and text vectors, the model's dependence on the order of the input sequence can be reduced. On the other hand, a preset ratio is set, and each group of interleaved vectors in the input sequence is shuffled (i.e., the sorting is shuffled) based on the preset ratio. The sorting of each group of interleaved vectors in the input sequence is determined based on the sorting of each text information obtained by optical character recognition. A group of interleaved vectors includes interleaved layout vectors and text vectors, that is, the layout vectors and the corresponding text vectors are shuffled as a whole, so as to enhance the model's resilience in identifying related information without considering the proximity of the markers in the sequence, such as Figure 2As shown, a group of interleaved vectors is b1, t2, t3 and t4. In another possible situation, before interleaving the layout vectors and the text vectors, the order of the text vectors or text information is first disrupted, and then based on the correspondence between the text information and the layout information, the layout vector is arranged in a neighboring position of the corresponding text vector. For example, the layout vector is directly arranged before the corresponding text vector, that is, the text order determined based on the optical character recognition process is first disrupted, and then the re-ordered groups of interleaved vectors and question samples are input into the initial document processing model, and the answer to the question sample is predicted by the initial document processing model, and the predicted answer is output.
[0086] Optionally, the preset ratio is less than or equal to 20%.
[0087] It is understandable that the preset ratio is less than or equal to 20%, which can effectively reduce the dependence of the model prediction on the order of the input sequence, thereby improving the model accuracy. Other possible scrambling ratios for random scrambling can be determined according to specific application scenarios. A preset ratio higher than 20% may affect the model convergence speed and reduce the model accuracy, which will not be elaborated here.
[0088] S104. Based on the predicted answers and the reference answers, the initial document processing model is iteratively trained to generate a target document processing model.
[0089] It can be understood that on the basis of the above S103, the loss function is calculated based on the predicted answer output by the model and the reference answer as the true value, the initial document processing model is iteratively trained through the loss function, the model parameters of the initial document processing model are updated, and the trained target document processing model is obtained.
[0090] Optionally, the above-mentioned iterative training of the initial document processing model based on the predicted answer and the reference answer to generate the target document processing model can be specifically implemented through the following steps:
[0091] Based on the predicted answers and the reference answers, the initial document processing model, the weight matrix and the auxiliary information are iteratively trained to generate a target document processing model, an updated weight matrix and updated auxiliary information.
[0092] It is understandable that the initial document processing model uses layout-aware next word prediction technology to predict the answer to the question sample. The next word prediction technology in the related technology only relies on the text content, mostly predicting the subsequent words based on the previous word sequence, and does not consider the impact of spatial layout on the prediction accuracy. The layout-aware next word prediction technology interweaves layout information and text information, comprehensively considering the content and layout in the document sample, so that the model has a richer and more accurate understanding of the structure and content. Specifically, the loss function is calculated based on the predicted answer and the reference answer, and the model parameters of the initial understanding model, the weight matrix and auxiliary information used for vectorizing the layout information are iteratively trained through the loss function, and the weight matrix, auxiliary information and model parameters are updated to obtain the trained target document processing model and the updated weight matrix and updated auxiliary information. When the target document processing model is subsequently applied for reasoning, the layout information can be vectorized based on the updated weight matrix and the updated auxiliary information. The calculation formula of the loss function is shown in formula (2):
[0093]
[0094] Where L is the loss function, T is the number of individual texts included in the document sample, P is the probability, and P(t i |t 1 , t 2 , ..., t i-1 ) indicates that given the preceding word sequence t in the target document processing model i |t 1 , t 2 , ..., t i-1 After that, the i-th word t i probability.
[0095] For example, see Figure 4 , Figure 4 A schematic diagram of the structure of word prediction provided in some embodiments of the present disclosure. Figure 4 The comparison between the next word prediction task in the related art and the next word prediction task based on layout awareness in the embodiment of the present disclosure is shown. The next word prediction task in the language model in the related art is to predict t2 based on t1, and then predict t3 based on t2, so as to predict the next word based on the previous word. The text processing model in the embodiment of the present disclosure implements the next word prediction task based on layout awareness. The next word prediction task based on layout awareness is to predict t2 based on b1, predict t3 based on t2, and predict t5 based on b4. Among them, the layout vector is represented by b, and the layout vector b does not predict, only the text vector is predicted, and the text vector is represented by t. <s> To start prediction,< / s> Marks the start of the prediction to end.
[0096] It can be understood that the target document processing model trained by the above-mentioned document processing model training method has a training accuracy based on different training sets in application scenarios such as visual question answering and key information extraction, as shown in Table 1. Among them, the first data set refers to the document visual question answering data set, the second data set refers to the reading comprehension data set, the third data set refers to the form data set, the fourth data set refers to the key information extraction data set, and the fifth data set refers to the bill data set. As shown in Table 1, for the same training data set, the training accuracy of the target document processing model is higher than the training accuracy of other models with document understanding functions (i.e. other models) in the related art. Table 1 specifically shows the training accuracy in terms of string similarity and F1 value (F1score).
[0097] Table 1:
[0098]
[0099] Table 2:
[0100]
[0101] Table 2 shows the training accuracy of different data sets in terms of accuracy. The sixth data set refers to the information chart data set, and the seventh data set refers to the label data set. For the same training data set, the accuracy of the target document processing model is higher than that of other models.
[0102] Table 3:
[0103]
[0104] Table 3 shows the comparison of the input length of the target document processing model and other models. The input length of the target document processing model is generally lower than that of other models, which also shows that mapping the layout information including multi-dimensional coordinates to the embedding dimension of the model and generating the layout vector can effectively reduce the input length.
[0105] The model training method for document processing provided by the embodiment of the present disclosure converts layout information including multi-dimensional coordinates into layout vectors, greatly reducing the input length, and sequencing the time of any mode of text interleaving, effectively integrating layout information and text information into the same sequence, so that the model can process two modes simultaneously and coordinately, making full use of the autoregressive characteristics of the language model and improving the model accuracy. At the same time, the model adopts layout-aware next word prediction technology to interweave layout information and text information, fully considering the content and layout in the document, so that the model can have a richer and more accurate understanding of the document structure and content. Secondly, the input order determined based on optical character recognition is disrupted according to a preset ratio, enhancing the model's resilience in identifying relevant information without considering the proximity of tags in the input sequence, and effectively improving the model training accuracy.
[0106] Based on the above embodiments, Figure 5 A flowchart of a document processing method provided by some embodiments of the present disclosure specifically includes the following steps: Figure 5 The following steps are shown:
[0107] S501, obtaining text information in a document to be processed, layout information of the text information in the document to be processed, and a target question.
[0108] Understandably, determine the document to be processed, which may be a document to be understood, which may be in image format or other formats, obtain text information in the document to be processed, layout information of the text information in the document to be processed, and target questions raised for the content expressed in the document to be processed, and the target questions may be questions to be understood about the content of the document to be processed.
[0109] Optionally, the above-mentioned obtaining of text information in the document to be processed and layout information of the text information in the document to be processed can be specifically implemented through the following steps:
[0110] Perform optical character recognition on the document to be processed to determine the text information and layout information.
[0111] It is understandable that the specific implementation steps of obtaining the text information in the document to be processed and the layout information of the text information in the document to be processed refer to the above embodiment, which will not be described in detail here.
[0112] S502: Perform vectorization processing on the layout information to generate a layout vector, and perform vectorization processing on the text information to generate a text vector.
[0113] Optionally, in S502, vectorization processing is performed on the layout information to generate a layout vector, which can be specifically implemented through the following steps:
[0114] The layout information is processed based on a weight matrix to generate a layout vector; wherein the weight matrix is a real number matrix having a preset embedding dimension and a coordinate dimension corresponding to the layout information.
[0115] Optionally, the above-mentioned processing of the layout information based on the weight matrix to generate the layout vector can be specifically implemented through the following steps:
[0116] Based on the weight matrix and auxiliary information, the layout information is processed to generate a layout vector; wherein the auxiliary information includes a bias matrix and / or an activation layer; and the bias matrix is a real number matrix with a preset embedding dimension.
[0117] Optionally, the above processing of the layout information based on the weight matrix and the bias matrix to generate the layout vector can be specifically implemented through the following steps:
[0118] The layout information and the weight matrix are dot-multiplied, and the dot-multiplication result is added to the bias matrix to generate a layout vector.
[0119] It is understandable that, based on the above S501, the specific implementation steps of S502 refer to the above embodiment and are not described in detail here.
[0120] S503. Based on the correspondence between the text information and the layout information, the layout vectors and the text vectors are arranged alternately, and the alternately arranged layout vectors and text vectors, as well as the target question, are input into the target document processing model to determine the answer to the target question.
[0121] The target document processing model is pre-trained by the above-mentioned document processing model training method.
[0122] It can be understood that, based on the above S502, after the layout vectors and the text vectors are interlaced, the interlaced layout vectors and the text vectors, as well as the target question, are input into a pre-trained target document processing model, and the target document processing model predicts and understands the text involved in the target question based on the interlaced layout vectors and the text vectors, and outputs the answer. The target question can obtain and input the text after the layout vectors and the text vectors are interlaced, or it can be obtained while obtaining the text information.
[0123] Optionally, the above-mentioned inputting the staggered layout vectors and text vectors, as well as the target question, into the target document processing model to determine the answer to the target question can be specifically implemented by the following steps:
[0124] Based on a preset ratio, groups of interleaved vectors arranged in sequence according to the order of each text information in the document to be processed are sorted and shuffled to obtain reordered groups of interleaved vectors; wherein a group of interleaved vectors includes staggered layout vectors and corresponding text vectors; the reordered groups of interleaved vectors and the target question are input into the target document processing model to determine the answer to the target question.
[0125] Optionally, the preset ratio is less than or equal to 20%.
[0126] It is understandable that the specific implementation steps of S503 refer to the above embodiment and are not described in detail here.
[0127] The document processing method provided by the embodiment of the present disclosure vectorizes the layout information and the text information to obtain the layout vector and the text vector respectively, introduces the layout information, and does not increase the extra input length through the vectorization processing. While retaining the content and spatial layout of the document and improving the accuracy of document understanding, it does not increase the extra computing power. It also provides the ability of interleaving text and layout input to better utilize the autoregressive characteristics of the model, further improving the understanding accuracy.
[0128] The following is an embodiment of a model training device for document processing provided in an embodiment of the present invention. The device and the model training method for document processing in the above-mentioned embodiments belong to the same inventive concept. For details not described in detail in the embodiment of the model training device for document processing, please refer to the embodiment of the model training method for document processing mentioned above.
[0129] Figure 6 A schematic diagram of the structure of a model training device for document processing provided in some embodiments of the present disclosure. Figure 6 As shown, the model training device 600 for document processing may include a first information acquisition module 601, a first vectorization module 602, a first vector interleaving module 603 and a model training module 604, wherein:
[0130] The first information acquisition module 601 is used to acquire text information corresponding to the document sample, layout information of the text information in the document sample, question samples and reference answers corresponding to the question samples; wherein the layout information is used to represent the position of the text information;
[0131] A first vectorization module 602, used to perform vectorization processing on the layout information to generate a layout vector, and to perform vectorization processing on the text information to generate a text vector;
[0132] A first vector interleaving module 603 is used to interleave the layout vector and the text vector based on the correspondence between the text information and the layout information, and input the interleaved layout vector and text vector, as well as the question sample, into the initial document processing model to determine the predicted answer corresponding to the question sample;
[0133] The model training module 604 is used to iteratively train the initial document processing model based on the predicted answers and the reference answers to generate a target document processing model.
[0134] Optionally, the first vectorization module 602 is used for:
[0135] The layout information is processed based on a weight matrix to generate a layout vector; wherein the weight matrix is a real number matrix having a preset embedding dimension and a coordinate dimension corresponding to the layout information.
[0136] Optionally, the first vectorization module 602 is used for:
[0137] Based on the weight matrix and auxiliary information, the layout information is processed to generate a layout vector; wherein the auxiliary information includes a bias matrix and / or an activation layer; the bias matrix is a real number matrix with a preset embedding dimension. Optionally, the model training module 604 is used to:
[0138] Based on the predicted answers and the reference answers, the initial document processing model, the weight matrix and the auxiliary information matrix are iteratively trained to generate a target document processing model, an updated weight matrix and updated auxiliary information.
[0139] Optionally, the first vector interleaving module 603 is used to:
[0140] Based on a preset ratio, each group of interleaved vectors sequentially arranged according to the order of each text information in the document sample is subjected to random processing to obtain each group of reordered interleaved vectors; wherein a group of interleaved vectors includes interleaved layout vectors and corresponding text vectors;
[0141] The reordered groups of interleaved vectors and question samples are input into the initial document processing model to determine the predicted answer.
[0142] Optionally, the preset ratio is less than or equal to 20%.
[0143] Optionally, the first information acquisition module 601 is used to:
[0144] Optical character recognition is performed on the document sample to determine text information and layout information.
[0145] The model training device for document processing provided in the embodiment of the present invention can execute the model training method for document processing provided in any embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method.
[0146] The following is an embodiment of a document processing device provided by an embodiment of the present invention. The device and the document processing methods of the above-mentioned embodiments belong to the same inventive concept. For details not described in detail in the embodiment of the document processing device, reference can be made to the embodiment of the above-mentioned document processing method.
[0147] Figure 7 This is a schematic diagram of the structure of a document processing device provided in some embodiments of the present disclosure. Figure 7 As shown, the document processing device 700 may include a second information acquisition module 701, a second vectorization module 702 and an answer determination module 703:
[0148] The second information acquisition module 701 is used to acquire text information in the document to be processed, layout information of the text information in the document to be processed, and target questions;
[0149] The second vectorization module 702 is used to perform vectorization processing on the layout information to generate a layout vector, and to perform vectorization processing on the text information to generate a text vector;
[0150] The answer determination module 703 is used to interleave the layout vectors and the text vectors based on the correspondence between the text information and the layout information, and input the interleaved layout vectors and text vectors, as well as the target question, into the target document processing model to determine the answer to the target question.
[0151] Optionally, the target document processing model is pre-trained using the document processing model training method described above.
[0152] Optionally, the second information acquisition module 701 is used to:
[0153] Perform optical character recognition on the document to be processed to determine the text information and layout information.
[0154] Optionally, the second vectorization module 702 is used for:
[0155] The layout information is processed based on a weight matrix to generate a layout vector; wherein the weight matrix is a real number matrix having a preset embedding dimension and a coordinate dimension corresponding to the layout information.
[0156] Optionally, the second vectorization module 702 is used for:
[0157] Based on the weight matrix and auxiliary information, the layout information is processed to generate a layout vector; wherein the auxiliary information includes a bias matrix and / or an activation layer; and the bias matrix is a real number matrix with a preset embedding dimension.
[0158] Optionally, the answer determination module 703 is used to:
[0159] Based on a preset ratio, groups of interleaved vectors arranged in sequence according to the order of each text information in a document to be processed are shuffled to obtain reordered groups of interleaved vectors; wherein a group of interleaved vectors includes interleaved layout vectors and corresponding text vectors; the reordered groups of interleaved vectors and a target question are input into a target document processing model to determine the answer to the target question.
[0160] Optionally, the preset ratio is less than or equal to 20%.
[0161] The document processing device provided in the embodiment of the present invention can execute the document processing method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0162] It is worth noting that in the embodiment of the above-mentioned document processing device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this disclosure.
[0163] The present disclosure also provides an electronic device, which may include a processor and a memory, wherein the memory may be used to store executable instructions. The processor may be used to read the executable instructions from the memory and execute the executable instructions to implement the model training method and document processing method of the above-mentioned embodiment.
[0164] Figure 8 A schematic diagram of the structure of an electronic device provided for some embodiments of the present disclosure.
[0165] like Figure 8 As shown, the electronic device 800 may include a processing device 801 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 are also stored. The processing device 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output interface (I / O interface) 805 is also connected to the bus 804.
[0166] Typically, the following devices may be connected to the I / O interface 805: an input device 806 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 807 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 808 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 809. The communication device 809 may allow the electronic device 800 to communicate with other devices wirelessly or by wire to exchange data.
[0167] It should be noted that Figure 8 The electronic device 800 shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure. Figure 8 The electronic device 800 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0168] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 809, or installed from the storage device 808, or installed from the ROM 802. When the computer program is executed by the processing device 801, the above-mentioned functions defined in the model training method and document processing method of any embodiment of the present disclosure are executed.
[0169] An embodiment of the present disclosure also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the processor implements the model training method and document processing method of any embodiment of the present disclosure.
[0170] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0171] In some embodiments, the client and server may communicate using any currently known or future developed network protocol such as HTTP, and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0172] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0173] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the steps of the document processing model training method and document processing method described in any embodiment of the present disclosure.
[0174] In embodiments of the present disclosure, computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on a user's computer, partially on a user's computer, as a separate software package, partially on a user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0175] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the equipment, method and computer program product according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0176] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0177] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0178] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0179] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0180] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A model training method for document processing, characterized in that: include: Acquire text information corresponding to a document sample, layout information of the text information in the document sample, a question sample, and a reference answer corresponding to the question sample; wherein the layout information is used to characterize the position of the text information; Performing vectorization processing on the layout information to generate a layout vector, and performing vectorization processing on the text information to generate a text vector; Based on the correspondence between the text information and the layout information, the layout vectors and the text vectors are arranged alternately, and the alternately arranged layout vectors and the text vectors, as well as the question sample, are input into an initial document processing model to determine a predicted answer corresponding to the question sample; Based on the predicted answer and the reference answer, the initial document processing model is iteratively trained to generate a target document processing model.
2. The method according to claim 1, characterized in that The vectorizing the layout information to generate a layout vector includes: The layout information is processed based on a weight matrix to generate the layout vector; wherein the weight matrix is a real number matrix having a preset embedding dimension and a coordinate dimension corresponding to the layout information.
3. The method according to claim 2, characterized in that The processing of the layout information based on the weight matrix to generate the layout vector includes: Based on the weight matrix and auxiliary information, the layout information is processed to generate the layout vector; wherein the auxiliary information includes a bias matrix and / or an activation layer; and the bias matrix is a real number matrix with a preset embedding dimension.
4. The method according to claim 3, characterized in that The iterative training of the initial document processing model based on the predicted answer and the reference answer to generate a target document processing model includes: Based on the predicted answer and the reference answer, the initial document processing model, the weight matrix and the auxiliary information are iteratively trained to generate the target document processing model, the updated weight matrix and the updated auxiliary information.
5. The method according to claim 1, characterized in that The step of inputting the staggered layout vectors and the text vectors, as well as the question sample, into an initial document processing model to determine a predicted answer corresponding to the question sample includes: Based on a preset ratio, each group of interleaved vectors sequentially arranged according to the order of each text information in the document sample is subjected to random processing to obtain each group of reordered interleaved vectors; wherein a group of interleaved vectors includes the interleaved layout vectors and the corresponding text vectors; The reordered groups of interleaved vectors and the question sample are input into the initial document processing model to determine the predicted answer.
6. The method according to claim 5, characterized in that The preset ratio is less than or equal to 20%.
7. The method according to claim 1, characterized in that Acquiring text information corresponding to a document sample and layout information of the text information in the document sample includes: Optical character recognition is performed on the document sample to determine the text information and the layout information.
8. A document processing method, characterized in that: include: Acquire text information in a document to be processed, layout information of the text information in the document to be processed, and a target question; Performing vectorization processing on the layout information to generate a layout vector, and performing vectorization processing on the text information to generate a text vector; Based on the correspondence between the text information and the layout information, the layout vectors and the text vectors are arranged alternately, and the alternately arranged layout vectors and the text vectors, as well as the target question, are input into a target document processing model to determine an answer to the target question.
9. The method according to claim 8, characterized in that The target document processing model is pre-trained by the model training method for document processing as described in any one of claims 1 to 7.
10. A model training device for document processing, characterized in that: include: A first information acquisition module is used to acquire text information corresponding to a document sample, layout information of the text information in the document sample, a question sample, and a reference answer corresponding to the question sample; wherein the layout information is used to characterize the position of the text information; A first vectorization module, used to perform vectorization processing on the layout information to generate a layout vector, and to perform vectorization processing on the text information to generate a text vector; A first vector interleaving module is used to interleave the layout vectors and the text vectors based on the correspondence between the text information and the layout information, and input the interleaved layout vectors and the text vectors, as well as the question sample, into an initial document processing model to determine a predicted answer corresponding to the question sample; The model training module is used to iteratively train the initial document processing model based on the predicted answer and the reference answer to generate a target document processing model.
11. A document processing device, characterized in that: include: A second information acquisition module is used to acquire text information in the document to be processed, layout information of the text information in the document to be processed, and a target question; A second vectorization module is used to perform vectorization processing on the layout information to generate a layout vector, and to perform vectorization processing on the text information to generate a text vector; The answer determination module is used to interleave the layout vectors and the text vectors based on the correspondence between the text information and the layout information, and input the interleaved layout vectors and the text vectors, as well as the target question, into a target document processing model to determine the answer to the target question.
12. An electronic device, characterized in that: include: processor; A memory for storing executable instructions; The processor is used to read the executable instructions from the memory and execute the executable instructions to implement the model training method for document processing described in any one of claims 1 to 7, or the document processing method described in claim 8 or 9.
13. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the processor implements the model training method for document processing described in any one of claims 1 to 7, or the document processing method described in claim 8 or 9.
Citation Information
Patent Citations
Key information extraction method and device, storage medium and electronic device
CN114238622A
Document processing method and device
CN114817444A
Text extraction model training method and device, text extraction method and device, equipment and medium
CN116186195A
Document detection model training method and device and electronic equipment
CN117333889A
Document retrieval method, man-machine interaction method, electronic equipment and storage medium
CN117573839A
