Problem positioning and solution strategy intelligent suggestion method based on data analysis
By constructing data security verification and correction guarantees for local language models and cloud processing processes, and automatically generating retail reports based on semantic understanding, the problem that existing technology cannot meet the business needs of different industries and groups is solved, and the reliability and flexibility of retail data are improved.
Patent Information
- Application Number
- CN202411651923.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-04-18
AI Technical Summary
The existing technology cannot meet the business needs of different industries and groups, resulting in the inability to accurately connect database screening instructions, and software development, adjustment and maintenance are difficult and costly.
Provide an intelligent suggestion method for problem positioning and solution strategies based on data analysis. It automatically analyzes user semantics by constructing a local language model, and provides data security verification and correction guarantees for cloud processing, and automatically generates retail reports based on semantic understanding.
Improve the reliability and flexibility of retail data, and achieve accurate connections to the business needs of different industries and groups by automatically analyzing user semantics and data security verification and correction guarantees.
Smart Images

Figure CN119848186A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of database statistical analysis, and in particular to a method for intelligently suggesting problem location and solution strategies based on data analysis. Background Art
[0002] In the retail industry, statistical management and analysis of various data on stores, warehouses, and commodities are information that corporate management must pay attention to every day. Existing technologies usually use predefined database screening instructions to present report data. Since predefined query instructions cannot meet the business needs of different industries and different groups of people, it is impossible to achieve accurate docking of different industries. Software companies need to continuously make development adjustments based on customer needs, which is difficult to maintain and has high development costs. Summary of the invention
[0003] The main technical problem solved by the present invention is to provide a method for intelligently suggesting problem location and solution strategies based on data analysis. It not only automatically analyzes user semantics by constructing a local language model, but also provides data security verification and correction protection for the cloud processing process, and automatically generates retail reports based on semantic understanding, thereby improving the reliability and flexibility of retail data.
[0004] In order to solve the above technical problems, a technical solution adopted by the present invention is to provide a method for intelligently suggesting problem location and solution strategies based on data analysis, comprising the following steps:
[0005] S1, design a question-answering sample dataset and train a local question-answering model. The question-answering sample dataset at least includes preset questions, specific keywords, database interfaces, and report pages; design several report templates, which at least include several database field names and database configuration information;
[0006] S2, obtain the input question and perform word segmentation to obtain several input keywords;
[0007] S3, the local question-answering model uses the Bayesian algorithm to match the input keywords with preset questions and calls the database interface to obtain intermediate data;
[0008] S4, present the intermediate data on the report page according to the report template; if the match fails, submit the input keywords and report template to the AI interface to obtain the SQL command generated by the cloud;
[0009] S5, filter out the SQL query command, verify the field in the database, and return to execute step S4 after the verification passes.
[0010] In a preferred embodiment of the present invention, the S5 check field is performed using the following method:
[0011] Generate the first comparison item: use the map structure to store the database field names defined in the report template;
[0012] Generate the second comparison item: Use the SQL text parsing tool to extract all the fields in the SELECT clause and WHERE clause in the SQL statement returned by the AI interface, as well as the table name in the FROM clause;
[0013] Compare the first comparison item with the second comparison item and output a verification result.
[0014] In a preferred embodiment of the present invention, when the verification fails, S5 further includes an SQL correction method:
[0015] Search all report templates for the illegal fields mentioned in the SQL query command. If any result is found, add an external link reference to the report template where the illegal field is located in the SQL query command; otherwise, call the similarity algorithm to match the field with the highest similarity from all report templates and replace the illegal field.
[0016] The beneficial effects of the present invention are as follows: the present invention provides a method for intelligently suggesting problem location and solution strategies based on data analysis, which not only automatically analyzes user semantics by constructing a local language model, but also provides data security verification and correction protection for cloud processing processes, and automatically generates retail reports based on semantic understanding, thereby improving the reliability and flexibility of retail data. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work, among which:
[0018] Figure 1 It is a flow chart of a method for intelligently suggesting problem location and solution strategies based on data analysis of the present invention. DETAILED DESCRIPTION
[0019] The technical solutions in the embodiments of the present invention are described clearly and completely below. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0020] like Figure 1 As shown, the embodiment of the present invention includes:
[0021] A method for intelligently suggesting problem location and solution strategies based on data analysis, comprising the following steps:
[0022] S1, design a question-answering sample dataset and train a local question-answering model. The question-answering sample dataset at least includes preset questions, specific keywords, database interfaces, and report pages; design several report templates, which at least include several database field names and database configuration information;
[0023] The following is an example of a sample question and answer dataset:
[0024]
[0025] S2, obtain the input question and perform word segmentation to obtain several input keywords;
[0026] Call the natural language model to segment the text into independent words, extract keywords such as "store", "today", "sales", "situation", and "how" from the word segmentation results (word segmentation algorithm), and query whether there are matching keywords in the internal list, such as the matched keywords: "store", "today", and "sales".
[0027] S3, the local question-answering model uses the Bayesian algorithm to match the input keywords with preset questions and calls the database interface to obtain intermediate data;
[0028] Use the Bayesian algorithm to sort the matched keywords "store", "today", and "sales" and adjust the dynamic priority. Specifically:
[0029] first,
[0030] The probability of the keyword "store" appearing in the internal list of question 1 is calculated using the leaf probability P(B1|A1);
[0031] The probability of the keyword "store" appearing in the internal list in question 2 is calculated using the leaf probability P(B1|A2);
[0032] …
[0033] The probability of the keyword "store" appearing in question n in the internal list is calculated using the probability P(B1|An).
[0034] then,
[0035] The probability of the keyword "today" appearing in question 1 in the internal list is calculated using the leaf probability P(B2|A1);
[0036] The probability of the keyword "today" appearing in question 2 in the internal list is calculated using the leaf probability P(B2|A2);
[0037] …
[0038] The probability of the keyword "today" appearing in question n in the internal list is calculated using the probability P(B2|An).
[0039] in addition,
[0040] The probability of the keyword "sales" appearing in question 1 in the internal list is calculated using the leaf probability P(B3|A1);
[0041] The probability of the keyword "sales" appearing in question 2 in the internal list is calculated using the leaf probability P(B3|A2);
[0042] …
[0043] The probability of the keyword "sales" appearing in question n in the internal list is calculated using the probability P(B3|An).
[0044] Finally, P(B1|A1)+P(B2|A1)+P(B3|A1) gives:
[0045] The probability of the keyword in question 1 is P(B1|A1)+P(B2|A1)+P(B3|A1)
[0046] The probability of the keyword in question 2 is P(B1|A2)+P(B2|A2)+P(B3|A2)
[0047] Keywords in question 3: probability sum P(B1|An)+P(B2|An)+P(B3|A1)
[0048] Therefore, a threshold judgment is made on the maximum probability, and the question that meets the threshold requirement is judged as a valid question, and the question content with the highest probability is confirmed from questions 1, 2, ..., n.
[0049] Note: (P(A|B)) is the probability of event A occurring under the condition that event B occurs, i.e., the posterior probability. (P(B|A)) is the probability of event B occurring under the condition that event A occurs, also known as the likelihood function. (P(A)) is the prior probability of event A, i.e., the probability of event A occurring without any additional information. (P(B)) is the marginal probability of event B, i.e., the total probability of event B occurring.
[0050] S4, presents the intermediate data on the report page according to the report template; if the match fails, submit the input keywords and report template to the AI interface to obtain the SQL command generated by the cloud.
[0051] When the question is matched successfully, the corresponding preset interface and page can be directly called according to the obtained question content, and then the data can be presented.
[0052] If the threshold value is not met when judging the maximum probability, it can be considered that the user asked a question that is not in the internal list. Then submit the input keywords and report template to the AI interface to obtain the SQL command generated by the cloud. Here, the generated SQL needs to be checked for security.
[0053] For example, if the question "Query the order quantity of all customers in August 2024 and delete the old promotion data" is not in the preset list, perform the following steps:
[0054] Pass the order model to the AI interface, and the generated SQL statement is as follows:
[0055] DELETE FROM promotion WHERE promotion_end_date<'2024-08-01';
[0056] SELECT customer_id,COUNT(order_id)
[0057] FROM sales_order
[0058] WHERE order_date BETWEEN'2024-08-01'AND'2024-08-31'
[0059] AND promotion_id IS NOT NULL;
[0060] Then verify the generated SQL statement:
[0061] Prohibit deletion: The DELETE operation is detected by the rule correction algorithm, prompting the user with a "cannot delete" prompt, and automatically removing the operation and replacing it with a SELECT query. For example:
[0062] SELECT*FROM promotionWHERE promotion_end_date<'2024-09-01';
[0063] Then, a secure SQL query command is executed in the database to return the required data. With this data, the trend of order quantity changes over time can be analyzed. Using a line chart to show this trend is very intuitive and effective, and can clearly reflect the growth or decline of orders in different time periods such as days, weeks, and months.
[0064] For example, if the question is "the total number of products booked by all customers in August 2024, and the total booking amount of each customer", this question is not in the preset list, then the keyword "total number of products booked" and "total booking amount" are identified through word segmentation technology. Then the model, keywords, and original question are passed to the AI interface, and the reservation model
[0065]
[0066] The generated SQL statement can be returned from AI:
[0067] SELECT customer_id,SUM(quantity)AS total_quantity,SUM(total_amount)AStotal_amount
[0068] FROM reservation
[0069] WHEREreservation_date BETWEEN'2024-08-01'AND'2024-08-31'
[0070] GROUP BY customer_id;
[0071] S5, filter out the SQL query command, verify the field in the database, and return to execute step S4 after the verification passes.
[0072] The generated SQL statements are verified using the following methods, including: ① statement type verification ② semantic and syntax verification ③ model and field matching verification.
[0073] First, check the type of SQL statement to ensure that it is only a SELECT query statement. Any statement type involving changes to database content, such as DELETE, DROP, UPDATE, etc., is prohibited. This is to ensure the integrity and security of the database and avoid unauthorized changes.
[0074] Secondly, call the SQL text parsing tool to parse the various parts of the SQL statement and check whether the references in the SELECT clause and the FROM clause match. Specifically, analyze the fields referenced in the SELECT or WHERE clause and confirm whether these references exist in the FROM clause.
[0075] In addition, the model name (reservation) and field names (reservation_id, Customer_id, Product_id Reservation_date, Quantity, Total_amount) defined by the model (such as the reservation model mentioned above) are stored in a Map structure. Then, the SQL text parsing tool is used to extract all the fields in the SELECT clause and WHERE clause in the SQL statement returned by AI, as well as the table name in the FROM clause. The model name and field name integrated in the Map structure are compared with the table name and field in the SQL statement returned by AI to ensure that the model name and field name referenced in the SQL statement returned by AI match the model structure of the actual database.
[0076] The S5 check field is performed in the following manner:
[0077] Generate the first comparison item: use the map structure to store the database field names defined in the report template;
[0078] Generate the second comparison item: Use the SQL text parsing tool to extract all the fields in the SELECT clause and WHERE clause in the SQL statement returned by the AI interface, as well as the table name in the FROM clause;
[0079] Compare the first comparison item with the second comparison item and output a verification result.
[0080] Furthermore, when the verification fails, S5 also includes a SQL correction method:
[0081] Search all report templates for the illegal fields mentioned in the SQL query command. If any result is found, add an external link reference to the report template where the illegal field is located in the SQL query command; otherwise, call the similarity algorithm to match the field with the highest similarity from all report templates and replace the illegal field.
[0082] After the user asks a question, the question content is segmented to generate keywords, and then the Bayesian algorithm is used to calculate the probability of the keywords in the preset questions and the probability of the keywords appearing in the model library. The preset questions here are pre-designed local question-answering questions. After the Bayesian calculation, the results are threshold judged. The input content that meets the threshold requirements can be judged as hitting the preset question. According to the preset content in the question-answering sample data set, the report page interface is directly called to present the query results of the corresponding business model. The business model here refers to the database structure and its corresponding business processing methods designed to match business needs, such as the reservation model mentioned above.
[0083] If the Bayesian probability of the input question after word segmentation does not meet the threshold requirement, that is, it is considered that there is no matching content for this question locally, then Bayesian is further used to calculate the probability of the keyword appearing in all business models. For example, a reservation model is designed to handle the needs of reservation business, and an order model is designed to handle the needs of order business... Related business models can also include product models, membership models, etc.
[0084] Then, from the probability data obtained by Bayesian calculation, the business model with the most probable keyword is selected. Then, the business model, the corresponding keywords, and the corresponding original input questions are sent to the cloud AI big model for processing through the AI interface to generate the required SQL statements.
[0085] The generated results returned, that is, the SQL statements generated by AI, need to be verified in three aspects:
[0086] ① Verify the legal operations in the statement, that is, call the SQL correction module to filter out SELECT operations and eliminate other non-SELECT operations.
[0087] ② Check whether the referenced field exists in the business model, that is, call the SQL correction module to verify whether the reference exists: When the field involved in the query is not found in the corresponding business model, for example, the customer_name field is missing in the order model, traverse other business models, such as the reservation model, product model, membership model, etc., and find the customer_name field. Then adjust the JOIN condition in the SELECT statement, establish a database association, and make the entire SELECT statement legally referenced.
[0088] ③ Check whether the referenced field exists in the business model, that is, call the SQL correction module to verify whether the reference exists: When the field involved in the query is not found in "all" business models, it is necessary to determine whether there is a spelling error in the field name, that is, store the model name (such as reservation) and field name (reservation_id, Customer_id Product_id, Reservation_date, Quantity, Total_amount) defined by the business model (such as the reservation model) in a Map structure.
[0089] Then, use the SQL text parsing tool to extract all the fields in the SELECT clause and WHERE clause in the SQL statement returned by AI, as well as the table name in the FROM clause. Compare the model name and field name integrated in the Map structure with the table name and field in the SQL statement returned by AI to ensure that the model name and field name referenced in the SQL statement returned by AI match the model structure of the actual database.
[0090] In this process, the SQL correction module needs to be called to determine that if the fields referenced in the generated SQL statement are inconsistent with the model structure definition, the string similarity algorithm will be used (to calculate the similarity of two strings, by decomposing the two strings and then dividing the size of the intersection by the size of the union to obtain the similarity value. That is, the formula is used: Make corrections.
[0091] For example, the generated prodcut_id(A) (wrong spelling) is automatically corrected to product_id, where A represents the field that cannot be matched, such as prodcut_id, and B represents all fields in the model. A and B use the above formula to calculate the similarity value, take the maximum value, and replace the field that is greater than the threshold. In this way, you can get the correct SQL command, and use the correct SQL command to call the interface to display the data results.
[0092] The following is a further introduction to the automated field matching and correction mechanism. When verifying the existence of a field, the fields in the SQL statement are divided into different levels of matching, strict matching and fuzzy matching. The specific steps are as follows:
[0093] ① Strict match: directly compare the field name in the SQL with the field name in the Map structure to see if they are completely consistent. If they are consistent, the verification passes.
[0094] ② Fuzzy matching: If strict matching fails, it will switch to fuzzy matching, use the string similarity algorithm to calculate the similarity (Jaccard similarity coefficient), and set the similarity threshold (for example, above 0.8) to determine whether it is a possible spelling error. If the threshold is reached, it will be automatically corrected.
[0095] Through the hierarchical matching mechanism introduced above, the system can flexibly deal with spelling errors while strictly controlling field consistency. This not only improves the intelligence level of field verification, but also avoids query interruption or failure that may be caused by an overly strict field matching mechanism.
[0096] For example, first the user enters text to query: "Query the sales quantity and current inventory of product number 12345 in October."
[0097] Then perform preliminary SQL generation and field parsing:
[0098] inventory_data model
[0099]
[0100] Generate preliminary SQL statements through the AI interface:
[0101] SELECT product_id,sales_quantity,stock_level FROM inventory_dataWHERE product_id=12345AND sale_date BETWEEN'2024-10-1'AND'2024-10-31';
[0102] Then do a field existence check:
[0103] (1) The system traverses and checks the fields in the inventory_data table and finds that the field sale_date does not exist in the table.
[0104] (2) The system enters the fuzzy matching process and searches for similar fields in the Map structure. It finds that there is a date field sale_date in the inventory_data table that is very close to sales_date.
[0105] Then perform similarity calculation and automatic correction:
[0106] (1) The system uses a string similarity algorithm (Jaccard similarity) to calculate:
[0107] ① Preprocessing: Use the string segmentation method to split each field name into letters and get ['s','a','l','e','s','d','a','t','e'] and ['s','a','l','e',,'d','a','t','e'].
[0108] ②Calculate the Jaccard similarity coefficient:
[0109] A'=['s','a','l','e','s','d','a','t','e']
[0110] B'=['s','a','l','e',,'d','a','t','e']
[0111] |A'∩B'|=8 (there are 's','a','l','e',,'d','a','t','e')
[0112] |A'∪B'|=9 (there are 's', 'a', 'l', 'e', 's', 'd', 'a', 't', 'e')
[0113] Therefore, the Jaccard similarity coefficient is 0.89
[0114] (2) The Jaccard similarity coefficient is 0.89, which exceeds the set threshold (0.8). The system replaces sale_date in the SQL statement with sales_date and generates a corrected SQL.
[0115] After that, SQL modification and verification are performed. The modified SQL statement is as follows:
[0116] SELECT product_id,sales_quantity,stock_level FROM inventory_dataWHERE product_id=12345AND sales_date BETWEEN'2024-10-1'AND'2024-10-31';
[0117] The system verifies the corrected SQL statement. After verification, the SQL statement is submitted for execution.
[0118] Finally, the execution result is obtained. The system executes the SQL statement and returns the result, which shows the sales quantity and current inventory level of product number 12345 in October. Users can understand the sales status of the product through the results and decide whether to replenish the stock in time.
[0119] In summary, the present invention provides a method for intelligently suggesting problem location and solution strategies based on data analysis. It not only automatically analyzes user semantics by constructing a local language model, but also provides data security verification and correction protection for the cloud processing process, and automatically generates retail reports based on semantic understanding, thereby improving the reliability and flexibility of retail data.
[0120] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for intelligently suggesting problem location and solution strategies based on data analysis, characterized in that: The following steps are involved: S1, design a question-answering sample dataset and train a local question-answering model. The question-answering sample dataset at least includes preset questions, specific keywords, database interfaces, and report pages; design several report templates, which at least include several database field names and database configuration information; S2, obtain the input question and perform word segmentation to obtain several input keywords; S3, the local question-answering model uses the Bayesian algorithm to match the input keywords with preset questions and calls the database interface to obtain intermediate data; S4, present the intermediate data on the report page according to the report template; if the match fails, submit the input keywords and report template to the AI interface to obtain the SQL command generated by the cloud; S5, filter out the SQL query command, verify the field in the database, and return to execute step S4 after the verification passes.
2. The method for intelligently suggesting problem location and solution strategies based on data analysis according to claim 1, characterized in that: The S5 check field is performed in the following manner: Generate the first comparison item: use the map structure to store the database field names defined in the report template; Generate the second comparison item: Use the SQL text parsing tool to extract all the fields in the SELECT clause and WHERE clause in the SQL statement returned by the AI interface, as well as the table name in the FROM clause; Compare the first comparison item with the second comparison item and output a verification result.
3. The method for intelligently suggesting problem location and solution strategies based on data analysis according to claim 1 is characterized in that: When the verification fails, S5 also includes a SQL correction method: Search all report templates for the illegal fields mentioned in the SQL query command. If any result is found, add an external link reference to the report template where the illegal field is located in the SQL query command; otherwise, call the similarity algorithm to match the field with the highest similarity from all report templates and replace the illegal field.
4. The method for intelligently suggesting problem location and solution strategies based on data analysis according to claim 1, characterized in that: The step S5 also includes determining a threshold value of the number of verification failures, and providing a failure notification to the user when the threshold value is reached.