A method and system for scheduling computing power of a modular RAG industry large model application based on dynamic routing

By using dynamic routing to select retrieval and generation modules, combined with real-time computing resources and task priorities, the problem of uneven resource allocation in large industry models has been solved, improving technical efficiency and accuracy, and achieving high-quality application results.

CN121233287BActive Publication Date: 2026-04-10QILU UNIVERSITY OF TECHNOLOGY (SHANDONG ACADEMY OF SCIENCES) +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-05
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing industry-wide models suffer from response delays and resource waste due to rigid allocation of computing resources, and fail to effectively combine task priority with dynamic scheduling, which affects the quality of generated answers and the system's economy.

Method used

A modular RAG industry large model computing power scheduling method based on dynamic routing is adopted. By dynamically selecting retrieval and generation modules, and combining real-time computing power resources and task requirements, high-priority tasks are prioritized. Dense, sparse and hybrid retrieval techniques are used to dynamically switch generation models to adapt to computing power resources.

Benefits of technology

It improves the efficiency and accuracy of answer generation, reduces resource waste, ensures high-quality answer output under limited computing power, and supports the large-scale application of large models in industrial, financial, legal and other scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121233287B_ABST
    Figure CN121233287B_ABST
Patent Text Reader

Abstract

The application relates to a computing power scheduling method and system for modular RAG industry large model application based on a dynamic routing, and belongs to the technical field of computing power scheduling. The method comprises the following steps: a pre-search dynamic routing method is used to acquire a user question, acquire available computing power resource quotas, then the computing power resource quotas required for searching are calculated, and the ratio R of the two is used as one of conditions for selecting a searching module; a pre-generation dynamic routing method is used to acquire a document list searched, acquire available computing power resource quotas, and check whether the available computing power resource quotas can meet the maximum computing power demand of a high-computing-power, balanced-computing-power or lightweight generation model; meanwhile, a priority-aware decision layer is established; and a multi-stage generation method is used to select a corresponding generation model to generate an answer according to the pre-generation dynamic routing method, so that the computing power resources are efficiently and adaptively utilized. The application improves the efficiency and accuracy of the generation of answers of the industry large model, and enables the industry large model to still output high-quality answers under the condition of limited computing power.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to a method and system for scheduling computing power of modular RAG industry large model applications based on dynamic routing, and belongs to the technical field of computing power scheduling. BACKGROUND

[0002] With the rapid development of artificial intelligence technology and large language models, various industry large model applications have been implemented, and retrieval enhancement generation technology, as a core technology supporting the implementation of industry large models, has been widely used in the fields of finance, medicine, industry, law, etc. While various industry large models have been implemented, people have higher requirements for the efficiency, adaptability and accuracy of industry large model applications. Different large models have significantly different computing power requirements, and the same model requires different computing power resources when processing different problems, which leads to the problem of inadaptability of computing power resources during the application of industry large models using RAG technology, thereby causing resource waste. For example, during the peak period of user requests, the system is difficult to quickly expand due to rigid resource allocation, resulting in response delay and affecting user experience; while in the low load period, the redundant computing power is idle, causing resource waste. In addition, the existing RAG technology does not combine a dynamic scheduling mechanism for task priority (such as distinguishing between real-time operation and maintenance diagnosis and ordinary knowledge question and answer tasks), and it is difficult to achieve precise matching of computing power and task complexity, which significantly affects the economy and service stability of the industry large model system. Furthermore, since the available computing power resources and the required computing power resources are constantly changing, when computing power resources are insufficient, how to ensure the quality of generated answers while limited computing power resources is also a problem to be solved. SUMMARY

[0003] In view of the defects of low adaptability of computing power demand and computing power resources, lack of task priority scheduling mechanism and inability to guarantee the quality of generation under limited computing power in the prior art, the application provides a method and system for scheduling computing power of modular RAG industry large model applications based on dynamic routing.

[0004] The application selects corresponding retrieval and generation modules according to the ratio of available computing resources and required computing resources and whether the user's question requires higher accuracy and detail integrity through a dynamic routing method. And by increasing the number of recall documents to ensure that the fault tolerance and quality of the generated answer are significantly improved under the condition of limited computing power. And by detecting the real-time requirements of the question to be generated by the module to generate answers, the relevant retrieval content of the question with real-time requirements is given to the generation module to meet the user's real-time requirements for the generated answers. Through the system and method, the efficiency and accuracy of the industry large model for generating answers are improved, and the adaptability of the computing power demand and computing power resources of the industry large model is improved, so that the industry large model can still output high-quality answers under the condition of limited computing power, thereby reducing the deployment threshold of the industry large model and promoting its large-scale landing application in industrial, financial, legal and other scenarios.

[0005] The technical solution of the application is:

[0006] To achieve the above-mentioned purpose, the first aspect of the application provides a computing power scheduling method for modular RAG industry large model application based on dynamic routing, comprising:

[0007] The pre-retrieval dynamic routing method: obtaining the user's question, obtaining the available computing power resource quota at the present stage, then calculating the retrieval required computing power resource quota, and the ratio R of the two is one of the conditions for deciding which retrieval module to select next; when the ratio R is greater than 1, if it is detected that the user's question requires higher accuracy and detail integrity, then the mixed retrieval is selected next; otherwise, the dense retrieval is selected; at the same time, the variable C is used to record whether the question requires higher accuracy and detail integrity, if it does, C=1, otherwise C=0; if the ratio R is less than or equal to 1, the sparse retrieval is selected;

[0008] The pre-generation dynamic routing method: obtaining the retrieved document list, obtaining the available computing power resource quota at the present stage, then checking whether the available computing power resource quota meets the maximum computing power requirement of the high-computing-power generation model,

[0009] If the requirement is met, then it is judged whether C is equal to 1, if C=1, the high-computing-power generation model is selected to generate answers, if C=0, the balanced mode generation model is selected to generate answers;

[0010] If the requirement is not met, it is checked whether the available computing power resource quota meets the maximum computing power requirement of the balanced mode generation model, if it does, the balanced mode generation model is selected to generate answers, otherwise, the lightweight generation model is selected to generate answers;

[0011] Meanwhile, a priority-aware decision layer is established to distinguish problems with higher real-time requirements from ordinary knowledge Q&A tasks, that is, when it is detected that a generated content has higher real-time requirements within a unit time period, the relevant search content of the problem is preferentially delivered to the generation model;

[0012] The multi-level generation method: according to the dynamic routing method before generation, the corresponding generation model is selected to realize dynamic adaptation of computing resource; the generation model includes a high-computing-power generation model, a balanced-mode generation model and a lightweight generation model.

[0013] Further preferably, the available computing resource quota at the present stage is obtained by collecting GPU memory utilization, core load and free memory through the resource monitoring agent deployed on the computing node, and calculating by the following formula:

[0014] ;

