A sql generation driven visualization method based on large model preference learning

By generating user profiles and using large language models to parse natural language query text, and optimizing structured query statements, the problems of inaccurate query results and lack of visualization flexibility in existing technologies are solved, achieving efficient and personalized query results and visualization presentation.

CN120030036BActive Publication Date: 2026-02-24JOINT WARFARE COLLEGE NAT DEFENSE UNIV OF THE CHINESE PEOPLES LIBERATION ARMY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510059600.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-14
Publication Date
2026-02-24
Estimated Expiration
2045-01-14

AI Technical Summary

Technical Problem

Existing Text2Vis methods based on large language models lack data exposure when generating structured query statements, making it difficult to accurately understand complex query semantics, resulting in inaccurate query results. Furthermore, data visualization lacks flexibility and cannot be automatically optimized based on data changes or user behavior.

Method used

User profiles are generated by acquiring users' historical query records. Natural language query text is parsed using a large language model to generate initial structured query statements. The final structured query statements are obtained through preference optimization. The results are then visualized in conjunction with the user profiles, and the SQL query and visualization results are dynamically optimized.

Benefits of technology

It improves the accuracy and efficiency of query results, provides personalized query results and chart recommendations, and significantly enhances the efficiency of query result visualization and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120030036B_ABST
    Figure CN120030036B_ABST
Patent Text Reader

Abstract

The application provides a SQL generation driven visualization method based on large model preference learning, which comprises the following steps: obtaining an input natural language query text and a user historical query record; generating a user portrait according to the user historical query record; using a pre-trained large language model to analyze the natural language query text, so as to obtain a table name of a database table related to a user query intention and a field name corresponding to a query object entity in the database table; generating an initial structured query statement according to the user portrait, the table name of the database table and the field name corresponding to the query object entity; performing preference optimization processing on the initial structured query statement according to the user query historical record and the user portrait, so as to obtain a final structured query statement; and visualizing a query result corresponding to the final structured query statement according to the user portrait, so as to obtain a visualization result. The application effectively improves the accuracy of the query result and the visualization processing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of artificial intelligence technology, and in particular relates to a visualization method driven by SQL generation based on large model preference learning. Background Technology

[0002] With the development of Large Language Models (LLMs), especially the breakthroughs in text understanding and context learning, researchers have begun to explore applying LLMs to the Text2Vis task. However, existing LLM-based Text2Vis methods still have some limitations when handling complex data queries, particularly when retrieving and manipulating data from large-scale tables. LLMs lack sufficient data exposure during training, making it difficult to directly generate suitable Structured Query Language (SQL) statements to meet the visualization requirements of query results.

[0003] For example, generating SQL statements directly from natural language query text fails to accurately understand the semantics of complex queries, often resulting in low-quality SQL queries and inaccurate results, thus impacting decision-making quality. Secondly, in data visualization, most systems rely on static chart templates, lacking flexibility. Even if some systems allow users to customize chart styles, these adjustments are mostly manual and cannot automatically optimize visualizations based on data changes or user behavior.

[0004] Therefore, there is an urgent need to propose a solution that meets the visualization needs of different users for query results in order to solve the above problems. Summary of the Invention

[0005] In order to at least solve one or more of the technical problems mentioned above, this invention proposes a visualization scheme for SQL generation driven by large model preference learning in several aspects.

[0006] In a first aspect, embodiments of the present invention provide a visualization method driven by SQL generation based on large-scale model preference learning. The method includes: acquiring input natural language query text and user historical query records; generating a user profile based on the user historical query records; parsing the natural language query text using a pre-trained large-scale language model to obtain the table names of database tables related to the user's query intent and the field names corresponding to the query object entities in the database tables; generating an initial structured query statement based on the user profile, the table names of the database tables, and the field names corresponding to the query object entities, the initial structured query statement including query object entities in an initial order and initial customized query parameters; performing preference optimization processing on the initial structured query statement based on the user's query history and user profile to obtain a final structured query statement, wherein the order of query object entities in the final structured query statement is obtained by optimizing and adjusting the initially ordered query object entities in the initial structured query statement based on the user's query history, and the preference customized query parameters in the final structured query statement are obtained by optimizing and adjusting the initial customized query parameters based on the user profile; and visualizing the query results corresponding to the final structured query statement based on the user profile to obtain a visualization result.

[0007] In some embodiments, the user profile includes preference filtering conditions, which represent preferences for cross-table join information, nested query information, and / or data aggregation operation information. Based on the user's query history and user profile, the initial structured query statement is optimized according to preferences, including: adjusting the position order and / or aggregation method of the query object entities included in the initial structured query statement and / or deleting redundant query object entities based on the query execution results of the user's query history; and optimizing the initial customized parameters included in the initial structured query statement according to the preference filtering conditions to obtain the final structured query statement.

[0008] In some embodiments, the user profile includes initial display configuration parameters. Based on the user's query history and user profile, the initial structured query statement is optimized according to preferences. This includes: inputting the initial display configuration parameters obtained from the user profile, the user's query history, and the initial structured query statement into a pre-built preference comparison model; adjusting the initial customized parameters of the initial structured query statement to obtain the final structured query statement. The initial customized parameters include cross-table join information, nested query information, and / or data aggregation operation information.

[0009] In some embodiments, the user profile includes recommended visualization types. Visualizing the query results corresponding to the final structured query statement based on the user profile includes: executing the final structured query statement to obtain query results corresponding to the final structured query statement; generating visualization specifications corresponding to the query results based on the recommended visualization types, where the visualization specifications are the result of defining rules for the basic attributes of graphical elements used to present the query results according to the visualization types; generating visualization code corresponding to the visualization specifications according to programming language rules; and running the visualization code to obtain visualization results, where the visualization results are the result of visualizing the query results according to the recommended visualization types.

[0010] In some embodiments, after visualizing the query results corresponding to the final structured query statement based on the user profile, the method further includes: receiving input new display configuration parameters, which are used to adjust the visualization results; visualizing the query results corresponding to the final structured query statement based on the new display configuration parameters to obtain new visualization results; and updating the new display configuration parameters to the user profile to obtain an updated user profile.

