Answer reasoning method and device, electronic equipment and storage medium

By detecting and converting language types and using probability sampling algorithm to generate candidate answer sets, the ambiguity and semantic drift problems of the model when dealing with complex semantics are solved, and the stability and reliability of the model are improved.

CN120012939APending Publication Date: 2025-05-16SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510161613.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-13
Publication Date
2025-05-16

AI Technical Summary

Technical Problem

The model may experience ambiguity and semantic drift when understanding and processing complex semantics, or the model outputs completely different answers due to the perturbation of the input, reducing the stability and reliability of the model.

Method used

By obtaining the inference problem and detecting its language type, converting it into the first and second language versions respectively, and using the probability sampling algorithm to input it multiple times into the preset language model, a set of candidate answers including N candidate answers is generated, from which one candidate answer is determined as the inference answer.

Benefits of technology

It reduces the biased impact of the inference problem of single language type, avoids local optimal solutions, generates more accurate inference answers, and improves the accuracy and robustness of model prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120012939A_ABST
    Figure CN120012939A_ABST
Patent Text Reader

Abstract

The invention discloses an answer reasoning method and device, electronic equipment and a storage medium, and relates to the technical field of machine learning, and the method comprises the steps: obtaining a reasoning question, detecting the language type of the reasoning question, and if the reasoning question is detected to be a first language type, judging whether the reasoning question is a second language type; inputting the reasoning problem into a first language version input by a corresponding first language type cue word template generation model; converting the first language type of the reasoning problem into a second language type expression through a preset language model, and inputting the reasoning problem expressed by the second language type into a second language version input by a corresponding second language type cue word template generation model; and based on a probability sampling algorithm, inputting the first language version and the second language version into a preset language model for multiple times, generating N candidate answers, and determining one candidate answer from the N candidate answers as a reasoning answer of the reasoning question. According to the method, the problems of ambiguity and semantic drift during model reasoning can be reduced, and the accuracy and robustness of model prediction are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of machine learning, and in particular to a method, device, electronic device and storage medium for reasoning about an answer. Background Art

[0002] With the development of machine learning and big data technology, the model is an artificial intelligence technology based on deep learning. Its core idea is to learn the potential patterns and semantic information of language through large-scale pre-training and fine-tuning. In practical applications, facing complex and diverse real-world scenarios, the model may encounter ambiguity and semantic drift when understanding and processing complex semantics, or the input disturbance may cause the model to output completely different answers, which will reduce the stability and reliability of the model.

[0003] Currently, the prompt words are usually sent to multiple preset models to obtain multiple generated answers, and the multiple generated answers are comprehensively optimized to obtain the optimized answer. However, although this method can improve the accuracy and reliability of the answers generated by a single model, it increases the training cost and memory usage of the model. Summary of the invention

[0004] The present application provides an answer reasoning method, device, electronic device and storage medium to at least solve the problem of ambiguity and semantic drift that may occur when the model in the related art understands and processes complex semantics, or the problem that the input disturbance may cause the model to output completely different answers, thereby reducing the stability and reliability of the model prediction.

[0005] The present application provides an answer reasoning method, the method comprising: obtaining a reasoning question and detecting a language type of the reasoning question; if it is detected that the reasoning question is of a first language type, inputting the reasoning question expressed in the first language type into a corresponding first language type prompt word template, and generating a first language version of a model input of the reasoning question through the first language type prompt word template; and converting the first language type of the reasoning question into a second language type expression through a preset language model, and inputting the reasoning question expressed in the second language type into a corresponding second language type prompt word template, and generating a second language version of the model input of the reasoning question through the second language type prompt word template; based on a probability sampling algorithm, inputting the first language version and the second language version into a preset language model for multiple times, and generating a candidate answer set including N candidate answers through the preset language model, where N≥1 and is a positive integer; determining a candidate answer from the N candidate answers as the reasoning answer to the reasoning question, and outputting the reasoning answer.

