A food safety expert question-answering system and method based on multi-agent cooperation
By employing a multi-agent collaborative architecture, the problems of user input verification and answer quality assessment in food safety question-and-answer systems have been solved, thereby improving professionalism and reliability and ensuring that answers meet food safety standards.
Patent Information
- Application Number
- CN202610879995.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-17
- Publication Date
- 2026-11-06
AI Technical Summary
Existing multi-agent question-answering systems lack mechanisms for verifying user input security, assessing answer quality, and iteratively optimizing in the field of food safety. They struggle to handle complex queries and lack professionalism.
It adopts a five-module collaborative architecture, including a food safety pre-control intelligent agent, a knowledge retrieval, a response generation, an evaluation intelligent agent, and an iterative optimization controller. Through safety detection, knowledge retrieval, response generation, multi-dimensional evaluation, and iterative optimization, it ensures the quality of responses.
It enables security auditing of user input, improves the professionalism and quality of responses, ensures that responses meet food safety standards, and are measurable and traceable.
Smart Images

Figure CN123048694A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a food safety expert question-and-answer system and method based on multi-agent collaboration, belonging to the technical field of artificial intelligence and intelligent question-and-answer systems. Background Technology
[0002] With the increasing prominence of food safety issues, the public's demand for food safety knowledge is constantly growing. Traditional food safety question-answering systems mainly rely on human experts or rule-based knowledge bases, which suffer from drawbacks such as slow response speed, limited coverage, and difficulty in handling complex open-ended questions. In recent years, question-answering systems based on large language models have made significant progress, but existing research shows that in professional fields such as food safety laws and regulations, traditional question-answering methods based on inverted indexes and knowledge graphs still have shortcomings in handling complex questions, responding to dynamic updates of regulations, and considering regional differences in regulations.
[0003] Research on multi-agent question-answering systems has been extensively explored in academia. The NG-Router framework proposed by Shi et al. models nutrition and health question answering as a knowledge graph-guided multi-agent collaborative problem. By integrating agent nodes into a heterogeneous knowledge graph and employing graph neural networks to learn task-aware routing distributions, it effectively addresses the dual challenges of limited reasoning capabilities in single-agent systems and the complexity of multi-agent architecture design. In the area of multi-agent debate and evaluation, researchers have proposed a multi-agent debate framework based on adaptive stability detection. This framework achieves evaluation of complex tasks through multi-agent collaborative reasoning and iterative optimization, and establishes a mathematical theoretical foundation for improving the accuracy of debate. In the field of agent validators, the AgentV-RL framework proposed by teams from Fudan University and others upgrades reward modeling from "static scoring" to agent validators. Through the collaborative work of two agents—forward and reverse validators—significant improvements are achieved on benchmarks such as MATH500.
[0004] However, existing research still has the following shortcomings: First, most multi-agent systems focus on the reasoning task itself and lack a pre-screening mechanism for the security of user input; second, there is a lack of an effective linkage mechanism for answer quality assessment and iterative optimization, and once an unqualified answer is generated, it cannot be corrected in a targeted manner; third, existing systems lack deep adaptation to the special characteristics of the food safety field, and have difficulty handling complex queries with domain characteristics such as descriptions of food poisoning symptoms, food ingredient contraindications, and the idea of nourishing the body through food, resulting in a lack of professionalism in the answers. Summary of the Invention
[0005] The purpose of this invention is to address the shortcomings and deficiencies of existing technologies by providing a food safety expert question-and-answer system and method based on multi-agent collaboration. It employs a five-module collaborative architecture, assigning different responsibilities such as safety review, knowledge retrieval, answer generation, quality assessment, and iterative optimization to dedicated agent modules, and continuously improving answer quality through an iterative optimization controller. This invention solves the problem of multi-objective tasks that are difficult for a single model to handle simultaneously through division of labor and collaboration, and overcomes the problem of uncontrollable quality in a single generation through an iterative optimization mechanism.
[0006] The technical solution adopted by this invention to solve its technical problem is: a food safety expert question-and-answer system based on multi-agent collaboration, which includes the following modules: Intelligent system for proactive risk control in food safety; The system utilizes a large language model to perform safety checks on user-inputted food safety-related questions, identify and block illegal or malicious content related to food safety, such as illegal food advertising, malicious rumors, and politically sensitive content, and outputs safety judgment results. Food safety knowledge retrieval module; Based on user queries regarding food safety, food hygiene, nutrition and health, food poisoning, and food regulations, relevant scientific knowledge, regulations, standards, and risk information are retrieved from a pre-set food safety professional knowledge base, and a structured food safety knowledge background is returned. An intelligent agent is generated to provide answers related to food safety. The system receives user queries, the aforementioned food safety knowledge background, and historical records of failed answers. Based on constraints, it generates plain text-formatted, expert-level food safety answers for the general public or professional users. The answers are prohibited from using any Markdown symbols to ensure the direct usability of the output content. Food safety response assessment intelligent agent; The generated food safety answers are quantitatively scored from multiple dimensions, including: the scientific accuracy of the food safety knowledge background stated in the answer, the completeness of the coverage of potential food safety risks in the user's query, and the standardization of the plain text format of the answer. The score and evaluation reasons are output. Iterative optimization controller; The evaluation score is compared with a preset pass threshold for food safety Q&A scenarios. When the score is lower than the threshold, a retry mechanism is triggered. The record of historical failed answers is passed to the food safety answer content generation agent, which is required to generate differentiated corrected answers that have improved in terms of professional knowledge depth or risk coverage breadth, until the pass standard or the maximum number of retries is reached.
[0007] Furthermore, the food safety pre-control intelligent agent of the present invention outputs the judgment result in JSON format, including a pass field indicating whether the detection is passed, and when pass is false, an additional reason field is attached to explain the food safety or content safety rules that caused the blockage.
[0008] Furthermore, when the intelligent agent for generating food safety answers according to the present invention receives historical failed answer records, it clearly marks in the prompt words that it is forbidden to repeat the food safety knowledge statements of existing answers, and requires that compared with historical failed answers, the depth of risk analysis or the breadth of coverage of food safety elements be significantly improved.
[0009] Furthermore, the scoring criteria for the food safety response assessment agent described in this invention include: accuracy requirements, the response content must conform to authoritative food safety knowledge background, and must not contain statements that contradict scientific consensus; completeness requirements, the response must cover key food safety risk points related to the query; and format requirements, conforming to plain text specifications, and finally outputting a numerical value of 0-100 points.
[0010] Furthermore, the iterative optimization controller described in this invention is configured with a maximum number of retries parameter. When the maximum number of retries is reached and a qualified answer that meets food safety professional standards is still not generated, the system outputs a failure message.
[0011] Furthermore, the knowledge retrieval module of this invention employs a keyword matching method, configuring a composite keyword database specifically for the field of food safety, covering common food testing items, food poisoning symptoms, names of foodborne diseases, common names of prohibited food additives, and related traditional Chinese medicine dietary therapy terms, and performs full-text matching and screening of multi-round dialogue content.
[0012] Furthermore, the intelligent agent generated in this invention performs post-processing before output, automatically removing possible Markdown markers such as code blocks or tables, ensuring that the final output food safety guidance information is in a plain text format that is easy to read directly.
[0013] This invention also provides a method for implementing a food safety expert question-and-answer system based on multi-agent collaboration, the method comprising the following steps: Step S1: The food safety pre-control intelligent agent performs safety testing; Step S2: The food safety knowledge retrieval module performs a knowledge retrieval; Step S3: The intelligent agent generates the answer to the food safety question. Step S4: The food safety response assessment agent performs quantitative scoring; Step S5: Iteratively optimize the controller to make judgments and control. Step S6: Output the final result.
[0014] Furthermore, the method of this invention employs a pre-emptive risk control agent to perform security checks on user input and obtains relevant food safety knowledge background through a knowledge retrieval module; it constructs a generative agent based on a large language model to generate plain text answers based on the knowledge background; it introduces an evaluation agent to quantitatively score the generated answers from three dimensions: accuracy, completeness, and format conformity; when the score is lower than a preset threshold, an iterative optimization mechanism is triggered, feeding back failed answer records as constraints to the generative agent to force the generation of differentiated and higher-quality corrected answers; through multiple rounds of optimization until the answer quality meets the standard or the maximum number of retries is reached, the final output is a question-and-answer result that meets professional food safety standards. This invention significantly improves the answer quality and reliability of the food safety question-and-answer system through multi-agent collaboration and iterative optimization strategies.
[0015] Beneficial effects: 1. This invention uses a front-end risk control intelligent agent to perform security checks on user input, effectively blocking illegal and sensitive content and ensuring the compliant use of the system.
[0016] 2. This invention introduces an independent evaluation agent to perform multi-dimensional quantitative scoring of the generated answers, thereby achieving measurability and traceability of answer quality.
[0017] 3. The present invention designs an iterative optimization controller that feeds back failed answer records to the generating agent, forcing the generation of differentiated and improved answers, which significantly improves the quality of the final output.
[0018] 4. This invention, through the decoupling design of the knowledge retrieval module and the generating agent, enables the system to flexibly connect to different knowledge sources and has good scalability. Attached Figure Description
[0019] Figure 1 This is a diagram of the architecture of the multi-agent collaborative food safety question-and-answer system of the present invention.
[0020] Figure 2 This is the iterative optimization control flowchart of the present invention. Detailed Implementation
[0021] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to examples and accompanying drawings. It should be understood that the specific examples described herein are merely illustrative and are not intended to limit the scope of protection of this invention.
[0022] Example 1 This embodiment provides a food safety expert question-and-answer system based on multi-agent collaboration, the overall architecture of which is as follows: Figure 1As shown, it includes a food safety pre-control intelligent agent, a food safety knowledge retrieval module, a food safety answer content generation intelligent agent, a food safety answer evaluation intelligent agent, and an iterative optimization controller.
[0023] The specific implementation steps of this invention include the following: Step S1: The food safety pre-control intelligent agent performs safety testing. When the system receives a user query, it first invokes a food safety pre-control intelligent agent to perform a safety check. This agent is built based on a large language model, and its system prompt is set to "You are a safety auditor in the field of food safety. Please check whether the user input contains illegal or malicious content such as food advertising (e.g., claims that food can cure diseases), malicious rumors (e.g., false panic information about food safety), or politically sensitive content." After receiving the user query, the risk control intelligent agent outputs a judgment result in JSON format, including a "pass" field indicating whether the detection passed. When "pass" is false, a "reason" field is attached explaining the reason for the block.
[0024] Step S2: The food safety knowledge retrieval module performs a knowledge retrieval. The food safety knowledge retrieval module searches and matches user queries against a pre-defined food safety professional knowledge base. In this embodiment, the knowledge base covers scientific knowledge, regulations, standards, and risk information related to food safety, food hygiene, nutrition and health, food poisoning, and food laws. The retrieval uses a keyword matching method, configuring a composite keyword database specifically for the food safety field. The retrieval process matches user queries with the knowledge base content, filters out relevant information, and outputs structured food safety knowledge background.
[0025] Step S3: Food Safety Response Generation - Intelligent Agent Generates Response The food safety answer generation agent is built based on a large language model. This agent receives three input parameters: the user query, the provided food safety knowledge background, and a record of previously failed answers. The system prompt for generating the agent is set as: "You are a food safety expert. Please answer the user question based on the provided [knowledge background], and the output should be geared towards the general public or professional users." The user prompt is constructed in the following format: [User Issue]: {User Query} [Knowledge Background]: {Knowledge Data} [Important Constraint]: If there are records of failed answers in the past, a completely new answer must be generated. Existing text must not be repeated. Significant improvements must be made in the depth of risk analysis or the breadth of coverage of food safety elements.
[0026] [Output Requirements]: Output only plain text content. Do not use any Markdown symbols (such as code blocks, tables, etc.) and do not include any explanatory prefixes.
[0027] Step S4: The food safety response assessment agent performs quantitative scoring. The food safety response assessment agent quantifies and scores the responses generated in step S3 (0-100 points). The assessment dimensions include: accuracy: the response content must conform to the information in the [Knowledge Background] and must not contain statements that contradict scientific consensus; completeness: whether the response covers the core food safety risk points and key information related to the user's query; and format conformity: whether the response strictly follows the plain text format and whether it contains prohibited symbols such as Markdown.
[0028] The evaluation agent outputs a score in JSON format, including the overall score and the reasons for each evaluation.
[0029] Step S5: Iteratively optimize the controller to make judgments and control. The iterative optimization controller is configured with a pass / fail threshold of PASS_SCORE_THRESHOLD = 60 and a maximum number of retries of MAX_RETRIES = 2. The controller compares the evaluation score with the threshold. If the score is ≥ 60, the answer is considered qualified, and the process proceeds to step S6 to output the final result. If the score is less than 60, the answer is deemed unqualified. The current answer record is added to the historical failure list, the retry count is incremented by 1, and the process returns to step S3 to regenerate.
[0030] During the retry process, the list of historical failed answers received by the generating agent is accumulated round by round, forcing the model to avoid repeating the expression of unqualified answers and generating differentiated corrected answers that have improved in terms of professional knowledge depth or risk coverage breadth.
[0031] Step S6: Output the final result If a satisfactory answer is generated, the system will output the final answer. If a satisfactory answer is not generated after reaching the maximum number of retries, the system will output a failure message: "After multiple attempts, a satisfactory answer that meets food safety professional standards could not be generated." Example 2 This embodiment demonstrates the effectiveness of the multi-agent cooperation mechanism of the present invention from a theoretical perspective.
[0032] Definition 1 (Evaluation Function) Let the problem space be... The answer space is The knowledge background space is Define the evaluation function Used to evaluate answers In the knowledge background The quality score below.
[0033] Definition 2 (Qualified Answer) Given a threshold The answer For the question In the knowledge background The following are qualified answers, if The set of qualified answers is denoted as .
[0034] Theorem 1 (Convergence of Iterative Optimization) Let the output distribution of the generating agent be... , A collection of answers to historical failures. This represents the minimum semantic distance between the newly generated answer and the historical answers. Then, under the constraints... After a finite number of iterations The system uses probability Generate qualified answers, among which This represents the prior probability of generating a valid answer in a single iteration.
[0035] Proof: Suppose that in a single generation, the probability of the generating agent generating a valid answer under no history constraint is . When the constraint of historical failure records is introduced, the generation space is divided into Neighborhood and its complement. Because... The generated intelligent agent is forced to explore The region outside the neighborhood increases the conditional probability of generating a valid answer. ,in for The relative volume in the answer space. (After...) Each round of independent attempts has a failure probability of no more than [percentage missing]. .make Solving for .Pick =0.3, When =0.05, Q.E.D.
[0036] Theorem 2 (Superiority of Multi-Agent Cooperation) Let the accuracy of a single-agent system be _____. The accuracy rate of the multi-agent system (including the collaborative work of risk control, generation, and evaluation agents) of this invention is [missing information]. Then there is
[0037] in To eliminate risk input gains for proactive risk control. To evaluate the quality constraint gain provided by the feedback. This is the correction gain brought about by iterative optimization. Therefore The equality holds only when all gain terms are 0.
[0038] Proof: According to the information processing inequality of multi-agent systems, introducing additional agents for task decomposition and result verification does not reduce the effective information content of the system. Let the information processing channel capacity of a single agent be... Joint channel capacity of multi-agent systems
[0039] in For the first The effective information capacity contributed by each agent. Since each agent has an independent role, their information gains can be added together. ,and then Q.E.D.
[0040] Theorem 3 (Evaluation Consistency) Assume the same answer... through The score of the second independent assessment was , ,......, And since each evaluation is independent and identically distributed, the sample mean is... Converging with probability to the expected true value And the half-width of the confidence interval is ,in Standard deviation, These are the standard normal quantiles.
[0041] Proof: By the central limit theorem, Take the significance level. When =0.05, =1.96, then the 95% confidence interval is This invention employs a single-assessment plus manual sampling mechanism, reducing variance and ensuring assessment reliability by constraining the consistency of assessment prompts. Q.E.D.
[0042] Example 3: This embodiment provides a complete example of the operating process of the system of the present invention.
[0043] Suppose a user enters the query: "How can I determine if wild-picked mushrooms are safe to eat?" The system processing flow is as follows: 1. Pre-emptive risk control detection: The intelligent pre-emptive risk control system for food safety detected no illegal advertising or malicious rumors in this query, thus determining it to be safe and returning `{"pass": true, "reason": "none"}.
[0044] 2. Knowledge Retrieval: The food safety knowledge retrieval module matches keywords such as "wild mushrooms," "poisonous mushrooms," "food poisoning," and "amatoxins" in the knowledge base, retrieving the following structured knowledge background: The core principle is that there are no simple and reliable folk methods (such as using silver needles to test for poison or boiling mushrooms with garlic until they turn black) that can accurately distinguish between edible and poisonous mushrooms.
[0045] Main risks: Many poisonous mushrooms (such as Amanita phalloides and Amanita subnigricans) contain highly toxic substances (such as amatoxins), which can lead to liver and kidney failure and a high mortality rate if ingested.
[0046] Authoritative advice: The best way to prevent mushroom poisoning is to "not pick, not buy, and not eat" any unfamiliar wild mushrooms. If you must eat them, purchase known safe cultivated varieties from reputable markets.
[0047] 3. First round of generation: The intelligent agent generates an initial answer based on the knowledge background for food safety responses, as follows: "There is no reliable home method to determine the safety of wild-picked mushrooms. Methods such as using a silver needle to test for poison, observing the color, or cooking with garlic are unreliable. Many highly poisonous mushrooms, such as the deadly Amanita phalloides, resemble edible mushrooms in appearance. Ingestion can lead to severe liver and kidney damage or even death. It is strongly recommended not to pick or eat any unfamiliar wild mushrooms. Safe mushrooms should be purchased from reputable supermarkets or markets." 4. Assessment and Decision-Making: The food safety response assessment agent scores the response. Accuracy: 90 points (Correctly refuted folk remedies and pointed out the core risks).
[0048] Completeness: 85 points (covers risks, incorrect methods, and authoritative advice).
[0049] Formatting Guidelines: 100 points (plain text, no Markdown).
[0050] Overall score: 88 points, which is 60 points above the passing threshold. No need to retry.
[0051] 5. Final output: The system outputs the above plain text answer, which is professional, accurate, complete, and meets food safety professional standards.
[0052] 6. If the quality of the response generated in the first round is poor (for example, simply answering "you can use a silver needle to test for poison" while omitting key risk information, resulting in a comprehensive score of only 45 points), a retry mechanism is triggered. The iterative optimization controller passes the historical failed responses to the generating agent, forcing it to generate an improved version. In the second round of generation, the generating agent will explicitly point out the unreliability of folk methods and supplement the response with the serious consequences of poisonous mushroom poisoning and authoritative prevention recommendations.
[0053] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the claims of the present invention.
Claims
1. A food safety expert question and answer system based on multi-agent collaboration, characterized in that, The system includes the following modules: Intelligent system for proactive risk control in food safety; The system utilizes a large language model to perform safety checks on user-inputted food safety-related questions, identify and block illegal or malicious content related to food safety, such as illegal food advertising, malicious rumors, and politically sensitive content, and outputs safety judgment results. Food safety knowledge retrieval module; Based on user queries regarding food safety, food hygiene, nutrition and health, food poisoning, and food regulations, relevant scientific knowledge, regulations, standards, and risk information are retrieved from a pre-set food safety professional knowledge base, and a structured food safety knowledge background is returned. An intelligent agent is generated to provide answers related to food safety. The system receives user queries, the aforementioned food safety knowledge background, and historical records of failed answers. Based on constraints, it generates plain text-formatted, expert-level food safety answers for the general public or professional users. The answers are prohibited from using any Markdown symbols to ensure the direct usability of the output content. Food safety response assessment intelligent agent; The generated food safety answers are quantitatively scored from multiple dimensions, including: the scientific accuracy of the food safety knowledge background stated in the answer, the completeness of the coverage of potential food safety risks in the user's query, and the standardization of the plain text format of the answer. The score and evaluation reasons are output. Iterative optimization controller; The evaluation score is compared with a preset pass threshold for food safety Q&A scenarios. When the score is lower than the threshold, a retry mechanism is triggered. The record of historical failed answers is passed to the food safety answer content generation agent, which is required to generate differentiated corrected answers that have improved in terms of professional knowledge depth or risk coverage breadth, until the pass standard or the maximum number of retries is reached.
2. The food safety expert question-answering system based on multi-agent collaboration according to claim 1, characterized in that, The food safety pre-control intelligent agent outputs the judgment result in JSON format, including a pass field indicating whether the detection is passed. When pass is false, a reason field is attached to explain the food safety or content safety rules that caused the block.
3. The food safety expert question-answering system based on multi-agent collaboration according to claim 1, characterized in that, When the intelligent agent generating the food safety answer receives a record of a previous failed answer, it explicitly indicates in the prompt that the food safety knowledge statement in the previous answer should not be repeated, and requires that the depth of risk analysis or the breadth of coverage of food safety elements be significantly improved compared to the previous failed answers.
4. The food safety expert question-answering system based on multi-agent collaboration according to claim 1, wherein, The scoring criteria for the food safety response assessment agent include: accuracy requirements, the response must conform to authoritative food safety knowledge background, and must not contain statements that contradict scientific consensus; completeness requirements, the response must cover key food safety risk points related to the query; and format requirements, it must conform to plain text specifications, and finally be output in the form of a numerical score of 0-100.
5. A food safety expert question-and-answer system based on multi-agent collaboration as described in claim 1, characterized in that, The iterative optimization controller is configured with a maximum number of retries parameter. When the maximum number of retries is reached and a qualified answer that meets food safety professional standards is still not generated, the system outputs a failure message.
6. A food safety expert question-and-answer system based on multi-agent collaboration as described in claim 1, characterized in that, The knowledge retrieval module employs a keyword matching method, configuring a composite keyword database specifically for the food safety field, covering common food testing items, food poisoning symptoms, names of foodborne diseases, common names of prohibited food additives, and related traditional Chinese medicine dietary therapy terms, and performs full-text matching and filtering of multi-round dialogue content.
7. A food safety expert question-and-answer system based on multi-agent collaboration as described in claim 1, characterized in that, The generated intelligent agent performs post-processing before output, automatically removing possible Markdown markers such as code blocks or tables, ensuring that the final output food safety guidance information is in a plain text format that is easy to read directly.
8. A method for implementing a food safety expert question-and-answer system based on multi-agent collaboration, characterized in that, The method includes the following steps: Step S1: The food safety pre-control intelligent agent performs safety testing; Step S2: The food safety knowledge retrieval module performs a knowledge retrieval; Step S3: The intelligent agent generates the answer to the food safety question. Step S4: The food safety response assessment agent performs quantitative scoring; Step S5: Iteratively optimize the controller to make judgments and control. Step S6: Output the final result.
9. The implementation method of a food safety expert question-and-answer system based on multi-agent collaboration according to claim 8, characterized in that, The method employs a pre-emptive risk control agent to perform security checks on user input and obtains relevant food safety knowledge background through a knowledge retrieval module; it constructs a generative agent based on a large language model to generate plain text answers based on the knowledge background; and it introduces an evaluation agent to quantitatively score the generated answers from three dimensions: accuracy, completeness, and format conformity. When the score is lower than the preset threshold, an iterative optimization mechanism is triggered, and the record of failed answers is fed back to the generating agent as a constraint, forcing the generation of differentiated and higher quality corrected answers; through multiple rounds of optimization until the answer quality meets the standard or the maximum number of retries is reached, the final output of the question and answer results that meet the professional standards of food safety is finally achieved.