[0011] In some embodiments, when the first interactive interface is a chat interactive interface, receiving new display configuration parameters input within the first interactive interface includes: receiving new natural language text input within the chat interactive interface, the new natural language text containing at least one keyword for adjusting the visualization results; and converting the keyword into new display configuration parameters in response to the new natural language text.

[0012] In some embodiments, when the second interactive interface is a graphical user interface, the graphical user interface includes an image display area for displaying visualization results and a parameter adjustment area for adjusting display configuration parameters. Receiving new display configuration parameters input by the user in the second interactive interface includes: receiving a selection operation input in the parameter adjustment area for an operation item related to the display configuration parameters; and updating the initial display configuration parameters according to the operation item content corresponding to the selection operation in response to the selection operation to obtain new display configuration parameters.

[0013] This invention provides a SQL generation-driven visualization method based on large-scale model preference learning. The method includes: acquiring input natural language query text and user query history; generating a user profile based on the user query history; parsing the natural language query text using a pre-trained large-scale language model to obtain the table names of database tables related to the user's query intent and the field names corresponding to the query entities in the database tables; generating an initial structured query statement based on the user profile, the table names, and the field names corresponding to the query entities, the initial structured query statement includes query entities in an initial order and initial customized query parameters; further optimizing the initial structured query statement based on the user's query history and user profile to obtain a final structured query statement. The order of query entities in the final structured query statement is obtained by optimizing the initially ordered query entities in the initial structured query statement based on the user's query history, and the customized query parameters in the final structured query statement are obtained by optimizing the initial customized query parameters based on the user profile. Finally, the query results corresponding to the final structured query statement are visualized based on the user profile to obtain the visualization result. Compared to related technologies, the technical solution provided by this invention accurately understands user intent through a large language model, converts natural language query text into SQL query statements, effectively improving query efficiency and accuracy. Furthermore, it dynamically optimizes the generation process of SQL query statements and visualization results through preference learning and user profiling, providing users with accurate query results and personalized chart recommendations, significantly improving the efficiency of query result visualization processing. Attached Figure Description

[0014] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:

[0015] Figure 1 This is an exemplary schematic diagram of a visualization method 100 based on large model preference learning for SQL generation according to an embodiment of the present invention;

[0016] Figure 2 An exemplary flowchart of step S104 of another embodiment of the present invention is shown;

[0017] Figure 3 An exemplary flowchart of step S105 of some other embodiments of the present invention is shown;

[0018] Figure 4 This diagram illustrates an interactive interface displaying a visualization result according to an embodiment of the present invention.

[0019] Figure 5A schematic diagram showing the visualization results of the interactive interface according to another embodiment of the present invention is shown;

[0020] Figure 6 This is a schematic diagram of the structure of a visualization device 600 driven by SQL generation based on large model preference learning according to an embodiment of the present invention;

[0021] Figure 7 A schematic block diagram of an electronic device 700 according to an embodiment of the present invention is shown.

[0022] The same or similar reference numerals in the accompanying drawings represent the same or similar parts. Detailed Implementation

[0023] To better understand and explain this invention, a further detailed description will be provided below with reference to the accompanying drawings. This invention is not limited to these specific embodiments. Rather, any modifications or equivalent substitutions made to this invention should be covered within the scope of the claims.

[0024] It should be noted that numerous specific details are provided in the following detailed embodiments. Those skilled in the art should understand that the present invention can be practiced without these specific details. In the various detailed embodiments given below, principles, structures, and components well known in the art are not described in detail in order to highlight the spirit of the invention.

[0025] The SQL generation-driven visualization method based on large model preference learning provided by this invention can be executed by a computer device, which can be a terminal or a server. The terminal can be a smartphone, tablet, laptop, touchscreen, personal computer (PC), personal digital assistant (PDA), or other similar device, and may also include a client. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.

[0026] Please refer to Figure 1 , Figure 1 This is an exemplary schematic diagram of a visualization method 100 based on large model preference learning for SQL generation according to an embodiment of the present invention. Figure 1 As shown, the method includes:

[0027] In step S101, the input natural language query text and the user's historical query records are obtained.

[0028] In the steps above, natural language query text refers to the query request entered in the form of a natural language question. User query history records include, but are not limited to: query time, user identifier, query statement, query results, database objects, execution status, and error messages. Query time is a timestamp used to record the execution time of the query. User identifier is used to distinguish different users and can be a user ID, username, or other uniquely identifying attributes. Query statement is the SQL query statement actually executed by the user, including at least SELECT operations. Query results are the result set returned after executing the query. For SELECT queries, these are the data rows that meet the query conditions. Database objects involve the database objects involved in the query, such as tables, views, stored procedures, etc. Execution status is the status of the query execution, such as success, failure, or warnings. This helps to understand whether problems occurred during query execution. Error messages can provide detailed information about the reasons for failure, such as syntax errors, insufficient permissions, data constraint conflicts, etc.

[0029] In step S102, a user profile is generated based on the user's historical query records.

[0030] In the above steps, user query history is input into a pre-built user profile building model to construct user profiles. The user profile building model can include, but is not limited to, clustering analysis models and association rule mining models. After obtaining user query history data, the data is cleaned and organized to remove duplicate, missing, or erroneous data. The data is then formatted and standardized. Personal information and behavioral characteristics of users (e.g., query frequency, preference for icon types) are extracted. Machine learning or related algorithms are used to mine the correlations between key features of user behavior, which are then used as user behavior and preferences. Finally, groups with similar personal behaviors and preferences are segmented to obtain user profiles.

[0031] In step S103, the natural language query text is parsed using a pre-trained large language model to obtain the table name of the database table related to the user's query intent and the field names corresponding to the query object entities in the database table; based on the user profile, the table name of the database table and the field names corresponding to the query object entities, an initial structured query statement is generated. The initial structured query statement includes the query object entities in an initial sort and the initial customized query parameters.

[0032] In the above steps, the database table related to the user's query intent refers to the database table determined in the relevant database based on the user's query intent.

