Data generation method for text-to-sql task, electronic device and storage medium

By constructing an entity relationship graph and performing graph transformations to generate structured data, the problem of insufficient diversity in database schema structures in existing technologies is solved. This achieves a data generation method for text-to-SQL tasks, improving the robustness of the system and the user interaction experience.

CN115757469BActive Publication Date: 2026-02-10AISPEECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211484854.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-24
Publication Date
2026-02-10
Estimated Expiration
2042-11-24

AI Technical Summary

Technical Problem

Existing technologies, when generating data for text-to-SQL tasks, mainly focus on the text level and lack research on the diversity of database schema structures, resulting in poor training performance.

Method used

Entity-relationship graphs are constructed and structured data is generated through graph transformations, including various graph transformations such as entity to attribute, concept to attribute, named relationship to unnamed relationship, etc., to generate data suitable for structural generalization.

Benefits of technology

It automatically generates a large amount of data suitable for structural generalization research, improves the robustness of the text-to-SQL system, and enhances the user's voice interaction experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115757469B_ABST
    Figure CN115757469B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a data generation method for text-to-SQL task, an electronic device and a storage medium. The method comprises: constructing a first entity relationship graph containing entities and relationships based on the relationship class table and the entity class table in the first database schema diagram of the original text-to-SQL data; obtaining a second entity relationship graph by at least graph transformation of the nodes or edges in the first entity relationship graph; generating a second entity relationship graph of relationship class change according to the second entity relationship graph, and generating structured data enhanced text-to-SQL data based on the abstract syntax tree determined by the second entity relationship graph. Embodiments of the present application can automatically generate a large amount of data suitable for structure generalization research with a small amount of annotation, and at the same time, the structured text-to-SQL data generated by the method can be used for data enhancement to improve the robustness of the text-to-SQL system, and thus improve the experience of user voice interaction.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of intelligent voice, and in particular to a data generation method for text-to-SQL task, an electronic device and a storage medium. BACKGROUND

[0002] Text-to-SQL refers to converting natural language (NL) utterances into structured SQL. In intelligent voice and user interaction, for example, when the user inputs query statements such as "Who is the singer of this song?" and "Who is the author of this book?", it is necessary to convert these texts into corresponding SQL statements for querying. In order to improve the interaction performance of intelligent voice, a large amount of text-to-SQL data is needed for training. The following techniques are usually used to obtain text-to-SQL data:

[0003] 1. Spider-Syn is a text-to-SQL data set based on Spider artificial collection, which is intended to provide research data for text generalization research in text-to-SQL tasks. The collection method is to replace the database-related words or phrases in the question with their synonyms by hand.

[0004] 2. ADVETA is a text-to-SQL data set based on Spider artificial collection, which is intended to provide research data for database structure and text generalization research in text-to-SQL tasks. The collection method is to add columns with adversarial names to the database and replace some column names with their synonyms by hand.

[0005] 3. MR is a fully automatic text-to-SQL data generation tool based on the original text-to-SQL data, which can automatically generate three kinds of text dissimilarity and eight kinds of database structure dissimilarity synthetic data. The generation method is rule-based transformation.

[0006] In the process of implementing the present application, the inventors found that the related art at least has the following problems:

[0007] The purpose of Spider-Syn and ADVETA is to destroy the string-based database schema linking method, and replacing the words in the question with synonyms is functionally equivalent to replacing the column names in the database with synonyms. However, both of them are only for text-level research.

[0008] ADVETA attempts to add new columns to the database, but does not change the label of the SQL to be predicted in the data, and cannot provide suitable research materials for structure generalization research.

[0009] MR is a full-automatic generation tool, but the rules it refers to in generating text diverse data are too simple to meet the requirements of studying text generalization, and its method of generating database structure diverse data is partially wrong (i.e., the generated database structure is the same as before), and all transformations do not change the final SQL, and like ADVETA, it cannot provide suitable data for the study of structural generalization. SUMMARY

[0010] To at least solve the problem that most of the data generated for the text-to-SQL task in the prior art stops at the text level and the structural diversity of the database schema is poor, the same question may have different expressions in the corresponding SQL in different structural database schemas, so that the training effect of the data enhanced at the text level is poor.

