Sample data generation method, device, electronic device and storage medium

By extending the initial rules and generating target logical statements, the problem of insufficient diversity of SQL statement generation in the existing technology is solved, and the diversified generation and authenticity guarantee of logical statements are realized, and the generation efficiency and accuracy are improved.

CN113886424BActive Publication Date: 2025-04-15JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111222792.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-20
Publication Date
2025-04-15
Estimated Expiration
2041-10-20

AI Technical Summary

Technical Problem

When generating structured query language SQL statements in the prior art, fixed rules cannot capture the basic distribution of logical statements, resulting in the generated logical statements being relatively single and not diverse enough, relying on manual design, affecting the generation efficiency and effect.

Method used

By obtaining multiple initial logical statements and initial rules, determining the probability values ​​with multiple expression rules, expanding the initial rules to obtain the target rules, and generating diverse target logic statements based on the target rules.

Benefits of technology

Effectively cover the true distribution of the corresponding fields, ensure the authenticity of logical statements, reduce dependence on manual resources, improve generation efficiency and accuracy, and assist in improving the generation effect of subsequent sample data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113886424B_ABST
    Figure CN113886424B_ABST
Patent Text Reader

Abstract

The present disclosure proposes a sample data generation method, device, electronic device and storage medium, the method includes obtaining multiple initial logic statements and initial rules, the initial rules include: parameter symbols and multiple expression rules; according to the multiple initial logic statements, determine multiple probability values ​​corresponding to the multiple expression rules, wherein the probability value describes the probability of the parameter symbol being transferred to the corresponding expression rule; expand the initial rules according to the multiple probability values ​​to obtain the target rules; and generate the target logic statement according to the target rule, the target logic statement is used to generate sample data. Through the present disclosure, it is possible to effectively generate diversified structured query language logic statements, so that the generated logic statements can effectively cover the actual distribution of the corresponding fields, ensure the authenticity of the logic statements, and reduce the dependence on artificial resources, thereby improving the generation efficiency and generation accuracy, and assisting in improving the generation effect of subsequent sample data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of natural language processing, and in particular to a sample data generation method, device, electronic device and storage medium. Background Art

[0002] In natural language processing, converting natural language to structured query language (SQL) statements (Natural Language to Structured Query Language, NL2SQL) is a core technology for table question answering, that is, converting natural language questions into SQL query statements that can be executed on the database. The input of NL2SQL technology is the database table and the question, and the output is an executable SQL statement. In recent years, with the development of deep learning technology, the focus is usually on using artificial intelligence models to solve the problems involved in NL2SQL technology, including: Generative models based on encoder-decoder (ED) structure.

[0003] Since the training of artificial intelligence models relies on a large amount of high-quality training sample data, related technologies usually use rule-based methods to generate massive sample data. The rule-based method generates corresponding SQL expressions for known tables by setting a series of fixed rules, and then generates natural questions corresponding to logical statements based on rule statement templates. Both logical statements and natural questions generated based on logical statements can be used as sample data for training models.

[0004] In this way, since fixed rules cannot capture the basic distribution of logical statements, and the distribution of logical statements in different fields is different, the generated logical statements are relatively simple, not diverse enough, and more dependent on manual design, which affects the generation efficiency and effect of subsequent sample data. Summary of the invention

[0005] The present disclosure aims to solve one of the technical problems in the related art at least to some extent.

[0006] To this end, the purpose of the present disclosure is to propose a sample data generation method, device, electronic device and storage medium, which can effectively generate a variety of structured query language logical statements, so that the generated logical statements can effectively cover the actual distribution of the corresponding field, ensure the authenticity of the logical statements, and reduce the dependence on artificial resources, thereby improving generation efficiency and generation accuracy, and assisting in improving the generation effect of subsequent sample data.

[0007] To achieve the above-mentioned purpose, the sample data generation method proposed in the first aspect of the embodiment of the present disclosure includes: obtaining multiple initial logical statements and initial rules, the initial rules including: parameter symbols and multiple expression rules; determining multiple probability values ​​corresponding to the multiple expression rules respectively according to the multiple initial logical statements, wherein the probability value describes the probability of the parameter symbol being transferred to the corresponding expression rule; expanding the initial rules according to the multiple probability values ​​to obtain the target rules; and generating the target logical statement according to the target rule, the target logical statement is used to generate sample data.