[0033] The query entity refers to the key entity determined based on the user's query intent. For example, a user enters the natural language query text "Display monthly sales data for electronic products in 2020" into a database query interface. Keywords related to the query intent can be identified, such as "display," "2020," "electronic products," "sales data," and "monthly." Based on the user's query intent, the database table "sales data" can be identified. Based on "sales data," the table name "sales_data" can be determined in the associated database. In this database table, the field names "sales_amount" and "sales_month" corresponding to the query entity ("monthly" and "sales data") can be further identified. The intent keyword "display" can also be identified in the entered natural language query text. Intent keywords are keywords used to express the query intent. Based on the user's entered natural language query text, it can be understood that the user's query intent is: to visualize the sales data of electronic products in 2020 by month.

[0034] By incorporating the semantic understanding capabilities of a large language model, this invention can accurately parse user-input natural language query text and automatically generate precise SQL query statements. Compared to traditional rule-based template methods, the SQL generation process of this invention is more flexible and intelligent, especially performing exceptionally well when handling complex or cross-table queries. This improvement reduces the burden on users to manually write queries while simultaneously enhancing query efficiency and accuracy.

[0035] In the above steps, based on users' historical query records (such as "trend changes in electronic product sales data in 2019" and "comparison of monthly electronic product sales data in the first half of this year"), it can be predicted that users' query habits involve searching for electronic product sales data, and that they expect to visualize the electronic product sales data by month. For example, predicting that a user's query behavior is to visualize electronic product sales data for a certain period by month. Custom query parameters corresponding to this query intent can include "WHERE" and "ORDER BY". Custom query parameters are keywords used in SQL query statements to customize the query results. For example, WHERE: used to filter the portion of the result set that meets the conditions. Only rows that meet the conditions specified in the WHERE clause will be included in the result set. ORDER BY: used to sort the result set. The ORDER BY clause can sort the results in ascending (ASC) or descending (DESC) order based on the values ​​of one or more columns. Custom parameters include, but are not limited to, WHERE clauses, ORDER BY clauses, GROUP BY clauses, cross-table join information, nested query information, and / or data aggregation operation information.

[0036] Custom parameters "WHERE" and "ORDER BY" can be determined based on the query entity extracted from the natural language query text. For example, "WHERE year = 2020" and "ORDER BY sa les_month". In some embodiments, initial custom parameters for generating structured query statements can be predicted using a machine learning model based on the user's historical query records. Machine learning models include, but are not limited to, linear regression and decision trees. For example, the required custom query parameters "WHERE" and "ORDER BY" can be predicted based on the user's historical query records. Then, using a pre-trained large language model, based on the initial custom parameters "WHERE year = 2020" and "ORDER BY sa les_month", the database table name "sa les_data", and the field names "sa les_amount" and "sa les_month" corresponding to the query entity, the initial SQL statement is generated as follows:

[0037] SELECT sa les_amount,sa les_month FROM sa les_data WHERE year=2020ORDER BY sa les_month.

[0038] In step S104, the initial structured query statement is optimized based on the user's query history and user profile to obtain the final structured query statement.

[0039] In the above steps, the position order of the query object entities in the final structured query statement is obtained by optimizing and adjusting the query object entities sorted initially in the initial structured query statement according to the user's query history. The preference customization query parameters in the final structured query statement are obtained by optimizing and adjusting the initial customization query parameters according to the user profile.

[0040] In some embodiments, performing preference optimization processing on the initial structured query statement according to the user's query history and user profile may be to perform preference optimization processing on the initial structured query statement using a preference learning model. [[ID=?]]

[0041] Suppose the user's query history includes "trend changes in electronic product sales data in 2019", "monthly data comparison of electronic product sales data in the first half of this year", "changes in electronic product sales data in the first quarter of 2019", etc. According to the content, query frequency, query time and other behavioral information of the user's query history, a user profile can be generated. For example, the user's query history includes a history of frequently querying various sales data and relatively few product energy consumption data. Among them, the history of frequently querying various sales data includes sales data of electronic products, sales data of hardware components of electronic products, or sales data of software products supporting electronic products. The relatively few product energy consumption data includes the purchase quantity and monthly consumption quantity of various raw materials used for producing the hardware components of electronic products. The preference learning model analyzes the user's query history and predicts that the user is interested in sales data, then assigns a larger priority weight value to the sales data and a smaller priority weight value to the energy consumption data.

[0042] Generalizing information such as user attributes, behavior habits, and preferences through the user profile can effectively improve the accuracy of personalized generation of SQL query statements.

[0043] In some embodiments, the final structured query statement is a query statement obtained by optimizing and adjusting each parameter in the initial structured query statement. Suppose the initial structured query statement is:

[0044] SELECT sa les_month,sa les_amount FROM sa les_data WHERE year=2020ORDER BY sa les_month.

[0045] Performing preference optimization processing on the initial structured query statement according to the user's query history and user profile, the final structured query statement can be obtained as:

[0046] SELECT sa les_amount,sa les_month FROM sa les_data WHERE year=2020,product=elect ORDER BY sa les_month.

[0047] In some embodiments, initial display configuration parameters and initial structured query statements obtained based on user profiles are input into a pre-built preference comparison model. At least initial customized parameters are adjusted on the initial structured query statement to obtain the final structured query statement. These initial customized parameters include cross-table join information, nested query information, and / or data aggregation operation information. For example, a preference comparison model can be built using a direct preference optimization algorithm. After collecting preference-related data, such as user feedback on query results, query execution time, and result relevance scores, the preference comparison model can quantify and compare different preferences. For example, Multi-Criterion Decision Analysis (MCDA) can be used to comprehensively consider multiple preferences, assign weights to each preference, and adjust the parameters in the SQL query based on the preference comparison results.

[0048] Based on the analysis results of the preference comparison model, adjust the parameters in the SQL query statement, including but not limited to modifying the WHERE clause of the query to filter more relevant data, using JOIN operations to combine multiple data sources, and adjusting sorting and pagination parameters to optimize the display of results.