[0006] The present application also provides an answer reasoning device, which includes: an acquisition module, which is used to acquire a reasoning question and detect the language type of the reasoning question; a processing module, which is used to input the reasoning question into a corresponding first language type prompt word template if it is detected that the reasoning question is of a first language type, and generate a first language version of the model input of the reasoning question through the first language type prompt word template; the processing module is also used to convert the first language type of the reasoning question into a second language type expression through a preset language model, and input the reasoning question expressed in the second language type into a corresponding second language type prompt word template, and generate a second language version of the model input of the reasoning question through the second language type prompt word template; the processing module is also used to input the first language version and the second language version into the preset language model multiple times based on a probability sampling algorithm, and generate a candidate answer set including N candidate answers through the preset language model, where N≥1 and is a positive integer; the processing module is also used to determine a candidate answer from the N candidate answers as the reasoning answer to the reasoning question, and output the reasoning answer.

[0007] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of the reasoning method for any of the above answers when executing the computer program.

[0008] The present application also provides a computer-readable storage medium, in which a computer program is stored, wherein when the computer program is executed by a processor, the steps of the reasoning method for any of the above answers are implemented.

[0009] The present application also provides a computer program product, including a computer program, which implements the steps of the reasoning method for any of the above answers when the computer program is executed by a processor.

[0010] Through this application, since the reasoning answer is a candidate answer in a candidate answer set, and the candidate answer in the candidate answer set is obtained by inputting the first language version and the second language version into the preset language model multiple times, therefore, compared with the single language type reasoning problem for answer reasoning, the use of reasoning problems of different language types for answer reasoning reduces the bias effect of answer reasoning for a single language type reasoning problem. In addition, based on the probability sampling algorithm, a candidate answer set including N candidate answers is generated, which can avoid falling into a local optimal solution, generate more accurate reasoning answers, and improve the accuracy and robustness of model predictions. This solves the problem of ambiguity and semantic drift that may occur when the model understands and processes complex semantics in the related technology, and the problem that the input disturbance may cause the model to output completely different answers, reducing the stability and reliability of the model prediction. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0012] Figure 1 is a schematic diagram of a method for reasoning about an answer according to an embodiment of the present invention;

[0013] Figure 2 is a flowchart of a method for reasoning about another answer according to an embodiment of the present invention;

[0014] Figure 3 is a flowchart of a reasoning method for another answer according to an embodiment of the present invention;

[0015] Figure 4 is a structural block diagram of an inference device for an answer according to an embodiment of the present invention;

[0016] Figure 5 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0017] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0018] It should be noted that, in the description of this application, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in this application are used to distinguish similar objects, and are not used to describe a specific order or sequence.

[0019] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0020] The specific application environment architecture or specific hardware architecture on which the execution of the reasoning method of the answer depends is described here.

[0021] The embodiments of the present invention are applied to the reasoning process of language models in understanding and processing complex semantics. The language model can understand and generate natural language text and has powerful language understanding and generation capabilities. In practical applications, the large model can be applied to various tasks, including intelligent dialogue systems, text generation, semantic understanding, text summarization, machine translation and other fields.

[0022] In related technologies, when faced with complex and diverse real-world scenarios, language models may encounter problems of ambiguity and semantic drift when understanding and processing complex semantics. Alternatively, input disturbances may cause the model to output completely different answers, reducing the stability and reliability of the model.

[0023] In order to solve the above problems, an embodiment of the present invention provides an answer reasoning method. In this method, the answer reasoning device obtains a first reasoning question; if it is determined that the first reasoning question is expressed in a first language type, the first reasoning question expressed in the first language type is input into the corresponding prompt word template to generate a first language version of the model input of the first reasoning question; and the first reasoning question is converted into a second language type expression, and the first reasoning question expressed in the second language type is input into the corresponding prompt word template to generate a second language version of the model input of the first reasoning question; based on the probability sampling algorithm, the first language version and the second language version are respectively input into the preset language model for multiple times to generate a candidate answer set including N candidate answers; a candidate answer is determined from the N candidate answers as the reasoning answer to the first reasoning question, and the reasoning answer is output. By expressing reasoning questions in different language types, the diversity of the model's training data is increased, thereby reducing the bias influence of the distribution of training data of a single language type, avoiding the influence of a single sampling that may fall into a local optimal solution, thereby improving the accuracy and robustness of the model prediction.

