Answer generation method and device, equipment, storage medium and product

By combining external and internal knowledge of the model, the generated answers are more reliable and accurate, solving the problem of low answer accuracy in the existing question-and-answer system and achieving higher answer accuracy.

CN119760101AActive Publication Date: 2025-04-04BEIJING QIHOOD TECHNOLOGY CO LTD

Patent Information

Application Number
CN202510179924.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-18
Publication Date
2025-04-04
Estimated Expiration
2045-02-18

AI Technical Summary

Technical Problem

In existing question and answer systems, large language models are prone to situations where the answers are inconsistent with the facts or are unfounded when generating answers, making the accuracy of the answers difficult to meet actual needs.

Method used

A method of answer generation is proposed. By obtaining the corresponding questions of dialogue instructions, the paragraphs matching the questions are retrieved from the external knowledge of the model, and corresponding paragraphs are generated based on the internal knowledge of the model through a large language model. After combining the source information, the answer is finally generated.

Benefits of technology

By combining external and internal knowledge of the model, the generated answers are more reliable and accurate, which can effectively improve the accuracy of the answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119760101A_ABST
    Figure CN119760101A_ABST
Patent Text Reader

Abstract

The invention discloses an answer generation method and device, equipment, a storage medium and a product, relates to the technical field of natural language processing, and discloses a method for obtaining a question corresponding to a dialogue instruction in response to the dialogue instruction; retrieving at least one first paragraph matched with the question from the external knowledge of the model, and generating at least one second paragraph matched with the question based on the internal knowledge of the model through the large language model; the first paragraph and the second paragraph are combined into a paragraph set, source information of each paragraph in the paragraph set is identified, and the source information indicates that the corresponding paragraph comes from the inside of the model or And through a large language model, based on the paragraph set and the source information of each paragraph in the paragraph set, generating an answer corresponding to the question. According to the method, reliable answers can be generated, and the accuracy of the answers is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language processing technology, and in particular to an answer generation method, device, equipment, storage medium and product. Background Art

[0002] With the rapid development of the Internet and the dramatic increase in the amount of information, users have an increasing demand for fast and accurate access to the information they need, so question-answering systems have emerged. Question-answering systems are a natural language processing technology that aims to automatically answer questions raised by users in natural language.

[0003] Related technologies usually use large language models to implement the answer generation function of question-answering systems. However, due to factors such as the quality and coverage of model training data, large language models are prone to generate answers that are inconsistent with facts or even unfounded, making it difficult for the accuracy of answers to meet actual needs, and there is an urgent need for improvement.

