Visual chart generation method, device and equipment and readable storage medium

Through a large language model, analyzing table data and generating chart codes is solved, and the problem of inefficient visualization of table data is achieved is achieved.

CN118762101APending Publication Date: 2024-10-11INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202410138262.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-31
Publication Date
2024-10-11

AI Technical Summary

Technical Problem

In the prior art, the visualization process of tabular data requires a lot of manual operations, resulting in inefficiency and inability to meet real-time requirements.

Method used

Data analysis and graph generation are used to use large language models to analyze table data, analyze column features and correlation features, generate drawing intentions, and generate graph drawing codes using prompt words and executable code templates to achieve automated processing.

Benefits of technology

It improves the efficiency of table data visualization, can meet the needs of large batches and real-time visualization, reduces manual operations, and ensures the executability of chart drawing code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118762101A_ABST
    Figure CN118762101A_ABST
Patent Text Reader

Abstract

The invention discloses a visual chart generation method, device and equipment and a readable storage medium, and the method comprises the steps: obtaining table data, and carrying out the data analysis of the table data through a large language model, and obtaining a plurality of drawing intentions; outputting a plurality of drawing intentions on the visual interface, and determining a target drawing intention according to the operation information of the visual interface; generating a cue word matched with the target drawing intention by utilizing the cue word model; the cue word and the executable code model corresponding to the cue word are input into the large language model for code generation processing, and a chart drawing code is obtained; and executing the chart drawing code to draw a visual chart corresponding to the table data. The method has the technical effects that by means of the large language model, links such as data analysis and chart generation operation processing are mechanically and automatically processed, the table data visualization efficiency can be effectively improved, the requirements of large-batch visualization table data can be further met, and the real-time table data visualization requirement can also be met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method, device, equipment and readable storage medium for generating a visualization chart. Background Art

[0002] In the past data visualization process, it is usually necessary to manually review the table data in csv (plain text format to store table data) or excel (spreadsheet software). Then, some analysis (profiling) of the data is performed. Based on the results of the analysis, it is decided which data to make what kind of data visualization (data visualization). Such visualization processes are almost all pure manual work.

[0003] When a large amount of tabular data needs to be visualized, the data visualization work is done manually in the traditional process, which will take a long time and consume a lot of manpower. In addition, the visualization operation of manual work cannot meet the needs of real-time drawing.

[0004] In summary, how to effectively solve problems such as visualization of tabular data is a technical problem that technical personnel in this field urgently need to solve. Summary of the invention

[0005] The purpose of this application is to provide a method, device, equipment and readable storage medium for generating a visual chart. With the help of a large language model, data analysis, chart generation operation processing and other links are mechanically automated, which can effectively improve the efficiency of tabular data visualization, further meet the needs of large-scale visualization of tabular data, and also meet the needs of real-time tabular data visualization.

[0006] In order to solve the above technical problems, this application provides the following technical solutions:

[0007] A method for generating a visual chart, comprising:

[0008] Acquire tabular data, and use a large language model to perform data analysis on the tabular data to obtain a number of drawing intentions;

[0009] Outputting a plurality of the drawing intentions on a visualization interface, and determining a target drawing intention according to operation information of the visualization interface;

[0010] Using the prompt word template, generating prompt words matching the target drawing intention;

[0011] Inputting the prompt word and the executable code template corresponding to the prompt word into the large language model for code generation processing to obtain a chart drawing code;

[0012] The chart drawing code is executed to draw a visual chart corresponding to the table data.

[0013] Preferably, the table data is analyzed using a large language model to obtain several drawing intentions, including:

[0014] Analyzing the field features of each field in the table data and the field association features between the fields using a large language model;

[0015] Using the column feature, obtaining the drawing intent of the bar chart and / or the drawing intent of the line chart;

[0016] The column association feature is used to obtain the drawing intent of the scatter plot.

[0017] Preferably, using the prompt word template to generate prompt words matching the target drawing intent includes:

[0018] Determining a target prompt word template corresponding to the image type of the target drawing intent from prompt word templates having a matching relationship with the image type;

[0019] In combination with the target drawing intent, replaceable parameters in the target prompt word template are modified to obtain the prompt word.

[0020] Preferably, if the target drawing intent is to represent a plurality of columns with a scatter plot, then modifying the replaceable parameters in the target prompt word template in combination with the target drawing intent to obtain the prompt word includes:

[0021] Outputting a target prompt word template for drawing a scatter plot on a visual interface; wherein the target prompt word template for drawing a scatter plot includes: drawing a scatter plot according to the first column and the second column of the data set, and generating a code that can display the scatter plot by referring to the provided code example;

[0022] Identify a first replaceable parameter of a target prompt word template for drawing a scatter plot, obtain a replaceable parameter, and replace the first replaceable parameter based on the target drawing intention to obtain a scatter plot prompt word;

[0023] Wherein, the first replaceable parameter is the data set, the first column and the second column in the target prompt word template for drawing the scatter plot;

[0024] If the target drawing intent is to represent a plurality of columns with a line graph, then modifying the replaceable parameters in the target prompt word template in combination with the target drawing intent to obtain the prompt word includes:

[0025] Outputting a target prompt word template for drawing a line graph on the visual interface; wherein the target prompt word template for drawing a line graph includes: drawing a line graph according to the third column and the fourth column of the data set, and generating a code that can display the line graph by referring to the provided code example;

[0026] Identifying a second replaceable parameter in the target prompt word template for drawing a line graph, and replacing the second replaceable parameter based on the target drawing intention to obtain a line graph prompt word;

