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

Through the data query method based on the large language model, natural language query statements are converted into Elasticsearch query DSL, solving the problems of high thresholds for traditional DSL and limited performance of visualization tools, and achieving efficient and accurate data query.

CN120045689APending Publication Date: 2025-05-27山东浪潮智慧医疗科技有限公司
View PDF 0 Cites 6 Cited by

Patent Information

Application Number
CN202411894514.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-20
Publication Date
2025-05-27

AI Technical Summary

Technical Problem

Elasticsearch's traditional query DSL has the problem of high learning and use thresholds, which is difficult to meet the complex data query needs of non-technical users or business analysts. At the same time, the Web-based visual query tools have limitations in performance and compatibility.

Method used

The data query method based on the large language model is adopted, and the natural language query statement input by the user is converted into Elasticsearch query DSL through natural language processing technology. The large language model and semantic layer technology are used to generate logical SQL and physical SQL query statements, and finally converted into Elasticsearch query DSL and executed.

Benefits of technology

The data query process is simplified, the user's data query efficiency and accuracy are improved, the cost is reduced, the complex query needs are met, and the performance and compatibility are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120045689A_ABST
    Figure CN120045689A_ABST
Patent Text Reader

Abstract

The invention belongs to the field of data query, and particularly discloses a data query method and system based on a large language model, a terminal and a medium. Analyzing the natural language query statement by using a natural language processing technology to obtain query parameters including a query entity, a statement dependency relationship and a user intention; utilizing a pre-trained large language model to generate a logic SQL query statement according to the query parameters; converting the logic SQL query statement into a physical SQL query statement by utilizing a semantic layer technology; the method comprises the following steps of: converting a physical SQL (Structured Query Language) query statement into a domain specific language for Elasticsearch query by utilizing an SQL parser; and executing the Elasticsearch query on the Elasticsearch cluster by using a domain specific language to obtain a query result. A natural language processing technology, a large language model and a semantic layer technology are utilized to convert a natural language query statement into an Elasticsearch query DSL, the data query process is simplified, the data query efficiency and precision of a user are improved, the cost is reduced, and the query requirement is met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of data query, and specifically relates to a data query method, system, terminal and medium based on a large language model. Background Art

[0002] Elasticsearch (hereinafter referred to as ES) has been widely used in scenarios such as log analysis, monitoring and alerting, full-text search, and real-time analysis due to its powerful full-text search ability and real-time data analysis ability. It supports efficient indexing and query operations, can handle petabytes of data, and achieve millisecond-level response speed.

[0003] There is a certain learning and usage threshold for the traditional query DSL (Domain Specific Language) of Elasticsearch. DSL is a programming language specifically designed for a specific domain, which allows users to define complex query logic in a declarative manner. For non-technical users or business analysts, understanding and writing DSL queries is a challenging task, seriously affecting data query efficiency and accuracy.

[0004] Currently, web-based visual query tools allow users to construct query statements through a graphical interface. However, these tools often only support simple query operations, and for complex query logic, users still need to write DSL code. In addition, these tools also have certain limitations in terms of performance and compatibility, and cannot fully meet the actual needs of enterprises. Summary of the Invention

[0005] To solve the above problems, the present invention provides a data query method, system, terminal and medium based on a large language model, which uses natural language processing technology, large language model and semantic layer technology to convert natural language query statements into Elasticsearch query DSL, simplifies the data query process, improves the user's data query efficiency and accuracy, reduces costs, and meets the query requirements.

[0006] In the first aspect, the technical solution of the present invention provides a data query method based on a large language model, including the following steps: Receive a natural language query statement input by the user; Use natural language processing technology to analyze the natural language query statement to obtain query parameters, including query entities, statement dependency relationships and user intentions; Use a pre-trained large language model to generate a logical SQL query statement according to the query parameters; Use semantic layer technology to convert the logical SQL query statement into a physical SQL query statement; Use an SQL parser to convert the physical SQL query statement into a domain-specific language for Elasticsearch queries; Execute the domain-specific language for Elasticsearch queries on the Elasticsearch cluster to obtain the query results.