[0049] The initial display configuration parameters, user query history, and initial structured query statement obtained from the user profile are input into a pre-built preference comparison model. At least the initial customized parameters of the initial structured query statement are adjusted. This may include adjusting the position order of the query object entities and initial customized parameters in the initial structured query statement based on the query execution results of the user query history, to obtain new positions corresponding to the query object entities and initial customized parameters; optimizing and adjusting the initial customized parameters in the initial structured query statement based on the initial display configuration parameters obtained from the user profile, to obtain preference-customized query parameters; and generating the final structured query statement based on the new positions corresponding to the query object entities and conditional clauses and the preference-customized query parameters.

[0050] For example, the final structured query statement is: SELECT sa les_amount, sa les_month FROM sales_data WHERE year=2020,product=elect ORDER BY sa les_month. Here, the query objects sa les_amount and sa les_month have changed positions compared to sa les_amount and sales_month in the initial structured query statement. The WHERE clause has added the query parameter product=elect, compared to the condition clause in the initial structured query statement.

[0051] In some embodiments, the initial display configuration parameters may also include a region field and / or a product category feature. A region field may be named "region"; a product category may be named "product_type". If, during the query process, the user prefers to aggregate data by region and product category, then after optimizing the initial structured query, a GROUP BY clause can be automatically added to the final structured query. For example, "GROUP BY region" and / or "GROUP BY product_type".

[0052] This invention dynamically optimizes the SQL query and visualization generation process through a preference learning mechanism and user profiling. Based on users' historical query records, behavioral habits, and specific needs, it provides personalized query results and chart recommendations. This significantly improves the user experience, enabling the product to more efficiently meet diverse needs while increasing user stickiness.

[0053] In step S105, the query results corresponding to the final structured query statement are visualized based on the user profile to obtain the visualization results.

[0054] In the steps described above, user profiles can include chart types related to the query results. Based on the user profile, visualization types that match the profile can be recommended to the user. For example, the user profile can be input into a pre-built visualization type recommendation model to obtain recommended visualization types. A visualization type refers to the chart type used to visualize the query results. By using various graphic elements (such as line charts, bar charts, pie charts, scatter plots, etc.), visualization charts can intuitively show the relationships and patterns between data, helping people to more easily understand and analyze the data.

[0055] Initial display configuration parameters can be obtained based on the recommended visualization type, and visualization specifications can be generated based on these parameters. The initial display configuration parameters are parameters related to the visualization type, determined based on user profiles. For example, the initial display configuration parameters might include a bar chart type, a first axis representing time, and a second axis representing sales revenue. These initial display configuration parameters can be determined based on user profiles. New display configuration parameters are obtained based on the user's modification intent within the interactive interface. These initial display configuration parameters include, but are not limited to, chart type, initial position parameters, and initial axis parameters. Initial position parameters indicate the sorting position of query entities and conditional clauses in a structured query statement. Initial axis parameters refer to the first and second axis parameters defined according to the chart type. Assuming the chart type is a line chart, the first axis is the x-axis, and the first axis parameter represents the time parameter; the second axis is the y-axis, and the second axis parameter represents the target value corresponding to the statistical time. The initial axis parameters can be axis parameters specified for chart types that conform to user habits and are pushed out based on user profiles.

[0056] In some embodiments, the visualization type recommendation model is constructed based on a model recommendation algorithm, such as collaborative filtering to find users similar to the user to recommend visualization types, or content-based recommendation to recommend similar visualization types based on the characteristics of the user's past query results, etc. Axial parameters include, but are not limited to, axial parameters related to bar charts, axial parameters related to line charts, and axial parameters related to pie charts.

[0057] In some embodiments, the visualization results can also be exported or shared. Based on the final generated visualization specifications, the desired charts or reports are presented to the user to ensure the results meet the user's expectations. Users can export visualizations in different formats (such as PDF, PNG, etc.). When the data source changes, in response to detecting the change, the SQL query statement is regenerated and the visualization results are updated. After a change in the data source, a real-time updated user profile is detected, and in response to the updated user profile, the visualization results and the method of exporting the visualization results are automatically adjusted.

[0058] If the data source changes (such as uploading sales data for the new quarter), the system will automatically identify the data change and update the visualization charts by updating the generated SQL query statements to ensure that the visualization charts provided to users show the latest data.

[0059] The SQL generation-driven visualization method proposed in this invention, based on large model preference learning, optimizes structured query statements according to user historical query records, which greatly satisfies users' personalized needs, reduces the number of steps users need to adjust visualization parameters multiple times to meet personalized requirements, and effectively improves the efficiency of query result visualization processing.

[0060] Figure 2 An exemplary flowchart of step S104 of another embodiment of the present invention is shown. It will be understood that... Figure 2 The steps S2041-S2042 shown are a specific implementation of the aforementioned step S104, therefore the preceding text Figure 1 The relevant features described can be applied similarly here.

[0061] Step S2041: Based on the query execution results of the user's query history, adjust the position order and / or aggregation method of the query object entities contained in the initial structured query statement and / or delete redundant query object entities.

[0062] Step S2042: Optimize the initial customized parameters contained in the initial structured query statement according to the preference filtering conditions to obtain the final structured query statement.

[0063] In the above steps, the information most relevant to the user profile in the initial structured query statement is concentrated in the customized query parameters. The user profile can also influence the customized parameters in the structured query statement. Customized parameters include, but are not limited to, cross-table join information, nested query information, and / or data aggregation operation information. A cross-table join (Join) refers to merging data from two or more tables in an SQL query to facilitate simultaneous querying and processing of information from different tables. In many application scenarios, data is often distributed across multiple tables. To obtain the required information, join operations are used to combine these tables. Cross-table joins can be used to implement complex query requirements and improve the efficiency of data querying and processing. A nested query (Subquery) refers to embedding another query statement within a single SQL query statement. Nested queries can be used to execute a subquery before the main query executes and return the result to the main query. Subqueries are typically used to generate temporary result sets to provide the main query with the required values. Nested queries can appear in the SELECT, FROM, and WHERE parts of an SQL query statement. Nested queries can be categorized into different types depending on the use case. For example, a subquery returns a single value (scalar value) and is typically used to calculate summary information or provide comparison values ​​in the WHERE clause. Nested queries can fulfill complex query requirements and improve the flexibility of SQL queries. Aggregate operations are a common calculation method in SQL queries used to combine multiple rows of data into one or more summary results. Aggregate operations are usually used with aggregate functions such as COUNT, SUM, AVG, MAX, and MIN. These functions can perform calculations on a set of values ​​and return a single result value.

