Digital factory data query method, device, equipment, medium and product

Through pre-trained natural language understanding model and knowledge graph, semantic analysis of user natural language queries is performed and SQL query statements is generated, which solves the shortcomings of existing Text to SQL technology in query consistency and accuracy, and realizes complex database operations and Multilingual support improves the efficiency and user experience of digital factory data query.

CN119025618APending Publication Date: 2024-11-26INSPUR TIANYUAN COMM INFORMATION SYST CO LTD

Patent Information

Application Number
CN202410929718.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-11
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

The existing Text to SQL technology has shortcomings in user natural language query conversion and query consistency and accuracy, and it is difficult to meet the needs of complex database operations.

Method used

The pre-trained natural language understanding model and knowledge graph are used to perform semantic analysis of user natural language query requests, generate SQL query statements, and build knowledge graphs using user historical query data, support multi-table connections, subqueries and data aggregation, and dynamically optimize query statements .

Benefits of technology

It improves the coherence and accuracy of query, simplifies the interaction between users and databases, enhances data-driven decision-making efficiency, supports complex database operations and multi-language input, and adapts to specific needs of different industries.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119025618A_ABST
    Figure CN119025618A_ABST
Patent Text Reader

Abstract

The invention provides a digital factory data query method and device, equipment, a medium and a product, and belongs to the technical field of computer scientificity, and the method comprises the steps: obtaining a natural language query request of a user; performing semantic analysis on the natural language query request according to a pre-trained natural language understanding model and a pre-constructed knowledge graph to obtain a query intention and a data operation demand of a user; wherein the knowledge graph is constructed based on historical query data of a user; generating an SQL query statement according to the query intention and the data operation requirement; and querying the database of the digital factory according to the SQL query statement to obtain a query result. According to the method, the knowledge graph is constructed through the historical query data of the user, the natural language query request of the user is subjected to semantic analysis by utilizing the natural language understanding model and the knowledge graph, the query intention and the data operation requirement of the user are obtained, context information is fully utilized, and the query coherence and accuracy are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer science and technology, and in particular to a digital factory data query method, device, equipment, medium and product. Background Art

[0002] In the management and operation environment of digital factories, a large amount of data needs to be monitored, queried and analyzed in real time to ensure the efficiency of the production process and the high standards of product quality. Currently, the query and analysis of the above data requires the use of structured query language (SQL), which is a challenge for production and management personnel with non-technical backgrounds because they need to learn and understand complex SQL syntax to effectively interact with the database.

[0003] With the rapid development of artificial intelligence and natural language processing technologies, especially the progress in natural language understanding (NLU) and machine learning, a technical solution for converting natural language queries into SQL queries has emerged, called Text to SQL technology, which enables users to express query requirements in their own language, and Text to SQL technology automatically converts query requirements into corresponding SQL statements.

[0004] However, existing Text to SQL technologies usually only convert the natural language currently input by the user, and the consistency and accuracy of query and conversion need to be improved. Summary of the invention

[0005] The present invention provides a digital factory data query method, device, equipment, medium and product to solve the defect that the prior art only converts the natural language currently input by the user, and the consistency and accuracy of the query and conversion need to be improved.

[0006] The present invention provides a digital factory data query method, comprising obtaining a natural language query request of a user; performing semantic analysis on the natural language query request according to a pre-trained natural language understanding model and a pre-constructed knowledge graph to obtain the user's query intention and data operation requirements; wherein the knowledge graph is constructed based on the user's historical query data; generating an SQL query statement according to the query intention and the data operation requirements; and querying a database of the digital factory according to the SQL query statement to obtain a query result.

[0007] According to a digital factory data query method provided by the present invention, the SQL query statement is generated according to the query intention and the data operation requirement, including: converting the query intention and the data operation requirement into an initial SQL query statement based on a pre-trained large-scale SQL data set; obtaining the user's historical query data and temporarily defined variables, verifying and adjusting the initial SQL query statement according to the historical query data and the temporarily defined variables, and generating the SQL query statement.