[0024] In the embodiment of the present invention, the inference device of the answer can be any device with computing capability. It is understandable that the inference device of the answer also has a display interface. Exemplarily, the inference device of the answer can include but is not limited to handheld devices (such as mobile phones or tablet computers, etc.), vehicle-mounted devices, wearable devices, virtual reality (VR) terminal devices, augmented reality (AR) terminal devices, etc. Electronic devices can also be called user equipment (UE) without limitation.

[0025] According to an embodiment of the present invention, an embodiment of a method for reasoning about an answer is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0026] In this embodiment, a method for reasoning an answer is provided, which can be used for the above-mentioned answer reasoning device. Figure 1 is a flowchart of a method for reasoning about an answer according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:

[0027] S101: Obtain a reasoning question and detect the language type of the reasoning question.

[0028] Among them, reasoning questions are expressed in the first language type.

[0029] The first language type may be any language type, for example, Chinese or English.

[0030] Exemplarily, the answer reasoning device obtains the reasoning question in response to the user inputting the reasoning question.

[0031] S102: If it is detected that the reasoning question is of the first language type, the reasoning question expressed in the first language type is input into a corresponding first language type prompt word template, and a first language version of the model input of the reasoning question is generated through the first language type prompt word template.

[0032] In some optional implementations, the answer reasoning device calls the first language type prompt word template, inputs the reasoning question into the first language type prompt word template, and outputs the first language version.

[0033] Exemplarily, taking English as the first language type, if the reasoning device of the answer detects that the reasoning question is expressed in English, the reasoning question expressed in English is input into the corresponding English prompt word template to generate an English version of the model input of the reasoning question.

[0034] It can be understood that the reasoning device of the answer can generate the format content required for model input based on the reasoning problem expressed in the first language type through the first language type prompt word template, and the format content is consistent with the reasoning problem expressed in the first language type, so that the model obtains the expected output.

[0035] S103: Convert the first language type of the reasoning problem into a second language type expression through a preset language model, input the reasoning problem expressed in the second language type into a corresponding second language type prompt word template, and generate a second language version of the model input of the reasoning problem through the second language type prompt word template.

[0036] The preset language model has the function of translating text of the first language type into text of the second language type. The preset language model also has the function of presetting answers to reasoning questions.

[0037] In one example, an answer reasoning device obtains a first language type sample set and a second language type sample set; based on the first language type sample set and the second language type sample set, a preset language model is trained.

[0038] It can be understood that, since the language types of the first language type sample set and the second language type sample set are different, the answer reasoning device can ensure that the preset language type obtained by training can be exposed to diverse languages ​​and question types and learn a more comprehensive data distribution.

[0039] In some optional implementations, the reasoning device of the answer calls the second language type translation prompt word template, inputs the reasoning question and the second language type translation prompt word template into the preset language model together, and outputs the second language type expression converted from the reasoning question; calls the second language type prompt word template, inputs the reasoning question of the second language type expression into the second language type prompt word template, and outputs the second language version.

[0040] Exemplarily, taking the case where the first language type is English and the second language type is Chinese, the reasoning device of the answer calls the Chinese translation prompt word template, inputs the reasoning question and the Chinese translation prompt word template into the preset language model, and outputs the Chinese expression converted from the reasoning question; calls the Chinese prompt word template, inputs the reasoning question expressed in Chinese into the Chinese prompt word template, and outputs the Chinese version.

