Natural language query translation device and its control method

KR102999644B1Active Publication Date: 2026-08-05KAKAO ENTERPRISE CORP +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
KR1020230095041
Authority / Receiving Office
KR · KR
Patent Type
Patents
Current Assignee / Owner
Filing Date
2023-07-21
Publication Date
2026-08-05
Estimated Expiration
2043-07-21

Smart Images

  • Figure R1020230095041_ABST
    Figure R1020230095041_ABST
Patent Text Reader

Abstract

The present invention relates to a natural language processing technology that converts a natural language query into an SQL query. More specifically, the present invention relates to a natural language processing technology that classifies a database based on a natural language query and converts the natural language query into an SQL query corresponding to the classified database using a conversion model that includes a Large Language Model (LLM).
Need to check novelty before this filing date? Find Prior Art

Description

Technology Field

[0001] The present invention relates to natural language query translation technology, and more specifically, to technology for effectively translating natural language queries into SQL queries for controlling a database. Background Technology

[0003] Recently, with the technological advancement of the natural language processing field, there has been a growing use of natural language-mediated conversational methods to obtain desired services, moving away from operations based on traditional machine-centric command input / output methods.

[0004] SQL refers to a language that enables communication between a database and a computer language for the retrieval, storage, and deletion of data. Through the standard SQL language, one can connect to and control the majority of databases (e.g., Oracle, DB2, SQL Server, MySQL, etc.).

[0005] Translating natural language queries into SQL queries (hereinafter referred to as NL2SQL) refers to converting natural language queries into SQL language corresponding to them. Recently, many methods utilizing artificial intelligence technology for NL2SQL have been developed, but there are problems such as relatively low accuracy or inability to process various types of natural languages.

[0006] Accordingly, there is a need for research on technologies that can perform NL2SQL effectively with higher accuracy while supporting various natural languages ​​(especially Korean). The problem to be solved

[0008] The problem that the present invention aims to solve is to provide NL2SQL technology capable of supporting various types of natural languages.

[0009] Another problem that the present invention aims to solve is to provide a technology that improves the efficiency and accuracy of NL2SQL technology.

[0010] Another problem that the present invention aims to solve is to provide a pre-manipulation process applied to a large language model (LLM) to increase the accuracy of the conversion when implementing NL2SQL using a large language model.

[0011] The technical problems to be solved by the present invention are not limited to those mentioned above, and other technical problems not mentioned will be clearly understood by those skilled in the art to which the present invention belongs from the description below. means of solving the problem

[0013] According to another aspect of the present invention for solving the above or other problems, a method for controlling a natural language query translation device comprising a memory for storing instructions and a processor configured to execute said stored instructions, a classification unit, and a conversion model, wherein the classification unit executed by the processor classifies a related database based on a natural language query; and the conversion model executed by the processor converts said natural language query into an SQL query corresponding to the classified related database, wherein the conversion model is configured to include a Large Language Model (LLM), and the conversion model receives a natural language input including said natural language query and outputs a converted SQL query based on the received natural language input, wherein the natural language input includes a schema for said classified related database and a natural language query.

[0014] The above natural language input may be configured to include additional entity tagging information.

[0015] The above natural language input may be the result of text concatenating at least two of the above natural language query, the above entity tagging information, and the above schema.

[0016] The above natural language input may include a label assigned to at least one of the above natural language query, the above entity tagging information, and the above schema.

[0017] The above entity tagging information may be information for normalizing names used in the above-classified related database.

[0018] Among the tables included in the above-classified related database, a table filtering step may be further included to filter out tables unrelated to the above-classified natural language query and output related tables.

[0019] It may further include a column filtering step that filters out columns unrelated to the natural language query on the above-mentioned related table and outputs the relevant columns.

[0021] According to one aspect of the present invention to solve the above or other problems, a natural language query translation device is provided, comprising: a classification unit that classifies a related database based on a natural language query; and a conversion model that converts the natural language query into an SQL query corresponding to the classified related database, wherein the conversion model is configured to include a Large Language Model (LLM). Effects of the invention

