Chemical policy question and answer method, device and equipment based on large language model and medium

By employing a chemical policy question-and-answer method based on a large language model, combined with hierarchical retrieval and multi-source information fusion, the problem of insufficient coordination between static knowledge and dynamic data in chemical industry question-and-answer systems has been solved. This has enabled accurate and efficient question-and-answer and reporting services, thereby improving the safety production and decision support capabilities of chemical enterprises.

CN121745281APending Publication Date: 2026-03-27ZHEJIANG AEROSPACE HENGJIA DATA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-24
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing intelligent question-and-answer systems in the chemical industry cannot effectively combine static policy knowledge with dynamic real-time data, resulting in inaccurate responses, rigid processes, and the use of a single data source, which fails to meet the needs of chemical enterprises for safe production and efficient decision-making.

Method used

A chemical industry policy question-and-answer method based on a large language model is adopted. By identifying the user's question intent, a hierarchical retrieval and multi-source information fusion mechanism is used to automatically route the question to a real-time database or static knowledge base, generate accurate question-and-answer responses, and generate in-depth analysis reports by combining real-time data.

Benefits of technology

It enables precise and efficient responses to policy consultations and real-time operational status in the chemical industry, improves the reliability and intelligence of the Q&A system, reduces reliance on professional engineers, and enhances the efficiency of safety production management and emergency response.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121745281A_ABST
    Figure CN121745281A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of intelligent questioning and answering, and provides a chemical policy questioning and answering method, device and equipment based on a large language model and a medium. According to the method, the questioning intention of the user is recognized, and a hierarchical retrieval and multi-source information fusion mechanism is adopted, so that the defects that a traditional question answering system is single in retrieval path, insufficient in static knowledge and dynamic data collaboration, difficult to consider both professionality and real-time performance and the like in application in the chemical field are effectively overcome. Accurate and efficient response to policy consultation and real-time operation state query in the chemical industry field is achieved, and the reliability, practicability and intelligent level of the question answering system are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent question-answering technology, and in particular to a method, apparatus, equipment and medium for question-answering chemical industry policies based on a large language model. Background Technology

[0002] As the chemical industry rapidly develops towards intelligent and refined operations, enterprises have an increasingly urgent need for safe production, compliant operation, and efficient decision-making. This requires enterprises to quickly and accurately understand and apply constantly updated policies and regulations, while simultaneously monitoring production status in real time and promptly analyzing and responding to anomalies. In recent years, artificial intelligence technologies, represented by Large Language Models (LLM), have provided a new technological path for building intelligent question-answering and analysis systems in the chemical industry due to their powerful natural language understanding and content generation capabilities.

[0003] In existing technologies, intelligent question answering methods based on large language models mainly fall into three categories: First, direct question answering based on general large models, which is simple to implement but lacks professional knowledge in the chemical industry and is prone to factual errors and logical biases; second, dedicated model methods based on domain fine-tuning, which improve professionalism but rely on a large amount of labeled data and are difficult to adapt to the dynamic updates of policies and data; and third, methods based on retrieval-augmented generation (RAG), which alleviate the "illusion" problem by combining with external knowledge bases, but still cannot effectively distinguish and coordinate the processing of static domain knowledge and dynamic real-time data in complex chemical industry scenarios.

[0004] In summary, while existing technologies each have their advantages in general question answering or database querying, none of them provide a complete, efficient, and accurate solution for the complex need to combine static policy knowledge question answering with dynamic real-time data analysis report generation in the chemical industry. Summary of the Invention

[0005] The technical problem to be solved by the present invention is to provide a chemical industry policy question-and-answer method, apparatus, equipment and medium based on a large language model, so as to solve the above-mentioned technical problem.

[0006] The technical solution of this invention to solve the above-mentioned technical problems is as follows: A chemical policy question-and-answer method based on a large language model, comprising: receiving user question information and identifying whether the question information involves data in a real-time database, wherein the real-time database stores real-time operational data in the chemical production process; when the question information involves data in the real-time database, retrieving the real-time database and the domain knowledge base according to the question information to obtain first retrieval information, and generating a question response through a large language model based on the first retrieval information and the question information; wherein, the domain knowledge base stores domain knowledge and standards for guiding chemical production, safety and compliance; when the question information involves data in the real-time database, retrieving the real-time database and the domain knowledge base according to the question information to obtain first retrieval information, and generating a question response through a large language model according to the first retrieval information and the question information; wherein, the domain knowledge base stores domain knowledge and standards for guiding chemical production, safety and compliance; when the question information involves data in the real-time database, retrieving the real-time database and the domain knowledge base according to ... When the question information does not involve data in the real-time database, it is matched with a question-and-answer knowledge base to identify whether a question-and-answer pair matching the question information exists in the knowledge base. The knowledge base is a database used to store question-and-answer pairs related to the chemical industry. When a question-and-answer pair matching the question information exists in the knowledge base, a question response is generated based on that pair. When no question-and-answer pair matching the question information exists in the knowledge base, the domain knowledge base is searched based on the question information to obtain second search information. A question response is then generated using a large language model based on the second search information and the question information.

[0007] The beneficial effects of this invention are as follows: By recognizing the user's question intent and employing a hierarchical retrieval and multi-source information fusion mechanism, this invention effectively overcomes the shortcomings of traditional question-and-answer systems in the chemical industry, such as single retrieval paths, insufficient coordination between static knowledge and dynamic data, and difficulty in balancing professionalism and real-time performance. It achieves accurate and efficient responses to policy consultations and real-time operational status queries in the chemical industry, significantly improving the reliability, practicality, and intelligence level of the question-and-answer system.

[0008] Based on the above technical solution, the present invention can be further improved as follows.