[0008] The method proposed in the embodiment of the first aspect of the present disclosure obtains multiple initial logical statements and initial rules, and the initial rules include: parameter symbols and multiple expression rules. According to the multiple initial logical statements, multiple probability values ​​corresponding to the multiple expression rules are determined, wherein the probability value describes the probability of the parameter symbol being transferred to the corresponding expression rule. The initial rules are expanded according to the multiple probability values ​​to obtain target rules, and target logical statements are generated according to the target rules. The target logical statements are used to generate sample data, and can effectively generate diversified structured query language logical statements, so that the generated logical statements can effectively cover the actual distribution of the corresponding fields, ensure the authenticity of the logical statements, and reduce the dependence on artificial resources, thereby improving the generation efficiency and accuracy, and assisting in improving the generation effect of subsequent sample data.

[0009] To achieve the above-mentioned purpose, the sample data generating device proposed in the second aspect embodiment of the present disclosure includes: an acquisition module, which is used to acquire multiple initial logical statements and initial rules, and the initial rules include: parameter symbols and multiple expression rules; a determination module, which is used to determine multiple probability values ​​corresponding to the multiple expression rules according to the multiple initial logical statements, wherein the probability value describes the probability of the parameter symbol being transferred to the corresponding expression rule; an expansion module, which is used to expand the initial rules according to the multiple probability values ​​to obtain the target rules; and a generation module, which is used to generate the target logical statement according to the target rule, and the target logical statement is used to generate sample data.

[0010] The sample data generating device proposed in the second aspect of the embodiment of the present disclosure obtains multiple initial logical statements and initial rules, and the initial rules include: parameter symbols and multiple expression rules. According to the multiple initial logical statements, multiple probability values ​​corresponding to the multiple expression rules are determined, wherein the probability value describes the probability of the parameter symbol being transferred to the corresponding expression rule. The initial rules are expanded according to the multiple probability values ​​to obtain target rules, and target logical statements are generated according to the target rules. The target logical statements are used to generate sample data, and can effectively generate diversified structured query language logical statements, so that the generated logical statements can effectively cover the actual distribution of the corresponding fields, ensure the authenticity of the logical statements, and reduce the dependence on artificial resources, thereby improving the generation efficiency and accuracy, and assisting in improving the generation effect of subsequent sample data.

[0011] According to the third aspect of the present disclosure, an electronic device is provided, 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, and the instructions are executed by the at least one processor so that the at least one processor can execute the sample data generation method of the embodiment of the first aspect of the present disclosure.

[0012] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is proposed, wherein the computer instructions are used to enable the computer to execute the sample data generating method of the embodiment of the first aspect of the present disclosure.

[0013] According to a fifth aspect of the present disclosure, a computer program product is provided, including a computer program, which, when executed by a processor, implements the sample data generating method of the embodiment of the first aspect of the present disclosure.

[0014] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The above and / or additional aspects and advantages of the present disclosure will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0016] Figure 1 is a flow chart of a sample data generation method proposed in an embodiment of the present disclosure;

[0017] Figure 2 is a schematic diagram of a database table in an embodiment of the present disclosure;

[0018] Figure 3 is a schematic diagram of a context-free grammar CFG in an embodiment of the present disclosure;

[0019] Figure 4 is a schematic diagram of an initial logic statement in an embodiment of the present disclosure;

[0020] Figure 5 is a flow chart of a sample data generation method proposed in another embodiment of the present disclosure;

[0021] Figure 6 is a schematic diagram of the structure of a sample data generating device proposed according to an embodiment of the present disclosure;

[0022] Figure 7 is a structural schematic diagram of a sample data generating device proposed according to another embodiment of the present disclosure;

[0023] Figure 8 A block diagram of an exemplary electronic device suitable for implementing embodiments of the present disclosure is shown. DETAILED DESCRIPTION

[0024] Embodiments of the present disclosure are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present disclosure, and are not to be construed as limitations of the present disclosure. On the contrary, the embodiments of the present disclosure include all changes, modifications, and equivalents that fall within the spirit and connotation of the appended claims.

[0025] Figure 1 It is a flowchart of a sample data generation method proposed in an embodiment of the present disclosure.

[0026] It should be noted that the executor of the sample data generation method of this embodiment is a sample data generation device, which can be implemented by software and / or hardware. The device can be configured in an electronic device, which may include but is not limited to a terminal, a server, etc.

[0027] like Figure 1 As shown, the sample data generation method includes:

[0028] S101: Acquire multiple initial logic statements and initial rules, where the initial rules include parameter symbols and multiple expression rules.

[0029] Among them, the logic statement currently to be processed can be called an initial logic statement, and the logic statement can be a structured query language SQL statement (Structured Query Language, SQL), or the logic statement can also be other types of logic statements that can be read and parsed by the database, without limitation.