[0015] Among them, is the available computing power quota, is the GPU core computing unit utilization rate obtained in real time through the hardware driver API, is the free memory capacity reported by the operating system, is the total physical memory capacity reported by the operating system, and the coefficients 0.7 and 0.3 are weight factors, which are calibrated by load test regression and used to balance the influence of GPU computing power and memory resources on the overall quota;

[0016] The search required computing resource quota is calculated by the following formula:

[0017] ;

[0018] Among them, is the search required computing resource quota, and L is the length of the question text, that is, the total number of characters in the user's question; is the length influence factor, which compresses the length value to the hundredth level; TermDensity is the density of domain terms, representing the coverage rate of domain terms in the question text, TermDensity is the ratio of the number of terms matched with the preloaded industry dictionary to the total number of nouns in the text; DepDepth is the maximum path depth of the dependency syntax tree.

[0019] Further preferably, when the user's question meets any of the following conditions, it is determined that the user's question requires higher accuracy and detail integrity;

[0020] Condition one: when the domain term density is greater than or equal to 0.25;

[0021] Condition two: the syntactic complexity, that is, the complexity of the grammatical structure, is greater than or equal to 2.5; the syntactic complexity The definition of is: ; wherein, is the maximum path depth of the dependency syntax tree, is the number of sentences.

[0022] Condition three: the keyword appears in the user question or the question text contains a predefined keyword.

[0023] Further preferably, the high-computing-power generation model is DeepSeek-R1-Distill-70B; the balanced mode generation model is DeepSeek-R1-8B-Q4; and the lightweight generation model is DeepSeek-R1-1.5B.

[0024] According to the application, the specific implementation process of the dense retrieval preferably includes:

[0025] Firstly, the user's question is preprocessed, including removing noise and standardizing;

[0026] Secondly, the preprocessed user's question is encoded into a vector to generate a query vector for retrieval; the query vector encoding in the dense retrieval is obtained after the user's question is sequentially subjected to word segmentation, embedding layer vectorization, Transformer encoding, pooling layer aggregation, and vector normalization, respectively;

[0027] Thirdly, the cosine similarity of the query vector and the candidate vector in the vector database is calculated, the cosine similarity algorithm is used for vector similarity retrieval, and the Top K document blocks similar to the query vector are found;

[0028] Fourthly, text hash deduplication is performed to remove duplicate or highly similar documents; firstly, duplicate or highly similar document blocks are quickly detected; the highly similar document block refers to a document block whose SimHash fingerprint Hamming distance d satisfies: 0 < d ≤ θ, wherein θ is a preset threshold; then, the Hamming distance is calculated, the SimHash fingerprints of two documents are compared, and the number of different bits is counted; if the Hamming distance is less than the threshold θ, the document is regarded as a duplicate document, and only the document with a higher SimHash fingerprint is retained;

[0029] Fifthly, redundancy control is used to balance relevance and diversity; the document with the maximum information gain to the current result set is selected by using the maximum marginal relevance algorithm; firstly, S = ∅ is initialized; then, the candidate documents are traversed, and the document with the highest score of the maximum marginal relevance algorithm is selected to join S; finally, the above process is repeated until the target number of documents is selected.

[0030] Further preferably, in the third step, the cosine similarity calculation formula is:

[0031] ;

[0032] where q is the query vector, d is the vector of document block or text, q⋅d is the vector dot product, , i is the dimension index, is the value of the query vector in the i-th dimension, representing the weight of the term in the query; is the value of the document vector in the i-th dimension, representing the weight of the term in the document; ||q|| and ||d|| are the Euclidean lengths of the vectors,

[0033] , , m represents the vector dimension, and i is only used as an index symbol in the dot product formula.

[0034] Further preferably, in the fourth step, the calculation formula of the Hamming distance is:

[0035] ;

[0036] where ⊕ represents the XOR operation, b is the number of hash bits, and are two binary strings of length b; , respectively represent the values of the binary strings and in the i-th bit, which are 0 or 1.

[0037] Further preferably, in the fifth step, the formula of the maximum margin relevance algorithm is:

[0038] ;

[0039] where λ∈[0,1], controlling the weight of relevance and diversity; is the relevance score of the document to the query , S is the selected document set, represents the candidate document, and represents the document being evaluated at present, represents the selected document, and represents the document that has been selected into the set S, represents the document similarity, i.e., the similarity between the document and , is the maximum margin relevance score, and is the comprehensive score of the document dᵢ, is the query relevance, representing the relevance score of the document dᵢ to the query q.

[0040] According to the present application, the specific implementation process of sparse retrieval preferably includes:

[0041] Firstly, the user's question is segmented, i.e., the user's question is split into independent terms;

[0042] Secondly, the step of extracting the stem and filtering the stop words is performed to generate a list of standardized terms;

[0043] Thirdly, a sparse vector is constructed, and a weight is assigned to each term by using the statistical model BM25 through the BM25 algorithm; the generated sparse vector only retains the terms with non-zero weights to form a high-dimensional sparse vector;

[0044] Fourthly, an inverted index retrieval is performed to quickly match the high-relevance documents through the pre-built inverted index.

[0045] Further preferably, in the third step, a weight is assigned to each term by using the BM25 algorithm, and the formula of the BM25 algorithm is as follows:

[0046] ;

[0047] wherein Q represents a user query; t is a term in the query; D is a document to be scored; f(t, D) represents the term frequency of the term t in the document D; |D| represents the length of the document D; avgdl is the average length of all documents in the document set; K1 and b are adjustment parameters; and IDF(t) is the inverse document frequency of the term t. , which means that it is a scoring function for measuring the relevance between the query Q and the document D in the BM25 algorithm.

[0048] The formula of the inverse document frequency is as follows:

[0049] ;

[0050] wherein the parameter N represents the total number of documents in the document set, and n(t) represents the number of documents including the term t.

[0051] Further preferably, in the fourth step, the inverted index retrieval is performed to quickly match the high-relevance documents through the pre-built inverted index, which includes the following steps:

[0052] Firstly, the inverted index structure is constructed, and each term corresponds to an inverted list, which records the document ID containing the term and the term frequency and the document length;

[0053] Secondly, the inverted list is pulled, and all relevant document lists are pulled from the inverted index according to the terms in the question;

[0054] Thirdly, the document score is calculated, and for each candidate document, the BM25 sub-scores of all terms in the question in the document are accumulated;

[0055] Finally, the sorting and screening are performed: all candidate documents are sorted in descending order of the document score, and the top K (K=900) documents are retained as the candidate results with high relevance ranking.

[0056] According to the application, the specific implementation process of the hybrid retrieval preferably comprises:

[0057] In the first step, the user's question is parsed and noise filtering is performed to remove spelling errors, meaningless symbols, standardize terms and split complex questions into independent sub-queries; then, keyword extraction is performed and a keyword list is generated;