[0011] In a first aspect, an embodiment of the present application provides a data generation method for a text-to-SQL task, comprising:

[0012] Based on the relationship class table and the entity class table in the first database schema diagram of the original text-to-SQL data, a first entity relationship diagram containing entities and relationships is constructed, wherein the entities are determined as nodes of the first entity relationship diagram, and the relationships between entities are determined as edges of the first entity relationship diagram;

[0013] At least graph transformation is performed on the nodes or edges in the first entity relationship diagram to obtain a second entity relationship diagram;

[0014] A second entity relationship diagram with relationship changes is generated according to the second entity relationship diagram, and structured data enhanced text-to-SQL data is generated based on the abstract syntax tree determined by the second entity relationship diagram.

[0015] In a second aspect, an embodiment of the present application provides a data generation system for a text-to-SQL task, comprising:

[0016] An entity relationship determination program module is configured to construct a first entity relationship diagram containing entities and relationships based on the relationship class table and the entity class table in the first database schema diagram of the original text-to-SQL data, wherein the entities are determined as nodes of the first entity relationship diagram, and the relationships between entities are determined as edges of the first entity relationship diagram;

[0017] A graph transformation program module is configured to perform at least graph transformation on the nodes or edges in the first entity relationship diagram to obtain a second entity relationship diagram;

[0018] A data generation program module is configured to generate a second entity relationship graph of a relationship class change according to the second entity relationship graph, and generate structured data enhanced text-to-SQL data based on an abstract syntax tree determined based on the second entity relationship graph.

[0019] In a third aspect, an electronic device is provided, which includes at least one processor and a memory connected to the at least one processor in communication, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the steps of the data generation method for a text-to-SQL task according to any one of the embodiments of the present application.

[0020] In a fourth aspect, an embodiment of the present application provides a storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the steps of the data generation method for a text-to-SQL task according to any one of the embodiments of the present application.

[0021] The embodiment of the present application has the beneficial effect that a large amount of data suitable for structure generalization research can be automatically generated with a small amount of labeling, and the structured text-to-SQL data generated by the method can also be used as data enhancement to improve the robustness of a text-to-SQL system, thereby improving the experience of user voice interaction. BRIEF DESCRIPTION OF DRAWINGS

