Plug-in calling method of plug-in calling capability fine-tuning large model

By improving the supervised fine-tuning dialogue training sample template and introducing plug-in information, the large language model is fine-tuned, which solves the problem that the model cannot understand user instructions, improves the success rate of plug-in calls and reduces resource requirements.

CN119312930APending Publication Date: 2025-01-14中铁科学研究院集团有限公司

Patent Information

Application Number
CN202411468690.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-21
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

Large language models may not be able to understand user instructions when dealing with professional or complex problems, resulting in plug-in calls failing or low success rates, and existing fine-tuning methods cannot effectively introduce plug-in calls.

Method used

By improving the supervised fine-tuning dialogue training sample template, introducing plug-in-related information, constructing samples and fine-tuning the big model, adding fine-tuning modules in series or parallel mode, freezing the original model weights, and only updating the fine-tuning module parameters to enhance the plug-in calling capabilities.

Benefits of technology

Improves the understanding of plug-in calls by the big model, generates standard answers, improves the success rate of plug-in calls, avoids catastrophic forgetting, and reduces the training resource requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119312930A_ABST
    Figure CN119312930A_ABST
Patent Text Reader

Abstract

The invention discloses a plug-in calling method for a plug-in calling capability fine-tuning large model. The plug-in calling method comprises the following steps: constructing a training sample set; designing a fine tuning module based on the original large model; modifying the architecture of the original large model, and adding the fine tuning module into the original large model; selecting a type of adding the fine adjustment module into the original large model: if the added type is a series connection mode, freezing the weight of the original large model part, training the fine adjustment module added into the original large model, and obtaining a plug-in calling large model after training is completed; if the addition type is a parallel connection mode, freezing the weight of the original large model part, and training a fine tuning module added into the original large model; after training is completed, the weight of the fine adjustment module and the original large model are combined, and a plug-in calling large model is obtained. By introducing related information of calling the plug-in into the dialogue training sample template, fine tuning training is performed on the large model, and the plug-in calling capability of the large model is enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of plug-in calling, and in particular to a plug-in calling method for a large model with fine-tuning of plug-in calling capability. Background Art

[0002] Large Language Model (LLM) is essentially a generative model, which refers to a deep learning model trained with a large amount of text data. It can understand the meaning of language text and generate content that meets the user's intentions, such as performing tasks, conducting human-computer dialogues, answering questions, and generating images. When we ask ChatGPT some relatively broad questions, it can answer them very well, but once we ask some professional questions or questions that require complex calculations, it may not be able to answer them, or it may answer wrong information. Because professional questions may not be involved in pre-training, or exceed the capabilities of the large model, although its answer looks like a correct answer, it is actually wrong. Therefore, for high-precision application scenarios, large models need to introduce plug-ins to expand the capabilities and ensure the accuracy of knowledge. Questions that cannot be answered by large models are generally implemented by calling external plug-ins.

[0003] To enable the big model to have the ability to call plug-ins, it is necessary to first fine-tune the big model to enhance its capabilities. Currently, the fine-tuning method for big models is mainly to fine-tune the dialogue capabilities. The template style of the fine-tuning training data set is the dialogue form between humans and big models, and it is impossible to introduce the calling function of third-party plug-ins.

[0004] Most of the currently open-source large models have undergone supervised fine-tuning and have a certain degree of conversational capabilities, but when the plug-in calling function is applied, it is not possible to ensure that the tool is called normally. This is because the training sample construction template commonly used for supervised fine-tuning is in the form of user questions and model answers, and does not introduce plug-in information. Therefore, when generating answers, the model may not understand user instructions and generate non-standard answers, resulting in plug-in call failure or low success rate. Summary of the invention

[0005] The technical problem to be solved by the present invention is that the model does not introduce plug-ins, which may cause the model to fail to understand user instructions when generating answers, generate non-standard answers, and cause plug-in call failure or low success rate. The purpose is to provide a plug-in calling method for a large model with fine-tuning of plug-in calling capability, by improving the template of the supervised fine-tuning dialogue training sample, introducing the relevant information of calling the plug-in into the dialogue training sample template to construct a sample, and then fine-tuning the large model to retain the general knowledge ability of the large model and avoid catastrophic forgetting of the model. The large model can fully understand the plug-in calling scenario, enhance the plug-in calling capability of the large model, and enable the large model to generate standardized answers suitable for plug-in calling, thereby improving the success rate of the large model calling the plug-in.