[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention

[0005] The main purpose of this application is to provide an answer generation method, device, equipment, storage medium and product that can generate reliable answers and improve the accuracy of the answers.

[0006] To achieve the above objectives, the present application proposes a method for generating an answer, the method comprising:

[0007] In response to a dialogue instruction, obtaining a question corresponding to the dialogue instruction;

[0008] Retrieving at least one first paragraph matching the question from model external knowledge, and generating at least one second paragraph matching the question based on model internal knowledge through a large language model;

[0009] Merging the first paragraph and the second paragraph into a paragraph set, and identifying source information of each paragraph in the paragraph set, wherein the source information indicates whether the corresponding paragraph is from inside the model or outside the model;

[0010] An answer corresponding to the question is generated through the large language model based on the paragraph set and source information of each paragraph in the paragraph set.

[0011] Optionally, generating an answer corresponding to the question by using the large language model based on the paragraph set and source information of each paragraph in the paragraph set includes:

[0012] By using the large language model, based on the question and the source information of each paragraph in the paragraph set, the paragraph set is iteratively updated, and the source information of each paragraph in the paragraph set obtained by each iterative update is identified, wherein the iterative update is used to retain the information that is consistent inside and outside the paragraph set and filter out the information that is inconsistent inside and outside and the irrelevant information of the question;

[0013] Based on the paragraph set obtained by each iterative update and the source information of each paragraph in the paragraph set, an answer corresponding to the question is generated.

[0014] Optionally, generating an answer corresponding to the question based on the paragraph set obtained by each iterative update and the source information of each paragraph in the paragraph set includes:

[0015] Through the large language model, based on the paragraph sets obtained from each iterative update and the source information of each paragraph in the paragraph set, alternative answers corresponding to each iterative update are generated respectively, and the answer corresponding to the question is selected from the generated multiple alternative answers.

[0016] Optionally, the model external knowledge includes a domain knowledge base, and before retrieving at least one first paragraph matching the question from the model external knowledge, the method further includes:

[0017] Obtaining a target website list, wherein the target website list includes multiple authoritative website identifiers;

[0018] Compare the primary domain name in the uniform resource locator URL corresponding to the crawled network resource with the website identifier in the target website list;

[0019] In the case where the primary domain name matches the website identifier in the target website list, the network resource is stored in the domain knowledge base.

[0020] Optionally, the model external knowledge includes a domain knowledge base, and before retrieving at least one first paragraph matching the question from the model external knowledge, the method further includes:

[0021] Determine the knowledge type involved in the content of the crawled network resources through the large language model;

[0022] In the case where the knowledge type involved in the content of the network resource matches the knowledge type of the domain knowledge base, the network resource is stored in the domain knowledge base.

[0023] Optionally, the model external knowledge includes a domain knowledge base, and before retrieving at least one first paragraph matching the question from the model external knowledge, the method further includes:

[0024] Call the risk control interface to detect harmful information on the content of the crawled network resources and obtain the harmful information detection result;

[0025] When the harmful information detection result indicates that the content of the network resource does not contain harmful information, the network resource is stored in the domain knowledge base.

[0026] Optionally, the model external knowledge includes a domain knowledge base, and retrieving at least one first paragraph matching the question from the model external knowledge includes:

[0027] The knowledge type involved in the problem is detected by using a problem detection model to obtain a type detection result;

[0028] When the type detection result indicates that the knowledge type involved in the question matches the knowledge type of the domain knowledge base, at least one first paragraph matching the question is retrieved from the network and the domain knowledge base; otherwise, at least one first paragraph matching the question is retrieved from the network.

[0029] Optionally, after obtaining, in response to the dialogue instruction, a question corresponding to the dialogue instruction, the method further includes:

[0030] Perform risk detection on the problem through the problem detection model to obtain risk detection results;

[0031] When the risk detection result indicates that there is a specified type of security risk in answering the question, a large language model that has been security-trained is selected from multiple large language models, and the large language model that has been security-trained is used to generate an answer corresponding to the question, and the answer generated by the large language model that has been security-trained does not contain harmful information.

[0032] Optionally, before obtaining the question corresponding to the dialogue instruction in response to the dialogue instruction, the method further includes:

[0033] Get a set of attack questions and a set of natural questions;

[0034] Generate answers corresponding to each question in the attack question set and the natural question set respectively by using the large language model;

[0035] Based on the answers generated by the large language model, performing a performance evaluation on the large language model;

[0036] Based on the performance evaluation results, the large language model is adjusted.

[0037] Optionally, before obtaining the question corresponding to the dialogue instruction in response to the dialogue instruction, the method further includes:

[0038] Get the question set;

[0039] Generate answers corresponding to each question in the question set respectively through multiple working modes of the large language model;

[0040] Based on the answers corresponding to the multiple working modes, performing performance evaluation on each working mode of the large language model;

[0041] Based on the performance evaluation results, the large language model is adjusted.

[0042] Optionally, the multiple working modes include at least two of a pure large model mode, an artificial intelligence AI search mode, and a retrieval enhancement generation RAG mode;

[0043] The pure large model mode refers to a mode that generates answers based only on the internal knowledge of the model;

[0044] The AI ​​search mode refers to a mode of generating answers based on the internal knowledge of the model and the knowledge retrieved by the search engine on the Internet;

[0045] The RAG mode refers to a mode for generating answers based on the internal knowledge of the model, the knowledge retrieved by the search engine on the Internet, and the knowledge in the domain knowledge base.

[0046] Optionally, the method further comprises:

[0047] Based on the answers corresponding to each question in the question set generated by the large language model using the AI ​​search mode and the RAG mode, respectively, the question set is divided into a consistent subset, a conflicting subset, and an inconsistent subset;

[0048] The questions in the consistent subset are questions that are answered correctly by both the AI ​​search mode and the RAG mode, the questions in the conflicting subset are questions that are answered correctly by either the AI ​​search mode or the RAG mode, and the questions in the inconsistent subset are questions that are answered incorrectly by both the AI ​​search mode and the RAG mode;

[0049] Based on the division results of the question set, the domain knowledge base is adjusted to improve the answer accuracy of the RAG model.

[0050] In addition, to achieve the above-mentioned purpose, the present application also proposes an answer generation device, the device comprising:

[0051] A question acquisition module, used for acquiring the question corresponding to the dialogue instruction in response to the dialogue instruction;

[0052] A paragraph acquisition module, used to retrieve at least one first paragraph matching the question from the model external knowledge, and generate at least one second paragraph matching the question based on the model internal knowledge through a large language model;

[0053] a paragraph synthesis module, configured to merge the first paragraph and the second paragraph into a paragraph set, and identify source information of each paragraph in the paragraph set, wherein the source information indicates whether the corresponding paragraph is from inside the model or outside the model;

[0054] The answer generation module is used to generate an answer corresponding to the question based on the paragraph set and the source information of each paragraph in the paragraph set through the large language model.

[0055] Optionally, the answer generation module includes:

[0056] a paragraph updating unit, configured to iteratively update the paragraph set based on the question and the source information of each paragraph in the paragraph set through the large language model, and identify the source information of each paragraph in the paragraph set obtained by each iterative update, wherein the iterative update is configured to retain the internal and external consistent information in the paragraph set and filter out the internal and external inconsistent information and irrelevant information of the question;

[0057] The answer generation unit is used to generate an answer corresponding to the question based on the paragraph set obtained by each iterative update and the source information of each paragraph in the paragraph set.

[0058] Optionally, the answer generation unit is used to generate alternative answers corresponding to each iterative update based on the paragraph set obtained by each iterative update and the source information of each paragraph in the paragraph set through the large language model, and select the answer corresponding to the question from the multiple generated alternative answers.

[0059] Optionally, the model external knowledge includes a domain knowledge base, and the device further includes:

[0060] The first knowledge base construction module is used to obtain a target website list, which includes multiple authoritative website identifiers; compare the primary domain name in the uniform resource locator URL corresponding to the crawled network resource with the website identifier in the target website list; if the primary domain name matches the website identifier in the target website list, store the network resource in the domain knowledge base.

[0061] Optionally, the model external knowledge includes a domain knowledge base, and the device further includes:

[0062] The second knowledge base construction module is used to determine the knowledge type involved in the content of the crawled network resources through the large language model; when the knowledge type involved in the content of the network resources matches the knowledge type of the domain knowledge base, the network resources are stored in the domain knowledge base.

[0063] Optionally, the model external knowledge includes a domain knowledge base, and the device further includes:

[0064] The third knowledge base construction module is used to call the risk control interface to perform harmful information detection on the content of the crawled network resources to obtain harmful information detection results; when the harmful information detection results indicate that the content of the network resources does not contain harmful information, the network resources are stored in the domain knowledge base.

[0065] Optionally, the model external knowledge includes a domain knowledge base,

[0066] The paragraph acquisition module is used to detect the knowledge type involved in the question through a question detection model to obtain a type detection result; when the type detection result indicates that the knowledge type involved in the question matches the knowledge type of the domain knowledge base, retrieve at least one first paragraph matching the question from the network and the domain knowledge base; otherwise, retrieve at least one first paragraph matching the question from the network.

[0067] Optionally, the device further comprises:

[0068] A model determination module is used to perform risk detection on the question through a question detection model to obtain a risk detection result; when the risk detection result indicates that there is a specified type of security risk in answering the question, a large language model that has been trained for security is selected from multiple large language models, and the large language model that has been trained for security is used to generate an answer corresponding to the question, and the answer generated by the large language model that has been trained for security does not contain harmful information.

[0069] Optionally, the device further comprises:

[0070] The first model adjustment module is used to obtain an attack question set and a natural question set; generate answers corresponding to each question in the attack question set and the natural question set respectively through the large language model; perform a performance evaluation on the large language model based on the answers generated by the large language model; and adjust the large language model based on the performance evaluation result.

[0071] Optionally, the device further comprises:

[0072] The second model adjustment module is used to obtain a question set; generate answers corresponding to each question in the question set through multiple working modes of the large language model; perform performance evaluation on each working mode of the large language model based on the answers corresponding to the multiple working modes; and adjust the large language model based on the performance evaluation results.

[0073] Optionally, the multiple working modes include at least two of a pure large model mode, an artificial intelligence AI search mode, and a retrieval enhancement generation RAG mode;

[0074] The pure large model mode refers to a mode that generates answers based only on the internal knowledge of the model;

[0075] The AI ​​search mode refers to a mode of generating answers based on the internal knowledge of the model and the knowledge retrieved by the search engine on the Internet;

[0076] The RAG mode refers to a mode for generating answers based on the internal knowledge of the model, the knowledge retrieved by the search engine on the Internet, and the knowledge in the domain knowledge base.

[0077] Optionally, the device further comprises:

[0078] A knowledge base adjustment module is used to divide the question set into a consistent subset, a conflicting subset and an inconsistent subset based on the answers corresponding to each question in the question set generated by the large language model using the AI ​​search mode and the RAG mode respectively; wherein the questions in the consistent subset are questions that are answered correctly by both the AI ​​search mode and the RAG mode, the questions in the conflicting subset are questions that are answered correctly by one of the AI ​​search mode and the RAG mode, and the questions in the inconsistent subset are questions that are answered incorrectly by both the AI ​​search mode and the RAG mode; based on the division results of the question set, the domain knowledge base is adjusted to improve the answer accuracy of the RAG mode.

[0079] In addition, to achieve the above-mentioned purpose, the present application also proposes an answer generation device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the answer generation method described above.

[0080] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the answer generation method described above are implemented.

[0081] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the answer generation method described above are implemented.

[0082] One or more technical solutions proposed in this application have at least the following technical effects:

[0083] The answer generation scheme provided in the present application takes into account the problems that the model training data may be incomplete and not updated in time. Therefore, after obtaining the question corresponding to the dialogue instruction, at least one first paragraph matching the question is retrieved from the external knowledge of the model, and at least one second paragraph matching the question is generated based on the internal knowledge of the model through the large language model. The first paragraph and the second paragraph are merged into a paragraph set, which makes up for the limitations of the internal knowledge of the large language model and enables the model to obtain more extensive and timely information. Then, the source information of each paragraph in the paragraph set is identified, so that the large language model can clearly distinguish the sources of different knowledge when generating answers. When there are differences between internal knowledge and external knowledge, the model can evaluate the reliability of the knowledge based on the source information, so as to better integrate and analyze the knowledge and generate more reliable and accurate questions and answers. BRIEF DESCRIPTION OF THE DRAWINGS

[0084] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0085] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0086] Figure 1 A schematic diagram of an implementation environment of the answer generation method for this application;

[0087] Figure 2 A flowchart of the first embodiment of the answer generation method of this application is provided;

[0088] Figure 3 A structural diagram of a question-answering system provided for this application;

[0089] Figure 4 A flowchart diagram of a second embodiment of the answer generation method of this application is provided;

[0090] Figure 5 A flowchart diagram of a third embodiment of the answer generation method of the present application is provided;

[0091] Figure 6 A flowchart diagram of a fourth embodiment of the answer generation method of the present application is provided;

[0092] Figure 7 A flowchart diagram of a fifth embodiment of the answer generation method of the present application is provided;

[0093] Figure 8 A schematic diagram of the construction process of a political domain knowledge base provided for this application;

[0094] Fig. 9 A flowchart diagram of a sixth embodiment of the answer generation method of the present application is provided;

[0095] Fig.10 A flowchart diagram of the seventh embodiment of the answer generation method of the present application is provided;

[0096] Fig.11 A schematic diagram of a performance evaluation process of a large language model provided for this application;

[0097] Fig.12 This is a schematic diagram of the module structure of the answer generation device according to the embodiment of the present application;

[0098] Fig.13 A schematic diagram of the device structure of the hardware operating environment involved in the answer generation method in the embodiment of the present application.

[0099] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0100] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0101] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0102] Figure 1 is a schematic diagram of an implementation environment provided by an embodiment of the present disclosure. Figure 1 , the implementation environment includes a terminal 101 and a server 102. The terminal 101 and the server 102 are connected via a wireless or wired network. Exemplarily, the terminal 101 is installed with a target application provided by the server 102, and the terminal 101 can implement functions such as data transmission and message interaction through the target application.

