Answer generation method and device, equipment and storage medium

By predicting the target answer type in a large language model and generating the answer using compression instructions, the problems of redundant encoding and poor generalization ability are solved, achieving a more efficient and flexible retrieval enhancement generation task.

CN122072644APending Publication Date: 2026-05-22TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TENCENT TECHNOLOGY (SHENZHEN) CO LTD
Filing Date
2024-11-20
Publication Date
2026-05-22

Smart Images

  • Figure CN122072644A_ABST
    Figure CN122072644A_ABST
Patent Text Reader

Abstract

The application relates to the field of natural language processing, and provides an answer generation method and device, equipment and a storage medium. The method comprises the following steps: obtaining a question to be answered and at least one reference document associated with the question to be answered; each reference document records content information related to the question to be answered; based on the question to be answered and the at least one reference document, a target answer type corresponding to the question to be answered is predicted from among a plurality of preset answer types; based on a mapping relationship between a preset answer type and a compression instruction, a target compression instruction corresponding to the target answer type is obtained; and according to an answer generation rule indicated in the target compression instruction, the question to be answered and the at least one reference document are combined to generate an answer corresponding to the question to be answered. Through the above method, the redundancy coding overhead can be reduced, and the generalization ability of a retrieval enhancement generation task can be enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of natural language processing technology, and provides a method, apparatus, device and storage medium for generating answers. Background Technology

[0002] When performing search enhancement generation tasks, the process usually begins by searching the web for content related to the question posed by the search target, obtaining various reference documents associated with the question, and then organizing the content of each reference document to generate an answer with the source of the answer.

[0003] In related technologies, large language models (such as GPT) are typically trained by designing instruction description templates. This allows the large language model to effectively combine retrieved reference documents and the question to be answered according to the answer generation rules in the instruction description, thereby directly completing the retrieval enhancement generation task. The instruction description is a textual prompt written in natural language to describe the answer generation rules.

[0004] However, large language models typically use fixed instruction description templates to perform the same type of retrieval augmentation generation tasks. In other words, for each question to be answered, the large language model needs to concatenate and encode the fixed instruction description template with the question to be answered and the retrieved reference documents. This results in these fixed instruction description templates being repeatedly encoded when the large language model is applied to a retrieval augmentation generation task with extremely high traffic, leading to significant redundant encoding overhead and even increasing the response latency of the retrieval augmentation generation task.

[0005] Furthermore, since the current set of instruction description templates is limited and the large language model is trained directly using these templates, if a retrieval requirement arises that the current templates cannot meet, the large language model needs to be retrained after designing new templates. This incurs additional training costs and time overhead. Therefore, it is evident that current methods using large language models to perform retrieval augmentation generation tasks suffer from poor generalization ability. Summary of the Invention

[0006] This application provides an answer generation method, apparatus, device, and storage medium to address the problems of high redundant coding overhead and poor generalization ability in current retrieval enhancement generation tasks.

[0007] Firstly, embodiments of this application provide an answer generation method, including:

[0008] Obtain the question to be answered, and at least one reference document associated with the question to be answered; each reference document records content information related to the question to be answered;

[0009] Based on the question to be answered and the at least one reference document, predict the target answer type corresponding to the question to be answered from among a plurality of preset answer types;

[0010] Based on the preset mapping relationship between answer types and compression instructions, the target compression instruction corresponding to the target answer type is obtained; each compression instruction is obtained by pre-compressing and encoding the instruction description content of the corresponding answer type, and is used to indicate the answer generation rules of the corresponding answer type;

[0011] According to the answer generation rules indicated in the target compression instruction, the question to be answered and the at least one reference document are combined to generate the answer corresponding to the question to be answered.

[0012] Secondly, embodiments of this application also provide an answer generation apparatus, including:

[0013] A communication unit is used to acquire a question to be answered and at least one reference document associated with the question to be answered; each reference document records content information related to the question to be answered.

[0014] The answer type prediction unit is used to predict the target answer type corresponding to the question to be answered from among a plurality of preset answer types, based on the question to be answered and the at least one reference document.

[0015] The answer generation unit is used to obtain the target compression instruction corresponding to the target answer type based on the preset mapping relationship between answer types and compression instructions; each compression instruction is obtained by pre-compressing and encoding the instruction description content of the corresponding answer type, and is used to indicate the answer generation rules of the corresponding answer type; according to the answer generation rules indicated in the target compression instruction, the question to be answered and the at least one reference document are combined to generate the answer corresponding to the question to be answered.

[0016] In one possible implementation, at least one reference document associated with the question to be answered is retrieved by a document retrieval unit. Specifically, the document retrieval unit is configured to: perform word segmentation on the question to be answered to obtain multiple first words included in the question; and for a set of multiple candidate documents, perform the following operations respectively: based on the matching degree between a candidate document and the multiple first words, obtain the similarity between the candidate document and the question to be answered; and among the multiple candidate documents, based on the obtained similarities, select at least one candidate document that meets the preset document filtering conditions as a reference document.

[0017] In one possible implementation, the answer type prediction unit, based on the question to be answered and the at least one reference document, predicts the target answer type corresponding to the question to be answered from among a preset plurality of answer types. Specifically, it performs the following operations for each of the plurality of answer types: based on the semantic information of the question to be answered, obtains a first probability that the answer type is the target answer type corresponding to the question to be answered; based on the semantic information of each of the at least one reference document, obtains a second probability that the answer type is the target answer type corresponding to the at least one reference document; based on the first probability and the second probability, obtains a target probability that the answer type is the target answer type corresponding to the question to be answered; and selects the answer type among the plurality of answer types whose target probability satisfies a preset probability condition as the target answer type.

[0018] In one possible implementation, the answer type prediction unit obtains a first probability that the answer type is the target answer type corresponding to the question to be answered, based on the semantic information of the question to be answered. Specifically, it is used to: perform word segmentation on the question to be answered to obtain multiple first words included in the question to be answered; encode the multiple first words respectively based on their respective arrangement positions and context information in the question to be answered to obtain a first embedding vector corresponding to the question to be answered; the first embedding vector represents the contextual relationship between the multiple first words; and obtain a first probability that the answer type is the target answer type corresponding to the question to be answered based on the contextual relationship represented in the first embedding vector.

[0019] In one possible implementation, the answer type prediction unit obtains a second probability that the answer type is the target answer type corresponding to the at least one reference document based on the semantic information of each of the at least one reference document. Specifically, this involves: performing word segmentation on each of the reference documents to obtain multiple second words included in each reference document; encoding the multiple second words based on their respective arrangement positions and context information in the at least one reference document to obtain a second embedding vector corresponding to each of the at least one reference document; each second embedding vector representing the contextual relationship between the multiple second words included in the corresponding reference document; and obtaining a second probability that the answer type is the target answer type corresponding to the at least one reference document based on the contextual relationship represented by each of the second embedding vectors.

[0020] In one possible implementation, the answer generation unit combines the question to be answered and the various reference documents according to the answer generation rules indicated in the target compression instruction to generate an answer corresponding to the question to be answered. Specifically, this involves: decoding the target compression instruction to reconstruct the instruction description content corresponding to the target answer type and obtain the answer generation rules for the target answer type; performing semantic parsing on the answer generation rules to obtain the document content filtering conditions corresponding to the target answer type; filtering candidate content information that meets the document content filtering conditions from the content information included in the various reference documents; and performing text fusion between the filtered candidate content information and the question to be answered to generate an answer corresponding to the question to be answered.