[0009] Furthermore, identifying whether the question information involves data in the real-time database includes: constructing structured prompt words based on the question information and the metadata of the real-time database; and inputting the structured prompt words into a large language model to identify whether the question information involves data in the real-time database through the large language model.

[0010] Further, the step of retrieving the real-time database and the domain knowledge base based on the question information to obtain the first retrieval information includes: converting the question information into a vector representation to obtain a question vector; calculating the similarity between the question vector and the vector representation of meta-knowledge related to the database query stored in a preset vector knowledge base, and retrieving the meta-knowledge most relevant to the question information based on the similarity; converting the question information into a structured query statement using a large language model based on the retrieved meta-knowledge; executing the structured query statement to retrieve the corresponding real-time data record from the real-time database; retrieving the domain knowledge base using a hybrid similarity retrieval method combining keyword retrieval and vector retrieval based on the question information to obtain knowledge fragments related to the question information; and obtaining the first retrieval information based on the real-time data record and the knowledge fragment.

[0011] Furthermore, the step of generating a question response using a large language model based on the first search information and the question information includes: structurally integrating the first search information and the question information to construct a first prompt context; and inputting the first prompt context into the large language model to generate a question response using the large language model.

[0012] Furthermore, the step of matching the question information with a question-and-answer knowledge base to identify whether a question-and-answer pair matching the question information exists in the question-and-answer knowledge base includes: calculating the vector similarity and keyword similarity between the question information and each question in the question-and-answer knowledge base; for each question in the question-and-answer knowledge base, weighting and merging the vector similarity and keyword similarity corresponding to the question to obtain the mixed similarity corresponding to the question; when there is a question with a corresponding mixed similarity higher than a preset threshold, it is determined that a question-and-answer pair matching the question information exists in the question-and-answer knowledge base; when there is no question with a corresponding mixed similarity higher than the preset threshold, it is determined that no question-and-answer pair matching the question information exists in the question-and-answer knowledge base.

[0013] Furthermore, the step of retrieving the domain knowledge base based on the question information to obtain second retrieval information, and generating a question response using a large language model based on the second retrieval information and the question information, includes: retrieving the domain knowledge base using a hybrid similarity retrieval method combining keyword retrieval and vector retrieval based on the question information to obtain knowledge fragments related to the question information, thereby obtaining the second retrieval information; structurally integrating the second retrieval information and the question information to construct a second prompt context; and inputting the second prompt context into the large language model to generate a question response through the large language model.

[0014] Furthermore, the method also includes: obtaining report requirement information, which describes whether the user needs to generate an analysis report; when the report requirement information indicates that an analysis report needs to be generated and the question information involves data in a real-time database, generating drawing code for data visualization based on the real-time data records; executing the drawing code to generate image data; and generating an analysis report according to a preset report template using a large language model based on the question information, the image data, and the first retrieval information.

[0015] To address the aforementioned technical problems, this invention also provides a chemical industry policy question-answering device based on a large language model, comprising: The question receiving module is used to receive user questions and identify whether the questions involve data in the real-time database, which stores real-time operating data in the chemical production process. The first response module is used to retrieve data from the real-time database and the domain knowledge base respectively based on the question information when the question information involves data in the real-time database, obtain the first retrieval information, and generate a question response through a large language model based on the first retrieval information and the question information; wherein, the domain knowledge base stores domain knowledge and standards for guiding chemical production, safety and compliance; The question-answer pair matching module is used to match the question information with the question-answer knowledge base when the question information does not involve data in the real-time database, and to identify whether there is a question-answer pair in the question-answer knowledge base that matches the question information; wherein, the question-answer knowledge base is a database used to store question-answer pairs related to the chemical industry; The second response module is used to generate a question response based on the question-answer pair that matches the question information when there is a question-answer pair in the question-answer knowledge base that matches the question information. The third response module is used to retrieve the domain knowledge base based on the question information when there is no question-answer pair matching the question information in the question-answer knowledge base, obtain second retrieval information, and generate a question response through a large language model based on the second retrieval information and the question information.

[0016] To address the aforementioned technical problems, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the chemical industry policy question-and-answer method based on a large language model as described above.

[0017] To address the aforementioned technical problems, the present invention also provides a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute the chemical industry policy question-and-answer method based on a large language model as described above. Attached Figure Description

[0018] Figure 1 This is a flowchart of the chemical industry policy question-answering method based on a large language model according to the present invention; Figure 2 This is a flowchart of Embodiment 1 of the present invention; Figure 3 This is a schematic diagram of the chemical industry policy question-and-answer device based on a large language model according to the present invention; Figure 4 This is a schematic diagram of the electronic device of the present invention. Detailed Implementation

[0019] The principles and features of the present invention are described below. The examples given are only for explaining the present invention and are not intended to limit the scope of the present invention.

[0020] As mentioned above, in existing technologies, intelligent question answering methods based on large language models can be mainly divided into the following categories: The first category is direct question answering based on a general-purpose large language model. This method directly utilizes a pre-trained general-purpose large language model to respond to user queries. Its advantages lie in the model's strong generalization ability and simple implementation. However, due to the highly specialized nature and specific terminology of the chemical industry, the general-purpose model lacks a deep understanding of industry policies, standards, and process principles. When directly applied to chemical policy question answering or safety analysis, it often suffers from factual errors, unprofessional expressions, or inaccurate logical reasoning, making it difficult to meet the reliability requirements of practical applications.

