Data processing method and device based on large language model
By independently configuring the data processing unit for each function, and pre-processing of input parameters and verification of output results during the processing of large language model, the problem of high maintenance costs during data processing of large language model is solved, and low cost and high efficiency are achieved program maintenance and iterative repair.
Patent Information
- Application Number
- CN202411120585.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-15
- Publication Date
- 2024-12-20
AI Technical Summary
When using multiple large language models for data processing, program maintenance costs are high, especially when it is necessary to iteratively repair or modify the program logical structure, which affects multiple functions, resulting in high retrieval and modification and high maintenance costs.
For each function, the input parameter entry unit, the prompt word generation unit and the large language model interface calling unit are independently configured. By preprocessing the input parameters, generating and verifying the output results, independent data processing for the target function is realized, and if necessary Re-call the large language model to ensure the accuracy and format consistency of the output results.
It reduces the maintenance cost when program logic structure changes, reduces the correlation between different functions, improves the difficulty and efficiency of iterative repair, allows only independent software units to be modified, and reduces the overall maintenance cost.
Smart Images

Figure CN119168084A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a data processing method and device based on a large language model. Background Art
[0002] In specific application projects, it may be necessary to make a large number of generative large language model interface calls and use multiple large language models to implement different data processing functions. For example, daily conversations with a large language model, using a large language model to extract and summarize key data, etc. Each function involves a complex data processing flow, and different functions require different programs to implement. When an application project has many functions and a large amount of programs, if there is a need for iterative repair of the program, it is difficult to retrieve the program that needs iterative repair. If changes are involved in the logical structure of the program, it will affect the functions of most functions, and each function needs to be modified, and the cost of program maintenance is high. Summary of the invention
[0003] The purpose of the embodiment of the present invention is to provide a data processing method and device based on a large language model to reduce program maintenance costs. The specific technical solution is as follows: In a first aspect of an embodiment of the present invention, a data processing method based on a large language model is first provided. For each function, the following software units for the function are configured: an input parameter passing unit, a prompt word generating unit, and a large language model interface calling unit. In the process of implementing data processing for the target function, the method includes: Calling the target input parameter input unit corresponding to the target function to obtain the input parameters; Calling a target prompt word generation unit corresponding to the target function, combining the input parameter with a target prompt word template to generate a prompt word, wherein the target prompt word template is: a pre-configured prompt word template corresponding to the target function; The target large language model calling unit corresponding to the target function is called, the interface of the target large language model corresponding to the target function is called, the prompt word is input into the target large language model, and the output result of the target large language model is obtained.
[0004] In one embodiment of the present invention, an input parameter preprocessing unit is further configured for each function. In the process of implementing data processing for the target function, before the target prompt word generation unit corresponding to the target function is called and the input parameter is combined with the target prompt word template to generate the prompt word, the following is further included: The input parameter preprocessor unit corresponding to the target function is called to adjust the format of the input parameter to a format matching the target prompt word template.
[0005] In one embodiment of the present invention, a large language model production result verification unit is further configured for each function. In the process of implementing data processing for the target function, after obtaining the output result of the target large language model, the method further includes: The target large language model production result verification unit corresponding to the target function is called to detect whether the output result conforms to the target format, and a detection result is generated, wherein the target format is: a pre-configured format that the output result of the target function should conform to.
[0006] In one embodiment of the present invention, for each function, a large language model generation result post-processing unit is further configured. In the process of implementing data processing for the target function, after obtaining the output result of the target large language model, the following is further included: The target large language model corresponding to the target function is called to generate a result post-processing unit, the output result is analyzed, and key content in the output result is extracted, wherein the key content is the content with the highest degree of association with the target function.
[0007] In one embodiment of the present invention, a unit for returning a bottom-line result is further configured for each function. In the process of implementing data processing for the target function, the method further includes: If the target large language model fails to output a result successfully, the target catch-all result unit corresponding to the target function is called to output a preset target result corresponding to the target function as the output result.
[0008] In one embodiment of the present invention, in the process of implementing data processing for the target function, the method further includes: If the target large language model fails to successfully output the result, the step of re-executing the target large language model calling unit corresponding to the target function, calling the interface of the target large language model corresponding to the target function, inputting the prompt word into the target large language model, and obtaining the output result of the target large language model.
[0009] In one embodiment of the present invention, the model configuration parameters and / or prompt word templates corresponding to each function are stored in the same file.
[0010] In a second aspect of an embodiment of the present invention, a data processing device based on a large language model is first provided. For each function, the following software units for the function are configured: an input parameter passing unit, a prompt word generating unit, and a large language model interface calling unit. In the process of implementing data processing for the target function, the device includes: A parameter acquisition module, used to call the target input parameter input unit corresponding to the target function to obtain the input parameters; a prompt word generation module, used to call a target prompt word generation unit corresponding to the target function, combine the input parameter with a target prompt word template, and generate a prompt word, wherein the target prompt word template is: a pre-configured prompt word template corresponding to the target function; The result acquisition module is used to call the target large language model calling unit corresponding to the target function, call the interface of the target large language model corresponding to the target function, input the prompt word into the target large language model, and obtain the output result of the target large language model.
[0011] In one embodiment of the present invention, an input parameter preprocessing unit is further configured for each function, and the device further includes: The format adjustment module is used to call the input parameter preprocessor unit corresponding to the target function to adjust the format of the input parameter to a format matching the target prompt word template.
[0012] In one embodiment of the present invention, a large language model production result verification unit is further configured for each function, and the device further includes: A result detection module is used to call the target large language model production result verification unit corresponding to the target function, detect whether the output result conforms to the target format, and generate a detection result, wherein the target format is: a pre-configured format that the output result of the target function should conform to.
[0013] In one embodiment of the present invention, a large language model generation result post-processing unit is further configured for each function, and the device further includes: The content extraction module is used to call the target large language model corresponding to the target function to generate a result post-processing unit, analyze the output result, and extract key content in the output result, wherein the key content is the content with the highest degree of association with the target function.
[0014] In one embodiment of the present invention, for each function, a unit for returning a bottom-line result is further configured, and the device further includes: The preset result output module is used to call the target bottom-up result unit corresponding to the target function to output the preset target result corresponding to the target function as the output result if the target large language model fails to output the result successfully.
[0015] In one embodiment of the present invention, in the process of implementing data processing for the target function, the device further includes: If the target large language model fails to output a result successfully, the result obtaining module is re-triggered for execution.
[0016] In one embodiment of the present invention, the model configuration parameters and / or prompt word templates corresponding to each function are stored in the same file.
[0017] In a third aspect of an embodiment of the present invention, an electronic device is provided, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; The processor is used to implement any method step described in the first aspect when executing a program stored in the memory.
[0018] In a fourth aspect of an embodiment of the present invention, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, any method step described in the first aspect is implemented.
[0019] In yet another aspect of the embodiments of the present invention, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute any one of the method steps described in the first aspect.
[0020] A data processing method based on a large language model is provided in an embodiment of the present invention. For each function, the following software units for the function are configured in the embodiment of the present invention: an input parameter passing unit, a prompt word generating unit, and a large language model interface calling unit, that is, the programs of different functions are independently set. In the process of implementing data processing for a target function, the target input parameter passing unit, the target prompt word generating unit, and the target large language model calling unit corresponding to the target function are called to implement the data processing process based on the large language model. Since the software units of different functions are independently set, and the software units corresponding to different data processing steps corresponding to the same function are also independently set. Therefore, the software units are independent of each other, the amount of code contained in each software unit is reduced, and the degree of correlation between each other is low. Therefore, if the program logic structure needs to be modified, it is less difficult to retrieve the program that needs to be iteratively repaired, and only the independent software units can be modified, and the maintenance cost is low. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.
[0022] Figure 1 A schematic flow chart of a first data processing method based on a large language model provided by an embodiment of the present invention; Figure 2 A schematic flow chart of a second data processing method based on a large language model provided by an embodiment of the present invention; Figure 3 A schematic flow chart of a third data processing method based on a large language model provided in an embodiment of the present invention; Figure 4 A schematic flow chart of a fourth data processing method based on a large language model provided in an embodiment of the present invention; Figure 5 A schematic flow chart of a fifth data processing method based on a large language model provided by an embodiment of the present invention; Figure 6 A schematic diagram of a software unit relationship provided by an embodiment of the present invention; Figure 7 A schematic diagram of the structure of a data processing device based on a large language model provided by an embodiment of the present invention; Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0023] 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 only 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 based on the present invention belong to the scope of protection of the present invention.
[0024] Since the application project has many functions and the program volume is large, if the program logic structure is changed, it will affect the functions of most functions, and each function needs to be modified, which increases the cost of program maintenance. In order to solve the above problems, an embodiment of the present invention provides a data processing method and device based on a large language model.
[0025] See also Figure 1 , which is a flow chart of the first data processing method based on a large language model provided in an embodiment of the present invention. For each function, the following software units for the function are configured: an input parameter passing unit, a prompt word generating unit, and a large language model interface calling unit, in the process of implementing data processing for the target function.
[0026] In one embodiment of the present invention, each function may be composed of one or more independent sub-functions, and the implementation of the sub-function is equivalent to its corresponding function. Each sub-function can be implemented by the corresponding large language model. For example, the above function is to generate a plan for a virtual character for the day, so "generate plan" is a function. To implement the function of generating a plan, it is first necessary to generate the important ideas of the virtual character for the day, for example, shopping is needed on that day. Then it is necessary to generate a time schedule for the virtual character. Finally, it is necessary to divide the time. The sub-functions included in the "generate plan" function are "generate important ideas", "generate time schedule", and "divide time". Each sub-function can be implemented by the corresponding large prediction model.
[0027] For example, the current application scenario is a virtual world, in which there are virtual characters, and the virtual characters can talk to each other. In the process of the conversation between the two virtual characters, the background information of virtual character 1 and virtual character 2 and the information generated by the interaction between the two virtual characters in history can be input into the large language model, and the large language model can generate a series of dialogues between the two. Alternatively, each virtual character can also correspond to a generative large language model to process the other party's speech and generate a response, that is, the function of virtual character dialogue can be realized through two large language models.
[0028] In the process of generating dialogues between virtual characters, in addition to passing the conversation of another virtual character into the large language model, historical conversations between the two virtual characters and character background information (such as the virtual character's occupation setting, age setting, personality setting, etc.) can also be passed in.
[0029] Alternatively, in the virtual world, the virtual character and the virtual scene can interact with each other, and in the process of interaction, the virtual character can interact with the virtual scene according to the actual situation of the virtual scene. For example, the large language model can generate an action plan for the virtual character based on the virtual character's own knowledge (for example, the virtual character knows which facilities and places exist in the virtual scene). For example, if the virtual character knows that there is a beach in the virtual scene, the action plan generated by the large language model can be to go to the beach. The virtual character arrives at the beach according to the action plan. In addition, the large language model can also determine the action of the virtual character at the place it arrives, for example, sunbathing at the beach. The behavior of the virtual character can be perceived by other characters, thereby affecting the behavior of other characters, being understood by other characters, or interacting with other characters.
[0030] In addition, when implementing the dialogue function between virtual characters, the virtual characters can also generate conversations based on virtual scenes. For example, when two virtual characters are talking, one of the virtual characters says "It's a nice day today, let's go out and play." In this process, the large language model is also needed to generate conversations based on the actual situation of the virtual scene. That is, the same large language model will be used in the implementation of both functions.
[0031] Alternatively, when implementing the function of using a large language model to generate an introduction to a painting or photograph, it is also necessary to use the large language model to extract the key points of the painting or photograph. That is, the large language model can be applied to the function of evaluating a painting or photograph, and can also be applied to the function of generating an introduction to a painting or photograph.
[0032] Therefore, for a function, there is a large language model interface calling unit corresponding to the function for calling the large language model to implement the function. The corresponding function can be implemented by calling the large language model interface calling unit to call the interface of the large language model.
[0033] On this basis, the above method includes the following steps S101-S103.
[0034] S101: calling the target input parameter transfer unit corresponding to the target function to obtain input parameters.
[0035] The above input parameters are parameters to be input into the large language model. When virtual characters interact with each other, the input parameters may be the latest output of another virtual character. Alternatively, the input parameters may be manually input by the user.
[0036] Specifically, the input parameter may be content manually input by a user or the full text of a conversation recently output by another virtual character, or key content extracted from the full text.
[0037] In addition, when applied to a scene in a virtual world, the input parameters may also include information about the virtual scene where the virtual character is located, such as the location of objects, facilities or places in the virtual scene, etc. When the information contained in the virtual scene is relatively complex, the preferred input parameters may also include richer information such as time information and weather information.
[0038] S102: calling a target prompt word generation unit corresponding to the target function, combining the input parameters with a target prompt word template, and generating prompt words.
[0039] The target prompt word template is a pre-configured prompt word template corresponding to the target function.
[0040] Specifically, the prompt word is the information input into the large language model.
[0041] In the embodiment of the present invention, the target prompt word template is a preset template, which contains fixed content and a part to be filled. After the input parameter is filled into the part to be filled, the prompt word can be generated.
[0042] For example, the target prompt word template may be "You need to generate a response based on the received content and the specific situation of the current virtual environment. The received content is: , the specific situation of the virtual environment is: ". The underlined part is the part to be filled in. Fill in the input parameter in this position to generate the prompt word.
[0043] S103: calling the target large language model calling unit corresponding to the target function, calling the interface of the target large language model corresponding to the target function, inputting the prompt word into the target large language model, and obtaining the output result of the target large language model.
[0044] In one embodiment of the present invention, the target large language model calling unit may be called, and the prompt word may be input into the target large language model to obtain the output result of the large language model.
[0045] As can be seen from the above, for each function, the following software units for the function are configured in the embodiment of the present invention: input parameter passing unit, prompt word generating unit, large language model interface calling unit, that is, the programs of different functions are independently set. In the process of implementing data processing for the target function, the target input parameter passing unit, target prompt word generating unit, and target large language model calling unit corresponding to the target function are called to implement the data processing process based on the large language model. Since the software units of different functions are independently set, and the software units corresponding to different data processing steps corresponding to the same function are also independently set. Therefore, the software units are independent of each other, the amount of code contained in each software unit is reduced, and the degree of correlation between each other is low. Therefore, if the program logic structure needs to be changed, the difficulty of retrieving the program that needs to be iteratively repaired is relatively low, and only independent software units can be modified, and the maintenance cost is low.
[0046] In another embodiment of the present invention, an input parameter preprocessing unit is also configured for each function. Figure 2 , which is a flow chart of a second data processing method based on a large language model provided by an embodiment of the present invention, and is similar to the aforementioned Figure 1 Compared with the embodiment shown, before the above step S103, the following step S104 is also included.
[0047] S104: calling the input parameter preprocessor unit corresponding to the target function to adjust the format of the input parameter to a format matching the target prompt word template.
[0048] As can be seen from the foregoing, in the embodiment of the present invention, the input parameters are combined with the target prompt word template to generate prompt words. The format of the target prompt word template is relatively fixed, and only input parameters with a fixed format can be combined with the target prompt word template. Therefore, in order to ensure that the input parameters can be added to the target prompt word template, in the embodiment of the present invention, step S104 can be performed first to adjust the format of the input parameters.
[0049] Specifically, adjusting the format of the input parameter may include adjusting the data type of the input parameter to the data type specified by the target prompt word template, for example, converting an integer (int) input parameter to a string (string) input parameter.
[0050] The number of characters included in the input parameters may also be adjusted. For example, the number of characters included in the input parameters generated by the user or other virtual characters may be large, which may result in a large amount of content with low information content, affecting the analysis of the information by the large language model. To this end, when the number of characters included in the input parameters is greater than the preset number of characters specified in the target prompt word template, the input parameters may be input for keyword extraction, and the number of characters of the extracted keywords is equal to the preset number of characters. Conversely, when the number of characters included in the input parameters is less than the preset number of characters specified in the target prompt word template, the input parameters have less information content, and it is difficult for the large language model to accurately analyze the input parameters with less information content, so the input parameters may be expanded, and the number of characters after expansion is equal to the preset number of characters.
[0051] As can be seen from the above, in the embodiment of the present invention, before calling the target prompt word generation unit to generate prompt words, the input parameter preprocessing unit is first called to convert the input parameters into a format that matches the target prompt word template, so that the input parameters meet the regulations and the two can be combined to obtain the prompt words.
[0052] In another embodiment of the present invention, a large language model production result verification unit is also configured for each function. Figure 3 , which is a flow chart of a third data processing method based on a large language model provided by an embodiment of the present invention, and is similar to the aforementioned Figure 1 Compared with the embodiment shown in the figure, step S105 is further included after step S103.
[0053] S105: Calling the target large language model production result verification unit corresponding to the above target function to detect whether the above output result conforms to the target format and generate a detection result.
[0054] The target format is the format that the output result of the pre-configured target function should conform to.
[0055] For example, the above target format is to divide the output result into different key points, and each key point is numbered. For example, the output result that conforms to the target format is "1, xxx 2, yyy", etc.
[0056] Alternatively, the number of words in the above target format cannot exceed a preset number of words; the output results are divided into different key points, and different key points are divided into different paragraphs, etc.
[0057] It should be noted that in order to make the large language model output the results in the target format, a sentence indicating the target format can be added to the target candidate prompt word template, such as "You need to control the number of words in the output result to within 100 words", etc., so that the generated candidate words contain sentences indicating the target format to instruct the large language model to output the results in the target format.
[0058] However, the output result of the large language model may not conform to the target format, and the output result does not meet the requirements. Therefore, in order to ensure that the output result of the large language model is a normal result that meets the requirements, step S105 can be executed after obtaining the output result to detect whether the output result conforms to the target format and obtain the detection result.
[0059] If the detection result indicates that the output result conforms to the target format, the output result is regarded as an output result that conforms to the requirements.
[0060] If the detection result indicates that the output result does not conform to the target format, the output result is deleted or ignored. In addition, an alarm result may be generated to warn of the problem that the output result does not conform to the target format.
[0061] As can be seen from the above, in the embodiment of the present invention, after obtaining the output result of the target large language model, the target large language model production result verification unit is also called to verify the output result of the target large language model to determine whether it conforms to the target format and generate a test result. The output result is tested to ensure that the output result meets the requirements.
[0062] In another embodiment of the present invention, a large language model generation result post-processing unit is also configured for each function. Figure 4 , which is a flow chart of a fourth data processing method based on a large language model provided by an embodiment of the present invention, and is similar to the aforementioned Figure 1 Compared with the embodiment shown in the figure, step S106 is further included after step S103.
[0063] S106: Calling the target large language model corresponding to the target function to generate a result post-processing unit, analyzing the output result, and extracting key content from the output result.
[0064] Among them, the above-mentioned key content is the content with the highest degree of relevance to the target function.
[0065] Since the target large language model output result may have a large amount of data, including a large amount of data with low information content, it is difficult for users or other virtual characters to quickly identify the key points in the target large language model output result and to respond quickly.
[0066] Therefore, in the embodiment of the present invention, the target large language model can be called to generate a result post-processing unit to analyze the output result and extract key content from the output result.
[0067] In one embodiment of the present invention, the output result can be input into a large language model for extracting key content, instructing the large language model to extract key content. In this case, the prompt word input into the large language model can be "Please extract key content from the following content, the specific content is: xxx", where xxx is the above output result.
[0068] In yet another embodiment of the present invention, key contents in the above output results may also be extracted by a semantic analysis algorithm other than the large language model.
[0069] As can be seen from the above, in the embodiment of the present invention, after obtaining the output result of the target large language model, the output result will also be analyzed and extracted for key content, thereby reducing the portion of the output result with lower information content, and facilitating subsequent rapid response based on key content with high information content. In addition, due to the extraction of key content, information that does not meet expectations or useless information in the output result can be removed, while facilitating subsequent processing and improving the overall production effect. In the event of an error in the subsequent function implementation process, the key content with less data volume can be quickly analyzed, thereby quickly locating the error.
[0070] In another embodiment of the present invention, a unit for returning a bottom-line result is also configured for each function. Figure 5 , which is a flow chart of a fifth data processing method based on a large language model provided by an embodiment of the present invention, and is similar to the aforementioned Figure 1 Compared with the embodiment shown in the figure, step S107 is further included after step S103.
[0071] S107: If the target large language model fails to output a result successfully, the target catch-all result unit corresponding to the target function is called to output a preset target result corresponding to the target function as the output result.
[0072] Specifically, the reason why the target large language model fails to output the result may be a network failure or a program running error, etc., which causes the target large language model to fail to output the result. Alternatively, if it is determined through the aforementioned S105 that the output result of the target large language model does not conform to the target format, it is determined that the target large language model fails to output the result.
[0073] On this basis, the embodiment of the present invention configures different target results for different target functions. In the case where the target large language model fails to output the result successfully, the target result is used as the output result so that the target function can continue to be executed. For example, the target result can be "Yes", "I'm sleeping", "Who am I?", "I'm idle" or when the present application is used for a dialogue between virtual characters in a virtual scene, the target result can also be an action plan that the virtual character has decided on, or the execution time of the action to be performed by the virtual character determined according to the current virtual time of the virtual scene, etc.
[0074] From the above, it can be seen that in the embodiment of the present invention, when the target large language model fails to successfully output the result, the target result corresponding to the target function is output through the target backup result unit as the output result, so that when the output result actually fails to be output, the normal execution of the target function can still be not hindered.
[0075] In yet another embodiment of the present invention, if the target large language model fails to output a result, the step S103 is performed again.
[0076] Specifically, the reason why the target large language model fails to output the result can be seen above. In the embodiment of the present invention, if the target large language model fails to output the result, step S103 can be re-executed. Since the large language model often has a certain randomness, the output results obtained by repeatedly inputting the same prompt word into the large language model may be different. The randomness of the large language model can be controlled by the model configuration parameters of the large language model.
[0077] Therefore, when the target large language model fails to output the result, re-inputting the prompt word into the large language model may successfully obtain the output result. Alternatively, if the output failure is due to a network failure or a program error, re-execution of step S103 may successfully obtain the output result after troubleshooting.
[0078] From the above, it can be seen that in the embodiment of the present invention, when the target large language model fails to successfully output the result, the target large language model calling unit can be re-called, and the prompt word can be re-processed through the target large language model, so that the output result may be successfully obtained, thereby increasing the probability of successful output result. In addition, since the implementation process of the target function may be relatively long, if the target large language model fails to output, the previously performed data processing and the generated results will be used, which will waste a lot of time cost and interface call cost. However, in the embodiment of the present invention, the probability of successful output can be increased by retrying, thereby saving time cost and interface call cost.
[0079] Since each large language model corresponds to its own model configuration parameters and / or prompt word templates, if the model configuration parameters and / or prompt word templates of each large language model are configured separately, it will take a lot of time to find the modification location when the model configuration parameters and / or prompt word templates need to be modified. In another embodiment of the present invention, the model configuration parameters and / or prompt word templates corresponding to each function are stored in the same file. The file can be a json file. By centrally recording the model configuration parameters and / or prompt word templates in this way, it will be easier to manage and modify and update them later.
[0080] See also Figure 6 , which is a schematic diagram of a software unit relationship provided in an embodiment of the present invention.
[0081] The input parameters passed in the figure are received by the input parameter passing unit. The parameters received in the input parameter passing unit can be preprocessed by the input parameter preprocessing unit. Then the prompt word generation unit generates prompt words. The prompt word generation unit contains prompt word templates. The output result is obtained by the target large language model calling unit. The LLM (LargeLanguage Model) can also be called to process the output result through the large language model production result verification unit, the large language model generation result post-processing unit and the retry.
[0082] Corresponding to the aforementioned data processing method based on a large language model, an embodiment of the present invention further provides a data processing device based on a large language model.
[0083] See also Figure 7 , which is a structural diagram of a data processing device based on a large language model provided by an embodiment of the present invention.
[0084] For each function, the following software units for the function are configured: an input parameter passing unit, a prompt word generating unit, and a large language model interface calling unit. In the process of implementing data processing for the target function, the device includes: A parameter acquisition module 701 is used to call a target input parameter input unit corresponding to the target function to acquire input parameters; The prompt word generation module 702 is used to call the target prompt word generation unit corresponding to the target function, combine the input parameters with the target prompt word template, and generate prompt words, wherein the target prompt word template is: a pre-configured prompt word template corresponding to the target function; The result acquisition module 703 is used to call the target large language model calling unit corresponding to the target function, call the interface of the target large language model corresponding to the target function, input the prompt word into the target large language model, and obtain the output result of the target large language model.
[0085] As can be seen from the above, for each function, the following software units for the function are configured in the embodiment of the present invention: input parameter passing unit, prompt word generating unit, large language model interface calling unit, that is, the programs of different functions are independently set. In the process of implementing data processing for the target function, the target input parameter passing unit, target prompt word generating unit, and target large language model calling unit corresponding to the target function are called to implement the data processing process based on the large language model. Since the software units of different functions are independently set, and the software units corresponding to different data processing steps corresponding to the same function are also independently set. Therefore, the software units are independent of each other, the amount of code contained in each software unit is reduced, and the degree of correlation between each other is low. Therefore, if the program logic structure needs to be changed, the difficulty of retrieving the program that needs to be iteratively repaired is relatively low, and only independent software units can be modified, and the maintenance cost is low.
[0086] In one embodiment of the present invention, an input parameter preprocessing unit is further configured for each function, and the device further includes: The format adjustment module is used to call the input parameter preprocessor unit corresponding to the target function to adjust the format of the input parameter to a format matching the target prompt word template.
[0087] As can be seen from the above, in the embodiment of the present invention, before calling the target prompt word generation unit to generate prompt words, the input parameter preprocessing unit is first called to convert the input parameters into a format that matches the target prompt word template, so that the input parameters meet the regulations and the two can be combined to obtain the prompt words.
[0088] In one embodiment of the present invention, a large language model production result verification unit is further configured for each function, and the device further includes: A result detection module is used to call the target large language model production result verification unit corresponding to the target function, detect whether the output result conforms to the target format, and generate a detection result, wherein the target format is: a pre-configured format that the output result of the target function should conform to.
[0089] As can be seen from the above, in the embodiment of the present invention, after obtaining the output result of the target large language model, the target large language model production result verification unit is also called to verify the output result of the target large language model to determine whether it conforms to the target format and generate a test result. The output result is tested to ensure that the output result meets the requirements.
[0090] In one embodiment of the present invention, a large language model generation result post-processing unit is further configured for each function, and the device further includes: The content extraction module is used to call the target large language model corresponding to the target function to generate a result post-processing unit, analyze the output result, and extract key content in the output result, wherein the key content is the content with the highest degree of association with the target function.
[0091] As can be seen from the above, in the embodiment of the present invention, after obtaining the output result of the target large language model, the output result will also be analyzed and extracted for key content, thereby reducing the portion of the output result with lower information content, and facilitating subsequent rapid response based on key content with high information content. In addition, due to the extraction of key content, information that does not meet expectations or useless information in the output result can be removed, while facilitating subsequent processing and improving the overall production effect. In the event of an error in the subsequent function implementation process, the key content with less data volume can be quickly analyzed, thereby quickly locating the error.
[0092] In one embodiment of the present invention, for each function, a unit for returning a bottom-line result is further configured, and the device further includes: The preset result output module is used to call the target bottom-up result unit corresponding to the target function to output the preset target result corresponding to the target function as the output result if the target large language model fails to output the result successfully.
[0093] From the above, it can be seen that in the embodiment of the present invention, when the target large language model fails to successfully output the result, the target result corresponding to the target function is output through the target backup result unit as the output result, so that when the output result actually fails to be output, the normal execution of the target function can still be not hindered.
[0094] In one embodiment of the present invention, in the process of implementing data processing for the target function, the device further includes: If the target large language model fails to output a result, the result obtaining module 703 is retriggered for execution.
[0095] From the above, it can be seen that in the embodiment of the present invention, when the target large language model fails to successfully output the result, the target large language model calling unit can be re-called, and the prompt word can be re-processed through the target large language model, so that the output result may be successfully obtained, thereby increasing the probability of successful output result. In addition, since the implementation process of the target function may be relatively long, if the target large language model fails to output, the previously performed data processing and the generated results will be used, which will waste a lot of time cost and interface call cost. However, in the embodiment of the present invention, the probability of successful output can be increased by retrying, thereby saving time cost and interface call cost.
[0096] In one embodiment of the present invention, the model configuration parameters and / or prompt word templates corresponding to each function are stored in the same file.
[0097] Since each large language model has its own model configuration parameters and / or prompt word templates, if the model configuration parameters and / or prompt word templates of each large language model are configured separately, it will take a lot of time to find the modification location when the model configuration parameters and / or prompt word templates need to be modified. In another embodiment of the present invention, the model configuration parameters and / or prompt word templates corresponding to each function are stored in the same file. By centrally recording the model configuration parameters and / or prompt word templates in this way, it will be easier to manage and modify and update them later.
[0098] The embodiment of the present invention further provides an electronic device, such as Figure 8 As shown, it includes a processor 801, a communication interface 802, a memory 803 and a communication bus 804, wherein the processor 801, the communication interface 802, and the memory 803 communicate with each other through the communication bus 804. Memory 803, used for storing computer programs; The processor 801 is used to implement the following steps of the data processing method based on the large language model when executing the program stored in the memory 803.
[0099] When the electronic device provided by the embodiment of the present invention is used to perform the data processing method based on the large language model, for each function, the following software units for the function are configured in the embodiment of the present invention: input parameter transfer unit, prompt word generation unit, large language model interface calling unit, that is, the programs of different functions are independently set. In the process of implementing the data processing for the target function, the target input parameter transfer unit, target prompt word generation unit, and target large language model calling unit corresponding to the target function are called to implement the data processing process based on the large language model. Since the software units of different functions are independently set, and the software units corresponding to the different data processing steps corresponding to the same function are also independently set. Therefore, the software units are independent of each other, the amount of code contained in each software unit is reduced, and the degree of correlation between each other is low. Therefore, if the program logic structure needs to be changed, the difficulty of retrieving the program that needs to be iteratively repaired is low, and only the independent software units can be modified, and the maintenance cost is low.
[0100] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0101] The communication interface is used for communication between the above terminal and other devices.
[0102] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0103] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0104] In another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the data processing method based on the large language model described in any of the above embodiments is implemented.
[0105] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is executed on a computer, the computer executes the data processing method based on a large language model described in any one of the above embodiments.
[0106] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0107] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants 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, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0108] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device, computer-readable storage medium, and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0109] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A data processing method based on a large language model, characterized in that: For each function, the following software units for the function are configured: an input parameter passing unit, a prompt word generating unit, and a large language model interface calling unit. In the process of implementing data processing for the target function, the method includes: Calling the target input parameter input unit corresponding to the target function to obtain the input parameters; Calling a target prompt word generation unit corresponding to the target function, combining the input parameter with a target prompt word template to generate a prompt word, wherein the target prompt word template is: a pre-configured prompt word template corresponding to the target function; The target large language model calling unit corresponding to the target function is called, the interface of the target large language model corresponding to the target function is called, the prompt word is input into the target large language model, and the output result of the target large language model is obtained.
2. The method according to claim 1, characterized in that: For each function, an input parameter preprocessing unit is also configured. In the process of implementing data processing for the target function, before the target prompt word generation unit corresponding to the target function is called and the input parameter is combined with the target prompt word template to generate the prompt word, it also includes: The input parameter preprocessor unit corresponding to the target function is called to adjust the format of the input parameter to a format matching the target prompt word template.
3. The method according to claim 1, characterized in that For each function, a large language model production result verification unit is also configured. In the process of implementing data processing for the target function, after obtaining the output result of the target large language model, it also includes: The target large language model production result verification unit corresponding to the target function is called to detect whether the output result conforms to the target format, and a detection result is generated, wherein the target format is: a pre-configured format that the output result of the target function should conform to.
4. The method according to claim 1, characterized in that: For each function, a large language model generation result post-processing unit is also configured. In the process of implementing data processing for the target function, after obtaining the output result of the target large language model, it also includes: The target large language model corresponding to the target function is called to generate a result post-processing unit, the output result is analyzed, and key content in the output result is extracted, wherein the key content is the content with the highest degree of association with the target function.
5. The method according to claim 1, characterized in that For each function, a unit for returning a bottom-line result is also configured. In the process of implementing data processing for the target function, the method further includes: If the target large language model fails to output a result successfully, the target catch-all result unit corresponding to the target function is called to output a preset target result corresponding to the target function as the output result.
6. The method according to claim 1, characterized in that In the process of implementing data processing for the target function, the method further includes: If the target large language model fails to successfully output the result, the step of re-executing the target large language model calling unit corresponding to the target function, calling the interface of the target large language model corresponding to the target function, inputting the prompt word into the target large language model, and obtaining the output result of the target large language model.
7. The method according to any one of claims 1 to 6, characterized in that The model configuration parameters and / or prompt word templates corresponding to each function are stored in the same file.
8. A data processing device based on a large language model, characterized in that: For each function, the following software units for the function are configured: an input parameter passing unit, a prompt word generating unit, and a large language model interface calling unit. In the process of implementing data processing for the target function, the device includes: A parameter acquisition module, used to call the target input parameter input unit corresponding to the target function to obtain the input parameters; a prompt word generation module, used to call a target prompt word generation unit corresponding to the target function, combine the input parameter with a target prompt word template, and generate a prompt word, wherein the target prompt word template is: a pre-configured prompt word template corresponding to the target function; The result acquisition module is used to call the target large language model calling unit corresponding to the target function, call the interface of the target large language model corresponding to the target function, input the prompt word into the target large language model, and obtain the output result of the target large language model.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 7 when executing a program stored in a memory.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Software development kit adaptation method and device, electronic equipment and storage medium
CN116931913A
Prompt word processing method and device, electronic equipment and storage medium
CN117666812A
Automatic voice operation method and device based on large language model, electronic equipment and storage medium
CN117727304A
Business function development method and device, computer equipment and storage medium
CN118034674A
Prompt text generation method and device and reply generation method and device applied to large language model
CN118171641A
Cited By
Data processing method and device based on large model
CN119168085A
A data processing method and apparatus based on a large model
CN119168085B
Enterprise process intelligent analysis system based on large language model
CN121119659A