[0041] It can be understood that the reasoning device of the answer can convert the reasoning problem into a second language type expression through a second language type prompt word template, and generate the format content required for the model input based on the reasoning problem expressed in the second language type, and the format content is consistent with the reasoning problem expressed in the second language type, so that the model obtains the expected output.

[0042] In some optional implementations, the reasoning device of the answer calls the second language type translation prompt word template based on a probability sampling algorithm, inputs the reasoning question and the second language type translation prompt word template into a preset language model multiple times, generates a reasoning question including M candidate second language type expressions; and determines the second language type expression converted from the reasoning question from the reasoning question of the M candidate second language type expressions.

[0043] In one example, the inference device of the answer calls a second language type translation prompt word template based on a probability sampling algorithm, inputs the inference question and the second language type translation prompt word template into a preset language model together to obtain an output result; based on the probability sampling algorithm, obtains at least one sampling parameter, and generates an inference question expressed in the second language type based on the at least one sampling parameter and the output result.

[0044] The at least one sampling parameter may include temperature, top-p, and top-k.

[0045] Temperature is used to control the randomness of the output. As you can understand, lower temperature values ​​produce more deterministic results; higher temperature values ​​increase diversity.

[0046] Top-p is used to indicate that the sampling range is all words whose cumulative probability reaches p in the output results.

[0047] Top-k is used to randomly select the next word from the top k words with the highest probability in the output result.

[0048] It can be understood that the reasoning device of the answer is based on a probability sampling algorithm, and can generate multiple reasoning questions expressed in the second language type through at least one different sampling parameter, and then generate reasoning questions including M second language type expressions, and determine the second language type expression converted from the reasoning questions expressed in the M second language type, so as to make the determined second language type expression converted from the reasoning question more accurate.

[0049] In one example, the answer reasoning device can determine the second language type expression converted from the reasoning questions expressed in the M second language types based on a semantic clustering algorithm.

[0050] It can be understood that the reasoning device of the answer uses a semantic clustering algorithm to make the second language type expression of the determined reasoning question conversion closest to the reasoning question in terms of semantics, thereby reducing the semantic deviation caused by direct translation. At the same time, the semantic clustering algorithm can consider the contextual information of the entire sentence or paragraph, thereby selecting the second language type expression of the reasoning question conversion that is more consistent with the overall logic and intention.

[0051] S104: Based on a probability sampling algorithm, the first language version and the second language version are respectively input into a preset language model for multiple times, and a candidate answer set including N candidate answers is generated through the preset language model.

[0052] Wherein, N ≥ 1 and is a positive integer.

[0053] In some optional embodiments, the answer reasoning device counts the total number of multiple candidate answers output by a preset language model, and when the total number is equal to N, generates a candidate answer set including N candidate answers.

[0054] It can be understood that the answer reasoning device can stop generating candidate answers when the number of generated candidate answers reaches N, and then determine a candidate answer set including N candidate answers.

[0055] In some optional embodiments, the answer reasoning device obtains the content of each candidate answer among multiple candidate answers output by a preset language model; groups the multiple candidate answers according to the content to obtain multiple groups; counts the number of answers of the candidate answers in each group, and determines a target group with the largest number of answers among the multiple groups; when the number of answers corresponding to the target group is greater than or equal to a preset threshold, obtains N candidate answers and generates a candidate answer set.

[0056] The content of each candidate answer included in each group is the same. N is the total number of all candidate answers in the multiple groups. It can be understood that N can be set according to actual needs without limitation.

[0057] It can be understood that the answer reasoning device can stop generating candidate answers when the maximum number of repeated candidate answers in the generated candidate answer set is greater than or equal to a preset threshold, and then determine a candidate answer set including N candidate answers.

[0058] S105: Determine a candidate answer from the N candidate answers as the inference answer to the inference question, and output the inference answer.

