Large language model intelligent number asking method suitable for electric quantity data query scene

By combining a large language model with semantic decomposition and a Transformer decoder to generate SQL statements for electricity marketing business, the problem of semantic understanding and multi-table joins in electricity marketing data query in existing technologies has been solved, achieving high accuracy and low failure rate in electricity data query.

CN120892452AActive Publication Date: 2025-11-04国网福建省电力有限公司营销服务中心 +1

Patent Information

Application Number
CN202511416277.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-30
Publication Date
2025-11-04
Estimated Expiration
2045-09-30

AI Technical Summary

Technical Problem

The existing NL2SQL model struggles to understand the electricity marketing-specific semantics and indicator logic in electricity marketing data scenarios. It cannot identify composite calculation logic and upstream and downstream indicator dependencies, resulting in inaccurate query results and a high failure rate. It also lacks the ability to handle multi-table joins and implicit field mapping.

Method used

A large language model is used in combination with a semantic decomposition module, a database field matching module, and a prompt word generation module. Keyword vectors are extracted through semantic decomposition, a structured Prompt is constructed, and SQL statements are generated using a Transformer decoder. Syntax errors are then corrected using an NTLR4 syntax tree.

Benefits of technology

It significantly improves the ability to parse semantics of electricity marketing business, automatically identifies the implicit mapping relationship between keywords and database fields, reduces the query failure rate, and improves the accuracy and completeness of SQL generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120892452A_ABST
    Figure CN120892452A_ABST
Patent Text Reader

Abstract

The invention relates to a large language model intelligent number asking method suitable for an electric quantity data query scene. The method comprises the following steps of performing semantic decomposition on query content input by a user to extract keyword vectors and query features; performing database field name matching based on the extracted keyword vectors to obtain database field names corresponding to all the keyword vectors; constructing a structured Prompt based on the query features and database field names corresponding to all keyword vectors, and generating a database preliminary query statement in the large language model according to the constructed Prompt; and repairing the database preliminary query statement to obtain a database query statement, querying corresponding data in the database through the database query statement, and returning the data to the user.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to a large language model intelligent question method suitable for an electric quantity data query scene and belongs to the technical field of machine learning. BACKGROUND

[0002] Electric quantity data involved in power marketing business is growing in scale, and business personnel need to frequently carry out user portrait analysis, daily electric quantity summary, market user dynamic tracking and other data query and analysis tasks in daily work; at present, relevant business personnel rely on traditional SQL query mode for data acquisition and analysis, and gradually adapt to the "question number type" data access method of directly generating SQL statements in natural language.

[0003] However, due to the typical characteristics of power marketing electric quantity data such as complex multi-table association, rich industry terms and deeply nested index logic, the application of the existing natural language to SQL method in the electric quantity data scene of power marketing still has the following challenges: the existing NL2SQL model is difficult to understand the power marketing specific semantics and index logic. Most of the current NL2SQL models are trained on general corpus, lack the understanding ability of "daily electric quantity pull rate", "industry year-on-year growth" and "monthly average load" and other power exclusive concepts, cannot identify the complex calculation logic and upstream and downstream index dependency relationship contained in the user question, and the generated SQL statement cannot effectively restore the business semantics, which seriously affects the accuracy and usability of the query result. The processing capacity of multi-table association and implicit field mapping is weak. Since electric quantity data is often stored in multiple business theme tables, complex multi-table association statements need to be constructed when querying. The existing NL2SQL technology is difficult to automatically identify the business association and JOIN path between implicit fields, and often has problems such as field missing and ambiguity conflict, which leads to SQL structure error or incomplete semantics, and high query failure rate. Lack of structured support for time series analysis requirements. There are a lot of typical time dimension deduction logic in electric quantity data analysis, and the general model is difficult to identify the time comparison rules and calculation formula therein, and it is difficult to automatically generate SQL statements containing aggregation calculation and multi-time window, which limits its applicability in marketing business analysis type questions. SUMMARY

[0004] In order to solve the problems existing in the prior art, the application provides a large language model intelligent question method suitable for an electric quantity data query scene.

[0005] The technical scheme of the application is as follows: On the one hand, the application provides a large language model intelligent question method suitable for an electric quantity data query scene, comprising the following steps: The query content input by the user is subjected to semantic decomposition to extract keyword vectors and query features; Based on the extracted keyword vector, the database field name matching is performed to obtain the database field name corresponding to each keyword vector; Based on the query feature and the database field name corresponding to each keyword vector, a structured Prompt is constructed, and a database preliminary query statement is generated in a large language model according to the constructed Prompt. After repairing the database preliminary query statement, a database query statement is obtained, and the corresponding data in the database is queried through the database query statement and returned to the user.

