Document question and answer method and device, equipment, storage medium and program product

By vectorizing the question statement and using the retrieval vectors in the preset vector library, combined with the reordering model, the problem of poor reply content accuracy in the existing document automated question and answer method is solved, and higher matching accuracy and breadth are achieved. Generated answers more closely match user questions.

CN118586398APending Publication Date: 2024-09-03CHINA UNIONPAY
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410621795.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-17
Publication Date
2024-09-03

AI Technical Summary

Technical Problem

The document responses generated by existing automated document question and answer methods have poor accuracy and low relevance, resulting in the final generated document responses being inconsistent with user questions.

Method used

By receiving question statements and performing vectorization processing, they match the search vectors in the preset vector library, establish question and answer pairs, and input them into the pre-trained reordering model to determine the order of relevance, thereby generating answers. This method includes splitting the original document, embedding text and tables, establishing a preset vector library, increasing the dimension and quantity of retrieval vectors, and improving the matching hit rate and accuracy.

Benefits of technology

It improves the accuracy and breadth of document matching, ensuring that the final answer is filtered out with the retrieval vectors most relevant to user questions, and the generated answers are more in line with user needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118586398A
    Figure CN118586398A
Patent Text Reader

Abstract

The invention provides a document question-answering method and device, equipment, a storage medium and a program product, and the document question-answering method comprises the steps: receiving a question statement by a document, and carrying out vectorization processing on the question statement to obtain a question vector; matching at least one first target retrieval vector corresponding to the question vector from at least one retrieval vector contained in a preset vector library; the retrieval vector comprises at least one of a text vector and a table vector; establishing question and answer pairs according to the first target retrieval vector and the question statement, and inputting the question and answer pairs into a pre-trained reordering model to obtain a correlation arrangement sequence corresponding to each question and answer pair; and determining a second target retrieval vector from the first target retrieval vector according to the correlation arrangement sequence, and generating an answer corresponding to the question statement according to the target original document corresponding to the second target retrieval vector. According to the method, the matching breadth and the matching accuracy of the finally matched reference document can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of intelligent question answering technology, and in particular to a document question answering method, apparatus, device, storage medium and program product. Background Art

[0002] With the development of computer technology, the number of electronic documents is increasing. Among them are complex and long documents containing semi-structured data and unstructured data such as text, tables, and pictures. These documents often contain rich knowledge and information, but it is not easy for humans to quickly and accurately find the required information from a large number of electronic documents.

[0003] The more common document automated question-answering methods have low search accuracy. The documents recalled based on user questions often have low relevance and poor accuracy, which will make the final generated document response inconsistent with the user's question. Summary of the invention

[0004] The present application provides a document question-and-answer method, apparatus, device, storage medium, and program product to solve the problem of poor accuracy of document response content generated by document automated question-and-answer methods in the prior art.

[0005] In a first aspect, the present application provides a document question-and-answer method, comprising:

[0006] Receiving a question statement, and performing vectorization processing on the question statement to obtain a question vector;

[0007] Matching at least one first target search vector corresponding to the question vector from at least one search vector included in a preset vector library; the search vector includes at least one of a text vector and a table vector;

[0008] Establishing a question-answer pair according to the first target retrieval vector and the question sentence, and inputting the question-answer pair into a pre-trained re-ranking model to obtain a relevance ranking order corresponding to each of the question-answer pairs;

[0009] According to the relevance arrangement order, a second target retrieval vector is determined from the first target retrieval vector, and an answer corresponding to the question statement is generated according to the target original document corresponding to the second target retrieval vector.

[0010] In one embodiment, matching at least one first target search vector corresponding to the question vector from at least one search vector included in a preset vector library includes:

[0011] Traversing each search vector included in the preset vector library, and calculating the cosine similarity value between the question vector and each search vector included in the preset vector library;

[0012] The cosine similarity values ​​are arranged in a preset order, and the search vectors corresponding to the first preset number of cosine similarities with the highest relevance arrangement order are taken as the first target search vectors.

[0013] In one embodiment, the step of establishing the preset vector library includes:

[0014] Collect at least one original document;

[0015] Splitting the original document using a pre-trained splitting model to obtain split text and split tables corresponding to the original document;

[0016] Perform text embedding on the split text and the split table to obtain a text vector and a table vector;

[0017] The preset vector library is established based on the text vector and the table vector.

[0018] In one embodiment, the method of using a pre-trained model to split the original document and obtaining the split text and split table corresponding to the original document includes:

[0019] Merging the split texts according to a first preset text length to obtain at least one first data block;

[0020] Inputting the split table into a pre-trained extraction model to obtain table summary information corresponding to the split table;

[0021] The performing text embedding on the split text and the split table to obtain a text vector corresponding to the split text and a table vector corresponding to the split table includes:

[0022] Text embedding is performed on the first data block and the table summary information to obtain the text vector and the table vector.

[0023] In one embodiment, the using of a pre-trained splitting model to split the original document to obtain the split text and split table corresponding to the original document includes:

[0024] Splitting the original document using a pre-trained splitting model to obtain a title, split text, and split table corresponding to the original document;

[0025] The step of merging the split texts according to the first preset text length to obtain at least one first data block includes:

[0026] According to the first preset text length, the split texts corresponding to each of the titles are merged to obtain at least one first data block corresponding to each of the titles.

[0027] In one embodiment, after merging the split texts according to the preset length to obtain at least one first data block, the method further includes:

[0028] According to a second preset text length, the text contained in the first data block is segmented to obtain at least one second data block; the first preset text length is greater than the second preset text length;

