Data query method and system

Through the target text analysis model based on deep learning, extracting key information in database queries and generating query statements, the problems of low database query efficiency and single presentation method are solved, efficient data retrieval and diversified result presentation are achieved, and the decision-making layer is met Quick query requirements.

CN119003797AInactive Publication Date: 2024-11-22YUNNAN SHIKUN TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411479166.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2024-11-22
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, database query efficiency is low, difficult to deploy and single presentation method, which is difficult to meet the demand for decision-making levels to quickly visualize data query.

Method used

A target text analysis model based on deep learning is adopted to obtain key information in the query text, generate a target query statement, and perform data queries based on the statement to provide a diverse result presentation method.

Benefits of technology

It improves the efficiency of database query, reduces the difficulty of query statement generation, provides a diverse way of presenting results, and allows the decision-making level to view and master information more intuitively.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119003797A_ABST
    Figure CN119003797A_ABST
Patent Text Reader

Abstract

The invention provides a data query method and system, and the method comprises the steps: obtaining a query text, and extracting key information in the query text; performing command analysis on the key information to generate a target query statement corresponding to the query text; and executing data query based on the target query statement to obtain a data query result. According to the method, the input corpus is analyzed by adopting the word embedding model based on pre-training and the classification task to obtain the expected query statement, so that the difficulty of generating the query statement is greatly reduced, corpus analysis can be completed without a large model, and the deployment difficulty is greatly reduced; the generation of the query statement is realized by adopting a deep learning model, so that the query efficiency is improved, and the retrieval difficulty is reduced; and diversified result presentation modes are adopted, so that the data presentation capability is improved, and managers can make decisions and grasp real-time information better.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a data query method and system. Background Art

[0002] In traditional technology, when it is necessary to query the content of a database, it is mainly achieved through manually written database query statements, which requires staff to have the ability to use basic database statements and write query statements for query. However, this method is cumbersome and takes a lot of time, resulting in low efficiency in generating database query statements. When it comes to querying different contents of multiple databases, the efficiency is further reduced, and the query results usually do not have a visual effect. When decision-making managers need to quickly query and visualize certain data, the existing technical solutions have low query efficiency and poor presentation effects.

[0003] At present, in order to solve this problem, some technologies use large language models to analyze the input corpus and finally derive SQL query commands. This method solves the problem of low efficiency of manually written query statements, but large models are difficult to deploy and train, and are not friendly to general enterprises or units. In addition, the presentation method is also single. Summary of the invention

[0004] To this end, the present invention provides a data query method and system, aiming to solve the problems of low efficiency, difficult deployment and single presentation method when performing data query on an existing database in the prior art.

[0005] To achieve the above objectives, the present invention adopts the following technical solutions: According to a first aspect of the present invention, the present invention provides a data query method, the method comprising: Step S1: obtaining a query text and extracting key information from the query text; Step S2: performing command parsing on the key information to generate a target query statement corresponding to the query text; Step S3: Execute data query based on the target query statement to obtain data query results.

[0006] Optionally, extracting key information from the query text includes: Build a target text parsing model based on deep learning; Parsing the query text using the target text parsing model to obtain key information; The key information includes the query object, query content, presentation form, query time mark, query start time and query end time in the query text.

[0007] Optionally, the building of a target text parsing model based on deep learning includes: Train a word embedding model based on a text corpus and obtain the word embedding layer as the output connection of the input layer; Building a feature extraction layer based on a convolutional neural network and a long short-term memory network as an output connection of the word embedding layer; Building a feature fusion layer based on the target detection adaptive network as an output connection of the feature extraction layer; Constructing a feature dimension-increasing layer as an output connection of the feature fusion layer, and connecting the output layer to obtain a text parsing model for performing multi-branch classification / regression tasks; The text parsing model is trained to obtain a target text parsing model.

[0008] Optionally, the using the text parsing model to parse the query text to obtain key information includes: Inputting the query text into the text parsing model, and using the word embedding layer to perform feature vectorization on the query text to obtain a text vector; Using the convolutional neural network and the long short-term memory network to extract features from the text vector respectively, to obtain a first text feature and a second text feature; Using the object detection adaptive network to perform feature fusion on the first text feature and the second text feature, and perform feature dimension upgrading to obtain a fused feature; Perform a multi-branch classification task based on the fusion features to obtain a query object, query content, presentation form and / or query time mark; and A multi-branch regression task is performed based on the fusion features to obtain a query start time and / or a query end time.