[0064] When the initial custom parameters include cross-table join information, nested query information, and / or data aggregation operation information, preference filtering conditions refer to the preference representation for cross-table join information, nested query information, and / or data aggregation operation information. For example, aggregation operations are often used with the GROUP BY clause to group data. When using GROUP BY, the query results are grouped by the unique values ​​of the specified columns, and then aggregate functions are applied to each group. Suppose we are calculating the average salary of employees in each department; the preference representation for data aggregation operation information would be:

[0065] SELECT department_id,AVG(sa l ary)AS avg_sa l ary

[0066] FROM employees

[0067] GROUP BY department_id;

[0068] In this example, GROUP BY department_id groups employees by department, and then the AVG function is used to calculate the average salary for each department.

[0069] Since the initial structured query is generated by a pre-trained large language model, its query structure differs from user preferences. The query structure can be optimized based on individual user preferences and filtering criteria. This optimization involves identifying the initial customized parameters included in the initial structured query; optimizing based on the preference representation of cross-table join information when the initial customized parameters include such information; optimizing based on the preference representation of nested query information when the initial customized parameters include such information; and optimizing based on the preference representation of data aggregation operation information when the initial customized parameters include such information. Optimization of initial customized parameters includes, but is not limited to, adjusting the position of customized parameters, adding or removing customized parameters, etc.

[0070] Assuming the initial custom parameters only include "ORDER BY", the initial custom parameters are optimized based on the user profile to obtain the preference-customized query parameters, which can include both "ORDER BY" and "GROUP BY".

[0071] In some embodiments, based on the query execution results from the user's query history, the order and / or aggregation method of the query object entities included in the initial structured query statement are adjusted, and / or redundant query object entities are deleted. Adjusting the order of query object entities includes repositioning the query object entities or deleting redundant query object entities. Adjusting the aggregation method can be done by modifying the aggregation function and its parameters. For example, assuming the goal is to calculate the total employee salary instead of the average salary, replacing the AVG function with the SUM function yields the following SQL query statement:

[0072] SELECT department_id,COUNT(*)AS num_emp loyees,SUM(sa l ary)AS total_sa l aryFROM emp loyees

[0073] GROUP BY department_id;

[0074] When adjusting the aggregation method, it is necessary to ensure that other parts of the query statement (such as SELECT, FROM, WHERE, GROUP BY, and ORDER BY) match the new aggregation method to ensure the accuracy and predictability of the query results.

[0075] The SQL generation-driven visualization method based on large model preference learning provided by this invention automatically optimizes structured query statements according to user query history and user profile, which can improve the accuracy of structured query statements and thus meet the visualization requirements of structured query results.

[0076] Figure 3 An exemplary flowchart of step S105 of some embodiments of the present invention is shown. It will be understood that... Figure 3 The steps S3051-S3054 shown are a specific implementation of the aforementioned step S105, therefore the preceding text Figure 1 The relevant features described can be applied similarly here.

[0077] Step S3051: Execute the final structured query statement to obtain the query results corresponding to the final structured query statement.

[0078] Step S3052: Generate a visualization specification corresponding to the query results based on the recommended visualization type. The visualization specification is the result of defining rules for the basic attributes of the graphic elements used to present the query results based on the visualization type.

[0079] In the steps described above, after receiving the natural language query text, the server parses it and constructs a user profile based on the user's query history. This user profile may include initial display configuration parameters. For example, if users prefer to display sales data using blue bar charts, the initial display configuration parameters would be a blue bar chart, with the x-axis representing time parameters and the y-axis representing monthly sales data.

[0080] In the steps described above, the visualization specification can be the result of defining rules for the basic attributes of the graphical elements used to present the query results based on the initial display configuration parameters. Assume the initial display configuration parameters are a blue bar chart, with the x-axis representing time and the y-axis representing monthly sales data. For example, when generating the visualization specification, based on the initial display configuration parameters, we can define a blue bar chart, with the x-axis representing the month and the y-axis representing monthly sales data. When determining to use a bar chart to display sales data, we define the mapping relationship between the month and the first axis parameter of the bar chart, and the mapping relationship between sales data and the second axis parameter. Then, we set the basic attributes of the graphical elements of the bar chart, such as setting the bar chart's color fill parameter to blue.

[0081] In some embodiments, visualization specifications may also include parameters such as chart layout parameters, data mapping relationships, and color selection. In some embodiments, visualization specifications can be dynamically adjusted based on user preference characteristics in the user profile. For example, after updating the user profile, the chart type in the user profile may change from a bar chart to a pie chart. When the user makes a new query, the visualization specifications are adjusted according to the updated user profile. Alternatively, after initially presenting the visualization results, new display configuration parameters input by the user can be received, and the visualization specifications can be adjusted according to these new display configuration parameters. For example, new display configuration parameters may include chart size, color, labels, and other attributes, as well as binding data from the query results to the chart.

[0082] The above-mentioned product automatically generates visualization specifications by recommending the most suitable data visualization charts. Users do not need to have programming or data analysis skills. The product can quickly generate intuitive charts, which effectively improves the efficiency of query result visualization processing.

[0083] Furthermore, users can interactively adjust the visualization results in real time and update the user profile with the adjusted content, making the data visualization process more convenient and flexible, and significantly reducing the learning cost and operational threshold for users in data analysis and presentation.

[0084] Step S3053: Generate visualization code corresponding to the visualization specification according to the programming language rules.

[0085] Step S3054: Run the visualization code to obtain the visualization result. The visualization result is the result of visualizing the query result according to the recommended visualization type.