[0006] The present invention is achieved through the following technical solutions:

[0007] The present invention provides a plug-in calling method for a large model with fine-tuning of plug-in calling capability, comprising the following specific steps:

[0008] Construct a training sample set;

[0009] Design fine-tuning modules based on the original large model;

[0010] Modify the original large model architecture and add the fine-tuning module to the original large model;

[0011] Choose how to add the fine-tuning module to the original large model architecture:

[0012] If the adding type is serial mode, then,

[0013] During training, the weights of the original large model are frozen, and the fine-tuning modules added to the original large model architecture are trained. After the training is completed, the plug-in calls the large model.

[0014] If the adding type is parallel, then,

[0015] During training, the weights of the original large model are frozen, and the fine-tuning module added to the original large model architecture is trained. After the training is completed, the weights of the fine-tuning module and the weights of the original large model are merged to obtain the large model called by the plug-in.

[0016] Furthermore, when the fine-tuning module is inserted and the adding type is in series, it specifically includes: serially connecting the fine-tuning module with each layer that needs to be fine-tuned, and the serial connection includes: connecting the layer that needs to be fine-tuned, the fine-tuning module, and the next layer of the layer that needs to be fine-tuned in sequence.

[0017] Furthermore, when inserting the fine-tuning module, when the adding type is in parallel, it specifically includes: connecting the fine-tuning module in parallel with each layer that needs to be fine-tuned linear transformation.

[0018] Furthermore, the sample template of the sample set includes six parts: context, plug-in set, user question, called plug-in information, plug-in call result and model answer;

[0019] The context is used to provide current background information;

[0020] The plug-in set includes at least one plug-in, and each plug-in includes a plug-in name, a plug-in function description, and a plug-in parameter set;

[0021] The user question is information input by the user on the client;

[0022] The called plug-in information includes a plug-in name and a plug-in parameter set;

[0023] The plug-in call result is the result returned by passing the input parameters to the called plug-in and processing by the plug-in;

[0024] The model answer is the answer given by the model after obtaining the plug-in call result and combining all known information.

[0025] Furthermore, the plug-in parameter set field declares the type of the parameter set, the parameter field set, and the parameter set that must be input;

[0026] The parameter set type is in the form of key-value pairs;

[0027] The parameter field set uses the parameter name as the key and the detailed information of the parameter as the value;

[0028] The detailed information of the parameter includes the type, unit and detailed meaning description of the parameter.

[0029] Furthermore, the specific steps of constructing a training sample set include: taking the text constructed by the context, plug-in set, user questions, called plug-in information, plug-in call results and model answers as the input of training data, and taking the called plug-in information, plug-in call results and model answers as labels to construct training samples.

[0030] Furthermore, when adding training of fine-tuning modules in series, it is necessary to ensure that the input dimension of the fine-tuning module matches the output dimension of the model fine-tuning layer, and the output dimension matches the input dimension of the subsequent layers of the model.

[0031] Furthermore, the specific steps for adding fine-tuning modules in parallel include:

[0032] Use the weight update matrix ΔW to linearly transform the weight matrix W0 of the pre-trained model, where W0∈Rd×k;

[0033] At the beginning of training, the weight update ΔW is decomposed into the product of two low-rank matrices, and ΔW = BA is obtained, where B ∈ Rd×r, A ∈ Rr×k, and the rank r <<min(d,k);

[0034] According to ΔW=BA, matrix A is initialized with random Gaussian distribution, and matrix B is initialized as a zero matrix;

[0035] During the training process, the pre-trained weight matrix W0 remains unchanged, and only the parameters of the low-rank matrices A and B are updated;

[0036] Furthermore, the steps of merging the trained fine-tuning module weights with the original large model include:

[0037] The weight merging calculation steps include:

[0038] W′=W0+ΔW

[0039] Where W0 represents the weight of the original large model, ΔW represents the weight of the fine-tuning module after fine-tuning, and W ′ Represents the combined model weight.

[0040] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0041] By improving the template of supervised fine-tuning dialogue training samples, introducing relevant information about calling plug-ins into the dialogue training sample template to construct samples, and then fine-tuning the large model, the general knowledge ability of the large model is retained to avoid catastrophic forgetting of the model. This allows the large model to fully understand the plug-in calling scenario, enhance the plug-in calling capability of the large model, and enable the large model to generate standardized answers suitable for plug-in calling, thereby improving the success rate of the large model calling plug-ins.