[0008] According to a digital factory data query method provided by the present invention, the data operation requirement includes at least one of multi-table connection, sub-query and data aggregation.

[0009] According to a digital factory data query method provided by the present invention, the natural language understanding model is obtained by training a large language model based on a Transformer architecture through a natural language library and a terminology library of a preset field corresponding to the digital factory.

[0010] According to a digital factory data query method provided by the present invention, after obtaining the user's natural language query request, it also includes: if the language of the natural language query request is not the target language, translating the natural language query request into a natural language query request in the target language.

[0011] According to a digital factory data query method provided by the present invention, after querying the database of the digital factory according to the SQL query statement to obtain the query result, it also includes: responding to user feedback information, optimizing the SQL query statement based on the user's historical query data; querying the database of the digital factory based on the optimized SQL query statement to obtain the optimized query result.

[0012] The present invention also provides a digital factory data query device, comprising: an acquisition module, used to obtain a user's natural language query request; a parsing module, used to perform semantic parsing on the natural language query request according to a pre-trained natural language understanding model and a pre-constructed knowledge graph, to obtain the user's query intention and data operation requirements; wherein the knowledge graph is constructed based on the user's query history; a generation module, used to generate an SQL query statement according to the query intention and the data operation requirements; and a query module, used to query the database of the digital factory according to the SQL query statement to obtain a query result.

[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any one of the digital factory data query methods described above is implemented.

[0014] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the digital factory data query method as described in any one of the above is implemented.

[0015] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the digital factory data query method as described above is implemented.

[0016] The digital factory data query method, device, equipment, medium and product provided by the present invention construct a knowledge graph through the user's historical query data, use the natural language understanding model and the knowledge graph to perform semantic analysis on the user's natural language query request, obtain the user's query intention and data operation requirements, make full use of contextual information, and improve the coherence and accuracy of the query. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 It is a flow chart of the digital factory data query method provided by the present invention.

[0019] Figure 2 It is a structural schematic diagram of the digital factory data query device provided by the present invention.

[0020] Figure 3 It is a structural schematic diagram of the digital factory data query system provided by the present invention.

[0021] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0022] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0023] Figure 1 It is a flow chart of the digital factory data query method provided by the present invention, such as Figure 1As shown, the present invention provides a digital factory data query method, which includes steps S100 to S400.

[0024] Step S100, obtaining the user's natural language query request; specifically, a visual interface can be provided to interact with the user, and the natural language query request input by the user in the interface can be obtained, so that the user can directly interact with the database of the present invention through natural language without having in-depth SQL knowledge, thereby simplifying the data access and analysis process and enhancing the efficiency and effectiveness of data-driven decision-making.

[0025] Step S200, semantically parse the natural language query request according to a pre-trained natural language understanding model and a pre-built knowledge graph to obtain the user's query intention and data operation requirements; wherein the knowledge graph is built based on the user's historical query data.

[0026] Step S300, generating an SQL query statement according to the query intent and the data operation requirements. Specifically, the present invention converts the query intent and the data operation requirements into a structured SQL query statement. The present invention can directly generate an SQL query statement according to the query intent and the data operation requirements to achieve simple natural language query conversion, and can also achieve complex queries through context perception to meet the requirements of complex database operations involving multi-table connections, subqueries, etc.

[0027] Step S400, query the database of the digital factory according to the SQL query statement to obtain the query result. Specifically, the SQL query statement is transmitted to the database of the digital factory through the database interface, and the query result is obtained based on the database interface. The database interface can also integrate a real-time monitoring function to automatically detect abnormal situations in the execution of SQL queries, and perform corresponding error processing or retry mechanisms to ensure accurate acquisition of query results and stable operation of the present invention.