[0006] Preferably, the specific steps of the semantic decomposition of the user input query content are as follows: After the query content is segmented, a keyword vector is obtained, and the keyword vector is input into a DeBERTa model to extract the context semantic vector of each keyword vector; A character feature extraction model is constructed, and the query content is input into the character feature extraction model to extract the feature of each character; A phrase feature extraction model is constructed, and after the context semantic vectors are spliced, a window with a preset character size is used for sliding extraction to obtain multiple fragments, the fragments are input into the phrase feature extraction model, and the phrase feature extraction model outputs the phrase feature of each fragment; The context semantic vectors, character features and phrase features are fused to obtain a fused feature vector; The fused feature vector is input into a bidirectional long short-term memory network to extract a bidirectional hidden vector of the fused feature vector, and after the bidirectional hidden vector is spliced, a comprehensive hidden vector is obtained; Based on a dependency syntax analysis algorithm, the dependency arcs between each keyword vector are extracted, a dependency arc set is constructed based on all the dependency arcs, a dependency convolution model is constructed, and the dependency arc set is input into the dependency convolution model to extract a dependency feature vector; The dependency feature vector and the comprehensive hidden vector are fused to obtain the query feature of the current query statement.

[0007] Preferably, the specific steps of the database field name matching based on the extracted keyword vector are as follows: All effective keyword vectors in the keyword vectors are screened; Based on the effective keyword vectors, the field name matching in the database is performed.

[0008] Preferably, the specific steps of constructing the structured Prompt based on the query feature and the database field name corresponding to each keyword vector are as follows: The query feature is linearly projected into a continuous vector sequence; For the database field name corresponding to each effective keyword vector, the database field name is encoded and embedded into the continuous vector sequence to obtain a field embedding vector sequence. The decoder based on the Transformer model is constructed, the field embedding vector sequence is input into the decoder, and the decoder outputs a structured prompt.

[0009] Preferably, the decoder based on the Transformer model specifically comprises a rotary position encoding attention layer, a local convolution layer, a feed-forward gated fusion layer, and an output layer.

[0010] Preferably, a database syntax tree is constructed through NTLR4, syntax errors in a database preliminary query statement are detected through the database syntax tree, and the syntax errors are repaired.

[0011] In another aspect, the application further provides a large language model intelligent question system suitable for an electric quantity data query scene, comprising a semantic decomposition module, a database field matching module, a prompt word generation module, and a query module. The semantic decomposition module is used for performing semantic decomposition on the query content input by a user to extract a keyword vector and a query feature. The database field matching module is used for matching database field names based on the extracted keyword vector to obtain database field names corresponding to all keyword vectors. The prompt word generation module is used for constructing a structured Prompt based on the query feature and the database field names corresponding to all keyword vectors, and generating a database preliminary query statement in a large language model according to the constructed Prompt. The query module is used for repairing the database preliminary query statement to obtain a database query statement, and returning corresponding data in the database to the user after querying the corresponding data in the database through the database query statement.

[0012] In another aspect, the application further provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to the application when executing the program.

[0013] In another aspect, the application further provides a computer readable storage medium having a computer program stored thereon, wherein the program is executable on a processor to implement the method according to the application.

[0014] The application has the following advantages: 1. The application introduces a semantic decomposition module that fuses context semantics, character features, and phrase features, cooperates with dependency syntax analysis and a dependency convolution network, can deeply understand professional terms and index logic such as "daily power consumption pull rate" and "year-on-year growth" in the power industry, significantly improves the analysis ability of complex business semantics, and solves the problem that the existing NL2SQL model cannot restore power marketing semantics.

[0015] 2、The application can automatically identify the implicit mapping relationship between the keywords and the database fields by the effective keyword screening and vector matching mechanism combined with field embedding and Transformer decoder modeling, reasonably construct the JOIN path, solve the problems of missing and semantic ambiguity of query fields in the prior art, and improve the accuracy and integrity of SQL generation.

[0016] 3、The application constructs a structured Prompt generation module, guides the large language model to output the preliminary SQL, and then automatically repairs the syntax errors by using the NTLR4 syntax tree model, realizes the closed-loop guarantee from natural language to executable SQL statement, reduces the query failure rate, and improves the user experience. BRIEF DESCRIPTION OF DRAWINGS