[0023] The effects of the natural language processing technology according to the present invention are described as follows.

[0024] According to at least one of the embodiments of the present invention, there is an advantage in that NL2SQL technology capable of supporting various types of natural languages ​​can be provided.

[0025] In addition, according to at least one of the embodiments of the present invention, there is an advantage in that a technology can be provided that improves the efficiency and accuracy of NL2SQL technology.

[0026] Additionally, according to at least one embodiment of the present invention, in implementing NL2SQL using a Large Language Model (LLM), there is an advantage in that a pre-manipulation process applied to the Large Language Model can be provided to increase the accuracy of the conversion.

[0027] Further scopes of the applicability of the present invention will become apparent from the following detailed description. However, since various changes and modifications within the spirit and scope of the present invention are clearly understood by those skilled in the art, specific embodiments, such as the detailed description and preferred embodiments of the present invention, should be understood as being given merely as examples. Brief explanation of the drawing

[0029] FIG. 1 is a block diagram illustrating a natural language query translation device (100) according to an embodiment of the present invention. FIG. 2 is a diagram illustrating a conceptual diagram of a conversion model (102) according to an embodiment of the present invention. FIG. 3 is a diagram illustrating a conceptual diagram of generating natural language input (301) according to an embodiment of the present invention. FIG. 4 illustrates an example of a natural language input (301) of a conversion model (102) configured to include a large-scale language model according to an embodiment of the present invention. FIG. 5 is a diagram illustrating a flowchart of a natural language processing method according to an embodiment of the present invention. FIG. 6 is a drawing illustrating the concept of a prompt manager unit (111) according to an embodiment of the present invention. FIG. 7 is a diagram illustrating the configuration of a natural language query translation device (100) according to one embodiment. Specific details for implementing the invention

[0030] Hereinafter, embodiments disclosed in this specification will be described in detail with reference to the attached drawings. Identical or similar components regardless of drawing symbols will be assigned the same reference number, and redundant descriptions thereof will be omitted. The suffixes "module" and "part" used for components in the following description are assigned or used interchangeably solely for the ease of drafting the specification and do not inherently possess distinct meanings or roles. Furthermore, in describing embodiments disclosed in this specification, if it is determined that a detailed description of related prior art could obscure the essence of the embodiments disclosed in this specification, such detailed description will be omitted. Additionally, the attached drawings are intended only to facilitate understanding of the embodiments disclosed in this specification; the technical concept disclosed in this specification is not limited by the attached drawings, and it should be understood that they include all modifications, equivalents, and substitutions that fall within the spirit and technical scope of the present invention.

[0032] Terms including ordinal numbers, such as first, second, etc., may be used to describe various components, but said components are not limited by said terms. These terms are used solely for the purpose of distinguishing one component from another.

[0033] When it is stated that one component is "connected" or "connected" to another component, it should be understood that while it may be directly connected or connected to that other component, there may also be other components in between. On the other hand, when it is stated that one component is "directly connected" or "directly connected" to another component, it should be understood that there are no other components in between.

[0034] A singular expression includes a plural expression unless the context clearly indicates otherwise.

[0035] In this application, terms such as “comprising” or “having” are intended to specify the existence of the features, numbers, steps, actions, components, parts, or combinations thereof described in the specification, and should be understood as not precluding the existence or addition of one or more other features, numbers, steps, actions, components, parts, or combinations thereof.

[0037] Large Language Models (LLMs) refer to deep learning algorithms capable of recognizing, summarizing, translating, predicting, and generating text and various content based on knowledge obtained from large datasets. Large Language Models are considered one of the most successful applications of transformer models, and OpenAI's "Chat-GPT" and Google's Bard are representative services of large Language Models.

[0038] Large-scale language models consist of machine learning neural networks trained on sets of data inputs and outputs. The text is in an unclassified state, and it is common for models to use self-supervised or semi-supervised learning methodologies. When information or content is input into a large-scale language model, the next word predicted by the algorithm is output.