[0058] In the second step, parallel retrieval is performed, and sparse retrieval and dense retrieval are performed in parallel; wherein, the sparse retrieval is based on the extended keyword list, uses the BM25 algorithm to retrieve candidate documents, and returns Top-M results; the dense retrieval first vectorizes the query, encodes the user question into a high-dimensional vector, then performs similarity calculation, searches Top-N similar document blocks in the vector database, and finally sorts based on cosine similarity;

[0059] In the third step, result fusion and reordering are performed; first, normalization scoring is performed to map the BM25 score and the cosine similarity to a unified scale; then, semantic and keyword cooperation is performed to obtain a candidate document list sorted by comprehensive score;

[0060] In the fourth step, deduplication and redundancy control are performed to obtain a document list.

[0061] The second aspect of the application provides a computing power scheduling system for modular RAG industry large model application based on dynamic routing, comprising:

[0062] The pre-retrieval dynamic routing module is configured to: obtain the user's question, obtain the available computing power resource quota at the present stage, then calculate the required computing power resource quota for retrieval, and the ratio R of the two is one of the conditions for deciding which retrieval module to select next; when the ratio R is greater than 1, if it is detected that the user's question requires higher accuracy and detail integrity, then the hybrid retrieval is selected next; otherwise, the dense retrieval is selected; at the same time, the variable C is used to record whether the question requires higher accuracy and detail integrity, if it does, C=1, otherwise C=0; if the ratio R is less than or equal to 1, the sparse retrieval is selected;

[0063] The pre-generation dynamic routing module is configured to: obtain the retrieved document list, obtain the available computing power resource quota at the present stage, then check whether the available computing power resource quota meets the maximum computing power requirement of the high-computing-power generation model,

[0064] If the requirement is met, then it is determined whether C is equal to 1, if C=1, the high-computing-power generation model is selected to generate an answer, if C=0, the balanced mode generation model is selected to generate an answer;

[0065] If the demand is not met, check if the available computing resource quota meets the maximum computing power demand of the balanced mode generation model, if yes, select the balanced mode generation model to generate the answer, otherwise, select the lightweight generation model to generate the answer.

[0066] Meanwhile, a priority-aware decision layer is established to distinguish problems with higher real-time requirements from ordinary knowledge Q&A tasks, that is, when in a unit time period, if it is detected that a generated content has higher real-time requirements, the relevant retrieval content of the problem is preferentially delivered to the generation model.

[0067] The multi-level generation module is configured to select a corresponding generation model according to the pre-generation dynamic routing method to realize dynamic adaptation of computing resource; and the generation model includes a high-computing-power generation model, a balanced mode generation model and a lightweight generation model.

[0068] The third aspect of the present application provides a computer device, comprising a processor, a memory and a bus, the memory stores machine readable instructions executable by the processor, when the computer device is running, the processor and the memory communicate through the bus, and the machine readable instructions are executed by the processor to perform the above-mentioned power scheduling method of the dynamic routing-based modular RAG industry large model application.

[0069] The fourth aspect of the present application provides a computer readable storage medium, the computer readable storage medium stores a computer program, and the computer program is executed by the processor to perform the above-mentioned power scheduling method of the dynamic routing-based modular RAG industry large model application.

[0070] The beneficial effects of the present application are:

[0071] 1. Through the dynamic routing mechanism (pre-retrieval dynamic routing and pre-generation dynamic routing), the state of computing resource and the demand of task are perceived in real time, and the dynamic adaptability of computing resource is significantly improved. During the peak period of user requests, the task processing throughput is improved, and the idle resources are reduced during the low load period. The sparse retrieval module can still efficiently recall relevant documents under low computing power conditions through the BM25 algorithm and dynamic adjustment of Top-K value (based on system load and query complexity), so that the retrieval efficiency is improved. The mixed retrieval module executes sparse retrieval and dense retrieval in parallel, and the answer accuracy of complex queries is improved after comprehensive score reordering.

[0072] 2. A priority-aware decision-making layer is introduced, which, combined with a real-time task keyword library (such as "fault" and "alarm"), dynamically schedules high-priority tasks. This reduces the response latency of real-time tasks (such as operational diagnostics). Simultaneously, a multi-level generation model pool (with hundreds of billions / tens of billions / billions of parameters) automatically switches to a lightweight model when computing power is insufficient through a pre-generation dynamic routing algorithm. Even in extreme scenarios (with computing power reduced by 50%), the quality of the generated answers is guaranteed.

[0073] 3. This invention achieves a balance between computing power adaptability, task scheduling efficiency and generation quality, providing reliable technical support for the large-scale application of industry-wide large models. Attached Figure Description

[0074] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an undue limitation of this application.

[0075] Figure 1 This is a flowchart of the computing power scheduling method for the application of a modular RAG industry large model based on dynamic routing, as described in this invention.

[0076] Figure 2 This is a schematic diagram of the overall framework of the computing power scheduling system for the modular RAG industry large model application based on dynamic routing, as described in this invention.

[0077] Figure 3 This is a flowchart of the pre-retrieval dynamic routing method of the present invention;

[0078] Figure 4 This is a flowchart of the dynamic routing method before generation according to the present invention. Detailed Implementation

[0079] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. However, this is not the only description; all aspects not described in detail herein are based on conventional techniques in the art.

[0080] Terminology Explanation:

[0081] 1. BM25 Statistical Model: This is a text relevance scoring algorithm based on probability statistics. It calculates the relevance score between query terms and documents by quantifying factors such as term frequency distribution, global scarcity, and text length. It is widely used in search engines, question-answering systems, and other scenarios. Its core objective is to provide a quantitative score for the relevance of queries to documents and quickly rank documents based on their scores.

[0082] 2, Large model RAG: A hybrid artificial intelligence framework that combines retrieval and generation, which enhances the accuracy and factualness of model output by combining external knowledge base retrieval mechanisms with the generation capabilities of large language models. The core process is: according to the input problem, retrieve relevant document fragments in real time, splice the retrieval results and the original problem, and input the large model to generate the final answer. This technology can effectively alleviate the "hallucination" problem of large models, and significantly improve the credibility and traceability of the results in question and answer systems, knowledge reasoning and other scenarios.

[0083] 3, Modular RAG: A design paradigm that decouples the components of the traditional RAG architecture, breaking down the retrieval and generation enhancement process into independently optimized sub-modules (such as retriever, generator, etc.). By flexibly configuring the combination of different modules, it can adapt to diverse business needs, support dynamic expansion and multi-level optimization, and is suitable for complex scenarios such as cross-domain knowledge fusion and personalized interaction, improving system maintainability and iteration efficiency.

[0084] 4, Sparse retrieval: A traditional retrieval method based on keyword matching, which calculates the explicit lexical overlap between queries and documents by constructing statistical models such as Term Frequency-Inverse Document Frequency (TF-IDF) and BM25. Its advantages are lightweight calculation, high indexing efficiency, and good performance in precise term matching scenarios, but it is weak in capturing implicit information such as synonyms and semantic associations, and is easily affected by lexical differences.