[0017] Figure 1 The method flowchart of the application. DETAILED DESCRIPTION

[0018] The technical solutions in the embodiments of the application will be clearly and completely described below with reference to the drawings in the embodiments of the application. Obviously, the described embodiments are only part of the embodiments of the application, rather than all the embodiments of the application. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the application.

[0019] It should be understood that the step numbers used herein are only for the convenience of description, and are not limited to the execution sequence of the steps.

[0020] It should be understood that the terms used in the specification of the application are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in the specification and the appended claims of the application, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include the plural forms.

[0021] The terms "include" and "contain" indicate the presence of the described features, whole, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, whole, steps, operations, elements, components and / or sets thereof.

[0022] The term "and / or" means any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.

[0023] Referring to Figure 1 A large language model intelligent query method suitable for electric quantity data query scenarios, comprising the following steps: The query content input by the user is semantically decomposed to extract keyword vectors and query features; The database field name matching is performed based on the extracted keyword vector, and database field names corresponding to all keyword vectors are obtained. The structured Prompt is constructed based on the query feature and the database field names corresponding to all keyword vectors, and the database preliminary query statement is generated in the large language model according to the constructed Prompt. The database query statement is obtained after repairing the database preliminary query statement, and the corresponding data is queried in the database through the database query statement and returned to the user.

[0024] In some embodiments, the specific steps of the semantic decomposition of the query content input by the user are as follows: The query content is segmented to obtain a keyword vector, and the keyword vector is input into a DeBERTa model to extract a context semantic vector of each keyword vector; A character feature extraction model is constructed, and the query content is input into the character feature extraction model to extract the feature of each character; A phrase feature extraction model is constructed, the context semantic vectors are spliced, and the fragments are extracted by sliding through a window of a preset character number, to obtain a plurality of fragments, the fragments are input into the phrase feature extraction model, and the phrase feature extraction model outputs the phrase feature of each fragment; All context semantic vectors, character features, and phrase features are fused to obtain a fused feature vector; The fused feature vector is input into a bidirectional long short-term memory network to extract a bidirectional hidden vector of the fused feature vector, and the bidirectional hidden vector is spliced to obtain a comprehensive hidden vector; Dependent arcs between each keyword vector are extracted based on a dependency syntax analysis algorithm, a dependent arc set is constructed based on all dependent arcs, a dependent convolution model is constructed, and the dependent arc set is input into the dependent convolution model to extract a dependent feature vector; The dependent feature vector and the comprehensive hidden vector are fused to obtain the query feature of the current query statement.

[0025] In a specific embodiment, the character feature extraction model and the phrase feature extraction model are both constructed based on a convolutional neural network, wherein the character feature extraction model is provided with three convolutional layers, and each convolutional layer is provided with 32 filters; and the phrase feature extraction model is provided with two convolutional layers, and each convolutional layer is provided with 64 filters. In a specific embodiment, a DeBERTa-v3 model is used to extract the context semantic vector of each keyword vector. In a specific embodiment, the query content is segmented by using a jieba segmentation algorithm. In one specific embodiment, a gating fusion unit is configured to fuse all context semantic vectors, character features, and phrase features, as shown in the following formula: ; in: Represents the fused feature vector; This represents the sigmoid activation function; Indicates character characteristics; Indicates character feature weights; Indicates phrase characteristics; Indicates phrase feature weights; Represents a context semantic vector; This indicates element-wise multiplication.

[0026] In a specific embodiment, the fused feature vector is input into a bidirectional long short-term memory network to extract the bidirectional latent vector of the fused feature vector. Then, the bidirectional latent vectors are concatenated to obtain the comprehensive latent vector, as shown in the following formula: ; ; in: Represents the positive latent vector of the fused feature vectors; Represents the inverse latent vector of the fused feature vectors; Represents the composite implicit vector; This indicates a splicing operation.

[0027] In one specific embodiment, a dependency convolution model is constructed, which includes multiple convolutional layers. The dependency arc set is input into the dependency convolution model to extract dependency feature vectors, as shown in the following formula: ; in: This indicates the dependency convolution model. The output of the last layer is the dependency feature vector; express Activation function; Represent the set of dependent arcs; Indicates the first The number of dependency arcs for each keyword vector; Indicates in Middle and the first Keyword vectors with dependency arcs between them A set; This indicates the dependency convolution model. Layer weight matrix; Indicates the first The keyword vector in the dependency convolution model Vector representation of layers; In one specific embodiment, the dependency feature vector is fused with the integrated hidden vector as shown in the following formula: ; ; Wherein: represents the query feature; represents the adaptive gating coefficient; represents the dependency feature vector; represents the gating weight vector.

