Intelligent number asking method and system for license system based on NL2SQL large model
By combining the fine-tuning of the ChatGLM4 model and the enhancement of QLoRA technology in the field knowledge, the generalization and domain applicability problems in the natural language to SQL statement conversion are solved, and efficient and accurate SQL statement generation and dynamic chart display in the certificate management system are realized.
Patent Information
- Application Number
- CN202510460841.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-14
- Publication Date
- 2025-08-01
AI Technical Summary
The prior art has problems such as insufficient generalization, poor scalability, insufficient domain knowledge and great impact on data noise in natural language to SQL statement conversion, especially in the certificate management system.
The open source ChatGLM4 model is used for fine-tuning, combined with QLoRA technology and domain knowledge enhancement, special prompt words are designed, and the model weight is adjusted locally through QLoRA technology, the model's performance on specific tasks is enhanced, and the model's grammar and logic verification is performed through the big model reflection link to optimize the operation of the model in a resource-constrained environment.
It improves the applicability and accuracy of the model in specific fields, reduces the risk of query failure, enriches the display form of query results, and meets diverse data analysis needs.
Smart Images

Figure CN120407602A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of artificial intelligence, and specifically provides an intelligent question answering method and system for a certificate system based on the NL2SQL large model. Background Technique
[0002] Most of the methods for converting natural language to SQL statements rely on template matching or rule-based methods. These methods map the natural language input by users to the corresponding SQL statements by presetting fixed query templates. However, due to the diversity of natural language expressions and the complexity of database structures, the template-based methods have the following limitations in practical applications: First, the generalization ability is insufficient, the applicable range of the template is limited, and it cannot cover various complex query scenarios. Second, the scalability is poor. When the database structure changes, the template needs to be redesigned, increasing the development and maintenance costs. Third, the dependence on domain knowledge. In scenarios involving domain-specific terms, traditional methods are often difficult to handle effectively and are prone to matching errors.
[0003] With the rise of deep learning technology, certain progress has been made in the technical path of using pre-trained models (such as BERT, GPT, etc.) to fine-tune and generate SQL statements. However, these methods still have the following problems in applications. First, the impact of data noise is large, and the model is easily affected by the noise and errors in the training data, and the generated SQL statements may have syntax or logical errors. Second, the context understanding is insufficient. The existing models have a relatively shallow understanding of the context of natural language questions, especially in complex queries that require integrating multiple tables or fields. Third, the lack of domain knowledge. The existing technologies do not fully combine the domain knowledge base, resulting in limitations in the performance of the model in specific domains (such as the certificate management system). Summary of the Invention
[0004] The purpose of the present invention is to provide an intelligent question answering method and system for a certificate system based on the NL2SQL large model to solve the problems raised in the above background technique.
[0005] To achieve the above purpose, the present invention provides the following technical solution: An intelligent question answering method for a certificate system based on the NL2SQL large model, including the following steps:
[0006] Select the open-source ChatGLM4 model as the base model, and use the QLoRA technology to fine-tune the base model. The fine-tuning dataset is Spider, and the batch_size is set to 1 during fine-tuning;
[0007] Through the QLoRA technology, local adjustment of the model weights is realized, reducing the training resource requirements and improving the performance of the model on specific tasks.
[0008] Preferably, it further includes the steps of prompt word design and domain knowledge enhancement:
[0009] Design special prompt words to guide the model to generate accurate SQL statements. The content of the prompt words includes describing the data table, determining the table headers, and generating SQL statements. Specifically, it conducts natural language descriptions of the database table headers and field contents, clarifies the meanings of each field, the primary key, data examples, and query conditions, and only queries data in the valid state;
[0010] Design prompt words to select the chart type, judge the suitable chart type for display according to the characteristics of the query results, and output in the specified format;
[0011] Sort out the "correspondence table between certificates and common languages" for the certificate management system to enhance the generalization ability of the model in domain-specific scenarios;
[0012] Conduct syntax and logic verification on the generated SQL statements through the large model reflection link.
[0013] Preferably, it further includes the steps of generating SQL statements and connecting to the database:
[0014] After the user inputs a natural language question, connect the generated SQL statement to the MySQL database, where the relevant data of the certificate management system is stored, including the handling type, handling quantity, handling department, and handling time of the certificates.
[0015] Preferably, it further includes the steps of analysis of query results and chart generation:
[0016] Parse the header fields of the query results to determine their meanings;
[0017] Automatically match the suitable chart type according to the data characteristics. For example, generate a pie chart for categorical data, a line chart for time series data, and a combined chart for multi-dimensional data;
[0018] Use Echarts to generate dynamic interactive charts and display them on the front end.
[0019] Preferably, it further includes the steps of model quantization coding deployment and front-end display and interaction functions:
[0020] Optimize the large language model through quantization coding technology, including quantizing the model weights from 32-bit floating-point numbers to 8-bit integers to reduce memory occupancy, and using VLLM acceleration to improve the calculation efficiency, so that the model can run efficiently in a hardware environment with limited resources;
[0021] The front end of the system integrates a question-and-answer-based interaction interface and an Echarts chart display module, supporting intelligent question answering, that is, the user directly inputs a question, and the system generates the corresponding SQL statement and displays the answer through a chart.
[0022] A system for an intelligent question answering method in a certificate system based on the NL2SQL large model, including a base model selection and fine-tuning module:
[0023] Select the open-source ChatGLM4 model as the base model;
[0024] Use the QLoRA technique to fine-tune the base model. The fine-tuning dataset is Spider, which contains 10,181 natural language questions, 5,693 SQL statements, distributed in 200 independent databases, covering 138 different fields;
[0025] During the fine-tuning process, the batch_size is set to 1. Through the QLoRA technique, local adjustment of the model weights is achieved, reducing the training resource requirements and improving the model's performance on specific tasks.
[0026] Preferably, it further includes a prompt design and domain knowledge enhancement module:
[0027] Design dedicated prompts to guide the model to generate accurate SQL statements, including prompts for describing the data tables to be queried, determining the table headers, and generating SQL statements, natural language descriptions of the database table headers and field contents, clarifying the meanings of each field, primary keys, data examples, and query conditions, and only querying data in the valid state;
[0028] Design prompts for selecting chart types, judge the suitable chart types according to the characteristics of the query results, and output them in the specified format;
[0029] Sort out the "correspondence table between certificates and common languages" for the certificate management system to enhance the model's generalization ability in domain-specific scenarios;
[0030] Conduct syntax and logic verification on the generated SQL statements through the large model reflection link.
[0031] Preferably, it further includes an SQL statement generation and database docking module:
[0032] Receive the natural language questions input by the user;
[0033] Generate corresponding SQL statements according to the prompt guidance;
[0034] Dock the generated SQL statements with the MySQL database, and the relevant data of the certificate management system is stored in the database, including the handling types, handling quantities, handling departments, and handling times of certificates.
[0035] Preferably, it further includes a query result analysis and chart generation module:
[0036] Analyze the header fields of the query results to determine their meanings;
[0037] Automatically match a suitable chart type according to the data characteristics. For example, generate a pie chart for categorical data, a line chart for time series data, and a combined chart for multi-dimensional data;
[0038] Use Echarts to generate dynamic interactive charts and display them on the front end.
[0039] Preferably, it further includes a model quantization coding deployment and front-end display interaction module, and this module:
[0040] Optimize the large language model through quantization coding technology, including quantizing the model weights from 32-bit floating point numbers to 8-bit integers to reduce memory occupancy, using VLLM acceleration to improve computing efficiency, so that the model can run efficiently in a hardware environment with limited resources;
[0041] The front end of the system integrates a question-and-answer-based interaction interface and an Echarts chart display module, supporting intelligent query by numbers, that is, the user directly enters a question, and the system generates the corresponding SQL statement and displays the answer through a chart.
[0042] Compared with the prior art, the beneficial effects of the present invention are:
[0043] The intelligent query by numbers method and system of the certificate system based on the NL2SQL large model proposed by the present invention uses the Spider dataset combined with the QLoRA fine-tuning technology to enhance the model's understanding ability of different contexts and expression methods, solves the problem of insufficient generalization caused by the diversity of natural language expressions, and can accurately generate high-quality SQL statements adapted to multiple scenarios.
[0044] Construct a "certificate-vulgar language" knowledge table. By enhancing the ability to integrate domain knowledge, the model can accurately identify and process special nouns and their vulgar expressions in a specific field, solve the problem of difficult query matching in the certificate management system, and improve the applicability in specific scenarios.
[0045] Add an automatic verification mechanism for SQL statements. Through the reflection link of the large model, verify the syntax and logic of the generated SQL statements to ensure that the SQL statements can be correctly executed, significantly reducing the risk of query failure or inaccurate results.
[0046] By analyzing the characteristics of the query results, automatically match the best chart type (such as pie chart, line chart, etc.) and generate dynamic interactive charts, solve the problem of poor adaptability of manually selected charts in the prior art, and at the same time enrich the display form of query results to meet diverse data analysis needs. Brief Description of the Drawings
[0047] Figure 1 It is the flowchart of the fine-tuning and deployment of the NL2SQL large model of the present invention;
[0048] Figure 2 This is the overall flowchart of the intelligent question number system of the present invention;
[0049] Figure 3 This is the core business interaction logic flowchart of the present invention;
[0050] Figure 4 This is the system architecture diagram of the present invention. Detailed implementation manners
[0051] In order to clearly and completely describe the purpose, technical solution of the present invention, and make the advantages more clearly understood, the following further details the embodiments of the present invention with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are part of the embodiments of the present invention, rather than all of the embodiments, and are only used to explain the embodiments of the present invention, not to limit the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present invention.
[0052] Embodiment 1, please refer to Figures 1 to 4 The present invention provides a technical solution: an intelligent question number method for a certificate system based on the NL2SQL large model, including the following steps:
[0053] (1) Select a base model and perform fine-tuning
[0054] The present invention selects the open-source ChatGLM4 (Chat General Language Model) model as the base model. The base model is efficiently fine-tuned through the QLoRA (Quantized Low-Rank Adaptation) technology. The NL2SQL fine-tuning dataset used is Spider, which contains: 10,181 natural language questions covering various query scenarios, 5,693 SQL statements distributed in 200 independent databases, covering 138 different fields, and having extremely high generality and representativeness.
[0055] During the fine-tuning process, the batch_size (batch processing size) is set to 1, ensuring the stability of the training process and the integrity of data details. Through the QLoRA technology, the present invention realizes local adjustment of the model weights, effectively reducing the training resource requirements while improving the performance of the model on specific tasks.
[0056] (2) Prompt design and domain knowledge enhancement
[0057] During the training and inference process of the large model, the present invention designs a set of dedicated prompts to guide the model to generate more accurate SQL statements. The content of these prompts includes:
[0058] 1. Describe the data table to be queried, determine the table headers and generate SQL statements: Describe the table headers and field contents of the database in natural language to help the large model understand the database structure. The example of the prompt here is:
[0059] - You are an NL2SQL large model that can convert the user's questions into SQL statements and can determine the table headers of each column of the queried data; the data tables involved are "XXX_data_0" and "XXX_data_1", and the two tables have the same structure and contain the same fields.
[0060] - The fields and corresponding descriptions included in the data tables "XXX_data_0" and "XXX_data_1" are as follows: "CERTIFICATE_ID" is the primary key of the table; "certificate_number" is the "certificate number"; "Certificate_Type" is the "type of certificate", which is the name and type of the certificate being processed. The database includes [Registration Certificate of Private Non-Enterprise Units, Approval Certificate for Retail Operation of Refined Oil, Animal Diagnosis and Treatment License, Veterinary Drug Business License, Animal Epidemic Prevention Condition Certificate, etc.]; "Issue_Dept" is the "department issuing the certificate", that is, the "issuing authority", which describes the "institution issuing the certificate". The database includes [XX Port, XX Airport, High-tech Zone, Free Trade Zone, etc.]; "Certificate_Holder" is the "holder's name", which describes the "name of the certificate holder or enterprise name (corporate certificate)", and describes the "holder of the certificate"; "Certificate_Holder_Code" is the "holder's certificate number", where for natural persons it is the ID number, and for enterprises it is the unified social credit code; "Certificate_Holder_Category" is the "holder type", including "2, 1, 4, 3", where "1 - natural person, 2 - legal person, 3 - mixed, 4 - others"; "Issue_Date" is the "issuing date", which describes the "certificate issuance date". The data example is [2022-12-14]. The year can be obtained through YEAR, for example: this year, YEAR(Issue_Date) = 2024; the month can be obtained through MONTH, for example: November, MONTH(Issue_Date) = 11; "Validity_START" is the "start time of the certificate validity period", such as the "start time of the ID card validity period", and the data example is "2022-11-16"; "Validity_End" is the "end time of the certificate validity period", such as the "end time of the ID card"; "Create_Time" is the "creation time", which describes the "data entry time"; "state" is the "data status", where "0 or 1 is valid data, 11 is changed data, 21 is the certificate has been cancelled, 22 is the certificate has been invalidated (default to query valid data)".
[0061] - Please generate the corresponding SQL statements and table headers based on the above fields and table names, and only query the data in the valid state, that is, the data where "state" is 0 or 1.
[0062] 2. Select the chart type: Based on the characteristics of the query results, determine the suitable chart type for display (such as pie chart, line chart, etc.). The prompt words designed here are:
[0063] - Analyze the user's question and the table header, and output the appropriate chart type for drawing, such as pie chart, line chart, bar chart, etc.;
[0064] - Among them, the parameter corresponding to the pie chart is "pie_chart", the parameter corresponding to the line chart is "line_chart", and the parameter corresponding to the bar chart is "bar_chart". Please output in the format of ("SQL" = "XXX"; "Header" = "XXX"; "type" = "XXX");
[0065] 3. Combining domain knowledge: For the certificate management system, the present invention has sorted out a "correspondence table between certificates and common terms", which contains the specific terms of certificates and their common popular expressions, enhancing the generalization ability of the model in domain-specific scenarios.
[0066] Table 1 Correspondence Table between Certificates and Common Terms
[0067]
[0068]
[0069]
[0070]
[0071]
[0072] Through the above design, the present invention solves the adaptability problem of the model in dealing with specific domain terms and improves the accuracy of the conversion from natural language to SQL statements.
[0073] The generated SQL statements are further subjected to syntax and logic verification through the large model reflection link to ensure that they can be correctly executed in the database.
[0074] (III) Generate SQL statements and connect to the database
[0075] After the user inputs a natural language question, the generated SQL statements are connected to the database. The SQL query module of the present invention is connected to the MySQL database, and the database stores relevant data of the certificate management system, including the types of certificates processed, the number of certificates processed, the departments for processing, and the processing time, etc.
[0076] (IV) Analysis of query results and chart generation
[0077] For the query results, the present invention realizes the determination of chart format and data through the following steps:
[0078] 1. Table header parsing: Analyze the table header fields of the query results to determine their meanings.
[0079] 2. Chart type selection: Automatically match the appropriate chart type according to the data characteristics. For example: for categorical data, generate a pie chart; for time series data, generate a line chart; for multi-dimensional data, generate a combined chart.
[0080] 3. Automatic chart generation: Use Echarts (a browser-based visualization library) to generate dynamic interactive charts and display them on the front end.
[0081] (V) Model quantization encoding and deployment
[0082] In order to reduce the model's dependence on computing power, the present invention optimizes the large language model through quantization encoding technology, specifically including:
[0083] 1. Parameter quantization: Quantize the model weights from 32-bit floating point numbers to 8-bit integers, significantly reducing memory occupancy;
[0084] 2. Inference acceleration: Use VLLM for acceleration to improve computing efficiency. This optimization enables the model to run efficiently in hardware environments with limited resources.
[0085] (VI) Front-end display and interaction functions
[0086] The front end of the system of the present invention integrates a question-based interaction interface and an Echarts chart display module, supporting intelligent data querying, that is, the user directly inputs a question, and the system generates the corresponding SQL statement and displays the answer through a chart.
[0087] Example 2, based on Example 1, proposes a system for the intelligent data querying method of a license certificate system based on the NL2SQL large model according to claim 5, including a base model selection and fine-tuning module: Select the open-source ChatGLM4 model as the base model; Use the QLoRA technology to fine-tune the base model, and the fine-tuning dataset is Spider, which contains 10,181 natural language questions and 5,693 SQL statements, distributed in 200 independent databases, covering 138 different fields; During the fine-tuning process, the batch_size is set to 1, and the QLoRA technology is used to achieve local adjustment of the model weights, reducing the training resource requirements and improving the model's performance on specific tasks.
[0088] It also includes a prompt design and domain knowledge enhancement module: Design dedicated prompts to guide the model to generate accurate SQL statements, including prompts for describing the data tables to be queried, determining the table headers, and generating SQL statements, natural language descriptions of the database table headers and field contents, clarifying the meanings of each field, primary keys, data examples, and query conditions, and only querying data in the valid state; Design prompts for selecting chart types, judge the suitable chart types for display according to the characteristics of the query results, and output in the specified format; Organize the "correspondence table between certificates and common languages" for the certificate management system to enhance the generalization ability of the model in domain-specific scenarios; Conduct syntax and logic verification on the generated SQL statements through the large model reflection link.
[0089] It also includes an SQL statement generation and database docking module: Receive the natural language questions input by the user; Generate corresponding SQL statements according to the prompt guidance; Docking the generated SQL statements with the MySQL database, where the relevant data of the certificate management system is stored, including the handling types, handling quantities, handling departments, and handling times of the certificates.
[0090] It also includes a query result analysis and chart generation module: Analyze the header fields of the query results to determine their meanings; Automatically match suitable chart types according to the data characteristics, such as generating pie charts for categorical data, line charts for time series data, and combined charts for multi-dimensional data; Use Echarts to generate dynamic interactive charts and display them on the front end.
[0091] It also includes a model quantization coding deployment and front-end display interaction module, which: Optimize the large language model through quantization coding technology, including quantizing the model weights from 32-bit floating point numbers to 8-bit integers to reduce memory occupancy, using VLLM acceleration to improve the calculation efficiency, so that the model can run efficiently in a hardware environment with limited resources; The front end of the system integrates a question-and-answer-based interaction interface and an Echarts chart display module, supporting intelligent question answering, that is, the user directly inputs a question, and the system generates the corresponding SQL statement and displays the answer through a chart.
[0092] Embodiment 3, based on Embodiment 2, proposes the following content:
[0093] Appendix Figure 4It shows the overall architecture and functional module division of the method of the present invention. The system is divided into a user layer, an application layer, a data layer, and a deployment layer from top to bottom. The user layer is responsible for user interaction, initiating queries through natural language input or voice. The system returns results in the form of questions and answers and generates intuitive graphical results through a chart display module. The application layer is the core logic processing part, covering natural language understanding and SQL generation. It optimizes the generation process through prompt engineering and performs syntax and logic verification on SQL statements. At the same time, it parses the headers and chart types of query results to ensure the accuracy of data display. The data layer connects to the MySQL database of the certificate management system to achieve accurate query of multi-dimensional data such as certificate types, quantities, departments, and time. The deployment layer uses model quantization and inference acceleration technologies to optimize model performance, reduce dependence on hardware resources, and enable it to run efficiently in a common server environment. The overall architecture diagram intuitively shows the complete process from user interaction to query execution and then to result display.
[0094] Appendix Figure 1 It shows the specific process of fine-tuning and deployment of the NL2SQL large model. First, in the base model selection stage, ChatGLM4 is selected as the base model to provide a solid foundation for subsequent fine-tuning (S1). Subsequently, in the dataset loading stage, the Spider dataset is loaded, which includes natural language questions and corresponding SQL statements to ensure data diversity and richness (S2). Then, by applying QLoRA fine-tuning, the QLoRA technology is used to reduce the training resource requirements and optimize the model performance at the same time (S3). After the fine-tuning is completed, it enters the model combination stage, where the fine-tuned model and the base model are combined into an overall model to improve domain professionalism and maintain the general question-answering ability of the large model (S4). In the model testing stage, the combined model is verified using the test set to evaluate its performance and obtain accuracy metrics (S5). Finally, in the model quantization deployment stage, the verified model is quantized to reduce resource consumption and achieve efficient inference deployment (S6).
[0095] Appendix Figure 2Shows the overall process of the NL2SQL large model intelligent question answering system. First, the user inputs a query question through the system's front-end interaction interface, supporting both text and voice input methods (S1). Then, based on the prompt words designed in the "Certificate and Colloquial Language Correspondence Table", the system optimizes the accuracy of the question expression and enhances the model's understanding ability of certificates (S2). Next, the system calls the fine-tuned NL2SQL large model to generate the corresponding SQL statement, as well as the table header and table type description (S3). The generated SQL statement undergoes syntax and logic verification through the reflection link of the large model to ensure that the SQL statement can be correctly executed in the database (S4). The verified SQL statement is passed to the database to perform the query operation and obtain the original query data (S5). Subsequently, the system performs data analysis on the query results and generates visual charts such as bar charts, pie charts, and line charts according to different types of results, and uses the Echarts component for display (S6). Finally, the system presents the charts and tables of the query results on the front-end interface, supporting the interactive function based on questions and answers, allowing users to intuitively obtain the query results (S7).
[0096] Appendix Figure 3 Shows the core business interaction logic process of the intelligent question answering system based on the NL2SQL large model. First, the user inputs natural language or voice through the interaction interface for query, and the system passes the question to the back-end processing module. Subsequently, based on the pre-designed prompt words and the fine-tuned NL2SQL large model, the input question is parsed to generate the corresponding SQL statement and undergoes syntax and logic verification through the reflection of the large model. The verified SQL statement is passed to the database to complete the query operation on the relevant data. Then, the system generates the corresponding visual chart according to the data characteristics. Finally, the chart and the query results are presented in an intuitive form on the front-end interface, and the user can evaluate the results (like / dislike) through the interaction interface. The entire process realizes the seamless connection from the user's natural language input to the graphical result output, improving the question answering experience and efficiency.
[0097] Example 4, based on Example 3, proposes an intelligent question answering method and device for a certificate system based on the NL2SQL large model, aiming to improve the accuracy of the conversion from natural language queries to SQL statements and the data visualization ability. The present invention is illustrated by the following cases.
[0098] Case scenario: Data query and visualization display of the certificate management system
[0099] 1. User question input
[0100] The user inputs a natural language question in the intelligent question answering system, such as "Query the number of animal diagnosis and treatment certificates issued in 2023". The system first receives the user's input through the front-end interaction interface and passes it to the back-end NL2SQL large model.
[0101] 2. Fine-tuning Deployment of the Base Model and Prompt-Guided Generation
[0102] The open-source ChatGLM4 model is selected as the base model, and it is fine-tuned using the QLoRA technique. The Spider dataset is utilized to enhance the model's adaptability to generating SQL statements in multiple domains, and then it is quantized and deployed. Based on the model fine-tuning, a series of prompts are designed to optimize the model's understanding of the certificate management system.
[0103] The prompts describe the database structure and field content, such as: "‘Certificate_Type' is the ‘certificate type' and is used to describe the name of the certificate being processed". The user is prompted to only query valid data (data where the ‘state' field is 0 or 1) to avoid returning redundant or invalid results. To adapt to the domain knowledge of certificate management, the present invention utilizes a "correspondence table between certificates and common language" to align the common language input by the user (such as "animal diagnosis and treatment certificate") with the professional terms in the database (such as "animal diagnosis and treatment license") to ensure that the model can correctly understand and generate accurate SQL statements.
[0104] In this case, the SQL statement generated by the system through the prompts is as follows:
[0105] "SELECT COUNT(*) AS `Number of Certificates`
[0106] FROM `certificate_data`
[0107] WHERE `certificate_type` = 'animal diagnosis and treatment license'
[0108] AND YEAR(`issue_date`) = 2023
[0109] AND `state` IN (0, 1);"
[0110] Furthermore, through the prompts, the large model is made to reflect on and check the generated SQL statement, and output the content that should be used as the table header and the type of graph that should be drawn.
[0111] 3. SQL Statement Generation and Database Connection
[0112] The generated SQL statement is automatically connected to the MySQL database by the system to query out the data results that meet the conditions.
[0113] 4. Generation of Query Result Charts
[0114] Based on the table headers, data, and chart types returned by the query results, the system automatically generates a bar chart using the Echarts library and displays it on the front-end interface:
[0115] 5. Front-end Display and Interaction
[0116] Users can view the chart results through the front-end interface and evaluate the accuracy of the query (like or dislike). If the user enters a new question, such as "Query the number of retail business approval certificates for refined oil issued in the high-tech zone in 2024", the system will regenerate the SQL statement and display the corresponding chart.
[0117] Although the embodiments of the present invention have been shown and described, it will be understood by those of ordinary skill in the art that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. An intelligent question numbering method for a certificate system based on the NL2SQL large model, characterized in that: It includes the following steps: Select the open-source ChatGLM4 model as the base model, and use the QLoRA technique to fine-tune the base model. The fine-tuning dataset is Spider, and the batch_size is set to 1 during fine-tuning; Implement local adjustment of the model weights through the QLoRA technique to reduce the training resource requirements and improve the model's performance on specific tasks.
2. The intelligent question numbering method for a certificate system based on the NL2SQL large model according to claim 1, characterized in that: It also includes the steps of prompt design and domain knowledge enhancement: Design dedicated prompts to guide the model to generate accurate SQL statements. The content of the prompts includes describing the data tables, determining the table headers, and generating SQL statements. Specifically, it is to describe the database table headers and field contents in natural language, clarify the meaning of each field, the primary key, data examples, and query conditions, and only query data with valid status; Design prompts to select the chart type, judge the suitable chart type for display according to the characteristics of the query results, and output in the specified format; Sort out the "correspondence table between certificates and common languages" for the certificate management system to enhance the model's generalization ability in domain-specific scenarios; Conduct syntax and logical verification on the generated SQL statements through the large model reflection link.
3. The intelligent question numbering method of the certificate system based on the NL2SQL large model according to claim 2, wherein: It also includes the steps of generating SQL statements and connecting to the database: After the user inputs a natural language question, connect the generated SQL statement to the MySQL database, and the database stores relevant data of the certificate management system, including the types of certificates processed, the number of certificates processed, the departments handling the certificates, and the processing time.
4. The intelligent question numbering method of a certificate system based on the NL2SQL large model according to claim 3, wherein: It also includes the steps of analyzing the query results and generating charts: Parse the header fields of the query results to determine their meanings; Automatically match the suitable chart type according to the data characteristics, such as generating a pie chart for categorical data, a line chart for time series data, and a combined chart for multi-dimensional data; Use Echarts to generate dynamic interactive charts and display them on the front end.
5. The intelligent question numbering method of a certificate system based on the NL2SQL large model according to claim 4, characterized in that: It also includes the steps of model quantization coding deployment and front-end display and interaction functions: Optimize the large language model through quantization coding technology, including quantizing the model weights from 32-bit floating-point numbers to 8-bit integers to reduce memory occupancy, and using VLLM acceleration to improve the calculation efficiency, so that the model can run efficiently in a hardware environment with limited resources; The front end of the system integrates a question-and-answer-based interactive interface and an Echarts chart display module, supporting intelligent data query, that is, the user directly inputs a question, and the system generates the corresponding SQL statement and displays the answer through charts.
6. A system for the intelligent question numbering method of the license certificate system based on the NL2SQL large model according to claim 5, characterized in that: It includes the base model selection and fine-tuning module: Select the open-source ChatGLM4 model as the base model; Use the QLoRA technique to fine-tune the base model. The fine-tuning dataset is Spider, which contains 10,181 natural language questions and 5,693 SQL statements, distributed in 200 independent databases, covering 138 different fields; During the fine-tuning process, the batch_size is set to 1, and local adjustment of the model weights is achieved through the QLoRA technique to reduce the training resource requirements and improve the model's performance on specific tasks.
7. A system according to claim 6, characterized in that: It also includes the prompt design and domain knowledge enhancement module: Design specific prompting words to guide the model to generate accurate SQL statements, including prompting words for describing the data tables to be queried, determining the table headers, and generating SQL statements, natural language descriptions of the database table headers and field contents, clarifying the meanings of each field, primary keys, data examples, and query conditions, and only querying data in the valid state; Design prompting words for selecting chart types, judge the suitable chart types for display according to the characteristics of the query results, and output them in the specified format; Sort out the "correspondence table between certificates and common languages" for the certificate management system to enhance the generalization ability of the model in domain-specific scenarios; Conduct syntax and logic verification on the generated SQL statements through the reflection link of the large model.
8. A system according to claim 7, characterized in that: It also includes an SQL statement generation and database docking module: Receive natural language questions input by users; Generate corresponding SQL statements according to the guidance of the prompting words; Dock the generated SQL statements with the MySQL database, and the database stores relevant data of the certificate management system, including the types of certificates processed, the number of certificates processed, the departments handling the certificates, and the processing time.
9. A system according to claim 8, wherein: It also includes a query result analysis and chart generation module: Analyze the header fields of the query results to determine their meanings; Automatically match suitable chart types according to the data characteristics, such as generating pie charts for categorical data, line charts for time series data, and combined charts for multi-dimensional data; Use Echarts to generate dynamic interactive charts and display them on the front end.
10. A system according to claim 9, wherein: It also includes a model quantization coding deployment and front-end display interaction module, and the module: Optimize the large language model through quantization coding technology, including quantizing the model weights from 32-bit floating-point numbers to 8-bit integers to reduce memory occupancy, using VLLM acceleration to improve computing efficiency, so that the model can run efficiently in hardware environments with limited resources; The front end of the system integrates a question-and-answer-based interaction interface and an Echarts chart display module, supporting intelligent question answering, that is, users directly input questions, and the system generates corresponding SQL statements and displays the answers through charts.
Citation Information
Patent Citations
Medical insurance intelligent query method and system based on NL2SQL
CN118132579A
Intelligent query method and system based on large model and retrieval enhancement technology
CN119003743A
Method and system for realizing intelligent number asking based on large model
CN119415538A
Intelligent number asking method based on large language model
CN119646021A
Context learning-based database query generation method and system and storage medium
CN119669265A
Cited By
Automatic driving automobile intelligence degree evaluation method based on subjective and objective mapping of large language model
CN121597823A