Artificial intelligence reasoning method and device, electronic equipment and computer storage medium
By splitting text into semantic units and processing subtasks in parallel, the problem of high token consumption and forgetting in large language models with long contexts and complex logical links is solved, and efficient and accurate inference results are generated.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING KNOWNSEC INFORMATION TECHNOLOGY CO LTD
- Filing Date
- 2025-12-19
- Publication Date
- 2026-04-10
AI Technical Summary
Existing large language models suffer from problems such as high token consumption, rapid increase in inference time, and easy forgetting of context when handling tasks with long context and complex logical links, leading to a decrease in output accuracy.
The text to be processed is divided into multiple semantic units, and each semantic unit is divided into subtasks according to its reasoning intent. A suitable reasoning model is selected based on the estimated load level and complexity of the subtasks. The final reasoning result is generated through parallel execution and result aggregation.
By decomposing tasks into subtasks, the overall reasoning time is shortened, contextual congestion and forgetting are avoided, reasoning efficiency is improved and resource waste is reduced, and the accuracy of reasoning results is ensured.
Smart Images

Figure CN121835888A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, in particular to an artificial intelligence reasoning method and device, electronic equipment and computer storage medium. BACKGROUND
[0002] LLM (Large Language Model) performs well in natural language understanding, reasoning and generation tasks. However, for tasks with long context, complex logical links or across knowledge domains, direct input to the model often has the following problems: when the input content is large, the token consumption is extremely high, resulting in a sharp increase in cost, at the same time, the reasoning time increases linearly or even super-linearly with the increase of task complexity, and when the reasoning link is too long, the model will be limited by the context window, resulting in information loss or forgetting, and the output accuracy decreases. SUMMARY
[0003] The present application relates to the technical field of artificial intelligence, in particular to an artificial intelligence reasoning method and device, electronic equipment and computer storage medium.
[0004] Embodiments of the present application can be implemented as follows: In a first aspect, the present application provides an artificial intelligence reasoning method, comprising: obtaining a plurality of semantic units obtained by semantically splitting a to-be-processed text; dividing all the semantic units into a plurality of sub-tasks according to the reasoning intention of each semantic unit; determining the reasoning model of each sub-task according to the estimated load level and complexity of each sub-task; executing the reasoning model of each sub-task to obtain the reasoning execution result of each sub-task; aggregating the reasoning execution results of all the sub-tasks to obtain the reasoning result of the to-be-processed text.
[0005] In an optional implementation, before the step of determining the reasoning model of each sub-task according to the estimated load level and complexity of each sub-task, the method comprises: obtaining the input text length and reasoning type of each sub-task; evaluating the token number of each sub-task according to the input text length of each sub-task; evaluating the resource occupation information of each sub-task according to the reasoning type of each sub-task; determining the estimated load level of each sub-task according to the token number and resource occupation information of each sub-task.
[0006] In an optional implementation, before the step of determining an inference model of each of the sub-tasks according to the estimated load level and complexity of each of the sub-tasks, the method further comprises: estimating the access frequency and the inference chain length of a knowledge base accessed by each of the sub-tasks; determining the complexity of each of the sub-tasks according to the access frequency and the inference chain length of each of the sub-tasks.
[0007] In an optional implementation, the step of executing the inference model of each of the sub-tasks to obtain the inference execution result of each of the sub-tasks comprises: generating an execution graph according to the dependency relationship between each two of the sub-tasks, wherein each node in the execution graph corresponds to a sub-task; executing the inference model of each of the sub-tasks based on the in-degree of each node in the execution graph to obtain the inference execution result of each of the sub-tasks.
[0008] In an optional implementation, before the step of generating an execution graph according to the dependency relationship between each two of the sub-tasks, wherein each node in the execution graph corresponds to a sub-task, the method further comprises: performing entity recognition on the input text of each of the sub-tasks to obtain entities of each of the sub-tasks; organizing the entities of each of the sub-tasks according to a preset format to obtain at least one information element of each of the sub-tasks; for any two of the sub-tasks, if there is a dependency relationship between any information element in a first sub-task of the two sub-tasks and any information element in a second sub-task of the two sub-tasks, it is determined that there is a dependency relationship between the first sub-task and the second sub-task.
[0009] In an optional implementation, the step of aggregating the inference execution results of all the sub-tasks to obtain the inference result of the to-be-processed text comprises: obtaining the task type of the sub-tasks; determining an aggregation strategy according to the task type; aggregating the inference execution results of the sub-tasks according to the aggregation strategy to obtain the inference result of the to-be-processed text.
[0010] In an optional implementation, the step of determining an aggregation strategy according to the task type comprises: if the task type is a classification type, the weighted voting strategy is determined as the aggregation strategy to perform weighted calculation on the inference execution results of the sub-tasks, and the inference result is determined according to the weighted calculation result; If the task type is a structured type, the logical merging strategy is determined as the aggregation strategy, so as to merge the inference execution results of the subtasks according to the priority of the subtasks' inference execution results to the preset event dependencies, and determine the inference result based on the merging result; If the task type is a question-and-answer type, then neural network fusion is determined as the aggregation strategy, so as to use a preset neural network model to fuse the inference execution results of the sub-task, and determine the inference result based on the fusion result.
[0011] In a second aspect, the present invention provides an artificial intelligence reasoning device, the device comprising: The acquisition module is used to acquire multiple semantic units obtained by semantically splitting the text to be processed. The segmentation module is used to divide all the semantic units into multiple subtasks according to the reasoning intent of each semantic unit; The determination module is used to determine the inference model for each subtask based on the estimated load level and complexity of each subtask. The execution module is used to execute the reasoning model of each subtask and obtain the reasoning execution result of each subtask. The aggregation module is used to aggregate the inference execution results of all the subtasks to obtain the inference result of the text to be processed.
[0012] Thirdly, the present invention provides an electronic device including a processor and a memory, the memory being used to store a program, and the processor being used to implement the artificial intelligence reasoning method as described in the first aspect when executing the program.
[0013] Fourthly, the present invention provides a computer storage medium having a computer program stored thereon, which, when executed by a processor, implements the artificial intelligence reasoning method as described in the first aspect.
[0014] Compared with the prior art, the present invention has the following beneficial effects: This invention semantically decomposes the text to be processed into multiple semantic units. Based on the reasoning intent of each semantic unit, it divides the text into multiple subtasks. Based on the estimated load level and complexity of each subtask, a reasoning model is determined for each subtask. Finally, the reasoning execution results of all subtasks are aggregated to obtain the reasoning result for the text to be processed. By decomposing the subtasks, the overall reasoning scale is reduced, avoiding inaccurate reasoning results due to context congestion and forgetting caused by excessively long tasks. It also provides conditions for parallel execution of subtasks, improving reasoning efficiency and shortening the overall reasoning time. By determining the most suitable reasoning model for each subtask based on its estimated load level and complexity, it effectively avoids resource waste and unnecessary cost consumption caused by task decomposition. Attached Figure Description
[0015] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 This is a flowchart illustrating the artificial intelligence reasoning method provided in this embodiment.
[0017] Figure 2 This is an example diagram of the execution diagram provided in this embodiment.
[0018] Figure 3 This is a block diagram of the artificial intelligence inference device provided in this embodiment.
[0019] Figure 4 This is a block diagram of the electronic device provided in this embodiment.
[0020] Icons: 10-Electronic device; 11-Processor; 12-Memory; 13-Bus; 100-Artificial intelligence inference device; 110-Acquisition module; 120-Partitioning module; 130-Determination module; 140-Execution module; 150-Aggregation module. Detailed Implementation
[0021] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0022] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0023] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0024] In the description of this invention, it should be noted that if terms such as "upper," "lower," "inner," or "outer" are used to indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship in which the product of this invention is usually placed, they are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this invention.
[0025] Furthermore, the terms "first" and "second" are used only to distinguish descriptions and should not be interpreted as indicating or implying relative importance.
[0026] It should be noted that, where there is no conflict, the features in the embodiments of the present invention can be combined with each other.
[0027] In this embodiment, to optimize the reasoning results and improve their accuracy, another commonly used approach is chain-based reasoning. This approach guides the model through step-by-step reasoning using prompts. For example, adding "Please think and reason step by step" to the prompt will generate a reasoning chain, progressively leading from simple conclusions to more complex ones. In this approach, the model's reasoning logic is more transparent through displayed prompts; each step's result is retained within the context, enhancing logical coherence. This method is particularly suitable for tasks requiring a clear understanding of intermediate processes, such as mathematical proofs and logic problem solutions.
[0028] However, this chain-based reasoning still involves sequential execution, so the overall time consumption is not significantly reduced. As the context content continues to grow, the token consumption increases rapidly with the increase in reasoning steps. When the chain length is too long, it may still trigger model forgetting, making it difficult to guarantee the stability of the final reasoning result.
[0029] In view of this, this embodiment provides an artificial intelligence inference method, apparatus, electronic device, and computer storage medium. Its core improvement lies in abandoning the current serial execution inference method, decomposing tasks based on inference intent, providing conditions for parallel task execution, improving inference efficiency, and effectively avoiding inaccurate inference results due to context congestion and forgetting caused by excessively long tasks. By determining the most suitable inference model for each subtask based on its estimated load level and complexity, resource waste and unnecessary cost consumption caused by task decomposition are effectively avoided. A detailed description follows.
[0030] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating the artificial intelligence inference method provided in this embodiment. The method includes the following steps: Step S101: Obtain multiple semantic units obtained by semantically splitting the text to be processed.
[0031] In this embodiment, the text to be processed can be the text content of documents such as contract documents, technical documents, and code documents that require reasoning. To remove data irrelevant to reasoning from the text and purify the input content, basic natural language preprocessing operations can be performed before semantic segmentation of the text. These operations include, but are not limited to, word segmentation, segmentation by paragraph or logical module, and removal of irrelevant metadata such as headers, footers, and numbering. Then, based on domain knowledge rules or a lightweight semantic model, the processed text is divided into several "semantic units" with independent meaning. For example, in a legal context, a contract can be divided into semantic blocks such as "performance obligations," "breach of contract clauses," and "exemptions"; each semantic unit represents a functionally complete semantic fragment.
[0032] Step S102: Based on the reasoning intent of each semantic unit, divide all semantic units into multiple sub-tasks.
[0033] In this embodiment, named entity recognition (NER) is first performed on each semantic unit to extract its key element set, such as the subject role (Party A / Party B), action (payment / delivery), triggering condition (delay exceeding 30 days), and quantitative indicators (amount of 1 million yuan, period of 6 months). These elements constitute the core semantic skeleton of the semantic unit. Subsequently, the functional objectives of the semantic unit are analyzed by combining a preset template or a trained dedicated classifier to determine its reasoning intent. For example, in the legal field, the dedicated classifier can be a legal intent recognition model, which is used to determine reasoning intents such as "liability determination," "legal citation retrieval," or "compensation amount calculation." Each semantic unit and its reasoning intent can be combined into an independent task candidate, thereby generating a sub-task with a clear execution objective. For example, the semantic unit "performance obligation" may generate a "clause parsing" sub-task after analysis; the semantic unit "breach of contract conditions" may generate a "breach of contract identification" sub-task.
[0034] It should be noted that, depending on the needs of the actual scenario, for overly complex subtasks, they can be further decomposed into multi-level tasks, refining the subtasks into smaller subtask units.
[0035] Step S103: Determine the inference model for each subtask based on the estimated load level and complexity of each subtask.
[0036] In this embodiment, the estimated load level is used to characterize the expected computational resource consumption of the subtask. The higher the computational resource consumption, the higher the estimated load level; otherwise, the lower the estimated load level. The estimated load level can be determined by assessing resource consumption such as the length of the input text of the subtask, the inference type, memory bandwidth, and GPU usage intensity. The complexity can be determined by whether external knowledge base access is required and its access frequency, as well as the number of logical derivation steps required.
[0037] In this embodiment, based on the estimated load level and complexity, the most suitable inference model for the subtask can be dynamically selected. For example, for subtasks with low load and low complexity (such as clause extraction), a lightweight model or rule engine is used for fast processing; for high-complexity tasks (such as cross-knowledge domain reasoning or RAG-enhanced question answering), a large language model or a multi-component collaborative architecture is invoked. This can significantly improve the overall system's cost-effectiveness and response efficiency.
[0038] Step S104: Execute the inference model for each subtask to obtain the inference execution result for each subtask.
[0039] In this embodiment, at the hardware level, different types of model instances can be deployed through GPU clusters, microservice containers, etc., to form an elastic computing pool, so as to achieve concurrent execution of multiple sub-tasks with no dependencies. At the software level, multi-threading, multi-instance, or distributed architecture can be used to support the concurrent execution of multiple sub-tasks, so as to shorten the total inference time and improve inference efficiency.
[0040] Step S105: Aggregate the inference execution results of all subtasks to obtain the inference result of the text to be processed.
[0041] In this embodiment, aggregation includes, but is not limited to, splicing, stacking, and fusion. Since different types of tasks have different ways of representing their inference execution results, in order to integrate the scattered subtask results into a logically consistent, fluently expressed, complete, and high-quality final output, the optimal fusion strategy can be adaptively selected based on the task characteristics.
[0042] The method provided in this embodiment reduces the overall inference scale by decomposing tasks into subtasks, avoiding inaccurate inference results due to context congestion and forgetting caused by excessively long tasks. It also provides conditions for parallel execution of subtasks, improving inference efficiency and shortening the overall inference time. By determining the most suitable inference model for each subtask based on its estimated load level and complexity, it effectively reduces resource waste and unnecessary cost consumption.
[0043] In an optional implementation, this embodiment also provides a method for determining the estimated load level: First, obtain the input text length and reasoning type for each subtask; In this embodiment, the reasoning types include, but are not limited to, information extraction, logical judgment, knowledge retrieval, and generative reasoning. For example, clause parsing belongs to the information extraction type, and breach of contract identification belongs to the logical judgment type.
[0044] Secondly, the number of tokens for each subtask is evaluated based on the length of the input text for each subtask. In this embodiment, since Large Language Models (LLMs) and various AI inference engines all use tokens as the basic input and output processing unit, accurately estimating the number of tokens is crucial for predicting memory usage, communication overhead, and inference latency. The input text can be segmented and statistically analyzed using a standard tokenizer tool to obtain precise token values. For example, the portion of a 10,000-word contract allocated to the "terms parsing" subtask might contain approximately 3,000 tokens. A high number of tokens implies a higher context window footprint and greater computational pressure, directly impacting execution costs.
[0045] Third, assess the resource consumption information of each subtask based on the reasoning type of each subtask; In this embodiment, the resource consumption information depends on the nature of the reasoning type itself. For example, the "information extraction" type has long inputs, but only requires local matching and label recognition, which can be handled by a lightweight CPU model with low memory and computing power consumption. The "generative reasoning" type has short inputs, but requires autoregressive generation of long paragraphs, involving a large number of matrix operations, and must use a large model accelerated by GPU, resulting in high resource consumption. The "knowledge retrieval enhancement" type also needs to access an external vector database, introducing I / O latency and network call overhead.
[0046] In this embodiment, the "inference type" can be mapped to a set of resource feature descriptions based on preset rules or a small classifier, such as: expected output length, whether external retrieval is enabled, whether high-precision floating-point operations are required, and recommended hardware type. These information collectively constitute "resource usage information".
[0047] Finally, based on the number of tokens and resource usage information of each subtask, the estimated load level of each subtask is determined.
[0048] In this embodiment, the number of tokens represents the scale dimension, and resource usage information represents the intensity dimension. These two dimensions are combined to comprehensively assess the estimated load level. As one implementation, a quantity threshold can be set according to the actual application scenario. Low and high token levels are determined based on the quantity threshold and the number of tokens. Each resource feature in the resource usage information can be assigned a corresponding weight. A resource usage score is calculated based on all resource features and their weights, and low and high resource demands are determined based on the resource usage score. The estimated load level can include low, medium, and high load levels, or it can be represented by continuous numerical values. For example, high token level + low resource demand is determined as medium load, low token level + high resource demand as medium or high load, and high token level + high resource demand as high load. Large-scale text cleaning belongs to medium load with high token level and low resource demand, while long document generation messages belong to high load with high token level and high resource demand.
[0049] In this embodiment, subtasks with an estimated high load level can be assigned to dedicated GPU nodes and their concurrency can be limited, while subtasks with an estimated low load level can be processed in batches in a shared CPU pool, thereby effectively avoiding resource waste and performance bottlenecks.
[0050] In an optional implementation, this embodiment also provides an implementation method for determining complexity: First, estimate the number of times the knowledge base is accessed and the length of the inference chain for each subtask; In this embodiment, many subtasks rely on external or internal knowledge bases (such as structured databases, vector databases, ontology libraries, rule engines, etc.) to obtain supporting information for reasoning. The degree of knowledge dependence varies among subtasks. For example, a subtask involving causal analysis of historical events may require multiple queries to a timeline database and a relational graph, while a simple named entity recognition subtask requires almost no access to a knowledge base. Therefore, based on the subtask's task type, key entities in the input text, and known knowledge source mapping relationships, the expected number of knowledge queries required during the entire execution process can be predicted. This can be implemented using a pre-trained lightweight prediction model or a rule-based heuristic algorithm. For example, if the task contains semantic keywords such as "cause," "lead to," or "background," it is determined to have a high knowledge retrieval tendency; if specific domain terms (such as medical or legal terms) are identified, the corresponding domain's dedicated knowledge base is associated, and the typical access frequency is estimated.
[0051] In this embodiment, the reasoning chain refers to a series of logical deduction steps required to solve a task, typically manifested as the length of a multi-hop reasoning chain. For example, "Why did Company A's stock price fall?" might involve multiple intermediate reasoning steps such as "financial report loss" → "market expectations lowered" → "investors selling off," forming a relatively long reasoning chain; while "Who is the CEO of Company B?" can be completed with a single-step table lookup. The length of the reasoning chain directly reflects the inherent cognitive complexity of the task. In practical implementation, the semantic intent of the subtask can be parsed by the natural language understanding module, and combined with the task template library or historical execution logs, the length of historical reasoning paths for similar tasks can be matched for estimation. Alternatively, a large model can be used to automatically generate potential reasoning paths and count their number of nodes as an approximation.
[0052] Secondly, the complexity of each subtask is determined based on the number of times each subtask is accessed and the length of the inference chain.
[0053] In this embodiment, the frequency of knowledge access reflects the strength of data dependencies, and the length of the inference chain reflects the logical depth. These two dimensions can be fused using weighted scoring models, decision trees, or small neural networks to determine complexity. For example, a subtask that requires only one knowledge query but five steps of causal reasoning should still be classified as a high-complexity task; conversely, tasks with frequent queries but no deep reasoning (such as list summarization) can be considered of medium complexity. By setting thresholds or clustering methods, all subtasks can be divided into three complexity levels: "low," "medium," and "high," thus guiding the selection of subsequent inference models. High-complexity tasks tend to call larger models with larger parameter scales and stronger reasoning capabilities (such as GPT-4 levels), while low-complexity tasks can be efficiently handled by lightweight models (such as TinyBERT).
[0054] In an optional implementation, after splitting the original text to be processed into multiple semantic units and further dividing them into independent subtasks, these subtasks are not always isolated from each other. The output of some tasks may constitute the input prerequisites for other tasks, that is, there is a logical or data dependency relationship. In order to accurately identify the dependency relationship between two subtasks, this embodiment provides an implementation method: First, entity recognition is performed on the input text of each subtask to obtain the entities of each subtask; In this embodiment, a Named Entity Recognition (NER) module fine-tuned from a pre-trained language model (such as BERT or RoBERTa) can be used, or large model prompting can be employed to extract key entities, such as names, organizations, time periods, locations, product names, financial indicators, and event types. For example, in the subtask of "analyzing Company A's Q3 2024 financial performance," the identified entities include "Company A" (organization), "Q3 2024" (time period), "financial report" (document type), "revenue," and "net profit" (financial indicators). These entities constitute the core objects and contextual anchors of interest in the subtask.
[0055] Secondly, the entities of each subtask are organized according to a preset format to obtain at least one information element for each subtask. In this embodiment, the preset format can be a unified knowledge representation template, typically including metadata such as the entity itself, entity category, domain, semantic roles (e.g., subject, object, conditional clause), time attribute, and confidence level. For example, "Company A's revenue in Q3 2024 was $89 billion" can be organized into the following multiple information elements: {Entity: Company A, Attribute: Revenue, Value: 89 billion, Time: 2024-Q3, Unit: RMB, Type: Financial}; {Document source: Q3 financial report, cited as: official disclosure}.
[0056] Finally, for any two subtasks, if there is a dependency between any information element in the first subtask and any information element in the second subtask, then it is determined that there is a dependency between the first and second subtasks.
[0057] In this embodiment, the method for determining the dependency relationship between any two subtasks is the same. This embodiment uses any two subtasks as an example. For the first subtask and the second subtask, the dependency relationship between them includes at least one of the following: Reference dependency: The result of the first subtask contains the entity values required by the second subtask. For example, if the first subtask outputs "net profit is 1 billion yuan", the second subtask needs to determine "whether the company's profit exceeds 500 million yuan".
[0058] Causal dependency: The causal information involved in the first subtask is a prerequisite for the result of the second subtask. For example, the first subtask analyzes "the price of raw materials is rising", and the second subtask infers "the production cost is rising".
[0059] Temporal dependency: The first and second subtasks describe different stages of the same event chain. For example, the "release of a new product" in the first subtask occurs first, followed by the "increase in market share" in the second subtask.
[0060] Thematic consistency + logical complementarity: The first and second sub-tasks serve the same high-level goal, and the information elements cover different dimensions. For example, the first sub-task extracts "user complaint content", and the second sub-task extracts "after-sales response time". Both are used to comprehensively evaluate service quality.
[0061] A dependency relationship is established between the first and second subtasks when any information element in the first subtask satisfies at least one of the aforementioned dependencies with any information element in the second subtask. This dependency identification mechanism based on structured information elements has higher accuracy and interpretability compared to traditional keyword co-occurrence or syntactic distance methods, and can effectively support the automatic generation of task graphs in complex reasoning processes.
[0062] After obtaining the dependencies between each pair of subtasks, this embodiment provides a subtask execution method based on an execution graph to make the execution of multiple subtasks more orderly and efficient: First, an execution graph is generated based on the dependencies between all subtasks, with each node in the execution graph corresponding to a subtask. In this embodiment, the execution graph can be a directed graph, where each node represents a subtask. If the output of subtask A is dependent on subtask B, a directed edge is added from node A to node B. By traversing all subtask pairs and identifying dependency patterns such as references, causality, and timing among their information elements, a standard and complete task dependency network execution graph can be automatically established. Please refer to... Figure 2 , Figure 2 This is an example diagram of the execution diagram provided in this embodiment. Figure 2 In the execution diagram, there are four subtasks: A, B, C, and D. Their functions are clause parsing, breach identification, legal clause matching, and compensation suggestion generation, respectively. A's downstream dependencies are B and C, meaning B and C's input depends on A. B's downstream dependency is D, meaning D's input depends on B. C's downstream dependency is D, meaning D's input depends on C.
[0063] Secondly, based on the in-degree of each node in the execution graph, the inference model of each subtask is executed to obtain the inference execution result of each subtask.
[0064] In this embodiment, the in-degree is the number of edges pointing to a node, reflecting how many preceding subtasks the subtask needs to wait for to complete before it can start. During the execution phase, a task scheduling strategy similar to topological sorting can be used to prioritize the execution of subtasks corresponding to nodes with an in-degree of 0. These tasks do not depend on the results of any other subtasks and are considered initially executable tasks. Once a subtask is completed, the system traverses all its successor nodes and decrements the in-degree of these successor nodes by 1. When the in-degree of a node drops to 0, it indicates that all its prerequisites have been met, and the model inference execution of that task is immediately triggered. This mechanism ensures the correctness of the task execution order and avoids the propagation of errors or null values due to incomplete data. At the same time, this mechanism supports highly parallel processing: multiple tasks with an in-degree of 0 can be executed concurrently, significantly improving overall inference efficiency.
[0065] It should be noted that when scheduling subtasks based on the execution graph, distributed subtask scheduling can also be implemented on multi-level clusters to further improve inference performance. The scheduler can also dynamically adjust the execution order based on task priority and resource usage, and can record historical execution logs to optimize future task decomposition and scheduling strategies.
[0066] In an optional implementation, the step of aggregating the inference execution results of all the subtasks to obtain the inference result of the text to be processed includes: First, obtain the task type of the subtask; In this embodiment, the task type represents the semantic category or functional scope to which the subtask belongs. For example, the task type is a classification task, a question-and-answer task, etc. The task type can be obtained by direct annotation by the intent recognition module during the subtask division stage, for example, by judging "whether it is a classification intent" based on a classification model; it can also be obtained by parsing keywords and sentence patterns in the subtask input text, for example, if it contains "which category does it belong to", it is judged as a classification, and "why / how" is judged as a question-and-answer; or it can be obtained by matching and classifying in a predefined task template library.
[0067] Secondly, the aggregation strategy is determined based on the task type; In this embodiment, the output format, semantic granularity, and confidence distribution generated by different task types differ significantly. Therefore, a single fixed merging method (such as simple concatenation or averaging) cannot be used. Instead, the most suitable aggregation logic must be selected based on the characteristics of the subtasks. The aggregation strategy can be configured by pre-installing a strategy mapping table or rule engine to correspond each subtask type with a specific aggregation algorithm.
[0068] Finally, the inference results of the subtasks are aggregated according to the aggregation strategy to obtain the inference result of the text to be processed.
[0069] In this embodiment, the aggregation strategy allows for more targeted fusion operations on the inference execution results. This embodiment provides aggregation strategies for classification types, structured types, and question-answering types respectively: For classification types: If the task type is a classification type, the weighted voting strategy will be determined as the aggregation strategy to perform weighted calculations on the inference execution results of subtasks, and the inference result will be determined based on the weighted calculation results.
[0070] In this embodiment, when multiple subtasks jointly serve a high-level classification objective (such as sentiment polarity judgment, risk level assessment, document category attribution, etc.), each subtask may output local classification results based on different semantic units or context fragments. Since the information relied upon by different subtasks has varying importance, and the confidence levels of their inference models differ, simple majority voting may lead to bias. Therefore, a weighted voting strategy is adopted for result aggregation. One implementation method is as follows: First, obtain the classification label output by each subtask and its corresponding confidence score, for example, the maximum probability value output by the softmax model, and use this confidence level as a weight; then, perform weighted summation by category. For example, if the three subtasks output "positive (weight 0.9)," "neutral (weight 0.6)," and "positive (weight 0.8)," the total score for the "positive" category is 0.9 + 0.8 = 1.7, which is higher than other categories; finally, select the category with the highest score as the overall inference result.
[0071] For structured types: If the task type is a structured type, the logical merging strategy is determined to be an aggregation strategy. The reasoning execution results of the subtasks are merged according to the priority of the subtasks' dependencies on preset events based on the reasoning execution results, and the reasoning result is determined based on the merging results.
[0072] In this embodiment, the structured subtasks aim to extract information elements with a fixed format from their input text, such as event triples (subject-behavior-object), table fields, time series data, etc. Multiple subtasks may identify different attributes or instances of the same event. To avoid information duplication, conflict, or omission, a logical merging strategy can be used for deduplication, completion, and sorting. As one implementation method: the logical merging strategy can be based on a preset knowledge template (such as an "emergency incident report template" containing fields such as time, location, people, cause, and impact), mapping the structured results output by each subtask to the corresponding fields, and merging them according to the following rules: Priority mechanism: When multiple subtasks provide different values for the same field (e.g., the time is "March 2024" and "early March" respectively), the priority is set according to the credibility of the source of the subtask (e.g., those from authoritative sentences are given priority), the accuracy level of the inference model or the explicitness of the context, and the high priority result is retained; Logical consistency check: Check whether the merged result meets the predefined logical constraints (such as the end time must not be earlier than the start time). If there is a conflict, a manual review prompt will be triggered or the default repair rule will be enabled. Missing field completion: For fields not covered by any subtask, mark them as empty or infer them from the context.
[0073] Based on the merging results, the inference results are determined, ultimately forming a complete, consistent, and business-compliant structured output (such as JSON, XML, or database records), which can be used for subsequent system integration or visualization. This logical merging strategy ensures the professionalism and usability of the extracted information, and is widely used in high-precision scenarios such as intelligence analysis, financial due diligence, and medical record structuring.
[0074] For question-and-answer types: If the task type is question-and-answer type, then neural network fusion is determined as the aggregation strategy, which uses a preset neural network model to fuse the inference execution results of the sub-tasks, and determines the inference result based on the fusion result.
[0075] In this embodiment, the original questions of question-and-answer type subtasks often involve multiple sub-questions, and each subtask generates answer fragments in natural language form. Directly splicing these fragments can lead to problems such as content repetition, disordered word order, and logical breaks. Therefore, a neural network fusion model can be introduced for semantic-level integration. The neural network fusion model can be a specially trained sequence-to-sequence (Seq2Seq) architecture (such as a model based on T5 or BART), whose input is a list of question-and-answer results from all subtasks (with optional weight labels), and whose output is a coherent, concise, and non-redundant comprehensive answer. The fusion process includes, but is not limited to, semantic deduplication, logical ordering, language polishing, and summary generation.
[0076] It should be noted that for cross-type tasks, a hierarchical aggregation mechanism can be introduced: first aggregate according to task type, then uniformly express the results of different types as natural language reports or visual suggestions, and finally output a complete, reliable, and comprehensive reasoning result oriented towards the original question.
[0077] In this embodiment, to facilitate understanding of the artificial intelligence reasoning method provided above, a reasoning task based on legal question answering is used as an example. For instance, the reasoning task is: "Determine the liability for breach of contract based on the contract text and provide a compensation suggestion." The artificial intelligence reasoning process for this reasoning task is as follows: (1) Input the text to be processed and the problem description The input text to be processed is a contract text, and the problem description is: "Determine the liability for breach of contract and provide compensation suggestions".
[0078] (2) Decomposing semantic units The contract text is divided into three semantic units: Contract Clause Unit: a unit describing the content of the contract (clause paragraphs), Reasoning Unit: a unit describing the reasoning objective (judging breach of contract and liability), and Compensation Request Unit: a unit describing the final task objective (compensation suggestion output).
[0079] (3) Keyword element extraction For the contract clause unit, the extracted results are: obligor, obligation content, and breach of contract conditions; for the reasoning unit, the extracted results are: breach of contract liability, responsible party, and other entities; for the compensation claim unit, the extracted results are: amount of loss and compensation standard.
[0080] (4) Intent recognition Based on the extracted elements and the segmented semantic units, the intents are identified as follows: Contract terms: clause parsing / extraction; Conditions for judging breach of contract: breach of contract identification / legal reasoning; Retrieving legal provisions: legal provision matching (knowledge retrieval); Generating compensation suggestions: generative reasoning.
[0081] (5) Dependency Construction Default identification requires input elements: payment obligation, delivery obligation, overdue conditions, and the party in default. If the output elements of the clause parsing contain the elements required for default identification, a dependency relationship is formed. Legal templates or small trained models can be used to determine the input and output elements of a semantic unit.
[0082] Based on the structured output of intent recognition, it is deduced that: judgment of breach of contract depends on clause parsing, legal matching depends on clause parsing (the parsed obligation text is used for knowledge retrieval), and compensation suggestions depend on breach of contract identification and legal matching, that is, the following dependency relationship: clause parsing → breach of contract identification, clause parsing → legal text matching, breach of contract identification → compensation suggestion, legal text matching → compensation suggestion.
[0083] (6) Subtask generation and execution graph construction The subtasks include: Clause Parsing Subtask (A), used to segment the contract text into clauses and extract information such as performance obligations and breach conditions; Breach of Contract Identification Subtask (B), used to determine whether there is a breach of contract in the contract and identify the party responsible for the breach; Legal Clause Matching Subtask (C), used to retrieve relevant laws and regulations from the knowledge base; and Compensation Recommendation Generation Subtask (D), which uses the results of A, B, and C to generate compensation recommendations based on compensation standards and historical cases.
[0084] The inputs and outputs of subtasks A, B, C, and D are as follows: A: Terms and Conditions Analysis Input: Full text of the contract Output: Structured data of the terms (list of obligations, list of conditions, elements of breach of contract, etc.) Downstream dependencies: B (default identification), C (legal provision matching) B: Breach of Contract Identification Input: Terms parsing result (from A); User input to determine liability for breach of contract. Output: Whether there was a breach of contract; the party responsible for the breach; a description of the breach. Downstream dependency: D (compensation suggestion generation) C: Matching legal provisions Input: Terms and conditions resolution results (from A) Output: Relevant legal provisions (administrative regulations, laws, and judicial interpretations); Matching relationship between the invoice and the contract. Downstream dependency: D (compensation suggestion generation) D: Compensation suggestion generation (generative model) Input: Breach of contract identification result (from B); Legal provision matching result (from C); User's requested "compensation suggestion" Output: A final, complete legal analysis report. The execution graph for construction is described above. Figure 2 Among them, B and C can be executed in parallel, and the dependencies are: A→B, A→C, B→D, C→D.
[0085] (7) Determine the reasoning model for each subtask based on the number of input tokens, whether external retrieval is required, and whether reasoning is required for each subtask.
[0086] For subtask A: clause parsing, since the input is a full-text contract, the scale is large and the complexity of text parsing and structure extraction is low. Therefore, a small text parsing model is adopted as the reasoning model, which can achieve fast reasoning while keeping costs under control, resulting in a high cost-performance ratio.
[0087] For subtask B: breach of contract identification, which is of medium scale, a large language model is used as the reasoning model because it requires reasoning.
[0088] For the C subtask: legal text matching, knowledge retrieval is required. Therefore, a retrieval model or a large language model combined with knowledge retrieval enhancement is used as the reasoning model.
[0089] For the D subtask: compensation suggestion, which belongs to the generative reasoning type, the complexity is high and the semantic understanding requirements are high. Therefore, a generative model is adopted as the reasoning model.
[0090] (8) The execution results of each subtask are integrated through the aggregation module to finally output a complete legal analysis report.
[0091] To provide a more intuitive understanding of the performance of the AI reasoning method provided in this embodiment and the traditional serial execution method, the following comparisons are made: Serial execution method: directly inputs the contract text and question into a large language model, allowing it to reason step-by-step and generate the final result; AI reasoning method provided in this embodiment (capable of parallel execution): employs task decomposition, subtask parallelism, and result aggregation mechanisms. Evaluation metrics include: Accuracy: the proportion of prediction results consistent with manually labeled results; Recall: the proportion of default situations successfully identified by the system; Inference Time: the average time taken for a single task from input to output; Token Cost: the average number of tokens required for a single inference attempt. Experimental results are compared in Table 1.
[0092] Table 1
[0093] Experiments show that the method provided in this embodiment significantly outperforms the serial execution scheme in both accuracy and recall, while reducing inference time by approximately 56% and average token consumption by approximately 38%. This demonstrates that through automated decomposition and parallel scheduling, the method provided in this embodiment can significantly improve execution efficiency and reduce computational costs while ensuring inference quality.
[0094] To perform the corresponding steps in the above embodiments and various possible implementations, an implementation of the artificial intelligence inference device 100 is given below. Please refer to... Figure 3 , Figure 3 This is a block diagram of the artificial intelligence inference device provided in this embodiment. It should be noted that the basic principle and technical effects of the artificial intelligence inference device 100 provided by the present invention are the same as those of the corresponding embodiments described above. For the sake of brevity, some parts of this embodiment are not mentioned.
[0095] The artificial intelligence reasoning device 100 includes an acquisition module 110, a division module 120, a determination module 130, an execution module 140, and an aggregation module 150.
[0096] The acquisition module 110 is used to acquire multiple semantic units obtained by semantically splitting the text to be processed.
[0097] The segmentation module 120 is used to divide all the semantic units into multiple subtasks according to the reasoning intent of each semantic unit.
[0098] The determination module 130 is used to determine the inference model of each subtask based on the estimated load level and complexity of each subtask.
[0099] The execution module 140 is used to execute the reasoning model of each of the sub-tasks and obtain the reasoning execution result of each of the sub-tasks.
[0100] The aggregation module 150 is used to aggregate the inference execution results of all the subtasks to obtain the inference result of the text to be processed.
[0101] In an optional implementation, the determining module 130 is further configured to: Obtain the input text length and inference type for each subtask; The number of tokens for each task is evaluated based on the length of the input text for each subtask. The resource consumption information of each subtask is evaluated based on the reasoning type of each subtask. Based on the number of tokens in each subtask and the resource usage information, determine the estimated load level of each subtask.
[0102] In an optional implementation, the determining module 130 is further configured to: Estimate the number of times the knowledge base is accessed and the length of the inference chain for each subtask; The complexity of each subtask is determined based on the number of times it is accessed and the length of the inference chain.
[0103] In an optional implementation, the execution module 140 is specifically used for: Based on the dependencies between all subtasks, an execution graph is generated, where each node in the execution graph corresponds to a subtask. Based on the in-degree of each node in the execution graph, the inference model of each subtask is executed to obtain the inference execution result of each subtask.
[0104] In an optional implementation, the execution module 140 is further configured to: Entity recognition is performed on the input text of each subtask to obtain the entities of each subtask; The entities of each subtask are organized according to a preset format to obtain at least one information element for each subtask. For any two subtasks, if there is a dependency between any information element in the first subtask and any information element in the second subtask, then it is determined that there is a dependency between the first and second subtasks.
[0105] In an optional implementation, the aggregation module 150 is specifically used for: Get the task type of the subtask; Determine the aggregation strategy based on the task type; The inference results of the subtasks are aggregated according to the aggregation strategy to obtain the inference result of the text to be processed.
[0106] In an optional implementation, the aggregation module 150 is specifically used to determine the aggregation strategy based on the task type, specifically for: If the task type is a classification type, the weighted voting strategy will be determined as the aggregation strategy, so as to perform weighted calculation on the reasoning execution results of the subtasks, and determine the reasoning result based on the weighted calculation result; If the task type is a structured type, the logical merging strategy is determined to be an aggregation strategy, which merges the inference execution results of subtasks according to the priority of the predefined event dependencies based on the inference execution results of the subtasks, and determines the inference result based on the merging result. If the task type is question-and-answer type, then neural network fusion is determined as the aggregation strategy, which uses a preset neural network model to fuse the inference execution results of the sub-tasks, and determines the inference result based on the fusion result.
[0107] This invention also provides a block diagram of an electronic device 10, which implements the artificial intelligence reasoning method of the aforementioned embodiments. Please refer to... Figure 4 , Figure 4 This is a block diagram of the electronic device 10 provided in this embodiment. The electronic device 10 includes a processor 11, a memory 12 and a bus 13. The processor 11 and the memory 12 are connected through the bus 13.
[0108] The processor 11 can be an integrated circuit chip with signal processing capabilities. In implementation, each step of the artificial intelligence reasoning method in the above embodiments can be completed by the integrated logic circuits in the hardware of the processor 11 or by software instructions. The processor 11 can be a general-purpose processor, including a CPU (Central Processing Unit), an NP (Network Processor), etc.; it can also be a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Logic Gate Array), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0109] The memory 12 is used to store programs that implement artificial intelligence reasoning methods. These programs can be software functional modules stored in the memory 12 in the form of software or firmware, or embedded in the OS (Operating System) of the electronic device 10.
[0110] After receiving the execution instruction, the processor 11 executes the program to implement the artificial intelligence reasoning method of the aforementioned embodiment.
[0111] This embodiment provides a computer storage medium on which a computer program is stored. When the computer program is executed by a processor, it implements the artificial intelligence reasoning method as described in the foregoing embodiments.
[0112] In summary, this invention provides an artificial intelligence reasoning method, apparatus, electronic device, and computer storage medium. The method includes: acquiring multiple semantic units obtained by semantically decomposing the text to be processed; dividing all semantic units into multiple subtasks according to the reasoning intent of each semantic unit; determining the reasoning model of each subtask according to the estimated load level and complexity of each subtask; executing the reasoning model of each subtask to obtain the reasoning execution result of each subtask; and aggregating the reasoning execution results of all subtasks to obtain the reasoning result of the text to be processed. Compared with the prior art, this embodiment has at least the following advantages: (1) In terms of computational cost, since the overall task is divided into smaller subtasks for parallel processing, redundant token consumption caused by long text input is effectively avoided, thereby significantly reducing the operating cost; (2) In terms of reasoning efficiency, through the parallel execution of multiple subtasks, the total execution time complexity of the entire task is reduced from the traditional Transform into , thereby significantly reducing the overall time consumption, where j is the jth subtask; (3) In terms of result quality, by shortening a single reasoning link and combining confidence weighting and context matching and other aggregation mechanisms, the forgetting problem common in long-link reasoning is effectively avoided, ensuring the complete preservation of key context information and the coherence of logical reasoning, making the final output result more accurate and reliable; (4) In terms of applicability and scalability, it is not only applicable to tasks such as legal question answering and text analysis, but can also be extended to various application scenarios such as code generation, logical reasoning, and scientific research auxiliary computing, demonstrating strong universality and scalability.
[0113] The above descriptions are merely various embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. An artificial intelligence reasoning method, characterized in that, The method includes: Obtain multiple semantic units obtained by semantically segmenting the text to be processed; Based on the reasoning intent of each semantic unit, all semantic units are divided into multiple sub-tasks; Based on the estimated load level and complexity of each subtask, determine the inference model for each subtask. Execute the inference model for each subtask to obtain the inference execution result for each subtask; The inference results of all the subtasks are aggregated to obtain the inference result of the text to be processed.
2. The method according to claim 1, characterized in that, Before the step of determining the inference model for each sub-task based on its estimated load level and complexity, the following steps are included: Obtain the input text length and inference type for each subtask; The number of tokens for each subtask is evaluated based on the length of the input text for each subtask. The resource consumption information of each subtask is evaluated based on the reasoning type of each subtask; Based on the number of tokens in each subtask and the resource usage information, the estimated load level of each subtask is determined.
3. The method according to claim 1, characterized in that, Before the step of determining the inference model for each sub-task based on its estimated load level and complexity, the following steps are included: Estimate the number of times the knowledge base is accessed and the length of the inference chain for each subtask; The complexity of each subtask is determined based on the number of times each subtask is accessed and the length of the inference chain.
4. The method according to claim 1, characterized in that, The step of executing the inference model for each subtask and obtaining the inference execution result for each subtask includes: An execution graph is generated based on the dependencies between all the subtasks, where each node in the execution graph corresponds to a subtask. Based on the in-degree of each node in the execution graph, the inference model of each subtask is executed to obtain the inference execution result of each subtask.
5. The method according to claim 4, characterized in that, The step of generating an execution graph based on the dependencies between all the subtasks, where each node in the execution graph corresponds to a step of a subtask, includes: Entity recognition is performed on the input text of each subtask to obtain the entity of each subtask; The entities of each subtask are organized according to a preset format to obtain at least one information element of each subtask. For any two subtasks, if there is a dependency between any information element in the first subtask and any information element in the second subtask, then it is determined that there is a dependency between the first subtask and the second subtask.
6. The method according to claim 1, characterized in that, The step of aggregating the inference results of all the subtasks to obtain the inference result of the text to be processed includes: Obtain the task type of the subtask; Determine the aggregation strategy based on the task type; The inference results of the subtasks are aggregated according to the aggregation strategy to obtain the inference result of the text to be processed.
7. The method according to claim 6, characterized in that, The step of determining the aggregation strategy based on the task type includes: If the task type is a classification type, then the weighted voting strategy is determined as the aggregation strategy to perform weighted calculation on the reasoning execution results of the subtasks, and the reasoning result is determined based on the weighted calculation results; If the task type is a structured type, the logical merging strategy is determined as the aggregation strategy, so as to merge the inference execution results of the subtasks according to the priority of the subtasks' inference execution results to the preset event dependencies, and determine the inference result based on the merging result; If the task type is a question-and-answer type, then neural network fusion is determined as the aggregation strategy, so as to use a preset neural network model to fuse the inference execution results of the sub-task, and determine the inference result based on the fusion result.
8. An artificial intelligence reasoning device, characterized in that, The device includes: The acquisition module is used to acquire multiple semantic units obtained by semantically splitting the text to be processed. The segmentation module is used to divide all the semantic units into multiple subtasks according to the reasoning intent of each semantic unit; The determination module is used to determine the inference model for each subtask based on the estimated load level and complexity of each subtask. The execution module is used to execute the reasoning model of each subtask and obtain the reasoning execution result of each subtask. The aggregation module is used to aggregate the inference execution results of all the subtasks to obtain the inference result of the text to be processed.
9. An electronic device, characterized in that, It includes a processor and a memory, the memory being used to store a program, and the processor being used to implement the artificial intelligence reasoning method as described in any one of claims 1-7 when executing the program.
10. A computer storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the artificial intelligence reasoning method as described in any one of claims 1-7.