A large model-based data acquisition method and device, electronic equipment and storage medium
By constructing task description prompts and using a large model to generate Python code, the problem of requiring developer intervention to obtain data tables for users was solved, achieving convenient and efficient data acquisition.
Patent Information
- Application Number
- CN202410715353.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2044-06-04
AI Technical Summary
In existing technologies, users need to develop code to obtain data tables, which leads to low efficiency, and existing large models cannot directly generate table data that meets the requirements.
By acquiring user demand task information and tool sets, task description prompts are constructed, and Python prompts are generated using a large model. Finally, Python code for executing the task is obtained and can be directly called to generate the required tabular data.
Without requiring developers to create the data, users can easily obtain the data they need, minimizing development workload and improving data acquisition efficiency.
Smart Images

Figure CN118838584B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of large model technology, and in particular to a data acquisition method, apparatus, electronic device and storage medium based on large models. Background Technology
[0002] In the ASA business system, when users require a table in a specific data format, developers need to create code to generate the table. Executing this code generates the corresponding table, such as a simple daily user activity table. Developers need to complete the front-end and back-end code and then provide users with a download link to download the table. However, when users have new requirements, they need to contact the developers for further code development and modifications, resulting in low data retrieval efficiency and significant inconvenience for users.
[0003] Large models refer to deep learning models trained on massive amounts of text data, capable of generating natural language text or understanding its meaning. The emergence of large models has the potential to fundamentally change the way humans interact with machines and reshape the entire computing ecosystem. Currently, various generative large models have been released. However, for existing open-source large models, if the prompt directly requests the generation of data in a specific format, such as "Generate a table with headers meeting the following conditions," the large model may directly reply "Unable to generate table," or the generated table may not meet the requirements, as existing prompts cannot generate tables that meet the requirements. Summary of the Invention
[0004] To address the aforementioned problems in the prior art, this invention provides a data acquisition method, apparatus, electronic device, and storage medium based on a large model. The technical problem to be solved by this invention is achieved through the following technical solution:
[0005] The first aspect of this invention provides a data acquisition method based on a large model, comprising the following steps:
[0006] Obtain the user demand task information sent by the target scenario and the tool set and default prompt word string corresponding to the tags of the target scenario;
[0007] After parsing the default prompt word string and the user's required task information, add them together with the system prompt word string and the string of the toolset to the corresponding template string of the task case template to obtain the task description prompt word;
[0008] The steps for executing the call to the large model interface are as follows: take the task description prompt as the input to the large model, and obtain the response string and the tool call instruction string output by the large model;
[0009] Based on the reply string and the tool invocation instruction string, determine the Python prompt words to be generated;
[0010] The generated Python prompts are used as input to the large model to obtain the Python code for executing the task output by the large model.
[0011] In one embodiment of the present invention, the step of parsing the default prompt word string and the user requirement task information, and then adding them together with the system prompt word string and the string of the toolset to the corresponding template string of the task case template to obtain the task description prompt word includes:
[0012] The default prompt string and the user's task information are parsed to generate a task prompt string;
[0013] Add the system prompt string, the task prompt string, and the toolset string to the corresponding string in the task case template to obtain the task description prompt.
[0014] In one embodiment of the present invention, the template string of the task case template includes:
[0015] Your name is {ai_name}
[0016] You are {ai_role}
[0017] You must follow these instructions to complete the task: {instructions}
[0018] Your task is: {task_description}
[0019] You must adhere to the following constraints: {constraints}
[0020] You can use the following tools or commands, also known as actions: 0. FINISH: Task completed, args: None; 1. ASK: Ask a question, args: "Question to ask". Note that the args parameter in ASK should directly state the question content and not output anything else: {tools}
[0021] You need to evaluate your performance: {performance_evaluation}
[0022] Related historical records: {long_term_memory}
[0023] Current task execution log: {short_term_memory}
[0024] Output format:
[0025] First, output your thought process according to the following format: {thought_instructions}
[0026] Then, output the action / tool you chose to execute according to the following format instructions: {format_instructions};
[0027] To complete the task, you must follow the following instructions: {instructions}, adhere to the following constraints: {constraints}, evaluate your performance: {performance_evaluation}, and output the following format: First, output your thought process according to the following format: {thought_instructions}, then output the action / tool you chose to perform according to the following format: {format_instructions} is the template string corresponding to the system prompt string.
[0028] In one embodiment of the present invention, determining the Python prompt word based on the reply string and the tool invocation instruction string includes:
[0029] When the tool invocation instruction string indicates that a tool in the tool set needs to be invoked, the tool invocation result output by the tool invocation instruction of the large model is obtained, and the tool invocation result is concatenated into the response string as the response concatenation string;
[0030] Determine whether the tool to be invoked, as indicated by the tool invocation indicator string, is an end tool;
[0031] When the indicated tool to be called is the end tool, the assembly template step is executed: the reply concatenation string is used as the string of the relevant history record, and is added to the corresponding string of the generated Python case template along with the task description prompt word to obtain the generated Python prompt word;
[0032] When the tool to be invoked is not the end tool, the concatenated reply string is used as the intermediate historical thought string;
[0033] The intermediate historical thought string and the task description prompt are used as input to the large model. The step of calling the large model interface is repeated until the calling tool indication string indicates that the current tool is the end tool, and then the assembly template step is executed.
[0034] In one embodiment of the present invention, the string used to generate the Python case template includes:
[0035] Your name is {ai_name}
[0036] You are {ai_role}
[0037] Your task is to generate a set of Python code that can complete the task [{task_description}].
[0038] After the following thought process, you have completed task [{task_description}]: {short_term_memory}
[0039] Now, please provide a standard JSON based on the task and your thought process. It must be parsed by json.reads. Do not output anything else. The JSON should contain two attributes: [task result type and Python execution code type]. The task result type is determined by the type of the result obtained from the task. If the result of codeText is data, it is of type string. If the result of codeText is a file address, it is of type file.
[0040] The Python execution code (codeText) is a summary of the thought process, from task completion to execution, and the generation of a set of executable Python 3 code that can complete the task. You must adhere to the following constraints: Functions defined in the Python code should use the utility methods called during the thought process, and all utility methods are assumed to be defined already; do not redefine them. Also, please ensure that the return and input parameters of the utility methods in the code are consistent with the actual return and input parameters during the thought process. The Python code must be a string type code string executable by Python 3, and newline characters must be used correctly. \\ n All data must be obtained through tools, and structural adjustments can only be made based on the data returned by the tools. Please do not use the do_Python tool. If there are any tools or methods that do not exist in your thinking process, please define them yourself. If there are token values defined in the generated code, please use the placeholder "%-TOKEN-%" to replace the specific values. If the result generated by the Python code is a file address, please only print the file address and do not print anything else.
[0041] In one embodiment of the present invention, the method further includes:
[0042] Call the Python code to execute the task and output the data information indicating the user's required task information.
[0043] In one embodiment of the present invention, the user requirement task information includes a user requirement task string, or includes a user requirement task string and the address of a reference file;
[0044] The reference documents include documents with filled-in content.
[0045] A second aspect of the present invention provides a data acquisition device based on a large model, comprising:
[0046] The acquisition module is used to acquire user demand task information sent by the target scenario and the tool set and default prompt word string corresponding to the tags of the target scenario;
[0047] The parsing module is used to parse the default prompt word string and the user requirement task information, and then add them together with the system prompt word string and the string of the toolset to the corresponding template string of the task case template to obtain the task description prompt word;
[0048] The calling module is used to execute the steps of calling the large model interface: taking the task description prompt as input to the large model, and obtaining the response string and the calling tool instruction string output by the large model;
[0049] The determination module is used to determine the Python prompt words to be generated based on the reply string and the tool invocation instruction string;
[0050] The generation module is used to take the generated Python prompts as input to the large model and obtain the Python code for executing the task output by the large model.
[0051] A third aspect of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement a data acquisition method based on a large model provided in the first aspect of the present invention.
[0052] A fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements a data acquisition method based on a large model provided in the first aspect of the present invention.
[0053] The beneficial effects of this invention are:
[0054] This invention matches user-defined task information and tools with task case templates to obtain task description prompts. These prompts are then used as input to a large model. Based on the model's output, Python prompts are further determined and used as input to the large model. The model outputs Python code capable of generating the user's desired table. This code can then be directly invoked to obtain the required table information. This invention requires only a small amount of user-defined task information. After constructing a Prompt and inputting it into the large model, the Python code for generating the table is obtained. No development work is required. Users can obtain the Python code for generating the table based on their desired data and invoke it to generate the required data. This is extremely convenient, improves flexibility, minimizes the workload of developers, maximizes user satisfaction, and improves data acquisition efficiency.
[0055] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings.
[0056] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0057] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:
[0058] Figure 1 A flowchart illustrating a data acquisition method based on a large model, provided in an embodiment of the present invention;
[0059] Figure 2 This is a block diagram of a data acquisition device based on a large model, provided in an embodiment of the present invention. Detailed Implementation
[0060] The present invention will be further described in detail below with reference to specific embodiments, but the implementation of the present invention is not limited thereto.
[0061] like Figure 1 As shown, the first aspect of this invention provides a data acquisition method based on a large model, comprising the following steps:
[0062] Step 11: Obtain the user request task information sent by the target scenario and the tool set and default prompt word string corresponding to the target scenario's tags.
[0063] Step 12: Parse the default prompt word string and the user's task information, and add them together with the system prompt word string and the tool set string to the corresponding template string of the task case template to obtain the task description prompt word.
[0064] Step 13, execute the steps of calling the large model interface: take the task description prompt as input to the large model, and obtain the response string and the tool call instruction string output by the large model.
[0065] Step 14: Based on the response string and the tool instruction string, determine the Python prompt words to be generated.
[0066] Step 15: Use the generated Python prompts as input to the large model to obtain the Python code for executing the task output by the large model.
[0067] In this embodiment, by matching user-required task information and tools with a task case template, a task description prompt is obtained. This prompt is then used as input to a large model. Based on the output of the large model, a Python string (prompt) is generated. This generated Python string is then used as input to the large model, which outputs Python code that generates the table required by the user. This code can then be directly called to obtain the desired table information. In this embodiment, only a small amount of user-required task information is needed. After constructing a Prompt and then inputting a Prompt reconstructed by the large model, the Python code for generating the table is obtained. Without requiring development by developers, users can obtain the Python code for generating the table based on the required data and call the code to generate the necessary data. This is extremely convenient, minimizing the workload of developers and maximizing the fulfillment of user needs.
[0068] A second aspect of this invention provides a data acquisition method based on a large model, comprising the following steps:
[0069] Step 21: Obtain the user demand task information sent by the target scenario and the tool set and default prompt word string corresponding to the target scenario's tags.
[0070] In this step, the corresponding toolset and default prompt word string can be obtained based on the tags of the target scenario. For example, the target scenario could be smart subscription, which has functions such as statistical filtering and calculation of user-delivered advertising data (impressions, clicks, downloads, click-through rate, etc.).
[0071] In one feasible implementation, the default prompt string includes, but is not limited to, Token="{0}", Timezone="{1}", Unitmark="{2}", etc., and the user requirement task information includes: the user requirement task string. For example, the user requirement task string includes, but is not limited to, account ID as "{3}", application ID as "{4}", dataset as "{5}", dimension as "{6}", and report granularity as "{7}". These strings can be considered as the constraints of the task. The content within the curly braces "{}" in the user requirement task information is filled in by the user in the target scenario on the front end according to their needs, while the content within the curly braces "{}" in the default prompt string is automatically obtained based on the target scenario's tags. Token represents the scenario identifier.
[0072] In one feasible implementation, the user requirement task information includes: the aforementioned user requirement task string and the address of a reference file; the reference file includes an Excel or TXT file containing example content. The reference file contains fields and data as reference examples; for example, if the reference file is an Excel file, it may contain multiple fields such as date, ad name, impressions, clicks, downloads, and click-through rate, with each field corresponding to a specific piece of data.
[0073] In this step, the toolset includes multiple tools. The purpose of these tools is to retrieve data that meets the requirements from the target database, and they may also include functions for further data processing.
[0074] In this step, when a user fills in the user's task information and uploads and saves the reference file in the target scenario of the smart subscription, the target scenario's tags are automatically obtained. The smart subscription sends the user's task information, the target scenario's tags, and the reference file address to the smart service. The smart service uses the target scenario's tags and a predefined tool dictionary (each tool in the backend system corresponds to a scenario it can use) to obtain the set of tools that might be used in that target scenario. The tags also allow the acquisition of default prompt words.
[0075] Step 22: Parse the default prompt word string and the user's task information, and add them together with the system prompt word string and the tool set string to the corresponding template string of the task case template to obtain the task description prompt word.
[0076] Step 22 includes steps 221-222:
[0077] Step 221: Parse the default prompt string and the user's task information to generate a task prompt string.
[0078] In this step, the parsing of the default prompt string and the user-required task string involves assembling the strings to obtain the task prompt string (i.e., the Prompt). For example, please query an Excel file under the constraints of Token = "{0}", Timezone = "{1}", Unitmark = "{2}", Account ID = "{3}", Application ID = "{4}", Dataset = "{5}", Dimension = "{6}", and Report granularity = "{7}".
[0079] The reference file's address is parsed to obtain the reference file, and its content is further parsed to obtain specific fields. For example, the parsed Excel file contains fields such as date, ad name, impressions, clicks, downloads, and click-through rate. The TXT file contains fields A, B, C, and D.
[0080] When the user task information includes a user task string and a reference file address, the reference file address is parsed to obtain the reference file. Then, the parsed string of the reference file, the default prompt word string, and the user task string are assembled to obtain the task prompt word string, which includes the corresponding "Please refer to the parsed reference file" content. For example, please query an Excel file under the constraints of Token="{0}", Timezone="{1}", Unitmark="{2}", Account ID is "{3}", Application ID is "{4}", Dataset is "{5}", Dimension is "{6}", and Report granularity is "{7}", and please refer to the file. The Excel file contains fields for date, ad name, impressions, clicks, downloads, and click-through rate.
[0081] Step 222: Add the system prompt string, task prompt string, and toolset string to the corresponding string in the task case template to obtain the task description prompt.
[0082] In this step, the system prompt string is a string of preset rules and configurations, such as ai_name, instructions, constraints, etc.
[0083] Specifically, the template string for the task case template includes:
[0084] Your name is {ai_name}, and you are {ai_role}.
[0085] You must follow these instructions to complete the task:
[0086] {instructions}
[0087] Your task is:
[0088] {task_description}
[0089] You must comply with the following constraints:
[0090] {constraints}
[0091] You can use the following tools or instructions, also known as actions:
[0092] 0.FINISH: Task completed, args: None
[0093] 1. ASK: Ask a question, args: "the question asked". Note that the args parameter in ASK should directly contain the question content and not output anything else.
[0094] {tools}
[0095] You need to evaluate your performance:
[0096] {performance_evaluation}
[0097] Relevant historical records:
[0098] {long_term_memory}
[0099] Current task execution log:
[0100] {short_term_memory}
[0101] Output format:
[0102] (1) First, output your thought process according to the following format instructions:
[0103] {thought_instructions}
[0104] (2) Then, output the action / tool you selected to perform, according to the following format instructions:
[0105] {format_instructions};
[0106] Here, your name is {ai_name}, you are {ai_role}, you must follow the following instructions to complete the task: {instructions}, you must follow the following constraints: {constraints}, you need to evaluate your performance: {performance_evaluation}, and the output format: First, output your thought process according to the following format instructions: {thought_instructions}, then output the action / tool you chose to perform according to the following format instructions: {format_instructions} is the template string corresponding to the system prompt word string.
[0107] For example, the task description prompt obtained is:
[0108] Your name is {Xiaoming}, and you are {AI Assistant}.
[0109] You must follow these instructions to complete the task:
[0110] 1. Use only one tool or one instruction for each decision.
[0111] 2. Ensure that the command you invoke or the tool you use is in the list of tools given below.
[0112] 3. Ensure your answers do not contain illegal or offensive information.
[0113] 4. If you have completed all tasks, be sure to end with the "FINISH" command.
[0114] 5. Think and output in Chinese.
[0115] 6. If you encounter any uncertainties about the task during your thinking process, you must use the "ASK" tool to ask questions.
[0116] 7. If the task is unclear, you must use the "ASK" tool to ask questions.
[0117] 8. If you encounter any ambiguities or parameter errors while using the tool, please think about them based on the tool description and the information provided. Do not use the "ASK" tool to ask questions.
[0118] 9. If a token is required, the token string passed to the tool must match the provided string.
[0119] Your task is:
[0120] {Please provide an Excel file with the following constraints: Token = "{0}", Timezone = "{1}", Unitmark = "{2}", Account ID = "{3}", Application ID = "{4}", Dataset = "{5}", Dimension = "{6}", and Report Granularity = "{7}". Please refer to the file containing fields for Date, Ad Name, Impressions, Clicks, Downloads, and Click-Through Rate.}
[0121] You must comply with the following constraints:
[0122] 1. If executing a command or tool fails, try changing the parameters or parameter format and calling it again.
[0123] 2. Your response must adhere to the factual information given above. Fabricated information is not permitted.
[0124] DO NOT MAKE UPINFORMATION.
[0125] 3. If the result is incorrect, try changing the way it is expressed.
[0126] 4. Do not repeatedly look up information that you already have.
[0127] 5. Ensure that the actions you generate are precisely executable. An action can include a specific method and a target output.
[0128] 6. When you encounter a concept, try to obtain its precise definition and analyze from which inputs you can derive its specific values. If you are still unsure after analysis, please use the "ASK" command to ask a question.
[0129] 7. When generating a natural language query, please include all known information in the query.
[0130] 8. Before performing an analysis or calculation, ensure that all sub-concepts involved in the analysis or calculation have been defined.
[0131] 9. You cannot print the entire contents of a document. This operation is too costly and could have unpredictable consequences, so it is strictly prohibited.
[0132] 10. No data can be calculated by yourself; all data must be obtained from tools, and structural adjustments can only be made based on the data returned by the tools.
[0133] 11. When using the tool, please strictly follow the parameter rules required in the tool's description to pass values.
[0134] 12. Please reflect on any unclear points regarding the use of the tools yourself; do not use the "ASK" tool to ask questions.
[0135] You can use the following tools or instructions, also known as actions:
[0136] 0.FINISH: Task completed, args: None
[0137] 1. ASK: Ask a question, args: "the question asked". Note that the args parameter in ASK should directly contain the question content and not output anything else.
[0138] {1. Tool 1 2. Tool 2 3. Tool 3 4. Tool 4}
[0139] You need to evaluate your performance:
[0140] 1. Do your best, use your highest level of expertise, and make the best decision through analysis and examination.
[0141] 2. With a holistic perspective, reflect on your plans and actions.
[0142] 3. Consider your previous strategies and decisions to improve your plan.
[0143] 4. If you repeatedly get the same results, modify your plans and decisions to avoid a vicious cycle. 5. If your current actions are not yielding the necessary information, try expanding on the definition of key concepts and then reasoning again.
[0144] 6. Ensure that when you analyze a key concept, you already know its criteria. Otherwise, try using tools to determine the criteria first.
[0145] Relevant historical records:
[0146] {long_term_memory}
[0147] Current task execution log:
[0148] {short_term_memory}
[0149] Output format:
[0150] (1) First, output your thought process according to the following format instructions:
[0151] Key concepts: Composite concepts or entities involved in the task. For key concepts whose values have been clearly determined, their full values should be noted after the concept.
[0152] Concept decomposition: Break down the key concepts in the task into a series of sub-elements to be queried. Each key concept is on a separate line, followed by the sub-elements of that concept, each on a separate line, with each sub-element starting with a "-".
[0153] Reflection:
[0154] Self-reflection, observing past execution records, and considering whether the concept breakdown was complete and accurate.
[0155] Step by step, consider whether the query for each key concept or element yielded accurate results.
[0156] Reflect on which elements / concepts you have already obtained. Are the values of the elements / concepts you obtained correct? What elements / concepts cannot be obtained from the current information?
[0157] Each reflection line should begin with a "-".
[0158] Reflection: Observe the execution records and your self-reflection, and think about it step by step.
[0159] (1) Analyze the dependencies between elements, for example:
[0160] i. Do I need to obtain the value / definition of A before I can obtain B through A?
[0161] ii. If I obtain A first, can I filter B through A to reduce the cost of exhaustively enumerating every B?
[0162] iii. Do A and B exist in the same data source? Can I retrieve B at the same time as retrieving A?
[0163] iv. Are there any more efficient or smarter ways to query a concept or element?
[0164] v. If my last attempt to query a concept or element failed, can I try querying it again from another resource?
[0165] vi. And so on, you can expand your thinking further…
[0166] (2) Based on the above analysis, the query priority among the sub-elements is arranged.
[0167] (3) Identify the sub-elements for which values need to be obtained.
[0168] (4) If you are unsure about something during the thinking process, you can use the ASK action to ask a question. You can only ask one question at a time, but you can ask multiple questions.
[0169] Note that you should not make any assumptions about the values / definitions of elements, and ensure that your information comes from the given data source!
[0170] Reasoning: Based on your reflection and thought, reason step by step about how the values of the selected sub-elements are obtained. If the previous plan failed, check whether the input contains a clear definition of each concept / element, and try to refine your query description.
[0171] Planning: Strictly adhere to the following rules when planning your current actions.
[0172] (1) List the execution plan for the current action in detail. Plan only one step at a time.
[0173] STEP ONLY!
[0174] (2) Analyze step by step, including the data source, the operation method of the data source, and the data analysis method. What known constants can be directly substituted into this analysis?
[0175] (3) Do not attempt to calculate every element of the file. This is too costly and strictly prohibited. You can find more efficient methods through analysis, such as conditional filtering.
[0176] (4) Does the above analysis depend on the value / definition of a certain element, and has the value / definition of that element not yet been obtained? If so, replan the current action to ensure that the values / definitions of all dependent elements have been obtained.
[0177] (5) Do not make any assumptions about the values / definitions of elements. Ensure your information comes from the given data source. Do not fabricate information!
[0178] (6) Ensure that all elements involved in the action you are performing have been given precise values / defined.
[0179] (7) If all subtasks have been completed, please end the task with the FINISH action.
[0180] }
[0181] (2) Then, output the action / tool you selected to perform, according to the following format instructions:
[0182] {Output in standard JSON format}
[0183] In this embodiment, the intelligent service parses the default prompt word string and the user's required task information to obtain the task prompt word string. The system prompt word string, the task prompt word string, and the string of the toolset are then filled into the task case template to generate the task description prompt.
[0184] Step 23, execute the steps of calling the large model interface: take the task description prompt as input to the large model, and obtain the response string and tool call instruction string output by the large model.
[0185] Step 24: Based on the response string and the tool instruction string, determine the Python prompt words to be generated.
[0186] In this embodiment, in steps 23 and 24, the large model receives the first complete Prompt, considers it, receives a response, and then calls the large model again until the result is obtained and the Python prompt is generated. The specific steps of step 24 include: steps 240-247:
[0187] Step 240: Determine whether the tool invocation instruction string indicates whether a tool in the tool set needs to be invoked.
[0188] Step 241: When the tool instruction string indicates that a tool in the tool set needs to be invoked, obtain the tool invocation result output by the tool indicated by the large model invocation, append the tool invocation result to the response string as the response concatenation string, and then execute step 243.
[0189] Step 242: When the tool instruction string indicates that it is not necessary to invoke a tool in the tool set, proceed to step 243.
[0190] Step 243: Determine whether the tool to be invoked indicated by the tool invocation instruction string is the end tool.
[0191] Step 244: When the tool invocation indicator string indicates that the tool to be invoked is the end tool, proceed to step 245.
[0192] Step 245, Template Assembly Step: Use the concatenated reply string as the relevant history string, and add it along with the task description prompt to the corresponding string in the generated Python case template to obtain the generated Python prompt.
[0193] The strings used to generate Python example templates include:
[0194] Your name is {ai_name}, and you are {ai_role}.
[0195] Your task is:
[0196] Generate a set of Python code that can complete the task [{task_description}].
[0197] After the following thought process, you have completed task [{task_description}]:
[0198] {short_term_memory}
[0199] Now, please provide a standard JSON object based on the task and your thought process. This object must be parsed by json.reads. Do not output anything else. The JSON object should contain two attributes: [task result (resultType)] and [Python execution code (codeText)].
[0200] The task result (resultType) is determined by the type of the result obtained from the task. If the result of (codeText) is data, it is a string type; if the result of codeText is a file address, it is a file.
[0201] type.
[0202] The Python executable code (codeText) is a summary of the thought process, the workflow from task completion to execution tools, generating a set of executable Python 3 code that can complete the task. You must adhere to the following constraints:
[0203] 1. In the Python code, please use the utility methods called during the thinking process to define functions. It is assumed that all utility methods have been defined and should not be defined again. Also, please note that the return and input parameters of the utility in the code are consistent with the return and input parameters of the actual utility during the thinking process.
[0204] 2. The Python code must be a string that can be executed by Python 3.
[0205] And the newline character must be used. \\ n .
[0206] 3. No data can be calculated by yourself; all data must be obtained through tools, and structural adjustments can only be made based on the data returned by the tools.
[0207] 4. Please do not use these tools (do_Python).
[0208] 5. If any tools or methods are not present in the thought process, please define and use them yourself.
[0209] 6. If there is a token value definition in the generated code, please use the placeholder "%-TOKEN-%" uniformly.
[0210] Replace a specific value.
[0211] 7. If the result generated by the Python code is a file address, please only print the file address and do not print the rest.
[0212] For example:
[0213] {data_json}
[0214] In this step, the task description prompt is filled into {task_description}, the relevant history string is filled into {short_term_memory}, a Python prompt is generated, and then step 25 is executed.
[0215] Step 246: When the tool to be invoked is not the end tool, use the reply concatenation string as the intermediate history thought string.
[0216] Step 247: Take the intermediate historical thought string and task description prompt as input to the large model, and repeat steps 23, 240-243, and 246-247 until the tool instruction string indicates that the current tool is the end tool, and then execute step 245.
[0217] Step 25: Use the generated Python prompts as input to the large model to obtain the Python code for executing the task output by the large model.
[0218] In this step, after obtaining the generated Python prompt words, we continue to input the large model to obtain the Python code for executing the task.
[0219] In this embodiment, after the task description prompts are used and the large model outputs a response to complete the task, the large model can then generate the Python code to execute the task. The Python code instructs the use of tools from the toolset to generate the forms required by the user.
[0220] Step 26: Call the Python code to execute the task and output the data information indicating the user's required task information. In this step, the Python code to execute the task is saved. The front end can preview or download the forms required by the user by directly calling the Python code from the back end.
[0221] For example, the output form required by the user is in the form of Table 1 below:
[0222]
[0223] Table 1
[0224] In this embodiment, only a small amount of task information needs to be input by the user. After constructing a Prompt and inputting the Prompt, which is then reconstructed from the large model, into the large model, the Python code for generating the table is obtained. No development work is required. Users can obtain the Python code for generating the table of the required data and call the code to generate the required data. It is very convenient to use, minimizes the workload of developers, and meets the needs of users to the greatest extent.
[0225] like Figure 2 As shown, a third aspect of the present invention provides a data acquisition device based on a large model, comprising:
[0226] The acquisition module 31 is used to acquire the user demand task information sent by the target scenario and the tool set and default prompt word string corresponding to the tags of the target scenario;
[0227] Parsing module 32 is used to parse the default prompt word string and user requirement task information, and then add them together with the system prompt word string and the tool set string to the corresponding template string of the task case template to obtain the task description prompt word;
[0228] Module 33 is called to execute the steps of calling the large model interface: taking the task description prompt as input to the large model, and obtaining the response string and the tool call instruction string output by the large model;
[0229] Module 34 is used to determine the Python prompt words to be generated based on the reply string and the tool instruction string.
[0230] Module 35 is used to take the generated Python prompts as input to the large model and obtain the Python code for executing the task output by the large model.
[0231] In one embodiment of the present invention, the default prompt word string and user requirement task information are parsed and then added together with the system prompt word string and the tool set string to the corresponding template string of the task case template to obtain the task description prompt word, including:
[0232] Parse the default prompt string and user-required task information to generate a task prompt string;
[0233] Add the system prompt string, task prompt string, and toolset string to the corresponding string in the task case template to obtain the task description prompt.
[0234] In one embodiment of the present invention, the template string of the task case template includes:
[0235] Your name is {ai_name}, you are {ai_role}, you must follow the following instructions to complete the task: {instructions}, your task is: {task_description}, you must follow the following constraints: {constraints}, you can use the following tools or instructions, also known as actions: 0. FINISH: Task completed, args: None, ASK: Ask a question, args: "Question to ask", note that the args parameter in ASK should directly state the question content and not output anything else: {tools}, you need to evaluate your performance: {performance_evaluation}, relevant history: {long_term_memory}, current task execution record: {short_term_memory}, output format:
[0236] First, output your thought process according to the following format: {thought_instructions}.
[0237] Then, output the action / tool you chose to execute according to the following format instructions: {format_instructions};
[0238] To complete the task, you must follow the following instructions: {instructions}, adhere to the following constraints: {constraints}, evaluate your performance: {performance_evaluation}, and output the following format: First, output your thought process according to the following format: {thought_instructions}, then output the action / tool you chose to perform according to the following format: {format_instructions} is the template string corresponding to the system prompt string.
[0239] In one embodiment of the present invention, determining the generation of Python prompt words based on the reply string and the tool invocation instruction string includes:
[0240] When the tool instruction string indicates that a tool in the toolset needs to be invoked, the tool invocation result output by the tool invocation instruction of the large model is obtained, and the tool invocation result is appended to the response string as the response concatenation string;
[0241] Determine whether the tool to be invoked, as indicated by the tool invocation instruction string, is an end-of-life tool;
[0242] When the tool to be invoked is the end tool, execute the assembly template step: use the reply concatenation string as the relevant history string, and add it along with the task description prompt to the corresponding string of the generated Python case template to obtain the generated Python prompt;
[0243] When the tool to be invoked is not the end tool, the reply concatenation string will be used as the intermediate history thought string;
[0244] Using the intermediate historical thought string and task description prompts as input to the large model, the process of calling the large model interface is repeated until the tool instruction string indicates that the current tool is the final tool, at which point the template assembly step is executed.
[0245] In one embodiment of the present invention, the string used to generate the Python case template includes:
[0246] Your name is {ai_name}, you are {ai_role}, and your task is to generate a set of Python code that can complete the task [{task_description}]. After the following thought process, you have completed the task [{task_description}]: {short_term_memory}. Now, please provide a standard JSON based on the task and your thought process, which must be parsed by json.ioads. Do not output anything else. The JSON contains two attributes: [task result resultType and Python execution code codeText]. The task result resultType is based on the type of the result obtained from the task. If the result of codeText is data, it is of type string; if the result of codeText is a file address, it is of type file.
[0247] The Python execution code (codeText) is a summary of the thought process, from task completion to execution, and the generation of a set of executable Python 3 code that can complete the task. You must adhere to the following constraints: Functions defined in the Python code should use the utility methods called during the thought process, and all utility methods are assumed to be defined already; do not redefine them. Also, please ensure that the return and input parameters of the utility methods in the code are consistent with the actual return and input parameters during the thought process. The Python code must be a string type code string executable by Python 3, and newline characters must be used correctly. \\ nAll data must be obtained through tools, and structural adjustments can only be made based on the data returned by the tools. Please do not use the do_Python tool. If there are any tools or methods that do not exist in your thinking process, please define them yourself. If there are token values defined in the generated code, please use the placeholder "%-TOKEN-%" to replace the specific values. If the result generated by the Python code is a file address, please only print the file address and do not print anything else.
[0248] In one embodiment of the present invention, an execution module is further included, which is used to call the Python code for executing the task and output data information indicating the user's required task information.
[0249] In one embodiment of the present invention, the user request task information includes a user request task string, or includes a user request task string and the address of a reference file;
[0250] The reference documents include completed documents.
[0251] A fourth aspect of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement a data acquisition method based on a large model provided in the above embodiments of the present invention.
[0252] A fifth aspect of the present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the data acquisition method based on a large model provided in the above embodiments of the present invention.
[0253] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0254] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0255] The method provided in this invention can be applied to electronic devices. Specifically, the electronic device can be a desktop computer, a portable computer, a smart mobile terminal, a server, etc. No limitation is made herein; any electronic device that can implement this invention falls within the protection scope of this invention.
[0256] For the device / electronic device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and relevant parts can be referred to in the description of the method embodiments.
[0257] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0258] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0259] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0260] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A data acquisition method based on a large model, characterized in that, Includes the following steps: Obtain the user demand task information sent by the target scenario and the tool set and default prompt word string corresponding to the tags of the target scenario; After parsing the default prompt word string and the user's required task information, add them together with the system prompt word string and the string of the toolset to the corresponding template string of the task case template to obtain the task description prompt word; The steps for executing the call to the large model interface are as follows: take the task description prompt as the input to the large model, and obtain the response string and the tool call instruction string output by the large model; Based on the response string and the tool invocation instruction string, determine the Python prompt words to generate, including: When the tool invocation instruction string indicates that a tool in the tool set needs to be invoked, the tool invocation result output by the tool invocation instruction of the large model is obtained, and the tool invocation result is concatenated into the response string as the response concatenation string; Determine whether the tool to be invoked, as indicated by the tool invocation indicator string, is an end tool; When the indicated tool to be called is the end tool, the assembly template step is executed: the reply concatenation string is used as the string of the relevant history record, and is added to the corresponding string of the generated Python case template along with the task description prompt word to obtain the generated Python prompt word; When the tool to be invoked is not the end tool, the concatenated reply string is used as the intermediate historical thought string; The intermediate historical thought string and the task description prompt are used as input to the large model. The step of calling the large model interface is repeated until the calling tool indication string indicates that the current tool is the end tool, and then the assembly template step is executed. The generated Python prompts are used as input to the large model to obtain the Python code for executing the task output by the large model.
2. The method as described in claim 1, characterized in that, The step of parsing the default prompt word string and the user's task requirement information, and then adding them together with the system prompt word string and the string of the toolset to the corresponding template string of the task case template, yields the task description prompt word, including: The default prompt string and the user's task information are parsed to generate a task prompt string; Add the system prompt string, the task prompt string, and the toolset string to the corresponding string in the task case template to obtain the task description prompt.
3. The method as described in claim 2, characterized in that, The template string for the task case template includes: Your name is {ai_name}, you are {ai_role}, you must follow the following instructions to complete the task: {instructions}, your task is: {task_description}, you must follow the following constraints: {constraints}, you can use the following tools or instructions, also known as actions: FINISH: task completed, args: None, ASK: ask a question, args: "question to be asked", note that the args parameter in ASK should directly state the question content and not output anything else: {tools}, you need to evaluate your performance: {performance_evaluation}, relevant history: {long_term_memory}, current task execution record: {short_term_memory}, output format: First, output your thought process according to the following format: {thought_instructions}. Then, output the action / tool you chose to execute according to the following format instructions: {format_instructions}; To complete the task, you must follow the following instructions: {instructions}, adhere to the following constraints: {constraints}, evaluate your performance: {performance_evaluation}, and output the following format: First, output your thought process according to the following format: {thought_instructions}, then output the action / tool you chose to perform according to the following format: {format_instructions} is the template string corresponding to the system prompt string.
4. The method as described in claim 1, characterized in that, The string used to generate the Python example template includes: Your name is {ai_name}, you are {ai_role}, and your task is to generate a set of Python code that can complete the task {task_description}. After the following thought process, you have completed the task {task_description}: {short_term_memory}. Now, please provide a standard JSON based on the task and your thought process, which must be parsed by json.ioads. Do not output anything else. The JSON contains two attributes: task result resultType and Python execution code codeText. The task result resultType is based on the type of the result obtained from the task. If the result of codeText is data, it is of type string; if the result of codeText is a file address, it is of type file. The Python execution code (codeText) is a summary of the thought process, from task completion to execution, and the generation of a set of executable Python 3 code that can complete the task. You must adhere to the following constraints: Functions defined in the Python code should use the utility methods called during the thought process, and all utility methods are assumed to be defined already; do not redefine them. Also, ensure that the parameters returned and passed to the utility in the code are consistent with the actual return and input parameters during the thought process. The Python code must be a string type that can be executed by Python 3, and newline characters must be used with backslashes (\). \n All data must be obtained through tools, and structural adjustments can only be made based on the data returned by the tools. Please do not use the do_Python tool. If there are any tools or methods that do not exist in your thinking process, please define them yourself. If there are token values defined in the generated code, please use the placeholder "%-TOKEN-%" to replace the specific values. If the result generated by the Python code is a file address, please only print the file address and do not print anything else.
5. The method as described in claim 1, characterized in that, The method further includes: Call the Python code to execute the task and output the data information indicating the user's required task information.
6. The method as described in claim 2, characterized in that, The user requirement task information includes a user requirement task string, or includes a user requirement task string and the address of a reference file; The reference documents include documents with filled-in content.
7. A data acquisition device based on a large model, characterized in that, include: The acquisition module is used to acquire user demand task information sent by the target scenario and the tool set and default prompt word string corresponding to the tags of the target scenario; The parsing module is used to parse the default prompt word string and the user requirement task information, and then add them together with the system prompt word string and the string of the toolset to the corresponding template string of the task case template to obtain the task description prompt word; The calling module is used to execute the steps of calling the large model interface: taking the task description prompt as input to the large model, and obtaining the response string and the calling tool instruction string output by the large model; The determination module is used to determine the Python prompt words to be generated based on the reply string and the tool invocation instruction string, including: When the tool invocation instruction string indicates that a tool in the tool set needs to be invoked, the tool invocation result output by the tool invocation instruction of the large model is obtained, and the tool invocation result is concatenated into the response string as the response concatenation string; Determine whether the tool to be invoked, as indicated by the tool invocation indicator string, is an end tool; When the indicated tool to be called is the end tool, the assembly template step is executed: the reply concatenation string is used as the string of the relevant history record, and is added to the corresponding string of the generated Python case template along with the task description prompt word to obtain the generated Python prompt word; When the tool to be invoked is not the end tool, the concatenated reply string is used as the intermediate historical thought string; The intermediate historical thought string and the task description prompt are used as input to the large model. The step of calling the large model interface is repeated until the calling tool indication string indicates that the current tool is the end tool, and then the assembly template step is executed. The generation module is used to take the generated Python prompts as input to the large model and obtain the Python code for executing the task output by the large model.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the data acquisition method based on a large model as described in any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the data acquisition method based on a large model as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Intelligent low-code page development system and method
CN117331561A
Visual programming method based on large language model, medium, device and equipment
CN117667054A