Answer generation method and device, equipment, storage medium and product
By retrieving paragraphs that match the question from external knowledge and merging them with internal knowledge, combined with iterative updates and source information evaluation, the problem of inaccurate generation by large language models is solved, and more reliable and accurate answer generation is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-18
- Publication Date
- 2026-03-17
AI Technical Summary
When generating responses, large language models are prone to producing answers that are inconsistent with the facts or have no basis, making it difficult to meet the accuracy requirements of actual situations.
By retrieving paragraphs matching the question from external knowledge sources and merging them with paragraphs generated from internal knowledge sources to form a paragraph set, identifying source information, generating answers using a large language model, and evaluating the reliability of knowledge by combining iterative updates and source information, an accurate answer is generated.
It improves the accuracy and reliability of the answers, compensates for the limitations of the model's internal knowledge, obtains broader and more timely information, and ensures the clarity and credibility of the answers.
Smart Images

Figure CN119760101B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of natural language processing technology, and in particular to a method, apparatus, device, storage medium and product for generating answers. Background Technology
[0002] With the rapid development of the internet and the dramatic increase in information volume, users' demand for quickly and accurately obtaining the information they need is growing, thus giving rise to question-answering systems. A question-answering system is a natural language processing technology designed to automatically answer questions posed by users in natural language.
[0003] Related technologies typically rely on large language models to generate answers in question-answering systems. However, due to limitations in the quality and coverage of the model training data, large language models are prone to generating answers that are inconsistent with the facts or even completely unfounded, resulting in inaccuracies that fail to meet practical needs and necessitate improvement.
[0004] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0005] The main objective of this application is to provide a method, apparatus, device, storage medium, and product for generating answers that can generate reliable answers and improve the accuracy of the answers.
[0006] To achieve the above objectives, this application proposes a method for generating answers, the method comprising:
[0007] In response to a dialogue command, obtain the question corresponding to the dialogue command;
[0008] Retrieve at least one first paragraph matching the question from external knowledge of the model, and generate at least one second paragraph matching the question based on internal knowledge of the model using a large language model;
[0009] 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. The source information indicates whether the corresponding paragraph comes from inside the model or outside the model.
[0010] Using the large language model, and based on the paragraph set and the source information of each paragraph in the paragraph set, the answer to the question is generated.
[0011] Optionally, generating the answer to the question using the large language model, based on the paragraph set and the source information of each paragraph in the paragraph set, includes:
[0012] 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 in each iteration is identified. The iterative update is used to retain consistent information in the paragraph set, filter out inconsistent information and irrelevant information of the question.
[0013] Based on the paragraph set obtained from each iteration update and the source information of each paragraph in the paragraph set, the answer to the question is generated.
[0014] Optionally, generating the answer to the question based on the paragraph set obtained from each iteration update and the source information of each paragraph in the paragraph set includes:
[0015] Using the large language model, candidate answers corresponding to each iteration update are generated based on the paragraph set obtained from each iteration update and the source information of each paragraph in the paragraph set, and the answer corresponding to the question is selected from the multiple candidate answers generated.
[0016] Optionally, the external knowledge of the model includes a domain knowledge base, and before retrieving at least one first paragraph matching the question from the external knowledge of the model, the method further includes:
[0017] Obtain a list of target websites, which includes multiple authoritative website identifiers;
[0018] The main domain name in the Uniform Resource Locator URL corresponding to the crawled network resources is compared with the website identifier in the target website list;
[0019] If the main domain name matches a website identifier in the target website list, the network resource is stored in the domain knowledge base.
[0020] Optionally, the external knowledge of the model includes a domain knowledge base, and before retrieving at least one first paragraph matching the question from the external knowledge of the model, the method further includes:
[0021] The large language model is used to determine the knowledge types involved in the content of the crawled web resources;
[0022] If 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 external knowledge of the model includes a domain knowledge base, and before retrieving at least one first paragraph matching the question from the external knowledge of the model, the method further includes:
[0024] The risk control interface is invoked to detect harmful information in the content of the crawled network resources, and the harmful information detection results are obtained.
[0025] If 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 external knowledge of the model includes a domain knowledge base, and retrieving at least one first paragraph matching the problem from the external knowledge of the model includes:
[0027] The problem detection model is used to detect the types of knowledge involved in the problem, and the type detection results are obtained.
[0028] If the type detection result indicates that the knowledge type involved in the problem matches the knowledge type in the domain knowledge base, at least one first paragraph matching the problem is retrieved from the network and the domain knowledge base; otherwise, at least one first paragraph matching the problem is retrieved from the network.
[0029] Optionally, after responding to a dialogue instruction and obtaining the question corresponding to the dialogue instruction, the method further includes:
[0030] The problem is assessed using a problem detection model to obtain risk detection results.
[0031] If the risk detection result indicates that there is a specified type of security risk in answering the question, a security-trained large language model is selected from multiple large language models. The security-trained large language model is used to generate the answer to the question, and the answer generated by the security-trained large language model 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] Obtain the attack problem set and the natural problem set;
[0034] The large language model is used to generate answers to each question in the attack question set and the natural question set, respectively.
[0035] Based on the answers generated by the large language model, the performance of the large language model is evaluated.
[0036] Based on the performance evaluation results, the large language model was 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] The large language model generates answers to each question in the question set through its various working modes.
[0040] Based on the answers corresponding to the various working modes, the performance of each working mode of the large language model is evaluated.
[0041] Based on the performance evaluation results, the large language model was adjusted.
[0042] Optionally, the multiple working modes include at least two of the following: pure large model mode, artificial intelligence (AI) search mode, and retrieval-enhanced generation (RAG) mode.
[0043] The pure large model mode refers to a mode that generates answers solely based on the knowledge within the model;
[0044] The AI search mode refers to a mode that generates answers based on the knowledge within the model and the knowledge retrieved by the search engine from the internet;
[0045] The RAG mode refers to a mode that generates answers based on the knowledge within the model, the knowledge retrieved from the internet by the search engine, and the knowledge in the domain knowledge base.
[0046] Optionally, the method further includes:
[0047] Based on the answers 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 problems in the consistent subset are those that are answered correctly by both the AI search mode and the RAG mode; the problems in the conflict subset are those that are answered correctly by either the AI search mode or the RAG mode; and the problems in the inconsistent subset are those 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 mode.
[0050] Furthermore, to achieve the above objectives, this application also proposes a response generation apparatus, the apparatus comprising:
[0051] The question acquisition module is used to acquire the question corresponding to the dialogue command in response to the dialogue command;
[0052] The paragraph acquisition module is used to retrieve at least one first paragraph that matches the question from external knowledge of the model, and generate at least one second paragraph that matches the question based on internal knowledge of the model using a large language model.
[0053] The paragraph synthesis module is used to merge the first paragraph and the second paragraph into a paragraph set, and to identify the source information of each paragraph in the paragraph set, wherein the source information indicates whether the corresponding paragraph comes from inside the model or outside the model;
[0054] The answer generation module is used to generate an answer to the question based on the large language model, the paragraph set, and the source information of each paragraph in the paragraph set.
[0055] Optionally, the answer generation module includes:
[0056] The paragraph update unit is used to iteratively update the paragraph set based on the question and the source information of each paragraph in the paragraph set using the large language model, and to identify the source information of each paragraph in the paragraph set obtained in each iteration update. The iterative update is used to retain consistent information in the paragraph set and filter out inconsistent information and irrelevant information of the question.
[0057] The answer generation unit is used to generate an answer to the question based on the paragraph set obtained from each iteration update and the source information of each paragraph in the paragraph set.
[0058] Optionally, the answer generation unit is configured to generate candidate answers corresponding to each iteration update based on the paragraph set obtained in each iteration update and the source information of each paragraph in the paragraph set, using the large language model, and select the answer corresponding to the question from the generated candidate answers.
[0059] Optionally, the external knowledge of the model includes a domain knowledge base, and the device further includes:
[0060] The first knowledge base construction module is used to obtain a list of target websites, which includes multiple authoritative website identifiers; compare the main domain name in the Uniform Resource Locator URL corresponding to the crawled network resources with the website identifiers in the target website list; and if the main domain name matches the website identifiers in the target website list, store the network resources in the domain knowledge base.
[0061] Optionally, the external knowledge of the model includes a domain knowledge base, and the device further includes:
[0062] The second knowledge base construction module is used to determine the knowledge types involved in the content of the crawled network resources through the large language model; and when the knowledge types involved in the content of the network resources match the knowledge types of the domain knowledge base, the network resources are stored in the domain knowledge base.
[0063] Optionally, the external knowledge of the model 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 detect harmful information in the content of the crawled network resources and obtain harmful information detection results; if 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 external knowledge of the model 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 and obtain a type detection result; if 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.
[0067] Optionally, the device further includes:
[0068] The model determination module is used to perform risk detection on the question using a question detection model and obtain a risk detection result; if the risk detection result indicates that there is a specified type of security risk in answering the question, a security-trained large language model is selected from multiple large language models, and the security-trained large language model is used to generate the answer corresponding to the question, and the answer generated by the security-trained large language model does not contain harmful information.
[0069] Optionally, the device further includes:
[0070] The first model adjustment module is used to obtain a set of attack questions and a set of natural questions; generate answers corresponding to each question in the set of attack questions and the set of natural questions respectively through the large language model; evaluate the performance of 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.
[0071] Optionally, the device further includes:
[0072] The second model adjustment module is used to obtain a set of questions; generate answers for each question in the set of questions through multiple working modes of the large language model; evaluate the performance of 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 the following: pure large model mode, artificial intelligence (AI) search mode, and retrieval-enhanced generation (RAG) mode.
[0074] The pure large model mode refers to a mode that generates answers solely based on the knowledge within the model;
[0075] The AI search mode refers to a mode that generates answers based on the knowledge within the model and the knowledge retrieved by the search engine from the internet;
[0076] The RAG mode refers to a mode that generates answers based on the knowledge within the model, the knowledge retrieved from the internet by the search engine, and the knowledge in the domain knowledge base.
[0077] Optionally, the device further includes:
[0078] The knowledge base adjustment module is used to divide the question set into consistent subsets, conflict subsets, and inconsistent subsets based on the answers to each question generated by the large language model using the AI search mode and the RAG mode, respectively. The consistent subset contains questions that are answered correctly by both the AI search mode and the RAG mode; the conflict subset contains questions that are answered correctly by one of the AI search mode and the RAG mode; and the inconsistent subset contains questions that are answered incorrectly by both the AI search mode and the RAG mode. Based on the division of the question set, the domain knowledge base is adjusted to improve the accuracy of the RAG mode's answers.
[0079] In addition, to achieve the above objectives, this application also proposes an answer generation device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the answer generation method as described above.
[0080] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and which, when executed by a processor, implements the steps of the answer generation method described above.
[0081] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the answer generation method described above.
[0082] One or more technical solutions proposed in this application have at least the following technical effects:
[0083] The answer generation scheme provided in this application takes into account the potential issues of incomplete or outdated model training data. Therefore, after obtaining the question corresponding to the dialogue instruction, it retrieves at least one first paragraph matching the question from external knowledge and generates at least one second paragraph matching the question using a large language model based on its internal knowledge. The first and second paragraphs are then merged into a paragraph set, thus compensating for the limitations of the large language model's internal knowledge and enabling the model to acquire broader and more timely information. Next, the source information of each paragraph in the paragraph set is identified, allowing the large language model to clearly distinguish the origins of different knowledge sources when generating answers. When there are discrepancies between internal and external knowledge, the model can assess the reliability of the knowledge based on the source information, thereby better integrating and analyzing knowledge to generate more reliable and accurate question-and-answer pairs. Attached Figure Description
[0084] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0085] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0086] Figure 1 This is a schematic diagram of an implementation environment for the response generation method of this application;
[0087] Figure 2 This is a flowchart illustrating the first embodiment of the response generation method for this application.
[0088] Figure 3 A schematic diagram of the structure of a question-and-answer system provided in this application;
[0089] Figure 4 This is a flowchart illustrating the second embodiment of the response generation method for this application.
[0090] Figure 5 This is a flowchart illustrating the third embodiment of the response generation method for this application.
[0091] Figure 6 This is a flowchart illustrating the fourth embodiment of the method for generating answers in this application.
[0092] Figure 7 This is a flowchart illustrating the fifth embodiment of the response generation method for this application.
[0093] Figure 8 A schematic diagram illustrating the construction process of a political domain knowledge base provided for this application;
[0094] Figure 9 This is a flowchart illustrating the sixth embodiment of the method for generating answers in this application.
[0095] Figure 10 This is a flowchart illustrating the seventh embodiment of the method for generating answers in this application.
[0096] Figure 11 A schematic diagram illustrating a performance evaluation process for the large language model provided in this application;
[0097] Figure 12 This is a schematic diagram of the module structure of the answer generation device in the embodiments of this application;
[0098] Figure 13 This is a schematic diagram of the device structure of the hardware operating environment involved in the answer generation method in this application embodiment.
[0099] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0100] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0101] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0102] Figure 1 This is a schematic diagram illustrating an implementation environment provided by an embodiment of this disclosure. See also... 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. For example, the terminal 101 is installed with a target application provided by the server 102, and the terminal 101 can perform functions such as data transmission and message interaction through the target application.
[0103] For example, terminal 101 can be a computer, mobile phone, tablet computer, or other terminal. For example, the target application can be a target application within the operating system of terminal 101, or a target application provided by a third party. For example, the target application can be a search application, a short video application, a shopping application, a navigation application, etc. For example, server 102 can be the backend server corresponding to the target application. Accordingly, server 102 can be a search application server, a short video application server, a shopping application server, a navigation application server, etc.
[0104] In this application, terminal 101 is used to respond to a dialogue command and obtain the question corresponding to the dialogue command. It then sends the question to server 102. Server 102 receives the question, retrieves at least one first paragraph matching the question from external model knowledge, and generates at least one second paragraph matching the question based on internal model knowledge using a large language model. The first and second paragraphs are merged into a paragraph set, and the source information of each paragraph in the paragraph set is identified, indicating whether the corresponding paragraph originates from within or outside the model. Next, based on the paragraph set and the source information of each paragraph in the paragraph set, the large language model generates an answer corresponding to the question. This answer is then sent to terminal 101. Terminal 101 receives and displays the answer.
[0105] Alternatively, the above-mentioned answer generation process can also be completed by terminal 101 alone. Alternatively, terminal 101 can complete it through an installed target application, such as a search application. This application embodiment does not impose any limitations on this.
[0106] The answer generation method provided in this application is applicable to various scenarios. For example, in the scenario of querying political information, users can ask questions about political news, events, and other information they want to know. The terminal then uses the method provided in this application to quickly find the political information the user needs and present it to the user as an answer. Another example is the medical scenario. The terminal can use the method provided in this application to answer various medical questions, assisting users in the medical field to solve various medical problems. Yet another example is the financial investment scenario. Users can ask questions about various financial investment information they need, such as the price trend of a certain financial product, to help them plan their investment decisions.
[0107] Figure 2 This is a flowchart illustrating the first embodiment of the method for generating responses to this application. (Refer to...) Figure 2 Taking the terminal as the executing entity as an example, the answer generation method includes the following steps S10 to S40:
[0108] Step S10: In response to the dialogue command, obtain the question corresponding to the dialogue command.
[0109] Dialogue commands are requests or commands issued by users to a terminal via voice, text, or other means. They can be direct questions, such as "What's the weather like in Beijing today?", or indirect expressions of needs, such as "I want to know the latest movie schedules." Regardless of the specific content of a dialogue command, this application refers to the content expressed in dialogue commands collectively as "questions."
[0110] For example, the terminal displays a dialog interface through which the user inputs any dialogue content. In response to the user's input, the terminal generates a dialogue command, using the user's input as the corresponding question.
[0111] Optionally, the large language model for handling the question is determined based on whether the question involves security risks. Specifically, after the terminal responds to the dialogue command and obtains the question corresponding to the dialogue command, it performs risk detection on the question using a question detection model to obtain a risk detection result. If the risk detection result indicates that the answer to the question has a specified type of security risk, a security-trained large language model is selected from multiple large language models. The security-trained large language model is used to generate the answer to the question, and the answer generated by the security-trained large language model does not contain harmful information.
[0112] For example, if the risk detection result indicates that there is no specified type of security risk in answering the question, an unsecured large language model is selected from multiple large language models, and the question is subsequently processed using this unsecured large language model. This embodiment of the application flexibly selects a large language model based on the risk status of the question, improving the question-answering system's ability to handle different types of questions. For ordinary questions, conventional models can be used for rapid processing, improving efficiency. For questions with security risks, a securely trained large language model is activated to ensure the security of the answer, enabling the system to better adapt to complex and ever-changing application scenarios.
[0113] Problem detection models are specifically designed to assess the risks of input problems. They employ specific algorithms and techniques, such as text classification, keyword recognition, and semantic analysis in natural language processing, to analyze the problem and determine whether it poses a security risk and the type of risk. This provides a basis for selecting a suitable large language model. Security risks refer to harmful content that the problem may contain, such as violence, discrimination, pornography, false information, or sensitive political information, or potential risk factors that may adversely affect system security or information security due to the intent behind the problem.
[0114] A security-trained large language model is a large language model that, in addition to regular training, undergoes extra training specifically for security-related content. During training, a large amount of sample data containing security risk information is used to teach the model how to identify and avoid generating harmful information. This ensures that when dealing with security-risk questions, the generated answers comply with security standards and do not contain any potentially harmful content.
[0115] In this embodiment, a problem detection model is used to detect risks in questions to identify those with security risks. A security-trained large language model is then used for processing, preventing the output of harmful information at the source and ensuring a safe information dissemination environment. Furthermore, users of the question-and-answer system do not need to worry about receiving answers containing harmful information; they can obtain more reliable and standardized answers, thereby improving user satisfaction.
[0116] Step S20: Retrieve at least one first paragraph that matches the question from external knowledge of the model, and generate at least one second paragraph that matches the question based on internal knowledge of the model using a large language model.
[0117] Large language models are language models trained using deep learning techniques. They possess powerful language understanding and generation capabilities, enabling them to process and generate natural language text. In question-answering systems, they play a crucial role in generating answers. For example, large language models are generative pre-trained models, such as GPT (a type of generative pre-trained model).
[0118] External knowledge refers to knowledge sources independent of the training data of the large language model. It is stored in external storage media such as databases and internet documents, possessing broader and more real-time information, and is used to supplement the limitations of the large language model's own knowledge. Internal knowledge refers to the knowledge learned by the large language model during training and stored in the model parameters. This knowledge originates from a large amount of text data, but may suffer from problems such as untimely updates and incomplete coverage.
[0119] The first paragraph is a text segment retrieved from external knowledge sources that matches the question in content; it represents information fragments from external knowledge that may be relevant to the answer. The second paragraph is a text segment generated by the large language model based on its internal knowledge, reflecting the model's understanding of the question and its initial response based on existing knowledge.
[0120] Optionally, the external knowledge of the model includes a domain knowledge base. Retrieving at least one first paragraph matching the question from the external knowledge of the model includes: detecting the knowledge type involved in the question using a question detection model to obtain a type detection result. If the type detection result indicates that the knowledge type involved in the question matches the knowledge type in the domain knowledge base, at least one first paragraph matching the question is retrieved from the internet and the domain knowledge base; otherwise, at least one first paragraph matching the question is retrieved from the internet.
[0121] Domain-specific knowledge bases are collections of knowledge specifically built for a particular domain. They store organized and filtered professional knowledge within that domain, exhibiting systematicity, specialization, and relevance. For example, a medical knowledge base contains information on disease diagnosis, treatment plans, and drug information. A financial knowledge base contains information on financial products, market dynamics, and economic regulations. A political knowledge base contains information on political theories, political systems, political figures and events, and current political events.
[0122] Knowledge types are used to distinguish knowledge from different fields. Examples include medical knowledge, financial knowledge, and political knowledge. The question detection model outputs a type detection result after detecting the knowledge type involved in the question, indicating the matching degree between the knowledge type involved in the question and the knowledge types in a specific knowledge base. This provides a basis for subsequent decisions on where to retrieve relevant knowledge.
[0123] In this embodiment, if the knowledge type involved in the question matches the knowledge type in the domain knowledge base, the first paragraph is retrieved first from both the domain knowledge base and the web. Because the domain knowledge base is meticulously organized and contains high-quality information, utilizing it to obtain professional knowledge provides a more accurate and authoritative answer. If the knowledge type involved in the question does not match the knowledge type in the domain knowledge base, only the first paragraph is retrieved from the web. This avoids ineffective searches in the domain knowledge base for knowledge types not covered, concentrating resources on web searches and improving overall retrieval 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. The source information indicates whether the corresponding paragraph comes from inside the model or outside the model.
[0125] The paragraph set is a collection formed by combining all detected first paragraphs and all generated second paragraphs. It contains question-related text paragraphs from both outside and inside the model and forms the information basis for generating the final answer.
[0126] Source information is used to mark the origin of each paragraph in the paragraph set, clearly indicating whether each paragraph originates from external knowledge retrieval results or is generated by the large language model based on internal knowledge.
[0127] Step S40: Using a large language model, based on the paragraph set and the source information of each paragraph in the paragraph set, generate the answer to the question.
[0128] The answer to the question is the solution provided to the user after the large language model processes the collection of paragraphs and the source information of each paragraph.
[0129] Figure 3 This is a schematic diagram of a question-and-answer system. (Reference) Figure 3 The question-and-answer system's open platform interface receives user questions. The questions are then passed to the risk control module, which uses a question detection model to assess their security. If no security risk is detected in the answer, the question is passed to a standard large language model (not security-trained). If a security risk is detected, the module determines whether the question involves politics. If the question does not involve politics, it is passed to a secure response model (security-trained large language model). If the question involves politics, the RAG module within the risk control module retrieves relevant knowledge from a political domain knowledge base and passes the question and related knowledge to the secure response model. For example, the RAG module can also integrate the relevant knowledge retrieved from the political domain knowledge base with relevant knowledge retrieved from a search engine online before passing the question and the integrated knowledge to the secure response model.
[0130] The answer generation scheme provided in this application takes into account the potential issues of incomplete or outdated model training data. Therefore, after obtaining the question corresponding to the dialogue instruction, it retrieves at least one first paragraph matching the question from external knowledge and generates at least one second paragraph matching the question using a large language model based on its internal knowledge. The first and second paragraphs are then merged into a paragraph set, thus compensating for the limitations of the large language model's internal knowledge and enabling the model to acquire broader and more timely information. Next, the source information of each paragraph in the paragraph set is identified, allowing the large language model to clearly distinguish the origins of different knowledge sources when generating answers. When there are discrepancies between internal and external knowledge, the model can assess the reliability of the knowledge based on the source information, thereby better integrating and analyzing knowledge to generate more reliable and accurate question-and-answer pairs.
[0131] Based on the first embodiment described above, a second embodiment of this application is proposed. Contents that are the same as or similar to the first embodiment can be referred to the above description and will not be repeated hereafter. (Refer to...) Figure 4 In the second embodiment, step S40 includes steps S401 to S402:
[0132] Step S401: Using the large language model, based on the source information of each paragraph in the question and paragraph set, iteratively update the paragraph set, and identify the source information of each paragraph in the paragraph set obtained in each iteration update. The iterative update is used to retain consistent information in the paragraph set, filter out inconsistent information and irrelevant information of the question.
[0133] Iterative updates refer to the process by which a large language model iterates through a collection of paragraphs multiple times to optimize it. During each iteration, the model adjusts the content of the current collection of paragraphs based on the question and the source information of the paragraphs. This means retaining information that meets the requirements and removing information that does not, gradually bringing the collection of paragraphs closer to the state most suitable for generating accurate answers. Each iteration is one such process.
[0134] In the context of consistent internal and external information, "internal" refers to paragraph information generated by the model based on its internal knowledge, while "external" refers to paragraph information retrieved from external knowledge sources. Consistent internal and external information means that the paragraph information generated internally by the model and the externally retrieved paragraph information are compatible in meaning and viewpoint, mutually corroborating and complementing each other to provide reliable evidence for answering the question.
[0135] Inconsistent information refers to information that contradicts, conflicts with, or differs between paragraph information generated internally by the model and paragraph information retrieved externally. For example, when answering questions about historical events, if the event time generated based on the model's internal knowledge is inconsistent with the time retrieved from external knowledge, this discrepancy falls under the category of inconsistent information.
[0136] Irrelevant information in a question refers to information in a collection of paragraphs that is not directly related to the question in terms of theme, content, or other aspects, and cannot help in answering the question.
[0137] Step S402: Based on the paragraph set obtained from each iteration update and the source information of each paragraph in the paragraph set, generate the answer to the question.
[0138] Optionally, based on the paragraph set obtained in each iteration update and the source information of each paragraph in the paragraph set, the answer to the question is generated, including: using a large language model, generating alternative answers corresponding to each iteration update based on the paragraph set obtained in each iteration update and the source information of each paragraph in the paragraph set, and selecting the answer to the question from the generated alternative answers.
[0139] When processing a problem, the large language model generates a candidate answer based on the updated paragraph set and paragraph source information after each iteration. After multiple iterations, the number of candidate answers will be the same as the number of iterations. Since the information in the paragraph set differs in each iteration, the generated candidate answers will also differ, thus providing multiple options for determining the final answer.
[0140] For example, from multiple candidate answers generated by a large language model, one is selected as the final output answer for the current question based on certain criteria and strategies. This selection process can comprehensively consider multiple factors such as the completeness, logic, relevance, source of information in the answer, and frequency of information occurrence to ensure that the answer provided to the user is of the best quality.
[0141] In this embodiment, considering that each iteration may highlight different key information in the paragraph set, alternative answers are generated based on the paragraph set obtained from each iteration and the source information of each paragraph in the paragraph set, thereby producing diverse alternative answers. Selecting the final answer from multiple alternative answers avoids the potential bias or inaccuracy of a single answer, thus improving the quality of the final answer.
[0142] For example, the following uses formulas to illustrate the process of obtaining a set of paragraphs and iteratively updating the set of paragraphs.
[0143] Formula (1): K←LLM(prompt1, query)
[0144] Where K represents the second paragraph generated by the large language model based on its internal knowledge. LLM stands for Large Language Model, prompt1 is the first prompt word, instructing the large language model to generate accurate, non-illusionary paragraphs relevant to the question based on its internal knowledge, and query represents the question.
[0145] Formula (2):
[0146] Among them, K C This is the merged collection of paragraphs. K R This is the first paragraph retrieved from external knowledge of the model.
[0147] Formula (3):
[0148] in, Let L be the set of paragraphs output after the i-th iteration update. (i+1)The source information of each paragraph in the paragraph set output after the i-th iteration update is provided. prompt2 is the second prompt word, which instructs the large language model to retain consistent information in the paragraph set and filter out inconsistent information and irrelevant information of the question. The set of paragraphs input for updating the i-th iteration. L (i) For the i-th iteration, update the source information of each paragraph in the input paragraph set.
[0149] Formula (4):
[0150] Here, 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 candidate answers for each iteration based on the paragraph set obtained from each iteration update and the source information of each paragraph in the paragraph set, and then select the final answer corresponding to the question from the multiple candidate answers generated. Let L be the set of paragraphs obtained from each iteration of the u-th iteration update. (u) This refers to the source information of each paragraph in the paragraph set obtained in each of the u iterations.
[0151] In this embodiment, by iteratively updating and retaining consistent information within the paragraph set while filtering out inconsistent information and irrelevant information, the final paragraph set used to generate the answer becomes more accurate. This allows the large language model to generate answers based on more reliable and relevant information, thereby providing users with more accurate and reliable responses.
[0152] Based on the first embodiment of this application described above, a third embodiment of this application is proposed. Contents that are the same as or similar to the first embodiment can be referred to the above description, and will not be repeated hereafter. See also... Figure 5 In the third embodiment, steps S011 to S013 are included before step S10.
[0153] Step S011: Obtain the target website list, which includes multiple authoritative website identifiers.
[0154] A target website list is a collection of identifiers for authoritative websites. These identifiers are used to determine which websites' online resources are trustworthy and suitable for storage in a domain knowledge base. Websites in the target website list possess high authority, credibility, and expertise within their specific domains. For example, in the political domain, the target website list includes official government websites and authoritative news media websites. Authoritative website identifiers are used to identify authoritative websites; for example, an authoritative website identifier might be the name of the authoritative website.
[0155] Step S012: Compare the main domain name in the Uniform Resource Locator URL corresponding to the crawled network resources with the website identifiers in the target website list.
[0156] Web crawling refers to the acquisition of various information from the internet through web crawling technology. This information may exist in various forms such as web page text and images, 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 amount of different types of knowledge content.
[0157] For example, crawled web resources, such as raw news data, need to be preprocessed. This step mainly includes the following aspects: Schema parsing: Parsing the structure of each news page to facilitate subsequent data extraction. Date extraction: Extracting the publication time from the news page to facilitate organizing news in chronological order. Title and content extraction: Extracting the title and body content from the news page for quick browsing and retrieval by users. Deduplication: Removing duplicate news by comparing news titles or content to avoid redundancy. Grouping by date: Categorizing news according to its publication date for easy querying by time dimension.
[0158] A URL (Uniform Resource Locator) is a string used to identify and locate resources on the internet. Every webpage, file, and other online resource has its corresponding URL. The URL allows you to accurately locate the corresponding online resource. The main domain name is the core part of the URL's domain name; it identifies the website to which the resource belongs and is crucial information for comparison with website identifiers in the target website list.
[0159] Step S013: If the main domain name matches the website identifier in the target website list, store the network resources in the domain knowledge base, which is contained in the external knowledge of the model.
[0160] To ensure the timeliness of data in the domain knowledge base, online resources can be crawled from the internet in real time, processed according to the methods provided in this application, and then stored in the domain knowledge base. For example, the latest news, journalist Q&A, and other politically related information can be crawled daily, processed, and stored in the political domain knowledge base.
[0161] It's important to note that if the domain knowledge base being built deals with politics, then the authoritative websites in the target website list above are those that publish authoritative political information. Similarly, if the domain knowledge base is related to medicine, then the authoritative websites in the target website list are those that publish authoritative medical information. This method of using the target website list allows for the selection of high-quality, professional information, ensuring the professionalism and authority of the domain knowledge base.
[0162] In this embodiment, a target website list is constructed using multiple authoritative website identifiers. Only when the website to which the crawled web resource belongs is determined to be an authoritative website in the target website list based on the main domain name of the web resource's URL, is the web resource stored in the domain knowledge base. This makes the knowledge in the domain knowledge base more accurate and reliable. Subsequent use of the knowledge in the domain knowledge base to generate answers can improve the accuracy and reliability of the responses.
[0163] Based on the first embodiment of this application described above, a fourth embodiment of this application is proposed. Contents that are the same as or similar to the first embodiment can be referred to the above description and will not be repeated hereafter. See also... Figure 6 In the fourth embodiment, steps S021 and S022 are included before step S10.
[0164] Step S021: Determine the knowledge types involved in the content of the crawled web resources through the large language model.
[0165] The knowledge types involved in the content of online resources are used to distinguish the domain to which the content belongs. For example, the knowledge types involved in the content of online resources may be political, financial, or medical.
[0166] Step S022: If 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, which is contained in the external knowledge of the model.
[0167] Matching the knowledge types involved in the content of online resources with the knowledge types of the domain knowledge base refers to whether the knowledge types of the online resources are consistent with or related to the pre-defined knowledge types of the domain knowledge base. For example, if the domain knowledge base focuses on the medical field, then when the large language model determines that the online resource content involves medical knowledge such as disease diagnosis and drug development, the two are considered to have a knowledge type match. If the domain knowledge base focuses on the political field, then when the large language model determines that the online resource content involves political knowledge such as political events and political opinions, the two are considered to have a knowledge type match.
[0168] For online resources like Wikipedia entries, given their broad knowledge coverage, it is necessary to determine the types of knowledge involved in the crawled Wikipedia entries to ensure that each domain's knowledge base only includes entries that match the preset knowledge types.
[0169] For example, before storing online resources such as Wikipedia entries in a domain knowledge base, preprocessing operations such as entity page extraction and deduplication can be performed on them.
[0170] It should be noted that while authoritative websites in the target website list, such as mainstream official media and Wikipedia, provide a wealth of information, there may be data deficiencies in certain niche areas or fringe topics. To address this issue, this application employs an open-ended supplementation strategy, allowing technical personnel to search for information from other websites online and supplement and modify the domain knowledge base based on the search results. This approach not only enriches the content of the domain knowledge base but also adapts to various unexpected problems.
[0171] In this embodiment, determining whether to store network resources in the domain knowledge base by judging whether the knowledge type matches ensures that the stored resources are consistent with the theme and positioning of the domain knowledge base. This makes the content of the domain knowledge base more accurate and professional, enhancing its authority.
[0172] Based on the first embodiment of this application described above, a fifth embodiment of this application is proposed. Contents that are the same as or similar to the first embodiment can be referred to the above description, and will not be repeated hereafter. See also... Figure 7 In the fifth embodiment, steps S031 and S032 are included before step S10.
[0173] Step S031: Call the risk control interface to detect harmful information in the content of the crawled network resources and obtain the harmful information detection results.
[0174] A risk control interface is a program interface used to detect whether harmful information exists in online resources. This interface can integrate various detection technologies, such as text analysis and image recognition, 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. This result indicates whether harmful information exists in the network resources, and the type of harmful information present.
[0176] Step S032: If 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 illustrating the construction process of a political knowledge base. Specifically, it uses news data to build this knowledge base. (Reference) Figure 8 First, news data is retrieved from the internet. Then, the news data undergoes preprocessing, including structure parsing, date extraction, title and content extraction, as well as deduplication and grouping. Next, trusted source filtering is performed, including obtaining a list of target websites, extracting the main domain from the news data's URLs, and comparing it with authoritative websites in the target website list to filter out news data from authoritative websites. Then, news risk control filtering is performed, i.e., risk detection is conducted on the content of the news data through a risk control interface to filter out news data that does not contain harmful information. Alternatively, news data without harmful information can be obtained through manual filtering. Finally, the filtered news data is stored in a political domain knowledge base.
[0178] In this embodiment, by detecting harmful information in crawled network resources, only those resources confirmed to be free of harmful information are stored in the domain knowledge base. This effectively prevents harmful information such as violence, pornography, terrorism, and misinformation from entering the domain knowledge base, ensuring its purity and security. Since the domain knowledge base is a crucial source of knowledge for question-and-answer systems, the exclusion of harmful information ensures that question-and-answer systems based on this knowledge base are not influenced by harmful information when answering user questions, resulting in more reliable, accurate answers that comply with laws, regulations, and ethical standards.
[0179] Based on the first embodiment of this application described above, a sixth embodiment of this application is proposed. Contents that are the same as or similar to the first embodiment can be referred to the above description, and will not be repeated hereafter. See also... Figure 9 In the sixth embodiment, steps S041 to S044 are included before step S10.
[0180] Step S041: Obtain the attack problem set and the natural problem set.
[0181] An attack question set refers to a collection of questions containing various harmful information, malicious intent, or designed to probe or damage a system. These questions may include violent, discriminatory, pornographic, or fraudulent content, or be used to probe weaknesses in large language models. For example, questions containing malicious attacks against a specific group fall under the attack question set. Exemplarily, the attack question set includes malicious questions detected from questions collected by a question-answering system, as well as attack questions synthesized based on known model vulnerabilities or theoretical attack prompts.
[0182] A natural question set is a collection of questions asked by users based on normal information needs. These questions do not contain harmful content or malicious intent, and their purpose is to acquire knowledge, resolve doubts, or conduct ordinary communication. For example, a natural question set includes questions that remain after filtering out malicious questions from questions collected by a question-answering system.
[0183] Step S042: Generate the answers to each question in the attack question set and the natural question set using the large language model.
[0184] Step S043: Based on the answers generated by the large language model, evaluate the performance of the large language model.
[0185] Performance evaluation involves the quantitative analysis and assessment of a large language model's performance in generating answers to sets of attack questions and natural questions. Evaluation metrics can include multiple dimensions such as accuracy, security, and relevance of the answers, thereby providing a comprehensive understanding of the large language model's capabilities and limitations in handling different types of questions.
[0186] Step S044: Adjust the large language model based on the performance evaluation results.
[0187] The performance evaluation results are data and conclusions obtained from the performance evaluation of the large language model regarding various indicators. These results intuitively reflect the advantages and disadvantages of the large language model in handling attack and natural language problems, providing a clear basis for subsequent model adjustments.
[0188] In this embodiment, by testing the large language model using both attack question sets and natural question sets, the model's performance can be comprehensively evaluated from two dimensions: normal usage scenarios and malicious attack scenarios. This allows us to understand the model's performance when meeting normal user needs, as well as its ability to cope with malicious input, thus providing a more complete and in-depth understanding of the model's capabilities.
[0189] Based on the performance evaluation results, adjustments to the large language model can not only effectively enhance its ability to identify and prevent harmful information, improve its security and stability in complex network environments, and prevent malicious exploitation, but also optimize its performance in handling users' actual needs, improve the accuracy and practicality of its answers, and increase user satisfaction with the model.
[0190] Based on the first embodiment of this application described above, a seventh embodiment of this application is proposed. Contents that are the same as or similar to the first embodiment can be referred to the above description, and will not be repeated hereafter. See also... Figure 10 In the seventh embodiment, steps S051 to S054 are included before step S10.
[0191] Step S051: Obtain the problem set.
[0192] A question set is a representative and diverse combination of questions used to comprehensively evaluate the performance of a large language model in different scenarios. For example, the question set includes an attack question set and a natural question set.
[0193] Step S052: Through the various working modes of the large language model, generate the answers corresponding to each question in the question set.
[0194] The working modes of a large language model refer to the different operating methods set up by the large language model to adapt to different application scenarios or user needs. Optionally, multiple working modes include at least two of the following: pure large model mode, artificial intelligence (AI) search mode, and retrieval-enhanced generation (RAG) mode.
[0195] Among them, the pure large model mode refers to the mode that generates answers solely based on the model's internal knowledge. That is, the large language model relies entirely on the knowledge it has learned during training and stored in the model parameters to generate answers. It does not rely on external real-time retrieved information, but simply thinks and answers based on its existing internal knowledge system.
[0196] AI search mode refers to a model that generates answers based on the model's internal knowledge and knowledge retrieved from the internet by a search engine. This mode combines the internal knowledge of a large language model with the knowledge obtained by the search engine from the internet. The large language model first uses its own knowledge to perform a preliminary understanding and analysis of the question, then uses the search engine to retrieve relevant content from the vast online information, and finally combines the two to generate an answer. When answering time-sensitive questions, the model's internal knowledge may not be able to cover the latest information. In this case, retrieving the latest scientific and technological information from the internet through a search engine and then integrating it with the model's own knowledge can provide a more timely and comprehensive answer.
[0197] The RAG (Resource-Agent-Generated) model refers to a method of generating answers based on the model's internal knowledge, knowledge retrieved from the internet by search engines, and knowledge from a domain knowledge base. This model further expands the sources of knowledge, incorporating not only internal model knowledge and knowledge retrieved from the internet by search engines, but also professional knowledge from a domain knowledge base. A domain knowledge base is a carefully constructed collection of knowledge specific to a particular domain, possessing professionalism and authority. In the RAG model, the model integrates these three aspects of knowledge to generate an answer when processing a question. For example, when answering professional questions in the medical field, it not only relies on the medical knowledge learned by the model itself and medical information found online, but also refers to professional theories and clinical research findings from a medical knowledge base, thus providing a more professional and accurate answer.
[0198] Different working modes are suitable for different types of problems and scenarios. The pure large model mode is suitable for answering questions based on common sense that don't require real-time information updates, quickly providing answers based on the model's existing knowledge. The AI search mode is suitable for questions that require incorporating the latest information, such as current events and popular culture. The RAG mode excels at handling specialized domain problems, providing in-depth and professional solutions using domain knowledge bases. This diverse range of modes can meet users' various needs in different scenarios, enhancing the user experience. In practical applications, the appropriate working mode can be selected based on the type of problem.
[0199] Step S053: Based on the answers corresponding to multiple working modes, perform performance evaluation on each working mode of the large language model.
[0200] Performance evaluation is the process of quantitatively analyzing and evaluating the responses generated by each working mode of a large language model, based on a series of pre-defined standards and indicators. Evaluation indicators may include the accuracy, security, completeness, relevance, and efficiency of the responses. Through performance evaluation, the strengths and weaknesses of each working mode in different aspects can be clearly identified.
[0201] For example, the model's responses in various operating modes can be evaluated through a performance evaluation interface. For instance, the SafetyEval API (Safety Evaluation Application Programming Interface) can be used to perform a safety evaluation of the model's responses in various operating modes, with evaluation levels including harmful, rejected, and safe.
[0202] For example, performance evaluation is conducted through manual annotation. First, each work mode's answer to the same question is assigned a safety score, with 1 indicating harm and 2 indicating safety. Then, the answers from the three work modes are compared to determine which work mode provides the best answer, and the winning work mode is identified. If the three work modes are considered to perform similarly for the same question, they are marked as "same".
[0203] For example, the performance of each workflow mode can be evaluated in terms of security, recall, and accuracy. The following are the evaluation data for each workflow mode.
[0204] First, regarding the recall rate for political issues: the RAG pattern recall rate for the natural question set was 16.8%. Within the attack question set, the RAG pattern recall rate for the nano-inspection attack set was 17.1%, and the RAG pattern recall rate for the red team attack set was 7.3%. The nano-inspection attack set includes malicious questions detected from questions collected from question-answering systems. The red team attack set contains attack questions synthesized based on known model vulnerabilities or theoretical attack hints. The RAG pattern recall rate for the Cyberspace Administration of China (CAC) question set within the attack question set was 10.1%.
[0205] Regarding the recall rate of questions in the financial sector: the recall rate of the RAG pattern for the ICBC question set was 29.4%. The overall recall rate of the RAG pattern across nine datasets in OpenFindata (an open-source financial evaluation dataset) was 17.2%.
[0206] For medical questions, the RAG pattern recall rate for the Chinese dataset MMedC (Multilingual Medical Corpus) is 7.6%, while the RAG pattern recall rate for the English dataset MMedC is 9.7%.
[0207] Second, regarding security in the political domain: For the nano-inspection attack set, the RAG pattern generated 8.33% more secure answers than the AI search pattern. For the red team attack set, the RAG pattern generated 8.37% more secure answers than the AI search pattern. For the natural problem set, the RAG pattern generated 0.71% more secure answers than the AI search pattern.
[0208] Third, regarding accuracy in the financial sector: the accuracy of the pure large model pattern for the ICBC question set was 77.89%. The accuracy of the AI search pattern was 81.63%. The accuracy of the RAG pattern was 82.99%. The RAG pattern improved accuracy by 5.1% compared to the pure large model pattern. The RAG pattern improved accuracy by 1.36% compared to the AI search pattern.
[0209] Compared to the pure large model mode, the RAG mode outperforms multiple OpenFindata datasets. For example, it improves accuracy by 5% in data inspection, 2.7% in financial fact judgment, 2% in financial terminology processing, 1.33% in named entity recognition, and 2.7% in sentiment recognition. Compared to the AI search mode, the RAG mode improves accuracy by 6.7% in sentiment recognition, 5% in data inspection, 4% in financial terminology processing, 2.9% in value extraction, 4% in intent understanding, and 1.3% in named entity recognition.
[0210] For accuracy in the medical field: For the MMedC Chinese dataset, the RAG mode improved accuracy by 2.1% compared to the pure large model mode and by 1.2% compared to the AI search mode. For the MMedC English dataset, the RAG mode improved accuracy by 1.0% compared to the pure large model mode and by 3.8% compared to the AI search mode.
[0211] In summary, for the aforementioned knowledge domains, the RAG model offers significant improvements in security, recall, and accuracy compared to the AI search model and the pure large model model.
[0212] Step S054: Adjust the large language model based on the performance evaluation results.
[0213] The performance evaluation results are specific data and analytical conclusions obtained from the performance evaluation of each working mode of the large language model on various indicators. These results intuitively demonstrate the advantages and disadvantages of each working mode, providing a clear basis for adjusting the large language model. For example, a certain working mode may score highly in accuracy but perform poorly in security. Therefore, adjustments can be made to address the security aspects of that working mode.
[0214] Optionally, the method further includes: dividing the question set into consistent subsets, conflict subsets, and inconsistent subsets based on the answers to each question generated by the large language model using both AI search mode and RAG mode. Based on the partitioning results of the question set, the domain knowledge base is adjusted to improve the accuracy of the RAG mode's answers.
[0215] The consistent subset contains questions that both the AI search mode and the RAG mode answer correctly. This indicates that for these questions, the knowledge and reasoning processes integrated by the models in both modes can effectively handle them, demonstrating the model's stability and accuracy in processing these issues. The conflicting subset contains questions that only one of the AI search mode and the RAG mode answers correctly. This conflict reflects differences in knowledge application, information integration, or reasoning methods between the two modes, leading to different results for certain questions, prompting users to pay attention to and analyze the reasons for these differences. The inconsistent subset contains questions that both the AI search mode and the RAG mode answer incorrectly. This indicates that for these questions, the model's current integrated knowledge sources and processing methods are insufficient, requiring comprehensive review and improvement to enhance the model's ability to answer these questions.
[0216] For example, for questions in the conflict subset where the RAG pattern is incorrectly answered, the analysis determines whether the problem stems from a mismatch between knowledge in the domain knowledge base and other knowledge sources, or from errors in the knowledge itself. This allows for correction or supplementation of relevant knowledge in the domain knowledge base. For questions in the inconsistency subset, a comprehensive review of the domain knowledge base's knowledge completeness in the relevant domain is conducted, leading to large-scale knowledge enhancement. This optimization approach efficiently improves the quality of the domain knowledge base, avoiding unnecessary adjustments.
[0217] In this embodiment, by dividing the question set into different subsets, it is possible to clearly identify on which questions the RAG mode answers incorrectly. These problems reflect potential deficiencies in the domain knowledge base, such as knowledge gaps, inaccuracies, or poor integration with other knowledge sources, thus providing a basis for accurately locating problems in the domain knowledge base. For example, if the RAG mode and AI search mode conflict and the RAG mode answers incorrectly on a certain type of professional question, it may mean that there is a bias in the knowledge of that professional field in the domain knowledge base, requiring adjustment. After targeted adjustments to the domain knowledge base, the RAG mode, when processing related questions, can more accurately integrate multiple knowledge sources due to the optimized knowledge foundation, thereby improving the accuracy of the answers.
[0218] It should be noted that the embodiments of this application also tested the performance of various operating modes of the issue detection model. Compared to the AI search mode, the RAG mode of the issue detection model improved the recall rate of a political domain issue set by 16%, reduced precision by 4%, and improved the F1 score (an evaluation metric) by 5.6%. Specifically, the RAG mode of the issue detection model combines domain knowledge base and knowledge searched from the internet by a search engine to perform risk detection on issues. The AI search mode of the issue detection model only combines knowledge searched from the internet by a search engine to perform risk detection on issues.
[0219] Figure 11 This is a schematic diagram illustrating a performance evaluation process for a large language model. (Reference) Figure 11 First, a political domain knowledge base is constructed. The knowledge sources for this base include trusted news sources, Wikipedia entries, and open-source materials. Trusted news sources refer to authoritative news websites in the target website list. All Wikipedia entries relate to politics. Open-source materials refer to information manually selected from the internet. Next, a question set is obtained, including both natural and attack questions. Then, the large language model generates answers to each question in the question set using three working modes: pure large model mode, AI search mode, and RAG mode. Finally, based on the answers from each working mode, the performance of each mode is evaluated. Performance evaluation includes assessment using a performance evaluation interface and manual evaluation.
[0220] In this embodiment, by allowing the large language model to process problem sets under multiple operating modes, a comprehensive and detailed understanding of the model's performance under different operating conditions can be achieved. This multi-dimensional evaluation helps to identify the limitations of each operating mode, thereby contributing to a deeper understanding of the model's characteristics. Subsequent adjustments to the large language model based on the performance evaluation results can then be made to address the shortcomings of each operating mode. This continuously improves the performance of each operating mode, making it more suitable for diverse user needs.
[0221] Another point to note is that the above examples are only for understanding this application and do not constitute a limitation on the answer generation method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.
[0222] This application also provides an answer generation device, please refer to... Figure 12 The answer generation device includes:
[0223] Question acquisition module 10 is used to acquire the question corresponding to the dialogue command in response to the dialogue command;
[0224] The paragraph acquisition module 20 is used to retrieve at least one first paragraph that matches the question from external knowledge of the model, and generate at least one second paragraph that matches the question based on internal knowledge of the model through the large language model.
[0225] The paragraph synthesis module 30 is used to merge the first paragraph and the second paragraph into a paragraph set, and to identify the source information of each paragraph in the paragraph set. The source information indicates whether the corresponding paragraph comes from inside the model or outside the model.
[0226] The answer generation module 40 is used to generate answers to questions based on a large language model, a set of paragraphs, and the source information of each paragraph in the set.
[0227] Optionally, the answer generation module 40 includes:
[0228] The paragraph update unit is used to iteratively update the paragraph set based on the source information of each paragraph in the question and the large language model. It identifies the source information of each paragraph in the paragraph set obtained in each iteration update. The iterative update is used to retain consistent information in the paragraph set and filter out inconsistent information and irrelevant information of the question.
[0229] The answer generation unit is used to generate answers to questions based on the paragraph set obtained from each iteration update and the source information of each paragraph in the paragraph set.
[0230] Optionally, the answer generation unit is used to generate candidate answers corresponding to each iteration update based on the paragraph set obtained in each iteration update and the source information of each paragraph in the paragraph set, using a large language model, and to select the answer corresponding to the question from the multiple candidate answers generated.
[0231] Optionally, the external knowledge of the model includes a domain knowledge base, and the device also includes:
[0232] The first knowledge base construction module is used to obtain a list of target websites, which includes multiple authoritative website identifiers; compare the main domain name in the Uniform Resource Locator URL corresponding to the crawled web resources with the website identifiers in the target website list; and if the main domain name matches the website identifier in the target website list, store the web resources in the domain knowledge base.
[0233] Optionally, the external knowledge of the model includes a domain knowledge base, and the device also includes:
[0234] The second knowledge base construction module is used to determine the knowledge types involved in the content of the crawled web resources through a large language model; if the knowledge types involved in the content of the web resources match the knowledge types in the domain knowledge base, the web resources are stored in the domain knowledge base.
[0235] Optionally, the external knowledge of the model includes a domain knowledge base, and the device also includes:
[0236] The third knowledge base construction module is used to call the risk control interface to detect harmful information in the content of the crawled network resources and obtain the harmful information detection results. If 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, external knowledge of the model includes domain knowledge bases.
[0238] The paragraph acquisition module 20 is used to detect the knowledge type involved in the question through the question detection model and obtain the type detection result; if the type detection result indicates that the knowledge type involved in the question matches the knowledge type 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.
[0239] Optionally, the device further includes:
[0240] The model determination module is used to perform risk detection on the question using the question detection model and obtain the risk detection result. When the risk detection result indicates that the answer to the question has a specified type of security risk, a security-trained large language model is selected from multiple large language models. The security-trained large language model is used to generate the answer to the question, and the answer generated by the security-trained large language model does not contain harmful information.
[0241] Optionally, the device further includes:
[0242] The first model adjustment module is used to obtain the attack question set and the natural question set; generate answers for each question in the attack question set and the natural question set using the large language model; evaluate the performance of 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 includes:
[0244] The second model adjustment module is used to obtain a set of questions; generate answers for each question in the set through multiple working modes of the large language model; evaluate the performance of 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, multiple working modes include at least two of the following: pure large model mode, artificial intelligence (AI) search mode, and retrieval-enhanced generation (RAG) mode;
[0246] Pure large model mode refers to the mode that generates answers based solely on the knowledge within the model;
[0247] AI search mode refers to a mode that generates answers based on knowledge within the model and knowledge retrieved from the internet by the search engine;
[0248] RAG (Related Aspects of Generic Entities) refers to a model that generates answers based on knowledge within the model, knowledge retrieved from the internet by search engines, and knowledge from domain knowledge bases.
[0249] Optionally, the device further includes:
[0250] The knowledge base adjustment module is used to divide the question sets generated by the large language model using both AI search mode and RAG mode into consistent subsets, conflict subsets, and inconsistent subsets. Consistent subsets contain questions that are answered correctly by both AI search mode and RAG mode; conflict subsets contain questions that are answered correctly by one of the AI search mode or RAG mode; and inconsistent subsets contain questions that are answered incorrectly by both AI search mode and RAG mode. Based on the division of the question sets, the domain knowledge base is adjusted to improve the accuracy of the RAG mode's answers.
[0251] The answer generation apparatus provided in this application, employing the answer generation method in the above embodiments, can solve the technical problem of low accuracy in answer generation from large language models in related technologies. Compared with the prior art, the beneficial effects of the answer generation apparatus provided in this application are the same as those of the answer generation method provided in the above embodiments, and other technical features in the answer generation apparatus are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0252] This 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, which are executed by the at least one processor to enable the at least one processor to perform the answer generation method in Embodiment 1 above.
[0253] The following is for reference. Figure 13 The diagram illustrates a structural schematic suitable for implementing the answer generation device of the embodiments of this application. The answer generation device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 13 The answer generation device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0254] like Figure 13As shown, the response generation device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the response generation device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. The communication device 1009 allows the response generating device to communicate wirelessly or wiredly with other devices to exchange data. Although response generating devices with various systems are shown in the figures, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.
[0255] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0256] The answer generation device provided in this application, employing the answer generation method in the above embodiments, can solve the technical problem of low accuracy in answer generation from large language models in related technologies. Compared with the prior art, the beneficial effects of the answer generation device provided in this application are the same as those of the answer generation method provided in the above embodiments, and other technical features in this answer generation device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0257] It should be understood that the various parts disclosed in this application can be implemented using 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 suitable manner in one or more embodiments or examples.
[0258] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0259] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the answer generation method in the above embodiments.
[0260] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. 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 conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0261] The aforementioned computer-readable storage medium may be included in the response generation device; or it may exist independently and not assembled into the response generation device.
[0262] The aforementioned computer-readable storage medium carries one or more programs that, when executed by the answer generation device, cause the answer generation device to: in response to a dialogue instruction, acquire the question corresponding to the dialogue instruction; retrieve at least one first paragraph matching the question from external knowledge of the model, and generate at least one second paragraph matching the question based on internal knowledge of the model using a large language model; merge the first paragraph and the second paragraph into a paragraph set, and identify the source information of each paragraph in the paragraph set, the source information indicating whether the corresponding paragraph originates from within or outside the model; and generate the answer corresponding to the question based on the paragraph set and the source information of each paragraph in the paragraph set using a large language model.
[0263] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0264] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0265] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0266] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described answer generation method, which can solve the technical problem of low accuracy in answer generation from 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 embodiments, and will not be repeated here.
[0267] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the answer generation method described above.
[0268] The computer program product provided in this application can solve the technical problem of low accuracy in generating answers using large language models in related technologies. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the answer generation method provided in the above embodiments, and will not be repeated here.
[0269] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. A response generation method characterized by, 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, wherein the model internal knowledge is knowledge learned by the large language model during training and stored in model parameters; merge the first paragraph and the second paragraph into a paragraph set, and identify the source information of each paragraph in the paragraph set, wherein the source information indicates that the corresponding paragraph is from the model internal or the model external; 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; wherein the generating 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 comprises: based on the question and the source information of each paragraph in the paragraph set, iteratively update the paragraph set through the large language model, and identify the source information of each paragraph in the paragraph set obtained by each iteration update, wherein the iteration update is used to retain the internal and external consistent information in the paragraph set, filter out the internal and external inconsistent information and irrelevant information of the question; and generate a candidate answer corresponding to each iteration update based on the paragraph set obtained by each iteration update and the source information of each paragraph in the paragraph set through the large language model, and select an answer corresponding to the question from the generated multiple candidate answers.
2. The method of claim 1, wherein, The model external knowledge includes a domain knowledge base, and before the retrieving at least one first paragraph matching the question from model external knowledge, the method further comprises: obtain a target website list, wherein the target website list includes a plurality of 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; if the main domain name matches the website identifier in the target website list, store the network resource in the domain knowledge base.
3. The method of claim 1, wherein, The model external knowledge includes a domain knowledge base, and before the retrieving at least one first paragraph matching the question from model external knowledge, the method further comprises: determine the knowledge type involved in the content of the crawled network resource through the large language model; if the knowledge type involved in the content of the network resource matches the knowledge type of the domain knowledge base, store the network resource in the domain knowledge base.
4. The method of claim 1, wherein, The model external knowledge includes a domain knowledge base, and before the retrieving at least one first paragraph matching the question from model external knowledge, the method further comprises: call a risk control interface to detect harmful information in the content of the crawled network resource, and obtain a harmful information detection result; if the harmful information detection result indicates that the content of the network resource does not contain harmful information, store the network resource in the domain knowledge base.
5. The method of claim 1, wherein, The external knowledge of the model includes a domain knowledge base, and retrieving at least one first paragraph matching the question from the external knowledge of the model includes: detecting the type of knowledge involved in the question through 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, retrieving at least one first paragraph matching the question from the network and the domain knowledge base, otherwise retrieving at least one first paragraph matching the question from the network.
6. The method of claim 1, wherein, After the method further includes: detecting the risk of the question through a question detection model to obtain a risk detection result; if the risk detection result indicates that answering the question poses a specified type of security risk, selecting a security-trained large language model from a plurality of large language models, the security-trained large language model being used to generate an answer corresponding to the question, and the security-trained large language model not including harmful information in the answer it generates.
7. The method of claim 1, wherein, Before the method further includes: obtaining a set of attack questions and a set of natural questions; generating answers corresponding to each question in the set of attack questions and the set of natural questions through the large language model; based on the answers generated by the large language model, evaluating the performance of the large language model; based on the performance evaluation result, adjusting the large language model.
8. The method of claim 1, wherein, Before the method further includes: obtaining a set of questions; generating answers corresponding to each question in the set of questions through multiple working modes of the large language model; based on the answers corresponding to the multiple working modes, evaluating the performance of each working mode of the large language model; based on the performance evaluation result, adjusting the large language model.
9. The method of claim 8, wherein, The multiple working modes include at least two of a pure large model mode, an artificial intelligence (AI) search mode, and a retrieval-augmented generation (RAG) mode; The pure large model mode refers to a mode of generating answers based only on internal knowledge of the model; The AI search mode refers to a mode of generating answers based on internal knowledge of the model and knowledge retrieved on the network by a search engine; The RAG mode refers to a mode of generating answers based on internal knowledge of the model, knowledge retrieved on the network by the search engine, and knowledge in a domain knowledge base.
10. The method of claim 9, wherein, The method further includes: based on the answers corresponding to each question in the set of questions generated by the large language model in the AI search mode and the RAG mode, dividing the set of questions into a consistent subset, a conflict subset, and an inconsistent subset; The consistent subset includes questions that are correctly answered by both the AI search mode and the RAG mode, the conflict subset includes questions that are correctly answered by one of the AI search mode and the RAG mode, and the inconsistent subset includes questions that are incorrectly answered by both the AI search mode and the RAG mode. Based on the division result of the question set, the domain knowledge base is adjusted to improve the correct answer rate of the RAG mode.
11. A response generation apparatus characterized by comprising: The device comprises: a question acquisition module configured to acquire a question corresponding to a dialogue instruction in response to the dialogue instruction; a paragraph acquisition module configured to retrieve at least one first paragraph matching the question from external knowledge of a model, and generate at least one second paragraph matching the question based on internal knowledge of the model by a large language model, the internal knowledge of the model being knowledge learned by the large language model during a training process and stored in model parameters; a paragraph synthesis module configured to combine the first paragraph and the second paragraph into a paragraph set, and identify source information of each paragraph in the paragraph set, the source information indicating that the corresponding paragraph is from internal or external of the model; a response generation module configured to generate a response corresponding to the question based on the paragraph set and the source information of each paragraph in the paragraph set by the large language model; The response generation module comprises: a paragraph update unit configured to iteratively update the paragraph set based on the question and the source information of each paragraph in the paragraph set by the large language model, and identify the source information of each paragraph in the paragraph set obtained by each iteration update, the iteration update being used to retain consistent internal and external information in the paragraph set, filter inconsistent internal and external information, and irrelevant information of the question; a response generation unit configured to generate a candidate response corresponding to each iteration update based on the paragraph set obtained by each iteration update and the source information of each paragraph in the paragraph set by the large language model, and select a response corresponding to the question from the generated multiple candidate responses.
12. The apparatus of claim 11, wherein, The external knowledge of the model includes a domain knowledge base, and the device further comprises: a first knowledge base construction module configured to acquire a target website list including a plurality of authoritative website identifiers, compare a main domain name in a uniform resource locator (URL) of a crawled network resource with a website identifier in the target website list, and store the network resource in the domain knowledge base in a case where the main domain name matches the website identifier in the target website list.
13. The apparatus of claim 11, wherein, The external knowledge of the model includes a domain knowledge base, and the device further comprises: a second knowledge base construction module configured to determine a knowledge type involved in content of the crawled network resource by the large language model, and store the network resource in the domain knowledge base in a case where the knowledge type involved in the content of the network resource matches a knowledge type of the domain knowledge base.
14. A response generation device, characterized by, The device comprises a memory, a processor, and a computer program stored on the memory and executable on the processor, and the computer program is configured to implement the steps of the answer generation method according to any one of claims 1 to 10.
15. A storage medium, characterized by The storage medium is a computer readable storage medium, and the storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the answer generation method according to any one of claims 1 to 10.
16. A computer program product, characterised in that, The computer program product comprises a computer program, and the computer program is executed by a processor to implement the steps of the answer generation method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Automatic question answering method and device based on artificial intelligence, storage medium and server
CN114003708A
RAG mixed retrieval method and device for improving accuracy of large language model
CN118277522A