[0085] 5, Dense retrieval: A semantic retrieval technology based on deep learning, which realizes semantic-level matching through vector similarity calculation. Compared with sparse retrieval, it can understand the implicit association of context and support complex patterns such as "question-answer" asymmetric retrieval, but it requires higher computational resources.

[0086] 6, Hybrid retrieval: A multi-strategy retrieval framework that combines the advantages of sparse and dense retrieval, usually using parallel retrieval result weighting fusion or cascading filtering. This method combines the advantages of keyword precise matching and semantic generalization, ensuring high recall rate but requiring more computational overhead, suitable for high-precision scenarios such as medical diagnosis and legal consultation.

[0087] Embodiment 1

[0088] The power scheduling method for the application of the modular RAG industry large model based on dynamic routing, as shown in Figure 1 , includes:

[0089] As shown in Figure 3As shown, the dynamic routing method before retrieval is as follows: The user's question is obtained, the available computing power resource quota is obtained, and then the computing power resource quota required for retrieval is calculated. The ratio R between the two is used as one of the conditions for deciding which retrieval module to select next. When the ratio R is greater than 1, if it is detected that the user's question requires higher accuracy and detail completeness, then a mixed retrieval is selected; otherwise, a dense retrieval is selected. Simultaneously, a variable C is used to record whether the question requires higher accuracy and detail completeness; if so, C=1; otherwise, C=0. If the ratio R is less than or equal to 1, then a sparse retrieval is selected.

[0090] like Figure 4 As shown, the dynamic routing method before generation is as follows: Obtain the list of documents retrieved by the retrieval module, obtain the currently available computing power resource quota, and then check whether the available computing power resource quota meets the maximum computing power requirement of the high-computing-power generation model.

[0091] If the requirements are met, then it is determined whether C is equal to 1. If C=1, then in order to ensure the quality of the generated model's answer and make the answer more fault-tolerant, the high computing power generation model is selected to generate the answer. If C=0, then the balanced mode generation model is selected to generate the answer.

[0092] If the requirements are not met, check whether the available computing power resource quota meets the maximum computing power requirement of the balanced mode generation model. If it does, select the balanced mode generation model to generate the answer; otherwise, select the lightweight generation model to generate the answer.

[0093] Simultaneously, a priority-aware decision-making layer is established to distinguish between questions with higher real-time requirements and ordinary knowledge-based question-answering tasks. That is, if it is detected that a certain generated content has higher real-time requirements within a unit time period, the relevant search content of the question will be given priority to the generation model. The specific implementation method is as follows: keyword matching is performed on the questions that need to be generated by the generation module. Keywords are matched in the predefined real-time task keyword library (such as "fault", "alarm", "emergency", etc.). When such keywords appear, the relevant search content of the question will be given priority to the generation module over ordinary knowledge-based question-answering tasks.

[0094] Multi-level generation method: It has a multi-level generation model pool, and selects the corresponding generation model according to the dynamic routing method before generation to realize computing power scheduling; the generation models include high computing power generation model, balanced mode generation model and lightweight generation model.

[0095] Multi-level generation method: It has a multi-level generation model pool, and selects the corresponding generation model according to the dynamic routing method before generation to realize dynamic adaptation of computing resources; the generation models include high computing power generation model, balanced mode generation model and lightweight generation model.

[0096] Example 2

[0097] The difference between the computing power scheduling method for modular RAG industry large-scale model applications based on dynamic routing described in Example 1 and the following is:

[0098] Obtaining the current available computing resource quota refers to: collecting GPU memory utilization, core load, and free memory through resource monitoring agents deployed on computing nodes, and calculating it using the following formula:

[0099] ;

[0100] in, Available computing power quota, This refers to the GPU core computing unit utilization rate (range 0-100%) obtained in real time through the hardware driver API. This refers to the amount of free memory reported by the operating system (in MB). The total physical memory capacity reported by the operating system (in MB) is used, with coefficients of 0.7 and 0.3 as weighting factors. These are calibrated through load testing regression to balance the impact of GPU computing power and memory resources on the overall quota.

[0101] The required computing power resource quota for retrieval is calculated using the following formula:

[0102] ;

[0103] in, To retrieve the required computing power resource quota, L is the length of the question text, which is the total number of characters (including spaces) in the user's question. Length is the impact factor, compressing the length value to the hundreds level; TermDensity is the domain term density, representing the domain term coverage of the question text. TermDensity is the ratio of the number of terms matched to the preloaded industry dictionary to the total number of nouns in the text; DepDepth is the maximum path depth of the dependency syntax tree. It is obtained through parsing using natural language processing tools (such as SpaCy) and reflects the complexity of the question's grammatical structure.

[0104] A user's problem is considered to require higher accuracy and detail when it meets any of the following conditions:

[0105] Condition 1: When the domain term density is greater than or equal to 0.25;

[0106] Condition 2: Syntactic complexity, i.e., the complexity of the grammatical structure, is greater than or equal to 2.5; syntactic complexity The definition of is: ;in, is the maximum path depth of the dependency parse tree, obtained by parsing with natural language processing tools (such as StanfordCoreNLP), reflecting the complexity of the syntax structure of the question. is the number of sentences, obtained by natural language processing tools (such as SpaCy).

[0107] Condition three: the keyword appears in the user's question or the question text contains predefined keywords. Keywords include but are not limited to "detailed explanation", "professional analysis", "complete description", "in-depth interpretation", "accurate answer", "comprehensive description", "specific elaboration", "rigorous answer", "authoritative analysis", "high precision".

[0108] The high-performance generation model is DeepSeek-R1-Distill-70B, which is compressed by knowledge distillation technology 671B, retaining more than 70% performance, and the maximum memory required is 180 GB. The balanced mode generation model is DeepSeek-R1-8B-Q4, which supports local deployment (Ollama framework), and the maximum memory usage is 10 GB. The lightweight generation model is DeepSeek-R1-1.5B. 1.5B (1.5 billion parameters), which is currently the smallest member of the DeepSeek-R1 family, and has extremely low demand for computing resources (even without GPU).

[0109] The specific implementation process of dense retrieval includes:

[0110] The first step is to preprocess the user's question, including removing noise and standardizing;

[0111] The second step is to use the same embedding model when building the vector database to encode the preprocessed user's question into a vector, generating a query vector for retrieval; the query vector encoding in dense retrieval is obtained by the user's question respectively in turn through word segmentation, embedding layer vectorization, Transformer encoding, pooling layer aggregation, and vector normalization;

[0112] The third step is to calculate the cosine similarity of the query vector and the candidate vector in the vector database, and use the cosine similarity algorithm for vector similarity retrieval to quickly find the Top K document blocks similar to the query vector from the index;

[0113] The vector database is constructed by the industry knowledge document library through the following steps:

[0114] Extracting the original text, text blocking, using the same embedding model as the query encoding for text vectorization encoding, and vector storage and index construction, finally persistently storing the vectorized data into the vector database.