[0021] In one possible implementation, the answer generation unit performs text fusion between the selected candidate content information and the question to be answered to generate an answer corresponding to the question to be answered. Specifically, it is used to: obtain a target layout method corresponding to the target answer type based on a preset mapping relationship between answer types and layout methods; and perform text fusion between the selected candidate content information and the question to be answered according to the target layout method to generate an answer corresponding to the question to be answered.

[0022] Thirdly, embodiments of this application also provide a computer device, including a processor and a memory, wherein the memory stores program code, and when the program code is executed by the processor, the processor performs the steps of any of the above-described answer generation methods.

[0023] Fourthly, embodiments of this application also provide a computer-readable storage medium including program code, which, when the program product is run on a computer device, is used to cause the computer device to perform the steps of any of the above-described answer generation methods.

[0024] Fifthly, embodiments of this application also provide a computer program product, including computer instructions, which are executed by a processor using the steps of any of the above-described answer generation methods.

[0025] The beneficial effects of this application are as follows:

[0026] This application provides an answer generation method, apparatus, device, and storage medium. In this method, since the instruction description is compressed and encoded according to the answer type, only one compression instruction needs to be added for questions of the same answer type to execute the corresponding search enhancement generation task. There is no need to add a large section of instruction description, and therefore no need to encode the large section of instruction description. Thus, the encoding length in practical applications can be greatly reduced, thereby reducing redundant encoding and improving the efficiency of search enhancement generation tasks.

[0027] Furthermore, by determining the answer type and the target compression instruction based on the target answer type, this application can decompose the retrieval enhancement generation task. In this case, when a new retrieval requirement arises, the mapping relationship between the preset answer type and the compression instruction can be updated without retraining the entire large language model, thus improving the generalization performance of the retrieval enhancement generation task.

[0028] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description

[0029] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0030] Figure 1 This is an optional schematic diagram of an application scenario in the embodiments of this application;

[0031] Figure 2 A flowchart illustrating the answer generation method provided in this application embodiment;

[0032] Figure 3 A schematic diagram illustrating the reference document acquisition process provided in this application embodiment;

[0033] Figure 4 A schematic diagram illustrating the first probability acquisition process for each answer type provided in the embodiments of this application;

[0034] Figure 5 This application provides schematic diagrams illustrating the second probability acquisition process for various answer types in its embodiments.

[0035] Figure 6 This is a schematic diagram illustrating the target answer type prediction process provided in an embodiment of this application.

[0036] Figure 7 This application provides a schematic diagram illustrating the compression encoder instruction description of the reconstruction task training process in an embodiment of the present application.

[0037] Figure 8 This is a schematic diagram of the training process for the compression encoder retrieval enhancement generation task provided in an embodiment of this application;

[0038] Figure 9 This is a schematic diagram illustrating the answer generation process provided in the embodiments of this application;

[0039] Figure 10 This is a schematic diagram illustrating the answer generation results provided in the embodiments of this application;

[0040] Figure 11 This is a schematic diagram of an answer generation system provided in an embodiment of this application;

[0041] Figure 12 This is a schematic diagram of the structure of an answer generation device provided in an embodiment of this application;

[0042] Figure 13 This is a schematic diagram of the hardware structure of a computer device according to an embodiment of this application;

[0043] Figure 14 This is a schematic diagram of the hardware structure of another computer device that applies an embodiment of this application. Detailed Implementation

[0044] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments of this application. Obviously, the described embodiments are only some embodiments of the technical solutions of this application, and not all embodiments. Based on the embodiments recorded in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the technical solutions of this application.

[0045] The design concept of the embodiments of this application is briefly introduced below:

[0046] In related technologies, large language models (such as GPT) are typically trained by designing instruction description templates. This allows the large language model to effectively combine retrieved reference documents and the question to be answered according to the answer generation rules in the instruction description, thereby directly completing the retrieval enhancement generation task. The instruction description is a textual prompt written in natural language to describe the answer generation rules.

[0047] However, large language models typically use fixed instruction description templates to perform the same type of retrieval augmentation generation tasks. In other words, for each question to be answered, the large language model needs to concatenate and encode the fixed instruction description template with the question to be answered and the retrieved reference documents. This results in these fixed instruction description templates being repeatedly encoded when the large language model is applied to a retrieval augmentation generation task with extremely high traffic, leading to significant redundant encoding overhead and even increasing the response latency of the retrieval augmentation generation task.

[0048] Furthermore, since the current set of instruction description templates is limited and the large language model is trained directly using these templates, if a retrieval requirement arises that the current templates cannot meet, a new instruction description template must be designed and the large language model retrained. This incurs additional training costs and time overhead. Therefore, it is evident that current methods using large language models to perform retrieval augmentation tasks suffer from poor generalization ability.

[0049] In view of this, embodiments of this application provide an answer generation method, apparatus, device, and storage medium. The method includes: acquiring a question to be answered and at least one reference document associated with the question; then, based on the question and the at least one reference document, predicting a target answer type corresponding to the question from a set of preset answer types, and obtaining a target compression instruction corresponding to the target answer type based on a preset mapping relationship between answer types and compression instructions; finally, combining the question and the at least one reference document according to the answer generation rules indicated in the target compression instruction to generate an answer corresponding to the question.

[0050] By using the above method, since the instruction description is compressed and encoded according to the answer type, only one compression instruction needs to be added for questions of the same answer type to execute the corresponding search enhancement generation task. There is no need to add a large section of instruction description, and therefore no need to encode the large section of instruction description. This can significantly reduce the encoding length in practical applications, thereby reducing redundant encoding and improving the efficiency of search enhancement generation tasks.

[0051] Furthermore, by determining the answer type and the target compression instruction based on the target answer type, this application can decompose the retrieval enhancement generation task. In this case, when a new retrieval requirement arises, the mapping relationship between the preset answer type and the compression instruction can be updated without retraining the entire large language model, thus improving the generalization performance of the retrieval enhancement generation task.

[0052] The preferred embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit this application. Furthermore, the embodiments and features in the embodiments of this application can be combined with each other without conflict.

[0053] Figure 1 One application scenario is shown, which includes a terminal device 110 and a server 120. The terminal device 110 establishes a communication connection with the server 120 through a wired network or a wireless network.

[0054] The user can input a question to be searched in the browser or other application interface of the terminal device 110. The server 120 can obtain the question via a communication connection and retrieve at least one reference document associated with it. Based on the question and the reference document, it predicts the target answer type from a set of preset answer types. Then, based on the preset mapping between answer types and compression instructions, it obtains the target compression instruction corresponding to the target answer type. Finally, according to the answer generation rules indicated in the target compression instruction, it combines the question and the reference document to generate the answer to the question.

[0055] In this application embodiment, the terminal device 110 may be a smartphone, tablet computer, laptop computer, desktop computer, smart speaker, smartwatch, etc., but is not limited to these.

[0056] The server 120 in this application embodiment can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. This application does not impose any restrictions on these services.

[0057] It should be noted that, Figure 1 The application scenarios shown are merely illustrative and are not intended to limit the scope of this application.

[0058] This application provides an answer generation method that can be applied to... Figure 1 In server 120 shown. See also Figure 2 An exemplary flowchart of an answer generation method is provided for embodiments of this application. The method may include the following steps 201-204:

[0059] Step 201: Obtain the question to be answered, and at least one reference document associated with the question to be answered.