[0030] The above-mentioned initial logical statements in the embodiments of the present disclosure can be used to assist in generating diversified target logical statements. That is to say, the target logical statements can be generated based on the expansion of the initial logical statements. Moreover, based on the sample data generation method provided in the embodiments of the present disclosure, the generated multiple target logical statements can effectively cover the actual distribution of the corresponding fields.

[0031] In the embodiments of the present disclosure, the logic statement is a structured query language SQL statement for example, but there is no limitation to this.

[0032] The initial logical statement may be, for example, Select SUM(Brand) from Table where Price>300000 and Origin=Germany.

[0033] This initial logic statement can be used to obtain corresponding data from the database table.

[0034] Database tables can be Figure 2 As shown, Figure 2 It is a schematic diagram of a database table in an embodiment of the present disclosure, wherein the database table includes: multiple column fields, and multiple column values ​​corresponding to the column fields, respectively. The multiple column fields, for example, vehicle model, brand, price, level, energy, origin, and displacement, correspond to various column fields, and respectively correspond to multiple column values.

[0035] After obtaining a plurality of initial logic statements, initial rules may also be obtained. The initial rules include parameter symbols and a plurality of expression rules. The initial rules may be used to assist in generating a plurality of target logic statements.

[0036] The initial rule refers to a grammatical expression rule, such as context-free grammar (CFG), unrestricted grammar, context-dependent grammar, context-free grammar and regular grammar, etc., without limitation.

[0037] In the embodiments of the present disclosure, an initial rule is taken as a context-free grammar CFG for example. The context-free grammar CFG includes: parameter symbols and multiple expression rules.

[0038] For example, see also Figure 3 and Figure 4 , Figure 3 is a schematic diagram of a context-free grammar CFG in an embodiment of the present disclosure, Figure 4 is a schematic diagram of an initial logic statement in an embodiment of the present disclosure. Figure 4 In the example, the initial logic statement is expressed in a tree diagram.

[0039] The context-free grammar CFG is described by G = (M, T, R, S):

[0040] M: Non-terminal symbols:

[0041] For example, "Select, Where, Conds, Cond, A, C, op".

[0042] T:Terminal symbols:

[0043] For example, SQL specific columns / values / budget symbols constitute the actual content of the SQL, such as Figure 4 "Brand, price, 200000" etc. in the box.

[0044] R: A set of production rules:

[0045] For example, Select includes: SELECT A or SELECT AA, or Conds includes: Cond or Cond ANDCond.

[0046] S: Starting symbol, here is "SQL" at the top of the tree.

[0047] The above-mentioned M, T, and S can be called parameter symbols, and the expression rules involved in R can be called multiple expression rules, without limitation.

[0048] Above Figure 3 and Figure 4 As shown in , it may be the context-free grammar CFG corresponding to the initial logical statement [Select SUM (brand) from Table where price > 300000 and origin = Germany]. In the embodiment of the present disclosure, after obtaining multiple initial logical statements, the initial rules corresponding to each initial logical statement can be obtained, thereby ensuring that the extended processing logic of the overall logical statement is completed based on a small number of initial logical statements.

[0049] S102: Determine a plurality of probability values ​​corresponding to a plurality of expression rules according to a plurality of initial logical statements, wherein the probability value describes the probability of the parameter symbol being transferred to the corresponding expression rule.

[0050] After obtaining the multiple initial logical statements and the initial rules, multiple probability values ​​corresponding to the multiple expression rules can be determined according to the multiple initial logical statements.

[0051] That is to say, the above-mentioned multiple initial logic statements may be a small number of logic statements, and then, the corresponding extended processing logic may be executed in combination with the initial rules with reference to the small number of initial logic statements.

[0052] During the expansion process, the probability values ​​corresponding to various expression rules in the context-free grammar CFG can be determined based on multiple initial logical statements. The probability value describes the probability of the parameter symbol in the context-free grammar CFG being transferred to the corresponding expression rule. The probability value can be used to assist subsequent expansion to obtain multiple target logical statements.

[0053] When determining multiple probability values ​​corresponding to multiple expression rules based on multiple initial logical statements, the multiple initial logical statements can be input into a pre-trained probability determination model to obtain multiple probability values ​​corresponding to the multiple expression rules output by the probability determination model. The probability value can be used to express the distribution probability of the corresponding expression rule among the multiple initial logical statements in terms of meaning, and in terms of numerical value, it expresses the probability of the parameter symbol in the initial rule being transferred to the corresponding expression rule.

