Traceable question and answer method and device, equipment and storage medium

By dividing the target document into document blocks and determining the target document blocks based on similarity, outputting answer text and screenshots, the problem of poor parsing ability of existing question-and-answer systems when dealing with non-text elements is solved, and the reliability and credibility of answers are improved. .

CN119128079APending Publication Date: 2024-12-13PICC INFORMATION TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411147103.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-20
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

The existing question and answer system has poor parsing capabilities when processing target documents containing non-text elements such as pictures and tables, resulting in low reliability of answers and inability to trace the source of the answers.

Method used

By dividing the target document into multiple document blocks, determining the target document block based on the similarity between the question text and each document block, outputting answer text and document block screenshots, realizing the traceability of the answer.

Benefits of technology

Improves the reliability of answers, allows users to understand the source of answers, and enhances the credibility of answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119128079A_ABST
    Figure CN119128079A_ABST
Patent Text Reader

Abstract

The invention provides a traceable question and answer method and device, equipment and a storage medium, and relates to the technical field of data processing. The method comprises the steps that a question and answer request is obtained, the question and answer request comprises a target document and a question text, and the question and answer request is used for requesting to determine an answer corresponding to the question text in the target document; determining a plurality of document blocks in the target document and the position of each document block in the target document; according to the problem text, at least one target document block is determined in the multiple document blocks, and the similarity between the problem text and the target document block is larger than or equal to a preset threshold value; according to the at least one target document block and the question text, determining an answer text; according to the position of the at least one target document block in the target document, determining a document block screenshot corresponding to each target document block in the target document; and outputting the answer text and the document block screenshot corresponding to each target document block, thereby improving the reliability of the answer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a traceable question-and-answer method, device, equipment and storage medium. Background Art

[0002] In some scenarios, it is necessary to search for the required information in a document containing a large amount of content. For example, in a regulation query scenario, the user needs to find the regulation corresponding to a certain event in a certain regulation file.

[0003] In the related art, a user can ask a question about a target document through a question-and-answer system. The user can upload the question and the target document to the question-and-answer system, and the question-and-answer system can parse the target document and then answer the user's question based on the parsed result of the target document.

[0004] However, the question-answering system can only parse target documents with pure text content. It has poor parsing capabilities for target documents containing non-text elements such as pictures and tables, and cannot trace the answers based on the target documents, resulting in low reliability of the answers. Summary of the invention

[0005] The present application provides a traceable question-and-answer method, apparatus, device, and storage medium to solve the problem of low answer reliability.

[0006] In a first aspect, the present application provides a traceable question-answering method, comprising:

[0007] Obtaining a question-and-answer request, the question-and-answer request including a target document and a question text, the question-and-answer request being used to request to determine an answer corresponding to the question text in the target document;

[0008] Determining a plurality of document blocks in the target document and a position of each document block in the target document, wherein the document blocks include at least two of text blocks, picture blocks or table blocks;

[0009] According to the question text, determining at least one target document block from the multiple document blocks, wherein the similarity between the question text and the target document block is greater than or equal to a preset threshold;

[0010] Determining an answer text according to the at least one target document block and the question text;

[0011] Determining, in the target document, a document block screenshot corresponding to each target document block according to a position of the at least one target document block in the target document;

[0012] The answer text and the document block screenshot corresponding to each target document block are output.

[0013] In a possible implementation method, determining at least one target document block from the plurality of document blocks according to the question text includes:

[0014] For any document block, determining the description text corresponding to the document block according to the type of the document block;

[0015] According to the question text and the description text corresponding to each document block, the at least one target document block is determined from the plurality of document blocks.

[0016] In a possible implementation method, determining the description text corresponding to the document block according to the type of the document block includes:

[0017] If the type of the document block is the text type, performing text recognition processing on the document block to obtain a description text corresponding to the document block;

[0018] If the type of the document block is the picture type, a first text is identified in the document block, and image recognition processing is performed on the document block to obtain image semantic information corresponding to the document block, and a description text corresponding to the document block is determined according to the first text and the image semantic information;

[0019] If the type of the document block is the table type, the table structure and table text are identified in the document block, and the description text corresponding to the document block is determined according to the table structure and the table text.

[0020] In a possible implementation method, determining the at least one target document block from the plurality of document blocks according to the question text and the description text corresponding to each document block includes:

[0021] Determine a first vector corresponding to the question text, and determine a second vector corresponding to each description text, to obtain a plurality of second vectors;

[0022] determining a similarity between the first vector and each second vector;

[0023] The multiple second vectors are sorted in descending order of similarity, and document blocks corresponding to first K second vectors among the multiple second vectors are determined as the at least one target document block, where K is an integer greater than or equal to 1.

[0024] In a possible implementation method, determining the answer text according to the at least one target document block and the question text includes:

[0025] fusing the description text corresponding to the at least one target document block with the question text to obtain a model text;

[0026] The model text is processed by a language model to obtain the answer text.

[0027] In a possible implementation method, determining a plurality of document blocks in the target document and a position of each document block in the target document includes:

[0028] Performing grid division processing on the target document to obtain a plurality of document grids;

[0029] For any document grid, determine a grid type corresponding to the document grid, where the grid type is a text type, a picture type, or a table type;

[0030] The plurality of document blocks and the position of each document block in the target document are determined according to the grid type corresponding to each document grid and the position of each document grid in the target document.

[0031] In a possible implementation method, determining the plurality of document blocks and the position of each document block in the target document according to the grid type corresponding to each document grid and the position of each document grid in the target document includes:

[0032] According to the grid type corresponding to each document grid and the position of each document grid in the target document, clustering document grids that are adjacent in position and have the same grid type is performed to obtain the plurality of document blocks;

[0033] For any document block, a document grid corresponding to the document block is determined, and the position of the document block in the target document is determined according to the position of the document grid corresponding to the document block in the target document.

[0034] In a second aspect, the present application provides a traceable question-answering device, comprising: an acquisition module, a first determination module, a second determination module, a third determination module, a fourth determination module and an output module, wherein:

[0035] The acquisition module is used to acquire a question-and-answer request, the question-and-answer request includes a target document and a question text, and the question-and-answer request is used to request to determine an answer corresponding to the question text in the target document;

[0036] The first determination module is used to determine a plurality of document blocks in the target document and a position of each document block in the target document, wherein the document blocks include at least two of text blocks, picture blocks or table blocks;

[0037] The second determination module is used to determine at least one target document block from the multiple document blocks according to the question text, and the similarity between the question text and the target document block is greater than or equal to a preset threshold;

[0038] The third determination module is used to determine the answer text according to the at least one target document block and the question text;

[0039] The fourth determining module is used to determine, according to the position of the at least one target document block in the target document, a document block screenshot corresponding to each target document block in the target document;

[0040] The output module is used to output the answer text and the document block screenshot corresponding to each target document block.

[0041] In a possible implementation, the second determining module is specifically configured to:

[0042] For any document block, determining the description text corresponding to the document block according to the type of the document block;

[0043] According to the question text and the description text corresponding to each document block, the at least one target document block is determined from the plurality of document blocks.

[0044] In a possible implementation, the second determining module is specifically configured to:

[0045] If the type of the document block is the text type, performing text recognition processing on the document block to obtain a description text corresponding to the document block;

[0046] If the type of the document block is the picture type, a first text is identified in the document block, and image recognition processing is performed on the document block to obtain image semantic information corresponding to the document block, and a description text corresponding to the document block is determined according to the first text and the image semantic information;

[0047] If the type of the document block is the table type, the table structure and table text are identified in the document block, and the description text corresponding to the document block is determined according to the table structure and the table text.

[0048] In a possible implementation, the second determining module is specifically configured to:

[0049] Determine a first vector corresponding to the question text, and determine a second vector corresponding to each description text, to obtain a plurality of second vectors;

[0050] determining a similarity between the first vector and each second vector;

[0051] The multiple second vectors are sorted in descending order of similarity, and document blocks corresponding to first K second vectors among the multiple second vectors are determined as the at least one target document block, where K is an integer greater than or equal to 1.

[0052] In a possible implementation, the second determining module is specifically configured to:

[0053] fusing the description text corresponding to the at least one target document block with the question text to obtain a model text;

[0054] The model text is processed by a language model to obtain the answer text.

[0055] In a possible implementation, the first determining module is specifically configured to:

[0056] Performing grid division processing on the target document to obtain a plurality of document grids;

[0057] For any document grid, determine a grid type corresponding to the document grid, where the grid type is a text type, a picture type, or a table type;

[0058] The plurality of document blocks and the position of each document block in the target document are determined according to the grid type corresponding to each document grid and the position of each document grid in the target document.

