Method, device and medium for calling functions of large models
By combining a clustering compression model with semantic and contextual features, function calls are dynamically optimized, solving the problem of low efficiency in function call processing in existing technologies and achieving efficient and fast function call processing and improved system performance.
Patent Information
- Application Number
- CN202511046975.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-29
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2045-07-29
AI Technical Summary
Existing technologies significantly increase computation and response latency when handling a large number of function calls, especially in scenarios involving multiple plugins, agent collaboration, or multi-window contexts, leading to a decline in system performance and user experience. Furthermore, existing clustering methods have failed to effectively optimize function call classification and clustering, resulting in low efficiency.
A dynamic optimization method based on a clustering compression model is adopted, which combines semantic features, contextual features and multi-label classification mechanism to accurately classify and optimize function calls. Furthermore, by introducing a reward evaluation function and a policy aggregator, the clustering effect is optimized, thereby improving the system's adaptability and performance.
It significantly improves the efficiency of large models when handling a large number of function calls, reduces computational overhead, improves response speed and resource utilization, and ensures the preservation of key information and efficient system operation.
Smart Images

Figure CN120541352B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network communication technology, and more specifically to a method, device, and medium for calling functions using a large model. Background Technology
[0002] In modern large-scale computing systems and artificial intelligence applications, handling massive amounts of function calls and contextual information has become a challenge. With technological advancements, many fields, particularly in welfare recommendation, intelligent customer service, and scenarios involving multi-plugin and intelligent agent collaboration, require systems to process thousands of function calls in real time, often containing complex contextual information. Traditional methods primarily rely on simple rules or matching based on statically predefined patterns for function call processing. However, this approach cannot effectively address the performance bottlenecks caused by massive amounts of data and the dynamic changes in contextual information.
[0003] In existing technologies, large language models (such as GPT and Claude) generally use context-based protocols (MCPs) for function call transmission. These models structure multi-dimensional information such as user commands, historical dialogues, task objectives, and system prompts before passing them to the model interface. While this method improves the flexibility and responsiveness of the model to some extent, the number of function calls passed to the model has also increased rapidly with the dramatic increase in the number of integrated MCP tools. Especially in scenarios with multiple plugins, agent collaboration, or multi-window contexts, each call may contain hundreds or thousands of function calls, leading to a significant increase in system computation and response latency, which seriously affects system performance and user experience.
[0004] Especially in applications such as welfare recommendation or planning, some tasks require the model to continuously iterate to find the optimal solution. This causes function calls to accumulate in a long loop, resulting in huge token consumption and performance loss. Faced with these challenges, existing solutions have failed to effectively optimize the classification and clustering of function calls, leading to inefficiency when handling high-frequency and large-scale function calls.
[0005] To address these issues, the industry has proposed a technical solution for function call clustering compression. This solution groups similar function calls using clustering algorithms, thereby reducing the number of function calls processed and thus lowering computational complexity. However, existing clustering methods are typically based on static feature extraction and clustering rules, failing to fully consider the changing context information and the dynamic nature of function calls. This results in suboptimal clustering performance in certain scenarios and can easily lead to information loss and inaccurate classification in practical applications. Summary of the Invention
[0006] To address the aforementioned issues, this invention proposes a dynamic optimization method based on a clustering compression model. This method aims to accurately classify and optimize function calls to be compressed by combining semantic features, contextual features, and a multi-label classification mechanism, thereby effectively reducing the computational overhead of the system and improving the processing efficiency and response speed of function calls.
[0007] Furthermore, by introducing a reward evaluation function and a policy aggregator, this invention employs a reinforcement learning mechanism during function call compression to further optimize the clustering effect and improve the system's adaptability and performance in large-scale function call scenarios.
[0008] According to a first aspect of this disclosure, a method for calling functions in a large model is provided, characterized in that the method includes: obtaining raw function calls for calling a large model context protocol server; determining scene features of the raw function calls using a feature recognition model; classifying the raw function calls into function calls to be retained and function calls to be compressed based on the scene features and the raw function calls using an aggregation strategy model; performing clustering on the function calls to be compressed using a clustering compression model to obtain clustered function calls; and injecting the function calls to be retained and the clustered function calls into a large model for invocation.
[0009] In one or more methods, determining the scene features of the original function call using a feature recognition model includes: acquiring historical data about the scene features; constructing a feature recognition model using a pre-trained language model based on the acquired historical data; determining one or more semantic features of the original function call using the feature recognition model; determining the label probabilities of one or more semantic features of the original function call using a multi-label classification head; and determining the scene features of the original function call based on the determined label probabilities.
[0010] In one or more methods, performing clustering on the function call to be compressed using a clustering compression model includes: using a feature recognition model to obtain semantic features and contextual features of the function call to be compressed; combining the semantic features and the contextual features to obtain an input vector passed to the clustering compression model; performing inductive processing on the semantic features based on a template induction model to obtain a standardized function call template; and performing clustering processing on the input vector using the clustering compression model based on the formed function call template to obtain clustered function calls.
[0011] In one or more methods, performing clustering processing on the input vector using a clustering compression model further includes: using a reinforcement scoring function to determine the importance parameters of the original function call for optimizing the quality of clustering compression.
[0012] In one or more methods, determining the importance parameters for optimizing cluster compression quality of the original function call using a reinforcement scoring function includes: determining the reward function and penalty function in the reinforcement scoring function; constructing a reward evaluator based on the determined reward function and penalty function; and adjusting the clustering strategy of the cluster compression model using the reward evaluator to obtain the clustering function call.
[0013] In one or more methods, using an aggregation strategy model, classifying the original function calls into function calls to be retained and function calls to be compressed based on the scenario features and the original function calls includes: using a feature recognition model to obtain semantic features and contextual features of the original function calls; based on the semantic features and contextual features, the strategy aggregator generates a priority strategy according to the semantic features and contextual information of the function calls to be compressed; and based on the priority strategy, classifying the original function calls into function calls to be retained and function calls to be compressed.
[0014] In one or more methods, an aggregation strategy model, including a Transformer model and a multilayer perceptron, is used to determine a prioritization strategy for the function call. The Transformer model is configured to convey semantic and contextual features of the original function call, and the multilayer perceptron is configured to compute the classification probability of the function call.
[0015] According to a second aspect of this disclosure, a computing device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; the memory storing instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method of the first aspect of this disclosure.
[0016] In a third aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause a computer to perform the method of the first aspect of this disclosure.
[0017] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0018] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. In the drawings, the same or similar reference numerals denote the same or similar elements.
[0019] Figure 1 A schematic diagram of a system for implementing a large model calling function method according to an embodiment of the present disclosure is shown.
[0020] Figure 2 A flowchart of a large model calling function method 200 according to an embodiment of the present disclosure is shown.
[0021] Figure 3 A block diagram of an electronic device according to an embodiment of the present disclosure is shown. Detailed Implementation
[0022] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0023] The term "comprising" and its variations as used herein signify open inclusion, i.e., "including but not limited to". Unless otherwise stated, the term "or" means "and / or". The term "based on" means "at least partially based on". The terms "one example embodiment" and "one embodiment" mean "at least one example embodiment". The term "another embodiment" means "at least one additional embodiment". The terms "first", "second", etc., may refer to different or the same objects. Other explicit and implicit definitions may also be included below.
[0024] Figure 1 A schematic diagram of a system for implementing a large model calling function method according to embodiments of the present disclosure is shown. Figure 1 As shown, the system includes a computing device 110, a network management device 130, and a network 140. The computing device 110 and the network management device 130 can interact with each other via the network 140 (e.g., the Internet).
[0025] The computing device 110 receives raw function call data, performs function call classification, clustering, and compression operations, and passes the results to a large model. The computing device 110 may include one or more processing units, such as a CPU, GPU, FPGA, etc., or it may be a desktop computer, laptop, tablet, etc. The computing device 110 is responsible for processing the function call data received from the network management device 130 and executing the various functions in the method.
[0026] Network management device 130 manages the context protocol server (MCP server) for large models and performs preliminary processing on function call data received from computing device 110. Network management device 130 interacts with computing device 110 via network 140, performing classification, compression, and optimization operations on function calls. This device includes dedicated hardware processing units, such as GPUs and ASICs, responsible for efficiently executing model training and inference operations.
[0027] Network 140 is used to connect computing device 110 and network management device 130 to transmit data and model information. Network 140 can be the Internet or a local area network, used to support remote computing and data interaction for large model function calls.
[0028] The computing device 110 receives raw function call data from the network management device 130. These raw function calls contain instructions and parameters that the large model needs to process. Raw function calls typically include multi-dimensional information, such as user input, historical dialogue records, task objectives, and system prompts.
[0029] The computing device 110 performs scene feature analysis on the original function calls using a feature recognition model. The feature recognition model extracts semantic and contextual features relevant to the current task based on the content of the original function calls. For example, if the call involves welfare recommendations, the model can identify the scene feature "holiday welfare". The computing device 110 uses an aggregation strategy model to classify function calls into "function calls to be retained" or "function calls to be compressed" based on the extracted scene features and the content of the original function calls. This step uses the aggregation strategy model to determine the priority of function calls and ensure that important function calls are not compressed. For function calls marked as to be compressed, the computing device 110 performs clustering operations using a clustering compression model. The clustering compression model analyzes the similarity features between function calls to be compressed, aggregating them into representative calls, thereby reducing redundant information and compressing the number of function calls. This process greatly improves the efficiency of system processing.
[0030] Finally, computing device 110 injects the function calls to be retained and the clustered and compressed function calls into the large model for final processing. The large model performs corresponding tasks based on these function calls, such as generating responses or performing specific operations. In this way, the system can efficiently process large amounts of function call data and reduce computational overhead.
[0031] Network management device 130 receives function call requests from external systems or users via network 140 and transmits the raw function calls to computing device 110. Computing device 110 processes the raw function calls, first extracting scene features using a feature recognition model, then classifying the function calls using an aggregation strategy model, ultimately determining which function calls need to be retained and which can be compressed. For the function calls to be compressed, computing device 110 performs clustering operations using a clustering compression model and generates compressed function calls. Finally, computing device 110 injects all processed function calls into a large model. The large model responds based on these optimized function calls, fulfilling user requests or executing specified tasks.
[0032] By implementing this method, computing device 110 can significantly improve the efficiency of large models when processing a large number of function calls. Through precise classification and compression operations, computing device 110 reduces unnecessary computation and memory consumption, thereby improving the response speed and performance of large models. This optimization method is applicable to various scenarios that require processing complex contexts and high-frequency function calls, effectively reducing the computational load of computing device 110 and improving resource utilization.
[0033] Note that the computing device 110 may have one or more processing units, including dedicated processing units such as GPUs, FPGAs, and ASICs, as well as general-purpose processing units such as CPUs. Additionally, one or more virtual machines may run on each computing device 110. In some embodiments, the computing device 110 and the network management device 130 may be integrated together or configured separately.
[0034] Figure 2 A flowchart of a large model calling function method 200 according to an embodiment of the present disclosure is shown. Method 200 may be performed by, for example... Figure 1 The computing device 110 shown can be used for execution, and can also be used in Figure 3 The method is performed at the illustrated electronic device 300. It should be understood that method 200 may also include additional boxes not shown and / or the boxes shown may be omitted, and the scope of this disclosure is not limited in this respect.
[0035] In step 202, the original function call used for the large model context protocol server call is obtained.
[0036] In one embodiment, raw function call data can be received from an external system and passed to a Large Model Context Protocol (MCP) server for further processing.
[0037] In practical applications, raw function calls typically originate from multiple input sources, such as user requests, historical dialogue records, task objectives, or instructions from external systems. These input sources may include various types of data, such as text, commands, and parameter settings. For example, in an intelligent customer service scenario, a user might submit requests to computing device 110 such as "inquire about holiday benefits" or "obtain reimbursement procedures." Computing device 110 needs to transform these requests into raw function calls and pass them to the large model context protocol server.
[0038] First, the computing device connects to external systems (such as user terminals and business systems) via a network to receive user requests. For each user request, the computing device 110 parses it into a corresponding raw function call. For example, if a user requests "query holiday benefits," the computing device 110 will parse this request into a raw function call, which includes information such as the query task, task type (holiday benefits), and parameters (such as date, user identity, etc.). This parsed function call data typically includes multiple fields, such as:
[0039] Function name: Indicates the function being called (e.g., "Query benefits").
[0040] Parameters: These include the specific data required for the function call (such as "holiday" type, query date, user information, etc.).
[0041] Contextual information: such as the user's current request context, historical dialogue content, or task goal, helps the large model understand the background information of the function call.
[0042] The computing device transmits these raw function call data to the context protocol server of the large model via a network protocol. The large model context protocol server is responsible for receiving these function calls and processing them according to the rules set by the computing device 110. The context protocol server performs context matching on the incoming raw function calls and further formats them into a structure that the large model can recognize for use in subsequent task processing.
[0043] In some application scenarios, multiple raw function calls may be passed in simultaneously, and these calls may contain complex information across multiple dimensions. For example, in a scenario where multiple plugins work together, a user request may involve multiple independent function calls. In this case, the computing device 110 needs to determine how to pass these function calls to the large model based on the priority and task type of each function call to ensure effectiveness and efficiency in subsequent processing.
[0044] Finally, upon receiving these raw function calls, the large model context protocol server performs further classification, feature extraction, or aggregation according to predetermined processing rules, so that the function calls can be passed to subsequent model components for specific processing. In this way, the raw function call data is effectively organized and passed to the large model, providing a foundation for the model's subsequent decisions and operations.
[0045] In step 204, the scene features of the original function call are determined using a feature recognition model.
[0046] In one embodiment, a feature recognition model can be used to determine the context features of the original function call. This process includes acquiring context feature information from historical data, constructing a feature recognition model using a pre-trained language model, and determining the semantic features of the original function call based on a multi-label classification head. Through these steps, the computing device 110 can accurately identify the application context of the original function call, thereby helping the large model make more accurate decisions in subsequent processing.
[0047] Scene characteristics can be obtained by collecting historical data. Historical data includes past function call records, task objective information, user interaction records, etc. This data can help the feature recognition model understand the characteristics of each scene and the behavioral patterns of original function calls under different scenes. For example, in a welfare recommendation system, historical data may include different users' holiday welfare query records, reimbursement process query records, etc. By analyzing this historical data, computing device 110 can provide rich contextual information for the feature recognition model.
[0048] The computing device 110 uses a pre-trained language model based on historical data to construct a feature recognition model. Pre-trained language models are typically trained on large-scale text datasets, effectively capturing semantic and contextual information within the text. In this embodiment, the feature recognition model automatically extracts semantic and contextual features related to each original function call by inputting function call samples from historical data and combining the knowledge from the pre-trained language model. For example, the pre-trained model can identify the relevance of a function call to scenarios such as holiday benefits and reimbursement processes.
[0049] Using these semantic features, the feature recognition model further determines the contextual characteristics of the original function call. The computing device 110 analyzes the content of the function call to extract one or more key semantic features. These semantic features represent the specific context in which the original function call occurs, such as "holiday benefits" or "reimbursement process." Based on these features, the computing device 110 can accurately label the function call and classify it into the corresponding application scenario.
[0050] Based on this, the computing device 110 uses a multi-label classification head to predict the label probability of the semantic features of each original function call. The multi-label classification head calculates the probability of each scene label based on the semantic features extracted by the feature recognition model. For example, the computing device 110 can calculate the probability of the "holiday benefits" label as 0.8 and the probability of the "reimbursement process" label as 0.2. These probabilities reflect the computing device 110's confidence level in each scene label, helping it determine which label is more suitable for the current function call.
[0051] Finally, based on the probabilities of these labels, the computing device 110 can accurately determine the scenario characteristics of the original function call. This determination process is based not only on label probabilities but also on the contextual information of the function call to ensure accurate identification of scenario characteristics. For example, if the probability of the "holiday benefits" label is high, the computing device 110 will classify the function call as a scenario of holiday benefits query and perform corresponding processing.
[0052] In a specific application scenario, suppose a user requests "whether there are extra subsidies for next year's Spring Festival." The computing device 110 needs to determine the scenario characteristics of this function call. The computing device 110 first acquires historical data about this scenario, which may include the user's past welfare query records and historical data on holiday benefits. Next, the computing device 110 uses a pre-trained language model to process the request, extracting semantic features such as "Spring Festival" and "subsidy." Based on these features, the feature recognition model determines that the request belongs to a holiday welfare query scenario.
[0053] The computing device 110 can use a multi-label classification head to predict the probability value of the "Spring Festival benefits" label. If the probability of the "Spring Festival benefits" label is 0.9 and the probability of the "other benefits" label is 0.1, the computing device 110 will finally determine that the scenario feature of the function call is a "holiday benefits" query, and pass the call to the processing module of the large model for further processing.
[0054] Through the above embodiments, the computing device 110 can accurately identify the application scenario corresponding to the original function call, providing an important basis for subsequent function call classification, clustering and compression, and ultimately improving the processing efficiency and response speed of the computing device 110.
[0055] In step 206, using the aggregation strategy model, based on the scenario features and the original function calls, the original function calls are classified into function calls to be retained and function calls to be compressed.
[0056] This embodiment describes the specific steps of classifying raw function calls into functions to be retained or functions to be compressed based on scenario characteristics and the raw function calls using an aggregation strategy model. This process is implemented through a feature recognition model, a strategy aggregator, and an aggregation strategy model (including a Transformer model and a multilayer perceptron). In this way, the computing device 110 can flexibly decide which function calls need to be retained and which can be compressed in large-scale function call scenarios, thereby improving computational efficiency and reducing the burden on the computing device 110.
[0057] First, the computing device extracts semantic and contextual features from the original function call using a feature recognition model. These features are obtained by analyzing the content of the original function call. Semantic features may include task type, parameter information, and scene tags, while contextual features include the user's historical interaction information and the background of the current request. For example, in a welfare recommendation system, semantic features might include "holiday benefits" and "reimbursement process," while contextual features might include the user's past welfare query records or the current task objective. The feature recognition model then passes this information to a subsequent aggregation strategy model for classification processing.
[0058] Next, based on the extracted semantic and contextual features, the policy aggregator generates corresponding priority policies. Specifically, the policy aggregator uses these features to evaluate the priority of function calls and assigns them to different categories based on the evaluation results. For function calls to be compressed, the policy aggregator decides whether to compress them based on their priority and contextual information. This process, through in-depth analysis of the semantic information of function calls, ensures that the compression policy does not lose important information and prioritizes retaining function calls that are crucial to the task.
[0059] In this process, the aggregation strategy model employs a combination of Transformer and Multilayer Perceptron (MLP) models to further optimize function call classification. The Transformer model is configured to transmit the semantic and contextual features of the original function calls. Through its self-attention mechanism, the Transformer performs deep processing on the input features, capturing global contextual relationships and semantic dependencies, ensuring that the contextual information of each function call is fully transmitted. The Multilayer Perceptron (MLP) is responsible for calculating the classification probability of each function call and generating a priority strategy based on these probabilities. Specifically, the MLP calculates the probability that each function call belongs to the class to be retained or the class to be compressed based on the input features, thus providing a decision-making basis for the policy aggregator.
[0060] Finally, based on the calculated priority strategy, computing device 110 classifies the original function calls into "function calls to be retained" or "function calls to be compressed". Function calls to be retained will continue to be used in subsequent processing, while function calls to be compressed will be merged, simplified or excluded to reduce the computational overhead of computing device 110.
[0061] In a specific application scenario, suppose a user requests "check if there are any extra subsidies during the Spring Festival". The computing device 110 needs to classify the original function call into a function call to be retained or a function call to be compressed through the above process.
[0062] First, the computing device uses a feature recognition model to extract semantic features of the request, such as "Spring Festival benefits" and "subsidies." Contextual features include the user's past benefit query history and task objective (e.g., querying benefits related to holidays). Then, the computing device passes these features to a policy aggregator, which evaluates the priority of the request based on these features.
[0063] Next, the strategy aggregator passes semantic and contextual features through a Transformer model and performs deep processing to capture holiday-related semantic information and background in the request. Based on the processed features, the MLP model calculates the probability that the function call belongs to the "holiday benefits" category and determines its priority. If the request is considered high-priority (e.g., the user has not recently queried relevant information and the request is very important in the current task), the request is marked as a function call to be retained; otherwise, if the request is considered redundant (e.g., the user has queried the same information multiple times), the request is classified as a function call to be compressed.
[0064] Based on a priority strategy, computing device 110 categorizes raw function calls into those to be retained or those to be compressed, providing input for subsequent processing. This ensures that computing device 110 can flexibly handle function calls in different scenarios and improves overall efficiency.
[0065] In step 208, the clustering compression model is used to perform clustering on the function calls to be compressed in order to obtain the clustered function calls.
[0066] Clustering compression models can be used to perform clustering processing on function calls to be compressed. This process includes obtaining the semantic and contextual features of the function calls to be compressed, performing standardization using a template inductive model, optimizing the clustering using a clustering compression model, and adjusting the clustering strategy by strengthening the scoring function to obtain the final clustered function calls.
[0067] The computing device 110 acquires semantic and contextual features about the function call to be compressed through a feature recognition model. Semantic features may include information such as keywords, parameters, and task objectives in the original function call, while contextual features include background information related to the function call, such as the user's historical interaction records, current task status, and scene tags. Through in-depth analysis of the function call to be compressed, the feature recognition model can extract this important information that is helpful for classification and clustering.
[0068] The computing device 110 combines the extracted semantic and contextual features to generate an input vector. These features are concatenated into a multi-dimensional vector and passed as input to the clustering compression model, ready for subsequent clustering operations. In this way, the clustering compression model can perform the clustering process based on comprehensive feature information, ensuring that the function calls after clustering can fully reflect the needs of different tasks and scenarios.
[0069] Template induction models perform inductive processing on the extracted semantic features. By learning from a large amount of function call data, template induction models automatically generate standardized function call templates. These templates help the system unify the format of different function calls, thereby reducing the diversity and complexity of function calls and making the clustering process more efficient. Through template induction, the system can ensure semantic consistency among different function calls, thus improving the performance of the clustering compression model.
[0070] During the clustering process, computing device 110 uses a clustering compression model to cluster the generated input vectors. The clustering compression model groups the function calls to be compressed based on the similarity of the input vectors, ensuring that similar function calls are classified into the same category, thereby reducing redundancy and computational burden. Each group of similar function calls is compressed into a representative call, reducing unnecessary computation and improving processing efficiency.
[0071] To further optimize clustering compression quality, the system introduces a reinforcement scoring function to determine the importance parameters of each original function call. The reinforcement scoring function evaluates clustering quality by setting reward and penalty functions. The reward function rewards function calls that effectively retain important information, while the penalty function penalizes function calls that lose important information or generate information conflicts. Through a comprehensive evaluation of rewards and penalties, the system optimizes the clustering strategy, ensuring that the clustering process is efficient while preserving important semantic information.
[0072] Based on the determined reward and penalty functions, a reward evaluator is constructed. The reward evaluator dynamically adjusts the clustering strategy of the cluster compression model according to the output of the reinforcement scoring function. This adjustment allows the clustering model to optimize in each iteration based on historical data and real-time feedback, thereby obtaining more accurate and effective function call compression results.
[0073] The reward function, based on compressed function call information and human preference ratings, optimizes the quality of compressed function calls. The reward function comprises the following components: Token Saving, Semantic Coverage, and Conflict Penalty. Token Saving represents the number of tokens reduced after compression, Semantic Coverage represents the degree of coverage of the original intent after compression, and Conflict Penalty represents the penalty for information conflicts caused by clustering errors. Finally, the computing device 110 obtains clustered function calls based on the optimized clustering strategy. These clustered function calls effectively reduce the system's computational burden and improve the model's response speed and processing efficiency.
[0074] Specifically, the reward function can be expressed as:
[0075] R = w1 * Token_Saving + w2 * Semantic_Coverage - w3 * Conflict_Penalty
[0076] Here, Token_Saving represents how many fewer tokens the compressed function call has compared to the original function call. w1 is the token-saving weight vector awaiting training. Semantic_Coverage represents whether the compression result accurately covers the original intent (e.g., it can be measured using parameters such as BERTScore). w2 is the intent weight vector awaiting training. Conflict_Penalty represents whether ambiguity is introduced (e.g., different holidays are confused). w3 is the conflict penalty weight vector awaiting training.
[0077] In one embodiment, suppose the system is processing a user request to "query if there are any extra allowances during the 2022 Spring Festival". The computing device 110 first extracts semantic features of the request, such as "Spring Festival benefits" and "allowances," as well as contextual features, such as the user's historical query records and task objectives, using a feature recognition model. These features are then passed to a clustering compression model, where the computing device 110 generates an input vector, which is then standardized using a template induction model.
[0078] During the clustering process, computing device 110 optimizes the clustering effect by strengthening the scoring function. First, the reward function scores whether the compressed function call retains the key information of "Spring Festival benefits," while the penalty function penalizes whether related allowance information is lost. The system adjusts the clustering strategy through the reward evaluator to ensure that the final compressed function call not only reduces redundant information but also retains all key information.
[0079] Ultimately, the request is clustered into a representative function call and injected into the larger model for further processing. Through this process, the system can efficiently handle a large number of function calls while preserving important contextual and semantic information, thus improving the system's processing power and efficiency.
[0080] Through the technical solution of this embodiment, the computing device can effectively utilize a clustering compression model and a reinforced scoring function to perform clustering processing on function calls to be compressed. By combining semantic features, contextual features, and a template induction model, the system can reduce redundant information and optimize the clustering effect of function calls. Simultaneously, the introduction of the reinforced scoring function provides the clustering process with the ability to dynamically adjust, ensuring that each function call retains key information during compression, ultimately improving the system's processing efficiency and response speed.
[0081] In step 210, the function calls to be retained and the clustered function calls are injected into the large model for use.
[0082] In one embodiment, computing device 110 obtains categorized function calls from previous steps. After processing by an aggregation strategy model, function calls to be retained are marked as high priority and prepared for subsequent processing. Simultaneously, function calls compressed by a clustering compression model are marked as function calls to be compressed and have been compressed into representative function calls. The two types of function calls are stored in different queues, ready for injection into the larger model.
[0083] The computing device 110 organizes and sorts these two types of function calls—function calls to be retained and clustered function calls—according to a specific strategy. Function calls to be retained, due to their high priority, are typically placed in a priority processing queue, while clustered function calls are sent to their respective compression queues. During this process, the system ensures the timeliness of function calls to be retained, prioritizing their delivery to large models to respond to user requests as quickly as possible. The compressed function calls, by reducing the number of calls, decrease the computational burden on large models, further improving the model's operating efficiency.
[0084] The computing device 110 injects the processed function calls (including function calls to be retained and clustered function calls) into the input interface of the large model. Upon receiving these function calls, the large model uses its deep learning capabilities to process them and generate responses. For example, in an intelligent customer service system, the large model returns the results of user queries based on these function calls, such as the query results for "Are there any extra allowances during the Spring Festival?" or the relevant steps of the "reimbursement process".
[0085] In this process, computing device 110 ensures that the large model can flexibly adjust the processing order according to the priority and processing requirements of each function call. For example, function calls to be reserved are processed first by the large model to ensure timely response to critical user requests, while clustered function calls are processed without affecting system performance. This strategy ensures that the system utilizes computing resources efficiently while guaranteeing the accuracy and timeliness of responses.
[0086] Suppose the system is processing a series of user query requests. The user requests include "Query whether there are extra allowances during the 2022 Spring Festival" and "View the reimbursement process." Through previous steps, the system has processed these requests into function calls to be retained and clustered function calls, respectively. For the first request, "Query whether there are extra allowances during the 2022 Spring Festival," it is identified as an important function call to be retained, and the system will prioritize processing this request. The second request, "View the reimbursement process," is considered a common query and belongs to the category of function calls to be compressed.
[0087] The computing device 110 places the two function calls into their respective queues and, according to priority, injects the function calls to be retained into the large model for processing first. After the large model has finished processing the function calls to be retained, it then processes the clustered function calls. In this way, the system ensures that users receive timely and accurate responses while optimizing the use of computing resources.
[0088] Through the technical solution of this embodiment, the computing device can effectively inject classified and compressed function calls into a large model, thereby achieving efficient function call processing. Function calls to be retained are processed first, ensuring rapid responses to critical requests, while clustered function calls are processed without affecting system performance, thus improving overall computational efficiency and system response speed. This process not only optimizes the computational burden of the large model but also guarantees the timeliness and accuracy of the user experience.
[0089] In one embodiment, using method 200 as described above, suppose the system is handling an intelligent customer service scenario where user queries involve multiple questions, such as "Are there extra allowances for the Spring Festival?", "What are the items included in the company's health check-up?", and "What are the Spring Festival holiday arrangements?". These queries involve multiple functional modules and services, typically requiring separate calls to multiple functions. Without compression, the system must process each query request individually, leading to excessive computational resource consumption and long response times.
[0090] First, the user submitted query requests: "Are there any extra allowances for the Spring Festival?", "What are the items included in the company's health check-up?", and "What are the holiday arrangements for the Spring Festival?". The computing device 110 received the user's requests through the system and transformed them into raw function calls, which were then passed to the Large Model Context Protocol server (MCP server).
[0091] These requests include three functions: "allowance inquiry," "physical examination item inquiry," and "holiday arrangement inquiry." Each function call triggers multiple independent function requests, and the data in the original function calls may include the query type, parameters (such as date, user information, etc.), and user's historical interaction records.
[0092] The computing device 110 processes these raw function calls using a feature recognition model. The feature recognition model extracts semantic features (e.g., "allowance query," "physical examination item query") and contextual features (e.g., user identity information, historical query records) for each function call. For example, for the query "Is there an extra allowance for the Spring Festival?", the feature recognition model identifies "Spring Festival" and "allowance" as semantic features, and combines this with historical data to determine whether the user has previously queried related information, as contextual features.
[0093] After acquiring semantic and contextual features, the computing device 110 classifies these function calls using an aggregation strategy model. Based on the function call priority and context, the strategy model categorizes function calls into "function calls to be retained" and "function calls to be compressed."
[0094] For example, the system identifies the "Spring Festival allowance" query request as more important in the current task, so it classifies it as a function call to be retained and processes it first. Meanwhile, the "company health checkup program" query is marked as a function call to be compressed, as its frequent and similar queries can be merged and compressed, thereby reducing the computational burden.
[0095] For function calls to be compressed, the system uses a clustering compression model to further cluster them. Based on the similarity characteristics of function calls, the clustering compression model merges multiple similar function calls into a single representative function call, thereby reducing unnecessary redundant computation.
[0096] For example, the query for "Spring Festival allowance" may have multiple variations, such as "whether red envelopes were issued" or "whether shopping cards were issued". The system uses a clustering compression model to compress these variations into a unified function call: "Spring Festival welfare query", thereby reducing redundancy in the calculation.
[0097] To further optimize the clustering results, the system uses a reinforcement scoring function to evaluate the importance of each function call and dynamically adjusts the clustering strategy based on the evaluation results. The reinforcement scoring function determines the importance of each function call in the compression process based on the design of the reward and penalty functions.
[0098] If the compressed function call still retains the key information of the original request (such as "Spring Festival allowance" information), the reward function will give a higher score.
[0099] Penalty function: If compression results in the loss of important information or semantic confusion, the penalty function will reduce the compression quality.
[0100] In this way, the system can dynamically adjust the clustering compression model to ensure that important information is preserved as much as possible in each compression process, while reducing unnecessary computational burden.
[0101] Finally, the processed function calls to be retained and the clustered function calls are injected into the large model for final processing. The large model generates responses based on these inputs, such as returning results for user queries like "Is there an extra allowance for the Spring Festival?" or relevant items for "Company health check-up".
[0102] When injecting function calls into a large model, the system ensures that function calls to be retained are processed first, while compressed function calls are processed step by step without affecting the results, thereby ensuring the overall response speed and processing efficiency of the system.
[0103] By employing the above techniques, the computational burden can be reduced. Through clustering compression models and function call classification, the system can reduce redundant function calls, significantly alleviating the processing burden on computing devices. Especially in complex query scenarios, multiple similar function calls are compressed into a single function call, reducing data transmission and computational operations for each function call. By prioritizing the processing of function calls to be retained and efficiently processing function calls to be compressed, the system can significantly improve processing speed while maintaining accuracy. Particularly under high-concurrency requests, response time is greatly shortened, resulting in a significantly improved user experience. Function call compression reduces the system's consumption of computing resources, especially when facing a large number of requests, allowing the system to utilize CPU, memory, and other computing resources more efficiently, avoiding resource waste.
[0104] Finally, by introducing a reinforced scoring function and a reward evaluator, the system ensures that the compressed function calls do not lose critical information, and that the compression quality can be dynamically optimized. This guarantees the system's efficiency and accuracy, ensuring that important contextual information is not lost due to compression.
[0105] Figure 3 A schematic block diagram of an example electronic device 300 that can be used to implement embodiments of the present disclosure is shown. For example, such as Figure 1 The computing device 110 shown can be implemented by electronic device 300. For example... Figure 3 As shown, the electronic device 300 includes a central processing unit (CPU) 301, which can perform various appropriate actions and processes according to computer program instructions stored in read-only memory (ROM) 302 or loaded from storage unit 308 into random access memory (RAM) 303. The random access memory 303 may also store various programs and data required for the operation of the electronic device 300. The CPU 301, ROM 302, and RAM 303 are interconnected via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0106] Multiple components in electronic device 300 are connected to input / output interface 305, including: input unit 306, such as keyboard, mouse, microphone, etc.; output unit 307, such as various types of monitors, speakers, etc.; storage unit 308, such as disk, optical disk, etc.; and communication unit 309, such as network card, modem, wireless transceiver, etc. Communication unit 309 allows electronic device 300 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0107] The various processes and procedures described above, such as methods, may be executed by the central processing unit 301. For example, in some embodiments, the methods may be implemented as computer software programs tangibly contained in a machine-readable medium, such as storage unit 308. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 300 via read-only memory 302 and / or communication unit 309. When the computer program is loaded into random access memory 303 and executed by the central processing unit 301, one or more actions of the methods described above may be performed.
[0108] This disclosure relates to methods, apparatus, systems, electronic devices, computer-readable storage media, and / or computer program products. A computer program product may include computer-readable program instructions for performing various aspects of this disclosure.
[0109] Computer-readable storage media can be tangible devices capable of holding and storing instructions for use by an instruction execution device. Computer-readable storage media can be, for example—but not limited to—electrical storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination of the foregoing. The computer-readable storage media used herein are not to be construed as transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., light pulses through fiber optic cables), or electrical signals transmitted through wires.
[0110] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge computing devices. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to computer-readable storage media within the respective computing / processing device.
[0111] Computer program instructions used to perform the operations of this disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as the "C" language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing the status information of the computer-readable program instructions to implement various aspects of this disclosure.
[0112] Various aspects of this disclosure are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.
[0113] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processing unit of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.
[0114] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.
[0115] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction, which contains one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0116] Those skilled in the art will understand that the present invention is not limited to the embodiments described above, and that the invention may be implemented in many other forms without departing from its spirit and scope. Therefore, the examples and embodiments shown are to be considered illustrative rather than restrictive, and the invention may encompass various modifications and substitutions without departing from the spirit and scope of the invention as defined by the appended claims.
Claims
1. A method for calling functions in a large model, characterized in that, The method includes: Obtain the raw function call used for the large model context protocol server call; the raw function call comes from multiple input sources, including user requests, historical dialogue records, task objectives, or external system instructions; Determining the scene features of the original function call using a feature recognition model includes: acquiring historical data about the scene features; and constructing a feature recognition model using a pre-trained language model based on the acquired historical data. The historical data includes at least: past function call records, task target information, and user interaction records. Using an aggregation strategy model, based on the scenario features and the original function calls, the original function calls are classified into function calls to be retained and function calls to be compressed. Using a clustering compression model, clustering is performed on the function calls to be compressed to obtain clustered function calls; and The function calls to be retained and the clustered function calls are injected into the large model for use.
2. The method according to claim 1, characterized in that, Determining the scenario features of the original function call using a feature recognition model also includes: Using a feature recognition model, one or more semantic features of the original function call are determined; Using a multi-label classification head, determine the label probabilities of one or more semantic features of the original function call; and Based on the determined label probabilities, the scenario characteristics of the original function call are determined.
3. The method according to claim 1, characterized in that, The step of performing clustering on the function to be compressed using a clustering compression model includes: Using a feature recognition model, semantic and contextual features of the function call to be compressed are obtained; The semantic features and the context features are combined to obtain the input vector that is passed to the clustering compression model; Based on a template inductive model, the semantic features are inductively processed to obtain standardized function call templates; and Based on the formed function call template, a clustering compression model is used to perform clustering processing on the input vector to obtain clustered function calls.
4. The method according to claim 3, characterized in that, The step of performing clustering processing on the input vector using a clustering compression model further includes: using a reinforcement scoring function to determine the importance parameters of the original function call for optimizing the clustering compression quality.
5. The method according to claim 4, characterized in that, The importance parameters for optimizing cluster compression quality of the original function call, determined using the enhanced scoring function, include: Determine the reward and penalty functions in the reinforcement scoring function; Based on the determined reward and penalty functions, construct a reward evaluator; Using the reward evaluator, the clustering strategy of the clustering compression model is adjusted to obtain the clustering function call.
6. The method according to claim 1, characterized in that, The aggregation strategy model, based on the scenario features and the original function calls, classifies the original function calls into function calls to be retained and function calls to be compressed, including: Using a feature recognition model, semantic and contextual features of the original function call are obtained; Based on the semantic and contextual features, the policy aggregator generates a priority policy according to the semantic features and contextual information of the function call to be compressed; Based on the aforementioned priority strategy, raw function calls are categorized into function calls to be retained and function calls to be compressed.
7. The method according to claim 6, characterized in that, The aggregation strategy model includes the Transformer model and the multilayer perceptron. The Transformer model is configured to convey the semantic and contextual features of the original function call; as well as The multilayer perceptron is configured to calculate the classification probability of the function call, thereby determining the priority strategy for the function call.
8. A computing device, characterized in that, include: At least one processing unit; At least one memory coupled to the at least one processing unit and storing instructions for execution by the at least one processing unit, the instructions, when executed by the at least one processing unit, causing the device to perform the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Rust language document test automatic generation method and device based on large code model
CN117951038A
Course learning and reinforcement learning driven dynamic optimal self-consistent clustering method
CN120372315A