[0028] In some embodiments, the specific steps of database field name matching based on the extracted keyword vector are as follows: Screening effective keyword vectors from all keyword vectors; Performing field name matching in the database based on the effective keyword vectors.

[0029] In one specific embodiment, the specific steps of screening effective keyword vectors from all keyword vectors are as follows: Taking all keyword vectors as candidate words, constructing a candidate word similarity graph, where each node in the candidate word similarity graph corresponds to a candidate word, and the cosine similarity between nodes is taken as the edge weight; Calculating the score of each node based on the edge weight between nodes, and iterating the score through a machine learning model, as shown in the following formula: ; ; Wherein: represents the score of the node corresponding to the th iteration; represents the damping coefficient, determined through iteration; represents the term frequency score; represents the set of nodes other than the node represents the edge weight between the node and the node represents the integrated edge weight of the node ; represents the score of the node corresponding to the th iteration; represents the TF-IDF score of the node ; represents the TF-IDF score of the node ; represents the TF-IDF score of the node ; represents the TF-IDF score of the node ; When the deviation between the current iteration and the previous iteration reaches a preset deviation threshold, the iteration is stopped, and the score of each node is obtained, and the candidate word corresponding to the node with a score greater than a preset score threshold is screened as an effective keyword vector.

[0030] In one specific embodiment, after the effective keyword vector and the database field name are respectively mapped into vectors of the same dimension by the Word2Vec model, the cosine similarity is calculated respectively, and the one with the largest cosine similarity is determined as a successful match.

[0031] In some embodiments, the specific steps of constructing the structured Prompt based on the query feature and the database field name corresponding to all keyword vectors are as follows: linearly projecting the query feature into a continuous vector sequence; encoding the database field name corresponding to each effective keyword vector and embedding it into the continuous vector sequence to obtain a field embedding vector sequence; constructing a decoder based on the Transformer model, inputting the field embedding vector sequence into the decoder, and outputting the structured Prompt from the decoder.

[0032] In one specific embodiment, the query feature is linearly projected into a continuous vector sequence, which is specifically shown as follows: ; wherein: represents the continuous vector sequence; represents the linear projection weight matrix; represents the linear projection bias.

[0033] In one specific embodiment, the database field name corresponding to each effective keyword vector is encoded and embedded into the continuous vector sequence to obtain a field embedding vector sequence, which is specifically shown as follows: ; ; wherein: represents the field embedding vector sequence; represents the encoding of the i-th database field name; represents the total number of database field names; represents the embedding vector of the i-th database field name, which is calculated based on a pre-trained text encoder; represents the relative position of the i-th database field name corresponding keyword vector in the query content, which is specifically the position of the first character of the query content.

[0034] ​​​In some embodiments, the Transformer model based decoder specifically comprises a rotary positional encoding attention layer, a local convolution layer, a feed-forward gated fusion layer, and an output layer. In a specific embodiment, the rotary positional encoding attention layer first performs rotary positional encoding on each database field name encoding in the field embedding vector sequence, specifically as follows: ; Wherein: represents the rotary positional encoding of the i-th database field name encoding; ; represents a rotary positional encoder; represents the i-th database field name encoding; ; The rotary positional encoding of the database field name encoding is replaced with the original database field name encoding in the field embedding vector sequence to obtain a new field embedding vector sequence, and then the attention weight is extracted through the attention mechanism, specifically as follows: ; ; ; Wherein: represents the weight of the i-th database field name encoding in the new field embedding vector sequence; ; represents the query vector of the i-th database field name encoding in the new field embedding vector sequence; ; represents the key vector of the i-th database field name encoding in the new field embedding vector sequence; ; represents the attention dimension; represents a learnable relative position bias table, which determines the bias value based on the distance between two database field name encodings; represents a learnable query matrix; represents a learnable key matrix; Based on the attention weight, each database field name encoding in the new field embedding vector sequence is weighted to obtain a weighted field embedding vector sequence.

