Method and electronic device for determining recommendation results based on user needs
By analyzing the user's natural language needs and converting them into SQL statements, combining intent reasoning models and multi-dimensional correlation analysis, the deviation problem of NL2SQL technology when dealing with user needs in different regions is solved, and more accurate user needs understanding and data query results are achieved.
Patent Information
- Application Number
- CN202411968788.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2044-12-30
AI Technical Summary
When existing NL2SQL technology deals with natural language queries from users in different regions, the deviation between data and user needs caused by language, grammar and vocabulary differences, and it is impossible to accurately understand user needs.
By obtaining the user's natural language needs, determining the user's interactive data, and parsing the data using the intent reasoning model, converting it into SQL statements. Feature extraction is performed on query results and multi-dimensional data, a similarity matrix is constructed, multi-dimensional correlation analysis is performed, and recommended results are generated.
It realizes a more accurate understanding of user needs and behavior, and generates multi-dimensional query results corresponding to user needs through multi-dimensional correlation analysis, improving the accuracy and efficiency of data query.
Smart Images

Figure CN119396872B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, and in particular to a method for determining recommendation results based on user needs. Background Art
[0002] NL2SQL (Natural Language to SQL) is a technology that converts natural language queries into SQL query statements. It involves multiple core technologies such as natural language processing (NLP), semantic parsing, and database schema mapping. Through these technologies, the system can generate SQL statements based on user needs, thereby directly querying the database and obtaining data.
[0003] The core function of NL2SQL is to convert the needs described by users in natural language into SQL query statements. Based on SQL statements, data is queried from the database to obtain the corresponding data. However, there are some scenarios, such as the differences in pronunciation, grammar, and vocabulary used by users in different regions, or the ambiguity or simplicity of user descriptions, which may cause the obtained data to deviate from the user's needs, making it impossible to accurately understand the user's needs. Summary of the invention
[0004] Based on this, it is necessary to provide a method for determining recommendation results based on user needs to address the above problems, which can more accurately understand user needs and behaviors.
[0005] In a first aspect, the present application provides a method for determining recommendation results based on user needs, the method comprising:
[0006] Obtaining user needs; where the needs are described in natural language;
[0007] Determine the user's interaction data based on the needs, and determine the user's interaction intention based on the interaction data and using the intention reasoning model;
[0008] By converting the interaction intention into SQL statements, a query result set Q and a multi-dimensional data set D are obtained; wherein the query result set Q includes n query results, and the multi-dimensional data set D includes data of m dimensions;
[0009] Perform feature extraction on the query results in the query result set Q to obtain the query result feature set F q , extract features from the multi-dimensional data set D and obtain a multi-dimensional feature set F d ; Among them, the query result feature set F q It includes n feature objects, multi-dimensional feature set F d It includes m feature objects;
[0010] Based on the query result feature set F q With the multi-dimensional feature set F d Determine a similarity matrix M, obtain an association analysis function A, and perform a multi-dimensional association analysis on the similarity matrix M through the association analysis function A to obtain a recommendation result set R; wherein the recommendation result set R includes k recommendation results, and the k recommendation results can form a multi-dimensional query result corresponding to the user's needs.
[0011] In one embodiment, the query result feature set F q With the multi-dimensional feature set F d Determine the similarity matrix M, including:
[0012] For the query result feature set F q Any feature object and multi-dimensional feature set F d Any feature object in the query result is determined by using the similarity function S. q Any feature object and multi-dimensional feature set F in d The similarity between any feature objects in ;
[0013] Based on the query result feature set F q The feature objects and multi-dimensional feature sets F in d The similarity between the feature objects in is used to determine the similarity matrix M.
[0014] In one embodiment, the query result set Q and the multi-dimensional data set D are determined by converting the interaction intent, including:
[0015] Semantically split the interaction intent based on the large language model and convert it into SQL statement results;
[0016] The SQL statement result is modified, and based on the modified SQL statement result, a query result set Q and a multi-dimensional data set D are determined.
[0017] In one embodiment, the SQL statement result is modified, and based on the modified SQL statement result, a query result set Q and a multi-dimensional data set D are determined, including:
[0018] Get the user's first modification operation on the SQL statement result;
[0019] Get the user's second modification operation on the SQL statement result;
[0020] Based on the first modification operation and the second modification operation on the SQL statement result, a query result set Q and a multi-dimensional data set D are determined.
[0021] In one embodiment, obtaining a first modification operation of a user on a SQL statement result includes:
[0022] Prompting at least part of the SQL statement results in at least one of the following ways: the first field is an attribute, the second field is a restriction, and the third field and the fourth field are required query results;
[0023] By prompting at least part of the SQL statement result, a first modification operation of the user on the SQL statement result is obtained.
[0024] In one embodiment, obtaining a first modification operation of a user on a SQL statement result by prompting at least a portion of the SQL statement result includes:
[0025] Instructing to display the corrected SQL statement result graphically through at least one of the following interaction modes: voice interaction, text interaction, and file interaction;
[0026] By displaying the corrected SQL statement results in a graphical form, the user can confirm and adjust the corrected SQL statement results.
[0027] Based on the user's confirmation and adjustment, the user's first correction operation on the SQL statement result is obtained.
[0028] In one embodiment, the second modification operation of the user on the SQL statement result includes:
[0029] Calculate the standard deviation of each column of data query results in the SQL statement results;
[0030] Determine the dispersion of each column data query result according to the standard deviation, and determine the abnormal column data query result based on the dispersion;
[0031] Use the correlation coefficient algorithm to calculate the correlation between the abnormal column data query results and other column data query results, and determine the affected fields in the SQL statement results based on the correlation;
[0032] By displaying the affected fields in the SQL statement result in a natural language manner, the second correction operation of the user on the SQL statement result is determined.
[0033] In one of the embodiments, the interaction data includes an interaction data set U, a context data set C, and an industry knowledge base K;
[0034] Based on the interaction data and using the intention inference model, the user's interaction intention is determined, including:
[0035] Determine the behavior feature set based on the interaction data set U , determine the context feature set based on the context data set C , determine the industry feature set based on the industry knowledge base K ;
[0036] Based on behavioral feature set , context feature set and industry feature sets , determine the input features ;
[0037] Input features Input the pre-trained intent inference model to obtain the user's interaction intention.
[0038] In one embodiment, the query result feature set , query result set , Represents a query result, a multi-dimensional feature set , multi-dimensional data set , Represents data of one dimension;
[0039] Similarity Matrix .
[0040] In a second aspect, the present application further provides an electronic device for determining a recommendation result based on a user's needs, the electronic device comprising:
[0041] The memory is used to store a computer program; the processor is used to execute the computer program, and when the computer program is executed by the processor, the steps of the method for determining recommendation results based on user needs in the first aspect are implemented.
[0042] The above method for identifying user needs collects the needs described by users in natural language and uses the needs to determine the user's interaction data; uses the intention reasoning model to parse the data, thereby accurately determining the user's interaction intention; converts the user's intention into an SQL statement, and after execution, obtains a query result set Q and a multi-dimensional data set D; extracts features from the query results and the multi-dimensional data to form query result feature sets F respectively. q and multi-dimensional feature set F d Based on the two feature sets, a similarity matrix M is determined, and an association analysis function A is obtained. The similarity matrix M is subjected to a multi-dimensional association analysis through the association analysis function A to obtain a recommendation result set R, which contains k recommendation results. These recommendation results can form a multi-dimensional query result corresponding to the user's needs. This method obtains query results corresponding to the user's needs by performing multi-dimensional association on the needs, and understands the user's needs and behaviors more accurately. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1An application environment diagram of a method for determining recommendation results based on user needs in one embodiment;
[0044] Figure 2 A flowchart of a method for determining recommendation results based on user needs in one embodiment;
[0045] Figure 3 In one embodiment, the query result feature set F q With the multi-dimensional feature set F d Flowchart for determining the similarity matrix M;
[0046] Figure 4 A flowchart of determining a query result set Q and a multi-dimensional data set D by converting an interaction intention in one embodiment;
[0047] Figure 5 A flowchart of determining a query result set Q and a multi-dimensional data set D based on a modified SQL statement result in one embodiment;
[0048] Figure 6 A flowchart of obtaining a first modification operation of a user on a SQL statement result in one embodiment;
[0049] Figure 7 A flowchart of a first modification operation of obtaining a user's SQL statement result by prompting at least a portion of the SQL statement result in one embodiment;
[0050] Figure 8 A flowchart of obtaining a second modification operation of a user on a SQL statement result in one embodiment;
[0051] Fig. 9 A flowchart of determining a user's interaction intention based on interaction data and using an intention reasoning model in one embodiment;
[0052] Fig.10 FIG. 4 is a diagram showing the internal structure of an electronic device in one embodiment. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical scheme and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Unless otherwise defined, the technical terms or scientific terms involved in the present application should have the general meaning understood by people with general skills in the technical field to which the present application belongs. The words such as "one", "a", "a kind of", "the", "these" and the like in the present application do not represent quantitative restrictions, and they can be singular or plural. The terms "first", "second", "third", etc. involved in the present application are only used to distinguish similar objects and do not represent a specific ordering for objects.
[0054] like Figure 1 The application environment shown in the figure includes a terminal 102 and a server 104. The method for determining the recommendation result based on the user's needs provided in the embodiment of the present application is applied to the server 104. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The user can input the demand through the terminal 102, and then the terminal 102 uploads the demand to the server 104. The server 104 generates a multi-dimensional query result corresponding to the user's demand based on the demand, and can send the query result to the terminal 102. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.
[0055] In one embodiment, Figure 2 As shown, a method for determining recommendation results based on user needs is provided, and the method includes the following steps:
[0056] Step 201: Obtaining user needs; wherein the needs are described in natural language;
[0057] Specifically, the user's natural language description of needs is obtained, wherein the needs may refer to the information that the user directly expresses through simple daily language that he wants to obtain. For example, the user may say "I want to see the sales data of this month" to express the needs.
[0058] Step 202: Determine the user's interaction data based on the demand, and determine the user's interaction intention based on the interaction data and using the intention reasoning model;
[0059] Specifically, the user's interaction data is determined based on the user's needs described in natural language, and the user's interaction intention is determined using an intent reasoning model. Specifically, key information is extracted from the natural language description previously provided by the user, and these key information constitute the user's interaction data. For example, if the user says "I want to see the sales data for this month", then "this month" and "sales data" can be interaction data extracted from the needs described by the user. An intent reasoning model can be used to analyze the interaction data. Among them, the intent reasoning model can be a pre-trained model based on pre-set rules, machine learning algorithms, or a combination of the two, which can help the system understand the specific purpose behind the user's request. Exemplarily, taking "I want to see the sales data for this month" as an example, the intent reasoning model recognizes that the user's intention may be to view the sales situation within a specific time period.
[0060] Step 203: converting the interaction intent into an SQL statement to obtain a query result set Q and a multi-dimensional data set D; wherein the query result set Q includes n query results, and the multi-dimensional data set D includes data of m dimensions;
[0061] Specifically, according to step 202, the user's interaction intention can be determined, and the NL2SQL method can be used to convert the interaction intention into a corresponding SQL statement. When the SQL statement is executed, a query result set Q and a multi-dimensional data set D are obtained. It should be noted that the query result set Q contains n query results, which are data that directly respond to user requests. For example, if the user wants to know sales data, the set Q can contain sales-related records or statistical information; the multi-dimensional data set D contains m dimensions of data, which can provide additional contextual information for the query results and can help the system perform a more comprehensive analysis. For example, if sales data needs to be analyzed by different dimensions such as region, product category, etc., then the multi-dimensional data set D can contain specific data of these dimensions.
[0062] Step 204: Extract features from the query results in the query result set Q to obtain a query result feature set F q , extract features from the multi-dimensional data set D and obtain a multi-dimensional feature set F d ; Among them, the query result feature set F q It includes n feature objects, multi-dimensional feature set F d It includes m feature objects;
[0063] Specifically, feature extraction is performed on the query result set Q and the multi-dimensional data set D obtained in step 203. For the query result set Q, each query result in the query result set Q is analyzed, and key features are extracted from each query result. The key features may be core information representing each query result, and these key features are aggregated to form a query result feature set F q , the set can contain n feature objects. Similarly, feature extraction is performed on the data of each dimension in the multidimensional data set D, the key features of the data of each dimension are extracted, and the key features of the data of each dimension are summarized to form a multidimensional feature set F d , the collection can contain m feature objects.
[0064] Step 205: Based on the query result feature set F q With the multi-dimensional feature set F d Determine a similarity matrix M, obtain an association analysis function A, and perform a multi-dimensional association analysis on the similarity matrix M through the association analysis function A to obtain a recommendation result set R; wherein the recommendation result set R includes k recommendation results, and the k recommendation results can form a multi-dimensional query result corresponding to the user's needs;
[0065] Specifically, based on the query result feature set F extracted in the previous step 204, q and multi-dimensional feature set F d Determine the similarity matrix M. It should be noted that this process can be calculated by q Each feature object in F d The similarity between each feature object in creates a similarity matrix M, where each element in the similarity matrix M represents the similarity value between a pair of feature objects. Furthermore, the similarity matrix can be constructed using a variety of methods, each of which is suitable for specific data types and analysis scenarios. For example, cosine similarity is often used to measure the angular difference between vectors in text data, and is suitable for comparing the similarity of document or word vectors; the Pearson correlation coefficient is used to evaluate the linear relationship between two continuous variables, and is suitable for measuring the correlation of asset prices in financial data analysis; the Jaccard similarity coefficient is suitable for comparing the ratio of the intersection to the union of two sets, and is often used to evaluate the similarity of user preferences in recommendation systems; the Euclidean distance measures the straight-line distance between two points, and is suitable for comparing pixel differences in image processing.
[0066] It should be noted that the association analysis function can be an algorithm or model for analyzing the data in the similarity matrix M and identifying meaningful patterns or associations therefrom. Furthermore, the association analysis function can identify the query result feature set F q The feature objects and multi-dimensional feature sets F in dThere is a combination of strong similarities between the feature objects in. Among them, the association analysis function can be based on statistics, machine learning or data mining technology, which can process large-scale data sets and discover frequent patterns, association rules or correlations between items. In this embodiment, an association analysis function suitable for the current data analysis needs can be selected or designed to analyze the similarity matrix M and generate a recommendation result set R.
[0067] The association analysis function A can be applied to the similarity matrix M to perform multi-dimensional association analysis. Furthermore, the association analysis function A can analyze each element in the similarity matrix M. Each element in M represents F q The characteristic objects in F d The similarity values between the feature objects in the image are used to find out which feature objects have the highest similarity, or which feature object combinations show strong correlation in multiple dimensions. Through multi-dimensional correlation analysis, the multi-dimensional data most relevant to the user's needs can be identified and used as recommendation results. Therefore, the recommendation result set R contains multiple recommendation results, which can reflect the correlation between the query results and multi-dimensional data that the user may be interested in. It should be noted that the correlation analysis function A is based on the similarity matrix Perform multi-dimensional correlation analysis and output recommendation results .Right now . Recommended result set , , where each Represents a recommendation result.
[0068] In this embodiment, the method collects the needs described by the user in natural language and uses the needs to determine the user's interaction data; uses the intention reasoning model to parse the data, thereby accurately determining the user's interaction intention; converts the user's intention into an SQL statement, and after execution, obtains a query result set Q and a multi-dimensional data set D; extracts features from each query result and multi-dimensional data to form query result feature sets F respectively. q and multi-dimensional feature set F d Based on the two feature sets, a similarity matrix M is determined, and an association analysis function A is obtained. The similarity matrix M is subjected to a multi-dimensional association analysis through the association analysis function A to obtain a recommendation result set R, which contains k recommendation results. These recommendation results can form a multi-dimensional query result corresponding to the user's needs. This method obtains query results corresponding to the user's needs by performing multi-dimensional association on the needs, and understands the user's needs and behaviors more accurately.
[0069] In one embodiment, Figure 3 As shown, based on the query result feature set F q With the multi-dimensional feature set Fd Determining the similarity matrix M includes the following steps:
[0070] Step 301: Targeting the query result feature set F q Any feature object and multi-dimensional feature set F d Any feature object in the query result is determined by using the similarity function S. q Any feature object and multi-dimensional feature set F in d The similarity between any feature objects in ;
[0071] Specifically, for the query result feature set F q Each feature object and multi-dimensional feature set F d The similarity function S is applied to each feature object in . It should be noted that the similarity function S is a mathematical tool used to quantify the similarity between two objects. In data analysis, the similarity function S calculates the feature values of two data points and outputs a value between 0 and 1, where 0 indicates complete dissimilarity and 1 indicates complete similarity. When implementing the similarity function S, methods such as cosine similarity and Euclidean distance can be used to select a suitable algorithm based on different data characteristics and requirements. In this embodiment, the similarity function S is implemented by comparing the query result feature set F one by one. q Any feature object and multi-dimensional feature set F in d For any feature object in , the similarity between them is quantified by the similarity function S. It should be noted that the similarity function S can be: . We can use the similarity function Calculate the query result feature set F q and multi-dimensional feature set F d The similarity between .
[0072] Step 302: Based on the query result feature set F q The feature objects and multi-dimensional feature sets F in d The similarity between the feature objects in is used to determine the similarity matrix M.
[0073] Specifically, the similarity values calculated in step 301 are integrated to form a complete similarity matrix M. Comprehensive query result feature set F q Each feature object and multi-dimensional feature set F d The similarities between each feature object in F can be calculated by the similarity function S. These similarity values are arranged in a certain order, which can be in the form of a matrix, where the rows can represent F q The columns in the feature object can be the representation of F dEach element in the similarity matrix M corresponds to the feature object in F q A feature object and F d The similarity between a feature object in .
[0074] For example, if F q There are n feature objects in F d If there are m feature objects in F, then the similarity matrix M will be an n×m matrix, and each cell (i, j) in the matrix represents F q The i-th feature object in F d The similarity between the j-th feature objects in .
[0075] In this embodiment, the method provides a way to understand and analyze the data features behind user needs. By constructing the similarity matrix M, the potential connection between the query results and multi-dimensional data can be revealed, which is crucial for in-depth understanding of user needs and providing personalized data analysis.
[0076] For example, based on the query result feature set F q The feature objects and multi-dimensional feature sets F in d The similarity between the feature objects in F is determined, and the similarity matrix M is constructed. q Each feature object in F d When comparing each object feature in the similarity function S, it provides a similarity value. This similarity value is placed in a specific cell of the similarity matrix M, which is located by F q The index of the object features in F d For example, if F q There are n object features, F d There are m object features in , and the similarity matrix M can be a matrix with n rows and m columns. In this matrix M, the cell at the i-th row and j-th column will store F q The i-th object feature and F d The similarity value between the jth feature objects in . The calculated similarity value is placed in the corresponding position of the similarity matrix M. That is, for the query result feature set F q Each feature object and multi-dimensional feature set F d For each feature object in , a similarity value can be calculated and put into the corresponding cell of the matrix. It should be noted that the position of the cell can be determined by F q The feature object index and F in d The feature object index in F q The i-th feature object in Fd The similarity value between the j-th feature object in is placed in the i-th row and j-th column of the matrix. In this way, each cell in the matrix can be filled one by one until all the similarity values between the feature objects are put into the similarity matrix M.
[0077] In one embodiment, as Figure 4 shown, by converting the interaction intention, the query result set Q and the multi-dimensional data set D are determined, including the following steps:
[0078] Step 401: Semantically split the interaction intention based on the large language model and convert it into the result of an SQL statement;
[0079] Specifically, the large language model receives the user's interaction intention, which can be a query or request expressed in natural language, and the large language model performs semantic analysis on it.
[0080] Among them, semantic splitting refers to decomposing the user's natural language description into the components required for database queries, such as entities, attributes, relationships, dimensions, and qualification conditions, etc. For example, if the user says "Show all sales records in Shanghai in the third quarter of this year", the large language model can identify "Shanghai" and "the third quarter of this year" as qualification conditions, and "all sales records" as the entity to be retrieved.
[0081] It should be noted that converting to an SQL statement means that the large language model converts these semantic units into SQL query language to form a specific SQL statement. The SQL statement can be directly executed in the database to retrieve the data that matches the user's request. In the above example, the converted SQL statement can be "SELECT * FROM sales WHERE region = 'Shanghai' AND quarter = 'third quarter' AND year = current year".
[0082] Step 402: Correct the result of the SQL statement, and based on the corrected result of the SQL statement, determine the query result set Q and the multi-dimensional data set D.
[0083] Specifically, check the initially generated SQL statements to confirm whether they match the structure and field names of the database, and whether they can be correctly executed to retrieve the required data.
[0084] Exemplarily, if the user's interaction intention is "Show all sales records in Shanghai in the third quarter of this year", the large language model can generate the following initial SQL statement:
[0085] SELECT * FROM sales WHERE region = 'Shanghai' AND quarter = 'third quarter' AND year = 'current year';
[0086] It should be noted that the SQL statement needs to be corrected. "Current year" needs to be replaced with a specific year value, such as 2024. "Third quarter" needs to be converted to a specific month range, that is, July to September. If the actual name of the "region" field in the database is "location", "region" needs to be replaced with "location". After correction, the SQL statement becomes:
[0087] SELECT * FROM sales WHERE location = 'Shanghai' AND (month>= 7 AND month<= 9) AND year = 2024;
[0088] The corrected SQL statement can be accurately executed in the database to retrieve the sales records requested by the user, forming a query result set Q; it can also retrieve multi-dimensional data related to these sales records, such as customer information and product categories for each order, forming a multi-dimensional data set D.
[0089] In this embodiment, the method can effectively convert the user's natural language request into a query statement that can be executed by the database, thereby improving the accuracy and efficiency of retrieving information from the database. By combining the semantic understanding ability and correction mechanism of the large language model, the accuracy and applicability of the query statement are ensured, so that the user's needs can be accurately captured and responded to.
[0090] In one embodiment, Figure 5 As shown, the SQL statement result is corrected, and based on the corrected SQL statement result, the query result set Q and the multi-dimensional data set D are determined, including the following steps:
[0091] Step 501: Obtain the first modification operation of the user on the SQL statement result;
[0092] Specifically, if the user finds that some fields do not exist in the database, some query logic does not meet business requirements, or the query results do not accurately reflect the user's original intentions, the user can propose a first correction operation, which can propose specific correction measures for these problems, such as changing field names, adding or deleting query conditions, adjusting sorting and grouping rules, etc. The first correction operation can help the system understand the user's real needs more accurately and ensure that the final executed SQL statement can return results that meet the user's expectations.
[0093] Step 502: Obtain the second modification operation of the user on the SQL statement result;
[0094] Specifically, if the user is concerned about more specific or subtle issues, such as the accuracy of the data, the completeness of the query results, or the presentation of the results, the user can propose a second correction operation, such as adjusting the data aggregation method, changing the connection conditions, optimizing the data filtering criteria, or correcting the problem of data type mismatch.
[0095] Step 503: Based on the first modification operation and the second modification operation on the SQL statement result, a query result set Q and a multi-dimensional data set D are determined.
[0096] Specifically, based on the first correction operation, the first correction operation may include modification of the logic, field name, query conditions, etc. of the SQL statement; based on the second correction operation, the second correction operation may be adjustment of data aggregation mode, optimization of data filtering criteria, or correction of data type mismatch and other issues. Combining the first correction operation and the second correction operation, a corrected SQL statement is generated. Executing the SQL statement, that is, retrieving data from the database, generating a query result set Q, which may contain specific information or data records requested by the user; retrieving multi-dimensional data related to the query result to form a multi-dimensional data set D, which provides additional contextual information for the query result, such as time, location, user behavior, and other multi-dimensional data.
[0097] In this embodiment, the method improves the accuracy and efficiency of SQL statement correction through direct user participation and feedback, and users can ensure that query statements and results meet their specific needs and expectations, thereby obtaining higher quality data output.
[0098] In one embodiment, Figure 6 As shown, obtaining the first modification operation of the user on the SQL statement result includes the following steps:
[0099] Step 601: prompting at least part of the SQL statement result in at least one of the following ways: the first field is an attribute, the second field is a restriction, and the third field and the fourth field are required query results;
[0100] Specifically, at least part of the SQL statement results are prompted in at least one of the following ways. Exemplarily, first, it can be pointed out that a certain field is an attribute, and the field can correspond to a column in a database table, which is used to describe the characteristics of the record; secondly, it can be prompted that a certain field is a restriction, and the field can be used to specify the scope or condition of the query; finally, it can be clearly pointed out which fields are the required query results, that is, the data that the user expects to retrieve from the database. For example, the user can be prompted: "The first field is an attribute, the second field is a restriction, and the third field and the fourth field are the required query results." This prompt can help the user identify the different parts in the SQL statement and ensure that these parts can correctly reflect the query intent, so that the user can correct the SQL statement more accurately.
[0101] Step 602: Obtain a first modification operation of the user on the SQL statement result by prompting at least part of the SQL statement result.
[0102] Specifically, the prompt information provided in step 601, for example, indicating which fields are attributes, which are limiting conditions, and which fields contain the required query results, can guide the user to perform the first correction operation. Further, based on the prompt information, the user can check the SQL statement results, identify possible errors or parts that do not meet expectations, and propose corresponding correction measures. Among them, the correction measures may include correcting field names, adjusting query conditions, modifying returned fields, etc.
[0103] In this embodiment, the method improves the accuracy of SQL queries and user participation, and can reduce the deviation in understanding query intent and improve the relevance of query results through clear field prompts and direct user participation.
[0104] In one embodiment, Figure 7 As shown, obtaining the user's first correction operation on the SQL statement result by prompting at least part of the SQL statement result includes the following steps:
[0105] Step 701: Obtain a modified SQL statement result, wherein the modified SQL statement result is a modification of the SQL statement result by the user based on at least a portion of the prompt of the SQL statement result;
[0106] Specifically, in this step, the user has received a prompt about the SQL statement result, and the prompt of the SQL statement result may include an explanation of different fields in the SQL result, such as which fields are attributes, limiting conditions, or required query results. Based on the prompt of the statement result, the user can understand the structure and content of the SQL statement result and identify the part that needs to be adjusted. Further, the user can modify the SQL statement result, which may be to modify the field name, adjust the query logic, optimize the query performance, or correct any errors, to obtain a modified SQL statement result.
[0107] Step 702: Instructing to graphically display the corrected SQL statement result through at least one of the following interaction modes: voice interaction, text interaction, and file interaction;
[0108] Specifically, the graphical display of the modified SQL statement result is indicated by at least one of the following interaction modes. For example, voice interaction can read the SQL statement result to the user through voice, so that the user can understand and make modification suggestions by listening; text interaction directly displays the SQL statement result in text form, and the user can read and edit the text content intuitively; file interaction can save the SQL statement result as a file, and the user can download or directly view and modify these files on the system interface.
[0109] Exemplarily, a generative evaluation indicator method can be used to output the evaluation indicators through a large model. The evaluation indicators may include determining the type of chart, the conditions to be displayed, the dimensions involved, and the measurement values. The user confirms the evaluation indicators and adjusts the output method based on the user's feedback. Perform a graphic preview and save the graphics and parameter information of each preview. The user can switch between different versions and choose the most appropriate display method. Generate the code of the graphical page based on the conclusion confirmed by the user and save it for subsequent use. Read the saved graphic page code and display it to the user. The user can make further adjustments and confirmations based on the displayed content.
[0110] Step 703: obtaining the user's confirmation and adjustment of the modified SQL statement result by graphically displaying the modified SQL statement result;
[0111] Specifically, after observing the data presented in graphical form, users can directly confirm whether the results meet their query requirements on the interface, or make further adjustments. These adjustments may involve changes to the chart type, refinement of data screening conditions, increase or decrease of display dimensions, or other modifications to the way data is presented.
[0112] Step 704: Based on the user's confirmation and adjustment, obtain the user's first correction operation on the SQL statement result.
[0113] Specifically, feedback provided by the user after viewing the graphically displayed data is obtained. The feedback may include confirmation of the results and any adjustments that need to be made. The user's feedback may also include verification of data accuracy, changes in the preferred display method, or further requirements for the depth of analysis. Furthermore, a series of correction operations may be generated based on the user's confirmation and adjustment. The correction operations may modify specific parts of the SQL query, such as adjusting the query logic, changing the aggregate function, the filter condition, or the way the data is sorted.
[0114] In this embodiment, the method improves the accuracy and relevance of SQL query results through direct user participation and feedback. Users can intuitively understand and evaluate query results and effectively communicate with the system through a variety of interactive methods, thereby guiding the system to make necessary adjustments.
[0115] In one embodiment, Figure 8 As shown, obtaining the second modification operation of the user on the SQL statement result includes the following steps:
[0116] Step 801: Calculate the standard deviation of each column of data query results in the SQL statement result;
[0117] Specifically, when the SQL statement is executed, a query result set containing multiple columns of data will be obtained. The standard deviation is calculated for each column of data in the query result set. It should be noted that the standard deviation calculation is based on the deviation of each data point from the average value, which can reflect the fluctuation of the value relative to the average value. If the standard deviation of a column of data is large, it means that the values of the column are relatively dispersed; if the standard deviation is small, it means that the data values are relatively concentrated and tend to the average value.
[0118] Calculate the mean of each column of data, and for each data point, calculate the square of the difference between its value and the mean of the column, calculate the average of these squared differences, and take the square root of this average to get the standard deviation. The standard deviation can be calculated using the following formula: .
[0119] in, represents the standard deviation, Represents the average value of each column of data. Represents the value of each data point.
[0120] Step 802: determining the dispersion of each column data query result according to the standard deviation, and determining the abnormal column data query result based on the dispersion;
[0121] Specifically, the dispersion of each column of data query results is determined according to the standard deviation. Exemplarily, a higher standard deviation value indicates that the data points are scattered farther around the mean, while a lower standard deviation value indicates that the data points are more closely distributed around the mean. An abnormal column data query result may refer to a column in which the data points deviate too far from the mean and do not conform to the expected distribution pattern. In actual operation, a threshold may be set, for example, data points outside of plus or minus three standard deviations are considered abnormal. That is, if some values in a column of data differ from the mean of the column by more than three standard deviations, these data may be considered abnormal, and the column is marked as an abnormal column.
[0122] Step 803: using a correlation coefficient algorithm to calculate the correlation between the abnormal column data query result and other column data query results, and determining the influencing fields in the SQL statement result based on the correlation;
[0123] Specifically, the correlation coefficient algorithm is used to calculate the correlation between the abnormal column data query results and the other column data query results. The correlation coefficient is a statistical indicator that can measure the strength and direction of the linear relationship between two variables. The value range of the correlation coefficient is between -1 and 1, where 1 indicates a complete positive correlation, -1 indicates a complete negative correlation, and 0 indicates no correlation. The correlation coefficient between the abnormal column data and each other column data in the result set is calculated to determine which columns have a significant correlation with the abnormal column data.
[0124] Based on the correlation calculation, determine the impact fields in the SQL statement results, that is, determine which fields (i.e. column data) may have an impact on the abnormal data. The column data of the impact field has a direct or indirect relationship with the abnormal data, providing users with a basis for further analysis and correction of SQL statements. For example, if a certain abnormal column data is highly correlated with the sales amount column, then the sales amount column may need to be checked and corrected.
[0125] Exemplarily, the formula for calculating the correlation between the abnormal column data query result and other column data query results may be:
[0126] ,
[0127] in represents the correlation coefficient, Represents the covariance of the query results of the abnormal column data, Indicates the standard deviation of the abnormal column data query results. Indicates the standard deviation of other column data query results. The following are Covariance and and The calculation formula of standard deviation. Since it is the covariance of the abnormal column data query results and the standard deviation of the abnormal column data query results, the denominator is n-1.
[0128] The covariance calculation formula is:
[0129] .
[0130] The standard deviation calculation formula is:
[0131] .
[0132] The standard deviation calculation formula is:
[0133] .
[0134] Sort the absolute values of the correlation coefficient calculation results, take the top 5 data fields, and use the multiple regression equation group to find the influencing combination.
[0135] .
[0136] Among them, Y is the dependent variable, X is the independent variable, and there are k independent variables and one constant term in the above formula.
[0137] Based on all impact combinations, the combinations with the greatest impact are recorded and output to LLM for natural language presentation.
[0138] Step 804: Determine the second modification operation of the user on the SQL statement result by displaying the affected fields in the SQL statement result in a natural language manner.
[0139] Specifically, the influencing fields in the SQL statement results are displayed in natural language to facilitate user understanding. This display method may include converting the influencing fields into an easy-to-read text format. For example, the following description may be generated: "The sales field has a significant deviation from expectations and may be affected by the following factors: product category, region, and time." Such a description can directly point to the data columns that need further investigation or correction. Through the natural language display method, users can more intuitively identify and understand which fields may be the cause of data anomalies or query results that do not meet expectations. Based on this information, they can decide whether to adjust the original SQL statement, such as modifying the query logic, adjusting the field selection, or changing the data filtering conditions.
[0140] In this embodiment, the method provides an intuitive and efficient user interaction method by combining statistical analysis and natural language processing technology. Based on the statistical analysis results and natural language descriptions provided by the system, users can more accurately identify and understand anomalies and key influencing factors in the data, thereby making more informed correction decisions.
[0141] In one embodiment, Fig. 9 As shown, the interaction data includes an interaction data set U, a context data set C, and an industry knowledge base K; based on the interaction data and using the intention reasoning model, determining the user's interaction intention includes the following steps:
[0142] Step 901: Determine a behavior feature set based on the interaction data set U , determine the context feature set based on the context data set C , determine the industry feature set based on the industry knowledge base K ;
[0143] Specifically, for the user interaction data set , . Among them, each Represents a user's interactive behavior. For context data collection , . Among them, each Represents contextual information, such as business domain, user role, etc. For industry knowledge base , . Among them, each Represents an industry knowledge point, such as industry-specific operations, terminology, etc.
[0144] Determine the behavior feature set based on the interaction data set U , .in, Indicates the user interaction behavior Extracted features. Determine the context feature set based on the context data set C , .in, Indicates that from context information Extracted features. Determine the industry feature set based on the industry knowledge base K , .in, From the industry knowledge point Extracted features.
[0145] Step 902: Based on the behavior feature set , context feature set and industry feature sets , determine the input features ;
[0146] Specifically, the behavioral feature set , context feature set and industry characteristic sets Combined together to form input features . That is, the input feature .
[0147] It should be noted that the behavioral feature set Can include user behavior data, such as user clicks, input, and browsing habits; context feature collection Can contain contextual information related to user interaction, such as time, location, and device type; industry feature collection It can contain industry-specific expertise and terminology. The features in these three feature sets are combined to form the input features ,This input feature can reflect the user’s interaction intention at a specific time and environment, and takes into account the influence of the industry background.
[0148] Step 903: Input features Input the pre-trained intent inference model to obtain the user's interaction intention.
[0149] Specifically, the input features As input, it is input into a pre-trained intent inference model. The pre-trained intent inference model may have been trained on a large amount of labeled data and learned how to identify the user's intent from the features. The pre-trained intent inference model can predict the user's intent based on the input feature set. The pre-trained intent inference model receives the input features. After that, the input features can be analyzed and processed through its internal algorithms and learned parameters. The intent inference model can use machine learning techniques, such as classification algorithms, neural networks, or decision trees, to evaluate feature sets and output the most likely interaction intent.
[0150] For example, assume that there is a pre-trained intent inference model, including an output space Y, where Y contains all possible user intents, such as , each Represents a potential user intention. The inference function Infer in the intention inference model maps the input feature X to an intent in the output space Y. In the model training phase, a labeled dataset T is set, which contains multiple pairs of input features and corresponding user intentions.
[0151] in, ,in Each are input features, is the corresponding user intent. During the training process, the loss function L can be used to measure the difference between the prediction of the inference function Infer and the actual user intent, that is, , and adjust Infer through the optimization algorithm to minimize the loss function.
[0152] Extract features based on users' real-time interactive behavior and contextual information . You can use the trained inference function Infer to perform intent inference, that is, Suppose a user browses multiple camera models on an e-commerce website and checks their prices and user reviews. The user's behavioral features may include which cameras he browsed, the time he spent on each page, etc.; context features may include the time when the user visited the website, the device he used, etc.; industry features may include professional terms for cameras and key words in user reviews. Combining these features, the system obtains The inference function Infer predicts the user's possible intention based on these features. , such as "Looking for a cost-effective camera".
[0153] In this embodiment, the method can provide a comprehensive and accurate way to understand and predict the user's interaction intention. By combining the user's behavioral characteristics, contextual characteristics and industry characteristics, the method can capture multiple dimensions of user needs, making the intention reasoning model more accurate and reliable.
[0154] In one embodiment, the query result feature set , query result set , Represents a query result, a multi-dimensional feature set , multi-dimensional data set , Represents data of one dimension;
[0155] Similarity Matrix .
[0156] Specifically, the query result feature set and multi-dimensional feature sets , and their corresponding similarity matrix M. Query result feature set Each query result in the query result set Q The characteristic representation composition is ,in From the query results The query result set Q contains specific query results, namely , each Represents a single query result.
[0157] Multi-dimensional feature set Contains each dimension data in the multidimensional data set D The feature representation of ,in From the dimension data The multidimensional data set D consists of different dimensional data, namely , each Represents data of a different dimension.
[0158] The similarity matrix M is a matrix consisting of the similarities between these feature representations, and its size is n×m, where n is the number of query results and m is the number of dimensional data. Each element S( , ) indicates the query result characteristics and dimensional features Therefore, M can be expressed as:
[0159] .
[0160] In this embodiment, the method can quantify the similarity relationship between query results and multi-dimensional data, provide an accurate reference for data analysis and decision-making, and can quickly identify the multi-dimensional data most relevant to a specific query result, thereby providing users with more personalized and in-depth data analysis results.
[0161] Based on the same concept, the present application also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor determines a method for determining recommendation results based on user needs when executing the computer program.
[0162] In one embodiment, an electronic device is provided, including a memory and a processor. The electronic device may be a terminal, and its internal structure diagram may be as follows: Fig.10 As shown. The electronic device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the electronic device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a method for determining a recommendation result based on user needs is implemented. The display screen of the electronic device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the housing of the electronic device, or an external keyboard, touchpad or mouse, etc.
[0163] Those skilled in the art will understand that Fig.10 The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0164] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0165] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for determining recommendation results based on user needs, characterized in that: The method comprises: Obtaining user needs; wherein the needs are described in natural language; Determine the interaction data of the user based on the demand, and determine the interaction intention of the user based on the interaction data and using an intention reasoning model; By converting the interaction intention into an SQL statement, a query result set Q and a multi-dimensional data set D are obtained; wherein the query result set Q includes n query results, and the multi-dimensional data set D includes data of m dimensions; Perform feature extraction on the query results in the query result set Q to obtain a query result feature set F q , extract features from the multi-dimensional data in the multi-dimensional data set D to obtain a multi-dimensional feature set F d ; Wherein, the query result feature set F q includes n feature objects, the multi-dimensional feature set F d It includes m feature objects; Based on the query result feature set F q With the multi-dimensional feature set F d Determine a similarity matrix M, obtain an association analysis function A, and perform a multi-dimensional association analysis on the similarity matrix M through the association analysis function A to obtain a recommendation result set R; wherein the recommendation result set R includes k recommendation results, and the k recommendation results can form a multi-dimensional query result corresponding to the needs of the user.
2. The method for determining recommendation results based on user needs according to claim 1, characterized in that: Based on the query result feature set F q With the multi-dimensional feature set F d Determine the similarity matrix M, including: For the query result feature set F q Any feature object in and the multi-dimensional feature set F d Any feature object in the query result is determined by using the similarity function S. q Any feature object in and the multi-dimensional feature set F d The similarity between any feature objects in ; Based on the query result feature set F q The feature object in and the multi-dimensional feature set F d The similarity between the feature objects in is used to determine the similarity matrix M.
3. The method for determining recommendation results based on user needs according to claim 1, characterized in that: By converting the interaction intention, a query result set Q and a multi-dimensional data set D are determined, including: Semantically split the interaction intent based on the large language model and convert it into SQL statement results; The SQL statement result is modified, and based on the modified SQL statement result, a query result set Q and a multi-dimensional data set D are determined.
4. The method for determining recommendation results based on user needs according to claim 3, characterized in that: The SQL statement result is modified, and based on the modified SQL statement result, a query result set Q and a multi-dimensional data set D are determined, including: Obtaining a first modification operation of the user on the result of the SQL statement; Obtaining a second modification operation of the user on the SQL statement result; Based on the first correction operation and the second correction operation on the SQL statement result, a query result set Q and a multi-dimensional data set D are determined.
5. The method for determining recommendation results based on user needs according to claim 4, characterized in that: Obtaining a first modification operation of the user on the SQL statement result, including: Prompting at least part of the SQL statement results in at least one of the following ways: the first field is an attribute, the second field is a restriction, and the third field and the fourth field are required query results; By prompting at least part of the SQL statement result, a first correction operation of the user on the SQL statement result is obtained.
6. The method for determining recommendation results based on user needs according to claim 5, characterized in that: Obtaining a first modification operation of the user on the SQL statement result by prompting at least part of the SQL statement result includes: Obtaining a modified SQL statement result, wherein the modified SQL statement result is a modification of the SQL statement result by the user based on at least a portion of the prompt of the SQL statement result; Instructing to display the corrected SQL statement result graphically through at least one of the following interaction modes: voice interaction, text interaction, and file interaction; Obtaining the user's confirmation and adjustment of the revised SQL statement result by graphically displaying the revised SQL statement result; Based on the confirmation and adjustment of the user, a first correction operation of the user on the SQL statement result is obtained.
7. The method for determining recommendation results based on user needs according to claim 4, characterized in that: Obtaining a second modification operation of the user on the SQL statement result, including: Calculate the standard deviation of each column of data query results in the SQL statement result; Determine the dispersion of each column data query result according to the standard deviation, and determine the abnormal column data query result based on the dispersion; Using a correlation coefficient algorithm, calculate the correlation between the abnormal column data query result and other column data query results, and determine the affected fields in the SQL statement result based on the correlation; By displaying the affected fields in the SQL statement result in a natural language manner, a second modification operation of the user on the SQL statement result is determined.
8. The method for determining recommendation results based on user needs according to any one of claims 1 to 7, characterized in that: The interaction data includes an interaction data set U, a context data set C, and an industry knowledge base K; Determining the user's interaction intention based on the interaction data and using an intention inference model includes: Determine a behavior feature set based on the interaction data set U , determine the context feature set based on the context data set C , determine the industry feature set based on the industry knowledge base K ; Based on the behavioral feature set , context feature set and industry feature sets , determine the input features ; The input features A pre-trained intention inference model is input to obtain the interaction intention of the user.
9. The method for determining recommendation results based on user needs according to any one of claims 1 to 7, characterized in that: Query result feature set , query result set , Represents a query result, a multi-dimensional feature set , multi-dimensional data set , Represents data of one dimension; Similarity Matrix .
10. An electronic device, characterized in that: include: Memory for storing computer programs; A processor is used to execute the computer program, and when the computer program is executed by the processor, the steps of the method for determining recommendation results based on user needs as described in any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Retrieval method and device based on user requirements and electronic equipment
CN116244344A
Digital factory data query method, device, equipment, medium and product
CN119025618A