[0115] The construction of the vector database is a process of persistently storing data into the vector database after extracting the original text, text blocking, embedding model coding, text vectorization, and vector storage and index construction by the industry knowledge document library.

[0116] In the fourth step, text hash deduplication removes duplicate or highly similar documents; and the generation module avoids receiving redundant information. First, completely duplicate or highly similar document blocks are quickly detected. The highly similar document block refers to a document block whose SimHash fingerprint Hamming distance d satisfies 0 < d ≤ θ, where θ is a preset threshold (usually 4). Then, the Hamming distance is calculated, the SimHash fingerprints of two documents are compared, and the number of different bits is counted. If the Hamming distance is less than the threshold θ, which is usually 4, the document is considered as a duplicate document, and only the document with a higher SimHash fingerprint is retained. The document SimHash fingerprint is obtained by sequentially passing the document through word segmentation and weight calculation, hash vector generation, weighted vector accumulation, and symbol bit conversion.

[0117] In the fifth step, redundancy control is used to balance relevance and diversity; and the result redundancy is avoided. The maximum marginal relevance algorithm is used to select the document with the maximum information gain for the current result set. First, S = ∅ is initialized. Then, the candidate documents are traversed, and the document with the highest score of the maximum marginal relevance algorithm is selected to join S. Finally, the above process is repeated until the target number of documents is selected.

[0118] In the third step, when it is judged that the user's question needs a more accurate answer when the ratio G is greater than 1, that is, when the user's question C = 1 this time, the value of K is increased to make the number of recalled documents more, thereby ensuring the quality of the answer and making the answer more fault-tolerant.

[0119] In the third step, the cosine similarity calculation formula is:

[0120] ;

[0121] where q is the query vector, d is the vector of the document block or text (a vector with the same dimension as the query), q⋅d is the vector dot product, , i is the dimension index (indicating the position), is the value of the query vector in the i-th dimension, indicating the weight of the term in the query; is the value of the document vector in the i-th dimension, indicating the weight of the term in the document; ||q|| and ||d|| are the Euclidean lengths of the vectors, , , m represents the vector dimension, and i is only used as an index symbol in the dot product formula.

[0122] In the fourth step, the Hamming distance calculation formula is:

[0123] ;

[0124] where, ⊕ represents XOR operation, b is the hash bit number, and are two binary strings (or binary vectors) of length b; in the context of SimHash, they are the SimHash fingerprints (binary representation) of two documents. 、 represent the values (bit values) of binary strings and at the i-th bit, taking values 0 or 1.

[0125] In the fifth step, the formula of the maximum edge correlation algorithm is:

[0126] ;

[0127] where, λ ∈ [0, 1], controlling the weight of relevance and diversity (default 0.7); is the relevance score of document to query , S is the selected document set, represents the candidate document, and represents the document currently being evaluated (from the document set D but not in the selected set S), represents the selected document, and represents the document that has been selected into the set S (used for comparison of similarity with dᵢ), represents the similarity of the document, i.e., the similarity between the document and , is the maximum edge correlation score, and is the comprehensive score of the document dᵢ (balancing relevance and diversity), is the query relevance, representing the relevance score of the document dᵢ to the query q.

[0128] The specific implementation process of sparse retrieval includes:

[0129] First, the user's question is segmented, i.e., the user's question is divided into independent word items;

[0130] Second, stem extraction and stop word filtering are performed, and after reducing noise, a standardized word item list is generated; the steps of general word filtering are loading the basic stop word table, loading the field expansion stop word table, and multi-dimensional stop word judgment and frequency threshold filtering.

[0131] Third, construct a sparse vector, use the statistical model BM25 to assign weights to each word item through the BM25 algorithm; reflect its importance to the question or document. The generated sparse vector only retains the non-zero weight word items, forming a high-dimensional sparse vector;

[0132] Fourth step, inverted index retrieval, through the pre-built inverted index to quickly match high relevance documents.

[0133] In the third step, each term is assigned a weight by the BM25 algorithm, and the formula of the BM25 algorithm is:

[0134] ;

[0135] Where Q represents the user query; t is the term in the query; D is the document to be scored; f(t, D) represents the term frequency of term t in document D; |D| represents the length of document D (calculated in terms); avgdl is the average length of all documents in the document set; K1 and b are adjustment parameters (default values are usually k1=1.2, b=0.75); IDF(t) is the inverse document frequency of term t; is the BM25 algorithm that measures the relevance score function of query Q and document D; its design goal is to more accurately reflect the semantic matching degree of the document and the query.

[0136] The formula of the inverse document frequency (IDF) is:

[0137] ;

[0138] Where parameter N represents the total number of documents in the document set, and n(t) represents the number of documents containing term t.

[0139] In the fourth step, inverted index retrieval, through the pre-built inverted index to quickly match high relevance documents; including:

[0140] First, the inverted index structure, each term corresponds to an inverted list, recording the document ID containing the term and its term frequency, document length; inverted index is the core data structure of search engine, contrary to the traditional forward index (document→term), it establishes the mapping relationship of term→document. Its essence is a distributed hash table. Each term's inverted list contains a sequence of document IDs and corresponding term statistical metadata;

[0141] Next, pull the inverted list, according to the terms in the question, pull all the relevant document list from the inverted index;

[0142] Then, calculate the document score, for each candidate document, accumulate the BM25 sub-score of all terms in the question in the document;

[0143] Finally, sorting and filtering: sort all candidate documents by document score from high to low, and keep the top K (K = 900) documents as the candidate results with high relevance ranking. The selection of the Top K value directly affects the retrieval efficiency and result quality, so dynamically adjusting the K value can better balance performance and effect. Here, K is dynamically adjusted based on system load. When it is judged that the user's question needs more accurate answers, that is, when the user's question C = 1, increase the K value so that the number of recalled documents is more, thereby ensuring the quality of the answer, and making the answer more fault-tolerant.

[0144] The inverted index retrieval example is demonstrated as follows:

[0145] Taking a simplified document set as an example, the full process of inverted index retrieval is intuitively demonstrated as follows:

[0146] Step 1: Build an inverted index;

[0147] Suppose there are the following 3 documents:

[0148] Document ID Document content;

[0149] D1 Artificial intelligence is a branch of computer science;

[0150] D2 Deep learning drives the development of artificial intelligence;

[0151] D3 Natural language processing belongs to the field of artificial intelligence;

[0152] Inverted index structure:

[0153] Term inverted list (document ID, term frequency, document length);

[0154] Artificial intelligence (D1, 1, 5), (D2, 1, 7), (D3, 1, 9);

[0155] Computer (D1, 1, 5);

[0156] Science (D1, 1, 5);

[0157] Deep (D2, 1, 7);

[0158] Learn (D2, 1, 7);

[0159] Promote (D2, 1, 7);

[0160] Develop (D2, 1, 7);

[0161] Natural language (D3, 1, 9);

[0162] Processing (D3, 1, 9);

[0163] Belongs (D3, 1, 9);

[0164] Domain (D3,1,9);

