Intelligent system based on NO2 pollution monitoring and knowledge questioning and answering

By building a NO2 knowledge question-and-answer system based on the RAG framework, combining the CEEMDAN-Informer prediction model with the Quartz task scheduling framework, the problems of data integration difficulties and delayed warnings in NO2 pollution monitoring are solved, real-time warnings of NO2 concentrations and professional knowledge question-and-answer services are achieved, the accuracy and timeliness of question-and-answer services are improved, and the intelligent development of environmental governance is supported.

CN120804260APending Publication Date: 2025-10-17XIAMEN UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510920533.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-04
Publication Date
2025-10-17

AI Technical Summary

Technical Problem

Existing technologies in NO2 pollution monitoring and control face problems such as difficulty in data integration, relatively delayed early warning, and insufficient public participation. In addition, large language models face problems of knowledge timeliness lag and illusion in professional knowledge Q&A, making it difficult to dynamically update professional information.

Method used

A NO2 knowledge question-answering system based on the RAG framework was built, combining the CEEMDAN-Informer prediction model with the Quartz task scheduling framework to achieve real-time early warning of NO2 concentration and professional knowledge question-answering. Multi-source data fusion and multidisciplinary technology collaboration were adopted, and intelligent question-answering was performed through the ONNX Runtime inference engine and the RAG question-answering model. The answers to repeated questions were cached in the Redis database.

Benefits of technology

It has achieved dynamic monitoring and real-time early warning of NO2 concentration, improved the accuracy and timeliness of questions and answers in professional fields, provided scientific decision-making support, provided technical support for smart environmental protection systems, and promoted the development of environmental governance towards intelligence and precision.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120804260A_ABST
    Figure CN120804260A_ABST
Patent Text Reader

Abstract

The invention discloses an intelligent system based on pollution monitoring and knowledge questions and answers, and the system specifically comprises a concentration prediction module which introduces a Quartz task scheduling framework to carry out the automatic scheduling and execution of a job; the method comprises the following steps: calling a getNO2HistoicalData () method to obtain historical concentration data, and calling a CEEMDAN-Informer prediction model obtained based on PyTorch training by adopting an ONNX Runtime inference engine to predict the historical concentration data; after the prediction is finished, a savePredicted NO2Data () method of a Mapper layer is called to store a predicted value into a MySQL database; the knowledge intelligent question and answer module adopts Vue.js to construct a user interface, and provides a question and answer input box and a result display box; creating a RESTful API interface by using Spring Boot to receive a front-end request, and calling an RAG question and answer model to perform question and answer; and through interaction between the API and the RAG question and answer model, knowledge retrieval and answer generation are completed, and answers of repeated questions are cached by using a Redis database.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of natural language processing, and mainly relates to a smart system based on pollution monitoring and knowledge question answering. BACKGROUND

[0002] With the acceleration of urbanization, NO2 pollution monitoring and management is facing challenges such as data integration difficulties, relatively lagging early warning, and insufficient public participation. Although existing research has made some progress in the construction of pollution prediction models and intelligent question answering systems, there is still a lack of comprehensive platforms that integrate forecasting and early warning, knowledge services, and decision support in environmental management practices.

[0003] At the same time, large language models have made progress in the application of professional knowledge question answering, but they still face the problem of lagging knowledge timeliness and "illusion". Traditional generative models rely on parameterized knowledge bases, making it difficult to dynamically update professional information and easily generate answers that do not match the facts or lack scientific basis, restricting their practicality in vertical fields such as environmental science. SUMMARY

[0004] The present application focuses on the intelligent needs of NO2 pollution control and proposes a NO2 knowledge question answering system based on the RAG framework, combining multiple technical collaboration methods to improve the professionalism of NO2 field question answering and provide technical support for the knowledge service function of the smart environmental protection system. To overcome the limitations of single technology application and promote the engineering transformation of scientific research achievements, the present application further integrates the research results of the CEEMDAN-Informer prediction model and the RAG question answering system to build a smart environmental protection system with a modular architecture. The system integrates air quality dynamic monitoring, NO2 concentration real-time early warning, and professional knowledge intelligent question answering through multi-source data fusion and multidisciplinary technical collaboration, and specific functions include:

[0005] The NO2 concentration prediction module introduces the Quartz task scheduling framework for automatic scheduling and job execution; calls the getNO2HistoricalData() method to obtain historical NO2 concentration data, uses the ONNX Runtime inference engine to call the CEEMDAN-Informer prediction model trained based on PyTorch to predict the historical NO2 concentration data; after the prediction is completed, the savePredictedNO2Data() method of the Mapper layer is called to store the predicted value to the MySQL database;

[0006] The NO2 knowledge intelligent question answering module adopts Vue.js to build a user interface, provides a question and answer input box and a result display box, adopts Spring Boot to create a RESTful API interface to receive front-end requests, calls an RAG question answering model to answer questions, interacts with the RAG question answering model through an API, completes knowledge retrieval and answer generation, and uses a Redis database to cache answers to repeated questions.

[0007] Further, the Quartz task scheduling framework is introduced for automatic scheduling and execution of jobs, and the specific steps include:

[0008] Environment configuration: introduce Quartz dependency in the Maven project of Spring Boot;

