Question-answering method, question-answering model training method, all-in-one machine and storage medium

By combining natural language models and non-natural language models and using a fusion module to weighted output the answer, the problem of insufficient accuracy of question answering models when processing natural language and code tasks is solved, achieving higher accuracy and reliability.

CN117114108BActive Publication Date: 2026-04-17IFLYTEK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
IFLYTEK CO LTD
Filing Date
2023-08-14
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

In existing technologies, question-answering models struggle to simultaneously achieve both general effectiveness and code efficiency, failing to reach optimal accuracy when handling both natural and non-natural language tasks.

Method used

The system uses natural language models and non-natural language models to answer queries, and determines the fusion weights through a fusion module. The answer information is then output based on the weighted average. The fusion module is trained using sample query statements and answer labels.

Benefits of technology

This enables the output of answer information that better matches the needs of query statements in both natural language and non-natural language tasks, thereby improving the reliability and accuracy of the answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117114108B_ABST
    Figure CN117114108B_ABST
Patent Text Reader

Abstract

This invention provides a question-answering method, a question-answering model training method, an all-in-one machine, and a storage medium. The method includes: acquiring a question statement; answering the question statement based on a natural language model and a non-natural language model, respectively, to obtain the natural language output of the natural language model and the non-natural language output of the non-natural language model; determining a fusion weight based on the natural language output and the non-natural language output, and weighting the natural language output and the non-natural language output based on the fusion weight to obtain the answer information corresponding to the question statement. The method, all-in-one machine, and storage medium provided by this invention, through the application of fusion weights, enable targeted bias towards outputs that better match the needs of the question statement in determining the answer information, thereby obtaining answer information that is more closely aligned with the needs of the question statement, more reliable, and more accurate. This ensures that the desired effect is achieved for both natural language-related tasks and non-natural language-related tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a question-answering method, a question-answering model training method, an all-in-one machine, and a storage medium. Background Technology

[0002] Computer-generated code has become one of the hot research topics in software engineering in recent years.

[0003] Existing code generation methods can train models by combining a large amount of general natural language task data with programming language code task data, so that the model can handle both general and code tasks.

[0004] However, the models trained using the above methods cannot simultaneously achieve the best general performance and code performance. Due to limitations in processing accuracy, they are difficult to promote and apply. Summary of the Invention

[0005] This invention provides a question-answering method, a question-answering model training method, an all-in-one machine, and a storage medium to address the shortcomings of existing technologies where models struggle to achieve both general-purpose performance and code efficiency.

[0006] This invention provides a question-and-answer method, comprising:

[0007] Get the query statement;

[0008] The query statement is answered based on the natural language model and the non-natural language model, respectively, to obtain the natural language output of the natural language model and the non-natural language output of the non-natural language model.

[0009] Based on the natural language output and the non-natural language output, a fusion weight is determined, and based on the fusion weight, the natural language output and the non-natural language output are weighted to obtain the answer information corresponding to the query statement.

[0010] According to a question-answering method provided by the present invention, determining the fusion weight based on the natural language output and the non-natural language output includes:

[0011] Based on the fusion module, the fusion weights corresponding to the natural language output and the non-natural language output are determined;

[0012] The fusion module is trained based on sample query statements and sample answer labels, combined with the natural language model and the non-natural language model.

[0013] According to a question-answering method provided by the present invention, the step of determining a fusion weight based on the natural language output and the non-natural language output, and weighting the natural language output and the non-natural language output based on the fusion weight to obtain the answer information corresponding to the query statement includes:

[0014] Based on the natural language output and the non-natural language output under each output unit, the fusion weight of each output unit is determined, and based on the fusion weight of each output unit, the natural language output and the non-natural language output under each output unit are weighted and fused to obtain the answer information corresponding to the query statement.

[0015] According to a question-answering method provided by the present invention, the natural language model is trained based on a first sample data, and the non-natural language model is trained based on a second sample data;

[0016] The ratio of natural language samples to non-natural language samples in the first sample data is greater than the ratio of natural language samples to non-natural language samples in the second sample data.

[0017] According to a question-answering method provided by the present invention, the natural language model is obtained by training the pre-trained language model using the first sample data, and the non-natural language model is obtained by training the pre-trained language model using the second sample data.

