Natural language and control text mixed arrangement of large language model prompt method

By identifying and distinguishing between natural language text and control text, and by updating the contextual prompts of the large language model in conjunction with functional plugins, the problem of uncertainty in the content generated by the large language model is solved, thereby achieving precise control over the generated content and improving the ability to correlate context.

CN119476260BActive Publication Date: 2025-11-04XIDIAN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411102475.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-12
Publication Date
2025-11-04
Estimated Expiration
2044-08-12

AI Technical Summary

Technical Problem

In existing technologies, the content generated by large language models has significant uncertainties, making it difficult to achieve precise control over the generation process and content.

Method used

By identifying the text types of natural language text and control text in the target input text, the contextual prompt text of the large language model is updated using preset rules, and the generated content is precisely controlled by functional plugins.

Benefits of technology

It enables precise control over the output content of large language models, improves the readability and maintainability of generated content, and enhances the contextual association capabilities and flexibility of large language models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119476260B_ABST
    Figure CN119476260B_ABST
Patent Text Reader

Abstract

The application provides a natural language and control text mixed arrangement large language model prompting method, and relates to the technical field of computers, and the method comprises the following steps: obtaining target input text input by a user; identifying the respective text types of at least one text block in the target input text based on a preset rule; the preset rule is used to represent the analysis format of the target input text; for each text block, if the text type comprises target natural language text, updating the context prompt text corresponding to the large language model based on the target natural language text; if the text type comprises target control text, calling a function plug-in corresponding to the target control text to update the context prompt text corresponding to the large language model. The technical scheme of the application updates the context prompt text corresponding to the large language model based on the target natural language text and / or the target control text, so that the output content of the large language model can be accurately controlled.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer technology, and in particular to a large language model prompting method for mixed arrangement of natural language and control text. BACKGROUND

[0002] At present, with the rapid development of artificial intelligence technology, large language models can be applied to text generation, translation, question answering, sentiment analysis, text classification, information extraction, semantic understanding and intelligent dialogue, etc. Large language models have become an important driving force in various fields due to their natural language processing capabilities.

[0003] However, since large language models are essentially mathematical models constructed based on probability statistics principles and training data, the inherent probability sampling randomness leads to a large uncertainty in the generated content when the quality of the prompt words is not high.

[0004] In the prior art, the method of using natural language strings to write prompt words to guide large language models often cannot achieve precise control over the generation process and content. SUMMARY

[0005] The present application provides a large language model prompting method for mixed arrangement of natural language and control text, which solves the problem of the prior art that it is difficult to achieve precise control over the generation process and content of the large language model, resulting in a large uncertainty in the generated content. The present application updates the context prompt text corresponding to the large language model based on the target natural language text and / or target control text, so that the output content of the large language model can be precisely controlled.

[0006] The present application provides a large language model prompting method for mixed arrangement of natural language and control text, comprising the following steps.

[0007] Obtain the target input text input by the user;

[0008] Based on a preset rule, identify the text type corresponding to each text block in the target input text; the preset rule is used to represent the analysis format of the target input text;

[0009] For each text block, if the text type includes a target natural language text, update the context prompt text corresponding to the large language model based on the target natural language text; if the text type includes a target control text, call the function plug-in corresponding to the target control text to update the context prompt text corresponding to the large language model.

[0010] According to the natural language and control text mixed arrangement large language model prompting method provided by the application, the text types include target natural language text or target control text.

[0011] The preset rules are used to identify the text types corresponding to each text block in the target input text.

[0012] Based on the preset rules and the font style and encoding content corresponding to the target input text, at least one text block corresponding to the target input text is determined.

[0013] For each text block, the text type corresponding to the text block is determined based on the preset rules and the encoding content corresponding to the text block.

[0014] According to the natural language and control text mixed arrangement large language model prompting method provided by the application, the calling of the function plug-in corresponding to the target control text updates the context prompt text corresponding to the large language model, including:

[0015] The function plug-in corresponding to the target control text is called to determine the execution result of the target control text.

[0016] Based on the execution result of the target control text, the context prompt text corresponding to the large language model is updated.

[0017] According to the natural language and control text mixed arrangement large language model prompting method provided by the application, the calling of the function plug-in corresponding to the target control text determines the execution result of the target control text, including:

[0018] In the case where the function plug-in corresponding to the target control text includes a calling plug-in, the large language model determines a first output result based on the context prompt text and the calling plug-in.

[0019] In the case where the function plug-in corresponding to the target control text includes a non-calling plug-in, a second output result corresponding to the non-calling plug-in is determined.