[0009] Creating a job class: creating a NO2PredictionJob class, calling a corresponding service class NO2PredictionService in the execute() method to execute NO2 concentration prediction;

[0010] Configuring the scheduler: in the configuration class, creating a Scheduler instance.

[0011] Further, the configuration of the scheduler further includes:

[0012] Defining job details, including the name, description of the job and the reference of the job class; creating an instance no2JobDetail of the job details and binding it with the NO2PredictionJob class;

[0013] Creating a CronTrigger trigger instance no2JobTrigger and using a Cron expression to define a job execution plan; passing the no2JobDetail instance and the no2JobTrigger instance as parameters into the Scheduler to execute the prediction task.

[0014] Further, the ONNX Runtime inference engine is used to call the CEEMDAN-Informer prediction model based on PyTorch training to predict the historical concentration data, the model is exported to ONNX format and then used in the Java environment for inference using the ONNX Runtime, and the specific steps include:

[0015] Exporting the trained PyTorch model to ONNX format;

[0016] In the configuration file, add Maven dependency of ONNX Runtime;

[0017] A service class is created in Java to load the model and perform inference, including: creating an environment for ONNX Runtime using OrtEnvironment; loading an ONNX model session using OrtSession; creating an input tensor using OrtTensor, and passing the tensor to the model;

[0018] Integrate the model service into the Spring Boot controller to provide efficient NO2 prediction functions through the REST API.

[0019] Further, the RAG question and answer model is trained based on the RAG framework, and the training process is as follows:

[0020] Import the SentenceTransformer class from the sentence_transformers library to map natural language sentences to vectors; create an instance of the SentenceTransformer class, use the pre-trained model moka-ai / m3e-base to generate sentence embeddings, encode the input sentence to get a high-dimensional vector representation, and the encoding process formula is: e i =Encoder(s i ),e i ∈R 768 , where s i represents the i-th sentence, Encoder represents the model encoding function, and R 768 represents that the vector belongs to 768 dimensions; the high-dimensional vector is retrieved through the IndexIVFFlat index in the constructed Faiss vector database; when the system successfully retrieves the relevant index from the vector database, the retrieval result is embedded into the prompt template and injected into the large language model to obtain the result of the large language model answer.

[0021] Further, the retrieval is performed through the IndexIVFFlat index, which adopts a cross-aggregation double-encoding mechanism to capture deep semantic associations, reorders the text, finds the most relevant text, and improves the quality of the retrieval result.

[0022] Further, the high-dimensional vector is also used for visual display, specifically including: introducing the t-SNE algorithm to embed the high-dimensional vector into two-dimensional space, and using cosine similarity to measure similarity, and displaying the similarity and clustering of data points through a scatter plot.

[0023] Further, the RAG question and answer model uses four indicators to evaluate the performance of the model, specifically including: fidelity, answer relevance, context relevance, and context recall rate.

[0024] Further, the answer to the repeated problem of the Redis database cache is used, when the problem appears repeatedly, the Redis database is directly queried, and the specific steps include: calling the redisTemplate.opsForValue().get() method to query the cache, if the cache is hit, the cache result is directly returned, and repeated retrieval and generation operations are avoided; when the cache is not hit, the RESTful API interface is called, and the problem is transferred to the NO2 knowledge intelligent question and answer module.

[0025] According to a second aspect of the present application, a computer program product is provided, which stores one or more computer programs thereon, the one or more computer programs being executed by a computer processor to implement the above method.

[0026] The one or more technical solutions in the embodiments of the present application have at least one of the following technical effects:

[0027] The present application is based on two core modules, the NO2 forecasting and warning module combines the Quartz task scheduling framework and the ONNXRuntime inference engine to realize the automatic deployment and efficient inference of the prediction model; the knowledge question and answer module optimizes the large model through the RAG framework, which significantly improves the accuracy and timeliness of professional field question and answer. The system provides scientific decision support for environmental management departments through multi-source data visualization display, dynamic warning push and intelligent knowledge service, and promotes public participation in environmental governance. The present application verifies the application potential of multi-technology integration in the field of environmental protection, provides a theoretical basis and practical example for the engineering of intelligent environmental protection technology, and promotes the development of environmental governance towards intelligence and precision. BRIEF DESCRIPTION OF DRAWINGS

[0028] The accompanying drawings are included to provide a further understanding of embodiments and are incorporated in and constitute a part of this specification. The drawings illustrate embodiments and, together with the description, serve to explain the principles of the present application. Other embodiments and many of the intended advantages of the present application will be readily appreciated as the same becomes better understood by reference to the following detailed description when considered in connection with the accompanying drawings. The elements of the drawings are not necessarily to scale relative to each other. Like reference numerals designate corresponding similar parts.

[0029] Figure 1 A schematic diagram of a smart system framework based on NO2 pollution monitoring and knowledge question and answer according to an embodiment of the present application is shown.

[0030] Figure 2 A schematic diagram of NO2 concentration prediction result visualization interface according to an embodiment of the present application is shown.

[0031] Figure 3 A schematic diagram of RAG question and answer model flow according to an embodiment of the present application is shown

