Method, device, storage medium and electronic device for generating question and answer responses

By introducing self-supervised learning tasks and dynamically updating model parameters in large language models, the problem of poor generalization performance of large language models in professional field applications is solved, and question-answer response generation that is more suitable for professional fields is achieved.

CN120277198BActive Publication Date: 2025-09-23ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510766184.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-10
Publication Date
2025-09-23
Estimated Expiration
2045-06-10

AI Technical Summary

Technical Problem

Large language models have poor generalization performance in professional field applications due to distribution shift and limited professional field data. RAG systems face challenges in adapting to professional fields.

Method used

By predicting the retrieved content during the inference process and dynamically updating the model parameters, the generated question-answer responses are made more consistent with the knowledge and logic of the target domain. The model parameters are optimized using self-supervised learning tasks, including document fragment segmentation, preprocessing, and generation of self-supervised learning signals.

Benefits of technology

The model's generation performance in professional fields is improved, and it can better adapt to problems with distribution shift and limited domain-specific data. The generated question-answer responses are more consistent with the knowledge and logic of the target domain.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120277198B_ABST
    Figure CN120277198B_ABST
Patent Text Reader

Abstract

The embodiments of this specification disclose a method, apparatus, storage medium, and electronic device for generating question-and-answer responses, wherein a target query is input into a target model, so that the target model obtains multiple first document fragments corresponding to the target query by performing an external search on the target query; each first document fragment is divided into prefix content and suffix content, and a first self-supervised learning task is formed based on the prefix content and the suffix content, so that the target model learns based on the first self-supervised learning task; a self-supervised learning signal corresponding to the first document fragment is generated by calculating the prediction loss of the target model for each first document fragment with respect to the first self-supervised learning task; and the model parameters of the target model are dynamically optimized based on the multiple self-supervised learning signals corresponding to the multiple first document fragments, so that the optimized target model outputs a corresponding question-and-answer response based on the target query.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to computer technology, and in particular to a method, device, storage medium, and electronic device for generating question-and-answer responses. Background Art

[0002] With the development of artificial intelligence, large language models (LLMs) have made significant progress in natural language processing tasks. However, their performance is limited in specific field applications due to distribution shift and limited professional domain data.

[0003] The Retrieval-Augmented Generation (RAG) system improves the question-answering capabilities of LLM by integrating external knowledge. However, when adapting the RAG system to professional domains, it still faces challenges due to suboptimal generalization performance caused by distribution shift and limited availability of professional domain data. Summary of the Invention

[0004] The purpose of the embodiments of this specification is to provide a method, device, storage medium, and electronic device for generating question and answer responses.

[0005] The embodiments of this specification provide a method for generating question-and-answer responses. This method dynamically updates model parameters for a target domain in real time by predicting retrieved content during the inference process. This ensures that the generated question-and-answer responses are more consistent with the knowledge and logic of the target domain, thereby improving the model's generation performance in specialized domains and enabling better adaptation to specialized domains. Compared to standard RAG systems, this solution can better address issues such as distribution shift and limited domain-specific data. The method includes:

[0006] Inputting a target query into a target model, so that the target model obtains a plurality of first document fragments corresponding to the target query by performing an external search on the target query;

[0007] Segmenting each first document segment into prefix content and suffix content, forming a first self-supervised learning task based on the prefix content and the suffix content, so that the target model learns based on the first self-supervised learning task;

[0008] Generate a self-supervised learning signal corresponding to each first document segment by calculating the prediction loss of the target model for the first self-supervised learning task;

[0009] Dynamically optimize the model parameters of the target model according to the multiple self-supervised learning signals corresponding to the multiple first document fragments, so that the optimized target model outputs a corresponding question-answer response based on the target query.

[0010] Furthermore, enabling the target model to obtain a plurality of first document fragments corresponding to the target query by performing an external search on the target query includes:

[0011] The target model performs an external search on the target query to obtain a plurality of second document fragments associated with the target query;

[0012] The multiple second document fragments are preprocessed to obtain multiple first document fragments corresponding to the target query.

[0013] Furthermore, the preprocessing of the plurality of second document fragments to obtain a plurality of first document fragments corresponding to the target query includes:

[0014] Perform length filtering on the multiple second document fragments, filter out the second document fragments whose corresponding length is greater than or equal to the first preset threshold and / or the second document fragments whose corresponding length is less than or equal to the second preset threshold, and use the remaining second document fragments as the multiple first document fragments corresponding to the target query.