[0040] In one embodiment of the present invention, a technique for translating natural language queries based on such a large-scale language model is proposed.

[0042] FIG. 1 is a block diagram illustrating a natural language query translation device (100) according to an embodiment of the present invention.

[0043] Referring to FIG. 1, a natural language query translation device (100) according to an embodiment of the present invention may be configured to include a classification unit (101), a transformation model (102), a normalization unit (103), a domain feature addition model (104), a table filtering unit (105), a column filtering unit (110), a prompt manager unit (111), a classification training unit (114), a transformation model training unit (115), a training DB (106), a schema DB (107), an entity tagging information DB (108), and a domain feature DB (109).

[0044] Since the components illustrated in FIG. 1 are not essential for implementing the natural language query translation device (100), the natural language query translation device (100) described herein may have more or fewer components than the components listed above.

[0046] The classification unit (101) is configured to classify databases related to the input natural language query and databases unrelated to the input natural language query when the natural language query is input. That is, the classification unit (101) receives the natural language query as input and determines the database related to the input natural language query.

[0047] The conversion model (102) is a configuration that converts natural language queries into SQL queries.

[0048] In particular, a conversion model (102) according to one embodiment of the present invention can use the classification result of the classification unit (101) to refer to what the database related to the input natural language query (hereinafter referred to as the database related to the natural language query) is, and generate an SQL query corresponding to the database (for controlling or querying the database related).

[0049] Referring to FIG. 2 below, the conversion model (102) will be examined in more detail.

[0051] FIG. 2 is a diagram illustrating a conceptual diagram of a conversion model (102) according to an embodiment of the present invention.

[0052] A conversion model (102) according to one embodiment of the present invention receives a natural language query (201) and converts it into an SQL query (202) by referring to the classification result (203) of the classification unit (101). The SQL query (202) is likely a command for controlling the database related to the received natural language query (201).

[0054] In the illustrated example, the natural language query (201) is a question that requires querying a database named "Participates_in", and the classification unit (101) interprets the natural language query (201) and transmits to the conversion model (102) as a classification result (203) that the database named "Participates_in" is the related database of the input natural language query (201). Upon receiving this, the conversion model (102) can generate an SQL query that can query (control) the database named "Participates_in".

[0056] In particular, the conversion model (102) according to one embodiment of the present invention may be configured to include the large-scale language model described above. The conversion model (102) configured to include the large-scale language model may perform not only the role of the conversion model (102) described above but also the role of a normalization unit (103) or a prompt manager unit (111).

[0057] The specific role of the prompt manager (111) will be described in detail below together with Fig. 6.

[0059] A conversion model (102) according to one embodiment of the present invention receives at least one of entity tagging information (204, knowledge) and a schema (205) as input along with a natural language query (201), and can convert it into an SQL query (202) by considering them together.

[0060] Hereinafter, a combination of at least two of a natural language query, entity tagging information, and a schema to be provided as input to a transformation model (102) will be referred to as a natural language input.

[0062] FIG. 3 is a diagram illustrating a conceptual diagram of generating natural language input (301) according to an embodiment of the present invention.

[0063] FIG. 4 illustrates an example of a natural language input (301) of a conversion model (102) configured to include a large-scale language model according to an embodiment of the present invention.

[0064] The following explanation will be explained with reference to Figures 3 and 4.

[0066] Looking at the natural language input (301) illustrated in FIG. 3, it may be configured to include a natural language query (201), entity tagging information (204, knowledge), schema (205), persona information (311), and constraint information (312).

[0067] Large-scale language models are characterized by the ability to receive input in a form similar to human language, such as natural language, rather than requiring a special form of input. Accordingly, a natural language input (301) according to an embodiment of the present invention is proposed to be configured in a concatenated form of at least one text among a natural language query (201), entity tagging information (204, knowledge), schema (205), persona information (311), and constraint information (312).