[0032] Figure 4 A RAGAs evaluation parameter flowchart according to an embodiment of the present application is shown.

[0033] Figure 5 A Redis cache flowchart according to an embodiment of the present application is shown.

[0034] Figure 6 A real-time detection station rolling window interface diagram according to an embodiment of the present application is shown.

[0035] Figure 7 A platform early warning pop-up window interface diagram according to an embodiment of the present application is shown.

[0036] Figure 8 is a structural diagram of a computer system of an electronic device suitable for implementing embodiments of the present application. DETAILED DESCRIPTION

[0037] The present application will be further described below in conjunction with the drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related application, and not to limit the application. In addition, it should be noted that, for the sake of description, only the parts related to the application are shown in the drawings.

[0038] It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict. The present application will be described in detail below with reference to the drawings and in conjunction with the embodiments.

[0039] Figure 1 A smart system framework diagram based on NO2 pollution monitoring and knowledge Q&A according to an embodiment of the present application is shown, as shown in Figure 1

[0040] Core module 1: NO2 concentration prediction module, introduce Quartz task scheduling framework for automatic scheduling and execution of jobs; call getNO2HistoricalData() method to obtain historical NO2 concentration data, use ONNX Runtime inference engine to call CEEMDAN-Informer prediction model based on PyTorch training to predict the historical NO2 concentration data; after the prediction is completed, call the savePredictedNO2Data() method of the Mapper layer to store the predicted value to the MySQL database;

[0041] ​In view of the problem of low efficiency of artificial timing execution of the NO2 concentration prediction task, the NO2 concentration prediction module of the system introduces a Quartz task scheduling framework to realize the automatic operation of the prediction program. Quartz is an open source job scheduling library that can flexibly schedule and execute jobs (Job). The job is a Java class that implements the Job interface, and the execution time, frequency and trigger conditions of the job can be customized according to the requirements. The specific implementation steps are as follows:

[0042] Environment configuration: introduce Quartz related dependencies in the Maven project of Spring Boot.

[0043] Create a job class: implement the Job interface, create a class named NO2PredictionJob, and call the corresponding service class NO2PredictionService in the execute() method to execute the NO2 concentration prediction.

[0044] Configure the scheduler: in the configuration class, create a Scheduler instance, and the specific configuration process is as follows:

[0045] Define job details: JobDetail contains detailed information of the job, including the name, description and reference of the job class of the job.

[0046] Create an instance of JobDetail named no2JobDetail, and bind it to the NO2PredictionJob class.

[0047] Create a trigger: trigger (Trigger) is used to define the execution time and frequency of the job. Create a CronTrigger instance named no2JobTrigger, and use the Cron expression to define the job execution plan, and pass no2JobDetail and no2JobTrigger as parameters into Scheduler to execute the prediction task.

[0048] NO2PredictServiceImpl is the implementation class of the NO2 prediction module in the Service layer interface, and the predictionNO2() method is used to realize the NO2 prediction. In the method, the getNO2HistoricalData() method is first called to obtain the historical NO2 concentration data, and then the corresponding prediction model is called for prediction.

[0049] The present application adopts the ONNX Runtime inference engine to call the CEEMDAN-Informer prediction model trained based on PyTorch, and the overall architecture of the model is as follows:

[0050] The original time series data X(t) is decomposed into several intrinsic mode functions (IMFs) and a residual term R(t):

[0051]

[0052] Each IMF component has stronger stability and predictability;

[0053] An independent Informer model is trained for each IMF component and residual term for prediction;

[0054] The final prediction result is the sum of the prediction values of each component.

[0055] The model training process specifically includes: collecting original data for standardization and normalization; a training set is constructed for each IMF sequence and an independent Informer model is trained, using MSE or MAE as the loss function and Adam as the optimizer; the model is converted to ONNX format using PyTorch's torch.onnx.ecport, and the conversion is performed once for each IMF model; ONNX Runtime loads each model for inference and summarizes the prediction results of all components; the sum of the summarized results is the prediction result of the original data. In some optional embodiments, high-frequency noise IMF can be discarded to reduce computational overhead, multiple IMFs use parameter-shared Informer models to save memory, and asynchronous ONNXRuntime is used to speed up multiple model inferences.

[0056] ONNX (Open Neural Network Exchange) is an open standardized format compatible with multiple deep learning frameworks such as PyTorch. ONNXRuntime is a high-performance inference engine designed specifically for executing ONNX format models. After exporting the model to ONNX format, inference can be performed in the Java environment using ONNXRuntime, which not only improves the portability of the model, but also ensures the performance and stability in actual application. The specific implementation steps are as follows:

[0057] Model format conversion: export the trained PyTorch model to ONNX format;

[0058] Environment configuration: add Maven dependencies of ONNX Runtime in the configuration file;

[0059] A service class is created in Java to load the model and perform inference, including: creating an environment for ONNX Runtime using OrtEnvironment; loading an ONNX model session using OrtSession; creating an input tensor using OrtTensor, and passing the tensor to the model;

[0060] Service integration: integrate the model service into the Spring Boot controller, and provide efficient NO2 prediction function through REST API.

