Method for creating prompt
View Patent ↗The present disclosure relates to a method for creating a prompt, the method may include: receiving properties of a prompt; clustering the received properties into syntax elements; diversifying, by a large language model (LLM), each of the clustered properties into a plurality of properties; creating a prompt format database; selecting a list of prompt formats in the created prompt format database; and creating prompts by inserting each of the diversified properties, obtained from the diversifying of each of the clustered properties, into each prompt format in the list of prompt formats in accordance with the syntax element of the corresponding clustered property of the diversified properties. The present disclosure also relates to an apparatus for creating a prompt, and a computer program.
1 . A method for creating a prompt, comprising:
receiving properties of a prompt;
clustering the received properties into syntax elements;
diversifying, by a large language model (LLM), each of the clustered properties into a plurality of properties;
creating a prompt format database, wherein the creating of the prompt format database comprises:
creating prompt formats,
evaluating the created prompt formats, wherein the evaluating of the created prompt formats comprises:
creating a set of sample prompts for each of the created prompt formats,
evaluating the set of sample prompts for the created prompt formats on a correlation to a specific objective of the method, and
evaluating, by a user and/or the LLM, each of the created prompt formats based on the evaluation results obtained from the evaluating of the set of sample prompts, and
creating a prompt format database from the created prompt formats of which the evaluation result obtained from the evaluating of each of the created prompt formats is higher than a predefined evaluation threshold;
selecting a list of prompt formats in the created prompt format database; and
creating prompts by inserting each of the diversified properties, obtained from the diversifying of each of the clustered properties, into each prompt format in the list of prompt formats in accordance with the syntax element of the corresponding clustered property of the diversified properties.
2 . The method according to claim 1 , wherein, in the receiving of the properties of the prompt, the properties are predefined properties, and/or inputted in a natural language by a user, and/or generated by a large language model (LLM) via predefined prompts.
3 . The method according to claim 2 , wherein the syntax elements in the clustering comprise a subject, a verb, and/or one or more other syntax elements.
4 . The method according to claim 3 , wherein, before the creating of the prompt formats, the method further comprises:
creating possible prompt properties:
from a natural language inputted by the user in accordance with a specific objective of the method, and/or
from prompts which are generated by the LLM in accordance with the specific objective, and/or
from properties which are generated by the LLM in accordance with the specific objective.
5 . The method according to claim 4 , wherein the creating of the prompt formats comprises creating prompt formats:
from the created possible prompt properties, and/or
from prompts which are generated by the LLM in accordance with the specific objective, and/or
from prompt formats generated by the LLM in accordance with the specific objective.
6 . The method according to claim 5 , wherein the creating of the set of sample prompts comprises:
generating prompts by the LLM in accordance with the specific objective,
classifying the generated prompts into each of the created prompt formats obtained from the creating of the prompt formats,
diversifying properties in each of the classified prompts to create a set of sample prompts for the corresponding prompt format.
7 . The method according to claim 6 , wherein the evaluating of the set of sample prompts comprises:
creating, by an image search engine and a text-to-image model, a set of images by using each sample prompt in the set of sample prompts of each of the created prompt formats,
evaluating by comparing the sets of images of the created prompt formats of which sample prompts have the same properties for each of the common syntax elements based on the correlation to the specific objective, and
evaluating all images in the sets of images, which are created from sample prompts having the same properties for each of the common syntax elements, based on the correlation to the specific objective,
wherein the evaluating of each of the created prompt formats comprises evaluating each of the created prompt formats based on a combination of the evaluation results obtained from the evaluating by comparing the sets of images and the evaluating of all images; and
wherein, in the creating of the prompt format database, the predefined evaluation threshold is a predefined evaluation threshold or set by the user.
8 . The method according to claim 7 , wherein the creating of the prompts further comprises:
if one of the diversified properties is syntax-clustered as the subject and the relevance of the said property to the specific objective is higher than a predefined threshold, then inserting the said property and other diversified properties into each prompt format in the list with the verb and/or one or more of the other syntax elements removed.
9 . The method according to claim 8 , wherein the diversifying of each of the clustered properties comprises diversifying each of the clustered properties in accordance with the specific objective,
wherein the specific objective is a weapon detection, and/or a specific object detection.
10 . The method according to claim 9 , wherein the selecting of the list of prompt formats comprises:
adding all prompt formats in the prompt format database obtained from the creating of the prompt format database to the list, and
removing duplicates of each prompt format from the list of prompt formats.
11 . The method according to claim 10 , after the diversifying of each of the clustered properties into the plurality of properties, the method further comprises filtering the diversified properties of one of the clustered properties based on a relevance of the diversified properties to each of the other clustered properties, the relevance is determined by the LLM;
wherein the creating of the prompts comprises:
creating prompts by inserting each of the filtered diversified properties obtained from the filtering of the diversified properties into each prompt format in the list of prompt formats in accordance with the syntax element of the corresponding clustered property of the filtered diversified properties, and
if one of the filtered diversified properties is syntax-clustered as the subject and the relevance of the said property to the specific objective is higher than a predefined threshold, then inserting the said property and other filtered diversified properties into each prompt format in the list with the verb and/or one or more of the other syntax elements removed.