[0018] According to a question-answering method provided by the present invention, the non-natural language model includes a code model and / or a mathematical model.

[0019] The present invention also provides a question-and-answer all-in-one machine, including a memory, a processor, a natural language model, a non-natural language model stored in the memory, and a computer program stored in the memory and executable on the processor;

[0020] When the processor executes the computer program, it invokes the natural language model and the non-natural language model to implement the question-answering method described above.

[0021] This invention also provides a question-answering model training method, comprising:

[0022] Based on the natural language model and the non-natural language model, the sample query statements are answered respectively to obtain the sample natural language output of the natural language model and the sample non-natural language output of the non-natural language model.

[0023] Obtain the initial fusion module, and based on the initial fusion module, determine the sample fusion weights corresponding to the sample natural language output and the sample non-natural language output;

[0024] Based on the sample fusion weights, the sample natural language output and the sample non-natural language output are weighted to obtain sample answer information;

[0025] Based on the sample answer information and the sample answer tags of the sample query statements, the initial fusion module is iterated to obtain the fusion module;

[0026] The question-answering model is determined based on the natural language model, the non-natural language model, and the fusion module.

[0027] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the question-and-answer method as described above.

[0028] The present invention also provides a computer program product, comprising at least one of a computer program, a natural language model, and a non-natural language model, wherein the computer program is executed by a processor to invoke the natural language model and the non-natural language model to implement the question-answering method described above.

[0029] The question-answering method, question-answering model training method, all-in-one machine, and storage medium provided by this invention determine the fusion weights based on natural language output and non-natural language output. The application of fusion weights enables the determination of answer information to be selectively biased towards the output that is more closely aligned with the needs of the query statement, thereby obtaining answer information that is more closely aligned with the needs of the query statement, more reliable, and more accurate. This ensures that the question-answering method achieves the expected results whether it is applied to natural language-related tasks or non-natural language-related tasks. Attached Figure Description

[0030] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0031] Figure 1 This is one of the flowcharts of the question-and-answer method provided by the present invention;

[0032] Figure 2 This is the second flowchart of the question-and-answer method provided by the present invention;

[0033] Figure 3 This is a flowchart illustrating the question-answering model training method provided by the present invention;

[0034] Figure 4This is a schematic diagram of the question-and-answer device provided by the present invention;

[0035] Figure 5 This is a schematic diagram of the question-and-answer all-in-one machine provided by the present invention. Detailed Implementation

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

[0037] Most existing code generation methods can be divided into two categories. One category utilizes the statistical characteristics inherent in programming languages ​​to build machine learning models for code generation in those languages. The other category trains a model by combining a large amount of general natural language task data with code task data from programming languages, enabling the model to handle both general and code tasks.

[0038] However, machine learning models built upon the inherent characteristics of programming languages ​​cannot ignore the expressive differences between programming languages ​​and natural language. They are typically limited to solving code-type problems and cannot be used to solve general natural language problems. Furthermore, models trained using both general task data and code task data cannot simultaneously achieve optimal general performance and code-specific performance.

[0039] To address the aforementioned issues, embodiments of the present invention provide a question-and-answer method to ensure that both general and code-related effects achieve the desired results.

[0040] Figure 1 This is one of the flowcharts illustrating the question-and-answer method provided by this invention, such as... Figure 1 As shown, the method includes:

[0041] Step 110: Obtain the query statement.

[0042] Specifically, a query statement is used to represent a question to be answered. A query statement can be text expressed in natural language, and it can also contain non-natural language. Non-natural language refers to languages ​​other than natural language, such as programming languages ​​like Java and C++, or mathematical and chemical languages. For example, when a user expects to obtain a code explanation for a certain piece of code through a question-and-answer format, the query statement can contain either code expressed in non-natural language or a request for code explanation expressed in natural language.

[0043] The query statement can be a statement directly entered by the user, such as "Please write the code to enable the camera". Alternatively, the query statement can be generated based on the user's input, combined with a pre-defined query template. For example, if the user enters "Code {}, this code needs correction", based on a query template for code correction, the query statement "Please carefully analyze the following code snippet: {}, and identify all potential errors or vulnerabilities. Please describe each error and its corresponding correction method, and provide the corrected code" can be generated. Furthermore, the query statement can also be automatically generated based on the computer's design logic; this embodiment of the invention does not specifically limit this.