[0007] In an optional implementation, use natural language processing technology to analyze the natural language query statement to obtain query parameters, specifically including: Perform text cleaning on the natural language query statement to remove irrelevant characters in the query statement; Use the NLP framework to split the natural language query statement after text cleaning into individual words or phrases; Assign part-of-speech tags to each word obtained by splitting; Based on the word segmentation results, use a pre-trained named entity recognition model to identify the query entities in the query statement; Use a dependency parser to parse the dependency relationships of the natural language query statement, generate a dependency syntax tree, and extract the dependency relationships from the dependency syntax tree; Use a pre-trained intent classification BERT model to perform intent classification on the natural language query statement to obtain the user's query intent.

[0008] In an optional implementation, the method further includes the following steps: Periodically extract names, aliases, and values from the processing results of natural language processing technology; Adopt an n-gram dictionary detection mechanism for dictionary matching to build a knowledge base.

[0009] In an optional implementation, use a pre-trained large language model to generate a logical SQL query statement according to the query parameters, specifically including: Input the query parameters into the pre-trained large language model to generate an initial logical SQL query statement; Parse the domain nouns from the initial logical SQL query statement; Based on the knowledge base, perform a legality check on the parsed domain nouns, and correct the incorrect fields through an error correction tool; Obtain the corrected logical SQL query statement.

[0010] In an optional implementation, use semantic layer technology to convert the logical SQL query statement into a physical SQL query statement, specifically including: Use semantic layer technology to manage the association relationships and operation formulas between technical terms and business terms; Based on the association relationships and operation formulas between technical terms and business terms in the technology, convert the technical terms in the logical SQL query statement into business terms to generate a physical SQL query statement.

[0011] In an alternative embodiment, use an SQL parser to convert the physical SQL query statement into a domain-specific language for Elasticsearch queries, specifically including: Map the SELECT clause to the aggs part of Elasticsearch; Map the WHERE clause to the query part of Elasticsearch; Map the GROUP BY clause to the terms part of Elasticsearch; Map the ORDER BY clause to the sort part of Elasticsearch.

[0012] In a second aspect, the technical solution of the present invention provides a data query system based on a large language model, including: A query statement receiving module, configured to receive a natural language query statement input by a user; A query parameter obtaining module, configured to analyze the natural language query statement by using natural language processing technology to obtain query parameters, including query entities, statement dependency relationships, and user intentions; A logical SQL query statement generating module, configured to generate a logical SQL query statement according to the query parameters by using a pre-trained large language model; A physical SQL query statement generating module, configured to convert the logical SQL query statement into a physical SQL query statement by using semantic layer technology; A statement conversion module, configured to convert the physical SQL query statement into a domain-specific language for Elasticsearch queries by using an SQL parser; A query execution module, configured to execute the domain-specific language for Elasticsearch queries on an Elasticsearch cluster to obtain a query result.

[0013] In an alternative embodiment, the system further includes: A knowledge base construction module, configured to periodically extract names, aliases, and values from the processing results of natural language processing technology, and perform dictionary matching by using an n-gram dictionary detection mechanism to construct a knowledge base.

[0014] In a third aspect, the technical solution of the present invention provides a terminal, including: A memory, configured to store a data query program based on a large language model; A processor for implementing the steps of the data query method based on a large language model as described in any one of the above when executing the data query program based on the large language model.

[0015] In a fourth aspect, the technical solution of the present invention provides a computer-readable storage medium, on which a data query program based on a large language model is stored. When the data query program based on the large language model is executed by a processor, the steps of the data query method based on the large language model as described in any one of the above are implemented.

[0016] The data query method, system, terminal and medium based on a large language model provided by the present invention have the following beneficial effects compared with the prior art: query parameters are extracted from natural language query statements through natural language processing technology, and physical SQL query statements are generated according to the query parameters by using a large language model and semantic layer technology. Then, the physical SQL query statements are converted into Elasticsearch query DSL, and the query results can be obtained by executing the DSL. The present invention only requires the user to input natural language query statements, and can automatically convert natural language into DSL for query by using natural language processing technology, a large language model and semantic layer technology, without writing DSL code, greatly improving the convenience, efficiency and accuracy of data query, and realizing efficient and accurate retrieval. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solution of the present invention, the drawings required to be used in the description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0018] Figure 1 It is a schematic flowchart of a data query method based on a large language model provided by an embodiment of the present invention.

