Intelligent building operation and maintenance inquiry method and system based on knowledge enhancement big language model
By enhancing knowledge and fine-tuning of Text2SQL on large language models, and combining knowledge graphs, the problem of complex data and structural correlation in smart building operation and maintenance is solved, and efficient data retrieval and operation and maintenance analysis is achieved.
Patent Information
- Application Number
- CN202510076494.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-17
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2045-01-17
AI Technical Summary
The prior art has difficulties in dealing with the complex operation and maintenance data and building structure correlations of smart buildings, especially in converting user requirements into structured query language (SQL) statements and extracting implicit knowledge structures.
A large language model based on knowledge enhancement is adopted to fine-tune the model through a Text2SQL data set of mixed building operation and maintenance scenarios, and combine the knowledge graph to build an operation and maintenance knowledge graph for data retrieval and analysis.
It realizes automated data retrieval, reduces manual operations, improves the accuracy and efficiency of operation and maintenance information inquiries, and meets the complex needs of smart building operation and maintenance.
Smart Images

Figure CN120012927A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of smart building operation and maintenance, and specifically relates to a smart building operation and maintenance inquiry method and system based on a knowledge-enhanced large language model. Background Art
[0002] With the acceleration of global urbanization, smart buildings have gradually become an important part of urban construction, and the importance of smart building operations and maintenance (O&M) tasks has become increasingly prominent, with the aim of reducing building operating costs, improving energy efficiency, and enhancing the comfort of the living environment. However, with the increasing complexity of smart building structures and the amount of data generated, building operations and maintenance need to extract value from massive information through effective information query methods to support decision-making, and this process faces many challenges.
[0003] Existing methods propose to apply large language models (LLMs) to the field of architecture to meet the challenges brought by smart buildings. By fine-tuning LLMs to adapt to tasks in specific fields, LLMs can better learn professional terms related to building operation and maintenance and the context of common inquiries. However, even though LLMs have shown strong capabilities in processing text information in the field of architecture, in some current work, there are still significant deficiencies in LLMs' in-depth understanding of the correlation between complex operation and maintenance data and building structures. First, the collected sensor data are often stored in structured databases, and user requirements need to be converted into structured query language (SQL) statements, which brings certain obstacles to LLMs' retrieval of relevant operation and maintenance data, especially when it comes to complex query conditions, such as nested queries under multiple conditions. Second, LLMs themselves do not have the knowledge of the intrinsic correlation between the internal spatial structure of the actual building and the monitoring data. It is difficult to fully extract and utilize the implicit knowledge structure behind the data and accurately complete information query tasks by relying solely on LLMs, especially when the data rules and spatial structure of the actual building need to be included in the data retrieval. This process greatly increases the operational threshold of the operation and maintenance tasks. The development of knowledge graphs provides an important solution to these shortcomings. It mainly focuses on analyzing and processing a large amount of text information that is highly semantically relevant and can be strongly inferred. It can also effectively describe the complex relationships between the various parts or components of a building, which will make the understanding and processing of structural relationships in the O&M process more intuitive and efficient. However, in the current operation and maintenance scenarios, there is a lack of work related to the construction of knowledge graphs for massive data and complex spatial relationships. Summary of the invention
[0004] To solve the above problems, the present invention discloses a smart building operation and maintenance query method and system based on a knowledge-enhanced large language model, which uses the Text2SQL data set of hybrid building operation and maintenance scenarios to fine-tune the LLM to achieve automatic data retrieval; fully utilizes the advantages of integrated knowledge graphs to maximize the use of rich information resources such as building space structure, equipment and monitoring data, operation and maintenance related rules; and generates corresponding operation and maintenance analysis and suggestions based on user inquiries, which better meets the operation and maintenance needs in the context of smart buildings and greatly reduces manual operations in the operation and maintenance process.
[0005] To achieve the above object, the technical solution of the present invention is as follows:
[0006] A method for querying smart building operation and maintenance information based on a knowledge-enhanced large language model comprises the following steps:
[0007] Step (1) is to pre-process the massive sensor data used for operation and maintenance information inquiries in real smart buildings by screening outliers through unsupervised anomaly detection methods to improve its reliability as a basis for query responses. The pre-processed data is stored in the operation and maintenance database.
[0008] Step (2), construct a mixed fine-tuning dataset consisting of question-SQL pairs from operation and maintenance scenarios to train the LLM with QLoRA (quantized low-rank adaptation). QLoRA is a fine-tuning technique that introduces an additional low-rank adaptation matrix to expand the LLM function under the original model parameters, thereby obtaining the original O&M LLM with enhanced natural language conversion to SQL (text-to-SQL (Text2SQL)) capability in operation and maintenance query scenarios;
[0009] Step (3): Based on the structural information and operation and maintenance rules of the actual building, define entities and relationships in a triple-based manner to build an operation and maintenance knowledge graph. A small number of examples are built based on several classic scenarios of operation and maintenance information query. The examples and the knowledge graph serve as an external knowledge base.
[0010] Step (4): for the search of the knowledge graph, the building level information classification and corresponding priority are defined for the entities involved in the operation and maintenance inquiry, and a graph search algorithm based on the class priority of the building entity is designed to obtain the classes and triples related to the inquiry in the operation and maintenance knowledge graph; for the search of examples, the text vector matching method is used to select the top three examples with the highest relevance; finally, under the designed prompt template, the LLM is guided to convert the query-related classes, triples and examples into knowledge prompts in the form of continuous text;
[0011] Step (5), the knowledge-enhanced O&M LLM enhanced by knowledge prompts completes the search of the operation and maintenance database, and the returned relevant data will be used as context information together with the query. Finally, the knowledge-enhanced O&M LLM provides reasonable operation and maintenance analysis and suggestions for the user's query based on this context information.
[0012] As a further optimization scheme of the smart building operation and maintenance information query method based on the knowledge-enhanced large language model described in the present invention, step (1) includes the following steps:
[0013] (1-1) For the massive sensor data used for operation and maintenance information query in real smart buildings, unsupervised outlier detection is performed based on the isolation forest algorithm. The isolation forest algorithm uses the fact that abnormal data is "few and different" and isolates each instance by effectively building a tree structure. Outliers are often isolated after a few rounds, while normal values obviously require more and more complex cuts and splits. Therefore, when the random forests jointly produce shorter path lengths for certain specific points, these points are likely to be abnormal. The specific algorithm steps are as follows:
[0014] Step 111: Given n data samples X = {x1, ..., x n}, randomly select m features from the dataset, and split the data points by randomly selecting a value between the maximum and minimum values of the selected features. The partitioning is repeated recursively until all data samples are isolated, thereby constructing an isolation tree (iTree).
[0015] Step 112, calculate the isolation forest path length, which is defined by the following formula:
[0016] h(x)=e+c(T.size)
[0017] Among them, h(x) is the path length of a single data sample on iTree, e is the number of edges that the data sample x experiences from the root node to the leaf node of the tree, T.size represents the number of samples at the same leaf node as sample x, c(T.size) can be regarded as a correction value, which represents the average path length of T.size samples to construct a binary tree; the calculation formula of c(n) is as follows:
[0018]
[0019] Among them, H(i) is the harmonic number, which can be estimated by ln(i)+0.5772156649 (Euler constant). The purpose of this correction value is to make the difference between the path lengths of abnormal and normal samples larger;
[0020] Step 113: Calculate the anomaly score, which is defined by the following formula:
[0021]
[0022] Among them, W(h(x)) is the average value of the depth reached by a single data sample x in all iTrees. c(n) is used to normalize h(x) and map s to the range of (0, 1). The smaller the path length of the data sample, the closer s is to 1, and the greater the probability that the data sample is an outlier. When E(h(x)) is closer to the average path length c(n) of the node where a certain sample is located, the anomaly score s approaches 0.5. When E(h(x)) is closer to 0, that is, the smaller the path length of the data sample, the feature segmentation is completed at an earlier position, and the anomaly score s approaches 1, then the point is likely to be an outlier. On the contrary, if s is much smaller than 0.5, then the point is likely to be a normal value.
[0023] Step 114: Perform appropriate anomaly screening on all data samples on iTree by setting a threshold k, and treat data samples with anomaly scores s≥k as outliers and remove them.
[0024] As a further optimization scheme of the smart building operation and maintenance information query method based on the knowledge-enhanced large language model described in the present invention, step (2) includes the following steps:
[0025] (2-1) Based on the general Text2SQL dataset, we mixed the operation and maintenance information query-SQL pairs to build a hybrid fine-tuning dataset Each sample pair contains a query x (i) and the corresponding SQL statement y (i) ;
[0026] (2-2) The model is trained using the hybrid fine-tuning dataset. The training goal is to optimize the model parameters by minimizing the negative log-likelihood of the SQL response conditioned on the question, and obtain the original O&M LLM. Specifically, the training objective function is defined as follows:
[0027]
[0028] in, is the target output value of the i-th sample at time step t, which is used to compare with the output value of the model to guide the gradient descent process so that the model's prediction is closer to the actual target output.
[0029] At the same time, the training method is based on QLoRA technology; specifically, all parameters W of the basic model are locked during training, and after inputting the training data X, only the newly added network layer is adjusted; in the initial stage, the newly added weight W is initialized by Gaussian distributionA , and the weight W B It is set to a zero matrix, which means that in the early stage of training, the newly added path BA will not have any effect on the model output; in the inference stage, the following formula is used to update the original language model weights, so as to enhance and optimize the original weights:
[0030] h=WX+W A W B X=(W+W A W B )
[0031] As a further optimization scheme of the smart building operation and maintenance information query method based on the knowledge-enhanced large language model described in the present invention, step (3) includes the following steps:
[0032] (3-1) Based on the structural information and operation and maintenance rules of the actual building, a detailed description is given from the basic floor information to the division of various functional spaces within each floor, integrating the relationship between space and water and electricity energy consumption and environmental sensing equipment. At the same time, it covers the spatial location distribution of various sensors and the standard threshold setting of various monitoring data. The building information entities and relationships are constructed in the form of triples to obtain the operation and maintenance knowledge graph;
[0033] (3-2) A systematic statistical analysis of information inquiries that may occur in the operation and maintenance of smart buildings was conducted, and they were classified into four categories: data condition analysis, basic data query, data comparison and judgment, and advanced data analysis. A small number of inquiries in typical scenarios were designed for each type of inquiry, and the corresponding SQL query statements were given as reference examples.
[0034] As a further optimization scheme of the smart building operation and maintenance information query method based on the knowledge-enhanced large language model described in the present invention, step (4) includes the following steps:
[0035] (4-1) The search on the operation and maintenance knowledge graph is based on the class priority of the building entity. The specific process is as follows:
[0036] Step 411, based on the obvious type distinction and hierarchical subordination between the building entities involved in the query, define the building hierarchical information entity classification and its priority (Rank): Floor (Rank 1), Region (Rank 2), Electricity Comsuption Group (Rank 2), Energy Comsuption Datas (Rank 3), Environment Datas (Rank 3), Standard Rules (Rank 4); the priority level will provide a basis for pruning in the retrieval pruning process;
[0037] Step 412: Use original O&M LLM to extract key information from the query raised by the user to obtain the building operation and maintenance entity involved in the query. i (i=1,2,...,N), the class it belongs to is c i (i=1,2,...,N), and define the search depth as d, and the central entity of each search depth
[0038] Step 413: Based on the building operation and maintenance entity set E={e1, e2, ..., e N} and the set of classes to which each entity belongs C = {c1,c2,...,c N}, initialize the subgraph search path of the operation and maintenance graph, define the building operation and maintenance entity with the highest priority in the query as the central entity for initial retrieval
[0039] Step 414: Use a beam search process with a depth of 1 and a width of N to find all triples related to the current central entity using relational search, thereby obtaining a set of candidate tail entities.
[0040] Step 415: Using a class-based pruning process, prune and delete the tail entities that do not belong to the next level of the current central entity;
[0041] Step 416: Using the prompt information, the LLM is used to judge and score the relevance of the candidate tail entity set to the original query, thereby screening out the triples relevant to the question and their corresponding tail entity set R d (d=1,2,…,M), so as to obtain the union of the tail entity and the central entity
[0042] Step 417: Use the category set C obtained from the query as the judgment condition for the search depth, that is, E S When the corresponding building entity category in can cover the category set C appearing in the query, it is ensured that all subgraphs related to the query have been retrieved; if it cannot be covered, let R d The entity in is used as the central entity for the next deep search Repeat steps 414 to 417 until E S The classes to which the entities belong completely cover the category set C; thereby extracting all knowledge triples related to the query and the corresponding classes;
[0043] (4-2) The search for examples uses the Euclidean distance to evaluate the similarity between the user query and each example question in the example library. All examples are sorted according to the calculated relevance score, and the top three examples with the highest relevance to the query are selected.
[0044] (4-3) Under the designed prompt template, guide LLM to convert the above query-related classes, triples and examples into knowledge prompts in the form of continuous text.
[0045] As a further optimization scheme of the smart building operation and maintenance information query method based on the knowledge-enhanced large language model described in the present invention, step (5) includes the following steps:
[0046] (5-1) Using the operation and maintenance database obtained after data preprocessing;
[0047] (5-2) Using the original O&M LLM fine-tuned by QLoRA;
[0048] (5-3) Using an external knowledge base consisting of an operation and maintenance knowledge graph and an example library;
[0049] (5-4) The knowledge hints obtained from the external knowledge base are used to enhance the fine-tuned original O&M LLM to obtain the core model knowledge-enhanced O&M LLM. The core model is guided to perform the first generation through the building operation and maintenance knowledge involved in the user's query, that is, to generate the correct SQL statement to complete the retrieval of the operation and maintenance database and obtain the relevant data as the basis for generating the response required for the query;
[0050] (5-5) The returned relevant data will be used as context information together with the inquiry. The knowledge-enhanced O&MLLM will be generated a second time based on this context information, that is, to provide reasonable operation and maintenance analysis and suggestions for the user's inquiry.
[0051] The present invention also provides a smart building operation and maintenance information query system based on knowledge-enhanced large language model, which uses the above-mentioned smart building operation and maintenance information query method based on knowledge-enhanced large language model, including:
[0052] QLoRA model fine-tuning unit: used to fine-tune the selected basic model using the mixed fine-tuning dataset, enhance the ability of the large language model to complete the operation and maintenance information query task, and obtain the original O&M LLM;
[0053] Operation and maintenance large language model subtask unit: used to use the original O&M LLM to complete the three subtasks of key information extraction, knowledge embedding text, and query-related data retrieval based on input information;
[0054] The key information extraction refers to extracting the key information contained in the user query by using the original O&M LLM, and using the key information as the input of the knowledge retrieval and text vector matching in the external knowledge retrieval unit;
[0055] The knowledge embedding text refers to using original O&M LLM to fill in the text with the relevant classes, triples and examples retrieved from the external knowledge based on the prompt template to obtain textual knowledge;
[0056] The query-related data retrieval refers to using the knowledge-enhanced O&M LLM to perform relevant data retrieval on the operation and maintenance data set based on the database description and the context of the user query, outputting SQL query statements, and obtaining relevant data information after the query;
[0057] External knowledge retrieval unit: used to use the query key information to perform knowledge retrieval and text vector matching on the operation and maintenance knowledge graph and the example library respectively, to obtain query-related knowledge information, namely, classes, triples, and examples;
[0058] The knowledge retrieval is implemented by a knowledge graph search algorithm based on the class priority of building entities;
[0059] The text vector matching is achieved by calculating the similarity of the text vectors based on the Euclidean distance;
[0060] Operation and maintenance database query unit: used to store the operation and maintenance data after the data preprocessing;
[0061] The operation and maintenance data includes six-dimensional environmental monitoring data, water and energy consumption monitoring data, electricity and energy consumption monitoring data, and monitoring equipment location information;
[0062] Operation and maintenance large language model dialogue generation unit: used to generate inquiry-related operation and maintenance analysis and suggestions based on user inquiries and the inquiry-related context obtained by the above unit, using the knowledge-enhanced O&M LLM obtained by knowledge enhancement of the original O&M LLM;
[0063] User interaction platform: used to input user queries and save historical conversation records between users and models.
[0064] The beneficial effects of the present invention are:
[0065] The method for querying operation and maintenance information of smart buildings based on knowledge-enhanced large language model described in the present invention uses the Text2SQL data set of hybrid building operation and maintenance scenarios to fine-tune the LLM to achieve automatic data retrieval; gives full play to the advantages of integrated knowledge graphs, and makes maximum use of rich information resources such as building space structure, equipment and monitoring data, and operation and maintenance related rules; and generates corresponding operation and maintenance analysis and suggestions based on user inquiries, which better meets the operation and maintenance needs in the context of smart buildings and greatly reduces manual operations in the operation and maintenance process. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Figure 1 It is a flow chart of a smart building operation and maintenance information query method based on a knowledge-enhanced large language model described in the present invention.
[0067] Figure 2 It is a system framework diagram of a smart building operation and maintenance information query method based on a knowledge-enhanced large language model described in the present invention.
[0068] Figure 3 It is a schematic diagram of the model fine-tuning architecture based on the hybrid fine-tuning dataset described in the present invention.
[0069] Figure 4 It is a Loss curve diagram of the model fine-tuning step described in the present invention.
[0070] Figure 5 It is a schematic diagram of the operation and maintenance knowledge graph construction process described in the present invention.
[0071] Figure 6 It is a schematic diagram of the entity-based knowledge graph search algorithm described in the present invention.
[0072] Figure 7 It is a schematic diagram of a prompt template for the knowledge embedding text subtask described in the present invention.
[0073] Figure 8 It is a comparison chart of the effects of the knowledge-enhanced large language model described in the present invention and other models in operation and maintenance information query testing.
[0074] Fig. 9 This is a user interaction platform interface display diagram of a smart building operation and maintenance information inquiry system based on a knowledge-enhanced large language model using the present invention. DETAILED DESCRIPTION
[0075] The present invention will be further explained below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the following specific embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention.
[0076] The method for querying intelligent building operation and maintenance information based on knowledge-enhanced large language model described in the present invention has a flow chart as shown below: Figure 1 As shown, the method comprises the following steps:
[0077] Step (1) is to pre-process the massive amount of sensor data used for operation and maintenance information inquiries by screening outliers through an unsupervised anomaly detection method to improve its reliability as a basis for query responses. The pre-processed data is stored in the operation and maintenance database.
[0078] (1-1) For the massive sensor data used for operation and maintenance information query, unsupervised outlier detection is performed based on the isolation forest algorithm; the data used in the present invention is one year of operation data collected by various sensors in the Yangtze River Metropolitan Smart Building to verify the effectiveness of the proposed method. The information contained in the sensor data is as follows:
[0079] There are 20 floors monitored, including L01 (negative first floor) and TOP (rooftop), and different functional areas are divided into 26 different areas such as various offices, large and small meeting rooms, coffee break areas, restaurants, and rest areas. 156 sensors are set up, among which the data collection time interval of environmental sensors is 10 minutes. The data monitoring time range is from 2022-01-01 to 2023-12-31, and the total number of data items is 593.05w. The collected data and standard range include the following:
[0080] CO2 concentration: The unit is ppm, the table value range is 0 to 2000. When the CO2 concentration is greater than 1000ppm, it is considered to be excessive.
[0081] PM10 concentration: unit: μg / cubic meter, range of table value: 0-500. A PM10 concentration greater than 75 μg / cubic meter is considered to exceed the PM10 concentration standard.
[0082] PM25 concentration: unit: μg / cubic meter, range of table value: 0-500. A PM25 concentration greater than 35 μg / cubic meter is considered to exceed the standard.
[0083] Relative humidity: Unit: %, table value range: 0~99. In summer and autumn, the relative humidity is within the normal range of 40%-60%. In spring and winter, the relative humidity is within the normal range of 30%-60%.
[0084] Temperature: Unit: Celsius, range of value: 0~39.5. In summer and autumn, the normal temperature is 22~28℃, and in spring and winter, the normal temperature is 16~24℃.
[0085] TVOC: The volatility of organic matter. The table value ranges from 1 to 9. A TVOC concentration greater than 5 is considered excessive.
[0086] The water energy meter records the total water consumption on each floor once a day.
[0087] The energy meter records the total electricity consumption of different electricity categories on each floor once a day.
[0088] Among all the collected environmental and hydropower energy consumption data, the six-dimensional environmental data has the highest abnormal distribution and the most complicated situation. It is difficult to filter it out through the existing outlier model. At the same time, the offline situation of each sensor is difficult to ignore. Therefore, all the data are first separated for missing values, and then the isolation forest is used to filter out outliers. The specific steps are as follows:
[0089] Step 111: Given a group of data of the same type as data sample X = {x1, ..., x n}, select m attribute features contained in this set of data for recursive segmentation until all data samples are isolated, thereby constructing iTree.
[0090] Step 112, calculate the isolation forest path length, which is defined by the following formula:
[0091] h(x)=e+c(T.size)
[0092] Among them, h(x) is the path length of a single data sample on iTree, e is the number of edges that the data sample x experiences from the root node to the leaf node of the tree, T.size represents the number of samples at the same leaf node as sample x, c(T.size) can be regarded as a correction value, which represents the average path length of T.size samples to construct a binary tree; the calculation formula of c(n) is as follows:
[0093]
[0094] Among them, H(i) is the harmonic number, which can be estimated by ln(i)+0.5772156649 (Euler constant). The purpose of this correction value is to make the difference between the path lengths of abnormal and normal samples larger;
[0095] Step 113: Calculate the anomaly score, which is defined by the following formula:
[0096]
[0097] Among them, W(h(x)) is the average value of the depth reached by a single data sample x in all iTrees. c(n) is used to normalize h(x) and map s to the range of (0, 1). The smaller the path length of the data sample, the closer s is to 1, and the greater the probability that the data sample is an outlier. When E(h(x)) is closer to the average path length c(n) of the node where a certain sample is located, the anomaly score s approaches 0.5. When E(h(x)) is closer to 0, that is, the smaller the path length of the data sample, the feature segmentation is completed at an earlier position, and the anomaly score s approaches 1, then the point is likely to be an outlier. On the contrary, if s is much smaller than 0.5, then the point is likely to be a normal value.
[0098] Step 114: Perform appropriate anomaly screening on all data samples on iTree by setting a threshold k, and remove data samples with anomaly scores s≥k as outliers. In the specific implementation, the threshold k=0.8 is set, that is, a total of about 2.48% of the original data is screened and deleted; the specific data processing details are shown in Table 1.
[0099] Table 1 is a display of the data preprocessing results of the present invention.
[0100]
[0101]
[0102] Step 2: Construct a mixed fine-tuning dataset consisting of problem-SQL pairs containing operation and maintenance scenarios to train LLM on QLoRA, such as Figure 3 As shown in the figure, an additional low-rank adaptation matrix is introduced to expand the LLM function with the original model parameters, thereby obtaining an LLM that enhances the Text2SQL capability in operation and maintenance query scenarios - the original O&M LLM.
[0103] (2-1) Build a hybrid fine-tuning dataset based on the CSpider dataset mixed with operation and maintenance information query-SQL pairs Each sample pair contains a query x (i) and the corresponding SQL statement y (i) ; Among them, the CSpider dataset is a Chinese Text2SQL dataset, which is more difficult than most Text2SQL datasets and is suitable for Chinese scenarios. The dataset contains a total of 10,181 questions and 5,693 unique complex SQL queries, involving 200 different databases. Based on the CSpider dataset, 1,300 query-SQL pairs related to operation and maintenance information inquiries were constructed and used as a hybrid fine-tuning dataset for training;
[0104] (2-2) Model training is performed using the hybrid fine-tuning dataset. The training goal is to optimize the model parameters by minimizing the negative log-likelihood of the SQL response conditioned on the question. Specifically, the training objective function is defined as follows:
[0105]
[0106] in, is the target output value of the i-th sample at time step t, which is used to compare with the output value of the model to guide the gradient descent process so that the model's prediction is closer to the actual target output.
[0107] For the QLoRA training process, specifically, all parameters W of the basic model are locked during training. After the training data X is input, only the newly added network layer is adjusted. In the initial stage, the newly added weights W are initialized by Gaussian distribution. A , and the weight W B It is set to a zero matrix, which means that in the early stage of training, the newly added path BA will not have any effect on the model output; in the inference stage, the following formula is used to update the original language model weights, so as to enhance and optimize the original weights:
[0108] h=WX+W A W B X=(W+W A W B )
[0109] The present invention uses Qwen1.5-32B as the basic model for training, and the parameters of the adapter are set to rank=32, alpha=16, and dropout=0.05. For the training settings, we set the learning rate learning rate=1.0e-4, combined with the AdamW optimizer for 5 epochs training, and do not use weight decay; we use deepspeed technology on 4 A800 graphics cards with a total of 320GB of memory to accelerate the training, and the entire training takes about 9 hours; the training loss curve is as follows Figure 4 As shown, it can be observed that both the training curve and the evaluation curve show a downward trend and converge at the end of training. At the same time, the difference between the two is very small at the end, which shows that the fitting effect of this training is very good and effective learning is obtained from the fine-tuning dataset.
[0110] Step 3: Based on the structural information and operation and maintenance rules of the actual building, define entities and relationships in a triple-based manner to build an operation and maintenance knowledge graph. Build a small number of examples based on several classic scenarios of operation and maintenance information queries. The examples and the knowledge graph together serve as an external knowledge base.
[0111] (3-1) Use the classes and relationships defined in Brick Schema to build an operation and maintenance knowledge graph. Brick Schema is an open source project that aims to standardize the description of physical, logical, and virtual assets in buildings and their relationships. It contains an extensible dictionary of building terms and concepts, a set of relationships for connecting and combining concepts, and provides guidance for building a knowledge graph in the field of construction. The construction process is as follows: Figure 5As shown in the figure, based on the structural information and operation and maintenance rules of the actual building, the division of various functional spaces from the basic floor information to each floor is described in detail, and the relationship between space and water, electricity and energy consumption, and environmental sensing equipment is integrated. At the same time, the spatial location distribution of various sensors and the standard threshold setting of various monitoring data are covered. Finally, the entities and relationships contained in the above information are determined in the form of triples, so as to construct the operation and maintenance knowledge graph;
[0112] (3-2) A systematic statistical analysis of the queries that may arise in the operation and maintenance of smart buildings was conducted. These operation and maintenance issues can be classified into four categories: data condition analysis, basic data query, data comparison and judgment, and advanced data analysis. A small number of typical queries were designed for each type of problem, and the corresponding SQL query statements were given as reference examples.
[0113] Step 4: For the search of knowledge graph, the building level information classification and corresponding priority are defined for the entities involved in the operation and maintenance information query, and a graph search algorithm based on class priority is designed, such as Figure 6 As shown, the steps are as follows:
[0114] Firstly, LLM is used to extract key information from the user's query and obtain the building operation and maintenance entities involved in the query;
[0115] Then, the subgraph search path of the operation and maintenance graph is initialized based on the obtained entities, and the entity with the highest priority in the class involved in the query is defined as the central entity of the initial search, and the classes included in the query are used as the judgment conditions for the search depth;
[0116] Secondly, search for triples with a depth of 1 related to the current central entity to obtain a set of candidate tail entities;
[0117] Next, the tail entities are pruned according to the priority of the defined classes, and the next level tail entities that do not belong to the class corresponding to the current central entity are deleted;
[0118] Then, LLM is used to judge and score the relevance of the pruned tail entity set to the question, and the most relevant n triples and their corresponding tail entity sets are screened out;
[0119] Repeat the above steps until the classes in the searched entity set completely cover the classes involved in the query, so as to ensure that all relevant subgraphs in the knowledge graph related to the question have been retrieved, and obtain the classes and triples related to the query in the operation and maintenance knowledge graph;
[0120] At the same time, the search for examples uses the Euclidean distance to evaluate the similarity between the user query and each example question in the example library, sorts all examples according to the calculated relevance score, and selects the top three examples with the highest relevance;
[0121] Finally, under the designed prompt template, LLM is guided to transform the query-related triples and examples into knowledge prompts in the form of continuous text.
[0122] (4-1) The search on the operation and maintenance knowledge graph is based on the class priority of the building entity. Figure 6 In the example shown, the specific process is as follows:
[0123] Step 411: Based on the obvious type distinction and hierarchical relationship between the building entities involved in the query, in the example query "Is the average temperature of each office on the 11th floor in July this year out of the standard range", the search for the graph always starts from "11th floor" to "office", then to "temperature", and finally to "standard range". Therefore, the building hierarchical information entity classification and its priority (Rank) are defined as shown in the following table:
[0124] Classification of building level information entities Rank Floor 1 Region, ElectricityConsumptionGroup 2 EnvironmentData, EnergyConsumptionData 3 StandardRules 4
[0125] Among them, the priority level will provide the basis for pruning during the retrieval pruning process, and the lower the level, the higher the priority will be pruned;
[0126] Step 412: Use original O&M LLM to extract key information from the query raised by the user to obtain the building operation and maintenance entity involved in the query. i (i=1,2,...,N), the class it belongs to is c i (i=1,2,...,N), and define the search depth as d, and the central entity of each search depth
[0127] Step 413: Based on the building operation and maintenance entity set E={e1, e2, ..., e N} and the set of classes to which each entity belongs C = {c1,c2,...,c N}, initialize the subgraph search path of the operation and maintenance graph, define the building operation and maintenance entity with the highest priority in the query as the central entity for initial retrieval
[0128] Step 414: Use a beam search process with a depth of 1 and a width of N to find all triples related to the current central entity using relational search, thereby obtaining a set of candidate tail entities. For example, in Figure 6 In the case shown, the initial central entity is "F11", then the candidate tail entity set
[0129] Step 415: Using a class-based pruning process, prune and delete the tail entities that do not belong to the next level of the current central entity;
[0130] Step 416: Using the prompt information, the LLM is used to judge and score the relevance of the candidate tail entity set to the original query, thereby screening out the triples relevant to the question and their corresponding tail entity set R d (d=1,2,…,M), which is represented as R1={President's Office, Finance Office} in the first step of the diagram. In this way, we get the union of the tail entity and the center entity.
[0131] Step 417: Use the category set C obtained from the query as the judgment condition for the search depth, that is, E S When the corresponding building entity categories in can cover the category set C appearing in the query, it is ensured that all subgraphs related to the query have been retrieved; Figure 6 In the case shown, C = {Floor, Region, Environment Datas, Standard Rules}. If it cannot be covered, let R d The entity in is used as the central entity for the next deep search Repeat steps 414 to 417 until E S The classes to which the entities belong completely cover the category set C; thereby extracting all knowledge triples related to the query and the corresponding classes;
[0132] (4-2) The search for examples uses the Euclidean distance to evaluate the similarity between the user query and each example question in the example library, sorts all examples according to the calculated relevance score, and selects the top three examples with the highest relevance to the query;
[0133] (4-3) For the external knowledge base composed of knowledge graph and examples, the retrieval-augmented generation (RAG) technology is introduced to call the external knowledge base as a model plug-in tool to provide knowledge enhancement for the original O&M LLM. Under the designed prompt template, the LLM is guided to convert the above query-related classes, triples and examples into knowledge prompts in the form of continuous text. The prompt template is as follows: Figure 7As shown; the input information comes from an external knowledge base, including relevant classes, relevant triples and relevant examples. The core of this prompt template lies in the combination of various entities that may exist in the relevant classes; the present invention sets prompt sub-templates with placeholders according to different combinations to fill in the content of relevant triples, and the sub-templates can be reused until the content of all relevant triples is covered; in addition, the text description in each prompt sub-template comprehensively considers the Rank sorting of the class to ensure the logical structure and clarity of the generated text information; original O&M LLM selects the most appropriate prompt template to fill in the content in the relevant triples and generates multiple independent text sentences; then, these sentences are merged with relevant examples to form the final knowledge prompt text.
[0134] Step 5: The knowledge-enhanced O&M LLM enhanced by knowledge prompts completes the search of the operation and maintenance database. The returned relevant data will be used as context information together with the query. Finally, the knowledge-enhanced O&M LLM provides reasonable operation and maintenance analysis and suggestions for the user's query based on this context information.
[0135] (5-1) Using the operation and maintenance database obtained after data preprocessing;
[0136] (5-2) Using the original O&M LLM fine-tuned by QLoRA;
[0137] (5-3) Using an external knowledge base consisting of an operation and maintenance knowledge graph and an example library;
[0138] (5-4) The knowledge hints obtained from the external knowledge base are used to enhance the fine-tuned original O&M LLM to obtain the core model knowledge-enhanced O&M LLM. The core model is guided to perform the first generation through the building operation and maintenance knowledge involved in the user's query, that is, to generate the correct SQL statement to complete the retrieval of the operation and maintenance database and obtain the relevant data as the basis for generating the response required for the query;
[0139] (5-5) The returned relevant data will be used as context information together with the inquiry. The knowledge-enhanced O&MLLM will be generated a second time based on this context information, that is, to provide reasonable operation and maintenance analysis and suggestions for the user's inquiry.
[0140] The present invention also provides a smart building operation and maintenance information query system based on knowledge-enhanced large language model, and applies the smart building operation and maintenance information query method based on knowledge-enhanced large language model, such as Figure 2 As shown, including:
[0141] QLoRA model fine-tuning unit: used to fine-tune the selected basic model using the mixed fine-tuning dataset, enhance the ability of the large language model to complete the operation and maintenance information query task, and obtain the original O&M LLM;
[0142] Operation and maintenance large language model subtask unit: used to use the original O&M LLM to complete the three subtasks of key information extraction, knowledge embedding text, and query-related data retrieval based on input information;
[0143] The key information extraction refers to extracting the key information contained in the user query by using the original O&M LLM, and using the information for knowledge retrieval and text vector matching in the external knowledge retrieval unit;
[0144] The knowledge embedding text refers to using original O&M LLM to fill in the text with the relevant classes, triples and examples retrieved from the external knowledge based on the prompt template to obtain textual knowledge;
[0145] The query-related data retrieval refers to using the knowledge-enhanced O&M LLM to perform relevant data retrieval on the operation and maintenance data set based on the database description and the context of the user query, outputting SQL query statements, and obtaining relevant data information after the query;
[0146] External knowledge retrieval unit: used to use the query key information to perform knowledge retrieval and text vector matching on the operation and maintenance knowledge graph and the example library respectively, to obtain query-related knowledge information, namely, classes, triples, and examples;
[0147] The knowledge retrieval is implemented by a knowledge graph search algorithm based on the class priority of building entities;
[0148] The text vector matching is achieved by calculating the similarity of the text vectors based on the Euclidean distance;
[0149] Operation and maintenance database query unit: used to store the operation and maintenance data after the data preprocessing;
[0150] The operation and maintenance data includes six-dimensional environmental monitoring data, water and energy consumption monitoring data, electricity and energy consumption monitoring data, and monitoring equipment location information;
[0151] Operation and maintenance large language model dialogue generation unit: used to generate inquiry-related operation and maintenance analysis and suggestions based on user inquiries and the inquiry-related context obtained by the above unit, using the knowledge-enhanced O&M LLM obtained by knowledge enhancement of the original O&M LLM;
[0152] User interaction platform: used to input user queries and save historical conversation records between users and models.
[0153] The user interaction platform interface developed based on the above system design is demonstrated as follows Fig. 9 shown.
[0154] The following experimental results show that compared with the existing methods, the present invention achieves better results by using the knowledge-enhanced large language model to complete operation and maintenance information inquiries.
[0155] This embodiment uses the CSpider dataset and the designed operation and maintenance query dataset for experiments. There are 1063 data in the CSpider dataset for evaluation testing, and an evaluation set of 466 queries is constructed for the operation and maintenance information query capability for evaluation testing.
[0156] On the CSpider evaluation set and the operation and maintenance information query evaluation set, the experiment used execution accuracy as the evaluation criterion to evaluate the accuracy of the model in completing queries. This standard refers to the paper "DB-GPT-Hub: Towards OpenBenchmarking Text-to-SQL Empoweredby Large Language Models". Based on this standard, a series of SOTA models were tested as experimental results.
[0157] Table 1 shows the test results of the original O&M LLM in this invention on the operation and maintenance information query evaluation set.
[0158] Model Name Execution accuracy GPT-4 0.955 originalO&MLLM 0.927 Qwen-32B 0.675 Qwen-14B 0.246 Wizardcoder-33B 0.676 Yi-34B 0.658 CodeLlama-70B 0.702 Llama2-70B 0.487
[0159] The results in Table 1 show that the fine-tuning of the original O&M LLM by the present invention significantly improves its performance in specific domain tasks. The execution accuracy of the fine-tuned original O&M LLM is nearly 25% higher than that of the basic model Qwen-32B. At the same time, the model achieved an execution accuracy of 92.7%, surpassing larger models such as Llama-70B and CodeLlama-70B, and slightly lower than the 95.5% accuracy of GPT-4. This result emphasizes the effectiveness of targeted training data and strategies in enhancing the model's ability to solve problems in specific domains, and far exceeds the effect of simply increasing the model size.
[0160] It can also be seen that there is a significant gap between Qwen-14B and Qwen-32B. In the embodiment of the present invention, the model with a parameter scale of 14B is obviously not competent for complex operation and maintenance information query tasks. In addition, the models with a parameter scale of about 30B, such as Yi-34B, Wizardcoder-33B and Qwen-32B, have a gap of less than 5% with the CodeLlama-70B tested in the experiment. Since the models were tested using exactly the same prompts in the experiment, it is not ruled out that each model may not have performed at its best, and the ideal accuracy difference may be different. However, considering the deployment and training costs, it is more economical to use a model with a parameter scale of about 30B. Therefore, it is undoubtedly very appropriate to choose the Qwen-32B model as the basic model for training in this study.
[0161] Llama2-70B performs relatively poorly when compared to models of similar size. This performance shortfall is primarily attributed to the model's lack of specialized training in Chinese or programming, which hinders its ability to effectively interpret Chinese operation and maintenance information queries in embodiments of the present invention, leading to misunderstandings of the purpose of the query and the generation of SQL statements that do not match the database structure. In contrast, domestically developed models such as Qwen, Wizardcoder, and Yi, as well as CodeLlama, which is specifically trained for programming capabilities, perform well on the operation and maintenance information query evaluation set.
[0162] Table 2 shows the test results of the original O&M LLM in this invention on the CSpider evaluation set.
[0163] Model Name Execution accuracy GPT-4 0.761 originalO&MLLM 0.749 Qwen-32B 0.670 Qwen-14B 0.498 Wizardcoder-33B 0.612 Yi-34B 0.605 CodeLlama-70B 0.692 llama2-70B 0.379
[0164] The fine-tuned original O&M LLM still shows significant improvement in the general Text2SQL task, achieving an execution accuracy of 74.9%, second only to GPT-4. This result shows that the cross-domain data hybrid training strategy of the present invention not only enhances the model's ability to handle complex query tasks in specific fields, but also maintains its generalization ability in general Text2SQL tasks.
[0165] In this embodiment, for the evaluation of knowledge-enhanced O&M LLM, the text-embedding-3-large model of OpenAI is called to vectorize the external knowledge base and store it in the Faiss vector library and connect it with the model. At the same time, the user's question is vectorized, and the most similar example content is matched according to the Euclidean distance, where the number of examples is set to top k = 3. At the same time, the operation and maintenance database is connected to the knowledge-enhanced O&M LLM to complete the retrieval. The knowledge-enhanced O&M LLM after the introduction of RAG technology is tested on the operation and maintenance information query evaluation set, and the performance of each model is compared using a heat map based on the above test results, as shown in the figure. Figure 8 Results shown.
[0166] Figure 8 In the figure, the execution accuracy of the knowledge-enhanced O&M LLM represents the final performance of our invention in the operation and maintenance information query task, and its execution accuracy reaches 95.5%, which is comparable to GPT-4. The knowledge-enhanced O&M LLM only improves the accuracy by 3% compared to the original O&M LLM. This is mainly because when the accuracy exceeds 90%, it becomes extremely difficult to achieve further improvement, and in this high accuracy range, errors tend to be concentrated on particularly challenging queries involving rare failure scenarios or complex system interactions. In addition, the limited number and difficulty of the test queries also pose certain limitations to demonstrating the performance improvement of the knowledge-enhanced O&M LLM.
[0167] It should be noted that the above content only illustrates the technical idea of the present invention and cannot be used to limit the protection scope of the present invention. For ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications all fall within the protection scope of the claims of the present invention.
Claims
1. A smart building operation and maintenance inquiry method based on knowledge-enhanced large language model, characterized in that: The following steps are involved: Step (1) for the massive sensor data used for operation and maintenance information inquiry in the real smart building, the data preprocessing of outliers is screened by unsupervised anomaly detection method to improve its reliability as a basis for inquiry response, and the preprocessed data is stored in the operation and maintenance database; Step (2), construct a mixed fine-tuning dataset consisting of question-SQL pairs in operation and maintenance scenarios to train the LLM with QLoRA. QLoRA is a fine-tuning technique that introduces an additional low-rank adaptation matrix to expand the LLM function under the original model parameters, thereby obtaining the original O&M LLM that enhances the ability to convert natural language into SQL in operation and maintenance query scenarios; Step (3): Based on the structural information and operation and maintenance rules of the actual building, define entities and relationships in a triple-based manner to build an operation and maintenance knowledge graph. A small number of examples are built based on several classic scenarios of operation and maintenance information query. The examples and the knowledge graph serve as an external knowledge base. Step (4): for the search of the knowledge graph, the building level information classification and corresponding priority are defined for the entities involved in the operation and maintenance inquiry, and a graph search algorithm based on the class priority of the building entity is designed to obtain the classes and triples related to the inquiry in the operation and maintenance knowledge graph; for the search of examples, the text vector matching method is used to select the top three examples with the highest relevance; finally, under the designed prompt template, the LLM is guided to convert the query-related classes, triples and examples into knowledge prompts in the form of continuous text; Step (5), the knowledge-enhanced O&M LLM enhanced by knowledge prompts completes the search of the operation and maintenance database, and the returned relevant data will be used as context information together with the query. Finally, the knowledge-enhanced O&M LLM provides reasonable operation and maintenance analysis and suggestions for the user's query based on this context information.
2. The method for querying operation and maintenance of smart buildings based on knowledge-enhanced large language model according to claim 1 is characterized in that: Step (1) comprises the following steps: (1-1) For the massive sensor data used for operation and maintenance information query in real smart buildings, unsupervised outlier detection is performed based on the isolation forest algorithm. The isolation forest algorithm takes advantage of the fact that abnormal data is "few and different" and isolates each instance by effectively building a tree structure. Outliers are often isolated after a few rounds, while normal values obviously require more and more complex cuts and splits. Therefore, when the random forests jointly produce shorter path lengths for certain specific points, these points are likely to be abnormal. The specific algorithm steps are as follows: Step 111: Given n data samples X = {x1, ..., x n } randomly select m features, split the data points by randomly selecting a value between the maximum and minimum values of the selected features, and recursively repeat the partition until all data samples are isolated, thereby constructing an isolation tree; Step 112, calculate the isolation forest path length, which is defined by the following formula: h(x)=e+c(T.size) Among them, h(x) is the path length of a single data sample on iTree, e is the number of edges that the data sample x experiences from the root node to the leaf node of the tree, T.size represents the number of samples at the same leaf node as sample x, and c(T.size) is regarded as a correction value, which represents the average path length of T.size samples to construct a binary tree; the calculation formula of c(n) is as follows: Where H(i) is the harmonic number, estimated by ln(i)+0.5772156649 (Euler constant). The purpose of this correction is to make the difference between the path lengths of abnormal and normal samples larger; Step 113: Calculate the anomaly score, which is defined by the following formula: Among them, E(h(x)) is the average value of the depth reached by a single data sample x in all iTrees. c(n) is used to normalize h(x) and map s to the range of (0, 1). When the path length of the data sample is smaller, s is closer to 1, and the probability that the data sample is an outlier is greater; when E(h(x)) is closer to the average path length c(n) of the node where a certain sample is located, the anomaly score s approaches 0.5; when E(h(x)) is closer to 0, that is, the path length of the data sample is smaller, the feature segmentation is completed at an earlier position, and the anomaly score s is closer to 1, then the point is likely to be an outlier; conversely, if s is much smaller than 0.5, then the point is likely to be a normal value; Step 114: Perform appropriate anomaly screening on all data samples on iTree by setting a threshold k, and treat data samples with anomaly scores s≥k as outliers and remove them.
3. The smart building operation and maintenance inquiry method based on knowledge-enhanced large language model according to claim 1 is characterized in that: Step (2) comprises the following steps: (2-1) Based on the general Text2SQL dataset, we mixed the operation and maintenance information query-SQL pairs to build a hybrid fine-tuning dataset Each sample pair contains a query x (i) and the corresponding SQL statement y (i) ; (2-2) The model is trained using the hybrid fine-tuning dataset. The training goal is to optimize the model parameters by minimizing the negative log-likelihood of the SQL response conditioned on the question, and obtain the original O&M LLM. Specifically, the training objective function is defined as follows: in, is the target output value of the i-th sample at time step t, which is used to compare with the output value of the model and guide the gradient descent process to make the model's prediction closer to the actual target output; At the same time, the training method is based on QLoRA technology; specifically, all parameters W of the basic model are locked during training, and after inputting the training data X, only the newly added network layer is adjusted; in the initial stage, the newly added weight W is initialized by Gaussian distribution A , and the weight W B It is set to a zero matrix, which means that in the early stage of training, the newly added path BA will not have any effect on the model output; in the inference stage, the following formula is used to update the original language model weights, so as to enhance and optimize the original weights: h=WX+W A W B X=(W+W A W B 。 4. The method for querying operation and maintenance of smart buildings based on knowledge-enhanced large language model according to claim 1 is characterized in that: Step (3) comprises the following steps: (3-1) Based on the structural information and operation and maintenance rules of the actual building, a detailed description is given from the basic floor information to the division of various functional spaces within each floor, integrating the relationship between space and water and electricity energy consumption and environmental sensing equipment. At the same time, it covers the spatial location distribution of various sensors and the standard threshold setting of various monitoring data. The building information entities and relationships are constructed in the form of triples to obtain the operation and maintenance knowledge graph; (3-2) A systematic statistical analysis was conducted on the information inquiries that may occur in the operation and maintenance of smart buildings, and they were classified into four categories: data condition analysis, basic data query, data comparison and judgment, and advanced data analysis. A small number of inquiries in typical scenarios were designed for each type of inquiry, and the corresponding SQL query statements were given as reference examples.
5. The method for querying operation and maintenance of smart buildings based on knowledge-enhanced large language model according to claim 1 is characterized in that: Step (4) comprises the following steps: (4-1) The search on the operation and maintenance knowledge graph is based on the class priority of the building entity. The specific process is as follows: Step 411, based on the obvious type distinction and hierarchical subordination between the building entities involved in the query, define the building hierarchical information entity classification and its priority (Rank): Floor (Rank 1), Region (Rank 2), Electricity Comsuption Group (Rank 2), Energy Comsuption Datas (Rank 3), Environment Datas (Rank 3), Standard Rules (Rank 4); the priority level will provide a basis for pruning in the retrieval pruning process; Step 412: Use original O&M LLM to extract key information from the query raised by the user to obtain the building operation and maintenance entity involved in the query. i (i=1,2,...,N), the class it belongs to is c i (i=1,2,...,N), and define the search depth as d, and the central entity of each search depth Step 413: Based on the building operation and maintenance entity set E={e1, e2, ..., e N } and the set of classes to which each entity belongs C = {c1,c2,...,c N }, initialize the subgraph search path of the operation and maintenance graph, define the building operation and maintenance entity with the highest priority in the query as the central entity for initial retrieval Step 414: Use a beam search process with a depth of 1 and a width of N to find all triples related to the current central entity using relational search, thereby obtaining a set of candidate tail entities. Step 415: Using a class-based pruning process, prune and delete the tail entities that do not belong to the next level of the current central entity; Step 416: Using the prompt information, the LLM is used to judge and score the relevance of the candidate tail entity set to the original query, thereby screening out the triples relevant to the question and their corresponding tail entity set R d (d=1,2,…,M), so as to obtain the union of the tail entity and the central entity Step 417: Use the category set C obtained from the query as the judgment condition for the search depth, that is, E S When the corresponding building entity category in can cover the category set C appearing in the query, it is ensured that all subgraphs related to the query have been retrieved; if it cannot be covered, let R d The entity in is used as the central entity for the next deep search Repeat steps 414 to 417 until E S The classes to which the entities belong completely cover the category set C; thereby extracting all knowledge triples related to the query and the corresponding classes; (4-2) The search for examples uses the Euclidean distance to evaluate the similarity between the user query and each example question in the example library, sorts all examples according to the calculated relevance score, and selects the top three examples with the highest relevance to the query; (4-3) Under the designed prompt template, guide LLM to convert the above query-related classes, triples and examples into knowledge prompts in the form of continuous text.
6. The method for querying operation and maintenance of smart buildings based on knowledge-enhanced large language model according to claim 1 is characterized in that: Step (5) comprises the following steps: (5-1) Using the operation and maintenance database obtained after data preprocessing; (5-2) Using the original O&M LLM fine-tuned by QLoRA; (5-3) Using an external knowledge base consisting of an operation and maintenance knowledge graph and an example library; (5-4) The knowledge hints obtained from the external knowledge base are used to enhance the fine-tuned original O&M LLM to obtain the core model knowledge-enhanced O&M LLM. The core model is guided to perform the first generation through the building operation and maintenance knowledge involved in the user's query, that is, to generate the correct SQL statement to complete the retrieval of the operation and maintenance database and obtain the relevant data as the basis for generating the response required for the query; (5-5) The returned relevant data will be used as context information together with the inquiry. The knowledge-enhanced O&M LLM will be generated a second time based on this context information, that is, to provide reasonable operation and maintenance analysis and suggestions for the user's inquiry.
7. A smart building operation and maintenance inquiry system based on a knowledge-enhanced large language model, applying the smart building operation and maintenance inquiry method based on a knowledge-enhanced large language model as described in any one of claims 1 to 6, characterized in that: include: QLoRA model fine-tuning unit: used to fine-tune the selected basic model using the mixed fine-tuning dataset, enhance the ability of the large language model to complete the operation and maintenance information query task, and obtain the original O&M LLM; Operation and maintenance large language model subtask unit: used to use the original O&M LLM to complete the three subtasks of key information extraction, knowledge embedding text, and query-related data retrieval based on input information; The key information extraction refers to extracting the key information contained in the user query by using the original O&M LLM, and using the key information as the input of the knowledge retrieval and text vector matching in the external knowledge retrieval unit; The knowledge embedding text refers to using original O&M LLM to fill in the text with the relevant classes, triples and examples retrieved from the external knowledge based on the prompt template to obtain textual knowledge; The query-related data retrieval refers to using the knowledge-enhanced O&M LLM to perform relevant data retrieval on the operation and maintenance data set based on the database description and the context of the user query, outputting SQL query statements, and obtaining relevant data information after the query; External knowledge retrieval unit: used to use the query key information to perform knowledge retrieval and text vector matching on the operation and maintenance knowledge graph and the example library respectively, to obtain query-related knowledge information, namely, classes, triples, and examples; The knowledge retrieval is implemented by a knowledge graph search algorithm based on the class priority of building entities; The text vector matching is achieved by calculating the similarity of the text vectors based on the Euclidean distance; Operation and maintenance database query unit: used to store the operation and maintenance data after the data preprocessing; The operation and maintenance data includes six-dimensional environmental monitoring data, water and energy consumption monitoring data, electricity and energy consumption monitoring data, and monitoring equipment location information; Operation and maintenance large language model dialogue generation unit: used to generate inquiry-related operation and maintenance analysis and suggestions based on user inquiries and the inquiry-related context obtained by the above unit, using the knowledge-enhanced O&M LLM obtained by knowledge enhancement of the original O&M LLM; User interaction platform: used to input user queries and save historical conversation records between users and models.
Citation Information
Patent Citations
Knowledge graph generation type question answering method and system based on large language model
CN117033608A
Dynamic adaptation question answering system and method based on hierarchical structure and retrieval enhancement
CN118193714A
Retrieval method and system based on domain-enhanced large language model
CN118796978A
Learning device, learning method, and learning program
JP7599622B1