[0020] Based on the first output result and / or the second output result, the execution result of the target control text is determined.

[0021] According to the natural language and control text mixed arrangement large language model prompting method provided by the application, the calling of the function plug-in corresponding to the target control text determines the execution result of the target control text, including:

[0022] In a case that the calling plug-in includes a preset plug-in, a vocabulary probability of an output vocabulary corresponding to the context prompt text is controlled by the large language model based on the preset plug-in; and the first output result is determined based on the vocabulary probability of the output vocabulary.

[0023] The preset plug-in at least includes a selection plug-in and / or a regular matching plug-in.

[0024] According to the large language model prompt method for mixed arrangement of natural language and control text provided by the application, the context prompt text corresponding to the large language model is updated based on the target natural language text, which includes:

[0025] The target natural language text is added to the context prompt text corresponding to the large language model.

[0026] The application further provides a large language model prompt device for mixed arrangement of natural language and control text, which includes the following modules:

[0027] The obtaining module is used to obtain a target input text input by a user;

[0028] The recognition module is used to recognize a text type corresponding to each text block in the target input text based on a preset rule; and the preset rule is used to represent an analysis format of the target input text.

[0029] The updating module is used to update the context prompt text corresponding to the large language model based on the target natural language text for each text block in a case that the text type includes the target natural language text; and the context prompt text corresponding to the large language model is updated by calling a function plug-in corresponding to the target control text in a case that the text type includes the target control text.

[0030] The application further provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor; and the processor implements the large language model prompt method for mixed arrangement of natural language and control text according to any one of the above-mentioned methods when executing the program.

[0031] The application further provides a non-transitory computer readable storage medium, which stores a computer program; and the computer program is executable on a processor to implement the large language model prompt method for mixed arrangement of natural language and control text according to any one of the above-mentioned methods.

[0032] The application further provides a computer program product, which includes a computer program; and the computer program is executable on a processor to implement the large language model prompt method for mixed arrangement of natural language and control text according to any one of the above-mentioned methods.

[0033] The natural language and control text mixed arrangement large language model prompting method provided by the application comprises the following steps: obtaining target input text input by a user; identifying a text type corresponding to each text block in the target input text based on a preset rule, wherein the preset rule is used to represent an analysis format of the target input text; updating context prompt text corresponding to a large language model based on a target natural language text in the case that the text type of each text block comprises the target natural language text; and calling a function plug-in corresponding to a target control text in the case that the text type of each text block comprises the target control text, and updating the context prompt text corresponding to the large language model. The technical scheme of the application identifies the text type corresponding to each text block in the target input text based on the preset rule, and then updates the context prompt text corresponding to the large language model based on the target natural language text and / or the target control text, so that the output content of the large language model can be accurately controlled. BRIEF DESCRIPTION OF DRAWINGS

[0034] In order to more clearly illustrate the technical solutions in the application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the application, and for those skilled in the art, other drawings can also be obtained without creative labor.

[0035] Figure 1 FIG. 1 is a flowchart of the natural language and control text mixed arrangement large language model prompting method provided by the application.

[0036] Figure 2 FIG. 2 is a structural schematic diagram of the natural language and control text mixed arrangement large language model prompting device provided by the application.

[0037] Figure 3 FIG. 3 is a structural schematic diagram of the electronic device provided by the application. DETAILED DESCRIPTION

[0038] In order to make the objects, technical solutions and advantages of the application clearer, the following will combine the drawings in the application to clearly and completely describe the technical solutions in the application. Obviously, the described embodiments are some embodiments of the application, rather than all the embodiments. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative labor are within the protection scope of the application.

[0039] In order to solve the above problems in the prior art, the application provides a natural language and control text mixed arrangement large language model prompting method, Figure 1 FIG. 1 is a flowchart of the natural language and control text mixed arrangement large language model prompting method provided by the application.Figure 1 As shown, the natural language and control text mixed arrangement large language model prompting method includes the following steps 110, 120 and 130.

[0040] Step 110: Obtain the target input text input by the user.

[0041] Specifically, the target input text input by the user can be obtained. The target input text can be written by the user in advance based on a preset rule.

[0042] Step 120: Based on a preset rule, identify the text type corresponding to each of at least one text block in the target input text; the preset rule is used to represent the analysis format of the target input text.

[0043] Specifically, after obtaining the target input text, the text type corresponding to each of at least one text block in the target input text can be identified based on a preset rule. It is easy to understand that the preset rule is both the writing rule when writing the target input text and the analysis format when analyzing the target input text.

[0044] In one embodiment, the text type includes target natural language text or target control text;