[0019] Figure 2 It is a schematic block diagram of the structure of a data query system based on a large language model provided by an embodiment of the present invention.

[0020] Figure 3 It is a schematic diagram of the structure of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0021] To make the objectives, features, and advantages of the present invention more apparent and understandable, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the specific embodiments of the present invention. Obviously, the embodiments described below are only a part of the embodiments of the present invention, rather than all embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this patent without creative efforts belong to the scope of protection of this patent.

[0022] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which this invention belongs. The terms used in the description of this invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.

[0023] The key terms that appear in the present invention will be explained below.

[0024] SQL: Structured Query Language, a structured query language.

[0025] Elasticsearch: abbreviated as ES, is a distributed, highly scalable, and highly real-time search and data analysis engine.

[0026] DSL: Domain-Specific Language, a domain-specific language.

[0027] NER: Named Entity Recognition, named entity recognition.

[0028] Figure 1 It is a schematic flowchart of a data query method based on a large language model provided by an embodiment of the present invention. Among them, Figure 1 The execution subject can be a data query system based on a large language model. The data query method based on a large language model provided by the embodiment of the present invention is executed by a computer device. Correspondingly, the data query system based on a large language model runs in the computer device. According to different requirements, the order of the steps in this flowchart can be changed, and some can be omitted.

[0029] As Figure 1 shown, the method includes the following steps.

[0030] S1, receive a natural language query statement input by the user.

[0031] In this step, the user inputs a natural language query statement at the front-end query interface of the platform. The background receives the natural language query statement input by the user and performs subsequent processing, and finally feeds back the query result to the front-end for the user to view.

[0032] S2. Analyze the natural language query statement using natural language processing technology to obtain query parameters, including query entities, statement dependency relationships, and user intentions.

[0033] S2.1. Clean the text of the natural language query statement to remove irrelevant characters from the query statement.

[0034] S2.2. Use the NLP framework to split the natural language query statement after text cleaning into individual words or phrases.

[0035] S2.3. Assign part-of-speech tags to each word obtained by splitting.

[0036] S2.4. Based on the word segmentation results, use a pre-trained named entity recognition model to identify query entities in the query statement.

[0037] S2.5. Use a dependency parser to analyze the dependency relationships of the natural language query statement, generate a dependency syntax tree, and extract the dependency relationships from the dependency syntax tree.

[0038] S2.6. Use a pre-trained intention classification BERT model to classify the intention of the natural language query statement to obtain the user's query intention.

[0039] In this embodiment, natural language processing technology is used to parse the natural language query statement input by the user, and key elements are extracted. Exemplarily, if the user inputs "Query error logs within the past week", core information such as "the past week" and "error logs" can be identified after this step of processing.

[0040] S3. Use a pre-trained large language model to generate a logical SQL query statement based on the query parameters.

[0041] S3.1. Input the query parameters into the pre-trained large language model to generate an initial logical SQL query statement.

[0042] S3.2. Parse domain nouns from the initial logical SQL query statement.

[0043] S3.3. Perform a legality check on the parsed domain nouns based on the knowledge base, and correct incorrect fields through an error correction tool.

[0044] S3.4. Obtain the corrected logical SQL query statement.

[0045] In this embodiment, a large language model is used to convert natural query language into a logical SQL query statement. The large language model is pre-trained, such as the GPT-4 model. Using the powerful language understanding and generation ability of the large language model, the query parameters of natural query language can be converted into a query statement that conforms to SQL syntax.

[0046] Exemplarily, for "finding error logs in the past week", the generated logical SQL query statement is: SELECT * FROM logs WHERE log_level = 'error' AND timestamp>= NOW() - INTERVAL 7 DAY。

[0047] To improve query accuracy, in this embodiment, after generating the initial logical SQL query statement, the domain nouns in it are detected and corrected for legality, and the legality and correction can be based on the knowledge base. Parse nouns such as tables, fields, and values from the generated SQL, and check their legality one by one. For illegal nouns, query the internal knowledge base (knowledge base) in a way similar to schema mapping, try to find the correct match, and rewrite the SQL. For example, the large language model may map the value to the wrong field, and the corrector module tries to find the correct field mapping and rewrite the SQL to ensure the accuracy of the query.

