Intelligent number asking method and device based on natural language, intelligent agent and electronic equipment
By using the coarse-recall model and the large model in combination with human-computer interaction in the intelligent question-and-answer system, the target data model, column names, and column values are determined, and SQL query statements are generated. This solves the problem of limited generation capabilities of the large model and achieves higher question-and-answer accuracy and interactive experience.
Patent Information
- Application Number
- CN202510724482.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2025-09-30
AI Technical Summary
In the existing technology, intelligent question-answering systems are limited by their ability to generate large models, resulting in low accuracy of question-answering results for complex query requirements.
A coarse recall model is used to recall multiple candidate data models from the target database. The target data model, column name, and column value are determined through a large model combined with human-computer interaction. A lightweight JSON statement is generated and converted into an SQL query statement to ultimately obtain accurate query results.
The accuracy of the number-asking results has been improved, and the effectiveness and interactive experience of the intelligent number-asking system have been enhanced.
Smart Images

Figure CN120723799A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, in particular to artificial intelligence fields such as natural language processing, large language models and intelligent search, and more particularly to an intelligent number-asking method, device, intelligent agent and electronic device based on natural language. Background Art
[0002] Smart data query is a data query method that allows users to interact with the system to query data through natural language. The system returns query results in text, charts, etc. based on the user's data query requirements.
[0003] In data query scenarios, limited by the ability to generate large models, simple queries are currently generally supported, such as querying for a specific metric, where the metric is a dimension or metric within the database. However, for more complex query requirements, the limited ability to generate large models can lead to problems such as low accuracy in the query results. Summary of the Invention
[0004] The present disclosure provides a natural language-based intelligent number-asking method, device, intelligent agent, and electronic device.
[0005] According to a first aspect of the present disclosure, there is provided a natural language-based intelligent number-asking method, comprising:
[0006] Based on the query information input by the user, a rough recall model is used to perform recall processing from the target database to obtain multiple candidate data models;
[0007] Determine, by the large model, a target data model, a target column name, and a target column value for querying from the plurality of candidate data models based on the query information and / or human-computer interaction;
[0008] Generate a lightweight data exchange format JSON statement based on the target column name and target column value and the query information through the large model, and convert the JSON statement into an SQL query statement;
[0009] A target query result matching the query information is obtained based on the SQL query statement.
[0010] According to a second aspect of the present disclosure, there is provided an intelligent number-asking device based on natural language, comprising:
[0011] Recall processing is used to recall the query information input by the user using a coarse recall model from the target database to obtain multiple candidate data models;
[0012] A first determination module is configured to determine a target data model, a target column name, and a target column value for querying data from the plurality of candidate data models based on the query information and / or human-computer interaction using a large model;
[0013] a generation module, configured to generate a lightweight data exchange format JSON statement through the large model based on the target column name and target column value and the query information, and convert the JSON statement into an SQL query statement;
[0014] A query module is used to obtain a target query result matching the query information based on the SQL query statement.
[0015] According to a third aspect of the present disclosure, there is provided an intelligent agent, comprising:
[0016] An input module, used for receiving input information;
[0017] a processing module, configured to determine a target task based on the input information received by the input module, determine a large model based on the target task, and execute the method described in the first aspect by calling the large model to obtain output information;
[0018] An output module is used to output the output information obtained by the processing module.
[0019] According to a fourth aspect of the present disclosure, there is provided an electronic device, including:
[0020] at least one processor; and
[0021] a memory communicatively connected to the at least one processor; wherein,
[0022] The memory stores instructions that can be executed by the at least one processor. The instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect.
[0023] According to a fifth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method described in the first aspect.
[0024] According to a sixth aspect of the present disclosure, a computer program product is provided, comprising a computer program, wherein the computer program implements the steps of the method of the first aspect when executed by a processor.
[0025] According to the technical solution disclosed in the present invention, the accuracy of the number-asking results can be greatly improved, the effect and performance of the intelligent number-asking system can be improved, and the interactive experience of the number-asking scenario can be improved.
[0026] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The accompanying drawings are provided to facilitate a better understanding of the present invention and do not constitute a limitation of the present disclosure.
[0028] Figure 1 A flowchart of a natural language-based intelligent number-asking method provided in an embodiment of the present disclosure;
[0029] Figure 2 A flowchart of a natural language-based intelligent number-asking method provided in an embodiment of the present disclosure;
[0030] Figure 3 A schematic diagram of a clarification process provided for an embodiment of the present disclosure;
[0031] Figure 4 An example diagram of asking a user for clarification provided in an embodiment of the present disclosure;
[0032] Figure 5 A flowchart of a natural language-based intelligent number-asking method provided in an embodiment of the present disclosure;
[0033] Figure 6 An example diagram of user interaction effects of the user interface provided by an embodiment of the present disclosure;
[0034] Figure 7 A flowchart of a natural language-based intelligent number-asking method provided in an embodiment of the present disclosure;
[0035] Figure 8 A block diagram of a natural language-based intelligent number-asking device provided in an embodiment of the present disclosure;
[0036] Figure 9 A block diagram of a natural language-based intelligent number-asking device provided in an embodiment of the present disclosure;
[0037] Figure 10 A block diagram of a natural language-based intelligent number-asking device provided in an embodiment of the present disclosure;
[0038] Figure 11 A block diagram of a natural language-based intelligent number-asking device provided in an embodiment of the present disclosure;
[0039] Figure 12 A block diagram of an electronic device according to an embodiment of the present disclosure;
[0040] Figure 13 A block diagram of an intelligent agent provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0041] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0042] The embodiments of the present disclosure relate to artificial intelligence technology fields such as natural language processing, large language models, and intelligent search.
[0043] Artificial Intelligence (AI) is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence.
[0044] Natural Language Processing (NLP) is a key area of research in computer science and artificial intelligence. It studies the theories and methods that enable effective communication between humans and computers using natural language. It is a discipline that uses computer technology to analyze, understand, and process natural language. This discipline uses computers as powerful tools for language research, quantitatively analyzing linguistic information with computer support and providing linguistic descriptions that can be used jointly by humans and computers.
[0045] Large language models (LLMs, also known as large models) are deep learning models trained using large amounts of text data. They can generate natural language text or understand the meaning of text. Large language models can handle a variety of natural language tasks, such as text classification, question-answering, and conversation, and are an important path to artificial intelligence.
[0046] An agent is an agent that can perceive its environment and take actions to achieve specific goals. It can be software, hardware, or a system, and possesses autonomy, adaptability, and interaction. An agent perceives changes in its environment (e.g., through sensors or data input), makes judgments and decisions based on learned knowledge and algorithms, and then executes actions to influence the environment or achieve a predetermined goal.
[0047] It should be noted that the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in the technical solution of this disclosure are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0048] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this disclosure are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions.
[0049] It is worth noting that in the embodiments of the present disclosure, certain software, components, models, etc. that already exist in the industry may be mentioned. They should be considered as exemplary and their purpose is only to illustrate the feasibility of implementing the technical solution of the present disclosure, but it does not mean that the applicant has or will necessarily use the solution.
[0050] The following describes the natural language-based intelligent number-asking method, device, agent, and electronic device according to embodiments of the present disclosure with reference to the accompanying drawings.
[0051] It should be noted that the execution subject of the natural language-based intelligent number-asking method of the embodiment of the present disclosure can be a natural language-based intelligent number-asking device, which can be implemented by software and / or hardware. The device can be configured in an electronic device, and the electronic device can include but is not limited to a terminal, a server, etc.
[0052] It is worth noting that the natural language-based intelligent questioning method of the embodiment of the present disclosure can be implemented by an autonomous agent (AutoAgent) based on a large language model, which can use natural language to interact with humans and machines to solve the problem of low accuracy of intelligent questioning.
[0053] Figure 1 The flowchart of the natural language-based intelligent number-asking method provided in the embodiment of the present disclosure is as follows. Figure 1 As shown, the natural language-based intelligent number-asking method may include but is not limited to the following steps.
[0054] In step 101, based on the query information input by the user, a rough recall model is used to perform recall processing from the target database to obtain multiple candidate data models.
[0055] In the embodiments of the present disclosure, the query information input by the user may refer to a query (or question) input by the user, which may represent the user's data query needs. In one possible implementation, the intelligent questioning method involved in the embodiments of the present disclosure may be applied to an intelligent agent platform, which may provide an input interface through which the user may input the query information. Upon receiving the query information input by the user, a coarse recall model may be used to perform a data model recall process from the target database to obtain multiple candidate data models.
[0056] In the embodiment of the present disclosure, the above-mentioned target database can be understood as a customer database. For example, assuming that the intelligent platform using the method provided by the present disclosure is connected to the database of customer A, the target database can be understood as the database of customer A. The above-mentioned data model can be understood as a data table in the target database, but is not limited thereto. For example, the data model can be associated and filtered by multiple tables. Optionally, the data model is obtained after associating and filtering multiple original tables in advance, and the timing of the association and filtering is earlier than the timing of recall. Exemplarily, each data model in the target database has a corresponding vector index, and the coarse recall model can calculate the similarity between the query information input by the user and the vector index of the data model in the target database, and recall the data models ranked in the top N as candidate data models. N can be a positive integer, for example, N can be 10.
[0057] In step 102, a target data model, a target column name, and a target column value for querying are determined from a plurality of candidate data models through the large model based on query information and / or human-computer interaction.
[0058] In an embodiment of the present disclosure, after the top N data models are recalled as candidate data models through a coarse recall model, a fine-grained recall can be performed among these candidate data models through a large model, that is, the large model can be used to determine which data model from these candidate data models can better answer the question currently input by the user, and select one of the data models for the question. Exemplarily, the target data model for the question can be determined from a plurality of candidate data models based on the query information input by the user through the large model. Alternatively, the target data model for the question can be determined from a plurality of candidate data models based on manual interaction through the large model, for example, a clarification request is issued to the user, and the target data model for the question is determined based on the result of the user's clarification. Alternatively, the target data model for the question can be determined from a plurality of candidate data models based on the query information input by the user and manual interaction.
[0059] It should be noted that, since the big model does not know the specific column selection value of the where condition used in SQL, and because the column selection value is strongly related to business knowledge, a column selection mechanism is needed to tell the big model the specific column value and column name information. Exemplarily, when determining the target data model for the query, the big model can determine the target column name and target column value from the target data model based on query information and / or human-computer interaction. For example, the big model can determine the target column name and target column value from the target data model based on the query information input by the user. For another example, the big model can determine the target column name and target column value from the target data model based on human-computer interaction, such as issuing a clarification request to the user based on the column information in the target data model, and determining the target column name and target column value based on the result of the user's clarification. For another example, the big model can determine the target column name and target column value from the target data model based on the query information input by the user and human-computer interaction.
[0060] In step 103, a lightweight data exchange format JSON statement is generated based on the target column name, target column value, and query information through the large model, and the JSON statement is converted into an SQL query statement.
[0061] In the embodiments of the present disclosure, the method involved in the embodiments of the present disclosure can adopt the NL2JSON solution. Since the JSON format is customized, the JSON statement can be converted into an SQL query statement in any format, which can solve the SQL dialect problem and be compatible with various data sources.
[0062] It should be noted that NL2JSON is a technology or tool that converts natural language (NL) to JSON format. This conversion is commonly used in data analysis and processing to convert data structures described in natural language into JSON format, so that JSON statements can be converted into SQL queries, allowing data queries based on SQL queries to obtain final results.
[0063] In step 104, a target query result matching the query information is obtained based on the SQL query statement.
[0064] In some embodiments, a database query can be performed based on an SQL query statement to obtain SQL query results; a user interface as the target query result is generated based on a JSON statement and the SQL query results through a graphical user interface (GUI, also called a user operation front end), and the user interface is displayed, which can be used to interact with the user.
[0065] For example, a large model can be used to query the database based on the SQL query statement to obtain SQL query results. Through the GUI front end, ECharts (a JavaScript-based data visualization chart library that provides intuitive, vivid, interactive, and customizable data visualization charts) can be used to draw based on JSON statements and SQL query results to obtain a user interface for user viewing and operation interaction. The user interface displays the target query results in response to the query information input by the user, and the user interface can support user operation interaction.
[0066] In the above embodiment, the coarse-grained recall of the data model can be performed through the coarse-grained recall model, and the fine-grained recall can be performed from the coarse-grained recall results based on the query information and / or human-computer interaction through the large model to obtain the target data model and the target column name and target column value. The large model is applied to automatically generate JSON statements, which are then converted into SQL query statements. The SQL query statements are used to perform data queries to obtain target query results that respond to the query information input by the user. Complex calculations involving multiple tables, across rows and columns, year-on-year and year-on-year comparisons, and simultaneous queries of multiple indicators can be supported. The superposition mechanism of coarse and fine recalls combined with human-computer interaction can greatly improve the accuracy of the query results, enhance the effect and performance of the intelligent query system, and enhance the interactive experience of the query scenario.
[0067] Figure 2 The flowchart of the natural language-based intelligent number-asking method provided in the embodiment of the present disclosure is as follows. Figure 2 As shown, the natural language-based intelligent number-asking method may include but is not limited to the following steps.
[0068] In step 201 , based on the query information input by the user, a coarse recall model is used to perform recall processing from the target database to obtain multiple candidate data models.
[0069] Optionally, step 201 may be implemented in any of the implementation methods in the embodiments of the present disclosure. The embodiments of the present disclosure do not limit this and will not be described in detail.
[0070] In step 202, a target data model for the query is determined from multiple candidate data models through a first clarification processing result of the large model based on query information and / or interaction with the user; the first clarification processing result is a clarification result for the data model.
[0071] In some embodiments, a large model can be used to perform recall processing among multiple candidate data models based on query information; when the number of data models recalled by the large model from the multiple candidate data models is multiple, interaction with the user can be performed based on a first clarification request, and the first clarification request can be used for the user to select a data model; after completing the clarification interaction with the user for the data model, a first clarification processing result for the data model can be collected; based on the first clarification processing result for the data model, a target data model can be determined from multiple candidate data models.
[0072] For example, the large model can be used to segment the query information entered by the user to obtain the entity words in the query information. It is worth noting that customer data contains various types of professional terms that are proprietary, such as "five provinces" and "XX No. 1 Chief". The various types of professional terms in the customer data can be used as a proper noun dictionary and fed into the segmentation module in the large model. This facilitates the segmentation module to segment the query information entered by the user based on the proper noun dictionary, achieving correct segmentation, thereby further improving the accuracy of data recall.
[0073] In an embodiment of the present application, when the large model recalls only one data model from multiple candidate data models based on the query information input by the user, the recalled data model can be considered to be more capable of answering the question currently input by the user, and the data model can be determined as the target data model for the query. When the large model recalls multiple data models from multiple candidate data models based on the query information input by the user, in order to improve the accuracy of data model recall, a first clarification request can be sent to the user to determine the target data model by asking the user for clarification.
[0074] In some embodiments, the above-mentioned optional implementation methods of interacting with the user based on the first clarification request may include: determining the data model to be clarified based on the number of candidate data models associated with each entity word in the query information input by the user; generating corresponding clarification words based on the data model to be clarified, and displaying the clarification words to the user; recording the clarification results of the user on the data model to be clarified through the input language user interface (LUI) or clicking.
[0075] It should be noted that in the disclosed embodiments, the agent uses a message flow approach. The agent's historical memory is stored as a list. Each round of clarification requires the previous round's information to be remembered. Only after the interaction with the user is completed can the full clarification results be collected. This requires control over the entire clarification state transition. Clarification supports multiple modules and multiple rounds of clarification. The overall clarification control process is as follows:
[0076] like Figure 3As shown, when the number of data models obtained through the large model recall is 1, it can be considered that there is no need to ask the user for clarification, and the data model can be determined as the target data model and the subsequent step 203 is executed. When the number of data models obtained through the large model recall is multiple, it is considered that it is necessary to ask the user for clarification, and a clarification request can be sent to the user. The clarification request can be presented to the user in the form of a text, and the value of the clarification status field (such as curr_status) is updated to 1 (such as curr_status=1, indicating that the clarification state has been entered), and the value of the clarification round control field (such as need_clarify_num) is set. The value of the clarification round control field is determined by the number of entity words in the query information input by the user and the number of candidate data models associated with each entity word. For example, if there are 3 entity words and the recall results of each entity word are multiple, the value of the clarification round control field can be 3. For another example, if there are 3 entity words, but only one of them has a multiple recall result, the value of the clarification round control field can be 1. Each round of clarification corresponds to a data model to be clarified associated with an entity word to be clarified. After all data models to be clarified associated with the entity word to be clarified are asked to clarify by the user, the results of the full clarification are collected, and the target data model is determined based on the collected results. Optionally, at the end of each round of clarification, the value of the clarification round control field can be reduced by 1 until the value reaches -1, which indicates that the clarification of the data model is completely completed. The value of the clarification status field can be updated to 0 (such as curr_status = 0), indicating that the clarification is completed. When the clarification is completed, the above-mentioned clarification status field and clarification round control field can be set to empty.
[0077] For example, if Figure 4 As shown, taking the query information input by the user "Which province has the lowest total order amount in Q1 2019?" as an example, the number of data models recalled by the large model is multiple. The user can be asked for clarification and a clarification text can be issued, such as "I found multiple similar data that can answer your question. You can select the data you want to query from below, or enter a more precise description. This will help me answer the question better." Here, the data model that requires user clarification can be presented to the user as an option, and the user can clarify by entering LUI or clicking.
[0078] In step 203, the target column name and target column value are determined from the target data model through the second clarification processing result of the large model based on the query information and / or interaction with the user; the second clarification processing result is a clarification result for the column name and / or column value.
[0079] In some embodiments, a large model is used to recall columns from a target data model based on query information, and the column recall may include target column name recall and target column value recall; when multiple candidate columns having similarities greater than or equal to a first threshold are obtained based on the column recall, and the semantic similarity between the multiple candidate columns is greater than or equal to a second threshold, interaction is performed with the user based on a second clarification request, and the second clarification request can be used for the user to select a column from multiple candidate columns; after completing the clarification interaction with the user for the column, a second clarification processing result for the column can be collected; based on the second clarification processing result for the column, the target column name and target column value are determined from the target data model.
[0080] In an embodiment of the present application, when the large model recalls the number of column names and column values in the target data model based on the query information input by the user, and the number is both 1, it is considered that the recalled column can answer the question currently input by the user, and the column name and column value can be determined as the target column name and target column value for the question. When the large model recalls multiple candidate columns in the target data model based on the query information input by the user, and the semantic similarity between the multiple candidate columns is greater than or equal to the second threshold (that is, multiple column names / column values with relatively high and close similarities are recalled), in order to improve the accuracy of column recall, a second clarification request can be sent to the user, and the target column name and target column value can be determined by asking the user for clarification.
[0081] In some embodiments, the above-mentioned optional implementation method of interacting with the user based on the second clarification request may include: determining the candidate columns to be clarified based on the number of candidate columns associated with each entity word in the query information; generating corresponding clarification words based on the candidate columns to be clarified, and displaying the clarification words to the user; recording the clarification results of the user on the candidate columns to be clarified by inputting LUI or clicking.
[0082] like Figure 3As shown, when performing a column selection operation through the big model, if the big model determines a column (column name and column value) from the target data model, it can be considered that there is no need to ask the user for clarification, and the column can be determined as the target column, that is, the target column name and target column value are obtained, and the subsequent step 204 is executed. When multiple column names / column values with high and close similarities are obtained through recall using a large model, it is considered necessary to ask the user for clarification. A clarification request can be sent to the user. This clarification request can be presented to the user in the form of text, and the value of the clarification status field (e.g., curr_status) is updated to 1 (e.g., curr_status = 1, indicating the entry into the clarification state). The value of the clarification round control field (e.g., need_clarify_num) is set. The value of the clarification round control field is determined by the number of entity words in the query information entered by the user and the number of candidate columns associated with each entity word. For example, if there are three entity words and each entity word has multiple recall results, the value of the clarification round control field can be 3. For another example, if there are three entity words but only one of them has multiple recall results, the value of the clarification round control field can be 1. Each round of clarification corresponds to a candidate column to be clarified associated with the entity word to be clarified. After the user has been asked to clarify all candidate columns to be clarified associated with the entity word to be clarified, the results of the full clarification are collected, and the target column name and target column value are determined based on the collected results. Optionally, at the end of each round of clarification, the value of the clarification round control field can be decremented by 1 until the value reaches -1, indicating that the clarification for the column is completely completed. The value of the clarification status field can be updated to 0 (e.g., curr_status = 0) to indicate the end of clarification. When clarification is completed, the clarification status field and the clarification round control field can be set to empty.
[0083] For example, following the above Figure 4 In the example shown, after asking the user to clarify all the data models that need clarification, the large model recalls multiple column names / column values with high and close similarity. At this time, the user can be asked for clarification and a clarification text can be issued, such as "I found multiple 'order' related information in the data. All similar values have been listed for you. You can select the data you want to query from below, or enter a more precise description. This will help me better answer the question." The column names and / or column values that require clarification can be presented to the user as options, and the user can clarify by entering the LUI or clicking on them.
[0084] In order to further improve the hit rate of column recall, the value of the first threshold can be dynamically adjusted. Optionally, in some embodiments, if there is an initial value (such as 0.99) with a similarity greater than or equal to the first threshold in the recall result and the number is 1, there is no need to enter clarification, and the recall result corresponding to the similarity can be determined as the target column name and target column value. If there is an initial value (such as 0.99) with a similarity greater than or equal to the first threshold in the recall result and the number is multiple, it is necessary to enter clarification. If there is no initial value (such as 0.99) with a similarity greater than or equal to the first threshold in the recall result, the value of the first threshold is reduced (such as reduced to 0.9), and continue to judge whether it is necessary to enter clarification based on the similarity in the recall result, the latest value of the first threshold, and the number of values with a similarity greater than or equal to the first threshold. When the first threshold is updated to the given minimum value (such as 0.73) and there is no similarity greater than or equal to the minimum value of the first threshold in the recall result, it can be determined whether Abbreviation is hit. If so, the value of the first threshold is reduced to 0.5. If there is a similarity greater than or equal to 0.5 in the recall result and the number is 1, the recall result corresponding to the similarity is determined as the target column name and target column value; if there is a similarity greater than or equal to 0.5 in the recall result and the number is multiple, clarification is required.
[0085] In step 204, a lightweight data exchange format JSON statement is generated based on the target column name, target column value, and query information through the large model, and the JSON statement is converted into an SQL query statement.
[0086] In embodiments of the present disclosure, the methods involved in the embodiments of the present disclosure can employ the NL2JSON solution. Because the JSON format is customizable, the target database type can be determined, and JSON statements can be converted into SQL query statements in a specific format that matches the target database type. Therefore, because the JSON format is customizable, JSON statements can be converted into SQL query statements in any format, resolving SQL dialect issues and maintaining compatibility with various data sources.
[0087] In step 205, a target query result matching the query information is obtained based on the SQL query statement.
[0088] In some embodiments, a database query can be performed based on an SQL query statement to obtain SQL query results; a user interface as the target query result is generated based on a JSON statement and the SQL query results through a graphical user interface (GUI, also called a user operation front end), and the user interface is displayed, which can be used to interact with the user.
[0089] For example, a large model can be used to query the database based on the SQL query statement to obtain SQL query results. Through the GUI front end, ECharts (a JavaScript-based data visualization chart library that provides intuitive, vivid, interactive, and customizable data visualization charts) can be used to draw based on JSON statements and SQL query results to obtain a user interface for user viewing and operation interaction. The user interface displays the target query results in response to the query information input by the user, and the user interface can support user operation interaction.
[0090] In the above embodiment, the recall accuracy can be further improved by fine-grained recall processing of the large model combined with the interaction results with the user, thereby further improving the accuracy of the question result.
[0091] Optionally, in some embodiments, Figure 5 As shown, based on the above embodiment, the natural language-based intelligent number-asking method may further include the following steps:
[0092] In step 501, a filter condition modification operation performed by a user on a user interface is received.
[0093] In step 502, based on the filter condition modification operation, the JSON statement is updated, and the query process is performed based on the updated JSON statement.
[0094] For example, following the above Figure 4 The example shown is Figure 6 As shown, a GUI can be used to draw based on JSON statements and SQL query results to obtain a user interface for user viewing and interactive operations. The user interface displays the target query results in response to the query information input by the user, and the user interface can support user operation interactions. When the user modifies the order date on the user interface, for example, the order date is modified from 2019-01-01 to 2019-01-31, the JSON statement can be updated based on the user's modification operation results, and the data can be reprocessed based on the updated JSON statement, and the latest data processing results can be presented to the user. Thus, through manual modification by the user himself, the accuracy of the query results can be greatly improved, such as achieving the requirement of 100% accuracy.
[0095] It should be noted that in addition to the need to tell the big model in detail about the column selection values, some business knowledge needs to be injected, such as the calculation formula for gross profit margin, etc. Different companies may have different calculation methods. This information can be told to the big model through the knowledge injection mechanism. In this way, in the data processing stage of the query scenario, the SQL query results can be processed in combination with business knowledge. Optionally, in some embodiments, when it can be determined that the query information input by the user contains entity words associated with business knowledge, when generating the user interface as the target query result, the SQL query results can be processed based on the business knowledge to obtain the data processing results, and the user interface can be generated through the GUI based on the JSON statement and the data processing results.
[0096] For example, if the query information input by the user contains the entity word "calculate gross profit margin", the business knowledge of "calculate gross profit margin" (that is, the calculation formula of gross profit margin) can be called through the big model. Based on the SQL query results, the business knowledge is used to calculate the gross profit margin to obtain the gross profit margin calculation result, and the user interface is generated through the GUI based on the JSON statement and the gross profit margin calculation result.
[0097] Optionally, in some embodiments, Figure 7 As shown, based on the above embodiment, the natural language-based intelligent number-asking method may further include the following steps:
[0098] In step 701, before the large model produces the final result, it can be parsed based on the JSON statement to generate the corresponding text, and the text can be displayed in a streaming manner.
[0099] In other words, before the large model produces the final result, reasonable copy can be parsed and presented to the user in a streaming manner, allowing the user to feel that the system is operating normally and to receive real-time feedback. This can control the overall lag time to a shorter time (such as 3 seconds), thereby greatly improving the user experience.
[0100] In one possible implementation, during the generation of a JSON statement, when any one or more fields in the first object of the JSON statement are generated, text matching the fields is generated and displayed, forming a streaming output, and the fields in the first object are associated with entity terms in the query information. For example, each time a field in the first object of the JSON statement is generated, text matching the field is generated and displayed, forming a streaming output effect.
[0101] For example, the following JSON parsed text is: Query "Total Amount" data, filter by "Order Date" between "2019-01-01" and "2019-03-31", "Order Date" between "2019-01-01" and "2019-03-31", and "Order Date by Year-Quarter Statistics". The query results that meet the above requirements are as follows:
[0102] This text is generated from the first object in the JSON statement (e.g., llmJson) along with the results of the large model and is presented to the user in a streaming manner. This not only explains how to solve the problem but also improves the user experience. For example, the JSON statement corresponding to the above text may include the following content:
[0103]
[0104]
[0105] Figure 8 This is a block diagram of a natural language based intelligent number-asking device provided in an embodiment of the present disclosure. Figure 8 As shown, the natural language-based intelligent number-asking device may include: a recall process 801 , a first determination module 802 , a generation module 803 and a query module 804 .
[0106] The recall process 801 is used to perform a recall process from the target database using a coarse recall model based on the query information input by the user to obtain multiple candidate data models.
[0107] The first determination module 802 is configured to determine a target data model, a target column name, and a target column value for querying data from a plurality of candidate data models based on query information and / or human-computer interaction using a large model.
[0108] The generation module 803 is used to generate a lightweight data exchange format JSON statement through the large model based on the target column name, target column value, and query information, and convert the JSON statement into an SQL query statement.
[0109] The query module 804 is configured to obtain target query results that match the query information based on the SQL query statement.
[0110] In some embodiments, the first determination module 802 includes: a first determination unit and a second determination unit. The first determination unit is configured to determine a target data model for querying from multiple candidate data models using a first clarification result of the large model based on query information and / or user interaction; the first clarification result is a clarification result for the data model. The second determination unit is configured to determine a target column name and a target column value from the target data model using a second clarification result of the large model based on query information and / or user interaction; the second clarification result is a clarification result for the column name and / or column value.
[0111] In some embodiments, the first determination unit is used to: perform recall processing among multiple candidate data models based on query information through the big model; when the number of data models recalled by the big model from multiple candidate data models is multiple, interact with the user based on a first clarification request, and the first clarification request is used for the user to select a data model; after completing the clarification interaction with the user for the data model, collect the first clarification processing result for the data model; based on the first clarification processing result for the data model, determine the target data model from multiple candidate data models.
[0112] In some embodiments, the first determination unit is used to: segment the query information through a large model to obtain entity words in the query information; the entity words are used to recall the data model; based on the number of candidate data models associated with each entity word, the data model to be clarified is determined; based on the data model to be clarified, corresponding clarification words are generated, and the clarification words are displayed to the user; the clarification results of the user on the data model to be clarified through the input language user interface LUI or clicking.
[0113] In some embodiments, the second determination unit is configured to: recall columns from the target data model based on the query information using the large model, wherein the column recall includes recalling the target column name and the target column value; upon obtaining multiple candidate columns whose similarities are greater than or equal to a first threshold based on the column recall, and wherein the semantic similarity between the multiple candidate columns is greater than or equal to a second threshold, interact with the user based on a second clarification request, wherein the second clarification request is used to allow the user to select a column from the multiple candidate columns; after completing the clarification interaction with the user for the column, collect the second clarification processing result for the column; and determine the target column name and target column value from the target data model based on the second clarification processing result for the column. In some embodiments, the second determination unit is configured to: determine the candidate columns to be clarified based on the number of candidate columns associated with each entity word in the query information; generate corresponding clarification words based on the candidate columns to be clarified and display the clarification words to the user; and record the clarification results of the user on the candidate columns to be clarified by inputting the LUI or clicking.
[0114] In some embodiments, the generation module 803 is used to: determine the type of the target database; and convert the JSON statement into an SQL query statement in a specific format that matches the type of the target database.
[0115] In some embodiments, the query module 804 is used to: perform database queries based on SQL query statements to obtain SQL query results; generate a user interface as the target query result based on JSON statements and SQL query results through a graphical user interface GUI, and display the user interface, which is used to interact with the user.
[0116] Optionally, in some embodiments, Figure 9 As shown, the natural language-based intelligent number-asking device may further include a display module 905. The display module 905 is used to parse the JSON statement to generate corresponding text before the large model produces the final result, and display the text in a streaming manner.
[0117] In some embodiments, the display module 905 is used to: during the process of generating a JSON statement, when generating any one or more fields in the first object in the JSON statement, generate and display text that matches the fields, forming a streaming output, and the fields in the first object are associated with the entity words in the query information. Figure 9 901-904 and Figure 8 801-804 have the same function and structure.
[0118] Optionally, in some embodiments, Figure 10 As shown, the intelligent number-asking device based on natural language may further include: an updating module 1006. The updating module 1006 is used to: receive a user's filter condition modification operation on the user interface; based on the filter condition modification operation, update the JSON statement, and perform the number-asking process based on the updated JSON statement. Figure 10 Zhong 1001-1005 and Figure 9 901-905 have the same function and structure.
[0119] Optionally, in some embodiments, Figure 11 As shown, the intelligent questioning device based on natural language can also include: a second determination module 1107. The second determination module 1107 is used to: determine whether there are entity words associated with business knowledge in the query information; and pre-inject business knowledge into the large model. In the embodiment of the present disclosure, the query module 1104 is used to: perform data processing on the SQL query results based on business knowledge to obtain data processing results; and generate a user interface based on the JSON statement and the data processing results through the GUI. Figure 11 Zhong 1101-1106 and Figure 101001-1006 have the same function and structure.
[0120] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0121] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0122] like Figure 12 , is a block diagram of an electronic device according to an embodiment of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0123] like Figure 12 As shown, the electronic device includes: one or more processors 1201, a memory 1202, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the electronic device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In other embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 12 A processor 1201 is taken as an example.
[0124] Memory 1202 is a non-transitory computer-readable storage medium provided by the present disclosure. The memory stores instructions executable by at least one processor, causing the at least one processor to execute the natural language-based intelligent number-asking method provided by the present disclosure. The non-transitory computer-readable storage medium of the present disclosure stores computer instructions for causing a computer to execute the natural language-based intelligent number-asking method provided by the present disclosure.
[0125] The memory 1202 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as the program instructions / modules corresponding to the natural language-based intelligent number-asking method in the embodiment of the present disclosure (for example, the attached Figure 8 The processor 1201 executes the non-transient software programs, instructions, and modules stored in the memory 1202 to execute various functional applications and data processing of the server, thereby implementing the natural language-based intelligent number-asking method in the above method embodiment.
[0126] The memory 1202 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and applications required for at least one function; the data storage area may store data created based on the use of the electronic device, etc. In addition, the memory 1202 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 1202 may optionally include a memory remotely located relative to the processor 1201, and these remote memories may be connected to the electronic device 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.
[0127] The electronic device may further include: an input device 1203 and an output device 1204. The processor 1201, the memory 1202, the input device 1203 and the output device 1204 may be connected via a bus or other means. Figure 12 The bus connection is taken as an example.
[0128] The input device 1203 can receive input digital or character information and generate key signal input related to user settings and function control of the electronic device, such as input devices such as a touch screen, a keypad, a mouse, a trackpad, a touch pad, a pointer, one or more mouse buttons, a trackball, and a joystick. The output device 1204 may include a display device, an auxiliary lighting device (e.g., an LED), and a tactile feedback device (e.g., a vibration motor). The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display, and a plasma display. In some embodiments, the display device may be a touch screen.
[0129] Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0130] These computer programs (also referred to as programs, software, software applications, or code) include machine instructions for a programmable processor and can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and / or device (e.g., a magnetic disk, an optical disk, a memory, a programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0131] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0132] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.
[0133] A computer system may include a client and a server. The client and server are generally remote from each other and typically interact via a communication network. This client-server relationship is established by computer programs running on the respective computers and establishing a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, a host product within a cloud computing service ecosystem that addresses the management difficulties and limited business scalability of traditional physical hosts and VPS services ("Virtual Private Servers" or simply "VPS"). The server may also be a server in a distributed system or a server integrated with blockchain.
[0134] Figure 13 A block diagram of an intelligent agent provided in an embodiment of the present disclosure. Figure 13 As shown, the intelligent agent may include an input module 1301, a processing module 1302, and an output module 1303. The input module 1301 is used to receive input information; the processing module 1302 is used to determine a target task based on the input information received by the input module 1301, determine a large model based on the target task, and execute the natural language-based intelligent number-asking method in the above-mentioned method embodiment by calling the large model to obtain output information; and the output module 1303 is used to output the output information obtained by the processing module 1302. For example, the target task may be an intelligent number-asking task.
[0135] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not limited herein.
[0136] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.
Claims
1. An intelligent number-asking method based on natural language, comprising: Based on the query information input by the user, a rough recall model is used to perform recall processing from the target database to obtain multiple candidate data models; Determine, by the large model, a target data model, a target column name, and a target column value for querying from the plurality of candidate data models based on the query information and / or human-computer interaction; Generate a lightweight data exchange format JSON statement based on the target column name and target column value and the query information through the large model, and convert the JSON statement into an SQL query statement; A target query result matching the query information is obtained based on the SQL query statement.
2. The method according to claim 1, wherein The step of determining a target data model, a target column name, and a target column value for querying data from the plurality of candidate data models based on the query information and / or human-computer interaction by using the large model includes: Determining a target data model for the query from the plurality of candidate data models by using the large model based on the query information and / or a first clarification result of interaction with the user; the first clarification result is a clarification result for the data model; The target column name and target column value are determined from the target data model through the second clarification processing result based on the query information and / or the interaction with the user by the large model; the second clarification processing result is a clarification result for the column name and / or column value.
3. The method according to claim 2, wherein: The step of determining a target data model for the query from the plurality of candidate data models based on the query information and / or the first clarification processing result of the interaction with the user by the large model includes: Performing a recall process in the plurality of candidate data models based on the query information by using the large model; When the number of data models recalled by the large model from the plurality of candidate data models is plural, interacting with the user based on a first clarification request, where the first clarification request is used for the user to select a data model; After completing the clarification interaction with the user on the data model, collecting a first clarification processing result on the data model; Based on the first clarification processing result for the data model, the target data model is determined from the multiple candidate data models.
4. The method according to claim 3, wherein: The interacting with the user based on the first clarification request includes: Segmenting the query information using the large model to obtain entity words in the query information; the entity words are used to recall the data model; Determining a data model to be clarified based on the number of candidate data models associated with each of the entity words; generating corresponding clarification words based on the data model to be clarified, and presenting the clarification words to the user; The clarification result of the data model to be clarified by the user through inputting the language user interface LUI or clicking is recorded.
5. The method according to claim 2, wherein: The determining, from the target data model, a target column name and a target column value by the large model based on the query information and / or the second clarification processing result of the interaction with the user, includes: Recalling columns from the target data model based on the query information through the large model, wherein the column recall includes target column name recall and target column value recall; If multiple candidate columns having similarities greater than or equal to a first threshold are obtained based on the column recall, and semantic similarities between the multiple candidate columns are greater than or equal to a second threshold, interacting with the user based on a second clarification request, where the second clarification request is used for the user to select a column from the multiple candidate columns; After completing the clarification interaction with the user for the column, collecting a second clarification processing result for the column; Based on the second clarification processing result for the column, the target column name and target column value are determined from the target data model.
6. The method according to claim 5, wherein: The interacting with the user based on the second clarification request includes: Determining candidate columns to be clarified based on the number of candidate columns associated with each entity word in the query information; generating corresponding clarification words based on the candidate column to be clarified, and displaying the clarification words to the user; The clarification result of the candidate column to be clarified by the user by inputting LUI or clicking is recorded.
7. The method of claim 1 , further comprising: Before the large model produces the final result, it is parsed based on the JSON statement to generate corresponding text, and the text is displayed in a streaming manner.
8. The method of claim 7, wherein: The parsing based on the JSON statement to generate a corresponding text, and displaying the text in a streaming manner, includes: In the process of generating the JSON statement, when any one or more fields in the first object in the JSON statement are generated, text matching the fields is generated and displayed to form a streaming output, and the fields in the first object are associated with the entity words in the query information.
9. The method of claim 1, wherein: The converting the JSON statement into an SQL query statement includes: Determining the type of the target database; The JSON statement is converted into an SQL query statement in a specific format that matches the type of the target database.
10. The method of claim 1, wherein: Obtaining a target query result matching the query information based on the SQL query statement includes: Perform a database query based on the SQL query statement to obtain an SQL query result; A user interface as the target query result is generated based on the JSON statement and the SQL query result through a graphical user interface (GUI), and the user interface is displayed. The user interface is used for interacting with the user.
11. The method of claim 10, further comprising: receiving a filter condition modification operation by the user on the user interface; Based on the filter condition modification operation, the JSON statement is updated, and the query process is performed based on the updated JSON statement.
12. The method according to claim 10 or 11, further comprising: Determine whether entity words associated with business knowledge exist in the query information; and pre-inject the business knowledge into the large model.
13. The method of claim 12, wherein: The step of generating a user interface as the target query result based on the JSON statement and the SQL query result through a graphical user interface (GUI) includes: Performing data processing on the SQL query result based on the business knowledge to obtain a data processing result; The user interface is generated by the GUI based on the JSON statement and the data processing result.
14. An intelligent number-asking device based on natural language, comprising: Recall processing is used to recall the query information input by the user using a coarse recall model from the target database to obtain multiple candidate data models; A first determination module is configured to determine a target data model, a target column name, and a target column value for querying data from the plurality of candidate data models based on the query information and / or human-computer interaction using a large model; a generation module, configured to generate a lightweight data exchange format JSON statement through the large model based on the target column name and target column value and the query information, and convert the JSON statement into an SQL query statement; A query module is used to obtain a target query result matching the query information based on the SQL query statement.
15. An intelligent agent comprising: An input module, used for receiving input information; a processing module, configured to determine a target task based on the input information received by the input module, determine a large model based on the target task, and obtain output information by executing the method according to any one of claims 1 to 13 by calling the large model; An output module is used to output the output information obtained by the processing module.
16. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 13.
17. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 13.
18. A computer program product comprising a computer program, wherein The computer program implements the steps of the method according to any one of claims 1 to 13 when executed by a processor.
Citation Information
Patent Citations
Method, system and device for converting natural language query into SQL and storage medium
CN114547072A
SQL statement generation method, device and equipment
CN117056351A
Intelligent question answering method, system and equipment based on large language model and database
CN118606348A
Natural language query statement processing method and device
CN118779340A
Method and device for converting natural language question into SQL statement and medium
CN119597785A