[0045] The identification of the text type corresponding to each of at least one text block in the target input text based on the preset rule includes:

[0046] Based on the preset rule and the font style and encoding content corresponding to the target input text, at least one text block corresponding to the target input text is determined;

[0047] For each text block, based on the preset rule and the encoding content corresponding to the text block, the text type corresponding to the text block is determined.

[0048] Specifically, at least one text block corresponding to the target input text can be determined based on preset rules and font styles and encoding content corresponding to the target input text. For example, the text including green font and the text including white font in the target input text can be determined as one text block. The text block including only white font can be determined as one text block based on the encoding content. For example, the text block including mixed green font and white font between “do” and “done” can be determined as one text block. “do / done” represents a cluster text block, and “do” and “done” can include at least one text block. For another example, in the text “read from console”, “read” is a function plug-in function name, “from” is a function plug-in parameter name, and “console” is a function plug-in parameter value. The text can obtain one output result, and thus the text “read from console” can be determined as one text block. It can be understood that in the actual target input text, “read from” is green text, and “console” is white text.

[0049] Further, the text type corresponding to the text block can be determined based on preset rules and encoding content corresponding to the text block. For example, the text type corresponding to the text block “read from console” is target control text, and the text type corresponding to the text block including only white font is target natural language text.

[0050] In addition, the present technical solution regards natural language as a basic programming element, realizes the distinction between natural language text and control text based on preset rules and encoding content corresponding to the text block, optimizes the text writing structure and paradigm of the large language model prompt program, and improves the readability and maintainability of the prompt code.

[0051] Optionally, the encoding format corresponding to the target control text can be as follows: function plug-in function name + function plug-in parameter name + function plug-in parameter value. The encoding format corresponding to the target control text can also be as follows: function plug-in function name + function plug-in parameter name + function plug-in parameter value + function plug-in parameter name + function plug-in parameter value. The encoding format corresponding to the target control text can also be a function plug-in function name and a combination of multiple function plug-in parameter names and function plug-in parameter values. For example, there is the following text: "complete prompt is How many days in a common year? stop at, or. temperature is 0.9", where "complete" is a function plug-in function name, "prompt is" is a function plug-in parameter name corresponding to "complete", "How many days in a common year?" is a function plug-in parameter value, "stop at" and "temperature is" are two function plug-in parameter names corresponding to "complete", and ", or. " and "0.9" are function plug-in parameter values. It is easy to understand that in the actual execution process, "complete", "prompt is", "stop at", "temperature is", and "or" are all of the same font style, while "How many days in a common year?" and "0.9" are of another font style. Among them, "or" represents a list, and "or" is a keyword in the encoding of the target input text, which is used to support the basic syntax structure of the target input text. The keyword also includes: "as" represents assignment, "and" represents list, ";" represents sentence break, and "do / done" represents program block.

[0052] In the above embodiment, based on the preset rule, and the font style and encoding content corresponding to the target input text, at least one text block corresponding to the target input text is determined, and then for each text block, based on the preset rule and the encoding content corresponding to the text block, the text type corresponding to the text block is determined. It can be accurately distinguished whether the text type corresponding to the text block is target natural language text or target control text, so as to ensure the updating of the context prompt text corresponding to the large language model.

[0053] Step 130: for each text block, if the text type includes target natural language text, updating the context prompt text corresponding to the large language model based on the target natural language text; if the text type includes target control text, calling the function plug-in corresponding to the target control text to update the context prompt text corresponding to the large language model.

[0054] Specifically, for each text block, if the text type includes the target natural language text, the context prompt text corresponding to the large language model can be updated based on the target natural language text, and if the text type includes the target control text, the function plug-in corresponding to the target control text is called to update the context prompt text corresponding to the large language model. It is easy to understand that the context prompt text is constantly updated, and the context prompt text can be input into the large language model each time the large language model is called to assist the large language model to realize the "memory" function, that is, to ensure the context association capability of the large language model. It is easy to understand that in the plurality of text blocks of the target input text, the text type of the text block can be the target natural language text or the target control text. It can also be that the text type of the plurality of texts includes both the target natural language text and the target control text.

[0055] In one embodiment, the calling the function plug-in corresponding to the target control text and updating the context prompt text corresponding to the large language model comprises:

[0056] Calling the function plug-in corresponding to the target control text to determine the execution result of the target control text;

[0057] Based on the execution result of the target control text, the context prompt text corresponding to the large language model is updated.