[0054] Optionally, in some embodiments, in determining multiple probability values ​​corresponding to multiple expression rules according to the multiple initial logical statements, multiple first numbers corresponding to the multiple expression rules may be determined, the first number indicating the number of times the parameter symbol is transferred to the corresponding expression rule in the multiple initial logical statements; multiple second numbers corresponding to the multiple expression rules are determined, the second number indicating the number of times the parameter symbol is transferred to other expression rules in the multiple initial logical statements; and the ratio of the first number to the corresponding second number is used as the probability value of the corresponding expression rule, so that the probability value can match the corresponding field in which the initial logical statement is located, so that the target rules subsequently obtained based on the probability value can describe the actual distribution of the corresponding field, and the method for determining the probability value is relatively simple, thereby ensuring the execution efficiency of the sample data generation method.

[0055] The above process can be called the process of training initial rules based on a small number of initial logical statements SQL. The number of times the parameter symbol is transferred to the corresponding expression rule in the multiple initial logical statements can be called the first number, and the number of times the parameter symbol is transferred to other expression rules in the multiple initial logical statements can be called the second number. Then, the ratio of the first number corresponding to each expression rule to the corresponding second number can be used as the probability value of the corresponding expression rule.

[0056] For example, in order to calculate the probability of the initial logical statement SQL in the domain scenario, we can first calculate the probability value of each expression rule based on the small number of initial logical statements SQL already existing in the domain scenario and the initial rules obtained above, and then trigger the subsequent construction of more target logical statements by replacing terminal symbols.

[0057] The probability value of each non-terminal symbol being transferred to its corresponding expression rule is calculated as follows:

[0058]

[0059] Among them, C refers to the number of times a certain expression rule appears, C(N->a) refers to the number of times the current M (non-terminal symbol) transfers to the a expression rule, and C(N->b) refers to the number of times the current M transfers to all possible expression rules.

[0060] Of course, any other possible method may be used to determine the multiple probability values ​​corresponding to the multiple expression rules, such as the above-mentioned model method, or engineering method, etc., and there is no limitation to this.

[0061] S103: Expanding the initial rule according to multiple probability values ​​to obtain a target rule.

[0062] For example, initial rules are trained based on a small amount of initial logical statements SQL to obtain a probabilistic context free grammar (PCFG), and the PCFG expression rules obtained through training can be called target rules.

[0063] The target rule PCFG expression is as follows:

[0064] G=(M,T,R,S).

[0065] Among them, the probabilistic context-free grammar PCFG is a grammatical expression rule similar to the context-free grammar CFG, wherein the P in the probabilistic context-free grammar PCFG refers to the transition probability of a series of expression rules (R), for example, whether the Select expression rule transfers to (SELECT A) or transfers to (SELECT AA).

[0066] S104: Generate a target logic statement according to the target rule, and the target logic statement is used to generate sample data.

[0067] After determining multiple probability values ​​corresponding to multiple expression rules respectively according to multiple initial logical statements and expanding the initial rules according to the multiple probability values ​​to obtain the target rules, the target logical statements can be generated according to the target rules, and the target logical statements are used to generate sample data.

[0068] For example, when generating a target logic statement according to a target rule, a database table may be determined, and then, based on the data content contained in the database table, multiple possible replacements may be made to T: terminal symbols in the initial logic statement to generate multiple replaced logic statements as target logic statements.

[0069] For example, CFG: Select A1,A2 WHERE Cond(A op Value);

[0070] Replacement: A1->"price", A2->"place of origin" A->"brand" op->"equal to" Value->"BMW", the generated target logic statement is SQL: Select price, place of origin Where brand = BMW.

[0071] In this embodiment, by obtaining multiple initial logical statements and initial rules, the initial rules include: parameter symbols and multiple expression rules, and according to the multiple initial logical statements, multiple probability values ​​corresponding to the multiple expression rules are determined, wherein the probability value describes the probability of the parameter symbol being transferred to the corresponding expression rule, the initial rules are expanded according to the multiple probability values ​​to obtain the target rules, and the target logical statements are generated according to the target rules. The target logical statements are used to generate sample data, and can effectively generate diversified structured query language logical statements, so that the generated logical statements can effectively cover the actual distribution of the corresponding fields, ensure the authenticity of the logical statements, and reduce the dependence on artificial resources, thereby improving the generation efficiency and accuracy, and assisting in improving the generation effect of subsequent sample data.

[0072] Figure 5 It is a flowchart of a sample data generating method proposed in another embodiment of the present disclosure.

[0073] like Figure 5 As shown, the sample data generation method includes:

[0074] S501: Acquire multiple initial logic statements and initial rules, where the initial rules include parameter symbols and multiple expression rules.

[0075] S502: Determine a plurality of probability values ​​corresponding to a plurality of expression rules according to a plurality of initial logical statements, wherein the probability value describes the probability of the parameter symbol being transferred to the corresponding expression rule.