[0035] In a specific embodiment, the local convolution layer is composed of multiple layers of depth separable convolution layers, and the convolution kernel size of each layer of depth separable convolution layer is different, which is used to extract the local features of each database field name encoding in the weighted field embedding vector sequence. For any layer of depth separable convolution layer, the output result is specifically as follows: ; ; wherein: represents the preliminary feature extracted by the deep separable convolution layer for the th database field name code in the weighted field embedding vector sequence; represents the kernel size of the current deep separable convolution layer; represents the weight of the current deep separable convolution layer; represents the preliminary feature extracted by the deep separable convolution layer for the th database field name code in the weighted field embedding vector sequence; represents the preliminary feature extracted by the deep separable convolution layer for the th database field name code in the weighted field embedding vector sequence; represents the local feature of the th database field name code in the weighted field embedding vector sequence output by the current deep separable convolution layer, which is input into the next deep separable convolution layer if the current deep separable convolution layer is not the last layer, or is the final output; represents LayerScale (scalable factor); represents the normalization operation; In one specific embodiment, the feedforward gate fusion layer includes a main channel and a gate channel, and is specifically as shown in the following formula: ; ; ; ; wherein: represents the output of the feedforward gate fusion layer; represents the main channel output of the feedforward gate fusion layer; represents the gate channel output of the feedforward gate fusion layer; represents the fusion result of the main channel output and the gate channel output of the feedforward gate fusion layer; represents the weighted field embedding vector sequence; represents the output weight matrix of the feedforward gate fusion layer; represents the output bias of the feedforward gate fusion layer; represents the local convolution layer output result; represents the main channel weight matrix; represents the main channel bias; represents the gate channel weight matrix; represents the gate channel bias; In one specific embodiment, the output layer is built based on a multilayer perception mechanism, for receiving the output of the feedforward gate fusion layer, and inputting a structured Prompt.

[0036] In one specific embodiment, the structured Prompt example is as follows: Question: Query the daily electricity consumption and pull rate of large industrial users in a certain area in March 2024 compared with the same period last year; Fields: date, city_name, industry_type, daily_energy, year_over_year, pull_rate; Objective: Generate an executable SQL that meets: 1. Statistics of daily dimension data of large industrial users in a certain area from 2024-03-01 to 2024-03-31; 2. Give the daily electricity consumption this year, the daily electricity consumption of the same period last year, the year-on-year growth rate (%), and the pull rate (%); 3. If the year_over_year or pull_rate field does not exist, calculate in SQL: Year-on-year = (This year's electricity consumption - last year's electricity consumption) / last year's electricity consumption x 100; Pull rate = daily growth / monthly cumulative growth x 100; 4. The results are sorted in ascending order of date.

[0037] In some embodiments, a database syntax tree is constructed through NTLR4, syntax errors in the database preliminary query statement are detected through the database syntax tree, and are repaired.

[0038] In some embodiments, a large language model intelligent question system suitable for electricity data query scenarios is proposed, including a semantic decomposition module, a database field matching module, a prompt word generation module, and a query module; The semantic decomposition module is used to perform semantic decomposition on the user's input query content to extract keyword vectors and query features; The database field matching module is used to match database field names based on the extracted keyword vectors to obtain the database field names corresponding to all keyword vectors; The prompt word generation module is used to construct a structured Prompt based on the query features and the database field names corresponding to all keyword vectors, and generate a database preliminary query statement in the large language model according to the constructed Prompt; The query module is used to repair the database preliminary query statement to obtain a database query statement, and returns the corresponding data to the user after querying the database through the database query statement.

[0039] In some embodiments, an electronic device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the method according to any of the embodiments of the application when executing the program.

[0040] In some embodiments, a computer readable storage medium is provided, having stored thereon a computer program, the program being executable on a processor to implement the method according to any of the embodiments of the application.

[0041] In the embodiments of the present application, "at least one" means one or more, and "multiple" means two or more. The "and / or" describes the association relationship of the associated objects, which means that there can be three kinds of relationships, for example, A and / or B, which can represent the cases of A alone, A and B together, and B alone. Wherein A and B can be singular or plural. The character " / " generally represents that the associated objects before and after it are in an "or" relationship. "At least one of the following" and the like expressions mean any combination of these items, including any combination of single or multiple items. For example, at least one of a, b and c can represent: a, b, c, a and b, a and c, b and c, or a and b and c, wherein a, b, and c can be single or multiple.

[0042] Those of ordinary skill in the art can be aware that each unit and algorithm step described in the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. Whether the functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0043] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described system, device and unit can refer to the corresponding processes in the foregoing method embodiments, which will not be described here.

[0044] In several embodiments provided in the present application, any function, if realized in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application or the parts of the technical solutions that essentially contribute to the prior art or the parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in the embodiments of the present application. The aforementioned storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.

[0045] The above description is only some embodiments of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation, or direct or indirect application in other related technical fields, based on the content of the specification and drawings of the present application, are also included in the patent protection scope of the present application.