[0058] Specifically, the function plug-in corresponding to the target control text can be called to determine the execution result of the target control text. The function plug-in corresponding to the target control text includes one or more of the complete plug-in complete, the read plug-in read, the processing return plug-in set, the condition plug-in if, the condition loop plug-in while, the traversal loop plug-in for, the comparison plug-in compare, the jump out plug-in break, the skip plug-in continue, the comment plug-in comment, the selection plug-in select, the regular matching plug-in match and the meta-programming plug-in call. After determining the execution result of the target control text, the context prompt text corresponding to the large language model can be updated based on the encoding order of each text block in the target input text and the execution result. It is easy to understand that the content in the context prompt text is related to the encoding order of each text block in the target input text, for example, if the encoding order of the text block A in the target input text is before the text block B, then the content in the context prompt text is the content corresponding to the text block A first and the content corresponding to the text block B second.

[0059] In the above embodiments, the function plug-in corresponding to the target control text is called to determine the execution result of the target control text, and then the context prompt text corresponding to the large language model is updated based on the execution result of the target control text. The context prompt text can ensure the context association capability of the large language model, and since the context prompt text is dynamically controlled, the control degree of the large language model can be improved.

[0060] In one embodiment, the calling of the function plug-in corresponding to the target control text and the determination of the execution result of the target control text include:

[0061] In the case where the function plug-in corresponding to the target control text includes a calling plug-in, the large language model is called to determine a first output result based on the context prompt text and the calling plug-in.

[0062] In the case where the function plug-in corresponding to the target control text includes a non-calling plug-in, a second output result corresponding to the non-calling plug-in is determined.

[0063] Based on the first output result and / or the second output result, the execution result of the target control text is determined.

[0064] Specifically, in the case where the function plug-in corresponding to the target control text includes a calling plug-in, the large language model is called to determine a first output result based on the context prompt text and the calling plug-in. The calling plug-in can include one or more of a complete plug-in complete, a selection plug-in select, a regular matching plug-in match, and a meta-programming plug-in call.

[0065] For example, the function plug-in corresponding to the target control text includes a complete plug-in complete, and the text form of the target control text is as follows: "complete prompt is How many days in a common year?stop at, or. temperature is 0.9", wherein the function plug-in complete can call the large language model to determine a first output result based on the context prompt text and the function plug-in parameter values corresponding to the calling plug-in: "How many days in a common year?", ",", ".", and "0.9". The first output result is "The calendar year includes 365 days or 366 days".

[0066] Specifically, in the case that the function plug-in corresponding to the target control text comprises a non-call plug-in, a second output result corresponding to the non-call plug-in is determined. The non-call plug-in can comprise a read plug-in read, a processing return plug-in set, a condition plug-in if, a condition loop plug-in while, a traversal loop plug-in for, a comparison plug-in compare, a jump-out plug-in break, a skip plug-in continue and a comment plug-in comment.

[0067] The present application is described by the following examples for different non-call plug-ins corresponding to the target control text:

[0068] For the read plug-in read, the read plug-in read indicates reading an external input, and the corresponding text is, for example, "read from console". The text indicates reading the content in the "console", and the second output result is the content in the "console". The "console" indicates the data in another hardware input device console, and the "from" is the function plug-in parameter name corresponding to the read plug-in read. The "from console" indicates that the external input source is the "console".

[0069] For the processing return plug-in set, the processing return plug-in set indicates processing and returning an input parameter, and the input parameter comprises a literal or a variable.

[0070] For the condition plug-in if, the condition plug-in if is used to detect whether a condition is true, and branch execution is performed according to the condition true case. The corresponding text is, for example, "if condition true then do This statement will be executed done". The text indicates that if the condition is true, the "This statement will be executed done" is output, and the corresponding second output result is "This statement will be executed done". The "condition" is the function plug-in parameter name corresponding to the condition plug-in if, and indicates a branch condition. The "then" is another function plug-in parameter name corresponding to the condition plug-in if, and indicates a branch program block.

[0071] The `while` loop plugin checks if a condition is true and executes the loop based on that condition. For example, the text "while condition true then doexecuting loop body done" means that if the condition is true, the loop will output "executing loopbody". The second output would be "executing loop body executing loop bodyexecuting loop body ……". "condition" is the plugin parameter name corresponding to the `while` loop plugin, representing the loop condition. "then" is another plugin parameter name corresponding to the `while` loop plugin, representing the loop block.

[0072] The `for` loop plugin iterates over a list, performing a loop. For example, if the text is "for each a or b or c then do item: item done as ite", the second output would be "item: a item: b item: c". "each" is the plugin parameter name corresponding to the `for` loop plugin, representing the list to be iterated over. "then" is another plugin parameter name corresponding to the `for` loop plugin, representing the loop block.