[0068] In one embodiment of the present invention, while performing the text merging described above, the merging can be performed by utilizing the label described below.

[0070] The natural language input (301) illustrated in FIG. 4 is merely an example, and the natural language input (301) may be composed of at least one of entity tagging information (204, knowledge), schema (205), persona information (311) and constraint information (312) combined with the natural language query (201).

[0072] Persona information (311) may include role information (311-1) and reference target information (311-2) of the transformation model (102). Role information (311-1) is information that specifies the specific role of the transformation model (102), and reference target information (311-2) is information for specifying the target that the transformation model (102) should refer to while performing its role. As shown in the example illustrated in FIG. 4, while specifying the role of converting to SQL, it may be specified to refer to entity tagging information (204, knowledge), schema (205), and constraint information (312).

[0074] Entity tagging information (204) may refer to matching information for a specific target and a term(s) when a specific target is used with a different term in the database, or when there are multiple terms that refer to a specific target. Entity tagging refers to converting various terms into names used in the database using the entity tagging information (204).

[0075] That is, if there is a name among the names received via natural language query that is not used in the database (database name, table name, column (attribute) name, etc.), then a type of mapping information for converting that name into a name used in the database can be called entity tagging information (204).

[0077] As a specific example, when the object 'Momo Rabbit' is used as the term 'Momo Rabbit diaper' in the database, the entity tagging information (204) includes information that matches 'Momo Rabbit' with 'Momo Rabbit diaper'.

[0078] And converting ‘Momorabbit’ into ‘Momorabbit diaper’ using this entity tagging information (204) can be called entity tagging.

[0080] A schema (205) refers to data that includes a structure in which the structure of data, the method of representing data, and the relationships between data are defined in a formal language in a specific database. It can be seen as a kind of user manual for using a specific database.

[0082] Referring to the schema (205) of the example illustrated in FIG. 4, it can be seen that there are two tables in a specific database.

[0083] Here, a specific database may refer to a database corresponding to the classification result (203) of the classification unit (101) described above. That is, the schema (205) in the example illustrated in FIG. 4 may be a schema (205) for a database related to the natural language query (201) as a result of the classification unit (101) referring to the natural language query (201).

[0085] The first table is named "users" and has six attributes (columns). Referring to the schema (205), the six attributes consist of 'id', 'age', 'gender', 'name', 'occupation', and 'year', and it can be seen that the primary key (PK) is the 'id' attribute.

[0086] The schema (205) may also include information about the format (type) of the data that each attribute has. For example, the data type of the 'id' attribute may be an integer (INT, integer), not allow null, and be provided in a sequentially increasing form.

[0088] Likewise, the name of the second table is "personal_information" and has three attributes. Referring to the schema (205), the three attributes consist of 'id', 'address', and 'phone_number', and it can be seen that 'id' refers to the 'id' attribute of the first table.

[0090] As such, the schema (205) of the database contains information that performs the role of a specification used when configuring the database, and therefore will contain important information for generating SQL queries to control the database.

[0092] Meanwhile, the 'attributes' included in the schema (205) will require a specification of what specific meaning they represent. For example, the data corresponding to the 'year' attribute included in the first table needs to be clearly specified as containing information of a certain meaning, such as 'year of joining', 'year of birth', or 'year of withdrawal'.

[0094] Accordingly, a natural language query translation device (100) according to one embodiment of the present invention includes information (or knowledge) for matching between words used in a natural language query (201) and attributes of a database as entity tagging information (204), and includes the entity tagging information in the natural language input (301) so that SQL translation can be performed by considering the entity tagging information together with the schema (205).

[0096] Constraint information (312) refers to information for specifying the output format of the SQL query (202). For example, the constraint information (312) may be a constraint condition or request to "output only SQL" without outputting additional phrases or information. The output corresponding to this constraint information (312) may be such that only the SQL query (202) that is immediately usable in the database is output.