[0021] The second category is domain-specific modeling methods based on fine-tuning. To enhance the model's specialization, some technical solutions employ supervised fine-tuning of general-purpose language models using specialized corpora from the chemical industry (such as policy documents, safety manuals, and accident case studies). While this method can improve the model's grasp of chemical knowledge to some extent, it has significant limitations. First, the fine-tuning process requires a large amount of high-quality labeled data, which is costly and time-consuming. Second, policies and real-time data in the chemical industry are constantly changing, and the fine-tuned model cannot flexibly and promptly absorb new knowledge, resulting in a serious knowledge update lag problem and difficulty adapting to scenarios with high real-time requirements.

[0022] The third category is retrieval-enhanced generation (RAG) methods. This method combines a large language model with an external knowledge base, retrieving relevant knowledge fragments before answering a question, and then generating the answer based on the retrieval results. This effectively improves the "illusion" problem of the model and enhances the accuracy of the answer. However, existing RAG technology still has shortcomings when applied to complex chemical engineering scenarios. Its main problem lies in its inability to effectively distinguish and collaboratively process static domain knowledge and dynamic real-time data. Specifically: 1. Lack of a precise routing mechanism for query intent: Existing methods typically use a single knowledge retrieval path for all user queries, failing to intelligently determine whether a question should be queried from a static knowledge base (such as policies and regulations) or a real-time database (such as sensor alarm data), resulting in inaccurate system responses.

[0023] 2. Weak ability to integrate multi-source information: Decision-making in the chemical industry often requires the integration of static knowledge (such as safety regulations) and real-time status (such as equipment readings). Existing technologies simply merge all retrieved document fragments into the model, which easily introduces a large amount of irrelevant information and interferes with the core judgment of the large model.

[0024] 3. Lack or Weak Real-Time Data Analysis and Report Generation Functionality: Although database query methods exist, most existing question-and-answer systems focus on document-based questions and answers, lacking the ability to seamlessly integrate real-time data query results with fixed-format report generation. This fails to meet users' deeper need for "not only to be informed of alarm status, but also to generate a standardized report containing trend analysis, compliance checks, and handling recommendations."

[0025] In summary, while existing technologies each have their advantages in general question-and-answer or database querying, none provide a complete, efficient, and accurate solution for the complex needs of combining static policy knowledge question-and-answer with dynamic real-time data analysis report generation in the chemical industry. Their core shortcomings lie in rigid processes, reliance on a single data source, and the inability to achieve intelligent routing based on question intent, effective fusion of multi-source information, and on-demand generation of in-depth analysis reports.

[0026] Therefore, the purpose of this invention is to overcome the shortcomings of the prior art and solve the core problems of rigid processes, single data source utilization, and difficulty in balancing real-time performance and accuracy in the prior art.

[0027] Specifically, the present invention aims to solve the following technical problems: 1. Addressing the issue of inaccurate query intent recognition and routing: To address the shortcomings of existing question-answering systems that use a single search path for all questions, this invention aims to establish an intelligent intent recognition and routing mechanism. By first determining whether the user's question involves real-time data, the system can automatically and accurately route the question to a real-time database or static knowledge base for retrieval, ensuring the system's targeted and accurate response.

[0028] 2. Addressing the weakness in fusing static knowledge with dynamic data: To address the difficulty of effectively utilizing multi-source heterogeneous information in existing retrieval enhancement generation technologies, this invention aims to design a hierarchical and ordered knowledge integration process. By structurally integrating static QA knowledge bases, domain knowledge base documents, and real-time database query results, it provides large language models with accurate, concise, and highly relevant contextual information, thereby improving the reliability of their complex reasoning and answer generation.

[0029] 3. Addressing the lack of real-time data analysis and standardized report generation capabilities: Addressing the weakness of existing systems, which are mostly limited to simple question-and-answer formats and lack in-depth analytical capabilities, this invention aims to integrate real-time data with static knowledge analysis and fixed-format report generation. The system can automatically generate structured reports based on real-time alarm data and chemical industry knowledge, including status analysis, trend judgment, compliance checks, and handling suggestions, meeting users' needs for in-depth decision support.

[0030] 4. Enhance the overall timeliness and usability of the system: The ultimate goal of this invention is to build an integrated intelligent system that can quickly respond to policy and regulatory inquiries and analyze and provide early warnings based on real-time production data. This system can effectively reduce reliance on professional engineers and improve the efficiency and intelligence level of safety production management and emergency response in chemical enterprises.

[0031] In summary, the core objective of this invention is to achieve efficient collaboration between static domain knowledge and dynamic real-time data through an innovative and intelligent process design, ultimately providing accurate, timely, and in-depth question-and-answer and reporting services.

[0032] Example 1 Based on this, such as Figure 1 and Figure 2 As shown, this embodiment provides a chemical industry policy question-answering method based on a large language model. The core of this method lies in using an intelligent, hierarchical decision-making process to collaboratively utilize a static knowledge base and a real-time database, ensuring the accuracy and timeliness of the response. The method mainly includes the following steps: S101. Receive user's question information and identify whether the question information involves data in the real-time database, which stores real-time operating data of the chemical production process.

[0033] S102. When the question information involves data in the real-time database, the real-time database and the domain knowledge base are searched separately according to the question information to obtain the first search information. Based on the first search information and the question information, a question response is generated through a large language model. The domain knowledge base stores domain knowledge and standards used to guide chemical production, safety and compliance.

[0034] S103. When the question information does not involve data in the real-time database, the question information is matched with the question-and-answer knowledge base to identify whether there is a question-and-answer pair in the question-and-answer knowledge base that matches the question information; wherein, the question-and-answer knowledge base is a database used to store question-and-answer pairs related to the chemical industry.

[0035] S104. When a question-and-answer pair that matches the question information exists in the question-and-answer knowledge base, generate a question response based on the question-and-answer pair that matches the question information.