[0073] The `compare` plugin compares the consistency of elements in a list, returning true if they match and false otherwise. For example, the text "compare value true and false as isEqual" means that the result of whether "true" and "false" match is assigned to "isEqual". Since "true" and "false" do not match, "False" is assigned to "isEqual", resulting in a second output of False. "value" is the plugin parameter name corresponding to the `compare` plugin, representing the list of elements to be compared.

[0074] The break plugin is used to exit loops.

[0075] The `continue` plugin is used to skip the current iteration and proceed to the next iteration.

[0076] The comment plugin is used to add comments.

[0077] Further, the execution result of the target control text can be determined based on the first output result and / or the second output result. It can be easily understood that in the case that the function plug-in corresponding to the target control text only includes the calling plug-in, only the first output result can be determined, and the execution result of the target control text is further determined based on the first output result. For example, the first output result can be determined as the execution result of the target control text. In the case that the function plug-in corresponding to the target control text only includes the non-calling plug-in, only the second output result can be determined, and the execution result of the target control text is further determined based on the second output result. For example, the second output result can be determined as the execution result of the target control text. In the case that the function plug-in corresponding to the target control text includes both the calling plug-in and the non-calling plug-in, both the first output result and the second output result can be determined, and the execution result of the target control text is further determined based on the first output result and the second output result. For example, the first output result and the second output result can be determined as the execution result of the target control text.

[0078] In the above embodiment, the execution result of the target control text is determined in different ways according to different function plug-ins corresponding to the target control text, so that the context prompt text corresponding to the large language model can be more accurately updated based on the target control text.

[0079] In one embodiment, the calling the large language model determines the first output result based on the context prompt text and the calling plug-in, comprising:

[0080] In the case that the calling plug-in includes a preset plug-in, the preset plug-in is used to control the large language model to generate the word probability of the output word corresponding to the context prompt text; and the first output result is determined based on the word probability of the output word.

[0081] The preset plug-in at least includes a selection plug-in and / or a regular matching plug-in.

[0082] Specifically, when a large language model is directly inputted with natural language text with a selection property such as "please help me choose between apple and banana after dinner", due to the characteristics of the large language model, the output content of the large language model does not always include only the selection result. In this case, the output content of the large language model can be "I am only a large language model and cannot make a decision for you, but I can tell you that apples have the following nutritional value: XXX, and bananas have the following nutritional value: XXX. Both apples and bananas are good fruits after dinner, and the best way is to choose according to your own physical condition". In addition, when a large language model needs to output more accurate content, it is also difficult to control the output result of the large language model through natural language input alone. Therefore, in order to enable the large language model to accurately generate a selection result or to enable the large language model to generate more accurate results, the following method can be performed.

[0083] In the case where the called plug-in includes a preset plug-in, the vocabulary probability of the output vocabulary corresponding to the updated context prompt text generated by the large language model can be controlled based on the function plug-in corresponding to the target control text. The preset plug-in at least includes a selection plug-in select and / or a regular matching plug-in match, and the preset plug-in can further include a meta-programming plug-in call. That is, the vocabulary probability of the output vocabulary of the large language model for the context prompt text can be forcibly modified through the selection plug-in select and / or the regular matching plug-in match. For example, the probability of the large language model outputting A vocabulary is 30%, the probability of generating B vocabulary is 40%, the probability of generating C vocabulary is 10%, and the probability of generating D vocabulary is 20%. In the embodiment of the present application, the vocabulary probabilities of generating A vocabulary and generating B vocabulary can be modified to 0 through the selection plug-in select, so that the output of the large language model can only be selected between C vocabulary and D vocabulary. Further, after the vocabulary probability of the output vocabulary of the large language model is controlled, the first output result outputted by the large language model can be obtained based on the vocabulary probability of the output vocabulary.

[0084] The selection plug-in select is used to modify the vocabulary probability predicted by the large language model and output a selection result. The corresponding text is, for example, "select from A or B or C", and the corresponding first output result can be "A". "from" is the function plug-in parameter name corresponding to the selection plug-in select, indicating a set of alternative texts.

[0085] The regular matching plug-in match is used to ensure that the large language model outputs results that conform to regular expressions according to modified lexical probability, and the corresponding text is, for example, “match regex (\d{3}) 555-\d{4,} with max token 14”, and the corresponding first output result can be “(189) 555-5555”. “regex” is the functional plug-in parameter name corresponding to the regular matching plug-in match, which is used to guide the large language model to output results that conform to regular expressions. “with max token” is another functional plug-in parameter name corresponding to the regular matching plug-in match, which indicates the maximum number of tokens allowed by the large language model to generate.