[0044] Step 120: Based on the natural language model and the non-natural language model, answer the query statement respectively to obtain the natural language output of the natural language model and the non-natural language output of the non-natural language model.

[0045] Specifically, after receiving the query statement, corresponding answer information can be generated based on it. Here, for the generation of answer information, a natural language model and a non-natural language model can be pre-trained. Both the natural language model and the non-natural language model can be trained based on a Large Language Model (LLM).

[0046] Corresponding to the natural and non-natural languages ​​mentioned above, the natural language model in this embodiment of the invention has the ability to process tasks related to natural language, which are general language tasks such as text generation and text translation; the non-natural language model has the ability to process tasks related to non-natural language. For example, for programming languages, the non-natural language model can specifically be a code model, and the corresponding tasks can be code generation, code completion, code interpretation, code correction, code testing, etc.; as another example, for mathematical languages, the non-natural language model can specifically be a mathematical model, and the corresponding tasks can be mathematical problem analysis, mathematical problem correction, algorithm interpretation, etc.

[0047] Since it's unclear whether the query corresponds to a natural language-related task or a non-natural language-related task, the query can be input into both a natural language model and a non-natural language model. Each model will then respond to the query and generate its own output. Here, the natural language model's response to the query is denoted as the natural language output, and the non-natural language model's response is denoted as the non-natural language output.

[0048] Understandably, since natural language models and non-natural language models have different focuses in task processing, there may be differences between natural language output and non-natural language output. For example, for the query "Please write code to turn on the camera", the non-natural language output based on the code model is more in line with the needs of the query than the natural language output based on the natural language model.

[0049] Step 130: Based on the natural language output and the non-natural language output, determine the fusion weight, and based on the fusion weight, weight the natural language output and the non-natural language output to obtain the answer information corresponding to the query statement.

[0050] Specifically, after obtaining the natural language output and the non-natural language output, the natural language output and the non-natural language output can be analyzed to determine which output is more in line with the needs of the query statement, thereby obtaining the fusion weight. The fusion weight here can be used to reflect the tendency of the final output answer information to correspond to the natural language output and the non-natural language output.

[0051] After obtaining the fusion weights, the natural language output and non-natural language output can be weighted based on these weights, and the weighted result can be used as the answer information corresponding to the query statement. For example, assuming the fusion weight is α, the weighting of natural language output and non-natural language output can be expressed as the following formula:

[0052] logits final =αlogits A +(1-α)logits B

[0053] In the formula, logits final Logits represents the answer information. A For natural language output, logits B This is non-natural language output.

[0054] The method provided in this invention determines the fusion weight based on natural language output and non-natural language output. The application of the fusion weight enables the determination of answer information to be biased towards the output that is more in line with the needs of the query statement, thereby obtaining answer information that is more in line with the needs of the query statement, more reliable, and more accurate. This ensures that the question-answering method can achieve the expected results whether it is applied to natural language related tasks or non-natural language related tasks.

[0055] Based on the above embodiments, step 130, determining the fusion weight based on the natural language output and the non-natural language output, includes:

[0056] Based on the fusion module, the fusion weights corresponding to the natural language output and the non-natural language output are determined;

[0057] The fusion module is trained based on sample query statements and sample answer labels, combined with the natural language model and the non-natural language model.

[0058] Specifically, the fusion weights can be determined through a pre-trained fusion module. It is understood that the fusion module here pre-learns the relationship between natural language output, non-natural language output, and fusion weights. The fusion module can be a fully connected layer or other neural network structure capable of outputting fusion weights; this embodiment of the invention does not impose specific limitations on it.

[0059] Training the fusion module can be achieved by combining a natural language model (NLP) and a non-natural language model (NFL). During training, the NLP and NFL can respectively perform natural language-related tasks to generate sample outputs of the query statements in both the NLP and NFL models. These two sample outputs can then serve as inputs for the fusion module's training. Pre-defined standard answers for the sample queries, i.e., sample answer labels, can be used as labels during training. This allows for supervised training of the fusion module, resulting in a module with fusion weights that reflect the tendency of the final output answer information to correspond to both natural and NFL outputs.