[0036] S105. When there is no question-answer pair matching the question information in the question-answer knowledge base, the domain knowledge base is searched according to the question information to obtain the second search information. Based on the second search information and the question information, the question response is generated through the large language model.

[0037] This method, by identifying the user's question intent and employing a hierarchical retrieval and multi-source information fusion mechanism, effectively overcomes the shortcomings of traditional question-and-answer systems in the chemical industry, such as single retrieval paths, insufficient coordination between static knowledge and dynamic data, and difficulty in balancing professionalism and real-time performance. It achieves accurate and efficient responses to policy inquiries and real-time operational status queries in the chemical industry, significantly improving the reliability, practicality, and intelligence of the question-and-answer system.

[0038] Optionally, in an embodiment, identifying whether the question information involves data in a real-time database includes: constructing structured prompt words based on the question information and the metadata of the real-time database; and inputting the structured prompt words into a large language model to identify whether the question information involves data in the real-time database through the large language model.

[0039] The system receives user-input questions via a web interface or API. These questions are entered by the user in natural language. First, the user's question and relevant information from the real-time database are provided to the large model via prompts. The large model then performs intent recognition, with the core criterion being whether the question involves or requires querying the online real-time database.

[0040] Optionally, in this embodiment, the first retrieval information is obtained by searching the real-time database and the domain knowledge base according to the query information, including: converting the query information into a vector representation to obtain a query vector; calculating the similarity between the query vector and the vector representation of meta-knowledge related to the database query stored in a preset vector knowledge base, and retrieving the meta-knowledge most relevant to the query information based on the similarity; converting the query information into a structured query statement using a large language model based on the retrieved meta-knowledge; executing the structured query statement to retrieve the corresponding real-time data record from the real-time database; searching the domain knowledge base according to the query information using a hybrid similarity retrieval method combining keyword retrieval and vector retrieval to obtain knowledge fragments related to the query information; and obtaining the first retrieval information based on the real-time data record and the knowledge fragments.

[0041] The first retrieval information includes real-time data records retrieved from the real-time database and knowledge fragments retrieved from the domain knowledge base.

[0042] Specifically, the user's query is first input into a pre-built vector knowledge base for retrieval. This vector knowledge base does not store raw real-time data, but rather stores meta-knowledge related to the database query, and its content mainly includes: Database and table structure data: such as the name of the data table, field names, field data types, and relationships between tables; Synonym data: Mapping chemical industry technical terms and common names to standard field names in the database; Sample queries: Stores standard SQL statements or query templates for common query intents.

[0043] The user's natural language question is converted into a high-dimensional vector by an embedding model. Then, the similarity between the vector of the user's question and the vector of meta-knowledge in the vector database is calculated. Finally, based on the vector similarity, the most relevant database table structure, synonym mapping relationship and reference query example are retrieved.

[0044] Based on the retrieved results (especially the database table structure and synonym mapping), the user's natural language query is transformed into a precise and executable structured query statement through a large language model.

[0045] Finally, the generated query is executed to retrieve relevant data records from the real-time database (such as the real-time alarm database and related real-time production database).

[0046] Specifically, based on user questions, keyword and vector similarity searches are performed in a pre-built chemical industry knowledge base (containing full texts of policies and regulations, historical accident reports, technical documents, and other unstructured or semi-structured documents) to obtain knowledge fragments related to the question.

[0047] Optionally, in an embodiment, generating a question response using a large language model based on the first search information and the question information includes: structurally integrating the first search information and the question information to construct a first prompt context; and inputting the first prompt context into the large language model to generate a question response using the large language model.

[0048] Specifically, the domain knowledge fragments, real-time data records, and question information obtained in the aforementioned steps are structurally integrated to construct a unified prompt context.

[0049] The constructed context is used as a prompt and input into the large language model. The large language model performs reasoning based on all the provided accurate information to generate the final natural language answer. In this embodiment, the large language model is an existing open-source large model or a closed-source large model API, such as DeepseekV3, DeepseekR3, etc.

[0050] Optionally, in an embodiment, matching the question information with a question-and-answer knowledge base to identify whether a question-and-answer pair matching the question information exists in the knowledge base includes: calculating the vector similarity and keyword similarity between the question information and each question in the knowledge base; for each question in the knowledge base, weighting and merging the vector similarity and keyword similarity corresponding to the question to obtain the mixed similarity corresponding to the question; when there is a question with a corresponding mixed similarity higher than a preset threshold, it is determined that a question-and-answer pair matching the question information exists in the knowledge base; when there is no question with a corresponding mixed similarity higher than the preset threshold, it is determined that no question-and-answer pair matching the question information exists in the knowledge base.

[0051] Specifically, the process begins by searching a pre-built chemical engineering QA knowledge base (i.e., a question-and-answer knowledge base) for existing answers that closely match the user's question. This knowledge base contains high-frequency question-and-answer pairs, such as interpretations of policy provisions and standard operating procedures.

[0052] If a QA pair with a keyword and vector similarity higher than a preset threshold is found in the QA knowledge base, the answer to that QA pair will be directly output to the user as the final response, and the process will end.

[0053] Specifically, the method involves calculating a hybrid similarity between keywords and vectors, that is, calculating the vector similarity and keyword similarity between the user's question and the QA question respectively, and then weighting and merging the two similarities to obtain a hybrid similarity.

[0054] Optionally, in an embodiment, the domain knowledge base is searched based on the question information to obtain second search information, and a question response is generated using a large language model based on the second search information and the question information. This includes: searching the domain knowledge base using a hybrid similarity retrieval method combining keyword retrieval and vector retrieval based on the question information to obtain knowledge fragments related to the question information, thus obtaining the second search information; structurally integrating the second search information and the question information to construct a second prompt context; and inputting the second prompt context into the large language model to generate a question response through the large language model.