[0103] Exemplarily, the terminal 101 is a computer, a mobile phone, a tablet computer or other terminals. Exemplarily, the target application is a target application in the operating system of the terminal 101, or a target application provided by a third party. For example, the target application is a search application, a short video application, a shopping application, a navigation application, etc. Exemplarily, the server 102 is a background server corresponding to the target application. Correspondingly, the server 102 is a search application server, a short video application server, a shopping application server, a navigation application server, etc.

[0104] In the present application, terminal 101 is used to respond to a dialogue instruction and obtain a question corresponding to the dialogue instruction. The question is sent to server 102. Server 102 receives the question, retrieves at least one first paragraph matching the question from the external knowledge of the model, and generates at least one second paragraph matching the question based on the internal knowledge of the model through a large language model. The first paragraph and the second paragraph are merged into a paragraph set, and the source information of each paragraph in the paragraph set is identified, and the source information indicates whether the corresponding paragraph comes from inside or outside the model. Then, through the large language model, based on the paragraph set and the source information of each paragraph in the paragraph set, an answer corresponding to the question is generated. The answer is then sent to terminal 101. Terminal 101 receives and displays the answer.

[0105] Alternatively, the above answer generation process may also be completed by the terminal 101 alone. Alternatively, the terminal 101 completes the process through an installed target application, such as a search application. This embodiment of the present application does not limit this.

[0106] The answer generation method provided in this application is applicable to a variety of scenarios. For example, in the scenario of querying political information, users can ask questions about political news, political events and other information they want to know. The terminal quickly finds the political information required by the user through the method provided by this application, and displays the political information to the user in the form of answers. Another example is a medical scenario. The terminal can answer various medical questions through the method provided by this application to assist users in the medical field to solve various medical problems. Another example is a financial investment scenario. Users can ask questions about various financial investment information they need to know, such as the price trend of a certain financial product, to help themselves plan investment decisions.

[0107] Figure 2 This is a flowchart of the first embodiment of the answer generation method of this application. Figure 2 Taking the execution subject as a terminal as an example, the answer generation method includes the following steps S10 to S40:

[0108] Step S10, in response to the dialogue instruction, obtaining the question corresponding to the dialogue instruction.

[0109] A dialogue instruction is a request or command sent by a user to a terminal in the form of voice, text, etc. It can be a direct question, such as "What is the weather in Beijing today?", or an indirect demand, such as "I want to know the latest movie schedule". Regardless of the specific content of the dialogue instruction, this application refers to the content expressed in the dialogue instruction as a question.

[0110] Exemplarily, the terminal displays a dialogue interface, and the user inputs any dialogue content through the dialogue interface. The terminal generates a dialogue instruction in response to the dialogue content input by the user, and uses the dialogue content input by the user as the question corresponding to the dialogue instruction.

[0111] Optionally, the large language model for processing the question is determined based on whether the question involves security risks. Specifically, after the terminal responds to the dialogue instruction and obtains the question corresponding to the dialogue instruction, the question is subjected to risk detection through the question detection model to obtain a risk detection result. When the risk detection result indicates that there is a security risk of a specified type in answering the question, a large language model that has been trained for security is selected from multiple large language models. The large language model that has been trained for security is used to generate an answer corresponding to the question, and the answer generated by the large language model that has been trained for security does not contain harmful information.

[0112] Exemplarily, when the risk detection result indicates that there is no security risk of a specified type in answering the question, a large language model that has not been security trained is selected from multiple large language models, and the question is subsequently processed by the large language model that has not been security trained. The embodiment of the present application flexibly selects a large language model according to the risk status of the question, thereby improving the question-answering system's ability to handle different types of questions. For ordinary questions, conventional models can be used for rapid processing to improve efficiency. For questions that present security risks, a large language model that has been security trained is enabled to ensure the security of the answer, so that the system can better adapt to complex and changing application scenarios.

[0113] The question detection model is a model specifically used to conduct risk assessment on input questions. It uses specific algorithms and technologies, such as text classification, keyword recognition, and semantic analysis in natural language processing, to analyze questions and determine whether there are security risks and the type of risks, providing a basis for the subsequent selection of appropriate large language models. Security risks refer to harmful content such as violence, discrimination, pornography, false information, sensitive political information, etc. that may be contained in questions, or potential risk factors that may have adverse effects on system security, information security, etc. due to the intention of raising questions.

[0114] The security-trained large language model is a large language model that is additionally trained for security-related content on top of regular training. During the training process, a large amount of sample data containing security risk information is used to enable the model to learn how to identify and avoid generating harmful information, ensuring that when dealing with questions with security risks, the generated answers meet security specifications and do not contain any content that may cause harm.

[0115] In the embodiment of the present application, the risk detection of questions is performed through the question detection model to identify questions with security risks, and a large language model that has been trained for security is selected for processing, thereby avoiding the output of harmful information from the source and ensuring the security of the information dissemination environment. In addition, when using the question-and-answer system, users do not have to worry about receiving answers containing harmful information, and can obtain more reliable and standardized answers, thereby improving user satisfaction.

[0116] Step S20, retrieving at least one first paragraph matching the question from the model external knowledge, and generating at least one second paragraph matching the question based on the model internal knowledge through the large language model.

[0117] A large language model is a language model trained based on deep learning technology. It has strong language understanding and generation capabilities, can process and generate natural language text, and undertakes the key task of generating answers in the question-answering system. Exemplarily, the large language model is a generative pre-trained model, such as GPT (a generative pre-trained model).

[0118] Model external knowledge is a source of knowledge that is independent of the training data of the large language model. It is stored in external storage media such as databases and Internet documents, and has more extensive and real-time information, which is used to supplement the lack of knowledge of the large language model itself. Model internal knowledge is the knowledge learned by the large language model during the training process and stored in the model parameters. This knowledge comes from a large amount of text data, but there may be problems such as untimely updates and incomplete coverage.

[0119] The first paragraph is a text paragraph that is retrieved from the model's external knowledge and matches the question in content. It is a piece of information in the external knowledge that may be related to the answer to the question. The second paragraph is a text paragraph generated by the large language model based on its own internal knowledge for the question. It reflects the model's understanding of the question and its initial response based on existing knowledge.

[0120] Optionally, the model external knowledge includes a domain knowledge base, and retrieving at least one first paragraph matching the question from the model external knowledge includes: detecting the type of knowledge involved in the question by using a question detection model to obtain a type detection result. If the type detection result indicates that the type of knowledge involved in the question matches the type of knowledge in the domain knowledge base, at least one first paragraph matching the question is retrieved from the network and the domain knowledge base; otherwise, at least one first paragraph matching the question is retrieved from the network.

[0121] A domain knowledge base is a collection of knowledge built specifically for a specific field. It stores the organized and filtered professional knowledge in the field and is systematic, professional, and targeted. For example, a medical knowledge base contains information such as disease diagnosis, treatment plans, and drug information. A financial knowledge base contains information such as financial product knowledge, market trends, and economic laws and regulations. A political knowledge base contains information such as political theories, political systems, political figures and events, and current political trends.

[0122] Knowledge types are used to distinguish knowledge in different fields, such as medical knowledge, financial knowledge, political knowledge, etc. The problem detection model detects the knowledge types involved in the problem and outputs the type detection results, which indicate the matching between the knowledge types involved in the problem and the knowledge types of the specific knowledge base, and provide a decision basis for where to retrieve relevant knowledge in the future.

[0123] In an embodiment of the present application, if the type of knowledge involved in the question matches the type of knowledge in the domain knowledge base, the first paragraph is preferentially retrieved from the domain knowledge base and the Internet. Since the domain knowledge base has been carefully organized and has high information quality, obtaining professional knowledge using the domain knowledge base can provide more accurate and authoritative answers. If the type of knowledge involved in the question does not match the type of knowledge in the domain knowledge base, only the first paragraph is retrieved from the Internet. This avoids invalid searches in the domain knowledge base for problems with knowledge types that cannot be covered by the domain knowledge base, concentrates resources on network searches, and improves overall search efficiency.

[0124] Step S30: merge the first paragraph and the second paragraph into a paragraph set, and identify the source information of each paragraph in the paragraph set, where the source information indicates whether the corresponding paragraph comes from inside the model or outside the model.