[0086] In the above steps, the final structured query statement is executed to obtain the query results corresponding to the final structured query statement. For example, executing the final structured query statement: SELECT sa les_amount, sa les_month FROM sa les_data WHERE year=2020,product=elect ORDER BY sa les_month, will obtain the sales data of electronic products for each month in 2020.

[0087] After obtaining the query results, a visualization specification corresponding to the query results is generated based on the recommended visualization type, and visualization code is also generated. Running the visualization code will produce the visualization results corresponding to the query results. The visualization specification defines the basic attributes of the graphic elements of the query results according to the recommended visualization type. After generating the initial visualization results, users can further adjust them through the interactive interface based on the actual effect, such as adjusting the axis range, changing the chart color scheme, and optimizing the label text, to ensure that the final visualization is both aesthetically pleasing and informative.

[0088] Based on user profiles, the system recommends visualization types and provides users with personalized charts. It automatically generates visualization specifications and code based on the visualization type, eliminating the need for users to have programming or data analysis skills. This reduces the operational cost of data visualization analysis and improves user satisfaction with the product.

[0089] In some embodiments, interactive features can also be added, such as displaying detailed information by hovering the mouse, changing the chart type or displaying different datasets by dropping down menus, which enriches the types of operations and can effectively improve user satisfaction with the product.

[0090] In some embodiments, after visualizing the query results corresponding to the final structured query statement based on the user profile, the method further includes: receiving new display configuration parameters; recording the new display configuration parameters in the user profile to obtain an updated user profile; and visualizing the query results corresponding to the final structured query statement based on the new display configuration parameters to obtain new visualization results.

[0091] In some embodiments, when a new display configuration parameter is received input within a first interactive interface, the first interactive interface is a chat interactive interface. The method further includes: receiving new natural language text input within the chat interactive interface, the new natural language text containing at least one keyword for adjusting the visualization type; in response to the new natural language text, converting the keyword into new display configuration parameters; updating the initial display configuration parameters in the visualization specification using the new display configuration parameters to obtain a new visualization specification; generating new visualization code corresponding to the new visualization specification according to programming language rules; and running the new visualization code to obtain a new visualization result. Figure 4 As shown, in the interactive interface, A represents the natural language query text entered by the user, and B represents the response content from the AI ​​side.

[0092] For example, if a user inputs the new natural language text "Change the chart type to a line chart", the server parses the new text and obtains the desired change: "Chart type" is changed to "line chart". This "line chart" is then converted into new display configuration parameters related to the visualization type. These new parameters could be axis parameters, such as the first axis parameter being the month of the line chart and the second axis parameter being the sales quantity corresponding to that month. The visualization specification is updated using these new axis parameters, and then new visualization code is generated based on this specification. Finally, the new visualization code is run to obtain a new visualization result, which is then provided as new feedback information within the chat interface.

[0093] In some embodiments, when a new display configuration parameter is received in the second interactive interface, the second interactive interface is a graphical user interface (GUI). The GUI includes an image display area for displaying visualization results and a parameter adjustment area for adjusting the display configuration parameters. The method includes: receiving a selection operation input in the parameter adjustment area for an operation item related to the display configuration parameters; updating the initial display configuration parameters according to the operation item content corresponding to the selection operation in response to the selection operation, obtaining new display configuration parameters; updating the initial display configuration parameters in the visualization specification using the new display configuration parameters, obtaining a new visualization specification; generating new visualization code corresponding to the new visualization specification according to programming language rules; and running the new visualization code to obtain a new visualization result. Figure 5 As shown, in the interactive interface, user A inputs natural language query text, and B is the response content from the artificial intelligence end. The second interactive interface provides the user with a visual result, which user A can adjust through the second interactive interface.

[0094] In some embodiments, after obtaining the new display configuration parameters, the method further includes: recording the new display configuration parameters into user profile data.

[0095] In some embodiments, the parameter adjustment area includes operation items corresponding to the data display range, operation items corresponding to the data display icon type, operation items corresponding to the icon element configuration parameters, and operation items corresponding to the visualization code. The visualization code is program code used to display the query results according to the visualization specifications.

[0096] In some embodiments, the static adjustments to SQL queries based on user profiles analyzed by the system are typically not directly participated in by the user. The system primarily "predicts" and "automatically adjusts" the generated charts and display content. For example, if a user's historical query records frequently use blue bar charts to display trends in sales data, the system will automatically select a bar chart and use blue when generating the chart to match the user's visual preferences.

[0097] When a user queries "2020 sales data," the system can be set to default to displaying a line chart. After retrieving the user's historical query records, the system automatically adjusts subsequent recommended charts to blue bar charts based on the user's preferences.

[0098] In some embodiments, after generating and displaying the visualization results, an interactive adjustment method (i.e., dynamic adjustment) can be provided to further enable users to customize and adjust the charts. Users can actively modify the generated visualization charts through the interactive interface and provide real-time feedback to the system. This is a dynamic adjustment process, where users modify the chart's style, color, data display range, axis labels, etc., according to specific needs. This step is used to enable active intervention in the visualization results; for example, users can select different time intervals by dragging the time axis, or select other chart types (such as switching from a bar chart to a line chart) through the menu.

[0099] After each adjustment to the visualization results, the adjusted display configuration parameters are recorded as user preference feedback in the user profile, and a preference learning algorithm drives subsequent SQL queries and visualization result optimization. For example, if a user repeatedly selects a certain chart type, that type of chart will be prioritized in subsequent recommendations, and the SQL query structure may even be directly optimized to speed up data return. The generated query statements and visualization specifications are adjusted based on the user's latest preferences. For example, if a user consistently adjusts the chart's time range to a specific interval, the system will automatically remember this preference, generate a matching SQL query, and adjust the time range for subsequent charts. For instance, after a user changes the chart type to a bar chart, the system records this preference and prioritizes bar charts over line charts in future queries, and the SQL query statement will automatically adjust to match the chart's requirements (such as modifying aggregation logic, field order, etc.).

