Methods, apparatuses, computer-readable media, and electronic devices for processing question-and-answer information
By rewriting the question information multiple times and adding thought chain prompts, and using a pre-set language model to process question-and-answer information, the problem of insufficient answer accuracy in existing technologies is solved, achieving higher answer accuracy and diversity.
Patent Information
- Application Number
- CN202311827056.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-27
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2043-12-27
AI Technical Summary
Existing question-and-answer information processing methods have low accuracy, mainly due to the single reasoning path, which fails to fully explore the semantic potential of the question.
By rewriting the problem information multiple times, multiple semantically consistent rewritten problem information is generated. Each rewritten problem information is given a thought chain prompt, which is then processed using a preset language model. Finally, the target answer information is selected from the multiple answer information.
It improves the accuracy of question-and-answer information processing by generating answers through multiple rewriting and detailed intermediate reasoning processes, expanding the answer selection space and improving the accuracy of the answers.
Smart Images

Figure CN117743551B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of artificial intelligence technology, specifically relating to a method, apparatus, computer-readable medium, and electronic device for processing question-and-answer information. Background Technology
[0002] With the development of artificial intelligence (AI) technology, question-and-answer processing using AI has been widely applied in various business scenarios. Currently, most question-and-answer processing methods use pre-trained language models to identify the meaning of user questions and provide corresponding answers. However, this model processing method usually generates corresponding answers directly based on a one-to-one relationship with the user's question, resulting in a relatively simple reasoning path and consequently, the accuracy of the provided answers needs to be improved. Summary of the Invention
[0003] The purpose of this application is to provide a method, apparatus, computer-readable medium, and electronic device for processing question-and-answer information, so as to improve the accuracy of question-and-answer information processing.
[0004] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.
[0005] According to one aspect of the embodiments of this application, a method for processing question-and-answer information is provided, including:
[0006] The problem information to be processed is rewritten multiple times to obtain multiple rewritten problem information; wherein the semantic meaning of the rewritten problem information is consistent with the semantic meaning of the problem information to be processed.
[0007] Each of the rewritten question information is assigned a thought chain prompt, which is used to indicate the intermediate information needed to generate the answer information of the rewritten question information;
[0008] By using a preset language model to process the multiple rewritten question information based on the thought chain prompts corresponding to the multiple rewritten question information respectively, the answer information corresponding to the multiple rewritten question information is obtained;
[0009] Select the target answer information corresponding to the question information to be processed from the answer information corresponding to the multiple rewritten question information.
[0010] According to one aspect of the embodiments of this application, a question-and-answer information processing apparatus is provided, comprising:
[0011] The information rewriting module is used to rewrite the problem information to be processed multiple times to obtain multiple rewritten problem information; wherein, the semantic meaning of the rewritten problem information is consistent with the semantic meaning of the problem information to be processed;
[0012] The thought chain prompt information generation module is used to assign thought chain prompt information to each of the multiple rewritten question information, wherein the thought chain prompt information is used to indicate the intermediate information required to generate the answer information of the rewritten question information;
[0013] The model processing module is used to process the multiple rewritten question information based on the thought chain prompt information corresponding to the multiple rewritten question information respectively using a preset language model, so as to obtain the answer information corresponding to the multiple rewritten question information respectively;
[0014] The target answer generation module is used to select the target answer information corresponding to the question information to be processed from the answer information corresponding to the multiple rewritten question information.
[0015] In one embodiment of this application, the information rewriting module is specifically used for:
[0016] The problem information to be processed is segmented into words to obtain multiple words contained in the problem information to be processed;
[0017] The words are replaced with synonyms to obtain the synonyms corresponding to the words, and rewriting question information is generated based on the synonyms corresponding to the words.
[0018] In one embodiment of this application, the information rewriting module is specifically used for:
[0019] Semantically segment the problem information to be processed to obtain the problem text information contained in the problem information to be processed and the context information corresponding to the problem text information;
[0020] The question text information and the context information are processed using an attention mechanism to obtain question attention features and context attention features;
[0021] The problem attention features are rewritten to obtain a candidate distribution of generated results; the context attention features are rewritten to obtain a candidate distribution of copied results.
[0022] The candidate distributions of the generated results and the candidate distributions of the copied results are fused to obtain the rewriting problem information.
[0023] In one embodiment of this application, the target answer generation module is specifically used for:
[0024] The answer information corresponding to the multiple rewritten question information is classified to obtain the type of the answer information, which includes natural language answer and non-natural language answer;
[0025] Based on the type of the answer information, the target answer information corresponding to the question information to be processed is determined from multiple rewritten question information.
[0026] In one embodiment of this application, the target answer generation module is specifically used for:
[0027] When the answer information is a non-natural language answer, the answer information is normalized to obtain normalized data of the answer information;
[0028] The normalized data is run by the execution module to obtain the running result of the normalized data;
[0029] If the result of the normalized data operation indicates that the normalized data can operate normally, then the corresponding answer information will be used as the target answer information corresponding to the question information to be processed.
[0030] In one embodiment of this application, the target answer generation module is specifically used for:
[0031] If there are multiple normalized data that can be processed normally, then the answer information with the highest initial probability is selected from the multiple answer information corresponding to the multiple normalized data that can be processed normally as the target answer information corresponding to the question information to be processed; wherein, the initial probability corresponding to the answer information is the probability output by the preset language model.
[0032] In one embodiment of this application, the target answer generation module is specifically used for:
[0033] When the answer information is a natural language answer, calculate the language fluency score corresponding to the answer information;
[0034] The weighted average of the language fluency score corresponding to the answer information and the initial probability corresponding to the answer information is used as the target probability of matching the answer information with the question information to be processed; wherein, the initial probability corresponding to the answer information is the probability output by the preset language model;
[0035] The answer information corresponding to the highest target probability is selected as the target answer information corresponding to the question information to be processed.
[0036] According to one aspect of the embodiments of this application, a computer-readable medium is provided, on which a computer program is stored, which, when executed by a processor, implements the question-and-answer information processing method as described in the above technical solutions.
[0037] According to one aspect of the embodiments of this application, an electronic device is provided, the electronic device comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor executes the executable instructions to cause the electronic device to perform a question-and-answer information processing method as described in the above technical solutions.
[0038] According to one aspect of the embodiments of this application, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the question-and-answer information processing method as described in the above technical solutions.
[0039] In the technical solution provided in this application embodiment, the problem information to be processed is first rewritten multiple times to obtain multiple rewritten problem information; wherein the semantic meaning of the rewritten problem information is consistent with the semantic meaning of the problem information to be processed; then, each of the multiple rewritten problem information is assigned a thought chain prompt, which is used to indicate the intermediate information needed to generate the answer information of the rewritten problem information; next, a preset language model processes the multiple rewritten problem information based on the thought chain prompts corresponding to each of the multiple rewritten problem information to obtain the answer information corresponding to each of the multiple rewritten problem information; finally, the target answer information corresponding to the problem information to be processed is selected from the answer information corresponding to each of the multiple rewritten problem information. It can be seen that the technical solution of this application can convert the problem information to be processed into multiple rewritten problem information with consistent semantic meaning for processing, thereby describing the problem information to be processed as much as possible and providing answer information, which can improve the accuracy of the final target answer information; at the same time, the technical solution of this application assigns thought chain prompts to each rewritten problem information, and the preset language model can generate answer information based on the intermediate information of the answer generation process indicated by the thought chain prompts, according to the detailed intermediate reasoning process, further improving the accuracy of the generated answer information.
[0040] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0041] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0042] Figure 1 An exemplary system architecture block diagram illustrating the application of the technical solution of this application is shown schematically.
[0043] Figure 2 An exemplary system architecture block diagram illustrating the application of the technical solution of this application is shown schematically.
[0044] Figure 3 A flowchart illustrating a question-and-answer information processing method provided in one embodiment of this application is shown schematically.
[0045] Figure 4A A schematic diagram illustrating a model rewriting process provided in one embodiment of this application is shown.
[0046] Figure 4B The diagram illustrates the rewriting and template filling process.
[0047] Figure 5 The diagram illustrates the training process of a preset language model provided in one embodiment of this application.
[0048] Figure 6 A flowchart illustrating a question-and-answer information processing method provided in one embodiment of this application is shown schematically.
[0049] Figure 7 A schematic diagram of a text classification model provided in one embodiment of this application is shown.
[0050] Figure 8A The diagram illustrates a process for generating target answer information according to an embodiment of this application.
[0051] Figure 8B A schematic diagram illustrating the processing of non-natural language answers is shown.
[0052] Figure 9 A schematic block diagram of the question-and-answer information processing apparatus provided in an embodiment of this application is shown.
[0053] Figure 10 A schematic diagram of a computer system architecture suitable for implementing the embodiments of this application is shown. Detailed Implementation
[0054] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this application more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art.
[0055] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.
[0056] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0057] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily need to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0058] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0059] It is understood that in the specific implementation of this application, customer information (such as transaction information, reconciliation data) and other related data are involved. When the above embodiments of this application are applied to specific products or technologies, customer permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0060] Figure 1 An exemplary system architecture block diagram illustrating the application of the technical solution of this application is shown schematically.
[0061] like Figure 1As shown, the system architecture 100 may include terminal devices 110, a network 120, and a server 130. Terminal devices 110 may include smartphones, tablets, laptops, smart voice interaction devices, smart home appliances, in-vehicle terminals, etc. Server 130 may be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. Network 120 may be a communication medium of various connection types capable of providing a communication link between terminal devices 110 and server 130, such as a wired communication link or a wireless communication link.
[0062] Depending on the implementation requirements, the system architecture in this application embodiment can have any number of terminal devices, networks, and servers. For example, server 130 can be a server group composed of multiple server devices. In addition, the technical solutions provided in this application embodiment can be applied to terminal device 110, or to server 130, or can be implemented jointly by terminal device 110 and server 130. This application does not impose any special limitations on this.
[0063] Figure 2 An exemplary system architecture block diagram illustrating the application of the technical solution of this application is shown schematically.
[0064] like Figure 2 As shown, the system architecture includes a perturbation module A, a unified model B, and a result aggregation model C. In this system architecture, the problem information to be processed is input as a prompt to the perturbation module A. The perturbation module A performs multiple rewriting processes on the problem information to obtain multiple rewritten problem information messages with the same semantic meaning as the problem information to be processed. Figure 2 The input prompt variant is shown; furthermore, perturbation module A also assigns corresponding thought chain hints to the rewritten question information. These thought chain hints indicate the intermediate information needed to generate the answer information for the rewritten question information. Perturbation module A inputs its multiple output rewritten question information and the corresponding thought chain hints to the unified model B. Unified model B is the preset language model used in this application's technical solution. Unified model B processes each rewritten question information based on the thought chain hints and outputs the answer information corresponding to each rewritten question information (i.e., ...). Figure 2 The output data of the unified model B also includes the chain of thought output data generated based on the chain of thought prompts, abbreviated as COT (Chain of Thought). The unified model B provides the output data to the result aggregation model C, which selects the target answer information corresponding to the question information to be processed from the answer information corresponding to multiple rewritten question information.
[0065] The method for processing question and answer information provided in this application will be described in detail below with reference to specific implementation methods.
[0066] Figure 3 A flowchart illustrating a question-and-answer information processing method according to an embodiment of this application is shown schematically. This method can be implemented by a terminal device or a server. Figure 3 As shown, the question-and-answer information processing method provided in this embodiment includes steps 310 to 340, as detailed below:
[0067] Step 310: Rewrite the problem information to be processed multiple times to obtain multiple rewritten problem information; wherein the semantic meaning of the rewritten problem information is consistent with the semantic meaning of the problem information to be processed.
[0068] Specifically, the problem information to be processed can be presented in the form of plain text, text + image, or text + audio / video. The text information contained in the problem information can be text information directly input by the user, or text information obtained by extracting text from the user's input image or audio / video information. For example, if the user's question is "Please check the weather conditions for region A for the next few days," then the problem information to be processed is the plain text form of that user's question. As another example, if the user's question is "Please generate program code that can draw this graph," then the problem information to be processed includes the user's question text and the image from which the user needs to draw the graph. It should be noted that the problem information to be processed refers to the information generated based on user input. User input is not necessarily a conventional question; it can also be a query, an initiation of a command, or other similar information.
[0069] Rewriting is a process to generate rewritten problem information that has the same semantic meaning as the problem information to be processed. Semantic consistency means that the two represent the same meaning. Multiple rewriting processes can be performed separately using different rewriting algorithms, or multiple rewriting processes can be performed using the same algorithm. For example, multiple rewriting algorithms can be set up, and each time a different algorithm is randomly selected for rewriting, resulting in one rewritten problem message. Another example is rewriting, which can be implemented through synonym replacement, replacing words in the problem information to be processed with their corresponding synonyms to obtain rewritten problem information. When performing multiple rewriting processes, different words in the problem information to be processed can be replaced with synonyms each time, resulting in multiple different rewritten problem messages.
[0070] In one embodiment of this application, the process of rewriting the problem information to be processed includes: segmenting the problem information to obtain multiple words contained in the problem information; performing synonym replacement on the multiple words to obtain synonyms corresponding to the multiple words; and generating rewritten problem information based on the synonyms corresponding to the multiple words. That is, firstly, the problem information to be processed is segmented to obtain each word contained in the problem information; then, synonym replacement is performed on each word; and finally, rewritten problem information is generated based on the synonyms. Of course, synonym replacement is performed on words that are synonyms; if some words do not have synonyms, then synonym replacement is not performed.
[0071] In one embodiment of this application, the rewriting of the problem information to be processed can be achieved through a model based on a copy mechanism. The rewriting process includes: semantically segmenting the problem information to be processed to obtain the problem text information and the corresponding context information contained in the problem information; applying attention mechanisms to the problem text information and the context information respectively to obtain problem attention features and context attention features; performing rewriting based on the problem attention features to obtain a candidate distribution of generated results; performing rewriting based on the context attention features to obtain a candidate distribution of copied results; and fusing the candidate distributions of generated results and copied results to obtain the rewritten problem information. Specifically, the semantic information to be processed includes problem information and non-problem information. Problem information and non-problem information are separated through semantic segmentation, with the non-problem information being the context information of the problem information. Then, the problem information and context information are processed by the rewriting model, which includes an attention layer, a result generation layer, and a fusion layer. First, feature extraction is performed on the question information and context information using the attention mechanism of the attention layer, resulting in question attention features and context attention features. These two attention features are then input into the result generation layer for rewriting processing, yielding the corresponding result information. The result generated based on the question attention features serves as the candidate distribution for generated results, while the result generated based on the context attention features serves as the candidate distribution for copied results. Finally, a fusion layer merges the two results to obtain the rewritten question information. For example, Figure 4A The schematic diagram illustrates the model rewriting process, as follows: Figure 4AAs shown, after semantic segmentation, the problem description (i.e., problem information) and context information in the prompt are input into the rewriting model. The attention layer in the rewriting model extracts features from the two input data, obtaining problem attention features and context attention features. Then, based on the problem attention features, a candidate distribution for generated results is obtained, and based on the context attention features, a candidate distribution for copied results is obtained. Finally, a fusion layer (i.e., a fusion layer) merges the candidate distributions for generated results and the candidate distributions for copied results, outputting the final rewritten result.
[0072] In one embodiment of this application, the rewriting process can also be implemented through rule-based text, that is, the rewriting process is performed based on text with set rewriting rules, for example, the rewriting process is performed based on regular expressions for the problem information to be processed.
[0073] Step 320: Assign thought chain hints to each of the multiple rewrite question information. The thought chain hints are used to indicate the intermediate information needed by the model to generate the answer information of the rewrite question information.
[0074] Specifically, a Chain of Thought (COT) refers to the chain of reasoning steps involved in solving a problem and generating an answer. For example, for a problem statement "calculate the result of 1 + (2 * 3)", the COT could be: first calculate 2 * 3, then add the result of 2 * 3 to 1 to obtain the final result. COT hints are used to indicate the intermediate information needed to generate the answer to the rewritten problem statement; that is, they indicate which intermediate steps and results the model needs to execute or output during the answer generation process. For example, COT hints could be a description of the example model's reasoning process, or instructions such as "Let's think step by step to reach a conclusion." In this embodiment, different rewritten problem statements can be assigned different COT hints, or multiple rewritten problem statements can be assigned the same COT hints.
[0075] In one embodiment of this application, thought chain prompts can be assigned through template filling. That is, multiple question templates are set, and then question modules are randomly selected to assign thought chain prompts to the rewritten question information.
[0076] For example, Figure 4B A schematic diagram illustrating the rewriting and template filling process is provided. Figure 4BAs shown, the input `prompt` represents the problem information to be processed. The specific content of this problem information is: "Xiaoming sold 48 apples to his friend in April. In May, he sold half the number of apples he sold in April. How many apples did he sell in total?" This problem information is input to the rewriting module. The specific rewriting process performed by the rewriting module is described in step 310. The rewritten problem information output by the rewriting module can be: "Xiaoming sold 48 apples to his friend in April. In May, he sold half the number of apples he sold in April. How many apples did he sell in total?" Next, the rewritten problem information is given a thought chain prompt through template filling. For example, the thought chain prompt is "Please output all intermediate calculation processes and results." After template filling, the rewritten problem information and its corresponding thought chain prompt are output.
[0077] Step 330: Process the multiple rewritten question information based on the thought chain prompts corresponding to the multiple rewritten question information using a preset language model to obtain the answer information corresponding to the multiple rewritten question information.
[0078] Specifically, the preset language model can be generated based on an existing pre-trained language model. This involves incrementally fine-tuning the existing pre-trained language model using datasets from multiple specific task scenarios to obtain the preset language model. The existing pre-trained language model is a common model, such as a Large Language Model (LLM). Incremental fine-tuning refers to training the pre-trained language model using a dataset from one specific task scenario to obtain a new language model, then using the dataset from the next specific task scenario to train this new language model, and so on, until all datasets from specific task scenarios are used to train the model to obtain the preset language model. In this embodiment, the incremental fine-tuning method can be LoRa, P-tuning, full-parameter training, or other fine-tuning methods. The preset language model is used to generate corresponding answer information based on the input data. In this embodiment, the input data for the preset language model is rewritten question information. After processing a paraphrased question, the pre-defined language model outputs an answer. Simultaneously, based on the thought process hints corresponding to the paraphrased question, the pre-defined language model also outputs the corresponding thought process result. In other words, the pre-defined language model outputs not only the answer but also the reasoning process used to arrive at the answer. Furthermore, when outputting the answer, the pre-defined language model also outputs an initial probability, which is the probability that the output answer matches the question information obtained by the pre-defined language model.
[0079] For example, Figure 5 The diagram illustrates the training process of a pre-defined language model, as follows: Figure 5As shown, the downstream task set represents multiple specific task scenarios involved in the training, including question answering, entity recognition, sentiment analysis, summarization, code variable uselessness judgment, and code documentation generation. During the training of the pre-defined language model, the dataset for each specific task scenario is denoted as the specific task dataset. First, the specific task dataset is used as input to the pre-trained model (short for pre-trained language model) to train a new model. Then, the specific task dataset of the downstream tasks is used to continue training the new model. The downstream task refers to the task following the task in the current specific task dataset used for training.
[0080] Step 340: Select the target answer information corresponding to the question information to be processed from the answer information corresponding to the multiple rewritten question information.
[0081] Specifically, after obtaining the answer information corresponding to multiple rewrite questions, one can be selected as the final target answer information. For example, based on the initial probability corresponding to each answer information, the answer information corresponding to the maximum initial probability can be selected as the target answer information.
[0082] In the technical solution provided in this application embodiment, firstly, the problem information to be processed is rewritten multiple times to obtain multiple rewritten problem information; wherein, the semantic meaning of the rewritten problem information is consistent with the semantic meaning of the problem information to be processed; then, each of the multiple rewritten problem information is assigned a thought chain prompt, which is used to indicate the intermediate information needed to generate the answer information of the rewritten problem information; next, the multiple rewritten problem information is processed separately based on the thought chain prompts corresponding to the multiple rewritten problem information using a preset language model to obtain the answer information corresponding to each of the multiple rewritten problem information; finally, the target answer information corresponding to the problem information to be processed is selected from the answer information corresponding to the multiple rewritten problem information. As can be seen, the technical solution of this application can convert the problem information to be processed into multiple rewritten problem information with consistent semantic meaning for processing. This allows for the description of the problem information to be processed and the provision of answer information as much as possible, expanding the selection space of the target answer information and improving the accuracy of the final target answer information. At the same time, the technical solution of this application assigns a thought chain prompt to each rewritten problem information. The preset language model can generate answer information based on the intermediate information of the answer generation process indicated by the thought chain prompt, according to the detailed intermediate reasoning process, further improving the accuracy of the generated answer information.
[0083] Figure 6 A flowchart illustrating a question-and-answer information processing method according to an embodiment of this application is shown schematically. This embodiment is a further refinement of the above embodiment. Figure 6As shown, the question-and-answer information processing method provided in this application embodiment includes steps 610 to 650, as detailed below:
[0084] Step 610: Rewrite the problem information to be processed multiple times to obtain multiple rewritten problem information; wherein the semantic meaning of the rewritten problem information is consistent with the semantic meaning of the problem information to be processed.
[0085] Step 620: Assign thought chain hints to each of the multiple rewritten question information. The thought chain hints are used to indicate the intermediate information needed by the model to generate the answer information of the rewritten question information.
[0086] Step 630: Process the multiple rewritten question information based on the thought chain hints corresponding to the multiple rewritten question information using a preset language model to obtain the answer information corresponding to the multiple rewritten question information.
[0087] Steps 610 to 630 are the same as steps 310 to 330 in the previous embodiments, and will not be described again here.
[0088] Step 640: Classify the answer information corresponding to the multiple rewritten question information to obtain the types of answer information. The types of answer information include natural language answers and non-natural language answers.
[0089] Specifically, the answer information output by the pre-defined language model includes two types: natural language answers and non-natural language answers. Natural language answers refer to answer information expressed in the form of natural language, which is generally a language that users can understand, such as text information formed in Chinese, English, etc. Non-natural language answers refer to answer information expressed in the form of languages other than natural language, such as languages understood by machines, such as programming languages like Java and C++, or mathematical formulas, chemical formulas, and protein structures.
[0090] In one embodiment of this application, answer information can be classified using specific classification rules. For example, the language format in the answer information can be matched with non-natural language formats. When a match is found, the answer information is considered to be a non-natural language answer; when a match is not found, the answer information is considered to be a non-natural language answer.
[0091] In one embodiment of this application, answer information can be classified using a classification model; alternatively, when the type of answer information cannot be distinguished based on classification rules, a classification model can be used to classify the answer information. For example, Figure 7 A schematic diagram illustrating a text classification process provided in one embodiment of this application is shown. Figure 7As shown, the input text represents the information to be classified. In this embodiment, the input text is the answer information output by the preset language model. First, the answer information is judged by the rule engine. If the type of the answer information can be accurately determined by the pre-built rule library corresponding to the rule engine, the classification result is directly output, and the classified text is obtained. If the type of the answer information cannot be accurately determined by the pre-built rule library corresponding to the rule engine, then the answer information is regarded as unclassified text, and the answer information is classified by a text classification model based on a Bert-like structure. The text classification model based on a Bert-like structure includes three parts: preprocessing and tokenization, pre-trained model Bert / RoBERTa, and FFN+softmax. Preprocessing and tokenization (word segmentation) refers to preprocessing the answer information, filtering out text that is not within the scope of the model's dictionary, and then using the tokenization statistical model of model matching to perform word segmentation on the input text. Each word (token) after segmentation is vectorized and mapped, and then used as input to the pre-trained model Bert / RoBERTa. The pre-trained model Bert / RoBERTa extracts features from the input data and outputs a feature extraction tensor. After mapping the model's output tensor FFN (feedforward neural network) to softmax, the classification probability result is output.
[0092] Step 650: Determine the target answer information corresponding to the question information to be processed from multiple rewritten question information based on the type of answer information.
[0093] Specifically, the probability of matching answer information with the information of the question to be processed is calculated differently depending on the type of answer information.
[0094] In one embodiment of this application, when the answer information is a non-natural language answer, the answer information is first normalized to obtain normalized data. Normalization checks the structure and semantics of the answer information, correcting issues that clearly do not conform to language characteristics and predefined rules. For example, if the answer information is C++ code, normalization verifies the answer information according to the C++ code writing format and corrects formatting errors. Then, the normalized data is run through an execution module to obtain the execution result. The execution module includes a compiler, interpreter, or executor that matches the language used in the answer information. For example, if the answer information is C++ code, the execution module is a compiler or executor capable of executing C++ programs; if the answer information is Java code, the execution module is a compiler or executor capable of executing Java programs. The result of normalizing the data indicates whether the normalized data can be run correctly. If the interpreter or executor runs the normalized data without errors, the normalized data can be considered to be running correctly. If the execution module encounters errors when running the normalized data, the normalized data is considered to be not running correctly. Finally, if the result of normalizing the data indicates that it can be run correctly, it means that the normalized data can be used, and the corresponding answer information can be used as the target answer information for the question to be processed. Obviously, if the result of normalizing the data indicates that it cannot be run correctly, the corresponding answer information cannot be used as the target answer information.
[0095] In one embodiment of this application, after the normalized data of each answer information is run by the execution module, multiple normalized data that can be run normally may be obtained. At this time, one of these multiple normalized data that can be run normally needs to be selected to determine the target answer information. As mentioned above, when the preset language model outputs answer information, it also outputs the initial probability that the answer information matches the question information to be processed. At this time, the answer information with the highest initial probability can be selected as the target answer information corresponding to the question information to be processed.
[0096] In one embodiment of this application, when the answer information is a natural language answer, the language fluency score corresponding to the answer information is first calculated. The language fluency score is a quantitative representation of the natural language fluency of the answer information. This language fluency score can be obtained by calculating indicators such as METEOR (Metric for Evaluation of Translation with Explicit Ordering), for example, calculating precision, recall, F-score, etc., and taking a weighted average of all indicators to obtain the language fluency score. Then, the weighted average of the language fluency score corresponding to the answer information and the initial probability corresponding to the answer information is used as the target probability of matching the answer information with the question information to be processed. That is, the weighted average of the initial probability output by the preset language model and the language fluency score is used as the target probability of the answer information. Finally, the answer information corresponding to the maximum target probability is selected as the target answer information corresponding to the question information to be processed.
[0097] In one embodiment of this application, Figure 8A This diagram schematically illustrates the process of generating target answer information according to one embodiment of this application. Figure 8A As shown, the output text set refers to the collection of multiple answer information output by the preset language model. Output type judgment refers to the classification and processing of the answer information, i.e., the execution process of step 640 above. When the answer information is a non-natural language answer, it enters the code normalization and execution module, performs normalization processing on the answer information, and runs it through the execution module. The specific process can be referred to the corresponding description in step 650 above. For example, Figure 8B This illustration demonstrates the processing of non-natural language answers. When the answer information is non-natural language, it can be treated as code, i.e. Figure 8B The output code results shown are as follows: The output code results of the preset language model are first subjected to code normalization processing, as described in step 650, to obtain multiple normalized results (i.e., normalized data); then the normalized results are input into the compiler / executor / interpreter for execution to determine whether it can run normally. (Continue to refer to...) Figure 8AWhen the answer information is in natural language, the system proceeds to the output probability calculation and sorting module. This module calculates the target probability of the answer information based on the language fluency score and the initial probability output by the preset language model. Then, the answer information is sorted according to the target probability. The specific process can be found in the corresponding description in step 650 above. Finally, the post-processing module performs post-processing on the target answer information output by the code normalization and execution module or the output probability calculation and sorting module. Post-processing includes filtering intermediate inference processes, removing special placeholders and other symbols, and adding sentence / segmentation markers. Filtering intermediate inference processes refers to removing the thought chain result information generated by the preset language model based on the thought chain prompts. Optionally, the intermediate inference process can be omitted, i.e., the thought chain result information can be retained.
[0098] It should be noted that although the steps of the method in this application are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0099] The following describes an embodiment of the apparatus of this application, which can be used to execute the question-and-answer information processing method in the above embodiments of this application. Figure 9 A schematic block diagram of a question-and-answer information processing apparatus provided in an embodiment of this application is shown. Figure 9 As shown, the question-and-answer information processing apparatus provided in this application embodiment includes:
[0100] The information rewriting module 910 is used to rewrite the problem information to be processed multiple times to obtain multiple rewritten problem information; wherein, the semantic meaning of the rewritten problem information is consistent with the semantic meaning of the problem information to be processed;
[0101] The thought chain prompt information generation module 920 is used to assign thought chain prompt information to the multiple rewritten question information respectively. The thought chain prompt information is used to indicate the intermediate information required by the model to generate the answer information of the rewritten question information.
[0102] The model processing module 930 is used to process the multiple rewritten question information based on the thought chain prompt information corresponding to the multiple rewritten question information respectively through a preset language model, so as to obtain the answer information corresponding to the multiple rewritten question information respectively;
[0103] The target answer generation module 940 is used to select the target answer information corresponding to the question information to be processed from the answer information corresponding to the multiple rewritten question information.
[0104] In one embodiment of this application, the information rewriting module 910 is specifically used for:
[0105] The problem information to be processed is segmented into words to obtain multiple words contained in the problem information to be processed;
[0106] The words are replaced with synonyms to obtain the synonyms corresponding to the words, and rewriting question information is generated based on the synonyms corresponding to the words.
[0107] In one embodiment of this application, the information rewriting module 910 is specifically used for:
[0108] Semantically segment the problem information to be processed to obtain the problem text information contained in the problem information to be processed and the context information corresponding to the problem text information;
[0109] The question text information and the context information are processed using an attention mechanism to obtain question attention features and context attention features;
[0110] The problem attention features are rewritten to obtain a candidate distribution of generated results; the context attention features are rewritten to obtain a candidate distribution of copied results.
[0111] The candidate distributions of the generated results and the candidate distributions of the copied results are fused to obtain the rewriting problem information.
[0112] In one embodiment of this application, the target answer generation module 940 is specifically used for:
[0113] The answer information corresponding to the multiple rewritten question information is classified to obtain the type of the answer information, which includes natural language answer and non-natural language answer;
[0114] Based on the type of the answer information, the target answer information corresponding to the question information to be processed is determined from multiple rewritten question information.
[0115] In one embodiment of this application, the target answer generation module 940 is specifically used for:
[0116] When the answer information is a non-natural language answer, the answer information is normalized to obtain normalized data of the answer information;
[0117] The normalized data is run by the execution module to obtain the running result of the normalized data;
[0118] If the result of the normalized data operation indicates that the normalized data can operate normally, then the corresponding answer information will be used as the target answer information corresponding to the question information to be processed.
[0119] In one embodiment of this application, the target answer generation module 940 is specifically used for:
[0120] If there are multiple normalized data that can be processed normally, then the answer information with the highest initial probability is selected from the multiple answer information corresponding to the multiple normalized data that can be processed normally as the target answer information corresponding to the question information to be processed; wherein, the initial probability corresponding to the answer information is the probability output by the preset language model.
[0121] In one embodiment of this application, the target answer generation module 940 is specifically used for:
[0122] When the answer information is a natural language answer, calculate the language fluency score corresponding to the answer information;
[0123] The weighted average of the language fluency score corresponding to the answer information and the initial probability corresponding to the answer information is used as the target probability of matching the answer information with the question information to be processed; wherein, the initial probability corresponding to the answer information is the probability output by the preset language model;
[0124] The answer information corresponding to the highest target probability is selected as the target answer information corresponding to the question information to be processed.
[0125] The specific details of the question-and-answer information processing apparatus provided in the various embodiments of this application have been described in detail in the corresponding method embodiments, and will not be repeated here.
[0126] Figure 10 A schematic block diagram of a computer system architecture for implementing an electronic device according to embodiments of the present application is shown.
[0127] It should be noted that, Figure 10 The computer system 1000 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0128] like Figure 10As shown, the computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 1002 or programs loaded from storage section 1008 into random access memory (RAM). The RAM 1003 also stores various programs and data required for system operation. The CPU 1001, ROM 1002, and RAM 1003 are interconnected via a bus 1004. An input / output interface 1005 (I / O interface) is also connected to the bus 1004.
[0129] The following components are connected to the input / output interface 1005: an input section 1006 including a keyboard, mouse, etc.; an output section 1007 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a local area network card, modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the input / output interface 1005 as needed. A removable medium 1011, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 1010 as needed so that computer programs read from it can be installed into the storage section 1008 as needed.
[0130] Specifically, according to embodiments of this application, the processes described in the various method flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 1009, and / or installed from removable medium 1011. When the computer program is executed by central processing unit 1001, it performs various functions defined in the system of this application.
[0131] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
[0132] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0133] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of this application, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0134] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, touch terminal, or network device, etc.) to execute the method according to the embodiments of this application.
[0135] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein.
[0136] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A method of processing question and answer information, characterized by, include: The problem information to be processed is rewritten multiple times to obtain multiple rewritten problem information; wherein the semantic meaning of the rewritten problem information is consistent with the semantic meaning of the problem information to be processed; one rewriting process of the problem information to be processed includes: semantically segmenting the problem information to be processed to obtain the problem text information contained in the problem information to be processed and the context information corresponding to the problem text information; applying attention mechanism processing to the problem text information and the context information respectively to obtain problem attention features and context attention features; rewriting processing based on the problem attention features to obtain a candidate distribution of generated results; rewriting processing based on the context attention features to obtain a candidate distribution of copied results; and fusing the candidate distribution of generated results and the candidate distribution of copied results to obtain the rewritten problem information; Each of the rewritten question information is assigned a thought chain prompt, which is used to indicate the intermediate information needed by the model to generate the answer information of the rewritten question information. By using a preset language model to process the multiple rewritten question information based on the thought chain prompts corresponding to the multiple rewritten question information respectively, the answer information corresponding to the multiple rewritten question information is obtained; Select the target answer information corresponding to the question information to be processed from the answer information corresponding to the multiple rewritten question information.
2. The method of claim 1, wherein, The rewriting process for the problem information to be processed includes: The problem information to be processed is segmented into words to obtain multiple words contained in the problem information to be processed; The words are replaced with synonyms to obtain the synonyms corresponding to the words, and rewriting problem information is generated based on the synonyms corresponding to the words.
3. The method of claim 1, wherein, Selecting the target answer information corresponding to the question information to be processed from the answer information corresponding to the multiple rewritten question information, including: The answer information corresponding to the multiple rewritten question information is classified to obtain the type of the answer information, which includes natural language answer and non-natural language answer; Based on the type of the answer information, the target answer information corresponding to the question information to be processed is determined from multiple rewritten question information.
4. The method of claim 3, wherein, Based on the type of the answer information, the target answer information corresponding to the question information to be processed is determined from multiple rewritten question information, including: When the answer information is a non-natural language answer, the answer information is normalized to obtain normalized data of the answer information; the normalization process checks the structure and semantics of the answer information and corrects problems that obviously do not conform to language characteristics and pre-defined rules; The normalized data is run by the execution module to obtain the running result of the normalized data; If the result of the normalized data operation indicates that the normalized data can operate normally, then the corresponding answer information will be used as the target answer information corresponding to the question information to be processed.
5. The method of claim 4, wherein, After running the normalized data through the execution module and obtaining the running result of the normalized data, the method further includes: If there are multiple normalized data that can be processed normally, then the answer information with the highest initial probability is selected from the multiple answer information corresponding to the multiple normalized data that can be processed normally as the target answer information corresponding to the question information to be processed; wherein, the initial probability corresponding to the answer information is the probability output by the preset language model.
6. The method of claim 4, wherein, Based on the type of the answer information, the target answer information corresponding to the question information to be processed is determined from multiple rewritten question information, including: When the answer information is a natural language answer, calculate the language fluency score corresponding to the answer information; The weighted average of the language fluency score corresponding to the answer information and the initial probability corresponding to the answer information is used as the target probability of matching the answer information with the question information to be processed; wherein, the initial probability corresponding to the answer information is the probability output by the preset language model; The answer information corresponding to the highest target probability is selected as the target answer information corresponding to the question information to be processed.
7. A processing device of question and answer information, characterized by, include: An information rewriting module is used to rewrite the problem information to be processed multiple times to obtain multiple rewritten problem information; wherein the semantic meaning of the rewritten problem information is consistent with the semantic meaning of the problem information to be processed; one rewriting process of the problem information to be processed includes: semantically dividing the problem information to be processed to obtain the problem text information contained in the problem information to be processed and the context information corresponding to the problem text information; performing attention mechanism processing on the problem text information and the context information respectively to obtain problem attention features and context attention features; performing rewriting processing based on the problem attention features to obtain a candidate distribution of generated results; performing rewriting processing based on the context attention features to obtain a candidate distribution of copied results; and performing fusion processing on the candidate distribution of generated results and the candidate distribution of copied results to obtain the rewritten problem information; The thought chain prompt information generation module is used to assign thought chain prompt information to each of the multiple rewritten question information, and the thought chain prompt information is used to indicate the intermediate information required by the model to generate the answer information of the rewritten question information. The model processing module is used to process the multiple rewritten question information based on the thought chain prompt information corresponding to the multiple rewritten question information respectively using a preset language model, so as to obtain the answer information corresponding to the multiple rewritten question information respectively; The target answer generation module is used to select the target answer information corresponding to the question information to be processed from the answer information corresponding to the multiple rewritten question information.
8. A computer readable medium having stored thereon a computer program, characterized in that, When executed by a processor, the computer program implements the question-and-answer information processing method according to any one of claims 1 to 6.
9. An electronic device, comprising: include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to execute the executable instructions to enable the electronic device to implement the question-and-answer information processing method as described in any one of claims 1 to 6.
