Method and device for realizing NL2SQL based on operation and maintenance industry large model
Through the NL2SQL method based on the operation and maintenance industry big model, the problems of poor adaptability and insufficient customization in the application of the operation and maintenance industry are solved, and a more accurate and efficient conversion from natural language to structured query language is achieved, which improves operation and maintenance efficiency.
Patent Information
- Application Number
- CN202510092551.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-21
- Publication Date
- 2025-05-09
AI Technical Summary
The existing NL2SQL technology has poor adaptability and insufficient customization in the application of the operation and maintenance industry, and cannot effectively handle specific terms and complex data structures in the operation and maintenance industry.
Using a large model based on the operation and maintenance industry, an efficient NL2SQL statement model is generated by generating seed problems and SQL statements, expanding problem sets, dividing training sets and test sets, and supervising fine-tuning training of the initial model is carried out to generate an efficient NL2SQL statement model.
A more accurate and efficient NL2SQL conversion is achieved, which can better understand the professional terms and data structures in the field of operation and maintenance, improve operation and maintenance efficiency and reduce the risk of human error.
Smart Images

Figure CN119961285A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to a method and device for implementing NL2SQL based on a large model of an operation and maintenance industry. Background Art
[0002] With the continuous development and popularization of information technology, the operation and maintenance industry plays a vital role in the process of enterprise informatization. Operation and maintenance personnel are responsible for monitoring, maintaining and managing the enterprise's IT systems and network equipment to ensure their normal operation and efficient performance. However, with the continuous expansion and increase in complexity of IT systems, operation and maintenance work has become more and more arduous and complicated. In order to improve the efficiency and accuracy of operation and maintenance work, the technology of natural language to structured query language (NL2SQL) came into being.
[0003] NL2SQL technology aims to convert natural language questions raised by users into database query language through natural language processing and artificial intelligence technology, thereby realizing fast query and operation of the database. In the operation and maintenance industry, NL2SQL statement technology can help operation and maintenance personnel to raise queries and operate databases more quickly and accurately, thereby improving operation and maintenance efficiency and reducing the risk of human error.
[0004] However, there are still some challenges and limitations in the application of existing NL2SQL technology in the operation and maintenance industry. First, the operation and maintenance industry has its own specific terminology and data structure, and the existing general NL2SQL model often cannot adapt well to the needs of the operation and maintenance industry. Second, the operation and maintenance industry has a huge amount of data and high data complexity, which requires a more professional and customized NL2SQL solution. Summary of the invention
[0005] The embodiments of the present invention provide a method and device for implementing NL2SQL based on a large model of the operation and maintenance industry, which can provide a more professional and customized NL2SQL solution.
[0006] According to one aspect of the present invention, a method for implementing NL2SQL based on a large model of an operation and maintenance industry is provided, comprising:
[0007] Generate a preset number of seed questions and a first SQL statement corresponding to each of the seed questions, and construct a seed question set and a seed SQL statement according to the seed questions and the first SQL statement;
[0008] Generate an expanded question set based on the seed question set and a second SQL statement corresponding to each expanded question in the expanded question set;
[0009] Divide the training set and the test set according to the seed question set, the expanded question set, the first SQL statement, and the second SQL statement, and generate a json format training set;
[0010] The preset initial model is trained by using the training set and the test set to obtain an NL2SQL statement model, so as to obtain an SQL statement by inputting a request question into the NL2SQL statement model.
[0011] Optionally, the method further includes:
[0012] Verifying the accuracy and reliability of the seed question set and the seed SQL statement;
[0013] The matching degree between the seed question set and the seed SQL statement and the corresponding SQL is verified.
[0014] Optionally, generating an expanded question set based on the seed question set and a second SQL statement corresponding to each expanded question in the expanded question set includes:
[0015] For the seed question in the seed question set, call GPT4 to construct a prompt text to generate an expanded sentence;
[0016] Call GPT4 to build prompt text and generate extended SQL statements for extended questions;
[0017] Use the script to connect to the MYSQL database and verify whether the execution results of the seed SQL statement and the extended SQL statement are consistent; if the results are consistent, use the extended SQL as the second SQL statement.
[0018] Optionally, dividing the training set and the test set according to the seed question set, the expanded question set, the first SQL statement, and the second SQL statement and generating the training set in json format includes:
[0019] Dividing the seed question set, the expanded question set, the first SQL statement, and the second SQL statement into a training set and a test set according to a preset ratio;
[0020] Convert the training set questions into JSON format, including table selection logic, field logic, and generated SQL statements;
[0021] Store the training set files in json format in the preset NL2SQL directory.
[0022] Optionally, the training of a preset initial model by using a training set and a test set includes:
[0023] Modify the fine-tuning startup parameters and set the position of the base model;
[0024] Enter the preset NL2SQL directory location and the output model file location;
[0025] Set the number of cards used for fine tuning and the cards used for fine tuning;
[0026] Start the model training script to perform supervised fine-tuning training.
[0027] Optionally, the method further includes:
[0028] Perform evaluation on the test set and connect to the MySQL database;
[0029] Execute the preset evaluation script to verify whether the SQL statements generated by the model are consistent with the SQL statement results in the test set. If they are consistent, mark them as correct; if not, mark them as requiring manual verification.
[0030] Optionally, the method further includes:
[0031] Encapsulate NL2SQL into an interface for other systems to call;
[0032] Create interface services through technical framework;
[0033] Set the external access IP address and port number of the interface so that other systems can access the interface through the network;
[0034] Configure the security access policy for the interface.
[0035] According to another aspect of the present invention, a device for implementing NL2SQL based on a large model of an operation and maintenance industry is provided, comprising:
[0036] A generating unit, configured to generate a preset number of seed questions and a first SQL statement corresponding to each of the seed questions, and construct a seed question set and a seed SQL statement according to the seed questions and the first SQL statement;
[0037] An expansion unit, configured to generate an expanded question set and a second SQL statement corresponding to each expanded question in the expanded question set based on the seed question set;
[0038] A division unit, used for dividing a training set and a test set according to the seed question set, the expanded question set, the first SQL statement and the second SQL statement, and generating a training set in JSON format;
[0039] The training unit is used to train a preset initial model through a training set and a test set to obtain an NL2SQL statement model, so as to obtain an SQL statement by inputting a request question into the NL2SQL statement model.
[0040] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0041] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method for implementing NL2SQL based on the operation and maintenance industry big model as described in any embodiment of the present invention.
[0042] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for implementing NL2SQL based on the operation and maintenance industry big model described in any embodiment of the present invention when executed.
[0043] The embodiment of the present invention provides a method and device for implementing NL2SQL based on a large model of the operation and maintenance industry. Generate a preset number of seed questions and a first SQL statement corresponding to each seed question, and construct a seed question set and a seed SQL statement according to the seed question and the first SQL statement; generate an extended question set and a second SQL statement corresponding to each extended question in the extended question set based on the seed question set; divide the training set and the test set according to the seed question set, the extended question set, the first SQL statement and the second SQL statement, and generate a json format training set; train the preset initial model through the training set and the test set to obtain an NL2SQL statement model, so as to obtain an SQL statement by inputting the request question into the NL2SQL statement model. The solution of the embodiment of the present invention establishes a large-scale deep learning model for the operation and maintenance industry, so that the system can better understand the professional terminology, data structure and query requirements in the operation and maintenance field, and achieve more accurate and efficient NL2SQL conversion.
[0044] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. 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.
[0046] Figure 1It is a flow chart of a method for implementing NL2SQL based on a large model of the operation and maintenance industry provided by an embodiment of the present invention;
[0047] Figure 2 It is a structural diagram of a device for implementing NL2SQL based on a large model of the operation and maintenance industry provided by an embodiment of the present invention;
[0048] Figure 3 It is a structural schematic diagram of an electronic device that implements the method for implementing NL2SQL based on a large model of the operation and maintenance industry according to an embodiment of the present invention. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0050] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0051] With the continuous development and popularization of information technology, the operation and maintenance industry plays a vital role in the process of enterprise informatization. Operation and maintenance personnel are responsible for monitoring, maintaining and managing the enterprise's IT systems and network equipment to ensure their normal operation and efficient performance. However, with the continuous expansion and increase in complexity of IT systems, operation and maintenance work has become more and more arduous and complicated. In order to improve the efficiency and accuracy of operation and maintenance work, the technology of natural language to structured query language (NL2SQL) came into being.
[0052] NL2SQL technology aims to convert natural language questions raised by users into database query language through natural language processing and artificial intelligence technology, so as to achieve fast query and operation of the database. In the operation and maintenance industry, NL2SQL technology can help operation and maintenance personnel to raise queries and operate databases more quickly and accurately, thereby improving operation and maintenance efficiency and reducing the risk of human error.
[0053] However, there are still some challenges and limitations in the application of existing NL2SQL technology in the operation and maintenance industry. First, the operation and maintenance industry has its own specific terminology and data structure, and the existing general NL2SQL model often cannot adapt well to the needs of the operation and maintenance industry. Secondly, the operation and maintenance industry has a huge amount of data and high data complexity, which requires more professional and customized NL2SQL solutions. Therefore, the NL2SQL method and system based on the large model of the operation and maintenance industry came into being.
[0054] like Figure 1 As shown, an embodiment of the present invention provides a method for implementing NL2SQL based on a large model of the operation and maintenance industry. The method may include the following steps:
[0055] S110: Generate a preset number of seed questions and a first SQL statement corresponding to each seed question, and construct a seed question set and a seed SQL statement according to the seed questions and the first SQL statement.
[0056] Using the existing database query log, natural language questions are matched with query statements to generate some annotated data. The operation and maintenance personnel manually create natural language and corresponding SQL query statements to generate some annotated data. For example, a total of 1,000 seed questions and 1,000 corresponding seed SQL statements are generated. The table structure of the operation and maintenance industry involved in this patent is the alarm table 'alter', the work order table 'workorder', the duty table 'user_onduty_info', and the cloud center mapping relationship table
[0057] 'cloud_center', satisfaction table 'workorder_satisfication_score'.
[0058] In an embodiment of the present invention, the method may further include the following steps:
[0059] Verifying the accuracy and reliability of the seed question set and the seed SQL statement;
[0060] The matching degree between the seed question set and the seed SQL statement and the corresponding SQL is verified.
[0061] Verify the seed data set to ensure the accuracy and reliability of the seed questions and seed SQL. Through verification, you can verify the matching degree between the seed questions and the corresponding SQL, eliminate possible errors or inconsistencies, and ensure that the data set meets actual needs. Verification can discover and correct potential problems, improve the quality of the data set, and lay a solid foundation for subsequent data processing and model training.
[0062] S120: Generate an expanded question set based on the seed question set and a second SQL statement corresponding to each expanded question in the expanded question set.
[0063] In the embodiment of the present invention, step S120 specifically includes:
[0064] For the seed question in the seed question set, call GPT4 to construct a prompt text to generate an expanded sentence;
[0065] Call GPT4 to build prompt text and generate extended SQL statements for extended questions;
[0066] Use the script to connect to the MYSQL database and verify whether the execution results of the seed SQL statement and the extended SQL statement are consistent; if the results are consistent, use the extended SQL as the second SQL statement.
[0067] Exemplarily, GPT4 is called to generate expanded questions for the sorted seed questions, and each seed question is expanded by 10 items, with the same semantics as the original question.
[0068] Call GPT4 to generate an extended statement. The constructed prompt text is as follows:
[0069] "Please construct a batch of new questions based on the original questions provided. All questions are stored in a json object. The new questions should maintain the original meaning and slightly adjust the wording of the question to make it similar to the original question but different in meaning. Original question: "Please provide at least 10 new questions and make sure they increase diversity and novelty while maintaining the original meaning."
[0070] Since there are many different implementation forms of SQL for the same problem, call GPT4 to generate SQL for the extended problem. The constructed prompt text is as follows:
[0071] "Please write the SQL for the following questions based on the contents and relationships of the following five tables. All questions correspond to only one SQL answer. If multiple SQLs are involved, please use join to perform multi-table joint query. The MySQL version is 8.3. Question: {} Answer format: SELECT. And splice the alarm table, work order table, duty table, cloud center mapping relationship table, satisfaction table table structure and the relationship between the table structures into the prompt."
[0072] Use the script to connect to the MYSQL database and verify whether the execution results of the seed SQL and the extended SQL are consistent. If the results are consistent, we will use the extended SQL as the candidate SQL to ensure that the SQL generated by the extension is consistent with the seed SQL in execution results, so as to verify the accuracy of the extended SQL.
[0073] S130, dividing a training set and a test set according to the seed question set, the expanded question set, the first SQL statement, and the second SQL statement, and generating a training set in json format.
[0074] In the embodiment of the present invention, step S130 specifically includes:
[0075] Dividing the seed question set, the expanded question set, the first SQL statement, and the second SQL statement into a training set and a test set according to a preset ratio;
[0076] Convert the training set questions into JSON format, including table selection logic, field logic, and generated SQL statements;
[0077] Store the training set files in json format in the preset NL2SQL directory.
[0078] Assume that 11,000 questions and corresponding SQL statements are generated, and 80% of the samples in the above collected data set are used as training sets, and the remaining 20% are used as test sets. The above data set format is Excel.
[0079] Convert each training set question in Excel to JSON format. The first step is to generate table selection logic. The JSON format example is as follows: {"instruction":"The following is the MySQL database table information: table name. For the question: "Current question", give the relevant table name and return it according to list without any explanation.","output":"[Table name involved in the current question]","step":1}.
[0080] For example, the current question is which cloud center did not receive any satisfaction rating in March 2024. The instruction contains five table names: alarm table, work order table, duty table, cloud center mapping table, and satisfaction table, as well as the current question. The output is the table names involved in the current question: cloud center mapping relationship table and satisfaction table.
[0081] Generate field logic, json format is as follows: {"instruction":"The following is the MySQL database, table structure, for the problem: the current problem, give the relevant field name, according to the list, without any explanation.","output":"[The fields involved in the current problem
[0082] 'cloud_center_id','grade_time']","step":2}.
[0083] Here, the problem mentioned above is also referenced. Instruction is the create table structure of the cloud center mapping relationship table and the satisfaction table and the current problem. Output is the field name in the satisfaction table and the cloud center mapping relationship table involved in the current problem.
[0084] Generate SQL statements. The Json format is as follows: {"instruction":"The following is a MySQL database schema structure: table structure. For the question: "Current question", give the corresponding SQL statement without any explanation. The current time is 2024.","output":SQL statement,"step":3}
[0085] The current problem is also referenced, the instruction is the create table structure of the cloud center mapping relationship table and satisfaction table and the current problem. The output is the SQL statement.
[0086] S140 , training a preset initial model through a training set and a test set to obtain an NL2SQL statement model, so as to obtain an SQL statement by inputting a request question into the NL2SQL statement model.
[0087] In the embodiment of the present invention, step S140 specifically includes:
[0088] Modify the fine-tuning startup parameters and set the position of the base model;
[0089] Enter the preset NL2SQL directory location and the output model file location;
[0090] Set the number of cards used for fine tuning and the cards used for fine tuning;
[0091] Start the model training script to perform supervised fine-tuning training.
[0092] Put the generated training set file in json format in the / data / NL2SQL directory. Modify the fine-tuning startup parameters, set pretrained_model to the location of the base model. The base model of the embodiment of the present invention adopts Baichuan2-13B-Chat, dataset_path is the location of the training set json, and output_dir is the output model file location. nproc_per_node_num is the number of cards used in this fine-tuning, and it is set to 3 in the embodiment of the present invention. CUDA_VISIBLE_DEVICES is which cards are used in this fine-tuning, and it is set to '0,1,2' in the embodiment of the present invention. Start the model training script and perform supervised fine-tuning training.
[0093] In an embodiment of the present invention, the method may further include:
[0094] Perform evaluation on the test set and connect to the MySQL database;
[0095] Execute the preset evaluation script to verify whether the SQL statements generated by the model are consistent with the SQL statement results in the test set. If they are consistent, mark them as correct; if not, mark them as requiring manual verification.
[0096] Execute the evaluation on the test set and connect to the database. The script connects to the MySQL database by default. Execute the evaluation script to verify whether the SQL statements generated by the model are consistent with the SQL statements in the test set. If they are consistent, mark them as correct. Otherwise, mark them as requiring manual verification. The operation and maintenance SQL experts verify the SQL statements that require manual verification.
[0097] In an embodiment of the present invention, the method may further include: encapsulating NL2SQL into an interface form for other systems to call;
[0098] Create interface services through technical framework;
[0099] Set the external access IP address and port number of the interface so that other systems can access the interface through the network;
[0100] Configure the security access policy for the interface.
[0101] Encapsulate the above NL2SQL into an interface for other systems to call, and set the IP address and interface for external access. Other systems can directly call the interface, enter the request question, and directly get the SQL statement. Set the external access IP address and port number of the interface (such as host = '0.0.0.0' and port = 5000 in the above Flask example) so that other systems can access the interface through the network. At the same time, you can also configure the security access policy of the interface as needed, such as setting access rights, authentication mechanism, etc.
[0102] This patent is to realize a method and system for implementing NL2SQL based on a large model of the operation and maintenance industry. The traditional operation and maintenance method relies on manual data query and analysis, which is inefficient and error-prone. In order to realize the automation and intelligence of operation and maintenance, it is necessary to efficiently manage and analyze the operation and maintenance data. However, the existing data query methods often require users to master the SQL language and cannot handle natural language queries well, which makes users subject to certain restrictions during use.
[0103] In response to the above problems, the method for implementing NL2SQL based on the large model of the operation and maintenance industry provided by the present invention has powerful data processing and text understanding capabilities, can efficiently realize the conversion of natural language queries to structured query languages, improve operation and maintenance efficiency, reduce operation and maintenance costs, and provide intelligent solutions for the operation and maintenance industry. It has broad application prospects and market value.
[0104] like Figure 2 As shown, an embodiment of the present invention provides a device for implementing NL2SQL based on a large model of the operation and maintenance industry, including:
[0105] A generating unit 210 is used to generate a preset number of seed questions and a first SQL statement corresponding to each seed question, and construct a seed question set and a seed SQL statement according to the seed questions and the first SQL statement;
[0106] An expansion unit 220, configured to generate an expanded question set and a second SQL statement corresponding to each expanded question in the expanded question set based on the seed question set;
[0107] A partitioning unit 230 is used to partition a training set and a test set according to the seed question set, the expanded question set, the first SQL statement, and the second SQL statement, and generate a training set in JSON format;
[0108] The training unit 240 is used to train the preset initial model through the training set and the test set to obtain the NL2SQL statement model, so as to obtain the SQL statement by inputting the request question into the NL2SQL statement model.
[0109] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the device for implementing NL2SQL based on the big model of the operation and maintenance industry. In other embodiments of the present invention, the device for implementing NL2SQL based on the big model of the operation and maintenance industry may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0110] The information interaction, execution process and other contents between the units in the above-mentioned device are based on the same concept as the embodiment of the method of the present invention. For specific contents, please refer to the description in the embodiment of the method of the present invention, and no further description is given here.
[0111] Figure 3 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0112] like Figure 3 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0113] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0114] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 11 executes the various methods and processes described above, such as a method for implementing NL2SQL based on a large model of the operation and maintenance industry.
[0115] In some embodiments, the method for implementing NL2SQL based on the operation and maintenance industry big model may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the method for implementing NL2SQL based on the operation and maintenance industry big model described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the method for implementing NL2SQL based on the operation and maintenance industry big model in any other appropriate manner (e.g., by means of firmware).
[0116] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0117] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0118] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0119] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0120] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0121] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0122] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0123] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for implementing NL2SQL based on a large model of the operation and maintenance industry, characterized in that: include: Generate a preset number of seed questions and a first SQL statement corresponding to each of the seed questions, and construct a seed question set and a seed SQL statement according to the seed questions and the first SQL statement; Generate an expanded question set based on the seed question set and a second SQL statement corresponding to each expanded question in the expanded question set; Divide the training set and the test set according to the seed question set, the expanded question set, the first SQL statement, and the second SQL statement, and generate a json format training set; The preset initial model is trained by using the training set and the test set to obtain an NL2SQL statement model, so as to obtain an SQL statement by inputting a request question into the NL2SQL statement model.
2. The method according to claim 1, characterized in that Further including: Verifying the accuracy and reliability of the seed question set and the seed SQL statement; The matching degree between the seed question set and the seed SQL statement and the corresponding SQL is verified.
3. The method according to claim 1, characterized in that The step of generating an expanded question set based on the seed question set and a second SQL statement corresponding to each expanded question in the expanded question set includes: For the seed question in the seed question set, call GPT4 to construct a prompt text to generate an expanded sentence; Call GPT4 to build prompt text and generate extended SQL statements for extended questions; Use the script to connect to the MYSQL database and verify whether the execution results of the seed SQL statement and the extended SQL statement are consistent; if the results are consistent, use the extended SQL as the second SQL statement.
4. The method according to claim 1, characterized in that: The step of dividing the training set and the test set according to the seed question set, the expanded question set, the first SQL statement, and the second SQL statement and generating the training set in json format includes: Dividing the seed question set, the expanded question set, the first SQL statement, and the second SQL statement into a training set and a test set according to a preset ratio; Convert the training set questions into JSON format, including table selection logic, field logic, and generated SQL statements; Store the training set files in json format in the preset NL2SQL directory.
5. The method according to claim 4, characterized in that The training of the preset initial model by using the training set and the test set includes: Modify the fine-tuning startup parameters and set the position of the base model; Enter the preset NL2SQL directory location and the output model file location; Set the number of cards used for fine tuning and the cards used for fine tuning; Start the model training script to perform supervised fine-tuning training.
6. The method according to claim 1, characterized in that Further including: Perform evaluation on the test set and connect to the MySQL database; Execute the preset evaluation script to verify whether the SQL statements generated by the model are consistent with the SQL statements in the test set. If they are consistent, mark them as correct. If not, it is marked as requiring manual verification.
7. The method according to claim 1, characterized in that Further including: Encapsulate NL2SQL into an interface for other systems to call; Create interface services through technical framework; Set the external access IP address and port number of the interface so that other systems can access the interface through the network; Configure the security access policy for the interface.
8. A device for implementing NL2SQL based on a large model of the operation and maintenance industry, characterized in that: include: A generating unit, configured to generate a preset number of seed questions and a first SQL statement corresponding to each of the seed questions, and construct a seed question set and a seed SQL statement according to the seed questions and the first SQL statement; An expansion unit, configured to generate an expanded question set and a second SQL statement corresponding to each expanded question in the expanded question set based on the seed question set; A division unit, used for dividing a training set and a test set according to the seed question set, the expanded question set, the first SQL statement and the second SQL statement, and generating a training set in JSON format; The training unit is used to train a preset initial model through a training set and a test set to obtain an NL2SQL statement model, so as to obtain an SQL statement by inputting a request question into the NL2SQL statement model.
9. An electronic device, characterized in that include: at least one processor; And a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method for implementing NL2SQL based on the operation and maintenance industry big model as described in any one of claims 1-7.
10. A computer readable medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for implementing NL2SQL based on a large model of the operation and maintenance industry according to any one of claims 1 to 7 when executed.
Citation Information
Patent Citations
NL2SQL data set construction method and device, equipment and medium
CN118503270A
Method and system for generating nl2sql training set based on large model and suitable for all industries
CN118964579A
Method and system for constructing NL2SQL data set in large model scene
CN119003570A