Data query method, system, device and medium based on AI large language model

Through the data query method based on the AI ​​large language model, the query code is generated by matching user portraits and data dictionaries, which solves the inconvenience of data acquisition in the self-service query system where users need to have coding capabilities, and realizes efficient data query without code operation.

CN119441450BActive Publication Date: 2025-10-21CHINA ECONOMIC INFORMATION SERVICE
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310964815.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-02
Publication Date
2025-10-21
Estimated Expiration
2043-08-02

AI Technical Summary

Technical Problem

The existing self-service query system requires users to have certain code development capabilities and understanding of the database in order to perform data queries, which makes it inconvenient for users to obtain data.

Method used

A data query method based on an AI large language model is adopted. By obtaining the query information input by the user, the second query information for language model recognition is generated, data dictionary matching is performed based on the user portrait, the language model interface is called to generate query code, and the query results are determined in the database cluster.

Benefits of technology

It enables users to quickly obtain massive amounts of data without the need for code development capabilities, improves the convenience and accuracy of data queries, and solves the query difficulties caused by users' lack of understanding of data structures.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119441450B_ABST
    Figure CN119441450B_ABST
Patent Text Reader

Abstract

The application discloses a data query method, system, device and medium based on an AI large language model, first query information input by an operator is acquired, the first query information is input into a processing model to generate second query information for language model identification, the processing model is used for matching the first query information with a data dictionary based on a user portrait corresponding to the operator, a corresponding language model interface is called based on the second query information for processing, and query code returned by the language model interface is received; and a query result is determined based on the query code and the database cluster. That is, the content input by the operator is associated and matched with the data dictionary, is assembled and submitted according to a language model interface specification, and more accurate returned results are acquired, so that the data automatic query is realized on the basis of not requiring user development capability, and a technical problem urgently to be solved by a person skilled in the art is solved.
Need to check novelty before this filing date? Find Prior Art

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 global digital transformation accelerates, digital technology is profoundly changing how people think, work, and learn. Digital literacy and skills for all employees are increasingly becoming key indicators of competitiveness and soft power. Strengthening digital literacy and skills education requires guiding people to adapt to the new digital ecosystem. By providing easy-to-use, convenient, and compatible tools, users can quickly access data, enabling data to better empower businesses.