[0125] The paragraph set is a set formed by merging all detected first paragraphs and all generated second paragraphs. It contains text paragraphs related to the question from both outside and inside the model, and is the information basis for generating the final answer.

[0126] Source information is used to mark the source of each paragraph in a paragraph collection, clearly indicating whether each paragraph originates from the results of external knowledge retrieval of the model or is content generated by a large language model based on internal knowledge.

[0127] Step S40: Generate an answer corresponding to the question through a large language model based on the paragraph set and the source information of each paragraph in the paragraph set.

[0128] The answer to the question is the answer to the question output to the user after the large language model processes the paragraph collection and the source information of each paragraph.

[0129] Figure 3 This is a schematic diagram of the structure of the question-answering system. Figure 3 , the open platform interface of the question-answering system receives the user's question. The question is given to the risk control module, and the risk control module performs risk detection on the question through the question detection model. When it is determined that there is no security risk in answering the question, the question is given to a conventional large language model for processing. The conventional large language model has not been trained for security. When it is determined that there is a security risk in answering the question, it is determined whether the question involves politics. When the question does not involve politics, the question is given to the security response large model for processing. The security response large model is a large language model that has been trained for security. When the question involves politics, the RAG module in the risk control module retrieves the question-related knowledge from the political field knowledge base, and gives the question and the question-related knowledge to the security response large model for processing. Exemplarily, the RAG module can also integrate the question-related knowledge retrieved from the political field knowledge base with the question-related knowledge retrieved by the search engine on the Internet, and then give the question and the integrated question-related knowledge to the security response large model for processing.

[0130] The answer generation scheme provided in the present application takes into account the problems that the model training data may be incomplete and not updated in time. Therefore, after obtaining the question corresponding to the dialogue instruction, at least one first paragraph matching the question is retrieved from the external knowledge of the model, and at least one second paragraph matching the question is generated based on the internal knowledge of the model through the large language model. The first paragraph and the second paragraph are merged into a paragraph set, which makes up for the limitations of the internal knowledge of the large language model and enables the model to obtain more extensive and timely information. Then, the source information of each paragraph in the paragraph set is identified, so that the large language model can clearly distinguish the sources of different knowledge when generating answers. When there are differences between internal knowledge and external knowledge, the model can evaluate the reliability of the knowledge based on the source information, so as to better integrate and analyze the knowledge and generate more reliable and accurate questions and answers.

[0131] Based on the above first embodiment, a second embodiment of the present application is proposed. For the same or similar contents as the first embodiment, please refer to the above introduction and will not be described in detail later. Figure 4 In the second embodiment, the above step S40 includes steps S401 to S402:

[0132] Step S401, through the large language model, based on the source information of each paragraph in the question and paragraph set, the paragraph set is iteratively updated, and the source information of each paragraph in the paragraph set obtained by each iterative update is identified. The iterative update is used to retain the consistent information inside and outside the paragraph set and filter out the inconsistent information inside and outside and the irrelevant information of the question.

[0133] Iterative update refers to the process of optimizing a paragraph set by a large language model through multiple iterative processing of the paragraph set. During each processing, the model will adjust the content of the current paragraph set based on the question and the paragraph source information, that is, retain the information that meets the requirements and remove the information that does not meet the requirements, so that the paragraph set gradually approaches the state that is most suitable for generating accurate answers. Each processing is an iterative update.

[0134] In the internal and external consistent information, "internal" refers to the paragraph information generated by the model based on internal knowledge. "External" refers to the paragraph information retrieved from the external knowledge of the model. Internally and externally consistent information means that the paragraph information generated by the model and the paragraph information retrieved from the outside are consistent in meaning, viewpoints, etc., and can verify and supplement each other, and together provide reliable basis for answering questions.

[0135] Internally and externally inconsistent information refers to information that is inconsistent, conflicting, or different between the paragraph information generated internally by the model and the paragraph information retrieved externally. For example, when answering questions about historical events, the event time generated based on the internal knowledge of the model is inconsistent with the time retrieved from the external knowledge of the model. This kind of information with differences is internally and externally inconsistent information.

[0136] Irrelevant information to a question refers to information in a paragraph set that has no direct connection with the question in terms of topic, content, etc. and cannot help answer the question.

[0137] Step S402: Generate an answer corresponding to the question based on the paragraph set obtained by each iterative update and the source information of each paragraph in the paragraph set.

[0138] Optionally, based on the paragraph set obtained from each iterative update and the source information of each paragraph in the paragraph set, an answer corresponding to the question is generated, including: using a large language model, based on the paragraph set obtained from each iterative update and the source information of each paragraph in the paragraph set, generating alternative answers corresponding to each iterative update, and selecting the answer corresponding to the question from the multiple generated alternative answers.

[0139] When processing questions, the large language model generates an alternative answer based on the paragraph set and paragraph source information after each iteration. After multiple iterations, multiple alternative answers will be obtained, the same number as the number of iterations. Since the information in the paragraph set after each iteration is different, the multiple alternative answers generated are also different, which provides multiple options for determining the final answer.

[0140] For example, from multiple candidate answers generated by the large language model, one is selected as the final output answer for the current question based on certain standards and strategies. This selection process can comprehensively consider multiple factors such as the completeness, logic, relevance, source of information in the answer, frequency of information occurrence, etc., to ensure the best quality of the answer provided to the user.

[0141] In the embodiment of the present application, considering that each iteration update may highlight different key information in the paragraph set, the alternative answers corresponding to each iteration update are generated based on the paragraph set obtained by each iteration update and the source information of each paragraph in the paragraph set, thereby generating diversified alternative answers. Selecting the final answer from multiple alternative answers avoids the one-sidedness or inaccuracy that may exist in a single answer, thereby improving the quality of the final answer.

[0142] Exemplarily, the process of obtaining a paragraph set and iteratively updating the paragraph set is described below in conjunction with a formula.

[0143] Formula (1): K←LLM(prompt1, query)

[0144] Where K is the second paragraph generated by the large language model based on the model's internal knowledge. LLM is the large language model, prompt1 is the first prompt word, indicating that the large language model generates an accurate and non-hallucinatory paragraph related to the question based on the model's internal knowledge. query is the question.

[0145] Formula (2):

[0146] Among them, K C is the set of merged paragraphs. R is the first paragraph retrieved from knowledge external to the model.

[0147] Formula (3):

[0148] in, is the set of paragraphs output after the i-th iteration update, L (i+1)is the source information of each paragraph in the paragraph set output after the i-th iteration update, prompt2 is the second prompt word, instructing the large language model to retain the consistent information inside and outside the paragraph set and filter out the inconsistent information and irrelevant information of the question. Update the input paragraph set for the i-th iteration. (i) Update the source information of each paragraph in the input paragraph set for the i-th iteration.

[0149] Formula (4):

[0150] Among them, response is the final answer generated by the large language model. prompt3 is the third prompt word, which instructs the large language model to generate alternative answers corresponding to each iterative update based on the paragraph set obtained by each iterative update and the source information of each paragraph in the paragraph set, and select the final answer corresponding to the question from the generated multiple alternative answers. is the set of paragraphs obtained by each iteration update in u iteration updates. (u) The source information of each paragraph in the paragraph set obtained by each iterative update in u iterative updates.

[0151] In the embodiment of the present application, by iteratively updating and retaining the consistent information in the paragraph set, filtering the inconsistent information and irrelevant information of the question, the paragraph set used to generate the answer can be made more accurate. The large language model generates answers based on more reliable and relevant information, thereby providing users with more accurate and reliable answers.

[0152] Based on the above first embodiment of the present application, a third embodiment of the present application is proposed. The same or similar contents as the first embodiment can be referred to the above introduction, and will not be repeated in the following. Figure 5 In the third embodiment, the process before step S10 includes steps S011 to S013.

[0153] Step S011, obtaining a target website list, the target website list including a plurality of authoritative website identifiers.

[0154] The target website list is a collection of multiple authoritative website identifiers, which are used to determine which websites' network resources are trustworthy and can be used to store in the domain knowledge base. The websites in the target website list have high authority, credibility and professionalism in specific fields. For example, in the political field, the target website list includes official government websites, authoritative news media websites, etc. The authoritative website identifier is used to identify authoritative websites. For example, the authoritative website identifier is the name of the authoritative website.

[0155] Step S012, comparing the primary domain name in the uniform resource locator URL corresponding to the crawled network resource with the website identifier in the target website list.

