Data query processing method and device
By performing word segmentation processing and semantic similarity calculation on the query text, and combining with the large language model to generate query conditional statements, the problem of insufficient question-and-answer accuracy of library tables in the existing technology is solved, and more efficient understanding of natural language problems and data query processing is achieved.
Patent Information
- Application Number
- CN202510004955.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-02
- Publication Date
- 2025-02-07
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing library table question and answer techniques are insufficient in handling complex contexts or long texts. Semantic matching and inference capabilities rely on predefined rules or specific training sets, resulting in user intent identification errors and large errors in determining target library tables.
By performing word segmentation processing on the query text, calculate the semantic similarity between the text word segmentation and the data table data field, determine the target data table, and fill the data field into the generation instruction template, enter the large language model to generate query condition statements, and finally in the target data table Data query is performed in .
Improve the ability to understand natural language problems, ensure that the most appropriate data table is selected for querying, generate initial screening SQL statements to narrow the data range, reduce the computing burden, and greatly improve the data calculation and reasoning ability of complex problems.
Smart Images

Figure CN119396862A_ABST
Abstract
Description
Technical Field
[0001] This document relates to the field of data processing technology, and in particular to a data query processing method and device. Background Art
[0002] The existing database-table question-answering technology is mainly nl2sql, which automatically converts natural language queries into SQL queries. This technology is mainly used to enable non-technical users to interact with the database directly through natural language without having to master SQL syntax. This process involves multiple aspects such as natural language processing (NLP), semantic understanding, and SQL statement generation; Existing technical solutions are usually trained for specific SQL generation tasks and perform poorly when processing complex contexts or long texts. Semantic matching and reasoning capabilities usually rely on predefined rules or specific training sets, and are prone to errors when faced with semantically complex or ambiguous queries. Intent recognition usually relies on metadata or keywords of database tables and cannot understand the user's deep intentions, resulting in large errors in determining the target database table. Therefore, how to improve the accuracy of database table question answering is the direction of future efforts. Summary of the invention
[0003] An object of an embodiment of the present specification is to provide a data query processing method and device to solve the problem of low data query accuracy.
[0004] To solve the above technical problems, one embodiment of this specification is implemented as follows: In a first aspect, an embodiment of the present specification provides a data query processing method, including: Perform word segmentation on the query text to obtain text segmentation; Calculating the semantic similarity between the text segmentation and the data field of the data table, and determining the target data table based on the semantic similarity; Filling the data fields in the target data table that are mapped to the text segmentation into a generation instruction template, and inputting the obtained generation instruction into a large language model to generate a conditional statement to obtain a query conditional statement; Based on the query condition statement, data query is performed in the target data table to obtain data query results.
[0005] In a second aspect, another embodiment of the present specification provides a data query processing device, including: A word segmentation processing module is configured to perform word segmentation processing on the query text to obtain text segmentation; A similarity calculation module is configured to calculate the semantic similarity between the text segmentation and the data field of the data table, and determine the target data table based on the semantic similarity; A conditional statement generation module is configured to fill the data fields in the target data table mapped with the text segmentation into a generation instruction template, and input the obtained generation instruction into a large language model to generate a conditional statement to obtain a query conditional statement; The data query module is configured to perform data query in the target data table based on the query condition statement to obtain data query results.
[0006] In a third aspect, another embodiment of the present specification provides a data query processing device, comprising: a memory, a processor, and computer executable instructions stored on the memory and executable on the processor, wherein the computer executable instructions, when executed by the processor, implement the steps of the data query processing method as described in the first aspect above.
[0007] In a fourth aspect, another embodiment of the present specification provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store computer-executable instructions, and when the computer-executable instructions are executed by a processor, the steps of the data query processing method as described in the first aspect above are implemented.
[0008] In a fifth aspect, another embodiment of the present specification provides a computer program product, wherein the computer program product includes a data query processing program, and the data query processing program is executed by a processor to implement the steps of the data access processing method as described in the first aspect above.
[0009] The data query processing method provided in this embodiment first performs word segmentation processing on the query text to obtain text segmentation, then calculates the semantic similarity between the text segmentation and the data field of the data table, determines the target data table based on the semantic similarity, more intelligently and accurately identifies the user intention, and improves the accuracy of similarity calculation, and then fills the data field in the target data table mapped with the text segmentation into the generation instruction template, and inputs the obtained generation instruction into the large language model to generate conditional statements to obtain query conditional statements, and realizes accurate and intelligent conversion of keywords in the query text to query conditional statements, and finally performs data query in the target data table based on the query conditional statements to obtain data query results. This solution improves the understanding of natural language problems, ensures the selection of the most appropriate data table for query, and generates preliminary screening SQL statements based on specific methods to narrow the data range, reduce the subsequent calculation burden, and greatly improve the data calculation and reasoning capabilities of complex problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions in one or more embodiments of the present specification, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0011] Figure 1 A processing flow chart of a data query processing method provided by one embodiment of this specification; Figure 2 A processing flow chart of a data query processing method applied to a database data query scenario provided by one embodiment of this specification; Figure 3 A schematic diagram of a data query processing device provided in one embodiment of this specification; Figure 4 A schematic diagram of the structure of a data query processing device provided in one embodiment of the present specification. DETAILED DESCRIPTION
[0012] In order to enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the technical solutions in one or more embodiments of this specification will be clearly and completely described below in conjunction with the drawings in one or more embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. Based on one or more embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this document.
[0013] This specification provides a data query processing method embodiment: Reference Figure 1 , which shows a data query processing method processing flow chart provided by this embodiment, referring to Figure 2 , which shows a processing flow chart of a data query processing method provided by this embodiment and applied to a database data query scenario.
[0014] Reference Figure 1 The data query processing method provided in this embodiment specifically includes the following steps S102 to S108.
[0015] Step S102, performing word segmentation processing on the query text to obtain text segmentation.
[0016] In this embodiment, the query text refers to the text for querying the data stored in the database. The query text may be a natural language text. Optionally, the query text includes a dialogue question. For example, the querying party may enter a dialogue question such as: "What is the total GDP of the first quarter and the second quarter of City A in 2024?" to query the data. It should be noted that the data stored in the database is usually stored in the form of a data table, that is, the data table is the basic unit for storing data in the database, and the data field of the data table represents the entity and / or attribute stored in the data table. For example, the data field may be region [xx city], year
[2024] , economic indicator name [gross domestic product], etc.
[0017] In practical applications, the number of data tables stored in the database is large, resulting in low efficiency of data query. Therefore, the data table can be screened to narrow the scope of data query. In view of this, after obtaining the query text, the query text can be segmented to match the data table according to the obtained text segmentation, and the target data table can be screened out from the database. Specifically, in the process of segmenting the query text, in order to obtain more accurate text segmentation, the segmentation can be performed based on the segmentation model. In an optional implementation manner provided in this embodiment, the query text is segmented in the following manner: Obtaining the query text; The query text is input into the word segmentation model for word segmentation processing to obtain the text segmentation.
[0018] Specifically, word segmentation refers to dividing a continuous text into individual independent units, which may be words, phrases, symbols, or other types of character strings. The word segmentation model may be a model with word segmentation function, such as a BERT model. It should be noted that, during the training process of the word segmentation model, the data fields of the data table may be used as training data sets to train the model to be trained, so as to improve the word segmentation ability of the word segmentation model.
[0019] Step S104, calculating the semantic similarity between the text segmentation and the data fields of the data table, and determining the target data table based on the semantic similarity.
[0020] After the query text is segmented and the text segmentation is obtained, in this step, in order to locate the target data table corresponding to the query text from multiple data tables, the semantic similarity between the text segmentation and the data field of the data table is calculated, and the target data table is determined based on the semantic similarity. The target data table refers to the data table where the data to be queried indicated by the query text is located.
[0021] Optionally, the data fields of the data table include standard data fields and / or synonymous data fields, wherein the standard data fields are obtained by standardizing all data fields based on standardization rules; In an optional implementation manner provided by this embodiment, the synonymous data field is obtained in the following manner: Extracting the field semantics of the full data field, and filling the field semantics and the full data field into an extraction instruction template to obtain an extraction instruction; The extraction instruction is input into the large language model to perform field extraction to obtain the synonymous data field.
[0022] Specifically, since users may use different expressions for the same data, for example, gross domestic product may also be called gross domestic product, GDP, total output value, national gross product, etc., in order to more accurately determine the target data table corresponding to the query text, the full data fields of the data table can be standardized to obtain standard data fields, and synonymous data fields of the full data fields can be obtained, and semantic similarity calculation can be performed based on the standard data fields and synonymous data fields; The full data fields may be data fields of all data tables in the database. In the process of standardizing the full data fields, the standardization rules that may be adopted may be naming structure rules, length restriction rules, and word meaning restrictions. For example, the naming structure is "entity + attribute", the length restriction is controlled within 3-6 characters, and the word meaning restriction is to avoid polysemy or synonym conflicts. In the process of obtaining synonymous data fields, in order to improve the acquisition efficiency and accuracy, the large language model can be used to generate synonymous data fields. Specifically, the field semantics of the full data field are first extracted, and the field semantics and the full data field are filled into the prompt template to obtain the generation instruction, and the generation instruction is input into the large language model for field generation to obtain the synonymous data field.
[0023] For example, the prompt template can be "The field name of the data table is: {original field name}, and its meaning is: {meaning}, please output the field name with the same meaning"; the input of the language model is: the field name of the library table is: gross domestic product, and its meaning is: the gross domestic product of a country or region, please output the field name with the same meaning; the output is: gross domestic product, GDP, total output value, national gross product, regional gross product, gross national economy, total economic output, regional GDP, total economic volume, regional GDP.
[0024] In addition, in order to further improve the accuracy of semantic similarity calculation, after obtaining synonymous data fields, the synonymous data fields can be screened in the second stage, that is, based on the word vector model and semantic similarity, synonyms whose semantic similarity with the full data field is greater than or equal to the similarity threshold are screened as the final synonymous data fields, where the similarity threshold can be adjusted according to the calculation accuracy of the overall solution. For example, the similarity threshold can be 0.8.
[0025] Continuing with the above example, based on the results output by the large language model, the synonym groups obtained through the second stage of screening are GDP, total output value, total economic output value, and total economic volume.
[0026] It should be noted that, in this embodiment, the standard data fields and synonymous data fields obtained based on the full data fields can be stored in a standardized synonym library. In the process of calculating semantic similarity, the semantic similarity between the text segmentation and the data fields in the standardized synonym library can be calculated; and the standard data fields and synonymous data fields have a mapping relationship with the original data fields in the full data fields.
[0027] In the specific execution process, in the process of calculating the semantic similarity between the text segmentation and the data field of the data table, the data fields can be grouped based on the field type of the data field, and the semantic similarity is calculated according to the obtained weights of the entity data field and the dimension data field. In an optional implementation provided by this embodiment, the semantic similarity between the text segmentation and the data field of the data table is calculated in the following manner: Grouping the data fields based on field types of the data fields to obtain entity data fields and dimension data fields; Calculating semantic similarity between the text segmentation and the entity data field and the dimension data field respectively to obtain entity semantic similarity and dimension semantic similarity; The semantic similarity is calculated based on the weight of the entity semantic similarity and the weight of the dimension semantic similarity.
[0028] Among them, the entity data field refers to the core object of the data table. The entity data field represents identifiable objects or concepts. For example, a data table stores macroeconomic indicator data related to different times and regions, and the "Economic Indicator Name" field is the entity field; the dimension data field describes the data context or the category of data attributes, which is used to provide meaningful context for the entity data field, such as time and place.
[0029] Specifically, in the process of calculating the semantic similarity between text segmentation and data fields of a data table, the data fields can be grouped based on the field type of the data fields to obtain entity data fields and dimension data fields, and the entity semantic similarity between the text segmentation and the entity data field and the dimension semantic similarity between the text segmentation and the dimension data field are calculated respectively. The semantic similarity is calculated based on the weight of the entity semantic similarity and the weight of the dimension semantic similarity.
[0030] For example, for text segmentation, its score with a data table is: entity semantic similarity*0.6+dimension semantic similarity*0.4. In this way, the score of each text segmentation and each data field of a data table can be calculated. The sum of the scores is the score of the text segmentation and a library table. In this way, the final score of the query text and each data table can be calculated.
[0031] In addition, in order to further improve the accuracy of semantic similarity calculation, the data fields are grouped based on the field type of the data fields. Before the step of obtaining the entity data field and the dimension data field is executed, the data fields of the data table can also be preliminarily screened. Specifically, for each text segmentation, the sub-semantic similarity of each text segmentation and each standard data field and synonymous data field of each library table is calculated, and the average value of the sub-semantic similarities is used as the semantic similarity between the query text and the data table. On this basis, only text segmentations with semantic similarity greater than or equal to the similarity threshold are retained, and semantic similarity calculation is performed based on the retained text segmentations and the entity data field and the dimension data field. It should be noted that the similarity threshold can be adjusted according to the calculation accuracy of the overall solution, for example, 0.7 can be used.
[0032] In a specific implementation process, in the process of determining a target data table based on semantic similarity, the data tables may be sorted based on the semantic similarity to obtain a data table list, and a data table in a preset position in the data table list may be used as a target data table.
[0033] Step S106, filling the data fields in the target data table that are mapped to the text segmentation into the generation instruction template, and inputting the obtained generation instruction into the large language model to generate conditional statements to obtain query conditional statements.
[0034] The above-mentioned calculation of the semantic similarity between the text segmentation and the data fields of the data table, after determining the target data table based on the semantic similarity, in this step, the data fields in the target data table mapped with the text segmentation are filled into the generation instruction template, and the obtained generation instruction is input into the large language model for conditional statement generation to obtain the query conditional statement.
[0035] During the specific execution process, the dimension data field in the target data table mapped to the text word segmentation can be filled into the generation instruction template to obtain the generation instruction; for example, the dimension data field "October 1, 2023" is filled into the prompt template to obtain the generation instruction "Convert "October 1, 2023" and output the converted value"; in addition, for the entity data field mapped to the text word segmentation, the entity data field can be directly used as the query condition statement.
[0036] It should be noted that the generation instruction template may also include field features of dimensional data fields; for example, after filling the dimensional data field "October 1, 2023" into the prompt template, the generation instruction obtained is "Convert "October 1, 2023" according to the following features, and directly output the converted value; wherein, the value is a combination of numbers and characters, the length of the value is 10, the value describes the date and time, and the value is in the form of yyyy-MM-dd". The large language model generates conditional statements according to the generation instruction, and the output result is "date = '2023-10-1'".
[0037] Specifically, the field features of the data field can be extracted in advance. Examples of field features are as follows: a. The data field can be a combination of values: a combination of Chinese characters, letters and numbers, or a combination of several items. For example, for the age field, the feature description of the field is: the value is a pure number; b. The field length of the data field: its value range or character range. For example, for the age field, the feature description of the field is: the value range is 1 to 100; c. Description of the data field: meaning, for example, the feature description of a field is: the value describes the date and time; d. The form of the value: the appearance of the value. For example, the feature description of a field is: the value describes a specific province and ends with the word "province"; e. Enumeration of values: the value can only be one of the specific values. For example, the feature description of a field is: the value can only be one of "primary industry", "secondary industry" or "tertiary industry".
[0038] Step S108: perform data query in the target data table based on the query condition statement to obtain data query results.
[0039] The above method fills the data fields in the target data table mapped with the text segmentation into the generation instruction template, and inputs the obtained generation instruction into the large language model to generate conditional statements. After obtaining the query conditional statement, in this step, data query is performed in the target data table based on the query conditional statement to obtain the data query result.
[0040] In the specific execution process, during the data query process, an SQL statement configuration may be performed based on the query condition statement obtained above to obtain an SQL statement, and data query may be performed based on the SQL statement. In an optional implementation manner provided by this embodiment, data query is performed in the target data table based on the query condition statement to obtain a data query result in the following manner: Fill the query condition statement into the SQL statement template to obtain an SQL statement; Based on the SQL statement, data query is performed in the target database table to obtain the data query result.
[0041] For example, "select * from table where conditional query statement and conditional query statement and..." is used as an SQL template. After obtaining the query conditional statement, the query conditional statement is filled into the SQL template to obtain a complete SQL statement, and data is queried in the target data table based on the complete SQL statement to obtain data query results.
[0042] In a specific implementation, when the query text includes a dialogue question, after the step of performing a data query in the target data table based on the query condition statement and obtaining the data query result is executed, the method further includes: generating an answer based on the data query result to obtain a dialogue answer to the dialogue question. Specifically, the answer to the data query result is converted into a natural language output and returned as a dialogue answer.
[0043] In addition, when the query text contains the operation logic for the data query result, the data query result can also be operated based on the operation logic. In an optional implementation provided by this embodiment, each target data is operated based on the operation logic in the following manner: Extracting text features of the query text, and determining the operation logic of each target data in the data query result according to the text features; The target data are operated based on the operation logic to obtain operation results.
[0044] Specifically, the above-mentioned operation process can be implemented by a structured data large model. The operation process of the structured data large model is specifically described below: the content of each cell in the data table is encoded into a word vector similar to natural language processing, and each cell is attached with structural information, including row number, column number, and whether it is a table header. At the same time, the natural language question entered by the user is encoded into a vector in the same format as the table data. The encoding process uses a Transformer-based word embedding method; based on the self-attention mechanism, the model calculates the correlation between each cell in the data table and other cells, and also calculates the correlation between the question text and each part of the data table; the representation of the question is matched with the representation of the data table , find the data table area that is most relevant to the question; based on the question type, the model selects one or more of the most relevant cells in the data table as candidate answers, and then calculates the score of each candidate cell, indicating the possibility of the cell answering the question. The cell with a higher score is more likely to contain the correct answer; for simple search questions, such as directly asking a value in the data table, the model directly extracts the content from the most likely cell as the answer. For questions that require reasoning or calculation, such as summation, counting, average, etc., logic is used to perform calculations. This layer performs numerical operations based on the relevant cell data selected from the data table and generates the final answer; the calculated or selected answer is converted into natural language output and returned as an answer.
[0045] For example, the table data and questions input into the structured data big model are: data = ["Region": [xx City, xx City], "Year": [2024, 2024], "Quarter": [First Quarter, Second Quarter],"Economic Indicator Name": [Gross Domestic Product, Gross Domestic Product],"Indicator Value": [1131.2, 190.27],"Unit": [100 million yuan, 100 million yuan]]; queries = ["What is the total gross domestic product of City A in the first and second quarters of 2024?"]; The output result is: sum(1131.2, 190.27) = 132.147 billion yuan.
[0046] In summary, the data query processing method provided by the present embodiment first performs word segmentation processing on the query text to obtain text segmentation, then calculates the semantic similarity between the text segmentation and the data field of the data table, determines the target data table based on the semantic similarity, identifies the user intention more intelligently and accurately, and improves the accuracy of similarity calculation, and then fills the data field in the target data table mapped with the text segmentation into the generation instruction template, and inputs the obtained generation instruction into the large language model to generate conditional statements to obtain query conditional statements, and realizes accurate and intelligent conversion of keywords in the query text to query conditional statements, and finally performs data query in the target data table based on the query conditional statements to obtain data query results. This solution improves the understanding of natural language problems, ensures the selection of the most appropriate data table for query, and generates preliminary screening SQL statements based on specific methods to narrow the data range, reduce the subsequent calculation burden, and greatly improves the data calculation and reasoning capabilities of complex problems.
[0047] The following combination Figure 2 , taking the application of the data query processing method provided by this embodiment in the database data query scenario as an example, the data query processing method provided by this embodiment is further described. Figure 2 The data query processing method applied to the database data query scenario specifically includes steps S202 to S220.
[0048] Step S202, obtaining a dialogue question, performing word segmentation processing on the dialogue question, and obtaining text segmentation.
[0049] Prior to this, the standard data fields of the data table were obtained by standardizing all data fields based on standardization rules, and the synonymous data fields of the data table were generated based on the large prediction model.
[0050] Step S204: grouping the data fields of the data table based on the field types of the data fields to obtain entity data fields and dimension data fields.
[0051] Step S206 , respectively calculating semantic similarity between the text segmentation and the entity data field and the dimension data field to obtain entity semantic similarity and dimension semantic similarity.
[0052] Step S208, calculating semantic similarity based on the weight of entity semantic similarity and the weight of dimension semantic similarity.
[0053] Step S210, determining a target data table based on semantic similarity.
[0054] Step S212, fill the data fields in the target data table that are mapped to the text segmentation into the generation instruction template to obtain the generation instruction.
[0055] Step S214: input the generation instruction into the large language model to generate a conditional statement to obtain a query conditional statement.
[0056] Step S216, fill the query condition statement into the SQL statement template to obtain the SQL statement.
[0057] Step S218: perform data query in the target database table based on the SQL statement to obtain data query results.
[0058] Step S220, generate answers based on the data query results to obtain dialogue answers to the dialogue questions.
[0059] Figure 3 A schematic diagram of a data query processing device provided by an embodiment of the present invention is shown in FIG. Figure 3 As shown, the device comprises: The word segmentation processing module 302 is configured to perform word segmentation processing on the query text to obtain text segmentation; A similarity calculation module 304 is configured to calculate the semantic similarity between the text segmentation and the data field of the data table, and determine the target data table based on the semantic similarity; The conditional statement generation module 306 is configured to fill the data fields in the target data table that are mapped to the text segmentation into the generation instruction template, and input the obtained generation instruction into the large language model to generate the conditional statement to obtain the query conditional statement; The data query module 308 is configured to perform data query in the target data table based on the query condition statement to obtain a data query result.
[0060] The data query processing device provided in this embodiment first performs word segmentation processing on the query text by running the word segmentation processing module 302 to obtain text segmentation, then runs the similarity calculation module 304 to calculate the semantic similarity between the text segmentation and the data field of the data table, determines the target data table based on the semantic similarity, then runs the conditional statement generation module 306 to fill the data field in the target data table mapped with the text segmentation into the generation instruction template, and inputs the obtained generation instruction into the large language model to generate conditional statements to obtain query conditional statements, and finally runs the data query module 308 to perform data query in the target data table based on the query conditional statements to obtain data query results, thereby improving the understanding of natural language problems, ensuring the selection of the most appropriate data table for query, and generating preliminary screening SQL statements based on specific methods to narrow the data range, reduce the subsequent calculation burden, and greatly improve the data calculation and reasoning capabilities of complex problems.
[0061] The data query processing device provided in one embodiment of this specification can implement each process in the aforementioned method embodiment and achieve the same functions and effects, which will not be repeated here.
[0062] Furthermore, an embodiment of the present specification also provides a data query processing device, Figure 4 A structural diagram of a data query processing device provided in an embodiment of this specification is shown as follows: Figure 4 As shown, the device includes: a memory 401, a processor 402, a bus 403 and a communication interface 404. The memory 401, the processor 402 and the communication interface 404 communicate through the bus 403, and the communication interface 404 may include an input and output interface, which includes but is not limited to a keyboard, a mouse, a display, a microphone, a loudspeaker, etc.
[0063] Figure 4 In the embodiment, the memory 401 stores computer executable instructions that can be run on the processor 402. When the computer executable instructions are executed by the processor 402, the following process is implemented: Perform word segmentation on the query text to obtain text segmentation; Calculating the semantic similarity between the text segmentation and the data field of the data table, and determining the target data table based on the semantic similarity; Filling the data fields in the target data table that are mapped to the text segmentation into a generation instruction template, and inputting the obtained generation instruction into a large language model to generate a conditional statement to obtain a query conditional statement; Based on the query condition statement, data query is performed in the target data table to obtain data query results.
[0064] The data query processing device provided in this embodiment, through the cooperation of the memory 401, the processor 402, the bus 403 and the communication interface 404, first performs word segmentation processing on the query text to obtain text segmentation, and then calculates the semantic similarity between the text segmentation and the data field of the data table, determines the target data table based on the semantic similarity, and more intelligently and accurately identifies the user intention, improves the accuracy of the similarity calculation, and then fills the data field in the target data table mapped with the text segmentation into the generation instruction template, and inputs the obtained generation instruction into the large language model to generate conditional statements to obtain query conditional statements, realizes accurate and intelligent conversion of keywords in the query text to query conditional statements, and finally performs data query in the target data table based on the query conditional statements to obtain data query results. This solution improves the understanding of natural language problems, ensures the selection of the most appropriate data table for query, and generates preliminary screening SQL statements based on specific methods to narrow the data range, reduce the subsequent calculation burden, and greatly improves the data calculation and reasoning capabilities of complex problems.
[0065] The data query processing device provided in an embodiment of this specification can implement each process in the aforementioned method embodiment and achieve the same functions and effects, which will not be repeated here.
[0066] Furthermore, another embodiment of the present specification provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store computer-executable instructions, and when the computer-executable instructions are executed by a processor, the following process is implemented: Perform word segmentation on the query text to obtain text segmentation; Calculating the semantic similarity between the text segmentation and the data field of the data table, and determining the target data table based on the semantic similarity; Filling the data fields in the target data table that are mapped to the text segmentation into a generation instruction template, and inputting the obtained generation instruction into a large language model to generate a conditional statement to obtain a query conditional statement; Based on the query condition statement, data query is performed in the target data table to obtain data query results.
[0067] The computer-readable storage medium provided in this embodiment first performs word segmentation processing on the query text to obtain text segmentation, then calculates the semantic similarity between the text segmentation and the data field of the data table, determines the target data table based on the semantic similarity, recognizes the user intention more intelligently and accurately, and improves the accuracy of similarity calculation, and then fills the data field in the target data table mapped with the text segmentation into the generation instruction template, and inputs the obtained generation instruction into the large language model to generate conditional statements to obtain query conditional statements, and realizes accurate and intelligent conversion of keywords in the query text to query conditional statements, and finally performs data query in the target data table based on the query conditional statements to obtain data query results. This solution improves the understanding of natural language problems, ensures the selection of the most appropriate data table for query, and generates preliminary screening SQL statements based on specific methods to narrow the data range, reduce the subsequent calculation burden, and greatly improve the data calculation and reasoning capabilities of complex problems.
[0068] The computer-readable storage medium includes a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0069] The computer-readable storage medium provided in an embodiment of this specification can implement each process in the aforementioned method embodiment and achieve the same functions and effects, which will not be repeated here.
[0070] Furthermore, another embodiment of the present specification also provides a computer program product, which implements the following process when executed by a processor: Perform word segmentation on the query text to obtain text segmentation; Calculating the semantic similarity between the text segmentation and the data field of the data table, and determining the target data table based on the semantic similarity; Filling the data fields in the target data table that are mapped to the text segmentation into a generation instruction template, and inputting the obtained generation instruction into a large language model to generate a conditional statement to obtain a query conditional statement; Based on the query condition statement, data query is performed in the target data table to obtain data query results.
[0071] The computer program product provided in this embodiment first performs word segmentation processing on the query text to obtain text segmentation, then calculates the semantic similarity between the text segmentation and the data field of the data table, determines the target data table based on the semantic similarity, recognizes the user intention more intelligently and accurately, and improves the accuracy of similarity calculation, and then fills the data field in the target data table mapped with the text segmentation into the generation instruction template, and inputs the obtained generation instruction into the large language model to generate conditional statements to obtain query conditional statements, and realizes accurate and intelligent conversion of keywords in the query text to query conditional statements, and finally performs data query in the target data table based on the query conditional statements to obtain data query results. This solution improves the understanding of natural language problems, ensures the selection of the most appropriate data table for query, and generates preliminary screening SQL statements based on specific methods to narrow the data range, reduce the subsequent calculation burden, and greatly improve the data calculation and reasoning capabilities of complex problems.
[0072] The computer program product provided in one embodiment of this specification can implement each process in the aforementioned method embodiment and achieve the same functions and effects, which will not be repeated here.
[0073] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0074] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0075] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0076] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0077] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0078] Memory may include non-permanent storage in a computer-readable storage medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable storage medium.
[0079] Computer-readable storage media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer-readable storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable storage media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0080] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0081] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0082] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A data query processing method, characterized in that: The method comprises: Perform word segmentation on the query text to obtain text segmentation; Calculating the semantic similarity between the text segmentation and the data field of the data table, and determining the target data table based on the semantic similarity; Filling the data fields in the target data table that are mapped to the text segmentation into a generation instruction template, and inputting the obtained generation instruction into a large language model to generate a conditional statement to obtain a query conditional statement; Based on the query condition statement, data query is performed in the target data table to obtain data query results.
2. The data query processing method according to claim 1, characterized in that: The data fields of the data table include standard data fields and synonymous data fields; wherein the standard data fields are obtained by standardizing the full data fields based on the standardization rules; The synonymous data field is obtained in the following manner: Extracting the field semantics of the full data field, and filling the field semantics and the full data field into an extraction instruction template to obtain an extraction instruction; The extraction instruction is input into the large language model to perform field extraction to obtain the synonymous data field.
3. The data query processing method according to claim 1, characterized in that: The calculating the semantic similarity between the text segmentation and the data field of the data table includes: Grouping the data fields based on field types of the data fields to obtain entity data fields and dimension data fields; Calculating semantic similarity between the text segmentation and the entity data field and the dimension data field respectively to obtain entity semantic similarity and dimension semantic similarity; The semantic similarity is calculated based on the weight of the entity semantic similarity and the weight of the dimension semantic similarity.
4. The data query processing method according to claim 1, characterized in that: The performing a data query in the target data table based on the query condition statement to obtain a data query result includes: Fill the query condition statement into the SQL statement template to obtain an SQL statement; Based on the SQL statement, data query is performed in the target database table to obtain the data query result.
5. The data query processing method according to claim 1, characterized in that: The query text includes a dialogue question; Correspondingly, after the step of performing a data query in the target data table based on the query condition statement and obtaining a data query result is executed, the step further includes: An answer is generated based on the data query result to obtain a dialogue answer to the dialogue question.
6. The data query processing method according to claim 1, characterized in that: After the step of performing a data query in the target data table based on the query condition statement to obtain a data query result is executed, the method further includes: Extracting text features of the query text, and determining the operation logic of each target data in the data query result according to the text features; The target data are operated based on the operation logic to obtain operation results.
7. The data query processing method according to claim 1, characterized in that: The word segmentation processing of the query text to obtain the text word segmentation includes: Obtaining the query text; The query text is input into the word segmentation model for word segmentation processing to obtain the text segmentation.
8. A data query processing device, characterized in that: include: A word segmentation processing module is configured to perform word segmentation processing on the query text to obtain text segmentation; A similarity calculation module is configured to calculate the semantic similarity between the text segmentation and the data field of the data table, and determine the target data table based on the semantic similarity; A conditional statement generation module is configured to fill the data fields in the target data table mapped to the text segmentation into a generation instruction template, and input the obtained generation instruction into a large language model to generate a conditional statement to obtain a query conditional statement; The data query module is configured to perform data query in the target data table based on the query condition statement to obtain data query results.
9. A data query processing device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer executable instructions, and when the computer executable instructions are executed on the processor, the steps of the method described in any one of claims 1 to 7 can be implemented.
10. A computer-readable storage medium having computer-executable instructions stored therein, characterized in that: When the computer executable instructions are executed by a processor, the steps of the method described in any one of claims 1 to 7 can be implemented.
11. A computer program product, characterized in that The computer program product comprises a data query processing program, and when the data query processing program is executed by a processor, the steps of the method described in any one of claims 1 to 7 can be implemented.
Citation Information
Patent Citations
Method for generating structured query statement based on natural language
CN111813802A
SQL (Structured Query Language) statement generation method and device based on large language model, equipment and medium
CN117743371A
Database query statement generation method and device, equipment and medium
CN118093629A
Data query method based on large model
CN118656385A