[0060] The unanswered questions represent the search needs of the target audience. For example, if the target audience needs to search for tourist attractions in Yunnan, the unanswered question could be "What are the tourist attractions in Yunnan?" Each reference document contains content information related to the unanswered questions.

[0061] In some embodiments, the reference document can be a document related to the question to be answered, retrieved by the server in a pre-defined document retrieval system after obtaining the question. This pre-defined document retrieval system may include publicly available knowledge base documents, web pages, academic papers, news articles, content published on social media, ebooks, research reports, etc. In other words, each document in the document retrieval system can refer to an independent unit of information, which can be a static file (such as a PDF or HTML file) or a document composed of dynamically generated content (such as database query results). Furthermore, the pre-defined document retrieval system can pre-index based on the content of the documents (such as keywords, phrases, metadata, etc.), so that when the document retrieval system is applied, at least one reference document related to the question to be answered can be obtained through a query algorithm.

[0062] In one possible implementation, when retrieving at least one reference document associated with the question to be answered in a pre-defined document retrieval system, the question to be answered can first be segmented to obtain multiple first-level words included in the question. Then, for multiple pre-defined candidate documents, the following operations are performed respectively: based on the matching degree between a candidate document and the multiple first-level words, the similarity between a candidate document and the question to be answered is obtained.

[0063] After obtaining the similarity between each candidate document and the question to be answered from multiple candidate documents, the server can select at least one candidate document that meets the preset document filtering criteria from the multiple candidate documents based on the obtained similarity scores, and use it as a reference document.

[0064] Since the questions input by the retrieval system are typically in natural language, they need to be processed first to transform them into a form understandable to the document retrieval system. Specifically, the server can divide the question into multiple first-order segments, and then use algorithms such as word embedding and sentence embedding to convert each segment into its corresponding vector representation. Furthermore, each document in the pre-defined document retrieval system can be converted into its corresponding vector representation during preprocessing. Then, algorithms such as Term Frequency (TF) and Inverse Document Frequency (IDF) can be used to determine the degree of matching between each candidate document and the multiple first-order segments.

[0065] For example, when the server determines the degree of matching between each candidate document and multiple first words by combining term frequency and inverse document frequency, it can calculate the frequency of occurrence of each first word in each candidate document, measure the importance of each first word by inverse document frequency, and assign a corresponding weight to each first word to obtain the TF-IDF value between each first word and each candidate document. The TF-IDF value can be used to characterize the degree of matching between the first word and the candidate document, and the TF-IDF value is positively correlated with the degree of matching.

[0066] Then, for any one of the multiple candidate documents, the question to be answered and the document can be represented as TF-IDF vectors based on the calculated TF-IDF value between each first word segment and that candidate document. The cosine similarity is then calculated to determine the similarity between the question to be answered and that candidate document, thereby selecting at least one candidate document that meets the preset document selection criteria as a reference document. A higher similarity indicates a greater relevance between the content of the candidate document and the question to be answered. Other similarity calculation methods can also be used, and this application does not limit the specific methods used.

[0067] In one possible implementation, the document filtering criteria can be to sort multiple candidate documents according to their similarity, and then use the top m candidate documents as reference documents, where m is a positive integer. For example, in a document retrieval system containing 10,000 candidate documents, the top 5 candidate documents with the highest similarity can be used as reference documents.

[0068] In another possible implementation, the document filtering criteria can also be to use candidate documents with a similarity greater than a preset similarity threshold as reference documents. For example, the similarity value can be 0-1, and assuming the preset similarity threshold is 0.8, then candidate documents with a similarity greater than 0.8 can be used as reference documents.

[0069] In another possible implementation, the document filtering criteria can be to sort multiple candidate documents according to their similarity, and then select the top m candidate documents from those with a similarity greater than a preset similarity threshold as reference documents. For example, the top 5 candidate documents with a similarity greater than 0.8 can be selected as reference documents.

[0070] It should be noted that the above document filtering criteria are merely exemplary, and those skilled in the art can set them according to actual circumstances or experience, which is not limited in this application.

[0071] Based on the above scheme, by determining the similarity between the candidate document and the question to be answered by matching the candidate document with multiple first-level word segments, more relevant reference documents can be retrieved. This allows for the generation of more accurate answers based on these more relevant reference documents.

[0072] In some embodiments, the server may further convert the multiple first word segments into their corresponding vector representations, and then, based on the semantics of the question to be answered, convert the question into a query vector. Then, based on the relevance between the vector representation of each candidate document and the query vector, a relevance score is calculated for each candidate document. The calculation of the relevance score may employ methods such as the Best Matching 25 (BM25) algorithm or a ranking model based on Bidirectional Encoder Representations from Transformers (BERT), and this application does not limit the specific method used.

[0073] Optionally, if the question to be answered involves the content mentioned above or the dialogue history, the context involved in the question to be answered can also be analyzed, and the context semantics can be fused into the vector representation corresponding to the question to be answered.

[0074] It should be noted that document retrieval systems can also utilize index structures (such as inverted indexes) and vector indexing techniques to improve retrieval efficiency. For methods of creating indexes, please refer to the index creation methods in related technologies, which will not be elaborated here.

[0075] Optionally, when determining reference documents, the candidate documents selected according to the above document selection criteria can be filtered to remove duplicate candidate documents, so as to ensure that the obtained reference documents have a certain degree of diversity.

[0076] See Figure 3 This is a schematic diagram illustrating the process of obtaining reference documents provided in an embodiment of this application. For example... Figure 3As shown, assume the document retrieval system includes n candidate documents, where n is a positive integer greater than 1. After inputting the question to be answered into the document retrieval system, the system first calculates the similarity between each candidate document and the question, obtaining a similarity of 0.9 for candidate document 1, 0.6 for candidate document 2, 0.5 for candidate document 3, ..., and a similarity of 0.8 for candidate document n. Then, based on the similarity between each candidate document and the question, document filtering is performed. Assume the document filtering criteria are: sorting multiple candidate documents according to their similarity, and then selecting the top m candidate documents with a similarity greater than 0.8 as reference documents, thus obtaining m reference documents, which are then output, where m is a positive integer.

[0077] Step 202: Based on the question to be answered and at least one reference document, predict the target answer type corresponding to the question to be answered from among a number of preset answer types.

[0078] The pre-defined answer types can include, but are not limited to, single-response, multi-response, and step-by-step types. A single-response answer typically refers to a concise and direct answer that addresses a specific question with a single sentence or viewpoint. Single-response answers are suitable for questions requiring a single fact or piece of information, such as, "Where are apples originally from?" Alternatively, single-response answers are also suitable for true / false or multiple-choice questions, such as, "Is the sun a star?"

[0079] Multiple-response type typically refers to answers that include multiple viewpoints or solutions. Multiple-response type is suitable for unanswered questions containing multiple sub-questions, such as "How to improve learning ability? What are some recommended learning resources?" Alternatively, multiple-response type can also be used for unanswered questions that require different options or solutions, such as "Can you recommend a few five-day travel routes in Yunnan?"

[0080] Step-based questions typically refer to answers that require an ordered sequence of steps or a process. They are suitable for procedural questions that require performing actions or solving problems, such as "How do I install a light bulb?" Alternatively, step-based questions can also be used for questions that require phased processing or step-by-step advancement, such as "How do I fix a slow computer?"