[0009] Optionally, the training of the text parsing model includes: Obtaining a training sample set, and using the training sample set to train the text parsing model; wherein, fine-tuning is performed on a preset learning rate of the word embedding model; and / or, Using cross entropy loss for supervised learning of multi-branch classification tasks; and / or, The mean square error loss function is used for supervised learning for multi-branch regression tasks.

[0010] Optionally, the method further comprises: When performing the multi-branch classification task based on the fusion feature, an abnormal branch is added for marking that no valid information is obtained in this text parsing.

[0011] Optionally, before performing command parsing on the key information, the method further includes: Perform command inspection on the key information to determine whether there is any abnormality; If there is no abnormality, continue to step S2; If there is an abnormality, step S1 is executed again until the key information is normal.

[0012] Optionally, the performing command parsing on the key information includes: Use the preset parsing rules to parse the key information in Json format and get the SQL statement.

[0013] Optionally, the method further comprises: Visualize or textualize the data query results using the presentation format specified in the key information; The presentation form includes at least one of a table form, an image form and a text form.

[0014] According to a second aspect of the present invention, the present invention provides a data query system, the system comprising: An information extraction module, used to obtain a query text and extract key information from the query text; A statement parsing module, used to perform command parsing on the key information and generate a target query statement corresponding to the query text; The data query module is used to execute data query based on the target query statement to obtain data query results.

[0015] The present invention adopts the above technical solution and has at least the following beneficial effects: Through the scheme of the present invention, the query text is obtained, and the key information in the query text is extracted; the key information is parsed to generate the target query statement corresponding to the query text; the data query is executed based on the target query statement to obtain the data query result. Therefore, the present invention parses the query text input by the inquirer to obtain the expected query statement, improves the efficiency of data retrieval based on the query statement, and diversifies the result presentation method so that the inquirer can view the data and grasp the information more intuitively.

[0016] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, 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 of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 A schematic diagram showing a flow chart of a data query method provided by an embodiment of the present invention is shown; Figure 2 A schematic diagram showing the structure of a text parsing model provided by an embodiment of the present invention is shown; Figure 3 A schematic diagram showing the structure of a data query system provided by an embodiment of the present invention is shown; Figure 4 A schematic diagram showing the structure of a data query system provided by another embodiment of the present invention is shown; Figure 5 A schematic diagram of the physical structure of a computer device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0019] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0020] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article 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, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0021] The embodiment of the present invention provides a data query method, such as Figure 1 As shown, at least the following steps S101 to S103 may be included: Step S101, obtaining a query text and extracting key information from the query text.

[0022] In the embodiment of the present invention, the query text refers to a piece of text entered by the queryer when querying certain data in an existing database, for example: querying the sales changes of XXX products in the past three years. Specifically, to extract the key information in the query text, it is necessary to first build a target text parsing model based on deep learning; then use the target text parsing model to parse the query text to obtain the key information.

[0023] Among them, key information is effective information for data query on the database, which may include the query object, query content, presentation form, query time mark, query start time and query end time in the query text.

[0024] The embodiment of the present invention parses the query text based on the target text parsing model, obtains the inference result, and generates a text in Json format. The code example is as follows: { Search_id: 1; Search_content: sole; Time_flag: 3; Start_time: 0; End_time: 0; Performe_type: graph; } In the above Json content, each item represents multiple key information obtained from the text parsing. Search_id is the id of the query object. This character is used to identify a specific object in the database, that is, XX product; Search_content is the query content. This character is used to indicate that the field "sole" of the storage object with id equal to 1 in the database needs to be queried; Time_flag is the query time flag. When the query time flag is not 0, this character is used to indicate the value of the query at several time nodes in the past since the last record time point. For example, the value corresponding to this character in Json is 3, and the time point of the last record is 2023, then the data of 2023, 2022, and 2021 are queried; Start_time is the query start time. When the query time flag is 0, this character is used to indicate the start time of the data record to be queried, such as 2015; End_time is the query end time. When the query time flag is 0, this character is used to indicate the end time of the data record to be queried, such as 2021; Performe_type is the presentation form, which can include three categories: table, image, and text.