[0055] Specifically, based on the user's question, a keyword and vector hybrid similarity search is performed in a pre-built chemical industry knowledge base (containing full texts of policies and regulations, historical accident reports, technical documents, and other unstructured or semi-structured documents) to obtain knowledge fragments related to the question, thus obtaining the second search information.

[0056] The second retrieval information and question information obtained in the preceding steps are structurally integrated to construct a unified prompt context. This constructed context is then used as a prompt and input into the large language model. The large language model performs reasoning based on all the provided precise information to generate the final natural language answer.

[0057] Optionally, in an embodiment, the method further includes: obtaining report requirement information, which describes whether the user needs to generate an analysis report; when the report requirement information indicates that an analysis report needs to be generated and the question information involves data in a real-time database, generating drawing code for data visualization based on real-time data records; executing the drawing code to generate image data; and generating an analysis report according to a preset report template using a large language model based on the question information, image data, and first retrieval information.

[0058] Based on the user's choices in the query, it is determined whether a fixed-format analysis report needs to be generated based on the results. When the report requirement is to generate an analysis report and the query involves data in the real-time database, the large language model automatically generates plotting code for data visualization based on the user's query intent and the data structure of the retrieved real-time database query results (such as including time series, device status, etc.). Executing the generated plotting code produces image data.

[0059] The large language model generates the final natural language report based on the following elements and according to a preset report template: 1. Original user question information: Clearly define the analysis objectives and scope of the report; 2. Real-time data records retrieved from the real-time database: serving as the core data support for the report; 3. Generated visual images: serving as a visual representation of the report; 4. Acquired relevant domain knowledge (such as security thresholds and processing procedures): used for in-depth analysis and recommendations.

[0060] If a user's question does not involve real-time data, the user generally does not request an analysis report; a direct reply with the results is sufficient. If, in this case, the user still requests a report, the plotting code will return empty and will not be executed.

[0061] At this point, the large language model generates the final natural language report based on the following elements and according to the preset report template: 1. Original user question information: Clearly define the analysis objectives and scope of the report; 2. Acquired domain knowledge (such as security thresholds and processing procedures): used for in-depth analysis and recommendations.

[0062] Compared with existing technologies, this method has the following significant advantages: 1. Improved accuracy and intelligence of question answering: By introducing intelligent intent recognition and routing mechanisms, this method can automatically distinguish whether a user's query involves dynamic real-time data and select the optimal retrieval path. This pre-emptive intent judgment fundamentally avoids the problem of irrelevant answers caused by the single retrieval path in existing technologies, ensuring the accuracy and intelligence level of the system response.

[0063] 2. It achieves a combination of rapid response to high-frequency questions in the chemical industry and in-depth processing of complex questions: By employing a hierarchical retrieval strategy, standard answers are prioritized from a highly efficient QA knowledge base when online data is not involved, enabling rapid responses to common, high-frequency questions in the chemical industry. For questions that are not matched or are complex, a deep domain knowledge base search is initiated to ensure the depth and accuracy of the answer. This structure effectively balances response efficiency and breadth of knowledge coverage, improving the user experience.

[0064] 3. Enabled automated generation of data-driven, visualized in-depth analysis reports in the chemical industry: Through an innovative report generation process, combining the code generation capabilities of a large language model with report synthesis capabilities, it can dynamically create data visualizations and embed them into structured reports. This not only provides textual analysis but also generates intuitive charts, making the analysis results readily apparent and providing more comprehensive and intuitive data support for decision-making, surpassing the limitations of traditional question-and-answer systems that can only provide text responses.

[0065] 4. Effectively overcomes the "illusion" problem of large models while ensuring data timeliness: The entire process of this method is based on a retrieval-enhanced generation framework. Each response and report generated by the large model strictly relies on information retrieved from a chemical engineering knowledge base and a real-time database. This greatly reduces the possibility of the model generating content out of thin air, ensuring the authenticity and accuracy of the output content. Furthermore, this method does not require frequent model retraining; it only needs to update the external knowledge base and the real-time database to maintain the latest state of knowledge, resulting in low maintenance costs and fast update speed.

[0066] In summary, this method, through a series of innovative process designs, successfully integrates static policy Q&A with dynamic real-time data analysis, constructing a precise, efficient, intuitive, and easy-to-maintain intelligent system that provides strong technical support for safe production, compliance management, and efficient decision-making in the chemical industry.

[0067] It should be noted that the core innovation claimed in this invention lies in the overall architecture of the method and system and the collaborative working logic of key modules. Its core lies not in the large language model itself, but in how to intelligently organize, retrieve, and fuse multi-source information to solve specific domain problems. Specifically, this includes: 1. Intelligent Routing and Hierarchical Retrieval Mechanism Based on Intent Recognition: The core lies in building a front-end intent recognition module, which automatically determines whether real-time data is involved based on the user's query and routes the query to two parallel and independent processing paths accordingly: one path prioritizes querying the static QA knowledge base for rapid response, while the other path accesses the real-time database through a vector knowledge database. This "routing + hierarchical" retrieval architecture is one of the core innovations of this invention, fundamentally solving the rigidity problem of a single retrieval path.

[0068] 2. An automated method for generating dynamic and visual chemical industry reports using integrated code: The core of this method lies in decomposing the report generation process in the chemical industry into an automated workflow: "Dynamically generating plotting code based on real-time database query results → executing the code to generate images → integrating data, charts, and large-scale model analysis results into a structured report." This method overcomes the limitations of fixed report templates, achieving a high degree of adaptability and automated generation of report content and charts, representing a core innovation in enhancing the system's decision support capabilities.

