CN-122019592-A - Intelligent building self-optimizing query system and query method
Abstract
The invention discloses a self-optimizing query system and a query method of an intelligent building, wherein the query system comprises a user interaction module, a natural language processing module, a knowledge retrieval module, a knowledge storage module, a data access module and a data source module, wherein the knowledge storage module stores knowledge vectors which are derived from vector sub-databases in a multi-element heterogeneous knowledge base, the knowledge vectors are obtained by vectorizing multiple knowledge of sub-knowledge bases in the multi-element heterogeneous knowledge base, and the sub-knowledge base comprises a data structure knowledge sub-knowledge base, a business logic knowledge sub-knowledge base and a query mode knowledge sub-knowledge base. The system combines the large language model with the technologies of a multi-element heterogeneous knowledge base, dynamic context generation and the like, is applied to intelligent building data analysis, and solves the problems of high query threshold, slow response, poor flexibility and difficult multiplexing of domain knowledge in the existing intelligent building data analysis.
Inventors
- XIN GUOMAO
- GUO LEI
- LIU KE
- LIU SHAN
- HAO JINGQUAN
- MA SHUJIE
Assignees
- 泰华智慧产业集团股份有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260130
Claims (7)
- 1. An intelligent building self-optimizing query system, comprising: The system comprises a user interaction module, a natural language processing module, a knowledge retrieval module, a knowledge storage module, a data access module and a data source module; The knowledge storage module stores a knowledge vector, wherein the knowledge vector is derived from a vector sub-database in a multi-element heterogeneous knowledge base, the knowledge vector is obtained by vectorization processing of multi-element knowledge of a sub-knowledge base in the multi-element heterogeneous knowledge base, the sub-knowledge base comprises a data structure knowledge sub-knowledge base, a business logic knowledge sub-knowledge base and a query mode knowledge sub-knowledge base, the data structure knowledge sub-database is used for storing a data definition language and comprises structure definitions for storing a worksheet, the structure definitions of the worksheet comprise table names, field names, data types and constraint conditions, the worksheet is a worksheet in a relational database of an intelligent building business system, the business logic knowledge sub-database is used for storing business rules, calculation logics, term definitions, special field meanings, value rules and business scene descriptions, the query mode knowledge sub-database is used for storing problem-structured query language pairings which are used as a reference template for generating structured query languages of a large language model, and comprise typical problems and corresponding structure pairs of the typical problems, the worksheet is a worksheet in the database, and the worksheet is provided with a multi-language pairing algorithm; The user interaction module is coupled with the natural language processing module and is used for integrating a web page interface, a representational state transfer application programming interface and instant messaging, and the client side inputs natural language problems through the user interaction module; The system comprises a user interaction module, a knowledge retrieval module, a natural language processing module, a data access module, a data processing module, a query result set and a query result set, wherein the user interaction module is used for receiving a user interaction module, the natural language processing module is coupled with the user interaction module and comprises a large language model, the natural language processing module receives the natural language problem, adopts the large language model to understand the natural language problem, is coupled with the knowledge retrieval module, and is used for carrying out intention recognition according to a prompt word output by the knowledge retrieval module by the large language model to generate a structured query language corresponding to the natural language problem; The knowledge retrieval module is coupled with the natural language processing module, converts the natural language problem into a problem vector according to the structured query language output by the natural language processing module, performs similarity matching on the problem vector and a knowledge vector in the vector sub-database, retrieves to obtain a corresponding knowledge item, constructs a structured context of the knowledge item, obtains the constructed prompt word, feeds back the prompt word to the natural language processing module and processes the prompt word by the large language model; the knowledge storage module is coupled with the knowledge retrieval module and is used for providing knowledge vector data for the knowledge retrieval module to retrieve and inquire; The data access module is coupled with the natural language processing module, and is used for connecting the natural language processing module with the data source module, executing query according to the structured query language generated by the natural language processing module, and returning a query result to the natural language processing module for processing; the data source module is coupled with the data access module, and comprises a relational database of the intelligent building service system and is used for providing original data in the relational database for query.
- 2. The intelligent building self-optimizing query system of claim 1, wherein the large language model is OpenAI-API compatible model.
- 3. The intelligent building self-optimizing query system of claim 1, wherein, The vector index algorithm is a hierarchical navigation small world algorithm.
- 4. The intelligent building self-optimizing query system of claim 1, wherein, The type of the relational database includes at least one of MySQL, postgreSQL, oracle.
- 5. The intelligent building self-optimizing query method is characterized by comprising the steps of constructing a multi-element heterogeneous knowledge base, inquiring natural language data and automatically optimizing the multi-element heterogeneous knowledge base data; The method for constructing the multi-element heterogeneous knowledge base comprises the following steps: The knowledge materials are arranged to obtain a knowledge data statistical table, wherein the knowledge data statistical table comprises a data structure knowledge statistical table, a business logic knowledge statistical table and a query mode knowledge statistical table; reading knowledge items in the knowledge data statistical table, and converting the text in the knowledge data statistical table into a knowledge vector by adopting a text embedding model of Chinese optimization; Storing the knowledge vector and the original text in the knowledge data statistical table to a vector sub-database, and establishing a vector index algorithm in the vector sub-database; The natural language data query method comprises the steps of converting natural language problems output by a user end into a structured query language based on a large language model and a search enhancement generation technical paradigm, querying in a relational database of an intelligent building service system according to the generated structured query language, processing an obtained query result set, and summarizing and generating a query result, wherein: The converting the natural language problem output by the user terminal into the structured query language comprises the following steps: The user side inputs a natural language problem, the natural language problem is converted into a problem vector by using the text embedding model, and the problem vector and the knowledge vector are ensured to be in the same semantic space, wherein the text embedding model is the same as the text embedding model adopted in the method for constructing the multi-element heterogeneous knowledge base; In the vector sub-database, carrying out similarity retrieval on the knowledge item and the problem vector, and selecting K retrieval results with highest similarity with the problem vector, wherein K=20, wherein the method of using cosine similarity or Euclidean distance as similarity measurement is adopted; Building a structured context of the retrieved knowledge items, and sorting according to importance and relevance, so as to build a prompt word, wherein the prompt word comprises a user problem and the retrieved knowledge items, the relevance is the similarity, and the importance is the priority of a service; inputting the constructed prompt words into a large language model, and generating a structured query language based on large language model reasoning by the large language model; Checking the correctness of the generated structured query language, verifying whether the name of the worksheet and the name of the field exist, optimizing the query performance, and processing special characters and SQL injection risks; the step of inquiring the relational database of the intelligent building business system according to the generated structured inquiry language, and the step of processing the obtained inquiry result set comprises the following steps: the method comprises the steps of sending a structured query language after verification to a target database, wherein the target database executes query according to the structured query language to obtain a query result set, if execution abnormality exists, capturing the execution abnormality and performing error processing, and recording an execution log for problem investigation, wherein the target database is at least one of relational databases of the intelligent building business system; converting the query result set returned by the target database into a structured format; The summarizing generating the query result includes: inputting the user questions and the query results, calling a large language model, and outputting a result summary in a natural language form, wherein the result summary comprises natural language questions and structured data; the automatic optimization of the multivariate heterogeneous knowledge base data comprises the following steps: Correcting a structured query language for capturing error cases of abnormal execution to obtain correct question-answer pairs, adding the correct question-answer pairs to the query mode knowledge sub-knowledge base in the multi-heterogeneous knowledge base to form new knowledge items, vectorizing the new knowledge items, and storing the new knowledge items in the vector sub-database.
- 6. The intelligent building self-optimizing query method of claim 5, wherein, The optimizing query performance includes: And adding an index prompt in a special field of the data structure knowledge in the multi-element heterogeneous knowledge base, and informing the large language model when constructing the prompt word, wherein the special field is preferentially considered to be utilized for carrying out large language model reasoning, and comprises a time range field and a specific equipment ID field.
- 7. The intelligent building self-optimizing query method of claim 5, wherein, The converting the query result set returned by the database into the structured format comprises the following steps: and processing the paging and truncation of the result set, and formatting special type data, wherein the special type data comprises date and number.
Description
Intelligent building self-optimizing query system and query method Technical Field The invention relates to the technical field of intelligence, in particular to a self-optimizing query system and a query method for an intelligent building. Background Along with the rapid development of the internet of things technology, a large number of sensors and intelligent devices are deployed in an intelligent building system, wherein the intelligent building system comprises an access control system, a parking management system, a meeting room reservation system, a hydropower meter monitoring system and the like. These systems generate massive amounts of structured data daily, stored in relational databases. However, building management personnel and common users often lack database query skills, and it is difficult to quickly acquire required information, so that the data value cannot be fully exerted. In the traditional data query mode, a professional database manager is required to write SQL sentences, the response period is long, and the real-time decision requirement cannot be met. While some Business Intelligence (BI) tools provide a visual interface, users are still required to understand complex data models and query logic, learning costs are high, and use thresholds are large. The existing intelligent building data query and analysis technology mainly has the following problems that 1, a query threshold is high, response efficiency is low, traditional query depends on SQL language and database knowledge, the traditional query is difficult to use by non-technicians, query requirements are translated through an IT department, response period is long, real-time decisions cannot be met, 2, flexibility is poor, semantic understanding is weak, BI tools generally only provide preset reports and cannot process temporary and personalized query, a system cannot understand natural language and must input the query according to a fixed format, fuzzy semantics cannot be processed, 3, domain knowledge is difficult to precipitate, business rules and query logic are dispersed in specialists and cannot be effectively multiplexed, new staff has high learning cost, knowledge inheritance is difficult, 4, data island problems are outstanding, intelligent building relates to multiple subsystems, data sources are dispersed, unified query inlets are lacked, and data integration and analysis work across the system is very complex. The Chinese patent literature (application number: 202211299032.7, application date: 2022.10.24) discloses a digital twin intelligent building brain-computer device and system, wherein the intelligent building system comprises a CA communication automation subsystem, a BA building electromechanical automation subsystem, a SA security automation subsystem, an FA fire control automation subsystem, an OA office automation subsystem and an HA residential automation subsystem. Through the SDK development kit, the device and the building intelligent system read and interact data such as communication network safety operation data, building electromechanical safety operation data, security video and traffic flow data, water, electricity, gas and heat energy consumption data, fire alarm data, office informatization data, intelligent residence operation data and the like. The intelligent building brain-computer device relates to fusion and analysis of multiple heterogeneous system data, supports receiving data through HTPP, MQTT, OPC and other protocols, and further realizes an extensible and matched data interface mode. The intelligent building brain-computer interface standard also provides a butt joint standard and a fusion direction for a CA communication automation subsystem, a BA building electromechanical automation subsystem, a SA security automation subsystem, a FA fire-fighting automation subsystem, an OA office automation subsystem and an HA residential automation subsystem, and lays a foundation for building intelligent building industry and industrial standards. Brain-computer databases, consisting of IoT databases, 3m+3s databases, expert knowledge databases. The scheme adopts the data fusion of a multi-element heterogeneous system, but does not realize the instant query data of non-technicians and has the problem of insufficient understanding for specific service query. Therefore, how to solve the problems of 1, high query threshold and low efficiency, 2, insufficient understanding of specific business, and 3, static knowledge base and easy outdated knowledge base becomes a technical problem to be solved in the art. Disclosure of Invention In view of the above, the invention provides a self-optimizing query system and a query method for intelligent buildings, which are used for solving the technical problems that 1, the query threshold is high, the efficiency is low, 2, the understanding of specific businesses is insufficient, and 3, the knowledge base is static and easy to be outdated. The system c