Claims

1. A large language model intelligent question method suitable for electric quantity data query scene, characterized in that, The method comprises the following steps: The semantic decomposition of the query content input by the user is performed to extract a keyword vector and a query feature; Database field names corresponding to all keyword vectors are obtained based on the extracted keyword vectors through database field name matching; A structured prompt is constructed based on the query feature and the database field names corresponding to all keyword vectors, and a database preliminary query statement is generated in a large language model according to the constructed prompt; After the database preliminary query statement is repaired, a database query statement is obtained, and corresponding data in the database is queried through the database query statement and then returned to the user.

2. The large language model intelligent question answering method suitable for electric quantity data query scene according to claim 1, characterized in that, The specific steps of the semantic decomposition of the query content input by the user are as follows: After the query content is segmented, a keyword vector is obtained, and then the keyword vector is input into a DeBERTa model to extract a context semantic vector of each keyword vector; A character feature extraction model is constructed, and each character feature is extracted by inputting the query content into the character feature extraction model; A phrase feature extraction model is constructed, a plurality of fragments are obtained by sliding extraction through a window of a preset character number after splicing all context semantic vectors, the fragments are input into the phrase feature extraction model, and the phrase feature extraction model outputs a phrase feature of each fragment; All context semantic vectors, character features and phrase features are fused to obtain a fusion feature vector; The fusion feature vector is input into a bidirectional long short-term memory network to extract a bidirectional hidden vector of the fusion feature vector, and a comprehensive hidden vector is obtained after splicing the bidirectional hidden vector; Dependent arcs between each keyword vector are extracted based on a dependent syntax analysis algorithm, a dependent arc set is constructed based on all dependent arcs, a dependent convolution model is constructed, and a dependent feature vector is extracted by inputting the dependent arc set into the dependent convolution model; The dependent feature vector and the comprehensive hidden vector are fused to obtain a query feature of the current query statement.

3. The large language model intelligent question answering method suitable for electric quantity data query scene according to claim 2, characterized in that, The specific steps of the database field name matching based on the extracted keyword vectors are as follows: All effective keyword vectors in all keyword vectors are screened; The field name matching is performed in the database based on the effective keyword vectors.

4. The large language model intelligent question answering method suitable for electric quantity data query scene according to claim 3, characterized in that, The specific steps of the construction of the structured prompt based on the query feature and the database field names corresponding to all keyword vectors are as follows: The query feature is linearly projected into a continuous vector sequence; For the database field name corresponding to each effective keyword vector, the database field name is encoded and embedded into the continuous vector sequence to obtain a field embedding vector sequence; A decoder based on a Transformer model is constructed, the field embedding vector sequence is input into the decoder, and the decoder outputs the structured prompt.

5. The large language model intelligent question answering method suitable for electric quantity data query scene according to claim 4, characterized in that, The decoder based on the Transformer model specifically comprises a rotating position coding attention layer, a local convolution layer, a feedforward gate fusion layer and an output layer.

6. The large language model intelligent question answering method suitable for electric quantity data query scene according to claim 1, characterized in that, A database syntax tree is constructed through NTLR4, syntax errors in the database preliminary query statement are detected through the database syntax tree, and the syntax errors are repaired.

7. A large language model intelligent question answering system suitable for electric quantity data query scene, characterized in that, The method comprises a semantic decomposition module, a database field matching module, a prompt word generation module and a query module. The semantic decomposition module is used for the semantic decomposition of the query content input by the user to extract a keyword vector and a query feature. The database field matching module is configured to perform database field name matching based on the extracted keyword vector, to obtain database field names corresponding to all keyword vectors; The prompt generation module is configured to construct a structured Prompt based on the query features and the database field names corresponding to all keyword vectors, and generate a database preliminary query statement in a large language model according to the constructed Prompt; The query module is configured to repair the database preliminary query statement to obtain a database query statement, and return corresponding data in the database to the user after querying the database according to the database query statement.

8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the method of any one of claims 1 to 6 when executing the program.

9. A computer readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Multi-document intelligent question and answer method and system based on large language model

    CN118394897A

  • Natural language to SQL (Structured Query Language) method and device based on large language model and medium

    CN120011392A

  • Data processing method and system for enterprise digital transformation platform

    CN120316124A

  • Context-based prompt generation for automated translations between natural language and query language

    US20250156413A1

Cited By

  • Hybrid RAG retrieval method and device based on constraint keyword extraction

    CN121092725A