[0048] An optional implementation method is to periodically extract names, aliases, and values from the processing results of natural language processing technology, and use the n-gram dictionary detection mechanism for dictionary matching to build a knowledge base (knowledge base).

[0049] S4. Use semantic layer technology to convert the logical SQL query statement into a physical SQL query statement.

[0050] In this embodiment, the logical SQL query statement is converted into a physical SQL query statement through semantic layer technology. First, the query caliber is managed, including the association relationship and operation formula between technical terms and business terms, to ensure data consistency and accuracy, facilitate account checking and comparison, and eliminate caliber confusion. Then, according to the association relationship and operation formula, translate technical names (such as table names and field names) into business terms (such as dimensions, metrics, and labels) to obtain the physical SQL query statement.

[0051] For example, the logical SQL query statement of "finding error logs in the past week" above is converted into a physical SQL query statement as follows: SELECT * FROM actual_logs_table WHERE actual_log_level_field = 'error' AND actual_timestamp_field>=CURRENT_TIMESTAMP - INTERVAL '7 days' S5, use an SQL parser to convert the physical SQL query statement into a domain-specific language for Elasticsearch queries.

[0052] In this embodiment, an SQL parser is used to convert the generated SQL statement into an Elasticsearch query DSL. The SQL parser uses Apache Calcite or JSqlParser for SQL parsing. By parsing the structure and content of the SQL statement, the corresponding Elasticsearch query DSL is generated.

[0053] The DSL generated by SQL to DSL includes the query, aggs, terms, and sort parts of Elasticsearch. The specific parsing process includes mapping the SELECT clause to the aggs part of Elasticsearch, the WHERE clause to the query part of Elasticsearch, the GROUP BY clause to the terms part of Elasticsearch, and the ORDER BY clause to the sort part of Elasticsearch.

[0054] Among them, the mapping of the SELECT clause maps the aggregation operation to the scripted_metric aggregation of Elasticsearch to generate the DSL.

[0055] Exemplarily, the physical SQL query statement of "finding error logs in the past week" is converted to: { "query": { "bool": { "must": { "match": { "actual_log_level_field": "error" } }, { "range": { "actual_timestamp_field": { "gte": "now-7d / d", "lt": "now / d" } } } } } } S6. Execute the Elasticsearch query in the Elasticsearch cluster using the domain-specific language to obtain the query result.

[0056] In this embodiment, the generated Elasticsearch query DSL is executed in the Elasticsearch cluster. By calling the API of Elasticsearch, the system can obtain the documents that meet the query conditions. This step realizes operations such as connecting to the Elasticsearch cluster, executing the query, and obtaining the result.

[0057] In the above, embodiments of a data query method based on a large language model have been described in detail. Based on the data query method based on the large language model described in the above embodiments, an embodiment of the present invention also provides a data query system based on the large language model corresponding to this method.

[0058] Figure 2 FIG. is a schematic block diagram of the structure of a data query system based on a large language model provided by an embodiment of the present invention. In this embodiment, the data query system 200 based on the large language model can be divided into multiple functional modules according to the functions it performs, such as Figure 2 shown. The module referred to in the present invention means a series of computer program segments that can be executed by at least one processor and can complete fixed functions, and are stored in the memory.

[0059] The query statement receiving module 210 is used to receive the natural language query statement input by the user.

[0060] The query parameter obtaining module 220 is used to analyze the natural language query statement using natural language processing technology to obtain query parameters, including query entities, statement dependency relationships, and user intentions.

[0061] The logical SQL query statement generating module 230 is used to generate a logical SQL query statement according to the query parameters using a pre-trained large language model.

[0062] The physical SQL query statement generating module 240 is used to convert the logical SQL query statement into a physical SQL query statement using semantic layer technology.

[0063] ​A statement conversion module 250, which is used to convert a physical SQL query statement into a domain-specific language for Elasticsearch query by using an SQL parser.

[0064] A query execution module 260, which is used to execute the domain-specific language for Elasticsearch query on an Elasticsearch cluster to obtain a query result.

[0065] In an optional embodiment, the system 200 further includes a knowledge base construction module 270, which is used to periodically extract names, aliases, and values from the processing results of natural language processing technologies, and perform dictionary matching by using an n-gram dictionary detection mechanism to construct a knowledge base.