[0081] In one possible implementation, for multiple answer types, the following operations are performed respectively: First, based on the semantic information of the question to be answered, a first probability that the answer type is the target answer type is obtained, and based on the semantic information of at least one reference document, a second probability that the answer type is the target answer type is obtained. Then, based on the first and second probabilities, a target probability that the answer type is the target answer type corresponding to the question to be answered is obtained.

[0082] Then, after obtaining the target probability for each answer type among the multiple answer types, the target answer type among the multiple answer types can be determined according to the preset probability conditions. That is, the answer type among the multiple answer types whose target probability satisfies the preset probability conditions is taken as the target answer type.

[0083] In some embodiments, a question classifier and a document classifier can be pre-built, and then the question classifier can be trained using a question training sample set, and the document classifier can be trained using a document training sample set. In practical applications, for each answer type, the question classifier can predict a first probability that an answer type is the target answer type based on the semantic information of the question to be answered, and the document classifier can predict a second probability that an answer type is the target answer type based on the semantic information of at least one reference document.

[0084] In this training dataset, each training sample in the question training set can be a historical unanswered question, and the label of each training sample is the answer type corresponding to the historical unanswered question. Each training sample in the document training set can be at least one historical reference document corresponding to a historical unanswered question, and the label of each training sample is the answer type corresponding to at least one historical reference document. The question classifier and document classifier can be classifiers built based on a Transformer-based language model for performing classification tasks, such as the robustly optimized BERT approach (RoBERTa). Specific training methods for the question classifier and document classifier can be found in the training methods for the RoBERTa model in related technologies, and will not be elaborated upon here.

[0085] For example, suppose the training samples in the question training sample set include: question A, question B, and question C. Then the training samples in the document training sample set can include: 2 historical reference documents corresponding to question A, 5 historical reference documents corresponding to question B, and 4 historical reference documents corresponding to question C. That is, the 2 historical reference documents corresponding to question A can be used as one training sample, the 5 historical reference documents corresponding to question B can be used as one training sample, and the 4 historical reference documents corresponding to question C can be used as one training sample.

[0086] It should be noted that the question classifier and document classifier can also be classifiers built based on other language models. The training methods for classifiers built based on different language models can be different, and this application does not limit this.

[0087] Based on the above scheme, since classifying answers requires classifying both the questions to be answered and the reference documents associated with the questions, the target answer type corresponding to the questions to be answered can be determined by combining the first probability determined based on the questions to be answered and the second probability determined based on the reference documents. This makes the determined target answer type more accurate, and further makes the subsequently generated answers more accurate.

[0088] In one possible implementation, predicting the first probability that an answer type is the target answer type using a pre-trained question classifier can be specifically performed as follows: The question to be answered is segmented to obtain multiple first segments. Then, based on the arrangement and contextual information of each first segment within the question, the segments are encoded to obtain a first embedding vector corresponding to the question. This first embedding vector represents the contextual relationship between the multiple first segments. Finally, based on the contextual relationship represented by the first embedding vector, a first probability that the answer type is the target answer type corresponding to the question is obtained.

[0089] For example, when predicting the first probability that answer type A is the target answer type corresponding to the question to be answered by a pre-trained question classifier, formula (1) is satisfied.

[0090] P qA =RoBERTa q (query) formula (1)

[0091] In the formula, P qA RoBERTa represents the first probability that answer type A is the target answer type corresponding to the question to be answered. q This represents the question classifier, and query represents the question to be answered.

[0092] Figure 4 This is a schematic diagram illustrating the first probability acquisition process for each answer type provided in this application embodiment. Assuming the preset answer types include answer type A, answer type B, and answer type C, the question to be answered is input into a pre-trained question classifier. The question classifier can perform word segmentation on the question to be answered to obtain k first words: token1, token2, token3, ..., token. k k is an integer greater than 1. Then, encoding the k first words yields the first embedding vector. Based on the contextual relationships represented in the first embedding vector, the first probability of answer type A is determined to be 0.8, the first probability of answer type B is 0.3, and the first probability of answer type C is 0.4.

[0093] Based on the above scheme, a vector representation of the question to be answered can be obtained by performing word segmentation and encoding. Based on the contextual relationship of the question to be answered represented in the first embedding vector, the answer type of the question to be answered can be classified, thereby generating a more accurate answer according to the answer type of the question to be answered.

[0094] In one possible implementation, predicting a second probability that an answer type corresponds to the target answer type using a pre-trained document classifier can be specifically performed as follows: Each reference document is segmented into individual words to obtain multiple second words included in each reference document. Based on the arrangement and contextual information of each of the multiple second words in at least one reference document, each of the multiple second words is encoded to obtain a second embedding vector corresponding to each of the at least one reference document. Each second embedding vector represents the contextual relationship between the multiple second words included in the corresponding reference document. Finally, based on the contextual relationships represented by each of the second embedding vectors, a second probability that the answer type corresponds to the target answer type of at least one reference document is obtained.

[0095] For example, when predicting the second probability that answer type A is the target answer type corresponding to at least one reference document through a pre-trained document classifier, formula (2) is satisfied.

[0096] P dA =RoBERTa d (documents) Formula (2)

[0097] In the formula, P dA RoBERTa represents the second probability that answer type A is the target answer type corresponding to at least one reference document. d This represents a document classifier, and "documents" represents the questions to be answered.

[0098] Figure 5 This is a schematic diagram illustrating the second probability acquisition process for each answer type provided in the embodiments of this application. Assuming the preset answer types include answer type A, answer type B, and answer type C, at least one reference document is input into a pre-trained document classifier. The document classifier can perform word segmentation on the question to be answered to obtain p second words: token1, token2, token3, ..., token. p p is an integer greater than 1. Then, by encoding each of the p second words, we can obtain the second embedding vector corresponding to at least one reference document. Based on the contextual relationships represented in the second embedding vector, we can determine the second probability of answer type A as 0.7, the second probability of answer type B as 0.2, and the second probability of answer type C as 0.5.

[0099] Based on the above scheme, a vector representation of the question to be answered can be obtained by performing word segmentation and encoding on at least one reference document. Based on the contextual relationship of the reference document represented in the second embedding vector, the answer type of at least one reference document can be classified, thereby generating a more accurate answer based on the answer type of the reference document.

[0100] In some embodiments, when determining the target probability of an answer type as the target answer type based on the first probability and the second probability obtained above, it can be determined by calculating the product of the first probability and the second probability, as shown in formula (3).

[0101] P A = P qA ·P dA Formula (3)

[0102] In the formula, P A This represents the target probability that answer type A is the target answer type.

[0103] In some embodiments, after obtaining the target probability for each of the multiple answer types, the answer type whose target probability satisfies a preset probability condition can be used as the target answer type. The preset probability condition can be selecting the answer type with the highest target probability among the multiple answer types. For example, if the target probability for a single type is 0.3, the target probability for multiple types is 0.5, and the target probability for a step type is 0.8, then since 0.8 > 0.5 > 0.3, the step type is chosen as the target answer type.

[0104] See Figure 6 This is a schematic diagram of the target answer type prediction process provided in an embodiment of this application. Assume that the question to be answered is input into a question classifier, and the first probability of answer type A is 0.8, the first probability of answer type B is 0.3, and the first probability of answer type C is 0.4. At least one reference document is input into a document classifier, and the second probability of answer type A is 0.7, the second probability of answer type B is 0.2, and the second probability of answer type C is 0.5. Then, through formula (3), the target probability of answer type A is 0.56, the target probability of answer type B is 0.06, and the target probability of answer type C is 0.2. Therefore, answer type A has the highest target probability, and thus answer type A is the target answer type.