[0029] The step of performing text embedding on the first data block and the table summary information to obtain the text vector and the table vector includes:

[0030] Text embedding is performed on the second data block and the table summary information to obtain the text vector and the table vector.

[0031] In one embodiment, before establishing the preset vector library based on the text vector and the table vector, the method further includes:

[0032] Determine a corresponding relationship between the text vector and the split text according to a second data block corresponding to the text vector, a first data block corresponding to the second data block, and a split text corresponding to the first data block;

[0033] Determine a corresponding relationship between the table vector and the split table according to the table summary information corresponding to the table vector and the split table corresponding to the table summary information;

[0034] The establishing the preset vector library based on the text vector and the table vector comprises:

[0035] The preset vector library is established based on the text vector and the table vector, as well as the corresponding relationship between the text vector and the split text, and the corresponding relationship between the table vector and the split table.

[0036] In one of the embodiments, the first target search vector includes at least one of a first target text vector and a first target table vector;

[0037] The step of establishing a question-answer pair according to the first target retrieval vector and the question sentence, and inputting the question-answer pair into a pre-trained re-ranking model to obtain a relevance ranking order corresponding to each of the question-answer pairs includes:

[0038] Establishing the question-answer pair according to the second data block corresponding to the first target text vector, the table summary information corresponding to the first target table vector, and the question statement;

[0039] The question-answer pairs are input into a pre-trained re-ranking model to obtain the relevance ranking order corresponding to each question-answer pair.

[0040] In one embodiment, after establishing the preset vector library based on the text vector and the table vector, as well as the correspondence between the text vector and the split text, and the correspondence between the table vector and the split table, the method further includes:

[0041] The second data block, the table summary information and the preset vector library are stored together in a first preset location, and the original document is stored in a second preset location.

[0042] In one of the embodiments, the second target search vector includes at least one of a second target text vector and a second target table vector;

[0043] The target original document corresponding to the second target retrieval vector includes at least one of an original document corresponding to the second target split text and an original document corresponding to the second target split table;

[0044] The step of determining a second target retrieval vector from the first target retrieval vector according to the relevance arrangement order, and generating an answer corresponding to the question statement according to a target original document corresponding to the second target retrieval vector, includes:

[0045] According to the relevance arrangement order, the first target retrieval vectors in a second preset number of question-answer pairs with a higher relevance arrangement order are used as the second target retrieval vectors;

[0046] Determine the second target split text and the second target split table corresponding to the second target search vector according to the correspondence between the text vector and the split text and the correspondence between the table vector and the split table in the preset vector library;

[0047] An answer corresponding to the question statement is generated according to the preset prompt information, the original document corresponding to the second target split text, and the original document of the second target split table.

[0048] In one embodiment, generating an answer corresponding to the question statement according to the preset prompt information, the original document corresponding to the target split text, and the original document of the target split table includes:

[0049] Acquire the original document corresponding to the second target split text and the original document of the second target split table from the second preset position;

[0050] An answer corresponding to the question statement is generated according to the preset prompt information, the original document corresponding to the second target split text, and the original document of the second target split table.

[0051] In one embodiment, the prompt information includes a connection relationship between the prompt text information and the data filling position;

[0052] The step of generating an answer corresponding to the question statement according to the preset prompt information, the original document corresponding to the target split text, and the original document of the target split table includes:

[0053] Fill the original document corresponding to the second target split text and the original document of the second target split table into the data filling position;

[0054] An answer corresponding to the question statement is generated according to the original document filled in the data filling position, the prompt text information and the connection relationship.

[0055] In a second aspect, the present application also provides a document question-and-answer device, comprising:

[0056] A receiving module, used for receiving a question statement and performing vectorization processing on the question statement to obtain a question vector;

[0057] A matching module, used to match at least one first target retrieval vector corresponding to the question vector from at least one retrieval vector included in a preset vector library; the retrieval vector includes at least one of a text vector and a table vector;

[0058] A sorting module, used to establish a question-answer pair according to the first target retrieval vector and the question sentence, and input the question-answer pair into a pre-trained re-ranking model to obtain a relevance ranking order corresponding to each question-answer pair;

[0059] A generating module is used to determine a second target retrieval vector from the first target retrieval vector according to the relevance arrangement order, and generate an answer corresponding to the question statement according to the target original document corresponding to the second target retrieval vector.

[0060] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the document question-and-answer method described in any of the above embodiments is implemented.

[0061] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the document question-and-answer method described in any of the above embodiments is implemented.

[0062] In a fifth aspect, the present application further provides a computer program product, which includes a computer program, and when the computer program product is executed by a processor, the document question-and-answer method described in any of the above embodiments is implemented.

[0063] The above-mentioned document question and answer method, device, equipment, storage medium and program product can pre-distinguish and process the text and table contained in the pre-stored original document, so that the dimension corresponding to the retrieval vector in the preset vector library is increased, and the number of retrieval vectors is increased. When a question statement is received, the question vector corresponding to the question statement can be compared and matched with a more fine-grained retrieval vector, so that the hit rate of the screened first target retrieval vector can be higher, thereby improving the matching breadth of the reference document finally matched, and the first target retrieval vector can also be reordered to screen out the first target retrieval vector most relevant to the question statement as the second target retrieval vector, thereby improving the matching breadth of the reference document finally matched while improving the matching accuracy of the reference document finally matched. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0065] Figure 1 An application environment diagram of a document question-and-answer method in an embodiment;

[0066] Figure 2 A schematic diagram of a flow chart of a document question-and-answer method in one embodiment;