[0156] Crawled web resources refer to various information obtained from the Internet through web crawler technology. This information may exist in various forms such as web page text and pictures, and is a potential data source for enriching domain knowledge bases. For example, news reports crawled from news websites and research papers obtained from academic platforms contain a large number of different types of knowledge content.

[0157] Exemplarily, crawled web resources such as raw news data need to be preprocessed. This step mainly includes the following aspects: Schema (structure) analysis: Analyze the structure of each news page to facilitate subsequent data extraction. Date extraction: Extract the release time from the news page to facilitate the organization of news in chronological order. Title and content extraction: Extract the title and text content from the news page to facilitate users to quickly browse and retrieve. De-duplication: Remove duplicate news by comparing news titles or content to avoid redundancy. Group by date: Classify the news according to its release date to facilitate query according to the time dimension.

[0158] URL (Uniform Resource Locator) is a string used to identify and locate resources on the Internet. Each web page, file and other network resources have a corresponding URL. The URL can be used to accurately find the corresponding network resource. The primary domain name is the core part of the URL domain name. It is used to identify the website to which the resource belongs and is the key information for comparison with the website identifier in the target website list.

[0159] Step S013, when the primary domain name matches the website identifier in the target website list, the network resource is stored in a domain knowledge base, and the domain knowledge base is included in the model external knowledge.

[0160] In order to ensure the timeliness of the data in the domain knowledge base, network resources can be crawled from the network in real time, and after processing according to the method provided in the embodiment of the present application, the domain knowledge base is stored. For example, the latest news information, journalists' questions and answers and other political information are crawled every day, processed and stored in the political domain knowledge base.

[0161] One thing that needs to be explained is that if the knowledge type involved in the domain knowledge base to be built is politics, then the authoritative websites in the above target website list are websites that publish authoritative political information. If the knowledge type involved in the domain knowledge base to be built is medicine, then the authoritative websites in the above target website list are websites that publish authoritative medical information. In this way, high-quality and professional information can be screened out through the target network list to ensure the professionalism and authority of the domain knowledge base.

[0162] In the embodiment of the present application, multiple authoritative website identifiers are constructed as a target website list. When the website to which the network resource belongs is determined to be an authoritative website in the target website list based on the primary domain name of the URL of the crawled network resource, the network resource is stored in the domain knowledge base, making the knowledge in the domain knowledge base more accurate and reliable. The subsequent use of the knowledge in the domain knowledge base to generate answers can improve the accuracy and reliability of the answers.

[0163] Based on the above first embodiment of the present application, a fourth embodiment of the present application is proposed. The same or similar contents as the first embodiment can be referred to the above introduction, and will not be repeated in the following. Figure 6 In the fourth embodiment, step S10 includes step S021 and step S022.

[0164] Step S021, determining the knowledge type involved in the content of the crawled network resources through a large language model.

[0165] The knowledge type involved in the content of the network resource is used to distinguish the field to which the content of the network resource belongs. For example, the knowledge type involved in the content of the network resource is political, financial, or medical.

[0166] Step S022: When the knowledge type involved in the content of the network resource matches the knowledge type of the domain knowledge base, the network resource is stored in the domain knowledge base, and the domain knowledge base is included in the model external knowledge.

[0167] The knowledge type involved in the content of network resources matches the knowledge type of the domain knowledge base, which means whether the knowledge type of network resources is consistent or related to the knowledge type preset in the domain knowledge base. For example, if the domain knowledge base is focused on the medical field, then when the large language model determines that the content of network resources involves medical knowledge such as disease diagnosis and drug development, the knowledge types of the two are considered to match. If the domain knowledge base is focused on the political field, then when the large language model determines that the content of network resources involves political knowledge such as political events and political views, the knowledge types of the two are considered to match.

[0168] For online resources such as Wikipedia entries, since their knowledge coverage is wide, it is necessary to determine the knowledge types involved in the crawled Wikipedia entries to ensure that the knowledge base in each field only includes entries that match the preset knowledge types.

[0169] Exemplarily, before storing network resources such as Wikipedia entries in a domain knowledge base, pre-processing operations such as entity page extraction and deduplication may be performed on them.

[0170] One thing that needs to be explained is that although the authoritative websites in the target website list, such as mainstream official media and Wikipedia, provide a lot of information, there may be insufficient data in some niche areas or marginal topics. In order to solve this problem, the embodiment of the present application adopts an open supplementary strategy, that is, technicians can search for information from other websites on the Internet and supplement and modify the domain knowledge base based on the searched information. This approach not only enriches the content of the domain knowledge base, but also can adapt to various unexpected problems.

[0171] In the embodiment of the present application, by judging whether the knowledge type matches, it is decided whether to store the network resource in the domain knowledge base, which can ensure that the stored resource is consistent with the subject and positioning of the domain knowledge base, making the content of the domain knowledge base more accurate and professional, and enhancing the authority of the domain knowledge base.

[0172] Based on the above first embodiment of the present application, a fifth embodiment of the present application is proposed. For the same or similar contents as the first embodiment, please refer to the above introduction, and no further description will be given later. Figure 7 In the fifth embodiment, step S031 and step S032 are included before step S10.

[0173] Step S031, calling the risk control interface to perform harmful information detection on the content of the crawled network resources to obtain harmful information detection results.

[0174] The risk control interface is a program interface used to detect whether there is harmful information in the content of network resources. This interface can integrate multiple detection technologies, such as text analysis, image recognition, etc., to identify different types of harmful information.

[0175] The harmful information detection result is the judgment conclusion output by the risk control interface after detecting the content of network resources. The result indicates whether there is harmful information in the network resources and the type of harmful information.

[0176] Step S032: When the harmful information detection result indicates that the content of the network resource does not contain harmful information, the network resource is stored in the domain knowledge base.

[0177] Figure 8This is a schematic diagram of the construction process of a political domain knowledge base. The political domain knowledge base is constructed based on news data. Figure 8 First, obtain news data from the Internet. Then preprocess the news data, including structural analysis, date extraction, title and content extraction, deduplication and grouping. Then perform trusted source filtering, including obtaining a list of target websites, extracting the main domain name in the URL of the news data and comparing it with the authoritative websites in the target website list to filter out news data from authoritative websites. Then perform news risk control filtering, that is, perform risk detection on the content of news data through the risk control interface to filter out news data that does not contain harmful information. Or obtain news data that does not contain harmful information through manual filtering. Finally, store the filtered news data in the political domain knowledge base.

[0178] In the embodiment of the present application, by detecting harmful information on the crawled network resources, only when it is confirmed that the network resources do not contain harmful information will they be stored in the domain knowledge base, which can effectively prevent harmful information such as violence, pornography, terrorism, and false information from entering the domain knowledge base. The purity and security of the domain knowledge base are ensured. Since the domain knowledge base is an important source of knowledge for the question-and-answer system. The exclusion of harmful information ensures that the question-and-answer system based on the domain knowledge base will not be disturbed by harmful information when answering user questions, and the output answers are more reliable and accurate, and comply with laws, regulations and ethical standards.

[0179] Based on the above first embodiment of the present application, a sixth embodiment of the present application is proposed. For the same or similar contents as the first embodiment, please refer to the above introduction, and no further description will be given later. Fig. 9 In the sixth embodiment, steps S041 to S044 are included before step S10.

[0180] Step S041, obtaining an attack question set and a natural question set.

[0181] The attack question set refers to a set of questions that contain various harmful information, malicious intentions, or are intended to test or damage the system. These questions may contain violent, discriminatory, pornographic, fraudulent content, or be used to detect weaknesses in large language models. For example, questions that contain malicious attacks on specific groups belong to the attack question set. Exemplarily, the attack question set includes malicious questions detected from questions collected by the question-answering system, and also includes attack questions synthesized based on known model vulnerabilities or theoretical attack prompt words.

[0182] A natural question set is a set of questions asked by users based on normal information needs. These questions do not contain harmful content or malicious intent, and are intended to gain knowledge, solve doubts, or conduct ordinary communication. For example, a natural question set includes questions that remain after filtering out malicious questions from questions collected by the question-answering system.

[0183] Step S042: Generate answers corresponding to each question in the attack question set and the natural question set respectively through the large language model.

[0184] Step S043: Based on the answers generated by the large language model, a performance evaluation is performed on the large language model.

