Zero-sample difficulty perception based large language model routing method, device and equipment

By employing a zero-shot difficulty-aware approach, utilizing item response theory and the DistilBERT model to predict the difficulty of query suggestions, and combining this with a linear integer programming algorithm to dynamically select a large language model, the problem of high computational cost and low efficiency caused by model locking is solved, achieving efficient and scalable model selection.

CN120407739BActive Publication Date: 2026-11-27UNIV OF SCI & TECH OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510472945.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-16
Publication Date
2026-11-27
Estimated Expiration
2045-04-16

AI Technical Summary

Technical Problem

Current large language model routing frameworks lack dynamic adaptation mechanisms due to model locking, resulting in inefficient use of models of different sizes, high computational costs, and low efficiency. Furthermore, existing prediction methods lack cross-domain generalization capabilities or require expensive resource updates.

Method used

By using a zero-shot difficulty-aware approach, we predict the difficulty of query suggestions using item response theory and the DistilBERT model. Combined with a linear integer programming algorithm, we dynamically select the optimal large language model to balance cost and performance, and establish a model-independent relationship between difficulty value and performance/cost.

Benefits of technology

It enables efficient evaluation of new integrated large language models with limited sample data, dynamically selects the optimal model, reduces operating costs, improves the scalability and efficiency of the LLM ecosystem, and solves the problem of insufficient cross-domain generalization ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407739B_ABST
    Figure CN120407739B_ABST
Patent Text Reader

Abstract

The present disclosure belongs to the technical field of artificial intelligence, and particularly relates to a large language model routing method, device and equipment based on zero-shot difficulty perception. The method comprises the following steps: determining the relationship between the performance and cost and difficulty of a candidate large language model based on sample data, wherein the sample data is generated by sampling a preset data set, the data in the data set is a pre-calibrated difficulty query prompt word, and the difficulty is determined by the text attribute of the query prompt word; obtaining a query prompt word and predicting the difficulty of the query prompt word; estimating the cost and performance of each candidate large language model based on the difficulty of the query prompt word, and determining a large language model for processing the query prompt word from the candidate large language models based on the cost and performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure belongs to the field of artificial intelligence technology, specifically relating to a routing method, apparatus, and device for a large language model based on zero-sample difficulty perception. Background Technology

[0002] Currently, cloud platforms like Amazon Web Services host a large number of large language models to meet diverse user needs. Among them, larger models usually have higher performance, but the high computational cost of large-scale language models makes them very inefficient in processing daily queries, which can actually be effectively solved by smaller models.

[0003] However, current large language model routing frameworks are plagued by model locking and lack dynamic adaptation mechanisms. This forces current large language model routing frameworks to either restrict deployment to static model libraries, potentially sacrificing performance improvements, or to absorb high operational latency and computational costs to completely overhaul the routing logic, which disrupts the scalable and cost-aware alignment between the model and the task. Summary of the Invention

[0004] This disclosure proposes a routing scheme for large language models based on zero-sample difficulty awareness to address the problem that current large language model routing frameworks lack dynamic adaptation mechanisms due to model locking.

[0005] The first aspect of this disclosure provides a routing method for large language models based on zero-shot difficulty awareness, including: The relationship between the performance, cost, and difficulty of candidate large language models is determined based on sample data. The sample data is generated by sampling a preset dataset, and the data in the dataset consists of query suggestion words with pre-calibrated difficulty. The difficulty is determined by the text attributes of the query suggestion words. Obtain query suggestions and predict the difficulty of the query suggestions; Based on the difficulty of the query suggestion words, the cost and performance of each candidate large language model are estimated, and based on the cost and performance, a large language model for processing the query suggestion words is determined from the candidate large language models.

[0006] In some embodiments of this disclosure, the sample data is generated by sampling a preset dataset, including: The preset dataset is divided into K equally wide difficulty intervals. From each interval, N / K representative data points are sampled, where N is the total number of sampled data points and K is an integer. Not less than 10 times K.

[0007] In some embodiments of this disclosure, N is not greater than 100.