[0098] When a natural language input (301) as in FIG. 4 is received, the transformation model (102) may output an SQL query (202) by considering at least one of entity tagging information (204, knowledge), schema (205), persona information (311) and constraint information (312) together with the natural language query (201).

[0100] A natural language input (301) according to one embodiment of the present invention is proposed to include labeling for each of the natural language query (201), entity tagging information (204, knowledge), schema (205), persona information (311), and constraint information (312). Labeling means specifying what information is on the entire natural language input (301). For example, a label of "question" may be assigned to the natural language query (201) to inform the transformation model (102) that it is a natural language query (201).

[0101] In the illustrated example, the natural language query (201) is labeled "question", the entity tagging information (204, knowledge) is labeled "knowledge", the schema (205) is labeled "schema", the persona information (311) is labeled "persona", and the constraint information (312) is labeled "constraint", but is not necessarily limited thereto.

[0103] The reference target information (311-2) included in the persona information (311) according to one embodiment of the present invention may utilize a label specified by the labeling described above. For example, when performing a transformation by considering the schema (205), the reference target information (311-2) may be specified to consider "schema," which is the label of the schema (205).

[0105] Returning to Figure 1, the remaining components will be explained.

[0107] The normalization unit (103) is configured to perform normalization on the SQL query (202) converted by the conversion model (102). Normalization according to an embodiment of the present invention may refer to a process of matching with the form expressed in the database. That is, depending on the type of database, the formats using table names, specific data item names included in the table, dates / times / numbers, etc., may differ, and normalization may refer to the operation of matching these formats with the format of the database to be queried.

[0108] For example, converting 'last year' or 'the previous year' into the database's year format, '2022', could be normalization.

[0110] Furthermore, the normalization unit (103) according to one embodiment of the present invention may further include performing entity tagging by considering the entity tagging information described above together with FIG. 1.

[0112] In addition, as described above, when the transformation model (102) is configured to include a large-scale language model, it is obvious that the normalization unit (103) can be implemented as a single unit rather than as a separate and independent unit from the transformation model (102). More specifically, the result output by the transformation model (102) configured to include a large-scale language model can output an SQL query (202) that has been normalized using the entity tagging information described above.

[0114] A domain characteristic addition model (104) according to one embodiment of the present invention is configured to add domain characteristics to an SQL query in order to operate differently according to the customer's business logic. As a specific example, the domain characteristic addition model (104) can add domain characteristics through modifications such as changing the name of an output column or adding a where clause.

[0115] To add domain characteristics, the domain characteristic addition model (104) can use domain characteristic information stored in the domain characteristic DB (109).

[0117] The table filtering unit (105) distinguishes between tables related to the input natural language query and tables that are not among the database. That is, among the multiple tables constituting the database, it is configured to select only the tables related to the input natural language query (hereinafter referred to as related tables), and among the tables included in the classified related database, it filters out tables that are not related to the natural language query and outputs the related tables. This is because tables determined by the table filtering unit (105) to be not related to the natural language query do not need to be included in the natural language input (301) of FIG. 4.

[0119] In general, large-scale language models have a limited size for the input. For example, OpenAI's "Chat-GPT," which utilizes the Transformer's decoder architecture, is limited to 4,096 input tokens. In other words, the number of input characters cannot exceed 4,096. Of course, the design could be modified to accept a larger number of input tokens, but the tokens of the modified model would also inevitably be limited to a certain number.

[0120] Therefore, in order to utilize large-scale language models for SQL translation, it is necessary to limit the input size to a certain level or lower.

[0122] Accordingly, when configuring the natural language query translation device (100) for the natural language input (301), it may be configured to include only the schema of the table determined to be a related table by the table filtering unit (105) as the natural language input (301), rather than including the entire schema of the database.

[0124] To this end, the natural language query translation device (100) may divide the database schema specified by the classification unit (101) into a plurality of table schemas, and generate a partial schema by combining the table schemas for at least one table determined to be a related table by the table filtering unit (105). The natural language query translation device (100) may be configured so that the generated partial schema is included in the natural language input (301) described above, thereby allowing it to accommodate the limitation of the number of input tokens in a large-scale language model.