[0061] After the prediction is completed, the savePredictedNO2Data() method of the Mapper layer is called to store the predicted value in the MySQL database, facilitating subsequent inquiry and analysis. The NO2 concentration prediction interface displays the prediction results in the form of intuitive charts, providing users with clear information about the changes in NO2 concentration, as shown in Figure 2

[0062] Core module 2: NO2 knowledge intelligent question and answer module, using Vue.js to build the user interface, providing a question and answer input box and a result display box; using the Controller layer of Spring Boot to create the NO2KnowledgeController class, creating RESTful API interfaces to receive front-end requests, and calling the RAG question and answer model for question and answer; interacting with the RAG question and answer model through API to complete knowledge retrieval and answer generation, and using Redis database to cache the answers to repeated questions.

[0063] The front-end module is developed based on the Vue 3 framework, and the user interface is built by integrating the Element Plus component library to ensure friendly interaction and response speed. During front-end development, Vue Router is used to manage routing states, and Pinia is used instead of traditional Vuex for state management to simplify data flow control. At the same time, Axios is used to realize asynchronous communication between the front-end and back-end, and RESTful API specifications are followed for interface design to ensure the efficiency and consistency of data transmission. In terms of project construction, Node.js is selected as the running environment, npm is used for package management, and the Vue CLI scaffolding tool is used to initialize the front-end project;

[0064] ​The backend service is built based on the Java language, adopts a hierarchical architecture design realized by a Spring Boot 3 framework, and a technical system includes Mybatis, Maven, Redis, Nginx, and components such as Git and Swagger. Spring Boot is a sub-project of the Spring framework, realizes IoC container management through an automatic assembly mechanism, completes the dependency injection of Bean objects according to the principle of convention over configuration, and effectively improves the system initialization efficiency. The hierarchical architecture of Spring Boot realizes the decoupling of business logic, makes the application program structure clear and the responsibilities distinct, is beneficial to development, testing and maintenance, and also promotes code reuse and modular design.

[0065] The RAG question and answer model is trained based on the RAG framework for the question and answer model, including data extraction, text segmentation, vectorization and data warehousing, etc., as shown in Figure 3 .

[0066] Compared with the traditional method, vector retrieval has significant advantages in semantic understanding, complex query processing and result relevance. It adopts a similarity calculation method based on deep semantic representation, which can effectively improve the retrieval accuracy and personalized service level, so the invention selects vector retrieval as the core method.

[0067] Text vectorization is a key link of the retrieval system, which directly affects the quality of semantic representation. Therefore, the invention adopts the M3E-base open source text embedding model, which is specially optimized for Chinese and multilingual scenarios and performs well in Chinese semantic retrieval and question and answer tasks. The M3E-base model has a small size and fast inference speed, and is suitable for local deployment in resource-limited environments. The specific implementation process is as follows:

[0068] First, the SentenceTransformer class is imported from the sentence transformers library, which is used to process sentence embedding and can map natural language sentences to vectors, and then realize similarity measurement and other functions. Next, an instance of SentenceTransformer is created, and a pre-trained model "moka-ai / m3e-base" is used to generate sentence embedding to encode the input sentence to obtain a high-dimensional vector representation. The encoding process formula is: e i =Encoder(s i ),e i ∈R 768 , where s i represents the i-th sentence, Encoder represents the model encoding function, and R 768 represents that the vector belongs to 768 dimensions.

[0069] Subsequently, the encode method of the model instance is called to vectorize each sentence in the sentences list and convert it into a vector embedding with a dimension of 768. In the generated embeddings array, each element corresponds to the vector representation of a sentence in the input sentence list, and these vectors will be used for subsequent similarity calculations.

[0070] Since the NO2 knowledge base needs to process large-scale vector data, Faiss is based on optimized memory data structures and efficient algorithms, with real-time retrieval capability for billion-level vector data. Secondly, its rich index types, including Flat, IVF, PQ, etc., support flexible configuration of retrieval strategies. With a hierarchical architecture design, it supports distributed deployment and horizontal expansion. Finally, the localization deployment mode meets the requirements of the project for data security and cost control. Therefore, after considering the specific needs of the project, the expected data size, and the actual use scenarios, etc., the application chooses to store data in the RAG vector database constructed by Faiss and build an index to realize the performance optimization and stable operation of the knowledge base system.

[0071] In the process of building a retrieval system and making full use of context information, vector retrieval is crucial. For the RAG pipeline, the search index is a key part of storing vectorized content. If brute force search is used to calculate the Euclidean distance (L2) between the query vector and all block vectors, it will face high computational complexity and large memory occupation. Brute force search needs to calculate the distance between the query vector and all database vectors, and then return the top K vectors with the highest similarity. The time complexity is O(n), where n is the number of block vectors. When the data volume is large, this method will cause a significant decrease in performance, because storing all block vectors in high-dimensional space will occupy a large amount of memory, which may cause memory overflow or system crash, and as the data set increases, the time and resources required for calculation will increase sharply, making it difficult to meet the real-time response requirements. Therefore, the application selects IndexIVFFlat vector index at the search index link to realize efficient retrieval for large-scale data sets.