[0008] In some embodiments of this disclosure, determining the relationship between the performance and difficulty of candidate large language models based on sample data includes: The candidate large language model is used to process the query suggestion words represented by the sample data to obtain the performance of the candidate large language model corresponding to the difficulty of the query suggestion words; The performance and difficulty of the candidate large language model within the difficulty range of the sample data are determined based on spline interpolation. Based on the performance-difficulty correspondence of the candidate large language models within each difficulty range, cubic spline interpolation is used to determine the performance-difficulty correspondence of the candidate large language models within the entire difficulty range.

[0009] In some embodiments of this disclosure, estimating the cost of a candidate large language model on a preset sample dataset includes: The candidate large language model is used to process the query suggestion words represented by the sample data in the sample dataset to obtain the output length of the candidate large language model corresponding to the difficulty of the query suggestion words; The correspondence between the output length and difficulty of the candidate large language model within the difficulty range of the sample data is determined based on spline interpolation. The average output length of each difficulty range is calculated to obtain the correspondence between the average output length and difficulty of the candidate large language model; The cost-difficulty relationship of the candidate large language model is determined based on the unit price of the input and output tokens and the correspondence between the average output length and difficulty.

[0010] In some embodiments of this disclosure, the difficulty of predicting the query suggestion term includes: By combining the text embedding features and semantic features of the query suggestion words, the difficulty of the query suggestion words is predicted.

[0011] In some embodiments of this disclosure, the step of combining the text embedding features and semantic features of the query suggestion words to predict the difficulty of the query suggestion words includes: The difficulty of the query suggestion words is predicted based on a difficulty prediction model with DistilBERT as the backbone network. The difficulty prediction model includes at least a feature fusion layer and a regularized regression head. The feature fusion layer concatenates the embedded encoding representation representing semantic depth with the semantic features representing structural complexity, and then dynamically weights the contribution of the features through an attention mechanism. The regression head maps the fused features to a difficulty score aligned with item response theory.

[0012] In some embodiments of this disclosure, determining the large language model for processing the query suggestion words from the candidate large language models based on the cost and performance includes: The large language model for processing the query suggestions is determined based on the following constraints, with the principle of maximizing overall performance under cost constraints;

[0013]

[0014]

[0015] Where M is the large language model set, S is the sample set, and the variables are binary. Indicates sample Should it be assigned to a large language model? , The performance score generated for each allocation, The costs incurred in the allocation This is the total cost budget.

[0016] A second aspect of this disclosure provides a routing apparatus for a large language model based on zero-sample difficulty awareness, comprising: The determination module is used to determine the relationship between the performance, cost, and difficulty of candidate large language models based on sample data. The sample data is generated by sampling a preset dataset, and the data in the dataset are query suggestion words with pre-calibrated difficulty. The difficulty is determined by the text attributes of the query suggestion words. The prediction module is used to obtain query suggestion words and predict the difficulty of the query suggestion words; The routing module is used to estimate the cost and performance of each candidate large language model based on the difficulty of the query suggestion words, and to determine the large language model for processing the query suggestion words from the candidate large language models based on the cost and performance.

[0017] A third aspect of this disclosure provides a routing device for a large language model based on zero-sample difficulty awareness, including a memory and a processor. The memory is used to store computer programs; The processor is configured to, when executing the computer program, implement the large language model routing method based on zero-sample difficulty awareness according to the first aspect of the present disclosure.

[0018] In summary, the zero-shot difficulty-aware large language model routing method, apparatus, and device provided in the embodiments of this disclosure establish a model-independent relationship between difficulty values ​​and the performance / cost of the large model. This allows for accurate and efficient evaluation of newly integrated large language models with only as few as 100 representative samples. This solves the problem of current routing systems being unable to integrate or requiring high computational resources for integration, providing a reliable foundation for dynamic routing and cost optimization, and significantly improving the scalability and efficiency of the LLM ecosystem. Furthermore, by combining the text embedding features and semantic features of prompts, it predicts difficulty scores for unseen prompts in real time, addressing the problem that existing prediction methods either lack cross-domain generalization ability or require comprehensive model-prompt testing. It achieves a zero-shot method that directly infers complexity from the contextual attributes of prompts; finally, it uses a linear integer programming algorithm to balance cost and accuracy under different constraints. This solves the problem of balancing cost and performance in model selection and enables dynamic model selection based on diverse user needs. Attached Figure Description

