Question answering method and device based on document image, equipment, storage medium and program product
Through the preset layout analysis model and image and text alignment processing, the problem of inaccurate understanding of document image layout by the question and answer model is solved, and the accuracy of document image question and answer is improved.
Patent Information
- Application Number
- CN202410763359.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-09-03
AI Technical Summary
In the existing technology, the question and answer model has a balanced understanding of each part of the document image. As a result, when the question is a local question of the document, the answer is not accurate enough, which reduces the accuracy of the document image question and answer.
The preset layout analysis model is used to perform layout analysis on the document image, and the question-related information is combined for splicing and coding to generate text feature information, and the question reply information is obtained through image and text alignment processing.
It improves the question-answering model's understanding of the document image layout, ensures that the answer can be accurately determined when the question is local to the document, and improves the accuracy of document image question-and-answer.
Smart Images

Figure CN118586403A
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and in particular to a document image-based question-answering method, apparatus, device, storage medium, and program product. Background Art
[0002] With the continuous development of computer technology and artificial intelligence, the understanding of documents has also changed from manual recognition to intelligent recognition, thereby improving work efficiency.
[0003] Currently, intelligent document recognition generally involves pre-building a question-and-answer model and converting the document into a corresponding document image. The document image and questions raised about the document are then input into the question-and-answer model, which then determines and outputs the corresponding answers in the document image based on the above questions.
[0004] However, this method of using the question-answering model to directly determine the answer based on the document image causes the question-answering model to have a balanced understanding of each part of the document image. As a result, when a question is about a local part of the document, the answer determined is not accurate enough, thus reducing the accuracy of document image question-answering. Summary of the invention
[0005] The present application provides a document image-based question-answering method, apparatus, device, storage medium and program product, which are used to solve the technical problem in the prior art that when a question is about a local issue of a document, the answer determined is not accurate enough, thereby reducing the accuracy of document image question-answering.
[0006] In a first aspect, the present application provides a document image-based question-answering method, comprising: obtaining a target document image and corresponding question-related information, and inputting the target document image into a preset layout analysis model; the preset layout analysis model is obtained by training a preset document image annotated with preset information until convergence; the preset information is: at least one preset layout type identifier in the preset document image and the area information of each preset layout type identifier in the preset document image; the preset layout type identifier includes any one of the following: a general title identifier, a header identifier, a footer identifier, a text identifier, a paragraph identifier, a picture title identifier, a picture identifier, a table title identifier, a table identifier, a formula identifier, and a reference identifier;
[0007] Determine at least one target layout type identifier in the target document image and area information of the target layout type identifier in the target document image using the preset layout analysis model;
[0008] The information related to the question, at least one target layout type identifier, and the area information of the target layout type identifier in the target document image are sequentially spliced and encoded to obtain text feature information corresponding to the target document image; the splicing is performed based on a preset unified format;
[0009] Acquire image feature information, and use a preset alignment strategy to align the image feature information and the text feature information to obtain image-text alignment information corresponding to the target document image;
[0010] The question answer information corresponding to the target document image is determined based on the image-text feature information and a preset question-answer model.
[0011] In one possible design, the preset layout analysis model is used to determine at least one target layout type identifier in the target document image and the area information of the target layout type identifier in the target document image, including: dividing the target document image according to the training results to obtain at least one circled area in the target document image, and determining the target layout type identifier corresponding to each circled area; and obtaining the area information corresponding to each circled area based on the division results.
[0012] In a possible design, before using the preset layout analysis model to determine at least one target layout type identifier in the target document image and the area information of the target layout type identifier in the target document image, it also includes: in response to receiving an operation of a user to circle an area in the preset document image, identifying the document content in the circled area to determine the corresponding preset layout type identifier; determining the area information of the circled area in the preset document image to obtain the area information corresponding to the preset layout type identifier; marking each circled area using the corresponding preset layout type identifier and the area information corresponding to the preset layout type identifier to obtain a preset document image marked with preset information.
[0013] In one possible design, determining the question answer information corresponding to the target document image based on the text feature information and a preset question-answering model includes: obtaining a preset question-answering model; the preset question-answering model is trained until convergence using a preset document image that is annotated with question-related information and corresponding question answer information; inputting the image-text alignment information into the preset question-answering model, and using the preset question-answering model to determine the question answer information corresponding to the question-related information based on the image-text alignment information; outputting the question answer information, and determining the question answer information as the question answer information corresponding to the target document image.
[0014] In a possible design, before obtaining the image feature information, it also includes: using a preset encoding strategy to encode the target document image to obtain the image feature information corresponding to the target document image; the image feature information includes the full document content and corresponding location information.
[0015] In one possible design, the question-related information includes a layout type association identifier; the image feature information and the text feature information are aligned using a preset alignment strategy, including: determining an associated layout type identifier in at least one target layout type identifier based on the layout type association identifier in the text feature information; the associated layout type identifier is a target layout type identifier for associated question-related information; obtaining area information of the associated layout type identifier in the preset document image, and determining the target document content corresponding to the area information of the associated layout type identifier in the full document content based on the position information in the image feature information; and establishing a corresponding relationship between the target document content and the question-related information to complete the alignment process.
[0016] In one possible design, the preset question-answering model is used to determine the question answer information corresponding to the question-related information based on the image-text alignment information, including: decoding the image-text alignment information to obtain question-related information and corresponding target document content; and determining the question answer information corresponding to the question-related information in the target document content based on the training results.
[0017] In a second aspect, the present application provides a document image-based question-answering device, comprising: an acquisition module, for acquiring a target document image and corresponding question-related information;
[0018] An input module is used to input the target document image into a preset layout analysis model; the preset layout analysis model is obtained by training a preset document image annotated with preset information until convergence; the preset information is: at least one preset layout type identifier in the preset document image and the area information of each preset layout type identifier in the preset document image; the preset layout type identifier includes any one of the following: a general title identifier, a header identifier, a footer identifier, a text identifier, a paragraph identifier, a picture title identifier, a picture identifier, a table title identifier, a table identifier, a formula identifier, and a reference identifier;
[0019] A determination module, configured to determine at least one target layout type identifier in the target document image and area information of the target layout type identifier in the target document image by using the preset layout analysis model;
[0020] A processing module, configured to sequentially perform splicing and encoding processing on the information related to the question, at least one target layout type identifier, and the area information of the target layout type identifier in the target document image, so as to obtain text feature information corresponding to the target document image; the splicing processing is performed based on a preset unified format;
[0021] The acquisition module is also used to acquire image feature information;
[0022] The processing module is further used to perform alignment processing on the image feature information and the text feature information using a preset alignment strategy to obtain image-text alignment information corresponding to the target document image;
[0023] The determination module is further used to determine the question answer information corresponding to the target document image based on the image-text feature information and a preset question-answer model.
[0024] In a third aspect, an embodiment of the present application provides an electronic device comprising: at least one processor and a memory; the memory stores computer execution instructions; the at least one processor executes the computer execution instructions stored in the memory, so that the at least one processor executes the document image-based question and answer method as described in the first aspect and various possible designs of the first aspect.
[0025] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the document image-based question and answer method described in the first aspect and various possible designs of the first aspect is implemented.
[0026] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the document image-based question-and-answer method as described in the first aspect and various possible designs of the first aspect.
[0027] The document image-based question-answering method, apparatus, device, storage medium and program product provided in the present application obtain a target document image and corresponding question-related information, and input the target document image into a preset layout analysis model; the preset layout analysis model is obtained by training a preset document image annotated with preset information until convergence; the preset information is: at least one preset layout type identifier in the preset document image and the area information of each preset layout type identifier in the preset document image; the preset layout type identifier includes any one of the following: a general title identifier, a header identifier, a footer identifier, a text identifier, a paragraph identifier, a picture title identifier, a picture identifier, a table title identifier, a table identifier, a formula identifier, and a reference identifier; the preset layout type identifier is used to identify the target document image and the corresponding question-related information, and the target document image is input into a preset layout analysis model; the preset layout analysis model is obtained by training a preset document image annotated with preset information until convergence; the preset information is: at least one preset layout type identifier in the preset document image and the area information of each preset layout type identifier in the preset document image; the preset layout type identifier includes any one of the following: a general title identifier, a header identifier, a footer identifier, a text identifier, a paragraph identifier, a picture title identifier, a picture identifier, a table title identifier, a table identifier, a formula identifier, and a reference identifier; The face analysis model determines at least one target layout type identifier in the target document image and the area information of the target layout type identifier in the target document image; the question-related information, at least one target layout type identifier and the area information of the target layout type identifier in the target document image are sequentially spliced and encoded to obtain text feature information corresponding to the target document image; the splicing process is performed based on a preset unified format; image feature information is obtained, and the image feature information and the text feature information are aligned using a preset alignment strategy to obtain image-text alignment information corresponding to the target document image; based on the image-text feature information and the preset question-answering model, the question answer information corresponding to the target document image is determined. Since a plurality of preset layout types are preset, and a preset layout analysis model is obtained by using a preset document image marked with at least one preset layout type identifier and the area information corresponding to each preset layout type identifier as a training sample, the target document image can be input into the preset layout analysis model by obtaining the target document image and the corresponding question-related information, and the preset layout analysis model can be used to determine at least one target layout type identifier in the target document image and the area information of the target layout type identifier in the target document image. By sequentially performing a unified format-based splicing and encoding process on the question-related information, at least one target layout type identifier, and the area information of the target layout type identifier in the target document image, the text feature information corresponding to the target document image can be obtained, thereby improving the readability of the text feature information. Thus, by obtaining the image feature information, the image feature information and the text feature information can be aligned to obtain the graphic feature information, and the question answer information corresponding to the target document image can be determined based on the graphic feature information and the preset question-answering model. This enables the question-answering model to understand each part according to the layout of the document image, and when a question is a local question about the document, the answer can be accurately determined, thereby improving the accuracy of document image question-answering. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0029] Figure 1 An application scenario diagram of the document image-based question-answering method provided in an embodiment of the present application;
[0030] Figure 2 The process of the document image-based question-answering method provided in the embodiment of the present application Figure 1 ;
[0031] Figure 3 The process of the document image-based question-answering method provided in the embodiment of the present application Figure 2 ;
[0032] Figure 4 The process of the document image-based question-answering method provided in the embodiment of the present application Figure 3 ;
[0033] Figure 5 A complete flow chart of the document image-based question-answering method provided in an embodiment of the present application;
[0034] Figure 6 A schematic diagram of the structure of a document image-based question-answering device provided in an embodiment of the present application;
[0035] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0036] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0037] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0038] In the technical solution of this application, the collection, storage, use, processing, transmission, provision and disclosure of information such as financial data or user data involved shall comply with the provisions of relevant laws and regulations and shall not violate public order and good morals.
[0039] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0040] In the prior art, when intelligently identifying documents, the documents are generally identified based on a question-answering model. Specifically, a document image with marked question information and corresponding answer information is used as a training sample in advance to establish a question-answering model. When a user needs to identify a document based on the question-answering model, the document is first converted into a corresponding document image, and then the document image and the question raised about the document are input into the question-answering model. The question-answering model determines the corresponding answer in the document image according to the above question and outputs it. This makes the question-answering model have a balanced understanding of each part of the document image. When a question is about a local question of the document, the answer determined is not accurate enough, which reduces the accuracy of document image question-answering.
[0041] In response to the above technical problems, the present application proposes the following technical concept: In order to improve the accuracy of document image question and answer, instead of directly inputting the document image and the questions raised for the document into the question and answer model, a layout analysis model for analyzing the layout information in the document is established. The layout of the document image is first analyzed using the model, and the analysis results are fused with the questions, and then the question and answer model is allowed to determine the corresponding answer based on the fusion results and output it. Then, when the user needs to identify the document based on the question and answer model, the document image and the questions raised for the document are obtained, and the document image is input into the layout analysis model. The model is used to analyze the layout information in the document image, and the analysis results and the above questions raised for the document are spliced and encoded, so as to determine the answer corresponding to the question in the image based on the encoded analysis results based on the question and answer model. The question and answer model is enabled to understand each part according to the layout of the document image, and when a question is a local question about the document, the answer can be accurately determined, thereby improving the accuracy of document image question and answer.
[0042] Figure 1 The application scenario diagram of the document image-based question-answering method provided in the embodiment of the present application is as follows: Figure 1As shown, the document image-based question-answering system provided by the present application includes: a user terminal 1, an electronic device 2, and a database 3. Among them, the user terminal 1 is a terminal with a document image-based question-answering requirement, the electronic device 2 is a device for executing question-answering based on the document image, and the database 3 is a database corresponding to the electronic device 2. Among them, the electronic device 2 is connected to the user terminal 1 and the database 3 in communication, respectively. First, the user inputs the target document image and the corresponding question-related information through the operation interface corresponding to the user terminal 1, and sends it to the electronic device 2. Then, the electronic device 2 obtains the target document image and the corresponding question-related information, and inputs the target document image into the preset layout analysis model. The preset layout analysis model is used to determine at least one target layout type identifier in the target document image and the regional information of the target layout type identifier in the target document image, and the question-related information, at least one target layout type identifier and the regional information of the target layout type identifier in the target document image are sequentially spliced and encoded based on a unified format to obtain the text feature information corresponding to the target document image. Acquire image feature information, and align it with text feature information to obtain graphic feature information, and then determine the question answer information corresponding to the target document image based on the graphic feature information and the preset question-answering model. Among them, the preset layout analysis model is obtained by training a preset document image annotated with preset information until convergence. Furthermore, the preset information is: at least one preset layout type identifier in the preset document image and the area information of each preset layout type identifier in the preset document image. The preset layout type identifier includes any one of the following: general title identifier, header identifier, footer identifier, text identifier, paragraph identifier, picture title identifier, picture identifier, table title identifier, table identifier, formula identifier, reference identifier.
[0043] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0044] Figure 2 The process of the document image-based question-answering method provided in the embodiment of the present application Figure 1 ,like Figure 2 As shown, the execution subject of this embodiment is a question-answering device based on document images. The question-answering device based on document images is located in an electronic device. Then the question-answering method based on document images provided in this embodiment includes the following steps:
[0045] S201. Obtain a target document image and corresponding question-related information, and input the target document image into a preset layout analysis model. The preset layout analysis model is obtained by training a preset document image annotated with preset information until convergence. The preset information is: at least one preset layout type identifier in the preset document image and the area information of each preset layout type identifier in the preset document image. The preset layout type identifier includes any one of the following: a general title identifier, a header identifier, a footer identifier, a text identifier, a paragraph identifier, a picture title identifier, a picture identifier, a table title identifier, a table identifier, a formula identifier, and a reference identifier.
[0046] The target document image is a document image that the user needs to ask a question about, and the document image is a document in an image format obtained by converting the format of the document.
[0047] The question-related information is question information related to the target document image, and may specifically include specific questions and background information related to the target document image. The specific question is a question asked about the target document image, such as "What is the title of this document?" The background information is background information of the target document image, such as "This document was written by Zhang San on x-month-x-year regarding recent weather changes."
[0048] The preset layout analysis model is a pre-established model for analyzing the layout conditions in the target document image, and is specifically obtained by training a preset document image annotated with preset information until convergence.
[0049] Furthermore, the preset information is at least one preset layout type identifier in the preset document image and the area information of each preset layout type identifier in the preset document image. The preset document image is a preset document image that has been used in the question-and-answer process. The preset layout type identifier is an identifier that represents the identity of the preset layout type, and the preset layout type is a pre-determined layout type. The area information is information corresponding to the coverage area of the preset layout type identifier in the preset document image, such as the pixel coordinates corresponding to the above-mentioned coverage area.
[0050] The preset layout type identifier includes any one of the following: a general title identifier, a header identifier, a footer identifier, a text identifier, a paragraph identifier, a picture title identifier, a picture identifier, a table title identifier, a table identifier, a formula identifier, and a reference identifier. By presetting multiple preset layout type identifiers, the layout situation in the document image can be quickly determined, thereby improving the efficiency of question answering.
[0051] It should be understood that the above examples are merely illustrative and should not constitute any limitation to the present application.
[0052] In this embodiment, a preset document image annotated with preset information, i.e., annotated with at least one preset layout type identifier and regional information of the preset layout type identifier in the preset document image, can be used as a training sample in advance to establish a preset layout analysis model. Then, in response to the electronic device acquiring the target document image and the corresponding question-related information, the target document image is input into the preset layout analysis model.
[0053] S202: Using a preset layout analysis model to determine at least one target layout type identifier in a target document image and regional information of the target layout type identifier in the target document image.
[0054] The target layout type identifier is a layout type identifier determined based on the target document image, that is, an identifier to which the layout type contained in the target document image belongs.
[0055] It can be understood that since the preset layout analysis model is trained by using a preset document image that is annotated with at least one preset layout type identifier and the regional information of the preset layout type identifier in the preset document image as a training sample, after the target document image is input into the preset layout analysis model, at least one target layout type identifier in the target document image and the regional information of the target layout type identifier in the target document image can be determined based on the training results of the preset layout analysis model.
[0056] S203: sequentially perform splicing and encoding processing on the question-related information, at least one target layout type identifier, and the area information of the target layout type identifier in the target document image to obtain text feature information corresponding to the target document image. The splicing processing is performed based on a preset unified format.
[0057] Among them, the splicing process is the process of splicing different field information into the same field information, which is specifically based on a preset unified format, which is a preset unified format specified for various types of fields, for example, specifying text as a string format, specifying numbers as a decimal format, etc. This embodiment does not limit the specific preset unified format. The encoding process is the process of encoding the fields in the splicing result to form a numerical feature.
[0058] The text feature information is extracted based on the splicing and encoding results, and represents question-related information, at least one target layout type identifier, and regional information of the target layout type identifier in the target document image.
[0059] In this embodiment, after determining at least one target layout type identifier in the target document image and the area information of the target layout type identifier in the target document image, the obtained question-related information, at least one target layout type identifier and the area information of the target layout type identifier in the target document image are converted in a preset unified format, and the conversion results are concatenated into the same string of fields. The above fields are encoded, and features are extracted based on the encoding results to obtain text feature information corresponding to the target document image.
[0060] S204: Acquire image feature information, and use a preset alignment strategy to align the image feature information and text feature information to obtain image-text alignment information corresponding to the target document image.
[0061] The image feature information is information that characterizes specific features in the target document image.
[0062] It is understandable that in addition to the text feature information containing question-related information and layout analysis results, the preset question-answering model also needs to know the specific content in the target document image to determine the answer to the question, and therefore, it is also necessary to obtain image feature information. Specifically, after obtaining the target document image, the specific content in the target document image can be identified, and the image feature information can be extracted based on the identification result.
[0063] Among them, the preset alignment strategy is a strategy for aligning features to enable the preset question-answering model to understand the image and conduct question-answering, which can specifically be a visual language adapter.
[0064] The image-text alignment information is information formed by aligning the image feature information and the text feature information.
[0065] In this embodiment, in response to determining the question answer information corresponding to the target document image based on the text feature information and the preset question-answering model, the pre-stored preset alignment strategy, text feature information and image feature information are obtained, and the preset alignment strategy is used to align the image feature information and the text feature information to obtain the image-text alignment information corresponding to the target document image.
[0066] S205: Determine the question answer information corresponding to the target document image based on the image-text feature information and a preset question-answer model.
[0067] Among them, the preset question-answering model is a pre-established model for ultimately executing the question-answering process.
[0068] The question answer information is information obtained by answering the question-related information.
[0069] In this embodiment, after obtaining the image-text feature information, a pre-established preset question-answering model is obtained, and the preset question-answering model is used based on the image-text feature information to determine the question answer information corresponding to the target document image.
[0070] The document image-based question-answering method, apparatus, device, storage medium and program product provided in the present application obtain a target document image and corresponding question-related information, and input the target document image into a preset layout analysis model; the preset layout analysis model is obtained by training a preset document image annotated with preset information until convergence; the preset information is: at least one preset layout type identifier in the preset document image and the area information of each preset layout type identifier in the preset document image; the preset layout type identifier includes any one of the following: a general title identifier, a header identifier, a footer identifier, a text identifier, a paragraph identifier, a picture title identifier, a picture identifier, a table title identifier, a table identifier, a formula identifier, and a reference identifier; The preset layout analysis model is used to determine at least one target layout type identifier in the target document image and the regional information of the target layout type identifier in the target document image; the question-related information, at least one target layout type identifier and the regional information of the target layout type identifier in the target document image are sequentially spliced and encoded to obtain the text feature information corresponding to the target document image; the splicing process is performed based on a preset unified format; the image feature information is obtained, and the image feature information and the text feature information are aligned using a preset alignment strategy to obtain the image-text alignment information corresponding to the target document image; the question answer information corresponding to the target document image is determined based on the image-text feature information and the preset question-answer model. Since a plurality of preset layout types are preset, and the preset layout analysis model is obtained by using the preset document image marked with at least one preset layout type identifier and the regional information corresponding to each preset layout type identifier as a training sample, the target document image can be input into the preset layout analysis model by obtaining the target document image and the corresponding question-related information, and the preset layout analysis model can be used to determine at least one target layout type identifier in the target document image and the regional information of the target layout type identifier in the target document image. By sequentially performing a unified format-based splicing and encoding process on the question-related information, at least one target layout type identifier, and the area information of the target layout type identifier in the target document image, the text feature information corresponding to the target document image can be obtained, thereby improving the readability of the text feature information. Thus, by obtaining the image feature information, the image feature information and the text feature information can be aligned to obtain the graphic feature information, and the question answer information corresponding to the target document image can be determined based on the graphic feature information and the preset question-answering model. This enables the question-answering model to understand each part according to the layout of the document image, and when a question is a local question about the document, the answer can be accurately determined, thereby improving the accuracy of document image question-answering.
[0071] Figure 3 The process of the document image-based question-answering method provided in the embodiment of the present application Figure 2 ,like Figure 3 As shown, based on the above-mentioned embodiment, this embodiment further refines the method of using a preset layout analysis model to determine at least one target layout type identifier in a target document image and the regional information of the target layout type identifier in the target document image. When using a preset layout analysis model to determine at least one target layout type identifier in a target document image and the regional information of the target layout type identifier in the target document image, this embodiment specifically includes the following steps:
[0072] S301. Divide the target document image according to the training result to obtain at least one circled area in the target document image, and determine the target layout type identifier corresponding to each circled area.
[0073] Among them, the circled area is the area circled according to the layout situation.
[0074] In this embodiment, in response to using a preset layout analysis model to determine at least one target layout type identifier in a target document image and area information of the target layout type identifier in the target document image, based on the acquired target document image, the target document image is divided according to the training results corresponding to the preset layout analysis model to obtain at least one circled area, and the target layout type identifier corresponding to each circled area is determined according to the document content in each circled area.
[0075] Among them, when dividing the target document image to obtain at least one circled area, it can be specifically: identifying the pixel coordinates contained in the target document image, drawing rectangles according to the pixel coordinates corresponding to the boundaries of various document contents contained in the target document image, and determining the area where each rectangle is located as the circled area.
[0076] It can be understood that since the training samples contain the preset layout type identifier and the area information of the preset layout type identifier in the document image, after obtaining the circled areas in the target document image, the target layout type identifier corresponding to each circled area can be determined based on the training samples.
[0077] S302: Obtain area information corresponding to each circled area based on the division result.
[0078] In this embodiment, after the target document image is divided, the area information corresponding to each circled area can be obtained, for example, the pixel coordinates of the four corners of the rectangle corresponding to each circled area are obtained, and the above pixel coordinates are used as the area information corresponding to each circled area.
[0079] Similarly, since each circled area is divided based on the target document image and the target layout type identifier is determined based on each circled area, the area information corresponding to each circled area is the area information of the target layout type identifier in the target document image.
[0080] It should be understood that the above examples are merely illustrative and should not constitute any limitation to the present application.
[0081] The document image-based question-answering method provided in this embodiment, when using a preset layout analysis model to determine at least one target layout type identifier in the target document image and the regional information of the target layout type identifier in the target document image, divides the target document image according to the training results to obtain at least one circled area in the target document image, and determines the target layout type identifier corresponding to each circled area; and obtains the regional information corresponding to each circled area based on the division results. Since the preset layout analysis model is a model trained to convergence, the target document image can be divided according to the training results to obtain at least one circled area in the target document image, and the preset layout type identifier corresponding to each circled area can be determined, and the regional information corresponding to each circled area can also be obtained based on the division results. In this way, at least one target layout type identifier and the regional information of the target layout type identifier in the target document image can be quickly determined, thereby improving the efficiency of determining the layout type and the corresponding area.
[0082] As an optional embodiment, based on the above embodiment, this embodiment further includes the following steps before using a preset layout analysis model to determine at least one target layout type identifier in the target document image and the area information of the target layout type identifier in the target document image:
[0083] Step a1: in response to receiving an operation of a user to circle an area in a preset document image, identifying the document content in the circled area to determine a corresponding preset layout type identifier.
[0084] It is understandable that the preset layout analysis model is obtained by training the preset document image with the preset information annotated until convergence. Therefore, before using the preset layout analysis model to determine at least one target layout type identifier in the target document image and the area information of the target layout type identifier in the target document image, it is necessary to first obtain the annotated preset information, that is, the preset document image annotated with at least one preset layout type identifier and the area information of the preset layout type identifier in the preset document image.
[0085] In this embodiment, the user can select multiple preset document images through the corresponding operation interface, perform an operation of enclosing an area in the selected preset document image, and specify a corresponding preset layout type identifier for the enclosed area. Then, in response to receiving the user's operation of enclosing an area in the preset document image, the electronic device recognizes the document content in the enclosed area, thereby determining the corresponding preset layout type identifier.
[0086] It can be understood that there is at least one circled area in the preset document image, and therefore, there is also at least one corresponding preset layout type identifier.
[0087] Step a2: determine the area information of the circled area in the preset document image to obtain the area information corresponding to the preset layout type identifier.
[0088] In this embodiment, after determining the preset layout type identifier corresponding to each circled area, the area information of each circled area is determined according to the rectangular boundaries of each circled area in the preset document image. For example, the pixel coordinates of the four corners of the rectangle are determined according to the rectangular boundaries of each circled area, thereby obtaining the area information corresponding to each preset layout type identifier.
[0089] It should be understood that the above examples are merely illustrative and should not constitute any limitation to the present application.
[0090] Step a3: Mark each circled area using the corresponding preset layout type identifier and the area information corresponding to the preset layout type identifier to obtain a preset document image marked with preset information.
[0091] In this embodiment, based on determining at least one preset layout type identifier in the preset document image and the area information of each preset layout type identifier in the preset document image, each circled area is marked using the preset layout type identifier corresponding to the preset layout type identifier and the area information corresponding to the preset layout type identifier, thereby obtaining a preset document image marked with preset information.
[0092] It is understandable that after obtaining the preset document image annotated with the preset information, the preset document image annotated with the preset information can be used as a training sample, and the pre-stored initial layout analysis model is obtained, and the initial layout analysis model is trained with the above training sample until convergence, thereby obtaining the preset layout analysis model. Among them, the initial layout analysis model can be an untrained deep learning model.
[0093] The document image-based question-answering method provided in this embodiment, before using the preset layout analysis model to determine at least one target layout type identifier in the target document image and the area information of the target layout type identifier in the target document image, in response to receiving the user's operation of circling an area in the preset document image, identifies the document content in the circled area to determine the corresponding preset layout type identifier; determines the area information of the circled area in the preset document image to obtain the area information corresponding to the preset layout type identifier; and marks each circled area using the corresponding preset layout type identifier and the area information corresponding to the preset layout type identifier to obtain the preset document image marked with the preset information. Since it is necessary to first obtain the preset document image marked with the preset information in order to establish the preset layout analysis model, by receiving the user's operation of circling an area in the preset document image, the document content in the circled area can be identified, so that the corresponding preset layout type identifier can be determined based on the recognition result. By determining the area information of the circled area in the preset document image and obtaining the area information corresponding to the preset layout type identifier, the corresponding preset layout type identifier and the area information corresponding to the preset layout type identifier can be used to mark each circled area, thereby successfully obtaining the preset document image marked with preset information, improving the accuracy of determining the layout type and the corresponding area information and the success rate of establishing a preset layout analysis model.
[0094] Figure 4 The process of the document image-based question-answering method provided in the embodiment of the present application Figure 3 ,like Figure 4 As shown, in this embodiment Figure 2 On the basis of the corresponding embodiment, the question answer information corresponding to the target document image is determined based on the image-text feature information and the preset question-answer model, and further refined. In this embodiment, when the question answer information corresponding to the target document image is determined based on the image-text feature information and the preset question-answer model, the following steps are specifically included:
[0095] S401, obtaining a preset question-answering model. The preset question-answering model is obtained by training a preset document image with labeled question-related information and corresponding question answer information until convergence.
[0096] In this embodiment, a preset document image that has been questioned and answered can be obtained in advance, and based on the result of the question-answering, the question-related information corresponding to the preset document image and the question answer information obtained according to the question answer information are obtained, and then the preset document image is annotated using the question-related information and the corresponding question answer information to form a training sample, and the initial question-answering model is trained using the training sample to obtain the preset question-answering model. The initial question-answering model is an untrained large language model.
[0097] Based on this, after obtaining the image-text alignment information corresponding to the target document image, a preset question-answering model is obtained.
[0098] S402: input the image-text alignment information into a preset question-answering model, and use the preset question-answering model to determine question answer information corresponding to question-related information based on the image-text alignment information.
[0099] In this embodiment, based on obtaining a preset question-answering model and image-text alignment information, the image-text alignment information is input into the preset question-answering model, and based on the training result of the preset question-answering model, question answer information corresponding to the question-related information is determined according to the image-text alignment information.
[0100] S403: Output the question answer information, and determine the question answer information as the question answer information corresponding to the target document image.
[0101] In this embodiment, after the question answer information is obtained, the question answer information can be output, determined as the question answer information corresponding to the target document image and displayed on the corresponding operation interface so that the user can know the answer result.
[0102] The document image-based question-answering method provided in this embodiment obtains a preset question-answering model when determining the question answering information corresponding to the target document image based on the image-text feature information and the preset question-answering model; the preset question-answering model is obtained by training until convergence using a preset document image annotated with question-related information and corresponding question answering information; the image-text alignment information is input into the preset question-answering model, and the preset question-answering model is used to determine the question answering information corresponding to the question-related information according to the image-text alignment information; the question answering information is output, and the question answering information is determined as the question answering information corresponding to the target document image. Since the preset question-answering model is obtained in advance using the preset document image annotated with question-related information and corresponding question answering information as a training sample, by obtaining the preset question-answering model, the image-text alignment information can be input into the preset question-answering model, and the model can be used to determine the question answering information corresponding to the question-related information according to the image-text alignment information and output, thereby improving the question-answering efficiency.
[0103] As an optional embodiment, based on any of the above embodiments, this embodiment further includes the following steps before acquiring the image feature information:
[0104] The target document image is encoded using a preset encoding strategy to obtain image feature information corresponding to the target document image. The image feature information includes the entire document content and corresponding position information.
[0105] The preset encoding strategy is a strategy for encoding the target document image into numerical features, which may specifically be a visual encoder.
[0106] The image feature information specifically includes the full document content and corresponding position information. The full document content is the entire document content in the target document image, and the position information is information representing the position of the full document content in the target document image.
[0107] It can be understood that the premise of obtaining the image feature information is that the image feature information has been determined currently.
[0108] Specifically, based on the acquired target document image, a pre-selected and stored preset encoding strategy is further obtained, and the preset encoding strategy, such as a visual encoder, is used to encode the target document image, and feature information is extracted based on the encoding result, such as the full document content and the corresponding position information, thereby determining the image feature information corresponding to the target document image.
[0109] The document image-based question-answering method provided in this embodiment uses a preset coding strategy to encode the target document image before obtaining the image feature information, so as to obtain the image feature information corresponding to the target document image; the image feature information includes the full document content and the corresponding position information. Since the specific content in the target document image is a necessary information for the preset question-answering model to answer, the image feature information corresponding to the target document image can be obtained by encoding the target document image using the preset coding strategy and extracting the full document content and the corresponding position information therein based on the coding result, so that the image feature information can be successfully obtained later, thereby improving the success rate of question-answering.
[0110] As an optional embodiment, in this embodiment, based on the above embodiment, the question-related information includes a layout type association identifier. When the image feature information and the text feature information are aligned using a preset alignment strategy, S401 specifically includes the following steps:
[0111] Step b1: Determine an associated layout type identifier in at least one target layout type identifier according to the layout type associated identifier in the text feature information. The associated layout type identifier is a target layout type identifier associated with the information related to the question.
[0112] In this embodiment, the question-related information includes a layout type association identifier, which is an identifier associated with a certain layout type.
[0113] The associated layout type identifier is a target layout type identifier that is associated with the question-related information.
[0114] In this embodiment, in response to the alignment of the image feature information and the text feature information using a preset alignment strategy, the text feature information is obtained, and the fields included in the text feature information are traversed. Then, according to the traversal result, the layout type association identifier and at least one target layout type identifier in the question-related information are obtained, and the target layout type identifier related to the layout type association identifier is determined from each target layout type identifier, so that the target layout type identifier is determined as the associated layout type identifier.
[0115] Exemplarily, if at least one target layout type identifier is: "General title identifier", "Text identifier", "Paragraph identifier", and the question-related information is "What is the document title of this document?", then it can be determined that the layout type association identifier in the question-related information is "Title", and the target layout type identifier related to "Title" in the "General title identifier", "Text identifier", and "Paragraph identifier" is "General title identifier", then it can be determined that the "General title identifier" is the associated layout type identifier.
[0116] It should be understood that the above examples are merely illustrative and should not constitute any limitation to the present application.
[0117] Step b2: obtaining the area information of the associated layout type identifier in the preset document image, and determining the target document content corresponding to the area information of the associated layout type identifier in the full document content according to the position information in the image feature information.
[0118] The target document content is the document content where the final answer to the question is located.
[0119] It can be understood that the associated layout type identifier is determined from at least one target layout type identifier, so after the associated layout type identifier is determined, the area information of the associated layout type identifier in the preset document image can be obtained from the text feature information.
[0120] Based on this, the image feature information is obtained, and the full document content and the corresponding location information are further obtained. Then, based on the above location information, the location of the area information identified by the associated layout type is searched, the document content located at that location is obtained, and the above document content is determined as the target document content corresponding to the area information identified by the associated layout type.
[0121] For example, if the question-related information is "What is the document title of this document?" and the associated layout type identifier is "general title identifier", then the target document content corresponding to "What is the document title of this document?" is the document content corresponding to the "general title identifier".
[0122] Step b3: Build a corresponding relationship between the target document content and question-related information to complete the alignment process.
[0123] In this embodiment, based on determining the target document content, a corresponding relationship is established between the target document content and question-related information, such as a mapping relationship, to complete the alignment process.
[0124] The document image-based question-answering method provided in this embodiment, when aligning the image feature information and the text feature information using a preset alignment strategy, determines the associated layout type identifier in at least one target layout type identifier according to the layout type association identifier in the text feature information; the associated layout type identifier is the target layout type identifier of the associated question-related information; obtains the area information of the associated layout type identifier in the preset document image, and determines the target document content corresponding to the area information of the associated layout type identifier in the full document content according to the position information in the image feature information; and builds a corresponding relationship between the target document content and the question-related information to complete the alignment process. Since the question-related information includes the layout type association identifier, by determining the associated layout type identifier in at least one target layout type identifier according to the layout type association identifier in the text feature information, that is, the target layout type identifier of the associated question-related information, the area information of the associated layout type identifier in the preset document image can be obtained. And by determining the target document content corresponding to the area information of the associated layout type identifier in the full document content according to the position information in the image feature information, a corresponding relationship can be built between the target document content and the question-related information, thereby successfully completing the alignment process and improving the success rate of the question-answering.
[0125] As an optional embodiment, based on the above embodiment, when the preset question-answering model is used to determine the question answer information corresponding to the question-related information according to the image-text alignment information, S403 specifically includes the following steps:
[0126] Step c1: decode the image-text alignment information to obtain question-related information and corresponding target document content.
[0127] In this embodiment, the image-text alignment information includes the aligned image feature information and text feature information, and both feature information are encoded. Therefore, in response to using a preset question-answering model to determine the question answer information corresponding to the question-related information based on the image-text alignment information, the image-text alignment information is first decoded using a built-in decoder to obtain the question-related information and the corresponding target document content.
[0128] Step c2: Determine the question answer information corresponding to the question related information in the target document content according to the training results.
[0129] It can be understood that the preset question-answering model is obtained by training preset document images that are labeled with question-related information and corresponding question-answering information as training samples until convergence. Therefore, after obtaining the question-related information corresponding to the target document image and the corresponding target document content, the question-answering information for the question-related information corresponding to the target document image can be automatically determined in the target document content based on the training results of the preset question-answering model.
[0130] The document image-based question-answering method provided in this embodiment, when using a preset question-answering model to determine the question-answering information corresponding to the question-related information according to the image-text alignment information, decodes the image-text alignment information to obtain the question-related information and the corresponding target document content; and determines the question-answering information corresponding to the question-related information in the target document content according to the training results. Since the content in the image-text alignment information has been encoded, the question-related information corresponding to the target document image and the target document content corresponding to the question-related information can be obtained based on the decoding results by decoding the image-text alignment information, and the question-answering information corresponding to the question-related information can be determined in the target document content according to the training results. In this way, it is possible to obtain answers to questions in specific document content based on the layout type, improve the success rate of question-answering, and further improve the accuracy of question-answering.
[0131] Figure 5 A complete flow chart of the document image-based question-answering method provided in the embodiment of the present application, such as Figure 5 As shown, the document image-based question answering method provided by the present application specifically includes the following steps:
[0132] S501 . In response to receiving an operation of a user to circle an area in a preset document image, identify the document content in the circled area to obtain a corresponding preset layout type identifier.
[0133] S502: Determine the area information of the circled area in the preset document image to obtain the area information corresponding to the preset layout type identifier.
[0134] S503: Mark each circled area using the corresponding preset layout type identifier and the area information corresponding to the preset layout type identifier to obtain a preset document image marked with preset information.
[0135] S504: Obtain the target document image and corresponding question-related information.
[0136] S505: Input the target document image into a preset layout analysis model.
[0137] The preset layout analysis model is obtained by training a preset document image annotated with preset information until convergence.
[0138] The preset information includes: at least one preset layout type identifier in the preset document image and area information of each preset layout type identifier in the preset document image.
[0139] Among them, the preset layout type identifier includes any one of the following: main title identifier, header identifier, footer identifier, text identifier, paragraph identifier, picture title identifier, picture identifier, table title identifier, table identifier, formula identifier, and reference identifier.
[0140] Specifically, when the preset layout analysis model is used to determine at least one target layout type identifier in the target document image and the area information of the target layout type identifier in the target document image, the target document image is divided according to the training result to obtain at least one circled area in the target document image, and the target layout type identifier corresponding to each circled area is determined. The area information corresponding to each circled area is obtained based on the division result.
[0141] S506: Use a preset layout analysis model to determine at least one target layout type identifier in the target document image and regional information of the target layout type identifier in the target document image.
[0142] S507: sequentially perform concatenation and encoding processing on the question-related information, at least one target layout type identifier, and the area information of the target layout type identifier in the target document image to obtain text feature information corresponding to the target document image.
[0143] The splicing process is performed based on a preset unified format.
[0144] S508: Encode the target document image using a preset encoding strategy to obtain image feature information corresponding to the target document image.
[0145] The image feature information includes the full document content and the corresponding location information.
[0146] S509: Obtain image feature information.
[0147] S510: Using a preset alignment strategy to align the image feature information and the text feature information to obtain image-text alignment information corresponding to the target document image.
[0148] Among them, the information related to the question includes a layout type association identifier. When the image feature information and the text feature information are aligned using a preset alignment strategy, the associated layout type identifier is determined in at least one target layout type identifier according to the layout type association identifier in the text feature information. The associated layout type identifier is a target layout type identifier for the associated question related information. The area information of the associated layout type identifier in the preset document image is obtained, and the target document content corresponding to the area information of the associated layout type identifier is determined in the full document content according to the position information in the image feature information. A corresponding relationship is established between the target document content and the information related to the question to complete the alignment process.
[0149] When the preset question-answering model is used to determine the question answer information corresponding to the question related information according to the image-text alignment information: the image-text alignment information is decoded to obtain the question related information and the corresponding target document content. The question answer information corresponding to the question related information is determined in the target document content according to the training result.
[0150] S511. Determine the question answer information corresponding to the target document image based on the image-text feature information and a preset question-answer model.
[0151] Specifically, a preset question-answering model is obtained. The preset question-answering model is obtained by training a preset document image with labeled question-related information and corresponding question-answering information until convergence. The image-text alignment information is input into the preset question-answering model, and the preset question-answering model is used to determine the question-answering information corresponding to the question-related information based on the image-text alignment information. The question-answering information is output, and the question-answering information is determined as the question-answering information corresponding to the target document image.
[0152] Figure 6 A schematic diagram of the structure of a document image-based question-answering device provided in an embodiment of the present application, such as Figure 6 As shown, the document image-based question-answering device includes: an acquisition module 61 , an input module 62 , a determination module 63 , and a processing module 64 .
[0153] Among them, the acquisition module 61 is used to obtain the target document image and the corresponding question-related information; the input module 62 is used to input the target document image into the preset layout analysis model; the preset layout analysis model is obtained by training the preset document image annotated with preset information until convergence; the preset information is: at least one preset layout type identifier in the preset document image and the area information of each preset layout type identifier in the preset document image; the preset layout type identifier includes any one of the following: general title identifier, header identifier, footer identifier, text identifier, paragraph identifier, picture title identifier, picture identifier, table title identifier, table identifier, formula identifier, reference identifier; the determination module 63 is used to determine at least one preset layout type identifier in the target document image using the preset layout analysis model A target layout type identifier and the area information of the target layout type identifier in the target document image; a processing module 64, used to sequentially perform splicing and encoding processing on question-related information, at least one target layout type identifier and the area information of the target layout type identifier in the target document image, so as to obtain text feature information corresponding to the target document image; the splicing processing is performed based on a preset unified format; the acquisition module 61, is also used to obtain image feature information; the processing module 64, is also used to align the image feature information and the text feature information using a preset alignment strategy, so as to obtain the image-text alignment information corresponding to the target document image; the determination module 63, is also used to determine the question answer information corresponding to the target document image based on the image-text feature information and the preset question-answer model.
[0154] Optionally, the determination module 63, when using a preset layout analysis model to determine at least one target layout type identifier in the target document image and regional information of the target layout type identifier in the target document image, is specifically configured to:
[0155] The target document image is divided according to the training results to obtain at least one circled area in the target document image, and the target layout type identification corresponding to each circled area is determined; and the area information corresponding to each circled area is obtained based on the division results.
[0156] Optionally, the document image-based question-answering device provided in this embodiment includes: a recognition module and a marking module.
[0157] Among them, the recognition module, before the determination module 63 adopts the preset layout analysis model to determine at least one target layout type identifier in the target document image and the area information of the target layout type identifier in the target document image, responds to receiving the user's operation of circling an area in the preset document image, identifies the document content in the circled area to determine the corresponding preset layout type identifier; the determination module 63 is also used to determine the area information of the circled area in the preset document image to obtain the area information corresponding to the preset layout type identifier; the marking module is used to mark each circled area with the corresponding preset layout type identifier and the area information corresponding to the preset layout type identifier to obtain a preset document image marked with preset information.
[0158] Optionally, the determination module 63, when determining the question answer information corresponding to the target document image based on the text feature information and the preset question-answer model, is specifically used to:
[0159] Obtain a preset question-answering model; the preset question-answering model is trained until convergence using a preset document image that is annotated with question-related information and corresponding question-answer information; input the image-text alignment information into the preset question-answering model, and use the preset question-answering model to determine the question-answer information corresponding to the question-related information based on the image-text alignment information; output the question-answer information, and determine the question-answer information as the question-answer information corresponding to the target document image.
[0160] Optionally, the processing module 64 is also used to encode the target document image using a preset encoding strategy before the acquisition module 61 acquires the image feature information, so as to obtain the image feature information corresponding to the target document image; the image feature information includes the full document content and the corresponding location information.
[0161] Optionally, the question-related information includes a layout type association identifier;
[0162] Accordingly, when the processing module 64 uses the preset alignment strategy to align the image feature information and the text feature information, it is specifically used to:
[0163] Determine an associated layout type identifier in at least one target layout type identifier based on the layout type association identifier in the text feature information; associate the layout type identifier with the target layout type identifier of the associated question-related information; obtain the area information of the associated layout type identifier in the preset document image, and determine the target document content corresponding to the area information of the associated layout type identifier in the full document content based on the position information in the image feature information; establish a corresponding relationship between the target document content and the question-related information to complete the alignment process.
[0164] Optionally, the determination module 63, when using a preset question-answering model to determine the question answer information corresponding to the question-related information according to the image-text alignment information, is specifically used to:
[0165] The image-text alignment information is decoded to obtain question-related information and corresponding target document content; and the question answer information corresponding to the question-related information is determined in the target document content according to the training results.
[0166] The document image-based question-and-answer device provided in the embodiment of the present application can be used to execute the technical solution of the document image-based question-and-answer method in the above-mentioned embodiment. Its implementation principle and technical effects are similar and will not be repeated here.
[0167] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. For example, the acquisition module 61 can be a separately established processing element, or it can be integrated in a chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a processing element of the above device. The function of the above acquisition module 61. The implementation of other modules is similar. In addition, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0168] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 7 As shown, the electronic device may include: a transceiver 71 , a processor 72 , and a memory 73 .
[0169] The processor 72 executes the computer execution instructions stored in the memory, so that the processor 72 executes the scheme in the above embodiment. The processor 72 can be a general-purpose processor, including a central processing unit CPU, a network processor (NP), etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0170] The memory 73 is connected to the processor 72 via the system bus 74 and completes communication between them. The memory 73 is used to store computer program instructions.
[0171] The transceiver 71 may be used to obtain tasks to be executed and configuration information of the tasks to be executed.
[0172] The system bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The transceiver is used to realize the communication between the database access device and other computers (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM) and may also include non-volatile memory.
[0173] The electronic device provided in the embodiment of the present application may be the terminal device of the above embodiment.
[0174] An embodiment of the present application also provides a chip for running instructions, which is used to execute the technical solution of the document image-based question-and-answer method in the above embodiment.
[0175] An embodiment of the present application also provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed on a computer, the computer executes the technical solution of the document image-based question-and-answer method of the above embodiment.
[0176] An embodiment of the present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. At least one processor can read the computer program from the computer-readable storage medium. When at least one processor executes the computer program, it can implement the technical solution of the document image-based question and answer method in the above embodiment.
[0177] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules 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 an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0178] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to implement the solution of this embodiment.
[0179] In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The above-mentioned module-composed unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
[0180] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the methods of various embodiments of the present application.
[0181] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.
[0182] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.
[0183] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0184] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.
[0185] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic control unit or a main control device.
[0186] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0187] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A document image-based question answering method, characterized in that: include: Acquire a target document image and corresponding question-related information, and input the target document image into a preset layout analysis model; The preset layout analysis model is obtained by training a preset document image annotated with preset information until convergence; the preset information is: at least one preset layout type identifier in the preset document image and the area information of each preset layout type identifier in the preset document image; The preset layout type identifier includes any one of the following: a general title identifier, a header identifier, a footer identifier, a text identifier, a paragraph identifier, a picture title identifier, a picture identifier, a table title identifier, a table identifier, a formula identifier, and a reference identifier; Determine at least one target layout type identifier in the target document image and area information of the target layout type identifier in the target document image using the preset layout analysis model; Sequentially performing splicing and encoding processing on the question-related information, at least one target layout type identifier, and the area information of the target layout type identifier in the target document image to obtain text feature information corresponding to the target document image; The splicing process is performed based on a preset unified format; Acquire image feature information, and use a preset alignment strategy to align the image feature information and the text feature information to obtain image-text alignment information corresponding to the target document image; The question answer information corresponding to the target document image is determined based on the image-text feature information and a preset question-answer model.
2. The method according to claim 1, characterized in that The step of using the preset layout analysis model to determine at least one target layout type identifier in the target document image and area information of the target layout type identifier in the target document image includes: Dividing the target document image according to the training result to obtain at least one circled area in the target document image, and determining a target layout type identifier corresponding to each circled area; Based on the division results, the area information corresponding to each circled area is obtained.
3. The method according to claim 2, characterized in that The method of using the preset layout analysis model to determine at least one target layout type identifier in the target document image and the target layout type identifier before the area information in the target document image also includes: In response to receiving an operation of circling an area in the preset document image by a user, identifying the document content in the circled area to determine a corresponding preset layout type identifier; Determine the area information of the circled area in the preset document image to obtain the area information corresponding to the preset layout type identifier; Each circled area is marked using a corresponding preset layout type identifier and area information corresponding to the preset layout type identifier to obtain a preset document image marked with preset information.
4. The method according to claim 1, characterized in that: The determining the question answer information corresponding to the target document image based on the image-text feature information and a preset question-answer model includes: Obtain a preset question-answering model; the preset question-answering model is obtained by training a preset document image annotated with question-related information and corresponding question answer information until convergence; Inputting the image-text alignment information into a preset question-answering model, and using the preset question-answering model to determine the question answer information corresponding to the question-related information according to the image-text alignment information; The question answer information is output, and the question answer information is determined as the question answer information corresponding to the target document image.
5. The method according to any one of claims 1 to 4, characterized in that: Before acquiring the image feature information, the method further includes: The target document image is encoded using a preset encoding strategy to obtain image feature information corresponding to the target document image; the image feature information includes the entire document content and corresponding position information.
6. The method according to claim 5, characterized in that The question-related information includes a layout type association identifier; The adopting a preset alignment strategy to align the image feature information and the text feature information includes: Determine an associated layout type identifier in at least one target layout type identifier according to the layout type associated identifier in the text feature information; the associated layout type identifier is a target layout type identifier of the associated question related information; Acquire the area information of the associated layout type identifier in the preset document image, and determine the target document content corresponding to the area information of the associated layout type identifier in the full document content according to the position information in the image feature information; A corresponding relationship is established between the target document content and the question-related information to complete the alignment process.
7. The method according to claim 6, characterized in that The step of using the preset question-answering model to determine the question answer information corresponding to the question-related information according to the image-text alignment information includes: Decoding the image-text alignment information to obtain question-related information and corresponding target document content; Determine the question answer information corresponding to the question related information in the target document content according to the training result.
8. A question-answering device based on document images, characterized in that: include: An acquisition module, used to acquire the target document image and corresponding question-related information; An input module, used for inputting the target document image into a preset layout analysis model; The preset layout analysis model is obtained by training a preset document image annotated with preset information until convergence; the preset information is: at least one preset layout type identifier in the preset document image and the area information of each preset layout type identifier in the preset document image; The preset layout type identifier includes any one of the following: a general title identifier, a header identifier, a footer identifier, a text identifier, a paragraph identifier, a picture title identifier, a picture identifier, a table title identifier, a table identifier, a formula identifier, and a reference identifier; A determination module, configured to determine at least one target layout type identifier in the target document image and area information of the target layout type identifier in the target document image by using the preset layout analysis model; A processing module, used for sequentially performing splicing and encoding processing on the information related to the question, at least one target layout type identifier, and the area information of the target layout type identifier in the target document image, so as to obtain text feature information corresponding to the target document image; the splicing processing is performed based on a preset unified format; The acquisition module is also used to acquire image feature information; The processing module is further used to perform alignment processing on the image feature information and the text feature information using a preset alignment strategy to obtain image-text alignment information corresponding to the target document image; The determination module is further used to determine the question answer information corresponding to the target document image based on the image-text feature information and a preset question-answer model.
9. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.
11. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 7 when being executed by a processor.
Citation Information
Cited By
Question and answer data extraction method and device
CN120892522A
Image-based man-machine interaction method and device, instrument and storage medium
JP2024120045A
Image-based human-machine interaction method, device, equipment, and storage medium
JP7789847B2