[0069] 3. The overall system architecture for the orderly fusion and collaborative generation of multi-source information: The core lies in protecting the collaborative working method of the above-mentioned innovations as an organic whole. That is, how to achieve integrated output from user questions to accurate answers or in-depth reports through specific connections and data interaction relationships in each step.

[0070] Example 2 Based on Example 1, this example provides a specific instance of the operation process as follows: Scenario: A user asks, "Please analyze the temperature fluctuation of distillation column T-101 in Workshop 3 over the past hour," and selects to generate a report.

[0071] By using the method in Example 1 to identify intent, it was determined that the question involved a real-time database.

[0072] User queries are sent to a vector knowledge database for retrieval. This database stores the following meta-knowledge: Table structure: (table_name:data,columns:[timestamp,device_id,value,device_name]); Synonyms: (“Distillation column T-101”,“T-101”), (“Temperature”,“temperature”); Query example: "SELECT ... FROM temperature _data WHERE device_id=? AND timestampBETWEEN ? AND ?".

[0073] Based on the retrieved metadata, the natural language question is converted into an SQL query: SELECT timestamp, value FROM data WHERE device_id='T-101'ANDtimestamp>=calc_time.

[0074] The SQL query was executed in the real-time database to retrieve the temperature time series data for the past hour.

[0075] Simultaneously, using the vector of user queries, relevant documents are retrieved from a chemical engineering knowledge base. For example, relevant knowledge fragments such as "the normal operating temperature range of distillation column T-101 is 150-190℃" are retrieved.

[0076] Construct a context for prompt words, including: the user's original question, the retrieved real-time temperature data (in tabular form), and the retrieved domain knowledge ("normal range 150-190℃"). Generate a natural language answer based on the context for prompt words.

[0077] Based on the context, the large language model automatically generates Python plotting code similar to the following: import matplotlib.pyplot as plt # ... (Data preprocessing code) plt.plot(timestamps, values) plt.axhline(y=190, color='r', linestyle='--', label='safety upper limit') plt.title('T-101 Temperature Trend Chart') Execute this code to generate image data.

[0078] The large language model receives all information (questions, data, images, knowledge) and generates a Markdown or Word format report containing the following sections according to a preset report template: Title: Analysis Report on Temperature Fluctuations of T-101

[0079] Executive Summary: Over the past hour, temperatures fluctuated between 155 and 182°C, remaining generally manageable, but approaching the safe limit at times.

[0080] Data visualization: generating images.

[0081] Detailed analysis: Comparing real-time data with safety regulations, it is pointed out that the peak temperature of 182℃ is close to the safety limit of 190℃, which requires attention.

[0082] Recommendation: It is recommended to check the stability of the heating source and increase the monitoring frequency for the next two hours.

[0083] Output: Output a structured analysis report.

[0084] Finally, this structured analysis report is returned to the user.

[0085] Example 3 Based on Example 1, this example provides another specific instance of the operation process as follows: In this embodiment, only the policy Q&A function is implemented. For example, a user might ask: "What is the standard oxygen concentration for confined space operations?" Intent recognition determined that the issue did not involve real-time data.

[0086] The QA knowledge base was searched first, and the standard answer was successfully found: "During the operation, the oxygen concentration in the confined space shall not be lower than 19.5% and shall not be higher than 23.5%". Since the QA knowledge base was matched, the process ended directly, and the answer was returned to the user.

[0087] Example 4 like Figure 3 As shown, this embodiment provides a chemical industry policy question-and-answer device 200 based on a large language model, including: The question receiving module 201 is used to receive the user's question information and identify whether the question information involves data in the real-time database, which stores real-time operating data in the chemical production process. The first response module 202 is used to retrieve data from the real-time database and the domain knowledge base respectively when the question information involves data in the real-time database, obtain the first retrieval information, and generate a question response through a large language model based on the first retrieval information and the question information; wherein, the domain knowledge base stores domain knowledge and standards used to guide chemical production, safety and compliance; The question-answer pair matching module 203 is used to match the question information with the question-answer knowledge base when the question information does not involve data in the real-time database, and to identify whether there is a question-answer pair in the question-answer knowledge base that matches the question information; wherein, the question-answer knowledge base is a database used to store question-answer pairs related to the chemical industry; The second response module 204 is used to generate a question response based on the question-answer pair that matches the question information when there is a question-answer pair in the question-answer knowledge base. The third response module 205 is used to retrieve the domain knowledge base based on the question information when there is no question-answer pair matching the question information in the question-answer knowledge base, obtain the second retrieval information, and generate a question response through the large language model based on the second retrieval information and the question information.

[0088] Optionally, in an embodiment, the problem receiving module 201 includes: The prompt word construction unit is used to construct structured prompt words based on the question information and the metadata of the real-time database; The recognition unit is used to input structured prompt words into the large language model so that the large language model can identify whether the question information involves data in the real-time database.

[0089] Optionally, in an embodiment, the first response module 202 includes: The vector representation unit is used to convert the query information into a vector representation to obtain the query vector. The meta-knowledge retrieval unit is used to calculate the similarity between the query vector and the vector representation of meta-knowledge related to the database query stored in the preset vector knowledge base, and retrieve the meta-knowledge most relevant to the query information based on the similarity. The statement construction unit is used to transform the query information into a structured query statement based on the retrieved meta-knowledge through a large language model; The first retrieval unit is used to execute structured query statements and retrieve the corresponding real-time data records from the real-time database; The second retrieval unit is used to search the domain knowledge base based on the question information using a hybrid similarity retrieval method that combines keyword retrieval and vector retrieval, in order to obtain knowledge fragments related to the question information. The information generation unit is used to obtain the first retrieval information based on real-time data records and knowledge fragments.

