Inference question answering method and device based on logical pattern prompt
By using a logic pattern-based approach to filter and combine the original responses of a large language model, its reasoning ability and response accuracy in complex tasks are improved, thus addressing the shortcomings of large language models in logical reasoning and mathematical calculation.
Patent Information
- Application Number
- CN202510219637.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2045-02-26
AI Technical Summary
Large language models perform poorly in complex tasks, especially in logical reasoning, mathematical calculation, and symbolic reasoning, lacking effective reasoning ability and answer accuracy.
By acquiring multiple representative examples of the target scenario, and using the arrangement of logical identifiers to filter and combine the original answers to the questions, the input text is constructed, thereby improving the reasoning ability of the large language model.
It enhances the large language model's understanding of the context and specific rules of the target scene, improves the model's generalization ability and the accuracy of the answers, especially in complex tasks.
Smart Images

Figure CN120317357B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, and in particular to a reasoning question and answer method and device based on logical mode prompting. BACKGROUND
[0002] In the field of natural language processing technology, large language models have shown excellent performance in general question and answer tasks. However, in more complex tasks such as logical reasoning, mathematical calculation and symbolic reasoning, large language models often perform poorly. One of the key reasons is that these problems require complex thinking ability, rather than just generating free-form text.
[0003] How to improve the reasoning ability of large language models, especially for the processing process of complex tasks, to improve the accuracy of the answers of large language models, is an important topic that needs to be solved in the industry at present. SUMMARY
[0004] The present application provides a reasoning question and answer method and device based on logical mode prompting, to improve the reasoning ability of large language models, especially for the processing process of complex tasks, to improve the accuracy of the answers of large language models.
[0005] The present application provides a reasoning question and answer method based on logical mode prompting, comprising the following steps:
[0006] Obtain a plurality of instances of the target scene to which the problem to be solved belongs, the instances being obtained based on a zero-shot prompting method, obtaining original answers of a large language model to a plurality of questions in the target scene, and filtering the original answers of the plurality of questions based on an arrangement mode of a logical identifier to obtain the instances, the logical identifier being used to represent operation logic in the target scene;
[0007] Combine the plurality of instances and the problem to be solved based on a prompt word template to construct an input text;
[0008] Input the input text into the large language model to obtain an answer result output by the large language model.
[0009] According to the reasoning question and answer method based on logical mode prompting provided by the present application, the determination process of the plurality of instances comprises:
[0010] Input a plurality of questions in the target scene into a large language model based on a zero-shot prompting method to obtain a plurality of original answers containing thinking processes output by the large language model;
[0011] Split the original answers by sentences to obtain a plurality of text segments;
[0012] The multiple text segments are divided based on the arrangement mode of the logical identifiers to obtain multiple segment sets.
[0013] Representative segments are selected from each segment set, and the multiple instances are determined based on the original answers and questions corresponding to the representative segments.
[0014] According to the reasoning question and answer method based on logical mode prompts provided by the application, the representative segments are selected from each segment set, which includes:
[0015] The text segments in each segment set are text vectorized to obtain multiple text vector sets.
[0016] The text segments corresponding to the vector expression center points in each text vector set are selected as the representative segments.
[0017] According to the reasoning question and answer method based on logical mode prompts provided by the application, the multiple text segments are divided based on the arrangement mode of the logical identifiers, which includes:
[0018] The logical identifiers contained in each text segment are determined based on the pre-determined logical identifier set in the target scene.
[0019] The multiple text segments are divided based on the arrangement mode of the identifiers contained in each text segment.
[0020] According to the reasoning question and answer method based on logical mode prompts provided by the application, the determination process of the logical identifier set includes:
[0021] In the case of the target scene being a mathematical problem question and answer scene, the logical identifier set is constructed based on mathematical symbols.
[0022] In the case of the target scene being a non-mathematical problem question and answer scene, the multiple questions are analyzed in the mathematical problem question and answer scene based on the analogy learning method of the large language model to generate a logical identifier set containing multiple logical identifiers.
[0023] According to the reasoning question and answer method based on logical mode prompts provided by the application, the number of instances is determined based on the number of logical identifiers in the logical identifier set and the number of questions in the target scene.
[0024] According to the reasoning question and answer method based on logical mode prompts provided by the application, the multiple text segments are divided based on the arrangement mode of the logical identifiers to obtain multiple segment sets, which includes:
[0025] The multiple text segments are divided according to a clustering method based on an arrangement mode of logical identifiers to obtain multiple segment sets.
[0026] The application further provides a reasoning question answering device based on logical mode prompting, comprising the following modules:
[0027] The representative example acquisition module is configured to acquire multiple representative examples of a target scene to which the problem to be solved belong, the representative examples being obtained based on a zero-shot prompting method, obtaining original answers of a large language model to multiple questions in the target scene, and being obtained by screening the original answers of the multiple questions based on an arrangement mode of logical identifiers, the logical identifiers being used to represent operation logic in the target scene.
[0028] The input text determination module is configured to combine the multiple representative examples and the problem to be solved based on a prompt word template to construct an input text.
[0029] The answer module is configured to input the input text into the large language model to obtain an answer result output by the large language model.
[0030] The application further provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the reasoning question answering method based on logical mode prompting according to any one of the above when executing the program.
[0031] The application further provides a non-transitory computer readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the reasoning question answering method based on logical mode prompting according to any one of the above.
[0032] The reasoning question answering method and device based on logical mode prompting provided by the application can screen original answers of multiple questions in a target scene based on an arrangement mode of logical identifiers to obtain multiple representative examples of the target scene. In combination with the multiple representative examples, a large language model can better understand the context and specific rules of the target scene, enhance the generalization ability of the model, provide rich background information and guidance for the model, help to generate more complete and accurate answers, and improve the reasoning ability of the large language model, especially in the processing process of complex tasks, which can improve the answer accuracy of the large language model. BRIEF DESCRIPTION OF DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in the application or the prior art, the following will briefly introduce the drawings needed in the embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.
[0034] Figure 1 is a flowchart of a logic pattern prompt-based inference question answering method provided by the present application.
[0035] Figure 2 is a question processing flowchart provided by the present application.
[0036] Figure 3 is a structural diagram of a logic pattern prompt-based inference question answering device provided by the present application.
[0037] Figure 4 is a structural diagram of an electronic device provided by the present application. DETAILED DESCRIPTION
[0038] To make the objectives, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be described clearly and completely below with reference to the drawings in the present application. Obviously, the described embodiments are some embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the protection scope of the present application.
[0039] In the field of natural language processing technology, large language models have shown excellent performance in general question answering tasks. However, in more complex tasks such as logical reasoning, mathematical calculation and symbolic reasoning, large language models often perform poorly. One of the key reasons is that these problems require complex thinking ability, rather than just generating free-form text. Currently, large language models relying on decoder structure are essentially focused on predicting the next word, and the input text and the knowledge it contains greatly affect the generation of the final answer.
[0040] The related method generally improves the prediction ability based on the way of thinking chain prompt. By providing several exemplary examples containing questions, reasoning processes and answers, the thinking chain prompt provides context guidance for downstream tasks. This method encourages large language models to generate multi-step logical reasoning, thereby maximizing the possibility of generating more logical answers. The advantage of this method lies in its simplicity and efficiency; unlike fine-tuning methods, this method does not require a large number of gradient updates and will not change the inherent ability of the model. Instead, it serves as an external knowledge enhancement. For different reasoning tasks, the model can be guided to the appropriate context, and then the demonstration set can be easily switched to activate the knowledge and ability in the relevant field.
[0041] There are two main shortcomings in the unsupervised chain-of-thought prompting method of the related method. First, there is still a significant gap between the selected demonstration set and the reasoning target. Although there have been a large number of studies on how to provide thought demonstration to enhance the reasoning ability of large language models, these methods largely rely on the semantic features of the question or answer. These features introduce irrelevant noise in a global range, which may mask the logical information required for reasoning. Therefore, the constructed demonstration set fails to effectively represent the logical knowledge of a specific field and is difficult to fully stimulate the correct reasoning of the large language model. Second, some demonstration selection methods lack explainability and scalability. These methods are mainly based on heuristic design, or use the model itself to generate additional demonstrations. The demonstration set selected by these means lacks explicit explanation in nature, making it difficult to evaluate its effectiveness or determine the direction of further optimization. This limitation is particularly prominent in scenarios where explainability is crucial.
[0042] How to improve the reasoning ability of large language models, especially the processing process for complex tasks, and improve the accuracy of the answers of large language models is an important topic that needs to be solved in the industry at present.
[0043] In view of the defects of the related method, the present application provides a reasoning question and answer method based on logical mode prompting, Figure 1 The flowchart of the reasoning question and answer method based on logical mode prompting provided by the present application is shown in Figure 1 As shown in the figure, the method comprises the following steps:
[0044] Step 110, obtaining a plurality of instances of the target scene to which the problem to be solved belongs, the instances being obtained based on a zero-shot prompting method, obtaining original answers of a large language model to a plurality of questions in the target scene, and filtering the original answers of the plurality of questions based on an arrangement mode of a logical identifier to obtain the instances, the logical identifier being used to represent operation logic in the target scene;
[0045] Step 120, combining the plurality of instances and the problem to be solved based on a prompt word template to construct an input text;
[0046] Step 130, inputting the input text into the large language model to obtain an answer result output by the large language model.
[0047] The execution subject of the reasoning question answering method based on the logic mode prompt provided by the present application can be an electronic device, a component in the electronic device, an integrated circuit, or a chip. The electronic device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a notebook computer, a palm computer, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), and the non-mobile electronic device can be a server, a network attached storage (NAS), or a personal computer (PC), without specific limitation of the present application.
[0048] The technical solution of the present application will be described in detail below with the computer executing the reasoning question answering method based on the logic mode prompt provided by the present application as an example.
[0049] In step 110, a plurality of representative examples of a target scene to which a problem to be solved belongs are obtained. The representative examples are obtained based on a zero-shot prompting method, and the original answers of a large language model to a plurality of questions in the target scene are obtained, and the original answers of the plurality of questions are filtered based on the arrangement mode of a logic identifier to obtain the original answers, and the logic identifier is used to represent the operation logic in the target scene.
[0050] It should be noted that the target scene refers to any environment with specific context, rules or operation logic, covering interactive content such as information retrieval, knowledge reasoning, decision support, etc., such as mathematical problem solving, legal consultation, programming problem solving, medical diagnosis, etc.
[0051] It is necessary to determine a plurality of representative examples of the target scene. Specifically, the determination process of the representative example can include:
[0052] A plurality of questions under the target scene are obtained. Based on the zero-shot prompting method, the original answers of a large language model to a plurality of questions are obtained.
[0053] Zero-shot learning means that the model generates answers only according to the input question or prompt without training for a specific task or providing additional labeled data. Here, it means directly asking a large language model a plurality of questions in a target scene without using additional training data.
[0054] A large language model (LLM) is a natural language processing model based on deep learning, which aims to understand and generate natural language text.
[0055] Before determining the original answers to multiple questions based on a large language model, the original large language model needs to be trained. Specifically, the training process can be implemented based on samples and labels corresponding to the samples.
[0056] Through the zero-shot prompting method, a series of questions related to the target scene are submitted to the large language model, and the model's answers to these questions are recorded.
[0057] After obtaining the original answers, the logical identifiers in the target scene are determined. Specifically, the logical identifiers are markers used to identify specific operation logic or rules in the target scene. These identifiers can be based on question types, solution structures, logical reasoning operations, etc. According to these identifiers, the original answers are filtered to retain those representative examples that conform to the operation logic of the target scene.
[0058] For example, for a mathematical solution question and answer scene, the logical identifier can be an operator in the mathematical operation process. Specifically, it can be: addition, subtraction, multiplication, division, percentage, derivative, etc.
[0059] It can be understood that, especially for the original answers to complex problems, multiple logical operations are involved. For example, for a mathematical solution question and answer scene, it can be to add and subtract first, and then perform multiplication. The multiple logical identifiers in the original answer to this question contain a specific arrangement. That is, for an original answer, it can be summarized as a logical operation segment constructed by multiple logical identifiers.
[0060] It can be understood that, for a large language model processing a large amount of questions and answers, many logical operation segments of question and answer processing can be the same or similar. Based on the extracted representative examples from the original answers, the large language model can be guided to answer new questions, which can improve the analysis efficiency and accuracy of the large language model.
[0061] After obtaining the original answers to multiple questions, the arrangement of the logical identifiers in each original answer is determined based on the identification of the logical identifiers in each original answer. Based on the arrangement of the logical identifiers, the original answers to multiple questions are filtered, and each arrangement represents a logical operation.
[0062] Specifically, the original answers with the same logical identifier arrangement can be divided into a cluster based on clustering. All original answers to the questions are divided to obtain multiple clusters. Representative examples are selected from each cluster to determine multiple representative examples of the target scene.
[0063] In step 120, the multiple representative examples and the problem to be solved are combined based on the prompt word template to construct an input text.
[0064] The prompt word template is a structured input format for guiding the large language model to generate answers that meet specific requirements. It may include question introduction, background information, specific task instructions, etc. When designing the template, the characteristics of the target scenario, the specific needs of the problem to be solved, and the output preferences of the large language model need to be considered.
[0065] The selected representative examples are combined with the problem to be solved according to the requirements of the prompt word template. This can be achieved through splicing, embedding or other methods, with the goal of constructing an input text that contains both the specific content of the representative examples and a clear indication of the problem to be solved. The combined content is then organized into the final input text.
[0066] In step 130, the input text is input into the large language model to obtain the answer result output by the large language model.
[0067] The constructed input text is submitted to the large language model, which generates a thought chain reasoning answer based on the input text.
[0068] For the processing flow of the problem to be solved, it can be as follows Figure 2 The problem processing flow provided by the present application is shown in the schematic diagram.
[0069] Specifically, a series of questions related to the target scenario are submitted to the large language model through the zero-shot prompt method, and the model's answers to these questions are recorded. After obtaining the original answers, the logical identifiers in the target scenario are determined. After obtaining the original answers to multiple questions, the arrangement of the logical identifiers in each original answer is determined based on the identification of the logical identifiers in each original answer. Based on the arrangement of the logical identifiers, the original answers to the multiple questions are filtered. Based on the prompt word template, the multiple representative examples and the problem to be solved are combined to construct an input text. The input text is input into the large language model to obtain the answer result output by the large language model.
[0070] The reasoning question and answer method based on logical pattern prompting provided by the present application filters the original answers to multiple questions in the target scenario through the arrangement of the logical identifiers, obtaining multiple representative examples of the target scenario. Combined with multiple representative examples, the large language model can better understand the context and specific rules of the target scenario, enhancing the generalization ability of the model, providing rich background information and guidance for the model, and helping to generate more complete and accurate answers, improving the reasoning ability of the large language model, especially for the processing of complex tasks, which can improve the accuracy of the large language model's answers.
[0071] In one embodiment, the determination process of multiple representative instances includes: based on the zero-shot prompting method, inputting multiple questions in the target scene into a large language model to obtain multiple original answers containing thought processes output by the large language model; splitting the original answers by sentences to obtain multiple text segments; dividing the multiple text segments based on the arrangement mode of the logical identifiers to obtain multiple segment sets; selecting representative segments from each segment set, and determining the multiple representative instances based on the original answers and questions corresponding to each representative segment.
[0072] In the target scene, first, multiple questions related to the target scene are input into a large language model in the form of natural language. These questions should be able to fully reflect the main characteristics and rules of the target scene, while maintaining a certain diversity and complexity. The large language model generates original answers containing thought processes based on these questions. These answers not only provide answers to the questions, but also show the thinking path and logical reasoning process of the model when solving the problem.
[0073] In order to more deeply analyze these original answers, the original answers are split by sentences to obtain multiple text segments. These text segments can be complete sentences, clauses or phrases, which together constitute the model's answer.
[0074] The division process aims to classify text segments with similar logical structures or functions into the same segment set. Each segment set represents a specific logical unit or reasoning step, which together constitutes the thinking framework of the model in the answering process.
[0075] From each segment set, a representative segment is selected, which reflects the logical structure of all segments in the set.
[0076] Based on the original answers and questions corresponding to each representative segment, the multiple representative instances are determined. That is, after determining a representative segment, the original answer corresponding to the representative segment and the question in the target scene corresponding to the representative segment are determined. Based on the original answer and the question, a representative instance is constructed. For each segment set, a representative instance is constructed, obtaining multiple representative instances.
[0077] In one embodiment, selecting a representative segment from each segment set includes: text vectorization of the text segments in each segment set to obtain multiple text vector sets; and selecting the text segment corresponding to the vector expression center point in each text vector set as the representative segment.
[0078] Text vectorization is the process of converting text data into numerical vectors, which can represent the features and semantic information of the text in high-dimensional space.
[0079] The purpose of calculating the vector representation of the center point is to find a vector that can represent the characteristics of the entire set. This center point vector should be able to reflect the common characteristics and distribution rules of all vectors in the set as much as possible.
[0080] It should be noted that the representative segment not only has representativeness, but also can reflect the main content and logical structure of the entire set.
[0081] In one embodiment, based on the arrangement mode of the logical identifiers, the plurality of text segments are divided, including: based on a predetermined set of logical identifiers in the target scene, logical identifier identification is performed on each text segment to determine the logical identifiers contained in the text segments; and based on the arrangement mode of the identifiers contained in the text segments, the plurality of text segments are divided.
[0082] When processing text data in the target scene, logical identifiers are used to guide how to effectively divide text segments.
[0083] After obtaining each text segment, logical identifier identification needs to be performed on each segment. Specifically, it involves matching the text in the segment with the set of logical identifiers to find all logical identifiers contained in the segment.
[0084] Rule-based methods or machine learning-based methods can be used. Rule-based methods usually involve defining a series of matching rules that can identify specific identifiers in the text. Machine learning-based methods use trained models to identify logical identifiers in the text.
[0085] After identifying the logical identifiers in each text segment, the text segments are divided according to the arrangement mode and logical relationship of these identifiers. This process aims to classify text segments with similar logical structures or functions into the same set to facilitate subsequent analysis and processing.
[0086] In one embodiment, the determination process of the set of logical identifiers includes: in the case that the target scene is a mathematical problem and question answering scene, constructing the set of logical identifiers based on mathematical symbols; in the case that the target scene is a non-mathematical problem and question answering scene, based on the analogy learning method of the large language model, performing analogy analysis of the plurality of problems in the mathematical problem and question answering scene to generate a set of logical identifiers containing a plurality of logical identifiers.
[0087] In the mathematical question and answer scenario, logical identifiers are often closely related to mathematical symbols and mathematical concepts. These identifiers can reflect the logical structure and reasoning steps of mathematical problems, and are the basis for understanding and solving mathematical problems. Common mathematical symbols in mathematical problems can be sorted out, such as plus sign (+), minus sign (-), multiplication sign (x), division sign (÷), equal sign (=), parentheses, fraction line, radical sign, etc., so as to construct a set of logical identifiers suitable for the mathematical question and answer scenario.
[0088] In non-mathematical question and answer scenarios, the analogy learning ability of large language models can be used to construct a set of logical identifiers. Analogy learning is a method of discovering new knowledge and laws by comparing the similarities between different objects or situations.
[0089] Through analogy analysis, it can be found that there are also logical relationships and reasoning steps similar to mathematical problems in non-mathematical problems. For example, key operations such as action, instruction, change, start, and execution.
[0090] In one embodiment, the number of instances is determined based on the number of logical identifiers in the set of logical identifiers and the number of problems in the target scenario.
[0091] Specifically, the formula for determining the number of instances can be:
[0092] ;
[0093] Wherein, represents the number of instances, n represents the number of logical identifiers in the set of logical identifiers, N represents the number of problems in the target scenario, represents the ceiling function, which rounds the value to the nearest integer. This formula realizes the quantitative determination process of the number of instances through quantification.
[0094] In one embodiment, the arrangement mode based on the logical identifier divides the plurality of text segments to obtain a plurality of segment sets, comprising: based on the arrangement mode of the logical identifier, the plurality of text segments are divided into a plurality of segment sets according to the clustering method.
[0095] Specifically, the text segments can be divided into K predefined clusters. This method assigns them to the nearest cluster by calculating the distance between the text segments and the cluster center.
[0096] Based on the arrangement mode of the logical identifier, the clustering method is used to divide the plurality of text segments, and a plurality of segment sets with similar logical structure and content are obtained. These sets help to better understand the logical relationship and reasoning steps of the text data, and provide strong support for subsequent analysis and processing.
[0097] The logic pattern prompt-based reasoning question answering device provided by the present application is described below, and the logic pattern prompt-based reasoning question answering device described below can be correspondingly referred to the logic pattern prompt-based reasoning question answering method described above.
[0098] As shown in Figure 3 The device comprises:
[0099] The representative example acquisition module 310 is configured to acquire a plurality of representative examples of a target scene to which a problem to be solved belongs, the representative examples being obtained based on a zero-shot prompt method, obtaining original answers of a large language model to a plurality of questions in the target scene, and being obtained by screening the original answers of the plurality of questions based on an arrangement mode of a logic identifier, the logic identifier being used to represent an operation logic in the target scene;
[0100] The input text determination module 320 is configured to combine the plurality of representative examples and the problem to be solved based on a prompt word template to construct an input text;
[0101] The answer module 330 is configured to input the input text into the large language model to obtain an answer result output by the large language model.
[0102] The logic pattern prompt-based reasoning question answering device provided by the present application screens original answers of a plurality of questions in a target scene based on an arrangement mode of a logic identifier to obtain a plurality of representative examples of the target scene. In combination with the plurality of representative examples, the large language model can better understand the context and specific rules of the target scene, enhance the generalization ability of the model, provide rich background information and guidance for the model, help to generate more complete and accurate answers, and improve the reasoning ability of the large language model, especially for the processing process of complex tasks, which can improve the answer accuracy of the large language model.
[0103] In one embodiment, the representative example acquisition module 310 is specifically configured to:
[0104] The determination process of the plurality of representative examples comprises:
[0105] Based on the zero-shot prompt method, a plurality of questions in the target scene are input into the large language model to obtain a plurality of original answers containing a thinking process output by the large language model;
[0106] The original answers are split by sentences to obtain a plurality of text segments;
[0107] Based on the arrangement mode of the logic identifier, the plurality of text segments are divided to obtain a plurality of segment sets;
[0108] select a representative segment from each of the segment sets, and determine the plurality of instances based on the original answers and questions corresponding to each of the representative segments.
[0109] In one embodiment, the instance obtaining module 310 is further specific to:
[0110] The selecting of the representative segment from each of the segment sets comprises:
[0111] Text vectorization is performed on the text segments in each of the segment sets to obtain a plurality of text vector sets;
[0112] The representative segment is selected as the text segment corresponding to the center point of the vector representation in each of the text vector sets.
[0113] In one embodiment, the instance obtaining module 310 is further specific to:
[0114] The arrangement of the logical identifiers, the dividing of the plurality of text segments comprises:
[0115] Logical identifier identification is performed on each of the text segments based on a pre-determined set of logical identifiers in the target scenario to determine the logical identifiers contained in each of the text segments.
[0116] The plurality of text segments are divided based on the arrangement of the identifiers contained in each of the text segments.
[0117] In one embodiment, the instance obtaining module 310 is further specific to:
[0118] The determination of the set of logical identifiers comprises:
[0119] In the case where the target scenario is a mathematical question and answer scenario, the set of logical identifiers is constructed based on mathematical symbols.
[0120] In the case where the target scenario is a non-mathematical question and answer scenario, the plurality of questions are subjected to analogy analysis of the mathematical question and answer scenario based on the analogy learning method of the large language model to generate a set of logical identifiers containing a plurality of logical identifiers.
[0121] In one embodiment, the instance obtaining module 310 is further specific to:
[0122] The number of instances is determined based on the number of logical identifiers in the set of logical identifiers and the number of questions in the target scenario.
[0123] In one embodiment, the instance obtaining module 310 is further specific to:
[0124] The logical identifier-based arrangement divides the plurality of text segments to obtain a plurality of segment sets, including:
[0125] The logical identifier-based arrangement divides the plurality of text segments according to the clustering method to obtain a plurality of segment sets.
[0126] Figure 4 An example of an entity structure diagram of an electronic device is shown as Figure 4 The electronic device can include a processor 410, a communications interface 420, a memory 430, and a communications bus 440, wherein the processor 410, the communications interface 420, and the memory 430 communicate with each other through the communications bus 440. The processor 410 can invoke the logical instructions in the memory 430 to execute the logical pattern prompt-based reasoning question and answer method, which includes obtaining a plurality of instances of the target scene to which the problem to be solved belongs, the instances being obtained based on a zero-shot prompt method, obtaining original answers of a large language model to a plurality of questions in the target scene, and filtering the original answers of the plurality of questions based on a logical identifier arrangement to obtain the logical identifier, which is used to represent the operation logic in the target scene.
[0127] The prompt word template is combined with the plurality of instances and the problem to be solved to construct an input text.
[0128] The input text is input into the large language model to obtain an answer result output by the large language model.
[0129] In addition, the logical instructions in the memory 430 described above can be implemented in the form of a software functional unit and sold or used as an independent product, which can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or part of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium, including a plurality of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method described in various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various program code storage media.
[0130] In another aspect, the present application also provides a computer program product comprising a computer program, which can be stored on a non-transitory computer-readable storage medium, and the computer program can be executed by a processor to enable a computer to perform the inference question answering method based on the logic pattern prompt provided by the above method, which comprises: obtaining a plurality of proxy examples of a target scene to which a problem to be solved belongs, the proxy examples being obtained based on a zero-shot prompting method, obtaining original answers of a large language model to a plurality of questions in the target scene, and screening the original answers of the plurality of questions based on an arrangement mode of a logic identifier, the logic identifier being used to represent operation logic in the target scene;
[0131] combining the plurality of proxy examples and the problem to be solved based on a prompt word template to construct an input text;
[0132] inputting the input text into the large language model to obtain an answer result output by the large language model.
[0133] In another aspect, the present application also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and the computer program can be executed by a processor to implement the inference question answering method based on the logic pattern prompt provided by the above method, which comprises: obtaining a plurality of proxy examples of a target scene to which a problem to be solved belongs, the proxy examples being obtained based on a zero-shot prompting method, obtaining original answers of a large language model to a plurality of questions in the target scene, and screening the original answers of the plurality of questions based on an arrangement mode of a logic identifier, the logic identifier being used to represent operation logic in the target scene;
[0134] combining the plurality of proxy examples and the problem to be solved based on a prompt word template to construct an input text;
[0135] inputting the input text into the large language model to obtain an answer result output by the large language model.
[0136] The device embodiments described above are only schematic, wherein the units shown as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., can be located in one place, or can be distributed on multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the present embodiment scheme. Those skilled in the art can understand and implement without creative labor.
[0137] Those skilled in the art can clearly understand the technical solutions of the various embodiments from the above description of the embodiments, and the various embodiments can be implemented by means of software with the necessary general hardware platforms, and of course, can also be implemented by hardware. Based on such understanding, the above technical solutions, essentially or in other words, the part of the prior art that makes a contribution, can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, and the like, and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0138] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for some technical features therein; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A reasoning question-answering method based on logical pattern prompts, characterized in that, include: Multiple representative examples of the target scenario to which the problem to be solved belongs are obtained. The representative examples are obtained by obtaining the original answers of the large language model to multiple questions in the target scenario based on the zero-shot prompting method, and the original answers of the multiple questions are filtered based on the arrangement of logical identifiers. The logical identifiers are used to represent the operational logic in the target scenario. Based on the prompt word template, the multiple representative examples and the problem to be solved are combined to construct the input text; The input text is input into the large language model to obtain the answer output by the large language model; The process of determining the plurality of representative examples includes: Based on the zero-shot prompting method, multiple questions in the target scenario are input into a large language model to obtain multiple original answers containing thought processes output by the large language model. The original answer was split into sentences to obtain multiple text fragments; Based on the arrangement of logical identifiers, the multiple text segments are divided to obtain multiple segment sets; Representative segments are selected from each segment set, and multiple representative examples are determined based on the original answers and questions corresponding to each representative segment.
2. The reasoning question-answering method based on logical pattern prompts according to claim 1, characterized in that, The step of selecting representative segments from each segment set includes: The text segments in each of the segment sets are vectorized to obtain multiple text vector sets; Each text segment corresponding to the vector representation center point in each text vector set is selected as the representative segment.
3. The reasoning question-answering method based on logical pattern prompts according to claim 1, characterized in that, The arrangement method based on logical identifiers, which divides the multiple text segments, includes: Based on a pre-determined set of logical identifiers in the target scene, logical identifiers are identified for each text segment to determine the logical identifiers contained in each text segment. The multiple text segments are divided based on the arrangement of the identifiers contained in each text segment.
4. The reasoning question-answering method based on logical pattern prompts according to claim 3, characterized in that, The process of determining the set of logical identifiers includes: In the case where the target scenario is a mathematical question-and-answer scenario, the set of logical identifiers is constructed based on mathematical symbols; When the target scenario is a non-mathematical question-and-answer scenario, the analogy learning method based on the large language model is used to perform analogy analysis on the multiple questions for mathematical question-and-answer scenarios, generating a set of logical identifiers containing multiple logical identifiers.
5. The reasoning question-answering method based on logical pattern prompts according to claim 3, characterized in that, The number of representative examples is determined based on the number of logical identifiers in the set of logical identifiers and the number of problems in the target scenario.
6. The reasoning question-answering method based on logical pattern prompts according to claim 1, characterized in that, The arrangement method based on logical identifiers divides the multiple text segments into multiple segment sets, including: Based on the arrangement of logical identifiers, the multiple text fragments are divided according to the clustering method to obtain multiple fragment sets.
7. A reasoning question-answering device based on logical pattern prompts, characterized in that, include: The representative example acquisition module is used to acquire multiple representative examples of the target scenario to which the problem to be solved belongs. The representative examples are obtained by acquiring the original answers of the large language model to multiple questions in the target scenario based on the zero-shot prompting method, and the original answers of the multiple questions are filtered based on the arrangement of logical identifiers. The logical identifiers are used to represent the operation logic in the target scenario. The input text determination module is used to combine the multiple representative examples and the problem to be solved based on the prompt word template to construct the input text; The answering module is used to input the input text into the large language model and obtain the answer result output by the large language model; The process of determining the plurality of representative examples includes: Based on the zero-shot prompting method, multiple questions in the target scenario are input into a large language model to obtain multiple original answers containing thought processes output by the large language model. The original answer was split into sentences to obtain multiple text fragments; Based on the arrangement of logical identifiers, the multiple text segments are divided to obtain multiple segment sets; Representative segments are selected from each segment set, and multiple representative examples are determined based on the original answers and questions corresponding to each representative segment.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the reasoning question-answering method based on logical pattern prompts as described in any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the reasoning question-answering method based on logical pattern prompts as described in any one of claims 1 to 6.