[0126] Furthermore, a natural language query translation device (100) according to one embodiment of the present invention proposes filtering columns on a specific table. This is because, in some cases, if the number of columns in even a single table increases, it exceeds the limited number of input tokens. To this end, the natural language query translation device (100) proposes to be equipped with a column filtering unit (110).

[0128] The column filtering unit (110) distinguishes between the part related to columns that are related to the input natural language query and the part related to columns that are not related to the input natural language query in the schema of a specific table. That is, among the multiple columns (attributes) constituting the table, only the columns related to the input natural language query (hereinafter referred to as related columns) are selected and configured to reference only the corresponding schema, and the columns unrelated to the natural language query are filtered from the related table and the related columns are output. This is because the schema of the column determined to be unrelated to the natural language query by the column filtering unit (110) does not need to be included in the natural language input (301) of FIG. 4.

[0130] To this end, the column filtering unit (110) may determine whether to filter based on whether the attribute values ​​match or by referring to metadata of a specific schema. In particular, filtering may be performed based not only on whether the text representing the attributes and the words included in the natural language query match exactly, but also on the degree of correspondence (similar matching).

[0131] For example, when determining which columns match the keyword 'overseas business' in a natural language query, it would be possible to determine that a match exists not only when the attribute value is exactly 'overseas business', but also when parts of the keyword are included, such as 'overseas business (confirmed)', or when terms like 'foreign business', which have the same or similar meaning as 'overseas business' (judging similarity between embedding vectors).

[0133] The prompt manager section (111) means a configuration for converting the result of querying a database into an appropriate answer that matches a natural language query (201) when the result of querying the database is obtained based on the SQL query (202) converted by the conversion model (102) according to an embodiment of the present invention.

[0135] As described above, if the conversion model (102) is configured to include a large-scale language model, it will be obvious that the prompt manager unit (111) can be implemented as a single unit rather than as a separate and independent unit from the conversion model (102).

[0137] The classification training unit (114) is a configuration that trains the classification unit (101) using training data stored in the training DB (106).

[0138] The transformation model training unit (115) is configured to train the transformation model (102) based on the training data stored in the training DB (106) and the schema data stored in the schema DB.

[0139] The training DB (106) is configured to store at least one training data. Training data refers to a dataset that serves as a standard for utilizing an artificial neural network or other artificial intelligence program. More specifically, training data is a dataset in which a specific input and an output that is the correct answer to the specific input are paired, and is used to train an artificial intelligence model so that the correct output can be produced.

[0140] The training data according to one embodiment of the present invention may be composed of a dataset in which natural language queries and correct answer SQL queries converted therefrom form pairs.

[0142] A schema DB (107) according to an embodiment of the present invention is a configuration that stores a schema (or schema data) for each database. As described above, a schema refers to data that includes a structure in which the structure of data, the method of representing data, and the relationships between data are defined in a formal language in a specific database. It can be viewed as a kind of user manual for using a specific database.

[0144] The entity tagging information DB (108) is a configuration that stores at least one entity tagging information. Entity tagging information refers to matching information for a specific target and term(s) as described above.

[0145] The domain characteristic DB (109) is a configuration that stores domain characteristic information. The domain characteristic information is used to reflect domain characteristics in the aforementioned domain characteristic addition model (104).

[0147] Meanwhile, in the block diagram shown in FIG. 1, the classification unit (101), transformation model (102), normalization unit (103), domain feature addition model (104), and prompt manager unit (111) are represented as distinct and independent components, but they are not necessarily limited to these independent components. For example, the transformation model (102) may be implemented to perform the roles of both the normalization unit (103) and the domain feature addition model (104).

[0148] Below, with reference to a specific flowchart, we examine the natural language processing technology according to one embodiment of the present invention.

[0150] FIG. 5 is a diagram illustrating a flowchart of a natural language processing method according to an embodiment of the present invention.

