Data retrieval method based on output result automatic adjustment
By introducing an automatically adjusted data retrieval method in the data query system, combining user feedback and multiple influencing factors, dynamically adjusting the K and P values, the existing system's difficulties in balancing accuracy and efficiency are solved, and higher users are achieved Satisfaction and system adaptability.
Patent Information
- Application Number
- CN202411469678.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-02-07
AI Technical Summary
Existing data query systems are difficult to balance between pursuing the accuracy of output results and response speed, resulting in the inability to meet users' needs for both accuracy and speed, and the static parameter setting lacks flexibility and adaptability.
A data retrieval method that is automatically adjusted based on the output results is adopted. Through recall, accuracy, user satisfaction, query rate and query complexity as influencing factors, the corresponding weight is set, the objective function is established, and K is adjusted through user feedback. and P values to dynamically adjust the query results.
It realizes flexibility to adapt to different user needs and scenarios while ensuring output accuracy and efficiency, and improves user satisfaction and system competitiveness.
Smart Images

Figure CN119397074A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data retrieval, and in particular to a data retrieval method based on automatic adjustment of output results. Background Art
[0002] As the core technology of information retrieval, data query is crucial for quickly acquiring, analyzing and utilizing large amounts of data. In many fields such as business intelligence, scientific research, and medical diagnosis, effective data query can not only improve the quality of decision-making, but also promote knowledge discovery and innovation. An accurate and efficient data query system can ensure the relevance and accuracy of the output results while providing a fast response time, which is especially important for applications that need to process large-scale data sets. Output accuracy and computational efficiency are two key indicators for measuring the performance of a query system, which together determine the effectiveness of the system in practical applications and user satisfaction.
[0003] However, despite significant progress in data query technology, current systems still face the challenge of balancing output accuracy and computational efficiency. Existing query systems often find it difficult to achieve both high accuracy and high efficiency at the same time, resulting in the possibility of sacrificing response speed in pursuit of output accuracy, and vice versa. This imbalance makes it difficult for the system to meet users' demands for both accuracy and speed in practical applications. Currently, many systems rely on manually set fixed parameters to balance accuracy and efficiency. Although this method can reflect the pursuit of accuracy and efficiency to a certain extent, it lacks flexibility and adaptability and cannot be dynamically adjusted according to the user's specific needs and context. Therefore, this static parameter setting cannot truly represent the user's real needs, and also limits the performance of the query system in a variety of application scenarios.
[0004] In view of this, a data retrieval method that automatically adjusts based on the output results is needed. Summary of the invention
[0005] In view of the problem that the setting of the accuracy and efficiency of the retrieval output results in the prior art lacks flexibility and adaptability and cannot truly represent the real needs of users, the present invention provides a data retrieval method based on automatic adjustment of the output results, which can use the recall rate, accuracy, user satisfaction, query rate and query complexity as influencing factors, set corresponding weights, and establish an objective function by weighted summation. The objective function reflects the relationship between efficiency and accuracy, and user feedback is introduced in this process, that is, the final solution of the objective function can obtain a result that meets user needs and balances output accuracy and efficiency, thereby affecting factors such as the number of locked data tables and the number of output fields in the query retrieval. The specific technical scheme is as follows:
[0006] A data retrieval method based on automatic adjustment of output results comprises the following steps:
[0007] Obtain user query information, and after querying, select the K tables with the highest similarity from the database, calculate the similarity of the fields in the selected K tables, and sort the fields according to the calculation results. Then select the P fields with the highest similarity as the output of the user query;
[0008] Take recall rate, accuracy rate, user satisfaction, query rate and query complexity as influencing factors, set corresponding weights, establish the objective function through weighted summation, and set corresponding constraints;
[0009] Solve the objective function and obtain the number of output tables K and the number of fields P under the current weighted tendency of efficiency and accuracy.
[0010] Preferably, the objective function is as follows:
[0011] O(K,P)=ω1Rc(K,P)+ω2P(K,P)+ω3U(K,P)+ω4Ra(K,P)-ω5C(K,P);
[0012] Where O(K,P) is the objective function, ω1, ω2, ω3, ω4, and ω5 are weight coefficients, corresponding to the relative importance of recall, precision, user feedback, query rate, and complexity, respectively. Rc(K,P) is the recall given K and P, P(K,P) is the precision given K and P, U(K,P) is the user's satisfaction feedback on the retrieval results given K and P, C(K,P) is the query complexity given K and P, and Rc(K,P) is the query rate given K and P, which is the inverse of the average time of query execution.
[0013] Preferably, user satisfaction is reflected in the form of a score, as follows:
[0014]
[0015] In the formula, r i is the specific rating given by the user, and n is the total number of ratings collected.
[0016] Preferably, the user satisfaction is calculated as follows:
[0017]
[0018] In the formula, r i is the specific rating given by the user, and n is the total number of ratings collected.
[0019] Preferably, the constraint conditions include: the number of tables K and the number of fields P cannot exceed a set maximum value.
[0020] Preferably, query complexity includes the complexity of question understanding, the complexity of index retrieval and the complexity of field rearrangement; wherein, the complexity of question understanding involves the semantic understanding of natural language queries input by users, including entity recognition and intent recognition; the complexity of index retrieval involves the process of quickly locating relevant database tables and fields through vector indexes and keyword indexes; the complexity of field rearrangement involves similarity calculation and rearrangement of retrieved fields.
[0021] Preferably, the query complexity is defined as follows:
[0022] C(K,P)=k1·C1+k2·C2+k3·C3;
[0023] Among them, k1-k3 are weight coefficients used to balance the relative importance of the complexity of different steps. C1 is the complexity of question understanding, which is quantified by the number of entities involved in the query. C2 is the complexity of index retrieval, which is quantified by the number of retrieved tables K and the number of fields P. C3 is the complexity of field reordering, which is quantified by the number of operations required to calculate field similarity.
[0024] Preferably, it also includes: establishing a vector index, a keyword index, a field Chinese name index, an English name index, and an enumerated data index.
[0025] A computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the data retrieval method automatically adjusted based on output results as described above.
[0026] A processor is used to run a program, wherein the program executes the data retrieval method automatically adjusted based on output results as described above when the program is run.
[0027] Compared with the prior art, the present invention has the following beneficial effects:
[0028] Traditional data query and retrieval systems usually use fixed parameter settings, which are determined when the system is designed and are difficult to adjust according to changes in actual application scenarios. This static parameter setting may cause the system to perform poorly when facing different users or different query requirements, and cannot fully meet the user's needs for output accuracy and computing efficiency. In contrast, the present invention uses a solution that dynamically adjusts the K and P values to make the system more adaptable to different application scenarios and user needs. By analyzing the complexity of the query, user feedback and historical data in real time, the system can flexibly adjust its behavior to adapt to the current query environment. For example, the system can identify that the user prefers to obtain results quickly within a specific time period, even if it means sacrificing some output accuracy; in other cases, the user may be more concerned about the comprehensiveness and accuracy of the results, and the system can adjust the K and P values accordingly to meet this demand. This improvement in adaptability and flexibility can not only improve user satisfaction, but also enable the system to remain competitive in a highly competitive market. In general, the solution of dynamically adjusting the K and P values can provide more flexible and adaptable services, which can not only improve user satisfaction, but also enable the system to remain competitive in the face of a changing market and technical environment. As technology develops and user needs change, this ability of the system to adapt will be one of the key factors in its long-term success. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following is a brief introduction to the drawings required for the specific embodiments or the description of the prior art. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts are not necessarily drawn according to the actual scale.
[0030] Figure 1 The figure is a flow chart of the method of the present invention. DETAILED DESCRIPTION
[0031] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are 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.
[0032] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0033] It should also be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0034] It should be further understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0035] In one embodiment of the present invention, a data retrieval method based on automatic adjustment of output results is provided, such as Figure 1 As shown, the implementation steps are as follows:
[0036] S1: Establish vector index and keyword index. This includes vectorizing each table in the database, generating a vector representation of the table, and storing it in the index. It also includes establishing a keyword index for key information such as the table name and field name for quick retrieval.
[0037] S2: Create a Chinese name index, an English name index, and an enumeration data index for the field. Specifically, for each field in the table, create an index for the Chinese name and the English name to support Chinese and English query requirements. For enumeration type fields, create an index for the enumeration value to support fast retrieval of the enumeration value.
[0038] S3: Retrieve matching database tables through keyword filtering and vector indexing. Specifically: segment the questions entered by the user and extract keywords. Then use the keyword index to quickly filter out possible related database tables. Finally, use the vector index to calculate the similarity of the filtered tables and select the K tables with the highest similarity.
[0039] S4: Re-search the fields of the K data tables and select P fields. Specifically, perform similarity calculation on the fields of the selected K tables, sort the fields according to the calculation results, and then select the P fields with the highest similarity as the basis for generating SQL.
[0040] In the above process, the adjustment process of K and P is as follows:
[0041] Complexity can be used as a constraint or a regulating factor in the objective function to affect the optimal values of K and P. The basic idea is to minimize the complexity of the query while ensuring query accuracy and user satisfaction. The following is a formula for the optimization solution combined with complexity:
[0042] O(K,P)=ω1Rc(K,P)+ω2P(K,P)+ω3U(K,P)+ω4Ra(K,P)-ω5C(K,P);
[0043] Where O(K,P) is the objective function, ω1, ω2, ω3, ω4, and ω5 are weight coefficients, corresponding to the relative importance of recall, precision, user feedback, query rate, and complexity, respectively. Rc(K,P) is the recall given K and P, P(K,P) is the precision given K and P, U(K,P) is the user's satisfaction feedback on the retrieval results given K and P, C(K,P) is the query complexity given K and P, and Rc(K,P) is the query rate given K and P, which is the inverse of the average time of query execution.
[0044] Among them, the recall rate is the ratio of the number of correctly retrieved relevant results to the sum of the number of correctly retrieved relevant results and the number of failed relevant results; the accuracy rate is the ratio of the number of correctly retrieved relevant results to the sum of the number of correctly retrieved relevant results and the number of incorrectly retrieved results.
[0045] User satisfaction is reflected in the form of scores, as follows:
[0046]
[0047] In the formula, r i is the specific rating given by the user, and n is the total number of ratings collected.
[0048] Query complexity includes the complexity of question understanding, the complexity of index retrieval, and the complexity of field rearrangement. Among them, the complexity of question understanding involves the semantic understanding of the natural language query input by the user, including entity recognition, intent recognition, etc., reflecting the cognitive complexity required to understand the user query. The complexity of index retrieval involves the process of quickly locating relevant database tables and fields through vector indexes and keyword indexes, reflecting the operational complexity of retrieving relevant tables and fields through indexes. The complexity of field rearrangement involves similarity calculation and rearrangement of the retrieved fields to select the best field, reflecting the computational complexity of rearranging fields according to similarity.
[0049] The following defines a complexity function to quantify the complexity defined above:
[0050] C(K,P)=k1·C1+k2·C2+k3·C3;
[0051] Among them, k1-k3 are weight coefficients used to balance the relative importance of the complexity of different steps. C1 is the complexity of question understanding, which is quantified by the number of entities involved in the query. C2 is the complexity of index retrieval, which is quantified by the number of retrieved tables K and the number of fields P. C3 is the complexity of field reordering, which is quantified by the number of operations required to calculate field similarity.
[0052] The above objective function not only considers the accuracy, user satisfaction and complexity of the query, but also the rate of query execution. In this way, the model will pursue high efficiency and high performance at the same time when optimizing the values of K and P, thereby improving the response speed of the system while ensuring the query quality. The weight coefficient can be used to adjust the degree of influence of the rate in the objective function and adjust it according to actual business needs. In this way, the NL2SQL model can intelligently select the K and P that are most suitable for the current query, while taking into account the impact of user satisfaction, thereby improving the accuracy, efficiency and user satisfaction of retrieval. This method can dynamically adjust the values of K and P in combination with historical data, user feedback and query complexity to achieve the best retrieval effect.
[0053] Here is a specific example to illustrate the specific quantification of complexity, as shown below:
[0054] Suppose the user queries: "Find the names and total electricity consumption of the three cities with the highest electricity consumption in the past month."
[0055] Then, the complexity of problem understanding is as follows:
[0056] The query involves entities such as "city", "electricity consumption", and "month", and the number of predicates such as "highest" and "total electricity consumption" as the value of C1.
[0057] The complexity of index retrieval is as follows:
[0058] Assuming that 5 related tables and 20 related fields are retrieved, the value of C2 can be quantified as 25, or the number of retrieved tables and fields can be processed by other formaldehyde summation.
[0059] The complexity of field rearrangement is as follows:
[0060] Assume that 200 comparison operations are required to calculate the similarity and sort the 20 fields, which can be quantified as the value of C3 being 200*20, or the number of fields and the number of permutations can be calculated by other methods.
[0061] In addition, each complexity can be normalized.
[0062] Set constraints to constrain the objective function solution process, such as: the number of tables K and the number of fields P cannot exceed the set maximum value.
[0063] In one embodiment of the present invention, based on the above framework, another method for calculating user satisfaction is provided. It is used to adapt to the situation that user feedback exists in binary form, for example, the user may be satisfied with the result (positive feedback) or dissatisfied (negative feedback). In this case, a logistic function or a sigmoid function is used to convert these binary feedbacks into a continuous satisfaction score.
[0064] The general form of a logistic function is:
[0065]
[0066] Where x is the input value, which is usually related to user feedback. When x is positive, σ(x) is close to 1, indicating high satisfaction; when x is negative, σ(x) is close to 0, indicating low satisfaction.
[0067] If we consider user feedback as a rating i , then we can use the logistic function to convert this rating into a satisfaction measure between 0 and 1:
[0068]
[0069] Here, r i is a specific rating given by the user, or a rating derived from user behavior (such as clicks, purchases, dwell time, etc.). The formula normalizes these ratings into a continuous satisfaction measure that can be easily integrated with other model components.
[0070] Therefore, the exponential part of using 1 is to convert user feedback into a continuous satisfaction measure, which helps to understand and optimize user satisfaction in a more detailed way. This method is particularly useful in dealing with recommendation systems and user satisfaction evaluation with continuous feedback values.
[0071] In summary, existing technologies often rely on fixed parameters set manually to balance output accuracy and computational efficiency. This approach lacks flexibility and cannot adapt to the specific needs of different users or scenarios. In contrast, the scheme of dynamically adjusting K and P can be adjusted in real time according to factors such as query complexity, user feedback, and historical data to achieve a better balance. In the dynamic adjustment scheme, the system dynamically selects appropriate K and P values according to the complexity of the current query. For example, for a simple query, the system may select fewer tables (smaller K values) and fields (smaller P values) to improve query efficiency; while for a complex query, the system may select more tables and fields to ensure the comprehensiveness and accuracy of the output results. This dynamic adjustment strategy enables the system to maintain high performance and satisfaction in different situations. In addition, by introducing user feedback as a basis for adjusting K and P values, the system can learn user preferences and adjust its behavior based on these preferences. This means that the system can gradually adapt to user needs over time and provide more personalized services. For example, if a user is highly satisfied with a query result, the system can analyze the K and P values of the query and apply these values in similar queries in the future to improve user satisfaction. In general, the solution of dynamically adjusting K and P values can provide more flexible and adaptable services, which can not only improve user satisfaction, but also enable the system to remain competitive in the face of changing market and technical environments. As technology develops and user needs change, this adaptability of the system will become one of the key factors for its long-term success.
[0072] Those of ordinary skill in the art will appreciate that the units of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition of each example has been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0073] In the embodiments provided by the present invention, it should be understood that the division of units is only a logical function division, and there may be other division methods in actual implementation, for example, multiple units can be combined into one unit, one unit can be split into multiple units, or some features can be ignored, etc.
[0074] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0075] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-0nlyMemory), random access memory (RAM, RandomAccessMemory), mobile hard disk, magnetic disk or optical disk, etc., which can store program code.
[0076] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. These modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention, and they should all be included in the scope of the claims and specification of the present invention.
Claims
1. A data retrieval method based on automatic adjustment of output results, characterized in that: The following steps are involved: Obtain user query information, and after querying, select the K tables with the highest similarity from the database, calculate the similarity of the fields of the selected K tables, sort the fields according to the calculation results, and then select the P fields with the highest similarity as the output of the user query; Take recall rate, accuracy rate, user satisfaction, query rate and query complexity as influencing factors, set corresponding weights, establish the objective function through weighted summation, and set corresponding constraints; Solve the objective function and obtain the number of output tables K and the number of fields P under the current weighted tendency of efficiency and accuracy.
2. A data retrieval method based on automatic adjustment of output results according to claim 1, characterized in that: The objective function is as follows: O(K,P)=ω1Rc(K,P)+ω2P(K,P)+ω3U(K,P)+ω4Ra(K,P)-ω5C(K,P); Where O(K,P) is the objective function, ω1, ω2, ω3, ω4, and ω5 are weight coefficients, corresponding to the relative importance of recall, precision, user feedback, query rate, and complexity, respectively. Rc(K,P) is the recall given K and P, P(K,P) is the precision given K and P, U(K,P) is the user's satisfaction feedback on the retrieval results given K and P, C(K,P) is the query complexity given K and P, and Rc(K,P) is the query rate given K and P, which is the inverse of the average time of query execution.
3. A data retrieval method based on automatic adjustment of output results according to claim 1, characterized in that: User satisfaction is reflected in the form of scores, as follows: In the formula, r i is the specific rating given by the user, and n is the total number of ratings collected.
4. A data retrieval method based on automatic adjustment of output results according to claim 1, characterized in that: The user satisfaction is calculated as follows: In the formula, r i is the specific rating given by the user, and n is the total number of ratings collected.
5. A data retrieval method based on automatic adjustment of output results according to claim 2, characterized in that: The constraint conditions include: the number of tables K and the number of fields P cannot exceed the set maximum values.
6. A data retrieval method based on automatic adjustment of output results according to claim 1, characterized in that: Query complexity includes the complexity of question understanding, the complexity of index retrieval, and the complexity of field rearrangement; among them, the complexity of question understanding involves the semantic understanding of natural language queries input by users, including entity recognition and intent recognition; the complexity of index retrieval involves the process of quickly locating relevant database tables and fields through vector indexes and keyword indexes; the complexity of field rearrangement involves similarity calculation and rearrangement of retrieved fields.
7. A data retrieval method based on automatic adjustment of output results according to claim 6, characterized in that: The query complexity is defined as follows: C(K,P)=k1·C1+k2·C2+k3·C3; Among them, k1-k3 are weight coefficients used to balance the relative importance of the complexity of different steps. C1 is the complexity of problem understanding, quantified by the number of entities involved in the query; C2 is the complexity of index retrieval, quantified by the number of retrieved tables K and the number of fields P; C3 is the complexity of field reordering, quantified by the number of operations required to calculate field similarity.
8. A data retrieval method based on automatic adjustment of output results according to claim 1, characterized in that: It also includes: establishing vector index, keyword index, field Chinese name index, English name index, and enumeration data index.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the data retrieval method based on automatic adjustment of output results as described in any one of claims 1 to 8.
10. A processor, characterized in that: The processor is used to run a program, wherein when the program is run, the data retrieval method based on automatic adjustment of output results as described in any one of claims 1 to 7 is executed.