[0105] Step 203: Based on the preset mapping relationship between answer types and compression instructions, obtain the target compression instruction corresponding to the target answer type.

[0106] Each compression instruction is pre-compressed based on the instruction description content of the corresponding answer type, and is used to indicate the answer generation rules for that answer type. For example, compressing the instruction description of a single type yields the compression instruction corresponding to that single type.

[0107] The compressed instructions obtained after compression encoding can be represented by a "prompt token". That is, the compressed instructions can be fixed-length tokens, which can be converted into corresponding vector representations in a large language model. It should be understood that the length of the prompt token can be set according to experience or actual conditions, for example, it can be 1 token or 2 tokens, and this application does not limit it in this regard.

[0108] In one possible implementation, before compressing and encoding the instruction description content based on the corresponding answer type, two pre-trained Large Language Models (LLMs) can be obtained. One of the LLMs can be used to construct a compression encoder by adding a fine-tuning module. The constructed compression encoder is then trained alternately on two tasks: instruction description reconstruction and downstream tasks. The downstream tasks can include retrieval enhancement generation and other generation tasks.

[0109] When training different tasks, the training samples are all instruction descriptions. To distinguish between different tasks, the corresponding tokens of the tasks can be appended to the training samples to inform the model of the task to be performed on the training samples. For example, [AE] can be appended to instruction description 1 to get "Instruction description 1 [AE]", which means that instruction description 1 is used to train the instruction description reconstruction task; [TASK] can be appended to instruction description 2 to get "Instruction description 2 [TASK]", which means that instruction description 2 is used to train the downstream task through [TASK].

[0110] Specifically, after obtaining the prompt token corresponding to the training sample through the compression encoder, the prompt token and the token corresponding to the task can be input into another large language model. The large language model can execute the corresponding task according to the token corresponding to the task and obtain the output result. The compression encoder and the large language model are fine-tuned by the loss between the output result and the label of the training sample. Thus, the large language model can execute both the instruction description reconstruction task and the downstream task through the representation of the prompt token.

[0111] It should be noted that the same loss function or different loss functions can be used when training different tasks; this application does not impose any restrictions on this. Furthermore, specific training methods can be found in related art on large language model training methods, which will not be elaborated upon here.

[0112] In one example, see Figure 7 This diagram illustrates the training process of the instruction description reconstruction task for the compression encoder provided in this embodiment. LLM represents a large language model, and LLM(frozen) represents a large language model with frozen parameters. Since large language models typically have already learned rich language representation capabilities, it is not necessary to retrain all parameters of the entire model. Therefore, most parameters in the LLM can be frozen, and only the parameters of the preset fine-tuning layer can be trained. That is, only the parameters involved in LoRA can be fine-tuned, thereby greatly reducing the computational resources and time consumption during the fine-tuning process. The low-rank adaptation (LoRA) method can be used in the fine-tuning module. Inputting instruction description 1 into the compression encoder yields the corresponding compression instruction [prompt token1]. Then, "[prompt token1][AE]" is used as a training sample, and instruction description 1 is used as the label for this training sample. This sample is then input into another large language model, which can reconstruct instruction description 1* from [prompt token1]. The compression encoder is then trained using the loss between instruction description 1* and instruction description 1.

[0113] In one example, see Figure 8 This is a schematic diagram of the training process for a retrieval enhancement generation task provided in an embodiment of this application. Assuming the downstream task is a retrieval enhancement generation task, instruction description 1 is input into the compression encoder to obtain the compression instruction [prompt token1] corresponding to instruction description 1. Then, [prompt token1], [TASK], the question to be answered, and at least one reference document are concatenated into a training sample "[prompt token1] + question to be answered + at least one reference document + [TASK]". The answer to the question to be answered is used as the label of this training sample, which is then input into another fine-tuned large language model. The large language model can first determine the retrieval enhancement generation task to be performed based on [TASK], and then generate the predicted answer to the question to be answered according to the answer generation rules indicated by [prompt token1], based on at least one reference document. The compression encoder can then be trained using the loss between the generated predicted answer and the answer in the label.

[0114] It should be noted that large language models can be generative pretrained Transformer (GPT) models, bidirectional encoder representations from Transformer (BERT) models, etc., and other fine-tuning methods in related technologies can also be used. This application does not limit them.

[0115] Based on the above scheme, since the compression encoder is trained alternately on the natural language instruction description reconstruction task and downstream tasks, it can efficiently compress natural language instruction descriptions while retaining the ability to generalize instruction descriptions to other tasks, thereby improving generalization performance.

[0116] In some embodiments, after obtaining the trained compression encoder, when performing compression encoding based on the instruction description content of the corresponding answer type, the instruction description written in natural language corresponding to each answer type can be obtained first.

[0117] For example, the instruction description for a single type could be: You are an intelligent assistant that answers questions and need to use the provided documents to answer the questions. Please provide an answer according to the following requirements: When the provided documents can answer the question, candidate content that can answer the question is selected from the provided documents according to the following answer generation rules: When there are multiple different candidate contents that can answer the question, but only one answer to the question can be true, the candidate content with the highest source document confidence, the most source documents, and the most recent source document time is selected as the unique answer.

[0118] For example, the instruction descriptions corresponding to multiple types could be: You are an intelligent assistant that answers questions and need to use the provided documents to answer the questions. Please provide answers according to the following requirements: When the provided documents can answer the questions, then according to the following answer generation rules, candidate content that can answer the questions is selected from the provided documents: When there are multiple different candidate contents, and multiple answers to the question can be true at the same time, then the candidate answers are listed in order.

[0119] The description of step-type instructions can be deduced in the same way, and will not be elaborated upon in this application.

[0120] Then, the instruction description content can be compressed and encoded using a trained compression encoder to obtain the compressed instruction corresponding to the instruction description for each answer type. For example, inputting the instruction description corresponding to a single type as mentioned above... Figure 7 or Figure 8The compression encoder shown can produce compression instructions corresponding to a single type.

[0121] In some embodiments, after obtaining the compression instruction corresponding to the instruction description for each answer type, a mapping relationship between answer types and compression instructions can be established. For example, the compression instruction corresponding to a single type can be [prompttoken1], the compression instruction corresponding to multiple types can be [prompt token2], and the compression instruction corresponding to a step type can be [prompt token3].

[0122] Step 204: According to the answer generation rules indicated in the target compression instruction, combine the question to be answered with at least one reference document to generate the answer to the question to be answered.

[0123] Specifically, the target compression instruction, the question to be answered, and at least one reference document can be concatenated into a single input data set and fed into the fine-tuned large language model. This allows the large language model to combine the question to be answered and at least one reference document according to the answer generation rules indicated in the target compression instruction, thereby generating the answer corresponding to the question to be answered.

[0124] For example, assuming the target compression instruction consists of multiple compression instructions corresponding to different types, the answer generation rule indicated in the compression instruction can be "when there are multiple different candidate content information in the reference document, and multiple answers to the question can be true at the same time, then the candidate content information is listed in sequence". The large language model can list the candidate content information of at least one reference document in sequence to generate the answer to the question to be answered.