[0015] Furthermore, the preprocessing of the plurality of second document fragments to obtain a plurality of first document fragments corresponding to the target query includes:

[0016] The multiple second document fragments are intelligently segmented, and the multiple sub-document fragments obtained by segmentation are used as the multiple first document fragments corresponding to the target query, wherein the number of the multiple sub-document fragments is greater than or equal to a preset number threshold.

[0017] Furthermore, the dynamically optimizing the model parameters of the target model according to the multiple self-supervised learning signals corresponding to the multiple first document fragments includes:

[0018] Dividing the plurality of self-supervised learning signals corresponding to the plurality of first document segments into a plurality of sets;

[0019] Obtain one set from the multiple sets, and dynamically optimize the current model parameters of the target model based on the self-supervised learning signals in the one set; if there is at least one set in the multiple sets that does not participate in the optimization, obtain another set from the at least one set, and continue to dynamically optimize the latest model parameters of the target model based on the self-supervised learning signals in the another set, and so on, until all the multiple sets have participated in the optimization.

[0020] Furthermore, the method further comprises:

[0021] Forming at least one second self-supervised learning task based on each first document segment, so that the target model learns based on the at least one second self-supervised learning task, wherein the second self-supervised learning task includes a sentence relationship judgment task and / or an entity recognition task;

[0022] The step of calculating the prediction loss of the target model for each first document segment with respect to the first self-supervised learning task to generate a self-supervised learning signal corresponding to the first document segment includes:

[0023] By calculating the first prediction loss of the target model for each first document segment with respect to the first self-supervised learning task and the second prediction loss with respect to the at least one second self-supervised learning task, a self-supervised learning signal corresponding to the first document segment is generated.

[0024] Furthermore, the method further comprises:

[0025] Dynamically adjust the task weights corresponding to the first self-supervised learning task and the at least one second self-supervised learning task according to the performance data of the target model on the first self-supervised learning task and the at least one second self-supervised learning task.

[0026] The embodiments of this specification also provide a device for generating a question-and-answer response, including:

[0027] A retrieval module, configured to input a target query into a target model, so that the target model obtains a plurality of first document fragments corresponding to the target query by performing an external search on the target query;

[0028] A self-supervised learning task module, configured to segment each first document segment into prefix content and suffix content, form a first self-supervised learning task based on the prefix content and the suffix content, and enable the target model to learn based on the first self-supervised learning task;

[0029] A self-supervised learning signal generation module is configured to generate a self-supervised learning signal corresponding to each first document segment by calculating the prediction loss of the target model for the suffix content in the first document segment;

[0030] A model output module is used to dynamically optimize the model parameters of the target model based on multiple self-supervised learning signals corresponding to the multiple first document fragments, so that the optimized target model outputs a corresponding question-answer response based on the target query.

[0031] An embodiment of this specification further provides a storage medium, wherein the storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the steps of the above method.

[0032] An embodiment of this specification further provides an electronic device, comprising: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the steps of the above method.

[0033] An embodiment of this specification also provides a computer program product having at least one instruction stored thereon, wherein the at least one instruction implements the steps of the above method when executed by a processor.

[0034] According to the scheme of the embodiment of this specification, a target query is input into a target model, so that the target model obtains multiple first document fragments corresponding to the target query by performing external retrieval on the target query; each first document fragment is divided into prefix content and suffix content, and a first self-supervised learning task is formed according to the prefix content and the suffix content, so that the target model learns based on the first self-supervised learning task; a self-supervised learning signal corresponding to the first document fragment is generated by calculating the prediction loss of the target model for each first document fragment with respect to the first self-supervised learning task; the model parameters of the target model are dynamically optimized according to the multiple self-supervised learning signals corresponding to the multiple first document fragments, so that the optimized target model outputs corresponding question-answer responses based on the target query, thereby realizing real-time dynamic updating of the model parameters of the target domain by predicting the retrieved content during the reasoning process, so that the generated question-answer responses are more in line with the knowledge and logic of the target domain, thereby improving the generation performance of the model in professional domains and being able to better adapt to professional domains. Compared with the standard RAG system, this scheme can better deal with the problems of distribution offset and limited domain-specific data. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 A flowchart of a method for generating a question-and-answer response provided in an embodiment of this specification;

[0036] Figure 2 A schematic diagram of a process for generating a question-and-answer response according to an example provided in an embodiment of this specification;

[0037] Figure 3 A schematic diagram of the structure of a device for generating question-and-answer responses provided in an embodiment of this specification;

