A data query method, device, equipment and medium
Patent Information
- Application Number
- CN202610842663.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-10
- Publication Date
- 2026-09-18
AI Technical Summary
[0004]本发明提供一种数据查询方法、装置、计算机设备及介质,以解决如何对数据库的查询过程进行优化,以提高查询的准确性的问题
[0009] In the above-mentioned data query method, apparatus, computer equipment, and storage medium, upon receiving a query request, the query request is converted into a query statement. Based on a preset index, the query statement is matched with each index data in a preset database to obtain a group of index data that meets the matching conditions. Entity parsing is performed on the query statement to obtain the target entity in the query statement. Field parsing is performed on each index data in the index data group to obtain the field attributes and field values corresponding to each index data. Based on the field attributes, field values, and target entities in the query statement, an alignment score representing the closeness between each index data and the target entity in the query statement, and a coverage score representing the coverage of each index data to the target entity in the query statement are calculated. The index score when each index data is matched with the query statement is obtained. The index score, alignment score, and coverage score of each index data are weighted and summed to obtain the summation result of each index data. The summation results of all index data are sorted to obtain the sorting result. The top K index data in the sorting result are determined. Based on a preset large language model, the query statement is matched with the K index data to obtain the target index data.
Smart Images

Figure CN122777577A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data query technology, and can be applied to the fields of financial technology and healthcare. In particular, it relates to a data query method, apparatus, device, and medium. Background Technology
[0002] With the rapid development of information technology and the growth of data scale, data querying plays an increasingly crucial role in various business systems. In existing technologies, data can typically be retrieved from a database based on query conditions using the corresponding indexing algorithm. For example, in the electronic medical record retrieval scenario in the healthcare field, the system uses indexing algorithms to match and return corresponding entries in the medical record database based on query conditions such as the doctor's input diagnosis code or drug name. In the insurance claims underwriting query scenario in the fintech field, the system uses indexing algorithms to query and return corresponding coverage, sum insured, deductible, and historical claims records based on query conditions such as the user's input policy number, ID number, or historical records. However, in practical applications, the above-mentioned index-based querying methods still have certain shortcomings. When the query conditions are broad or the query algorithm itself has limitations, the indexed results often contain a large amount of data, which may be mixed with a large amount of index data that has low or no relevance to the user's true intent. Users need to sift through the massive amount of returned data one by one, which not only leads to low query efficiency but also easily misses key information, resulting in poor overall query accuracy.
[0003] Therefore, optimizing the database query process to improve query accuracy has become an urgent problem to be solved. Summary of the Invention
[0004] This invention provides a data query method, apparatus, computer equipment, and medium to address the problem of how to optimize the database query process to improve query accuracy.
[0005] Firstly, a data query method is provided, including: Upon receiving a query request, the query request is converted into a query statement. Based on a preset index, the query statement is matched with each index data in the preset database to obtain a group of index data that meets the matching conditions. The query statement is parsed to obtain the target entity in the query statement. Each index data in the index data group is parsed to obtain the field attributes and field values corresponding to each index data. Based on the field attributes, field values, and target entities in the query statement corresponding to each index data, calculate the alignment score, which represents the proximity of each index data to the target entity in the query statement, and the coverage score, which represents the coverage of each index data to the target entity in the query statement. Obtain the index score when each index data is matched with the query statement, perform a weighted summation of the index score, alignment score and coverage score of each index data to obtain the summation result of each index data, and sort the summation results of all index data to obtain the sorting result; The top K index data in the sorting results are determined. Based on a preset large language model, the query statement and the K index data are matched to obtain the target index data, where K is an integer greater than zero.
[0006] Secondly, a data query device is provided, comprising: The first index module is used to convert the query request into a query statement when a query request is received, and to match the query statement with each index data in the preset database based on the preset index to obtain a group of index data that meets the matching conditions. The parsing module is used to perform entity parsing on the query statement to obtain the target entity in the query statement, and to perform field parsing on each index data in the index data group to obtain the field attributes and field values corresponding to each index data. The first calculation module is used to calculate an alignment score, which represents the closeness between each index data and the target entity in the query statement, and a coverage score, which represents the coverage of each index data to the target entity in the query statement, based on the field attributes, field values, and target entities in the query statement corresponding to each index data. The sorting module is used to obtain the index score when each index data is matched with the query statement, perform a weighted summation of the index score, alignment score and coverage score of each index data to obtain the summation result of each index data, and perform sorting on the summation results of all index data to obtain the sorting result; The filtering module is used to determine the top K index data in the sorting results, and to match the query statement with the K index data based on a preset large language model to obtain the target index data, where K is an integer greater than zero.
[0007] Thirdly, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described data query method.
[0008] Fourthly, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the steps of the above-described data query method.
[0009] In the above-mentioned data query method, apparatus, computer equipment, and storage medium, upon receiving a query request, the query request is converted into a query statement. Based on a preset index, the query statement is matched with each index data in a preset database to obtain a group of index data that meets the matching conditions. Entity parsing is performed on the query statement to obtain the target entity in the query statement. Field parsing is performed on each index data in the index data group to obtain the field attributes and field values corresponding to each index data. Based on the field attributes, field values, and target entities in the query statement, an alignment score representing the closeness between each index data and the target entity in the query statement, and a coverage score representing the coverage of each index data to the target entity in the query statement are calculated. The index score when each index data is matched with the query statement is obtained. The index score, alignment score, and coverage score of each index data are weighted and summed to obtain the summation result of each index data. The summation results of all index data are sorted to obtain the sorting result. The top K index data in the sorting result are determined. Based on a preset large language model, the query statement is matched with the K index data to obtain the target index data.
[0010] The process involves retrieving an index data group from a pre-defined database based on a pre-defined index. Then, it uses a combination of matching scores, similarity scores, alignment scores, and coverage scores to precisely sort and filter all index data within the group. This effectively filters out index data with low relevance to the query intent. After sorting and filtering, a pre-defined large language model is used to select the most relevant index data from K index data based on the query statement. This three-tiered, progressive processing architecture—index retrieval, sorting and filtering, and language model selection—refines the data range step-by-step based on the large amount of data returned by index retrieval, ultimately returning the most relevant and accurate index data to the user without presenting a large number of records with low relevance or semantic ambiguity. This improves the accuracy of data queries and enhances the user experience. Attached Figure Description
[0011] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. 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 effort.
[0012] Figure 1This is a schematic diagram of an application environment for a data query method provided in Embodiment 1 of the present invention; Figure 2 This is a flowchart illustrating a data query method provided in Embodiment 2 of the present invention; Figure 3 This is a flowchart illustrating a data query method provided in Embodiment 3 of the present invention; Figure 4 This is a flowchart illustrating a data query method provided in Embodiment 4 of the present invention; Figure 5 This is a flowchart illustrating a data query method provided in Embodiment 5 of the present invention; Figure 6 This is a schematic diagram of a data query device provided in Embodiment Six of the present invention; Figure 7 This is a schematic diagram of the structure of a computer device provided in Embodiment 7 of the present invention. Detailed Implementation
[0013] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0014] The data query method based on artificial intelligence provided in Embodiment 1 of this invention can be applied to, for example... Figure 1 The invention pertains to a server-side application environment. The server connects to a database and a client. The client communicates with the server via a network. The server receives query requests from the client and sends queries to a pre-defined database. The client can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster consisting of multiple servers. The invention will be described in detail below through specific embodiments.
[0015] For example, in the insurance claims underwriting query scenario in the fintech field, the server receives a query request sent by the claims reviewer's client, such as "users who purchased critical illness insurance last year and were hospitalized this year due to heart disease." This request is converted into a query statement. Based on preset keyword and vector indexes, keyword matching and similarity matching are performed in the policy database to obtain policy data groups that meet the conditions. Entity parsing is performed on the query statement to extract target entities such as "last year," "critical illness insurance," "this year," "heart disease," and "hospitalization." Field parsing is performed on the recalled policy data to obtain field attributes and corresponding values such as the insured product, insurance time, the disease of occurrence, and claims records. Alignment score (e.g., the similarity between "critical illness insurance" and the insured product field) and coverage score (e.g., the proportion of the target entity appearing in the policy records) are calculated for each policy data point. The matching score or vector similarity score of each policy data point during index matching is obtained. These scores are then weighted and summed with the alignment score and coverage score, and the data is sorted. The top K policy data points are selected. The original query statement and K policy data are input into the large language model, and the model outputs the most matching policy data as the final underwriting reference result.
[0016] Please see Figure 2 As shown, Figure 2 This is a flowchart illustrating a data query method provided in Embodiment 2 of the present invention, which is applied to... Figure 1 Taking the server-side as an example, the steps are as follows: S21: Upon receiving a query request, the query request is converted into a query statement. Based on the preset index, the query statement is matched with each index data in the preset database to obtain a group of index data that meets the matching conditions.
[0017] In this embodiment, a query request can refer to a data query instruction initiated by a user through a client, a query statement can refer to a retrieval expression that can be recognized and processed by an index after processing the query request, a preset index can refer to a data structure pre-built based on structured data records in a database for data matching queries, a preset database is used to store index data, index data can refer to structured data records, matching conditions can refer to preset rules or thresholds used to determine whether there is a correlation between the query statement and the index data, and an index data group can refer to a collection of index data that meets the matching conditions.
[0018] For example, in the electronic medical record retrieval scenario in the healthcare field, when a client requests a query for "medical records of patients hospitalized for diabetes last year", the natural language query request can be converted into a query statement containing keywords such as "diabetes", "hospitalization", and "last year". Based on a preset index, the query statement is matched in the electronic medical record database to obtain multiple medical record index data that meet the matching conditions. These multiple medical record index data that meet the matching conditions are then formed into an index data group.
[0019] S22: Perform entity parsing on the query statement to obtain the target entity in the query statement. Perform field parsing on each index data in the index data group to obtain the field attributes and field values corresponding to each index data.
[0020] S23: Based on the field attributes, field values, and target entities in the query statement corresponding to each index data, calculate the alignment score, which represents the closeness between each index data and the target entity in the query statement, and the coverage score, which represents the coverage of each index data to the target entity in the query statement.
[0021] In this embodiment, field attributes and field values are in one-to-one correspondence. The target entity can refer to keywords or phrases with specific semantic meanings extracted from the query statement, used to characterize the core object or condition of the user's query. For example, in the query statement "find patients who purchased critical illness insurance last year and were hospitalized this year due to heart disease", the target entity can include "last year", "critical illness insurance", "heart disease", "hospitalization", etc. Field attributes can refer to the names or labels of various data fields in the index data, used to identify the category of information stored in the field. Field values can refer to the specific data content corresponding to the field attributes. For example, for a field with the field attribute "diagnosis result", its corresponding field value can be "heart disease", and for a field with the field attribute "insurance time", its corresponding field value can be "2024-03-15".
[0022] Specifically, entity parsing is performed on the query statement to determine the target entity in the query statement. Field parsing is performed on each index data in the index data group to obtain the field attributes and field values of the corresponding index data. Based on each field attribute, the field value of the corresponding field attribute, and the target entity in the query statement, an alignment score representing the closeness between each index data and the target entity in the query statement and a coverage score representing the coverage of each index data to the target entity in the query statement are calculated.
[0023] S24: Obtain the index score when each index data is matched with the query statement, perform a weighted summation of the index score, alignment score and coverage score of each index data to obtain the summation result of each index data, and sort the summation results of all index data to obtain the sorted result.
[0024] In this embodiment, the index score can refer to the score calculated during the matching of query statements based on preset indexes, which is used to characterize the degree of association between index data and query statements. The summation result can refer to the score obtained by weighted summation of the index score, alignment score and coverage score of the same index data. The sorting result can refer to the result of sorting all index data in the index data group based on the summation result.
[0025] Specifically, during the matching process of query statements in the database based on preset indexes, the index score between each index data in the index data group and the query statement is obtained. For any index data, the index score, alignment score and coverage score corresponding to the index data can be weighted and summed based on preset weights to obtain the summation result of the index data. Based on the summation result of all index data in the index data group, all index data in the index data group are sorted to obtain the sorting result.
[0026] S25: Determine the top K index data in the sorting results, and match the query statement with the K index data based on the preset large language model to obtain the target index data.
[0027] In this embodiment, K is an integer greater than zero. The preset large language model can refer to a deep learning model that has been pre-trained on a large corpus and has the ability to understand and generate natural language. The preset large language model can output the target index data that is semantically most consistent with the input query statement and K index data.
[0028] Specifically, based on the sorting results, the top K index data corresponding to the summation results are determined. The query statement and the K index data are input into a preset large language model, and the target index data is output.
[0029] Optionally, preset suggestion words can be obtained, and the query statement and K index data can be matched based on the preset suggestion words through a preset large language model to obtain the target index data.
[0030] Among them, preset prompt words can refer to structured instruction text used to guide the large language model to perform tasks according to a specific format or rule. For example, preset prompt words can clearly define the role of the preset large language model as a precise data retrieval assistant, requiring it to select the most matching item from the list of numbers based solely on the user's query statement, and forcibly output a single number (such as "3") or "0" (indicating no match), strictly prohibiting any explanatory text, thereby ensuring that the output can be reliably parsed by the program.
[0031] In this embodiment, after retrieving the index data group from the database based on a preset index, all index data in the index data group are precisely sorted and filtered by comprehensively considering matching score, similarity score, alignment score, and coverage score. This effectively filters out index data with low relevance to the query intent. After sorting and filtering, the most target index data is further selected from K index data based on the query statement using a preset large language model. Through a three-level progressive processing architecture of index retrieval, sorting and filtering, and language model selection, the data range can be refined step by step based on the large amount of data returned by index retrieval, ultimately returning the most relevant and accurate index data to the user without presenting the user with a large number of records with low relevance or semantic ambiguity, thereby improving the accuracy of data query and user experience.
[0032] like Figure 3 The diagram shows a flowchart of a data query method provided in Embodiment 3 of the present invention. Step S23, which calculates an alignment score representing the proximity of each index data point to the target entity in the query statement and a coverage score representing the coverage of each index data point to the target entity in the query statement, based on the field attributes, field values, and target entities in the query statement corresponding to each index data point, may include the following steps: S31: For any index data, calculate an alignment score that represents the degree of closeness between each target entity in the query statement and the field value of the corresponding field attribute in the index data, based on the field attributes in the index data, the field values of the corresponding field attributes, and the target entities in the query statement.
[0033] S32: The alignment scores between all target entities in the query statement and the corresponding field values in the index data are weighted and calculated to obtain an alignment score that represents the degree of closeness between the index data and the target entities in the query statement.
[0034] S33: Calculate the intersection between all target entities in the query statement and all field attributes in the index data. Based on the intersection and all target entities in the query statement, calculate the coverage score, which represents the degree of coverage of the index data to the target entities in the query statement.
[0035] Specifically, for any index data in the index data group, the process of calculating the alignment score between the index data and the query statement can be as follows: For any target entity (such as price, time, etc.) identified in the query statement, calculate the alignment score between the target entity and the field value of the corresponding field attribute in the index data, based on the degree of closeness. For example, if the target entity is a price range... The indexed data contains a field attribute named "Price" that corresponds to the price range of the target entity, defined as... Then, the method for calculating the alignment score between the target entity's price range and the field attribute price can be defined as follows: ,in, For price sensitivity parameters, To calculate the alignment score between the price range of the target entity and the price of the field attribute in the query statement, similarly, the alignment score is calculated for other target entities in the query statement. Finally, the alignment scores between all target entities in the query statement and their corresponding field attributes in the index data are weighted and calculated to obtain the alignment score between the query statement and the index data. The formula for the weighted calculation can be: Where F is the set of target entities in the query statement. The weight corresponds to the target entity, where k is the target entity. The score is the alignment score between the query statement and the index data.
[0036] The process of calculating the coverage score between any index data in the index data group and the query statement can be described as follows: count how many target entities in the query statement appear in the index data, that is, the calculation formula can be: ,in, The target entity set in the query statement. The index data corresponds to the set of entities in the descriptive text. The score represents the coverage of the query statement with the index data.
[0037] In this embodiment, by calculating the alignment score, the proximity between different index data and the target entity can be effectively quantified and distinguished. By calculating the coverage score, the coverage of different index data to the target entity can be effectively quantified and distinguished. This provides an evaluation basis for the subsequent screening of index data in the index data group. Therefore, when sorting and screening based on the alignment score and coverage score, index data with more complete information and more comprehensive query intent can be screened out, which improves the accuracy of subsequent sorting and screening, and thus improves the accuracy of the query.
[0038] like Figure 4 The diagram shown is a flowchart of a data query method provided in Embodiment 4 of the present invention. This data query method may further include the following steps: S41: For any index data in the preset database, determine the field attributes and corresponding field values in the index data, and convert the index data into descriptive text based on the field attributes and corresponding field values in the index data.
[0039] S42: Segment the description text to obtain description terms, establish a mapping relationship between each description term and the description text, and construct a preset keyword index based on the mapping relationship between each description term and the corresponding description text in all description texts.
[0040] S43: Using a pre-trained embedding model, the descriptive text is mapped to an embedding vector, and a preset vector index is constructed based on the embedding vectors of all descriptive texts.
[0041] S44: Set the preset keyword index and preset vector index as the preset index.
[0042] In this embodiment, the descriptive text can refer to sentences or paragraphs in natural language form, which are converted from field attributes and field values in the index data according to a preset template. The descriptive term can refer to a single word or the smallest semantic unit obtained after word segmentation of the descriptive text. The pre-trained embedding model can refer to a language model that has been pre-trained and can map text into a dense vector representation. The preset keyword index can refer to a data structure built based on the mapping relationship between the descriptive term and the descriptive text, which is used to support keyword matching queries. The preset vector index can refer to a data structure built based on the embedding vector of the descriptive text, which is used to support vector similarity retrieval.
[0043] Specifically, for any indexed data in a preset database, the field attributes and corresponding field values in the indexed data are determined. Based on the field attributes and corresponding field values, the indexed data is converted into natural language descriptive text. For example, in an insurance claims underwriting query scenario in the fintech field, a certain indexed data record contains the following field attributes: "Insured Product" with a value of "Critical Illness Insurance," "Insurance Date" with a value of "March 15, 2024," "Insured Age" with a value of "45 years old," and "Historical Claims Records" with a value of "None." The resulting description... The text can be: "The insured product of this policy is critical illness insurance, the insurance period is March 15, 2024, the insured's age is 45, and there is no historical claim record. In the process of constructing the preset keyword index, the descriptive text is segmented to obtain descriptive terms, and a mapping relationship is established between each descriptive term and the corresponding descriptive text. Based on the mapping relationship between each descriptive term and its corresponding descriptive text, the preset keyword index is constructed. In the process of constructing the preset vector index, a pre-trained embedding model is used to map the descriptive text into embedding vectors, and the embedding vectors corresponding to all descriptive texts are stored in the nearest neighbor index structure to construct the preset vector index."
[0044] Optionally, in S21 above, based on a preset index, the query statement is matched against each index data in the preset database to obtain a group of index data that meets the matching conditions, including: Based on the preset keyword index, calculate the matching score between the query statement and each index data in the preset database, and select the index data whose matching score meets the matching condition from all index data in the preset database to add to the index data group; Based on the preset vector index, the similarity score between the query statement and each index data in the preset database is calculated. The index data that meets the matching condition in the similarity score is selected from all the index data in the preset database and added to the index data group.
[0045] Among them, the matching score can refer to the score that represents the degree of relevance between the index data and the query statement, and the similarity score can refer to the score that represents the degree of similarity between the index data and the query statement.
[0046] Specifically, when querying based on a preset keyword index, the query statement can be segmented to obtain query terms. Each query term is then standardized to obtain standardized query terms. For example, for query terms expressing time, such as "last September," the term is dynamically calculated and standardized to "2025-09" based on the current system time (e.g., January 2026). For query terms describing fuzzy numerical values, such as "more than 5,000 yuan," the term is converted into a structured range "5000–6000 yuan" using predefined numerical mapping rules. Simultaneously, business-related categories such as "mobile phone" and "laptop" are identified. The formula for calculating the matching score between any indexed data in the database and the query statement can be: ,in, Let w be the set of all standardized query terms. The descriptive text corresponding to the indexed data. To standardize the term w in the descriptive text Frequency in Inverse document frequency, b is an adjustment parameter, and avgdl is the average document length. The index data is assigned a matching score between the index data and the query statement. Based on the matching score, index data with matching scores exceeding a preset threshold are selected and added to the index data group.
[0047] When performing a query based on a preset vector index, the query statement is input into a pre-trained embedding model to obtain a query vector. For any index data in the database, the cosine similarity between the corresponding embedding vector of the index data and the query vector is calculated. Based on the cosine similarity, index data with similarity scores exceeding a preset threshold are selected and added to the index data group.
[0048] After performing a query based on the preset keyword index and the preset vector index, all index data in the index data group are deduplicated to obtain the final index data obtained from the query based on the preset keyword index and the preset vector index.
[0049] In this embodiment, by using keyword indexing and vector indexing in parallel for dual-path recall and calculating matching score and similarity score respectively, the user's query intent can be fully covered from two dimensions: precise keyword matching and semantic similarity. This improves the comprehensiveness and accuracy of the query and provides a high-quality, high-coverage candidate data foundation for subsequent ranking and fine-tuning of the large language model, thereby further improving the overall accuracy of data query.
[0050] like Figure 5 The diagram shows a flowchart of a data query method provided in Embodiment 5 of the present invention. In S24 above, the index score of each index data point when matching with the query statement is obtained. The index score, alignment score, and coverage score of each index data point are weighted and summed to obtain the summation result for each index data point. The summation results of all index data points are then sorted to obtain the sorted result, including: S51, obtain the matching score and similarity score when each indexed data is matched with the query statement.
[0051] S52, the matching score and similarity score are the index scores when the corresponding index data is matched with the query statement.
[0052] S53, perform a weighted summation of the matching score, similarity score, alignment score and coverage score for each index data to obtain the summation result for each index data, and sort the summation results of all index data to obtain the sorted result.
[0053] Specifically, when sorting, the matching score, similarity score, alignment score and coverage score of each index data can be weighted and summed based on preset weights to obtain the summation result of each index data. The summation results of all index data are then sorted to obtain the sorting result.
[0054] Optionally, the step S24 above, which involves obtaining the index score when each index data is matched with the query statement, performing a weighted summation of the index score, alignment score, and coverage score for each index data to obtain the summation result for each index data, and sorting the summation results of all index data to obtain the sorting result, further includes: Obtain the matching score and similarity score when each indexed data is matched with the query statement; The matching score and similarity score are the index scores when the corresponding index data is matched with the query statement; The matching score, similarity score, alignment score, and coverage score of each index data are input into the sorted and trained model. The sorted and trained model then uses these scores to obtain the normalized score for each index data. All indexes are sorted based on their normalized scores to obtain the sorting results.
[0055] Among them, the model that has been trained for sorting can refer to a neural network model that has been trained for sorting index data. This trained model can automatically learn and output the optimal sorting result based on the matching score, similarity score, alignment score and coverage score of each index data.
[0056] Specifically, the matching score, similarity score, alignment score, and coverage score of each index data are used to form the feature vector of the corresponding index data. The feature vector of each index data is then input into the pre-trained sorting model. Based on the feature vectors of all index data, the model obtains the normalized score of the corresponding index data. Based on the normalized scores of all index data, all index data are sorted to obtain the sorting result.
[0057] The training process for a pre-trained, sorted model can be as follows: constructing triples (Q, ...) from real user interaction logs or expert annotations. , Q is a sample query statement. For index data samples, For relevance labels, assign each (Q, Convert the sample into a feature vector. ,in, For matching scores, Similarity score, alignment score, Score for coverage , to feature vector Input the initial model, and the model outputs the predicted normalized score during forward propagation. Based on loss function The initial model is trained, where, This refers to the set of sample pairs selected from the index data samples corresponding to the same query statement sample. The penalty term is based on the difference in predicted scores. To determine the degree of influence of the positions of i and j on the NDCG metric, and using them as weights, the core logic is: for any two indexed data samples, if the true label... > The model should make > Otherwise, a loss will occur, and the magnitude of the loss is also weighted by the degree to which the swapping positions affect the sorting quality.
[0058] In this embodiment, all index data is sorted using a pre-trained model based on index scores (matching score, similarity score), alignment score, and coverage score. This replaces the fixed weighting method with manually preset weights. Compared to the preset weight method, this avoids the subjectivity and limitations of manual parameter tuning, improving the accuracy of the sorting. Furthermore, sorting based on matching score, similarity score, alignment score, and coverage score allows for a comprehensive evaluation of the relevance of index data to the query statement from multiple dimensions, such as keyword matching, semantic similarity, entity field alignment, and entity coverage completeness, thus improving the accuracy of the sorting and consequently the accuracy of the query.
[0059] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0060] In one embodiment, a data query device is provided, and the database query optimization device for the database is applied to the server. This data query device corresponds one-to-one with the data query methods in the above embodiments. For example... Figure 6 As shown, the data query device includes a first index module 61, a parsing module 62, a first calculation module 63, a sorting module 64, and a filtering module 65. Detailed descriptions of each functional module are as follows: The first index module 61 is used to convert the query request into a query statement when a query request is received, and to match the query statement with each index data in the preset database based on the preset index to obtain an index data group that meets the matching conditions. Parsing module 62 is used to perform entity parsing on the query statement to obtain the target entity in the query statement, and to perform field parsing on each index data in the index data group to obtain the field attributes and field values corresponding to each index data. The first calculation module 63 is used to calculate an alignment score that represents the closeness between each index data and the target entity in the query statement, and a coverage score that represents the coverage of each index data to the target entity in the query statement, based on the field attributes, field values, and target entities in the query statement corresponding to each index data. The sorting module 64 is used to obtain the index score when each index data is matched with the query statement, perform a weighted summation of the index score, alignment score and coverage score of each index data to obtain the summation result of each index data, and perform sorting on the summation results of all index data to obtain the sorting result; The filtering module 65 is used to determine the top K index data in the sorting results, and to match the query statement with the K index data based on a preset large language model to obtain the target index data, where K is an integer greater than zero.
[0061] Optionally, the first calculation module 63 mentioned above includes: The second calculation unit is used to calculate, for any index data, an alignment score that characterizes the degree of closeness between each target entity in the query statement and the field value of the corresponding field attribute in the index data, based on the field attributes in the index data, the field values of the corresponding field attributes, and the target entities in the query statement. The third calculation unit is used to perform a weighted calculation on the alignment scores between the field values of all target entities in the query statement and the corresponding fields in the index data, so as to obtain an alignment score that represents the degree of closeness between the index data and the target entities in the query statement. The fourth calculation unit is used to calculate the intersection between all target entities in the query statement and all field attributes in the index data, and to calculate a coverage score that represents the degree of coverage of the index data to the target entities in the query statement based on the intersection and all target entities in the query statement.
[0062] Optionally, the data query device further includes: The conversion module is used to determine the field attributes and corresponding field values of any index data in the preset database, and convert the index data into descriptive text based on the field attributes and corresponding field values. The first construction module is used to segment the description text into words to obtain description terms, establish a mapping relationship between each description term in the description text and the description text, and construct a preset keyword index based on the mapping relationship between each description term in all description texts and the corresponding description text. The second construction module is used to map the description text into embedding vectors through a pre-trained embedding model, and to construct a preset vector index based on the embedding vectors of all description texts. The first forming module is used to convert the preset keyword index and the preset vector index into the preset index.
[0063] Optionally, the first index module 61 mentioned above includes: The second indexing unit is used to calculate the matching score between the query statement and each index data in the preset database based on the preset keyword index, and to select the index data whose matching score meets the matching condition from all index data in the preset database and add it to the index data group. The third indexing unit is used to calculate the similarity score between the query statement and each index data in the preset database based on the preset vector index, and to select index data whose similarity score meets the matching condition from all index data in the preset database and add them to the index data group.
[0064] Optionally, the sorting module 64 mentioned above includes: The first acquisition unit is used to acquire the matching score and similarity score when each index data is matched with the query statement; The second forming unit is used to convert the matching score and the similarity score into index scores when the corresponding index data is matched with the query statement; The weighted unit is used to perform a weighted summation of the matching score, similarity score, alignment score, and coverage score of each index data to obtain the summation result of each index data. The summation results of all index data are then sorted to obtain the sorted result.
[0065] Optionally, the sorting module 64 further includes: The second acquisition unit is used to acquire the matching score and similarity score when each index data is matched with the query statement; The third forming unit is used to convert the matching score and the similarity score into index scores when the corresponding index data is matched with the query statement; The first model prediction unit is used to input the matching score, similarity score, alignment score and coverage score of each index data into the sorted and trained model, and obtain the normalized score of each index data based on the matching score, similarity score, alignment score and coverage score of each index data through the sorted and trained model. The model sorting unit is used to sort all indexes based on the normalized scores of all index data to obtain the sorting result.
[0066] Optionally, the above-mentioned filtering module 65 includes: The third acquisition unit is used to acquire preset prompt words; The second model prediction unit is used to match the query statement and the K index data based on the preset prompt words using the preset large language model to obtain the target index data.
[0067] Specific limitations regarding the data query device can be found in the limitations of the intelligent question-answering method described above, and will not be repeated here. Each module in the aforementioned data query device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0068] Embodiment 7 of the present invention provides a computer device, which may be a server, and its internal structure diagram may be as follows. Figure 7 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database stores query requests. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a data query method.
[0069] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the data query method described in the above embodiment, for example... Figure 2 As shown in S21-S25, or Figures 3 to 5 As shown, to avoid repetition, it will not be described again here. Alternatively, when the processor executes a computer program, it implements the functions of each module / unit in this embodiment of the data management device, for example, Figure 6 The functions of the first index module 61, parsing module 62, first calculation module 63, sorting module 64, and filtering module 65 shown are not described again here to avoid repetition.
[0070] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When executed by a processor, the computer program implements the data query method described in the above embodiment, for example... Figure 2 As shown in S21-S25, or Figures 3 to 5 As shown, to avoid repetition, it will not be described again here. Alternatively, when the processor executes a computer program, it implements the functions of each module / unit in this embodiment of the data management device, for example, Figure 6 The functions of the first index module 61, parsing module 62, first calculation module 63, sorting module 64, and filtering module 65 shown are not described again here to avoid repetition.
[0071] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0072] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0073] If any software tools or components not belonging to this company appear in the embodiments of this invention, they are merely illustrative examples and do not represent actual use. All user personal information involved in the embodiments of this invention is authorized (with knowledge and consent) by the relevant parties or fully authorized by all parties, and the executing entity may obtain it through various legal and compliant means. The collection, storage, use, processing, transmission, provision, and disclosure of the information, data, and signals involved all comply with the relevant laws and regulations of the relevant countries and regions, and do not violate public order and good morals.
[0074] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A data query method, characterized in that, include: Upon receiving a query request, the query request is converted into a query statement. Based on a preset index, the query statement is matched with each index data in the preset database to obtain a group of index data that meets the matching conditions. The query statement is parsed to obtain the target entity in the query statement. Each index data in the index data group is parsed to obtain the field attributes and field values corresponding to each index data. Based on the field attributes, field values, and target entities in the query statement corresponding to each index data, calculate the alignment score, which represents the proximity of each index data to the target entity in the query statement, and the coverage score, which represents the coverage of each index data to the target entity in the query statement. Obtain the index score when each index data is matched with the query statement, perform a weighted summation of the index score, alignment score and coverage score of each index data to obtain the summation result of each index data, and sort the summation results of all index data to obtain the sorting result; The top K index data in the sorting results are determined. Based on a preset large language model, the query statement and the K index data are matched to obtain the target index data, where K is an integer greater than zero.
2. The data query method as described in claim 1, characterized in that, The step of calculating an alignment score, representing the proximity of each index data point to the target entity in the query statement, and a coverage score, representing the coverage of each index data point to the target entity in the query statement, based on the field attributes, field values, and target entities corresponding to each index data point, includes: For any index data, based on the field attributes in the index data, the field values of the corresponding field attributes, and the target entities in the query statement, an alignment score is calculated to characterize the degree of closeness between each target entity in the query statement and the field value of the corresponding field attribute in the index data. The alignment scores between all target entities in the query statement and the corresponding field values in the index data are weighted and calculated to obtain an alignment score that characterizes the closeness between the index data and the target entities in the query statement. Calculate the intersection between all target entities in the query statement and all field attributes in the index data. Based on the intersection and all target entities in the query statement, calculate the coverage score, which represents the degree of coverage of the index data to the target entities in the query statement.
3. The data query method as described in claim 1, characterized in that, The data query method also includes: For any index data in the preset database, determine the field attributes and corresponding field values in the index data, and convert the index data into descriptive text based on the field attributes and corresponding field values in the index data; The description text is segmented into words to obtain description terms. A mapping relationship is established between each description term in the description text and the description text itself. Based on the mapping relationship between each description term in all description texts and the corresponding description text, a preset keyword index is constructed. The description text is mapped to an embedding vector using a pre-trained embedding model, and a preset vector index is constructed based on the embedding vectors of all description texts. The preset keyword index and the preset vector index are used as the preset index.
4. The data query method as described in claim 3, characterized in that, The step of matching the query statement with each index data in the preset database based on a preset index to obtain a group of index data that meets the matching conditions includes: Based on the preset keyword index, calculate the matching score between the query statement and each index data in the preset database, and select the index data whose matching score meets the matching condition from all index data in the preset database to add to the index data group; Based on the preset vector index, the similarity score between the query statement and each index data in the preset database is calculated respectively. The index data whose similarity score meets the matching condition is selected from all index data in the preset database and added to the index data group.
5. The data query method as described in claim 4, characterized in that, The process involves obtaining the index score for each index data item when matching it with the query statement, weighted summing of the index score, alignment score, and coverage score for each index data item, obtaining the summation result for each index data item, and sorting the summation results for all index data items to obtain the sorted result, including: Obtain the matching score and similarity score when each index data is matched with the query statement; The matching score and the similarity score are the index scores when the corresponding index data is matched with the query statement; The matching score, similarity score, alignment score, and coverage score of each index data are weighted and summed to obtain the sum of each index data. The sums of all index data are then sorted to obtain the sorted result.
6. The data query method as described in claim 4, characterized in that, The process of obtaining the index score when each index data is matched with the query statement, performing a weighted summation of the index score, alignment score, and coverage score for each index data to obtain the summation result for each index data, and sorting the summation results of all index data to obtain the sorted result, also includes: Obtain the matching score and similarity score when each index data is matched with the query statement; The matching score and the similarity score are the index scores when the corresponding index data is matched with the query statement; The matching score, similarity score, alignment score, and coverage score of each index data are input into the sorted and trained model. The sorted and trained model then obtains the normalized score of each index data based on its matching score, similarity score, alignment score, and coverage score. Based on the normalized scores of all index data, all indexes are sorted to obtain the sorting result.
7. The data query method as described in claim 1, characterized in that, The method, based on a preset large language model, matches the query statement with the K index data to obtain target index data, including: Get preset prompt words; Using the preset large language model and based on the preset prompt words, the query statement and the K index data are matched to obtain the target index data.
8. A data query device, characterized in that, include: The first index module is used to convert the query request into a query statement when a query request is received, and to match the query statement with each index data in the preset database based on the preset index to obtain a group of index data that meets the matching conditions. The parsing module is used to perform entity parsing on the query statement to obtain the target entity in the query statement, and to perform field parsing on each index data in the index data group to obtain the field attributes and field values corresponding to each index data. The first calculation module is used to calculate an alignment score, which represents the closeness between each index data and the target entity in the query statement, and a coverage score, which represents the coverage of each index data to the target entity in the query statement, based on the field attributes, field values, and target entities in the query statement corresponding to each index data. The sorting module is used to obtain the index score when each index data is matched with the query statement, perform a weighted summation of the index score, alignment score and coverage score of each index data to obtain the summation result of each index data, and perform sorting on the summation results of all index data to obtain the sorting result; The filtering module is used to determine the top K index data in the sorting results, and to match the query statement with the K index data based on a preset large language model to obtain the target index data, where K is an integer greater than zero.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the data query method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the data query method as described in any one of claims 1 to 7.