[0059] In a possible implementation, the first determining module is specifically configured to:

[0060] According to the grid type corresponding to each document grid and the position of each document grid in the target document, clustering document grids that are adjacent in position and have the same grid type is performed to obtain the plurality of document blocks;

[0061] For any document block, a document grid corresponding to the document block is determined, and the position of the document block in the target document is determined according to the position of the document grid corresponding to the document block in the target document.

[0062] 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-executable instructions; the at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the traceable question-and-answer method described in the first aspect and various possible designs of the first aspect.

[0063] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the traceable question-and-answer method described in the first aspect and various possible designs of the first aspect is implemented.

[0064] 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 traceable question-and-answer method described in the first aspect and various possible designs of the first aspect.

[0065] The traceable question-and-answer method, apparatus, device and storage medium provided by the present application can first divide the target document into multiple document blocks when it is necessary to determine the answer to a question text based on a target document, determine the target document block based on the similarity between the question text and each document block, output the answer text based on the target document block and the question text, and output the corresponding document block screenshot based on the position of the target document block in the target document. The above method can trace the source of the answer while outputting the answer text, thereby solving the problem of low reliability of the answer. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] 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.

[0067] Figure 1 A schematic diagram of the system architecture provided for an embodiment of the present application;

[0068] Figure 2 A flowchart of a traceable question-and-answer method provided in an embodiment of the present application;

[0069] Figure 3 A schematic diagram of a visual operation window of a question-and-answer system provided in an embodiment of the present application;

[0070] Figure 4 A schematic diagram of a process for determining a document block provided in an embodiment of the present application;

[0071] Figure 5 A schematic diagram of another traceable question-and-answer method provided in an embodiment of the present application;

[0072] Figure 6 A schematic diagram of a process of performing grid division processing on a target document provided in an embodiment of the present application;

[0073] Figure 7 A schematic diagram of the structure of a traceable question-answering device provided in an embodiment of the present application;

[0074] Figure 8A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0075] 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

[0076] 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.

[0077] 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.

[0078] 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.

[0079] For ease of understanding, the following Figure 1 , the system architecture applicable to the embodiments of the present application is described.

[0080] Figure 1 This is a schematic diagram of the system architecture provided by the embodiment of this application. Figure 1 , including a terminal device 101 and a question-answering system 102. The terminal device 101 may be a local device of a user, and the question-answering system 102 may be provided in the terminal device 101. Questions may be input into the question-answering system 102. After receiving the questions, the question-answering system 102 may parse the questions and output answers to the questions.

[0081] In the related art, users can ask questions about the target document through the question-answering system. Users can upload questions and target documents to the question-answering system, which can parse the target document and then answer the user's question based on the parsed result of the target document. However, the question-answering system can only parse target documents with pure text content, and has poor parsing capabilities for target documents containing non-text elements such as pictures and tables, and cannot trace the answer based on the target document, resulting in low reliability of the answer.

[0082] In response to the above technical problems, in an embodiment of the present application, when it is necessary to determine the answer to a question text based on a target document, the target document can be first divided into multiple document blocks, the target document block can be determined based on the similarity between the question text and each document block, the answer text can be output based on the target document block and the question text, and the corresponding document block screenshot can be output based on the position of the target document block in the target document. The above method can trace the source of the answer while outputting the answer text, thereby improving the reliability of the answer.

[0083] 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.

[0084] Figure 2 A flowchart of a traceable question-answering method provided in an embodiment of the present application. Figure 2 As shown, the method may include the following steps:

[0085] S201: Get a question and answer request.

[0086] The execution subject of the embodiment of the present application may be a terminal device, or a traceable question-answering device arranged in the terminal device. The traceable question-answering device may be implemented by software, or by a combination of software and hardware.

[0087] A question-and-answer system may be provided in the terminal device, and the user may input the target document and question text into the question-and-answer system. The visual operation window of the question-and-answer system may include a "submit" control, and the user may generate a question-and-answer request by clicking the submit control. The question-and-answer request is used to request the answer corresponding to the question text in the target document. The question-and-answer request includes the target document and the question text.

[0088] Next, combine Figure 3 ,Through specific examples, the visual operation window of the question-answering system is explained.

[0089] Figure 3 For a schematic diagram of the visual operation window of the question-answering system provided in the embodiment of the present application, see Figure 3 , including a document upload module, a question upload module and a "submit" control. Users can upload the target document through the document upload module, and then upload the question text through the question upload module. By clicking the "submit" control, a question and answer request can be generated.