[0025] like Figure 2As shown, it is a structural schematic diagram of the target text parsing model based on deep learning constructed in an embodiment of the present invention. The model construction process specifically includes: training a word embedding model based on a text corpus to obtain a word embedding layer as an output connection of the input layer; constructing a feature extraction layer based on a convolutional neural network and a long short-term memory network as an output connection of the word embedding layer; constructing a feature fusion layer based on a target detection adaptive network as an output connection of the feature extraction layer; constructing a feature dimensionality enhancement layer as an output connection of the feature fusion layer, and connecting the output layer to obtain a text parsing model for performing multi-branch classification / regression tasks; training the text parsing model to obtain a target text parsing model.

[0026] In the embodiment of the present invention, the word embedding model can be first trained based on the open source Chinese corpus to obtain a word embedding layer with good performance. The word embedding layer is used to embed the input query text into the vector space, that is, feature vectorization, to obtain a text vector. At the same time, the embodiment of the present invention regards the text parsing task as a multi-branch task, that is, different information extraction is performed based on an input query text. Among them, the branches corresponding to the query object, query content, query time mark and presentation mode are classification tasks, and the branches corresponding to the query start time and query deadline are regression tasks. In order to fully extract local and global information in the query text, the embodiment of the present invention uses CNN convolutional neural network and LSTM long short-term memory network to extract features from the text vector respectively, obtain the first text feature and the second text feature, and then convert the first text feature and the second text feature to the same shape, and then use the ASFF target detection adaptive network feature fusion method to fuse the first text feature and the second text feature, perform a feature dimensionality upgrade to obtain a fusion feature, increase the number of feature vectors, and facilitate the full representation of text information. Finally, multi-branch classification and multi-branch regression tasks are performed based on the fusion features to obtain key information.

[0027] Furthermore, when performing a multi-branch classification task based on fusion features, an abnormal branch can be added to identify the branch that did not extract valid information in this text parsing. In other words, when setting the number of categories of the classification task branch, a category can be added to identify the branch that did not extract valid information in this information extraction, so as to facilitate the detection of the abnormality in the subsequent command inspection.

[0028] It should be noted that after the text parsing model is built, it is still necessary to train the text parsing model. Specifically, obtain a training sample set and use the training sample set to train the text parsing model. It should be noted that in the process of training the text parsing model, the word embedding model does not need to be retrained, and only needs to set a very small learning rate for fine-tuning. In addition, the cross entropy loss function can be used for supervised learning for multi-branch classification tasks; the mean square error loss function can be used for supervised learning for multi-branch regression tasks.

[0029] Step S102: perform command parsing on the key information to generate a target query statement corresponding to the query text.

[0030] Before parsing the key information, you can also perform command verification on the key information to determine whether there are any anomalies. Command verification is mainly used to eliminate unclear requirements in the original command or to determine the content that is incorrectly recognized by the target text parsing model.

[0031] If there is no anomaly in the key information, continue to execute the subsequent command parsing steps; if there is anomaly in the key information, it is necessary to re-execute step S101, that is, re-enter the query text to extract the key information until there is no anomaly in the key information.

[0032] Furthermore, the command parsing in the embodiment of the present invention refers to parsing the key information in the Json format using preset parsing rules to obtain a target query statement, which may specifically be a SQL statement.

[0033] Step S103, executing data query based on the target query statement to obtain data query results.

[0034] After the command parsing is completed, the data query is executed in the database based on the generated SQL statement to obtain the data query results, and the data query results are visualized or textualized using the presentation format specified in the key information. That is, the data query results are displayed to the queryer according to the presentation format specified in Json.

[0035] Furthermore, the queryer can check the presented data query results. If they meet expectations, the query ends. If they do not meet the expected commands, such as the query time, the task can be re-executed until the expected data query results are obtained.

[0036] The embodiment of the present invention provides a data query method, including obtaining a query text, extracting key information from the query text; performing command parsing on the key information, generating a target query statement corresponding to the query text; executing a data query based on the target query statement, and obtaining a data query result. Through the present invention, a pre-trained word embedding model and classification task are used to parse the input corpus to obtain an expected query statement, which greatly reduces the difficulty of generating query statements, and can complete corpus analysis without a large model, greatly reducing the deployment difficulty; the generation of query statements is implemented by a deep learning model, which improves query efficiency and reduces retrieval difficulty; a variety of result presentation methods are used to improve data presentation capabilities, so that managers can make better decisions and grasp real-time information.