[0185] Performance evaluation is to quantitatively analyze and evaluate the performance of the large language model in generating answers to attack question sets and natural question sets. Evaluation indicators can include multiple dimensions such as accuracy, security, and relevance of answers, so as to fully understand the capabilities and limitations of the large language model in handling different types of questions.

[0186] Step S044: adjusting the large language model based on the performance evaluation result.

[0187] The performance evaluation results are the data and conclusions obtained through performance evaluation on the performance of various indicators of the large language model. These results intuitively reflect the advantages and disadvantages of the large language model in dealing with attack problems and natural problems, and provide a clear basis for subsequent adjustments to the model.

[0188] In the embodiment of the present application, by testing the large language model using a set of attack questions and a set of natural questions, the performance of the model can be comprehensively evaluated from two dimensions: normal use scenarios and malicious attack scenarios. It is possible to understand the performance of the model when it meets the normal needs of users, and to understand the model's ability to respond to malicious inputs, thereby having a more complete and in-depth understanding of the model's capabilities.

[0189] Adjusting the large language model based on the performance evaluation results can not only effectively enhance the model's ability to identify and prevent harmful information, improve the model's security and stability in complex network environments, and prevent it from being maliciously exploited, but also optimize the model's performance in processing actual user needs, improve the accuracy and practicality of answers, and enhance user satisfaction with the model.

[0190] Based on the above-mentioned first embodiment of the present application, a seventh embodiment of the present application is proposed. The same or similar contents as those of the first embodiment can be referred to the above introduction, and will not be repeated in the following. Fig.10 In the seventh embodiment, steps S051 to S054 are included before step S10.

[0191] Step S051, obtaining a question set.

[0192] The question set is a set of representative and diverse question combinations used to comprehensively evaluate the performance of large language models in different scenarios. Exemplarily, the question set includes an attack question set and a natural question set.

[0193] Step S052: Generate answers corresponding to each question in the question set through multiple working modes of the large language model.

[0194] The working modes of the large language model are different operating modes set by the large language model to adapt to different application scenarios or user needs. Optionally, the multiple working modes include at least two of a pure large model mode, an artificial intelligence AI search mode, and a retrieval enhancement generation RAG mode.

[0195] Among them, the pure large model mode refers to a mode that generates answers based only on the model's internal knowledge. In other words, the large language model completely relies on the knowledge it has learned during the training process and stored in the model parameters to generate answers. It does not rely on external real-time information retrieval, but simply thinks and answers based on the existing internal knowledge system.

[0196] AI search mode refers to a mode that generates answers based on the model's internal knowledge and the knowledge retrieved by the search engine on the Internet. This mode combines the internal knowledge of the large language model with the knowledge obtained by the search engine from the Internet. The large language model first uses its own knowledge to make a preliminary understanding and analysis of the question, then uses the search engine to retrieve relevant content from the vast network information, and finally combines the two to generate an answer. When answering questions with strong timeliness, the model's internal knowledge may not cover the latest information. At this time, searching the latest scientific and technological information on the Internet through the search engine and then integrating it with its own knowledge can give a more timely and comprehensive answer.

[0197] The RAG model refers to a model that generates answers based on the model's internal knowledge, the knowledge retrieved by the search engine on the Internet, and the knowledge in the domain knowledge base. This model further expands the source of knowledge. In addition to the model's internal knowledge and the knowledge retrieved by the search engine from the Internet, it also incorporates professional knowledge in the domain knowledge base. The domain knowledge base is a collection of knowledge carefully constructed for a specific field, which is professional and authoritative. In the RAG model, when the model handles a problem, it will combine these three aspects of knowledge to generate answers. For example, when answering professional questions in the medical field, it not only relies on the medical knowledge learned by the model itself and the medical information on the Internet, but also refers to professional theories and clinical research results in the medical field knowledge base, so as to give more professional and accurate answers.

[0198] Different working modes are suitable for different types of questions and scenarios. The pure large model mode is suitable for answering some questions based on common sense and do not require real-time information updates. It can quickly give answers based on the existing knowledge of the model. The AI ​​search mode is suitable for questions that need to be combined with the latest information, such as current affairs, popular culture, etc. The RAG mode performs well in dealing with professional field problems and can use the field knowledge base to provide in-depth and professional answers. This diverse mode selection can meet the various needs of users in different scenarios and improve the user experience. In actual applications, you can choose a matching working mode to deal with the type of problem.

[0199] Step S053: Based on the answers corresponding to the multiple working modes, the performance of each working mode of the large language model is evaluated.

[0200] Performance evaluation is the process of quantitatively analyzing and evaluating the answers generated by each working mode of the large language model based on a series of pre-set standards and indicators. Evaluation indicators may include accuracy, security, completeness, relevance, and efficiency of answers. Through performance evaluation, the pros and cons of each working mode in different aspects can be clearly identified.

[0201] Exemplarily, the answers of the model in each working mode are evaluated through the performance evaluation interface. For example, the answers of the model in each working mode are evaluated for safety through the SafetyEval API (safety evaluation application programming interface), and the evaluation levels include harmful, refusal to answer and safe.

[0202] For example, the performance evaluation is performed by manual annotation. First, a safety score is assigned to the answer to the same question in each working mode, where 1 means harmful and 2 means safe. Then, the answers of the three working modes are compared to determine which working mode has the best answer, and the winning working mode is marked. If the three working modes are considered to have similar performance on the same question, they are marked as "same".

[0203] For example, the performance of each working mode can be evaluated from the aspects of safety, recall rate and accuracy. The following is the evaluation data of each working mode.

[0204] First, the recall rate of political questions: The recall rate of the RAG model for the natural question set is 16.8%. In the attack question set, the recall rate of the RAG model for the nano-inspection attack set is 17.1%, and the recall rate of the RAG model for the red team attack set is 7.3%. Among them, the nano-inspection attack set includes malicious questions detected from questions collected by the question-answering system. The red team attack set contains attack questions synthesized based on known model vulnerabilities or theoretical attack prompt words. The recall rate of the RAG model for the Cyberspace Administration of China question set in the attack question set is 10.1%.

[0205] For the recall rate of financial problems: the recall rate of the RAG model for the ICBC problem set is 29.4%. The overall recall rate of the RAG model on the 9 datasets of OpenFindata (a financial open source evaluation dataset) is 17.2%.

[0206] For medical problems, the recall rate of the RAG model of the MMedC (Multilingual Medical Corpus) Chinese dataset is 7.6%, and the recall rate of the RAG model of the MMedC English dataset is 9.7%.

[0207] Second, for the security of political issues: For the nano-inspection attack set, the number of security answers generated by the RAG mode increased by 8.33% relative to the AI ​​search mode. For the red team attack set, the number of security answers generated by the RAG mode increased by 8.37% relative to the AI ​​search mode. For the natural question set, the number of security answers generated by the RAG mode increased by 0.71% relative to the AI ​​search mode.

[0208] Third, the accuracy of financial problems: The accuracy of the pure large model mode (Accuray) for the ICBC problem set is 77.89%. The accuracy of the AI ​​search mode is 81.63%. The accuracy of the RAG mode is 82.99%. The accuracy of the RAG mode is 5.1% higher than that of the pure large model mode. The accuracy of the RAG mode is 1.36% higher than that of the AI ​​search mode.

[0209] Compared with the pure large model mode, the RAG mode performs better on multiple datasets of OpenFindata. For example, the accuracy of data inspection tasks has increased by 5%. The accuracy of financial fact judgment tasks has increased by 2.7%. The accuracy of financial terminology related processing tasks has increased by 2%. The accuracy of named entity recognition tasks has increased by 1.33%. The accuracy of emotion recognition tasks has increased by 2.7%. Compared with the AI ​​search mode, the accuracy of emotion recognition tasks in the RAG mode has increased by 6.7%. The accuracy of data inspection tasks has increased by 5%. The accuracy of financial terminology related processing tasks has increased by 4%. The accuracy of value extraction tasks has increased by 2.9%. The accuracy of intent understanding tasks has increased by 4%. The accuracy of named entity recognition has increased by 1.3%.

[0210] For medical problems, the accuracy of the RAG model is 2.1% higher than that of the pure large model model and 1.2% higher than that of the AI ​​search model for the MMedC Chinese dataset. For the MMedC English dataset, the accuracy of the RAG model is 1.0% higher than that of the pure large model model and 3.8% higher than that of the AI ​​search model.

[0211] In summary, it can be seen that for the above-mentioned knowledge fields, the RAG mode has significant improvements in security, recall rate and accuracy compared with the AI ​​search mode and the pure large model mode.