[0090] The target document may refer to a document containing text content, image content or table content. For example, the target document may refer to an insurance policy; the question text may refer to a question raised by a user regarding the target document, for example, the question text may refer to "find how an insurance company fulfills its contractual obligations in the target document".

[0091] Question-answering requests are used to request that the answer corresponding to the question text be determined in the target document.

[0092] S202: Determine a plurality of document blocks in a target document, and a position of each document block in the target document.

[0093] The target document may be grid-divided to obtain a plurality of document blocks, and the shape of the document block may be a rectangle. The types of document blocks may include text blocks, image blocks, and table blocks. Among them, a text block may refer to the content in the document block as plain text content; an image block may refer to the content in the document block as image content; and a table block may refer to the content in the document block as table content.

[0094] Next, combine Figure 4 , the process of determining the document block is explained through specific examples.

[0095] Figure 4 For a schematic diagram of the process of determining a document block provided in the embodiment of the present application, see Figure 4 , the target document includes plain text content 1, image content 2, table content 3 and image content 4. According to the content of the target document, it can be determined that the document block corresponding to plain text content 1 is text block 1, the document block corresponding to image content 2 is image block 2, the document block corresponding to table content 3 is table block 3, and the document block corresponding to image content 4 is image block 4.

[0096] The document block includes at least two of the text block, the picture block or the table block, that is, the target document needs to include at least two of the document blocks of the text block, the picture block or the table block.

[0097] The position of each document block in the target document can be determined in the following way: the position of the document block in the target document can be represented by the coordinates of the four vertices of the document block. For example, assuming that the target document can be reassembled on the same document page in the order of page numbers from small to large, and a coordinate system is established with the lower left vertex of the document page as the origin, the terminal device can determine that the coordinates of one vertex of the document block is A (x1, y1), the length of the document block is a, and the width of the document block is b. Then, the coordinates of the remaining three vertices of the document block can be determined as B (x1+a, y1), C (x1+a, y1+b), and D (x1, y1+b). Based on the coordinates of the four vertices, the position of the document block can be determined.

[0098] The position of the document block in the target document may be stored in a preset database, wherein the preset database may be located in a storage space in a storage device.

[0099] S203: Determine at least one target document block from the multiple document blocks according to the question text, and the similarity between the question text and the target document block is greater than or equal to a preset threshold.

[0100] The similarity between two contents can be represented by similarity, wherein the higher the similarity, the higher the similarity between the two contents; conversely, the lower the similarity, the lower the similarity between the two contents.

[0101] The terminal device may determine the similarity between the question text and each document block in turn. When the similarity between the question text and a document block is greater than or equal to a preset threshold, the document block may be determined as a target document block, and the number of target document blocks may be greater than or equal to 1. The preset threshold is a value set in advance by the user in the terminal device, which may be used to determine the target document block. For example, the preset threshold may be 0.8.

[0102] S204: Determine an answer text according to at least one target document block and the question text.

[0103] The terminal device may fuse at least one target document block and the question text to obtain a model text, and the model text may refer to a model question sentence including at least one target document block and the question text. For example, assuming the question text is "What are the legal rights and interests of insurance products", the model text may be "Please explain what the legal rights and interests of insurance products are based on the content of the following target document block".

[0104] The model text is input into the language model and processed by the language model to obtain the answer text.

[0105] S205. Determine, in the target document, a document block screenshot corresponding to each target document block according to a position of at least one target document block in the target document.

[0106] The position of the target document block in the target document can be obtained from a preset database, and the four vertex coordinates of the target document block can be determined based on the position of the target document block in the target document. The document block screenshot corresponding to each target document block can be determined based on the four vertex coordinates.

[0107] Document block screenshots can be used to illustrate the location of the answer text in the target document.

[0108] S206: Output the answer text and the document block screenshot corresponding to each target document block.

[0109] The terminal device can display the answer text and the document block screenshot corresponding to each target document block on the visual interface of the question-answering system.