[0067] Figure 3 A schematic diagram of a flow chart of determining a first target retrieval vector in a document question answering method according to an embodiment;

[0068] Figure 4 A schematic diagram of a flow chart of determining a relevance ranking order corresponding to a question-answer pair by a document question-answering method in one embodiment;

[0069] Figure 5 A schematic diagram of a process for generating an answer corresponding to a question statement by a document question answering method in one embodiment;

[0070] Figure 6 A schematic diagram of a process for establishing a preset vector library for a document question-answering method in one embodiment;

[0071] Figure 7 A schematic diagram of a flow chart of a document question-and-answer method in one embodiment;

[0072] Figure 8is a schematic diagram of the structure of a document question-and-answer device in one embodiment;

[0073] Fig. 9 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment.

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

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

[0076] The document question-answering method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown, the terminal 102 communicates with the server 104 via the network.

[0077] For example, the document question-answering method is applied to the terminal 102. When the terminal 102 receives the question statement, it vectorizes the question statement to obtain the question vector; then the terminal 102 obtains the preset vector library from the data storage system of the server 104, and matches at least one first target retrieval vector corresponding to the question vector from at least one retrieval vector contained in the preset vector library; the retrieval vector includes at least one of a text vector and a table vector; and a question-answer pair is established according to the first target retrieval vector and the question statement, and the question-answer pair is input into a pre-trained reordering model to obtain the relevance ranking order corresponding to each question-answer pair; finally, the terminal 102 determines the second target retrieval vector from the first target retrieval vector according to the relevance ranking order, and generates the answer corresponding to the question statement according to the target original document corresponding to the second target retrieval vector. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices, and the Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc. The server 104 can be implemented by an independent server or a server cluster composed of multiple servers. The terminal 102 and the server 104 may be connected directly or indirectly via wired or wireless communication, such as via a network connection.

[0078] For another example, the document question-answering method is applied to the server 104. When the terminal 102 receives the question statement, it sends the question statement to the server 104. The server 104 vectorizes the question statement to obtain a question vector, obtains a preset vector library from the data storage system, and matches at least one first target retrieval vector corresponding to the question vector from at least one retrieval vector contained in the preset vector library; the retrieval vector includes at least one of a text vector and a table vector; then the server 104 establishes a question-answer pair based on the first target retrieval vector and the question statement, and inputs the question-answer pair into a pre-trained re-ranking model to obtain the relevance ranking order corresponding to each question-answer pair; finally, according to the relevance ranking order, the second target retrieval vector is determined from the first target retrieval vector, and the answer corresponding to the question statement is generated according to the target original document corresponding to the second target retrieval vector. It can be understood that the data storage system can be an independent storage device, or the data storage system is located on the server 104, or the data storage system is located on another terminal.

[0079] It should be noted that the network communication between the terminal 102 and the server 104 is applicable to different network standards, for example, it can be applicable to global system of mobile communication (GSM), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time division synchronous code division multiple access (TD-SCDMA), long term evolution (LTE) system and future 5G and other network standards. Optionally, the above communication system can be a system in the scenario of ultra-reliable and low latency communications (URLLC) transmission in a 5G communication system.

[0080] Therefore, optionally, the above-mentioned base station can be a base station (Base Transceiver Station, referred to as BTS) and / or a base station controller in GSM or CDMA, or a base station (NodeB, referred to as NB) and / or a radio network controller (Radio Network Controller, referred to as RNC) in WCDMA, or an evolved base station (EvolutionalNode B, referred to as eNB or eNodeB) in LTE, or a relay station or access point, or a base station (gNB) in the future 5G network, etc., and the present application is not limited here.

[0081] The terminal 102 can be a wireless terminal or a wired terminal. A wireless terminal can be a device that provides voice and / or other service data connectivity to a user, a handheld device with a wireless connection function, or other processing devices connected to a wireless modem. A wireless terminal can communicate with one or more core network devices via a radio access network (Radio Access Network, referred to as RAN). A wireless terminal can be a mobile terminal, such as a mobile phone (or "cellular" phone) and a computer with a mobile terminal, for example, a portable, pocket-sized, handheld, computer-built-in or vehicle-mounted mobile device, which exchanges language and / or data with a radio access network. For another example, a wireless terminal can also be a personal communication service (Personal Communication Service, referred to as PCS) phone, a cordless phone, a Session Initiation Protocol (Session Initiation Protocol, referred to as SIP) phone, a wireless local loop (Wireless Local Loop, referred to as WLL) station, a personal digital assistant (Personal Digital Assistant, referred to as PDA) and other devices. The wireless terminal may also be referred to as a system, a subscriber unit, a subscriber station, a mobile station, a mobile station, a remote station, a remote terminal, an access terminal, a user terminal, a user agent, a user device or user equipment, without limitation. Optionally, the terminal device may also be a smart watch, a tablet computer or other device.

[0082] In one embodiment, a document question-answering method is provided. In this embodiment, the document question-answering method is exemplified by being applied to a terminal. It can be understood that the document question-answering method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. As Figure 2 shown, the document question-answering method includes:

[0083] Step 202, receive a question statement, and perform vectorization processing on the question statement to obtain a question vector.

[0084] The question statement can be input by a user through a fixed component on the human-computer interaction interface of the terminal. Herein, the fixed component can refer to a pre-constructed page or applet. The question statement can be text content screened and recalled for a reference document pre-stored in the server.