[0060] Therefore, the process of obtaining the answer information corresponding to the query statement based on the trained fusion module is as follows: Figure 2 As shown. Figure 2 In this context, the input prompt is the query statement, general model A is a natural language model used to perform general natural language-related tasks, and code model B is a non-natural language model used to perform code-related tasks. By inputting the query statement as the prompt into general model A and code model B respectively, the natural language output logits of general model A can be obtained. A And the non-natural language output logits of code model B. B Based on this, the natural language output logits will be generated. A Non-natural language output logits B The input is fed into the fusion module C to obtain the fusion weight α. The fusion weight α is then applied to the natural language output logits. A Non-natural language output logits B By performing a weighted summation, we can obtain the final output answer information, logits. final .

[0061] Based on any of the above embodiments Figure 3 This is a flowchart illustrating the question-answering model training method provided by the present invention. The question-answering model here includes the natural language model and non-natural language model involved in the above steps, and also includes a fusion module for fusing natural language output and non-natural language output. For example... Figure 3 As shown, the question-answering model can be trained based on the following steps. It can be understood that the fusion module used in step 130 can also be trained based on the following steps:

[0062] Step 310: Based on the natural language model and the non-natural language model, answer the sample query statements respectively to obtain the sample natural language output of the natural language model and the sample non-natural language output of the non-natural language model.

[0063] Specifically, before training the fusion module, it is necessary to obtain the trained natural language model and non-natural language model, and during the training process of the fusion module, the model parameters of the natural language model and non-natural language model remain unchanged.

[0064] To train the fusion module, we can first collect sample queries and label them with standard answers, i.e., sample answer tags corresponding to the sample queries. Considering that the fusion module needs to measure the tendency of the final output answer information to correspond to both natural language and non-natural language outputs, the sample queries and sample answer tags can be selected from a certain number of question-answer pairs from natural language tasks and a certain number from non-natural language tasks. For example, sample queries can include general natural language-related task queries such as "Give specific implementation steps for this requirement," with the corresponding sample answer tag being "Specific implementation steps"; sample queries can also include code-related task queries such as "Generate code to implement this function," with the corresponding sample answer tag being "Specific code."

[0065] After collecting sample query statements and sample answer labels, the sample query statements can be used as model inputs, fed into the natural language model and the non-natural language model respectively, to obtain the outputs generated by the natural language model and the non-natural language model in response to the sample query statements. Here, the output of the natural language model to the sample query statements is denoted as the sample natural language output, and the output of the non-natural language model to the sample query statements is denoted as the sample non-natural language output.

[0066] Step 320: Obtain the initial fusion module, and based on the initial fusion module, determine the sample fusion weights corresponding to the sample natural language output and the sample non-natural language output.

[0067] Step 330: Based on the sample fusion weight, the sample natural language output and the sample non-natural language output are weighted to obtain sample answer information.

[0068] Here, the initial fusion module is the fusion module to be trained, which can be a parameter-initialized fusion module, such as a parameter-initialized fully connected layer. The obtained sample natural language output and sample non-natural language output can be used as inputs to the initial fusion module. Based on the sample natural language output and sample non-natural language output, the initial fusion module measures the tendency of the final output answer information to correspond to the natural language output and non-natural language output, thereby obtaining and outputting the weight values ​​used to fuse the sample natural language output and sample non-natural language output, denoted here as the sample fusion weights.

[0069] After obtaining the sample fusion weights, the sample natural language output and sample non-natural language output can be weighted and summed based on the sample fusion weights, and the result of the weighted sum is recorded as the sample answer information. It can be understood that the sample answer information here is the answer information predicted by the initial fusion model.

[0070] Step 340: Based on the sample answer information and the sample answer tags, perform parameter iteration on the initial fusion module to obtain the fusion module.

[0071] Specifically, after obtaining the sample answer information, the loss value can be calculated by comparing the sample answer information and the sample answer label. This loss value is then used to iterate the parameters of the initial fusion module, and the initial fusion module after parameter iteration is used as the fusion module for subsequent question answering.