[0212] Step S054: adjusting the large language model based on the performance evaluation result.

[0213] The performance evaluation results are the specific data and analysis conclusions on various indicators of each working mode of the large language model obtained through performance evaluation. These results intuitively show the advantages and disadvantages of each working mode, and provide a clear basis for the adjustment of the large language model. For example, a working mode scores high in accuracy, but performs poorly in security. Then adjustments can be made to the security of the working mode in the future.

[0214] Optionally, the method further includes: dividing the question set into a consistent subset, a conflicting subset, and an inconsistent subset based on the answers corresponding to each question in the question set generated by the large language model using the AI ​​search mode and the RAG mode, respectively. Based on the division results of the question set, the domain knowledge base is adjusted to improve the correctness of the answers in the RAG mode.

[0215] Among them, the questions in the consistent subset are those that are answered correctly by both the AI ​​search mode and the RAG mode. This shows that for these questions, the knowledge and reasoning processes integrated by the models in both modes can effectively deal with them, reflecting the stability and accuracy of the model in dealing with these problems. The questions in the conflicting subset are those that are answered correctly by only one of the AI ​​search mode and the RAG mode. This conflict reflects that there are differences in the application of knowledge, information integration or reasoning methods between the two modes, resulting in different processing results for certain questions, prompting users to pay attention to and analyze the reasons for this difference. The questions in the inconsistent subset are those that are answered incorrectly by both the AI ​​search mode and the RAG mode. This shows that for these problems, the current knowledge sources and processing methods integrated by the model are insufficient, and need to be comprehensively reviewed and improved to enhance the model's ability to answer these problems.

[0216] For example, for questions in the conflicting subset that the RAG model answers incorrectly, we analyze whether the knowledge in the domain knowledge base does not match other knowledge sources or whether the knowledge itself is incorrect, and then correct or supplement the relevant knowledge in the domain knowledge base. For questions in the inconsistent subset, we comprehensively review the knowledge completeness of the domain knowledge base in the fields involved in such questions and perform large-scale knowledge improvement. This optimization method can effectively improve the quality of the domain knowledge base and avoid blind adjustments.

[0217] In an embodiment of the present application, by dividing the question set into different subsets, it is possible to clearly identify on which questions the RAG mode has incorrect answers. These problems reflect that the domain knowledge base may have problems such as missing knowledge, inaccuracy, or poor integration with other knowledge sources, thereby providing a basis for accurately locating problems in the domain knowledge base. For example, if the RAG mode conflicts with the AI ​​search mode answer on a certain type of professional question and the RAG mode is wrong, it may mean that there is a deviation in the knowledge of the professional field in the domain knowledge base and it needs to be adjusted. After targeted adjustments to the domain knowledge base, when dealing with related issues, the RAG mode can more accurately integrate multiple sources of knowledge due to the optimized knowledge base, thereby improving the accuracy of the answer.

[0218] One point that needs to be explained is that the embodiments of the present application also tested the performance of various working modes of the problem detection model. Compared with the AI ​​search mode, the RAG mode of the problem detection model has a 16% higher recall rate for the set of political field problems, a 4% lower precision, and a 5.6% higher F1 value (an evaluation indicator). Among them, the RAG mode of the problem detection model refers to combining the domain knowledge base and the knowledge searched by the search engine from the Internet to perform risk detection on the problem. The AI ​​search mode of the problem detection model refers to performing risk detection on the problem only in combination with the knowledge searched by the search engine from the Internet.

[0219] Fig.11 This is a schematic diagram of the performance evaluation process of a large language model. Fig.11 First, a political domain knowledge base is constructed. The knowledge sources of the political domain knowledge base include credible news sources, Wikipedia entries, and open sources. Among them, credible news sources refer to authoritative news websites in the target website list. Wikipedia entries all involve politics. Open source refers to information manually screened from the Internet. Next, a question set is obtained, which includes a natural question set and an attack question set. Then, the large language model uses three working modes to generate answers corresponding to each question in the question set. The three working modes are pure large model mode, AI search mode, and RAG mode. Then, based on the answers corresponding to each working mode, the performance of each working mode is evaluated. The performance evaluation includes evaluation using a performance evaluation interface and manual evaluation.

[0220] In an embodiment of the present application, by allowing the large language model to process a set of questions under multiple working modes, it is possible to fully and carefully understand the performance of the model under different operating modes. This multi-dimensional evaluation helps to discover the limitations of each working mode, which helps to gain a deeper understanding of the model characteristics. Subsequently, based on the performance evaluation results, the large language model is adjusted, and targeted adjustments can be made to the deficiencies of each working mode. The performance of each working mode is continuously improved to make it more in line with the diverse needs of users.

[0221] Another point that needs to be explained is that the above examples are only used to understand the present application and do not constitute a limitation on the answer generation method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.

[0222] This application also provides a device for generating an answer, please refer to Fig.12 , the answer generating device comprises:

[0223] A question acquisition module 10, for acquiring a question corresponding to a dialogue instruction in response to the dialogue instruction;

[0224] A paragraph acquisition module 20, configured to retrieve at least one first paragraph matching the question from the model external knowledge, and generate at least one second paragraph matching the question based on the model internal knowledge through the large language model;

[0225] A paragraph synthesis module 30, configured to merge the first paragraph and the second paragraph into a paragraph set, and identify source information of each paragraph in the paragraph set, wherein the source information indicates whether the corresponding paragraph originates from inside the model or outside the model;

[0226] The answer generation module 40 is used to generate an answer corresponding to the question based on the paragraph set and the source information of each paragraph in the paragraph set through a large language model.

[0227] Optionally, the answer generation module 40 includes:

[0228] A paragraph updating unit, which is used to iteratively update the paragraph set based on the source information of each paragraph in the question and paragraph set through a large language model, and to identify the source information of each paragraph in the paragraph set obtained by each iterative update. The iterative update is used to retain the consistent information inside and outside the paragraph set and filter out the inconsistent information inside and outside and the irrelevant information of the question;

[0229] The answer generation unit is used to generate an answer corresponding to the question based on the paragraph set obtained by each iterative update and the source information of each paragraph in the paragraph set.

[0230] Optionally, the answer generation unit is used to generate alternative answers corresponding to each iterative update based on the paragraph sets obtained from each iterative update and the source information of each paragraph in the paragraph set through a large language model, and select the answer corresponding to the question from the multiple generated alternative answers.

[0231] Optionally, the model external knowledge includes a domain knowledge base, and the device further includes:

[0232] The first knowledge base construction module is used to obtain a target website list, which includes multiple authoritative website identifiers; compare the main domain name in the uniform resource locator URL corresponding to the crawled network resource with the website identifier in the target website list; when the main domain name matches the website identifier in the target website list, store the network resource in the domain knowledge base.

[0233] Optionally, the model external knowledge includes a domain knowledge base, and the device further includes:

[0234] The second knowledge base construction module is used to determine the knowledge type involved in the content of the crawled network resources through a large language model; when the knowledge type involved in the content of the network resources matches the knowledge type of the domain knowledge base, the network resources are stored in the domain knowledge base.

[0235] Optionally, the model external knowledge includes a domain knowledge base, and the device further includes:

[0236] The third knowledge base construction module is used to call the risk control interface to perform harmful information detection on the content of the crawled network resources to obtain harmful information detection results; when the harmful information detection results indicate that the content of the network resources does not contain harmful information, the network resources are stored in the domain knowledge base.

[0237] Optionally, the model external knowledge includes a domain knowledge base,

[0238] The paragraph acquisition module 20 is used to detect the knowledge type involved in the question through the question detection model to obtain a type detection result; when the type detection result indicates that the knowledge type involved in the question matches the knowledge type of the domain knowledge base, at least one first paragraph matching the question is retrieved from the network and the domain knowledge base; otherwise, at least one first paragraph matching the question is retrieved from the network.

[0239] Optionally, the device further comprises:

[0240] The model determination module is used to perform risk detection on questions through a question detection model to obtain risk detection results; when the risk detection results indicate that there is a specified type of security risk in answering the question, a large language model that has been trained for security is selected from multiple large language models, and the large language model that has been trained for security is used to generate an answer corresponding to the question, and the answer generated by the large language model that has been trained for security does not contain harmful information.

[0241] Optionally, the device further comprises:

[0242] The first model adjustment module is used to obtain an attack question set and a natural question set; generate answers corresponding to each question in the attack question set and the natural question set respectively through a large language model; perform a performance evaluation on the large language model based on the answers generated by the large language model; and adjust the large language model based on the performance evaluation results.

[0243] Optionally, the device further comprises:

[0244] The second model adjustment module is used to obtain a question set; generate answers corresponding to each question in the question set through multiple working modes of the large language model; perform performance evaluation on each working mode of the large language model based on the answers corresponding to the multiple working modes; and adjust the large language model based on the performance evaluation results.

[0245] Optionally, the multiple working modes include at least two of a pure large model mode, an artificial intelligence AI search mode, and a retrieval enhancement generation RAG mode;

[0246] The pure large model mode refers to the mode that generates answers based only on the internal knowledge of the model;

[0247] AI search mode refers to the mode of generating answers based on the internal knowledge of the model and the knowledge retrieved by the search engine on the Internet;

[0248] The RAG model refers to a model that generates answers based on the internal knowledge of the model, the knowledge retrieved by the search engine on the Internet, and the knowledge in the domain knowledge base.

[0249] Optionally, the device further comprises:

[0250] The knowledge base adjustment module is used to divide the question set into a consistent subset, a conflicting subset and an inconsistent subset based on the answers corresponding to each question in the question set generated by the large language model using the AI ​​search mode and the RAG mode respectively; among them, the questions in the consistent subset are questions that are answered correctly by both the AI ​​search mode and the RAG mode, the questions in the conflicting subset are questions that are answered correctly by one of the AI ​​search mode and the RAG mode, and the questions in the inconsistent subset are questions that are answered incorrectly by both the AI ​​search mode and the RAG mode; based on the division results of the question set, the domain knowledge base is adjusted to improve the accuracy of the answers in the RAG mode.

[0251] The answer generation device provided by the present application adopts the answer generation method in the above embodiment, which can solve the technical problem of low accuracy of answer generation by large language models in related technologies. Compared with the prior art, the beneficial effects of the answer generation device provided by the present application are the same as the beneficial effects of the answer generation method provided by the above embodiment, and other technical features in the answer generation device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0252] The present application provides an answer generation device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the answer generation method in the above-mentioned embodiment one.

[0253] Reference below Fig.13 , which shows a schematic diagram of the structure of an answer generation device suitable for implementing the embodiment of the present application. The answer generation device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig.13 The answer generating device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0254] like Fig.13As shown, the answer generation device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the answer generation device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the answer generation device to communicate with other devices wirelessly or by wire to exchange data. Although the answer generation device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.

[0255] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0256] The answer generation device provided by the present application adopts the answer generation method in the above embodiment, which can solve the technical problem of low accuracy of answer generation by large language models in related technologies. Compared with the prior art, the beneficial effects of the answer generation device provided by the present application are the same as the beneficial effects of the answer generation method provided by the above embodiment, and the other technical features in the answer generation device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0257] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0258] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0259] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer program) stored thereon, and the computer-readable program instructions are used to execute the answer generation method in the above-mentioned embodiment.

[0260] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0261] The computer-readable storage medium may be included in the answer generation device; or may exist independently without being assembled into the answer generation device.

[0262] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the answer generation device, the answer generation device: obtains the question corresponding to the dialogue instruction in response to the dialogue instruction; retrieves at least one first paragraph matching the question from the external knowledge of the model, and generates at least one second paragraph matching the question based on the internal knowledge of the model through the large language model; merges the first paragraph and the second paragraph into a paragraph set, and identifies the source information of each paragraph in the paragraph set, the source information indicating whether the corresponding paragraph comes from inside or outside the model; generates the answer corresponding to the question through the large language model based on the paragraph set and the source information of each paragraph in the paragraph set.

[0263] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0264] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0265] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0266] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned answer generation method, and can solve the technical problem of low accuracy of answers generated by large language models in related technologies. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the answer generation method provided in the above-mentioned embodiment, and will not be repeated here.

[0267] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned answer generation method when executed by a processor.

[0268] The computer program product provided by this application can solve the technical problem of low accuracy of answer generation by large language models in related technologies. Compared with the prior art, the beneficial effects of the computer program product provided by this application are the same as those of the answer generation method provided by the above embodiment, which will not be elaborated here.

[0269] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A method for generating an answer, characterized in that: The method comprises: In response to a dialogue instruction, obtaining a question corresponding to the dialogue instruction; Retrieving at least one first paragraph matching the question from model external knowledge, and generating at least one second paragraph matching the question based on model internal knowledge through a large language model; Merging the first paragraph and the second paragraph into a paragraph set, and identifying source information of each paragraph in the paragraph set, wherein the source information indicates whether the corresponding paragraph is from inside the model or outside the model; An answer corresponding to the question is generated through the large language model based on the paragraph set and source information of each paragraph in the paragraph set.

2. The method according to claim 1, characterized in that The generating, by using the large language model, an answer corresponding to the question based on the paragraph set and source information of each paragraph in the paragraph set includes: By using the large language model, based on the question and the source information of each paragraph in the paragraph set, the paragraph set is iteratively updated, and the source information of each paragraph in the paragraph set obtained by each iterative update is identified, wherein the iterative update is used to retain the information that is consistent inside and outside the paragraph set and filter out the information that is inconsistent inside and outside and the irrelevant information of the question; Based on the paragraph set obtained by each iterative update and the source information of each paragraph in the paragraph set, an answer corresponding to the question is generated.

3. The method according to claim 2, characterized in that The generating an answer corresponding to the question based on the paragraph set obtained by each iterative update and the source information of each paragraph in the paragraph set includes: Through the large language model, based on the paragraph sets obtained from each iterative update and the source information of each paragraph in the paragraph set, alternative answers corresponding to each iterative update are generated respectively, and the answer corresponding to the question is selected from the generated multiple alternative answers.

4. The method according to claim 1, characterized in that The model external knowledge includes a domain knowledge base. Before retrieving at least one first paragraph matching the question from the model external knowledge, the method further includes: Obtaining a target website list, wherein the target website list includes multiple authoritative website identifiers; Compare the primary domain name in the uniform resource locator URL corresponding to the crawled network resource with the website identifier in the target website list; In the case where the primary domain name matches the website identifier in the target website list, the network resource is stored in the domain knowledge base.

5. The method according to claim 1, characterized in that The model external knowledge includes a domain knowledge base. Before retrieving at least one first paragraph matching the question from the model external knowledge, the method further includes: Determine the knowledge type involved in the content of the crawled network resources through the large language model; In the case where the knowledge type involved in the content of the network resource matches the knowledge type of the domain knowledge base, the network resource is stored in the domain knowledge base.

6. The method according to claim 1, characterized in that The model external knowledge includes a domain knowledge base. Before retrieving at least one first paragraph matching the question from the model external knowledge, the method further includes: Call the risk control interface to detect harmful information on the content of the crawled network resources and obtain the harmful information detection result; When the harmful information detection result indicates that the content of the network resource does not contain harmful information, the network resource is stored in the domain knowledge base.

7. An answer generation device, characterized in that: The device comprises: A question acquisition module, used for acquiring a question corresponding to the dialogue instruction in response to the dialogue instruction; A paragraph acquisition module, used to retrieve at least one first paragraph matching the question from the model external knowledge, and generate at least one second paragraph matching the question based on the model internal knowledge through a large language model; a paragraph synthesis module, configured to merge the first paragraph and the second paragraph into a paragraph set, and identify source information of each paragraph in the paragraph set, wherein the source information indicates whether the corresponding paragraph is from inside the model or outside the model; The answer generation module is used to generate an answer corresponding to the question based on the paragraph set and the source information of each paragraph in the paragraph set through the large language model.

8. A device for generating an answer, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the answer generation method according to any one of claims 1 to 6.

9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the answer generation method according to any one of claims 1 to 6 are implemented.

10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the answer generation method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Automatic question answering method and device based on artificial intelligence, storage medium and server

    CN114003708A

  • Document data updating method and device, equipment and medium

    CN117708064A

  • Knowledge base question and answer construction method and device based on large model

    CN118035405A

  • RAG mixed retrieval method and device for improving accuracy of large language model

    CN118277522A

  • Knowledge question and answer method, device and equipment and storage medium

    CN119322827A

Cited By

  • Text interaction method, system and equipment based on large language model and medium

    CN121561031A