[0085] The process of the terminal performing vectorization processing on the question statement can be based on statistics or a neural network. This process can, for example, include: First, the terminal preprocesses the question statement to remove stop words, punctuation marks, etc. Subsequently, the terminal uses the forward maximum matching algorithm to decompose the question statement into at least one word or phrase, and removes common meaningless words, such as "of", "is", etc. Immediately afterwards, the terminal uses the word2vec language model to convert the word or phrase into a corresponding word vector. The finally obtained word vector can be regarded as the question vector. It should be noted that the embodiment of the present application does not limit the method of performing vectorization processing on the question statement, as long as it can extract the question vector corresponding to the question statement. For example, the terminal can also use a neural network model, etc. to perform vectorization processing on the question statement.

[0086] The question vector represents the semantic information of the question statement. By converting the text data into a numerical vector, the terminal simplifies the difficulty of text analysis.

[0087] Step 204, match at least one first target retrieval vector corresponding to the question vector from at least one retrieval vector included in the preset vector library; the retrieval vector includes at least one of a text vector and a table vector.

[0088] The retrieval vector can be understood as a label of the reference document, used to characterize the key content of the reference document. In the embodiment of the present invention, the retrieval vectors saved in the preset vector library can not only characterize the key content of the text in the reference document, but also characterize the key content of the table in the reference document. By performing a differentiation process on the text and table of the reference document, the dimension corresponding to the retrieval vector in the preset vector library is increased, and at the same time the number of retrieval vectors is increased, which can be understood as increasing the matching targets of the reference document, making the hit rate of the first target retrieval vector higher when the terminal matches the question vector with the retrieval vector, thereby improving the document matching accuracy.

[0089] The first target search vector may refer to a search vector in a preset vector library whose similarity with the question vector reaches a preset value.

[0090] Step 206: Create a question-answer pair based on the first target retrieval vector and the question statement, and input the question-answer pair into a pre-trained re-ranking model to obtain a relevance ranking order corresponding to each question-answer pair.

[0091] The terminal can collect multiple word vectors corresponding to each sample question for multiple sample questions, and then establish multiple sample question-word vector sample question-answer pairs based on the sample questions and the corresponding multiple word vectors, and use the sample question-answer pairs to train the initial reranking model to obtain a trained reranking model.

[0092] The re-ranking model is used to rank at least one first target retrieval vector. The re-ranking module can output a relevance ranking order based on the semantic relevance between the first target retrieval vector and the question statement, for example. The re-ranking can be based on various features and algorithms, such as the matching degree between the first target retrieval vector and the question statement, the weight of the first target retrieval vector, the relevance of the first target retrieval vector, etc. Through the re-ranking, the time of terminal matching retrieval can be reduced and the efficiency of document question answering can be improved.

[0093] Step 208: Determine a second target retrieval vector from the first target retrieval vector in order of relevance, and generate an answer corresponding to the question statement according to the target original document corresponding to the second target retrieval vector.

[0094] In this embodiment, the terminal can, for example, select several first target retrieval vectors that are at the front in the relevance arrangement order as the second target retrieval vector. By reordering the first target retrieval vectors, the terminal can put the first target retrieval vector that is most relevant to the question statement in front, thereby improving the accuracy of the terminal in obtaining the second target retrieval vector corresponding to the question statement.

[0095] The target original document may refer to a reference document pre-stored in the data storage system of the server, and the retrieval vector in the preset vector library has a mapping relationship established with the reference document in advance, that is, it can be understood that the text vector in the preset vector library corresponds one-to-one to the reference document, and the table vector in the preset vector library corresponds one-to-one to the reference document.

[0096] After determining the second target retrieval vector, the terminal can use the reference document corresponding to the second target retrieval vector as the target original document, and use the target original document as the result of the document question and answer to generate a final answer.

[0097] In the above-mentioned document question-and-answer method, the terminal can pre-distinguish and process the text and tables contained in the pre-stored reference documents, so that the dimension corresponding to the retrieval vector in the preset vector library is increased, and the number of retrieval vectors is increased. When the terminal receives a question statement, the question vector corresponding to the question statement can be compared and matched with a more fine-grained retrieval vector, so that the hit rate of the screened first target retrieval vector can be higher, thereby improving the matching breadth of the reference document finally matched, and the terminal can also reorder the first target retrieval vector to screen out the first target retrieval vector that is most relevant to the question statement as the second target retrieval vector, thereby improving the matching breadth of the reference document finally matched while improving the matching accuracy of the reference document finally matched.

[0098] like Figure 3 As shown, in some optional embodiments, step 204 includes:

[0099] Step 2042, traverse each search vector included in the preset vector library, and calculate the cosine similarity value between the question vector and each search vector included in the preset vector library;

[0100] Step 2044: Arrange the cosine similarity values ​​in a preset order, and use the search vectors corresponding to the first preset number of cosine similarities that are arranged in the front order as the first target search vectors.

[0101] In this embodiment, the calculation formula of the cosine similarity value between the question vector and the search vector is as follows:

[0102]

[0103] Among them, A represents the question vector, B represents the retrieval vector, AB represents the dot product of the question vector and the retrieval vector, ‖A‖ represents the modulus of the question vector, and ‖B‖ represents the modulus of the retrieval vector.

[0104] The preset order may be in descending order of cosine similarity values, and the first target search vector may be understood as the TOP N search vectors with larger cosine similarity values ​​to the question vector, where N is a first preset number.

[0105] In some optional embodiments, the step of establishing a preset vector library includes:

[0106] Collect at least one original document;

[0107] Use the pre-trained splitting model to split the original document and obtain the split text and split table corresponding to the original document;