[0038] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this specification. DETAILED DESCRIPTION

[0039] To make the objectives, technical solutions, and advantages of this specification more clear, the following will clearly and completely describe the technical solutions of this specification in conjunction with the specific embodiments of this specification and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without making any creative efforts are within the scope of protection of this specification.

[0040] See Figure 1 , is a flow chart of a method for generating a question and answer response provided in an embodiment of this specification. In this embodiment of this specification, the method for generating a question and answer response is applied to the apparatus for generating a question and answer response (hereinafter referred to as "the question and answer response generating apparatus") or an electronic device equipped with the question and answer response generating apparatus described in this embodiment. Figure 1 The process shown in FIG. 1 is described in detail. The method for generating a question-and-answer response may specifically include the following steps:

[0041] S102: Input a target query into a target model, so that the target model obtains a plurality of first document fragments corresponding to the target query by performing an external search on the target query.

[0042] In some embodiments, the target model refers to a large language model, which refers to a deep learning model trained using a large amount of text data, so that the model can generate natural language text or understand the meaning of language text. In some embodiments, the target query input to the target model refers to the instruction or question input by the user to the target large model, and the target large model will generate a corresponding question-and-answer response after performing corresponding processing based on the target query. In some embodiments, the target query may include only text content, or the target query may also include but is not limited to image content, audio content, video content, icon content, and other forms of content in addition to text content. This example embodiment does not specifically limit this.

[0043] In some embodiments, the target model includes a RAG (Retrieval-Augmented Generation) system. The RAG system improves the question-answering capabilities of the large language model by integrating external knowledge sources, enabling the large language model to access and utilize external knowledge during the generation process, thereby compensating for the limitations of the static parameterized knowledge of the large language model. In some embodiments, the RAG system performs an external search on the target query input into the target model using an external knowledge source, and obtains multiple first document fragments corresponding to the target query based on the search results. For example, a preset number of document fragments with the highest correlation with the target query in the search results can be used as the multiple first document fragments corresponding to the target query, or a preset number of document fragments that have been recently published in the search results can be used as the multiple first document fragments corresponding to the target query. This example embodiment does not specifically limit the specific method of obtaining multiple first document fragments based on the search results.

[0044] In some embodiments, external search can include only text retrieval, or it can include multimodal retrieval (such as images and charts) in addition to text retrieval to enrich the types of information retrieved, allowing the target model to utilize knowledge from more diverse dimensions. In some embodiments, the external knowledge source used for external search can be a static data source or a real-time data source to ensure that the target model obtains the latest information, especially in professional fields such as finance and news where timeliness is a high priority.

[0045] S104: Segment each first document segment into prefix content and suffix content, and form a first self-supervised learning task according to the prefix content and the suffix content, so that the target model learns based on the first self-supervised learning task.

[0046] In some embodiments, each first document fragment is divided into prefix content and suffix content, and the union of the prefix content and the suffix content is the first document fragment. In some embodiments, the specific segmentation method can be random segmentation, which only needs to ensure that the prefix content and the suffix content are semantically complete. Alternatively, it can be preset punctuation segmentation, for example, segmentation is performed at a preset punctuation mark (for example, a period or a comma) in the first document fragment, so that the absolute value of the difference between the number of words in the prefix content and the number of words in the suffix content is less than a preset threshold. It should be noted that the above segmentation method is only an example and not a limitation. Those skilled in the art should understand that any method of segmenting document fragments can be included in the scope of protection of this specification. This example embodiment does not specifically limit the specific method of segmenting document fragments.

[0047] In some embodiments, a first self-supervised learning task is formed based on the prefix content and suffix content obtained after segmenting each first document fragment. The first self-supervised learning task is used to predict the suffix content based on the prefix content. That is, the first self-supervised learning task is a prefix-suffix pair prediction task. The target model performs self-supervised learning on the prefix content and suffix content corresponding to multiple first document fragments based on the first self-supervised learning task, so that the target model can predict the suffix content based on the prefix content. In some embodiments, self-supervised learning is a learning method that does not require manually labeled data. It generates "pseudo-labels" or "auxiliary tasks" by leveraging the structure of the data itself and uses these generated labels to train the model.

[0048] S106 , generating a self-supervised learning signal corresponding to each first document segment by calculating the prediction loss of the target model for the first self-supervised learning task.