[0028] An embodiment of simple natural language query conversion is as follows: Assuming that in a digital factory environment, the user wants to query the detailed information of all production data in January 20XX, and only needs to enter "find detailed information of production data in January 20XX". The present invention performs parsing based on the natural language understanding model and identifies the keywords "find", "January 20XX", "production data" and "detailed information". These keywords constitute the user's query intention. According to the parsing results, the SQL query statement "SELECT * FROM production_data WHERE date>= '20XX-01-01' AND date<= '20XX-01-31'" is constructed. This query statement is then submitted to the database for execution through the database interface, and the query results are returned and displayed on the interface, showing the detailed information of each record in the form of a data table, including date, production line, production quantity, etc. In this way, users can easily obtain the required detailed data without having to master complex SQL syntax.

[0029] In one embodiment, the present invention tracks the user's query history and session status through the knowledge graph to ensure the consistency of the query session. Dynamically manage and reference the user's query history and temporary variables to provide context-related information and suggestions for subsequent queries. The present invention uses long-term dependency processing technology to effectively manage and reference context information in long-term sessions to ensure the accuracy and consistency of continuous queries.

[0030] It can be understood that the present invention constructs a knowledge graph through the user's historical query data, uses the natural language understanding model and the knowledge graph to perform semantic analysis on the user's natural language query request, obtains the user's query intention and data operation requirements, makes full use of contextual information, and improves the coherence and accuracy of the query.

[0031] Based on the above embodiment, as an optional embodiment, the SQL query statement is generated according to the query intention and the data operation requirement, including step S310 and step S320.

[0032] Step S310, based on the pre-trained large-scale SQL data set, the query intent and the data operation requirements are converted into an initial SQL query statement; the large-scale SQL data set contains a large number of SQL statements and corresponding natural language descriptions, and the query intent and data operation requirements are used as keywords to search in the large-scale SQL data set to generate an initial SQL query statement. Through the pre-trained large-scale SQL data set, it is possible to automatically identify multi-table relationships and data aggregation operations in complex queries, generate efficient and optimized query statements, and ensure the accuracy and consistency of query results. Optionally, the data operation requirements include at least one of multi-table connections, subqueries, and data aggregation.

[0033] For example: A user enters a natural language query: "Find the production data for January 20XX", which is converted into "SELECT* FROM production_data WHERE date>= '20XX-01-01' AND date<= '20XX-01-31'".

[0034] Step S320, obtaining the user's historical query data and temporarily defined variables, verifying and adjusting the initial SQL query statement according to the historical query data and the temporarily defined variables, and generating the SQL query statement. The temporarily defined variables can be implemented as subqueries, table variables and / or temporary tables. Verifying and adjusting the initial SQL query statement according to the historical query data and the temporarily defined variables specifically refers to determining whether the initial SQL query statement is associated with the historical query data and the temporarily defined variables, and whether it involves complex database operations such as multi-table connections and subqueries. If so, combining the initial SQL query statement with the SQL query statement corresponding to the historical query data to adjust the initial SQL query statement and generate the SQL query statement.

[0035] For example, the user first queries the production data of January 20XX, and then further queries the data of production line A. After the user enters "search for production data of January 20XX" and obtains the result, the query context information (that is, the historical query data) is saved. When the user continues to enter "search for data of production line A again", it is recognized that "search again" means the continuation of the query, so the new condition "production line A" is automatically merged with the previous query to generate a new SQL query statement "SELECT *FROM production_data WHERE date>= '20XX-01-01' AND date<= '20XX-01-31' ANDproduction_line = 'A'". The query statement is then executed to display the query results that meet the new conditions.

[0036] For example, in a scenario where multi-dimensional data comparison is required, the user may want to query the comparative data of production line A and production line B in the past three months. First, the user inputs "find the data of production line A in the past three months", and the present invention generates and executes the SQL query "SELECT * FROM production_data WHERE date>= DATE_SUB(CURDATE(),INTERVAL 3 MONTH) AND production_line = 'A'" to display the three-month data of production line A. Subsequently, the user inputs "find the data of production line B for comparison", and the present invention recognizes the comparison requirement, generates and executes a new SQL query "SELECT * FROM production_data WHERE date>= DATE_SUB(CURDATE(), INTERVAL 3MONTH) AND production_line = 'B'", and automatically generates a comparison chart to display the data comparison of the two production lines. This automated processing capability helps users efficiently complete complex data analysis tasks.

