Method and equipment for controlling data authority in SQL (structured query language) query statement generated by large language model
By adding permission information filtering and evaluation processing to the vector database, SQL query statements are generated using a large language model, which solves the security risks of permission control caused by uncertainty in the generation results of the large language model, and realizes the effective permission control of SQL query statements .
Patent Information
- Application Number
- CN202411027650.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-11-15
AI Technical Summary
The uncertainty in generating SQL query statements in large language models leads to security risks in permission control and fails to achieve the expected goals.
Combining the permission information of the user account, filtering conditions are added when searching in the vector database, correct SQL query statements are generated through a large language model, and permission validity evaluation is performed by embedding the positive and negative examples of the vector database in the prompt word to ensure the generation SQL query statements have effective permission control.
By adding permission information filtering and evaluation processing, the effectiveness of SQL query statements is guaranteed, and the security risks caused by uncertainty in the generation results of large language models are solved.
Smart Images

Figure CN118964383A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method and device for controlling data authority in SQL query statements generated by a large language model. Background Art
[0002] By using retrieval enhancement generation technology, natural language can be converted into SQL query statements that can be run by the SQL database. After obtaining the query result data, the content is organized through a large language model and returned to the user.
[0003] However, it is well known that the uncertainty of the results generated by large language models leads to security risks in permission control, and often fails to achieve the expected goals when applied. Summary of the invention
[0004] The object of the present invention is to provide a method and device for controlling data authority in SQL query statements generated by a large language model.
[0005] To solve the above problems, the present invention provides a data authority control method in generating SQL query statements using a large language model, comprising:
[0006] Combined with the permission information of the user account, based on the user query text, filter conditions are added when searching in the vector database to effectively reflect the relevant information of permission control in the prompt word, and generate the correct SQL query statement through the large language model;
[0007] By embedding positive and negative examples of queries in the vector database in the prompt words, the correct SQL query statements are evaluated for permission validity through a large language model, and finally an SQL query statement with effective permission control is obtained.
[0008] Furthermore, in the above method, filtering conditions are added when searching in the vector database, including:
[0009] In the vector database, permission control instructions are embedded in the metadata.
[0010] Furthermore, in the above method, combined with the permission information of the user account, based on the user query text, a filtering condition is added when searching in the vector database, so that the relevant information of the permission control is effectively reflected in the prompt word, and the correct SQL query statement is generated through the large language model, including:
[0011] Based on the user query file, the permission information of the login account and the vector database, the vector database query is performed through the permission information filtering to obtain the vector database query result;
[0012] Based on the vector database query results, the correct SQL query statements are generated through the large language model.
[0013] Furthermore, in the above method, based on the vector database query result, a correct SQL query statement is generated by a large language model, including:
[0014] Based on the vector database query results and the user query text, prepare prompt word data to generate SQL statement prompt words;
[0015] Based on the SQL statement prompt words, the correct SQL query statement is generated through the large language model.
[0016] Furthermore, in the above method, by embedding positive and negative examples of the query in the vector database in the prompt word, the correct SQL query statement is evaluated for the validity of the permission through the large language model, and finally the SQL query statement with effective permission control is obtained, including:
[0017] Based on the correct SQL query statement, the permission information of the login account and the positive and negative examples of the query in the vector database, the prompt word data is prepared to obtain the prompt words for evaluating the validity of the permission;
[0018] Based on the prompt words for evaluating permission effectiveness, the large language model evaluates permission effectiveness to obtain SQL query statements with effective permission control.
[0019] According to another aspect of the present invention, there is also provided a data authority control device for generating SQL query statements using a large language model, comprising:
[0020] The generation module is used to combine the permission information of the user account and add filtering conditions when searching in the vector database based on the user query text, so as to effectively reflect the relevant information of permission control in the prompt word and generate the correct SQL query statement through the large language model;
[0021] The permission validity evaluation module is used to evaluate the validity of permissions by embedding positive and negative examples of queries in the vector database in the prompt words, and using a large language model to evaluate the validity of the correct SQL query statements, and finally obtain SQL query statements with effective permission control.
[0022] Furthermore, in the above device, a generation module is used to embed permission control instructions in metadata in the vector database.
[0023] Furthermore, in the above-mentioned device, the generation module is used to perform vector database query based on the user query file, the permission information of the login account and the vector database, and obtain the vector database query result by filtering the permission information; based on the vector database query result, generate the correct SQL query statement through the large language model.
[0024] Furthermore, in the above device, a generation module is used to prepare prompt word data based on the vector database query results and the user query text to generate SQL statement prompt words; based on the SQL statement prompt words, a correct SQL query statement is generated through a large language model.
[0025] Furthermore, in the above-mentioned device, the permission validity evaluation module is used to prepare prompt word data based on the correct SQL query statement, the permission information of the login account and the positive and negative examples of the query in the vector database to obtain prompt words for evaluating the validity of the permission; based on the prompt words for evaluating the validity of the permission, the large language model evaluates the validity of the permission to obtain an SQL query statement with effective permission control.
[0026] Compared with the prior art, the present invention adds two improvements in the process of converting natural language into SQL query statements that can be run by the SQL database to ensure the validity of the permission control of the SQL query statements. The first improvement is: combining the permission information of the user account, based on the user query text, adding filtering conditions when searching in the vector database, so as to effectively reflect the relevant information of the permission control in the prompt word and generate the correct SQL query statement; the second improvement is: adding the permission validity evaluation process, by embedding the positive and negative examples of the query in the vector database in the prompt word, and evaluating the validity of the permission for the correct SQL query statement through the large language model, and finally obtaining the SQL query statement with effective permission control.
[0027] The present invention relates to a large language model, a vector database and a search enhancement generation technology, which can be applied to the permission control when using a large language model to generate SQL query statements and query enterprise data. The present invention can solve the problem of potential security risks in permission control when generating SQL query statements due to the uncertainty of the results generated by the large language model. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 It is a flowchart of a method for controlling data permissions in generating SQL query statements using a large language model according to an embodiment of the present invention. DETAILED DESCRIPTION
[0029] The present invention is further described in detail below in conjunction with the accompanying drawings.
[0030] In a typical configuration of the present application, the terminal, the device of the service network and the trusted party all include one or more processors (CPU), input / output interfaces, network interfaces and memories.
[0031] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0032] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory media such as modulated data signals and carrier waves.
[0033] like Figure 1 As shown, the present invention provides a data authority control method in generating SQL query statements using a large language model, comprising:
[0034] Step S1, combining the permission information of the user account and based on the user query text, adding filtering conditions when searching in the vector database, so as to effectively reflect the relevant information of the permission control in the prompt word, and generating the correct SQL query statement through the large language model;
[0035] Preferably, the permission control description can be embedded in the metadata (meta_data) in the vector database, as shown in the following table:
[0036]
[0037] Step S2, by embedding positive and negative examples of the query in the vector database in the prompt word, the correct SQL query statement is evaluated for permission validity through the large language model, and finally an SQL query statement with effective permission control is obtained.
[0038] Here, the present invention adds two improvements in the process of converting natural language into SQL query statements that can be run by the SQL database to ensure the validity of the permission control of the SQL query statement. The first improvement is: combining the permission information of the user account, based on the user query text, adding filtering conditions when searching in the vector database, so as to effectively reflect the relevant information of the permission control in the prompt word and generate the correct SQL query statement; the second improvement is: adding the permission validity evaluation process, by embedding the positive and negative examples of the query in the vector database in the prompt word, and evaluating the validity of the permission for the correct SQL query statement through the large language model, and finally obtaining the SQL query statement with effective permission control.
[0039] The present invention relates to a large language model, a vector database and a search enhancement generation technology, which can be applied to the permission control when using a large language model to generate SQL query statements and query enterprise data. The present invention can solve the problem of potential security risks in permission control when generating SQL query statements due to the uncertainty of the results generated by the large language model.
[0040] In an embodiment of the method for controlling data authority in generating SQL query statements using a large language model of the present invention, step S1, combining the authority information of the user account, based on the user query text, adding a filtering condition when searching in the vector database, so as to effectively reflect the relevant information of the authority control in the prompt word, and generating a correct SQL query statement through the large language model, comprises:
[0041] Step S11, based on the user query file, the permission information of the login account and the vector database, perform a vector database query by filtering the permission information to obtain a vector database query result;
[0042] Step S12: Generate a correct SQL query statement through a large language model based on the vector database query result.
[0043] In an embodiment of the method for controlling data authority in generating SQL query statements using a large language model of the present invention, step S12, based on the vector database query result, generates a correct SQL query statement using a large language model, including:
[0044] Step S121, based on the vector database query result and the user query text, prepare prompt word data to generate SQL statement prompt words;
[0045] Step S122: Generate a correct SQL query statement based on the SQL statement prompt word through a large language model.
[0046] In an embodiment of the method for controlling data authority in a SQL query statement generated by a large language model of the present invention, step S2, by embedding positive and negative examples of the query in the vector database in the prompt word, uses the large language model to evaluate the authority validity of the correct SQL query statement, and finally obtains an SQL query statement with effective authority control, including:
[0047] Step S21, based on the correct SQL query statement, the permission information of the login account and the positive and negative examples queried in the vector database, prepare prompt word data to obtain prompt words for evaluating the validity of the permission;
[0048] Step S22: Based on the prompt words for evaluating the validity of the authority, the large language model evaluates the validity of the authority to obtain an SQL query statement with effective authority control.
[0049] According to another aspect of the present invention, there is also provided a data authority control device for generating SQL query statements using a large language model, comprising:
[0050] The generation module is used to combine the permission information of the user account and add filtering conditions when searching in the vector database based on the user query text, so as to effectively reflect the relevant information of permission control in the prompt word and generate the correct SQL query statement through the large language model;
[0051] The permission validity evaluation module is used to evaluate the validity of permissions by embedding positive and negative examples of queries in the vector database in the prompt words, and using a large language model to evaluate the validity of the correct SQL query statements, and finally obtain SQL query statements with effective permission control.
[0052] Furthermore, in the above device, a generation module is used to embed permission control instructions in metadata in the vector database.
[0053] Furthermore, in the above-mentioned device, the generation module is used to perform vector database query based on the user query file, the permission information of the login account and the vector database, and obtain the vector database query result by filtering the permission information; based on the vector database query result, generate the correct SQL query statement through the large language model.
[0054] Furthermore, in the above device, a generation module is used to prepare prompt word data based on the vector database query results and the user query text to generate SQL statement prompt words; based on the SQL statement prompt words, a correct SQL query statement is generated through a large language model.
[0055] Furthermore, in the above-mentioned device, the permission validity evaluation module is used to prepare prompt word data based on the correct SQL query statement, the permission information of the login account and the positive and negative examples of the query in the vector database to obtain prompt words for evaluating the validity of the permission; based on the prompt words for evaluating the validity of the permission, the large language model evaluates the validity of the permission to obtain an SQL query statement with effective permission control.
[0056] Compared with the prior art, the present invention adds two improvements in the process of converting natural language into SQL query statements that can be run by the SQL database to ensure the validity of the permission control of the SQL query statements. The first improvement is: combining the permission information of the user account, based on the user query text, adding filtering conditions when searching in the vector database, so as to effectively reflect the relevant information of the permission control in the prompt word and generate the correct SQL query statement; the second improvement is: adding the permission validity evaluation process, by embedding the positive and negative examples of the query in the vector database in the prompt word, and evaluating the validity of the permission for the correct SQL query statement through the large language model, and finally obtaining the SQL query statement with effective permission control.
[0057] The present invention relates to a large language model, a vector database and a search enhancement generation technology, which can be applied to the permission control when using a large language model to generate SQL query statements and query enterprise data. The present invention can solve the problem of potential security risks in permission control when generating SQL query statements due to the uncertainty of the results generated by the large language model.
[0058] The detailed contents of the device embodiments of the present invention can be found in the corresponding parts of the method embodiments, which will not be described in detail here.
[0059] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
[0060] It should be noted that the present invention can be implemented in software and / or a combination of software and hardware, for example, can be implemented using an application specific integrated circuit (ASIC), a general purpose computer or any other similar hardware device. In one embodiment, the software program of the present invention can be executed by a processor to implement the steps or functions described above. Similarly, the software program of the present invention (including related data structures) can be stored in a computer readable recording medium, for example, a RAM memory, a magnetic or optical drive or a floppy disk and the like. In addition, some steps or functions of the present invention can be implemented using hardware, for example, as a circuit that cooperates with a processor to perform each step or function.
[0061] In addition, a part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. The program instruction for calling the method of the present invention may be stored in a fixed or removable recording medium, and / or transmitted through a data stream in a broadcast or other signal-bearing medium, and / or stored in a working memory of a computer device that runs according to the program instruction. Here, according to an embodiment of the present invention, a device is included, the device including a memory for storing computer program instructions and a processor for executing program instructions, wherein, when the computer program instruction is executed by the processor, the device is triggered to run the method and / or technical solution based on the aforementioned multiple embodiments of the present invention.
[0062] It is obvious to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential features of the present invention. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present invention is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the device claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
Claims
1. A data permission control method for generating SQL query statements using a large language model. It is characterized in that include: Combined with the permission information of the user account, based on the user query text, filter conditions are added when searching in the vector database to effectively reflect the relevant information of permission control in the prompt word, and generate the correct SQL query statement through the large language model; By embedding positive and negative examples of queries in the vector database in the prompt words, the correct SQL query statements are evaluated for permission validity through a large language model, and finally an SQL query statement with effective permission control is obtained.
2. The method for controlling data authority in generating SQL query statements using a large language model as claimed in claim 1, It is characterized in that Add filter conditions when searching in the vector database, including: In the vector database, permission control instructions are embedded in the metadata.
3. The data authority control method in generating SQL query statements using a large language model as claimed in claim 1, It is characterized in that Combined with the permission information of the user account, based on the user query text, filter conditions are added when searching in the vector database to effectively reflect the relevant information of permission control in the prompt word, and the correct SQL query statement is generated through the large language model, including: Based on the user query file, the permission information of the login account and the vector database, the vector database query is performed through the permission information filtering to obtain the vector database query result; Based on the vector database query results, the correct SQL query statements are generated through the large language model.
4. The data authority control method in generating SQL query statements using a large language model as claimed in claim 3, It is characterized in that Based on the vector database query results, the correct SQL query statements are generated through the large language model, including: Based on the vector database query results and the user query text, prepare prompt word data to generate SQL statement prompt words; Based on the SQL statement prompt words, the correct SQL query statement is generated through the large language model.
5. The data authority control method in generating SQL query statements using a large language model as claimed in claim 1, It is characterized in that By embedding positive and negative examples of queries in the vector database in the prompt words, the large language model is used to evaluate the validity of the correct SQL query statements, and finally the SQL query statements with effective permission control are obtained, including: Based on the correct SQL query statement, the permission information of the login account and the positive and negative examples of the query in the vector database, the prompt word data is prepared to obtain the prompt words for evaluating the validity of the permission; Based on the prompt words for evaluating permission effectiveness, the large language model evaluates permission effectiveness to obtain SQL query statements with effective permission control.
6. A data permission control device in a large language model to generate SQL query statements, It is characterized in that include: The generation module is used to combine the permission information of the user account and add filtering conditions when searching in the vector database based on the user query text, so as to effectively reflect the relevant information of permission control in the prompt word and generate the correct SQL query statement through the large language model; The permission validity evaluation module is used to evaluate the validity of permissions by embedding positive and negative examples of queries in the vector database in the prompt words, and using a large language model to evaluate the validity of the correct SQL query statements, and finally obtain SQL query statements with effective permission control.
7. The data authority control device for generating SQL query statements using a large language model as claimed in claim 6, It is characterized in that A generation module is used to embed permission control instructions in metadata in a vector database.
8. The data authority control device for generating SQL query statements using a large language model as claimed in claim 6, It is characterized in that The generation module is used to perform vector database query based on user query files, login account permission information and vector database, filter by permission information, obtain vector database query results; based on the vector database query results, generate correct SQL query statements through a large language model.
9. The data authority control device for generating SQL query statements using a large language model as claimed in claim 8, It is characterized in that A generation module is used to prepare prompt word data based on the vector database query result and the user query text to generate SQL statement prompt words; Based on the SQL statement prompt words, the correct SQL query statement is generated through the large language model.
10. The data authority control device for generating SQL query statements using a large language model as claimed in claim 6, It is characterized in that The permission validity evaluation module is used to prepare prompt word data based on the correct SQL query statement, the permission information of the login account and the positive and negative examples of the query in the vector database to obtain prompt words for evaluating the validity of the permission; Based on the prompt words for evaluating permission effectiveness, the large language model evaluates permission effectiveness to obtain SQL query statements with effective permission control.
Citation Information
Patent Citations
SQL (Structured Query Language) statement generation method and device based on large language model, equipment and medium
CN117743371A
Vertical field large model construction method and device based on 12345 data
CN117891826A
Natural semantic database comprehensive construction method capable of ensuring credibility and security
CN118296125A
Cited By
Information retrieval method and device, electronic equipment and storage medium
CN121743368A