[0100] In other embodiments, the system displays the user-requested visualization results and supports exporting or sharing them. The system can display the charts or reports required by the user according to the final generated visualization specifications, ensuring the results meet the user's expectations. Users can also export visualizations in different formats (such as PDF, PNG, etc.). In some embodiments, the system can automatically adjust the format of the displayed results by updating the user profile in real time. For example, if the user prefers to export a PDF report, the system will automatically update the format of the exported report and adjust the data filtering conditions according to the user's preferences.

[0101] In other embodiments, when a change in the data source is detected and an input natural language query text is received, an SQL query statement is generated based on the new data source, and the displayed visualization results are updated. Users can also readjust the query and visualization specifications according to new data sources or business needs. For example, when the data source changes (such as the upload of sales data for the new quarter), the system automatically identifies the data change and updates the visualization charts through SQL queries to ensure that users can view the latest data.

[0102] After generating the visualization results, users can interactively modify them through the interface and update the modified content in the user profile. Then, the newly generated SQL query statement can be optimized based on the user profile. This allows for dynamic adjustment of the visualization, enabling the product to better adapt to changes in user needs and effectively improving the efficiency of visualization processing.

[0103] In summary, the SQL generation-driven visualization method based on large model preference learning proposed in this invention automatically generates accurate SQL query statements by combining the intent recognition and preference learning mechanisms of a large language model, and dynamically adjusts the data visualization specifications according to user profiles, which greatly improves the accuracy of SQL query results, the personalization of visualization results, and the convenience of interactive experience.

[0104] The SQL generation-driven visualization method based on large model preference learning proposed in this invention can be widely applied to various data-intensive fields, especially suitable for data analysis, business intelligence (BI), big data analysis platforms, enterprise data visualization dashboards and other products and projects.

[0105] Please refer to Figure 6 , Figure 6 This is a schematic diagram of the structure of a visualization device 600 driven by SQL generation based on large model preference learning according to an embodiment of the present invention. Figure 6 As shown, the device 600 includes:

[0106] The query text and query record acquisition module 601 is configured to acquire the input natural language query text and the user's historical query records.

[0107] The user profile generation module 602 is configured to generate user profiles based on users' historical query records.

[0108] The text parsing and statement generation module 603 is configured to parse the natural language query text using a pre-trained large language model to obtain the table names of the database tables related to the user's query intent and the field names corresponding to the query object entities in the database tables; based on the user profile, the table names of the database tables, and the field names corresponding to the query object entities, it generates an initial structured query statement, which includes the query object entities in an initial sort and initial customized query parameters.

[0109] The query statement preference optimization module 604 is configured to perform preference optimization processing on the initial structured query statement based on the user's query history and user profile to obtain the final structured query statement. The order of the query object entities in the final structured query statement is obtained by optimizing and adjusting the query object entities in the initial structured query statement according to the user's query history. The preference-customized query parameters in the final structured query statement are obtained by optimizing and adjusting the initial customized query parameters according to the user profile.

[0110] The visualization module 605 is configured to visualize the query results corresponding to the final structured query statement based on the user profile, thereby obtaining the visualization results.

[0111] In some embodiments, the user profile includes preference filtering conditions. The query statement preference optimization module 604 is further configured to adjust the position order and / or aggregation method of the query object entities contained in the initial structured query statement and / or delete redundant query object entities based on the query execution results of the user's query history; and optimize the initial customized parameters contained in the initial structured query statement according to the preference filtering conditions to obtain the final structured query statement.

[0112] In some embodiments, the user profile includes initial display configuration parameters. The query statement preference optimization module 604 is further configured to input the initial display configuration parameters obtained based on the user profile, the user's query history, and the initial structured query statement into a pre-built preference comparison model, and at least adjust the initial customized parameters of the initial structured query statement to obtain the final structured query statement. The initial customized parameters include cross-table join information, nested query information, and / or data aggregation operation information.

[0113] In some embodiments, the user profile includes recommended visualization types. The visualization display module 605 is configured to execute a final structured query statement to obtain query results corresponding to the final structured query statement; generate visualization specifications corresponding to the query results based on the recommended visualization types, wherein the visualization specifications are the result of defining rules for the basic attributes of the graphic elements used to present the query results based on the visualization types; generate visualization code corresponding to the visualization specifications based on programming language rules; and run the visualization code to obtain visualization results, wherein the visualization results are the result of visualizing the query results according to the recommended visualization types.

[0114] In some embodiments, the apparatus further includes: a parameter receiving module configured to receive input new display configuration parameters, the new display configuration parameters being used to adjust the visualization results; a visualization display module 605 configured to visualize the query results corresponding to the final structured query statement based on the new display configuration parameters, thereby obtaining new visualization results; and a user profile updating module configured to update the new display configuration parameters to the user profile, thereby obtaining an updated user profile.

[0115] In some embodiments, when the first interactive interface is a chat interactive interface, the parameter receiving module is configured to receive new natural language text input within the chat interactive interface, the new natural language text containing at least one keyword for adjusting the visualization results; in response to the new natural language text, the keyword is converted into new display configuration parameters.

[0116] In some embodiments, when the second interactive interface is a graphical user interface, the graphical user interface includes an image display area for displaying visualization results and a parameter adjustment area for adjusting display configuration parameters. The parameter receiving module is configured to receive a selection operation input in the parameter adjustment area for an operation item related to the display configuration parameters; in response to the selection operation, the initial display configuration parameters are updated according to the operation item content corresponding to the selection operation to obtain new display configuration parameters.

[0117] The SQL generation-driven visualization device provided by this invention, based on large-model preference learning, optimizes the initial structured query statement by leveraging user query history and user profiles. This improves the accuracy of query results, reduces manual modification by users, and increases the processing efficiency of structured queries. Furthermore, the visualization results are dynamically adjusted based on the visualization type recommended by the user profile, enhancing personalized recommendations and optimization.

[0118] Furthermore, through interactive functions, user modification information can be obtained to update user profiles and influence the optimization results of SQL query statements driven by preference learning algorithms. This can effectively improve the accuracy of generated SQL query statements and continuously meet the personalized needs of visualization results.