[0110] In an embodiment of the present application, when it is necessary to determine the answer to a question text based on a target document, the target document can be first divided into multiple document blocks, and the position of each document block in the target document can be determined; the similarity between the question text and each document block can be determined, and the document block with a similarity greater than or equal to a preset threshold can be determined as the target document block; based on the target document block and the question text, the answer text can be determined; based on the position coordinates of the target document block, a document block screenshot corresponding to the target document block can be determined, and the answer text and the document block screenshot can be output. By first segmenting the target document and then determining the target document block with a higher similarity to the question text, the source of the answer can be traced while the answer text is output, thereby improving the reliability of the answer.

[0111] Based on any of the above embodiments, Figure 5 , a detailed description of the traceable question-answering method is given.

[0112] Figure 5 A process diagram of another traceable question-answering method provided in an embodiment of the present application. Figure 5 , the method may include:

[0113] S501: Get a question and answer request.

[0114] It should be noted that the execution process of the above S501 can refer to S201 and will not be repeated here.

[0115] S502: Perform grid division processing on the target document to obtain multiple document grids.

[0116] Grid partitioning refers to partitioning a target document into multiple smaller document grids.

[0117] The target document can be gridded in the following manner: the terminal device first obtains the content of the target document, and determines the side length of each grid to be gridded according to a preset value; the target document is gridded to obtain multiple document grids. The preset value can be a value set by the user in advance on the terminal device, which is used to determine the side length of each document grid.

[0118] Next, combine Figure 6 , through a specific example, the process of gridding the target document is explained.

[0119] Figure 6 For a schematic diagram of the process of meshing the target document provided in the embodiment of the present application, see Figure 6The target document includes plain text content 1, image content 2, table content 3 and image content 4. The terminal device can determine that the side length of each grid in the grid division process is d according to a preset value, and then divide the target document into multiple grids with a side length of d to obtain multiple document grids.

[0120] S503: For any document grid, determine the grid type corresponding to the document grid and the position of each document grid in the target document.

[0121] The grid type may include text type, image type or table type. The text type means that the document grid contains only text content; the image type means that the document grid contains only image content; and the table type means that the document grid contains only table content.

[0122] The position of each document grid in the target document can be determined in the following way: the position of the document grid in the target document can be represented by the coordinates of the four vertices of the document grid. Assuming that the target document can be reassembled on the same document page in ascending order of page numbers, and a coordinate system is established with the lower left vertex of the document page as the origin, the terminal device can determine that the coordinates of one vertex of the document grid is A(x1,y1), the length of the document grid is a, and the width of the document grid is b. Then, the coordinates of the remaining three vertices of the document grid can be determined as B(x1+a,y1), C(x1+a,y1+b), and D(x1,y1+b). Based on the coordinates of the four vertices, the position of the document grid can be determined.

[0123] S504: Based on the grid type corresponding to each document grid and the position of each document grid in the target document, cluster document grids that are adjacent in position and have the same grid type to obtain a plurality of document blocks.

[0124] Clustering processing can be performed in the following manner: the terminal device obtains the position of each document grid in the target document, and determines the adjacent grids of each document grid according to the position of each document grid in the target document; for any document grid, the type of the adjacent grids of the document grid is determined, and the adjacent grids with the same grid type as the document grid are identified; these document grids with adjacent positions and the same grid type are clustered and merged into a document block; the above process is repeated until all document grids are processed and multiple document blocks are obtained.

[0125] For any document grid, its adjacent grids may be document networks in four directions: up, down, left, and right.

[0126] S505 . For any document block, determine the document grid corresponding to the document block, and determine the position of the document block in the target document according to the position of the document grid corresponding to the document block in the target document.

[0127] The position of a document block in a target document can be determined in the following manner: for any document block, all document grids contained in the document block and the position of the document grids in the target document are determined, and the four vertex coordinates of each document grid can be determined based on the position of the document grid in the target document; the vertex coordinates of all document grids in the document block are obtained, and the maximum row coordinate and the minimum row coordinate, as well as the maximum column coordinate and the minimum column coordinate are determined; based on the maximum row coordinate, the minimum row coordinate, the maximum column coordinate and the minimum column coordinate, the four vertex coordinates of the document block can be determined, that is, the position of the document block in the target document can be determined.

[0128] For example, assuming that among the vertex coordinates of all document grids in the document block, the maximum row coordinate is x1, the minimum row coordinate is x2, the maximum column coordinate is y1, and the minimum column coordinate is y2, then the four vertex coordinates of the document block are (x1, y1), (x1, y2), (x1, y1), and (x2, y1).

[0129] S506: For any document block, determine the description text corresponding to the document block according to the type of the document block.

