Intelligent building operation and maintenance inquiry method and system based on knowledge-enhanced large language model
By constructing a hybrid fine-tuning dataset and knowledge graph, the Text2SQL capabilities of the large language model are enhanced, solving the problem of understanding data correlation in the operation and maintenance of smart buildings, realizing automated data retrieval and operation and maintenance analysis, and improving operation and maintenance efficiency.
Patent Information
- Application Number
- CN202510076494.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-17
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2045-01-17
AI Technical Summary
Existing large-scale language models struggle to effectively understand the complex relationships between operational data and building structures in smart building operations and maintenance. They are particularly difficult to handle nested queries under multiple conditions and to convert user requirements into structured query languages. Furthermore, they lack knowledge of the inherent connections between the building's internal spatial structure and monitoring data.
By constructing a hybrid fine-tuning dataset to train the LLM, combining knowledge graphs and unsupervised anomaly detection methods, using triples to define entities and relations, and designing a graph search algorithm, the LLM's Text2SQL capabilities are enhanced, enabling automated data retrieval and operational analysis.
It improves data retrieval efficiency during operation and maintenance, reduces manual operations, meets the operation and maintenance needs in the context of smart buildings, and provides more accurate operation and maintenance analysis and suggestions.
Smart Images

Figure CN120012927B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the field of intelligent building operation and maintenance, and particularly relates to an intelligent building operation and maintenance inquiry method and system based on a knowledge-enhanced large language model. BACKGROUND
[0002] With the acceleration of global urbanization, intelligent buildings have gradually become an important part of urban construction, and the importance of intelligent building operation and maintenance (O&M) tasks is increasingly prominent. The purpose of O&M is to reduce building operation costs, improve energy utilization efficiency, and enhance the comfort of the living environment. However, with the increasing complexity of intelligent building structures and the increasing amount of data generated, building operation and maintenance need to extract value from massive amounts of information through effective information inquiry means to support decision-making, and this process faces many challenges.
[0003] Existing methods propose applying large language models (LLMs) to the building field to address the challenges brought about by intelligent buildings. Through fine-tuning, LLMs are adapted to specific domain tasks, enabling them to better learn specialized terminology 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 building field, there are still significant deficiencies in their ability to deeply understand the relevance of complex operation and maintenance data and building structures in current work. First, the sensor data collected is often stored in structured databases, requiring the conversion of user requirements into structured query language (SQL) statements, which poses certain obstacles to LLMs retrieving relevant operation and maintenance data, especially when dealing with complex inquiry conditions such as nested queries under multiple conditions. Second, LLMs themselves do not possess knowledge of the inherent relationship between the internal spatial structure of actual buildings and monitoring data, making it difficult for them to fully extract and utilize the implicit knowledge structure behind the data, and accurately complete information inquiry tasks, especially when the data rules and spatial structure of actual buildings need to be incorporated into data retrieval, which greatly increases the operation threshold of the operation and maintenance task. The development of knowledge graphs provides an important solution to these deficiencies. They mainly focus on analyzing and processing large amounts of text information with high semantic relevance and strong inferential capabilities, and can effectively describe the complex relationships between 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, there is currently a lack of related work on the construction of knowledge graphs for massive amounts of data and complex spatial relationships in the operation and maintenance context. SUMMARY
[0004] To solve the above problems, the application discloses a wisdom building operation and maintenance inquiry method and system based on a knowledge enhanced large language model, fine-tunes the LLM by means of a Text2SQL data set of a mixed building operation and maintenance scene to realize automatic data retrieval, gives full play to the advantages of a knowledge graph, maximally utilizes rich information resources such as building space structures, equipment and monitoring data, and operation and maintenance related rules, and generates corresponding operation and maintenance analysis and suggestions according to user inquiries, which more meets the operation and maintenance requirements under the wisdom building background and greatly reduces manual operation in the operation and maintenance process.
[0005] To achieve the above purpose, the technical scheme of the application is as follows:
[0006] A wisdom building operation and maintenance information inquiry method based on a knowledge enhanced large language model, comprising the following steps:
[0007] Step (1), for the massive sensor data used for operation and maintenance information inquiry in a real wisdom building, an unsupervised anomaly detection method is used for data preprocessing to screen abnormal values, so as to improve the reliability of the data as inquiry reply basis, and the preprocessed data is stored in an operation and maintenance database.
[0008] Step (2), a mixed fine-tuning data set composed of question-SQL pairs is constructed to train the LLM by QLoRA (quantized low-rank adaptation), which is a fine-tuning technology that introduces an additional low-rank adaptation matrix to expand the functions of the LLM under the original model parameters, so as to obtain an original O&M LLM enhanced with the ability to convert natural language into SQL (text-to-SQL (Text2SQL)) under the operation and maintenance inquiry scene;
[0009] Step (3), according to the structure information and operation and maintenance rules of an actual building, an entity and a relationship are defined based on a triple way to construct an operation and maintenance knowledge graph, a few examples are constructed according to several typical scenes of operation and maintenance information inquiry, and the examples and the knowledge graph are used as an external knowledge base together;
[0010] Step (4), for the search of the knowledge graph, building level information classification and corresponding priority of the entities involved in the operation and maintenance inquiry are defined, and a graph search algorithm based on the priority of the building entities is designed to obtain the classes and triples related to the inquiry in the operation and maintenance knowledge graph; for the search of the examples, a text vector matching method is used to select the top three examples with the highest relevance; finally, the LLM is guided to convert the inquiry related classes, triples and examples into knowledge prompts in the form of continuous text under the designed prompt template;
[0011] Step (5), the enhanced knowledge-enhanced O&M LLM is obtained through knowledge prompting to complete the retrieval of the operation and maintenance database, and the relevant data returned will be combined with the inquiry as context information, and finally the knowledge-enhanced O&M LLM provides reasonable operation and maintenance analysis and suggestions for the inquiry of the user according to the context information.
[0012] As a further optimization scheme of the intelligent building operation and maintenance information inquiry method based on the knowledge-enhanced large language model, step (1) comprises the following steps:
[0013] (1-1), for the massive sensor data used for operation and maintenance information inquiry in the real intelligent building, unsupervised anomaly value detection is performed based on the isolation forest algorithm; the isolation forest algorithm utilizes the fact that abnormal data is "rare and different", and isolates each instance by effectively constructing a tree structure, wherein the abnormal value is often isolated after a few rounds, and the normal value obviously needs more and more complex cutting partition, therefore, when the random forest collectively generates a shorter path length for certain specific points, these points are likely to be abnormal; the specific algorithm steps are as follows:
[0014] Step 111, randomly select m features on the given n-instance data sample X={x1,…,x n} and divide the data points by randomly selecting a value between the maximum and minimum values of the selected features, and the division is recursively repeated 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] Wherein, h(x) is the path length of a single data sample on the iTree, e is the number of edges experienced by the data sample x from the root node to the leaf node of the tree, T.size represents the number of samples in the same leaf node as the sample x, and c(T.size) can be regarded as a correction value representing the average path length of a binary tree constructed by T.size samples; the calculation formula of c(n) is as follows:
[0018]
[0019] Wherein, H(i) is a harmonic number, which can be estimated by ln(i)+0.5772156649 (Euler's constant), and the purpose of the correction value is to make the path length difference between abnormal and normal samples larger;
[0020] Step 113, calculate the anomaly score, defined by the following formula:
[0021]
[0022] Wherein, W(h(x)) is the average value of the depth reached by a single data sample x in all iTree, h(x) is normalized by c(n) to map s into 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 the sample is located, the anomaly score s tends to 0.5; when E(h(x)) is closer to 0, that is, the path length of the data sample is smaller, the feature segmentation ends at an earlier position, and the anomaly score s tends to 1, which is likely to be an outlier; on the contrary, if s is much smaller than 0.5, it is likely to be a normal value.
[0023] Step 114, set a threshold k to screen all data samples on the iTree, and remove data samples with anomaly score s≥k as outliers.
[0024] As a further optimization scheme of the wisdom building operation and maintenance information inquiry method based on a knowledge-enhanced large language model, step (2) comprises the following steps:
[0025] (2-1), based on the mixed operation and maintenance information inquiry-SQL pair of the general Text2SQL data set, a mixed fine-tuning data set is constructed Wherein each sample pair contains an inquiry x (i) and the corresponding SQL statement y (i) .
[0026] (2-2), use the mixed fine-tuning data set for model training, the training target 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 target function is defined as follows:
[0027]
[0028] Wherein, 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, so that the prediction of the model is closer to the true target output.
[0029] At the same time, the training method is based on QLoRA technology; specifically, all parameters W of the base model are locked during training, and only the newly added network layer is adjusted after inputting the training data X; in the initial stage, the newly added weight W is initialized by Gaussian distributionA and the weight W B is set to zero matrix, which means that at the beginning of training, the newly added path BA will not have any impact on the model output; and in the inference stage, the following formula is used to update the original language model weight, so as to realize the enhancement and optimization of the original weight:
[0030] h=WX+W A W B X=(W+W A W B )
[0031] As a further optimization scheme of the wisdom building operation information inquiry method based on the knowledge enhanced large language model, step (3) comprises the following steps:
[0032] (3-1), according to the structure information and operation rules of the actual building, the division of each type of functional space from the basic floor information to each floor is described in detail, the association of space and water, electricity and energy consumption, environmental sensing equipment is integrated, and the spatial position distribution of various sensors and the standard threshold setting of various monitoring data are covered, and the building information entity and relationship are constructed by the way of triplets to obtain the operation knowledge graph;
[0033] (3-2), the information inquiry that may appear in the operation of the wisdom building is systematically analyzed and classified into four categories of data condition analysis, basic data query, data comparison and judgment and advanced data analysis; a small number of inquiries in typical scenes are designed for each type of inquiry, and the corresponding SQL query statement is given as a reference example;
[0034] As a further optimization scheme of the wisdom building operation information inquiry method based on the knowledge enhanced large language model, step (4) comprises the following steps:
[0035] (4-1), the search on the operation knowledge graph is based on the class priority of the building entity, and the specific process is as follows:
[0036] Step 411, according to the obvious type difference and level subordinate relationship between the building entities involved in the inquiry, the building level information entity classification and its priority (Rank) are defined: 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 the basis for pruning in the retrieval pruning process;
[0037] Step 412, key information extraction is performed on the user's query by using the original O&M LLM to obtain the building operation and maintenance entities e involved in the query i (i = 1, 2,..., N), and the class to which it belongs is c i (i = 1, 2,..., N), and the class to which it belongs is c
[0038] Step 413, according to the set of building operation and maintenance entities E = {e1, e2,..., e N} involved in the query and the set of classes C = {c1, c2,..., c N} to which each entity belongs, the operation and maintenance graph is initialized for subgraph search path, and the building operation and maintenance entity with the highest priority of the class in the query is defined as the center entity of the initial retrieval
[0039] Step 414, a beam search process with a depth of 1 and a width of N is adopted, and all triples related to the current center entity are found by using relationship search, so as to obtain a candidate tail entity set
[0040] Step 415, a class-based pruning process is adopted to prune and delete tail entities that do not belong to the next level of the current center entity;
[0041] Step 416, the relevance of the candidate tail entity set to the original query is judged and scored by using the prompt information and the LLM, so as to screen out triples and their corresponding tail entity set R related to the question d (d = 1, 2,..., M), so as to obtain the union set of tail entities and center entities
[0042] Step 417, according to the class set C obtained from the query as the judgment condition of the search depth, that is, the building entity class corresponding to E S can cover the class set C appearing in the query, it is ensured that all subgraphs related to the query have been retrieved; if it cannot be covered, the entity in R d is taken as the center entity of the next depth search and steps 414-417 are repeated until the classes to which the entities in E S completely cover the class set C; all knowledge triples related to the query and the corresponding classes are extracted;
[0043] (4-2), for the search of the example, the Euclidean distance is used to evaluate the similarity between the user's 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, guiding the LLM to convert the above-mentioned inquiry-related classes, triples and examples into continuous text form knowledge prompts.
[0045] As a further optimization scheme of the wisdom building operation and maintenance information inquiry method based on knowledge-enhanced large language model, step (5) comprises the following steps:
[0046] (5-1) using the operation and maintenance database obtained through data preprocessing;
[0047] (5-2) using original O&M LLM fine-tuned by QLoRA;
[0048] (5-3) using an external knowledge base composed of an operation and maintenance knowledge graph and an example library;
[0049] (5-4) using the knowledge prompts obtained from the external knowledge base to enhance the fine-tuned original O&M LLM to obtain the core model knowledge-enhanced O&M LLM, through the building operation and maintenance knowledge involved in the user inquiry, guiding the core model to generate for the first time, that is, generating correct SQL statements to complete the retrieval of the operation and maintenance database, obtaining relevant data as the basis for generating replies to inquiries;
[0050] (5-5) the relevant data returned will be used as context information together with the inquiry, and the knowledge-enhanced O&M LLM will generate for the second time according to this context information, that is, providing reasonable operation and maintenance analysis and suggestions for the user's inquiry.
[0051] The application also provides a wisdom building operation and maintenance information inquiry system based on a knowledge-enhanced large language model, which applies the wisdom building operation and maintenance information inquiry method based on a knowledge-enhanced large language model, comprising:
[0052] QLoRA model fine-tuning unit: for fine-tuning the selected base model using the mixed fine-tuning data set, strengthening the ability of the large language model to complete the operation and maintenance information inquiry task, and obtaining original O&M LLM;
[0053] Operation and maintenance large language model subtask unit: for using original O&M LLM to complete three subtasks of key information extraction, knowledge embedding text and inquiry-related data retrieval according to input information;
[0054] The key information extraction refers to extracting the key information contained in the user inquiry using original O&M LLM, and using the 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 text filling of related classes, triples and examples obtained by external knowledge retrieval based on a prompt template by an original O&M LLM, to obtain knowledge in a text form;
[0056] The inquiry-related data retrieval refers to related data retrieval of an operation and maintenance dataset based on a database description and a context of a user inquiry by a knowledge-enhanced O&M LLM, output of an SQL query statement, and obtaining of related data information after the query;
[0057] The external knowledge retrieval unit is used for knowledge retrieval and text vector matching of an operation and maintenance knowledge graph and an example library based on inquiry key information, to obtain inquiry-related knowledge information, i.e., classes, triples and examples;
[0058] The knowledge retrieval is implemented based on a class priority-based knowledge graph search algorithm of a building entity;
[0059] The text vector matching is implemented based on a Euclidean distance to calculate the similarity of text vectors;
[0060] The operation and maintenance database query unit is used for storing operation and maintenance data after data preprocessing;
[0061] The operation and maintenance data contains six-dimensional environment monitoring data, water energy consumption monitoring data, electricity energy consumption monitoring data and monitoring device point information in terms of categories;
[0062] The operation and maintenance large language model dialogue generation unit is used for generating operation and maintenance analysis and suggestions related to inquiries based on a knowledge-enhanced O&M LLM obtained by knowledge enhancement of an original O&M LLM, and a context related to inquiries obtained by the above units;
[0063] The user interaction platform is used for input of user inquiries and saving of historical dialogue records of users and models.
[0064] The beneficial effects of the present application are as follows:
[0065] The intelligent building operation and maintenance information inquiry method based on the knowledge-enhanced large language model disclosed in the present application realizes automatic data retrieval by fine-tuning of an LLM with a Text2SQL dataset of a mixed building operation and maintenance scene; the advantages of fusion of a knowledge graph are fully utilized, and rich information resources such as building space structures, devices and monitoring data, operation and maintenance related rules are maximally utilized; and operation and maintenance analysis and suggestions are generated according to user inquiries, which more meets the operation and maintenance requirements in the context of intelligent buildings, and greatly reduces manual operation in the operation and maintenance process. BRIEF DESCRIPTION OF DRAWINGS
[0066] Figure 1 is a knowledge-enhanced large language model-based intelligent building operation and maintenance information inquiry method flowchart according to the present application.
[0067] Figure 2 is a system framework diagram of the knowledge-enhanced large language model-based intelligent building operation and maintenance information inquiry method according to the present application.
[0068] Figure 3 is a model fine-tuning architecture diagram based on a mixed fine-tuning dataset according to the present application.
[0069] Figure 4 is a Loss curve diagram of the model fine-tuning step according to the present application.
[0070] Figure 5 is a construction process diagram of the operation and maintenance knowledge graph according to the present application.
[0071] Figure 6 is a knowledge graph search algorithm diagram based on entity classes according to the present application.
[0072] Figure 7 is a prompt template diagram of the knowledge embedding text subtask according to the present application.
[0073] Figure 8 is an effect comparison diagram of the knowledge-enhanced large language model and other models in operation and maintenance information inquiry testing according to the present application.
[0074] Figure 9 is a user interaction platform interface display diagram of a knowledge-enhanced large language model-based intelligent building operation and maintenance information inquiry system according to the present application. DETAILED DESCRIPTION
[0075] The present application will be further illustrated below in conjunction with the drawings and specific embodiments, and it should be understood that the following specific embodiments are only used to illustrate the present application and not to limit the scope of the present application.
[0076] The knowledge-enhanced large language model-based intelligent building operation and maintenance information inquiry method according to the present application has a flowchart as shown in Figure 1 The method comprises the following steps:
[0077] Step (1), for the massive sensor data used for operation and maintenance information inquiry, the data preprocessing of screening abnormal values is performed through an unsupervised anomaly detection method to improve the reliability of the inquiry reply basis, and the preprocessed data is stored in the operation and maintenance database.
[0078] (1-1), for massive sensor data for operation and maintenance information inquiry, unsupervised anomaly detection based on isolation forest algorithm; The data used by the present application is verified by one year of operation data collected by various sensors in the Yangtze River City Intelligent Building to verify the effectiveness of the proposed method, the information contained in the sensor data is as follows:
[0079] The monitored layers are 20 layers, including L01 (negative one layer) and TOP (roof), and different functional areas are divided into 26 different areas such as various offices, conference rooms, tea breaks, restaurants, rest areas, etc. 156 sensors are set up, among which the collection data time interval of environmental sensors is 10 minutes, the monitoring time range of data is from 2022-01-01 to 2023-12-31, and the total number of data is 593.05w, The collected data and standard range include the following contents:
[0080] ·co2 concentration: unit ppm, table value range 0~2000, CO2 concentration greater than 1000ppm is considered as CO2 concentration exceeding standard.
[0081] ·pm10 concentration: unit μg / cubic meter, table value range 0~500, pm10 concentration greater than 75 μg per cubic meter is considered as pm10 concentration exceeding standard.
[0082] ·pm25 concentration: unit μg / cubic meter, table value range 0~500, pm25 concentration greater than 35 μg per cubic meter is considered as pm25 concentration exceeding standard.
[0083] ·Relative humidity: unit %, table value range 0~99, in summer and autumn, relative humidity in 40%-60% is within the normal range, in spring and winter, relative humidity in 30%-60% is within the normal range.
[0084] ·Temperature: unit Celsius, table value range 0~39.5, in summer and autumn, temperature in 22~28℃ is within the normal range, in spring and winter, temperature in 16~24℃ is within the normal range.
[0085] ·TVOC: organic volatile degree, table value range 1~9, TVOC concentration greater than 5 is considered as exceeding standard.
[0086] Water meter recording frequency is once a day, recording the total water consumption of each floor.
[0087] Electric energy meter recording frequency is once a day, recording the total power consumption of different power categories of each floor.
[0088] In all the collected environmental, water and electricity consumption data, the six-dimensional environmental data has the highest abnormal distribution and the most complex situation, which is difficult to be fixed and screened by the existing outlier model. Meanwhile, the offline situation of each sensor cannot be ignored. Therefore, all data are first separated from the missing values, and then the isolated forest is used for outlier screening. The specific steps are as follows:
[0089] Step 111, a group of data of the same type is given as a data sample X={x1,…,x n}, and m attribute features contained in the group of data are selected for recursive segmentation until all data samples are isolated, so as to construct iTree.
[0090] Step 112, the isolated forest path length is calculated, which is defined by the following formula:
[0091] h(x)=e+c(T.size)
[0092] Wherein, h(x) is the path length of a single data sample on iTree, e is the number of edges experienced by data sample x from the root node to the leaf node of the tree, T.size represents the number of samples in the same leaf node as sample x, and c(T.size) can be regarded as a correction value representing the average path length of a binary tree constructed by T.size samples; the calculation formula of c(n) is as follows:
[0093]
[0094] Wherein, H(i) is the harmonic number, which can be estimated by ln(i)+0.5772156649 (Euler's constant). The purpose of the correction value is to make the path length difference between abnormal and normal samples larger;
[0095] Step 113, the abnormal score is calculated, which is defined by the following formula:
[0096]
[0097] Wherein, W(h(x)) is the average value of the depth reached by a single data sample x in all iTree, and c(n) is used to normalize h(x) to 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)) tends to be the average path length c(n) of the node where a certain sample is located, the abnormal score s tends to be 0.5. When E(h(x)) tends to be 0, i.e. the path length of the data sample is smaller, the feature segmentation ends at an earlier position, and the abnormal score s tends to be 1, which means that the point is likely to be an outlier. Conversely, if s is much smaller than 0.5, the point is likely to be a normal value.
[0098] Step 114, by setting a threshold value k, all data samples on the iTree are properly screened for anomalies, and data samples with anomaly score s≥k are regarded as outliers and removed. In a specific implementation, the threshold value k is set to 0.8, i.e. about 2.48% of the original data is filtered out; the specific data processing details are shown in Table 1.
[0099] Table 1 is a data preprocessing result of the present application
[0100]
[0101]
[0102] Step 2: Construct a hybrid fine-tuning dataset composed of operation and maintenance scene question-SQL pair groups to perform QLoRA training on LLM, as shown in Figure 3 , an additional low-rank adaptive matrix is introduced to expand the LLM function under the original model parameters, thereby obtaining an LLM with enhanced Text2SQL capability in the operation and maintenance inquiry scene—original O&M LLM.
[0103] (2-1), construct a hybrid fine-tuning dataset mixed with operation and maintenance information inquiry-SQL pairs based on the CSpider dataset Each sample pair contains a question x (i) and its corresponding SQL statement y (i) ; wherein the CSpider dataset is a Chinese Text2SQL dataset, which is more difficult than most Text2SQL datasets and is suitable for Chinese scenarios. This dataset contains 10181 questions and 5693 unique complex SQL queries, involving 200 different databases. Based on the CSpider dataset, 1300 operation and maintenance information inquiry related question-SQL pairs are constructed and used as a hybrid fine-tuning dataset for training.
[0104] (2-2), use the hybrid fine-tuning dataset to perform model training, and 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] wherein, 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 true target output.
[0107] For the QLoRA training process, specifically, all parameters W of the base model are locked during training, and only the newly added network layers are adjusted after inputting the training data X; in the initial stage, the newly added weights W are initialized by a Gaussian distribution A , and the weights W B are set to zero matrix, which means that at the beginning of training, the newly added path BA will not have any impact on the model output; and in the inference stage, the original language model weight is updated as follows to achieve the enhancement and optimization of the original weight:
[0108] h = WX + W A W B X = (W + W A W B )
[0109] The application adopts Qwen1.5-32B as the base model for training, and the adapter parameter is set to rank = 32, alpha = 16 and dropout = 0.05; for the training setting, the learning rate is set to 1.0e-4, combined with the AdamW optimizer for 5 epochs of training, and weight decay is not used; the deepspeed technology is used 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 shown in Figure 4 It can be observed that the training curve and the evaluation curve both show a downward trend and converge at the end of training, and the difference between the two is small at the end, which indicates that the fitting effect of this training is good, and effective learning is obtained from the fine-tuning data set.
[0110] Step 3: According to the structure information and operation and maintenance rules of the actual building, define entities and relationships in a triple way to construct an operation and maintenance knowledge graph, and construct a small number of examples according to the classic several types of operation and maintenance information inquiry, and the examples and the knowledge graph are used as an external knowledge base.
[0111] (3-1), learn from the classes and relationships defined by 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, which includes an extensible building terminology and concept dictionary, a set of relationships for connecting and combining concepts, providing guidance for building a knowledge graph in the building field. The construction process is as Figure 5As shown, according to the structure information of the actual building and the operation and maintenance rules, the division of each floor and each type of functional space in each floor is described in detail, the association of space and water, electricity and energy consumption, environmental sensing equipment is integrated, and the spatial position 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 by triplets to build the operation and maintenance knowledge graph.
[0112] (3-2), the possible inquiries in the operation and maintenance of intelligent buildings are systematically analyzed, which 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 inquiries are designed for each type of problem, and the corresponding SQL query statements are given as reference examples.
[0113] Step 4: For knowledge graph search, the building level information classification and corresponding priority of the entities involved in the operation and maintenance information inquiry are defined, and a graph search algorithm based on class priority is designed, as shown in Figure 6 The steps are as follows:
[0114] First, the key information of the inquiry proposed by the user is extracted using LLM to obtain the building operation and maintenance entities involved in the inquiry;
[0115] Then, the subgraph search path of the operation and maintenance graph is initialized according to the obtained entities, and the highest priority class of the entities involved in the inquiry is defined as the initial search center entity, and the classes contained in the inquiry are used as the judgment condition for search depth;
[0116] Secondly, the candidate tail entity set is obtained by searching the triplets related to the current center entity with a depth of 1;
[0117] Then, according to the defined priority of the class, the tail entities are pruned, and the tail entities that do not belong to the next level of the class corresponding to the current center entity are deleted;
[0118] Then, the LLM is used to judge and score the relevance of the pruned tail entity set to the problem, and the most relevant n triplets and their corresponding tail entity set are selected;
[0119] Repeat the above steps until the classes in the searched entity set completely cover the classes involved in the inquiry, so as to ensure that all relevant subgraphs in the knowledge graph related to the problem have been searched, and the classes and triplets related to the inquiry in the operation and maintenance knowledge graph are obtained;
[0120] At the same time, the Euclidean distance is used to evaluate the similarity between the user inquiry and each example problem in the example library, and all examples are sorted according to the calculated relevance score, and the top three examples with the highest relevance are selected;
[0121] Finally, the designed prompt template guides the LLM to transform query-related triples and examples into knowledge prompts in the form of continuous text.
[0122] (4-1) Searching on the operation and maintenance knowledge graph is based on the class priority of building entities. Figure 6 In the example shown, the specific process is as follows:
[0123] Step 411: Based on the clear type distinctions and hierarchical relationships among 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 map always proceeds from "11th floor" to "office", then to "temperature", and finally to "standard range". Therefore, the building hierarchy information entity classification and its priority (Rank) are defined as follows:
[0124] Classification of building hierarchy information entities Rank Floor 1 Region, ElectricityConsumptionGroup 2 EnvironmentData, EnergyConsumptionData 3 StandardRules 4
[0125] The priority level will provide the basis for pruning during the retrieval pruning process; the lower the priority level, the more likely it will be pruned.
[0126] Step 412: Use the original O&M LLM to extract key information from the user's query to obtain the building operation and maintenance entity e involved in the query. i (i = 1, 2, ..., N), belonging to class c i (i = 1, 2, ..., N), and define the search depth as d, with the central entity at each search depth.
[0127] Step 413: Based on the set of building operation and maintenance entities E = {e1, e2, ..., e} involved in the query... N The set of classes to which each entity belongs, C = {c1, c2, ..., c3}. N The subgraph search path for the operation and maintenance graph is initialized, and the building operation and maintenance entity with the highest priority in the query class is defined as the central entity for the initial retrieval.
[0128] Step 414: Using a beam search process with a depth of 1 and a width of N, all triples related to the current central entity are found using relational search, thus obtaining the candidate tail entity set. For example, in Figure 6 In the case shown, the initial central entity If F11 is "F1", then the candidate tail entity set is
[0129] Step 415, using the class-based pruning process, pruning and deleting the tail entity that does not belong to the next level of the current center entity;
[0130] Step 416, using the prompt information, judging and scoring the relevance of the candidate tail entity set to the original query by LLM, so as to filter out the triplets and the corresponding tail entity set R that are related to the question d (d = 1, 2, …, M), represented as R1 = {CEO office, finance office} in the first step of the diagram. In this way, the union of the tail entity and the center entity is obtained
[0131] Step 417, using the class set C obtained from the query as the judgment condition of search depth, that is, E S The corresponding building entity class can cover the class set C in the query, that is, it is ensured that all subgraphs related to the query have been retrieved; in Figure 6 C = {Floor, Region, Environment Datas, Standard Rules}, if it cannot be covered, let R d The entity in the step 414 is taken as the center entity of the next depth search and repeat steps 414-417 until the class to which the entity in the step 414 belongs completely covers the class set C; in this way, all knowledge triplets related to the query and the corresponding classes are extracted; S The class to which the entity in the step 414 belongs completely covers the class set C; in this way, all knowledge triplets related to the query and the corresponding classes are extracted;
[0132] (4-2), for the search of the example, the Euclidean distance is used 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;
[0133] (4-3), for the external knowledge base composed of the knowledge graph and the example, the retrieval-augmented generation (RAG) technology is introduced to call the external knowledge base as a model external tool, so as to provide knowledge enhancement for the original O&M LLM, and under the designed prompt template, the LLM is guided to convert the above query-related classes, triplets and examples into knowledge prompts in the form of continuous text, and the prompt template is as follows Figure 7As shown; the input information comes from the external knowledge base, including related classes, related triples and related examples, the core of this prompt template is the combination of various entities that may exist in the related classes; the present application sets up prompt sub-templates with placeholders according to different combinations to fill in the content of related triples, the sub-templates can be reused until all the content of related triples is covered; in addition, the text description in each prompt sub-template comprehensively considers the Rank order of the class to ensure the logical structure and clarity of the generated text information; the original O&M LLM selects the most appropriate prompt template to fill in the content of the related triples, generating multiple independent text sentences; then, these sentences are combined with the related examples to form the final knowledge prompt text.
[0134] Step 5: The knowledge-enhanced O&M LLM obtained by the knowledge prompt is used to complete the retrieval of the operation and maintenance database, and the related data returned will be combined with the inquiry as context information, and finally the knowledge-enhanced O&M LLM provides reasonable operation and maintenance analysis and suggestions for the user's inquiry according to the context information.
[0135] (5-1) using the operation and maintenance database obtained by data preprocessing;
[0136] (5-2) using the original O&M LLM fine-tuned by QLoRA;
[0137] (5-3) using the external knowledge base composed of operation and maintenance knowledge graph and example library;
[0138] (5-4) using the knowledge prompt obtained from the external knowledge base to enhance the fine-tuned original O&M LLM to obtain the core model knowledge-enhanced O&M LLM, through the building operation and maintenance knowledge involved in the user inquiry, guiding the core model to generate for the first time, that is, generating correct SQL statements to complete the retrieval of the operation and maintenance database, obtaining related data as the basis for generating replies to inquiries;
[0139] (5-5) the related data returned will be combined with the inquiry as context information, and the knowledge-enhanced O&M LLM will generate for the second time according to the context information, that is, providing reasonable operation and maintenance analysis and suggestions for the user's inquiry.
[0140] The present application also provides a smart building operation and maintenance information inquiry system based on a knowledge-enhanced large language model, which applies the smart building operation and maintenance information inquiry method based on the knowledge-enhanced large language model as described above, as shown in the accompanying drawings, comprising: Figure 2
[0141] The QLoRA model fine-tuning unit is configured to fine-tune the selected base model by using the mixed fine-tuning data set, to strengthen the ability of the large language model to complete the operation and maintenance information inquiry task, and to obtain an original O&M LLM;
[0142] The operation and maintenance large language model subtask unit is configured to use the original O&M LLM to complete three subtasks of key information extraction, knowledge embedding text, and inquiry related data retrieval according to input information;
[0143] The key information extraction refers to extracting key information contained in user inquiry 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 text filling of related classes, triples and examples obtained by external knowledge retrieval by using the original O&M LLM based on a prompt template, to obtain text form knowledge;
[0145] The inquiry related data retrieval refers to related data retrieval of an operation and maintenance data set based on database description and context of user inquiry by using the knowledge-enhanced O&M LLM, to output an SQL query statement, and to obtain related data information after the query;
[0146] The external knowledge retrieval unit is configured to use the inquiry key information to perform knowledge retrieval and text vector matching on an operation and maintenance knowledge graph and an example library respectively, to obtain inquiry related knowledge information, i.e., classes, triples and examples;
[0147] The knowledge retrieval is implemented based on a class priority-based knowledge graph search algorithm of a building entity;
[0148] The text vector matching is implemented based on a Euclidean distance to calculate the similarity of text vectors;
[0149] The operation and maintenance database query unit is configured to store the operation and maintenance data after data preprocessing;
[0150] The operation and maintenance data includes six-dimensional environment monitoring data, water energy consumption monitoring data, electricity energy consumption monitoring data and monitoring device point information in terms of categories;
[0151] The operation and maintenance large language model dialogue generation unit is configured to use the knowledge-enhanced O&M LLM obtained by knowledge enhancement on the original O&M LLM, to generate operation and maintenance analysis and suggestions related to inquiry according to user inquiry and inquiry related context obtained by the above unit;
[0152] User interaction platform: used for inputting user inquiries and saving historical dialogue records between users and the model.
[0153] The user interaction platform interface developed according to the above system design is demonstrated as shown in Figure 9
[0154] The following experimental results show that, compared with existing methods, the present application uses knowledge to enhance the large language model to complete the operation and maintenance information inquiry and achieves better results.
[0155] The present embodiment uses the CSpider dataset and the designed operation and maintenance inquiry dataset for experiments. There are 1063 data in the CSpider dataset for evaluation test, and 466 inquiry evaluation sets are constructed for evaluation test for operation and maintenance information inquiry capability.
[0156] On the CSpider evaluation set and the operation and maintenance information inquiry evaluation set, the experiment uses execution accuracy as the evaluation standard to evaluate the accuracy of the model in completing the inquiry. This standard is referenced from the literature "DB-GPT-Hub: Towards Open Benchmarking Text-to-SQL Empowered by Large Language Models", and a series of SOTA models are tested based on this standard as experimental results.
[0157] Table 1 is the test result of the original O&M LLM in the present application on the operation and maintenance information inquiry 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 of Table 1 show that the fine-tuning of the original O&M LLM in the present application significantly improves its performance in specific domain tasks. The fine-tuned original O&M LLM improves the execution accuracy by nearly 25% compared to the base model Qwen-32B. At the same time, the model achieves 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 specific domain problems, far exceeding 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, and in the embodiments of the present application, the 14B parameter scale model is obviously unable to perform complex operation and maintenance information inquiry tasks. In addition, models with a parameter scale of about 30B, such as Yi-34B, Wizardcoder-33B, and Qwen-32B, have a difference of less than 5% from CodeLlama-70B tested in the experiment. Since the models were tested in the experiment using the same prompts, it cannot be ruled out that each model did not perform at its best, and the ideal accuracy difference may be different. However, considering the deployment and training costs, using a model with a parameter scale of about 30B is more economically beneficial, so it is undoubtedly appropriate to choose the Qwen-32B model as the base model for training in this study.
[0161] Llama2-70B performs relatively poorly when compared to similar-scale models, and this performance deficiency is mainly attributed to the lack of specialized training in Chinese or programming for this model, which hinders its ability to effectively interpret Chinese operation and maintenance information inquiries in the embodiments of the present application, leading to misunderstandings of the inquiry purpose 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 trained specifically for programming capabilities, perform well on the operation and maintenance information inquiry evaluation set.
[0162] Table 2 is a test result of the original O&M LLM in the present application 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 performs significantly better 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 mixed training strategy of the present application not only enhances the model's ability to handle complex inquiry tasks in specific domains, but also maintains its generalization ability in the general Text2SQL task.
[0165] In this embodiment, for the evaluation of the knowledge-enhanced O&M LLM, the external knowledge base is vectorized by calling the text-embedding-3-large model of openai and stored in the faiss vector library and connected with the model, at the same time the user's question is vectorized, the most similar example content is matched according to the Euclidean distance, the number of examples is set to top k = 3, and the operation and maintenance database is connected with the knowledge-enhanced O&M LLM to complete retrieval. The knowledge-enhanced O&M LLM after introducing the RAG technology is tested on the operation and maintenance information inquiry evaluation set, and the performance of each model is compared using the heat map according to the test results above, as shown in Figure 8
[0166] Figure 8 In this embodiment, the execution accuracy of the knowledge-enhanced O&M LLM represents the final performance of our invention in the operation and maintenance information inquiry task, and the 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, which is mainly because it is extremely difficult to achieve further improvement when the accuracy exceeds 90%, and within this high accuracy range, errors are often concentrated on particularly challenging queries, involving rare fault scenarios or complex system interactions. In addition, the number and difficulty of test queries are limited, which also limits 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 application and cannot limit the protection scope of the present application. For ordinary skilled persons in the technical field, they can make several improvements and refinements without departing from the principles of the present application, and these improvements and refinements fall within the protection scope of the claims of the present application.
Claims
1. A method for intelligent building operation and maintenance inquiry based on knowledge-enhanced large language model, characterized in that, The method comprises the following steps: Step (1), for the massive sensor data for operation and maintenance information inquiry in real smart buildings, the data preprocessing of screening abnormal values by unsupervised anomaly detection method is carried out, so as to improve the reliability of the data as the basis for inquiry reply, and the preprocessed data is stored in the operation and maintenance database; Step (2), a hybrid fine-tuning dataset composed of question-SQL pairs is constructed to train the LLM through QLoRA, QLoRA is a fine-tuning technology that introduces an additional low-rank adaptation matrix to expand the function of the LLM under the original model parameters, so as to obtain an original O&M LLM enhanced in the ability of converting natural language into SQL in the operation and maintenance inquiry scene; Step (3), according to the structure information and operation and maintenance rules of the actual building, the entities and relationships are defined based on the triple pattern to construct the operation and maintenance knowledge graph, and a small number of examples are constructed according to the classic scenes of operation and maintenance information inquiry, and the examples and the knowledge graph are used as the external knowledge base together; Step (4), for the search of the knowledge graph, the entity involved in the operation and maintenance inquiry is defined as the building level information classification and the corresponding priority, and a graph search algorithm based on the priority of the building entity is designed, and the class and triple related to the inquiry in the operation and maintenance knowledge graph are obtained; for the search of the examples, the method of text vector matching is used to select the top three examples with the highest relevance; finally, the LLM is guided to convert the inquiry-related classes, triples and examples into continuous text form of knowledge prompts under the designed prompt template; Step (5), the knowledge-enhanced O&M LLM is obtained through the knowledge prompts to complete the retrieval of the operation and maintenance database, and the relevant data returned together with the inquiry are used as the context information, and finally the knowledge-enhanced O&M LLM provides reasonable operation and maintenance analysis and suggestions for the inquiry of the user according to the context information.
2. The knowledge-enhanced large language model-based intelligent building operation and maintenance inquiry method according to claim 1, characterized in that, Step (1) comprises the following steps: (1-1), for the massive sensor data for operation and maintenance information inquiry in real smart buildings, unsupervised anomaly value detection is carried out based on the isolation forest algorithm; the isolation forest algorithm utilizes the fact that abnormal data is "few and different", and isolates each instance by effectively constructing a tree structure, wherein the abnormal value is usually isolated after a few rounds, and the normal value obviously needs more and more complex cutting partition, so when the random forest generates a shorter path length for some specific points, these points are likely to be abnormal; the specific algorithm steps are as follows: Step 111, randomly select m features on the data sample X = {x1,..., xn} of n instances, split the data points by randomly selecting a value between the maximum and minimum values of the selected features, and repeat the division recursively until all data samples are isolated, thereby constructing an isolation tree. n} on the data sample X = {x1,..., xn} of n instances, split the data points by randomly selecting a value between the maximum and minimum values of the selected features, and repeat the division recursively until all data samples are isolated, thereby constructing an isolation tree. Step 112, the isolation forest path length is calculated, which is defined by the following formula: h(x) = e + c(T.size) Wherein, h(x) is the path length of a single data sample on iTree, e is the number of edges experienced by data sample x from the root node of the tree to the leaf node, T.size represents the number of samples in the same leaf node as sample x, and c(T.size) is regarded as a correction value, which represents the average path length of a binary tree constructed by T.size samples; the calculation formula of c(n) is as follows: Wherein, H(i) is the harmonic number, estimated by ln(i) + 0.5772156649 (Euler's constant), the purpose of the correction is to make the path length difference between abnormal and normal samples larger; Step 113, calculate the anomaly score, defined by the following formula: Wherein, E(h(x)) is the average value of the depth reached by a single data sample x in all iTree, h(x) is normalized by c(n) to map s into the range of (0, 1), when the path length of the data sample is smaller, s is closer to 1, at this time the probability of the data sample being an outlier is greater; When E(h(x)) is more close to the average path length c(n) of the node where the sample is located, the anomaly score s tends to 0.5; When E(h(x)) is more close to 0, that is, the path length of the data sample is smaller, the feature segmentation ends at an earlier position, and the anomaly score s is more close to 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; Step 114, set a threshold k to screen all data samples on iTree for appropriate anomalies, and remove data samples with anomaly score s greater than or equal to k as outliers.
3. The knowledge-based enhanced large language model method for intelligent building operation and maintenance inquiry according to claim 1, characterized in that, Step (2) includes the following steps: (2-1), based on the general Text2SQL dataset mixed with operation and maintenance information inquiry-SQL pairs to build a mixed fine-tuning dataset where each sample pair contains an inquiry x (i) and its corresponding SQL statement y (i) ; (2-2), use the mixed fine-tuning data set to train the model, the training target 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, there is a definition of the following training objective function: wherein, Yt,i is the target output value for the i-th sample at time step t, used to compare with the output value of the model under the guidance of gradient descent process, making the prediction of the model closer to the real target output; Meanwhile, the training is based on the QLoRA technique; specifically, all parameters W of the base model are locked during training, and only the newly added network layers are adjusted after inputting the training data X; in the initial stage, the newly added weights W are initialized by a Gaussian distribution A , and the weights W B are set to zero matrices, which means that the newly added path BA does not have any impact on the model output at the beginning of training; and in the inference stage, the original language model weights are updated as follows to achieve the enhancement and optimization of the original weights: h = WX + W A W B X = (W + W A W B ).
4. The knowledge-based enhanced large language model method for intelligent building operation and maintenance inquiry according to claim 1, characterized in that, Step (3) includes the following steps: (3-1), according to the structure information and operation and maintenance rules of the actual building, describe in detail from the basic floor information to the division of various functional spaces in each floor, integrate the association of space and water, electricity and energy consumption, environmental sensing equipment, and cover the spatial position distribution of various sensors and the standard threshold setting of various monitoring data, and build a building information entity and relationship through the way of triple to obtain the operation and maintenance knowledge graph; (3-2), the information inquiry that may appear in the intelligent building operation and maintenance is systematically analyzed and 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 are designed, and the corresponding SQL query statements are given as reference examples.
5. The knowledge-based enhanced large language model method for intelligent building operation and maintenance inquiry according to claim 1, characterized in that, Step (4) includes the following steps: (4-1), the search on the operation and maintenance knowledge graph is based on the class priority of the building entity, and the specific process is as follows: Step 411, according to the obvious type distinction and level affiliation between the building entities involved in the inquiry, define the building level 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 the basis for pruning in the retrieval pruning process; Step 412, key information extraction is performed on the inquiry raised by the user by using the original O&M LLM, to obtain the building operation and maintenance entity e involved in the inquiry i (i = 1, 2,..., N), the class to which it belongs is c i (i = 1, 2,..., N), and the search depth is defined as d, and the center entity of each search depth Step 413, according to the building operation entity set E = {e1, e2,..., e N} involved in the inquiry and the class set C = {c1, c2,..., c N} to which each entity belongs, the operation graph is initialized for subgraph search path, and the building operation entity belonging to the highest priority class in the inquiry is defined as the center entity of initial retrieval Step 414, using a beam search process with depth 1 and width N, find all triples related to the current center entity using relation search, thus obtaining a candidate tail entity set Step 415, using the class-based pruning process, pruning and deleting the tail entities that do not belong to the next level of the current central entity; Step 416, using the prompt information, judging and scoring the relevance of the candidate tail entity set and the original query by LLM, so as to screen out the triplets and the corresponding tail entity set R which have relevance with the question d (d=d, 2, …, M), so as to obtain the union set of the tail entity and the center entity Step 417, according to the category set C obtained from the query as the search depth judgment condition, that is, E S When the corresponding building entity category in the middle can cover the category set C appearing in the query, that is, it is ensured that all subgraphs related to the query have been retrieved; if it cannot be covered, let R d The entity in the middle as the central entity of the next depth search And repeat steps 414-417 until E S The class to which the entity in the middle belongs completely covers the category set C; in this way, all knowledge triples related to the query and the corresponding classes are extracted; (4-2), for example, the Euclidean distance is used to evaluate the similarity between the user inquiry 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 inquiry are selected; (4-3), under the designed prompt template, guide the LLM to convert the above inquiry-related classes, triples and examples into continuous text form of knowledge prompts.
6. The knowledge-based enhanced large language model method for intelligent building operation and maintenance inquiry according to claim 1, characterized in that, Step (5) includes 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 the external knowledge base composed of operation and maintenance knowledge graph and example library; (5-4) using the knowledge prompts obtained from the external knowledge base to enhance the fine-tuned original O&M LLM, obtaining the core model knowledge-enhanced O&M LLM, guiding the core model to generate for the first time through the building operation and maintenance knowledge involved in the user inquiry, that is, generating correct SQL statements to complete the retrieval of the operation and maintenance database, obtaining relevant data as the basis for generating a reply to the inquiry; (5-5) the relevant data returned will be used as context information together with the inquiry, and the knowledge-enhanced O&M LLM will generate for the second time according to this context information, that is, providing 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 the knowledge-enhanced large language model in any one of claims 1-6, characterized in that, It includes: QLoRA model fine-tuning unit: used to fine-tune the selected base model using the mixed fine-tuning dataset, to enhance the ability of large language models to complete operation and maintenance information inquiry tasks, and obtain original O&M LLM; Operation and maintenance large language model subtask unit: used to use original O&M LLM to complete three subtasks of key information extraction, knowledge embedding text, and inquiry-related data retrieval according to input information; The key information extraction refers to using original O&M LLM to extract the key information contained in the user inquiry, and using the information as the input of the knowledge retrieval and text vector matching in the external knowledge retrieval unit; The knowledge embedding text refers to text filling of related classes, triples and examples obtained by external knowledge retrieval based on a prompt template using an original O&M LLM, to obtain knowledge in a text form; The inquiry related data retrieval refers to related data retrieval of an operation and maintenance data set based on a database description and a context of a user inquiry using a knowledge-enhanced O&M LLM, output of an SQL query statement, and obtaining of related data information after the query; An external knowledge retrieval unit is configured to perform knowledge retrieval and text vector matching on an operation and maintenance knowledge graph and an example library respectively using the inquiry key information, to obtain inquiry related knowledge information, i.e. classes, triples and examples; The knowledge retrieval is implemented based on a class priority knowledge graph search algorithm of a building entity; The text vector matching is implemented based on a Euclidean distance to calculate a similarity of text vectors; An operation and maintenance database query unit is configured to store operation and maintenance data after data preprocessing; The operation and maintenance data includes six-dimensional environment monitoring data, water consumption energy consumption monitoring data, electricity consumption energy consumption monitoring data and monitoring equipment point information in terms of categories; An operation and maintenance large language model dialogue generation unit is configured to generate operation and maintenance analysis and suggestions related to an inquiry based on a user inquiry and an inquiry related context obtained by the above units using a knowledge-enhanced O&M LLM obtained by knowledge enhancement on an original O&M LLM; A user interaction platform is configured to input a user inquiry and save historical dialogue records of a user and a model.
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