[0042] By introducing a fine-tuning module with a small number of parameters during the fine-tuning phase, the original model parameters are not changed, which greatly reduces the training parameters and required resources. Only a small number of samples and resources are needed to achieve the same effect as traditional model fine-tuning. While improving the plug-in calling capability of large models, the generalization ability of the original model is retained to avoid overfitting. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope. For those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without creative work. In the drawings:

[0044] Figure 1A training method for a plug-in calling model in an embodiment of the present invention;

[0045] Figure 2 This is the calling process in the embodiment of the present invention;

[0046] Figure 3 Inserting a fine-tuning module in series in the embodiment of the present invention;

[0047] Figure 4 A fine-tuning module is inserted in parallel in the embodiment of the present invention. DETAILED DESCRIPTION

[0048] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments and drawings. The exemplary embodiments of the present invention and their description are only used to explain the present invention and are not intended to limit the present invention.

[0049] As a possible implementation, Figure 1 As shown, this embodiment provides a plug-in calling method for a large model with fine-tuning plug-in calling capability, and the specific steps include: constructing a training sample set; designing a fine-tuning module based on the original large model; modifying the original large model architecture, adding the fine-tuning module to the original large model, and completing the training to obtain a modified fine-tuning model;

[0050] If the adding type is in series, the fine-tuning module added to the original large model is trained. When the fine-tuning module is trained, the weight of the original large model is frozen. After the training is completed, the plug-in calls the large model.

[0051] If the adding type is in parallel, the fine-tuning module added to the original large model is trained; when the fine-tuning module is trained, the weight of the original large model is frozen; after the training is completed, the weight of the fine-tuning module and the original large model are merged to obtain the large model called by the plug-in.

[0052] By improving the template of the supervised fine-tuning dialogue training sample, introducing the relevant information of calling the plug-in into the dialogue training sample template to construct the sample, and then fine-tuning the large model, the general knowledge ability of the large model is retained to avoid catastrophic forgetting of the model. The large model can fully understand the plug-in calling scenario and enhance the plug-in calling capability of the large model. The large model can generate standardized answers suitable for plug-in calling, thereby improving the success rate of the large model calling the plug-in.

[0053] In some possible embodiments, a fine-tuning module is constructed based on the original large model, and the size, complexity and compatibility of the fine-tuning module with the rest of the original large model need to be considered. The fine-tuning module design can approximate the weight update matrix through low-rank decomposition or reduce the training parameters through dimension transformation and feature transformation methods.

[0054] In some possible embodiments, the fine-tuning position is first designed, and a fine-tuning module is inserted into each layer that needs fine-tuning linear transformation (for example, the self-attention layer and feed-forward layer of each Transformer block) or a fine-tuning network layer structure is added to the original large model architecture layer. Figure 3 and Figure 4 As shown, it can be parallel or serial with the original neural network layer;

[0055] like Figure 3 As shown, serial connection: the inserting of the fine-tuning module specifically includes the following steps: serially connecting the fine-tuning module with each layer that needs to be fine-tuned, that is, inserting the fine-tuning module after the layer that needs to be fine-tuned in the original large model, and connecting it in series with the layer that needs to be fine-tuned in the original large model and the next layer of the layer that needs to be fine-tuned in the original model. The fine-tuning module can be a simple linear layer, one or more convolutional layers, a recurrent neural network layer, an attention mechanism layer, or a more complex sub-network, and it is necessary to ensure that the output dimension of the fine-tuning module matches the input dimension of the subsequent layers of the model.

[0056] like Figure 4 As shown, parallel connection: the fine-tuning module is connected in parallel with each layer that needs to be fine-tuned linear transformation.

[0057] In some possible embodiments, the weights of the original large model part are frozen for the modified model, and the original weights of the large model are frozen, which means that these weights will not be updated in the subsequent training process. This can prevent the original knowledge of the pre-trained model from being destroyed during the fine-tuning process, resulting in catastrophic forgetting of the model after fine-tuning. The weight freezing method is mainly implemented in deep learning frameworks such as PyTorch by setting the requires_grad attribute of the parameter to False, and can also be implemented by setting the parameter group of the optimizer, and only passing the parameters of the fine-tuning module to the optimizer.