[0027] The second replaceable parameter includes a data set, a third column and a fourth column in the target prompt word template for drawing a line graph.

[0028] Preferably, the prompt word and the executable code template are input into the large language model for code generation processing to obtain the chart drawing code, including:

[0029] Using the large language model, extracting drawing parameters from the prompt words;

[0030] The corresponding replaceable code parameters in the executable code template are replaced with the drawing parameters to obtain the chart drawing code.

[0031] Preferably, it also includes:

[0032] Storing usage records of prompt word templates;

[0033] Accordingly, the use of the prompt word template to generate a prompt word matching the target drawing intention includes:

[0034] combining the target drawing intention with the usage records corresponding to each of the prompt word templates, and calculating the recommendation score corresponding to each of the prompt word templates;

[0035] Outputting the prompt word template matching the image type in the basic recommendation area of ​​the visualization interface;

[0036] outputting the prompt word template outside the basic recommendation area based on the recommendation score;

[0037] Determining a target prompt word template based on the operation information of the visualization interface;

[0038] The target prompt word template is used to generate prompt words matching the target drawing intention.

[0039] Preferably, the usage record includes the column selected for drawing the visual chart and the column characteristics of the column, and the number of times the prompt word template is used;

[0040] Accordingly, combining the target drawing intent with the usage records corresponding to each of the prompt word templates, and calculating the recommendation score corresponding to each of the prompt word templates, includes:

[0041] Comparing the target drawing intent with the usage record to obtain the number of fields of the same type;

[0042] The product of the number of columns of the same type and the number of times used is calculated, and the product result is determined as the recommendation score.

[0043] A visual chart generating device, comprising:

[0044] An intention analysis module is used to obtain table data and perform data analysis on the table data using a large language model to obtain a number of drawing intentions;

[0045] A target drawing intent selection module is used to output a plurality of the drawing intents on a visualization interface and determine a target drawing intent according to operation information of the visualization interface;

[0046] A prompt word generation module, used to generate prompt words matching the target drawing intention by using the prompt word template;

[0047] A drawing code generation module, used for inputting the prompt word and the executable code template corresponding to the prompt word into the large language model for code generation processing to obtain a chart drawing code;

[0048] The visual chart generating module is used to execute the chart drawing code to draw a visual chart corresponding to the table data.

[0049] An electronic device, comprising:

[0050] Memory for storing computer programs;

[0051] A processor is used to implement the steps of the above-mentioned visual chart generation method when executing the computer program.

[0052] A readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned visualization chart generation method are implemented.

[0053] Apply the method provided in the embodiment of the present application to obtain tabular data, and use a large language model to perform data analysis on the tabular data to obtain a number of drawing intentions; output a number of drawing intentions on a visualization interface, and determine a target drawing intention based on the operation information of the visualization interface; use a prompt word template to generate a prompt word that matches the target drawing intention; input the prompt word and the executable code template corresponding to the prompt word into the large language model for code generation processing to obtain a chart drawing code; execute the chart drawing code to draw a visual chart corresponding to the tabular data.

[0054] Technical effect: Since the large language model has data analysis capabilities, after obtaining the table data, the table data can be first analyzed based on the large language model to obtain several drawing intentions. The drawing intention is output on the visual interface for the user to select the target drawing intention. Then, in combination with the prompt word template, a prompt word matching the target drawing intention is generated. In order to avoid the large language model from performing boundless divergent processing, the prompt word and the executable code template matching the prompt word are input into the large language model for code generation processing, and a chart drawing code constrained within the scope of the executable code template can be obtained, thereby ensuring the executability of the chart drawing code. By executing the chart drawing code, a visual chart corresponding to the table data can be drawn. That is, with the help of the large language model, when visualizing the table data, the data analysis and chart generation operation processing that were originally manually implemented can be automated, which can effectively improve the efficiency of table data visualization, further meet the needs of large-scale visualization of table data, and also meet the needs of real-time table data visualization.

[0055] Correspondingly, the embodiments of the present application also provide a visualization chart generation device, equipment and readable storage medium corresponding to the above-mentioned visualization chart generation method, which have the above-mentioned technical effects and are not repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0057] Figure 1 This is a flowchart of a method for generating a visual chart in an embodiment of the present application;

[0058] Figure 2 A line graph corresponding to Table 1 in the embodiment of the present application;

[0059] Figure 3A scatter plot corresponding to Table 1 in the embodiment of the present application;

[0060] Figure 4 A pie chart corresponding to Table 1 in the embodiments of the present application;

[0061] Figure 5 Another pie chart corresponding to Table 1 in the embodiments of the present application;

[0062] Figure 6 A bar graph corresponding to Table 1 in the embodiment of the present application;

[0063] Figure 7 This is a schematic diagram of the structure of a visual chart generating device in an embodiment of the present application;

[0064] Figure 8 This is a schematic diagram of the structure of an electronic device in an embodiment of the present application;

[0065] Fig. 9 This is a schematic diagram of a specific structure of an electronic device in an embodiment of the present application;

[0066] Fig.10 This is a specific implementation flow chart of a method for generating a visual chart in an embodiment of the present application. DETAILED DESCRIPTION

[0067] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0068] Please refer to Figure 1 , Figure 1 This is a flowchart of a method for generating a visual chart in an embodiment of the present application, and the method includes the following steps:

[0069] S101, obtaining table data, and using a large language model to perform data analysis on the table data to obtain a number of drawing intentions.

[0070] The table data can be a table data of csv or excel. In this embodiment, no specific limitation is made on what information the table data stores, the number and type of internal columns, and the value itself.