[0019] The features and advantages of this disclosure will be more clearly understood by referring to the accompanying drawings, which are schematic and should not be construed as limiting the scope of this disclosure in any way. Figure 1 This is a schematic diagram of the routing framework for a large language model based on zero-shot difficulty awareness proposed in this publication; Figure 2 This is a schematic diagram of a computer system to which this disclosure applies; Figure 3 This is a flowchart illustrating a large language model routing method based on zero-shot difficulty awareness, according to some embodiments of this disclosure; Figure 4 This is a performance comparison of our method with various single-model implementations under different cost constraints; Figure 5 This is a schematic diagram of a large language model routing device based on zero-sample difficulty awareness, as shown in some embodiments of this disclosure; Figure 6 This is a schematic diagram of a large language model routing device based on zero-sample difficulty awareness, according to some embodiments of this disclosure. Detailed Implementation

[0020] In the following detailed description, numerous specific details of this disclosure are set forth by way of example in order to provide a thorough understanding of the relevant disclosure. However, it will be apparent to those skilled in the art that this disclosure may be practiced without these details. It should be understood that the terms “system,” “apparatus,” “unit,” and / or “module” used in this disclosure are a method of distinguishing different parts, elements, sections, or components at different levels in a sequential arrangement. However, these terms may be replaced by other expressions if they can achieve the same purpose.

[0021] It should be understood that when a device, unit, or module is referred to as being "on," "connected to," or "coupled to" another device, unit, or module, it may be directly connected to or coupled to, or communicate with, other devices, units, or modules, or there may be intermediate devices, units, or modules present, unless the context explicitly indicates otherwise. For example, the term "and / or" as used in this disclosure includes any one and all combinations of one or more of the associated listed items.

[0022] The terminology used in this disclosure is for the purpose of describing particular embodiments only and is not intended to limit the scope of this disclosure. As shown in this specification and claims, unless the context clearly indicates otherwise, words such as "a," "an," "an," and / or "the" do not specifically refer to the singular and may include the plural. Generally speaking, the terms "comprising" and "including" only indicate the inclusion of explicitly identified features, integrals, steps, operations, elements, and / or components, and such expressions do not constitute an exclusive list, in which other features, integrals, steps, operations, elements, and / or components may also be included.

[0023] Referring to the following description and accompanying drawings, these and other features and characteristics, operating methods, functions of related structural elements, combinations of parts, and economics of manufacture of this disclosure can be better understood, wherein the description and drawings form part of the specification. However, it is clearly understood that the drawings are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this disclosure. It is understood that the drawings are not drawn to scale.

[0024] Various structural diagrams are used in this disclosure to illustrate various variations of embodiments according to this disclosure. It should be understood that the preceding or following structures are not intended to limit this disclosure. The scope of protection of this disclosure is defined by the claims.

[0025] The rapid development of large-scale language models, from compact, task-specific systems (such as Med-PaLM) to large-scale general-purpose models (such as DeepSeek-R1, GPT-o1, Qwen-2, and Llama-3.1), has reshaped the field of natural language processing. While increasing model size generally improves performance, the excessively high computational cost of large-scale language models makes them inefficient at handling everyday queries that can actually be efficiently solved by smaller models.

[0026] Cloud platforms like Amazon Web Services host a large number of large language models to meet diverse user needs; however, current systems require users to manually specify the model invoked for each query. As the number of deployed models surges, this approach becomes increasingly unsustainable, with two main problems: (1) it fails to fully utilize smaller, more cost-effective models for simpler tasks; and (2) it over-relies on very large-scale models, leading to unnecessary operational costs.

[0027] With the accelerated release speed of large language models and the expansion of application scenarios, automated model routing systems have become crucial. These systems can dynamically select the optimal model for each query, thereby minimizing costs while maintaining service quality. Current large language model routing frameworks employ two paradigms, but both have inherent scalability limitations.