[0049] In some embodiments, after the target model completes self-supervised learning based on the first self-supervised learning task, a self-supervised learning signal corresponding to each first document fragment is generated by calculating the prediction loss of the target model for the first self-supervised learning task. Specifically, for each first document fragment, a self-supervised learning signal corresponding to the first document fragment is generated by calculating the loss between the predicted suffix content predicted by the target model based on the prefix content of the first document fragment and the actual suffix content of the first document fragment. A self-supervised learning signal refers to a clear target or label used to guide model learning. The self-supervised learning signal guides the target model to learn, and during the learning process, the target model dynamically optimizes (or dynamically adjusts) the model parameters. This solution introduces a self-supervised learning task, uses the retrieved document fragments as supervisory signals, and generates a learning signal through the prefix-suffix pair prediction task for the target model to optimize the model parameters.

[0050] S108, dynamically optimizing the model parameters of the target model according to the multiple self-supervised learning signals corresponding to the multiple first document fragments, so that the optimized target model outputs a corresponding question-answer response based on the target query.

[0051] In some embodiments, the model parameters of the target model are dynamically optimized (or dynamically adjusted) based on the multiple self-supervised learning signals corresponding to the multiple first document fragments, so that the model parameters of the target model adapt to the target domain corresponding to the target query, thereby achieving dynamic adjustment of the model parameters without the need for a large amount of labeled data, and being able to adapt to complex professional fields more flexibly. For example, the gradient descent method can be used to optimize the model parameters of the target model to maintain computational efficiency. It should be noted that the above-mentioned method of optimizing the model parameters is only an example and not a limitation. Those skilled in the art should understand that any method of optimizing the model parameters based on the self-supervised learning signal can be included in the scope of protection of this specification, and this example embodiment does not specifically limit the specific method of optimizing the model parameters.

[0052] In some embodiments, the target model after optimizing the model parameters generates and outputs a final question-and-answer response based on the target query input into the target model. Through the optimized model parameters, the generated question-and-answer response is more consistent with the knowledge and logic of the target domain corresponding to the target query.

[0053] According to the scheme of the embodiment of this specification, a target query is input into a target model, so that the target model obtains multiple first document fragments corresponding to the target query by performing external retrieval on the target query; each first document fragment is divided into prefix content and suffix content, and a first self-supervised learning task is formed according to the prefix content and the suffix content, so that the target model learns based on the first self-supervised learning task; a self-supervised learning signal corresponding to the first document fragment is generated by calculating the prediction loss of the target model for each first document fragment with respect to the first self-supervised learning task; the model parameters of the target model are dynamically optimized according to the multiple self-supervised learning signals corresponding to the multiple first document fragments, so that the optimized target model outputs corresponding question-answer responses based on the target query, thereby realizing real-time dynamic updating of the model parameters of the target domain by predicting the retrieved content during the reasoning process, so that the generated question-answer responses are more in line with the knowledge and logic of the target domain, thereby improving the generation performance of the model in professional domains and being able to better adapt to professional domains. Compared with the standard RAG system, this scheme can better deal with the problems of distribution offset and limited domain-specific data.

[0054] In some embodiments, enabling the target model to obtain multiple first document fragments corresponding to the target query by performing an external search on the target query includes: enabling the target model to obtain multiple second document fragments associated with the target query by performing an external search on the target query; and preprocessing the multiple second document fragments to obtain multiple first document fragments corresponding to the target query. In some embodiments, the RAG system performs external retrieval on the target query input to the target model by using an external knowledge source, retrieves multiple second document fragments associated with the target query, and then obtains multiple first document fragments corresponding to the target query by preprocessing the multiple second document fragments, wherein the preprocessing includes but is not limited to text cleaning (removing noise and unstructured content to ensure that the document fragments input to the target model are clear), chunking and truncation (cutting long document fragments into short document fragments suitable for target model input), information enhancement (supplementing contextual information to help the target model better understand the content of the document fragment), relevance filtering (retaining the document fragments most relevant to the target query and reducing noise), compression and summarization (streamlining the content of the document fragment and retaining the core information), embedding optimization (ensuring that the embedding of the document fragment is aligned with the semantic space of the target model), adversarial content filtering (preventing malicious or misleading content in the document fragment from affecting the generated results), etc. This example embodiment does not specifically limit the specific method of preprocessing.