[0076] The description of S501 - S502 can be specifically referred to the above embodiment, which will not be repeated here.

[0077] S503: Determine a target probability value greater than a probability threshold from among the multiple probability values.

[0078] After determining the multiple probability values ​​corresponding to the multiple expression rules respectively according to the multiple initial logical statements, the target probability value greater than the probability threshold can be determined from the multiple probability values. That is to say, the embodiment of the present disclosure supports determining the target expression rule with a larger transfer probability from the multiple expression rules included in the target rule, thereby assisting in the expansion of the logical statement based on the target expression rule, which not only enables the generated logical statement to effectively cover the actual distribution of the corresponding field, but also realizes the generation of logical statements with more significant transfer possibilities, thereby comprehensively ensuring the generation quality of the logical statements.

[0079] S504: Determine a target expression rule corresponding to the target probability value, and a target parameter symbol corresponding to the target expression rule.

[0080] S505: Use the target parameter symbol and the target expression rule as the target rule.

[0081] S506: Form a reference logic statement according to the target parameter symbol and the target expression rule.

[0082] For example, after calculating the probability value of each expression rule based on a small number of initial logical statements SQL existing in this field scenario and the initial rules obtained above, the target probability value greater than the probability threshold can be determined, that is, the logical statement SQL with a higher probability of occurrence (that is, a more significant possibility of transfer) is determined to be: Select A1, A2 WHERE Cond(A op Value), or Select A WHERE Cond(A op Value) AND Cond(A op Value), etc., without any restriction.

[0083] Among them, the expression rules involved in Select A1, A2 WHERE Cond(A op Value), or Select A WHERE Cond(A opValue) AND Cond(A op Value) can be called target expression rules, and the parameter symbols involved can be called target parameter symbols. In this example, the probability value of the target parameter symbol being transferred to the target expression rule can be a target probability value greater than the probability threshold.

[0084] Therefore, the logical statement formed according to the target parameter symbol and the target expression rule can be called a reference logical statement, that is, Select A1, A2 WHERE Cond (A op Value) or Select A WHERE Cond (A opValue) AND Cond (A op Value) mentioned above.

[0085] For example, if the SQL statement contains sort-related syntax, the target rules can also be expanded in the same way.

[0086] For example:

[0087] Natural sentence: List the car brands that are made in Germany in order of price, from high to low.

[0088] Reference logic statement: Select brand Where origin = Germany Order by price DESC

[0089] Target rules:

[0090] SQL:=SELECT|SELECT WHERE|SELECT WHERE ORDER.

[0091] S507: Determine multiple optional symbol values ​​corresponding to the target parameter symbol.

[0092] The target parameter symbol may be the non-terminal symbol M in the above example, so that Figure 2 The database table shown in determines a variety of optional symbol values ​​corresponding to the non-terminal symbol M (the values ​​in the actual domain scenario corresponding to the non-terminal symbol M can be called optional symbol values).

[0093] Optionally, in some embodiments, when determining a plurality of optional symbol values ​​corresponding to the target parameter symbol, a database table may be obtained, the database table including: a plurality of column fields, and a plurality of column values ​​corresponding to the column fields, respectively. From the database table, a target column field matching the target parameter symbol is determined, and the plurality of column values ​​corresponding to the target column field are used as a plurality of optional symbol values, thereby realizing rapid integration of content in actual domain scenarios, avoiding a large amount of manpower, reducing dependence on professional knowledge, and assisting in subsequent rapid construction of target logical statements.

[0094] The column fields of the database table and the various column values ​​corresponding to the column fields can be shown as above. Figure 2 As shown, it can be Figure 2 The target column fields that match the non-terminal symbol M are: model, brand, price, energy, origin, etc., and then, Figure 2 The multiple column values ​​corresponding to the vehicle model, brand, price, energy source, origin, etc. are read as multiple optional symbol values.

[0095] S508: Expand the reference logic statement using a plurality of optional symbol values ​​to obtain a plurality of target logic statements corresponding to the plurality of optional symbol values.

[0096] In the above, after determining the various optional symbol values ​​corresponding to the target parameter symbol, such as vehicle type, brand, price, energy, origin, etc., a large number of target logical statements SQL can be obtained by performing random replacement:

[0097] CFG: Select A1,A2 WHERE Cond(A op Value);

[0098] Replace: A1->"price", A2->"origin" A->"brand" op->"equal to" Value->"BMW";

[0099] Target logical statement SQL: Select price, origin Where brand = BMW.