[0072] Furthermore, the loss value is calculated here based on the sample answer information and sample answer labels. This can be achieved using common language model loss functions, such as negative log-maximum likelihood loss, which can be expressed as the following formula:

[0073]

[0074] In the formula, L(u) represents the loss value, θ is the model parameter, and u i-k ,…,u i-1 Let P(u) be the token of the first k words in the preceding text. i |u i-k ,…,u i-1 ;θ) indicates that in the model parameter θ, u in the previous text i-k ,…,u i-1 In the case where the token corresponding to i at the current time is u i The probability of.

[0075] It can be understood that after completing steps 310-340, the fusion module can be obtained, and the fusion module obtained here can be directly used to execute step 130.

[0076] Based on any of the above embodiments, the training steps of the question-answering model further include:

[0077] Step 350: Determine the question-answering model based on the natural language model, the non-natural language model, and the fusion module.

[0078] Specifically, after training the fusion module, the natural language model, non-natural language model, and fusion module can be integrated to obtain a question-answering model. In this question-answering model, the outputs of the natural language model and the non-natural language model are connected to the input of the fusion module. That is, when applying the question-answering model, the question can be directly input into the model. Inside the model, the question and answer statements are input into the natural language model and the non-natural language model respectively, resulting in natural language output and non-natural language output. These outputs are then input into the fusion module, where the fusion weights are weighted, and the question-answering model outputs the weighted answer information.

[0079] Based on any of the above embodiments, step 130 includes:

[0080] Based on the natural language output and the non-natural language output under each output unit, the fusion weight of each output unit is determined, and based on the fusion weight of each output unit, the natural language output and the non-natural language output under each output unit are weighted and fused to obtain the answer information corresponding to the query statement.

[0081] Specifically, both natural language models and non-natural language models can output data according to predefined output units. These output units can be at the word level, character level, or sentence level.

[0082] Taking word-level as the output unit, both natural language output and non-natural language output can be represented as a word of length n. v The vector logits, where n v Let V be the number of words in the vocabulary. Each item in logits corresponds to the probability score of each word in the vocabulary, which can be normalized using softmax to obtain the probability P of each word. v = softmax(logits).

[0083] Accordingly, when performing weighted fusion of natural language output and non-natural language output, the aforementioned output unit can be used as the unit for updating the fusion weight. That is, the natural language output and non-natural language output of each output unit can be associated with the fusion weight of the corresponding output unit. Furthermore, when performing weighted fusion of natural language output and non-natural language output for each output unit, the weighted sum is also based on the fusion weight of the corresponding output unit.

[0084] Taking word-level output as an example, after the natural language model and the non-natural language model output the natural language output and non-natural language output of the first word respectively, the fusion module can determine the fusion weight of the first word based on the natural language output and non-natural language output of the first word, and perform weighted fusion of the natural language output and non-natural language output of the first word based on the fusion weight of the first word, thereby obtaining the first word in the answer information; subsequently, after the natural language model and the non-natural language model output the natural language output and non-natural language output of the second word respectively, the fusion module can determine the fusion weight of the second word based on the natural language output and non-natural language output of the second word, and perform weighted fusion of the natural language output and non-natural language output of the second word based on the fusion weight of the second word, thereby obtaining the second word in the answer information; and so on, until the output of the natural language model and the non-natural language model ends.

[0085] The method provided in this invention determines the fusion weight of each output unit to achieve the fusion of natural language output and non-natural language output under each output unit. The dynamic adjustment of the fusion weight can ensure the timeliness of the adjustment of the answer information to the natural language output and non-natural language output, thereby ensuring the reliability of the final output answer information.

[0086] Understandably, in multi-turn conversation scenarios, the types of tasks required by the queries in each turn may be different. For example, the first few turns may be used for code generation and interpretation, which are code-related tasks, while the last turn may be used to summarize the above conversations, which are general natural language-related tasks. Adjusting the fusion weights at the output unit level, such as word level, can ensure that the bias towards natural language output and non-natural language output is adjusted in a timely manner in multi-turn conversations, thereby ensuring that the answer information in the conversation can always maintain the expected effect as the types of tasks required by the queries change.

[0087] Based on any of the above embodiments, the natural language model is trained based on the first sample data, and the non-natural language model is trained based on the second sample data;