[0151] In step S501, the classification unit (101) receives a natural language query input. A natural language query is a natural language containing a question to be converted into an SQL query, and means a target to be converted into an SQL query for controlling or querying at least one of a plurality of databases.

[0153] Then, in step S502, the classification unit (101) classifies the databases for the input natural language query (databases related to the natural language query). Among the aforementioned multiple databases, the classification unit (101) distinguishes between databases related to the natural language query (related databases) and databases not related to the natural language query.

[0155] Next, the table filtering unit (105) performs filtering on the tables related to the input natural language query (S503). Among the related databases determined by the classification unit (101), the tables related to the natural language query and the tables not related to it are distinguished, and the tables not related to the natural language query are filtered to output the related tables. That is, step S503 selects only the tables related to the input natural language query from among the multiple tables constituting the related database.

[0157] In step S504, the column filtering unit (110) distinguishes between the part related to the column associated with the input natural language query and the part related to the column that is not associated with the schema of the related table selected in step S503. That is, in step S504, among the multiple columns (attributes) constituting the related table, only the columns related to the input natural language query are selected.

[0159] Next, in step S505, the conversion model (102) converts the input natural language query into an SQL query. As described above with Fig. 2, the conversion of the SQL query performed by the conversion model (102) can be performed by utilizing the classification result (203) of the classification unit (101). At this time, the natural language input (301) provided to the conversion model (102) may include a schema for the relevant table in step S503 or a schema for the relevant column in step S504, so that a natural language input (301) that fits the limited number of input tokens of the conversion model (102) may be provided.

[0161] Next, the natural language query translation device (100) queries a database (S506) based on the converted SQL query and obtains the query result. The prompt manager unit (111) configures a prompt for the query result (S507). The configuration of the prompt by the prompt manager unit (111) will be explained below with reference to FIG. 6.

[0163] FIG. 6 is a drawing illustrating the concept of a prompt manager unit (111) according to an embodiment of the present invention.

[0164] An example illustrated in FIG. 6 illustrates the case where the natural language query (201) is "How many male artists live in Jeoji-ri 323?".

[0165] In response to such a natural language query (201), the natural language query translation device (100) can generate a natural language input (301). As described above in relation to FIGS. 3 and 4, the natural language input (301) may be configured in a concatenated form of at least one text among the natural language query (201), entity tagging information (204, knowledge), schema (205), persona information (311) and constraint information (312).

[0167] The natural language input (301) generated in this way is input into the conversion model (102).

[0168] The transformation model (102) can be configured to include a Large Language Model (LLM) as described above.

[0169] The conversion model (102) converts natural language input (301) into an SQL query (202). In particular, the conversion model (102) can perform the conversion in the form of generating an SQL query (202) for a database classified as a related database by the classification unit (101).

[0170] 601 represents an SQL query (202) that converts the natural language query (201) "How many male artists live in Jeoji-ri 323?" in the example shown in FIG. 6.

[0172] Next, the natural language query translation device (100) transmits the generated SQL query (202) to the database (602) to obtain the query result (603). That is, the SQL query (202) converted by the conversion model (102) will be a query to obtain the query result (603) from the database (602).

[0173] In the example illustrated in FIG. 6, it can be seen that the result (603) of the database (602) for the natural language query (201) is "10".

[0175] Next, the prompt manager (111) configures the prompt based on the natural language query (301) and the search result (603). Configuring the prompt means converting the search result (603) into an expression that is easy for the user to understand, and can convert it into a corresponding expression by referring to the natural language query (301).

[0176] For example, as in the example shown in FIG. 6, when the database lookup result (603) for the natural language query (201) "How many male artists live in Jeoji-ri 323?" is "10", it can be converted into the expression "There are 10 male artists living in Jeoji-ri 323."

[0178] FIG. 7 is a diagram illustrating the configuration of a natural language query translation device (100) according to one embodiment.