[0055] In some embodiments, the preprocessing of the multiple second document fragments to obtain the multiple first document fragments corresponding to the target query includes: performing length filtering on the multiple second document fragments, filtering out the second document fragments whose corresponding length is greater than or equal to the first preset threshold and / or the second document fragments whose corresponding length is less than or equal to the second preset threshold from the multiple second document fragments, and using the remaining second document fragments as the multiple first document fragments corresponding to the target query. In some embodiments, because document fragments that are too long or too short may cause the effect of the target model to decline (such as information redundancy or insufficient information), after retrieving the multiple second document fragments associated with the target query, it is necessary to filter out the second document fragments whose corresponding length is greater than or equal to the first preset threshold and / or the second document fragments whose corresponding length is less than or equal to the second preset threshold from the multiple second document fragments, and use the second document fragments remaining after filtering as the multiple first document fragments corresponding to the target query.

[0056] In some embodiments, the preprocessing of the multiple second document fragments to obtain the multiple first document fragments corresponding to the target query includes: intelligently segmenting the multiple second document fragments, and using the multiple sub-document fragments obtained by segmentation as the multiple first document fragments corresponding to the target query, wherein the number of the multiple sub-document fragments is greater than or equal to a preset number threshold. In some embodiments, in order to ensure that the first self-supervised learning task has enough document fragments for self-supervised learning, after retrieving the multiple second document fragments associated with the target query, it is necessary to intelligently segment the multiple second document fragments to obtain multiple sub-document fragments, so that the number of the multiple sub-document fragments is greater than or equal to the preset number threshold, and then use the multiple sub-document fragments as the multiple first document fragments corresponding to the target query. In some embodiments, each sub-document fragment obtained by segmentation needs to ensure the semantic integrity within the sub-document fragment. In some embodiments, the length of each sub-document fragment obtained by segmentation is less than or equal to the first preset length threshold, or, on this basis, it is also necessary to meet the requirement that the length of each sub-document fragment is greater than or equal to the second preset length threshold. In some embodiments, the core goals of intelligent segmentation include but are not limited to semantic integrity (ensuring that each sub-document fragment contains complete meaning units (such as paragraphs, topics, etc.), avoiding the destruction of logical chains or key information due to segmentation), contextual coherence (maintaining the inherent logical structure of each sub-document fragment (such as cause and effect, comparison, temporal relationship, etc.), avoiding incorrect reasoning of the target model due to context breaks), computational efficiency optimization (balancing semantic quality and computational overhead, avoiding the impact of overly complex segmentation strategies on system real-time performance), etc. This example embodiment does not make special limitations on this.

[0057] In some embodiments, the dynamic optimization of the model parameters of the target model based on the multiple self-supervised learning signals corresponding to the multiple first document fragments includes: dividing the multiple self-supervised learning signals corresponding to the multiple first document fragments into multiple sets; obtaining one set from the multiple sets, and dynamically optimizing the current model parameters of the target model based on the self-supervised learning signals in the set; if there is at least one set in the multiple sets that does not participate in the optimization, obtaining another set from the at least one set, and continuing to dynamically optimize the latest model parameters of the target model based on the self-supervised learning signals in the another set, and so on, until all the sets have participated in the optimization. In some embodiments, the multiple self-supervised learning signals corresponding to the multiple first document fragments are divided into multiple sets, each set including several self-supervised learning signals, the union of the multiple sets is the multiple self-supervised learning signals, and each of the multiple self-supervised learning signals is located only in one of the multiple sets. It should be noted that this example embodiment does not impose any special restrictions on the number of groups of the multiple sets and the number of self-supervised learning signals in each set. In some embodiments, a set of sets is obtained from multiple sets (for example, randomly obtained), and the current model parameters of the target model are dynamically optimized based on the self-supervised learning signal in the set of sets. After the optimization is completed, it is determined whether there is at least one set in the multiple sets that does not participate in the optimization. If not, the optimization is terminated. If so, another set of sets is obtained from at least one set that does not participate in the optimization (for example, randomly obtained), and the latest model parameters of the target model are continuously dynamically optimized based on the self-supervised learning signal in the another set of sets, and so on, until all the multiple sets have participated in the optimization, thereby avoiding excessive jitter through the group optimization method. In some embodiments, in the process of dynamically optimizing the latest model parameters of the target model using the self-supervised learning signal in each set, an AdamW (Adam with Decoupled Weight Decay) optimizer is used to accumulate gradients and perform clipping to ensure training stability. The AdamW optimizer is an optimization algorithm for deep learning model training. It is a variant of the Adam (Adaptive Moment Estimation) optimizer. It should be noted that the above-mentioned method of optimizing model parameters is only an example and not a limitation. Those skilled in the art should understand that the method of optimizing model parameters using any optimizer can be included in the scope of protection of this specification. This example embodiment does not specifically limit the specific type of optimizer.