[0090] Optionally, in an embodiment, the first response module 202 further includes: The first prompt context unit is used to structurally integrate the first search information and the question information to construct the first prompt context; The first response unit is used to input the first prompt context into the large language model so that the large language model can generate a question response.

[0091] Optionally, in an embodiment, the question-and-answer pair matching module 203 includes: The similarity calculation unit is used to calculate the vector similarity and keyword similarity between the question information and each question in the question-answering knowledge base, respectively. The weighted calculation unit is used to weight and merge the vector similarity and keyword similarity corresponding to each question in the question-answering knowledge base to obtain the mixed similarity corresponding to the question. The first determination unit is used to determine whether there is a question-answer pair in the question-answer knowledge base that matches the question information when there is a question with a corresponding mixed similarity higher than a preset threshold. The second determination unit is used to determine that there is no question-answer pair in the question-answer knowledge base that matches the question information when there is no corresponding question with a mixed similarity higher than a preset threshold.

[0092] Optionally, in an embodiment, the third response module 205 includes: The third retrieval unit is used to search the domain knowledge base based on the query information using a hybrid similarity retrieval method that combines keyword retrieval and vector retrieval to obtain knowledge fragments related to the query information and thus obtain the second retrieval information. The second prompt context unit is used to structurally integrate the second search information and the question information to construct the second prompt context; The second response unit is used to input the second prompt context into the large language model so as to generate a question response through the large language model.

[0093] Optionally, in an embodiment, the apparatus further includes: The information acquisition module is used to acquire report requirement information, which describes whether the user needs to generate an analysis report. The code generation module is used to generate plotting code for data visualization based on real-time data records when the report requirement is to generate an analysis report and the question involves data in a real-time database. The image generation module is used to execute drawing code to generate image data; The report generation module is used to generate an analysis report based on the query information, image data, and initial search information, using a large language model and a preset report template.

[0094] In some embodiments, the chemical industry policy question-answering device 200 based on a large language model of the present invention can be implemented in a combination of hardware and software. As an example, the chemical industry policy question-answering device 200 based on a large language model of the present invention can be a processor in the form of a hardware decoding processor, which is programmed to execute the chemical industry policy question-answering method based on a large language model of the present invention. For example, the processor in the form of a hardware decoding processor can be one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.

[0095] The modules described in the embodiments of this invention can be implemented in software or hardware. The names of the modules are not, in some cases, limiting the scope of the module itself.

[0096] Example 5 like Figure 4 As shown, this embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the chemical industry policy question-and-answer method based on a large language model as described in Embodiment 1.

[0097] In other words, an electronic device according to an embodiment of the present invention may include, but is not limited to: a processor and a memory; the memory is used to store computer programs; the processor is used to execute the chemical industry policy question-and-answer method based on a large language model as shown in any embodiment of the present invention by calling the computer program.

[0098] In one alternative embodiment, an electronic device is provided, such as Figure 4 As shown, Figure 4The illustrated electronic device 300 includes a processor 301 and a memory 303. The processor 301 and the memory 303 are connected, for example, via a bus 302. Optionally, the electronic device 300 may further include a transceiver 304, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 304 is not limited to one type, and the structure of the electronic device 300 does not constitute a limitation on the embodiments of the present invention.

[0099] Processor 301 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this invention. Processor 301 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0100] Bus 302 may include a path for transmitting information between the aforementioned components. Bus 302 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 302 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 4 The bus 302 is represented by only one thick line, but this does not mean that there is only one bus or one type of bus.

[0101] The memory 303 may be a ROM (Read Only Memory) or other type of static storage device capable of storing static information and instructions, RAM (Random Access Memory) or other type of dynamic storage device capable of storing information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto.

[0102] The memory 303 is used to store application code (computer program) for executing the present invention, and its execution is controlled by the processor 301. The processor 301 is used to execute the application code stored in the memory 303 to implement the content shown in the foregoing method embodiments.

[0103] Among them, electronic devices can also be terminal devices, which can be any device that can install applications, including at least one of smartphones, tablets, laptops, desktop computers, smart speakers, smartwatches, smart TVs, and smart in-vehicle devices.

[0104] It should be noted that, Figure 4 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of the present invention.

[0105] Example 6 This embodiment provides a non-transitory computer-readable storage medium that stores computer instructions for causing a computer to execute a chemical industry policy question-and-answer method based on a large language model, as described in Embodiment 1.

[0106] Alternatively, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, a floppy disk, and an optical data storage device, etc.

[0107] In an exemplary embodiment, a computer program product or computer program is also provided, which includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the aforementioned chemical policy question-and-answer method based on a large language model.

[0108] Computer program code for performing the operations of this invention 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 C or similar 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).

[0109] It should be understood that the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of methods and computer program products according to various embodiments of the present invention. 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 the 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, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0110] The computer-readable storage medium provided in this invention can be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EEPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0111] The aforementioned computer-readable storage medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the method shown in the above embodiments.

[0112] The above description is merely a preferred embodiment of the present invention and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of disclosure in this invention is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-disclosed concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this invention.

[0113] It should be noted that the terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and represent a limitation on a specific order or sequence. Where appropriate, the order of use for similar objects can be interchanged so that the embodiments of this application described herein can be implemented in an order other than that shown or described.

[0114] Those skilled in the art will recognize that this invention can be implemented as a system, method, or computer program product. Therefore, this invention can be specifically implemented in the following forms: it can be entirely hardware, entirely software (including firmware, resident software, microcode, etc.), or a combination of hardware and software, generally referred to herein as a "circuit," "module," or "system." Furthermore, in some embodiments, this invention can also be implemented as a computer program product contained in one or more computer-readable media, which includes computer-readable program code.

