Industrial data query method and device based on large model
Through the industry data query method based on big models, users can query industry data without learning SQL, solving the problems of high query cost and low accuracy in the existing technology, and achieving efficient and accurate data query.
Patent Information
- Application Number
- CN202411085104.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-11-15
AI Technical Summary
The way of querying industry data in the prior art requires learning SQL and writing accurate SQL instructions, resulting in high query cost, low accuracy and low efficiency.
Using a large-model-based industry data query method, loading the big model of the target industry, obtaining query statements expressed by users in natural language, and inputting them into the big model to obtain query results, reducing the need for learning SQL.
Users can query data without learning SQL, which reduces query costs, improves query accuracy and efficiency, enhances the semantic understanding of industry data by the big model, and quickly generates answers consistent with user needs.
Smart Images

Figure CN118964388A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to an industry data query method and device based on a large model. Background Art
[0002] With the development of big data, people from all walks of life will conduct data analysis by querying industry data.
[0003] The current way to query industry data is that query personnel use Structured Query Language (SQL) to query the desired industry data from the database. However, the above query method requires query personnel to spend a certain amount of time to learn SQL and write accurate SQL instructions, which has high query costs, low query accuracy and low query efficiency. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides an industry data query method and device based on a large model to solve the problems of high query cost, low query accuracy and low query efficiency existing in the existing query method.
[0005] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:
[0006] A first aspect of an embodiment of the present invention discloses an industry data query method based on a large model, the method comprising:
[0007] Loading a large model corresponding to a target industry, where the target industry is any industry, and the large model corresponding to the target industry is obtained by training based on sample data;
[0008] Obtaining a query statement expressed in a natural language constructed according to an arbitrary query pattern;
[0009] Input the query statement into the big model, so that the big model searches for query results matching the query statement from a general data table corresponding to the target industry, wherein the core columns of the general data table include any one or more of the following: an indicator column, a dimension column, an attribute column, a value column, and a unit column;
[0010] If the query result fed back by the large model is obtained, the query result is output.
[0011] Preferably, obtaining a query statement expressed in a natural language constructed according to any query mode includes:
[0012] When user input is detected, intelligent prompt information is displayed, and the intelligent prompt information includes: question styles corresponding to each query mode;
[0013] A query statement expressed in natural language constructed by the user according to a questioning style corresponding to any of the query modes is obtained.
[0014] Preferably, the process of obtaining a large model corresponding to the target industry based on sample data training includes:
[0015] Obtain sample data corresponding to the target industry, wherein the sample data includes multiple sets of question-answer script pairs, each set of the question-answer script pairs includes a corresponding question script and an answer script, and the type of the question script is an attribute script, an indicator dimension script, a range query script, a value query script, or a value range rhetorical question script;
[0016] When the first training mode is enabled, using part of the sample data to adjust part of the model parameters of the pre-trained model to obtain a large model corresponding to the target industry;
[0017] When the second training method is enabled, the specific model or the pre-trained model is fully trained using the full amount of the sample data to obtain a large model corresponding to the target industry.
[0018] Preferably, after the query statement is input into the large model, the method further includes:
[0019] If error information fed back by the large model is obtained, the error information and / or suggestion information is output, wherein the error information is used to characterize that the large model cannot recognize the query statement, and the suggestion information is used to suggest using any of the query modes to construct the query statement.
[0020] Preferably, it also includes:
[0021] Collect feedback information;
[0022] The large model is modified according to the feedback information.
[0023] Preferably, it also includes:
[0024] The large model is updated and iterated according to a preset update cycle.
[0025] A second aspect of an embodiment of the present invention discloses an industry data query device based on a large model, the device comprising:
[0026] A loading unit, used to load a large model corresponding to a target industry, where the target industry is any industry, and the large model corresponding to the target industry is obtained by training based on sample data;
[0027] An acquisition unit, used to acquire a query statement expressed in a natural language constructed according to any query mode;
[0028] A query unit, used for inputting the query statement into the big model, so that the big model searches for a query result matching the query statement from a general data table corresponding to the target industry, wherein the core columns of the general data table include any one or more of the following: an indicator column, a dimension column, an attribute column, a value column, and a unit column;
[0029] The output unit is used to output the query result if the query result fed back by the large model is obtained.
[0030] Preferably, the acquisition unit includes:
[0031] A display module is used to display intelligent prompt information when detecting user input content, wherein the intelligent prompt information includes: question styles corresponding to each query mode;
[0032] The acquisition module is used to acquire a query statement expressed in natural language constructed by the user according to a question style corresponding to any of the query modes.
[0033] Preferably, the loading unit comprises:
[0034] An acquisition module, used for acquiring sample data corresponding to the target industry, wherein the sample data includes multiple sets of question-answer script pairs, each set of the question-answer script pairs is of a type of an attribute script, an indicator dimension script, a range query script, a value query script, or a value range rhetorical question script, and each set of the question-answer script pairs includes a corresponding question script and an answer script;
[0035] A first training module, used to adjust some model parameters of the pre-trained model using part of the sample data when the first training mode is enabled, so as to obtain a large model corresponding to the target industry;
[0036] The second training module is used to use the full amount of the sample data to comprehensively train the specific model or the pre-trained model when the second training method is enabled, so as to obtain a large model corresponding to the target industry.
[0037] Preferably, the output unit is also used for: if error information fed back by the large model is obtained, outputting the error information and / or suggestion information, the error information is used to characterize that the large model cannot recognize the query statement, and the suggestion information is used to suggest using any of the query patterns to construct the query statement.
[0038] Based on the above-mentioned embodiment of the present invention, a method and device for querying industry data based on a big model is provided. The method is as follows: load the big model corresponding to the target industry; obtain a query statement expressed in natural language constructed according to an arbitrary query mode; input the query statement into the big model, so that the big model queries the query result matching the query statement from the general data table corresponding to the target industry; if the query result fed back by the big model is obtained, the query result is output. In this scheme, the big model corresponding to the target industry is loaded, the query statement expressed in natural language by the user is obtained, and the query statement is input into the big model to obtain the query result. Users do not need to learn SQL and write SQL instructions. They can query the desired query results through natural language and big models, which reduces query costs, improves query accuracy and improves query efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] 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 only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0040] Figure 1 A flowchart of an industry data query method based on a large model provided by an embodiment of the present invention;
[0041] Figure 2 A flowchart of obtaining a large model corresponding to a target industry through training provided in an embodiment of the present invention;
[0042] Figure 3 An overall architecture diagram of an industry data query method based on a large model provided by an embodiment of the present invention;
[0043] Figure 4 A structural block diagram of an industry data query device based on a large model provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0044] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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.
[0045] In this application, the terms "comprises", "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element.
[0046] As can be seen from the background technology, with the development of big data, people from all walks of life will perform data analysis by querying industry data. The current way to query industry data is: the query personnel use structured query language (SQL) to query the desired industry data from the database. However, the above query method requires the query personnel to spend a certain amount of time to learn SQL and write accurate SQL instructions, the query cost is high, the query accuracy is low, and the query efficiency is low.
[0047] The inventors have found through research that in the field of natural language processing (NLP), model fine-tuning technology is one of the important technologies to promote application progress and performance optimization. Model fine-tuning technology refers to: based on the pre-trained model, the large model for a specific task is adjusted to adapt to new data sets and task requirements. Model fine-tuning technology can make full use of the generalization ability of the pre-trained model, and at the same time capture the language features and contextual information unique to the target task through fine-tuning, thereby significantly improving the performance of the model in specific application scenarios.
[0048] Based on the above research content, this solution proposes a method and device for industry data query based on a big model, which loads the big model corresponding to the target industry, obtains the query statement expressed by the user in natural language, and inputs the query statement into the big model to obtain the query result. Users do not need to learn SQL and write SQL instructions, and can query the desired query results through natural language and big models to reduce query costs, improve query accuracy and improve query efficiency.
[0049] In practical applications, this solution enhances the big model's ability to understand the semantics of industry data in various industries, especially enhances the big model's ability to understand new problems and new needs, so that the big model can quickly and accurately generate answers consistent with user needs; when users use the big model corresponding to the industry to query information, this solution can quickly and accurately obtain the required industry knowledge, thereby greatly improving the user experience; the following is a detailed explanation of this solution through various embodiments.
[0050] See also Figure 1, shows a flow chart of an industry data query method based on a large model provided by an embodiment of the present invention, the industry data query method comprises the following steps:
[0051] Step S101: Load the large model corresponding to the target industry.
[0052] In the process of implementing step S101, the big model corresponding to the target industry is loaded from the big models corresponding to various industries, wherein the target industry is any industry, and the big model corresponding to the target industry is trained based on sample data, and each industry is trained to obtain a corresponding big model.
[0053] It should be noted that when a user queries industry data of a certain industry, he or she can load the large model of the industry to perform the query, so the target industry is the industry whose industry data the user needs to query.
[0054] The big model corresponding to each industry is also called the NL2SQL (Natural Language to SQL) model or the big model NL2SQL converter. The big model can convert natural language into SQL statements for data query.
[0055] It should be further explained that when constructing the big models corresponding to each industry, it is necessary to conduct an in-depth analysis of the needs of each industry in order to explore the characteristics and technical details of the industry; considering that the big models mainly serve statistical management and data analysis, the application scenarios of the big models cover a wide range, from production efficiency monitoring in the manufacturing industry to sales trend analysis in the retail industry. Each sub-segment has its own uniqueness, which requires a full understanding of the differences between the industries when constructing the big models corresponding to the industries. The objects of concern of each industry are different.
[0056] For a certain automobile manufacturer in the manufacturing industry, the automobile manufacturer is concerned about key performance indicators (KPIs) such as the mean time between failures (MTBF) of the production line, equipment utilization rate (OEE), and output per shift. These indicators are often associated with multiple dimensions such as time, production line, equipment model, and supplier. Therefore, the large model constructed for the manufacturing industry needs to be able to handle complex queries such as "Please provide the mean time between failures of model X production line in the past three months", and at the same time, it needs to identify and associate other related dimensions, such as being able to handle "the equipment utilization rate of the production line involved in the parts provided by supplier Y in the same period".
[0057] For the retail industry, the objects of concern may be indicators such as inventory turnover, customer flow, and sales, which are closely related to factors such as product categories, store locations, and promotional activities. For example, retailers may need to query "Which category of goods had the highest inventory turnover rate among all stores during Christmas last year?" This requires the constructed large model to be able to understand and process natural language instructions involving multiple dimensions and time ranges, and then convert them into precise SQL query statements.
[0058] For some institutions, they may focus on statistics on employment rates, education expenditures, medical resources, etc. For example, they may query "Which places have seen the fastest growth in education expenditures in the past five years?" This also tests the dimensional recognition and time series processing capabilities of the constructed large model.
[0059] In order to meet the needs of the above industries, the big models corresponding to the industries need to be highly flexible and intelligent, and the big models should be able to understand and process various complex queries. The big models should have at least the following functions:
[0060] (1) Ability to identify and interpret industry terminology and abbreviations;
[0061] (2) Support multi-dimensional cross-analysis, including but not limited to time, location, department, product type, etc.;
[0062] (3) Ability to process ambiguous time expressions and automatically convert them into specific date ranges, such as processing ambiguous time expressions such as "last quarter" and "this year" and converting them into specific date ranges;
[0063] (4) Provide an error correction mechanism. When the query statement expressed in natural language entered by the user contains grammatical errors or unclear logic, it can provide suggestions or corrected query statements.
[0064] By deeply analyzing the needs of various industries, we can build a large model (NL2SQL model) that is closer to practical applications. This not only simplifies the workflow of data analysts, but also greatly improves the efficiency and accuracy of data queries.
[0065] Step S102: Obtain a query statement expressed in a natural language constructed according to any query mode.
[0066] In the process of implementing step S102, when it is detected that a user (such as a data analyst) is inputting content, intelligent prompt information is displayed, and the intelligent prompt information includes: the question style corresponding to each query mode; the displayed question style is used to guide the user to construct a query statement expressed in natural language according to the corresponding query mode; and obtain the query statement expressed in natural language constructed by the user according to the question style corresponding to any query mode.
[0067] That is, when a user enters a query statement, intelligent prompt information is displayed to help the user construct a more accurate query statement expressed in natural language, thereby reducing the user's input errors;
[0068] It should be noted that pre-defined query patterns (also called question patterns) are the core strategy to ensure data query flexibility and user-friendliness, which involves building a series of comprehensive and intuitive query templates to cover various needs from indicator retrieval to complex multidimensional analysis. Query patterns correspond to query templates. Through pre-defined query patterns, users can express query intentions in natural language according to the query patterns without having to understand the complexity of SQL syntax, thereby significantly improving the convenience and efficiency of data interaction.
[0069] The query modes defined in this solution include but are not limited to query modes such as "indicator range query", "dimension range query", "attribute range query", "detailed value query based on indicators, dimensions, and attributes", and "query indicators, dimensions, and attributes based on value range". These query modes are explained below.
[0070] (1) Index range query:
[0071] Query patterns such as "Indicator Range Query" can be used to help users understand the list of available indicators. For example, the query statement constructed according to the query pattern such as "Indicator Range Query" expressed in natural language is: List all indicators related to sales performance;
[0072] Query modes such as "indicator range query" not only make it easy for users who are new to the system to quickly familiarize themselves with the system functions, but also provide a basis for advanced users to build complex queries.
[0073] (2) Dimension range query:
[0074] Query patterns such as "dimension range query" allow users to explore different aspects of data. For example, the query statement constructed according to the query pattern such as "dimension range query" expressed in natural language is: display all time-related dimensions;
[0075] Query patterns such as Dimension Range Query can help users gain a deeper understanding of the structure of their data by identifying time periods, geographic locations, or other classification criteria that can be used for further analysis.
[0076] (3) Attribute range query:
[0077] Query patterns such as "attribute range query" focus on revealing the segmented attributes under a specific dimension. For example, the query statement expressed in natural language constructed according to the query pattern such as "attribute range query" is: list all product categories;
[0078] Through query modes such as "attribute range query", users can divide query conditions more finely, thereby achieving refined analysis of data.
[0079] (4) Detailed value query based on indicators, dimensions, and attributes:
[0080] Query modes such as "detailed value query based on indicators, dimensions, and attributes" are relatively rich and diverse, and are designed to meet users' query needs for specific data points. For example, the query statement expressed in natural language constructed according to the query mode such as "detailed value query based on indicators, dimensions, and attributes" is: Query the total sales of all products in East China in the second quarter of this year;
[0081] Query patterns such as "detailed value query based on indicators, dimensions, and attributes" usually combine indicators, dimensions, and attributes, and require the big model to accurately understand and convert them into corresponding SQL query statements to obtain accurate results.
[0082] (5) Ask about indicators, dimensions, and attributes based on the value range:
[0083] Query patterns such as "return indices, dimensions, and attributes based on value ranges" allow users to trace related indicators, dimensions, or attributes based on known value ranges. For example, a query statement expressed in natural language constructed according to the query pattern "return indices, dimensions, and attributes based on value ranges" is: Find all product categories with sales exceeding one million;
[0084] Query modes such as "asking about indicators, dimensions, and attributes based on value ranges" are suitable for data mining and anomaly detection scenarios, and can help users quickly locate key information.
[0085] The above are some instructions for some query modes. When defining these query modes, you should ensure simplicity and flexibility.
[0086] Among them, simplicity can ensure that the query mode is concise and clear, avoiding lengthy and complex expressions, which can improve the accuracy and efficiency of user input;
[0087] Flexibility supports multiple expressions and can correctly identify the user's query intent even if the user uses different vocabulary.
[0088] Through pre-built multiple query modes, the big models corresponding to various industries can provide users with a powerful and user-friendly data query platform, which can play an important role both in daily business monitoring and in-depth data analysis scenarios. This not only improves the efficiency of data query, but also promotes the popularization of data-driven decision-making, helping enterprises to better utilize data assets and better promote business development.
[0089] Step S103: input the query statement into the big model, so that the big model searches for query results matching the query statement from the general data table corresponding to the target industry.
[0090] In the process of implementing step S103, after obtaining the query statement expressed in natural language constructed by the user according to the question style corresponding to any query mode, the query statement expressed in natural language is input into the big model corresponding to the target industry, so that the big model queries the query result matching the query statement from the general data table corresponding to the target industry, and the query result includes the industry data of the queried target industry.
[0091] It should be noted that each industry has a corresponding general data table pre-built, which stores the industry data corresponding to the industry. The general data table adopts a general data structure, and the core columns of the general data table include any one or more of the following: indicator column, dimension column, attribute column, value column and unit column.
[0092] When the big model corresponding to the target industry queries the query results that match the query statement from the general data table corresponding to the target industry, the big model first converts the "query statement expressed in natural language" into an SQL query statement, and then queries the query results that match the "query statement expressed in natural language" from the general data table through the SQL query statement.
[0093] In some embodiments, after the query statement expressed in natural language is input into the big model corresponding to the target industry, if the query result fed back by the big model is obtained, step S104 is executed;
[0094] If error information fed back by the large model is obtained, the error information and / or suggestion information are output. The error information is used to characterize that the large model cannot recognize the query statement (query statement expressed in natural language), and the suggestion information is used to suggest using any query mode to construct the query statement (query statement expressed in natural language).
[0095] That is to say, after the query statement expressed in natural language is input into the big model corresponding to the target industry, if a query statement that cannot be recognized by the big model is encountered (equivalent to encountering a question that cannot be recognized by the big model), an error message and / or suggestion information is output, and the user is kindly prompted to input an error through the error message, and the user is advised to adopt a certain query format (query mode) through the suggestion information.
[0096] For the universal data tables mentioned above, this solution pre-builds universal data tables corresponding to various industries. Universal data tables are the key to realizing diversified query requirements and data analysis functions. Universal data tables can not only accommodate a wide range of data types, but also ensure data consistency and integrity, providing a solid foundation for the subsequent "converting query statements expressed in natural language into SQL query statements". The core columns of universal data tables include one or more of the indicator columns, dimension columns, attribute columns, value columns, and unit columns. The core columns of universal data tables carry important information and together construct a comprehensive data view. The indicator columns, dimension columns, attribute columns, value columns, and unit columns are explained below.
[0097] Indicator column: The indicator column is responsible for recording specific statistical data names, such as sales, inventory or visits. The indicator column is the core part of data query;
[0098] Dimension columns: Dimension columns cover the classification and grouping information of data. For example, dimension columns contain dimension information such as time, region, and product category. These dimension information helps to refine query conditions and allow users to view data from different angles.
[0099] Attribute column: The attribute column further expands the description of the dimension. For example, the attribute column includes the specific model of the product category, the specific city of the region, etc. The attribute column provides a more detailed screening basis;
[0100] Value column: The value column stores specific values, which is the part of the query result that most directly reflects the data status;
[0101] Unit column: The unit column specifies the standard of measurement of the value, whether it is a monetary unit, volume unit, or other measurement standard, the unit column can ensure the accurate interpretation of the data.
[0102] The general data table composed of the core columns mentioned above can adapt to various query scenarios. Whether it is a simple query of the value of a certain indicator within a specific time, or a complex analysis of the comprehensive performance across multiple dimensions, the required information can be quickly obtained through precise SQL query statements (converted from "query statements expressed in natural language"); in addition, standardized data processing methods can also reduce data redundancy and inconsistency, thereby improving the overall data quality, making the query results output by the large model more accurate and reliable, and effectively supporting data analysts to make wise judgments based on query results;
[0103] By building common data tables corresponding to various industries, we can not only achieve efficient data management and query, but also promote cross-departmental and cross-industry data sharing and analysis, providing strong support for business decision-making.
[0104] Step S104: If the query result fed back by the large model is obtained, the query result is output.
[0105] In the specific implementation of step S104, if the query result fed back by the large model is obtained, the query result fed back by the large model is output;
[0106] That is to say, when the big model corresponding to the target industry converts the "query statement expressed in natural language" into an SQL query statement and queries the query result from the general data table based on this (SQL query statement), the big model feeds back the query result obtained by the query. At this time, the query result fed back by the big model is output, thereby feeding back the query result that matches the "query statement expressed in natural language" input by the user to the user.
[0107] It should be noted that in actual applications, the performance of the large model corresponding to the target industry may not meet expectations in certain scenarios, which requires the large model corresponding to the target industry to be revised;
[0108] In some embodiments, feedback information is collected and the macro model corresponding to the target industry is modified according to the feedback information.
[0109] It is understandable that when collecting feedback information on the big model corresponding to the target industry, the following contents are usually involved: collecting specific cases, analyzing the deviation between the query results of the big model and the actual results, identifying the deficiencies of potential training data (sample data used to train the big model), and identifying the defects of the model architecture of the potential big model;
[0110] Try to collect as much detailed feedback information as possible on the big model corresponding to the target industry. This feedback information can help you locate the problems of the big model more accurately.
[0111] In the process of using the feedback information to correct the big model corresponding to the target industry, the correction measures involved include any one or more of the following: re-labeling sample data, adding sample data under specific scenarios, adjusting model parameters of the big model, and rebuilding the model architecture of the big model;
[0112] After revising the big model corresponding to the target industry, the revised big model is subjected to the corresponding testing process to ensure that the revised big model solves the original defects and does not introduce new problems.
[0113] It should be noted that the iterative update of the large model is an ongoing process, which aims to continuously improve the performance and adaptability of the large model;
[0114] In some embodiments, the big model corresponding to the target industry is updated and iterated according to a preset update cycle; further, the big model corresponding to each industry is updated and iterated according to a preset update cycle, so that the updated and iterated big model can integrate the latest algorithms, process larger-scale data, and support more diverse query types.
[0115] When regularly updating and iterating large models, you can use model retraining, performance tuning, function enhancement and other means to update and iterate large models. The time and labor costs of updating and iterating are controlled within a certain range (for example, completing the update and iteration of the large model within one day). This helps to quickly respond to market changes and user feedback, and maintain the competitiveness and value of the large model.
[0116] The update and iteration process of the big model should be institutionalized to form a fixed update cycle and quality assurance process to ensure that each update and iteration can be smoothly transitioned and avoid interference with existing services. Through continuous updates and iterations, the big model can gradually evolve to better serve the ever-evolving business scenarios and become the engine for industry data-driven decision-making in various industries.
[0117] In the embodiment of the present invention, the big model corresponding to the target industry is loaded, the query statement expressed by the user in natural language is obtained, and the query statement is input into the big model to obtain the query result. The user does not need to learn SQL and write SQL instructions, and can query the desired query results through natural language and big models, thereby reducing the query cost, improving the query accuracy and improving the query efficiency.
[0118] For the above-mentioned embodiments of the present invention Figure 1 The large model corresponding to the target industry involved in step S101 is shown in Figure 2 , shows a flow chart of obtaining a large model corresponding to a target industry through training provided by an embodiment of the present invention, Figure 2 The following steps are involved:
[0119] Step S201: Obtain sample data corresponding to the target industry.
[0120] In the process of implementing step S201, sample data corresponding to the target industry is obtained. The sample data corresponding to the target industry includes multiple sets of question-answer script pairs. Each set of question-answer script pairs includes a corresponding question script and an answer script. The type of the question script is an attribute script, an indicator dimension script, a range inquiry script, a value question script or a value range rhetorical question script. The answer script is the true answer to the question script.
[0121] It should be noted that in the process of training the big model corresponding to the target industry, the construction of the question and answer script pair is a key step in training the big model. The question and answer script pair directly affects the big model's ability to understand and execute complex queries. In order to ensure that the big model can work accurately in various scenarios, the sample data used to train the big model needs to cover various types of queries. Therefore, the sample data contains multiple sets of question and answer script pairs. The type of question script in each set of question and answer script pairs is attribute script, indicator dimension script, range query script, value question method script or value range rhetorical script. The attribute script, indicator dimension script, range query script, value question method script and value range rhetorical script mentioned above are explained below.
[0122] (1) Property script:
[0123] The attribute script is mainly used to teach the big model how to identify and understand various attributes in the data, such as teaching the big model to identify provinces, cities, departments, and time in the data;
[0124] For example, the property script may contain the content "What is the industrial output value of JS Province?"
[0125] For example, an attribute script may contain the content "In the second quarter of 2023, by what percentage did the GDP of the city of NJ increase?"
[0126] Through these attribute scripts, the large model can learn to map attributes in natural language to corresponding fields in the database.
[0127] (2) Indicator dimension script:
[0128] The indicator dimension script helps the big model grasp the relationship between different indicators and their dimensions. For example, the indicator dimension script contains the following content: display the output value of the primary, secondary and tertiary industries of all industries;
[0129] Another example is that the indicator dimension script contains the following content: compare the proportion of the population with different educational levels;
[0130] The indicator dimension script enables the big model to understand how indicators are classified and compared according to different dimensions.
[0131] (3) Range query script:
[0132] The scope inquiry script involves how to ask and answer questions about the scope of indicators or dimensions. For example, the scope inquiry script contains the following: list all queryable indicators;
[0133] Another example is that the scope inquiry script includes "Which departments have sales exceeding 1 million?"
[0134] Training the big model through range query scripts can enable the big model to recognize specific values and understand the concept of range.
[0135] (4) Value query script:
[0136] The value-asking script focuses on how to ask for the specific value of a particular indicator. For example, the value-asking script contains the content "What is the education expenditure of BJ City in the first half of 2023?"
[0137] Another example is that the value question script contains the content "What percentage did the output value of the tertiary industry increase last year?"
[0138] These query scripts ensure that the big model can accurately convert natural language queries into specific numerical queries.
[0139] (5) Value range question script:
[0140] The value range rhetorical question script can teach the big model how to reversely search for indicators, dimensions or attributes based on a given value range. For example, the value range rhetorical question script contains the content "Which cities have GDP growth exceeding the average?"
[0141] Another example is the value range rhetorical question script, which includes the following: Find all departments with sales between 500,000 and 1 million;
[0142] These value range query scripts are crucial for data analysis and reporting because they help the big model understand the logic of the reverse query.
[0143] When constructing the above-mentioned question scripts such as attribute scripts, indicator dimension scripts, range query scripts, value question scripts, value range rhetorical question scripts, etc., we should ensure that these question scripts cover all possible query scenarios, including but not limited to time series analysis, spatial distribution query, hierarchical classification and multi-dimensional cross-analysis; question scripts should be as diverse as possible, and contain different grammatical structures and expressions to enhance the generalization ability of large models.
[0144] In addition, after obtaining sample data (equivalent to the training data set), it is also crucial to optimize the quality of the sample data. Ways to optimize sample data include removing duplicate or irrelevant samples (question-answer script pairs) to ensure the balance of sample data and avoid certain types of queries being too frequent, which may lead to bias in the large model. Cross-validation techniques can be used to further evaluate the performance of the large model on unseen data, thereby ensuring the reliability of the large model in practical applications.
[0145] In summary, constructing question-answer script pairs in sample data is a relatively detailed and complex process. On the premise of having a deep understanding of the target scenarios of the big model, continuous tuning and optimization are required to ensure that the big model can perform well in real-world data query tasks. By training the big model with question-answer script pairs in sample data, an intelligent and flexible NL2SQL model can be formed, thereby providing users with an efficient and accurate data query experience.
[0146] After obtaining sample data, the selection of training strategy is critical to ensure that the trained large model can run stably and achieve expected performance after it goes online.
[0147] Therefore, this solution provides two training methods for large model training. These two training methods are called the first training method and the second training method, respectively. These two training methods have different advantages and applicable scenarios.
[0148] When the first training mode is enabled, step S202 is executed; when the second training mode is enabled, step S203 is executed.
[0149] Step S202: When the first training method is enabled, some model parameters of the pre-trained model are adjusted using some sample data to obtain a large model corresponding to the target industry.
[0150] In the specific implementation of step S202, when the first training method is enabled, some sample data are selected from all the sample data to adjust some model parameters of the pre-trained model, so as to obtain a large model corresponding to the target industry.
[0151] In some embodiments, the first training method may be a LoRA (Low-Rank Adaptation) fine-tuning training method. The LoRA fine-tuning training method is a lightweight adaptive training technology. When using the LoRA fine-tuning training method and part of the sample data for training, a low-rank matrix is added to the pre-trained model, and only part of the model parameters of the pre-trained model are updated, keeping the weight of the model body of the pre-trained model unchanged, thereby training a large model corresponding to the target industry.
[0152] It should be noted that the first training method (such as the LoRA fine-tuning training method) is suitable for quickly adapting models on limited computing resources and small-scale new data sets, while avoiding the situation where "the model will not forget old knowledge when learning new knowledge"; the first training method (LoRA fine-tuning training method) can effectively reduce training time and storage costs, and is especially suitable for personalized or domain-specific scenarios, such as suitable for training large models corresponding to industries such as finance and medical care.
[0153] Step S203: When the second training method is enabled, the specific model or pre-trained model is fully trained using the full sample data to obtain a large model corresponding to the target industry.
[0154] In the specific implementation of step S203, when the second training method is enabled, the specific model or the pre-trained model is fully trained using the full amount of sample data, so as to obtain a large model corresponding to the target industry;
[0155] It should be noted that the specific model mentioned above can be selected according to the actual situation of the target industry. For example, the specific model can be a certain type of neural network model.
[0156] In some embodiments, the second training method may be a full data training method. When using the full data training method for training, all available sample data is used to train from scratch or to perform comprehensive training on a pre-trained model, thereby training a large model corresponding to the target industry.
[0157] It should be noted that the second training method (such as the full data training method) can make full use of the richness and diversity of sample data to enable the large model to learn a more comprehensive feature representation, so that the large model has better generalization ability in a wide range of scenarios. For large models that pursue extreme performance and versatility, the second training method can be used for training.
[0158] Through the above-mentioned steps S201 to S203, a large model corresponding to the target industry is trained; similarly, by adopting the methods such as the above-mentioned steps S201 to S203, a large model corresponding to each industry can be trained.
[0159] It is worth mentioning that after training the big model corresponding to the target industry, in order to ensure that the big model can run stably in the actual environment, the big model needs to be tested before it goes online. The testing process includes multiple key evaluations aimed at comprehensively verifying the performance, accuracy and stability of the big model.
[0160] The specific process of testing the big model is as follows: A / B testing is performed on the trained big model. The A / B test is used to compare the performance of the newly trained big model with the original big model. By randomly assigning user groups, it is observed whether the newly trained big model significantly improves query accuracy or user experience;
[0161] Then, the trained large model is subjected to stress testing. Stress testing can simulate high-concurrency scenarios and check the response speed and accuracy of the large model under extreme loads, which is crucial to ensuring service continuity and reliability.
[0162] Then, the trained large model is tested under boundary conditions. The boundary condition test focuses on edge cases to ensure that the large model can still give a reasonable response when processing abnormal or extreme data.
[0163] Then, the trained large model is subjected to performance benchmark testing, which can quantify the speed, latency, and resource consumption of the large model, thereby optimizing the configuration and improving efficiency.
[0164] The above embodiments of the present invention Figure 1 and Figure 2 This is a description of this plan. To further understand this plan, Figure 3 The overall architecture diagram of an industry data query method based on a large model is shown to illustrate this solution as a whole. Figure 3 The following steps are involved:
[0165] Step S301: Analyze the data characteristics of each industry.
[0166] It should be noted that when constructing the big models corresponding to each industry, it is necessary to conduct an in-depth analysis of the needs of each industry in order to explore the characteristics and technical details of the industry; considering that the big models mainly serve statistical management and data analysis, the application scenarios of the big models cover a wide range, from production efficiency monitoring in the manufacturing industry to sales trend analysis in the retail industry. Each sub-segment has its own uniqueness, which requires a full understanding of the differences between the industries when constructing the big models corresponding to the industries. The objects of concern of each industry are different.
[0167] The data characteristics of each industry can be found in the above embodiments of the present invention. Figure 1 The content in step S101 is not repeated here.
[0168] Step S302: construct a general data table.
[0169] Step S303: construct a query pattern.
[0170] It should be noted that the query mode is also called the question mode.
[0171] Step S304: Create question-answer script pairs in sample data.
[0172] Step S305: Perform model training based on sample data.
[0173] Step S306: Test and launch the trained large model.
[0174] Step S307: Collect feedback information and modify the macro model according to the feedback information.
[0175] In the specific implementation of step S307, if the online large model fails to fully meet the customer scenario, feedback information corresponding to positive feedback is collected, and the large model is corrected according to the feedback information;
[0176] The method of correcting the large model is: returning to step S303 to step S305 and quickly correcting the large model.
[0177] Step S308: iteratively update the large model.
[0178] In the specific implementation of step S308, the large model is iteratively updated regularly or as needed while controlling time and labor costs.
[0179] It should be noted that the execution principle of step S301 to step S308 can be found in the above embodiment of the present invention. Figure 1 and Figure 2 The content will not be repeated here.
[0180] In summary, this solution is based on a large model to quickly improve the accuracy of NL2SQL for various industry indicators. It standardizes the indicators of various industries through templates and scripts, realizes rapid training of large models, and solves the problems of insufficient understanding of specialized indicators of various industries by large models in actual applications and non-standard conversion of special indicators into SQL, thereby reducing training time and labor costs.
[0181] More specifically, this solution uses the constructed general data tables and question patterns, combined with a small amount of targeted sample data, to quickly optimize and train the big model corresponding to a specific industry, thereby prompting the big model's ability to answer industry data and ensuring that the answers output by the big model are accurate and correct; the above strategy not only speeds up the training process of the big model, but also ensures the response quality and efficiency when processing industry data;
[0182] Through efficient training methods, the big model can better adapt to complex and changeable question types and diverse application scenarios, significantly improving the user's interactive experience and satisfaction; users will enjoy personalized services that are more in line with their needs, and achieve the industry-corresponding big model's rapid optimization goals in information analysis and accurate answers in specific fields.
[0183] In general, this solution has the following beneficial effects:
[0184] 1. Accelerate the efficiency of generating indicator training data for large models corresponding to the industry: By using the technology of expanding indicator seed problems, the need for manual intervention is significantly reduced, and the speed and efficiency of generating training data sets based on specific industry indicator problems are improved.
[0185] 2. Ensure the quality of training data generation: Through semantic understanding and reasoning of industry indicators, automatically create extended questions that are highly consistent with the semantics of the original questions, ensure the logical coherence and contextual fit of the generated training data, and improve the accuracy and reliability of large model data generation.
[0186] 3. Optimize the cost-effectiveness of the test set: Automatically expand seed questions and extract test samples, and execute the automated process according to the preset ratio, saving labor costs and time costs, and effectively reducing the construction and maintenance costs of the test set.
[0187] 4. Significantly improve the accuracy of large models corresponding to the industry.
[0188] 5. Enhance the adaptability and flexibility of large models: Large models can automatically adjust to adapt to changing data formats and requirements, which enhances the flexibility and versatility of large models and further improves the adaptability of large models in various application scenarios.
[0189] Corresponding to the industry data query method based on a large model provided in the above embodiment of the present invention, see Figure 4 , the embodiment of the present invention also provides a structural block diagram of an industry data query device based on a large model, the industry data query device includes: a loading unit 401, an acquisition unit 402, a query unit 403 and an output unit 404;
[0190] The loading unit 401 is used to load the big model corresponding to the target industry. The target industry can be any industry. The big model corresponding to the target industry is obtained by training based on sample data.
[0191] The acquisition unit 402 is used to acquire a query statement expressed in a natural language constructed according to any query mode.
[0192] The query unit 403 is used to input the query statement into the big model, so that the big model searches for query results matching the query statement from the general data table corresponding to the target industry. The core columns of the general data table include any one or more of the following: indicator column, dimension column, attribute column, value column and unit column.
[0193] The output unit 404 is used to output the query result if the query result fed back by the large model is obtained.
[0194] Preferably, the output unit 404 is also used to: if error information fed back by the large model is obtained, output error information and / or suggestion information, the error information is used to characterize that the large model cannot recognize the query statement, and the suggestion information is used to suggest using any query mode to construct the query statement.
[0195] In the embodiment of the present invention, the big model corresponding to the target industry is loaded, the query statement expressed by the user in natural language is obtained, and the query statement is input into the big model to obtain the query result. The user does not need to learn SQL and write SQL instructions, and can query the desired query results through natural language and big models, thereby reducing the query cost, improving the query accuracy and improving the query efficiency.
[0196] Preferably, combined Figure 4 The content shown, the acquisition unit 402 includes a display module and an acquisition module, and the execution principle of each module is as follows:
[0197] The display module is used to display intelligent prompt information when detecting user input content. The intelligent prompt information includes: question styles corresponding to each query mode.
[0198] The acquisition module is used to acquire a query statement expressed in natural language constructed by a user according to a question style corresponding to any query mode.
[0199] Preferably, combined Figure 4 As shown in the figure, the loading unit 401 includes an acquisition module, a first training module and a second training module. The execution principle of each module is as follows:
[0200] An acquisition module is used to obtain sample data corresponding to the target industry, wherein the sample data includes multiple sets of question-answer script pairs, each set of question-answer script pairs is of the type of an attribute script, an indicator dimension script, a range inquiry script, a value question script or a value range rhetorical question script, and each set of question-answer script pairs includes a corresponding question script and an answer script.
[0201] The first training module is used to adjust some model parameters of the pre-trained model using part of the sample data when the first training method is enabled, so as to obtain a large model corresponding to the target industry.
[0202] The second training module is used to comprehensively train a specific model or a pre-trained model using the full amount of sample data when the second training method is enabled, so as to obtain a large model corresponding to the target industry.
[0203] Preferably, combined Figure 4 The content shown, the industry data query device also includes:
[0204] The correction unit is used to collect feedback information and correct the large model according to the feedback information.
[0205] The updating unit is used to update and iterate the large model according to a preset updating cycle.
[0206] In summary, the embodiment of the present invention provides an industry data query method and device based on a big model, which loads a big model corresponding to the target industry, obtains a query statement expressed by a user in natural language, and inputs the query statement into the big model to obtain a query result. The user does not need to learn SQL and write SQL instructions, and can query the desired query results through natural language and big models, thereby reducing query costs, improving query accuracy, and improving query efficiency.
[0207] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, 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 creative work.
[0208] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0209] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for querying industry data based on a large model, characterized in that: The method comprises: Loading a large model corresponding to a target industry, where the target industry is any industry, and the large model corresponding to the target industry is obtained by training based on sample data; Obtaining a query statement expressed in a natural language constructed according to an arbitrary query pattern; Input the query statement into the big model, so that the big model searches for query results matching the query statement from a general data table corresponding to the target industry, wherein the core columns of the general data table include any one or more of the following: an indicator column, a dimension column, an attribute column, a value column, and a unit column; If the query result fed back by the large model is obtained, the query result is output.
2. The method according to claim 1, characterized in that Get queries expressed in natural language constructed using any query mode, including: When user input is detected, intelligent prompt information is displayed, and the intelligent prompt information includes: question styles corresponding to each query mode; A query statement expressed in natural language constructed by the user according to a questioning style corresponding to any of the query modes is obtained.
3. The method according to claim 1, characterized in that The process of obtaining a large model corresponding to the target industry based on sample data training includes: Obtain sample data corresponding to the target industry, wherein the sample data includes multiple sets of question-answer script pairs, each set of the question-answer script pairs includes a corresponding question script and an answer script, and the type of the question script is an attribute script, an indicator dimension script, a range query script, a value query script, or a value range rhetorical question script; When the first training mode is enabled, using part of the sample data to adjust part of the model parameters of the pre-trained model to obtain a large model corresponding to the target industry; When the second training method is enabled, the specific model or the pre-trained model is fully trained using the full amount of the sample data to obtain a large model corresponding to the target industry.
4. The method according to claim 1, characterized in that After the query statement is input into the large model, the method further includes: If error information fed back by the large model is obtained, the error information and / or suggestion information is output, wherein the error information is used to characterize that the large model cannot recognize the query statement, and the suggestion information is used to suggest using any of the query modes to construct the query statement.
5. The method according to any one of claims 1 to 4, characterized in that: Also includes: Collect feedback information; The large model is modified according to the feedback information.
6. The method according to any one of claims 1 to 4, characterized in that: Also includes: The large model is updated and iterated according to a preset update cycle.
7. An industry data query device based on a large model, characterized in that: The device comprises: A loading unit, used to load a large model corresponding to a target industry, where the target industry is any industry, and the large model corresponding to the target industry is obtained by training based on sample data; An acquisition unit, used to acquire a query statement expressed in a natural language constructed according to any query mode; A query unit, used for inputting the query statement into the big model, so that the big model searches for a query result matching the query statement from a general data table corresponding to the target industry, wherein the core columns of the general data table include any one or more of the following: an indicator column, a dimension column, an attribute column, a value column, and a unit column; The output unit is used to output the query result if the query result fed back by the large model is obtained.
8. The device according to claim 7, characterized in that The acquisition unit comprises: A display module is used to display intelligent prompt information when detecting user input content, wherein the intelligent prompt information includes: question styles corresponding to each query mode; The acquisition module is used to acquire a query statement expressed in natural language constructed by the user according to a question style corresponding to any of the query modes.
9. The device according to claim 7, characterized in that The loading unit comprises: An acquisition module, used for acquiring sample data corresponding to the target industry, wherein the sample data includes multiple sets of question-answer script pairs, each set of the question-answer script pairs is of a type of an attribute script, an indicator dimension script, a range query script, a value query script, or a value range rhetorical question script, and each set of the question-answer script pairs includes a corresponding question script and an answer script; A first training module, used to adjust some model parameters of the pre-trained model using part of the sample data when the first training mode is enabled, so as to obtain a large model corresponding to the target industry; The second training module is used to use the full amount of the sample data to comprehensively train the specific model or the pre-trained model when the second training method is enabled, so as to obtain a large model corresponding to the target industry.
10. The device according to claim 7, characterized in that The output unit is also used to: if error information fed back by the large model is obtained, output the error information and / or suggestion information, the error information is used to characterize that the large model cannot recognize the query statement, and the suggestion information is used to suggest using any of the query modes to construct the query statement.
Citation Information
Patent Citations
Database query instruction generation method and device, computer equipment and storage medium
CN117909355A
Medical insurance intelligent query method and system based on NL2SQL
CN118132579A
Large language model training method and method for generating codes by using large language model
CN118261201A
Data generation method, data generation device, computer equipment and storage medium
CN118277412A
Cited By
Query statement model fine tuning method, device and equipment based on large model
CN119599131A
Market index data query method, system and terminal based on large language model
CN120849475A
Enterprise industry question number multi-agent method and system based on large model
CN121255991A