[0130] The grid type of the document grid corresponding to the document block can be determined as the type of the document block, that is, if the grid type of the corresponding document grid in the document block is a text type, then the type of the document block is a text type; if the grid type of the corresponding document grid in the document block is a picture type, then the type of the document block is a picture type; if the grid type of the corresponding document grid in the document block is a table type, then the type of the document block is a table type.

[0131] The description text can be used to represent the content and semantic information of the document block.

[0132] The description text corresponding to the documentation block can be determined as follows:

[0133] If the type of the document block is a text type, text recognition processing is performed on the document block to obtain a description text corresponding to the document block.

[0134] If the document block is of the image type, the first text is identified in the document block, and the document block is subjected to image recognition processing to obtain image semantic information corresponding to the document block, and the description text corresponding to the document block is determined based on the first text and the image semantic information. The text information in the document block can be determined by optical character recognition technology, and the text information can be converted into editable text content, which can be determined as the first text.

[0135] If the type of the document block is a table type, the table structure and table text are identified in the document block, and the description text corresponding to the document block is determined according to the table structure and the table text.

[0136] S507: Determine a first vector corresponding to the question text, and determine a second vector corresponding to each description text, to obtain a plurality of second vectors.

[0137] The terminal device can obtain the question text and use the word embedding technology to convert the question text into a first vector, that is, each word in the question text is converted into a vector of a fixed dimension, and then these vectors are averaged or weighted summed to obtain the first vector corresponding to the question text.

[0138] The terminal device can obtain all description texts corresponding to the target document, and convert each description text into a second vector through word embedding technology to obtain multiple second vectors. That is, for any description text, each word in the description text is converted into a vector of a fixed dimension, and then these vectors are averaged or weighted summed to obtain the second vector corresponding to the description text.

[0139] S508: Determine the similarity between the first vector and each second vector.

[0140] A first vector and a plurality of second vectors are obtained, and a similarity between the first vector and each of the second vectors is determined in sequence.

[0141] The similarity between two vectors can be determined by the inner product method. For example, assuming A is the first vector, B is the second vector, and A = (a1, a2, ..., an) and B = (b1, b2, ..., bn), then the similarity p(A, B) between the first vector and the second vector is:

[0142]

[0143] The similarity p ranges from (0, 1), and the closer the similarity p is to 1, the more similar the two vectors are.

[0144] S509: Determine at least one target document block according to the similarity between the first vector and each second vector.

[0145] At least one target document block may be determined in the following manner: obtaining the similarity between the first vector and each second vector, sorting the multiple second vectors in descending order, and determining the document blocks corresponding to the first K second vectors among the multiple second vectors as at least one target document block.

[0146] Here, K is a value set by the user in the terminal device in advance, and K is an integer greater than or equal to 1.

[0147] S510: Fusing the description text and question text corresponding to at least one target document block to obtain a model text.

[0148] S511. Process the model text through the language model to obtain the answer text and the document block screenshot corresponding to each target document block.

[0149] S512: Output the answer text and the document block screenshot corresponding to each target document block.

[0150] It should be noted that the execution process of the above S510-S512 can refer to S204-S206, which will not be repeated here.

[0151] In an embodiment of the present application, when it is necessary to determine the answer to a question text based on a target document, the target document can be firstly grid-divided to obtain a plurality of document grids; based on the grid type of each document grid and its position in the target document, the document grids with adjacent positions and the same grid type are clustered to obtain a plurality of document blocks; based on the type of the document block, the description text corresponding to each document block is determined; a first vector corresponding to the question text and a second vector corresponding to each description text are determined, and based on the first vector and the plurality of second vectors, the similarity between the first vector and each second vector is determined, the similarities are sorted from high to low, and the document blocks corresponding to the first K second vectors are determined as at least one target document block; the description text corresponding to at least one target document block is fused with the question text to obtain a model text; the model text is processed through a language model to obtain an answer text and a screenshot of the document block corresponding to each target document block, and the source of the answer can be traced while the answer text is output, thereby improving the reliability of the answer.

[0152] Figure 7 For a structural diagram of a traceable question-answering device provided in an embodiment of the present application, see Figure 7 The traceable question-answering device 10 includes: an acquisition module 11, a first determination module 12, a second determination module 13, a third determination module 14, a fourth determination module 15 and an output module 16, wherein:

[0153] The acquisition module 11 is used to acquire a question-and-answer request, wherein the question-and-answer request includes a target document and a question text, and the question-and-answer request is used to request to determine an answer corresponding to the question text in the target document;

[0154] The first determination module 12 is used to determine a plurality of document blocks in the target document and the position of each document block in the target document, wherein the document block includes at least two of a text block, a picture block or a table block;

[0155] The second determination module 13 is used to determine at least one target document block from the multiple document blocks according to the question text, and the similarity between the question text and the target document block is greater than or equal to a preset threshold;

[0156] The third determination module 14 is used to determine the answer text according to the at least one target document block and the question text;

[0157] The fourth determining module 15 is used to determine, according to the position of the at least one target document block in the target document, a document block screenshot corresponding to each target document block in the target document;

[0158] The output module 16 is used to output the answer text and the document block screenshot corresponding to each target document block.

[0159] In a possible implementation, the second determining module 13 is specifically configured to:

[0160] For any document block, determining the description text corresponding to the document block according to the type of the document block;

[0161] According to the question text and the description text corresponding to each document block, the at least one target document block is determined from the plurality of document blocks.

[0162] In a possible implementation, the second determining module 13 is specifically configured to:

[0163] If the type of the document block is the text type, performing text recognition processing on the document block to obtain a description text corresponding to the document block;

[0164] If the type of the document block is the picture type, a first text is identified in the document block, and image recognition processing is performed on the document block to obtain image semantic information corresponding to the document block, and a description text corresponding to the document block is determined according to the first text and the image semantic information;

[0165] If the type of the document block is the table type, the table structure and table text are identified in the document block, and the description text corresponding to the document block is determined according to the table structure and the table text.

[0166] In a possible implementation, the second determining module 13 is specifically configured to:

[0167] Determine a first vector corresponding to the question text, and determine a second vector corresponding to each description text, to obtain a plurality of second vectors;

[0168] determining a similarity between the first vector and each second vector;

[0169] The multiple second vectors are sorted in descending order of similarity, and document blocks corresponding to first K second vectors among the multiple second vectors are determined as the at least one target document block, where K is an integer greater than or equal to 1.

[0170] In a possible implementation, the second determining module 13 is specifically configured to:

[0171] fusing the description text corresponding to the at least one target document block with the question text to obtain a model text;

[0172] The model text is processed by a language model to obtain the answer text.

[0173] In a possible implementation, the first determining module 12 is specifically configured to:

[0174] Performing grid division processing on the target document to obtain a plurality of document grids;

[0175] For any document grid, determine a grid type corresponding to the document grid, where the grid type is a text type, a picture type, or a table type;

[0176] The plurality of document blocks and the position of each document block in the target document are determined according to the grid type corresponding to each document grid and the position of each document grid in the target document.

[0177] In a possible implementation, the first determining module 12 is specifically configured to:

[0178] According to the grid type corresponding to each document grid and the position of each document grid in the target document, clustering document grids that are adjacent in position and have the same grid type is performed to obtain the plurality of document blocks;

[0179] For any document block, a document grid corresponding to the document block is determined, and the position of the document block in the target document is determined according to the position of the document grid corresponding to the document block in the target document.

[0180] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 8 As shown, the electronic device may include: a transceiver 111 , a processor 112 , and a memory 113 .