[0059] In some optional embodiments, the reasoning device of the answer determines the question type of the reasoning question; determines whether the question type is the first type; if so, takes the candidate answer with the highest number of occurrences in the candidate answer set as the reasoning answer; if not, determines the reasoning answer from the candidate answer set based on a semantic clustering algorithm.

[0060] The first type is used to indicate that the reasoning question has a unique answer. For example, the first type may be a mathematical calculation type. The first type of reasoning question may be what is the sum of a first value and a second value.

[0061] Other types except the first type are used to indicate that the reasoning question does not have a unique answer. For example, other types of reasoning questions may be what the abstract of an article may be.

[0062] In one example, an answer reasoning device encodes each candidate answer in a candidate answer set to obtain each semantic vector of each candidate answer; clusters at least one semantic vector based on a semantic clustering algorithm to obtain multiple clusters, each cluster including multiple semantic vectors; counts the number of semantic vectors of multiple semantic vectors in each cluster to obtain multiple semantic vector numbers; and takes the candidate answer closest to the cluster center in the cluster corresponding to the largest number of semantic vectors among the multiple semantic vector numbers as the reasoning answer.

[0063] Among them, each semantic vector corresponds one-to-one to each candidate answer.

[0064] It can be understood that the reasoning device of the answer can determine the reasoning answer to the reasoning question from the set of candidate answers based on the question type of the reasoning question. When the reasoning question has a unique answer, the candidate answer with the highest number of occurrences is used as the reasoning answer to improve the accuracy of the reasoning answer; and when the reasoning question does not have a unique answer, the semantic clustering algorithm is used to make the second language type expression of the determined reasoning question conversion semantically closest to the reasoning question, thereby reducing the semantic deviation caused by direct translation. At the same time, the semantic clustering algorithm can consider the contextual information of the entire sentence or paragraph, so as to select the second language type expression of the reasoning question conversion that is more in line with the overall logic and intention.

[0065] Based on the above Figure 1 According to the method shown, the reasoning device of the answer can obtain a reasoning question; if it is detected that the reasoning question is expressed in a first language type, the reasoning question expressed in the first language type is generated into a first language version of the model input of the reasoning question; and the reasoning question is converted into a second language type expression, and a second language version of the model input of the reasoning question is generated; based on a probability sampling algorithm, the first language version and the second language version are respectively input into a preset language model for multiple times to generate a candidate answer set including N candidate answers; a candidate answer is determined from the N candidate answers as the reasoning answer to the reasoning question, and the reasoning answer is output.

[0066] Since the inference answer is a candidate answer in a candidate answer set, and the candidate answers in the candidate answer set are obtained by inputting the first language version and the second language version into the preset language model multiple times, compared with answer reasoning for a single language type reasoning problem, answer reasoning using reasoning problems of different language types reduces the bias effect of answer reasoning for a single language type reasoning problem. In addition, based on the probability sampling algorithm, a candidate answer set including N candidate answers is generated, which can avoid falling into a local optimal solution, generate more accurate reasoning answers, and improve the accuracy and robustness of model predictions. This solves the problem of ambiguity and semantic drift that may occur when the model understands and processes complex semantics in related technologies, as well as the problem that the model may output completely different answers due to input disturbances, reducing the stability and reliability of model predictions.

[0067] In this embodiment, another method of reasoning for an answer is provided. Figure 2 is a flowchart of a method for reasoning about another answer according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:

[0068] S201: Obtain a first reasoning question.

[0069] S202: Determine whether the first reasoning question is expressed in the first language type;

[0070] If yes, include:

[0071] S2031: Inputting a first reasoning question expressed in a first language type into a corresponding prompt word template to generate a first language version of a model input of the first reasoning question;

[0072] S2032: Convert the first reasoning question into a second language type expression through a preset language model, and input the first reasoning question expressed in the second language type into a corresponding prompt word template to generate a second language version of the model input of the first reasoning question.

[0073] If no (the first reasoning question is expressed in the second language type), then include:

[0074] S2041: Input the first reasoning question expressed in the second language type into the corresponding prompt word template to generate a second language version of the model input of the first reasoning question.

[0075] S2042: Convert the first reasoning question into a first language type expression through a preset language model, and input the first reasoning question expressed in the first language type into a corresponding prompt word template to generate a first language version of the model input of the first reasoning question.

[0076] S205: Based on a probabilistic sampling algorithm, randomly input the first language version or the second language version into a preset language model to generate corresponding candidate answers.

[0077] S206: Determine whether the stop condition is met, if not, continue to execute 205. The stop condition may be that the number of the generated multiple candidate answers reaches a first threshold, or the number of repeated candidate answers in the multiple candidate answers reaches a second threshold.

[0078] S207: If yes, stop the preset language model from continuing to generate candidate answers, and determine a candidate answer from multiple candidate answers as the reasoning answer to the first reasoning question.

[0079] In this embodiment, another method of reasoning about the answer is provided. Figure 3 is a flowchart of a method for reasoning about another answer according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:

[0080] S301: Obtain a first reasoning question.

[0081] S302: Determine whether the first reasoning question is expressed in the first language type;

[0082] If yes, include:

[0083] S3031: Inputting a first reasoning question expressed in a first language type into a corresponding prompt word template to generate a first language version of a model input of the first reasoning question;

[0084] S3032: Based on a probability sampling algorithm, the first reasoning question is converted into a second language type expression through a preset language model, and the first reasoning question expressed in the second language type is input into a corresponding prompt word template to generate a second language version of the model input of the first reasoning question.

[0085] S304: Based on a probability sampling algorithm, randomly input the first language version or the second language version into a preset language model to generate corresponding candidate answers.

[0086] S305: Determine whether the stop condition is met, if not, continue to execute S3032.

[0087] S306: If yes, stop the preset language model from continuing to generate candidate answers, and determine a candidate answer from multiple candidate answers as the reasoning answer to the first reasoning question.

[0088] If no (the first reasoning question is expressed in the second language type), then include:

[0089] S3071: Input the first reasoning question expressed in the second language type into the corresponding prompt word template to generate a second language version of the model input of the first reasoning question.

[0090] S3072: Based on a probability sampling algorithm, the first reasoning question is converted into a first language type expression through a preset language model, and the first reasoning question of the first language type expression is input into a corresponding prompt word template to generate a first language version of the model input of the first reasoning question.

[0091] S308: Based on a probability sampling algorithm, randomly input the first language version or the second language version into a preset language model to generate corresponding candidate answers.

[0092] S309: Determine whether the stop condition is met, if not, continue to execute S3072; if yes, execute S306.

[0093] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method.

[0094] The embodiment of the present application also provides a kind of reasoning device of answer, and this device is used to realize the above-mentioned embodiment and preferred implementation mode, and has been described and will not be repeated. As used below, the term "module" can realize the combination of software and / or hardware of predetermined function. Although the device described in the following embodiment is preferably realized by software, the realization of hardware, or the combination of software and hardware is also possible and conceived.

[0095] This embodiment provides an answer reasoning device, such as Figure 4 As shown, Figure 4 is a structural block diagram of an inference device for an answer according to an embodiment of the present invention, the device comprising:

[0096] The acquisition module 401 is used to acquire a reasoning question and detect the language type of the reasoning question.

[0097] The processing module 402 is used to input the reasoning question expressed in the first language type into the corresponding first language type prompt word template if it is detected that the reasoning question is of the first language type, and generate the first language version of the model input of the reasoning question through the first language type prompt word template.

[0098] The processing module 402 is also used to convert the first language type of the reasoning problem into a second language type expression through a preset language model, input the reasoning problem expressed in the second language type into a corresponding second language type prompt word template, and generate a second language version of the model input of the reasoning problem through the second language type prompt word template.

[0099] The processing module 402 is further used to input the first language version and the second language version into the preset language model multiple times based on the probability sampling algorithm, and generate a candidate answer set including N candidate answers through the preset language model, where N≥1 and is a positive integer.

