Task processing method and device, computer equipment and storage medium
By combining dynamic batch processing and hardware interrupt mechanisms with a local-global hybrid attention mechanism, the problem of improper allocation of computing resources in large model inference is solved, enabling efficient processing of text tasks of different lengths in banking and financial business and ensuring the timely processing of high-priority tasks.
Patent Information
- Application Number
- CN202510957506.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-09
- Publication Date
- 2025-10-28
AI Technical Summary
Existing large-scale model inference processes suffer from large global computational loads, frequent memory accesses, and a lack of flexible scheduling and resource allocation, resulting in slow inference speeds and low efficiency. This is especially true in fintech business scenarios such as banking, where efficiency requirements are extremely high, and high-priority tasks may be unable to be processed in a timely manner due to the blocking of low-priority tasks.
By dynamically batching input text tasks, distinguishing between regular batches and ultra-long batches, and utilizing hardware interrupt mechanisms to achieve preemptive scheduling of current tasks by priority text tasks, and combining local-global hybrid attention mechanisms and different sparsity rates, historical key-value pairs are generated, classified, and cached.
The allocation of computing resources has been optimized, improving the processing efficiency of text tasks of different lengths, ensuring that high-priority tasks can be processed in a timely manner, and improving the overall task processing efficiency.
Smart Images

