Data query method, system and equipment based on AI big language model and medium
Through the data query method based on the AI large language model, the query information input by the user and the user portrait are used to match the data dictionary, and query code is generated and executed, which solves the problem that users need to have code development capabilities and understand the database in the existing technology. It realizes the effect of automatic data query and rapid acquisition of massive data.
Patent Information
- Application Number
- CN202310964815.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-02
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2043-08-02
AI Technical Summary
The existing self-service query system requires users to have certain code development capabilities and detailed understanding of the database, and it is impossible to realize automatic data query without requiring user development capabilities.
The data query method based on the AI large language model is adopted. By obtaining the query information input by the user, query information suitable for language model recognition is generated, and data dictionary matching is used using the user portrait, and finally query code is generated and executed to obtain query results.
It realizes the rapid acquisition of massive data without the need for users to understand the data structure and have code development capabilities, and solves the problem of data query difficulties caused by inconvenient data acquisition and lack of understanding of the data structure.
Smart Images

Figure CN119441450A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of automatic data query technology, and in particular to a data query method, system, device and medium based on an AI large language model. Background Art
[0002] As the global digital transformation continues to accelerate, digital technology is profoundly changing the way people think, work and learn. The digital literacy and skills of all employees are increasingly becoming key indicators of competitiveness and soft power. To strengthen digital literacy and skills education, we must guide people to adapt to the new digital ecology, and use easy-to-use, convenient and compatible tools to allow users to quickly obtain data and enable data to better empower business.
[0003] Although the existing self-service query system provides data query functions, it requires users to have certain code development capabilities and a detailed understanding of the database in order to clearly understand the data storage location and data retrieval logic and write query codes.
[0004] Therefore, how to realize automatic data query without requiring user development capabilities is a technical problem that needs to be solved urgently by technical personnel in this field. Summary of the invention
[0005] Based on the above problems, the present application provides a data query method, system, device and medium based on an AI large language model to realize automatic data query.
[0006] To solve the above problems, the technical solutions provided in the embodiments of the present application are as follows:
[0007] The first aspect of the present application provides a data query method based on an AI large language model, comprising:
[0008] Acquiring first query information input by an operator;
[0009] Inputting the first query information into a processing model to generate second query information for language model recognition, wherein the processing model is used to match the first query information with a data dictionary based on a user profile corresponding to the operator, and the data dictionary is a metadata dictionary of all database tables in the database cluster;
[0010] Calling a corresponding language model interface for processing based on the second query information, and receiving a query code returned by the language model interface;
[0011] A query result is determined based on the query code and the database cluster.
[0012] Optionally, the data dictionary includes data categories, and the user portrait is generated in a manner including:
[0013] Acquire operator behavior information, where the behavior information is used to characterize common data categories and usage scenarios;
[0014] The behavior information is associated with the corresponding data category to generate a user profile.
[0015] Optionally, the behavior information includes feedback information, and after determining the query result based on the query code and the database cluster, the method further includes:
[0016] Obtaining feedback information from the operator on the query result;
[0017] The processing model is optimized based on the feedback information.
[0018] Optionally, the calling a corresponding language model interface for processing based on the second query information includes:
[0019] A key corresponding to the second query information is determined, and a corresponding language model interface is called based on the key and the second query information.
[0020] Optionally, after obtaining the first query information input by the operator, the method further includes:
[0021] Acquire a scene image, and detect the scene image to determine an operator who is inputting the first query information;
[0022] Based on a pre-established user portrait library, a user portrait corresponding to the operator is determined.
[0023] Optionally, the user portrait is generated by:
[0024] Get the operator's language text;
[0025] Using a pre-trained multi-feature extraction model, extracting features from the language text to obtain a plurality of different types of features, wherein the plurality of different types of features include sentence pattern features, sentence color meaning features, and pragmatic meaning features;
[0026] A user portrait corresponding to the operator is determined based on the multiple different types of features.
[0027] Optionally, the second query information is used to provide data structure or dictionary information.
[0028] The second aspect of the present application provides a data query system based on an AI large language model, comprising:
[0029] An acquisition unit, used for acquiring first query information input by an operator;
[0030] A second query information generating unit, configured to input the first query information into a processing model to generate second query information for language model recognition, wherein the processing model is configured to match the first query information with a data dictionary based on a user profile corresponding to the operator, wherein the data dictionary is a metadata dictionary of all database tables in the database cluster;
[0031] An interface calling unit, configured to call a corresponding language model interface for processing based on the second query information, and receive a query code returned by the language model interface;
[0032] A query result determination unit is used to determine a query result based on the query code and the database cluster.
[0033] The third aspect of the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the data query method based on the AI large language model described in any one of the first aspects is implemented.
[0034] The fourth aspect of the present application provides a computer-readable storage medium, which stores instructions. When the instructions are executed on a terminal device, the terminal device executes the data query method based on the AI large language model as described in any one of the first aspects above.
[0035] Compared with the prior art, this application has the following beneficial effects:
[0036] By obtaining the first query information input by the operator; inputting the first query information into the processing model, generating the second query information for language model recognition, the processing model is used to complete the matching of the first query information with the data dictionary based on the user portrait corresponding to the operator, and the data dictionary is the metadata dictionary of all database tables in the database cluster; based on the second query information, the corresponding language model interface is called for processing, and the query code returned by the language model interface is received; based on the query code and the database cluster, the query result is determined. Compared with the prior art, the self-service query has higher requirements on users, and requires understanding of the data storage structure and certain code development capabilities. The solution provided by the present application associates and matches the operator's input content with the data dictionary, assembles and submits it according to the language model interface specification, and obtains more accurate return results. That is, the user does not need to understand the data structure, and the user's code development ability is not required. Massive data can be quickly obtained without complex query operations and code writing. Solving the problem of inconvenience in user data acquisition and difficulty in data query due to lack of understanding of data structure, and realizing automatic data query without requiring user development capabilities, is a technical problem that technicians in this field need to solve urgently. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in this embodiment or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0038] Figure 1 A flow chart of a data query method based on an AI large language model provided in an embodiment of the present application;
[0039] Figure 2 A structural diagram of a data query system based on an AI large language model provided in an embodiment of the present application. DETAILED DESCRIPTION
[0040] 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 are within the scope of protection of this application.
[0041] To facilitate understanding of the technical solutions provided by the embodiments of the present application, the background technology involved in the embodiments of the present application will be described below.
[0042] As mentioned above, the existing self-service query system provides data query functions, but users are required to have certain code development capabilities and a detailed understanding of the database in order to clearly understand the data storage location and data retrieval logic and write query codes. In recent years, AI large language models have developed rapidly. ChatGPT is a natural language processing system driven by artificial intelligence technology. It can communicate by understanding and learning human language, and can also interact according to the context of the chat. It can complete tasks such as writing emails, video scripts, copywriting, translation, code, and writing papers. Domestic AI large language model products include Baidu Wenxin Yiyan, Ali Tongyi Qianwen, Huawei Pangu, Fudan University MOSS, etc. These products are closer to the usage habits of Chinese people in terms of understanding Chinese semantics, and have certain basic common sense and preliminary logical thinking ability, but there is still room for improvement in complex science calculations.
[0043] The method provided in the embodiment of the present application is executed by a background system, for example, by a data query background server. The data query background server can be a server device or a server cluster composed of multiple servers.
[0044] In order to solve this problem, the present application provides a data query method, system, device and medium based on an AI large language model. By obtaining the first query information input by the operator; inputting the first query information into the processing model, generating the second query information for language model recognition, the processing model is used to complete the matching of the first query information with the data dictionary based on the user portrait corresponding to the operator, and the data dictionary is the metadata dictionary of all database tables in the database cluster; based on the second query information, the corresponding language model interface is called for processing, and the query code returned by the language model interface is received; based on the query code and the database cluster, the query result is determined. That is, after the system obtains the input information, it generates the data query code based on the language model interface, submits the code to the local database and returns the corresponding data. Users can quickly obtain massive data through text or language description without complex query operations and code writing. Solve the problem of inconvenient user data acquisition and difficulty in data query due to lack of understanding of data structure. At the same time, by collecting user usage feedback and user portrait information such as user roles and data range of concern, the user input text is trained and preset for model training, and the accuracy of the results returned by the language model is further improved.
[0045] In order to facilitate understanding of the data query method based on the AI large language model provided in the embodiment of the present application, the scenario example of the present application is explained below.
[0046] The following is an example of an embodiment to illustrate a data query method based on an AI large language model provided by the present application. Figure 1 , which is a flow chart of a data query method based on an AI large language model provided in an embodiment of the present application. The execution subject of the method flow is a server. Further, the subject may be a data query system based on an AI large language model in the server. The method includes:
[0047] S101: Acquire first query information input by an operator.
[0048] The first query information may be text or voice input by the user in the chat box of the self-service query front end, such as indicators, dates and indicator values related to the scale of new energy storage projects.
[0049] In actual application scenarios, the self-service query front end may include a chat box, a query interface, a data result display, etc. The chat box is an interactive window between the user and the system background, providing a dialogue interaction function. The user enters a text description of the query and obtains a query code. An evaluation feedback function is provided, and the user can evaluate and score the returned query code.
[0050] In actual application scenarios, a camera device can be set at an appropriate position on the front end of the self-service query to identify the facial information of the current operator. A fingerprint recognition function can also be set on the front end interface to obtain the operator's fingerprint when the operator manually enters the content to be queried, and match it with the pre-stored user database based on the above-mentioned relevant information of the operator.
[0051] In a possible implementation manner, after obtaining the first query information input by the operator, the method further includes:
[0052] Step A1: Acquire a scene image, and detect the scene image to determine the operator who is inputting the first query information.
[0053] The scene image of the current automatic query front-end device is obtained, and the current scene is detected. In the actual application scenario, when voice information is received, the scene image can be lip-movement detected to determine the operator of the currently input first query information. When text information is received, the camera device is turned on to determine the operator.
[0054] Step A2: Based on a pre-established user portrait library, determine the user portrait corresponding to the operator.
[0055] Therefore, the embodiments of the present application can solve the defect that self-service query in the prior art does not support user personalized needs. This method records the user's behavior in the background system, analyzes the common data categories and usage scenarios of different users, generates user portraits, and performs more accurate data dictionary matching on the text entered by the user, thereby improving the accuracy of the returned results and achieving the effect of "one thousand faces for one thousand people".
[0056] S102: Input the first query information into a processing model to generate second query information for language model recognition.
[0057] The processing model is used to complete the matching of the first query information with a data dictionary based on the user portrait corresponding to the operator, and the data dictionary is a metadata dictionary of all database tables of the database cluster.
[0058] The chat function's backend system receives user input, associates and matches the input content with the data dictionary, and generates text content that is easily recognized by the AI language model. A simple example is as follows (field definitions are omitted):
[0059] The table structure related to the known industry economic data is:
[0060] Create table in_indicators(id int...);
[0061] Create table in_indicator_data(id int...);
[0062] Create table in_indicator_tree(id int...);
[0063] Please help me generate a piece of SQL code to query "the name, date and value of indicators related to the scale of new energy storage projects".
[0064] In actual application scenarios, the data dictionary includes data categories, and the generation method of the user portrait includes:
[0065] Step B1: Obtain the operator's behavior information.
[0066] The behavior information is used to characterize the user's common data categories and usage scenarios.
[0067] Step B2: Associating the behavior information with the corresponding data category to generate a user profile.
[0068] Analyze various behavioral information such as user input, feedback, and queries, associate user roles with data categories, generate user portraits, and provide training materials and optimization suggestions for the background text processing model.
[0069] In an actual application scenario, after obtaining the first query information input by the operator, the method further includes:
[0070] The user portrait is generated in the following manner:
[0071] Step C1: Obtain the operator's language text.
[0072] That is, the first query information content input by the operator is obtained.
[0073] Step C2: Using a pre-trained multi-feature extraction model, extract features from the language text to obtain multiple different types of features, wherein the multiple different types of features include sentence pattern features, sentence color meaning features, and pragmatic meaning features.
[0074] Due to differences in expression habits and accents, different users may express the same content in different ways. Therefore, it is necessary to analyze and extract the operator's language text to generate more standard language content that will not cause ambiguity.
[0075] Step C3: Determine a user portrait corresponding to the operator based on the multiple different types of features.
[0076] In a possible application scenario, the features of several different types obtained in the above steps are screened to form the required user profile, and the screening of features can be adaptively adjusted according to actual needs.
[0077] S103: Calling a corresponding language model interface for processing based on the second query information, and receiving a query code returned by the language model interface.
[0078] The calling a corresponding language model interface for processing based on the second query information includes:
[0079] A key corresponding to the second query information is determined, and a corresponding language model interface is called based on the key and the second query information.
[0080] The second query information is used to provide data structure or dictionary information. The language model interface can be an AI large language model interface, that is, using the LangChain framework, the AI large language model interfaces released by multiple manufacturers are pre-packaged in the background system, accessed through a proprietary key, and can be flexibly configured and used as needed. For example, domestic related data queries for Chinese semantics use interface A, and foreign data queries for English semantics use interface B, so that the returned results are more accurate. It should be noted that these interfaces can be adjusted according to actual needs. This is only an example and does not limit the scope of protection.
[0081] S104: Determine a query result based on the query code and the database cluster.
[0082] The database cluster, i.e., the data storage medium, can be configured to connect to multiple data sources. In actual application scenarios, users can copy the query code in the chat box to the query page, submit the query, and return the query results from the database cluster.
[0083] This solves the problem of many AI large language model products using different accounts or clients and inconsistent interface language rules. This method pre-packages the interfaces of AI large language models released by multiple manufacturers in the background system, such as ChatGPT, Baidu Wenxin Yiyan, etc., which can be accessed through proprietary keys and can be flexibly configured to access different AI large language model interfaces as needed. Users interact in the chat box of self-service query without having to care about the specific interfaces and language rules used at the bottom layer.
[0084] Furthermore, in the prior art, users directly using AI large language models may bring data security risks. The data used in this method is stored locally, and calling the external interface only provides a data dictionary, does not upload business data, does not include database account information, etc., and avoids data security issues.
[0085] In a possible implementation, the behavior information includes feedback information, and after determining the query result based on the query code and the database cluster, the method further includes:
[0086] S105: Obtaining feedback information of the operator on the query result.
[0087] S106: Optimizing the processing model based on the feedback information.
[0088] Users can evaluate and rate the returned code in the chat box, and all user behaviors will be recorded in the user behavior analysis module as material and basis for optimizing the text processing model.
[0089] Therefore, this application solves the problem that self-service query in the prior art cannot provide feedback on the returned results and the user experience is not good enough. This method designs an interactive chat box where users can evaluate the returned results. The backend system records the user's business requirement description, the returned query code, and the user's evaluation feedback. Using these data, the association model between text processing and data dictionary is optimized to improve the success rate of data matching.
[0090] The above are some specific implementations of the data query method based on the AI large language model provided in the embodiment of the present application. Based on this, the present application also provides a corresponding system for data query. The system provided in the embodiment of the present application will be introduced from the perspective of functional modularization. Figure 2 A structural diagram of a data query system based on an AI large language model provided in an embodiment of the present application.
[0091] The system comprises:
[0092] The acquisition unit 201 is used to acquire first query information input by an operator;
[0093] A second query information generating unit 202 is used to input the first query information into a processing model to generate second query information for language model recognition, wherein the processing model is used to match the first query information with a data dictionary based on a user profile corresponding to the operator, and the data dictionary is a metadata dictionary of all database tables in the database cluster;
[0094] An interface calling unit 203 is used to call a corresponding language model interface for processing based on the second query information, and receive a query code returned by the language model interface;
[0095] The query result determination unit 204 is used to determine the query result based on the query code and the database cluster.
[0096] Optionally, the data dictionary includes data categories, and the user portrait is generated in a manner including:
[0097] Acquire operator behavior information, where the behavior information is used to characterize common data categories and usage scenarios;
[0098] The behavior information is associated with the corresponding data category to generate a user profile.
[0099] Optionally, the system further includes:
[0100] A feedback information acquisition unit, used to acquire feedback information of the operator on the query result;
[0101] A model optimization unit is used to optimize the processing model based on the feedback information.
[0102] Optionally, the interface calling unit is specifically used to determine a key corresponding to the second query information, and call a corresponding language model interface based on the key and the second query information.
[0103] Optionally, the system further includes:
[0104] An operator determining unit, used to acquire a scene image, detect the scene image, and determine an operator who is inputting the first query information;
[0105] The user portrait determination unit is used to determine the user portrait corresponding to the operator based on a pre-established user portrait library.
[0106] Optionally, the user portrait is generated by:
[0107] Get the operator's language text;
[0108] Using a pre-trained multi-feature extraction model, extracting features from the language text to obtain a plurality of different types of features, wherein the plurality of different types of features include sentence pattern features, sentence color meaning features, and pragmatic meaning features;
[0109] A user portrait corresponding to the operator is determined based on the multiple different types of features.
[0110] Optionally, the second query information is used to provide data structure or dictionary information.
[0111] The embodiment of the present application also provides corresponding devices and computer storage media for implementing the data query method solution based on the AI large language model provided in the embodiment of the present application.
[0112] Among them, the device includes a memory and a processor, the memory is used to store instructions or codes, and the processor is used to execute the instructions or codes so that the device executes the data query method based on the AI large language model described in any embodiment of the present application.
[0113] The computer storage medium stores code, and when the code is executed, the device executing the code implements the data query method based on the AI large language model described in any embodiment of the present application.
[0114] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system or device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0115] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0116] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0117] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0118] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data query method based on AI large language model, characterized in that: include: Acquiring first query information input by an operator; Inputting the first query information into a processing model to generate second query information for language model recognition, wherein the processing model is used to match the first query information with a data dictionary based on a user profile corresponding to the operator, and the data dictionary is a metadata dictionary of all database tables in the database cluster; Calling a corresponding language model interface for processing based on the second query information, and receiving a query code returned by the language model interface; A query result is determined based on the query code and the database cluster.
2. The method according to claim 1, characterized in that The data dictionary includes data categories, and the user portrait generation method includes: Acquire operator behavior information, where the behavior information is used to characterize common data categories and usage scenarios; The behavior information is associated with the corresponding data category to generate a user profile.
3. The method according to claim 2, characterized in that The behavior information includes feedback information, and after determining the query result based on the query code and the database cluster, the method further includes: Obtaining feedback information from the operator on the query result; The processing model is optimized based on the feedback information.
4. The method according to claim 1, characterized in that: The calling a corresponding language model interface for processing based on the second query information includes: A key corresponding to the second query information is determined, and a corresponding language model interface is called based on the key and the second query information.
5. The method according to claim 1, characterized in that After obtaining the first query information input by the operator, the method further includes: Acquire a scene image, and detect the scene image to determine an operator who is inputting the first query information; Based on a pre-established user portrait library, a user portrait corresponding to the operator is determined.
6. The method according to claim 1, characterized in that The user portrait is generated in the following manner: Get the operator's language text; Using a pre-trained multi-feature extraction model, extracting features from the language text to obtain a plurality of different types of features, wherein the plurality of different types of features include sentence pattern features, sentence color meaning features, and pragmatic meaning features; A user portrait corresponding to the operator is determined based on the multiple different types of features.
7. The method according to claim 1, characterized in that The second query information is used to provide data structure or dictionary information.
8. A data query system based on AI large language model, characterized in that: The system comprises: An acquisition unit, used for acquiring first query information input by an operator; A second query information generating unit, configured to input the first query information into a processing model to generate second query information for language model recognition, wherein the processing model is configured to match the first query information with a data dictionary based on a user profile corresponding to the operator, wherein the data dictionary is a metadata dictionary of all database tables in the database cluster; An interface calling unit, configured to call a corresponding language model interface for processing based on the second query information, and receive a query code returned by the language model interface; A query result determination unit is used to determine a query result based on the query code and the database cluster.
9. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the data query method based on the AI large language model as described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device executes the data query method based on the AI large language model as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Report generation method and apparatus, computer device, and storage medium
CN109542956A
Title generation method and device, electronic equipment and storage medium
CN111859918A
Intelligent session method and server based on table data retrieval
CN115495563A
Multi-market data query method, system and device
CN115718768A
AI-based call-out method and device and storage medium
CN115858744A