[0028] (1) Direct routing framework. These methods use static model-task mappings or cascading workflows, requiring full evaluation of queries within predefined models. These methods cannot integrate new models without radical architectural changes because their logic is hard-coded for a fixed set of models; while cascading workflows incur secondary evaluation costs as the model pool grows.

[0029] (2) Two-stage routing framework. This type of approach separates performance prediction from model selection, but current practices often rely on predictors trained based on specific architectural features. When a new model is introduced, these predictors fail to capture the task-query-large language model interactions that are crucial for generalization and require retraining to obtain new interaction data.

[0030] Both paradigms suffer from model lock-in, where rigid dependence on static model representations or training data limits scalability. A core challenge for existing routing frameworks integrating emerging large language models is their lack of dynamic adaptation mechanisms, necessitating costly manual intervention or resource-intensive updates. This constraint creates a dilemma: either limit deployment to static model libraries, potentially sacrificing performance gains, or absorb high operational latency and computational costs to completely overhaul the routing logic, disrupting the scalable, cost-aware alignment between the model and the task.

[0031] In view of this, this disclosure proposes a routing framework for large language models based on zero-shot difficulty awareness. First, model-independent difficulty values ​​for the query dataset are obtained through item response theory modeling. Then, based on these difficulty values ​​decoupled from model capabilities, lightweight performance and cost analysis is provided for the newly integrated large language model. This establishes a large language model routing framework that decouples routing logic from model-specific data, such as... Figure 1 As shown. The key advantages of choosing difficulty over other metrics are as follows: Model independence: Using a benchmark calibrated by project reaction theory as a general measure of complexity avoids model-specific biases inherent in architecture-dependent metrics.

[0032] High efficiency and scalability: Model analysis can be completed quickly with as few as 100 representative samples, while other metrics, such as accuracy, require extensive testing, or model central features require expensive per-model analysis.

[0033] Stability and interpretability: Unlike task classification or temporary complexity scores that require frequent updates, the difficulty value remains stable between model releases.

[0034] Figure 2 This is a schematic diagram of a computer system applicable to this disclosure. Figure 2 The computer system shown includes a large language model routing server connected to a large language model hosting platform network. The large language model hosting platform hosts multiple large language models of varying performance and size. The large language model routing server receives user query requests and selects the most suitable large language model from the large language model hosting platform to handle the query request.

[0035] The large language model routing server can be a single machine, a cluster, or a distributed server. In particular, the large language model routing server can be deployed on the large language model hosting platform.

[0036] Figure 3 This is a flowchart illustrating a zero-shot difficulty-aware large language model routing method according to some embodiments of this disclosure. In some embodiments, the zero-shot difficulty-aware large language model routing method is... Figure 2 The large language model routing server shown executes the method, which includes the following steps: S310, Based on the sample data, determine the relationship between the performance, cost and difficulty of the candidate large language model, wherein the sample data is generated by sampling a preset dataset, and the data in the dataset are query suggestion words with pre-calibrated difficulty, and the difficulty is determined by the text attributes of the query suggestion words.

[0037] This disclosure first models the difficulty determined by the textual attributes of query suggestions.

[0038] To enhance the difficulty of the modeling Model potential capabilities And guessing probability To investigate the interaction relationships between these relationships, this disclosure utilizes an established probabilistic framework (such as item response theory) to offline calibrate difficulty values ​​on datasets across various domains. The probabilistic framework is as follows:

[0039] in, Representation Model Did you respond to the prompt correctly? While Project Response Theory provides a method for quantifying difficulty, this disclosure creatively transforms difficulty into... and ability Separation, allowing Freeze as a universal anchor point, while updating for new models. .

[0040] To obtain the offline calibration difficulty value, this disclosure models and suggests the difficulty based on the probabilistic framework of the aforementioned project reaction theory. Model potential capabilities And guessing probability The interaction relationship between them. Specific steps include: 1. For , , Set a normal distribution prior.

[0041] 2. Joint estimation is performed using stochastic variational inference. The core of stochastic variational inference is the Optimized Evidence Lower Bound (ELBO), whose formula is:

[0042] in, It is a variational distribution. It is a prior distribution. It is the expectation of the log-likelihood function, representing the expected value of the observed data under the variational distribution. The expected value of the log-likelihood. The KL divergence is used to measure the difference between the variational distribution and the prior distribution. By maximizing the ELBO, the accurate value is finally obtained. Parameter estimates.

[0043] Then, a sample dataset is constructed to evaluate the performance and cost of large language models: Using pre-calibrated difficulty values Hierarchical classification of domain or general datasets Difficulty intervals of equal width. From each interval, sample... Representative anchor point hints (N is the total number of sample data obtained, K is an integer) Not less than 10 times K and usually ).

[0044] Determine the relationship between the performance and difficulty of candidate large language models on a sample dataset: When introducing a new model At this point, its capabilities are analyzed only at these anchor points. This sparse evaluation is sufficient because the difficulty levels act as a shared reference frame: the model's performance at the anchor points is directly mapped to its expected accuracy across the entire difficulty range via spline interpolation. New Model capability parameters Estimation is performed using maximum likelihood estimation (MLE) with a regularized log-likelihood function:

[0045] in, Indicates the model at the anchor point The correctness of the above, Used to prevent numerical underflow Control the strength of L2 regularization.

[0046] Finally, a cubic spline interpolator is constructed to cover the difficulty values ​​across the entire interval. Mapping to expected accuracy This allows for performance prediction of any unseen data point through a simple lookup based on difficulty.

[0047] Determine the relationship between cost and difficulty of candidate large language models on a sample dataset: This disclosure utilizes the relationship between difficulty and output length to efficiently estimate cost. The effectiveness of this method is mainly based on the following two observations: 1. Correlation between difficulty and output length: More difficult hints from various tasks (such as mathematical reasoning and code generation) usually produce longer outputs (detailed derivation, multi-step code), thus forming a cost structure related to the difficulty level.

[0048] 2. Reuse of representative samples: Since the representative samples have already been stratified by difficulty, reusing them for cost estimation can avoid additional cue testing.

[0049] Method and Flow: 1. Obtain a partial relation table from representative samples: Evaluate the output length of the new model on the sample dataset and correlate the difficulty value of the samples with the output length.

[0050] 2. Interpolation to obtain a complete relation table: Using the data obtained in the previous step, spline interpolation is performed to directly infer the model output length for the entire difficulty range without additional testing.

[0051] 3. Calculate the average output length of each difficulty range to obtain an average model output length mapping table.

[0052] 4. Finally, by multiplying the average model output length by the price of a single output token of the corresponding model, and adding the known input length multiplied by the price of a single input token of the corresponding model, the estimated model inference cost can be obtained.

[0053] S320, Obtain query suggestion words and predict the difficulty of the query suggestion words.

[0054] This disclosure assesses the difficulty of prompt words from two perspectives: 1. Semantic depth: The DistilBERT model is used to embed and encode contextual semantics (such as technical terms and implicit inference chains), which are associated with higher difficulty.

[0055] 2. Structural complexity: quantified using 11 semantic features, including rhetorical structural ambiguity, average sentence length, parse tree depth, and other dimensions.

[0056] Specifically, the difficulty prediction model disclosed herein employs a DistilBERT backbone network with 66M parameters to process the input token sequence and output a contextual embedding representation. A feature fusion layer concatenates the embedding-encoded representation representing semantic depth with semantic features representing structural complexity, and then dynamically weights the contributions of these features through an attention mechanism (e.g., emphasizing syntactic depth in programming tasks, while focusing on lexical diversity in creative writing). A regularized regression head maps the fused representation to a difficulty score aligned with item response theory.

[0057] The difficulty prediction model disclosed herein aims to inherit the statistical robustness of psychometric theory while avoiding its computational overhead. Furthermore, the model is able to handle unseen task types in zero-shot mode because its features are extracted from the inherent properties of the text, rather than relying on post-processing interactions with the model.

[0058] S330, based on the difficulty of the query suggestion words, estimate the cost and performance of each of the candidate large language models, and based on the cost and performance, determine the large language model for processing the query suggestion words from the candidate large language models.