[0088] The ratio of natural language samples to non-natural language samples in the first sample data is greater than the ratio of natural language samples to non-natural language samples in the second sample data.

[0089] Specifically, in order to obtain a natural language model capable of handling tasks related to natural language and a non-natural language model capable of handling tasks related to non-natural language, different sample data can be selected for training the natural language model and the non-natural language model.

[0090] Here, the sample data used to train the natural language model is denoted as the first sample data, and the sample data used to train the non-natural language model is denoted as the second sample data.

[0091] To enhance logical reasoning capabilities while maintaining performance on general natural language tasks, the first sample data can include not only natural language samples but also non-natural language samples. Similarly, to improve semantic understanding and multi-turn conversation performance while maintaining performance on non-natural language tasks, the second sample data can include not only non-natural language samples but also natural language samples. In other words, both the first and second sample data can contain a mixture of natural and non-natural language samples.

[0092] Based on this, considering that natural language models and non-natural language models have different focuses in task processing, the proportion of natural language samples and non-natural language samples included in the first sample data and the second sample data can be distinguished. The proportion of natural language samples in the first sample data is higher than that in the second sample data, while the proportion of non-natural language samples in the second sample data is higher than that in the first sample data.

[0093] For example, when non-natural language specifically refers to code, the ratio of natural language samples to code samples in the first sample data used to train the natural language model can be 8:2. This ensures general performance while improving the logical reasoning ability of the natural language model with a small number of code samples. In addition, the ratio of natural language samples to code samples in the second sample data used to train the code model can be 2:8. This ensures code performance while improving the semantic understanding ability and multi-turn dialogue performance of the code model with a small number of natural language samples.

[0094] Based on any of the above embodiments, the natural language model is obtained by training the first sample data on the basis of the pre-trained language model, and the non-natural language model is obtained by training the second sample data on the basis of the pre-trained language model.

[0095] Specifically, a natural language model can be obtained by applying supervised fine-tuning (SFT) to a pre-trained language model using first sample data; similarly, a non-natural language model can be obtained by applying supervised fine-tuning (SFT) to a pre-trained language model using second sample data.

[0096] Here, the pre-trained language model used to obtain the natural language model and the non-natural language model can be the same pre-trained language model. This pre-trained language model can be a pre-trained large-scale language model (LMM), such as the Spark Cognitive Large Model.

[0097] Based on any of the above embodiments, the non-natural language model includes a code model and / or a mathematical model.

[0098] Specifically, non-natural languages ​​can include programming languages, and correspondingly, non-natural language models can include code models. Here, code models can implement functions such as code generation, code completion, code explanation, code correction, and code testing.

[0099] Furthermore, non-natural language can include mathematical language, and correspondingly, non-natural language models can include mathematical models. Here, mathematical models can realize functions such as mathematical problem analysis, mathematical problem grading, and algorithm explanation.

[0100] The following example uses a non-natural language model as the code model to illustrate a question-answering method:

[0101] First, based on the first and second sample data, a natural language model for a general task and a code model for a code task need to be trained respectively, building upon the pre-trained language model. Here, in the first sample data, the proportion of natural language samples is higher than that of code samples, and in the second sample data, the proportion of code samples is higher than that of natural language samples.

[0102] Secondly, by combining the natural language model and the code model, a fusion module is trained to measure the output tendency of both.

[0103] Subsequently, the query statement is obtained. This query statement can be used for reasoning general natural language tasks, as well as for reasoning code-related tasks.

[0104] After receiving the query statement, it can be input into the natural language model and the code model respectively. The natural language model and the code model will then answer the query statement and generate the corresponding output, namely the natural language output and the code output.

[0105] Next, the natural language output and code output can be input into the fusion module to obtain the fusion weight of the fusion module output. Then, the fusion weight is applied to the natural language output and code output for weighted summation to obtain the answer information for the query statement.

[0106] The method provided in this invention determines the fusion weight based on natural language output and code output. The application of the fusion weight enables the determination of answer information to be biased towards the output that is more in line with the needs of the query statement, thereby obtaining answer information that is more in line with the needs of the query statement, more reliable, and more accurate. This ensures that the question-answering method can achieve the expected results whether it is applied to general tasks related to natural language or code tasks.