[0108] Perform text embedding on the split text and split table to obtain text vectors and table vectors;

[0109] Create a preset vector library based on text vectors and table vectors.

[0110] The original document refers to the document that provides system knowledge and information support. When the terminal receives a question statement, it can retrieve relevant information from the document collection formed by these original documents, find the most appropriate original document to generate the final answer. In this embodiment, the performance and effect of the terminal generating the answer corresponding to the question statement depends largely on the quality and coverage of the collection of original documents.

[0111] The splitting model can be a YoLoX model, a set of a BERT model and a table recognition model, a Faster R-CNN model, etc. As an example, the terminal can obtain the specific contents such as pages, footers, page paragraphs, titles and tables contained in each original document by inputting multiple original documents into a pre-trained YoLoX model. In this embodiment, the terminal can use the page paragraphs and tables output by the YoLoX model as split text and split tables.

[0112] The step of the terminal embedding the split text to obtain a text vector includes: inputting the preprocessed split text into a text embedding model, the text embedding model generates a corresponding vector representation for each word or phrase contained in the split text, and then merging the vectors of each word or phrase into a vector representation of the entire split text by taking an average, a weighted average, etc., to obtain a final text vector. Among them, preprocessing the split text may include performing text preprocessing operations such as word segmentation, removing stop words, stemming or lemmatization on the split text, and the text embedding model may be a Word2Vec model, a GloVe model, a FastText model, a BERT model, etc.

[0113] The step of the terminal performing text embedding on the split table to obtain a table vector includes: extracting text content from the split table, performing word segmentation on the extracted text content, splitting the extracted text content into words or phrases, using the above-mentioned text embedding model to obtain a vector representation of each word or phrase, and then merging the vector representation of each word or phrase by taking an average, a weighted average, etc., to obtain a vector representation of the text content extracted from the split table as the final table vector.

[0114] The preset vector library may be a collection of text vectors and table vectors.

[0115] In some optional embodiments, after the original document is split using a pre-trained model to obtain the split text and split table corresponding to the original document, the method further includes:

[0116] Merging the split texts according to a first preset text length to obtain at least one first data block;

[0117] Input the split table into the pre-trained extraction model to obtain the table summary information corresponding to the split table;

[0118] The steps of embedding the split text and split table and obtaining the text vector and table vector include:

[0119] Text embedding is performed on the first data block and the table summary information to obtain a text vector and a table vector.

[0120] The first data block refers to the result of merging all the split texts from the original document. The first preset text length is used to limit the text length of each first data block. Document merging of the split texts is used to granularize the split texts to avoid traversing and matching the question vector with the split texts corresponding to all the original documents for each question-answer matching, so as to reduce the matching workload.

[0121] The extraction model may include a bag-of-words model, a TF-IDF model, a word2vec model, etc. The table summary information may be understood as the text content extracted from the split table.

[0122] The step of the terminal performing text embedding on the first data block to obtain a text vector includes: inputting the text content contained in the first data block into a text embedding model after word segmentation processing, the text embedding model generating a corresponding vector representation for each word or phrase contained in the first data block, and then merging the vectors of each word or phrase as the vector representation of the first data block by taking the average value, weighted average value, etc., to obtain the final text vector.

[0123] The step of the terminal performing text embedding on the table summary information to obtain a table vector includes: performing word segmentation on the table summary information, splitting the table summary information into words or phrases, using the above-mentioned text embedding model to obtain the vector representation of each word or phrase, and then merging the vector representation of each word or phrase by taking the average, weighted average, etc., to obtain the vector representation of the table summary information as the final table vector.

[0124] In some optional embodiments, the steps of using a pre-trained splitting model to split the original document and obtaining the split text and split table corresponding to the original document include:

[0125] Use the pre-trained splitting model to split the original document to obtain the title, split text and split table corresponding to the original document;

[0126] The step of merging the split texts according to a first preset text length to obtain at least one first data block includes:

[0127] According to the first preset text length, the split texts corresponding to the respective titles are merged to obtain at least one first data block corresponding to the respective titles.

[0128] In this embodiment, when the terminal uses a splitting model to split multiple original documents, it can simultaneously obtain the title corresponding to each original document, the text content and table content corresponding to each title, and then merge the text content corresponding to each title according to the first preset text length to obtain a first data block, thereby classifying and merging the split texts of multiple original documents according to the titles to achieve further granularity of the first data block.

[0129] In some optional embodiments, after the step of merging the split texts according to a preset length to obtain at least one first data block, the step further includes:

[0130] According to a second preset text length, the text contained in the first data block is segmented to obtain at least one second data block; the first preset text length is greater than the second preset text length;

[0131] The step of performing text embedding on the first data block and the table summary information to obtain a text vector and a table vector includes:

[0132] Text embedding is performed on the second data block and the table summary information to obtain a text vector and a table vector.

[0133] The text length that the second data block can accommodate is shorter than that of the first data block, that is, it can be understood that the second data block is a further segmentation of the first data block, the first data block is a large text block, and the second data block is a small text block.

[0134] The step of the terminal performing text embedding on the second data block to obtain a text vector includes: inputting the text content contained in the second data block into a text embedding model after word segmentation processing, the text embedding model generating a corresponding vector representation for each word or phrase contained in the second data block, and then merging the vectors of each word or phrase as the vector representation of the second data block by taking the average value, weighted average value, etc., to obtain the final text vector.

[0135] The terminal in this embodiment improves the granularity of the text vectors in the preset vector library by further dividing the first data block on the basis of classifying and merging the split texts of multiple original documents according to titles, thereby improving the hit rate of the question vector in the document question and answer process and improving the accuracy of the final question and answer.