[0165] Step 2: Retrieve the inverted list;

[0166] Suppose a user asks "the development of artificial intelligence", the word segmentation will result in the term set: {artificial intelligence, development}.

[0167] Retrieve relevant documents from the inverted index:

[0168] Artificial Intelligence → D1, D2, D3;

[0169] Development → D2;

[0170] The merged candidate document set: D1, D2, D3 (D1 and D3 are linked by "artificial intelligence", and D2 contains two terms).

[0171] Step 3: Calculate the document score (BM25 simplified version);

[0172] Assuming we use the simplified BM25 formula:

[0173] Score = Σ (term weight), term weight = (term frequency × inverse document frequency) / document length;

[0174] Parameter settings:

[0175] Average document length = (5+7+9) / 3 ≈ 7;

[0176] Simplified calculation of Inverse Document Frequency (IDF): log(total number of documents / number of documents containing the term + 1);

[0177] Calculation process:

[0178] D1:

[0179] Includes the term: Artificial Intelligence;

[0180] Term weight = (1 × log(3 / 3+1)) / 5 ≈ (1×0.477) / 5 ≈ 0.095;

[0181] Total score = 0.095;

[0182] D2:

[0183] Includes the following terms: artificial intelligence, development;

[0184] Artificial intelligence weight = (1 × log(3 / 3+1)) / 7 ≈ 0.068;

[0185] Developing weight = (1 x log(3 / 1+1)) / 7 = (1 x 0.693) / 7 = 0.099;

[0186] Total score = 0.068 + 0.099 = 0.167;

[0187] D3:

[0188] Contains the term: artificial intelligence;

[0189] Term weight = (1 x log(3 / 3+1)) / 9 = 0.053;

[0190] Total score = 0.053;

[0191] Step 4: Dynamic adjustment of K value and sorting and screening;

[0192] Default K value: Assume the system default K = 2.

[0193] Dynamic adjustment:

[0194] If the user's question complexity C = 1 is detected (such as the question contains multiple keywords or requires in-depth analysis), increase the K value to K = 3.

[0195] Finally, sort by score: D2(0.167) > D1(0.095) > D3(0.053).

[0196] Output result:

[0197] When K = 3, return all 3 documents (sorted by score).

[0198] When K = 2, only return D2 and D1.

[0199] Example summary;

[0200] Step operation output result;

[0201] Inverted index construction document segmentation → statistical term → document mapping as shown in the table structure above;

[0202] Inverted list pulls query term matching → merge document ID candidate documents D1, D2, D3;

[0203] Score calculation BM25 formula accumulates term weight D2(0.167), D1(0.095), D3(0.053);

[0204] Dynamic K value adjustment and sorting Adjust K according to C value → Sort by score Top K document list (such as K = 3, return in full);

[0205] Key logic explanation;

[0206] The core role of inverted index: convert full-text matching problem into set intersection operation through term→document mapping, greatly improve retrieval efficiency.

[0207] The meaning of BM25 score: balance the contradiction between relevance (high-frequency words) and discrimination (rare words) by considering term frequency, inverse document frequency and document length.

[0208] The value of dynamic K: self-adaptation between precision (large K) and performance (small K), for example, quickly return Top 2 results for simple queries (C=0), and expand the candidate pool to ensure fault tolerance for complex queries (C=1).

[0209] The specific implementation process of hybrid retrieval includes:

[0210] The hybrid retrieval method significantly improves the answer quality for complex queries by synergistically combining dense retrieval (semantic vector matching) and sparse retrieval (keyword matching).

[0211] First, analyze and filter the user's question, remove spelling errors, meaningless symbols, standardize terms, and split complex problems into independent subqueries; then, extract keywords and generate a keyword list;

[0212] Second, parallel retrieval execution, parallel execution of sparse retrieval (keyword matching) and dense retrieval (semantic vector matching); among them, sparse retrieval is based on the expanded keyword list, using BM25 algorithm to retrieve candidate documents, returning Top-M results (M=1000); dense retrieval first vectorizes the query, using the same embedding model as the vector database to encode the user's question into a high-dimensional vector, then performs similarity calculation, searches for Top-N similar document blocks (N=1000) in the vector database, and finally, sorts based on cosine similarity;

[0213] Third, result fusion and reordering; first, normalize the score, map the BM25 score and cosine similarity to a unified scale; then, perform semantic and keyword synergy to get a candidate document list sorted by comprehensive score;

[0214] Fourth, deduplication and redundancy control to get a deduplicated and diversity-optimized document list.

[0215] Perform semantic and keyword synergy to get a candidate document list sorted by comprehensive score; including:

[0216] First, normalize the score; linearly map the BM25 score to the [0, 1] interval, find the highest and lowest BM25 scores in the Top-1000 documents, and then calculate:

[0217] BM25 norm = (raw score - min score) / (max score - min score);

[0218] where raw score is the raw BM25 score of a document in sparse retrieval (keyword matching). Then cosine similarity is mapped from [-1, 1] to [0, 1], i.e. cosine similarity is normalized, the formula is:

[0219] ;

[0220] where raw cosine value is the raw cosine similarity of a document with query vector in dense retrieval (semantic matching).

[0221] Second, dynamic weight allocation. First, analyze query features, such as the number of query technical terms, query length, and whether it contains comparative words. Then set the weight, technical comparison class: α = 0.3 (keyword matching weight, corresponding retrieval type is sparse retrieval), β = 0.7 (semantic matching weight, corresponding retrieval type is dense retrieval). The fact query class α = 0.6, β = 0.4. Research review class α = 0.4, β = 0.6. Finally, the comprehensive score calculation:

[0222] ;

[0223] where BM25 norm is the keyword matching strength, i.e. the original BM25 score is mapped to a standard range (usually [0, 1]). is the preprocessing (unitization) of the input vector in the process of calculating the cosine similarity.

[0224] Example 3

[0225] The power scheduling system of the modular RAG industry large model application based on dynamic routing includes:

[0226] The pre-retrieval dynamic routing module is configured to: obtain the user's question, obtain the available computing resource quota at the present stage, then calculate the required computing resource quota for retrieval, and the ratio R of the two is one of the conditions for deciding which retrieval module to select next; when the ratio R is greater than 1, if it is detected that the user's question needs higher accuracy and detail integrity, then the mixed retrieval is selected next; otherwise, the dense retrieval is selected; at the same time, the variable C is used to record whether the question needs higher accuracy and detail integrity, if it needs, C = 1, otherwise C = 0; if the ratio R is less than or equal to 1, the sparse retrieval is selected;

[0227] The pre-generation dynamic routing module is configured to: acquire the document list retrieved by the retrieval module, acquire the available computing resource quota at the present stage, and then check whether the available computing resource quota meets the maximum computing power requirement of the high-computing-power generation model,

[0228] If the requirement is met, then it is determined whether C is equal to 1. If C = 1, the high-computing-power generation model is selected to generate the answer in order to ensure the quality of the answer of the generation model and make the answer more fault-tolerant. If C = 0, the balanced mode generation model is selected to generate the answer.