[0100] S509: Input the target logical sentence into the pre-trained sentence generation model to obtain a target natural question sentence output by the sentence generation model that matches the target logical sentence, wherein the target logical sentence and the target natural question sentence are used together as sample data.

[0101] After the initial logical statements are expanded to obtain a plurality of target logical statements, matching natural questions may be generated according to the target logical statements. The matching natural questions may be referred to as target natural questions.

[0102] Optionally, a target natural question matching a target logical sentence may be generated in combination with text generation related technologies, or a sequence-to-sequence to generative model may be used to generate a target natural question matching a target logical sentence, without limitation.

[0103] The above sentence generation model can be pre-trained.

[0104] When training a sentence generation model, a self-supervised method can be used for training without any restriction.

[0105] For example, the sentence generation model can be a generative pre-training (GPT) model, or a pre-training model related to text generation tasks such as a denoising autoencoder model built using a sequence-to-sequence model. The model can first be fine-tuned using a small amount of SQL & natural language (NL) question (i.e., natural questions) corpus to enable it to perform the task of generating corresponding natural questions based on a given SQL.

[0106] Experiments show that after fine-tuning the model using a small amount of data, the model can generate smooth natural questions. Then, based on the target logical sentences generated above, the generative pre-trained model can be combined to generate target natural questions with diverse expressions, fluent language and close to specific scenarios.

[0107] The target logical sentences and target natural questions generated above can be used together as sample data to pre-train various NL2SQL task models.

[0108] In this embodiment, it is possible to effectively generate diversified structured query language logical statements, so that the generated logical statements can effectively cover the real distribution of the corresponding fields, ensure the authenticity of the logical statements, and reduce the dependence on artificial resources, thereby improving the generation efficiency and generation accuracy, and assisting in improving the generation effect of subsequent sample data. It supports determining the target expression rule with a larger transfer probability from the multiple expression rules included in the target rule, thereby assisting in the expansion of logical statements based on the target expression rule, not only making the generated logical statements effectively cover the real distribution of the corresponding fields, but also achieving the generation of logical statements with more significant transfer possibilities, and comprehensively ensuring the generation quality of logical statements. In addition, the use of pre-trained language models can effectively save data resources and artificial resources to construct sentence templates, and can also effectively ensure the expression diversity and fluency of the generated natural questions.

[0109] Figure 6 It is a structural diagram of a sample data generating device proposed according to an embodiment of the present disclosure.

[0110] like Figure 6 As shown, the sample data generating device 60 includes:

[0111] An acquisition module 601 is used to acquire a plurality of initial logic statements and initial rules, wherein the initial rules include: parameter symbols and a plurality of expression rules;

[0112] A determination module 602 is used to determine a plurality of probability values ​​corresponding to a plurality of expression rules according to a plurality of initial logic statements, wherein the probability value describes the probability of the parameter symbol being transferred to the corresponding expression rule;

[0113] An expansion module 603 is used to expand the initial rule according to multiple probability values ​​to obtain a target rule;

[0114] The generating module 604 is used to generate a target logic statement according to the target rule, and the target logic statement is used to generate sample data.

[0115] In some embodiments of the present disclosure, Figure 7 As shown, Figure 7602 is a schematic diagram of a sample data generating device according to another embodiment of the present disclosure. The determining module 602 includes:

[0116] The first determination submodule 6021 is used to determine a plurality of first order numbers corresponding to a plurality of expression rules, respectively, the first order numbers indicating the number of times the parameter symbol is transferred to the corresponding expression rule in the plurality of initial logic statements;

[0117] The second determining submodule 6022 is used to determine a plurality of secondary numbers corresponding to the plurality of expression rules, respectively, the secondary numbers indicating the number of times the parameter symbol is transferred to other expression rules in the plurality of initial logic statements;

[0118] The third determination submodule 6023 is used to use the ratio of the first number to the corresponding second number as the probability value of the corresponding expression rule.

[0119] In some embodiments of the present disclosure, Figure 7 As shown, the expansion module 603 is specifically used for:

[0120] From the plurality of probability values, determining a target probability value that is greater than a probability threshold;

[0121] Determine a target expression rule corresponding to the target probability value, and a target parameter symbol corresponding to the target expression rule;

[0122] The target parameter symbol and the target expression rule are used as the target rule.

[0123] In some embodiments of the present disclosure, Figure 7 As shown, the generating module 604 is specifically used for:

[0124] Form a reference logic statement according to the target parameter symbol and the target expression rule;

[0125] determining a plurality of selectable symbol values ​​corresponding to the target parameter symbol;

[0126] The reference logic statements are expanded respectively using a plurality of optional symbol values ​​to obtain a plurality of target logic statements corresponding to the plurality of optional symbol values.