[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 define the data storage location and data retrieval logic and write query code.

[0004] Therefore, how to realize automatic data query without requiring user development capabilities is a technical problem that needs to be solved urgently by those skilled in the art. Summary of the Invention

[0005] Based on the above problems, this application provides a data query method, system, device and medium based on 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 the user profile corresponding to the operator, wherein 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 profile is generated in the following manner:

[0013] Obtaining 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, calling a corresponding language model interface for processing based on the second query information includes:

[0019] 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.

[0020] Optionally, after obtaining the first query information input by the operator, the method further includes:

[0021] Acquiring a scene image and detecting 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 multiple different types of features, wherein the multiple different types of features include sentence pattern features, sentence color meaning features, and pragmatic meaning features;

[0026] A user profile 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 this application provides a data query system based on an AI large language model, comprising:

[0029] an acquiring unit, configured to acquire 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, the data dictionary being 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 determining unit is configured 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 existing technology, this application has the following beneficial effects:

[0036] This approach involves obtaining 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. The processing model is configured to match the first query information with a data dictionary based on the user profile corresponding to the operator. The data dictionary is a metadata dictionary for all database tables in a database cluster; the corresponding language model interface is invoked for processing based on the second query information, and a query code is returned by the language model interface; and a query result is determined based on the query code and the database cluster. Compared to existing self-service queries, which place higher demands on users, requiring an understanding of data storage structures and certain code development capabilities, the solution provided in this application associates and matches operator input with the data dictionary, assembling and submitting the results according to language model interface specifications to obtain more accurate results. This means that users do not need to understand data structures, and code development capabilities are not high. Massive amounts of data can be quickly retrieved without complex query operations or code writing. This approach addresses the inconvenience of user data acquisition and the difficulty of data querying caused by a lack of understanding of data structures, enabling automated data query without requiring user development capabilities. This is a technical problem urgently needed by those skilled in the art. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the technical solutions in this embodiment or the prior art, the following briefly introduces the drawings required for use in the embodiment or the prior art description. 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 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 This is 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 help those skilled in the art better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art 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, existing self-service query systems provide data query capabilities, but these require users to possess certain code development capabilities and a detailed understanding of the database in order to clearly identify data storage locations and data retrieval logic, and to write query code. In recent years, AI large language models have developed rapidly. ChatGPT is a natural language processing system driven by artificial intelligence technology. It can conduct conversations by understanding and learning human language, and can also interact based on the context of the chat. It can complete tasks such as writing emails, video scripts, copywriting, translation, coding, and writing papers. Domestic AI large language model products include Baidu Wenxin Yiyan, Alitong Yi Qianwen, Huawei Pangu, Fudan University MOSS, and others. These products are more in line with Chinese people's usage habits in understanding Chinese semantics and possess a certain level of basic common sense and rudimentary logical thinking skills, but there is still room for improvement in complex scientific calculations.

[0043] The method provided in the embodiment of the present application is executed by a background system, for example, a data query background server. The data query background server can be a single server device or a server cluster composed of multiple servers.

[0044] To address this issue, embodiments of the present application provide a data query method, system, device, and medium based on an AI large language model. The method involves obtaining 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. The processing model is configured to match the first query information with a data dictionary, which is a metadata dictionary for all database tables in a database cluster, based on the operator's corresponding user profile. The corresponding language model interface is then invoked for processing based on the second query information, and a query code returned by the language model interface is received. The query result is determined based on the query code and the database cluster. Specifically, after receiving the input information, the system generates data query code based on the language model interface, submits the code to the local database, and returns the corresponding data. Users can quickly access massive amounts of data through text or language descriptions without the need for complex query operations or code writing. This method addresses the inconvenience of user data acquisition and the difficulty of data querying caused by a lack of understanding of data structures. Furthermore, by collecting user feedback and user profile information such as user roles and data scope of interest, a model is trained and pre-set based on the user-input text, further improving the accuracy of the language model's returned results.

[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 describes a data query method based on an AI large language model provided by this application through an embodiment. Figure 1 , this figure is a flow chart of a data query method based on an AI large language model provided by an embodiment of the present application. The execution subject of the method process is a server. Further, the subject can 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 can 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 frontend can include a chat box, a query interface, and a data result display. The chat box is the interactive window between the user and the system backend, providing a dialogue-based interaction function. Users enter a text description of the query and receive a query code. A feedback function is also provided, allowing users to rate the returned query code.

[0050] In actual application scenarios, a camera device can be installed at an appropriate location on the self-service query front end to identify the current operator's facial information. Alternatively, a fingerprint recognition function can be set up on the front end interface to obtain the operator's fingerprint when the operator manually enters the query content, and then match the operator's relevant information with the pre-stored user database.

[0051] In a possible implementation, 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 actual application scenarios, when receiving voice information, lip movement detection can be performed on the scene image to determine the operator of the current first query information input. When receiving text information, 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 in the existing technology that self-service query 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 profile corresponding to the operator, and the data dictionary is a metadata dictionary of all database tables in the database cluster.

[0058] The chat function's backend system receives user input, associates and matches the input with the data dictionary, and generates text that can be easily recognized by the AI ​​language model. A simple example is as follows (field definitions are omitted):

[0059] The table structure related to 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 "indicator name, date and indicator value related to the scale of new energy storage projects."

[0064] In actual application scenarios, the data dictionary includes data categories, and the user profile generation method 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 user input, feedback, queries and other behavioral information, 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 and unambiguous language content.

[0075] Step C3: Determine a user profile corresponding to the operator based on the multiple different types of features.

[0076] In a possible application scenario, the features of different types obtained in the above steps are screened to form the required user profile. The feature screening 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] 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.

[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, 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 data queries with Chinese semantics use interface A, and foreign data queries with English semantics use interface B, making the returned results more accurate. It should be noted that these interfaces can be adjusted according to actual needs. This is only for 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, a 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 the query results will be returned from the database cluster.

[0083] This solves the problem of inconsistent interface language rules across numerous AI large language model products, using different accounts or clients. This method pre-packages AI large language model interfaces released by multiple vendors, such as ChatGPT and Baidu Wenxin Yiyan, in the backend system. These interfaces are accessed via proprietary keys and can be flexibly configured to connect to different AI large language model interfaces as needed. Users interacting in the self-service chat box do not need to worry about the specific underlying interfaces and language rules.

[0084] Furthermore, existing technologies that directly use large AI language models can pose data security risks. This method uses data stored locally, and calls to external interfaces only provide a data dictionary. No business data is uploaded, and no information such as database accounts is included, thus avoiding 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 from the operator on the query result.

[0087] S106: Optimize the processing model based on the feedback information.

[0088] Users can evaluate and rate the returned code in the chat box. All user behaviors will be recorded in the user behavior analysis module as material and basis for optimizing the text processing model.

[0089] This application addresses the existing issue of self-service queries being unable to provide feedback on returned results, resulting in a poor user experience. This method incorporates 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 user feedback. This data is then used to optimize the association model between text processing and the data dictionary, improving 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 this application. Based on this, this application also provides a corresponding system for data query. The system provided in the embodiment of this application will be introduced from the perspective of functional modularization. Figure 2 This is 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] An acquisition unit 201 is configured to acquire first query information input by an operator;

[0093] A second query information generating unit 202 is configured to input the first query information into a processing model to generate second query information for language model recognition. The processing model is configured to match the first query information with a data dictionary based on a user profile corresponding to the operator. The data dictionary is a metadata dictionary of all database tables in the database cluster.

[0094] An interface calling unit 203 is 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;

[0095] The query result determining unit 204 is configured to determine a query result based on the query code and the database cluster.

[0096] Optionally, the data dictionary includes data categories, and the user profile is generated in the following manner:

[0097] Obtaining 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, configured to acquire feedback information from 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 configured 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, configured to acquire a scene image, detect the scene image, and determine an operator who is inputting the first query information;

[0105] The user portrait determining 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 multiple different types of features, wherein the multiple different types of features include sentence pattern features, sentence color meaning features, and pragmatic meaning features;

[0109] A user profile 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 embodiments of the present application also provide corresponding devices and computer storage media for implementing the data query method solution based on the AI ​​large language model provided in the embodiments of the present application.

[0112] In which, 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. 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, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the systems or devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.

[0115] It should be understood that in this 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 previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items 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 document, relational terms such as first and second, etc., are used only 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 "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.

[0117] The steps of the methods or algorithms 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), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, 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 is intended to enable one skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to one 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 is not limited to the embodiments shown herein, but is intended to 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 the user profile corresponding to the operator, wherein the data dictionary is a metadata dictionary of all database tables in the database cluster; Invoking a corresponding language model interface for processing based on the second query information, and receiving a query code returned by the language model interface, wherein the second query information includes relevant metadata information matched from the data dictionary, and is used to guide the language model to generate a standardized database query code, wherein the query code is a structured query language code that can be directly executed on the database cluster; 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 profile is generated in the following manner: Obtaining 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. 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, wherein The calling a corresponding language model interface for processing based on the second query information includes: 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.

5. The method according to claim 1, wherein After obtaining the first query information input by the operator, the method further includes: Acquiring a scene image and detecting 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 multiple different types of features, wherein the multiple different types of features include sentence pattern features, sentence color meaning features, and pragmatic meaning features; A user profile 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 by: The system comprises: an acquiring unit, configured to acquire 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, the data dictionary being 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, wherein the second query information includes relevant metadata information matched from the data dictionary, and is configured to guide the language model to generate a standardized database query code, wherein the query code is a structured query language code that can be directly executed on the database cluster; A query result determining unit is configured 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. 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 the 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

  • Title generation method and device, electronic equipment and storage medium

    CN111859918A

  • Information retrieval method based on convolutional neural network, and device related thereto

    WO2021051517A1