[0037] For example, in actual operation, the user may need to query multiple times in succession to gradually refine the data. The user first queries "find the production data for January 20XX", generates the SQL query statement "SELECT * FROM production_data WHERE date>= '20XX-01-01' AND date<= '20XX-01-31'", and saves the query context. Next, the user refines the query condition and enters "data where product is X". The present invention uses the context information to generate a new SQL query "SELECT *FROM production_data WHERE date>= '20XX-01-01' AND date<= '20XX-01-31' ANDproduct = 'X'". Further, the user enters "find records with production exceeding 1000", and the present invention generates the final SQL query "SELECT * FROM production_data WHERE date>= '20XX-01-01' AND date<= '20XX-01-31' AND product = 'X' AND quantity>1000". The present invention executes the final query and displays the results, and the user can gradually refine the query conditions in this way to flexibly obtain the required accurate data.

[0038] It can be understood that the present invention, through the reference to context information, can dynamically call the user's historical query data and temporarily defined variables when generating SQL queries, ensure that the generated query statements comply with the context logic, and provide accurate data access, so that users can gradually refine the query conditions in a natural and continuous manner, greatly simplifying the operational process of complex data queries.

[0039] Based on the above embodiment, as an optional embodiment, the natural language understanding model is obtained by training a large language model based on the Transformer architecture using a natural language library and a terminology library of a preset field corresponding to the digital factory.

[0040] Optionally, the natural language understanding model is operated using a natural language understanding algorithm based on the Tongyi Qianwen 72b large model, which performs semantic analysis on the query input by the user. During the analysis process, the model identifies the keywords and phrases in the query, and determines the user's query intent and the data operation requirements involved based on the keywords and phrases, ensuring accurate capture of the query intent, including the identification of the required data tables, fields and operation types.

[0041] Optionally, the present invention also introduces multi-task learning and transfer learning techniques in the model training process of the natural language understanding model, so that the model can show higher accuracy and efficiency when processing specific terms and complex queries in the industrial field. By fine-tuning and optimizing a large amount of industrial field data, efficient natural language query parsing can be achieved in a complex digital factory environment. In order to meet the special needs of the digital factory, the present invention customizes, optimizes and expands the Tongyi Qianwen 72b large model. The optimization process includes increasing the ability to understand the context of the conversation, so that the model can continuously track and manage the user's query history. At the same time, by adding industry-specific terminology libraries and multilingual processing modules, it can flexibly process natural language queries in different languages ​​and adapt to complex industrial environments. The model introduces a multi-task learning mechanism, which enables it to simultaneously process natural language query parsing and context management tasks. By training in a multi-task scenario, the model can better understand complex query requirements and provide high-precision SQL generation.

[0042] For example, digital factory operations often involve specific industry terms, such as "work order". When a user enters the query "Search for work order data in January 20XX", "work order" can be automatically identified as an industry term and mapped to the SQL field "work_order". The natural language understanding model performs semantic analysis on the user input, identifies the keywords "search", "January 20XX", and "work order", and then generates the corresponding SQL query statement "SELECT * FROM work_order WHERE date>= '20XX-01-01' AND date<= '20XX-01-31'". After the SQL query is executed, the work order data is returned and displayed.

[0043] It can be understood that the present invention has the ability to adapt to industry terms, can flexibly respond to professional needs in different fields, and meet the query requirements of various users.

[0044] Based on the above embodiment, as an optional embodiment, after obtaining the user's natural language query request, it also includes: if the language of the natural language query request is not the target language, translating the natural language query request into a natural language query request in the target language.