[0127] In some embodiments of the present disclosure, Figure 7 As shown, the generating module 604 is specifically used for:

[0128] Obtain a database table, the database table including: multiple column fields, and multiple column values ​​corresponding to the column fields;

[0129] From the database table, determine the target column field that matches the target parameter symbol;

[0130] The various column values ​​corresponding to the target column field are used as various optional symbol values.

[0131] In some embodiments of the present disclosure, Figure 7 As shown, it also includes:

[0132] Input module 605 is used to input the target logical sentence into the pre-trained sentence generation model after generating the target logical sentence according to the target rule, so as to obtain the target natural question sentence output by the sentence generation model that matches the target logical sentence, wherein the target logical sentence and the target natural question sentence are jointly used as sample data.

[0133] With the above Figures 1 to 5 Corresponding to the sample data generation method provided in the embodiment, the present disclosure also provides a sample data generation device. Figures 1 to 5 The sample data generation method provided in the embodiment corresponds to the sample data generation method, so the implementation of the sample data generation method is also applicable to the sample data generation device provided in the embodiment of the present disclosure, and will not be described in detail in the embodiment of the present disclosure.

[0134] In this embodiment, by obtaining multiple initial logical statements and initial rules, the initial rules include: parameter symbols and multiple expression rules, and according to the multiple initial logical statements, multiple probability values ​​corresponding to the multiple expression rules are determined, wherein the probability value describes the probability of the parameter symbol being transferred to the corresponding expression rule, the initial rules are expanded according to the multiple probability values ​​to obtain the target rules, and the target logical statements are generated according to the target rules. The target logical statements are used to generate sample data, and can effectively generate diversified structured query language logical statements, so that the generated logical statements can effectively cover the actual distribution of the corresponding fields, ensure the authenticity of the logical statements, and reduce the dependence on artificial resources, thereby improving the generation efficiency and accuracy, and assisting in improving the generation effect of subsequent sample data.

[0135] In order to implement the above embodiments, the present disclosure further proposes an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the sample data generation method proposed in the above embodiments of the present disclosure is implemented.

[0136] In order to implement the above embodiments, the present disclosure further proposes a non-transitory computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the sample data generating method proposed in the above embodiments of the present disclosure is implemented.

[0137] In order to implement the above embodiments, the present disclosure further proposes a computer program product. When an instruction processor in the computer program product executes, the sample data generating method proposed in the above embodiments of the present disclosure is executed.

[0138] Figure 8 A block diagram of an exemplary electronic device suitable for implementing embodiments of the present disclosure is shown. Figure 8 The electronic device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0139] like Figure 8 As shown, the electronic device 12 is in the form of a general computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 connecting different system components (including the system memory 28 and the processing unit 16). The bus 18 represents one or more of several types of bus structures, including a memory bus or a memory controller, a peripheral bus, a graphics acceleration port, a processor or a local bus using any bus structure in a variety of bus structures. For example, these architectures include, but are not limited to, the Industry Standard Architecture (Industry Standard Architecture; hereinafter referred to as: ISA) bus, the MicroChannel Architecture (MicroChannel Architecture; hereinafter referred to as: MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (Video Electronics Standards Association; hereinafter referred to as: VESA) local bus, and the Peripheral Component Interconnection (Peripheral Component Interconnection; hereinafter referred to as: PCI) bus.

[0140] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.

[0141] The memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 8 Not shown, often called a "hard drive").

[0142] although Figure 8Not shown in the figure, a disk drive for reading and writing a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing a removable non-volatile optical disk (e.g., a compact disc read only memory (CD-ROM), a digital versatile disc read only memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the various embodiments of the present disclosure.

[0143] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in the memory 28, such program modules 42 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 42 generally perform the functions and / or methods of the embodiments described in the present disclosure.

[0144] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 12, and / or may communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. Furthermore, the electronic device 12 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 via a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0145] The processing unit 16 executes various functional applications and data processing by running the programs stored in the system memory 28, such as implementing the sample data generation method mentioned in the above embodiment.

[0146] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0147] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

[0148] It should be noted that, in the description of the present disclosure, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of the present disclosure, unless otherwise specified, the meaning of "plurality" is two or more.

[0149] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present disclosure includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present disclosure belong.

[0150] It should be understood that the various parts of the present disclosure can be implemented in hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0151] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

[0152] In addition, each functional unit in each embodiment of the present disclosure may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.

[0153] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.

[0154] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present disclosure. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0155] Although the embodiments of the present disclosure have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present disclosure. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present disclosure.

Claims