[0229] If the requirement is not met, it is checked whether the available computing resource quota meets the maximum computing power requirement of the balanced mode generation model. If the requirement is met, the balanced mode generation model is selected to generate the answer. Otherwise, the lightweight generation model is selected to generate the answer.

[0230] Meanwhile, a priority-aware decision layer is established to distinguish between problems with higher real-time requirements and ordinary knowledge question and answer tasks. That is, when in a unit time period, if it is detected that a generated content has higher real-time requirements, the relevant retrieval content of the problem is preferentially given to the generation model. The specific implementation manner is that the problem to be generated by the generation module is subjected to keyword matching, and the keywords are matched in a defined real-time task keyword library (such as “fault”, “alarm”, “emergency” and the like). When the keywords appear, the relevant retrieval content of the problem is preferentially given to the generation module than ordinary knowledge question and answer tasks.

[0231] The multi-level generation module is configured to have a multi-level generation model pool, and to select a corresponding generation model according to the pre-generation dynamic routing method to realize computing power scheduling. The generation model includes a high-computing-power generation model, a balanced mode generation model and a lightweight generation model.

[0232] Embodiment 4

[0233] A computer device includes a processor, a memory and a bus. The memory stores machine-readable instructions executable by the processor. When the computer device is running, the processor communicates with the memory through the bus. The machine-readable instructions are executed by the processor to perform the computing power scheduling method of the modular RAG industry large model application based on dynamic routing in embodiments 1 or 2.

[0234] Embodiment 5

[0235] A computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the computing power scheduling method of the modular RAG industry large model application based on dynamic routing in embodiments 1 or 2 is performed.

Claims

1. A computing power scheduling method for modular RAG industry large model applications based on dynamic routing, characterized in that, Comprise: Pre-retrieval dynamic routing method: obtain the user's question, obtain the available computing resource quota at the present stage, then calculate the required computing resource quota for retrieval, and the ratio R of the two is one of the conditions for deciding which retrieval module to select next; when the ratio R is greater than 1, if it is detected that the user's question requires higher accuracy and detail integrity, then the mixed retrieval is selected next; otherwise, the dense retrieval is selected; at the same time, the variable C is used to record whether the question requires higher accuracy and detail integrity, if it does, C=1, otherwise C=0; if the ratio R is less than or equal to 1, the sparse retrieval is selected; Pre-generation dynamic routing method: obtain the list of retrieved documents, obtain the available computing resource quota at the present stage, then check whether the available computing resource quota meets the maximum computing power requirement of the high-computing power generation model, If the requirement is met, then determine whether C is equal to 1, if C=1, select the high-computing power generation model to generate the answer, if C=0, select the balanced mode generation model to generate the answer; If the requirement is not met, check whether the available computing resource quota meets the maximum computing power requirement of the balanced mode generation model, if it does, select the balanced mode generation model to generate the answer, otherwise, select the lightweight generation model to generate the answer; At the same time, a priority-aware decision layer is established to distinguish between questions that require higher real-time performance and ordinary knowledge Q&A tasks, that is, when in a unit time period, if it is detected that a generated content requires higher real-time performance, the relevant retrieval content of the question is preferentially given to the generation model; Multi-level generation method: according to the pre-generation dynamic routing method, the corresponding generation model is selected to realize dynamic adaptation of computing resources; the generation model includes a high-computing power generation model, a balanced mode generation model, and a lightweight generation model; The required computing resource quota for retrieval is calculated by the following formula: ; wherein, L is the length of the question text, i.e., the total number of characters in the user's question, for retrieving the required computing resource quota; is a length impact factor that compresses the length value to the order of 100; TermDensity is the density of domain terms, representing the coverage of domain terms in the question text, TermDensity is the ratio of the number of terms matched with the preloaded industry dictionary to the total number of nouns in the text; DepDepth is the maximum path depth of the dependency syntax tree; When the user's question meets any of the following conditions, it is determined that the user's question requires higher accuracy and detail integrity; Condition one: when the domain term density is greater than or equal to 0.25; Condition two: the syntactic complexity, i.e. the complexity of the syntactic structure, is greater than or equal to 2.5; the syntactic complexity is defined as: wherein, is the maximum path depth of the dependency syntactic tree, is the number of clauses;​ Condition three: the user's question contains a keyword or the question text contains a predefined keyword.

2. The dynamic routing-based computing power scheduling method for modular RAG industry large model applications according to claim 1, characterized in that, The available computing resource quota at the present stage is obtained by collecting GPU memory utilization, core load, and free memory through resource monitoring agents deployed on computing nodes, and is calculated by the following formula: ; wherein, is the available compute quota, is the GPU core compute unit utilization acquired in real-time through the hardware driver API, is the free memory capacity reported by the operating system, is the total physical memory capacity reported by the operating system, the coefficients 0.7 and 0.3 are weight factors calibrated through load testing regression to balance the impact of GPU compute and memory resources on the overall quota.

3. The dynamic routing based modular RAG industry model application computing power scheduling method of claim 2, wherein, The high-computing power generation model is DeepSeek-R1-Distill-70B; the balanced mode generation model is DeepSeek-R1-8B-Q4; and the lightweight generation model is DeepSeek-R1-1.5B.

4. The dynamic routing based modular RAG industry large model application computing power scheduling method according to claim 1, characterized in that, The specific implementation process of dense retrieval includes: First, pre-process the user's question, including removing noise and standardizing; Second, encode the pre-processed user's question into a vector to generate a query vector for retrieval; the query vector encoding in dense retrieval is obtained by sequentially passing the user's question through word segmentation, embedding layer vectorization, Transformer encoding, pooling layer aggregation, and vector normalization; Thirdly, cosine similarity between query vector and candidate vectors in vector database is calculated, cosine similarity algorithm is used for vector similarity retrieval, and Top K documents are found which are similar to query vector; Fourthly, text hash de-duplication is used to remove duplicate or highly similar documents. Firstly, duplicate or highly similar document blocks are quickly detected. Highly similar document blocks refer to two documents whose SimHash fingerprint Hamming distance d satisfies: 0 < d ≤ θ, wherein θ is a preset threshold. Then, the Hamming distance is calculated. The number of different bits is counted by comparing the SimHash fingerprints of the two documents. If the Hamming distance is less than the threshold θ, the document is considered as a duplicate document, and only the document with higher SimHash fingerprint is retained; Fifthly, redundancy control is used to balance relevance and diversity. The document with the highest information gain to the current result set is selected by using the maximum marginal relevance algorithm. Firstly, S = ∅ is initialized. Then, the candidate documents are traversed, and the document with the highest score of the maximum marginal relevance algorithm is selected to join S. Finally, the above process is repeated until the target number is selected.