[0058] In some embodiments, the method further includes: forming at least one second self-supervised learning task based on each first document segment, so that the target model learns based on the at least one second self-supervised learning task, wherein the second self-supervised learning task includes a sentence relationship judgment task and / or an entity recognition task; wherein the generating a self-supervised learning signal corresponding to the first document segment by calculating the prediction loss of the target model for each first document segment with respect to the first self-supervised learning task includes: generating a self-supervised learning signal corresponding to the first document segment by calculating the first prediction loss of the target model for each first document segment with respect to the first self-supervised learning task and the second prediction loss with respect to the at least one second self-supervised learning task. In some embodiments, in addition to the first self-supervised learning task for predicting suffix content based on prefix content, other self-supervised learning tasks (such as sentence relationship judgment, entity recognition, etc.) may be introduced to enhance the target model's ability to understand text. It should be noted that the above self-supervised learning tasks are merely examples, and this example embodiment does not specifically limit the number or type of self-supervised learning tasks. In some embodiments, at least one second self-supervised learning task is formed based on each first document fragment, and the second self-supervised learning task includes a sentence relationship judgment task and / or an entity recognition task. Then, in addition to learning based on the first self-supervised learning task, the target model also learns based on the at least one second self-supervised learning task. Then, by calculating the first prediction loss of the target model for each first document fragment with respect to the first self-supervised learning task and the second prediction loss with respect to the at least one second self-supervised learning task, a self-supervised learning signal corresponding to the first document fragment is generated, wherein the first prediction loss refers to the loss between the prediction result of the target model for the first self-supervised learning task and the true value, and the second prediction loss refers to the loss between the prediction result of the target model for the second self-supervised learning task and the true value. The corresponding self-supervised learning signal can be generated by adding the first prediction loss to the second prediction loss corresponding to each second self-supervised learning task, or by adding the product of the first prediction loss and the task weight of the first self-supervised learning task to the product of the second prediction loss corresponding to each second self-supervised learning task and the task weight of the second self-supervised learning task.

[0059] In some embodiments, the method further includes: dynamically adjusting the task weights corresponding to the first self-supervised learning task and the at least one second self-supervised learning task, respectively, based on the performance data of the target model on the first self-supervised learning task and the at least one second self-supervised learning task. In some embodiments, the task weights of the first self-supervised learning task and at least one of the at least one second self-supervised learning task are dynamically adjusted based on the performance data of the target model on the first self-supervised learning task and each of the at least one second self-supervised learning tasks, so that when the target model subsequently receives a new query with a new input, the target model performs corresponding self-supervised learning based on the adjusted task weights to optimize the overall learning effect, wherein the performance data includes but is not limited to at least one of accuracy, precision, recall, F1 score (the harmonic mean of precision and recall, used to balance the relationship between the two), normalized cumulative loss gain, and the like, which is not specifically limited in this example embodiment.

[0060] Figure 2 A flowchart of an example for generating a question-and-answer response is provided in an embodiment of this specification.

[0061] like Figure 2 As shown in the figure, the query q is input into the model, and the model obtains the corresponding document fragment by searching the database. The retrieved document fragment is preprocessed to obtain the target document fragment corresponding to the query q, and each target document fragment is divided into prefix and suffix pairs to form a self-supervised learning task, so that the model can predict the suffix content based on the prefix content. The self-supervisory signal is generated by calculating the prediction loss of the model for the suffix content. The model dynamically adjusts the model parameters according to the self-supervisory information (i.e., model parameter adaptation). Finally, the model after adjusting the model parameters generates the corresponding question-answer response based on the query q and outputs it.

[0062] Figure 3 This is a schematic diagram of the structure of a device for generating question-and-answer responses, provided in an embodiment of this specification. This device for generating question-and-answer responses (hereinafter referred to as "question-and-answer response generating device 1") can be implemented as all or part of an electronic device through software, hardware, or a combination of both. According to some embodiments, this question-and-answer response generating device 1 includes a retrieval module 11, a self-supervised learning task module 12, a self-supervised learning signal generation module 13, and a model output module 14.

[0063] A retrieval module 11 is configured to input a target query into a target model, so that the target model performs an external search on the target query to obtain a plurality of first document fragments corresponding to the target query;

[0064] A self-supervised learning task module 12 is configured to segment each first document segment into prefix content and suffix content, form a first self-supervised learning task based on the prefix content and the suffix content, and enable the target model to learn based on the first self-supervised learning task;