[0071] For example, the table data could be Figure 1 Table shown.

[0072] Table 1, Table 1 is a specific table

[0073] Column A Column B Column C Column D Column E Field F A 2023-6 1 A class 70 50 B 2023-7 2 A class 20 60 C 2023-8 3 B class 30 70 D 2023-9 4 A class 80 80 E 2023-10 5 B class 15 90

[0074] After obtaining the table data, the Large Language Model (LLM) can be used to analyze the data to obtain several drawing intents.

[0075] The drawing intent may be expressed as drawing a certain type of graph for one or more columns. For example, for Table 1, the drawing intent may be drawing a bar graph for column E.

[0076] In a specific implementation of the present application, two table data are merged and visualized, and the specific implementation process includes:

[0077] Get first table data and second table data;

[0078] Determine whether the columns of the first table data and the second table data are consistent;

[0079] If yes, then the data content of the second table data is added to the first data table in order according to the columns to obtain a merged table;

[0080] If not, a new column corresponding to the second table data is created in the first table data, and the content of the second table data is inserted into the newly created column in sequence to obtain a merged table;

[0081] After obtaining the merged table, the large language model is used to analyze the data of the merged table to obtain several drawing intentions;

[0082] After obtaining a number of drawing intentions, execute step S102.

[0083] That is, this embodiment can merge multiple tables and merge them according to the specific conditions of the tables, so that the merged visualization of two tables can be realized based on the merged table. When three or more tables need to be merged, the above steps are repeated until they are merged into one table, and then the large language model is used to analyze the data of the merged table to obtain several drawing intentions. In this way, the specific needs of merging and visualizing tables can be met.

[0084] In a specific implementation of the present application, a large language model is used to analyze the table data to obtain several drawing intentions, including:

[0085] Using a large language model, analyze the field features of each field in the table data and the field association features between the fields;

[0086] Using the column features, obtain the drawing intent of the bar chart and / or the drawing intent of the line chart;

[0087] Utilize the column association feature to obtain the drawing intent of the scatter plot.

[0088] For ease of description, the above steps are combined for illustration below.

[0089] That is, the big language model analyzes the table data (profiling), and the field features of each data field can obtain the field correlation features between each data field. Among them, the field feature can be specifically the nature of the field, such as classification, time date, and number. The field correlation feature is the correlation between the fields, for example, several fields have a time series relationship.

[0090] For example: After analyzing Table 1, we can find that field A is a general string, field B is a date type data. Fields C, E, and F are numeric type data. Field D is classified data, because its data only has two types: Aclass and Bclass. After analyzing the data fields, we can make drawing intent a and drawing intent b according to the following rules:

[0091] Rule 1: Numeric columns can be compared using a bar chart.

[0092] Rule 2: Time and date type fields can use line charts to represent the changes of other fields over time.

[0093] That is, drawing intention a: columns C, E, and F are represented by bar graphs respectively;

[0094] Drawing intention b: Column B uses a line graph to represent the changes in other columns over time.

[0095] Analyze the correlation between each numeric field. Spearman's rank correlation coefficient can be used to analyze numeric fields. The result of the analysis is a correlation coefficient, expressed as +1 to -1. +1 indicates the maximum positive correlation, and -1 indicates the minimum negative correlation. The absolute value of the correlation coefficient is sorted, and a plotting scheme c is generated according to the following rules.

[0096] Rule 3: The correlation coefficients between columns C and E, columns C and F, and columns E and F are ce, cf, ef.

[0097] That is, the drawing intention c is to represent the columns C, E, and F using scatter plots, respectively.

[0098] After the above data analysis based on data type and data relevance, drawing intention a, drawing intention b, and drawing intention c are generated.

[0099] In other words, the large language model can find out the possibilities of various conventional drawings corresponding to the tabular data, and thus obtain several drawing intentions.

[0100] S102: Outputting a plurality of drawing intentions on a visualization interface, and determining a target drawing intention according to operation information of the visualization interface.

[0101] In practical applications, for a table of data, it is often necessary to visualize part of the information rather than all of it, and the types of charts for visualization are often only one or a small number of them. In order to avoid drawing a large number of useless / redundant charts, in this embodiment, after obtaining several drawing intents, several drawing intents can be output on the visualization interface for the user to choose.

[0102] Specifically, after the visual interface outputs the drawing intent, the user can select or modify the drawing intent, so that the target drawing intent can be determined based on the operation information.

[0103] For example, after the visualization interface outputs the drawing intent, the user can select the drawing intent of interest according to actual needs. Of course, the user can also adjust the drawing intent of interest, such as modifying the column (such as changing column A to column B), modifying the chart type (such as changing a bar chart to a pie chart), or limiting the drawing range of the column (for example, there are 50 data in the table data, and only the first 20 data under a certain column are selected for drawing).

[0104] S103: Generate prompt words matching the target drawing intention by using the prompt word template.

[0105] When generating a chart, it can be based on the executable code. In this embodiment, a large language model can be used to generate the executable code. In order to enable the large language model to generate the executable code, it is necessary to first generate a prompt word (a prompt word sentence used to instruct the LLM to make an answer) for generating the code.

[0106] In this embodiment, prompt words matching the target drawing intent may be generated based on the prompt word template.

[0107] Specifically, in this embodiment, different prompt word templates can be pre-set according to different drawing types. When prompt words need to be generated, it is only necessary to find the prompt word template of the drawing type corresponding to the target drawing intent, and then generate prompt words matching the target drawing intent based on the prompt word template.