[0059] After predicting the difficulty of the query suggestion words entered by the user using the difficulty prediction model, the cost and performance of each candidate large language model in processing this suggestion word can be determined based on the relationship between the cost and performance of the large language model obtained in S310 and the difficulty.

[0060] This disclosure formulates the large language model routing problem as an integer linear programming problem to maximize total accuracy under cost constraints.

[0061] Specifically, the following constraints are used to maximize overall performance while adhering to cost constraints:

[0062]

[0063]

[0064] Where M is the large language model set, S is the sample set, and the variables are binary. Indicates sample Should it be assigned to a large language model? , The performance score generated for each allocation, The costs incurred in the allocation This is the total cost budget.

[0065] The second constraint ensures that each prompt is routed to one and only one model, while the third constraint ensures that the total cost does not exceed the budget limit.

[0066] One embodiment of this disclosure relates to... Figure 3 The method described in S310-S330 (hereinafter referred to as our method) was compared with the state-of-the-art two-stage method FORC as a baseline.

[0067] The tests implemented the Item Response Theory (OPT) model using the py-irt library from the Mendoza Business Analytics, Learning, and Language Lab, and trained it for 2000 epochs on a single A100 40GB GPU. A DistilBERT model with 66M parameters was developed as the difficulty prediction model and fine-tuned for 50 epochs on a single A100 GPU with a learning rate of 3e-5 and a batch size of 32. The datasets selected for the tests included the ARC Challenge for scientific question answering, GSM8K for mathematical problem solving, HellaSwag for commonsense reasoning, TruthfulQA for real-world question answering, and the WinoGrande dataset for coreference resolution, totaling 14,617 samples. To avoid redundant work when training the ORT model, the tests utilized evaluation results collected from HuggingFace's OpenLLM leaderboard using TinyBenchmark. These results covered the five tasks mentioned above, involving 395 LLMs. Furthermore, to train the difficulty prediction model, the test divided each collected dataset into a training set and a test set in a 7:3 ratio. The nine candidate large language model sets selected for the test during routing are shown in Table 1.

[0068]

[0069] Table 1. List of candidate large language models selected in the test ($ / per million tokens) The tests set all candidate models as the new ensemble model, and the cost-saving ratio was used as a metric, reflecting the cost savings achieved by our method when matching the performance of a single model. Table 2 shows the average accuracy and total cost of the two most accurate models on each dataset, and compares the cost-saving ratio of our method with the baseline method when matching corresponding performance. Our method achieves significant cost savings on all datasets while maintaining competitive accuracy. In particular, we achieve cost savings of 24.3% and 70.1% on HellaSwag with no accuracy loss and minimal accuracy loss, respectively, significantly outperforming the baseline method. Furthermore, we achieve higher cost-saving ratios than the baseline method on 7 out of 10 datasets, and only 0.2%, 1.69%, and 4% on the other 3 datasets, respectively. Figure 4 The results demonstrate the performance comparison between our method and individual model implementations under different cost constraints, highlighting the cost efficiency and scalability of our method in model routing tasks.

[0070]

[0071] Table 2. Cost savings of our method compared to baseline methods. Figure 5 This is a schematic diagram of a large language model routing device based on zero-sample difficulty awareness, as shown in some embodiments of this disclosure. Figure 5 As shown, the zero-shot difficulty-aware large language model routing device 500 includes a determination module 510, a prediction module 520, and a routing module 530. In some embodiments of this disclosure, the zero-shot difficulty-aware large language model routing function is provided by... Figure 2 The large language model routing server shown is executed, where: The determination module 510 is used to determine the relationship between the performance, cost and difficulty of candidate large language models based on sample data, wherein the sample data is generated by sampling a preset dataset, and the data in the dataset are query suggestion words with pre-calibrated difficulty, and the difficulty is determined by the text attributes of the query suggestion words; The prediction module 520 is used to obtain query suggestion words and predict the difficulty of the query suggestion words; The routing module 530 is used to estimate the cost and performance of each of the candidate large language models based on the difficulty of the query suggestion words, and to determine the large language model for processing the query suggestion words from the candidate large language models based on the cost and performance.