[0058] In some possible embodiments, during the sample construction phase, a large model fine-tuning data template style is designed, and plug-in collection, called plug-in information, and plug-in call result fields are added to the human-large model dialogue template to construct a training sample. That is, the plug-in call training sample template consists of six parts: context, plug-in collection, user question, called plug-in information, plug-in call result, and model answer.

[0059] The context gives the current background information, such as "select appropriate tools to answer questions based on the user's questions."

[0060] The plugin collection includes at least one plugin. Each plugin includes three fields: plugin name, plugin function description, and plugin parameter collection. The plugin parameter collection field declares the parameter collection type, parameter field collection, and parameter collection that must be entered. The parameter collection type is in the form of a key-value pair. The parameter field collection uses the parameter name as the key and the detailed information of the parameter as the value. The detailed information of the parameter includes the parameter type, unit, detailed meaning description, etc. The parameter collection that must be entered is optional, indicating which parameters must be passed in when the plugin is called.

[0061] User questions are the information entered by the user on the client.

[0062] The called plug-in information includes the plug-in name and the input parameters of the plug-in.

[0063] The plug-in call result is the result returned by passing the input parameters to the called plug-in and processing by the plug-in.

[0064] The model answer is the answer given by the model after obtaining the plug-in call result and combining all known information.

[0065] The text constructed from six parts, namely context, plug-in collection, user questions, called plug-in information, plug-in call results, and model answers, is used as the input of training data. The called plug-in information, plug-in call results, and model answers are used as labels for training data to strengthen the model's ability to understand plug-in call scenarios. At this stage, only the network layer parameters in the fine-tuning module are trained, while the other weights of the large model remain unchanged. This means that computing resources are mainly focused on updating these small number of parameters, greatly reducing training time and GPU memory requirements.

[0066] In some possible embodiments, the fine-tuning module added to the original large model is trained, and the specific steps include: initializing the weight update amount ΔW based on the pre-trained weight matrix W0, where the matrix W0∈Rd×k; decomposing the weight update amount ΔW into the product of two low-rank matrices to obtain ΔW=BA, where B∈Rd×r, A∈Rr×k, and the rank r<<min(d,k);

[0067] At the beginning of training, according to ΔW=BA, matrix A is initialized with random Gaussian distribution and matrix B is initialized to zero matrix;

[0068] During the training process, the pre-trained weight matrix W0 remains unchanged, and only the parameters of the low-rank matrices A and B are updated;

[0069] In some possible embodiments, the trained fine-tuning module weights are merged with the original large model, wherein the parallel designed fine-tuning module weights can also be directly merged into the network structure weights corresponding to the large model by matrix addition to form a new large model with a plug-in calling function, but it is necessary to ensure that the weights of the fine-tuning module have the same dimensions and shapes as the weights at the corresponding positions of the pre-trained model. The specific calculation steps for merging the trained fine-tuning module weights with the original large model include:

[0070] W′=W0+ΔW

[0071] Where W0 represents the weight of the original large model, ΔW represents the weight of the fine-tuning module after fine-tuning, and W ′ Represents the combined model weight.

[0072] In some possible embodiments, the fine-tuning module can be removed from the large model fine-tuning architecture after weight merging. The weight-merged model is saved as a new large model with a plug-in call function, and the subsequent deployment and reasoning can directly deploy the model, which is consistent with the loading and use process of the original model. When the weight-merged model is used for reasoning, the performance of the model will reflect the result of fine-tuning, and no additional fine-tuning module computing overhead will be generated, which helps to reduce the use of storage space and simplify model deployment.

[0073] In some possible embodiments, the first interaction: constructing an instruction input model based on the context, the custom plug-in set and the user's question, and the model generates information of the called plug-in, including the plug-in name and plug-in input parameters.

[0074] Call plug-in: pass parameters to the plug-in to get the plug-in call result.

[0075] Second interaction: Build an instruction input model based on context, custom plug-in collection, user questions, called plug-in information, and plug-in call results. The model generates a final answer based on the plug-in call.

[0076] like Figure 2 As shown, custom plug-in + user question → build prompt (register custom plug-in and user question to instruction) → input model → generate plug-in call information → build prompt again (including custom plug-in, called plug-in, plug-in call result) → input model → generate final answer.

[0077] The plug-in calling sample template generated in this embodiment cannot be used on similar products and is only used to train the plug-in calling function. The large model plug-in calling method in this embodiment is based on the plug-in calling template design, simulates the scene during model training, and improves the success rate of large model plug-in calling.

