Data link generation method and device based on large language model
By inputting the first prompt word containing the pending task, initial data and data link description into the large language model, the target data link is solved, and the problem of difficult to control the divergence and granularity of the thinking chain method of the big model is realized. More explicit processing instructions and more efficient task processing.
Patent Information
- Application Number
- CN202311559551.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-21
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2043-11-21
AI Technical Summary
When using the thinking chain method, the divergence and granularity of thinking in large language models are difficult to control, resulting in a deviation or continuous cycle of thinking. As the steps increase, the thinking chain may exceed the processing limit of the large model, resulting in the inability to continue thinking.
By entering the first prompt word into the large language model, including the pending task, initial data information and data link description, the target data link includes the processing method of the pending task, clarifying the intermediate data variables of each operation node and Operation instructions.
It realizes a complete data link solution for outputting large language models, reduces the error rate, controls the processing volume of large models, reduces the demand for large language models capabilities, and improves task scheduling and model division of labor efficiency.
Smart Images

Figure CN117592568B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the technical field of large language models, and in particular to a data link generation method, device and electronic device based on a large language model. Background Art
[0002] Prompt engineering is used to guide artificial intelligence (AI) on how to complete tasks. Thought chaining is a prompting method that prompts a large language model (also called a large model) to explain behavior. Especially when solving complex problems, the thought chain prompting paradigm enables the large language model to break down the problem step by step and take corresponding actions to solve the problem. This method is conducive to sorting out ideas, reducing errors, and improving the success rate of problem solving.
[0003] However, this "think one step, do one step" thinking chain method has many unknowns and uncertainties in execution. The user does not know what the next step of the large language model will be, and until the last moment, the user does not know how many steps the large language model needs to solve the problem, nor does he know whether the problem has been successfully solved.
[0004] When faced with complex problems or when the capabilities of the large language model are not strong enough, the thinking chain method is used. Since it is a cyclic process of "thinking-acting-observing", the divergence and granularity of thinking are difficult to control, which can easily lead to deviation and loss of direction, or endless looping in the intermediate steps, thus failing to obtain the ideal answer.
[0005] In addition, due to the limitations of the context length of the large language model itself, as the number of steps in the thinking chain increases, the steps in the thinking chain may exceed the processing limit of the large language model, causing the large model to be unable to continue thinking and subsequent thinking chain steps to be missed. Summary of the invention
[0006] The embodiment of the present invention provides a data chain generation method and device based on a large language model, which is used to solve the problem that the divergence and granularity of the thinking of the large language model are difficult to control in the prompt engineering using the thinking chain method.
[0007] In order to solve the above-mentioned technical problems, the present invention is achieved as follows:
[0008] In a first aspect, an embodiment of the present invention provides a data link generation method based on a large language model, characterized by comprising:
[0009] Determine a first prompt word according to the input information, the first prompt word including: a task to be processed, initial data information and a data link description, wherein the input information includes the task to be processed and the initial data information, and the data link description includes a processing method indication corresponding to the task to be processed;
[0010] The first prompt word is input into a large language model, and a target data chain output by the large language model is obtained, wherein the target data chain includes at least one operation node for processing the task to be processed, and each operation node includes an intermediate data variable and an operation instruction corresponding to the intermediate data variable.
[0011] In a second aspect, an embodiment of the present invention provides a data link generation device based on a large language model, comprising:
[0012] A first determination module is used to determine a first prompt word according to input information, wherein the first prompt word includes: a task to be processed, initial data information and a data link description, wherein the input information includes the task to be processed and the initial data information, and the data link description includes a processing method indication corresponding to the task to be processed;
[0013] The first input module is used to input the first prompt word into a large language model and obtain a target data chain output by the large language model, wherein the target data chain includes at least one operation node for processing the task to be processed, and each operation node includes an intermediate data variable and an operation instruction corresponding to the intermediate data variable.
[0014] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: a processor, a memory, and a program stored in the memory and executable on the processor, wherein the program, when executed by the processor, implements the steps of the data link generation method based on the large language model as described in the first aspect above.
[0015] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the data link generation method based on the large language model as described in the first aspect above are implemented.
[0016] In the embodiment of the present invention, by inputting the first prompt word into the large language model, the large language model can output a complete data chain solution idea, avoiding the situation where the steps are unknown and the task solution cannot be obtained. Each intermediate data variable in the data chain has a clear definition and processing method (i.e., operation instructions). Compared with the textual expression of the thinking chain, the execution instructions are clearer and the error rate is reduced; the processing process of the intermediate data variables is relatively independent, and the processing volume of the large language model is controllable, which reduces the demand for the large language model's capabilities, and is also conducive to task scheduling and model division of labor, increasing efficiency and reducing costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0018] Figure 1 This is a flow chart of a method for generating a data link based on a large language model according to an embodiment of the present invention;
[0019] Figure 2 A schematic diagram of a data link prompt word template for generating a first prompt word according to an embodiment of the present invention;
[0020] Figure 3 This is a flow chart of intermediate data variables according to an embodiment of the present invention;
[0021] Figure 4 The third flowchart of the data link generation method based on the large language model according to the embodiment of the present invention;
[0022] Figure 5 This is a fourth flow chart of a method for generating a data link based on a large language model according to an embodiment of the present invention;
[0023] Figure 6 It is a structural schematic diagram of a data link generation device based on a large language model according to an embodiment of the present invention;
[0024] Figure 7 Schematic diagram of the structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0026] First, the technical terms involved in the present invention are briefly explained below.
[0027] The “large language model” mentioned in the present invention refers to a large language model (LLM), which is a language model with a large parameter scale. It is designed to understand and generate human language. It is trained with a large amount of text data and can perform a wide range of tasks including text summarization, translation, sentiment analysis, etc.
[0028] The "chain of thought" (CoT) described in the present invention includes a series of intermediate reasoning steps when solving a task to be processed. Through the "chain of thought prompt", the large language model can be prompted to break down a more complex reasoning task step by step, obtain the final reasoning result step by step, and improve the ability of the large language model to perform complex reasoning.
[0029] The "data chain" described in the present invention can also be called a data-driven thinking chain method. Similar to the "thinking chain", it includes a series of intermediate reasoning steps when solving the task to be processed. Through the "data chain description (or data chain prompt)", the large language model can be prompted to decompose a more complex reasoning task step by step, obtain the final reasoning result step by step, and improve the ability of the large language model to perform complex reasoning. However, the difference between the data chain and the thinking chain is that each intermediate reasoning step is related to the data.
[0030] The data link generation method based on the large language model provided in the embodiment of the present invention is applicable to data analysis scenarios, but the embodiment of the present invention is not limited to this. Figure 1 , an embodiment of the present invention provides a data link generation method based on a large language model, comprising:
[0031] Step 1: determining a first prompt word according to input information, wherein the first prompt word includes: a task to be processed, initial data information, and a data link description, wherein the input information includes the task to be processed and the initial data information, and the data link description includes a processing method indication corresponding to the task to be processed;
[0032] In the embodiment of the present invention, the first prompt word may also be called a data link prompt word.
[0033] In the embodiment of the present invention, the task to be processed may be, for example, a problem to be solved, etc. For example, the problem to be solved is "divide restaurants into three categories: fast, normal, and slow according to delivery time, and analyze the relationship between restaurants in different delivery time categories and the average ratings of restaurants".
[0034] In the embodiment of the present invention, the initial data information is the initial data information associated with the task to be processed, and includes, for example, the data type, data size, data variable name and / or sample data of the input initial data.
[0035] In the embodiment of the present invention, the data may optionally be data in a broad sense, including at least one of the following: data of different data types such as pictures, tables, texts, and audios.
[0036] Step 2: Input the first prompt word into a large language model, and obtain a target data chain output by the large language model, wherein the target data chain includes at least one operation node for processing the task to be processed, and each operation node includes an intermediate data variable and an operation instruction corresponding to the intermediate data variable.
[0037] In the embodiment of the present invention, optionally, the operation node includes at least one of the following: the name of the intermediate data variable, the data type, the dependent data variables, the data description and the operation instruction.
[0038] The data description of the intermediate data variable may also be referred to as an explanation of the intermediate data variable.
[0039] The operation instruction corresponding to the intermediate data variable may also be described as a function or method used to determine the intermediate data variable.
[0040] In an embodiment of the present invention, by inputting the first prompt word into the large language model, the large language model can output a complete data chain solution idea, avoiding the situation where the steps are unknown and the task solution cannot be obtained. Each intermediate data variable in the data chain has a clear definition and processing method (i.e., operation instructions). The processing method based on the data chain can instruct the large model to perform task processing based on the initial data and the intermediate data variables. The execution instructions are clearer, the error rate is reduced, and the processing ability and performance of the large language model are greatly improved. Compared with the textual expression of the thinking chain, the processing method based on the data chain solves the problem that the large language model in the processing method based on the thinking chain does not focus on the data to process the task; and the processing process of the intermediate data variables in the processing method based on the data chain is relatively independent, and the processing volume of the large language model is controllable, which reduces the demand for the ability of the large language model, and is also conducive to task scheduling and model division of labor, increasing efficiency and reducing costs.
[0041] In the embodiment of the present invention, optionally, the processing method indication includes at least one of the following:
[0042] Instructing the large language model to perform a multi-step analysis on the task to be processed to generate the intermediate data variable corresponding to the task to be processed;
[0043] The large language model is instructed to process the task to be processed based on the specified initial data.
[0044] In the embodiment of the present invention, optionally, the processing method indication further includes at least one of the following:
[0045] Instruct the large language model to perform a multi-step analysis on the task to be processed, and generate a data chain flow chart corresponding to the intermediate data variable, wherein the data chain flow chart is a flow chart with the initial data as the starting point, the output result corresponding to the last operation node as the end point, and the intermediate data variable as the intermediate node;
[0046] Instructing to use a specified analysis toolkit to process the pending task;
[0047] Instruct the large language model to output at least one of the following attribute information of all intermediate data variables in a standardized format: name, data type, dependent data variables, data description, and operation instruction.
[0048] In the embodiment of the present invention, the first prompt word includes, in addition to the task to be processed, the initial data information and the data link description, optionally, also includes at least one of the following:
[0049] Background information is used to indicate the identity information of the large language model; the identity information includes, for example, the role and / or skills of the large language model. For example, the identity information of the large language model is a data analyst who is good at tools such as pandas and sklearn, etc., which is not limited in this embodiment of the present invention.
[0050] The first constraint information is used to indicate the constraint information of the large language model on the processing process of the task to be processed and / or the constraint information on the output target data chain, wherein the constraint information on the processing process of the task to be processed includes at least one of the following: only based on the initial data and intermediate data variables for analysis, each intermediate data variable is directly obtained based on the data variable it depends on, and no code is output; the constraint information on the output target data chain includes at least one of the following: the expected output format of the target data chain and the sample corresponding to the expected output format. The expected output format of the target data chain is, for example, a text format, but this is not limited in the embodiments of the present invention.
[0051] It should be noted that the first prompt word can be a combination of natural language and the above data, or a combination of pseudo code and the above data. Of course, it can also be a combination of natural language, pseudo code and the above data. Technical personnel in this field can make corresponding designs according to the specific implementation and application situation, and the embodiments of the present invention are not limited to this.
[0052] In the embodiment of the present invention, please refer to Figure 2 , a user interface can be provided, and a prompt word template (also called a data link prompt word template) can be displayed on the user interface. The user can enter relevant information for generating the first prompt word in the corresponding text box, and click the OK button to generate the first prompt word.
[0053] The following example illustrates this.
[0054] There is a dataset of takeaway scenarios (i.e. the initial data information mentioned above), including information such as city, region, restaurant name, average consumption, average rating, food type, address, delivery time, etc. We want the large language model to answer the question "divide restaurants into three categories: fast, normal, and slow according to delivery time, and analyze the relationship between restaurants in different delivery time categories and their average ratings" (i.e. the task to be processed above), and output it based on the data chain method.
[0055] According to the above-mentioned tasks to be processed, initial data information and data link description, the first prompt word is determined, and the first prompt word is input into the large language model, and the large model outputs the target data link. In some embodiments, the target data link includes multiple operation nodes. Taking the above-mentioned takeaway scenario as an example, the three operation nodes of the target data link output by the large model can be shown as follows. :
[0056] First operation node:
[0057] "name" (data variable name): "df_delivery_time_category" (delivery speed category),
[0058] "dependencies" (dependent data variables): ["df" (initial data)],
[0059] "desc" (Explanation / description of intermediate data variables): "Divide restaurants into three categories: fast, normal and slow according to delivery time",
[0060] "guide" (function / method used): "Based on the delivery time value, classify the restaurants into three categories: fast, normal, and slow. You can use the pandas cut function to bin the delivery time and then add a new column to represent the category."
[0061] Second operation node:
[0062] "name":"df_delivery_time_avg_ratings"(average rating of delivery category),
[0063] "dependencies":["df_delivery_time_category"],
[0064] "desc":"Average rating of restaurants in each delivery time category",
[0065] "guide":"Based on the delivery time categories obtained, calculate the average rating of restaurants in each category. This can be achieved using the groupby function and mean function of pandas."
[0066] The third operation node:
[0067] "name":"answer"(answer),
[0068] "dependencies":["df_delivery_time_avg_ratings"],
[0069] "desc":"Divide restaurants into three categories according to delivery time: fast, normal and slow, and analyze the relationship between restaurants in different delivery time categories and their average ratings",
[0070] "guide":"Based on the obtained data variable df_delivery_time_avg_ratings, find the average rating of restaurants in each delivery time category and analyze it."
[0071] It should be noted that the above three operation nodes are only examples. Depending on the specific implementation scenario and the specific problem to be solved, technicians in this field can obtain operation nodes with different contents. For example, each operation node may only include part of the content of guide, desc, dependencies and name, and may also include other content in addition to guide, desc, dependencies and name. The embodiment of the present invention does not limit this. The target data chain includes three operation nodes for processing the tasks to be processed, and each operation node includes intermediate data variables and operation instructions corresponding to the intermediate data variables. In other words, solving the problem of "dividing restaurants into three categories of fast, ordinary and slow according to delivery time, and analyzing the relationship between restaurants in different delivery time categories and the average ratings of restaurants" requires three steps (operation nodes).
[0072] Among them, the intermediate data variable of the first operation node is "df_delivery_time_category" (delivery speed category), and the dependent data variable (dependencies) of "df_delivery_time_category" is "df". In this embodiment, df is the initial data, and the data description is "divide restaurants into three categories: fast, ordinary and slow according to the delivery time". The operation instruction is "divide restaurants into three categories: fast, ordinary and slow according to the delivery time value. You can use the cut function of pandas to bin the delivery time, and then add a new column to represent the category.".
[0073] Among them, the intermediate data variable of the second operation node is "df_delivery_time_avg_ratings" (average rating of the delivery category), and the data variable (dependencies) on which "df_delivery_time_avg_ratings" depends is "df_delivery_time_category", which is the intermediate data variable of the first operation node. The data description is "the average rating of restaurants in each delivery time category", and the operation instruction is "based on the obtained delivery time category, calculate the average rating of restaurants in each category. This can be achieved using pandas' groupby function and mean function.".
[0074] Among them, the intermediate data variable of the third operation node is "answer", and the data variable (dependencies) on which "answer" depends is "df_delivery_time_avg_ratings", which is the intermediate data variable of the second operation node. The data description is "divide restaurants into three categories: fast, ordinary and slow according to delivery time, and analyze the relationship between restaurants in different delivery time categories and their average ratings." The operation instruction is "Based on the obtained data variable df_delivery_time_avg_ratings, find the average rating of restaurants in each delivery time category and analyze it."
[0075] Optionally, the target data chain further includes: an intermediate data variable flow chart, wherein the intermediate data variable flow chart is a flow chart that takes the initial data as the starting point, the intermediate data variable of the last operation node as the end point, and the intermediate data variables of other operation nodes except the last operation node as intermediate nodes. The intermediate data variable flow chart corresponding to the above example can be as follows Figure 3 shown.
[0076] In the embodiment of the present invention, optionally, please refer to Figure 4 , the data link generation method based on the large language model also includes:
[0077] Step 3: Generate at least one second prompt word according to the target data chain, each of the second prompt words corresponds to at least one of the intermediate data variables, and the second prompt word is used to instruct the large language model to generate the implementation code of the intermediate data variable and run the code to obtain the intermediate data variable;
[0078] In the embodiment of the present invention, the second prompt word may also be referred to as a code generation prompt word.
[0079] Step 4: Input the at least one second prompt word into the large language model, and obtain at least one intermediate output result output by the large language model, wherein the intermediate output result includes the implementation code of the intermediate data variable and the intermediate data variable obtained by running the code.
[0080] Optionally, the large language model determines the analysis process of the intermediate data variable corresponding to the second prompt word according to the second prompt word, generates an analysis process implementation code for the intermediate data variable, and runs the implementation code to obtain the value of the intermediate data variable.
[0081] In the present invention, a second prompt word is automatically generated according to a target data link, and the second prompt word is input into a large language model to obtain the implementation code of the intermediate data variable output by the large language model and the intermediate data variable obtained by running the code, so that a user can clearly understand the implementation code of the intermediate data variable of the task to be processed, the implementation process of the intermediate data variable is clearer, the error rate is reduced, and the processing process of the intermediate data variable is relatively independent. The processing volume of the large language model is controllable, which reduces the demand for the large language model capability, and is conducive to task scheduling and model division of labor, increasing efficiency and reducing costs.
[0082] Optionally, generating at least one second prompt word according to the target data link includes:
[0083] Step 31: Determine the dependent data variable in the second prompt word according to the data variable to which the intermediate data variable in the target data chain depends;
[0084] For example, for the first operation node in the above example, the dependent data variable in the second prompt word may be a small number of samples of "df". For the second operation node in the above example, the dependent data variable in the second prompt word may be a small number of samples of "df_delivery_time_category (delivery speed category)".
[0085] Step 32: According to the operation instruction of the intermediate data variable in the target data chain, determine the task description of generating the intermediate data variable in the second prompt word, and the reference method for generating the intermediate data variable.
[0086] For example, for the first operation node in the above example, the task description of generating the intermediate data variable in the second prompt word and the reference method for generating the intermediate data variable can be: Your task is to write Python code to calculate "the average rating of restaurants in each delivery time category" and save it as a new variable "df_delivery_time_avg_ratings" (average rating of delivery category). Reference suggestion: Calculate the average rating of restaurants in each category based on the delivery time category. This can be achieved using the groupby function and mean function of pandas.
[0087] Optionally, inputting the at least one second prompt word into a large language model and obtaining at least one intermediate output result output by the large language model includes:
[0088] Determining the order of the at least one second prompt word according to the order of the at least one operation node in the target data chain;
[0089] Input each second prompt word into the large language model in sequence according to the order of the at least one second prompt word to obtain at least one intermediate output result output by the large language model.
[0090] In the embodiment of the present invention, since there may be a dependency relationship between the intermediate data variables corresponding to different operation nodes in the target data chain, for example, the calculation of the intermediate data variable at the later position in the target data chain needs to depend on the value of the intermediate data variable at the earlier position, it is necessary to first calculate the intermediate data variable at the earlier position in the target data chain, and then calculate the intermediate data variable at the later position in the target data chain, so as to ensure that the calculation of each intermediate data variable can be realized. For example, the order of the first operation node is before the second operation node, and the order of the second operation node is before the third operation node, so the second prompt word corresponding to the first operation node is before the second prompt word corresponding to the second operation node, and so on, it is determined that the second prompt word corresponding to the first operation node and the second prompt word corresponding to the second operation node are successively input into the large language model to obtain the two intermediate output results described below.
[0091] Optionally, the second prompt word includes at least one of the following:
[0092] Instructing the large language model to use the initial data or intermediate data variables for analysis (i.e., dependent data variables);
[0093] Instruct the large language model to use the operation instructions of the intermediate data variables to perform code generation (ie, generate the task description and reference method of the intermediate data variables).
[0094] Optionally, the second prompt word further includes at least one of the following:
[0095] Instructing the large language model to use a specified analysis toolkit for analysis;
[0096] Background information is used to indicate the identity information of the large language model; the identity information includes, for example, the role and / or skills of the large language model. The identity information of the large language model is, for example, an AI engineer who is good at Python programming and machine learning modeling.
[0097] Second constraint information, where the second constraint information is constraint information for the code generated by the large language model.
[0098] In an embodiment of the present invention, the second prompt word may also have a corresponding template, and the template has relevant content that needs to be filled in (such as the data variables that the above-mentioned intermediate data variables depend on, the task description of the intermediate data variables, background information, second constraint information, etc.). According to the template of the second prompt word and the target data link, the second prompt word can be automatically generated.
[0099] For example, according to the order of the operation nodes in the target data chain (for example, the operation node for obtaining df_delivery_time_category is in front, and the operation node for obtaining df_delivery_time_avg_ratings is in the back in the above example), the order of the second prompt words corresponding to the operation nodes is determined, and the second prompt words are input into the large language model in sequence according to the order of the second prompt words (for example, the second prompt word corresponding to df_delivery_time_category is input first, and then the second prompt word corresponding to df_delivery_time_avg_ratings is input), and the large language model outputs an intermediate output result according to the second prompt word, and the intermediate output result includes the implementation code of the intermediate data variable and the intermediate data variable obtained by running the code.
[0100] For the first operation node in the above example, the intermediate output result of the large language model is as follows:
[0101] import pandas as pd
[0102] #Divide delivery time into three categories
[0103] df_delivery_time_category (delivery speed category) = df.copy()
[0104] df_delivery_time_category['Delivery time category']=pd.cut(df_delivery_time_category['Delivery time'],
[0105] bins=[0,30,60,float('inf')],
[0106] labels = ['fast', 'normal', 'slow'])
[0107] df_delivery_time_category.head(3)
[0108] ||ID|Area|City|Restaurant|Price|Avg ratings|Total ratings|Food type|Address|Delivery time|Delivery time category|
[0109] |---:|---:|:---|:---|:---|---:|---:|---:|---:|:---|:---|---:|:---|
[0110] |0|211|Koramangala|Bangalore|Tandoor Hut|300|4.4|100|Biryani,Chinese,North Indian,South Indian|5Th Block|59|Normal|
[0111] |1|221|Koramangala|Bangalore|Tunday Kababi|300|4.1|100|Mughlai,Lucknowi|5Th Block|56|Normal|
[0112] |2|246|Jogupalya|Bangalore|Kim Lee|650|4.4|100|Chinese|Double Road|50|Normal|
[0113] For the second operation node in the above example, the intermediate transmission result output by the large language model is as follows:
[0114] import pandas as pd
[0115] df_delivery_time_avg_ratings(Avg ratings of delivery category) = df_delivery_time_category.groupby('Delivery time category')['Avg ratings'].mean().reset_index()
[0116] df_delivery_time_avg_ratings.head(3)
[0117] ||Delivery time category|Avg ratings|
[0118] |---:|:---|---:|
[0119] |0|Fast|4.11574|
[0120] |1|Normal|3.67478|
[0121] |2|Slow|3.57562|
[0122] From the above examples, it can be seen that the large language model can output the implementation code of the intermediate data variable and the value of the intermediate data variable obtained by running the code based on the second prompt word, so that the user can clearly understand the implementation code of the intermediate data variable of the task to be processed. The implementation process of the intermediate data variable is clearer, which reduces the error rate. The processing process of the intermediate data variables is relatively independent, and the processing volume of the large language model is controllable, which reduces the demand for the capabilities of the large language model. At the same time, it is conducive to task scheduling and model division of labor, increasing efficiency and reducing costs.
[0123] It should be noted that in the above steps 3 and 4, for other operation nodes in the target data chain except the last operation node, the last operation node does not execute the above steps 3 and 4.
[0124] Optionally, refer to Figure 5 , the data link generation method based on the large language model also includes:
[0125] Step 5: generating a third prompt word according to the at least one intermediate output result, wherein the third prompt word is used to instruct the large language model to generate an analysis report for the task to be processed;
[0126] In the embodiment of the present invention, the third prompt word may also be referred to as an analysis report prompt word.
[0127] Step 6: Input the third prompt word into the large language model, and obtain an analysis report on the task to be processed output by the large language model.
[0128] In an embodiment of the present invention, a third prompt word can be automatically generated based on the intermediate output result, and the third prompt word can be input into the large language model to obtain an analysis report of the task to be processed output by the large language model, thereby obtaining the analysis result of the task to be processed. Optionally, the third prompt word includes at least one of the following:
[0129] Instructing the large language model to analyze and process the task to be processed (i.e., including the task to be processed and the target and method of the analysis report);
[0130] Instruct the large language model to process the task to be processed based on the target data chain and the intermediate output result (ie, including the target data chain and the intermediate output result).
[0131] For example, the task to be processed is "divide restaurants into three categories: fast, normal and slow according to delivery time, and analyze the relationship between restaurants in different delivery time categories and their average ratings". In the first stage: the acquired target data chain includes three operation nodes, including: the operation node corresponding to df_delivery_time_category (delivery speed category), the operation node corresponding to df_delivery_time_avg_ratings (the average rating of the delivery category), and the operation node corresponding to answer. In the second stage, the intermediate output results corresponding to df_delivery_time_category (delivery speed category) and df_delivery_time_avg_ratings (average rating of delivery category) are obtained, wherein the intermediate output result of df_delivery_time_category (delivery speed category) is to divide restaurants into three categories: fast, ordinary and slow, and the intermediate output result corresponding to df_delivery_time_avg_ratings (average rating of delivery category) is: the average rating of restaurants with fast delivery category is 4.11574, the average rating of restaurants with ordinary delivery category is 3.67478, and the average rating of restaurants with slow delivery category is 3.57562. The third prompt word may include: instructing the large language model to process the task to be processed based on the above-mentioned target data chain and the intermediate output results, so as to obtain the answer corresponding to the task to be processed: the average rating of restaurants with faster delivery time is higher, and the average rating of restaurants with slower delivery time is relatively lower. Optionally, the third prompt word also includes:
[0132] Background information is used to indicate the identity information of the large language model; the identity information includes, for example, the role and / or skills of the large language model. For example, the large language model is an analyst who is familiar with Python programming and good at language expression.
[0133] The third constraint information is constraint information for generating an analysis report of the task to be processed for the large language model, wherein the third constraint information includes at least one of the following instructions:
[0134] Instructing the large language model to use existing available data for analysis; the existing available data, for example, includes: original data and intermediate output results;
[0135] Instructing the large language model to output the analysis report using natural language;
[0136] The large language model is instructed to output an interpretation or suggestion of the analysis result.
[0137] It should be noted that, although the content of the second prompt word, the third prompt word and the first prompt word may be different, the form of the second prompt word, the third prompt word and the first prompt word may be similar, and this is not limited in the embodiment of the present invention.
[0138] For example, the analysis report of the task to be processed output by the large language model may be as follows:
[0139] Based on the available data, we have divided restaurants into three categories based on delivery time: fast, normal, and slow, and calculated the average rating of restaurants within each category.
[0140] Based on the results of the data analysis, the average ratings of restaurants within each delivery time category are as follows:
[0141] -The average rating of restaurants in the Fast category is 4.11574.
[0142] -The average rating of restaurants in the General category is 3.67478.
[0143] -The average rating of restaurants in the Slow category is 3.57562.
[0144] The above data show that restaurants with faster delivery times have higher average scores, while restaurants with slower delivery times have relatively lower average scores.
[0145] suggestion:
[0146] 1. If you care about the ratings of restaurants, you can choose restaurants with faster delivery times. This way, you can enjoy the food while minimizing the waiting time.
[0147] 2. If you don’t have any particular requirements for delivery time, and the restaurant’s rating is not a decisive factor for you, then you can choose restaurants with average or slow delivery time. This will broaden your selection and allow you to try more types of food.
[0148] Please refer to Figure 6 The embodiment of the present invention further provides a data link generation device 70 based on a large language model, comprising:
[0149] A first determination module 71 is used to determine a first prompt word according to input information, wherein the first prompt word includes: a task to be processed, initial data information and a data link description, wherein the input information includes the task to be processed and the initial data information, and the data link description includes a processing method indication corresponding to the task to be processed;
[0150] The first input module 72 is used to input the first prompt word into the large language model and obtain the target data chain output by the large language model, wherein the target data chain includes at least one operation node for processing the task to be processed, and each operation node includes an intermediate data variable and an operation instruction corresponding to the intermediate data variable.
[0151] Optionally, the processing method indicates at least one of the following:
[0152] Instruct the large language model to perform a multi-step analysis on the task to be processed to generate the intermediate data variable corresponding to the task to be processed; instruct the large language model to process the task to be processed based on the specified initial data.
[0153] Optionally, the processing method instruction further includes at least one of the following:
[0154] Instruct the large language model to perform a multi-step analysis on the task to be processed, and generate a data chain flow chart corresponding to the intermediate data variable, wherein the data chain flow chart is a flow chart with the initial data as the starting point, the output result corresponding to the last operation node as the end point, and the intermediate data variable as the intermediate node;
[0155] Instructing to use a specified analysis toolkit to process the pending task;
[0156] Instruct the large language model to output at least one of the following attribute information of all intermediate data variables in a standardized format: name, data type, dependent data variables, data description, and operation instruction.
[0157] Optionally, the first prompt word further includes at least one of the following:
[0158] Background information, used to indicate the identity information of the large language model;
[0159] The first constraint information is used to indicate the constraint information of the large language model on the processing process of the task to be processed and / or the constraint information on the output target data chain, wherein the constraint information on the processing process of the task to be processed includes at least one of the following: analysis is performed only based on initial data and intermediate data variables, each intermediate data variable is directly obtained based on its dependent data variables, and no code is output; the constraint information on the output target data chain includes at least one of the following: the expected output format of the target data chain and a sample corresponding to the expected output format.
[0160] Optionally, the operation node includes at least one of the following: the name of the intermediate data variable, the data type, the dependent data variables, the data description and the operation instruction.
[0161] Optionally, the data link generating device 70 based on the large language model further includes:
[0162] A second determination module is used to generate at least one second prompt word according to the target data link, each of the second prompt words corresponds to at least one of the intermediate data variables, and the second prompt word is used to instruct the large language model to generate an implementation code for the intermediate data variable and run the code to obtain the intermediate data variable;
[0163] The second input module is used to input the at least one second prompt word into the large language model and obtain at least one intermediate output result output by the large language model, wherein the intermediate output result includes the implementation code of the intermediate data variable and the intermediate data variable obtained by running the code.
[0164] Optionally, generating at least one second prompt word according to the target data link includes:
[0165] Determine the dependent data variable in the second prompt word according to the data variable on which the intermediate data variable in the target data chain depends;
[0166] According to the operation instruction of the intermediate data variable in the target data chain, the task description of generating the intermediate data variable in the second prompt word and the reference method for generating the intermediate data variable are determined.
[0167] Optionally, inputting the at least one second prompt word into a large language model and obtaining at least one intermediate output result output by the large language model includes:
[0168] Determining the order of the at least one second prompt word according to the order of the at least one operation node in the target data chain;
[0169] Input each second prompt word into the large language model in sequence according to the order of the at least one second prompt word to obtain at least one intermediate output result output by the large language model.
[0170] Optionally, the second prompt word includes at least one of the following:
[0171] Instructing the large language model to use the initial data or intermediate data variables for analysis;
[0172] The large language model is instructed to use the operation instructions of the intermediate data variables for code generation.
[0173] Optionally, the data link generating device 70 based on the large language model further includes:
[0174] A third determining module, configured to generate a third prompt word according to the at least one intermediate output result, wherein the third prompt word is used to instruct the large language model to generate an analysis report on the task to be processed;
[0175] The third input module is used to input the third prompt word into the large language model and obtain an analysis report on the task to be processed output by the large language model.
[0176] Optionally, the third prompt word includes at least one of the following:
[0177] Instructing the large language model to analyze and process the task to be processed;
[0178] Instruct the large language model to process the task to be processed based on the target data link and the intermediate output result.
[0179] Optionally, the third prompt word also includes:
[0180] Background information, used to indicate the identity information of the large language model;
[0181] The third constraint information is constraint information for generating an analysis report of the task to be processed for the large language model, wherein the third constraint information includes at least one of the following instructions:
[0182] Instructing the large language model to use the existing available data for analysis;
[0183] Instructing the large language model to output the analysis report using natural language;
[0184] The large language model is instructed to output an interpretation or suggestion of the analysis result.
[0185] Please refer to Figure 7The embodiment of the present invention further provides an electronic device 80, including a processor 81, a memory 82, and a computer program stored in the memory 82 and executable on the processor 81. When the computer program is executed by the processor 81, the various processes of the above-mentioned data link generation method based on the large language model are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0186] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process of the above-mentioned data link generation method embodiment based on a large language model is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0187] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0188] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0189] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
Claims
1. A data link generation method based on a large language model, characterized in that: include: Determining a first prompt word according to input information, the first prompt word including: a task to be processed, initial data information associated with the task to be processed, and a data link description, wherein the input information includes the task to be processed and the initial data information, and the data link description includes a processing method indication corresponding to the task to be processed; Inputting the first prompt word into a large language model, and obtaining a target data chain output by the large language model, wherein the target data chain includes at least one operation node for processing the task to be processed, and each operation node includes an intermediate data variable and an operation instruction corresponding to the intermediate data variable; The target data chain includes a series of intermediate reasoning steps when solving the task to be processed. The data chain description can prompt the large language model to decompose the task to be processed step by step and obtain the final reasoning result step by step. Each intermediate reasoning step is related to the data. Also includes: Generate at least one second prompt word according to the target data chain, each of the second prompt words corresponds to at least one of the intermediate data variables, and the second prompt word is used to instruct the large language model to generate implementation code of the intermediate data variable and run the code to obtain the intermediate data variable; The at least one second prompt word is input into the large language model, and at least one intermediate output result output by the large language model is obtained, wherein the intermediate output result includes an implementation code of the intermediate data variable and the intermediate data variable obtained by running the code.
2. The method according to claim 1, characterized in that The processing method indicates at least one of the following: Instruct the large language model to perform a multi-step analysis on the task to be processed to generate the intermediate data variable corresponding to the task to be processed; instruct the large language model to process the task to be processed based on the specified initial data.
3. The method according to claim 2, characterized in that The processing method instruction also includes at least one of the following: Instruct the large language model to perform a multi-step analysis on the task to be processed, and generate a data chain flow chart corresponding to the intermediate data variable, wherein the data chain flow chart is a flow chart with the initial data as the starting point, the output result corresponding to the last operation node as the end point, and the intermediate data variable as the intermediate node; Instructing to use a specified analysis toolkit to process the pending task; Instruct the large language model to output at least one of the following attribute information of all intermediate data variables in a standardized format: name, data type, dependent data variables, data description, and operation instruction.
4. The method according to claim 1, characterized in that The first prompt word also includes at least one of the following: Background information, used to indicate the identity information of the large language model; The first constraint information is used to indicate the constraint information of the large language model on the processing process of the task to be processed and / or the constraint information on the output target data chain, wherein the constraint information on the processing process of the task to be processed includes at least one of the following: analysis is performed only based on initial data and intermediate data variables, each intermediate data variable is directly obtained based on its dependent data variables, and no code is output; the constraint information on the output target data chain includes at least one of the following: the expected output format of the target data chain and a sample corresponding to the expected output format.
5. The method according to claim 1, characterized in that The operation node includes at least one of the following: the name of the intermediate data variable, the data type, the dependent data variables, the data description and the operation instruction.
6. The method according to claim 1, characterized in that Generating at least one second prompt word according to the target data link, including: Determine the dependent data variable in the second prompt word according to the data variable on which the intermediate data variable in the target data chain depends; According to the operation instruction of the intermediate data variable in the target data chain, the task description of generating the intermediate data variable in the second prompt word and the reference method for generating the intermediate data variable are determined.
7. The method according to claim 1, characterized in that The step of inputting the at least one second prompt word into the large language model and obtaining at least one intermediate output result output by the large language model includes: Determining the order of the at least one second prompt word according to the order of the at least one operation node in the target data chain; Input each second prompt word into the large language model in sequence according to the order of the at least one second prompt word to obtain at least one intermediate output result output by the large language model.
8. The method according to claim 1, characterized in that The second prompt word includes at least one of the following: Instructing the large language model to use the initial data or intermediate data variables for analysis; The large language model is instructed to use the operation instructions of the intermediate data variables for code generation.
9. The method according to any one of claims 1, 6, 7 and 8, characterized in that: Also includes: generating a third prompt word according to the at least one intermediate output result, wherein the third prompt word is used to instruct the large language model to generate an analysis report for the task to be processed; The third prompt word is input into the large language model, and an analysis report on the task to be processed output by the large language model is obtained.
10. The method according to claim 9, characterized in that The third prompt word includes at least one of the following: Instructing the large language model to analyze and process the task to be processed; Instruct the large language model to process the task to be processed based on the target data link and the intermediate output result.
11. The method according to claim 10, characterized in that The third prompt word also includes: Background information, used to indicate the identity information of the large language model; The third constraint information is constraint information for generating an analysis report of the task to be processed for the large language model, wherein the third constraint information includes at least one of the following instructions: Instructing the large language model to use the existing available data for analysis; Instructing the large language model to output the analysis report using natural language; The large language model is instructed to output an interpretation or suggestion of the analysis result.
12. A data link generation device based on a large language model, characterized in that: include: A first determination module is used to determine a first prompt word according to input information, wherein the first prompt word includes: a task to be processed, initial data information associated with the task to be processed, and a data link description, wherein the input information includes the task to be processed and the initial data information, and the data link description includes a processing method indication corresponding to the task to be processed; A first input module, used for inputting the first prompt word into a large language model, and obtaining a target data chain output by the large language model, wherein the target data chain includes at least one operation node for processing the task to be processed, and each operation node includes an intermediate data variable and an operation instruction corresponding to the intermediate data variable; The target data chain includes a series of intermediate reasoning steps when solving the task to be processed. The data chain description can prompt the large language model to decompose the task to be processed step by step and obtain the final reasoning result step by step. Each intermediate reasoning step is related to the data. The device is further used to generate at least one second prompt word according to the target data link, each of the second prompt words corresponds to at least one of the intermediate data variables, and the second prompt word is used to instruct the large language model to generate an implementation code for the intermediate data variable and run the code to obtain the intermediate data variable; The at least one second prompt word is input into the large language model, and at least one intermediate output result output by the large language model is obtained, wherein the intermediate output result includes an implementation code of the intermediate data variable and the intermediate data variable obtained by running the code.
13. An electronic device, characterized in that: include: A processor, a memory, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, the steps of the data link generation method based on a large language model as described in any one of claims 1 to 11 are implemented.
Citation Information
Patent Citations
Information recommendation method based on generative large language model and related device
CN116932733A
Chained natural language interaction method and system driven by large language model
CN116992006A