[0072] When the user inputs the query information, the system first processes the query text through the M3E-base encoder to convert it into the corresponding query embedding F(q). The M3E-base encoder can accurately extract features based on the query content and generate a high-dimensional vector representation closely related to the context, so as to facilitate subsequent retrieval. Then, the system uses the generated F(q) to search in the Faiss vector database that has been constructed through the IndexIVFFlat index.

[0073] By capturing deep semantic association through cross-aggregation double encoding mechanism, the text is reordered to find the most relevant text, effectively improving the quality of search results and making large models produce higher quality answers. Among them, the cross-aggregation double encoding mechanism specifically includes: using M3E-base encoder to encode the key and text, obtaining global sentence vector and token level vector sequence, the global sentence vector is used for preliminary vector recall, and the token level vector sequence is used for interaction and aggregation; Then, use cross attention mechanism to model bidirectional attention of key and each text token level, get deeper context dependent representation:

[0074] Att(Q,D)=softmax(QW1D T )·D

[0075] Att(D,Q)=softmax(DW2Q T )·Q

[0076] Wherein, Q represents the token representation sequence of the key, the dimension is L q ×d, L q represents the number of tokens, d represents the hidden vector dimension, i.e. 768; D represents the token representation sequence of the text, the dimension is L q ×d, W1 and W2 represent different learnable linear transformation matrices respectively, used to adjust the similarity calculation space, softmax represents the activation function, and Att represents the result representation after weighted attention. Bidirectional attention means that the key focuses on the text, and the text also focuses on the key, forming a symmetric interaction information flow.

[0077] Further, the cross matrix M ij =cos(q i ,d j ) is constructed, wherein q i represents the vector representation of the i-th token in the key, the dimension is d, d j represents the j-th token vector representation in the text, the dimension is d, cos represents the cosine similarity, and M ij represents the matching strength at position (i,j), which constitutes an L q ×L d similarity matrix;

[0078] In the similarity measurement link, cosine similarity is selected, which focuses on evaluating the directional similarity of two vectors, and the modulus of the vector has no interference on the result. The cosine similarity of two vectors A(x 11 ,x 12 ,...,x 1n ) and B(x 21 ,x 22 ,...,x2n )Cosine similarity calculation, the calculation process is as follows:

[0079]

[0080] Where θ represents the angle between vectors A and B, |a| and |b| represent the length of the two vectors, respectively, the cosine similarity value range is [-1, 1], when the direction of two vectors coincide, the cosine takes the maximum value 1, indicating that the two vectors are completely the same, close to 1 indicates that the two vectors have high similarity; two vectors are orthogonal, the cosine value is 0, that is, there is no correlation; when the direction of two vectors is completely opposite, the cosine takes the minimum value -1.

[0081] Further, using Gaussian function for similarity soft matching scoring: Where K(c) represents the response value of the kth Gaussian function to the similarity value c, μ k represents the center value of the kth function, σ k represents the width, controls the fuzziness of the response, and c represents the input similarity.

[0082] When the system successfully retrieves the relevant index from the vector database, it embeds these retrieval results into the prompt template and injects them into the large language model. The large model can more accurately grasp the user's query intent and give accurate and detailed responses combined with the associated knowledge reserve. Through this prompt enhancement framework, the retrieved knowledge can effectively guide the system, improve the quality of model output, and reduce the probability of generating irrelevant or inaccurate content when the model lacks context information support, thereby alleviating the illusion problem faced by the current large model to some extent. At the same time, the prompt words also provide standardized format guidance for the output results, ensuring that the large model's final generated response can meet user needs and improve the system's answer quality.

[0083] Further, the t-SNE (t-Distributed Stochastic Neighbor Embedding) algorithm is introduced to reduce the dimensionality of high-dimensional sentences to two-dimensional space for visualization. In this process, the TSNE class is imported from the Scikit-learn library, which is an important tool set in the field of Python machine learning, providing a variety of algorithms and tools, including dimensionality reduction technology modules.

[0084] When creating an instance of t-SNE, the parameter n_components=2 is specified, which indicates that the high-dimensional data will be reduced to a two-dimensional space, ensuring that the t-SNE algorithm outputs a two-dimensional embedding result suitable for visualization. Perplexity is a hyperparameter of t-SNE that has a significant impact on the performance of the algorithm. This parameter controls the local neighborhood, and its value is usually between 5 and 50, with smaller values making the algorithm pay more attention to local structure. Through grid search verification, setting perplexity=5 optimizes the contour coefficient, effectively preserving the local structure.

[0085] Finally, the fit_transform method is called to perform dimensionality reduction on the high-dimensional embeddings data. This method first fits the model and then returns the two-dimensional data after dimensionality reduction, storing the result in the embeddings_2d array. Each row in this two-dimensional array corresponds to a sentence in the original embedding, and each column represents the two-dimensional coordinate after dimensionality reduction.

[0086] After reducing the high-dimensional sentence embeddings to a two-dimensional space, the similarity and clustering between data points are displayed in the form of a scatter plot. Specifically, t-SNE can effectively preserve the local structure between data points, making similar sentence embeddings close in the two-dimensional space, while dissimilar sentence embeddings are relatively far apart.

[0087] Further, four core evaluation indicators of the RAGAs framework are selected to comprehensively evaluate the performance of the model, such as Figure 4 as shown below:

[0088] 1) Faithfulness: Measures the consistency of the answer with the facts retrieved from the context by RAG. If all the claims in the answer can be inferred from the given context, the generated answer is considered faithful. To calculate this, first identify a set of claims from the generated answer. Then, cross-check each of these claims with the given contexts to determine whether it can be inferred from the given contexts, with the formula:

[0089]

[0090] 2) Answer Relevancy: Evaluates the fit of the answer to the question. To estimate the relevance of the answer, for a given answer a(q), prompt the large model to generate n potential questions q i from the answer a(q). Then, for each q i , determine the similarity sim(q,q i). The formula for calculating the answer relevance score of question q is:

[0091]

[0092] 3) Context Relevancy: This measures the relevance of the question to the retrieved context. The relevance of the context to the question depends on whether it contains only the information needed to answer the question. Ideally, the retrieved context should only contain information that answers the question. To estimate the relevance of the context, given a question q and its context c(q), a large model is used to extract a subset S of sentences from c(q) that are crucial to answering q. ext , the calculation formula of context relevance score is:

[0093]

[0094] 4) Context Recall: This measures the degree of consistency between the retrieved context and the true answer provided by humans. To estimate context recall based on factual conclusions, each sentence of the factual conclusion needs to be analyzed to determine whether it can be attributed to the retrieved context. Ideally, all sentences in the true answer should be attributed to the retrieved context. The calculation formula is as follows:

[0095]

[0096] In summary, this system's question-answering model effectively addresses the knowledge lag and hallucination problems of traditional large models in specialized fields through the fusion of multiple technologies. First, it integrates authoritative data from multiple sources to build a high-quality knowledge base, encompassing academic literature, policy documents, and monitoring reports. It then vectorizes text using text segmentation and M3E-base semantic embedding technology, constructing an efficient vector database based on Faiss to support high-precision semantic retrieval. Second, it designs a two-stage retrieval optimization strategy, utilizing a text reranking mechanism to improve the relevance of search results. It also uses prompt word engineering to guide the large model in generating professional answers, achieving knowledge infusion and enhanced reasoning. Experimental evaluation demonstrates that the system performs well in metrics such as fidelity, answer relevance, factual accuracy, and contextual recall within the RAGAs framework, validating the effectiveness of the RAG technology. Furthermore, semantic embedding dimensionality reduction and topic clustering visualization analysis demonstrate that the system can accurately distinguish different semantic topics, further supporting the rationality of the vector representation.

[0097] According to another module of this system: data storage module. The storage architecture of this system builds a multimodal data storage system through the coordinated optimization of relational databases, vector databases and in-memory databases, and optimizes system performance through hierarchical management of structured and unstructured data. MySQL 8.0 relational database is selected to store structured monitoring data, including NO2 concentration time series, meteorological parameters and user information. Through B+ tree index optimization and ACID transaction management mechanism, data integrity and query efficiency are guaranteed, and a composite index strategy is established for high-frequency access scenarios to improve data access speed. For the unstructured text data of the knowledge base, a NO2 knowledge vector database is built based on Faiss, combined with technologies such as the M3E-base semantic embedding model to achieve efficient similarity retrieval and improve retrieval accuracy.

[0098] Cache, as a high-speed buffer for data exchange, is a key component for improving system performance. Redis, a memory-based key-value store NoSQL database, is widely used in scenarios such as caching and session management due to its excellent performance, rich functional features, and ease of use. It is one of the core components for building high-performance, scalable systems. To cope with high concurrent access pressure, the system uses Redis to build a three-level cache system:

[0099] 1) Hotspot data cache

[0100] Redis is deployed as an independent cache layer between the Web server and the database, storing hot data persistently in memory to significantly reduce the frequency of database access and improve data retrieval efficiency. When a user initiates a data request, the system first accesses the Redis cache layer. If it misses, it goes through to the MySQL database for query, and the query results are then loaded into the cache. The cache process is as follows: Figure 5 shown.

[0101] 2) Session State Cache

[0102] In the distributed deployment of web applications, traditional session management, which stores user session information in server memory, is prone to session synchronization issues, impacting system scalability and consistency. A distributed session management solution based on Redis effectively addresses this challenge. Specifically, after a user successfully logs in to the system, the server persistently stores the user's session information, including user ID, login status, and permission identifiers, in a Redis cluster. During subsequent request processing, each service node can quickly access the session data in Redis through a unified interface, eliminating the need for complex session synchronization operations. This ensures data consistency and improves system performance.

[0103] 3) Model inference cache

[0104] For the problem of repeated queries, an answer cache pool is established. If there is a cache, the answer is returned directly to reduce the frequency of large model calls and shorten the corresponding time. Model inference caching not only improves system performance but also provides stability in high-concurrency scenarios, making it a core optimization module for intelligent systems.

[0105] Further, according to the national standard, the 24-hour average concentration limit of NO2 must be used in daily reports, i.e., the daily average concentration limit of NO2 is 80 μg / m 3 . Based on this threshold, combined with real-time monitoring and prediction data, a dynamic early warning mechanism is constructed. As shown in Figure 6 , the site monitoring data interface displays the NO2 concentration values of each monitoring site in real time, providing real-time data support for early warning.