[0179] The natural language query translation device (100) according to the various embodiments disclosed in this document may be of various forms. The natural language query translation device (100) may include, for example, a portable communication device (e.g., a smartphone), a computer device, a portable multimedia device, a portable medical device, a camera, a wearable device, a home appliance, or a server. The natural language query translation device (100) according to the embodiments of this document is not limited to the aforementioned devices.

[0181] Referring to FIG. 7, the natural language query translation device (100) includes a processor (1001) and a memory (1002).

[0182] Memory (1002) stores one or more instructions executable by the processor (1001) and various data used in one or more components. The data may include, for example, software (e.g., a program), input or output data for the associated instructions, and data regarding the transformer model. Memory (1002) may include volatile memory such as RAM, DRAM, SRAM, and / or non-volatile memory known in the art such as flash memory.

[0184] The processor (1001) executes one or more instructions stored in memory (1002).

[0185] The processor (1001) can execute one or more operations described above in relation to FIGS. 1 to 5 by executing instructions. Additionally, the configuration of the present invention described above together with FIG. 1 may be a configuration implemented by instructions executed by the processor (1001). In one embodiment, the processor (1001) may perform SQL conversion using a transformer model.

[0187] Although embodiments of the technology for converting natural language queries into SQL queries according to the present invention have been described above, these are described as at least one embodiment, and the technical concept, configuration, and operation of the present invention are not limited thereby. Furthermore, the scope of the technical concept of the present invention is not limited or restricted by the drawings or the description with reference to the drawings. In addition, the concept and embodiments of the invention presented in this invention may be used by those skilled in the art as a basis for modifying or designing other structures to perform the same purpose of the present invention. An equivalent structure modified or changed by those skilled in the art is bound by the technical scope of the present invention as described in the claims, and various changes, substitutions, and modifications are possible within the limits of not departing from the concept or scope of the invention as described in the claims.

Claims

Claim 1 A method for controlling a natural language query translation device comprising a memory for storing instructions and a processor configured to execute said stored instructions, a classification unit, and a conversion model, wherein the classification unit executed by the processor classifies a related database based on a natural language query; and the conversion model executed by the processor converts said natural language query into an SQL query corresponding to the classified related database, wherein the conversion model is configured to include a Large Language Model (LLM), and the conversion model receives a natural language input including said natural language query and outputs a converted SQL query based on the received natural language input, wherein the natural language input includes a schema and a natural language query for said classified related database, and the natural language input is configured to further include entity tagging information. Claim 2 delete Claim 3 A method for controlling a natural language query translation device according to claim 1, wherein the natural language input is the result of text concatenating at least two of the natural language query, the entity tagging information, and the schema. Claim 4 A method for controlling a natural language query translation device, wherein the natural language input comprises a label specified in at least one of the natural language query, the entity tagging information, and the schema. Claim 5 A method for controlling a natural language query translation device, wherein the entity tagging information is information for normalizing names used in the classified related database. Claim 6 A method for controlling a natural language query translation device according to claim 1, further comprising a table filtering step of filtering tables not related to the natural language query among the tables included in the classified related database and outputting related tables. Claim 7 A method for controlling a natural language query translation device according to claim 6, further comprising a column filtering step of filtering columns unrelated to the natural language query on the related table and outputting related columns. Claim 8 A natural language query translation device comprising a memory for storing instructions and a processor configured to execute said stored instructions, a classification unit, and a conversion model, wherein the classification unit classifies a related database based on a natural language query; and a conversion model that converts said natural language query into an SQL query corresponding to the classified related database, wherein the conversion model is configured to include a Large Language Model (LLM), wherein the conversion model receives a natural language input including said natural language query and outputs a converted SQL query based on the received natural language input, wherein the natural language input includes a schema and a natural language query for said classified related database, and wherein the natural language input is configured to further include entity tagging information.

Citation Information

Patent Citations

  • Text query method and apparatus, device and storage medium

    KR1020210038471A

  • Semantic linking of natural language words with columns and tables in databases

    KR1020210082727A