Document retrieval methods, devices, electronic equipment and storage media
By combining sparse document retrieval, dense document retrieval, and a dual-tower matching model, the problems of synonyms and scenario specificity in financial research report reading comprehension are solved, achieving high-accuracy recall and prediction of answer fragments, and improving the efficiency of financial professionals in using research reports.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-05
- Publication Date
- 2026-04-03
AI Technical Summary
Existing financial research report reading comprehension technologies suffer from insufficient information constraints when querying data indicators, inadequate synonym processing, and low accuracy of general architectures in specific scenarios.
We employ a combination of sparse and dense document retrieval models and a dual-tower matching model. We optimize the model through pre-training and contrastive learning, expand synonyms using prompt templates, construct negative samples for training, and add coarse and fine reading modules to improve the recall and prediction accuracy of answer fragments.
It improved the accuracy of reading comprehension of financial research reports, and significantly enhanced the question-and-answer effect, with the accuracy rate increasing from less than 60% to over 85%.
Smart Images

Figure CN116680381B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of reading comprehension technology, specifically to a document retrieval method, apparatus, electronic device, and storage medium. Background Technology
[0002] Reading comprehension technology is the technique of finding the answer to a question within a set of documents, given a query question and a document set. Reading comprehension has always been a hot topic in both academia and industry. Taking financial research reports as an example, these reports contain rich professional knowledge and data, representing the analysis results of financial professionals. Implementing reading comprehension techniques within these reports can effectively help financial professionals find data-driven answers, improving the efficiency of using these reports.
[0003] The following problems exist in the existing reading comprehension of financial research reports: 1) When querying data indicators, restrictive information is not taken into account, resulting in incorrect answers; 2) There are multiple different expressions for the same definition in the financial field, and using a fixed thesaurus to handle synonym queries is not conducive to automatic expansion; 3) The existing general reading comprehension architecture is not targeted when facing specific scenarios such as financial research reports, and the accuracy of reading comprehension needs to be improved. Summary of the Invention
[0004] In view of the above problems, the present invention is proposed to provide a document retrieval method, apparatus, electronic device and storage medium that overcomes or at least partially solves the above problems.
[0005] According to one aspect of the present invention, a document retrieval method is provided, the method comprising:
[0006] Receive the query to be retrieved and determine the target document set as the search scope;
[0007] The query question is input into a pre-trained sparse document retrieval model and / or dense document retrieval model, and a list of candidate documents is obtained from the document set based on the query question.
[0008] The query question and the candidate document list are input into a pre-trained dual-tower matching model to obtain the answer fragment corresponding to the query question from the candidate document list.
[0009] The answer to the query question is determined and returned based on the answer fragment.
[0010] In some implementations, the pre-training of the sparse document retrieval model or the dense document retrieval model includes the following steps:
[0011] Generate prompt templates based on the constituent elements and sentence structure of the question;
[0012] Each component element is expanded using synonyms, and these synonyms are then applied to the prompt template to obtain multiple extended questions.
[0013] Multiple question-answer pairs are formed by combining multiple extended questions and their corresponding answers, thus creating a sample dataset.
[0014] In some implementations, the pre-training of the dual-tower matching model includes the following steps:
[0015] Construct a negative sample of the problem. The negative sample includes a first limiting word and a query segment. The query segment is the same as, similar to or synonymous with the query segment in the positive sample. The first limiting word is different from the limiting word in the positive sample.
[0016] The dual-tower matching model is trained by comparison using the negative and positive samples.
[0017] In some implementations, the pre-training of the dual-tower matching model further includes the following steps:
[0018] The negative sample also includes a second qualifier that is the same as, similar to, or synonymous with the qualifier in the positive sample. The first qualifier and the second qualifier are not in the same paragraph or the same sentence.
[0019] In some implementations, the dual-tower matching model includes a query encoder, a document encoder, and an interaction layer. The interaction layer includes an infrastructure model and a multi-task learning layer, which includes a coarse reading module and a fine reading module.
[0020] The skimming module is used to determine whether the current paragraph contains the answer segment, and the fine reading module is used to predict the specific location of the answer segment.
[0021] In some implementations, the intensive reading module includes a sentence position prediction unit and a word position prediction unit. The sentence position prediction unit is used to predict the sentence containing the answer fragment, and the word position prediction unit is used to predict the specific position of the answer fragment in the sentence containing the answer fragment.
[0022] In some implementations, the coarse reading module includes a binary classification model, and the coarse reading module and the fine reading module are respectively equipped with loss functions, wherein the loss functions of the sentence position prediction unit and the word position prediction unit respectively include the softmax function.
[0023] According to another aspect of the present invention, a document retrieval device is provided, the device comprising:
[0024] The receiving module is adapted to receive the query to be retrieved and determine the target document set as the retrieval scope;
[0025] The recall module is adapted to input the query question into a pre-trained sparse document retrieval model and / or dense document retrieval model, and obtain a list of candidate documents from the document set according to the query question;
[0026] The prediction module is adapted to input the query question and the candidate document list into a pre-trained dual-tower matching model, and obtain the answer fragment corresponding to the query question from the candidate document list;
[0027] The determination module is adapted to determine and return the answer result of the query question based on the answer fragment.
[0028] According to another aspect of the present invention, an electronic device is provided, comprising: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus;
[0029] The memory is used to store at least one executable instruction that causes the processor to perform an operation corresponding to the document retrieval method according to any one of the preceding statements.
[0030] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores one or more programs, which, when executed by a processor, implement the document retrieval method according to any one of the preceding descriptions.
[0031] As described above, the document retrieval scheme disclosed in this invention first receives the query question input by the user and determines or selects a target document set as the retrieval scope; then, the query question is input into a pre-trained sparse document retrieval model or a dense document retrieval model, and a candidate document list is obtained from the document set based on the query question; the query question and the candidate document list are input into a pre-trained dual-tower matching model, and answer fragments corresponding to the query question are obtained from the candidate document list; finally, the answer result is determined based on one or more answer fragments according to a certain paradigm or sentence structure, and returned to the user. The above scheme addresses the difficulties in reading comprehension, such as limiting words, synonyms, and reading comprehension frameworks, by proposing optimization strategies, improving the accuracy of research report reading comprehension, and achieving excellent question-and-answer performance.
[0032] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0033] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0034] Figure 1 A flowchart illustrating a document retrieval method according to an embodiment of the present invention is shown;
[0035] Figure 2 A schematic diagram of the structure of a document retrieval model based on reading comprehension technology according to an embodiment of the present invention is shown;
[0036] Figure 3 A schematic diagram of a prompt template according to an embodiment of the present invention is shown;
[0037] Figure 4 A schematic diagram of negative sample construction in contrastive learning according to an embodiment of the present invention is shown;
[0038] Figure 5 A schematic diagram of an interaction layer according to an embodiment of the present invention is shown;
[0039] Figure 6 A schematic diagram of a close reading module according to an embodiment of the present invention is shown;
[0040] Figure 7 A schematic diagram illustrating sentence position prediction according to an embodiment of the present invention is shown;
[0041] Figure 8 A schematic diagram of the overall framework for text retrieval according to an embodiment of the present invention is shown;
[0042] Figure 9 A schematic diagram of a document retrieval device according to an embodiment of the present invention is shown;
[0043] Figure 10 A schematic diagram of the structure of an electronic device according to an embodiment of the present invention is shown. Detailed Implementation
[0044] Exemplary embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the invention and to fully convey the scope of the invention to those skilled in the art.
[0045] Figure 1A document retrieval method according to an embodiment of the present invention is illustrated, and the method is applied to an electronic device. The electronic device includes a smart terminal device with computer programs installed, a computer device, and / or a cloud. The smart terminal device includes, but is not limited to, smartphones and tablets; the computer device includes, but is not limited to, personal computers, laptops, industrial computers, network hosts, single network servers, and sets of multiple network servers; the cloud consists of a large number of computers or network servers based on cloud computing, wherein cloud computing is a type of distributed computing, consisting of a virtual supercomputer composed of a group of loosely coupled computer sets.
[0046] See Figure 1 As shown, this embodiment discloses a document retrieval method, including:
[0047] Step 110: Receive the query question to be retrieved and determine the target document set as the retrieval scope.
[0048] For example, when searching for "Where will the 2022 World Cup be held?", a search engine can return a specific answer card containing the precise answer "Qatar" extracted from a document or paragraph on a webpage.
[0049] The retrieval process in this embodiment is divided into two stages: the first stage is the search stage, which is to find a list of documents L related to question q in the document set D through search technology, as candidates for the answer recognition process; the second stage is the answer fragment prediction stage, which finds the answer fragment s corresponding to q in L.
[0050] Step 120: Input the query question into a pre-trained sparse document retrieval model or dense document retrieval model, and obtain a list of candidate documents from the document set according to the query question.
[0051] This step pertains to the retrieval phase, where sparse document retrieval and dense document retrieval are two different algorithms. The terms "sparse" and "dense" refer to the differences in how queries and documents are processed during query matching.
[0052] Sparse document retrieval refers to processing queries in a word-by-word manner. It uses word features, such as Term Frequency (TF) and Inverse Document Frequency (IDF), and then calculates the relevance between the query and the document by using a distance algorithm based on the term frequencies of the query and the document, such as BM25.
[0053] Dense document retrieval, on the other hand, first embeds the complete query and documents using an encoder, resulting in two vectors, and then calculates the distance between these two vectors. Because dense document retrieval considers the impact of the entire query or document rather than individual words during embedding, the vector space is no longer single-dimensional but distributed across multiple dimensions, making the vector space much denser. A list L of documents that may contain the answer is obtained through searching and serves as input for the prediction stage.
[0054] Optionally, the above model is preferably a dense document retrieval model, or a combination of the two models to determine the result. In dense document retrieval, the question and the document need to be encoded separately to obtain vector representations of both. The encoder is generally based on a pre-trained language model, such as word2vec, BERT, Roberta, etc., and the vector obtained by passing the word sequence of the text through the above deep neural network is used as the output of the encoder.
[0055] Step 130: Input the query question and the candidate document list into the pre-trained dual-tower matching model, and obtain the answer fragment corresponding to the query question from the candidate document list.
[0056] The prediction steps using the dual-tower matching model include: encoding the question q and the documents d in the document list L separately using an encoder; then calculating the association between the question and the paragraphs using an interaction layer to predict the answer fragment. Architectures such as Transformer and BERT can serve as the main body of the interaction layer, and other knowledge information, such as knowledge graphs, can be introduced to improve the accuracy of the interaction layer's predictions.
[0057] Step 140: Determine and return the answer result for the query question based on the answer fragment.
[0058] The answer can be one or more fragments, and can generally be organized according to a fixed pattern or sentence structure to determine and return the final answer result to the client.
[0059] For the specific document retrieval framework, please refer to Figure 2 As shown, the above scheme can address the difficulties in reading comprehension, such as limiting words, synonyms, and reading comprehension frameworks. It employs sparse document retrieval models, dense document retrieval models, or dual-tower matching models for recall and predictive analysis, and finally determines the answer to the question based on the obtained answer fragments, thereby improving the accuracy of research report reading comprehension and achieving good question-answering results.
[0060] In one or more embodiments, the pre-training of the sparse document retrieval model or the dense document retrieval model includes the following steps:
[0061] Generate prompt templates based on the constituent elements and sentence structure of the question;
[0062] Each component element is expanded using synonyms, and these synonyms are then applied to the prompt template to obtain multiple extended questions.
[0063] Multiple question-answer pairs are formed by combining multiple extended questions and their corresponding answers, thus creating a sample dataset.
[0064] For details, see Figure 3 The illustrated prompt learning template structure is used to solve the matching problem caused by synonyms in reading comprehension. The training data for reading comprehension consists of <question, answer> pairs. Each training dataset contains multiple question-answer pairs. For synonyms of the constituent elements appearing in the "question," a placeholder is first used to obtain the sentence structure of the question. This sentence structure can then serve as a prompt pattern. Based on this prompt pattern, multiple questions of the same type are expanded by adding synonyms.
[0065] The above-mentioned prompting mechanism can greatly increase the training data of the model. On the other hand, because only the "question" is expanded and not the "answer", the model can learn the synonym relationship between the "question" and the "answer" during training, and can automatically handle the synonym expressions between the "question" and the "answer" in subsequent encoding.
[0066] In some embodiments, the pre-training of the dual-tower matching model includes the following steps:
[0067] Construct a negative sample of the problem. The negative sample includes a first limiting word and a query segment. The query segment is the same as, similar to or synonymous with the query segment in the positive sample. The first limiting word is different from the limiting word in the positive sample.
[0068] The dual-tower matching model is trained by comparison using the negative and positive samples.
[0069] In some optional embodiments, the pre-training of the dual-tower matching model further includes the following steps:
[0070] The negative sample also includes a second qualifier that is the same as, similar to, or synonymous with the qualifier in the positive sample. The first qualifier and the second qualifier are not in the same paragraph or the same sentence.
[0071] The mechanism of contrastive learning involves adding seemingly relevant but actually incorrect samples during training to widen the gap between related texts and those that appear relevant but are not. In reading comprehension exercises for research reports, for matching questions, such as "XXX Company's sales in 2021," a passage containing the phrase "At the beginning of 2021, XXX announced its 2020 performance, sales..." will be detected. This is because the recalled passage contains all the keywords from the question: "2021, XXX, sales," but the data indicators within the passage are not clearly defined, leading to incorrect answers.
[0072] To address the aforementioned issues, a large number of paragraphs or sentences containing the query terms from the question, but with different definitions, were added to the training data and labeled as negative samples. This was used to train the interaction layer model, which then learned to identify such mismatch issues. For example, using the question "XXX Company's sales in 2021," a model like this could be constructed... Figure 4 The sample set shown is used to obtain positive and negative samples for contrastive learning training, thereby improving the scalability of the model.
[0073] In some embodiments, the dual-tower matching model includes a query encoder, a document encoder, and an interaction layer. The interaction layer includes an infrastructure model and a multi-task learning layer. The multi-task learning layer includes a coarse reading module and a fine reading module.
[0074] The skimming module is used to determine whether the current paragraph contains the answer segment, and the fine reading module is used to predict the specific location of the answer segment.
[0075] In the model design of the interaction layer, optionally, the Roberta model can be used as the basic architecture model, and then additional processing modules and loss functions can be added to improve the prediction performance of the interaction layer. Specifically, the interaction layer also includes the following two parts: a coarse reading module and a fine reading module, see [link to documentation]. Figure 5 As shown. It should be noted that, Figure 5 The dual-tower matching model in the example is just that; the specific positions of each layer can be adjusted according to the actual algorithm.
[0076] Based on general human reading and searching habits, the first step is to determine whether the paragraph contains the answer; if it does, then the paragraph containing the answer is located. In the interaction layer, this is reflected in the construction of a multi-task learning layer, which includes a skimming module and a intensive reading module. These two modules can be implemented in parallel or sequentially, with a sequential approach being preferred.
[0077] The intensive reading module is responsible for predicting the specific location of the answer, consistent with existing reading comprehension models. The extensive reading module, on the other hand, determines whether the current paragraph contains the answer. The extensive reading module is primarily a binary classification module, specifically used to determine whether a paragraph contains the answer. Its loss function is the same as that for binary classification.
[0078]
[0079] Where N is the batch sample size during training, y i It's a tag, y i ' is the predicted probability that an answer exists.
[0080] The final loss function L is the sum of the loss function of the coarse reading module and the loss function of the fine reading module:
[0081]
[0082] This module can improve the F1 score of model training by more than 10%. The F1 score is a comprehensive evaluation metric (F-Measure), which is the harmonic mean of accuracy and recall.
[0083] In some embodiments, the intensive reading module includes a sentence position prediction unit and a word position prediction unit. The sentence position prediction unit is used to predict the sentence containing the answer fragment, and the word position prediction unit is used to predict the specific position of the answer fragment in the sentence containing the answer fragment.
[0084] Optionally, the coarse reading module and the fine reading module are each equipped with a loss function, and the loss functions of the sentence position prediction unit and the word position prediction unit respectively include the softmax function.
[0085] Specifically, in reading comprehension, even within correct paragraphs, errors can occur in predicting the start and end positions of the answer. This is because when sentences are complex, the model needs to predict more sequence positions. Therefore, in the intensive reading module, this embodiment designs a multi-level prediction unit based on sentences and words. The principle is as follows: First, predict which sentences contain the answer, segmenting sentences using punctuation marks such as commas, periods, and questions. Then, within the sentences containing the answer, predict the specific position where the answer appears. Finally, based on the specific start and end positions, obtain the answer segment. Its specific structure is as follows: Figure 6 As shown.
[0086] Optionally, in actual execution, the sentence position prediction unit and the word position prediction unit can be arranged and executed in a serial or parallel manner, preferably in a serial manner. The sentence position prediction unit and the word position prediction unit can be implemented using a machine learning model or a neural network model, preferably using a neural network model.
[0087] For example, see Figure 7 As shown, assuming the complete paragraph containing the answer has 15 sentences, then...<s1,s2,s3,……,s15> If the sentences containing the answer are sentences 4 to 7, then sentences 4 to 7 need to be predicted and output based on the sentence position prediction unit.
[0088] In practice, a parameter `max_seq_length` controls the maximum number of characters in a paragraph (this parameter is a built-in parameter of the Roberta model and is generally set between 300 and 700). Another parameter, the maximum number of sentences, is also included, which can be set to 50 in practice. Because the predicted length of sentence positions is much shorter than the predicted length of word positions, it is easier to fit the data.
[0089] Then, the word position prediction unit predicts the specific position of the answer fragment in sentences 4 to 7.
[0090] Optionally, similar to the loss function for word prediction, the loss function for sentence prediction is also the softmax function. The final loss function for the intensive reading portion is:
[0091]
[0092] This module can further improve the F1 score of the above document retrieval model by more than 5%.
[0093] In summary, combining Figure 8 The document retrieval framework diagram shown below illustrates the key points and technical effects of this invention embodiment:
[0094] 1. Optimize pre-trained models based on prompt template learning mechanism to solve the synonym problem in the financial field;
[0095] 2. Optimize the interaction layer model based on the contrastive learning mechanism to solve the problem of inconsistent matching constraints;
[0096] 3. Add a coarse reading module to improve the accuracy of model predictions;
[0097] 4. In the intensive reading module, sentence position prediction and word position prediction units are added to further improve the accuracy of model prediction.
[0098] 5. Through the above optimizations, the results were finally implemented in the research report reading comprehension module, with the accuracy rate increasing from less than 60% to over 85%, and the question-and-answer performance was excellent.
[0099] See Figure 9 The document retrieval device 900 shown specifically includes:
[0100] The receiving module 910 is adapted to receive the query question to be retrieved and determine the target document set as the retrieval scope;
[0101] The recall module 920 is adapted to input the query question into a pre-trained sparse document retrieval model and / or dense document retrieval model, and obtain a list of candidate documents from the document set according to the query question;
[0102] The prediction module 930 is adapted to input the query question and the candidate document list into a pre-trained dual-tower matching model, and obtain the answer fragment corresponding to the query question from the candidate document list;
[0103] The determination module 940 is adapted to determine and return the answer result of the query question based on the answer fragment.
[0104] The above solutions address the challenges of reading comprehension, such as limiting words, synonyms, and reading comprehension frameworks. They employ sparse document retrieval models, dense document retrieval models, or dual-tower matching models for recall and prediction, respectively, thereby improving the accuracy of research report reading comprehension and achieving excellent question-answering results.
[0105] In some embodiments, the pre-training of the sparse document retrieval model or the dense document retrieval model in the recall module 920 includes the following steps:
[0106] Generate prompt templates based on the constituent elements and sentence structure of the question;
[0107] Each component element is expanded using synonyms, and these synonyms are then applied to the prompt template to obtain multiple extended questions.
[0108] Multiple question-answer pairs are formed by combining multiple extended questions and their corresponding answers, thus creating a sample dataset.
[0109] In some embodiments, the pre-training of the dual-tower matching model in the prediction module 930 includes the following steps:
[0110] Construct a negative sample of the problem. The negative sample includes a first limiting word and a query segment. The query segment is the same as, similar to or synonymous with the query segment in the positive sample. The first limiting word is different from the limiting word in the positive sample.
[0111] The dual-tower matching model is trained by comparison using the negative and positive samples.
[0112] In some embodiments, the pre-training of the dual-tower matching model in the prediction module 930 further includes the following steps:
[0113] The negative sample also includes a second qualifier that is the same as, similar to, or synonymous with the qualifier in the positive sample. The first qualifier and the second qualifier are not in the same paragraph or the same sentence.
[0114] In some embodiments, the dual-tower matching model includes a query encoder, a document encoder, and an interaction layer. The interaction layer includes an infrastructure model and a multi-task learning layer. The multi-task learning layer includes a coarse reading module and a fine reading module.
[0115] The skimming module is used to determine whether the current paragraph contains the answer segment, and the fine reading module is used to predict the specific location of the answer segment.
[0116] In some embodiments, the intensive reading module includes a sentence position prediction unit and a word position prediction unit. The sentence position prediction unit is used to predict the sentence containing the answer fragment, and the word position prediction unit is used to predict the specific position of the answer fragment in the sentence containing the answer fragment.
[0117] In some embodiments, the coarse reading module includes a binary classification model, and the coarse reading module and the fine reading module are respectively provided with loss functions, wherein the loss functions of the sentence position prediction unit and the word position prediction unit respectively include the softmax function.
[0118] It should be noted that:
[0119] The algorithms and displays provided herein are not inherently related to any particular computer, virtual device, or other equipment. Various general-purpose devices can also be used in conjunction with the teachings herein. The required structure for constructing such devices is apparent from the above description. Furthermore, this invention is not directed to any particular programming language. It should be understood that the contents of the invention described herein can be implemented using various programming languages, and the above description of specific languages is for the purpose of disclosing the best mode of implementation of the invention.
[0120] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0121] Similarly, it should be understood that, in order to simplify the invention and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof. However, this disclosure should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the following claims, inventive aspects lie in fewer than all features of a single foregoing disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into this detailed description, wherein each claim itself is a separate embodiment of the invention.
[0122] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and further, they can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or device so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.
[0123] Furthermore, those skilled in the art will understand that although some embodiments described herein include certain features but not others included in other embodiments, combinations of features from different embodiments are intended to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments can be used in any combination.
[0124] The various component embodiments of the present invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components in the document retrieval device according to embodiments of the present invention. The present invention can also be implemented as a device or apparatus program (e.g., a computer program and computer program product) for performing part or all of the methods described herein. Such programs implementing the present invention can be stored on a computer-readable medium or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
[0125] This invention provides a non-volatile computer-readable storage medium storing at least one executable instruction that can execute the document retrieval method in any of the above method embodiments.
[0126] Figure 10 The diagram shows a structural schematic of an embodiment of the electronic device of the present invention. The specific embodiments of the present invention do not limit the specific implementation of the electronic device.
[0127] like Figure 10 As shown, the electronic device may include: a processor 1002, a communications interface 1004, a memory 1006, and a communications bus 1008.
[0128] The processor 1002, communication interface 1004, and memory 1006 communicate with each other via communication bus 1008. Communication interface 1004 is used to communicate with other network elements such as clients or other servers. The processor 1002 executes program 1010, specifically performing the relevant steps described in the above-described document retrieval embodiment for electronic devices.
[0129] Specifically, program 1010 may include program code that includes computer operation instructions.
[0130] The processor 1002 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention. The electronic device includes one or more processors, which may be processors of the same type, such as one or more CPUs; or they may be processors of different types, such as one or more CPUs and one or more ASICs.
[0131] Memory 1006 is used to store program 1010. Memory 1006 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0132] Specifically, program 1010 can be used to cause processor 1002 to perform the operations corresponding to the above-described document retrieval embodiments.
[0133] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.
Claims
1. A document retrieval method, the method comprising: Receive the query to be retrieved and determine the target document set as the search scope; The query question is input into a pre-trained sparse document retrieval model and / or dense document retrieval model, and a list of candidate documents is obtained from the document set based on the query question. The query question and the candidate document list are input into a pre-trained dual-tower matching model to obtain the answer fragment corresponding to the query question from the candidate document list. The answer result for the query question is determined and returned based on the answer fragment. The dual-tower matching model includes a query encoder, a document encoder, and an interaction layer. The interaction layer includes an infrastructure model and a multi-task learning layer. The multi-task learning layer includes a rough reading module and a fine reading module. The rough reading module is used to determine whether the current paragraph contains the answer segment, and the fine reading module is used to predict the specific location of the answer segment. The intensive reading module includes a sentence position prediction unit and a word position prediction unit. The sentence position prediction unit is used to predict the sentence containing the answer fragment, and the word position prediction unit is used to predict the specific position of the answer fragment in the sentence containing the answer fragment. The loss functions of the sentence position prediction unit and the word position prediction unit each include a softmax function. The loss function of the intensive reading module is the sum of the loss functions of the sentence position prediction unit and the word position prediction unit. The coarse reading module includes a binary classification model with the following loss function: Where N is the batch size during training, y i It's a tag, y i ' is the predicted probability that an answer exists; The final loss function is the sum of the loss function of the coarse reading module and the loss function of the fine reading module.
2. The method according to claim 1, characterized in that, The pre-training of the sparse document retrieval model or the dense document retrieval model includes the following steps: Generate prompt templates based on the constituent elements and sentence structure of the question; Each component element is expanded using synonyms, and these synonyms are then applied to the prompt template to obtain multiple extended questions. Multiple question-answer pairs are formed by combining multiple extended questions and their corresponding answers, thus creating a sample dataset.
3. The method according to claim 1, characterized in that, The pre-training of the dual-tower matching model includes the following steps: Construct a negative sample of the problem. The negative sample includes a first limiting word and a query segment. The query segment is the same as, similar to or synonymous with the query segment in the positive sample. The first limiting word is different from the limiting word in the positive sample. The dual-tower matching model is trained by comparison using the negative and positive samples.
4. The method according to claim 3, characterized in that, The pre-training of the dual-tower matching model also includes the following steps: The negative sample also includes a second qualifier that is the same as, similar to, or synonymous with the qualifier in the positive sample. The first qualifier and the second qualifier are not in the same paragraph or the same sentence.
5. A document retrieval device, the device comprising: The receiving module is adapted to receive the query to be retrieved and determine the target document set as the retrieval scope; The recall module is adapted to input the query question into a pre-trained sparse document retrieval model and / or dense document retrieval model, and obtain a list of candidate documents from the document set according to the query question; The prediction module is adapted to input the query question and the candidate document list into a pre-trained dual-tower matching model, and obtain the answer fragment corresponding to the query question from the candidate document list; The determining module is adapted to determine and return the answer result of the query question based on the answer fragment; The dual-tower matching model includes a query encoder, a document encoder, and an interaction layer. The interaction layer includes an infrastructure model and a multi-task learning layer. The multi-task learning layer includes a coarse reading module and a fine reading module. The skimming module is used to determine whether the current paragraph contains the answer segment, and the fine reading module is used to predict the specific location of the answer segment. The intensive reading module includes a sentence position prediction unit and a word position prediction unit. The sentence position prediction unit is used to predict the sentence containing the answer fragment, and the word position prediction unit is used to predict the specific position of the answer fragment in the sentence containing the answer fragment. The loss functions of the sentence position prediction unit and the word position prediction unit each include a softmax function, and the loss function of the intensive reading module is the sum of the loss functions of the sentence position prediction unit and the word position prediction unit. The coarse reading module includes a binary classification model with the following loss function: Where N is the batch size during training, y i It's a tag, y i ' is the predicted probability that an answer exists; The final loss function is the sum of the loss function of the coarse reading module and the loss function of the fine reading module.
6. An electronic device, comprising: The processor, memory, communication interface, and communication bus are provided, wherein the processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction, which causes the processor to perform the operation corresponding to the document retrieval method according to any one of claims 1-4.
7. A computer-readable storage medium, wherein, The computer-readable storage medium stores one or more programs, which, when executed by a processor, implement the operations corresponding to the document retrieval method according to any one of claims 1-4.
Citation Information
Patent Citations
Method for generalizing training text corpus in commercial dialogue system
CN111859906A
Multi-modal pre-training model training method, application method and device thereof
CN112990297A
Question and answer processing method and device, computer equipment and storage medium
CN115858748A
Document question and answer method and system, electronic equipment and storage medium
CN115905487A