[0045] The present invention not only supports Chinese input, but also can process multi-language input, ensuring wide application in an international environment. For example, a user inputs "Find production data for January 20XX" in English. The natural language understanding model will translate the query into Chinese "Find production data for January 20XX", perform semantic analysis on it, and identify the query intent. Then, generate the corresponding SQL query statement "SELECT * FROM production_data WHERE date>= '20XX-01-01' AND date<= '20XX-01-31'". After the SQL query statement is submitted to the database for execution, the query results are obtained and displayed, and the results are displayed in Chinese.

[0046] It can be understood that the present invention ensures international applicability through multi-language support, so that users can smoothly perform query operations regardless of the language they use.

[0047] Based on the above embodiment, as an optional embodiment, after querying the database of the digital factory according to the SQL query statement to obtain the query result, step S500 and step S600 are further included.

[0048] Step S500, in response to user feedback, the SQL query statement is optimized based on the user's historical query data; optionally, the query result can be evaluated based on user feedback or by using machine learning to determine the accuracy and performance of the query result. If the user's feedback indicates that the detection result is not accurate enough, the SQL query statement can be optimized based on the feedback information and historical query data, such as modifying the query conditions, optimizing the query path, and adjusting the query parameters to ensure the efficiency and accuracy of the query.

[0049] For example, when a user first searches for production data in January 20XX, he or she may find that the amount of data is too large and difficult to process. After the user enters "search for production data in January 20XX" and obtains the query result, it is detected that the amount of data is large, and the user will be prompted whether to narrow the query scope. The user enters "narrow to the previous 5 days" according to the prompt, and the present invention will generate an optimized SQL query statement "SELECT * FROM production_data WHERE date>= '20XX-01-01' ANDdate<= '20XX-01-05'", and executes the query again to return the result. Through this interactive method, users can continuously adjust and optimize query conditions to obtain query results that better meet their needs.

[0050] Step S600: query the database of the digital factory based on the optimized SQL query statement to obtain an optimized query result.

[0051] It is understandable that the present invention analyzes the user's historical query and context information, provides intelligent query suggestions and optimization solutions, and enhances the user's interactive experience. The recommendation algorithm based on user behavior analysis is added, which can dynamically generate personalized query suggestions based on the user's query pattern and historical records, thereby improving user query efficiency and satisfaction.

[0052] In summary, the present invention has the following beneficial effects.

[0053] 1. Improve query accuracy and understanding depth: By adopting the natural language understanding algorithm based on the Tongyi Qianwen 72b large model, it can deeply analyze the user's natural language query and accurately identify the key information and intent in the query. Compared with traditional natural language processing technology, it can better understand complex sentence structures and professional terms, thereby generating more accurate and efficient SQL query statements.

[0054] 2. Support complex query generation and optimize query execution: Using advanced SQL generation algorithms, the present invention can automatically handle complex database operation requirements, such as multi-table joins, subqueries, and advanced data aggregation. This not only expands the ability of the present invention to handle various data queries, but also improves the query execution efficiency through intelligent optimization algorithms, significantly reducing the response time and load of the database.

[0055] 3. Dynamic query optimization and adaptive adjustment: The present invention implements an interactive query optimization mechanism that dynamically learns and adapts to users' query habits and feedback through machine learning technology, and automatically optimizes the generated SQL query statements. This feature enables the present invention to continuously improve the relevance and accuracy of queries, and maintain high performance even when user needs change.

[0056] 4. Context management enhances user experience: Through the context management algorithm, the present invention can maintain the consistency of queries in continuous query sessions, automatically referencing and managing the user's query history. This not only reduces the need for users to repeatedly input, but also greatly enhances the user's interactive experience by providing context-related information and suggestions.

[0057] 5. Multi-language support and industry adaptability: The present invention supports multiple language inputs and can adapt to the specific needs of different industries. This is achieved by fine-tuning the large model with specific industry data, so that the present invention can not only serve global users, but also accurately process the professional terms and operations of specific industries to meet a wider range of application scenarios.