[0037] Further, as Figure 1 The specific implementation of the present invention provides a data query system, such as Figure 3 As shown, the system may include: an information extraction module 310 , a sentence parsing module 320 and a data query module 330 .

[0038] The information extraction module 310 can be used to obtain the query text and extract key information from the query text; The statement parsing module 320 can be used to parse the key information and generate a target query statement corresponding to the query text; The data query module 330 can be used to execute data query based on the target query statement to obtain data query results.

[0039] Alternatively, if Figure 4 As shown, another embodiment of the present invention provides a data query system, which further includes: an abnormality judgment module 340 and an information presentation module 350.

[0040] The abnormality judgment module 340 can be used to perform command inspection on key information to determine whether there is an abnormality; If there is no abnormality, continue to step S2; If there is an abnormality, step S1 is executed again until the key information is normal.

[0041] The information presentation module 350 may be used to visualize or textualize the data query results using the presentation format specified in the key information; The presentation form includes at least one of a table form, an image form and a text form.

[0042] Optionally, the information extraction module 310 may also be used to construct a target text parsing model based on deep learning; Use the target text parsing model to parse the query text and obtain key information; Among them, the key information includes the query object, query content, presentation form, query time mark, query start time and query end time in the query text.

[0043] Optionally, the information extraction module 310 may also be used to train a word embedding model based on a text corpus, and obtain a word embedding layer as an output connection of the input layer; A feature extraction layer is built based on a convolutional neural network and a long short-term memory network as the output connection of the word embedding layer; Construct a feature fusion layer based on the target detection adaptive network as the output connection of the feature extraction layer; Construct a feature dimension-increasing layer as the output connection of the feature fusion layer, and connect the output layer to obtain a text parsing model for performing multi-branch classification / regression tasks; The text parsing model is trained to obtain the target text parsing model.

[0044] Optionally, the information extraction module 310 may also be used to input the query text into the text parsing model, and perform feature vectorization on the query text using the word embedding layer to obtain a text vector; Using a convolutional neural network and a long short-term memory network to extract features from the text vector respectively, to obtain a first text feature and a second text feature; Using the object detection adaptive network to fuse the first text feature and the second text feature, and perform feature dimension upgrading to obtain a fused feature; Perform multi-branch classification tasks based on the fusion features to obtain query objects, query contents, presentation forms and / or query time marks; and, A multi-branch regression task is performed based on the fused features to obtain a query start time and / or a query end time.

[0045] Optionally, the information extraction module 310 may also be used to obtain a training sample set, and use the training sample set to train the text parsing model; wherein fine-tuning is performed on a preset learning rate of the word embedding model; and / or, Using cross entropy loss for supervised learning of multi-branch classification tasks; and / or, The mean square error loss function is used for supervised learning for multi-branch regression tasks.

[0046] Optionally, the information extraction module 310 may also be used to add an abnormal branch for identifying that no valid information is obtained in this text parsing when performing a multi-branch classification task based on fusion features.

[0047] Optionally, the statement parsing module 320 may also be used to parse the key information in the Json format using preset parsing rules to obtain an SQL statement.

[0048] It should be noted that for other corresponding descriptions of various functional modules involved in a data query system provided in an embodiment of the present invention, reference can be made to Figure 1 The corresponding description of the method shown will not be repeated here.

[0049] Based on the above Figure 1 The method shown, accordingly, an embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the data query method of any of the above embodiments are implemented.

[0050] Based on the above Figure 1 The method shown and Figure 4 The embodiment of the device shown in the figure, the embodiment of the present invention also provides a physical structure diagram of a computer device, such as Figure 5 As shown, the computer device may include a communication bus, a processor, a memory and a communication interface, and may also include an input / output interface and a display device, wherein each functional unit may communicate with each other through the bus. The memory stores a computer program, and the processor is used to execute the program stored in the memory and execute the steps of the data query method in the above embodiment.

[0051] Those skilled in the art can clearly understand that the specific working processes of the systems, devices, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and for the sake of brevity, they are not further described here.

[0052] In addition, the functional units in various embodiments of the present invention may be physically independent of each other, or two or more functional units may be integrated together, or all functional units may be integrated into one processing unit. The above integrated functional units may be implemented in the form of hardware, or in the form of software or firmware.