[0100] The processing module 402 is further used to determine a candidate answer from the N candidate answers as an inference answer to the inference question, and output the inference answer.

[0101] In some optional implementations, the processing module 402 is specifically configured to call the first language type prompt word template, input the reasoning question into the first language type prompt word template, and output the first language version.

[0102] In some optional implementations, the processing module 402 is further specifically used to call the second language type translation prompt word template, input the reasoning problem and the second language type translation prompt word template into a preset language model, and output the second language type expression converted from the reasoning problem; call the second language type prompt word template, input the reasoning problem of the second language type expression into the second language type prompt word template, and output the second language version.

[0103] In some optional implementations, the processing module 402 is further specifically configured to call the second language type translation prompt word template based on a probability sampling algorithm, input the reasoning problem and the second language type translation prompt word template into a preset language model multiple times, generate a reasoning problem including M candidate second language type expressions, where M ≥ 1 and is a positive integer; and determine the second language type expression converted from the reasoning problem from the reasoning problem of the M candidate second language type expressions.

[0104] In some optional implementations, the processing module 402 is further specifically configured to count the total number of multiple candidate answers output by a preset language model, and when the total number is equal to N, generate a candidate answer set including N candidate answers.

[0105] In some optional embodiments, the processing module 402 is further specifically used to obtain the content of each candidate answer among multiple candidate answers output by a preset language model; group the multiple candidate answers according to the content to obtain multiple groups, and the content of each candidate answer included in each group is the same; count the number of answers of the candidate answers in each group, and determine a target group with the largest number of answers among the multiple groups; when the number of answers corresponding to the target group is greater than or equal to a preset threshold, obtain N candidate answers and generate a candidate answer set, where N is the total number of all candidate answers in the multiple groups.

[0106] In some optional implementations, the processing module 402 is further specifically used to determine the question type of the reasoning question; determine whether the question type is the first type, the first type is used to indicate that the reasoning question has a unique answer; if so, use the candidate answer with the highest number of occurrences in the candidate answer set as the reasoning answer; if not, determine the reasoning answer from the candidate answer set based on a semantic clustering algorithm.

[0107] For the description of the features in the embodiment corresponding to the reasoning device of the answer, please refer to the relevant description of the embodiment corresponding to the reasoning method of the answer, which will not be repeated here.

[0108] The embodiment of the present application also provides an electronic device, see Figure 5 , Figure 5 is a schematic diagram of the structure of an electronic device provided by an optional embodiment of the present invention, such as Figure 5 As shown, it includes a memory 10 and a processor 20, wherein the memory 10 stores a computer program, and the processor 20 is configured to run the computer program to execute the steps in the above-mentioned reasoning method embodiment of any one of the answers.

[0109] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps in any of the above-mentioned answer reasoning method embodiments when run.

[0110] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0111] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in the inference method embodiment of any of the above answers are implemented.

[0112] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the reasoning method embodiment of any of the above answers are implemented.

[0113] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0114] The above is a detailed introduction to the reasoning method, device, electronic device and storage medium of an answer provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of ​​the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.

Claims

1. A method for reasoning about an answer, characterized in that: The method comprises: Obtaining a reasoning question and detecting a language type of the reasoning question; If it is detected that the reasoning question is of the first language type, inputting the reasoning question into a corresponding first language type prompt word template, and generating a first language version of the model input of the reasoning question through the first language type prompt word template; The first language type of the reasoning problem is converted into a second language type expression by a preset language model, and the reasoning problem expressed in the second language type is input into a corresponding second language type prompt word template, and a second language version of the model input of the reasoning problem is generated by the second language type prompt word template; Based on a probabilistic sampling algorithm, the first language version and the second language version are input into the preset language model for multiple times, and a candidate answer set including N candidate answers is generated by the preset language model, where N ≥ 1 and is a positive integer; A candidate answer is determined from the N candidate answers as an inference answer to the inference question, and the inference answer is output.