Figure CN120849048A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence and natural language processing, and in particular to a task processing method, apparatus, computer device, and storage medium. Background Technology
[0002] With the deep integration of natural language processing and artificial intelligence technologies and their widespread application across various industries, large-scale model-based technology systems have become a key force driving the intelligent transformation of many fields. They have demonstrated enormous application potential in text task processing, covering numerous scenarios such as intelligent customer service, document analysis, and risk assessment. The fintech sector is a prime example, with banks, as the core entities of the financial system, actively introducing large-scale model technology to improve service quality and operational efficiency.
[0003] However, with the continuous expansion of large-scale models and the increasingly stringent real-time requirements of business scenarios, the current large-scale model inference process is facing a severe speed bottleneck. This bottleneck is particularly prominent in financial technology business scenarios such as banks, which have extremely high efficiency requirements, and greatly limits the large-scale and efficient deployment and application of large models in actual business.
[0004] Traditional attention architectures, as core components of large-scale model inference, exhibit numerous drawbacks when processing text tasks, and these problems are further amplified in the complex business scenarios of banking. On one hand, their global computational load is extremely large. In actual banking operations, such as processing long text tasks like analyzing large amounts of customer transaction records and generating credit assessment reports, traditional attention architectures need to perform pairwise interactions on all elements in the entire text sequence to capture the dependencies between them. This global computational approach causes the computational complexity to increase quadratically with the length of the text, resulting in a significant increase in inference time.
[0005] Furthermore, traditional methods are extremely inefficient when processing text tasks of varying priorities. In the daily operations of banks, task priorities differ significantly. For example, urgent transaction inquiries involving customer fund security and important business consultations for high-net-worth clients are high-priority tasks that require immediate processing; while routine tasks such as generating market research reports and compiling internal training materials are low-priority tasks that can wait. However, traditional methods typically employ a uniform processing strategy, failing to flexibly schedule and allocate resources based on task priority. This leads to high-priority tasks potentially being delayed due to the blocking effect of low-priority tasks. For instance, in a bank's back-office processing system, an urgent customer account anomaly inquiry request might be delayed for a long time due to multiple low-priority routine report generation tasks in the queue, thus delaying problem resolution and potentially posing risks and losses to the bank. Summary of the Invention
[0006] The purpose of this invention is to provide a task processing method, apparatus, computer device, and storage medium, which aims to solve the problems of slow inference speed and low efficiency caused by the large global computational load and frequent memory access of the traditional attention architecture, as well as the lack of flexible scheduling and resource allocation when processing different text tasks.
[0007] In a first aspect, embodiments of the present invention provide a task processing method, including:
[0008] The input text task is dynamically batched based on the length of the input sequence to obtain regular batches and ultra-long batches.
[0009] The text tasks to be processed and the current text task in the input text task are obtained. Tasks belonging to the ultra-long batch in the text tasks to be processed are detected as priority text tasks. The priority text task is preemptively scheduled to the current text task through a hardware interrupt mechanism.
[0010] A local-global hybrid attention mechanism is used to compute the priority text task;
[0011] The text tasks belonging to the regular batch in the text tasks to be processed are calculated using a first sparsity rate to generate a first historical key-value pair; the priority text tasks are calculated using a second sparsity rate to generate a second historical key-value pair; wherein, the first sparsity rate is greater than the second sparsity rate;
[0012] The first historical key-value pair is cached in the first cache pool, and the second historical key-value pair is cached in the second cache pool.
[0013] Secondly, embodiments of the present invention also provide a task processing apparatus, comprising:
[0014] The processing unit is used to dynamically batch the input text task according to the length of the input sequence to obtain regular batches and ultra-long batches.
[0015] The scheduling unit is used to obtain the pending text tasks and the current text task in the input text task, detect the tasks in the pending text tasks that belong to the ultra-long batch as priority text tasks, and realize the preemptive scheduling of the priority text task on the current text task through the hardware interrupt mechanism.
[0016] The first computing unit is used to compute the priority text task using a local-global hybrid attention mechanism;
[0017] The second computing unit is used to process text tasks belonging to the regular batch in the text tasks to be processed using a first sparsity rate to generate a first historical key-value pair; and to process the priority text tasks using a second sparsity rate to generate a second historical key-value pair; wherein the first sparsity rate is greater than the second sparsity rate;
[0018] A caching unit is used to cache the first historical key-value pair in a first cache pool and cache the second historical key-value pair in a second cache pool.
[0019] Thirdly, embodiments of the present invention provide a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the task processing method described in the first aspect above.
[0020] Fourthly, embodiments of the present invention also provide a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, which, when executed by a processor, causes the processor to perform the task processing method described in the first aspect.
[0021] This invention provides a task processing method, apparatus, computer device, and storage medium. The method dynamically processes input text tasks in batches based on the length of the input sequence to distinguish between regular batches and ultra-long batches. It utilizes a hardware interrupt mechanism to achieve preemptive scheduling of the current text task by priority text tasks belonging to the ultra-long batch. Furthermore, it combines a local-global hybrid attention mechanism and a method of calculating and classifying historical key-value pairs using different sparsity rates for different batches, thereby achieving efficient processing of text tasks of different lengths, optimizing the allocation of computing resources, and improving the overall task processing efficiency. Attached Figure Description
[0022] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This is a schematic diagram of an application environment for the task processing method provided in this embodiment of the invention;
[0024] Figure 2 This is a flowchart illustrating a task processing method provided in an embodiment of the present invention;
[0025] Figure 3 yes Figure 2 A schematic diagram of a specific implementation of step S300;
[0026] Figure 4 This is another flowchart illustrating the task processing method provided in this embodiment of the invention;
[0027] Figure 5 This is a schematic diagram of the structure of the task processing device provided in the embodiment of the present invention;
[0028] Figure 6 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention;
[0029] Figure 7 This is another structural schematic diagram of the computer device provided in this embodiment of the invention. Detailed Implementation
[0030] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0031] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0032] It should also be understood that the terms used in the present specification are only for the purpose of describing particular embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0033] It should be further understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0034] The task processing method provided in this embodiment of the invention can be applied to, for example, Figure 1In this application environment, the client communicates with the program via a network. The program can dynamically batch the text tasks input by the client based on the length of the input sequence, resulting in regular batches and ultra-long batches. It then retrieves the text tasks to be processed and the current text task from the input text tasks, identifies tasks belonging to the ultra-long batch as priority tasks, and uses a hardware interrupt mechanism to preemptively schedule the priority tasks over the current text task. A local-global hybrid attention mechanism is used to compute the priority tasks. A first sparsity rate is used to process the text tasks belonging to the regular batch, generating a first historical key-value pair. A second sparsity rate is used to process the priority tasks, generating a second historical key-value pair. The first sparsity rate is greater than the second sparsity rate. Finally, the first historical key-value pair is cached in a first cache pool, and the second historical key-value pair is cached in a second cache pool.
[0035] In the technical solution of this invention, for financial business scenarios, especially banking business, the input text tasks can be divided into regular batches and ultra-long batches by input sequence length. For example, text tasks with a length of less than 1000 characters are classified as regular batches, such as simple customer inquiries and account balance inquiry feedback; text tasks with a length of 1000 characters or more are classified as ultra-long batches, such as complex loan application material analysis and risk assessment reports; the system obtains the pending text tasks and the current text task in the input bank text tasks. Tasks belonging to the ultra-long batch among the pending text tasks are identified as priority text tasks. In the bank's business processing system, a regular batch of customer inquiry tasks (the current text task) may be being processed. If an ultra-long batch of urgent loan application review tasks (a priority text task among the pending text tasks) is detected, a hardware interrupt mechanism is used to preemptively schedule the priority text task over the current text task. The hardware interrupt mechanism can quickly pause the currently processed regular task and allocate computing resources to the high-priority ultra-long task, ensuring that critical tasks involving significant customer interests and bank risk control can be processed in a timely manner.
[0036] Next, a local-global hybrid attention mechanism is employed to compute prioritized text tasks. Taking a bank loan application review task as an example, this task requires comprehensive analysis of a large amount of information about the applicant, including basic personal information, credit history, and income verification. The first sparsity rate is used to process text tasks belonging to the regular batch, generating the first historical key-value pairs. For regular batch customer inquiry tasks, due to their shorter text length and relatively simpler information, a larger first sparsity rate is used for computation, which can reduce computational load and memory usage while ensuring a certain level of accuracy. For example, when processing customer inquiries about account balances, only key information related to the account balance needs to be focused on, without needing to analyze the entire text in detail. The second sparsity rate is used to process prioritized text tasks, generating the second historical key-value pairs. Since prioritized text tasks are usually more complex and important, a smaller second sparsity rate is used for computation to ensure that the key information in the text is fully captured. The first historical key-value pairs are cached in the first cache pool, and the second historical key-value pairs are cached in the second cache pool. In a bank's business processing system, the first cache pool can be used to store historical key-value pairs for regular batch tasks. These key-value pairs can be used to quickly respond to similar routine inquiry tasks, improving the system's response speed. The second cache pool is used to store historical key-value pairs for priority text tasks. These key-value pairs are of significant reference value for processing subsequent similar important tasks.
[0037] For the fintech business field, this invention dynamically processes input text tasks in batches based on the length of the input sequence to distinguish between regular batches and ultra-long batches. It utilizes a hardware interrupt mechanism to preemptively schedule priority text tasks belonging to the ultra-long batches for the current text task. Combined with a local-global hybrid attention mechanism and a method of generating historical key-value pairs with different sparsity rates for different batches and categorizing and caching them, this achieves efficient processing of text tasks of varying lengths, optimizes computational resource allocation, and improves overall task processing efficiency. The client can be, but is not limited to, various personal computers, laptops, smartphones, and tablets. The program can be implemented using a standalone server or a server cluster consisting of multiple servers. The invention will be described in detail below through specific embodiments.
[0038] Please see Figure 2 , Figure 2 This is a flowchart illustrating a task processing method provided in an embodiment of the present invention, the method comprising steps S100 to S500:
[0039] S100. Dynamically batch the input text task according to the length of the input sequence to obtain regular batches and ultra-long batches.
[0040] In the daily operations of banks, a massive amount of text-based tasks are generated every day, such as responding to customer inquiries, reviewing loan applications, analyzing transaction records, and generating risk assessment reports. These text-based tasks are not only numerous but also vary in length and complexity. Furthermore, different tasks have different priorities. For example, urgent transaction inquiries involving customer fund security and important business inquiries from high-net-worth clients are high-priority tasks that require immediate processing; while routine tasks such as generating market research reports and compiling internal training materials are low-priority tasks.
[0041] In this embodiment, in actual banking scenarios, transaction records may contain a large amount of transaction details, resulting in long text lengths; while customer inquiries may be relatively brief. By setting an appropriate length threshold, text tasks are divided into regular batches and extra-long batches. For example, text tasks with a length of less than 1000 characters are classified as regular batches, which may include simple customer inquiries, account balance inquiries, etc.; text tasks with a length of 1000 characters or more are classified as extra-long batches, which may involve complex loan application material analysis, risk assessment reports, etc.
[0042] Dynamic batch processing fully considers the characteristics of bank text tasks, rationally classifying tasks of different lengths. Regular batches of text tasks are relatively simple to process and require less computational resources; however, very long batches of text tasks, due to their complexity and importance, require significantly more computational resources. This categorization approach optimizes the allocation of computational resources and improves overall processing efficiency.
[0043] Step S100 includes the following step S110:
[0044] S110. The dynamic time warping algorithm is used to perform cluster analysis on the input text task based on the length of the input sequence, automatically determine the optimal batch partitioning threshold, and dynamically divide the input text task into regular batches and ultra-long batches according to the optimal batch partitioning threshold.
[0045] Dynamic Time Warping (DTW) is a common algorithm used in time series analysis. It measures the similarity between two time series of different lengths by non-linearly stretching or compressing the time axis to find the optimal matching path, minimizing the distance between the two series under a certain metric. In this embodiment, the input text task is treated as a special type of "sequence," where the sequence features are primarily based on the length of the input text sequence. Because text length reflects, to some extent, the complexity of the text and the amount of resources required for processing, DTW can be used to perform clustering analysis on the text task based on its length feature.
[0046] In banking scenarios, text-based tasks are diverse and complex. For example, customer inquiry text tasks vary greatly in length; some customers simply ask about their account balance, resulting in short texts of only a few dozen characters. Others, however, inquire about loan policies, financial product features, and more, leading to texts hundreds or even thousands of characters long. Similarly, loan application review tasks vary significantly in length depending on the level of detail provided in the applicant's basic information, financial situation, and credit history. Short loan applications may only contain basic points, while longer ones may include extensive attachments and detailed explanations, exceeding several thousand characters. Furthermore, transaction record analysis tasks vary in length; simple transaction query texts are short, while complex anomaly analysis may require lengthy texts detailing the time, location, amount, counterparty, and other information of a transaction.
[0047] Furthermore, the clustering analysis process based on the DTW algorithm is as follows: First, collect various text tasks from the bank over a period of time, and extract the length of the input sequence for each text task as a feature vector. For example, for each text task, record its number of characters to form a one-dimensional feature vector containing only the text length. Assuming N text tasks are collected, then N one-dimensional feature vectors are obtained, forming a feature matrix.
[0048] Next, the distance metric is defined. In the DTW algorithm, a distance metric needs to be defined between the feature vectors of two text tasks. Since only text length is considered, a simple Euclidean distance can be used as the initial distance metric. For the feature vectors x = (x1 and y = (y1)) of two text tasks (where x1 and y1 represent the lengths of the two texts respectively), the Euclidean distance between them is d(x,y) = x1 - y1|. During the calculation process of the DTW algorithm, a distance matrix is constructed based on this initial distance, and the optimal matching path is found through dynamic programming, making the "similarity" measurement of the length features of the two text tasks more accurate.
[0049] Next, a clustering algorithm is executed, selecting a suitable clustering algorithm to combine with the DTW algorithm, such as the K-means clustering algorithm. First, K cluster centers are randomly initialized (the value of K can be set according to the approximate classification requirements of the bank text tasks; for example, initially setting K=2 to divide the text tasks into shorter and longer categories). Then, for each text task, the DTW algorithm is used to calculate its distance to each cluster center, assigning it to the nearest cluster. Next, based on the text tasks assigned to each cluster, the center of that cluster is recalculated (for text length-based clustering, the new cluster center can be the average of all text lengths in that cluster). This process of assigning and updating cluster centers is repeated until the cluster centers no longer change significantly or the preset number of iterations is reached.
[0050] Next, the optimal batch splitting threshold is determined. After the clustering analysis is completed, the clustering results are observed. Assuming K=2 is used for clustering, two clusters are obtained. One cluster contains text tasks with relatively shorter lengths, and the other contains text tasks with relatively longer lengths. At this point, the optimal batch splitting threshold can be determined by analyzing the boundary conditions between the two clusters. For example, finding the dividing point between the text lengths of the two clusters is the optimal batch splitting threshold. Specifically, a reasonable threshold can be determined by calculating the statistical characteristics of the text lengths in the two clusters, such as the median and quartiles. For example, if the median text length of the shorter text cluster is 500 characters, and the median text length of the longer text cluster is 1500 characters, then the optimal batch splitting threshold can be set to 1000 characters (this value can be adjusted according to the actual situation).
[0051] Finally, dynamic batching is implemented. Based on the determined optimal batching threshold, the input bank text tasks are dynamically divided into regular batches and extra-long batches. Text tasks with a length less than the optimal batching threshold are classified as regular batches; text tasks with a length greater than or equal to the optimal batching threshold are classified as extra-long batches. For example, if the optimal batching threshold is set to 1000 characters, then a customer inquiry text with a length of 800 characters will be classified as a regular batch, while a loan application review text with a length of 1200 characters will be classified as an extra-long batch.
[0052] S200. Obtain the text tasks to be processed and the current text task in the input text task, detect the tasks belonging to the ultra-long batch in the text tasks to be processed as priority text tasks, and realize the preemptive scheduling of the priority text task on the current text task through the hardware interrupt mechanism.
[0053] In this embodiment, the priorities of text tasks differ significantly within a banking scenario. For example, urgent customer requests for fund transfer inquiries involve real-time updates on customer funds and potential security issues, requiring immediate processing and accurate feedback; while routine tasks such as generating promotional copy for bank products have relatively lower timeliness requirements. Long batches of text tasks, such as generating complex loan risk assessment reports, are typically related to the bank's core business and major decisions, and therefore have higher priority. Regular batches of text tasks, such as compiling daily customer email reply templates, have relatively lower priority.
[0054] Input text tasks are stored in the system's task pool as data packets. Each data packet contains detailed information about the text task, such as the task content, submission time, and source channel. When processing a text task begins, a list of pending text tasks is retrieved from the task pool. Simultaneously, information about the currently processed text task (the current text task) is recorded, including task identifier and processing progress.
[0055] For example, a bank's loan department receives a large number of loan application-related text tasks daily. When a customer submits a detailed loan application via online banking (containing information on personal financial status, credit history, loan purpose, etc., exceeding a pre-set threshold for excessively long batches), this text task is added to the task pool. Simultaneously, if a bank customer service representative is processing a regular batch of customer inquiries (regarding the bank's fixed deposit interest rate, with a shorter text), the system records this ongoing task as the current text task.
[0056] Furthermore, based on the excessively long batch segmentation threshold determined by the dynamic time warping algorithm in step S110, each task in the list of text tasks to be processed is detected. For each text task to be processed, its input sequence length is extracted and compared with the excessively long batch segmentation threshold. In the example of the loan business department mentioned above, after a new loan application text task is obtained from the task pool, the length information of the text is extracted. Assuming the excessively long batch segmentation threshold is 1000 characters, and the length of the loan application text is 1500 characters, since 1500 > 1000, this text task to be processed is detected as belonging to the excessively long batch and is marked as a priority text task.
[0057] A hardware interrupt is a signal triggered by a hardware device (such as a processor or memory controller) that forces the processor to suspend the currently executing task and instead handle the event corresponding to the interrupt request. In this embodiment, the hardware interrupt mechanism is used to implement preemptive scheduling of the current text task by the priority text task.
[0058] In step S200, converting the terms in the term template set into term control vectors includes the following step S210:
[0059] S210. Inject hardware-level priority tags into the text tasks in the ultra-long batch, and mark the tasks in the ultra-long batch with injected hardware-level priority tags as priority text tasks.
[0060] In this embodiment,
[0061] Among them, Figure 3 As shown, step S200 includes the following steps S220 to S221:
[0062] S220. Detect whether there are priority text tasks belonging to the ultra-long batch among the tasks of the text task to be processed by computing the unified device architecture;
[0063] S221. When it is detected that there is a priority text task belonging to the ultra-long batch in the text task to be processed, the GPU hardware interrupt mechanism is triggered to realize the preemptive scheduling of the priority text task on the current text task.
[0064] In this embodiment, when a priority text task is detected among the pending text tasks, a hardware interrupt signal is sent to the processor. This interrupt signal has a higher priority than the currently executing task processing flow. Upon receiving the interrupt signal, the processor immediately suspends the currently processing text task (the current text task), saves the processing state of the current task, including key information such as register states and program counters, so that processing can be resumed later. The processor begins processing the priority text task, retrieves its detailed information from the task pool, and performs calculations and processing according to a predetermined processing flow. Once the priority text task is completed, the processor resumes the processing of the task based on the previously saved processing state of the current text task, continuing the operations performed before the interruption.
[0065] S300. A local-global hybrid attention mechanism is used to calculate the priority text task;
[0066] In this embodiment, the local-global hybrid attention mechanism combines the advantages of both local and global attention mechanisms. Local attention focuses primarily on local regions relevant to the current processing position within the priority text task, reducing computational load and improving efficiency. Global attention, on the other hand, considers the relationships between all positions within the priority text task, helping to capture the overall semantics and long-range dependencies of the text. By combining these two mechanisms, the accuracy of text semantic understanding can be improved while maintaining computational efficiency.
[0067] In banking scenarios, priority document processing tasks are typically complex and crucial. For example, complex loan application documents contain a wide range of information, including the applicant's personal information, financial situation, credit history, and loan purpose. These elements are interconnected; for instance, the applicant's income stability is closely related to their loan repayment ability, and delinquencies in their credit history can affect loan approval outcomes. Furthermore, the documents may contain key information, such as specific financial indicators and collateral details, which are critical to loan approval decisions.
[0068] Among them, Figure 3 As shown, in step S300, the local-global hybrid attention mechanism is used to calculate the priority text task, and the terms in the term template set are converted into term control vectors, including the following steps S310 to S311:
[0069] S310. Based on the sequence length of the priority text task, the global calculation of the priority text task is decomposed into multiple local windows and global key nodes. Local calculations are performed in each local window to obtain the calculation results of multiple local windows.
[0070] S311. The calculation results of the multiple local windows are fused with the global key node to obtain the calculation result.
[0071] In step S310, in banking scenarios, the sequence lengths of priority text tasks (such as generating complex loan risk assessment reports and writing large-scale financial data analysis reports) vary significantly. Sequence length is a key factor determining computational complexity and resource requirements. Based on the sequence length of the priority text tasks, their global computation is decomposed into multiple local windows and global key nodes. Specifically, directly performing global computation on excessively long sequences would result in a huge computational load, consuming a large amount of computing resources, and potentially exceeding the hardware's processing capacity. By dividing the sequence into local windows, relatively independent computations can be performed within each window, reducing computational complexity and improving computational efficiency. Information in text often has local relevance. For example, in loan risk assessment reports, information about the borrower's financial situation, credit history, repayment ability, etc., is usually concentrated in specific paragraphs or chapters. Decomposing the computation into local windows can better capture this local information and improve the accuracy of the computation.
[0072] Determine a fixed window size based on experience or pre-set parameters. For example, set the window size to 500 characters, and divide the priority text task into multiple local windows according to this window size. Dynamically adjust the window size based on the text's structural features (such as paragraphs or chapters) or semantic information. For example, in a financial data analysis report, a smaller window size can be set for sections with dense data tables to allow for more detailed data processing; a larger window size can be set for sections with more textual descriptions.
[0073] Furthermore, global key nodes are points in the text that have significant semantic or structural meaning. They can connect different local windows, ensuring global consistency in computation. Methods for determining global key nodes include:
[0074] In banking documents, chapter titles typically mark the beginning of different topics and can serve as global key nodes. Natural language processing (NLP) technology is used to identify key entities (such as company names and financial terms) and significant events (such as loan disbursements and default records) within the text, and these locations are then designated as global key nodes. For example, consider a large bank annual financial report analysis task, exceeding 10,000 characters in length. Dividing the text into 10 local windows of 1,000 characters each, we can identify these as global key nodes. Simultaneously, we determine the locations of chapter titles (such as "Financial Overview," "Revenue Analysis," "Cost Analysis," and "Risk Assessment") and key financial indicators (such as net profit and debt-to-equity ratio) within the report.
[0075] Furthermore, in step S311, a local-global hybrid attention mechanism is employed for local computation within each local window. Specifically, within the local window, the scaling dot product attention formula is used to calculate the attention weights between each location and other locations, focusing on the information associations within the local region. Based on the attention weights, key features within the local window, such as important words, phrases, and sentence structures, are extracted. The extracted local features are then integrated to generate the computation result for the local window, which can be a vector representation containing semantic information from within the local window.
[0076] For each global key node, textual information within a certain range around it is collected, and simple feature extraction and processing are performed to form an information representation of the global key node. These representations can be used in subsequent fusion processes to maintain global computational coherence. Different weights are assigned to local windows and global key nodes based on their importance and relevance. For example, local windows containing important financial data are given higher weights; global key nodes connecting different chapters are also given appropriate weights. Then, the computation results of multiple local windows and the information representations of the global key nodes are weighted and averaged. A gating mechanism is used to dynamically control the degree of fusion between the computation results of local windows and the information of global key nodes. The gating mechanism can automatically adjust the fusion ratio according to the current task requirements and text content, making the fused result more reasonable.
[0077] In a specific implementation, in the task of analyzing bank annual financial reports, a local-global hybrid attention mechanism is used to calculate the vector representation of each 1000-character local window. Simultaneously, the surrounding 200 characters of text information for each global key node (such as chapter titles and key financial indicator positions) are extracted and processed to obtain the information vector of the global key node. Then, a weighted fusion strategy is adopted, assigning weights based on the importance of the local window and the global key node (e.g., a weight of 0.7 for the local window and 0.3 for the global key node), and fusing them into a comprehensive calculation result vector. This vector contains the semantic information of the entire text while maintaining a balance between local and global attention.
[0078] In summary, by decomposing the global computation of priority text tasks into multiple local windows and global key nodes, and then fusing the results after computation within each local window, banks can accurately understand the semantics of the text while ensuring computational efficiency, thus providing strong support for subsequent business decisions.
[0079] In step S300, the step of performing local calculations within each local window to obtain the calculation results of multiple local windows includes the following step S320:
[0080] S320. The calculation results for multiple local windows are obtained according to the following formula:
[0081]
[0082] Among them, LocalAttn m Q represents the calculation result of the m-th local window. m K m and V m Let be the query matrix, key matrix, and value matrix of the m-th local window, respectively. represents the scaling factor, and T represents the transpose operation.
[0083] In this embodiment, within the local window, the query matrix is used to capture the query needs of the current processing position for information from other positions. It is typically obtained by linear transformation of the text features within the local window and reflects the type of information the current position is interested in. For example, in a bank loan application text, when processing a local window related to "credit history," the query matrix might focus more on information related to credit scores, overdue records, etc. The key matrix represents the information features of each position within the local window and is the basis for matching information from other positions with the query position. Also obtained from text features through linear transformation, different key vectors can highlight different aspects of the text's features. In the loan application text example above, the key matrix might contain various feature vectors related to credit history, such as the number of overdue payments and credit score ranges. The value matrix stores the actual information content of each position within the local window and is a crucial basis for calculating the final result. After the query matrix and key matrix are matched, the corresponding information in the value matrix is weighted and combined to form the calculation result of the local window. In the loan application text, the value matrix might contain specific credit history information, such as specific overdue dates and amounts.
[0084] Using the above calculation formula, banks can effectively utilize the local-global hybrid attention mechanism when processing priority text tasks, performing accurate calculations within a local window to provide strong support for subsequent global information fusion and business decisions.
[0085] S400: The text tasks belonging to the regular batch in the text tasks to be processed are processed using a first sparsity rate to generate a first historical key-value pair; the priority text tasks are processed using a second sparsity rate to generate a second historical key-value pair; wherein, the first sparsity rate is greater than the second sparsity rate;
[0086] In this embodiment, sparsity in text task computation refers to the degree of information filtering in the text when calculating attention mechanisms or performing feature extraction. A higher sparsity means that more information is ignored during the computation process, and only the relatively more important or relevant parts are retained; while a lower sparsity means that more information is retained.
[0087] In banking text processing scenarios, regular batch text tasks typically refer to those texts that are numerous, relatively low in importance, and have less stringent time requirements, such as daily customer inquiry records and textual instructions for ordinary business transactions. Priority text tasks, on the other hand, are texts that are of high importance, require priority processing, and have extremely high requirements for the accuracy of the processing results, such as complex loan approval reports and important financial risk assessment reports.
[0088] Due to the large number of text tasks in regular batch processing, a larger first sparsity is used to improve processing efficiency and reduce computational resource consumption. A larger sparsity can quickly filter out key information in the text and ignore some relatively minor details, thereby speeding up processing while maintaining a certain level of processing quality. Priority text tasks, on the other hand, have extremely high requirements for the accuracy of the processing results and need to fully consider all kinds of information in the text; therefore, a smaller second sparsity is used. A smaller sparsity can retain more text details and relevant information, ensuring a comprehensive understanding and accurate processing of priority text tasks.
[0089] By using a first sparsity rate to process regular batch text tasks and generate a first historical key-value pair, and using a second sparsity rate to process priority text tasks and generate a second historical key-value pair, banks can achieve efficient and accurate processing of text tasks of different importance, providing strong support for business decisions.
[0090] S500: Cache the first historical key-value pair in the first cache pool, and cache the second historical key-value pair in the second cache pool.
[0091] A cache pool is a memory area used for temporary data storage. It allows for fast data access and retrieval, reducing the number of reads from slower storage devices (such as hard drives) and thus improving overall system performance. In a bank text task processing system, the cache pool stores historical key-value pairs so that subsequent tasks can quickly access and utilize this data. In this embodiment, a hierarchical dual-cache pool architecture is designed, dividing the HBM memory into a regular cache (Cache0), i.e., the first cache pool, and a priority cache (Cache1), i.e., the second cache pool. Cache1 is connected to the GPU via a dedicated NVLink channel, increasing bandwidth by 2.5 times. Cache1 is specifically used to store historical key-value pairs for priority text tasks, forming a dedicated priority cache space.
[0092] Among them, Figure 4 As shown, the task processing method further includes the following steps S601 to S603:
[0093] S601. Query the second cache pool and locate similar matches using the hash table;
[0094] S602. Combining the dual conditions of cosine similarity and length difference, select target matching items from the similar matching items;
[0095] S603. Calculate the priority text task using the target matching item.
[0096] In this embodiment, in step S601, in the bank priority text task processing scenario, the second cache pool stores historical key-value pairs generated by processing priority text tasks through a second sparsity calculation. Hash tables, as an efficient data structure, can quickly locate similar matches during the query process. Hash tables map keys to a specific storage location using hash functions, making the time complexity of query operations approach constant level, greatly improving query efficiency.
[0097] Taking a new bank loan approval report as an example, the process first extracts key features from the report, such as the borrower's credit score, debt ratio, and income level. Then, these features are input into a hash function to obtain a hash value. The key-value pair corresponding to this hash value is then searched in the hash table of the second cache pool. This may yield multiple historical loan approval cases similar to the current loan approval report; these cases are the initially selected similarity matches.
[0098] In step S602, cosine similarity is an indicator that measures the degree of similarity between two vectors in direction. In text processing, it is used to calculate the cosine value of the angle between two text feature vectors; the closer the value is to 1, the more semantically similar the two texts are. Length difference refers to the degree of difference between the lengths (i.e., the magnitudes of the vectors) of two text feature vectors. In text processing, length difference can reflect the amount of information in the text. If the length difference between the feature vectors of two texts is too large, it may affect the similarity judgment between them.
[0099] Taking bank loan approval reports as an example, for several similar historical loan approval cases initially screened, the cosine similarity and length difference between the current report and each case are calculated. Assume the cosine similarity threshold is 0.8 and the length difference threshold is 0.2. If a historical case has a cosine similarity of 0.85 and a length difference of 0.15 with the current report, then that case meets both conditions and is selected as a target match; while another case with a cosine similarity of 0.75 and a length difference of 0.25 does not meet the conditions and is excluded.
[0100] In step S603, the target matching item is a historical key-value pair selected from the second cache pool that is most similar to the current priority text task. These key-value pairs contain rich historical processing information and results, which can be used to fuse the approval results and key approval basis of the selected target loan approval cases with the information in the current loan approval report. Then, the fused information is input into the loan approval model for calculation. The model will generate the approval result of the current loan approval report based on the fused information, comprehensively considering factors such as the borrower's credit status and financial status. If the model judges that the borrower has good credit and stable financial status, it may give an approval result of loan approval; if there are some risk factors, such as overdue credit records or excessive debt ratio, it may give an approval result of loan rejection or further review required. This provides important reference and guidance for the calculation of the priority text task.
[0101] As can be seen, in the above solution, for the fintech business field, the input text tasks are processed in batches according to the length of the input sequence to distinguish between regular batches and ultra-long batches. The hardware interrupt mechanism is used to realize the preemptive scheduling of the priority text tasks belonging to the ultra-long batch of the text tasks to be processed on the current text task. Combined with the local-global hybrid attention mechanism and the method of calculating and caching historical key-value pairs with different sparsity rates for different batches, the solution achieves efficient processing of text tasks of different lengths, optimizes the allocation of computing resources, and improves the overall task processing efficiency.
[0102] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0103] This invention also provides a task processing device, which corresponds one-to-one with the task processing methods described in the above embodiments. For example... Figure 5 As shown, the task processing device 700 includes: a processing unit 701, a scheduling unit 702, a first computing unit 703, a second computing unit 704, and a cache unit 705. Detailed descriptions of each functional unit are as follows:
[0104] Processing unit 701 is used to dynamically batch process the input text task according to the length of the input sequence to obtain regular batches and ultra-long batches.
[0105] The scheduling unit 702 is used to obtain the text tasks to be processed and the current text task in the input text task, detect the tasks belonging to the ultra-long batch in the text tasks to be processed as priority text tasks, and realize the preemptive scheduling of the priority text task on the current text task through the hardware interrupt mechanism.
[0106] The first computing unit 703 is used to compute the priority text task using a local-global hybrid attention mechanism;
[0107] The second computing unit 704 is used to process text tasks belonging to the regular batch in the text task to be processed using a first sparsity rate to generate a first historical key-value pair; and to process the priority text task using a second sparsity rate to generate a second historical key-value pair; wherein the first sparsity rate is greater than the second sparsity rate.
[0108] The caching unit 705 is used to cache the first historical key-value pair in the first cache pool and cache the second historical key-value pair in the second cache pool.
[0109] This invention provides a task processing device that dynamically processes input text tasks in batches based on the length of the input sequence to distinguish between regular batches and ultra-long batches. It utilizes a hardware interrupt mechanism to preemptively schedule priority text tasks belonging to the ultra-long batches for the current text task. Furthermore, it combines a local-global hybrid attention mechanism with a method that uses different sparsity rates to generate and classify historical key-value pairs for different batches, thereby achieving efficient processing of text tasks of varying lengths, optimizing computational resource allocation, and improving overall task processing efficiency.
[0110] For specific limitations regarding the task processing device, please refer to the limitations on the task processing method above, which will not be repeated here. Each module in the aforementioned task processing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in hardware or independently of the processor in the computer device, or stored in software in the memory of the computer device, so that the processor can call and execute the operations corresponding to each module.
[0111] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements a task processing method, server-side function, or step.
[0112] In one embodiment, a computer device is provided, which may be a client, and its internal structure diagram may be as follows: Figure 7 As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements a task processing method, client-side functions, or steps.
[0113] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps:
[0114] The input text task is dynamically batched based on the length of the input sequence to obtain regular batches and ultra-long batches.
[0115] The text tasks to be processed and the current text task in the input text task are obtained. Tasks belonging to the ultra-long batch in the text tasks to be processed are detected as priority text tasks. The priority text task is preemptively scheduled to the current text task through a hardware interrupt mechanism.
[0116] A local-global hybrid attention mechanism is used to compute the priority text task;
[0117] The text tasks belonging to the regular batch in the text tasks to be processed are calculated using a first sparsity rate to generate a first historical key-value pair; the priority text tasks are calculated using a second sparsity rate to generate a second historical key-value pair; wherein, the first sparsity rate is greater than the second sparsity rate;
[0118] The first historical key-value pair is cached in the first cache pool, and the second historical key-value pair is cached in the second cache pool.
[0119] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0120] The input text task is dynamically batched based on the length of the input sequence to obtain regular batches and ultra-long batches.
[0121] The text tasks to be processed and the current text task in the input text task are obtained. Tasks belonging to the ultra-long batch in the text tasks to be processed are detected as priority text tasks. The priority text task is preemptively scheduled to the current text task through a hardware interrupt mechanism.
[0122] A local-global hybrid attention mechanism is used to compute the priority text task;
[0123] The text tasks belonging to the regular batch in the text tasks to be processed are calculated using a first sparsity rate to generate a first historical key-value pair; the priority text tasks are calculated using a second sparsity rate to generate a second historical key-value pair; wherein, the first sparsity rate is greater than the second sparsity rate;
[0124] The first historical key-value pair is cached in the first cache pool, and the second historical key-value pair is cached in the second cache pool.
[0125] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0126] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0127] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0128] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A task processing method, characterized in that, Includes the following steps: The input text task is dynamically batched based on the length of the input sequence to obtain regular batches and ultra-long batches. The text tasks to be processed and the current text task in the input text task are obtained. Tasks belonging to the ultra-long batch in the text tasks to be processed are detected as priority text tasks. The priority text task is preemptively scheduled to the current text task through a hardware interrupt mechanism. A local-global hybrid attention mechanism is used to compute the priority text task; The text tasks belonging to the regular batch in the text tasks to be processed are calculated using a first sparsity rate to generate a first historical key-value pair; the priority text tasks are calculated using a second sparsity rate to generate a second historical key-value pair; wherein, the first sparsity rate is greater than the second sparsity rate; The first historical key-value pair is cached in the first cache pool, and the second historical key-value pair is cached in the second cache pool.
2. The task processing method according to claim 1, characterized in that, The step of dynamically batching the input text task according to the length of the input sequence to obtain regular batches and ultra-long batches includes the following steps: The dynamic time warping algorithm is used to perform cluster analysis on the input text task based on the length of the input sequence, automatically determine the optimal batch splitting threshold, and dynamically divide the input text task into regular batches and ultra-long batches according to the optimal batch splitting threshold.
3. The task processing method according to claim 1, characterized in that, The step of identifying tasks belonging to the ultra-long batch among the text tasks to be processed as priority text tasks includes the following steps: A hardware-level priority tag is injected into the text tasks in the ultra-long batch, and the tasks in the ultra-long batch with the injected hardware-level priority tag are marked as priority text tasks.
4. The task processing method according to claim 1, characterized in that, The process of identifying tasks belonging to the ultra-long batch among the text tasks to be processed as priority text tasks, and implementing preemptive scheduling of the priority text tasks over the current text tasks through a hardware interrupt mechanism, includes the following steps: The unified device architecture is used to detect whether there are priority text tasks belonging to the ultra-long batch among the tasks of the text task to be processed; When a priority text task belonging to the ultra-long batch is detected in the pending text tasks, the GPU hardware interrupt mechanism is triggered to realize the preemptive scheduling of the priority text task on the current text task.
5. The task processing method according to claim 1, characterized in that, The calculation of the priority text task using a local-global hybrid attention mechanism includes the following steps: Based on the sequence length of the priority text task, the global computation of the priority text task is decomposed into multiple local windows and global key nodes. Local computation is performed within each local window to obtain the computation results of multiple local windows. The calculation results of multiple local windows are fused with the global key node to obtain the calculation result.
6. The task processing method according to claim 5, characterized in that, The process of performing local calculations within each local window to obtain calculation results for multiple local windows includes the following steps: The calculation results for multiple local windows are obtained according to the following formula: Among them, LocalAttn m Q represents the calculation result of the m-th local window. m K m and V m Let be the query matrix, key matrix, and value matrix of the m-th local window, respectively. represents the scaling factor, and T represents the transpose operation.
7. The task processing method according to claim 1, characterized in that, It also includes the following steps: Query the second cache pool and locate similar matches using a hash table; By combining the dual conditions of cosine similarity and length difference, target matches are selected from the similarity matches. The priority text task is calculated using the target matching terms.
8. A task processing device, characterized in that, include: The processing unit is used to dynamically batch the input text task according to the length of the input sequence to obtain regular batches and ultra-long batches. The scheduling unit is used to obtain the pending text tasks and the current text task in the input text task, detect the tasks in the pending text tasks that belong to the ultra-long batch as priority text tasks, and realize the preemptive scheduling of the priority text task on the current text task through the hardware interrupt mechanism. The first computing unit is used to compute the priority text task using a local-global hybrid attention mechanism; The second computing unit is used to process the text tasks belonging to the regular batch in the text tasks to be processed using the first sparsity rate, and generate the first historical key-value pairs. The priority text task is processed using a second sparsity rate to generate a second historical key-value pair; wherein the first sparsity rate is greater than the second sparsity rate; A caching unit is used to cache the first historical key-value pair in a first cache pool and cache the second historical key-value pair in a second cache pool.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the task processing method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to perform the task processing method as described in any one of claims 1 to 7.
Citation Information
Cited By
Large model underlying data processing method and system based on sparse attention
CN121029778A
Key value cache dynamic compression method based on multi-dimensional semantic entropy and task adaptive perception
CN121681717A
A key-value cache dynamic compression method based on multi-dimensional semantic entropy and task adaptive perception
CN121681717B
Prefix caching method and device suitable for mixed attention model architecture
CN122088718A
A prefix caching method and apparatus suitable for a hybrid attention model architecture
CN122088718B