[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.

[0023] Figure 1 is a flowchart of a data generation method for a text-to-SQL task provided by an embodiment of the present application;

[0024] Figure 2 is a schematic diagram of different response modes of a target SQL when the question is the same and the database schema is different in a data generation method for a text-to-SQL task provided by an embodiment of the present application;

[0025] Figure 3 is a generation framework diagram of a data generation method for a text-to-SQL task provided by an embodiment of the present application;

[0026] Figure 4 is a schematic diagram of DS generated by different transformation modes of a data generation method for a text-to-SQL task provided by an embodiment of the present application;

[0027] Figure 5 is a generation data statistical diagram of four graph transformations of a data generation method for a text-to-SQL task provided by an embodiment of the present application;

[0028] Figure 6 is a structural diagram of a data generation system for a text-to-SQL task provided by an embodiment of the present application;

[0029] Figure 7 is a structural diagram of an embodiment of an electronic device for data generation of a text-to-SQL task provided by an embodiment of the present application. DETAILED DESCRIPTION

[0030] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings of the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of the present application.

[0031] As shown in Figure 1 is a flowchart of a data generation method for a text-to-SQL task provided by an embodiment of the present application, including the following steps:

[0032] S11: based on a relationship class table and an entity class table in a first database schema diagram of original text-to-SQL data, a first entity relationship diagram containing entities and relationships is constructed, wherein the entities are determined as nodes of the first entity relationship diagram, and the relationships between the entities are determined as edges of the first entity relationship diagram;

[0033] S12: a second entity relationship diagram is obtained by at least graph transformation of nodes or edges in the first entity relationship diagram;

[0034] S13: a second entity relationship diagram of relationship class change is generated according to the second entity relationship diagram, and structured data enhancement text-to-SQL data is generated based on an abstract syntax tree determined based on the second entity relationship diagram.

[0035] In the present embodiment, it is considered that the prior art lacks research on various structures of DS (database schema). As Figure 2As shown, given the same textual question from a user and different database schemas, the target SQL (Structured Query Language) is completely different. An entity's "singer" can be a specific cell value in a column, table, or column "identity," depending on the ontology of the corresponding DS. Although the user intent is very simple, this distinction in database schema roles leads to entirely different SQL drafts. This problem becomes even more complex when multi-table scenarios are involved, as there are numerous possible combinations of roles.

[0036] This method proposes a data and structure-driven generative framework for synthesizing structured data-enhanced text-to-SQL data. The raw text-to-SQL dataset is obtained from the Spider dataset, containing 8659 training examples and 1034 validation examples across 146 databases. The test dataset, which is not publicly available, contains 2147 samples across 40 databases.

[0037] For step S11, the generation framework of this method is as follows: Figure 3 As shown, select one piece of raw text to SQL data from the raw text to SQL dataset and construct its corresponding database architecture diagram. For example, the raw text to SQL data is:

[0038] Sample(X,D,Y)

[0039] Question (X): Who is the author of Harry Potter?

[0040] Database(D)

[0041] SQL(Y): SELECT people.name FROM people JOIN author ON people.id=author.pid JOIN write ON author.id=write.aid JOIN novel ON write.nid=novel.id WHERE novel.name='Harry Potter' / / Corresponding query statement.

[0042] The corresponding database architecture diagram is as follows: Figure 3 As shown in Database(D) in the diagram, the "people", "author", "write", and "novel" nodes are labeled with their respective categories. The "write" nodes within the dashed boxes represent relational tables, while the remaining "aid" and "nid" nodes represent entity tables.

[0043] An ER graph (Entity-Relationship Graph) is constructed using the relation class table and the entity class table. The ER graph contains three basic components, i.e., entities (i.e., data objects), relationships, and attributes. Among them, an entity: entities with the same attributes have the same characteristics and properties, and the same type of entities is abstracted and characterized by the entity name and the attribute name set. An attribute: a certain property of an entity, and an entity can be characterized by several attributes. A relationship: the way in which data objects are connected to each other is called a relationship.

[0044] Under the inspiration of the ER graph, the method modifies the model according to the entity relationship to ensure the rationality of the modified model. To this end, the method introduces an entity-relationship graph (E-R), which is evolved from the E-R graph, but omits the attribute node to emphasize the topological characteristics. The nodes in the E-R graph represent an entity, and the edges represent the relationship between the entities corresponding to the end nodes. Both the nodes and the edges represent a table in the DS. For example, as shown in FIG. 1, each “people” table, “author” table, and “novel” table corresponds to a node in the E-R graph, the relationship between the entities is determined as an edge (dashed line), and the “write” table is incorporated into an edge (solid line). In order to construct the E-R graph, a binary tag is manually annotated for each table in the DS to distinguish between entities and relationships. Figure 3

[0045] For step S12, in order to further enhance the structured text to SQL data, the enhanced second entity relationship graph is obtained by performing graph transformation based on nodes or edges, and the graph transformation is performed in the following ways by separate examples: entity to attribute graph transformation, concept to attribute graph transformation, named relationship to unnamed relationship graph transformation, and unnamed relationship to named relationship graph transformation.

[0046] As an implementation, the entity to attribute graph transformation includes:

[0047] The pair of nodes in the first entity relationship graph are selected to determine the source entity and the target entity, wherein the target entity contains the foreign key table of the table corresponding to the source entity;

[0048] The attributes of the source entity are converted based on the attributes of the target entity to realize the entity to attribute graph transformation.

[0049] ​In this implementation, E2A (Entity to Attribute) corresponds to an ER transformation for merging nodes. A pair of nodes in the ER diagram is selected and split into a source entity and a target entity. The target entity mapping table is the only foreign key table in the DS that contains the source entity mapping table. Both nodes can be considered source entities as long as the combination is valid. Figure 4 The “Entity to Attribute” method, as shown, converts attributes in the source entity into new attributes in the target entity. To avoid semantic loss, the attributes are renamed according to the rules.

[0050] As one implementation method, the graph transformation from concept to attribute includes:

[0051] A pre-trained named entity recognition model is used to detect the parent category of the entity corresponding table of the node in the first entity relationship graph, and a table is created based on the parent category to store the concept of the entity;

[0052] The concept of the entity is replaced with the attribute of the entity to achieve a graph transformation from concept to attribute.

[0053] In this implementation, C2A (Concept to Attribute) corresponds to a modification node ER transformation. Unlike column-based modifications, the focus is on changing the role of the table. The entity's concept (represented by the table name in DS) is transformed into its attribute. First, a pre-trained NER (Named Entity Recognition) model is used to detect the entity's high-level category. Figure 4 In the "Concept to Attribute" example shown, "people" is the parent category of "singer". Then, an additional attribute is created to store the concept according to the rules. A new column identifier can be used to record the concept "singer".

[0054] As one implementation, the graph transformation from named relations to unnamed relations includes:

[0055] Create a foreign key for changing the relationship type for the relationship corresponding to the edge in the first entity relationship graph, and determine the relationship corresponding to the edge as Named and the relationship corresponding to the foreign key as Unnamed.

[0056] The Unnamed relationship is modified based on the Named relationship to achieve a graph transformation from named to unnamed relationships.

[0057] In this implementation, N2U (Named to Unnamed) corresponds to a modified edge ER transformation. Relations represented in the table are named "Named," and relations represented in the foreign key are named "Unnamed." For example, in... Figure 4 The “named to unnamed” relationship shown is represented by the table “singer”, which is a named relationship, and the foreign key in the table “song” which represents an unnamed relationship. The type of the relationship can be changed by creating a foreign key in another table.

[0058] As one implementation, the graph transformation from unnamed to named relationships includes:

[0059] The Unnamed relationship is modified in reverse based on the Named relationship to achieve a graph transformation from an unnamed relationship to a named relationship.

[0060] In this implementation, U2N (Unnamed to Named) also corresponds to a modified edge ER transformation, which is the inverse transformation from named to unnamed. A relation table is created and named using a combination of the names of the two target tables to store the relations. Then, the join is constructed by transferring a foreign key in one table and creating another foreign key within it, resulting in... Figure 4 The example shown is an "unnamed relationship to named relationship".

[0061] For step S13, in order to further restore the enhanced second entity-relationship graph to the enhanced Database (D'), the abstract syntax tree determined by the second entity-relationship graph is used to generate structured data-enhanced text-to-SQL data. Here, the AST (abstract syntax tree) is a tree representation of the abstract syntactic structure of source code written in a programming language. Each node of the tree represents a construct appearing in the source code. The syntax is "abstract" because it does not represent every detail appearing in the actual syntax, but only structural, content-related details.

[0062] Specifically, for each ER transformation in step S12, the relevant subtrees in the AST are detected, and the corresponding rules are applied to update the subtrees. For example, when applying a concept to an attribute transformation, an additional conditional subtree is added to the corresponding WHERE subtree. Finally, the modified SQL is parsed using the modified AST. This method considers two types of synthesized data: affected and unaffected. Affected samples contain different SQL compared to the original data, while unaffected samples contain the same SQL. These two types are distinguished based on whether the SQL involves DS elements affected by the transformation. The AST update module is only used to synthesize affected data.

[0063] The generated SQL data is determined using the updated abstract syntax tree:

[0064] Sample(X,D',Y')

[0065] Question (X): Who is the author of Harry Potter?

[0066] Database(D')

[0067] SQL(Y'): SELECT people.name FROM people JOIN author ON people.id=author.pid JOIN novel ON author.id=novel.aid WHERE novel.name='HarryPotter' / / Generated query statement.

[0068] like Figure 5 The total number of synthesized data of various types synthesized through different ER transformations is shown. Synthesis quality was evaluated by comparing the execution results of raw and structured data augmentation synthesis (DS, SQL) pairs. On average, 90.43% of the generated samples maintained consistent execution results. Approximately 8% of the samples yielded different results due to inconsistencies in cell value representation.

[0069] This implementation demonstrates that a large amount of data suitable for structural generalization research can be automatically generated using a small number of annotations. Furthermore, the structured text-to-SQL data generated by this method can be used for data augmentation to improve the robustness of text-to-SQL systems, thereby enhancing the user's voice interaction experience.

[0070] like Figure 6 The diagram shown is a structural schematic of a data generation system for text-to-SQL tasks provided by an embodiment of the present invention. The system can execute the data generation method for text-to-SQL tasks described in any of the above embodiments and is configured in a terminal.

[0071] This embodiment provides a data generation system 10 for text-to-SQL tasks, which includes: an entity relationship determination program module 11, a graph transformation program module 12, and a data generation program module 13.

[0072] The entity relationship determination module 11 is used to construct a first entity relationship graph containing entities and relationships based on the relationship class table and entity class table in the first database architecture graph of the original text to SQL data. The entities are determined as nodes in the first entity relationship graph, and the relationships between entities are determined as edges in the first entity relationship graph. The graph transformation module 12 is used to perform graph transformation at least through the nodes or edges in the first entity relationship graph to obtain a second entity relationship graph. The data generation module 13 is used to generate a second entity relationship graph with relationship class transformation based on the second entity relationship graph, and generate structured data-enhanced text to SQL data based on the abstract syntax tree determined by the second entity relationship graph.

[0073] This invention also provides a non-volatile computer storage medium storing computer-executable instructions that can execute the data generation method for text-to-SQL tasks in any of the above method embodiments;

[0074] In one embodiment, the non-volatile computer storage medium of the present invention stores computer-executable instructions, which are configured as follows:

[0075] Based on the relational and entity tables in the first database architecture graph of raw text to SQL data, a first entity relation graph containing entities and relationships is constructed, wherein the entities are determined as nodes in the first entity relation graph, and the relationships between entities are determined as edges in the first entity relation graph.

[0076] The second entity relationship graph is obtained by performing graph transformations on at least the nodes or edges in the first entity relationship graph;

[0077] A second entity relationship diagram with changing relationship classes is generated based on the second entity relationship diagram. Based on the abstract syntax tree determined by the second entity relationship diagram, structured data augmentation text-to-SQL data is generated.

[0078] As a non-volatile computer-readable storage medium, it can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as program instructions / modules corresponding to the methods in the embodiments of the present invention. One or more program instructions are stored in the non-volatile computer-readable storage medium, and when executed by a processor, they perform the data generation method for text-to-SQL tasks in any of the above method embodiments.

[0079] Figure 7 This is a schematic diagram of the hardware structure of an electronic device for a data generation method for text-to-SQL tasks provided in another embodiment of this application, as shown below. Figure 7 As shown, the device includes:

[0080] One or more processors 710 and memory 720, Figure 7 Taking a processor 710 as an example, the device for a data generation method for text-to-SQL tasks may further include an input device 730 and an output device 740.

[0081] The processor 710, memory 720, input device 730, and output device 740 can be connected via a bus or other means. Figure 7 Taking the example of a connection between China and Israel via a bus.

[0082] The memory 720, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the program instructions / modules corresponding to the data generation method for text-to-SQL tasks in the embodiments of this application. The processor 710 executes various server functions and data processing by running the non-volatile software programs, instructions, and modules stored in the memory 720, thereby implementing the data generation method for text-to-SQL tasks described in the above embodiments.

[0083] The memory 720 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and applications required for at least one function; the data storage area may store data, etc. Furthermore, the memory 720 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 720 may optionally include memory remotely located relative to the processor 710, and these remote memories can be connected to the mobile device via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0084] Input device 730 can receive input numerical or character information. Output device 740 may include display devices such as a display screen.

[0085] The one or more modules are stored in the memory 720, and when executed by the one or more processors 710, they execute the data generation method for text-to-SQL tasks in any of the above method embodiments.

[0086] The above-described product can perform the methods provided in the embodiments of this application, and has the corresponding functional modules and beneficial effects for performing the methods. Technical details not described in detail in this embodiment can be found in the methods provided in the embodiments of this application.

[0087] Non-volatile computer-readable storage media may include a stored program area and a stored data area, wherein the stored program area may store an operating system and an application program required for at least one function; the stored data area may store data created based on the use of the device, etc. Furthermore, the non-volatile computer-readable storage medium may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, the non-volatile computer-readable storage medium may optionally include memory remotely located relative to the processor, and these remote memories may be connected to the device via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0088] This invention also provides an electronic device comprising: at least one processor and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the steps of the data generation method for text-to-SQL tasks according to any embodiment of this invention.

[0089] The electronic devices described in this application exist in various forms, including but not limited to:

[0090] (1) Mobile communication devices: These devices are characterized by their mobile communication capabilities and primarily aim to provide voice and data communication. These terminals include smartphones, multimedia phones, feature phones, and low-end phones.

[0091] (2) Ultra-mobile personal computer devices: These devices fall under the category of personal computers, possessing computing and processing capabilities, and generally also have mobile internet access features. These terminals include PDAs, MIDs, and UMPCs, such as tablet computers.

[0092] (3) Portable entertainment devices: These devices can display and play multimedia content. This category includes audio and video players, handheld game consoles, e-book readers, as well as smart toys and portable car navigation devices.

[0093] (4) Other electronic devices with data processing functions.

[0094] In this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, without necessarily requiring or implying any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising" or "including" include not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0095] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0096] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, 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 can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0097] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A data generation method for text-to-SQL tasks, comprising: Based on the relational and entity tables in the first database architecture graph of raw text to SQL data, a first entity relation graph containing entities and relationships is constructed, wherein the entities are determined as nodes in the first entity relation graph, and the relationships between entities are determined as edges in the first entity relation graph. A second entity relationship graph is obtained by performing graph transformations on at least the nodes or edges in the first entity relationship graph. These graph transformations include entity-to-attribute transformations, concept-to-attribute transformations, named-to-unnamed-to-named-to-named-to-named-to-named-to-named-to-attribute transformations. The entity-to-attribute transformation includes: selecting pairs of nodes in the first entity relationship graph as source and target entities, where the target entity contains a foreign key table corresponding to the source entity; and transforming the attributes of the source entity based on the attributes of the target entity to achieve the entity-to-attribute graph transformation. A second entity relationship diagram with changing relationship classes is generated based on the second entity relationship diagram. Based on the abstract syntax tree determined by the second entity relationship diagram, structured data augmentation text-to-SQL data is generated.

2. The method according to claim 1, wherein, The graph transformation from concept to attribute includes: A pre-trained named entity recognition model is used to detect the parent category of the entity corresponding table of the node in the first entity relationship graph, and a table is created based on the parent category to store the concept of the entity; The concept of the entity is replaced with the attribute of the entity to achieve a graph transformation from concept to attribute.

3. The method according to claim 1, wherein, The graph transformation from named relations to unnamed relations includes: Create a foreign key for changing the relationship type for the relationship corresponding to the edge in the first entity relationship graph, and determine the relationship corresponding to the edge as Named and the relationship corresponding to the foreign key as Unnamed. The Unnamed relationship is modified based on the Named relationship to achieve a graph transformation from named to unnamed relationships.

4. The method according to claim 3, wherein, The graph transformation from unnamed relations to named relations includes: The Unnamed relationship is modified in reverse based on the Named relationship to achieve a graph transformation from an unnamed relationship to a named relationship.

5. A data generation system for text-to-SQL tasks, comprising: The entity relationship determination module is used to construct a first entity relationship graph containing entities and relationships based on the relationship class table and entity class table in the first database architecture graph from raw text to SQL data. The entities are determined as nodes in the first entity relationship graph, and the relationships between entities are determined as edges in the first entity relationship graph. A graph transformation module is used to perform graph transformations at least through nodes or edges in the first entity relationship graph to obtain a second entity relationship graph. The graph transformations include entity-to-attribute transformations, concept-to-attribute transformations, named-to-unnamed-to-named-to-named-to-named-to-named-to-named-to-named-to-attribute transformations. The entity-to-attribute transformation includes: selecting pairs of nodes in the first entity relationship graph as source and target entities, wherein the target entity contains a foreign key table corresponding to the source entity; and transforming the attributes of the source entity based on the attributes of the target entity to achieve the entity-to-attribute graph transformation. The data generation module is used to generate a second entity relationship diagram with changing relationship classes based on the second entity relationship diagram, and to generate structured data-enhanced text-to-SQL data based on the abstract syntax tree determined by the second entity relationship diagram.

6. An electronic device comprising: At least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the steps of the method according to any one of claims 1-4.

7. A storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program implements the steps of the method described in any one of claims 1-4.

Citation Information

Patent Citations

  • Equipment information management method and system based on knowledge graph and storage medium

    CN115271369A