[0053] A person skilled in the art can understand that if the integrated functional unit is implemented in the form of software and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention can be essentially or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, which includes several instructions to enable a computing device (such as a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention when running the instructions. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.

[0054] Alternatively, all or part of the steps of implementing the aforementioned method embodiments may be accomplished by hardware associated with program instructions (such as a computing device such as a personal computer, a server, or a network device), and the program instructions may be stored in a computer-readable storage medium. When the program instructions are executed by a processor of the computing device, the computing device executes all or part of the steps of the method described in the various embodiments of the present invention.

[0055] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that within the spirit and principles of the present invention, the technical solutions described in the aforementioned embodiments can still be modified, or some or all of the technical features therein can be replaced by equivalents. However, these modifications or replacements do not deviate from the protection scope of the present invention.

Claims

1. A data query method, characterized in that: The method comprises: Step S1: obtaining a query text and extracting key information from the query text; Step S2: performing command parsing on the key information to generate a target query statement corresponding to the query text; Step S3: Execute data query based on the target query statement to obtain data query results.

2. The data query method according to claim 1, characterized in that: The extracting key information from the query text includes: Build a target text parsing model based on deep learning; Parsing the query text using the target text parsing model to obtain key information; The key information includes the query object, query content, presentation form, query time mark, query start time and query end time in the query text.

3. The data query method according to claim 2, characterized in that: The construction of a target text parsing model based on deep learning includes: Train a word embedding model based on a text corpus and obtain the word embedding layer as the output connection of the input layer; Building a feature extraction layer based on a convolutional neural network and a long short-term memory network as an output connection of the word embedding layer; Building a feature fusion layer based on the target detection adaptive network as an output connection of the feature extraction layer; Constructing a feature dimension-increasing layer as an output connection of the feature fusion layer, and connecting the output layer to obtain a text parsing model for performing multi-branch classification / regression tasks; The text parsing model is trained to obtain a target text parsing model.

4. The data query method according to claim 3, characterized in that: The query text is parsed using the text parsing model to obtain key information, including: Inputting the query text into the text parsing model, and using the word embedding layer to perform feature vectorization on the query text to obtain a text vector; Using the convolutional neural network and the long short-term memory network to extract features from the text vector respectively, to obtain a first text feature and a second text feature; Using the object detection adaptive network to perform feature fusion on the first text feature and the second text feature, and perform feature dimension upgrading to obtain a fused feature; Perform a multi-branch classification task based on the fusion features to obtain a query object, query content, presentation form and / or query time mark; and A multi-branch regression task is performed based on the fusion features to obtain a query start time and / or a query end time.

5. The data query method according to claim 3, characterized in that: The training of the text parsing model includes: Obtaining a training sample set, and using the training sample set to train the text parsing model; wherein, fine-tuning is performed on a preset learning rate of the word embedding model; and / or, Using cross entropy loss function for supervised learning for multi-branch classification tasks; and / or, The mean square error loss function is used for supervised learning for multi-branch regression tasks.

6. The data query method according to claim 4, characterized in that: The method further comprises: When performing the multi-branch classification task based on the fusion feature, an abnormal branch is added for marking that no valid information is obtained in this text parsing.

7. The data query method according to claim 4, characterized in that: Before performing command parsing on the key information, the method further includes: Perform command inspection on the key information to determine whether there is any abnormality; If there is no abnormality, continue to step S2; If there is an abnormality, step S1 is executed again until the key information is normal.

8. The data query method according to claim 1, characterized in that:The command parsing of the key information includes: Use the preset parsing rules to parse the key information in Json format and get the SQL statement.

9. The data query method according to any one of claims 1 to 8, characterized in that: The method further comprises: Visualize or textualize the data query results using the presentation format specified in the key information; The presentation form includes at least one of a table form, an image form and a text form.

10. A data query system, characterized in that: The system comprises: An information extraction module, used to obtain a query text and extract key information from the query text; A statement parsing module, used to perform command parsing on the key information and generate a target query statement corresponding to the query text; The data query module is used to execute data query based on the target query statement to obtain data query results.

Citation Information

Patent Citations

  • Main data-oriented natural language query and report intelligent generation method

    CN110674164A

  • Structured query statement generation method and device and application

    CN116991877A

  • Knowledge graph-based medicine supply chain question-answering method and system

    CN117251543A

  • SQL statement generation method and system based on deep learning

    CN118132592A

  • Information interaction method and device

    CN118332097A