[0086] The meta-programming plug-in call is used to call other functional plug-ins and / or call external plug-ins, so the meta-programming plug-in call can be a calling plug-in or a non-calling plug-in, depending on the type of functional plug-in it calls. The text corresponding to the meta-programming plug-in call is, for example, “call function complete with parameter How many days in a common year? and. and 0.9 as result”, and the corresponding first output result is “A common year, also known as a non-leap year, has 365 days”. “function” is the functional plug-in parameter name corresponding to the meta-programming plug-in call, which indicates the functional plug-in function name of the called functional plug-in. In the above example, the called functional plug-in is the complete plug-in. “with parameter” is another functional plug-in parameter name corresponding to the meta-programming plug-in call, which indicates the functional plug-in parameter value corresponding to the called functional plug-in. In addition, the meta-programming plug-in call can easily prompt the large language model to automatically call external tools and complete complex interactive tasks, greatly reducing the difficulty of guiding the large language model to learn to use tools and provide correct parameters. This external tool calling method implemented through meta-programming not only simplifies the interaction process between the large language model and external tools, improves text readability and maintainability, but also meets the needs of diverse scenarios, increases the flexibility and expandability of the large language model.

[0087] In the above embodiment, in the case that the calling plug-in includes the preset plug-in, based on the preset plug-in, the large language model is controlled to generate a word probability of an output word corresponding to the context prompt text, and then based on the word probability of the output word, the first output result is determined. The first output result not only conforms to the context prompt text, but also ensures that the first output result contains accurate selection results in the case that the functional plug-in includes the selection plug-in, and ensures that the first output result contains accurate results conforming to the regular expression in the case that the functional plug-in includes the regular matching plug-in.

[0088] In one embodiment, the updating of the context prompt text corresponding to the large language model based on the target natural language text comprises:

[0089] Adding the target natural language text to the context prompt text corresponding to the large language model.

[0090] Specifically, the target natural language text can be added to the context prompt text corresponding to the large language model. It is easy to understand that the order of updating the context prompt text is determined based on the encoding order of the target input text. In the case that the natural language text is in front and the target control text is behind, the updated context prompt text corresponding to the large language model is also in the order of natural language text in front and the execution result of the target control text behind. In the case that the order of the natural language text and the target control text in the target input text is alternately interlaced, such as the encoding order of natural language text A + target control text B + natural language text C + target control text D, the updated context prompt text corresponding to the large language model is natural language text A + the execution result of target control text B + natural language text C + the execution result of target control text D. It is easy to understand that in the case that the target input text includes functional plug-ins such as traversal loop plug-in for, conditional loop plug-in while and conditional plug-in if, the encoding order in the target input text can be that the target control text A has any number of target control texts and / or target natural language texts nested therein.

[0091] The application provides a natural language and control text mixed arrangement large language model prompting method, which comprises the following steps: first, obtaining target input text input by a user; then, identifying the text type corresponding to each text block in the target input text based on a preset rule, wherein the preset rule is used to represent the analysis format of the target input text; and then, updating the context prompt text corresponding to the large language model based on the target natural language text in the case that the text type of each text block comprises target natural language text, or calling the function plug-in corresponding to the target control text in the case that the text type of each text block comprises target control text, and updating the context prompt text corresponding to the large language model. The technical scheme of the application can accurately control the output content of the large language model by identifying the text type corresponding to each text block in the target input text based on the preset rule, and then updating the context prompt text corresponding to the large language model based on the target natural language text and / or the target control text.

[0092] The natural language and control text mixed arrangement large language model prompting device provided by the application is described below, and the natural language and control text mixed arrangement large language model prompting device described below can be correspondingly referred to the natural language and control text mixed arrangement large language model prompting method described above.

[0093] Figure 2 FIG. 1 is a structural schematic diagram of the natural language and control text mixed arrangement large language model prompting device provided by the application, as shown in the figure, the natural language and control text mixed arrangement large language model prompting device 200 comprises the following acquisition module 210, identification module 220 and updating module 230. Figure 2

[0094] The acquisition module 210 is used to acquire the target input text input by the user.

[0095] The identification module 220 is used to identify the text type corresponding to each text block in the target input text based on the preset rule, wherein the preset rule is used to represent the analysis format of the target input text.

[0096] The updating module 230 is used to update the context prompt text corresponding to the large language model based on the target natural language text in the case that the text type of each text block comprises target natural language text, or call the function plug-in corresponding to the target control text in the case that the text type of each text block comprises target control text, and update the context prompt text corresponding to the large language model.