[0078] As a possible implementation, this embodiment provides a specific plug-in calling example:

[0079] 1. Construct sample

[0080] First, construct samples according to the plug-in calling template, and build training samples according to the following template style.

[0081] Template Examples

[0082] Context: You are an AI assistant, and your task is to select the right tools, provide answers and support for the user's questions and requirements. When calling the following function, please use the Json format to represent the parameters of the call.

[0083] Plugin Collection: #Available Tools

[0084] {

[0085] "name:calculate interest",

[0086] "description":"Calculate the deposit interest amount",

[0087] "parameters":{

[0088] "type":"object",

[0089] "properties":{

[0090] "principal":{

[0091] "type":"number",

[0092] "description":"Deposit principal"},

[0093] "rate":{

[0094] "type":"number",

[0095] "description":"interest rate"},

[0096] "time":{

[0097] "type":"number",

[0098] "description":"Time span (in years)"}

[0099] },

[0100] "required":["principal","rate","time"]}

[0101] }

[0102] User Question: Hello, I need to calculate the interest on a deposit I am considering. The deposit principal is 10,000 yuan, the interest rate is 2.9%, and the deposit term is 5 years. Can you help me calculate it?

[0103] Plugin called: calculate_interest{principal":10000,rate":2.9,"time":5}

[0104] Plugin call result: {"interest":1450}

[0105] Model answer: The total interest on your deposit for five years will be $1,450.

[0106] 2. Model fine-tuning training

[0107] For large models, you can choose open source large models such as Llama, Qwen or ChatGLM series, and then fine-tune the plug-in calling capabilities of these open source large models. The training process is as follows.

[0108] (1) Module design

[0109] The fine-tuning module is designed by approximating the weight update matrix through low-rank decomposition. For the pre-trained weight matrix W0∈Rd×k, its update amount ΔW is decomposed into the product of two low-rank matrices, that is, ΔW=BA, where B∈Rd×r, A∈Rr×k, and rank r<<min(d,k). During the training process, the pre-trained weight matrix W0 remains unchanged, and only the parameters of the low-rank matrices A and B are updated. Matrix A is usually initialized using a random Gaussian distribution, while matrix B is initialized to a zero matrix. In this way, at the beginning of training, ΔW=BA is zero and has no effect on the model output.

[0110] (2) Modify the model architecture

[0111] Inject the designed fine-tuning module into the self-attention layer of the transformer architecture.

[0112] (3) Weight Freeze

[0113] The original weight W0 of the large model is frozen and no parameter update is performed during training.

[0114] (4) Training and fine-tuning module

[0115] Use the transformer library to load the constructed training samples and model, and perform training. During training, update the parameters of the A and B matrices. After training, save the fine-tuning module parameters.

[0116] 3. Model merging

[0117] Model merging is achieved by weight addition. The original weight matrix W0 is modified by W0+BA. BA is the fine-tuning module after training, which can be regarded as an incremental adjustment to the original weight.

[0118] Finally, the large model plug-in capability training was completed, and the large model plug-in calling capability combined with the fine-tuning module capability was enhanced. The plug-in calling success rate was effectively improved and can be applied to plug-in calling scenarios.

[0119] The following is an implementation example of a large model calling a plug-in

[0120] Known commonly used formulas in the first-class "Construction Engineering Practice":

[0121] The calculation formula for leveling the site is: S = (A + 4) × (B + 4) = S bottom + 2L outside + 16;

[0122] In the formula: S is the amount of site leveling; A is the length of the outer edge of the exterior wall in the length direction of the building; B is the length of the outer edge of the exterior wall in the width direction of the building; Sbottom is the building area of ​​the ground floor of the building; Loutside is the perimeter of the outer edge of the exterior wall of the building.

[0123] This formula is applicable to the calculation of site leveling engineering quantity for any building or structure consisting of a rectangle

[0124] Question: It is known that the length of the outer edge of the exterior wall in the length direction of the building is 20 meters, and the length of the outer edge of the exterior wall in the width direction of the building is 30 meters. Please help me calculate the workload of leveling the site?

[0125] Correct answer: 816

[0126] Before fine-tuning, calling the tool failed and got the wrong answer

[0127] {"role":"system","content":"You are an AI assistant whose task is to provide appropriate responses and support to users' questions and requests."}

