Data query method and device, storage medium and computer program product
By analyzing the meaning and part of speech in the target text and using a large language model to generate query statements, the problem of low efficiency and high cost of manually writing SQL statements is solved, and automated query is realized, improving efficiency and accuracy.
Patent Information
- Application Number
- CN202411472716.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-01-17
AI Technical Summary
In the prior art, when querying data by manually writing SQL statements, it is inefficient and costly, and there is a lack of effective solutions.
By analyzing the meaning and part of speech in the target text, determining the text type, and using the pre-trained large language model to generate query statements, query directly in the database, generate and execute query statements to obtain the results.
No manual intervention is required, which greatly improves query efficiency and accuracy and reduces labor costs.
Smart Images

Figure CN119322787A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of electronic information technology, and in particular to a data query method and device, a storage medium, and a computer program product. Background Art
[0002] In the process of software development, there is often a need to query some temporary report data, such as order logistics status, business reports, etc. Usually, when querying, SQL (Structured Query Language) statements are manually written based on the query keywords provided by the customer, and the SQL statements are run to query the corresponding database. However, this method requires the operator to understand the writing rules of SQL statements, and the entire query process is manually operated, so it takes a lot of time and labor costs.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] The embodiments of the present application provide a data query method and device, a storage medium, and a computer program product to at least solve the technical problem that the related technology uses manual query statements to query data, resulting in low query efficiency and high labor costs.
[0005] According to one aspect of an embodiment of the present application, a data query method is provided, comprising: obtaining a target text input by a target object, wherein the target text includes a plurality of words; determining the meaning and part of speech of each word in the target text, and determining the text type of the target text based on the meaning and part of speech of each word, wherein the text type includes: query text or non-query text; in the case where the text type is query text, generating a target query statement based on the analysis result of the target text based on a pre-trained large language model; and outputting the query result obtained by querying a preset database using the target query statement.
[0006] Optionally, the meaning and part of speech of each word in the target text are determined, and the text type of the target text is determined based on the meaning and part of speech of each word, including: for each word, the meaning and part of speech of the word are determined, and whether the word is a query intention word based on the meaning and part of speech of the word; when any one of the multiple words is a query intention word and the part of speech of the word is a verb, the text type of the target text is determined to be a query text; when none of the multiple words are query intention words, or when any one of the multiple words is a query intention word but the part of speech of the word is not a verb, the text type of the target text is determined to be a non-query text.
[0007] Optionally, determining whether a word is a query intent word based on the meaning and part of speech of the word includes: calculating the semantic similarity between the meaning of the word and the meaning of any query intent word in a preset query intent vocabulary; judging whether the semantic similarity is greater than a preset similarity threshold; if the semantic similarity is greater than the similarity threshold, determining that the word is a query intent word; if the semantic similarity is not greater than the similarity threshold, determining that the word is not a query intent word.
[0008] Optionally, before generating a target query statement based on the analysis results of the target text based on the pre-trained large language model, the method also includes: determining whether the target object has the authority to query in a preset database; if the target object does not have the authority to query in the preset database, feeding back a query failure prompt message to the target object, wherein the query failure prompt message is used to prompt the target object that it does not have the authority to query in the preset database.
[0009] Optionally, a target query statement is generated based on the analysis result of the target text based on a pre-trained large language model, including: using the pre-trained large language model to analyze the target text to obtain a query intent category corresponding to the target text; determining a query statement template corresponding to the query intent category, wherein the query statement template includes multiple slots, and each slot corresponds to a type of entity; using a named entity recognition algorithm to determine multiple named entities in the target text, and filling the multiple named entities into the multiple slots in the query statement template to generate a target query statement.
[0010] Optionally, the query results obtained by querying the preset database using the target query statement are output, including: querying the preset database using the target query statement to obtain the query results; converting the query results into a data chart using a data visualization tool, and outputting the data chart.
[0011] Optionally, before outputting the data chart, the method further includes: generating watermark information based on the object identifier of the target object; adding the watermark information to the data chart using a lowest bit watermark algorithm, and outputting the data chart with the watermark information added.
[0012] According to another aspect of an embodiment of the present application, a data query device is also provided, including: an acquisition module for acquiring a target text input by a target object, a determination module for determining the meaning and part of speech of each word in the target text, and determining the text type of the target text based on the meaning and part of speech of each word, wherein the text type includes: query text or non-query text; a generation module for generating a target query statement based on the analysis result of the target text by a pre-trained large language model when the text type is a query text; and an output module for outputting the query result obtained by querying a preset database using the target query statement.
[0013] According to another aspect of an embodiment of the present application, a non-volatile storage medium is further provided, the non-volatile storage medium including a stored computer program, wherein the device where the non-volatile storage medium is located executes the above-mentioned data query method by running the computer program.
[0014] According to another aspect of an embodiment of the present application, a computer program product is further provided. The computer program product includes a stored computer program, wherein the computer program implements the above-mentioned data query method when executed by a processor.
[0015] In the embodiment of the present application, the meaning and part of speech of each word in the text are analyzed to determine whether the type of the text is a query text; when the type of the text is a query text, the target text is analyzed using a large language model, and a corresponding target query statement is generated according to the analysis result; the corresponding database is operated according to the target query statement to obtain the query result, and the query result is fed back to the target object. The entire query process does not require human intervention, which greatly improves the query efficiency and query accuracy, thereby solving the technical problem that the related technology manually writes query statements to query data, resulting in low query efficiency and high labor costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0017] Figure 1 It is a hardware structure block diagram of an optional computer terminal (or mobile device) for implementing a data query method according to an embodiment of the present application;
[0018] Figure 2 is a flowchart of an optional data query method according to an embodiment of the present application;
[0019] Figure 3 is a schematic diagram of an optional output data chart according to an embodiment of the present application;
[0020] Figure 4 is a schematic diagram of an optional output data chart according to an embodiment of the present application;
[0021] Figure 5 is a schematic structural diagram of an optional data query device according to an embodiment of the present application;
[0022] Figure 6 It is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0023] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0025] In addition, the relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. For example, an interface is set up between this system and the relevant user or organization. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.
[0026] In order to better understand the embodiments of the present application, the technical terms involved in the embodiments of the present application are explained as follows:
[0027] Large Language Model (LLM) refers to a large-scale language model that uses machine learning techniques to understand and generate natural language. These models are usually based on deep learning algorithms and are trained using large-scale text data to more accurately predict the likelihood and context of unknown text.
[0028] ASR (Automatic Speech Recognition) technology, also known as speech recognition technology, aims to convert the vocabulary content in human speech into computer-readable input, such as keystrokes, binary codes or character sequences. At present, ASR technology has been widely used in many fields, including but not limited to: voice assistants, telephone customer service automation, speech recognition notes, etc.
[0029] Agent: refers to an agent or entity that can autonomously complete preset goals.
[0030] Named Entity Recognition (NER) algorithm is a subtask of information extraction, which aims to locate and classify named entities in text into pre-defined categories, such as people, organizations, locations, time expressions, quantities, monetary values, percentages, etc.
[0031] Example 1
[0032] According to an embodiment of the present application, a method embodiment of a data query method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0033] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal (or mobile device) for implementing a data query method. Figure 1 As shown, the computer terminal 10 (or mobile device 10) may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0034] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or mobile device). As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0035] The memory 104 can be used to store software programs and modules of application software, such as program instructions / data storage devices corresponding to the data query method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the data query method of the above-mentioned application is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0036] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0037] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).
[0038] In the above operating environment, Figure 2 is a flow chart of an optional data query method according to an embodiment of the present application, such as Figure 2 As shown, the method at least includes steps S202-S208, wherein:
[0039] Step S202: obtaining the target text input by the target object.
[0040] The target text is composed of multiple words combined according to certain grammatical rules.
[0041] Step S204, determining the meaning and part of speech of each word in the target text, and determining the text type of the target text according to the meaning and part of speech of each word.
[0042] Since the meaning of each word in the target text may be different, in order to understand the specific intention (what meaning is expressed) of the target text input by the target object, it is necessary to analyze the meaning (i.e. the meaning, concept or specific meaning expressed by the word in a specific context) and part of speech (i.e. the role or function played by the word in the text) of each word in the target text, so as to determine the text type of the target text, where the text type can be divided into query text (i.e. text used for query data function) and non-query text (i.e. other types of text except query text in multiple types of text).
[0043] Step S206: When the text type is a query text, a target query statement is generated based on the analysis result of the target text by the pre-trained large language model.
[0044] Among them, the above-mentioned large language model (LLM) can use machine learning technology to understand and analyze the target text to obtain the corresponding text analysis results, and then construct a target query statement according to the text analysis results, wherein the target query statement can be in the form of an SQL statement.
[0045] Step S208: outputting the query result obtained by querying the preset database using the target query statement.
[0046] Specifically, the target query statement is executed to query in the corresponding preset database, and the query result is obtained, and finally the query result is fed back to the client of the target object to complete the data query.
[0047] The above method of this embodiment is further introduced below.
[0048] As an optional implementation, in the technical solution provided in the above step S202, the method may include:
[0049] Acquire initial information input by the target object, wherein the type of the initial information includes: voice form or text form;
[0050] When the type of the initial information is in voice form, the initial information in voice form is converted into text form by using ASR speech recognition technology to obtain an initial text, and the initial text is preprocessed to obtain a target text;
[0051] When the type of the initial information is in text form, directly preprocess the initial information to obtain the target text.
[0052] Among them, the above preprocessing operations include but are not limited to: removing useless characters (such as special characters, HTML tags, URLs, etc.), removing stop words (such as "of", "and", "is", etc.), converting to lowercase (i.e., converting all characters to lowercase to eliminate differences caused by case), stemming or lemmatization (i.e., restoring the vocabulary to its basic form. For example, restoring "running" to "run" and "dogs" to "dog"), etc.
[0053] As an alternative implementation, in the technical solution provided in the above step S204, the method may include:
[0054] For each word, determine the meaning and part of speech of the word, and determine whether the word is a query intention word based on the meaning and part of speech of the word.
[0055] When any one of the multiple words is a query intention word and the part of speech of the word is a verb, determine that the text type of the target text is a query text.
[0056] For example, if the target text is "Please query Zhang San's phone bill information for July", since the word "query" among the multiple words "Zhang San", "query", "July", and "phone bill information" in the target text is a query intention word, and the role of this word in the entire target text is a verb, therefore, it can be determined that the target text is a query text.
[0057] When none of the multiple words is a query intention word, or any one of the multiple words is a query intention word but the part of speech of the word is not a verb, determine that the text type of the target text is a non-query text.
[0058] For example, if the target text is "Please compare the data differences between query database 1 and query database 2", since the word "query" among the multiple words "compare", "query", "database 1", "database 2", and "data differences" in the target text is a query intention word, but the role of this word in the entire target text is not a verb but a noun, therefore, it can be determined that the target text is a non-query text.
[0059] Another example, if the target text is "Excuse me, what time is it in Beijing time now", since none of the words "now", "Beijing time", and "what time" among the multiple words in the target text is a query intention word, therefore, it can be determined that the target text is a non-query text.
[0060] It should be noted that, for non-query text, the text can be directly processed without subsequent query operations.
[0061] For example, the embodiment of the present application may determine whether a word is a query intention word according to the following method, including:
[0062] First, the semantic similarity between the meaning of the word and the meaning of any query intent word in a preset query intent vocabulary is calculated, wherein the query intent vocabulary includes common query intent words such as "query", "search", "statistics", etc.
[0063] Next, determining whether the word meaning similarity is greater than a preset similarity threshold;
[0064] When the word meaning similarity is greater than the similarity threshold, the word is determined to be a query intention word;
[0065] When the word meaning similarity is not greater than the similarity threshold, it is determined that the word is not a query intention word.
[0066] As an optional implementation, in the technical solution provided in the above step S206, in order to ensure the security of the data, the user's query permissions are usually set. For example, a user can only view the order information of his or her orders on a shopping platform, while the customer service staff of a store can view the order information of customers who have placed orders in his or her store.
[0067] Therefore, when the target object queries data, it is taken into account that different objects have different query permissions. Therefore, before generating a target query statement based on the analysis results of the target text based on the pre-trained large language model, it is also possible to determine whether the target object has the permission to query in the preset database; if the target object does not have the permission to query in the preset database, a query failure prompt message is fed back to the target object, wherein the query failure prompt message is used to prompt the target object that it does not have the permission to query in the preset database.
[0068] For example, the target text input by user A is "query user B's phone card points information". Since "query" in the target text is a query intent word, and the word plays a role as a verb in the entire target text, the target text is a query text. However, user A does not have the authority to query in the database corresponding to user B (the database stores all information related to user B), so the only feedback to user A is the query failure prompt message "no authority to obtain user B's phone card points information".
[0069] As an optional implementation, in the technical solution provided in the above step S206, the method may include:
[0070] Use the pre-trained large language model to analyze the target text and obtain the query intent category corresponding to the target text;
[0071] Determine a query statement template corresponding to the query intent category, wherein the query statement template includes a plurality of slots, and each slot corresponds to a type of entity;
[0072] A named entity recognition algorithm is used to determine multiple named entities in the target text, and the multiple named entities are filled into multiple slots in the query statement template to generate a target query statement.
[0073] In the above embodiment, the target text is analyzed using a large language model to extract features related to the query intent, and based on the extracted features, the query intent category corresponding to the target text (i.e., the target or operation type that the user wants to query) is determined, such as selection (i.e., retrieving information in the database), insertion (i.e., inserting new information into the database), update (modifying existing information in the database), deletion (i.e., deleting information in the database), statistics (i.e., calculating the total value, average value, maximum value or minimum value of certain data in the database), grouping (i.e., grouping the data in the database according to one or more fields), etc. Then, a query statement template corresponding to the query intent category is determined from multiple query statement templates, wherein the query statement template includes multiple slots, and each slot corresponds to a type of entity. Further, a named entity recognition (NER) algorithm is used to identify multiple named entities in the target text, such as names, place names, time, etc., and the identified multiple named entities are filled into multiple slots in the query statement template to generate a target query statement.
[0074] It should be noted that in order to ensure the correctness and efficiency of the query statement, you can also first check whether the target query statement conforms to the grammatical specifications and whether the logic is correct. If so, you can directly use the target query statement to perform data query operations. If there are problems, you can optimize the syntax and logic of the target query statement.
[0075] As an optional implementation, in the technical solution provided in the above step S208, the method may include: using the target query statement to query in a preset database to obtain query results; using a data visualization tool to convert the query results into a data chart, and outputting the data chart.
[0076] Specifically, you can first connect to the corresponding database and use the target query statement to perform a query operation to obtain the query results; then, use a data visualization library (such as the Matplotlib library) to convert the query results into a data chart; finally, output the data chart in the form of a picture.
[0077] For example, the target text input by Zhang San is "Query Zhang San's order information for July", and it is determined through step S204 that the target text is a query text, and Zhang San has the permission to query in his relevant database. The database operation agent can determine the corresponding query statement template according to the intent recognition category obtained by analyzing the target text by the large language model, and fill the multiple named entities obtained by naming the entities of the target text into the corresponding slots of the query statement template to obtain the target query statement: select order_no, order_amount, order_info, order_date, user_name, discount_info from t_order where user_name = 'Zhang San' and order_date >= '2024 / 7 / 1' and order_date <= '2024 / 7 / 31'. The database operation agent operates on the database related to Zhang San through the above target query statement to obtain the query result, and outputs the query result to Zhang San in the form of a data chart as shown in Figure 3 shown.
[0078] Another example is that the target text input by Zhang San is "Query Zhang San's points information", and it is determined through step S204 that the target text is a query text, and Zhang San has the permission to query in his relevant database. The database operation agent can determine the corresponding query statement template according to the intent recognition category obtained by analyzing the target text by the large language model, and fill the multiple named entities obtained by naming the entities of the target text into the corresponding slots of the query statement template to obtain the target query statement: select user_name, level, sex, acc_points, redeemed_points, current_points from t_points where user_name = 'Zhang San'. The database operation agent operates on the database related to Zhang San through the above target query statement to obtain the query result, and outputs the query result to Zhang San in the form of a data chart as shown in Figure 4 shown.
[0079] Furthermore, to ensure the security of the output query data, the embodiment of the present application can also generate watermark information based on the object identifier of the target object; use the least significant bit watermark algorithm to add the watermark information to the data chart and output the data chart with the added watermark information. Among them, the above least significant bit watermark algorithm embeds the watermark information into the least significant bit of the pixel value of the data chart. This method has little visual impact on the picture and can provide effective watermark information.
[0080] Based on the scheme defined by the above steps S202 to S208, it can be known that in the embodiment, the meaning and part of speech of each word in the text are analyzed to determine whether the type of the text is a query text; when the type of the text is a query text, the target text is analyzed using a large language model to obtain the query intent category of the target text, and multiple named entities in the identified target text are filled into the query statement template corresponding to the query intent category to obtain the target query statement; the corresponding database is operated according to the target query statement to obtain the query result, and the query result is fed back to the target object. The entire query process does not require human intervention, which greatly improves the query efficiency and query accuracy, thereby solving the technical problem that the related technology manually writes query statements to query data, resulting in low query efficiency and high labor costs.
[0081] Example 2
[0082] Based on Embodiment 1 of the present application, an embodiment of a data query device is also provided, and the device executes the data query method of the above embodiment when it is running. Figure 5 is a schematic diagram of the structure of an optional data query device according to an embodiment of the present application, such as Figure 5 As shown, the data query device at least includes an acquisition module 52, a determination module 54, a generation module 56 and an output module 58, wherein:
[0083] The acquisition module 52 is used to acquire the target text input by the target object.
[0084] A determination module 54 is used to determine the meaning and part of speech of each word in the target text, and determine the text type of the target text according to the meaning and part of speech of each word, wherein the text type includes: query text or non-query text;
[0085] A generating module 56, configured to generate a target query sentence based on the analysis result of the target text by the pre-trained large language model when the text type is a query text;
[0086] The output module 58 is used to output the query result obtained by querying the preset database using the target query statement.
[0087] It should be noted that the various modules in the above-mentioned data query device can be program modules (for example, a set of program instructions that implement a certain specific function) or hardware modules. For the latter, it can be expressed in the following forms, but is not limited to this: the expression form of each of the above-mentioned modules is a processor, or the functions of each of the above-mentioned modules are implemented by a processor.
[0088] Example 3
[0089] According to an embodiment of the present application, a non-volatile storage medium is further provided, in which a program is stored, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the data query method in Example 1.
[0090] Optionally, the device where the non-volatile storage medium is located implements the following steps by running the program: obtaining a target text input by the target object, wherein the target text includes multiple words; determining the meaning and part of speech of each word in the target text, and determining the text type of the target text based on the meaning and part of speech of each word, wherein the text type includes: query text or non-query text; when the text type is query text, generating a target query statement based on the analysis result of the target text based on a pre-trained large language model; and outputting the query result obtained by querying a preset database using the target query statement.
[0091] According to an embodiment of the present application, a computer program product is also provided, which includes a stored computer program, wherein the computer program implements the data query method in Example 1 when executed by a processor.
[0092] Optionally, the computer program executes the following steps: obtaining a target text input by a target object, wherein the target text includes a plurality of words; determining the meaning and part of speech of each word in the target text, and determining the text type of the target text based on the meaning and part of speech of each word, wherein the text type includes: query text or non-query text; when the text type is query text, generating a target query statement based on the analysis result of the target text based on a pre-trained large language model; and outputting the query result obtained by querying a preset database using the target query statement.
[0093] According to an embodiment of the present application, a processor is also provided, which is used to run a program, wherein the data query method in Example 1 is executed when the program is running.
[0094] Optionally, when the program is running, the following steps are executed: obtaining a target text input by a target object, wherein the target text includes a plurality of words; determining the meaning and part of speech of each word in the target text, and determining the text type of the target text based on the meaning and part of speech of each word, wherein the text type includes: query text or non-query text; when the text type is query text, generating a target query statement based on the analysis result of the target text based on a pre-trained large language model; and outputting the query result obtained by querying a preset database using the target query statement.
[0095] According to an embodiment of the present application, an electronic device is also provided, wherein: Figure 6 is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present application, such as Figure 6As shown, the electronic device includes one or more processors; a memory for storing one or more programs, which, when the one or more programs are executed by the one or more processors, enables the one or more processors to run the programs, wherein the programs are configured to execute the data query method in the above-mentioned embodiment 1 when running.
[0096] Optionally, the processor is configured to execute the following steps through a computer program: obtaining a target text input by a target object, wherein the target text includes multiple words; determining the meaning and part of speech of each word in the target text, and determining the text type of the target text based on the meaning and part of speech of each word, wherein the text type includes: query text or non-query text; when the text type is query text, generating a target query statement based on the analysis results of the target text based on a pre-trained large language model; and outputting the query results obtained by querying a preset database using the target query statement.
[0097] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0098] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0099] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0100] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0101] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0102] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the relevant technology or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.
[0103] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A data query method, characterized in that: include: Acquire a target text input by a target object, wherein the target text includes a plurality of words; Determine the meaning and part of speech of each word in the target text, and determine the text type of the target text according to the meaning and part of speech of each word, wherein the text type includes: query text or non-query text; In the case where the text type is the query text, generating a target query sentence based on the analysis result of the target text by the pre-trained large language model; Output the query result obtained by querying the preset database using the target query statement.
2. The method according to claim 1, characterized in that Determining the meaning and part of speech of each word in the target text, and determining the text type of the target text according to the meaning and part of speech of each word, including: For each of the words, determine the meaning and part of speech of the word, and determine whether the word is a query intention word based on the meaning and part of speech of the word; When any one of the multiple words is the query intention word and the part of speech of the word is a verb, determining the text type of the target text to be the query text; When none of the multiple words is the query intention word, or any one of the multiple words is the query intention word but the part of speech of the word is not a verb, the text type of the target text is determined to be the non-query text.
3. The method according to claim 2, characterized in that Determining whether the word is a query intention word based on the word meaning and part of speech of the word includes: Calculating the similarity between the meaning of the word and the meaning of any query intent word in a preset query intent word library; Determine whether the word meaning similarity is greater than a preset similarity threshold; When the word meaning similarity is greater than the similarity threshold, determining that the word is the query intention word; When the word meaning similarity is not greater than the similarity threshold, it is determined that the word is not the query intention word.
4. The method according to claim 1, characterized in that: Before generating a target query sentence based on the analysis result of the target text by the pre-trained large language model, the method further includes: Determining whether the target object has the authority to query the preset database; In the case that the target object does not have the authority to query the preset database, query failure prompt information is fed back to the target object, wherein the query failure prompt information is used to prompt that the target object does not have the authority to query the preset database.
5. The method according to claim 1, characterized in that Generating a target query statement based on the analysis result of the target text by the pre-trained large language model, including: Analyze the target text using a pre-trained large language model to obtain a query intent category corresponding to the target text; Determine a query statement template corresponding to the query intent category, wherein the query statement template includes a plurality of slots, and each slot corresponds to a type of entity; A named entity recognition algorithm is used to determine a plurality of named entities in the target text, and the plurality of named entities are filled into a plurality of slots in the query statement template to generate the target query statement.
6. The method according to claim 1, characterized in that Outputting the query results obtained by querying the preset database using the target query statement includes: Querying the preset database using the target query statement to obtain the query result; The query result is converted into a data chart using a data visualization tool, and the data chart is output.
7. The method according to claim 6, characterized in that Before outputting the data chart, the method further includes: generating watermark information based on the object identifier of the target object; The watermark information is added to the data chart using a lowest bit watermark algorithm, and the data chart with the watermark information added is output.
8. A data query device, characterized in that: include: The acquisition module is used to obtain the target text input by the target object. A determination module, used to determine the meaning and part of speech of each word in the target text, and determine the text type of the target text according to the meaning and part of speech of each word, wherein the text type includes: query text or non-query text; A generating module, configured to generate a target query statement based on the analysis result of the target text by a pre-trained large language model when the text type is the query text; The output module is used to output the query result obtained by querying the preset database using the target query statement.
9. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a computer program, wherein the device where the non-volatile storage medium is located executes the data query method according to any one of claims 1 to 7 by running the computer program.
10. A computer program product, characterized in that include: A computer program, wherein when the computer program is executed by a processor, the data query method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Query statement generation method and system and storage medium
CN120162428A
ERP query method and device based on natural language understanding, equipment and storage medium
CN120994694A