[0097] In one embodiment, the text type comprises target natural language text or target control text, and the identification module 220 is specifically used to:

[0098] ​determine at least one text block corresponding to the target input text based on the preset rule and font style and encoding content corresponding to the target input text;

[0099] For each of the text blocks, determine a text type corresponding to the text block based on the preset rule and encoding content corresponding to the text block.

[0100] In one embodiment, the updating module 230 is specifically configured to:

[0101] call a function plug-in corresponding to the target control text to determine an execution result of the target control text;

[0102] update the context prompt text corresponding to the large language model based on the execution result of the target control text.

[0103] In one embodiment, the updating module 230 is specifically further configured to:

[0104] in a case where the function plug-in corresponding to the target control text includes a calling plug-in, call the large language model to determine a first output result based on the context prompt text and the calling plug-in;

[0105] in a case where the function plug-in corresponding to the target control text includes a non-calling plug-in, determine a second output result corresponding to the non-calling plug-in;

[0106] determine the execution result of the target control text based on the first output result and / or the second output result.

[0107] In one embodiment, the updating module 230 is specifically further configured to:

[0108] in a case where the calling plug-in includes a preset plug-in, control the large language model to generate a word probability of an output word corresponding to the context prompt text based on the preset plug-in; and determine the first output result based on the word probability of the output word;

[0109] the preset plug-in at least includes a selection plug-in and / or a regular matching plug-in.

[0110] In one embodiment, the updating module 230 is specifically further configured to:

[0111] add the target natural language text to the context prompt text corresponding to the large language model.

[0112] The application provides a natural language and control text mixed arrangement large language model prompting device, which first acquires target input text input by a user, then identifies respective text types of at least one text block in the target input text based on a preset rule, and the preset rule is used to represent an analysis format of the target input text. Then, for each text block, if the text type includes target natural language text, the large language model corresponding context prompting text is updated based on the target natural language text; if the text type includes target control text, a function plug-in corresponding to the target control text is called to update the large language model corresponding context prompting text. The technical scheme of the application identifies respective text types of at least one text block in the target input text based on the preset rule, and then updates the large language model corresponding context prompting text based on the target natural language text and / or the target control text, so that the output content of the large language model can be accurately controlled.

[0113] Figure 3 An example of an entity structure diagram of an electronic device is shown in Figure 3 The electronic device can include a processor 310, a communications interface 320, a memory 330, and a communications bus 340, wherein the processor 310, the communications interface 320, and the memory 330 communicate with each other through the communications bus 340. The processor 310 can invoke a logical instruction in the memory 330 to execute a natural language and control text mixed arrangement large language model prompting method, which includes:

[0114] Acquiring target input text input by a user;

[0115] Identifying respective text types of at least one text block in the target input text based on a preset rule; the preset rule is used to represent an analysis format of the target input text;

[0116] For each text block, if the text type includes target natural language text, the large language model corresponding context prompting text is updated based on the target natural language text; if the text type includes target control text, a function plug-in corresponding to the target control text is called to update the large language model corresponding context prompting text.

[0117] In addition, the logical instructions in the memory 330 described above can be implemented in the form of a software function unit and sold or used as an independent product, and can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the parts that contribute to the prior art or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various program storage media.

[0118] In another aspect, the present application also provides a computer program product, which comprises a computer program, the computer program can be stored on a non-transitory computer readable storage medium, and the computer program can be executed by a processor to enable a computer to execute the natural language and control text mixed arrangement large language model prompting method provided by the above-mentioned method, the method comprising:

[0119] obtaining a target input text input by a user;

[0120] identifying a text type corresponding to each of at least one text block in the target input text based on a preset rule; the preset rule is used to represent the analysis format of the target input text;

[0121] for each of the text blocks, if the text type includes a target natural language text, updating the context prompt text corresponding to the large language model based on the target natural language text; if the text type includes a target control text, calling a function plug-in corresponding to the target control text to update the context prompt text corresponding to the large language model.

[0122] In another aspect, the present application also provides a non-transitory computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the natural language and control text mixed arrangement large language model prompting method provided by the above-mentioned method, the method comprising:

[0123] obtaining a target input text input by a user;

[0124] identifying a text type corresponding to each of at least one text block in the target input text based on a preset rule; the preset rule is used to represent the analysis format of the target input text;

[0125] For each of the text blocks, if the text type includes target natural language text, the context prompt text corresponding to the large language model is updated based on the target natural language text; if the text type includes target control text, the function plug-in corresponding to the target control text is called to update the context prompt text corresponding to the large language model.