[0065] A self-supervised learning signal generating module 13 is configured to generate a self-supervised learning signal corresponding to each first document segment by calculating the prediction loss of the target model for the suffix content in the first document segment;

[0066] The model output module 14 is used to dynamically optimize the model parameters of the target model based on the multiple self-supervised learning signals corresponding to the multiple first document fragments, so that the optimized target model outputs the corresponding question-answer response based on the target query.

[0067] In some embodiments, enabling the target model to obtain multiple first document fragments corresponding to the target query by performing an external search on the target query includes: enabling the target model to obtain multiple second document fragments associated with the target query by performing an external search on the target query; and preprocessing the multiple second document fragments to obtain multiple first document fragments corresponding to the target query.

[0068] In some embodiments, the preprocessing of the multiple second document fragments to obtain the multiple first document fragments corresponding to the target query includes: performing length filtering on the multiple second document fragments, filtering out the second document fragments whose corresponding length is greater than or equal to a first preset threshold and / or the second document fragments whose corresponding length is less than or equal to a second preset threshold in the multiple second document fragments, and using the remaining second document fragments as the multiple first document fragments corresponding to the target query.

[0069] In some embodiments, the preprocessing of the multiple second document fragments to obtain the multiple first document fragments corresponding to the target query includes: intelligently segmenting the multiple second document fragments, and using the multiple sub-document fragments obtained by segmentation as the multiple first document fragments corresponding to the target query, wherein the number of the multiple sub-document fragments is greater than or equal to a preset number threshold.

[0070] In some embodiments, the dynamic optimization of the model parameters of the target model based on the multiple self-supervised learning signals corresponding to the multiple first document fragments includes: dividing the multiple self-supervised learning signals corresponding to the multiple first document fragments into multiple groups of sets; obtaining one group of sets from the multiple groups of sets, and dynamically optimizing the current model parameters of the target model based on the self-supervised learning signals in the one group of sets; if there is at least one group of sets that does not participate in the optimization among the multiple groups of sets, obtaining another group of sets from the at least one group of sets, and continuing to dynamically optimize the latest model parameters of the target model based on the self-supervised learning signals in the another group of sets, and so on, until all the multiple groups of sets have participated in the optimization.

[0071] In some embodiments, the question-and-answer response generation device 1 is also used to: form at least one second self-supervised learning task based on each first document fragment, so that the target model learns based on the at least one second self-supervised learning task, wherein the second self-supervised learning task includes a sentence relationship judgment task and / or an entity recognition task; wherein, the self-supervised learning signal corresponding to the first document fragment is generated by calculating the prediction loss of the target model for each first document fragment with respect to the first self-supervised learning task, including: generating the self-supervised learning signal corresponding to the first document fragment by calculating the first prediction loss of the target model for each first document fragment with respect to the first self-supervised learning task and the second prediction loss with respect to the at least one second self-supervised learning task.

[0072] In some embodiments, the question and answer response generation device 1 is also used to dynamically adjust the task weights corresponding to the first self-supervised learning task and the at least one second self-supervised learning task based on the performance data of the target model on the first self-supervised learning task and the at least one second self-supervised learning task.

[0073] The above device embodiments correspond to the aforementioned method embodiments. For detailed descriptions, please refer to the description of the method embodiments, which will not be repeated here. The device embodiments are obtained based on the corresponding method embodiments and have the same technical effects as the corresponding method embodiments. For detailed descriptions, please refer to the corresponding method embodiments.

[0074] The embodiments of this specification also provide a computer storage medium, which can store multiple instructions, and the instructions are suitable for being loaded by a processor and executing the method of the embodiments of this specification.

[0075] An embodiment of the present specification further provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded by the processor to execute the method of the embodiment of the present specification.

[0076] The embodiments of this specification also provide Figure 4 The structural diagram of the electronic device shown in FIG. Figure 4 At the hardware level, the electronic device includes a processor, an internal bus, a network interface, memory, and non-volatile storage, and may also include other hardware required for its operations. The processor reads the corresponding computer program from the non-volatile storage into the memory and then runs it to implement the above method.

[0077] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0078] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Thus, this specification may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0079] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0080] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0081] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.

[0082] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0083] This specification may be described in the general context of computer-executable instructions, such as program modules, executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media, including storage devices.

[0084] The various embodiments in this specification are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiments are generally similar to the method embodiments, so the description is relatively simple. For relevant parts, refer to the description of the method embodiments.