1. A method for generating sample data, characterized in that: The method comprises: Acquire multiple initial logic statements and initial rules, wherein the initial rules include: parameter symbols and multiple expression rules; Determine a plurality of first times corresponding to the plurality of expression rules, respectively, the first times indicating the number of times the parameter symbol is transferred to the corresponding expression rule in the plurality of initial logic statements; Determine a plurality of second times corresponding to the plurality of expression rules, respectively, the second times indicating the number of times the parameter symbol is transferred to other expression rules in the plurality of initial logical statements; Using the ratio of the first number of times to the corresponding second number of times as the probability value of the corresponding expression rule; From the probability values, determining a target probability value that is greater than a probability threshold; Determine a target expression rule corresponding to the target probability value, and a target parameter symbol corresponding to the target expression rule; Using the target parameter symbol and the target expression rule as the target rule; and A target logic statement is generated according to the target rule, and the target logic statement is used to generate sample data.

2. The method according to claim 1, characterized in that Generating a target logic statement according to the target rule includes: Forming a reference logic statement according to the target parameter symbol and the target expression rule; Determining a plurality of selectable symbol values ​​corresponding to the target parameter symbol; The reference logic statements are expanded respectively using the multiple optional symbol values ​​to obtain multiple target logic statements corresponding to the multiple optional symbol values ​​respectively.

3. The method according to claim 2, characterized in that The determining of a plurality of optional symbol values ​​corresponding to the target parameter symbol comprises: Acquire a database table, the database table comprising: a plurality of column fields, and a plurality of column values ​​corresponding to the column fields respectively; Determining, from the database table, a target column field that matches the target parameter symbol; The multiple column values ​​corresponding to the target column field are used as the multiple optional symbol values.

4. The method according to claim 1, characterized in that After generating the target logic statement according to the target rule, the method further includes: The target logical sentence is input into a pre-trained sentence generation model to obtain a target natural question sentence output by the sentence generation model that matches the target logical sentence, wherein the target logical sentence and the target natural question sentence are used together as the sample data.

5. A sample data generating device, characterized in that: The device comprises: An acquisition module, used to acquire a plurality of initial logic statements and initial rules, wherein the initial rules include: parameter symbols and a plurality of expression rules; A determination module, configured to determine, according to the plurality of initial logic statements, a plurality of probability values ​​respectively corresponding to the plurality of expression rules, wherein the probability values ​​describe the probability of the parameter symbol being transferred to the corresponding expression rule; An expansion module, used for expanding the initial rule according to the multiple probability values ​​to obtain a target rule; A generating module, used for generating a target logic statement according to the target rule, wherein the target logic statement is used to generate sample data; The determining module comprises: A first determination submodule is used to determine a plurality of first times corresponding to the plurality of expression rules, the first times indicating the number of times the parameter symbol is transferred to the corresponding expression rule in the plurality of initial logic statements; A second determination submodule is used to determine a plurality of secondary numbers corresponding to the plurality of expression rules, respectively, the second number indicating the number of times the parameter symbol is transferred to other expression rules in the plurality of initial logic statements; A third determination submodule, configured to use a ratio of the first number of times to the corresponding second number of times as a probability value of the corresponding expression rule; The expansion module is specifically used for: From the plurality of probability values, determining a target probability value that is greater than a probability threshold; Determine a target expression rule corresponding to the target probability value, and a target parameter symbol corresponding to the target expression rule; The target parameter symbol and the target expression rule are used as the target rule.

6. The device according to claim 5, characterized in that The generating module is specifically used for: Forming a reference logic statement according to the target parameter symbol and the target expression rule; Determining a plurality of selectable symbol values ​​corresponding to the target parameter symbol; The reference logic statements are expanded respectively using the multiple optional symbol values ​​to obtain multiple target logic statements corresponding to the multiple optional symbol values ​​respectively.

7. The device according to claim 6, characterized in that The generating module is specifically used for: Acquire a database table, the database table comprising: a plurality of column fields, and a plurality of column values ​​corresponding to the column fields respectively; Determining, from the database table, a target column field that matches the target parameter symbol; The multiple column values ​​corresponding to the target column field are used as the multiple optional symbol values.

8. The device according to claim 5, characterized in that Also includes: An input module is used to input the target logical sentence into a pre-trained sentence generation model after generating the target logical sentence according to the target rule, so as to obtain a target natural question sentence output by the sentence generation model that matches the target logical sentence, wherein the target logical sentence and the target natural question sentence are collectively used as the sample data.

9. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed 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 method according to any one of claims 1 to 4.

10. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Data pair generation method and device, electronic equipment and storage medium

    CN112559552A

  • Systems and / or methods for event stream deviation detection

    US20120158360A1