[0058] The digital factory data query device provided by the present invention is described below. The digital factory data query device described below and the digital factory data query method described above can be referred to each other.

[0059] Figure 2 is a structural diagram of a digital factory data query device provided by the present invention, such as Figure 2 As shown, the present invention further provides a digital factory data query device, including an acquisition module 210 , a parsing module 220 , a generation module 230 and a query module 240 .

[0060] The acquisition module 210 is used to acquire the user's natural language query request.

[0061] The parsing module 220 is used to perform semantic parsing on the natural language query request according to a pre-trained natural language understanding model and a pre-built knowledge graph to obtain the user's query intention and data operation requirements; wherein the knowledge graph is built based on the user's query history.

[0062] The generation module 230 is used to generate an SQL query statement according to the query intention and the data operation requirement.

[0063] The query module 240 is used to query the database of the digital factory according to the SQL query statement to obtain the query result.

[0064] It should be noted that the digital factory data query device provided by the present invention can execute the digital factory data query method described in any of the above embodiments during specific operation, and has the technical effect corresponding to the method, which will not be elaborated in this embodiment.

[0065] Figure 3 is a structural diagram of the digital factory data query system provided by the present invention, such as Figure 3 As shown, the present invention provides a digital factory data query system, including a natural language input module, a natural language understanding module, an SQL generation module, a database interface module, an interactive query optimization module and a context management module.

[0066] The natural language input module is used to receive natural language query requests from users; it supports multi-language input, including Chinese, English and other common languages. Users can use everyday language to describe data query requirements without having to master SQL syntax.

[0067] The natural language understanding module uses a natural language understanding algorithm based on a large language model to perform semantic analysis on the received queries and determine the query intent and data operation requirements. This is implemented using the Tongyi Qianwen 72b large model base based on the Transformer architecture. The model has been pre-trained in a wide range of language environments and has deep semantic understanding capabilities. By fine-tuning specific data in the digital factory field, the understanding accuracy of unique terms and complex query expressions in industrial environments has been significantly improved, thereby ensuring the accuracy and relevance of query generation.

[0068] The SQL generation module generates corresponding SQL query statements based on the query intent and data operation requirements obtained from the natural language understanding module; it not only supports basic SQL operations such as SELECT, JOIN, WHERE and GROUP BY, but also can automatically handle more complex database query requirements. By using the contextual understanding ability of the Tongyi Qianwen 72b large model, it automatically identifies the required data associations and performs appropriate data aggregation operations, thereby optimizing the query structure and improving query execution efficiency.

[0069] The database interface module is used to execute SQL query statements and receive query results.

[0070] The interactive query optimization module dynamically adjusts SQL query statements based on user feedback and query results; it can dynamically adjust SQL queries based on user instant feedback. By adopting machine learning technology, the algorithm continuously learns and adapts to users' query habits and optimization strategies, effectively realizing self-optimization of the query process, thereby improving the speed and quality of query responses. Using natural language processing technology, it analyzes users' historical queries and contextual information, provides intelligent query suggestions and optimization solutions, and enhances users' interactive experience. A recommendation algorithm based on user behavior analysis has been added, which can dynamically generate personalized query suggestions based on users' query patterns and historical records, thereby improving user query efficiency and satisfaction.

[0071] The context management module tracks the user's query history and session status, provides context-related data and query suggestions, and maintains the consistency of the query. By continuously tracking the user's query history and session status, the consistency of the query context is effectively maintained. By utilizing the long-term dependency processing capabilities of the Tongyi Qianwen 72b large model, the previous query definitions and results are dynamically referenced, which significantly improves the accuracy of the query and the user's interactive experience.

[0072] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the digital factory data query method, which includes: obtaining a natural language query request of a user; semantically parsing the natural language query request according to a pre-trained natural language understanding model and a pre-built knowledge graph to obtain the user's query intention and data operation requirements; wherein the knowledge graph is constructed based on the user's historical query data; generating an SQL query statement according to the query intention and the data operation requirements; and querying the database of the digital factory according to the SQL query statement to obtain a query result.