[0108] In a specific implementation, using the prompt word template to generate prompt words matching the target drawing intent includes:

[0109] Determine a target prompt word template corresponding to the target drawing intention from the prompt word templates that have a matching relationship with the image type;

[0110] According to the target drawing intention, the replaceable parameters in the target prompt word template are modified to obtain the prompt word.

[0111] For ease of description, the above steps are combined for explanation below.

[0112] That is to say, the prompt word templates corresponding to different image types can be pre-set, and the corresponding matching relationship between the image type and the prompt word range can be set. After the target drawing intent is determined, the target prompt word template matching the target drawing intent can be found from multiple prompt word templates based on the image type in the target drawing intent.

[0113] For example, the prompt word templates may include prompt word templates corresponding to different graph types such as line graph prompt word templates, bar graph prompt word templates, scatter graph prompt word templates, and pie chart prompt word templates. If the graph type in the target drawing intent is a line graph, the line graph prompt word template may be determined as the target prompt word template.

[0114] After the target prompt word template is clarified, the replaceable parameters in the target prompt word template are replaced in combination with the target drawing intention to obtain the prompt word.

[0115] For example, replaceable parameters in the target prompt word template can be marked with symbols such as {} or not. When replacing, the fields in the template can be rewritten based on the fields in the target prompt word template, and the data set is also changed to table data. Through modification, the target prompt word template can match the target drawing intent, thereby obtaining the prompt word of the target drawing intent.

[0116] In a specific implementation, in order to improve the success rate of code generation (code generation) of drawing scatter plot codes, clear prompt words can be added. Prevent the large language model from producing similar hallucination answers. Hallucination answers, that is, the large language model does not use the information provided by the user, but imagines some non-existent answers. Because the answer the user wants is an executable code. Therefore, an executable code can be provided for reference. The following is a description of how to obtain prompt words in combination with the drawing intentions of different graph types:

[0117] For a scatter plot:

[0118] If the target drawing intent is to represent several columns with a scatter plot, the replaceable parameters in the target prompt word template are modified in combination with the target drawing intent to obtain prompt words, including:

[0119] Outputting a target prompt word template for drawing a scatter plot on a visual interface; wherein the target prompt word template for drawing a scatter plot includes: drawing a scatter plot according to the first column and the second column of the data set, and generating a code that can display the scatter plot by referring to the provided code example;

[0120] Identify a first replaceable parameter of a target prompt word template for drawing a scatter plot, obtain a replaceable parameter, and replace the first replaceable parameter based on the target drawing intent to obtain a scatter plot prompt word;

[0121] The first replaceable parameter is the data set, the first column and the second column in the target prompt word template for drawing the scatter plot.

[0122] In practical applications, the target prompt word template for drawing a scatter plot can be specifically:

[0123] visualization_prompt=f"

[0124] You are a programmer who is good at Python visualization code. Draw a scatter plot based on the data set's columns C and F. Refer to the code example provided to generate code that can display the scatter plot.

[0125] The {} in the above prompt words are replaceable parameters. When drawing different charts, by identifying the replaceable parameters and replacing the parameters, the effect of drawing different chart prompt words can be produced. More complex parameters can also be added to guide the large language model to generate more complex charts. Among them, the identification of replaceable parameters can be specifically based on the parameter marking, such as {}, or using a trained model to identify and replace. Thus, the scatter plot prompt words are obtained.

[0126] For a line chart:

[0127] If the target drawing intent is to represent several columns with a line graph, the replaceable parameters in the target prompt word template are modified in combination with the target drawing intent to obtain prompt words, including:

[0128] Outputting a target prompt word template for drawing a line graph in a visual interface; wherein the target prompt word template for drawing a line graph includes: drawing a line graph according to the third column and the fourth column of the data set, and referring to the provided code example to generate a code that can display the line graph;

[0129] Identify a second replaceable parameter in the target prompt word template for drawing a line graph, and replace the second replaceable parameter based on the target drawing intent to obtain a line graph prompt word;

[0130] The second replaceable parameter includes the data set, the third column and the fourth column in the target prompt word template for drawing the line graph.

[0131] For example: In actual application, the target prompt word template can be specifically as follows: visualization_prompt2 = f"You are a programming assistant who is good at Python visualization code. Draw a {line chart} based on {field B} and {field E} of {data set}. And refer to the provided {code example} to generate the code that can display the {line chart}." Replace the data set, field B and field E with the table data and the field in the target drawing intent respectively. You can get the line chart prompt word.

[0132] The process of obtaining prompt words for other types of images can be parameterized similarly and will not be listed here one by one.

[0133] It should be noted that the first, second, third and fourth do not have any limiting meanings such as priority, order, etc. They are mainly used to distinguish different columns and parameters.

[0134] S104: Input the prompt word and the executable code template corresponding to the prompt word into the large language model for code generation processing to obtain a chart drawing code.

[0135] In order to avoid the large language model from performing boundless divergent processing, for example, the large language model gives an unexecutable code, or the code does not achieve the desired effect after execution. Therefore, in this embodiment, an executable code template can be given so that the large language model can output an executable chart drawing code whose execution effect meets actual requirements.

[0136] In this embodiment, different executable code templates may be set for different chart types, and the executable code template of the same chart type as the prompt word is the executable code template corresponding to the prompt word.

[0137] That is, when the prompt word is input to the large language model, the executable code template corresponding to the prompt word is also output to it. The large language model performs code generation processing to obtain the chart drawing code.

[0138] In a specific implementation, the prompt word and the executable code template are input into the large language model for code generation processing to obtain the chart drawing code, including:

[0139] Using a large language model, drawing parameters are extracted from the prompt words;

[0140] The corresponding replaceable code parameters in the executable code template are replaced with the drawing parameters to obtain the chart drawing code.

[0141] For ease of description, the above steps are combined for explanation below.

[0142] The large language model can extract drawing parameters from the prompt words, and the drawing parameters can specifically include information such as fields, processed data objects, etc. Then, the corresponding replaceable code parameters in the executable code template are replaced with the drawing parameters, thereby obtaining the chart drawing code.

[0143] Example: A prompt for drawing intent for drawing a scatter plot is: visualization_prompt = f "You are a programming assistant who is good at Python visualization code. Draw a scatter plot based on {field C} and {field F} of the {data set}. And refer to the provided {code example} to generate code that can display the {scatter plot}."

[0144] The {} in the above prompts are replaceable parameters. When you want to draw different charts, you can replace different parameters to produce different chart prompts. You can also add more complex parameters to guide the large language model to generate more complex charts.

[0145] The executable code sample for drawing the scatter plot corresponding to the prompt word is as follows:

[0146]

[0147] Among them, code_template introduces the drawing package (matplotlib) and the data processing package (pandas). Among them, the data is raw_data in the pandas object format. The scatter plot uses {col_C} and {col_F} to obtain the data of columns C and F in the data set (raw_data). And specify the scatter plot drawing method scatter to draw the chart. After the drawing method scatter_plot() loads the raw_data of the data set, it will draw a scatter plot of columns C and F in the chart. Because the previous visualization_prompt has specified that a scatter plot should be drawn, the program example template of the scatter plot is selected. Let the big language model use its reasoning ability. Judge for yourself that as long as col_C and col_F are replaced with the correct column names in raw_data, the scatter plot can be correctly drawn. As for other detailed parameters of the chart, such as the chart title, the length and width of the chart, the size and color of the scatter plot points, etc., they can be handled according to this method.

[0148] The following are examples of executable code templates for other graph types:

[0149] The code example for drawing a line chart is as follows:

[0150] import matplotlib.pyplot as plt;

[0151] columnA=['A','B','C','D','E']# horizontal coordinate of the point (column A);

[0152] columnB=['2023-6','2023-7','2023-8','2023-9','2023-10'];

[0153] columnC=[1,2,3,4,5]#(column C);

[0154] columnD=['A','A','B','A','B']#(column D);

[0155] columnE=[70,20,30,80,15]#The vertical coordinate of line 1 (column E);

[0156] columnF = [50,60,70,80,90] # The vertical coordinate of line 2 (column F); def line_plot (x, y1, y2):

[0157] #Draw a line chart based on the x-axis;

[0158] plt.plot(x,y1,'s-',color='r',label="ColumnE")#s-: square;

[0159] plt.plot(x,y2,'o-',color='g',label="ColumnF")#o-:circle;

[0160] plt.xlabel("X name")# horizontal axis name;

[0161] plt.ylabel("Y name")#vertical axis name;

[0162] plt.show();

[0163] line_plot(columnA,columnE,columnF).

[0164] Code example for drawing a scatter plot:

[0165] def scatter_plot():

[0166] plt.title('plot scatter');

[0167] plt.scatter(columnC,columnB,c='b',marker='*');

[0168] plt.scatter(columnE,columnB,c='g',marker='D');

[0169] plt.scatter(columnF,columnB,c='r',marker='X');

[0170] plt.show();

[0171] scatter_plot();

[0172] Code example for drawing a pie chart:

[0173] def pie_plot(rawdata,labels):

[0174] plt.title('plot pie');

[0175] plt.pie(rawdata,labels=labels,autopct='%1.2f%%');

[0176] plt.show();

[0177] pie_plot(columnE,columnB);

[0178] pie_plot(columnF,columnA);

[0179] Code example for drawing a bar graph:

[0180]

[0181]

[0182] After the chart drawing code is generated, the operation of step S105 may be performed.

[0183] S105: Execute the chart drawing code to draw a visual chart corresponding to the table data.

[0184] Execute the chart drawing code to draw a visual chart corresponding to the table data. For example, taking Table 1 above as an example, the visual chart drawn can be specifically referred to Figures 2 to 6 It should be noted that Figures 2 to 6These are just a few examples of various charts that can be drawn based on Table 1. The purpose is to show that different types of charts can be visualized based on Table 1. In practical applications, it may be necessary to draw only one of them, or other forms of charts, such as color changes, background color adjustments, etc. The specific form of the chart itself that can be visualized in the embodiment of the present application is not limited to this. The changes in the executable code examples and the adjustment of the parameters can also generate other more complex or more detailed charts, which are not listed here one by one.

[0185] Apply the method provided in the embodiment of the present application to obtain tabular data, and use a large language model to perform data analysis on the tabular data to obtain a number of drawing intentions; output a number of drawing intentions on a visualization interface, and determine a target drawing intention based on the operation information of the visualization interface; use a prompt word template to generate a prompt word that matches the target drawing intention; input the prompt word and the executable code template corresponding to the prompt word into the large language model for code generation processing to obtain a chart drawing code; execute the chart drawing code to draw a visual chart corresponding to the tabular data.