2. The method according to claim 1, characterized in that: The step of inputting the reasoning question into a corresponding first language type prompt word template and generating a first language version of the model input of the reasoning question through the first language type prompt word template includes: The first language type prompt word template is called, the reasoning question is input into the first language type prompt word template, and the first language version is output.

3. The method according to claim 1, characterized in that The method of converting the first language type of the reasoning problem into a second language type expression by using a preset language model, inputting the reasoning problem expressed in the second language type into a corresponding second language type prompt word template, and generating a second language version of the model input of the reasoning problem by using the second language type prompt word template includes: Calling a second language type translation prompt word template, inputting the reasoning question and the second language type translation prompt word template into the preset language model, and outputting the second language type expression converted from the reasoning question; The second language type prompt word template is called, the reasoning question expressed in the second language type is input into the second language type prompt word template, and the second language version is output.

4. The method according to claim 3, characterized in that: The calling of the second language type translation prompt word template, inputting the reasoning question and the second language type translation prompt word template into the preset language model, and outputting the second language type expression converted from the reasoning question, comprises: Based on the probability sampling algorithm, calling the second language type translation prompt word template, inputting the reasoning question and the second language type translation prompt word template into the preset language model multiple times, and generating the reasoning question including M candidate second language type expressions, where M≥1 and is a positive integer; The second language type expression converted from the reasoning question is determined from the reasoning questions of the M candidate second language type expressions.

5. The method according to claim 1, characterized in that The generating a candidate answer set including N candidate answers by using the preset language model includes: The total number of the plurality of candidate answers output by the preset language model is counted, and when the total number is equal to N, the candidate answer set including the N candidate answers is generated by the preset language model.

6. The method according to claim 1, characterized in that The generating a candidate answer set including N candidate answers by using the preset language model includes: Obtaining the content of each of the candidate answers among the multiple candidate answers output by the preset language model; According to the content, the plurality of candidate answers are grouped to obtain a plurality of groups, wherein the content of each candidate answer included in each group is the same; Counting the number of answers of the candidate answers in each of the groups, and determining a target group with the largest number of answers among the multiple groups; When the number of answers corresponding to the target group is greater than or equal to a preset threshold, the N candidate answers are obtained to generate the candidate answer set, where N is the total number of all candidate answers in the multiple groups.

7. The method according to any one of claims 1 to 6, characterized in that: The step of determining a candidate answer from the N candidate answers as the reasoning answer to the reasoning question includes: determining a problem type of the reasoning problem; Determining whether the question type is a first type, where the first type is used to indicate that the reasoning question has a unique answer; If yes, then the candidate answer with the highest number of occurrences in the candidate answer set is used as the inference answer; If not, the inferred answer is determined from the candidate answer set based on a semantic clustering algorithm.

8. A device for reasoning an answer, characterized in that: The device comprises: An acquisition module, used for acquiring a reasoning question and detecting a language type of the reasoning question; a processing module, configured to input the reasoning question into a corresponding first language type prompt word template if it is detected that the reasoning question is of the first language type, and generate a first language version of the model input of the reasoning question through the first language type prompt word template; The processing module is further configured to convert the first language type of the reasoning problem into a second language type expression through a preset language model, input the reasoning problem expressed in the second language type into a corresponding second language type prompt word template, and generate a second language version of the model input of the reasoning problem through the second language type prompt word template; The processing module is further configured to input the first language version and the second language version into the preset language model for multiple times based on a probability sampling algorithm, and generate a candidate answer set including N candidate answers through the preset language model, where N ≥ 1 and is a positive integer; The processing module is further used to determine a candidate answer from the N candidate answers as an inference answer to the inference question, and output the inference answer.

9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the method for inferring the answer as claimed in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the method for reasoning the answer as claimed in any one of claims 1 to 7.