[0072] Figure 6 This is a schematic diagram of a large language model routing device based on zero-sample difficulty awareness, as shown in some embodiments of this disclosure. Figure 6 As shown, the zero-sample difficulty-aware large language model routing device 600 includes a memory 620 and a processor 610. The memory 620 is used to store computer programs; the processor 610 is used to implement... Figure 3 The routing method for large language models based on zero-sample difficulty awareness, as described in S310-S330.

[0073] In summary, the zero-shot difficulty-aware large language model routing method, apparatus, and device provided in the embodiments of this disclosure establish a model-independent relationship between difficulty values ​​and the performance / cost of the large model. This allows for accurate and efficient evaluation of newly integrated large language models with only as few as 100 representative samples. This solves the problem of current routing systems being unable to integrate or requiring high computational resources for integration, providing a reliable foundation for dynamic routing and cost optimization, and significantly improving the scalability and efficiency of the LLM ecosystem. Furthermore, by combining the text embedding features and semantic features of prompts, it predicts difficulty scores for unseen prompts in real time, addressing the problem that existing prediction methods either lack cross-domain generalization ability or require comprehensive model-prompt testing. It achieves a zero-shot method that directly infers complexity from the contextual attributes of prompts; finally, it uses a linear integer programming algorithm to balance cost and accuracy under different constraints. This solves the problem of balancing cost and performance in model selection and enables dynamic model selection based on diverse user needs.

[0074] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the devices and modules described above can be referred to the corresponding descriptions in the foregoing device embodiments, and will not be repeated here.

[0075] Although the subject matter described herein is provided in the general context of execution on a computer system in conjunction with an operating system and applications, those skilled in the art will recognize that other implementations can also be executed in conjunction with other types of program modules. Generally, program modules include routines, programs, components, data structures, and other types of structures that perform specific tasks or implement specific abstract data types. Those skilled in the art will understand that the subject matter described herein can be practiced using other computer system configurations, including handheld devices, multiprocessor systems, microprocessor-based or programmable consumer electronics, minicomputers, mainframes, etc., and can also be used in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules may reside on both local and remote memory storage devices.

[0076] Those skilled in the art will recognize that the units and method steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this disclosure.

[0077] It should be understood that the specific embodiments described above are merely illustrative or explanatory of the principles of this disclosure and do not constitute a limitation thereof. Therefore, any modifications, equivalent substitutions, improvements, etc., made without departing from the spirit and scope of this disclosure should be included within the protection scope of this disclosure. Furthermore, the appended claims are intended to cover all variations and modifications falling within the scope and boundaries of the appended claims, or equivalent forms of such scope and boundaries.

Claims

1. A routing method for large language models based on zero-shot difficulty awareness, characterized in that, include: The relationship between the performance, cost, and difficulty of candidate large language models is determined based on sample data. The sample data is generated by sampling a preset dataset, and the data in the dataset consists of query suggestion words with pre-calibrated difficulty. The difficulty is determined by the text attributes of the query suggestion words. Obtain query suggestions and predict the difficulty of the query suggestions; Based on the difficulty of the query suggestion words, estimate the cost and performance of each of the candidate large language models, and determine the large language model to process the query suggestion words from the candidate large language models based on the cost and performance. Among them, determining the relationship between the performance and difficulty of candidate large language models based on sample data includes: The candidate large language model is used to process the query suggestion words represented by the sample data to obtain the performance of the candidate large language model corresponding to the difficulty of the query suggestion words; The performance and difficulty of the candidate large language model within the difficulty range of the sample data are determined based on spline interpolation. Based on the performance-difficulty correspondence of the candidate large language models within each difficulty range, cubic spline interpolation is used to determine the performance-difficulty correspondence of the candidate large language models within the entire difficulty range. For candidate large language models, estimating the cost of the model on a predefined sample dataset includes: The candidate large language model is used to process the query suggestion words represented by the sample data in the sample dataset to obtain the output length of the candidate large language model corresponding to the difficulty of the query suggestion words; The correspondence between the output length and difficulty of the candidate large language model within the difficulty range of the sample data is determined based on spline interpolation. The average output length of each difficulty range is calculated to obtain the correspondence between the average output length and difficulty of the candidate large language model; The cost-difficulty relationship of the candidate large language model is determined based on the unit price of the input and output tokens and the correspondence between the average output length and difficulty.