[0136] In some optional embodiments, before establishing a preset vector library based on the text vector and the table vector, the method further includes:

[0137] Determine a correspondence between the text vector and the split text according to the second data block corresponding to the text vector, the first data block corresponding to the second data block, and the split text corresponding to the first data block;

[0138] Determine the corresponding relationship between the table vector and the split table according to the table summary information corresponding to the table vector and the split table corresponding to the table summary information;

[0139] The steps of establishing a preset vector library based on text vectors and table vectors include:

[0140] A preset vector library is established based on text vectors and table vectors, as well as the correspondence between text vectors and split texts, and the correspondence between table vectors and split tables.

[0141] It can be understood that the preset vector library in this embodiment not only includes text vectors and table vectors, but also includes the mapping relationship between text vectors and split texts, and the mapping relationship between table vectors and split tables.

[0142] like Figure 4 As shown, in some optional embodiments, the first target retrieval vector includes at least one of a first target text vector and a first target table vector;

[0143] Step 206 includes:

[0144] Step 2062: Create a question-answer pair according to the second data block corresponding to the first target text vector, the table summary information corresponding to the first target table vector, and the question statement;

[0145] Step 2064: input the question-answer pairs into a pre-trained re-ranking model to obtain the relevance ranking order corresponding to each question-answer pair.

[0146] If the retrieval vector includes at least one of a text vector and a table vector, the terminal uses the text vector that matches the question vector in the preset vector library as the first target text vector, and uses the table vector that matches the question vector in the preset vector library as the first target table vector. Furthermore, a question-answer pair between the second data block corresponding to the first target text vector and the question statement, and a question-answer pair between the table summary information corresponding to the first target table vector and the question statement are established, and the question-answer pair is input into the reordering model to obtain the correlation arrangement order of each first target text vector and the first target table vector.

[0147] like Figure 5 As shown, in some optional embodiments, the second target retrieval vector includes at least one of a second target text vector and a second target table vector;

[0148] The target original document corresponding to the second target retrieval vector includes at least one of an original document corresponding to the second target split text and an original document corresponding to the second target split table;

[0149] Step 208 includes:

[0150] Step 2082: according to the order of relevance, the first target search vectors in the second preset number of question-answer pairs with the highest order of relevance are used as the second target search vectors;

[0151] Step 2084: Determine the second target split text and the second target split table corresponding to the second target search vector according to the correspondence between the text vector and the split text and the correspondence between the table vector and the split table in the preset vector library;

[0152] Step 2086: Generate an answer corresponding to the question statement based on the preset prompt information, the original document corresponding to the second target split text, and the original document of the second target split table.

[0153] The terminal uses the first target retrieval vector in a second preset number of question-answer pairs with a higher order of relevance as the second target retrieval vector, and correspondingly uses the text vector in the second target retrieval vector as the second target text vector, and uses the table vector in the second target retrieval vector as the second target table vector.

[0154] Further, according to the correspondence between the text vector and the split text, and the correspondence between the table vector and the split table stored in the preset vector library, the second target split text and the second target split table corresponding to the second target retrieval vector are determined.

[0155] Furthermore, the terminal uses the original text where the second target split text is located as the target original document of the second target text vector, uses the original text where the second target split table is located as the target original document of the second target table vector, and prompts information to generate a final answer.

[0156] Among them, after the terminal establishes the preset vector library, the second data block, the table summary information, the text vector and the table vector contained in the preset vector library, the mapping relationship between the text vector and the split text, and the mapping relationship between the table vector and the split table can be stored together in the first preset position, and all original documents can be stored in the second preset position. The original documents in the second preset position can use the split text or the split table as a pointer for index extraction.

[0157] In step 2086, the terminal can obtain the original document corresponding to the second target split text and the original document of the second target split table from the second preset position; and generate an answer corresponding to the question statement based on the preset prompt information, the original document corresponding to the second target split text and the original document of the second target split table.

[0158] The prompt information may include a connection relationship between the prompt text information and the data filling position. In the process of generating the final answer, the terminal may fill the original document corresponding to the second target split text and the original document of the second target split table into the data filling position, and generate the final answer according to the connection relationship with the prompt text information.

[0159] like Figure 6 As shown, in one embodiment, the method for establishing a preset vector library includes:

[0160] Step 601: Collect at least one original document;

[0161] Step 602: Use the pre-trained splitting model to split the original document to obtain the title, split text and split table corresponding to each original document;

[0162] Step 603: merge the split texts corresponding to the titles according to the first preset text length to obtain at least one first data block corresponding to each title;

[0163] Step 604: segment the text contained in the first data block according to the second preset text length to obtain at least one second data block;

[0164] Step 605: input the split table into a pre-trained extraction model to obtain table summary information corresponding to the split table;

[0165] Step 606: Perform text embedding on the second data block and the table summary information to obtain a text vector and a table vector;

[0166] Step 607: Determine the correspondence between the text vector and the split text according to the second data block corresponding to the text vector, the first data block corresponding to the second data block, and the split text corresponding to the first data block; and determine the correspondence between the table vector and the split table according to the table summary information corresponding to the table vector and the split table corresponding to the table summary information;

[0167] Step 608: Establish a preset vector library based on the text vector and the table vector, as well as the correspondence between the text vector and the split text, and the correspondence between the table vector and the split table.

[0168] It should be noted that the above step 605 can be set before step 603 or performed simultaneously with step 603.