[0181] The processor 112 executes the computer execution instructions stored in the memory, so that the processor 112 executes the scheme in the above embodiment. The processor 112 can be a general-purpose processor, including a central processing unit CPU, a network processor (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.

[0182] The memory 113 is connected to the processor 112 via a system bus and completes communication between them. The memory 113 is used to store computer program instructions.

[0183] The transceiver 111 may be used to obtain tasks to be executed and configuration information of the tasks to be executed.

[0184] 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.

[0185] The electronic device provided in the embodiment of the present application may be the terminal device of the above embodiment.

[0186] An embodiment of the present application also provides a chip for running instructions, which is used to execute the technical solution of the traceable question-and-answer method in the above embodiment.

[0187] 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 traceable question-and-answer method in the above embodiment.

[0188] 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 traceable question-and-answer method in the above embodiment.

[0189] 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.

[0190] 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.

[0191] 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.

[0192] 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.

[0193] 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.

[0194] 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.

[0195] 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.

[0196] 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.

[0197] 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.

[0198] 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.

[0199] 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 traceable question-answering method, characterized in that: include: Obtaining a question-and-answer request, the question-and-answer request including a target document and a question text, the question-and-answer request being used to request to determine an answer corresponding to the question text in the target document; Determining a plurality of document blocks in the target document and a position of each document block in the target document, wherein the document blocks include at least two of text blocks, picture blocks or table blocks; According to the question text, determining at least one target document block from the multiple document blocks, wherein the similarity between the question text and the target document block is greater than or equal to a preset threshold; Determining an answer text according to the at least one target document block and the question text; Determining, in the target document, a document block screenshot corresponding to each target document block according to a position of the at least one target document block in the target document; The answer text and the document block screenshot corresponding to each target document block are output.

2. The method according to claim 1, characterized in that Determining at least one target document block from the plurality of document blocks according to the question text includes: For any document block, determining the description text corresponding to the document block according to the type of the document block; According to the question text and the description text corresponding to each document block, the at least one target document block is determined from the plurality of document blocks.

3. The method according to claim 2, characterized in that Determining, according to the type of the document block, a description text corresponding to the document block, including: If the type of the document block is the text type, performing text recognition processing on the document block to obtain a description text corresponding to the document block; If the type of the document block is the picture type, a first text is identified in the document block, and image recognition processing is performed on the document block to obtain image semantic information corresponding to the document block, and a description text corresponding to the document block is determined according to the first text and the image semantic information; If the type of the document block is the table type, the table structure and table text are identified in the document block, and the description text corresponding to the document block is determined according to the table structure and the table text.

4. The method according to claim 2 or 3, characterized in that: Determining at least one target document block from the plurality of document blocks according to the question text and the description text corresponding to each document block includes: Determine a first vector corresponding to the question text, and determine a second vector corresponding to each description text, to obtain a plurality of second vectors; determining a similarity between the first vector and each second vector; The multiple second vectors are sorted in descending order of similarity, and document blocks corresponding to first K second vectors among the multiple second vectors are determined as the at least one target document block, where K is an integer greater than or equal to 1.

5. The method according to any one of claims 2 to 4, characterized in that: Determining an answer text according to the at least one target document block and the question text comprises: fusing the description text corresponding to the at least one target document block with the question text to obtain a model text; The model text is processed by a language model to obtain the answer text.

6. The method according to any one of claims 1 to 5, characterized in that: Determining a plurality of document blocks in the target document and a position of each document block in the target document includes: Performing grid division processing on the target document to obtain a plurality of document grids; For any document grid, determine a grid type corresponding to the document grid, where the grid type is a text type, a picture type, or a table type; The plurality of document blocks and the position of each document block in the target document are determined according to the grid type corresponding to each document grid and the position of each document grid in the target document.

7. The method according to claim 6, characterized in that Determining the plurality of document blocks and the position of each document block in the target document according to the grid type corresponding to each document grid and the position of each document grid in the target document includes: According to the grid type corresponding to each document grid and the position of each document grid in the target document, clustering document grids that are adjacent in position and have the same grid type is performed to obtain the plurality of document blocks; For any document block, a document grid corresponding to the document block is determined, and the position of the document block in the target document is determined according to the position of the document grid corresponding to the document block in the target document.

8. A traceable question-answering device, characterized in that: include: an acquisition module, a first determination module, a second determination module, a third determination module, a fourth determination module and an output module, wherein: The acquisition module is used to acquire a question-and-answer request, the question-and-answer request includes a target document and a question text, and the question-and-answer request is used to request to determine an answer corresponding to the question text in the target document; The first determination module is used to determine a plurality of document blocks in the target document and a position of each document block in the target document, wherein the document blocks include at least two of text blocks, picture blocks or table blocks; The second determination module is used to determine at least one target document block from the multiple document blocks according to the question text, and the similarity between the question text and the target document block is greater than or equal to a preset threshold; The third determination module is used to determine the answer text according to the at least one target document block and the question text; The fourth determining module is used to determine, according to the position of the at least one target document block in the target document, a document block screenshot corresponding to each target document block in the target document; The output module is used to output the answer text and the document block screenshot corresponding to each target document block.

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

Patent Citations

  • Question answering method and system based on semantic similarity and readable storage medium

    CN113553416A

  • Large model question and answer method and device based on domain knowledge

    CN117609477A

  • Multi-document question and answer method and device, electronic equipment and storage medium

    CN117648418A

  • Traceability question and answer method for electric power security file under multi-modal data and related equipment

    CN118394899A