[0125] In some embodiments, the large language model used to generate answers to questions can be obtained through supervised fine-tuning of compression instructions corresponding to each answer type. This allows the large language model to first perform an instruction description reconstruction task to reconstruct the corresponding compression instructions, and then perform a retrieval enhancement generation task according to the reconstructed instruction description to generate answers to questions. For specific fine-tuning methods, please refer to the fine-tuning methods in related technologies; this application will not elaborate on them.

[0126] In one possible implementation, step 204 can be specifically executed as follows: The server can first decode the target compression instruction, reconstruct the instruction description content corresponding to the target answer type, and obtain the answer generation rules for the target answer type. Then, semantic parsing is performed on the answer generation rules to obtain the document content filtering conditions corresponding to the target answer type. Next, candidate content information that meets the document content filtering conditions is filtered from the content information included in each reference document. Finally, the filtered candidate content information can be fused with the question to be answered to generate the answer corresponding to the question.

[0127] In some embodiments, the server can concatenate the target compression instruction, the token corresponding to the task, the question to be answered, and at least one reference document into a single input data. After inputting this into the fine-tuned large language model, the fine-tuned large language model can determine whether the task to be executed is a downstream task or a reconstruction task based on the token corresponding to the task.

[0128] When the current task is identified as a downstream task, the fine-tuned large language model can convert the target compression instruction into a vector representation, then perform semantic parsing on the vector representation to determine the document content filtering conditions corresponding to the target answer type, and finally generate the answer to the question to be answered. The document content filtering conditions can be written in the instruction description by relevant staff based on experience or actual conditions; see the document content filtering conditions included in the instruction description example above, which will not be elaborated upon here.

[0129] When the current task is determined to be a reconstruction task, the fine-tuned large language model can convert the target compression instruction into a vector representation, then decode the vector representation, reconstruct the instruction description corresponding to the target compression instruction, and directly output the obtained instruction description as output data.

[0130] It should be noted that the reconstructed instruction description content is the same as the answer generation rules represented by the instruction description before compression, but the natural language description may be different.

[0131] Based on the above scheme, since the answer generation rules are obtained by decoding the target compression instructions, the encoding length of natural language instruction descriptions in practical applications can be significantly reduced, especially for tasks with very long natural language instruction descriptions.

[0132] See Figure 9This is a schematic diagram of the answer generation process provided in an embodiment of this application. After obtaining the question to be answered and at least one reference document, the target answer type corresponding to the question to be answered can be determined by a question classifier and a document classifier. Based on the target answer type, a target compression instruction is determined. Assuming the target compression instruction is [prompt token1], then [prompt token1], [TASK], the question to be answered, and at least one reference document are concatenated into the input data: "[prompt token1] + question to be answered + at least one reference document + [TASK]", which is then input into the fine-tuned large language model to generate the answer corresponding to the question to be answered.

[0133] In one possible implementation, when the selected candidate content information and the question to be answered are text-fused to generate the answer to the question to be answered, the target layout method corresponding to the target answer type can also be obtained based on the preset mapping relationship between answer type and layout method. Then, the selected candidate content information and the question to be answered are text-fused according to the target layout method to generate the answer to the question to be answered.

[0134] For example, the layout for step-by-step types could use an ordered list to present the process, such as using 1, 2, 3... to represent the first step, the second step, the third step, and so on. Alternatively, for multiple types, the layout could list each solution or the answer to each question separately and display them using an unordered list.

[0135] It should be noted that the formatting methods for each answer type can be preset by relevant staff based on experience or actual situation, and this application does not impose any restrictions on this.

[0136] Based on the above scheme, since this application decomposes the task of enhancing retrieval generation and makes determining the answer type an additional step, it is convenient to optimize other functions related to answer type. When generating answers, the layout method can be determined according to different answer types, thereby optimizing the retrieval experience of the retrieval object.

[0137] In some embodiments, since the retrieval enhancement generation task typically requires displaying the source of the answer, i.e. the name or web address of the reference document, after generating the answer to the question to be answered, the name or web address of the reference document also needs to be appended to the answer.

[0138] See Figure 10 This is a schematic diagram illustrating the answer generation result provided in an embodiment of this application. For example... Figure 10As shown, when generating answers, the question to be answered can be displayed at the top. Taking the question "Sagittarius's favorite zodiac sign in their lifetime" as an example, since this question contains multiple answers, it can be seen that the answer types are multiple. Therefore, the answers can be displayed in an unordered list according to the format corresponding to the multiple types. Below the answers, the name of the referenced document will also be used to identify the source of the answer.

[0139] See Figure 11 This is a schematic diagram of an answer generation system provided in an embodiment of this application. The answer generation system may include an answer type prediction module and an answer generation module. The answer type prediction module may include a question classification submodule and a document classification submodule. By inputting the question to be answered into the question classification submodule and at least one reference document into the document classification submodule, the target answer type corresponding to the question to be answered can be obtained through the answer type prediction module. Then, the target answer type, the question to be answered, and at least one reference document are input into the answer generation module to generate the answer corresponding to the question to be answered.

[0140] Based on the same inventive concept as the above-described method embodiments, this application also provides an answer generation device. For example... Figure 12 The answer generation device 1200 shown may include:

[0141] The communication unit 1201 is used to acquire a question to be answered and at least one reference document associated with the question to be answered; each reference document records content information related to the question to be answered.

[0142] Answer type prediction unit 1202 is used to predict the target answer type corresponding to the question to be answered from among a plurality of preset answer types, based on the question to be answered and the at least one reference document.

[0143] The answer generation unit 1203 is used to obtain the target compression instruction corresponding to the target answer type based on the preset mapping relationship between answer types and compression instructions; each compression instruction is obtained by pre-compressing and encoding the instruction description content of the corresponding answer type, and is used to indicate the answer generation rules of the corresponding answer type; according to the answer generation rules indicated in the target compression instruction, the question to be answered and the at least one reference document are combined to generate the answer corresponding to the question to be answered.

[0144] In one possible implementation, at least one reference document associated with the question to be answered is retrieved by a document retrieval unit 1204, which is specifically used to: perform word segmentation on the question to be answered to obtain a plurality of first words included in the question to be answered; and perform the following operations on a plurality of preset candidate documents respectively: obtain the similarity between the candidate document and the question to be answered based on the matching degree between the candidate document and the plurality of first words; and select at least one candidate document that meets the preset document filtering conditions from the plurality of candidate documents as a reference document based on the obtained similarity scores.

[0145] In one possible implementation, the answer type prediction unit 1202, based on the question to be answered and the at least one reference document, predicts the target answer type corresponding to the question to be answered from among a preset plurality of answer types. Specifically, it performs the following operations for each of the plurality of answer types: based on the semantic information of the question to be answered, obtains a first probability that an answer type is the target answer type corresponding to the question to be answered; based on the semantic information of each of the at least one reference document, obtains a second probability that an answer type is the target answer type corresponding to the at least one reference document; based on the first probability and the second probability, obtains a target probability that an answer type is the target answer type corresponding to the question to be answered; and selects the answer type among the plurality of answer types whose target probability satisfies a preset probability condition as the target answer type.

[0146] In one possible implementation, the answer type prediction unit 1202 obtains a first probability that the answer type is the target answer type corresponding to the question to be answered based on the semantic information of the question to be answered. Specifically, it is used to: perform word segmentation on the question to be answered to obtain multiple first words included in the question to be answered; encode the multiple first words respectively based on their respective arrangement positions and context information in the question to be answered to obtain a first embedding vector corresponding to the question to be answered; the first embedding vector represents the contextual relationship between the multiple first words; and obtain a first probability that the answer type is the target answer type corresponding to the question to be answered based on the contextual relationship represented in the first embedding vector.