[0169] Correspondingly, such as Figure 7 As shown, the document question-answering method includes:

[0170] Step 701: receiving a question statement, and performing vectorization processing on the question statement to obtain a question vector;

[0171] Step 702: Calculate the cosine similarity value between at least one text vector, at least one table vector and the question vector included in the preset vector library, and use a first preset number of text vectors and table vectors with larger cosine similarity values ​​as first target text vectors and first target table vectors;

[0172] Step 703: Acquire the second data block corresponding to the first target text vector and the table summary information corresponding to the first target table vector from the preset vector library;

[0173] Step 704: Use the second data block corresponding to the first target text vector and the question sentence to establish a question-answer pair, and use the table summary information corresponding to the first target table vector and the question sentence to establish a question-answer pair;

[0174] Step 705: Input the question-answer pairs into a pre-trained re-ranking model to obtain the relevance ranking order corresponding to each question-answer pair;

[0175] Step 706: according to the order of relevance, the first target search vectors in the second preset number of question-answer pairs with the highest order of relevance are used as the second target search vectors;

[0176] Step 707: Determine the second target split text and the second target split table corresponding to the second target search vector according to the correspondence between the text vector and the split text and the correspondence between the table vector and the split table in the preset vector library;

[0177] Step 708: Obtain the original document corresponding to the second target split text and the original document of the second target split table;

[0178] Step 709: fill the original document corresponding to the second target split text and the original document of the second target split table into the data filling position, and generate the answer to the question statement according to the connection relationship between the data filling position and the prompt text information.

[0179] In the above-mentioned document question-answering method, the terminal can distinguish and process the text and table contained in the initial document, and merge and split the text twice, so that the terminal can generate the final text vector according to the text blocks after the two splits and mergers, so that the dimension corresponding to the retrieval vector in the preset vector library is increased, and the number of retrieval vectors is increased. When the terminal receives a question statement, the question vector corresponding to the question statement can be compared and matched with a more fine-grained retrieval vector, so that the hit rate of the screened first target retrieval vector can be higher, thereby improving the matching breadth of the reference document finally matched. In addition, the terminal can also reorder the first target retrieval vector to screen out the first target retrieval vector that is most relevant to the question statement as the second target retrieval vector, thereby improving the matching breadth of the reference document finally matched while improving the matching accuracy of the reference document finally matched. Finally, the terminal can fill the original document corresponding to the second target retrieval vector into the preset data filling position, and generate an answer according to the preset prompt text information and connection relationship, so that the final output answer is standardized and easy to read.

[0180] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0181] Based on the same inventive concept, the embodiment of the present application also provides a document question and answer device for implementing the document question and answer method involved above. The implementation scheme for solving the problem provided by the document question and answer device is similar to the implementation scheme recorded in the above document question and answer method, so the specific limitations in one or more document question and answer device embodiments provided below can refer to the limitations of the document question and answer method above, and will not be repeated here.

[0182] In one embodiment, Figure 8 As shown, a document question-answering device 800 is provided, comprising:

[0183] The receiving module 802 is used to receive a question statement and perform vectorization processing on the question statement to obtain a question vector;

[0184] A matching module 804 is used to match at least one first target search vector corresponding to the question vector from at least one search vector included in a preset vector library; the search vector includes at least one of a text vector and a table vector;

[0185] A sorting module 806 is used to establish a question-answer pair according to the first target search vector and the question sentence, and input the question-answer pair into a pre-trained re-ranking model to obtain a relevance ranking order corresponding to each question-answer pair;

[0186] The generating module 808 is used to determine the second target retrieval vector from the first target retrieval vector according to the order of relevance, and generate an answer corresponding to the question statement according to the target original document corresponding to the second target retrieval vector.

[0187] Each module in the document question-and-answer device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0188] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig. 9 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a document question and answer method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.

[0189] Those skilled in the art will understand that Fig. 9The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0190] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, each step of the above-mentioned document question-and-answer method is implemented.

[0191] In one embodiment, a computer program product is provided, including a computer program, which implements the various steps of the above-mentioned document question and answer method when executed by a processor.

[0192] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0193] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0194] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the present application. It should be noted that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A document question-answering method, characterized in that: include: Receiving a question statement, and performing vectorization processing on the question statement to obtain a question vector; Matching at least one first target search vector corresponding to the question vector from at least one search vector included in a preset vector library; the search vector includes at least one of a text vector and a table vector; Establishing a question-answer pair according to the first target retrieval vector and the question sentence, and inputting the question-answer pair into a pre-trained re-ranking model to obtain a relevance ranking order corresponding to each of the question-answer pairs; According to the relevance arrangement order, a second target retrieval vector is determined from the first target retrieval vector, and an answer corresponding to the question statement is generated according to the target original document corresponding to the second target retrieval vector.

2. The method according to claim 1, characterized in that The matching of at least one first target retrieval vector corresponding to the question vector from at least one retrieval vector included in the preset vector library includes: Traversing each search vector included in the preset vector library, and calculating the cosine similarity value between the question vector and each search vector included in the preset vector library; The cosine similarity values ​​are arranged in a preset order, and the search vectors corresponding to the first preset number of cosine similarities with the highest relevance arrangement order are taken as the first target search vectors.

3. The method according to claim 2, characterized in that The steps of establishing the preset vector library include: Collect at least one original document; Splitting the original document using a pre-trained splitting model to obtain split text and split tables corresponding to the original document; Perform text embedding on the split text and the split table to obtain a text vector and a table vector; The preset vector library is established based on the text vector and the table vector.