[0107] Based on any of the above embodiments Figure 4 This is a schematic diagram of the question-and-answer device provided by the present invention, as shown below. Figure 4 As shown, the device includes:

[0108] Unit 410 is used to retrieve query statements;

[0109] The answering unit 420 is used to answer the query statement based on the natural language model and the non-natural language model respectively, to obtain the natural language output of the natural language model and the non-natural language output of the non-natural language model;

[0110] The output unit 430 is used to determine the fusion weight based on the natural language output and the non-natural language output, and to weight the natural language output and the non-natural language output based on the fusion weight to obtain the answer information corresponding to the query statement.

[0111] The apparatus provided in this invention determines the fusion weight based on natural language output and non-natural language output. The application of the fusion weight enables the determination of answer information to be biased towards the output that is more in line with the needs of the query statement, thereby obtaining answer information that is more in line with the needs of the query statement, more reliable, and more accurate. This ensures that the question-answering method can achieve the expected results whether it is applied to natural language related tasks or non-natural language related tasks.

[0112] Based on any of the above embodiments, the output unit includes:

[0113] The weight determination subunit is used to determine the fusion weights corresponding to the natural language output and the non-natural language output based on the fusion module;

[0114] The fusion module is trained based on sample query statements and sample answer labels, combined with the natural language model and the non-natural language model.

[0115] Based on any of the above embodiments, the device further includes a training unit, used for:

[0116] Based on the natural language model and the non-natural language model, the sample query statements are answered respectively to obtain the sample natural language output of the natural language model and the sample non-natural language output of the non-natural language model.

[0117] Obtain the initial fusion module, and based on the initial fusion module, determine the sample fusion weights corresponding to the sample natural language output and the sample non-natural language output;

[0118] Based on the sample fusion weights, the sample natural language output and the sample non-natural language output are weighted to obtain sample answer information;

[0119] Based on the sample answer information and the sample answer tags, the parameters of the initial fusion module are iterated to obtain the fusion module.

[0120] Based on any of the above embodiments, the output unit is specifically used for:

[0121] Based on the natural language output and the non-natural language output under each output unit, the fusion weight of each output unit is determined, and based on the fusion weight of each output unit, the natural language output and the non-natural language output under each output unit are weighted and fused to obtain the answer information corresponding to the query statement.

[0122] Based on any of the above embodiments, the natural language model is trained based on the first sample data, and the non-natural language model is trained based on the second sample data;

[0123] The ratio of natural language samples to non-natural language samples in the first sample data is greater than the ratio of natural language samples to non-natural language samples in the second sample data.

[0124] Based on any of the above embodiments, the natural language model is obtained by training the first sample data on the basis of the pre-trained language model, and the non-natural language model is obtained by training the second sample data on the basis of the pre-trained language model.

[0125] Based on any of the above embodiments, the non-natural language model includes a code model and / or a mathematical model.

[0126] Figure 5 This is a structural schematic diagram of the question-and-answer all-in-one machine provided by the present invention, as shown below. Figure 5As shown, the electronic device may include a processor 510, a communications interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communications interface 520, and the memory 530 communicate with each other via the communication bus 540. The memory 530 stores a natural language model, a non-natural language model, and a computer program stored in the memory that can run on the processor.

[0127] The processor 510 can invoke a computer program stored in memory 530 to execute a question-and-answer method, the method including:

[0128] Get the query statement;

[0129] The query statement is answered based on the natural language model and the non-natural language model, respectively, to obtain the natural language output of the natural language model and the non-natural language output of the non-natural language model.

[0130] Based on the natural language output and the non-natural language output, a fusion weight is determined, and based on the fusion weight, the natural language output and the non-natural language output are weighted to obtain the answer information corresponding to the query statement.

[0131] Here, the code processing appliance can be a privately deployed appliance for natural language models and non-natural language models. The natural language models and non-natural language models stored in the memory of the code processing appliance, as well as the computer programs used to call these models, can be obtained by downloading and installing computer program installation packages or update packages from model providers. The natural language models and non-natural language models can be placed in the installation package or update package in the form of model files.