[0186] Technical effect: Since the large language model has data analysis capabilities, after obtaining the table data, the table data can be first analyzed based on the large language model to obtain several drawing intentions. The drawing intention is output on the visual interface for the user to select the target drawing intention. Then, in combination with the prompt word template, a prompt word matching the target drawing intention is generated. In order to avoid the large language model from performing boundless divergent processing, the prompt word and the executable code template matching the prompt word are input into the large language model for code generation processing, and a chart drawing code constrained within the scope of the executable code template can be obtained, thereby ensuring the executability of the chart drawing code. By executing the chart drawing code, a visual chart corresponding to the table data can be drawn. That is, with the help of the large language model, when visualizing the table data, the data analysis and chart generation operation processing that were originally manually implemented can be automated, which can effectively improve the efficiency of table data visualization, further meet the needs of large-scale visualization of table data, and also meet the needs of real-time table data visualization.

[0187] It should be noted that, based on the above embodiments, the embodiments of the present application also provide corresponding improved solutions. In the preferred / improved embodiments, the same steps or corresponding steps as those in the above embodiments can be referenced to each other, and the corresponding beneficial effects can also be referenced to each other, which will not be described one by one in the preferred / improved embodiments of this article.

[0188] In a specific implementation, a prompt word template can also be recommended according to the usage situation, and the specific implementation process includes:

[0189] Storing usage records of prompt word templates;

[0190] Accordingly, using the prompt word template, generate prompt words that match the target drawing intent, including:

[0191] Combine the target drawing intention with the usage records of each prompt word template, and calculate the recommendation score corresponding to each prompt word template;

[0192] In the basic recommendation area of ​​the visualization interface, output prompt word templates that match the image type;

[0193] Outputting prompt word templates outside the basic recommendation area based on the recommendation score;

[0194] Determine the target prompt word template based on the operation information of the visual interface;

[0195] Use the target prompt word template to generate prompt words that match the target drawing intention.

[0196] The usage record includes the columns and column features of the columns selected for drawing the visualization chart, and the number of times the prompt word template is used;

[0197] Accordingly, the target drawing intent is combined with the usage records corresponding to each prompt word template to calculate the recommendation score corresponding to each prompt word template, including:

[0198] Compare the target drawing intent with the usage records to obtain the number of columns of the same type;

[0199] The product of the number of columns of the same type and the number of times used is calculated, and the product result is determined as the recommendation score.

[0200] For example, the visualization prompt word visualization_prompt2 will generate a visualization chart for the data type of column B and column E. It can be stored in the database in the following format:

[0201] Visual_mapping2 = {

[0202] Col_1:time;

[0203] Col_2:number;

[0204] Chart:line;

[0205] Count:20;

[0206] Prompt: "visualization_prompt2" # records visualization prompt words. Among them, Col_1 and Col_2 record the data types of columns B and E respectively. Chart records the type of chart that the user wants to draw, and Count indicates how many times the prompt word of this type has been used in the database.

[0207] In actual application, the first time a user generates the visualization prompt word, the Count is 4 points, each click adds 1 point, and using the prompt word to generate a visualization chart adds 2 points.

[0208] In this way, in addition to providing drawing prompt words according to basic rules, the system can also extract prompt words related to the data set from the database and recommend them to the user. The recommended rules are as follows:

[0209] 1. If there is a field type that is the same as the data set field, 1 point will be added, that is, the number of matching field types.

[0210] 2. Count is the magnification factor of the recommended number, recommended points = (number of column types that match) * (Count / 4).

[0211] So according to the above Visual_mapping2 example, it matches the type of two columns. So it can get 2 points (1+1).

[0212] The specific recommendation score = (2) * (20 / 4) = 10 points, * indicates a product operation. Considering that more than one visual prompt word meets the conditions, the recommendation score can be used to rank each prompt word. The higher the score, the more prominent the prompt word will be in the visual interface, such as the UI (User Interface), such as the center of the screen. The higher the score the prompt word can get, the more popular or more useful it is than the prompt word of the system's preset rules. This also allows the system to generate more excellent visual prompt words with the participation of users.

[0213] In a specific implementation, additional prompt words provided by users may be collected to enrich the prompt word library. The specific implementation process includes:

[0214] Step 1: After the prompt word is output on the visual interface, the prompt word is modified in response to the user operation to obtain a new prompt word;

[0215] Step 2: Output a prompt word input window in the visual interface, and obtain a new prompt word from the prompt word input window;

[0216] Step 3: Save the new prompt word.

[0217] That is, in actual application, visual prompt words are automatically generated according to the data set field type for the user to choose. If the user is not satisfied with the visual prompt words automatically generated by the system, he or she can modify the prompts to meet his or her needs, or provide complete prompt words by himself or herself. At this time, the relevant information of the new prompt words modified or newly provided by the user can be stored. When storing new prompt words, the corresponding relationship between the field type and the generated chart needs to be saved.

[0218] Corresponding to the above method embodiment, the embodiment of the present application further provides a visualization chart generating device, and the visualization chart generating device described below and the visualization chart generating method described above can refer to each other.

[0219] See also Figure 7 As shown, the device includes the following modules:

[0220] The intention analysis module 101 is used to obtain table data and analyze the table data using a large language model to obtain a number of drawing intentions;

[0221] The target drawing intent selection module 102 is used to output a plurality of drawing intents on the visualization interface and determine the target drawing intent according to the operation information of the visualization interface;

[0222] A prompt word generation module 103, used to generate prompt words matching the target drawing intention by using the prompt word template;

[0223] A drawing code generation module 104 is used to input a prompt word and an executable code template corresponding to the prompt word into a large language model for code generation processing to obtain a chart drawing code;

[0224] The visualization chart generating module 105 is used to execute the chart drawing code to draw a visualization chart corresponding to the table data.

[0225] Using the device provided in the embodiment of the present application, tabular data is obtained, and a large language model is used to perform data analysis on the tabular data to obtain a number of drawing intentions; a number of drawing intentions are output on a visualization interface, and a target drawing intention is determined based on the operation information of the visualization interface; a prompt word template is used to generate a prompt word that matches the target drawing intention; the prompt word and the executable code template corresponding to the prompt word are input into the large language model for code generation processing to obtain a chart drawing code; the chart drawing code is executed to draw a visual chart corresponding to the tabular data.

[0226] Technical effect: Since the large language model has data analysis capabilities, after obtaining the table data, the table data can be first analyzed based on the large language model to obtain several drawing intentions. The drawing intention is output in the visual interface for the user to select the target drawing intention. Then, in combination with the prompt word template, a prompt word matching the target drawing intention is generated. In order to avoid the large language model from performing boundless divergent processing, the prompt word and the executable code template matching the prompt word are input into the large language model for code generation processing, and a chart drawing code constrained within the scope of the executable code template can be obtained, thereby ensuring the executability of the chart drawing code. By executing the chart drawing code, a visual chart corresponding to the table data can be drawn. That is, with the help of the large language model, when visualizing the table data, the data analysis and chart generation operation processing that were originally manually implemented can be automated, which can effectively improve the efficiency of table data visualization, further meet the needs of large-scale visualization of table data, and also meet the needs of real-time table data visualization.

[0227] In a specific implementation of the present application, the intention analysis module is specifically used to analyze the field features of each field in the table data and the field association features between each field using the large language model;

[0228] Using the column features, obtain the drawing intent of the bar chart and / or the drawing intent of the line chart;

[0229] Utilize the column association feature to obtain the drawing intent of the scatter plot.

[0230] In a specific implementation of the present application, the prompt word generation module is specifically used to determine a target prompt word template corresponding to the image type of the target drawing intent from the prompt word templates having a matching relationship with the image type;

[0231] According to the target drawing intention, the replaceable parameters in the target prompt word template are modified to obtain the prompt word.

[0232] In a specific embodiment of the present application, if the target drawing intent is to represent several columns with a scatter plot, the prompt word generation module is specifically used to output a target prompt word template for drawing a scatter plot in a visual interface; wherein the target prompt word template for drawing a scatter plot includes: drawing a scatter plot according to the first column and the second column of the data set, and generating a code that can display the scatter plot with reference to the provided code example; identifying a first replaceable parameter of the target prompt word template for drawing the scatter plot, obtaining a replaceable parameter, and replacing the first replaceable parameter based on the target drawing intent to obtain a scatter plot prompt word; wherein the first replaceable parameter is the data set, the first column and the second column in the target prompt word template for drawing the scatter plot;

[0233] If the target drawing intention is to represent several columns with a line graph, the prompt word generation module is specifically used to output a target prompt word template for drawing a line graph in a visual interface; wherein, the target prompt word template for drawing a line graph includes: drawing a line graph according to the third column and the fourth column of the data set, and generating a code that can display the line graph with reference to the provided code example; identifying the second replaceable parameter in the target prompt word template for drawing the line graph, and replacing the second replaceable parameter based on the target drawing intention to obtain the line graph prompt word; wherein, the second replaceable parameter includes the data set, the third column and the fourth column in the target prompt word template for drawing the line graph.

[0234] In a specific implementation of the present application, the drawing code generation module is specifically used to extract drawing parameters from the prompt words using a large language model;

[0235] The corresponding replaceable code parameters in the executable code template are replaced with the drawing parameters to obtain the chart drawing code.

[0236] In a specific implementation of the present application, the template recording module is used to store the usage record of the prompt word template;

[0237] Correspondingly, the prompt word generation module is specifically used to combine the target drawing intent with the usage records corresponding to each prompt word template, calculate the recommendation score corresponding to each prompt word template; output the prompt word template matching the drawing type in the basic recommendation area of ​​the visualization interface; output the prompt word template outside the basic recommendation area based on the recommendation score; determine the target prompt word template based on the operation information of the visualization interface; and use the target prompt word template to generate a prompt word matching the target drawing intent.

[0238] In a specific implementation of the present application, the usage record includes the fields selected for drawing the visualization chart and the field features of the fields, and the number of times the prompt word template is used;

[0239] Correspondingly, the prompt word generation module is specifically used to compare the target drawing intention with the usage record to obtain the number of columns of the same type; calculate the product of the number of columns of the same type and the number of times used, and determine the product result as the recommendation score.

[0240] Corresponding to the above method embodiment, the embodiment of the present application further provides an electronic device, and the electronic device described below and the visual chart generation method described above can refer to each other.

[0241] See also Figure 8 As shown, the electronic device includes:

[0242] A memory 332, for storing computer programs;

[0243] The processor 322 is used to implement the steps of the visual chart generating method of the above method embodiment when executing the computer program.

[0244] For details, please refer to Fig. 9 , Fig. 9 A specific structural diagram of an electronic device provided for this embodiment, the electronic device may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 322 (for example, one or more processors) and a memory 332, and the memory 332 stores one or more computer programs 342 or data 344. Among them, the memory 332 can be a temporary storage or a permanent storage. The program stored in the memory 332 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the data processing device. Furthermore, the processor 322 can be configured to communicate with the memory 332 to execute a series of instruction operations in the memory 332 on the electronic device 301.

[0245] The electronic device 301 may further include one or more power supplies 326 , one or more wired or wireless network interfaces 350 , one or more input and output interfaces 358 , and / or one or more operating systems 341 .

[0246] The steps in the visual chart generating method described above can be implemented by the structure of an electronic device.

[0247] Corresponding to the above method embodiment, the embodiment of the present application further provides a readable storage medium. The readable storage medium described below and the visual chart generating method described above can refer to each other.

[0248] A readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the visualization chart generating method of the above method embodiment.

[0249] The readable storage medium may specifically be a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or other readable storage medium that can store program codes.

[0250] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0251] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with 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 terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art 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 this application.