[0073] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0074] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the digital factory data query method provided by the above methods, which method includes: obtaining a natural language query request from a user; semantically parsing the natural language query request based on a pre-trained natural language understanding model and a pre-built knowledge graph to obtain the user's query intention and data operation requirements; wherein the knowledge graph is constructed based on the user's historical query data; generating an SQL query statement based on the query intention and the data operation requirements; and querying the database of the digital factory based on the SQL query statement to obtain a query result.

[0075] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the digital factory data query method provided by the above-mentioned methods, the method comprising: obtaining a natural language query request from a user; semantically parsing the natural language query request according to a pre-trained natural language understanding model and a pre-built knowledge graph to obtain the user's query intention and data operation requirements; wherein the knowledge graph is constructed based on the user's historical query data; generating an SQL query statement according to the query intention and the data operation requirements; and querying the database of the digital factory according to the SQL query statement to obtain a query result.

[0076] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0077] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0078] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A digital factory data query method, characterized in that: include: Obtain the user's natural language query request; The natural language query request is semantically parsed according to a pre-trained natural language understanding model and a pre-built knowledge graph to obtain the user's query intention and data operation requirements; wherein the knowledge graph is built based on the user's historical query data; Generate SQL query statements according to the query intent and the data operation requirements; The database of the digital factory is queried according to the SQL query statement to obtain the query result.

2. The digital factory data query method according to claim 1, characterized in that: Generating a SQL query statement according to the query intent and the data operation requirements includes: Converting the query intent and the data operation requirements into an initial SQL query statement based on a pre-trained large-scale SQL data set; The user's historical query data and temporarily defined variables are obtained, and the initial SQL query statement is verified and adjusted according to the historical query data and the temporarily defined variables to generate the SQL query statement.

3. The digital factory data query method according to claim 1 or 2, characterized in that: The data operation requirement includes at least one of multi-table connection, subquery and data aggregation.

4. The digital factory data query method according to claim 1, characterized in that: The natural language understanding model is obtained by training a large language model based on a Transformer architecture using a natural language library and a terminology library of a preset field corresponding to the digital factory.

5. The digital factory data query method according to claim 1, characterized in that: After obtaining the user's natural language query request, the method further includes: If the language of the natural language query request is not the target language, the natural language query request is translated into a natural language query request in the target language.

6. The digital factory data query method according to claim 1, characterized in that: After querying the database of the digital factory according to the SQL query statement to obtain the query result, the method further includes: In response to user feedback, optimizing the SQL query statement based on the user's historical query data; The database of the digital factory is queried based on the optimized SQL query statement to obtain the optimized query result.

7. A digital factory data query device, characterized in that: include: An acquisition module, used to obtain a user's natural language query request; A parsing module, used to perform semantic parsing on the natural language query request according to a pre-trained natural language understanding model and a pre-built knowledge graph to obtain the user's query intention and data operation requirements; wherein the knowledge graph is built based on the user's query history; A generation module, used to generate SQL query statements according to the query intent and the data operation requirements; The query module is used to query the database of the digital factory according to the SQL query statement to obtain the query result.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the digital factory data query method according to any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the digital factory data query method according to any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the digital factory data query method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Database metadata relational knowledge graph generation method

    CN115203337A

  • SQL (Structured Query Language) statement generation method and system, medium and equipment

    CN117251469A

  • Method for converting full-link natural language into structured query language

    CN118227653A

  • Human-machine conversation method and apparatus, device, and storage medium

    WO2023051021A1

Cited By

  • Method and device for generating SQL (Structured Query Language) based on semantic alignment and hierarchical Agent

    CN119377255A

  • Method for determining recommendation result based on user demand and electronic equipment

    CN119396872A

  • Method and electronic device for determining recommendation results based on user needs

    CN119396872B

  • Risk query method and device based on large model, medium and equipment

    CN119621759A

  • Power question query method based on large model

    CN119988405A