Computer-implemented methods and systems for dynamic prompt generation and integration with large language models for document revision
Computer-implemented methods and systems interface with a language model (e.g., a Large Language Model (LLM)) to assist in document revision. The methods and systems allow text to be selected within a document and an action definition to be selected from an action definition library. The text and/or the action definition may be selected using a graphical user interface (GUI). An action defined by the selected action definition is applied to the selected text to generate text. For example, the selected action definition may include a prompt, and the prompt may be combined with the selected text to generate a combined prompt. The combined prompt may be provided as an input to the LLM, which may generate the generated text. The generated text may be integrated into the document.
1 . A method performed by at least one computer processor executing computer program instructions stored on at least one non-transitory computer-readable medium, the method comprising:
(A) receiving, from a user, via a prompt editor of a graphical user interface (GUI), a plurality of initial prompt definition inputs;
(B) creating plurality of initial prompts from the plurality of initial prompt definition inputs, wherein each of the plurality of initial prompts includes content from a corresponding one of the initial prompt definition inputs;
(C) receiving, via the GUI, input from the user selecting text within a document, wherein receiving input from the user selecting text within the document comprises receiving input from the user selecting a contiguous block of text within the document;
(D) receiving, via the GUI, input from the user selecting a particular initial prompt from among the plurality of initial prompts;
(E) generating, based on the selected text and the particular initial prompt, a processed prompt;
(F) providing the processed prompt to a language model to generate output; and
(G) updating the document based on the output.
2 . The method of claim 1 , wherein receiving input from the user selecting text within the document comprises receiving input from the user dragging across text within a manifestation of the document in the GUI.
3 . The method of claim 1 , wherein receiving input from the user selecting the particular initial prompt comprises receiving input from the user selecting an identifier of the particular initial prompt from a list of initial prompt identifiers manifested in the GUI.
4 . The method of claim 1 , wherein receiving input from the user selecting the particular initial prompt comprises receiving input from the user selecting a manifestation of an action definition from a contextual menu.
5 . The method of claim 1 , wherein the particular initial prompt comprises a simple text prompt containing no dynamic content.
6 . The method of claim 1 , wherein the particular initial prompt comprises a tokenized prompt, the tokenized prompt comprising at least one token acting as a placeholder for dynamic content.
7 . The method of claim 1 , wherein the particular initial prompt comprises a compound prompt comprising multiple component prompts that differ from each other.
8 . The method of claim 7 , wherein (F) comprises:
(F) (1) performing (F) for each of the compound prompt's multiple component prompts to generate a plurality of outputs;
(F) (2) manifesting the plurality of outputs to the user; and
(F) (3) receiving, via the GUI, input from the user selecting one of the plurality of outputs.
9 . The method of claim 7 , wherein (F) comprises:
(F) (1) performing step (F) for a first component prompt of the compound prompt to generate a first output; and
(F) (2) performing step (F) for a second component prompt of the compound prompt, using the first output as an input to the language model, to generate second output.
10 . The method of claim 1 , wherein the particular initial prompt comprises a scripted prompt written in a scripting language.
11 . The method of claim 1 , wherein generating the processed prompt comprises concatenating the particular initial prompt with the selected text.
12 . The method of claim 1 , wherein the particular initial prompt comprises a tokenized prompt containing a token, and wherein generating the processed prompt comprises:
(E) (1) obtaining a value for the token; and
(E) (2) replacing the token with the value.
13 . The method of claim 12 , wherein obtaining the value for the token comprises using a trained model to generate the value.
14 . The method of claim 13 , wherein using the trained model to generate the value comprises using the language model to generate the value.
15 . The method of claim 1 , wherein generating the processed prompt comprises:
(E) (1) providing the selected text and the particular initial prompt as inputs to the language model; and
(E) (2) receiving the processed prompt as output from the language model.
16 . The method of claim 1 , wherein the language model comprises a large language model (LLM).
17 . The method of claim 1 , wherein providing the processed prompt to the language model comprises:
(F) (1) receiving, from the user, language model selection input selecting the language model from a plurality of language models; and
(F) (2) providing the processed prompt to the language model.
18 . The method of claim 1 , wherein updating the document based on the output comprises inserting the output into the document immediately after the selected text.
19 . The method of claim 1 , wherein updating the document based on the output comprises:
(G) (1) receiving, via the GUI, input from the user specifying a location in the document other than a location of the selected text; and
(G) (2) inserting the output into the document at the location specified by the user.
20 . The method of claim 1 , wherein updating the document based on the output comprises replacing the selected text in the document with the output.
21 . The method of claim 1 , wherein updating the document based on the output comprises:
(G) (1) manifesting a preview of the document updated with the output to the user via the GUI;
(G) (2) receiving, via the GUI, input from the user accepting the preview; and
(G) (3) updating the document in response to receiving the input from the user accepting the preview.
22 . A system comprising at least one non-transitory computer-readable medium having computer program instructions stored thereon, the computer program instructions being executable by at least one computer process to perform a method, the method comprising:
(A) receiving, from a user, via a prompt editor of a graphical user interface (GUI), a plurality of initial prompt definition inputs;
(B) creating a plurality of initial prompts from the plurality of initial prompt definition inputs, wherein each of the plurality of initial prompts includes content from a corresponding one of the initial prompt definition inputs;
(C) receiving, via the GUI, input from the user selecting text within a document, wherein receiving input from the user selecting text within the document comprises receiving input from the user selecting a contiguous block of text within the document;
(D) receiving, via the GUI, input from the user selecting a particular initial prompt from among the plurality of initial prompts;
(E) generating, based on the selected text and the particular initial prompt, a processed prompt;
(F) providing the processed prompt to a language model to generate output; and
(G) updating the document based on the output.