[0066] The data query system based on a large language model in this embodiment is used to implement the foregoing data query method based on a large language model. Therefore, the specific implementation manners in this system can be seen in the embodiment part of the data query method based on a large language model in the foregoing text. Therefore, its specific implementation manners can refer to the descriptions of the corresponding various part embodiments, and will not be elaborated here.

[0067] In addition, since the data query system based on a large language model in this embodiment is used to implement the foregoing data query method based on a large language model, its functions correspond to those of the foregoing method, and will not be elaborated here.

[0068] Figure 3 FIG. is a schematic structural diagram of a terminal 300 provided by an embodiment of the present invention, including: a processor 310, a memory 320, and a communication unit 330. When the processor 310 implements the data query program based on a large language model stored in the memory 320, the following steps are implemented: Receive a natural language query statement input by a user; Use natural language processing technologies to analyze the natural language query statement to obtain query parameters, including a query entity, a statement dependency relationship, and a user intention; Use a pre-trained large language model to generate a logical SQL query statement according to the query parameters; Use semantic layer technologies to convert the logical SQL query statement into a physical SQL query statement; Use an SQL parser to convert the physical SQL query statement into a domain-specific language for Elasticsearch query; Execute the domain-specific language for Elasticsearch query on an Elasticsearch cluster to obtain a query result.

[0069] The terminal 300 includes a processor 310, a memory 320, and a communication unit 330. These components communicate via one or more buses. Those skilled in the art can understand that the structure of the server shown in the figure does not constitute a limitation on the present invention. It can be a bus structure, a star structure, and can also include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.

[0070] Among them, the memory 320 can be used to store the execution instructions of the processor 310. The memory 320 can be implemented by any type of volatile or non-volatile storage terminal or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk. When the execution instructions in the memory 320 are executed by the processor 310, the terminal 300 can execute some or all of the steps in the above method embodiments.

[0071] The processor 310 is the control center of the storage terminal, connecting various parts of the entire electronic terminal through various interfaces and lines. By running or executing software programs and / or modules stored in the memory 320, and by calling the data stored in the memory, it executes various functions of the electronic terminal and / or processes data. The processor can be composed of an integrated circuit (IC). For example, it can be composed of a single packaged IC, or can be composed of multiple packaged ICs with the same or different functions connected together. For example, the processor 310 can only include a central processing unit (CPU). In the embodiment of the present invention, the CPU can be a single operation core or can include multiple operation cores.

[0072] The communication unit 330 is used to establish a communication channel so that the storage terminal can communicate with other terminals. It receives user data sent by other terminals or sends user data to other terminals.

[0073] The present invention also provides a computer storage medium. The storage medium here can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), etc.

[0074] The computer storage medium stores a data query program based on a large language model. When the data query program based on the large language model is executed by the processor, the following steps are implemented: Receive the natural language query statement input by the user; Use natural language processing technology to analyze the natural language query statement to obtain query parameters, including query entities, statement dependency relationships, and user intentions; Use a pre-trained large language model to generate a logical SQL query statement based on the query parameters; Use semantic layer technology to convert the logical SQL query statement into a physical SQL query statement; Use an SQL parser to convert the physical SQL query statement into a domain-specific language for Elasticsearch queries; Execute the domain-specific language for Elasticsearch queries on an Elasticsearch cluster to obtain query results.

[0075] Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solutions in the embodiments of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk, or an optical disc, etc., which can store program codes. It includes several instructions to enable a computer terminal (which can be a personal computer, a server, or a second terminal, a network terminal, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.

[0076] In several embodiments provided by the present invention, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in an electrical, mechanical, or other form.

[0077] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0078] In addition, in each embodiment of the present invention, each functional unit may be integrated into one processing unit, may exist separately as individual physical units, or two or more units may be integrated into one unit.

[0079] The foregoing description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily 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 invention. Therefore, the present invention will not be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A data query method based on a large language model, characterized in that: The following steps are involved: Receiving a natural language query statement input by a user; Use natural language processing technology to analyze natural language query statements and obtain query parameters, including query entities, statement dependencies, and user intent; Use the pre-trained large language model to generate logical SQL query statements based on query parameters; Use semantic layer technology to convert logical SQL query statements into physical SQL query statements; Use the SQL parser to convert physical SQL query statements into the domain-specific language used for Elasticsearch queries; Execute Elasticsearch queries on the Elasticsearch cluster using a domain-specific language to obtain query results.