[0128] {“role”: “user”, “content”: “Given that the length of the outer edge of the building’s exterior wall is 20 meters in the length direction and 30 meters in the width direction, please help me calculate the amount of work required to level the site.”}

[0129] {'role': 'assistant', 'content': 'To calculate the site leveling work quantity, we need to know the following information:

[0130] 1. Ground undulations: whether there are height differences, slopes, etc.

[0131] 2. Leveling standards: for example, the elevation or level that the ground needs to reach.

[0132] In the absence of these specific information, we can make a simple estimate. Usually, the amount of work required to level the site can be roughly estimated by the following steps:

[0133] **Step 1: Determine the building's footprint**

[0134] —The building is 20 meters long and 30 meters wide, so its floor area is:

[0135] Area = length × width = 20 meters × 30 meters = 600 square meters

[0136] *Step 2: Assume that the entire site needs to be leveled**

[0137] —If we assume that the entire site (including around the building) needs to be leveled to the same height, then the work volume is these 600 square meters.

[0138] However, the following factors need to be considered in actual situations:

[0139] **Slope and foundation depth**: If excavation or backfilling is required to form a certain slope, or the foundation is reinforced, this will increase the additional earthwork volume.

[0140] **Original ground conditions**: If the site is uneven, cut-and-fill balancing may be required, that is, taking away some soil and filling it with soil from other places, so the actual material required may be less than or equal to 600 square meters. **Safety distance**: In order to ensure construction safety and meet regulatory requirements, a certain range of safety distance is usually reserved, which also needs to be taken into consideration.

[0141] In the absence of the above detailed information, here are some simple estimates for a few different scenarios:

[0142] 1. **Leveling only the area where the building is located**: about 600 cubic meters (assuming an average thickness of 0.5 meters per square meter).

[0143] 2. **Including the area within 3 meters around the building**: approximately 960 cubic meters (an additional 36 square meters of area, the thickness is also calculated as 0.5 meters).

[0144] 3. **Wider Area**: Expand area and thickness calculations based on specific circumstances.

[0145] Please note that the above are estimates based on simplified models, and the actual site leveling work may be different. In specific engineering projects, professional engineers should perform detailed calculations based on site conditions and design drawings. '}

[0146] After fine-tuning, the model enhances the tool calling function and answers correctly in combination with the tool.

[0147] {"role":"system","content":"You are an AI assistant whose task is to provide appropriate responses and support to users' questions and requests."}

[0148] {“role”: “user”, “content”: “Given that the length of the outer edge of the building’s exterior wall is 20 meters in the length direction and 30 meters in the width direction, please help me calculate the amount of work required to level the site.”}

[0149] {"role":"tool","content":"calculate_leveled_area,{"L":20.0,"W":30.0},The result of building quantity calculated by calling the tool is: 816.0"}

[0150] ('role': 'assistant', 'content': 'Based on the length and width of the building you provided (20 meters and 30 meters respectively), it is calculated that the site leveling work is approximately 816 square meters. This is based on a simple calculation of the outer edge area of ​​the exterior wall. Please note that other factors such as foundation conditions and building structure may need to be considered in actual construction, so this value is for reference only.'}

[0151] Calculate_leveled_area is a custom plug-in, which needs to be implemented by writing program code or external service API. You only need to input the length and width of the site, and the plug-in will calculate the leveling volume and return the correct result to the large model. This is implemented through a custom function.

[0152] Custom plugin information

[0153] "name":"calculate_leveled_area",

[0154] "description":"Calculate the amount of work for leveling the site",

[0155] "parameters":{"type":"object",

[0156] "properties":{

[0157] "L":{

[0158] "type":"float",

[0159] "description":"Length",

[0160] },

[0161] "W":{

[0162] "type":"float",

[0163] "description":"Width",

[0164] },

[0165] },

[0166] "required":["L","W"],

[0167] }

[0168] Custom plugins:

[0169] def calculate_leveled_area(L,W):

[0170] S=(L+4)*(W+4)

[0171] return S

[0172] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A plug-in calling method for a large model with fine-tuning of plug-in calling capability, characterized in that: The specific steps include: Construct a training sample set; Design fine-tuning modules based on the original large model; Modify the original large model architecture and add the fine-tuning module to the original large model; Choose how to add the fine-tuning module to the original large model architecture: If the adding type is serial mode, then, During training, the weights of the original large model are frozen, and the fine-tuning modules added to the original large model architecture are trained. After the training is completed, the plug-in calls the large model. If the adding type is parallel, then, During training, the weights of the original large model are frozen, and the fine-tuning module added to the original large model architecture is trained. After the training is completed, the weights of the fine-tuning module and the original large model are merged to obtain the large model called by the plug-in.

2. The plug-in calling method for a large model with fine-tuning of plug-in calling capability according to claim 1, characterized in that: The specific steps of modifying the original large model architecture include: Design the fine-tuning position as needed, and insert the fine-tuning module at the position of each layer that needs fine-tuning.

3. The plug-in calling method for a large model with fine-tuning of plug-in calling capability according to claim 2, characterized in that: When the inserting fine-tuning module is added in series, the method specifically includes: connecting the fine-tuning module in series with each layer that needs to be fine-tuned, wherein the serial connection includes: Insert the fine-tuning module after the layer of the original large model that needs to be fine-tuned, and connect it in series with the layer of the original large model that needs to be fine-tuned and the next layer of the layer of the original model that needs to be fine-tuned; When initializing a fine-tuning module, ensure that the input dimensions of the fine-tuning module match the output dimensions of the fine-tuning layers of the model, and that the output dimensions match the input dimensions of subsequent layers of the model.

4. The plug-in calling method for a large model with fine-tuning of plug-in calling capability according to claim 2, characterized in that: When inserting the fine-tuning module, when the adding type is in parallel, it specifically includes: connecting the fine-tuning module in parallel with each layer that needs to be fine-tuned linear transformation.

5. The plug-in calling method for a large model with fine-tuning of plug-in calling capability according to claim 1, characterized in that: The sample template of the sample set includes six parts: context, plug-in set, user question, called plug-in information, plug-in call result and model answer; The context is used to provide current background information; The plug-in set includes at least one plug-in, and each plug-in includes a plug-in name, a plug-in function description, and a plug-in parameter set; The user question is information input by the user on the client; The called plug-in information includes a plug-in name and a plug-in parameter set; The plug-in call result is the result returned by passing the input parameters to the called plug-in and processing by the plug-in; The model answer is the answer given by the model after obtaining the plug-in call result and combining all known information.

6. The plug-in calling method for a large model with fine-tuning of plug-in calling capability according to claim 5, characterized in that: The plug-in parameter set field declares the type of the parameter set, the parameter field set, and the parameter set that must be input; The parameter set type is in the form of key-value pairs; The parameter field set uses the parameter name as the key and the detailed information of the parameter as the value; The detailed information of the parameter includes the type, unit and detailed meaning description of the parameter.

7. The plug-in calling method for a large model with fine-tuning of plug-in calling capability according to claim 1, characterized in that: The specific steps of constructing a training sample set include: taking the text constructed by the context, plug-in set, user questions, called plug-in information, plug-in call results and model answers as input of training data, taking the called plug-in information, plug-in call results and model answers as labels, and constructing training samples.

8. The plug-in calling method for a large model with fine-tuning of plug-in calling capability according to claim 4, characterized in that: The specific steps of training include: Use the weight update matrix ΔW to linearly transform the weight matrix W0 of the pre-trained model, where W0∈Rd×k; At the beginning of training, the weight update ΔW is decomposed into the product of two low-rank matrices, and ΔW = BA is obtained, where B ∈ Rd×r, A ∈ Rr×k, and the rank r <<min(d,k); According to ΔW=BA, matrix A is initialized with random Gaussian distribution and matrix B is initialized to a zero matrix. During the training process, the pre-trained weight matrix W0 remains unchanged, and only the parameters of the low-rank matrices A and B are updated.

9. The plug-in calling method for a large model with fine-tuning of plug-in calling capability according to claim 8, characterized in that: The steps of merging the trained fine-tuning module weights with the original large model include: The weight merging calculation steps include: W′=W0+ΔW Where W0 represents the weight of the original large model, ΔW represents the weight of the fine-tuning module after fine-tuning, and W′ represents the weight of the merged model.

Citation Information

Patent Citations

  • Code processing model training method and device, electronic equipment and storage medium

    CN116820429A

  • Speech recognition fine tuning task acceleration method based on low-rank matrix approximation

    CN117059103A

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

    CN117112065A

  • Model training method and device, plug-in prediction method and device, equipment, medium and product

    CN117668560A

  • Service plug-in calling method based on large language model

    CN118193174A

Cited By

  • Code processing method, code repairing method and model request processing method

    CN120950373A