[0147] In one possible implementation, the answer type prediction unit 1202 obtains a second probability that the answer type is the target answer type corresponding to the at least one reference document based on the semantic information of each of the at least one reference document. Specifically, it is used to: perform word segmentation on each of the reference documents to obtain multiple second words included in each reference document; encode each of the multiple second words based on their respective arrangement positions and context information in the at least one reference document to obtain a second embedding vector corresponding to each of the at least one reference document; each second embedding vector represents the contextual relationship between the multiple second words included in the corresponding reference document; and obtain a second probability that the answer type is the target answer type corresponding to the at least one reference document based on the contextual relationship represented by each of the second embedding vectors.

[0148] In one possible implementation, the answer generation unit 1203 combines the question to be answered and the various reference documents according to the answer generation rules indicated in the target compression instruction to generate an answer corresponding to the question to be answered. Specifically, this involves: decoding the target compression instruction to reconstruct the instruction description content corresponding to the target answer type and obtain the answer generation rules for the target answer type; performing semantic parsing on the answer generation rules to obtain the document content filtering conditions corresponding to the target answer type; filtering candidate content information that meets the document content filtering conditions from the content information included in the various reference documents; and performing text fusion with the filtered candidate content information and the question to be answered to generate an answer corresponding to the question to be answered.

[0149] In one possible implementation, the answer generation unit 1203 performs text fusion between the selected candidate content information and the question to be answered to generate an answer corresponding to the question to be answered. Specifically, it is used to: obtain the target layout method corresponding to the target answer type based on the preset mapping relationship between answer types and layout methods; and perform text fusion between the selected candidate content information and the question to be answered according to the target layout method to generate an answer corresponding to the question to be answered.

[0150] For ease of description, the above sections are divided into modules (or units) according to their functions and described separately. In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program with a predetermined function, which works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functions of that module or unit.

[0151] Having described the answer generation method and apparatus according to exemplary embodiments of this application, we will now describe a computer device according to another exemplary embodiment of this application.

[0152] Those skilled in the art will understand that various aspects of this application can be implemented as a system, method, or program product. Therefore, various aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."

[0153] Based on the same inventive concept as the above-described method embodiments, this application also provides a computer device. In one embodiment, the computer device may be a server, such as... Figure 1 The server 120 is shown. In this embodiment, the computer device 1300 is structured as follows: Figure 13 As shown, it may include at least a memory 1301, a communication module 1303, and at least one processor 1302.

[0154] The memory 1301 is used to store computer programs executed by the processor 1302. The memory 1301 may mainly include a program storage area and a data storage area. The program storage area may store the operating system and programs required to run instant messaging functions, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.

[0155] Memory 1301 may be volatile memory, such as random-access memory (RAM); memory 1301 may also be non-volatile memory, such as read-only memory, flash memory, hard disk drive (HDD), or solid-state drive (SSD); or memory 1301 may be any other medium capable of carrying or storing a desired computer program having the form of instructions or data structures and accessible by a computer, but is not limited thereto. Memory 1301 may be a combination of the above-described memories.

[0156] Processor 1302 may include one or more central processing units (CPUs) or digital processing units, etc. Processor 1302 is used to implement the above-described answer generation method when calling computer programs stored in memory 1301.

[0157] The communication module 1303 is used to communicate with terminal devices and other servers.

[0158] This application embodiment does not limit the specific connection medium between the memory 1301, communication module 1303, and processor 1302. This application embodiment... Figure 13 The memory 1301 and the processor 1302 are connected via a bus 1304, and the bus 1304 is in Figure 13 The diagram uses thick lines to describe the connections between other components; these are for illustrative purposes only and should not be considered limiting. The 1304 bus can be divided into address bus, data bus, control bus, etc. For ease of description, Figure 13 It is described using only a thick line, but does not indicate that there is only one bus or one type of bus.

[0159] The memory 1301 stores a computer storage medium, which stores computer-executable instructions for implementing the answer generation method of this application embodiment. The processor 1302 is used to execute the above-described answer generation method, such as... Figure 2 As shown.

[0160] In another embodiment, the computer device can also be other computer devices, such as... Figure 1 The terminal device 110 is shown. In this embodiment, the structure of the computer device can be as follows: Figure 14As shown, it includes components such as: communication component 1410, memory 1420, display unit 1430, camera 1440, sensor 1450, audio circuit 1460, Bluetooth module 1470, processor 1480, etc.

[0161] The communication component 1410 is used to communicate with a server. In some embodiments, it may include a Wireless Fidelity (WiFi) module, which is a short-range wireless transmission technology, and the electronic device can send and receive information through the WiFi module.

[0162] The memory 1420 can be used to store software programs and data. The processor 1480 executes various functions of the terminal device 110 and performs data processing by running the software programs or data stored in the memory 1420. The memory 1420 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. The memory 1420 stores an operating system that enables the terminal device 110 to run. In this application, the memory 1420 may store the operating system and various application programs, and may also store computer programs that execute the answer generation method of the embodiments of this application.

[0163] The display unit 1430 can also be used to display information input by the object or information provided to the object, as well as various menus of the terminal device 110, in a graphical user interface (GUI). Specifically, the display unit 1430 may include a display screen 1432 disposed on the front of the terminal device 110. The display screen 1432 may be configured as a liquid crystal display, a light-emitting diode, or the like. The display unit 1430 can be used to display the answer generation interface, question retrieval interface, etc., as described in this application embodiment.

[0164] The display unit 1430 can also be used to receive input digital or character information and generate signal inputs related to object settings and function control of the terminal device 110. Specifically, the display unit 1430 may include a touch screen 1431 disposed on the front of the terminal device 110, which can collect touch operations on or near the object, such as clicking a button, dragging a scroll box, etc.

[0165] The touchscreen 1431 can be placed on top of the display screen 1432, or the touchscreen 1431 and the display screen 1432 can be integrated to realize the input and output functions of the terminal device 110. After integration, it can be referred to as a touch display screen. In this application, the display unit 1430 can display the application and the corresponding operation steps.

[0166] Camera 1440 can be used to capture still images, and objects can publish images captured by camera 1440 through an application. There can be one or multiple cameras 1440. An optical image of an object is generated through a lens and projected onto a photosensitive element. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then transmitted to processor 1480 to be converted into a digital image signal.

[0167] The terminal device may also include at least one sensor 1450, such as an accelerometer 1451, a proximity sensor 1452, a fingerprint sensor 1453, and a temperature sensor 1454. The terminal device may also be equipped with other sensors such as a gyroscope, barometer, hygrometer, thermometer, infrared sensor, light sensor, and motion sensor.

[0168] Audio circuitry 1460, speaker 1461, and microphone 1462 provide an audio interface between the device and terminal device 110. Audio circuitry 1460 converts received audio data into electrical signals, transmits them to speaker 1461, and speaker 1461 converts them into sound signals for output. Terminal device 110 may also be equipped with volume buttons for adjusting the volume of the sound signal. On the other hand, microphone 1462 converts collected sound signals into electrical signals, which are then received by audio circuitry 1460, converted into audio data, and output to communication component 1410 for transmission to, for example, another terminal device 110, or to memory 1420 for further processing.