[0132] Furthermore, when the computer program in the aforementioned memory 530 can be implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0133] On the other hand, the present invention also provides a computer program product, which includes at least one of a computer program, a natural language model, and a non-natural language model. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute the question-answering method provided by the above methods, the method including:

[0134] Get the query statement;

[0135] The query statement is answered based on the natural language model and the non-natural language model, respectively, to obtain the natural language output of the natural language model and the non-natural language output of the non-natural language model.

[0136] Based on the natural language output and the non-natural language output, a fusion weight is determined, and based on the fusion weight, the natural language output and the non-natural language output are weighted to obtain the answer information corresponding to the query statement.

[0137] Understandably, users can download and install or update computer program products from model providers, such as downloading and installing the aforementioned computer program products from cloud servers, thereby enabling them to execute the aforementioned question-answering methods on their local terminals to obtain the services provided by natural language models and non-natural language models.

[0138] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the question-and-answer methods provided by the methods described above, the method comprising:

[0139] Get the query statement;

[0140] The query statement is answered based on the natural language model and the non-natural language model, respectively, to obtain the natural language output of the natural language model and the non-natural language output of the non-natural language model.

[0141] Based on the natural language output and the non-natural language output, a fusion weight is determined, and based on the fusion weight, the natural language output and the non-natural language output are weighted to obtain the answer information corresponding to the query statement.

[0142] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0143] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0144] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A question-and-answer method, characterized in that, include: Retrieve the query statement; The query statement is answered based on a natural language model and a non-natural language model, respectively, to obtain the natural language output of the natural language model and the non-natural language output of the non-natural language model. The non-natural language model includes a code model and / or a mathematical model. Based on the natural language output and the non-natural language output under each output unit, the fusion weight of each output unit is determined, and based on the fusion weight of each output unit, the natural language output and the non-natural language output under each output unit are weighted and fused to obtain the answer information corresponding to the query statement.

2. The question-and-answer method according to claim 1, characterized in that, The determination of the fusion weights for each output unit based on the natural language output and the non-natural language output under each output unit includes: Based on the fusion module, the fusion weights of each output unit corresponding to the natural language output and the non-natural language output under each output unit are determined; The fusion module is trained based on sample query statements and sample answer labels, combined with the natural language model and the non-natural language model.

3. The question-and-answer method according to claim 1 or 2, characterized in that, The natural language model is trained based on the first sample data, and the non-natural language model is trained based on the second sample data; The ratio of natural language samples to non-natural language samples in the first sample data is greater than the ratio of natural language samples to non-natural language samples in the second sample data.

4. The question-and-answer method according to claim 3, characterized in that, The natural language model is trained using the first sample data based on the pre-trained language model, and the non-natural language model is trained using the second sample data based on the pre-trained language model.

5. A question-answering model training method, characterized in that, include: Based on natural language models and non-natural language models, sample query statements are answered respectively to obtain sample natural language output of the natural language model and sample non-natural language output of the non-natural language model. The non-natural language model includes code model and / or mathematical model. Obtain the initial fusion module, and based on the initial fusion module, determine the sample fusion weights of each output unit corresponding to the sample natural language output and the sample non-natural language output under each output unit; Based on the sample fusion weights of each output unit, the sample natural language output and sample non-natural language output under each output unit are weighted to obtain sample answer information; Based on the sample answer information and the sample answer tags of the sample query statements, the initial fusion module is iterated to obtain the fusion module; The question-answering model is determined based on the natural language model, the non-natural language model, and the fusion module.

6. A question-and-answer all-in-one machine, characterized in that, Includes a memory, a processor, and a natural language model, a non-natural language model, and a computer program stored in the memory and capable of running on the processor; When the processor executes the computer program, it invokes the natural language model and the non-natural language model to implement the question-answering method as described in any one of claims 1 to 4.

7. A computer program product, characterized in that, It includes at least one of a computer program, a natural language model, and a non-natural language model, wherein the computer program is executed by a processor to invoke the natural language model and the non-natural language model to implement the question-answering method as described in any one of claims 1 to 4.

8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the question-and-answer method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Visual question and answer processing method and device, computer readable medium and program product

    CN113722458A

  • Universal physician ranking system based on an integrative model of physician expertise

    US20210350915A1