4. The method according to claim 3, characterized in that The method of using the pre-trained model to split the original document and obtaining the split text and split table corresponding to the original document includes: Merging the split texts according to a first preset text length to obtain at least one first data block; Inputting the split table into a pre-trained extraction model to obtain table summary information corresponding to the split table; The performing text embedding on the split text and the split table to obtain a text vector corresponding to the split text and a table vector corresponding to the split table includes: Text embedding is performed on the first data block and the table summary information to obtain the text vector and the table vector.

5. The method according to claim 4, characterized in that The method of using a pre-trained splitting model to split the original document and obtaining split text and a split table corresponding to the original document includes: Splitting the original document using a pre-trained splitting model to obtain a title, split text, and split table corresponding to the original document; The step of merging the split texts according to the first preset text length to obtain at least one first data block includes: According to the first preset text length, the split texts corresponding to each of the titles are merged to obtain at least one first data block corresponding to each of the titles.

6. The method according to claim 4, characterized in that After merging the split texts according to the preset length to obtain at least one first data block, the method further includes: According to a second preset text length, the text contained in the first data block is segmented to obtain at least one second data block; the first preset text length is greater than the second preset text length; The step of performing text embedding on the first data block and the table summary information to obtain the text vector and the table vector includes: Text embedding is performed on the second data block and the table summary information to obtain the text vector and the table vector.

7. The method according to claim 6, characterized in that Before establishing the preset vector library based on the text vector and the table vector, the method further includes: Determine a corresponding relationship between the text vector and the split text according to a second data block corresponding to the text vector, a first data block corresponding to the second data block, and a split text corresponding to the first data block; Determine a corresponding relationship between the table vector and the split table according to the table summary information corresponding to the table vector and the split table corresponding to the table summary information; The establishing the preset vector library based on the text vector and the table vector comprises: The preset vector library is established based on the text vector and the table vector, as well as the corresponding relationship between the text vector and the split text, and the corresponding relationship between the table vector and the split table.

8. The method according to claim 7, characterized in that The first target search vector includes at least one of a first target text vector and a first target table vector; The step of establishing a question-answer pair according to the first target retrieval vector and the question sentence, and inputting the question-answer pair into a pre-trained re-ranking model to obtain a relevance ranking order corresponding to each of the question-answer pairs includes: Establishing the question-answer pair according to the second data block corresponding to the first target text vector, the table summary information corresponding to the first target table vector, and the question statement; The question-answer pairs are input into a pre-trained re-ranking model to obtain the relevance ranking order corresponding to each question-answer pair.

9. The method according to claim 7, characterized in that After establishing the preset vector library based on the text vector and the table vector, as well as the correspondence between the text vector and the split text, and the correspondence between the table vector and the split table, the method further includes: The second data block, the table summary information and the preset vector library are stored together in a first preset location, and the original document is stored in a second preset location.

10. The method according to claim 9, characterized in that The second target search vector includes at least one of a second target text vector and a second target table vector; The target original document corresponding to the second target retrieval vector includes at least one of an original document corresponding to the second target split text and an original document corresponding to the second target split table; The step of determining a second target retrieval vector from the first target retrieval vector according to the relevance arrangement order, and generating an answer corresponding to the question statement according to a target original document corresponding to the second target retrieval vector, includes: According to the relevance arrangement order, the first target retrieval vectors in a second preset number of question-answer pairs with a higher relevance arrangement order are used as the second target retrieval vectors; Determine the second target split text and the second target split table corresponding to the second target search vector according to the correspondence between the text vector and the split text and the correspondence between the table vector and the split table in the preset vector library; An answer corresponding to the question statement is generated according to the preset prompt information, the original document corresponding to the second target split text, and the original document of the second target split table.

11. The method according to claim 10, characterized in that The step of generating an answer corresponding to the question statement according to the preset prompt information, the original document corresponding to the target split text, and the original document of the target split table includes: Acquire the original document corresponding to the second target split text and the original document of the second target split table from the second preset position; An answer corresponding to the question statement is generated according to the preset prompt information, the original document corresponding to the second target split text, and the original document of the second target split table.

12. The method according to claim 10, characterized in that The prompt information includes a connection relationship between the prompt text information and the data filling position; The step of generating an answer corresponding to the question statement according to the preset prompt information, the original document corresponding to the target split text, and the original document of the target split table includes: Fill the original document corresponding to the second target split text and the original document of the second target split table into the data filling position; An answer corresponding to the question statement is generated according to the original document filled in the data filling position, the prompt text information and the connection relationship.

13. A document question-and-answer device, characterized in that: include: A receiving module, used for receiving a question statement and performing vectorization processing on the question statement to obtain a question vector; A matching module, used to match at least one first target retrieval vector corresponding to the question vector from at least one retrieval vector included in a preset vector library; the retrieval vector includes at least one of a text vector and a table vector; A sorting module, used to establish a question-answer pair according to the first target retrieval vector and the question sentence, and input the question-answer pair into a pre-trained re-ranking model to obtain a relevance ranking order corresponding to each question-answer pair; A generating module is used to determine a second target retrieval vector from the first target retrieval vector according to the relevance arrangement order, and generate an answer corresponding to the question statement according to the target original document corresponding to the second target retrieval vector.

14. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the document question and answer method according to any one of claims 1 to 12 are implemented.

15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the document question-and-answer method according to any one of claims 1 to 12 are implemented.

16. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the document question-and-answer method described in any one of claims 1 to 12 are implemented.

Citation Information

Cited By

  • Visual question and answer method and device, equipment, storage medium and product

    CN118916471A