[0119] Figure 7 A schematic block diagram of an electronic device 700 according to an embodiment of the present invention is shown. Figure 7 As shown, the electronic device 700 may include a processor 701 and a memory 702. The memory 702 stores computer program instructions for executing a visualization method driven by SQL generation based on large model preference learning. When the computer program instructions are executed by the processor 701, the electronic device 700 executes the method according to the preceding description. Figures 1 to 3 The method described herein. For example, in some embodiments, the electronic device 700 is used to implement a visualization method driven by SQL generation based on large model preference learning, as can be seen in the foregoing embodiments, which will not be repeated here.

[0120] An embodiment of the present invention provides an electronic device, the device comprising: a processor; and a memory storing computer program instructions implemented by a computer for executing a visualization method driven by SQL generation based on large model preference learning, wherein when the computer program instructions are executed by the processor, the electronic device performs, as follows: Figures 1 to 3 The method described.

[0121] This invention provides a computer-readable storage medium comprising computer-implemented computer program instructions for executing a visualization method driven by SQL generation based on large model preference learning. When executed by a processor, the computer program instructions cause the implementation of... Figures 1 to 3 The method described.

[0122] Those skilled in the art will recognize that embodiments of the present invention can be implemented as a system, method, or computer program product. Therefore, the present invention can be specifically implemented as entirely hardware, entirely software (including firmware, resident software, microcode, etc.), or a combination of hardware and software, generally referred to herein as a "circuit," "module," "unit," or "system." Furthermore, in some embodiments, the present invention can also be implemented as a computer program product contained in one or more computer-readable media, which includes computer-readable program code.

[0123] Any combination of one or more computer-readable media may be used. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example,, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (not exhaustive) of a computer-readable storage medium may include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus, or device.

[0124] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0125] It should be understood that each block of a flowchart and / or block diagram, as well as combinations of blocks in a flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine that, when executed by a computer or other programmable data processing device, creates means for implementing the functions / operations specified in the blocks of the flowchart and / or block diagram.

[0126] While numerous embodiments of the invention have been shown and described herein, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Many modifications, alterations, and alternatives will occur to those skilled in the art without departing from the spirit and essence of the invention. It should be understood that various alternatives to the embodiments of the invention described herein may be employed in the practice of the invention. The appended claims are intended to define the scope of protection of the invention and therefore cover equivalents or alternatives within the scope of these claims.

Claims

1. A visualization method driven by SQL generation based on large model preference learning, characterized in that, The method includes: Obtain the input natural language query text and the user's query history; Generate a user profile based on the user's query history; The natural language query text is parsed using a pre-trained large language model to obtain the table name of the database table related to the user's query intent and the field name corresponding to the query object entity in the database table; based on the user profile, the table name of the database table and the field name corresponding to the query object entity, an initial structured query statement is generated, which includes the query object entities in an initial sort and the initial customized query parameters. Based on the user query history and the user profile, the initial structured query statement is optimized to obtain the final structured query statement. The order of the query object entities in the final structured query statement is obtained by optimizing and adjusting the query object entities in the initial structured query statement according to the user query history. The preference-customized query parameters in the final structured query statement are obtained by optimizing and adjusting the initial customized query parameters according to the user profile. Based on the user profile, the query results corresponding to the final structured query statement are visualized to obtain the visualization results.

2. The method according to claim 1, characterized in that, The user profile includes preference filtering conditions, which represent preferences for cross-table join information, nested query information, and / or data aggregation operation information. Based on the user's query history and the user profile, the initial structured query statement undergoes preference optimization processing, including: Based on the query execution results of the user's query history, adjust the position order and / or aggregation method of the query object entities contained in the initial structured query statement and / or delete redundant query object entities; The initial customized parameters contained in the initial structured query statement are optimized according to the preference filtering conditions to obtain the final structured query statement.

3. The method according to claim 1, characterized in that, The user profile includes initial display configuration parameters. Based on the user's query history and the user profile, the initial structured query statement undergoes preference optimization processing, including: The initial display configuration parameters obtained based on the user profile, the user's query history, and the initial structured query statement are input into a pre-built preference comparison model. At least the initial customized parameters of the initial structured query statement are adjusted to obtain the final structured query statement. The initial customized parameters include cross-table join information, nested query information, and / or data aggregation operation information.

4. The method according to claim 1, characterized in that, The user profile includes recommended visualization types. Based on the user profile, the query results corresponding to the final structured query statement are visualized, including: Execute the final structured query statement to obtain the query results corresponding to the final structured query statement; A visualization specification corresponding to the query results is generated based on the recommended visualization type. The visualization specification is the result of defining rules for the basic attributes of the graphic elements used to present the query results based on the visualization type. Generate visualization code corresponding to the visualization specification according to the programming language rules; Running the visualization code yields a visualization result, which is a visualization presentation of the query result based on the recommended visualization type.

5. The method according to claim 3, characterized in that, After visualizing the query results corresponding to the final structured query statement based on the user profile, the method further includes: Receive new display configuration parameters as input, which are used to adjust the visualization results; Based on the new display configuration parameters, the query results corresponding to the final structured query statement will be visualized to obtain new visualization results; Update the new display configuration parameters to the user profile to obtain the updated user profile.

6. The method according to claim 5, characterized in that, When the first interactive interface is a chat interactive interface, new display configuration parameters are received within the first interactive interface, including: The system receives new natural language text input within the chat interface, the new natural language text containing at least one keyword for adjusting the visualization results; In response to the new natural language text, the keywords are converted into the new display configuration parameters.

7. The method according to claim 5, characterized in that, When the second interactive interface is a graphical user interface, the graphical user interface includes an image display area for displaying visualization results and a parameter adjustment area for adjusting display configuration parameters. The second interactive interface receives new display configuration parameters input by the user, including: Receive selection operations input within the parameter adjustment area for operation items related to the displayed configuration parameters; In response to the selection operation, the initial display configuration parameters are updated according to the operation item content corresponding to the selection operation to obtain new display configuration parameters.

Citation Information

Patent Citations

  • Static data query method and device based on distributed architecture

    CN111858656A

  • Self-adaptive SQL (Structured Query Language) differential privacy noise adding method

    CN119201981A