[0115] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.

Claims

1. A chemical industry policy question-answering method based on a large language model, characterized in that, include: Receive user questions and identify whether the questions involve data in a real-time database, which stores real-time operational data of the chemical production process; When the question information involves data in the real-time database, the real-time database and the domain knowledge base are searched according to the question information to obtain the first search information. Then, based on the first search information and the question information, a question response is generated through a large language model. The domain knowledge base stores domain knowledge and standards for guiding chemical production, safety and compliance. When the question information does not involve data in the real-time database, the question information is matched with the question-and-answer knowledge base to identify whether there is a question-and-answer pair in the question-and-answer knowledge base that matches the question information; wherein, the question-and-answer knowledge base is a database used to store question-and-answer pairs related to the chemical industry; When a question-and-answer pair that matches the question information exists in the question-and-answer knowledge base, a question response is generated based on the question-and-answer pair that matches the question information. When there is no question-answer pair matching the question information in the question-answer knowledge base, the domain knowledge base is searched according to the question information to obtain second search information, and a question response is generated through a large language model based on the second search information and the question information.

2. The chemical industry policy question-answering method based on a large language model according to claim 1, characterized in that, The step of identifying whether the query information involves data in a real-time database includes: Structured prompt words are constructed based on the question information and the metadata of the real-time database; The structured prompt words are input into a large language model to identify whether the question information involves data in a real-time database.

3. The chemical industry policy question-answering method based on a large language model according to claim 1, characterized in that, The step of retrieving the real-time database and the domain knowledge base based on the query information to obtain the first retrieval information includes: The question information is converted into a vector representation to obtain the question vector; Calculate the similarity between the question vector and the vector representation of meta-knowledge related to database queries stored in a preset vector knowledge base, and retrieve the meta-knowledge most relevant to the question information based on the similarity. Based on the retrieved meta-knowledge, the question information is transformed into a structured query statement through a large language model; Execute the structured query statement to retrieve the corresponding real-time data records from the real-time database; Based on the question information, a hybrid similarity retrieval method combining keyword retrieval and vector retrieval is used to search the domain knowledge base to obtain knowledge fragments related to the question information; The first retrieval information is obtained based on the real-time data records and the knowledge fragments.

4. The chemical industry policy question-answering method based on a large language model according to claim 1, characterized in that, The step of generating a question response using a large language model based on the first search information and the question information includes: The first search information and the question information are structurally integrated to construct a first prompt context; The first prompt context is input into the large language model to generate a question response.

5. The chemical industry policy question-answering method based on a large language model according to claim 1, characterized in that, The step of matching the question information with a question-and-answer knowledge base to identify whether a question-and-answer pair matching the question information exists in the question-and-answer knowledge base includes: Calculate the vector similarity and keyword similarity between the question information and each question in the question-answering knowledge base; For each question in the question-answering knowledge base, the vector similarity and keyword similarity corresponding to the question are weighted and combined to obtain the mixed similarity corresponding to the question; When there is a question with a corresponding mixed similarity higher than a preset threshold, it is determined that there is a question-answer pair in the question-answering knowledge base that matches the question information; When there is no corresponding question with a mixed similarity higher than a preset threshold, it is determined that there is no question-answer pair in the question-answer knowledge base that matches the question information.

6. The chemical industry policy question-answering method based on a large language model according to claim 1, characterized in that, The step of retrieving the domain knowledge base based on the question information to obtain second retrieval information, and generating a question response using a large language model based on the second retrieval information and the question information, includes: Based on the question information, a hybrid similarity retrieval method combining keyword retrieval and vector retrieval is used to search the domain knowledge base to obtain knowledge fragments related to the question information, thereby obtaining the second retrieval information; The second search information and the question information are structurally integrated to construct a second prompt context; The second prompt context is input into the large language model to generate a question response.

7. The chemical industry policy question-answering method based on a large language model according to claim 3, characterized in that, Also includes: Obtain report requirement information, which describes whether the user needs to generate an analysis report; When the report requirement information is that an analysis report needs to be generated and the question information involves data in the real-time database, drawing code for data visualization is generated based on the real-time data records; Execute the drawing code to generate image data; Based on the question information, the image data, and the first search information, an analysis report is generated using a large language model according to a preset report template.

8. A chemical industry policy question-and-answer device based on a large language model, characterized in that, include: The question receiving module is used to receive user questions and identify whether the questions involve data in the real-time database, which stores real-time operating data in the chemical production process. The first response module is used to retrieve data from the real-time database and the domain knowledge base respectively based on the question information when the question information involves data in the real-time database, obtain the first retrieval information, and generate a question response through a large language model based on the first retrieval information and the question information; wherein, the domain knowledge base stores domain knowledge and standards for guiding chemical production, safety and compliance; The question-answer pair matching module is used to match the question information with the question-answer knowledge base when the question information does not involve data in the real-time database, and to identify whether there is a question-answer pair in the question-answer knowledge base that matches the question information; wherein, the question-answer knowledge base is a database used to store question-answer pairs related to the chemical industry; The second response module is used to generate a question response based on the question-answer pair that matches the question information when there is a question-answer pair in the question-answer knowledge base that matches the question information. The third response module is used to retrieve the domain knowledge base based on the question information when there is no question-answer pair matching the question information in the question-answer knowledge base, obtain second retrieval information, and generate a question response through a large language model based on the second retrieval information and the question information.

9. An electronic device, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the chemical industry policy question-and-answer method based on a large language model as described in any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to execute the chemical industry policy question-and-answer method based on a large language model as described in any one of claims 1 to 7.