2. The data query method based on a large language model according to claim 1, characterized in that: Use natural language processing technology to analyze natural language query statements and obtain query parameters, including: Perform text cleaning on natural language query statements to remove irrelevant characters in the query statements; Use the NLP framework to split the natural language query statements after text cleaning into separate words or phrases; Assign a part of speech to each word obtained by splitting; Based on the word segmentation results, the pre-trained named entity recognition model is used to identify the query entities in the query sentence; Use a dependency syntax analyzer to parse the dependency relationship of a natural language query sentence, generate a dependency syntax tree, and extract the dependency relationship from the dependency syntax tree; Use the pre-trained intent classification BERT model to classify the intent of natural language query sentences and obtain the user's query intent.

3. The data query method based on a large language model according to claim 2, characterized in that: The method further comprises the following steps: Periodically extract names, aliases, and values ​​from the processing results of natural language processing technology; The n-gram dictionary detection mechanism is used for dictionary matching to build the knowledge base.

4. The data query method based on a large language model according to claim 1 or 3, characterized in that: Use the pre-trained large language model to generate logical SQL query statements based on query parameters, including: Input query parameters into the pre-trained large language model to generate the initial logical SQL query statement; Parse domain terms from the initial logical SQL query statement; Based on the knowledge base, the legitimacy of the parsed domain terms is checked, and the wrong fields are corrected through the error correction tool; Get the corrected logical SQL query statement.

5. The data query method based on a large language model according to claim 4, characterized in that: Using semantic layer technology to convert logical SQL query statements into physical SQL query statements specifically includes: Use semantic layer technology to manage the relationship and calculation formulas between technical terms and business terms; Based on the association between technical terms and business terms and the operation formula, the technical terms in the logical SQL query statement are converted into business terms to generate a physical SQL query statement.

6. The data query method based on a large language model according to claim 5, characterized in that: Use the SQL parser to convert physical SQL query statements into the domain-specific language used for Elasticsearch queries, including: Map the SELECT clause to the aggs part of Elasticsearch; Map the WHERE clause to the query part of Elasticsearch; Map the GROUP BY clause to the terms part of Elasticsearch; Maps the ORDER BY clause to the sort part of Elasticsearch.

7. A data query system based on a large language model, characterized in that: include: A query statement receiving module, used to receive a natural language query statement input by a user; A query parameter acquisition module is used to analyze natural language query statements using natural language processing technology to obtain query parameters, including query entities, statement dependencies, and user intent; A logical SQL query statement generation module is used to generate logical SQL query statements according to query parameters using a pre-trained large language model; A physical SQL query statement generation module is used to convert a logical SQL query statement into a physical SQL query statement by using semantic layer technology; A statement conversion module, which is used to convert physical SQL query statements into a domain-specific language for Elasticsearch queries using an SQL parser; The query execution module is used to execute the Elasticsearch query on the Elasticsearch cluster using a domain-specific language to obtain the query results.

8. The data query system based on a large language model according to claim 7, characterized in that: The system also includes: The knowledge base construction module is used to periodically extract names, aliases, and values ​​from the processing results of natural language processing technology, and use the n-gram dictionary detection mechanism to perform dictionary matching to build a knowledge base.

9. A terminal, characterized in that: include: A memory, used for storing a data query program based on a large language model; A processor, configured to implement the steps of the data query method based on a large language model as described in any one of claims 1 to 6 when executing the data query program based on a large language model.

10. A computer-readable storage medium, characterized in that: The readable storage medium stores a data query program based on a large language model, and when the data query program based on a large language model is executed by a processor, the steps of the data query method based on a large language model as described in any one of claims 1 to 6 are implemented.

Citation Information

Cited By

  • SQL (Structured Query Language) optimization interaction method and device based on deep learning framework large model

    CN120508569A

  • Method and system for performing natural language question and answer directly according to dimension value

    CN121144446A

  • Data compliance intelligent auditing method and device based on AI, equipment and medium

    CN121413754A

  • Natural language access system and method based on large language model and business metadata

    CN121935273A

  • Method and system for converting natural language query into ES DSL based on large model and medium

    CN122470709A