[0106] When the predictionNO2() method of the NO2PredictService class completes the prediction of the NO2 concentration value at the next time, if the predicted value exceeds the threshold (80 μg / m 3 ), the early warning mechanism is triggered, and the prediction result and coping strategy are pushed to the user end in real time. After the early warning is triggered, the platform synchronously alarms in the following two ways:

[0107] 1) Front-end pop-up window: dynamically display early warning information and suggested measures in the visualization big screen, as shown in Figure 7 ;

[0108] 2) SMS push: The system integrates Aliyun SMS to realize the function of sending early warning SMS. First, import the Java SDK of Aliyun SMS in the pom.xml configuration file of the project. Create a new class called SmsService in the Spring Boot service layer, and define the sendSms method in this class. This method receives information such as mobile phone number, SMS signature, SMS template code, and SMS template parameters. The SMS template contains concentration value, early warning information, and protection suggestions. Inside the sendSms method, obtain the Access KeyID and Access KeySecret obtained in the Aliyun console, and then call the AliyunSmsUtil.sendSms() method to send early warning SMS to registered users to ensure that early warning information can be timely conveyed to users.

[0109] In summary, the system realizes the monitoring of NO2 in a prediction model-question and answer system-platform integrated manner: historical NO2 concentration data is collected to construct a standardized dataset, in the construction of the knowledge question and answer module, text segmentation, M3E-base semantic embedding, Faiss vector retrieval and text reordering technologies are integrated based on the RAG framework, and the answer of the DeepSeek large model is optimized combined with the prompt word engineering to alleviate the knowledge "illusion" problem. Finally, through the collaborative development of Spring Boot and Vue, the NO2 forecasting and warning and knowledge question and answer functions are integrated, Nginx and Redis are integrated, and the smart environmental protection platform is constructed.

[0110] Reference is made below in conjunction with Figure 8 which shows a structural schematic diagram of a computer system 800 suitable for implementing the electronic device of the embodiments of the present application. Figure 8 The electronic device shown is merely an example and should not impose any limitation on the functions and use range of the embodiments of the present application.

[0111] As shown in Figure 8 , the computer system 800 includes a central processing unit (CPU) 801 which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 802 or programs loaded from a storage portion 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the system 800 are also stored. The CPU 801, the ROM 802 and the RAM 803 are connected to each other through a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0112] The following components are connected to the I / O interface 805: an input portion 806 including a keyboard, a mouse, etc.; an output portion 807 including a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 808 including a hard disk, etc.; and a communication portion 809 including a network interface card such as a LAN card, a modem, etc. The communication portion 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as necessary. A removable medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is mounted on the drive 810 as necessary, so that a computer program read therefrom is installed in the storage portion 808 as necessary.

[0113] In particular, the processes described above with reference to the flow charts can be implemented as a computer software program according to embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a computer readable storage medium, the computer program comprising program code for performing the methods illustrated by the flow charts. In such embodiments, the computer program can be downloaded and installed from a network via the communication section 809, and / or installed from the removable media 811. When the computer program is executed by the central processing unit (CPU) 801, the above-described functions defined in the methods of the present application are performed. It should be noted that the computer readable storage medium of the present application can be a computer readable signal medium or a computer readable storage medium or any combination of the two. The computer readable storage medium may, for example, be - but is not limited to - an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any suitable combination of the above. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, the computer readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus or device. In the present application, the computer readable signal medium can include a data signal carried in a baseband or as part of a carrier wave, in which the computer readable program code is carried. Such a propagated data signal can take any of a variety of forms, including but not limited to electro-magnetic, optical, or any suitable combination thereof. The computer readable signal medium can also be any computer readable storage medium that can be used for by or in connection with an instruction execution system, apparatus or device, and that can contain or store a program for use by or in connection with an instruction execution system, apparatus or device. The program code contained on the computer readable storage medium can be transmitted by any suitable medium, including but not limited to wireless, wire line, optical fiber cable, RF, etc., or any suitable combination of the above.

[0114] Computer program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Python, C++, or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).

[0115] The computer program instructions can also be loaded onto a computer or other programmable information processing apparatus to cause a series of operations to be performed on the computer or other programmable information processing apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable information processing apparatus implement the functions / acts specified in the flowchart and / or block diagram block or blocks.

[0116] The modules involved in the embodiments of the present application can be implemented in the form of software or hardware.

[0117] As another aspect, the present application also provides a computer readable storage medium, which can be included in the electronic device described in the above embodiments, or can exist independently without being assembled into the electronic device. The computer readable storage medium carries one or more programs, when the one or more programs are executed by the electronic device, the electronic device is caused to: a concentration prediction module, introduced into a Quartz task scheduling framework to automatically schedule and execute jobs; call a getNO2HistoricalData() method to obtain historical concentration data, use an ONNXRuntime inference engine to call a CEEMDAN-Informer prediction model trained based on PyTorch to predict the historical concentration data; after the prediction is completed, call a savePredictedNO2Data() method of a Mapper layer to store the predicted value to a MySQL database; a knowledge intelligent question and answer module, uses Vue.js to build a user interface, provides a question and answer input box and a result display box; uses Spring Boot to create a RESTful API interface to receive a front-end request, calls a RAG question and answer model to answer questions; interacts with the RAG question and answer model through an API, completes knowledge retrieval and answer generation, and uses a Redis database to cache answers to repeated questions.