[0126] The device embodiments described above are merely illustrative, wherein the units illustrated as separate components can or can not be physically separated, and the components illustrated as units can or can not be physical units, i.e., can be located in one place, or can be distributed on multiple network units. Part or all of the modules can be selected to achieve the purpose of the embodiment scheme according to actual needs. Those skilled in the art can understand and implement without creative labor.

[0127] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be realized by means of software and the necessary general hardware platform, and of course, it can also be realized by hardware. Based on such understanding, the above technical solutions can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some parts of the embodiments.

[0128] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A large language model prompting method for mixed arrangement of natural language and control text, characterized in that, The method comprises the following steps: obtaining target input text input by a user; identifying, based on a preset rule, a text type corresponding to each of at least one text block in the target input text; the preset rule is used to represent a parsing format of the target input text; for each of the text blocks, if the text type includes target natural language text, updating context prompt text corresponding to a large language model based on the target natural language text; if the text type includes target control text, calling a function plug-in corresponding to the target control text to update the context prompt text corresponding to the large language model; the text type includes the target natural language text and the target control text; the identifying, based on the preset rule, of the text type corresponding to each of the at least one text block in the target input text comprises the following steps: determining at least one text block corresponding to the target input text based on the preset rule and font style and encoded content corresponding to the target input text; for each of the text blocks, determining a text type corresponding to the text block based on the preset rule and encoded content corresponding to the text block; the calling of the function plug-in corresponding to the target control text to update the context prompt text corresponding to the large language model comprises the following steps: calling the function plug-in corresponding to the target control text to determine an execution result of the target control text; updating the context prompt text corresponding to the large language model based on the execution result of the target control text; the calling of the function plug-in corresponding to the target control text to determine the execution result of the target control text comprises the following steps: if the function plug-in corresponding to the target control text includes a calling plug-in, determining a first output result based on the context prompt text and the calling plug-in by the large language model; if the function plug-in corresponding to the target control text includes a non-calling plug-in, determining a second output result corresponding to the non-calling plug-in; determining the execution result of the target control text based on the first output result and / or the second output result.

2. The natural language and control text mixed arrangement large language model prompting method of claim 1, wherein, the calling of the large language model based on the context prompt text and the calling plug-in to determine the first output result comprises the following steps: if the calling plug-in includes a preset plug-in, controlling the large language model to generate a word probability of an output word corresponding to the context prompt text based on the preset plug-in; and determining the first output result based on the word probability of the output word; the preset plug-in at least includes a selection plug-in and / or a regular matching plug-in.

3. The natural language and control text mixed arrangement large language model prompting method according to claim 1 or 2, characterized in that, the updating of the context prompt text corresponding to the large language model based on the target natural language text comprises the following step: adding the target natural language text to the context prompt text corresponding to the large language model.

4. A large language model prompting apparatus for mixed natural language and control text layout, characterized in that, The method comprises the following steps: an obtaining module is configured to obtain target input text input by a user; an identifying module is configured to identify, based on a preset rule, a text type corresponding to each of at least one text block in the target input text; the preset rule is used to represent a parsing format of the target input text; The updating module is configured to, for each text block, update the context prompt text corresponding to the large language model based on the target natural language text if the text type includes the target natural language text; and call a function plug-in corresponding to the target control text to update the context prompt text corresponding to the large language model if the text type includes the target control text. The text type includes the target natural language text and the target control text, and the identification module is specifically configured to: determine at least one text block corresponding to the target input text based on the preset rule and the font style and the encoding content corresponding to the target input text; determine, for each text block, a text type corresponding to the text block based on the preset rule and the encoding content corresponding to the text block; The updating module is specifically configured to: call the function plug-in corresponding to the target control text to determine an execution result of the target control text; update the context prompt text corresponding to the large language model based on the execution result of the target control text; The updating module is specifically further configured to: determine a first output result based on the context prompt text and the calling plug-in of the large language model if the function plug-in corresponding to the target control text includes a calling plug-in; determine a second output result corresponding to a non-calling plug-in if the function plug-in corresponding to the target control text includes the non-calling plug-in; determine the execution result of the target control text based on the first output result and / or the second output result.

5. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the program to implement the large language model prompting method for mixed arrangement of natural language and control text according to any one of claims 1 to 3.

6. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the large language model prompting method for mixed arrangement of natural language and control text according to any one of claims 1 to 3.

7. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the large language model prompting method for mixed arrangement of natural language and control text according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Large model plug-in calling method and device, equipment and medium

    CN117112064A

  • Large model plug-in calling method and device, equipment and medium

    CN117112065A