[0169] The Bluetooth module 1470 is used to interact with other Bluetooth devices that also have a Bluetooth module via the Bluetooth protocol. For example, a terminal device can establish a Bluetooth connection with a wearable electronic device (such as a smartwatch) that also has a Bluetooth module through the Bluetooth module 1470, thereby exchanging data.

[0170] The processor 1480 is the control center of the terminal device, connecting various parts of the terminal through various interfaces and lines. It executes various functions and processes data by running or executing software programs stored in the memory 1420 and calling data stored in the memory 1420. In some embodiments, the processor 1480 may include one or more processing units; the processor 1480 may also integrate an application processor and a baseband processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the baseband processor mainly handles wireless communication. It is understood that the baseband processor may not be integrated into the processor 1480. In this application, the processor 1480 can run the operating system, applications, user interface display and touch response, and the answer generation method of this embodiment. Furthermore, the processor 1480 is coupled to the display unit 1430.

[0171] Furthermore, it should be noted that in the specific embodiments of this application, object data related to answer generation is involved. When the above embodiments of this application are applied to specific products or technologies, permission or consent from the object is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0172] In some possible implementations, various aspects of the answer generation method provided in this application can also be implemented in the form of a program product, which includes a computer program. When the program product is run on a computer device, the computer program is used to cause the computer device to perform the steps of the answer generation method according to the various exemplary embodiments of this application described above. For example, the computer device can perform actions such as... Figure 2 The steps are shown in the figure.

[0173] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0174] The program product of the embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include a computer program, and may run on an electronic device. However, the program product of this application is not limited thereto. In this document, the readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with a command execution system, apparatus, or device.

[0175] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a readable computer program. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with a command execution system, apparatus, or device.

[0176] Computer programs contained on readable media may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0177] Computer programs for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The computer program can execute entirely on the user's computer device, partially on the user's computer device, as a standalone software package, partially on the user's computer device and partially on a remote computer device, or entirely on a remote computer device. In cases involving remote computer devices, the remote computer device can be connected to the user's computer device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer device (e.g., via the Internet using an Internet service provider).

[0178] It should be noted that although several units or sub-units of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units.

[0179] Furthermore, although the operations of the method of this application are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.

[0180] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing a computer-usable computer program.

[0181] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, produce a machine for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0182] These computer program commands may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the commands stored in the computer-readable storage medium produce an article of manufacture including command means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0183] These computer program commands can also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing the commands executed on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0184] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0185] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method for generating answers, characterized in that, include: Obtain the question to be answered, and at least one reference document associated with the question to be answered; Each reference document contains information related to the question to be answered; Based on the question to be answered and the at least one reference document, predict the target answer type corresponding to the question to be answered from among a plurality of preset answer types; Based on the preset mapping relationship between answer types and compression instructions, the target compression instruction corresponding to the target answer type is obtained; each compression instruction is obtained by pre-compressing and encoding the instruction description content of the corresponding answer type, and is used to indicate the answer generation rules of the corresponding answer type; According to the answer generation rules indicated in the target compression instruction, the question to be answered and the at least one reference document are combined to generate the answer corresponding to the question to be answered.

2. The method according to claim 1, characterized in that, Obtain at least one reference document associated with the question to be answered, including: The question to be answered is segmented into words to obtain multiple first words included in the question to be answered; For multiple preset candidate documents, perform the following operations respectively: based on the matching degree between a candidate document and the multiple first word segments, obtain the similarity between the candidate document and the question to be answered; Among the multiple candidate documents, at least one candidate document that meets the preset document filtering criteria is selected as a reference document based on the obtained similarity scores.

3. The method according to claim 1, characterized in that, The step of predicting the target answer type corresponding to the question to be answered from among a preset number of answer types, based on the question to be answered and the at least one reference document, includes: For each of the aforementioned answer types, perform the following operations respectively: Based on the semantic information of the question to be answered, a first probability is obtained that the answer type is the target answer type corresponding to the question to be answered; Based on the semantic information of each of the at least one reference document, a second probability is obtained that the answer type is the target answer type corresponding to the at least one reference document; Based on the first probability and the second probability, obtain the target probability that the answer type is the target answer type corresponding to the question to be answered; The answer type whose target probability satisfies the preset probability condition among the multiple answer types is taken as the target answer type.

4. The method according to claim 3, characterized in that, The step of obtaining a first probability that the answer type is the target answer type corresponding to the question to be answered, based on the semantic information of the question to be answered, includes: The question to be answered is segmented into words to obtain multiple first words included in the question to be answered; Based on the arrangement position and context information of the plurality of first word segments in the question to be answered, the plurality of first word segments are encoded to obtain a first embedding vector corresponding to the question to be answered; the first embedding vector represents the contextual relationship between the plurality of first word segments. Based on the contextual relationships represented in the first embedding vector, a first probability is obtained that the answer type is the target answer type corresponding to the question to be answered.

5. The method according to claim 3, characterized in that, The step of obtaining a second probability that an answer type is the target answer type corresponding to the at least one reference document based on the semantic information of each of the at least one reference document includes: Each of the reference documents is segmented into words to obtain multiple second words included in each reference document; Based on the arrangement position and context information of the plurality of second word segments in the at least one reference document, the plurality of second word segments are encoded to obtain the second embedding vector corresponding to each of the at least one reference document; each second embedding vector represents the contextual relationship between the plurality of second word segments included in the corresponding reference document; Based on the contextual relationships represented by each of the second embedding vectors, a second probability is obtained that the answer type is the target answer type corresponding to the at least one reference document.

6. The method according to any one of claims 1-5, characterized in that, The step of combining the unanswered question and the various reference documents according to the answer generation rules indicated in the target compression instruction to generate the answer corresponding to the unanswered question includes: Decode the target compression instruction, reconstruct the instruction description content corresponding to the target answer type, and obtain the answer generation rule for the target answer type; Semantic analysis is performed on the answer generation rules to obtain the document content filtering conditions corresponding to the target answer type; From the content information included in each of the reference documents, candidate content information that meets the document content filtering criteria is selected; The selected candidate content information is fused with the question to be answered to generate the answer to the question.

7. The method according to claim 6, characterized in that, The step of fusing the selected candidate content information with the question to be answered to generate the answer to the question to be answered includes: Based on the preset mapping relationship between answer types and layout methods, the target layout method corresponding to the target answer type is obtained; The selected candidate content information is fused with the question to be answered according to the target layout method to generate the answer to the question to be answered.

8. An answer generation device, characterized in that, include: A communication unit is used to acquire a question to be answered and at least one reference document associated with the question to be answered; Each reference document contains information related to the question to be answered; The answer type prediction unit is used to predict the target answer type corresponding to the question to be answered from among a plurality of preset answer types, based on the question to be answered and the at least one reference document. The answer generation unit is used to obtain the target compression instruction corresponding to the target answer type based on the preset mapping relationship between answer types and compression instructions; each compression instruction is obtained by pre-compressing and encoding the instruction description content of the corresponding answer type, and is used to indicate the answer generation rules of the corresponding answer type; according to the answer generation rules indicated in the target compression instruction, the question to be answered and the at least one reference document are combined to generate the answer corresponding to the question to be answered.

9. A computer device, characterized in that, It includes a processor and a memory, wherein the memory stores program code that, when executed by the processor, causes the processor to perform the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, It includes program code that, when run on a computer device, causes the computer device to perform the steps of the method according to any one of claims 1 to 7.

11. A computer program product, characterized in that, It includes computer instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1 to 7.