Text-generated instruction objects using large language model
In an example embodiment, a solution is provided that automatically adds a system message to natural language text provided by a user to generate a prompt to a Large Language Model (LLM) to automatically generate a code in a declarative language format, the code corresponding to the natural language text. Furthermore, retrieval augmented generation may be utilized to overcome the maximum number of contextual tokens permitted as input to an LLM. More particularly, the system message may be designed to include an instruction to the LLM to generate search calls for one or more entity definitions in a specified format from a database. The search calls may then be performed on the database via a similarity search to obtain the relevant information, which can then be passed back into the LLM for the generation of the code.
1 . A system comprising:
at least one hardware processor; and
a computer-readable medium storing instructions that, when executed by the at least one hardware processor, cause the at least one hardware processor to perform operations comprising:
receiving natural language text describing data to be retrieved from a database;
generating a prompt by adding a system message to the natural language text, the system message including an instruction to generate code in a declarative language format for the retrieval of the data from the database, the instruction including a request to generate one or more search calls, on the database, for one or more entities specified in the natural language text;
passing the prompt to a large language model (LLM);
receiving, from the LLM, a first response comprising the one or more search calls as generated by the LLM, wherein the one or more search calls specify one or more entity definitions to be searched in the database;
executing a similarity search on the database using the one or more search calls, to obtain one or more similarity search results;
adding the one or more similarity search results to the prompt to generate a modified prompt, the modified prompt requesting that the LLM generate code in a declarative language format;
submitting the modified prompt to the LLM; and
receiving, from the LLM, a second response comprising the code in the declarative language format as generated by the LLM based on the modified prompt.
2 . The system of claim 1 , wherein the declarative language format is Core Query Notation (CQN).
3 . The system of claim 1 , wherein the LLM is a Generative Pre-trained Transformer (GPT) model.
4 . The system of claim 1 , wherein the operations further comprise fine-tuning the LLM using the database.
5 . The system of claim 1 , wherein the operations further comprise: retrieving data from the database by executing the code.
6 . The system of claim 1 , wherein the database defines table names and field names of fields within corresponding tables.
7 . The system of claim 1 , wherein the database defines entities used by an application operating on a cloud application server.
8 . A method comprising:
receiving natural language text describing data to be retrieved from a database;
generating a prompt by adding a system message to the natural language text, the system message including an instruction to generate code in a declarative language format for the retrieval of the data from the database, the instruction including a request to generate one or more search calls, on the database, for one or more entities specified in the natural language text;
passing the prompt to a large language model (LLM);
receiving, from the LLM, a first response comprising the one or more search calls as generated by the LLM, wherein the one or more search calls specify one or more entity definitions to be searched in the database;
executing a similarity search on the database using the one or more search calls, to obtain one or more similarity search results;
adding the one or more similarity search results to the prompt to generate a modified prompt, the modified prompt requesting that the LLM generate code in a declarative language format;
submitting the modified prompt to the LLM; and
receiving, from the LLM, a second response comprising the code in the declarative language format as generated by the LLM based on the modified prompt.
9 . The method of claim 8 , wherein the declarative language format is Core Query Notation (CQN).
10 . The method of claim 8 , wherein the LLM is a Generative Pre-trained Transformer (GPT) model.
11 . The method of claim 8 , further comprising fine-tuning the LLM using the database.
12 . The method of claim 8 , further comprising retrieving data from the database by executing the code.
13 . The method of claim 8 , wherein the database defines table names and field names of fields within corresponding tables.
14 . The method of claim 8 , wherein the database defines entities used by an application operating on a cloud application server.
15 . A non-transitory machine-readable medium storing instructions which, when executed by one or more processors, cause the one or more processors to perform operations comprising:
receiving natural language text describing data to be retrieved from a database;
generating a prompt by adding a system message to the natural language text, the system message including an instruction to generate code in a declarative language format for the retrieval of the data from the database, the instruction including a request to generate one or more search calls, on the database, for one or more entities specified in the natural language text;
passing the prompt to a large language model (LLM);
receiving, from the LLM, a first response comprising the one or more search calls as generated by the LLM, wherein the one or more search calls specify one or more entity definitions to be searched in the database;
executing a similarity search on the database using the one or more search calls, to obtain one or more similarity search results;
adding the one or more similarity search results to the prompt to generate a modified prompt, the modified prompt requesting that the LLM generate code in a declarative language format;
submitting the modified prompt to the LLM; and
receiving, from the LLM, a second response comprising the code in the declarative language format as generated by the LLM based on the modified prompt.
16 . The non-transitory machine-readable medium of claim 15 , wherein the declarative language format is Core Query Notation (CQN).
17 . The non-transitory machine-readable medium of claim 15 , wherein the LLM is a Generative Pre-trained Transformer (GPT) model.
18 . The non-transitory machine-readable medium of claim 15 , wherein the operations further comprise fine-tuning the LLM using the database.
19 . The non-transitory machine-readable medium of claim 15 , wherein the operations further comprise:
retrieving data from the database by executing the code.
20 . The non-transitory machine-readable medium of claim 15 , wherein the database defines table names and field names of fields within corresponding tables.