5. The dynamic routing based modular RAG industry large model application computing power scheduling method according to claim 4, characterized in that, In the third step, the cosine similarity calculation formula is: ; where q is the query vector, d is the vector of the document block or text, q · d is the vector dot product, , i is the dimension index, is the value of the query vector in the i-th dimension, indicating the weight of the term in the query; is the value of the document vector in the i-th dimension, indicating the weight of the term in the document; ||q|| and ||d|| are the Euclidean lengths of the vectors, , , m represents the vector dimension, and i is only an index symbol in the dot product formula.

6. The dynamic routing based modular RAG industry large model application computing power scheduling method according to claim 4, characterized in that, In the fourth step, the Hamming distance calculation formula is: ; wherein denotes an exclusive OR operation, b is the number of hash bits, and are two binary strings of length b; , denote the value of the binary string and at the i-th bit, taking values 0 or 1; In the fifth step, the maximum marginal relevance algorithm formula is: ; where λ ∈ [0, 1] controls the weight between relevance and diversity; For documents with query relevance scores, S is the selected document set, denotes candidate documents, denotes the document currently being evaluated, denotes selected documents, denotes the documents that have been selected into the set S, represents the similarity between documents, i.e., the similarity between documents and , is the maximum margin relevance score, and is the overall score of document di, is the query relevance, which represents the relevance score of document di with query q.

7. The dynamic routing based modular RAG industry model application computing power scheduling method according to claim 1, characterized in that, The specific implementation process of sparse retrieval includes: Firstly, the user's question is segmented, that is, the user's question is divided into independent terms; Secondly, stem extraction and stop word filtering are performed to generate a standardized term list; Thirdly, a sparse vector is constructed. The BM25 algorithm is used to assign weights to each term by using the statistical model BM25. The generated sparse vector only retains the non-zero weight terms to form a high-dimensional sparse vector; Fourthly, inverted index retrieval is performed to quickly match high-relevance documents by using the pre-built inverted index; In the third step, the BM25 algorithm is used to assign weights to each term. The formula of the BM25 algorithm is: ; where Q represents a user query; t is a term in the query; D is a document to be scored; f(t, D) represents the term frequency of term t in document D; |D| represents the length of document D; avgdl is the average length of all documents in the document collection; and b is a tuning parameter; IDF(t) is the inverse document frequency of term t; is a scoring function that measures the relevance of a query Q to a document D in the BM25 algorithm. The formula of inverse document frequency is: ; Wherein, the parameter N represents the total number of documents in the document set, and n(t) represents the number of documents including the term t; In the fourth step, inverted index retrieval is performed to quickly match high-relevance documents by using the pre-built inverted index. It includes: Firstly, the inverted index structure is constructed. Each term corresponds to an inverted list, which records the document ID and term frequency of the document containing the term, as well as the document length. Secondly, the inverted list is pulled. According to the terms in the question, the list of all related documents is pulled from the inverted index. Thirdly, the document score is calculated. For each candidate document, the BM25 sub-score of each term in the question in the document is accumulated. Finally, sorting and screening are performed. The documents are sorted from high to low according to the document score, and the Top K is retained as the candidate result, that is, the high-relevance document.

8. The dynamic routing based modular RAG industry model application computing power scheduling method according to any one of claims 1-7, characterized in that, The specific implementation process of hybrid retrieval includes: Firstly, the user's question is analyzed and noise filtering is performed to remove spelling errors, meaningless symbols, standardize terms, and split complex questions into independent sub-queries. Then, key word extraction is performed to generate a key word list. The second step is parallel retrieval execution, in which sparse retrieval and dense retrieval are performed in parallel; the sparse retrieval is based on the extended keyword list, uses the BM25 algorithm to retrieve candidate documents, and returns Top-M results; the dense retrieval first vectorizes the query, encodes the user question into a high-dimensional vector, then performs similarity calculation, searches for Top-N similar document blocks in the vector database, and finally sorts based on cosine similarity; The third step is result fusion and reordering; first, normalize the score, map the BM25 score and cosine similarity to a unified scale; then, perform semantic and keyword collaboration to obtain a candidate document list sorted by comprehensive score; The fourth step is to perform deduplication and redundancy control to obtain a document list.

9. A computing power scheduling system for modular RAG industry large model applications based on dynamic routing, characterized in that, It includes: The pre-retrieval dynamic routing module is configured to: obtain the user's question, obtain the available computing resource quota at the present stage, then calculate the required computing resource quota for retrieval, and the ratio R of the two is one of the conditions for deciding which retrieval module to select next; when the ratio R is greater than 1, if it is detected that the user's question requires higher accuracy and detail integrity, then the mixed retrieval is selected next; otherwise, the dense retrieval is selected; at the same time, the variable C is used to record whether the question requires higher accuracy and detail integrity, if it does, C=1, otherwise C=0; if the ratio R is less than or equal to 1, then the sparse retrieval is selected; The pre-generation dynamic routing module is configured to: obtain the retrieved document list, obtain the available computing resource quota at the present stage, then check whether the available computing resource quota meets the maximum computing power requirement of the high-computing power generation model, If the requirement is met, then determine whether C is equal to 1, if C=1, select the high-computing power generation model to generate the answer, if C=0, select the balanced mode generation model to generate the answer; If the requirement is not met, check whether the available computing resource quota meets the maximum computing power requirement of the balanced mode generation model, if it does, select the balanced mode generation model to generate the answer, otherwise, select the lightweight generation model to generate the answer; At the same time, a priority-aware decision layer is established to distinguish between questions that require higher real-time performance and ordinary knowledge Q&A tasks, i.e., when in a unit time period, if it is detected that a generated content requires higher real-time performance, the relevant retrieval content of the question is prioritized to the generation model; The multi-level generation module is configured to: select the corresponding generation model according to the pre-generation dynamic routing method to realize dynamic adaptation of computing resources; the generation model includes a high-computing power generation model, a balanced mode generation model, and a lightweight generation model; The required computing resource quota for retrieval is calculated by the following formula: ; wherein, L is the length of the question text, i.e., the total number of characters in the user's query, for retrieving the required computing resource quota; is a length impact factor that compresses the length value to the order of 100; TermDensity is the density of domain terms, representing the coverage of domain terms in the question text, TermDensity is the ratio of the number of terms matched with the preloaded industry dictionary to the total number of nouns in the text; DepDepth is the maximum path depth of the dependency syntax tree; When the user's question meets any of the following conditions, it is determined that the user's question requires higher accuracy and detail integrity; Condition one: when the domain term density is greater than or equal to 0.25; Condition two: the syntactic complexity, i.e. the complexity of the syntactic structure, is greater than or equal to 2.5; the syntactic complexity is defined as: ; wherein, is the maximum path depth of the dependency syntactic tree, is the number of clauses; Condition three: the user question contains a keyword or the question text contains a predefined keyword.

Citation Information

Patent Citations

  • Multi-factor strategy-based computing power resource optimal scheduling distribution method

    CN115550370A

  • Computing power routing method and device, equipment and medium

    CN118802925A