[0118] The above description is merely the preferred embodiments of the present application and the explanation of the principles of the applied technology. It should be understood by those skilled in the art that the scope of the application involved in the present application is not limited to the technical solutions formed by the specific combinations of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above inventive concept. For example, the above features can be replaced with the technical features disclosed in the present application (but not limited to) having similar functions to form technical solutions.

Claims

1. An intelligent system based on NO2 pollution monitoring and knowledge question answering, characterized by: include: The NO2 concentration prediction module introduces the Quartz task scheduling framework for automated scheduling and job execution. The getNO2HistoricalData() method is called to obtain historical NO2 concentration data. The CEEMDAN-Informer prediction model trained on PyTorch is used with the ONNX Runtime inference engine to predict the historical NO2 concentration data. After the prediction is complete, the savePredictedNO2Data() method of the Mapper layer is called to store the predicted value in a MySQL database. The NO2 knowledge intelligent question-and-answer module uses Vue.js to build the user interface, providing a question-and-answer input box and a result display box; it uses Spring Boot to create a RESTful API interface to receive front-end requests and call the RAG question-and-answer model for question-and-answer; it interacts with the RAG question-and-answer model through the API to complete knowledge retrieval and answer generation, and uses the Redis database to cache answers to repeated questions.

2. The smart system according to claim 1, characterized in that: The introduction of the Quartz task scheduling framework for automatic scheduling and job execution includes the following specific steps: Environment configuration: Introduce Quartz dependencies into Spring Boot's Maven project; Create a job class: Create the NO2PredictionJob class and call the corresponding service class NO2PredictionService in the execute() method to perform NO2 concentration prediction; Configure the scheduler: In the configuration class, create a Scheduler instance.

3. The smart system according to claim 2, characterized in that: The specific configuration of the configuration scheduler also includes: Define the job details, including the job name, description, and reference to the job class; create an instance of the job details no2JobDetail and bind it to the NO2PredictionJob class; Create a CronTrigger trigger instance no2JobTrigger and use a Cron expression to define the job execution plan. Pass the no2JobDetail instance and no2JobTrigger instance as parameters to the Scheduler to execute the prediction task.

4. The smart system according to claim 1, wherein: The ONNX Runtime inference engine is used to call the CEEMDAN-Informer prediction model obtained by training based on PyTorch to predict the historical concentration data. After exporting the model to ONNX format, the ONNX Runtime is used in the Java environment for inference. The specific steps include: Export the trained PyTorch model to ONNX format; In the configuration file, add the Maven dependency of ONNX Runtime; Create a service class in Java to load the model and perform inference, including: using OrtEnvironment to create the ONNX Runtime environment; using OrtSession to load the ONNX model session; using OrtTensor to create input tensors and pass them to the model; Integrate the model service into the Spring Boot controller and provide efficient NO2 prediction capabilities through the REST API.

5. The smart system according to claim 1, characterized in that: The RAG question answering model is trained based on the RAG framework. The training process is as follows: Import the SentenceTransformer class from the sentence_transformers library to map natural language sentences into vectors; create an instance of the SentenceTransformer class, use the pre-trained model moka-ai / m3e-base to generate sentence embeddings, and encode the input sentence to obtain a high-dimensional vector representation. The encoding process formula is: i =Encoder(s i ),e i ∈R 768 , where s i Represents the i-th sentence, Encoder represents the model encoding function, R 768 The representation vector belongs to 768 dimensions; the high-dimensional vector is retrieved in the constructed Faiss vector database using the IndexIVFFlat index; when the system successfully retrieves the relevant index from the vector database, the retrieval result is embedded in the prompt template and injected into the large language model to obtain the result of the large language model answer.

6. The smart system according to claim 5, characterized in that: The retrieval is performed through the IndexIVFFlat index, in which a cross-aggregation dual encoding mechanism is used to capture deep semantic associations, re-sort the texts, find the most relevant texts, and improve the quality of the retrieval results.

7. The smart system according to claim 5, characterized in that: The high-dimensional vectors are also used for visualization, specifically including: introducing the t-SNE algorithm to embed the high-dimensional vectors into a two-dimensional space, and using cosine similarity to measure similarity, and displaying the similarity and clustering between data points in the form of a scatter plot.

8. The smart system according to claim 5, characterized in that: The RAG question answering model uses four indicators to evaluate the performance of the model, including: fidelity, answer relevance, context relevance and context recall.

9. The smart system according to claim 1, wherein: The Redis database is used to cache answers to repeated questions. When a question is asked repeatedly, the Redis database is directly queried. The specific steps include: calling the redisTemplate.opsForValue().get() method to query the cache. If the cache is hit, the cache result is directly returned to avoid repeated retrieval and generation operations; when the cache is not hit, the RESTfulAPI interface is called to transfer the question to the NO2 knowledge intelligent question and answer module.

10. A computer program product, characterized in that A computer program is stored thereon, and when the computer program is executed by a processor, the intelligent system according to any one of claims 1 to 9 is implemented.