2. The method according to claim 1, characterized in that, The sample data is generated by sampling a preset dataset, including: The preset dataset is divided into K equally wide difficulty intervals. From each interval, N / K representative data points are sampled, where N is the total number of sampled data points and K is an integer. Not less than 10 times K.

3. The method according to claim 2, characterized in that: N is no greater than 100.

4. The method according to claim 1, characterized in that, The difficulty of predicting the query suggestion words includes: By combining the text embedding features and semantic features of the query suggestion words, the difficulty of the query suggestion words is predicted.

5. The method according to claim 4, characterized in that, The method of predicting the difficulty of the query suggestion by combining the text embedding features and semantic features of the query suggestion includes: The difficulty of the query suggestion words is predicted based on a difficulty prediction model with DistilBERT as the backbone network. The difficulty prediction model includes at least a feature fusion layer and a regularized regression head. The feature fusion layer concatenates the embedded encoding representation representing semantic depth with the semantic features representing structural complexity, and then dynamically weights the contribution of the features through an attention mechanism. The regression head maps the fused features to a difficulty score aligned with item response theory.

6. The method according to claim 1, characterized in that, The process of determining the large language model for processing the query suggestion words from the candidate large language models based on the cost and performance includes: The large language model for processing the query suggestions is determined based on the following constraints, with the principle of maximizing overall performance under cost constraints; Where M is the large language model set, S is the sample set, and the variables are binary. Indicates sample Should it be assigned to a large language model? , The performance score generated for each allocation, The costs incurred in the allocation This is the total cost budget.

7. A routing device for a large language model based on zero-shot difficulty awareness, characterized in that, include: The determination module is used to determine the relationship between the performance, cost, and difficulty of candidate large language models based on sample data. The sample data is generated by sampling a preset dataset, and the data in the dataset are query suggestion words with pre-calibrated difficulty. The difficulty is determined by the text attributes of the query suggestion words. The prediction module is used to obtain query suggestion words and predict the difficulty of the query suggestion words; The routing module is used to estimate the cost and performance of each candidate large language model based on the difficulty of the query suggestion words, and to determine the large language model for processing the query suggestion words from the candidate large language models based on the cost and performance. Among them, determining the relationship between the performance and difficulty of candidate large language models based on sample data includes: The candidate large language model is used to process the query suggestion words represented by the sample data to obtain the performance of the candidate large language model corresponding to the difficulty of the query suggestion words; The performance and difficulty of the candidate large language model within the difficulty range of the sample data are determined based on spline interpolation. Based on the performance-difficulty correspondence of the candidate large language models within each difficulty range, cubic spline interpolation is used to determine the performance-difficulty correspondence of the candidate large language models within the entire difficulty range. For candidate large language models, estimating the cost of the model on a predefined sample dataset includes: The candidate large language model is used to process the query suggestion words represented by the sample data in the sample dataset to obtain the output length of the candidate large language model corresponding to the difficulty of the query suggestion words; The correspondence between the output length and difficulty of the candidate large language model within the difficulty range of the sample data is determined based on spline interpolation. The average output length of each difficulty range is calculated to obtain the correspondence between the average output length and difficulty of the candidate large language model; The cost-difficulty relationship of the candidate large language model is determined based on the unit price of the input and output tokens and the correspondence between the average output length and difficulty.

8. A routing device based on a large language model with zero-shot difficulty awareness, characterized in that: Including memory and processor, The memory is used to store computer programs; The processor is configured to, when executing the computer program, implement the large language model routing method based on zero-sample difficulty awareness as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Task processing method and device, electronic equipment and computer readable storage medium

    CN119718573A

  • Search optimization method, device and medium based on large model

    CN119782494A