[0085] The foregoing is merely an example of the present invention and is not intended to limit the present invention. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be included within the scope of the claims of the present invention.

Claims

1. A method for generating a question-and-answer response, comprising: Inputting a target query into a target model, so that the target model obtains a plurality of first document fragments corresponding to the target query by performing an external search on the target query; Segmenting each first document segment into prefix content and suffix content, forming a first self-supervised learning task based on the prefix content and the suffix content, so that the target model learns based on the first self-supervised learning task; Generate a self-supervised learning signal corresponding to each first document segment by calculating the prediction loss of the target model for the first self-supervised learning task; Dynamically optimize the model parameters of the target model according to the multiple self-supervised learning signals corresponding to the multiple first document fragments, so that the optimized target model outputs a corresponding question-answer response based on the target query.

2. The method according to claim 1, wherein causing the target model to obtain a plurality of first document fragments corresponding to the target query by performing an external search on the target query comprises: The target model performs an external search on the target query to obtain a plurality of second document fragments associated with the target query; The multiple second document fragments are preprocessed to obtain multiple first document fragments corresponding to the target query.

3. The method according to claim 2, wherein preprocessing the plurality of second document fragments to obtain the plurality of first document fragments corresponding to the target query comprises: Perform length filtering on the multiple second document fragments, filter out the second document fragments whose corresponding length is greater than or equal to the first preset threshold and / or the second document fragments whose corresponding length is less than or equal to the second preset threshold, and use the remaining second document fragments as the multiple first document fragments corresponding to the target query.

4. The method according to claim 2, wherein preprocessing the plurality of second document fragments to obtain the plurality of first document fragments corresponding to the target query comprises: The multiple second document fragments are intelligently segmented, and the multiple sub-document fragments obtained by segmentation are used as the multiple first document fragments corresponding to the target query, wherein the number of the multiple sub-document fragments is greater than or equal to a preset number threshold.

5. The method according to claim 1, wherein the dynamically optimizing the model parameters of the target model according to the plurality of self-supervised learning signals corresponding to the plurality of first document segments comprises: Dividing the plurality of self-supervised learning signals corresponding to the plurality of first document segments into a plurality of sets; Obtain one set from the multiple sets, and dynamically optimize the current model parameters of the target model based on the self-supervised learning signals in the one set; if there is at least one set in the multiple sets that does not participate in the optimization, obtain another set from the at least one set, and continue to dynamically optimize the latest model parameters of the target model based on the self-supervised learning signals in the another set, and so on, until all the multiple sets have participated in the optimization.

6. The method according to claim 1, further comprising: Forming at least one second self-supervised learning task based on each first document segment, so that the target model learns based on the at least one second self-supervised learning task, wherein the second self-supervised learning task includes a sentence relationship judgment task and / or an entity recognition task; The step of calculating the prediction loss of the target model for each first document segment with respect to the first self-supervised learning task to generate a self-supervised learning signal corresponding to the first document segment includes: By calculating the first prediction loss of the target model for each first document segment with respect to the first self-supervised learning task and the second prediction loss with respect to the at least one second self-supervised learning task, a self-supervised learning signal corresponding to the first document segment is generated.

7. The method according to claim 6, further comprising: Dynamically adjust the task weights corresponding to the first self-supervised learning task and the at least one second self-supervised learning task according to the performance data of the target model on the first self-supervised learning task and the at least one second self-supervised learning task.

8. An apparatus for generating a question-and-answer response, comprising: A retrieval module, configured to input a target query into a target model, so that the target model obtains a plurality of first document fragments corresponding to the target query by performing an external search on the target query; A self-supervised learning task module, configured to segment each first document segment into prefix content and suffix content, form a first self-supervised learning task based on the prefix content and the suffix content, and enable the target model to learn based on the first self-supervised learning task; A self-supervised learning signal generation module is configured to generate a self-supervised learning signal corresponding to each first document segment by calculating the prediction loss of the target model for the suffix content in the first document segment; A model output module is used to dynamically optimize the model parameters of the target model based on multiple self-supervised learning signals corresponding to the multiple first document fragments, so that the optimized target model outputs a corresponding question-answer response based on the target query.

9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

10. An electronic device, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the steps of the method according to any one of claims 1 to 7.

11. A computer program product having at least one instruction stored thereon, characterized in that: When the at least one instruction is executed by the processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Question response method and device based on large language model

    CN117235226A

  • Method for question-answering based on asr

    KR102552401B1