[0252] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0253] Finally, it should be noted that, in this article, relationships such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms include, include or any other variations are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes 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.

[0254] Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for generating a visual chart, characterized in that: include: Acquire tabular data, and use a large language model to perform data analysis on the tabular data to obtain a number of drawing intentions; Outputting a plurality of the drawing intentions on a visualization interface, and determining a target drawing intention according to operation information of the visualization interface; Using the prompt word template, generating prompt words matching the target drawing intention; Inputting the prompt word and the executable code template corresponding to the prompt word into the large language model for code generation processing to obtain a chart drawing code; The chart drawing code is executed to draw a visual chart corresponding to the table data.

2. The method according to claim 1, characterized in that The table data is analyzed using a large language model to obtain several drawing intentions, including: Analyzing the field features of each field in the table data and the field association features between the fields using a large language model; Using the column feature, obtaining the drawing intent of the bar chart and / or the drawing intent of the line chart; The column association feature is used to obtain the drawing intent of the scatter plot.

3. The method according to claim 1, characterized in that: Using the prompt word template, generating prompt words matching the target drawing intent, including: Determining a target prompt word template corresponding to the image type of the target drawing intent from prompt word templates having a matching relationship with the image type; In combination with the target drawing intent, replaceable parameters in the target prompt word template are modified to obtain the prompt word.

4. The method according to claim 3, characterized in that If the target drawing intent is to represent a plurality of columns with a scatter plot, then modifying the replaceable parameters in the target prompt word template in combination with the target drawing intent to obtain the prompt word includes: Outputting a target prompt word template for drawing a scatter plot on a visual interface; wherein the target prompt word template for drawing a scatter plot includes: drawing a scatter plot according to the first column and the second column of the data set, and generating a code that can display the scatter plot by referring to the provided code example; Identify a first replaceable parameter of a target prompt word template for drawing a scatter plot, obtain a replaceable parameter, and replace the first replaceable parameter based on the target drawing intention to obtain a scatter plot prompt word; Wherein, the first replaceable parameter is the data set, the first column and the second column in the target prompt word template for drawing the scatter plot; If the target drawing intent is to represent a plurality of columns with a line graph, then modifying the replaceable parameters in the target prompt word template in combination with the target drawing intent to obtain the prompt word includes: Outputting a target prompt word template for drawing a line graph on the visual interface; wherein the target prompt word template for drawing a line graph includes: drawing a line graph according to the third column and the fourth column of the data set, and generating a code that can display the line graph by referring to the provided code example; Identifying a second replaceable parameter in the target prompt word template for drawing a line graph, and replacing the second replaceable parameter based on the target drawing intention to obtain a line graph prompt word; The second replaceable parameter includes a data set, a third column and a fourth column in the target prompt word template for drawing a line graph.

5. The method according to claim 1, characterized in that Input the prompt word and the executable code template into the large language model for code generation processing to obtain a chart drawing code, including: Using the large language model, extracting drawing parameters from the prompt words; The corresponding replaceable code parameters in the executable code template are replaced with the drawing parameters to obtain the chart drawing code.

6. The method according to any one of claims 1 to 5, characterized in that: Also includes: Storing usage records of prompt word templates; Accordingly, the use of the prompt word template to generate a prompt word matching the target drawing intention includes: combining the target drawing intention with the usage records corresponding to each of the prompt word templates, and calculating the recommendation score corresponding to each of the prompt word templates; Outputting the prompt word template matching the image type in the basic recommendation area of ​​the visualization interface; outputting the prompt word template outside the basic recommendation area based on the recommendation score; Determining a target prompt word template based on the operation information of the visual interface; The target prompt word template is used to generate prompt words matching the target drawing intention.

7. The method according to claim 6, characterized in that The usage record includes the column selected for drawing the visual chart and the column characteristics of the column, and the number of times the prompt word template is used; Accordingly, combining the target drawing intent with the usage records corresponding to each of the prompt word templates, and calculating the recommendation score corresponding to each of the prompt word templates, includes: Comparing the target drawing intent with the usage record to obtain the number of fields of the same type; The product of the number of columns of the same type and the number of times used is calculated, and the product result is determined as the recommendation score.

8. A visual chart generating device, characterized in that: include: An intention analysis module is used to obtain table data and perform data analysis on the table data using a large language model to obtain a number of drawing intentions; A target drawing intent selection module is used to output a plurality of the drawing intents on a visualization interface and determine a target drawing intent according to operation information of the visualization interface; A prompt word generation module, used to generate prompt words matching the target drawing intention by using the prompt word template; A drawing code generation module, used for inputting the prompt word and the executable code template corresponding to the prompt word into the large language model for code generation processing to obtain a chart drawing code; The visual chart generating module is used to execute the chart drawing code to draw a visual chart corresponding to the table data.

9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the method for generating a visual chart as claimed in any one of claims 1 to 7 when executing the computer program.

10. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for generating a visualization chart according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Big data visualization method, platform, equipment and storage medium

    CN118916418A

  • Table image and table LaTeX code generation method and device

    CN119089879A

  • Data display method and device based on large language model, medium and equipment

    CN120688455A

  • Chart data generation method and device and chart analysis model training method and device

    CN120747991A