A large-scale knowledge graph reasoning optimization method

By constructing a multi-layered storage structure and a dynamic caching mechanism, and combining a lightweight neural network to dynamically schedule tasks between GPUs and CPUs, the problem of low computational efficiency in large-scale knowledge graph reasoning is solved, achieving efficient data access and resource utilization.

CN122154757APending Publication Date: 2026-06-05HUAZHONG UNIV OF SCI & TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUAZHONG UNIV OF SCI & TECH
Filing Date
2026-05-09
Publication Date
2026-06-05

Smart Images

  • Figure CN122154757A_ABST
    Figure CN122154757A_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of electric digital data processing, and particularly relates to a large-scale knowledge graph reasoning optimization method, which firstly constructs a multi-layer storage structure and a multi-level cache mechanism to optimize data access, then designs a lightweight neural network group for parallel processing, realizes efficient use of heterogeneous computing resources through an intelligent task allocation mechanism, improves reasoning efficiency through path grouping and priority allocation, and finally guarantees reasoning accuracy through parameter self-adaptive optimization and a multiple verification mechanism. The application migrates the knowledge of a large pre-training model to a lightweight network through a knowledge distillation technology, realizes lightweight of the model without loss of reasoning performance. The method forms a complete optimization system, realizes collaborative optimization of storage access, computing processing and resource allocation, and effectively solves the technical problem of low computing efficiency in the large-scale knowledge graph reasoning process in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of electronic digital data processing, and more specifically, relates to a large-scale knowledge graph reasoning optimization method. Background Technology

[0002] Knowledge graphs, as a structured representation of knowledge, have been widely applied in various fields such as intelligent search, question answering systems, and recommendation systems, especially in e-commerce recommendations. In practical applications, as the scale of knowledge graphs continues to expand, efficient reasoning within them has become a significant technical challenge. Traditional knowledge graph reasoning methods mainly include rule-based reasoning, path-based reasoning, and embedding-based reasoning. Rule-based reasoning methods use predefined logical rules for reasoning, offering strong interpretability, but the maintenance and updating costs of these rules are high. Path-based reasoning methods search for connection paths between entities, discovering potential relationships, but their search efficiency is low in large-scale knowledge graphs. Embedding-based reasoning methods map entities and relationships to a low-dimensional vector space, performing reasoning through vector operations, and possess good scalability.

[0003] However, existing knowledge graph reasoning methods suffer from several problems when handling large-scale knowledge graphs. First, the storage structure of knowledge graphs often adopts a uniform approach, failing to optimize for the characteristics of entity relationships, resulting in low data access efficiency. Second, caching strategies lack in-depth analysis of access patterns and fail to effectively utilize the characteristics of multi-level storage systems. Third, task allocation during the reasoning computation process is not flexible enough, failing to fully leverage the advantages of heterogeneous computing resources. Furthermore, existing methods often employ heavyweight deep learning models when handling complex reasoning tasks, leading to a waste of computational resources.

[0004] Improving computational efficiency and resource utilization is a pressing issue in large-scale knowledge graph reasoning. The core problem that existing technologies struggle to address lies in the lack of a systematic solution that comprehensively considers storage optimization, computational resource allocation, and model lightweighting, leading to low computational efficiency during reasoning. Summary of the Invention

[0005] In view of the above-mentioned defects or improvement needs of the existing technology, the present invention provides a large-scale knowledge graph reasoning optimization method, which aims to solve the technical problem of low computational efficiency in the process of large-scale knowledge graph reasoning in the existing technology.

[0006] To achieve the above objectives, according to one aspect of the present invention, a method for optimizing large-scale knowledge graph reasoning is provided, comprising: Offline Phase: Construct a multi-layered storage structure for the knowledge graph, storing the knowledge graph in layers according to entity relationship types. Calculate the connection density value for each layer, which is represented by the ratio of the number of entity relationships actually stored in that layer to the total number of entity relationships in the knowledge graph. Determine the cache priority score for each entity based on its access frequency and the connection density value of its storage structure. Divide all entity caches into memory cache, SSD cache, and HDD storage according to their scores from highest to lowest. Construct N lightweight neural network units, and deploy them to GPUs and CPUs in groups based on the GPU-CPU computing power ratio. Online Inference Phase: Inference requests from the knowledge graph are obtained, and target entity nodes are extracted. An initial state score for the target entity node is calculated based on its degree, connection type distribution, and historical access frequency within the knowledge graph. Horizontal relation density (representing the degree of connection within its own storage layer) and vertical relation density (representing the degree of connection across layers) are calculated to determine the relation distribution state of the target entity node. When the relation distribution state meets the inference threshold requirement, multi-path parallel search is performed to obtain multiple inference paths. Otherwise, the relationships of the target entity node are expanded until the inference threshold requirement is met. The searched inference paths are grouped to obtain multiple path groups. These path groups are allocated to GPUs or CPUs according to the computing power ratio or the ratio of the initial state score to the computing power ratio. The credibility of each inference path group is calculated, and the allocation priority among all inference path groups whose credibility meets the preset requirements is determined. The allocation priority is then sequentially input into the neural network units of the GPU or CPU. For each of the N neural network units, an original convolutional kernel parameter set is constructed, each containing parameters for multiple convolutional kernels at different scales. Within each neural network unit, an equivalent convolutional kernel set is obtained based on the corresponding original convolutional kernel parameter set. The parameters of each equivalent convolutional kernel in the equivalent convolutional kernel set are calculated based on the ratio of the original convolutional kernel parameters to the baseline convolutional kernel parameters. In the GPU, multiple deployed neural network units utilize the equivalent convolutional kernel sets to perform feature extraction operations in parallel, obtaining an inference path feature vector set corresponding to each input inference path set. Adaptive parameter optimization is performed in the CPU. When any equivalent convolutional kernel parameter in any neural network unit exceeds a parameter threshold, the parameter adjustment mechanism of that neural network unit is triggered to adjust the parameters. The confidence score of each inference path within each inference path set is calculated based on the path feature vector set. The inference paths within the inference path set are sorted based on the confidence scores, and the N inference paths with the highest confidence scores are selected as candidate main paths. The CPU is used to perform logical verification and supplementary inference on the candidate main paths to generate a complete inference result. By comparing the candidate main paths with the verified inference results, the knowledge graph multi-level caching model and the network parameters are updated, and the task allocation strategy for N neural network units is optimized and adjusted.

[0007] Furthermore, the connection density value of each storage layer is expressed as:

[0008] In the formula, For the first The connection density value of the layered storage structure; For the first The actual number of entity relationships contained in the knowledge graph stored in the layer; This represents the total number of entity relations in the knowledge graph. For the first The number of entity relationships stored in the layer whose access frequency exceeds a preset threshold; This is a balancing factor, with a value ranging from 0.2 to 0.4. In the offline phase, the method also includes: when the connection density value is greater than the corresponding preset threshold, the information of the storage structure of this layer is stored using an adjacency matrix; otherwise, it is stored using an adjacency list.

[0009] Furthermore, the cache priority score for each entity is calculated as follows:

[0010] In the formula, Score the cache priority. This represents the cumulative number of visits to a single entity within a unit of time. The preset time window length; This represents the connection density value of the storage structure of the layer where the entity resides; Weighted by access frequency; This is the time decay coefficient; The decay rate; This represents the time interval since the last access to this entity.

[0011] Furthermore, the N associated parallel neural network units are deployed to a GPU or CPU as follows: A dynamic scheduling strategy is adopted, based on the real-time computing power ratio. Dynamic adjustments are made, including the real-time computing power ratio. In the formula, , , These represent the number of GPU computing cores, clock frequency, and single-operation efficiency coefficient, respectively. , , These represent the number of CPU cores, the number of threads, and the efficiency coefficient for a single operation, respectively. when When the value is greater than 10, GPU acceleration can be triggered when the parallelism of the neural network unit is greater than or equal to 2 or the batch processing is greater than or equal to 16; when When the value is greater than 1 and less than or equal to 10, tasks with a parallelism greater than or equal to 4 or a batch size greater than or equal to 32 are assigned to the GPU; when... When the value is less than or equal to 1, tasks with a parallelism of 8 or greater or greater than 8 or a batch size of 64 or greater are assigned to the CPU; once a task is detected to contain branching logic or irregular control flow, the task is assigned to the CPU. Initial state score of the target entity node The calculation method is as follows:

[0012] In the formula, and These represent the in-degree and out-degree of the target entity node, respectively. This represents the maximum degree in the knowledge graph; Represents the first in a knowledge graph The proportion of class relationships; This represents the total number of relation types in the knowledge graph; Indicates the access frequency of the target entity node; This represents the average access frequency of all nodes in the knowledge graph. , , These represent the weight coefficients of each feature, with values ​​ranging from 0 to 1 and a total of 1.

[0013] Furthermore, the calculation method for the lateral relationship density of the target entity node is as follows:

[0014] In the formula, This refers to the density of horizontal relationships. This represents the number of first-order neighbors of the target entity node in its own storage layer. The total number of nodes in the storage layer containing the target entity node; This refers to the number of strongly connected neighbors whose edge weights exceed a threshold corresponding to the target entity node. These are the strong connection weight coefficients; The calculation method for vertical relationship density is as follows:

[0015] In the formula, This refers to the density of vertical relationships; This represents the total number of nodes directly and indirectly connected across layers. The maximum possible number of cross-layer connections; This represents the number of direct cross-layer connections. For direct connection weight coefficients; The relationship distribution state is a weighted sum of the horizontal relationship density and the vertical relationship density.

[0016] Furthermore, the formula for calculating the equivalent convolution kernel parameters is as follows:

[0017] In the formula, Represents the original convolution kernel parameters. , These represent the size of the original convolution kernel and the size of the reference convolution kernel, respectively. This represents the preset error adjustment coefficient. This indicates the preset maximum permissible error. Indicates historical training error. This is the error correction term.

[0018] Furthermore, the credibility of each inference path group The calculation method is as follows:

[0019] In the formula, Indicates the first path in this path group The weight of each path, where n represents the total number of paths in the path group; Indicates the first path in this path group The length of the longest common subsequence of the paths; Indicates the first path in this path group The total length of the path; Indicates the first path in this path group The first path The strength value of the relationship; Indicates the first path in this path group The number of relationships in the path; The allocation method for reasoning path groups is as follows: Calculate the queue priority for each inference path group, denoted as: ;in, The logical complexity score (i.e., time complexity, determined based on the reasoning request) represents a single group of reasoning paths. Indicates the estimated execution time of a single inference path group; Indicates the memory requirements of a single inference path group; Indicates the amount of known available memory; This represents the memory weighting coefficient; Assign priority based on queue priority score.

[0020] Furthermore, the confidence score for each inference path. The calculation method is as follows:

[0021] In the formula, This indicates the first step of the reasoning path. Features Attention weights This represents the preset path length penalty coefficient. This indicates the length of the reasoning path. Indicates the preset relation strength weight. This indicates a preset threshold for relationship strength. The method for ranking the inference paths within the inference path group based on the confidence scores is as follows: An improved heap sort algorithm is used to achieve efficient sorting. The adjustment function of the heap is defined as:

[0022] in, This represents the group of reasoning paths to be sorted; Indicates the index of the current node; This represents the index of the node with the highest confidence score among its left and right child nodes; Finally, the one with the highest confidence score was selected. Several reasoning paths are selected as candidate main paths, among which... The value ranges from 3 to 5, and the specific value is determined by the following formula: ,in and These represent the maximum and minimum confidence scores, respectively. Indicates the threshold for score difference; For paths with similar confidence scores, a diversity assessment function is introduced. Perform diverse pruning: and This represents a set of nodes for two paths. When extracting paths sequentially from the top of the heap, if the current path matches the set of already selected paths... Div If the value is lower than the preset threshold, the path is skipped and the next path is extracted until N inference paths that meet the high score requirements and have sufficient differences are selected. If the number of inference paths after screening is less than N, the preset threshold is lowered until N paths are selected or all candidates are traversed, so as to achieve a balance between diversity and coverage.

[0023] Furthermore, the method of logical verification is as follows: Perform a consistency check on each candidate main path: the check function is defined as follows: ,in Indicates the main path to be verified; Indicates the first Rule functions; This represents the total number of rules; constraint verification uses predicate logic expressions: ,in, Relative predicates; Indicates a binding predicate, Represent two entities; determine the main path that meets the consistency requirements; For each main path that meets the consistency requirements Expand to obtain the expansion path The method is as follows: ,in Indicates the minimum confidence threshold; This represents the minimum support threshold; and These represent the confidence calculation function and the support calculation function, respectively; the extended path As the final result of the reasoning.

[0024] According to another aspect of the invention, a computer-readable storage medium is provided, the computer-readable storage medium including a stored computer program, wherein, when the computer program is run by a processor, it controls the device where the storage medium is located to perform the steps of the method described above.

[0025] In summary, compared with the prior art, the technical solutions conceived by this invention have the following main advantages: 1. This invention proposes a large-scale knowledge graph inference optimization method. By constructing a multi-layered storage structure and dynamic caching mechanism in the offline stage, combined with a connection density-adaptive storage strategy and a hierarchical cache priority model, it achieves efficient organization and fast access to knowledge graph data, significantly reducing data retrieval latency. Through the design of lightweight neural network groups and intelligent task allocation, computationally intensive parallel tasks and logically complex serial tasks are scheduled to GPUs and CPUs respectively, fully leveraging the synergistic advantages of heterogeneous computing resources and solving the problem of low resource utilization caused by traditional single computing modes. In the online inference stage, a dynamic decision-making mechanism based on the ratio of initial state scores of entity nodes to computing power is introduced to achieve intelligent allocation of inference path groups. Combined with parallel feature extraction based on equivalent convolutional kernel groups and adaptive parameter optimization on the CPU side, it ensures both the efficiency of high-concurrency path computation and the accuracy of inference results through logical verification and parameter adjustment. Furthermore, through a closed-loop feedback mechanism to continuously update the caching model and task allocation strategy, the system can dynamically adapt to the evolution of the knowledge graph and load changes, achieving dual optimization of inference efficiency and resource utilization. The overall technical solution has significant advantages in systematicity, adaptability, and dynamic evolution capabilities. Attached Figure Description

[0026] Figure 1 This is a flowchart of a large-scale knowledge graph reasoning optimization method provided in an embodiment of the present invention.

[0027] Figure 2 A connection density analysis diagram of each layer of the e-commerce knowledge graph storage structure provided in an embodiment of the present invention.

[0028] Figure 3 This is a diagram showing the distribution of cache priority scores provided in an embodiment of the present invention.

[0029] Figure 4 The graph shows a comparison of parameters and computational performance analysis of convolution kernels of different sizes provided in the embodiments of the present invention.

[0030] Figure 5 A multi-dimensional analysis diagram of the reasoning path provided in the embodiments of the present invention. Detailed Implementation

[0031] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.

[0032] Example 1 A large-scale knowledge graph reasoning optimization method, such as Figure 1 As shown, it includes: Offline Phase: Construct a multi-layered storage structure for the knowledge graph, storing the knowledge graph in layers according to entity relationship types. Calculate the connection density value for each layer, which is represented by the ratio of the number of entity relationships actually stored in that layer to the total number of entity relationships in the knowledge graph. Determine the cache priority score for each entity based on its access frequency and the connection density value of its storage structure. Divide all entity caches into memory cache, SSD cache, and HDD storage according to their scores from highest to lowest. Construct N lightweight neural network units, and deploy them to GPUs and CPUs in groups based on the GPU-CPU computing power ratio. Online Inference Phase: Inference requests from the knowledge graph are obtained, and target entity nodes are extracted. An initial state score for the target entity node is calculated based on its degree, connection type distribution, and historical access frequency within the knowledge graph. Horizontal relation density (representing the degree of connection within its own storage layer) and vertical relation density (representing the degree of connection across layers) are calculated to determine the relation distribution state of the target entity node. When the relation distribution state meets the inference threshold requirement, multi-path parallel search is performed to obtain multiple inference paths. Otherwise, the relationships of the target entity node are expanded until the inference threshold requirement is met. The searched inference paths are grouped to obtain multiple path groups. These path groups are allocated to GPUs or CPUs according to the computing power ratio or the ratio of the initial state score to the computing power ratio. The credibility of each inference path group is calculated, and the allocation priority among all inference path groups whose credibility meets the preset requirements is determined. The allocation priority is then sequentially input into the neural network units of the GPU or CPU. For each of the N neural network units, an original convolutional kernel parameter set is constructed, each containing parameters for multiple convolutional kernels at different scales. Within each neural network unit, an equivalent convolutional kernel set is obtained based on the corresponding original convolutional kernel parameter set. The parameters of each equivalent convolutional kernel in the equivalent convolutional kernel set are calculated based on the ratio of the original convolutional kernel parameters to the baseline convolutional kernel parameters. In the GPU, multiple deployed neural network units utilize the equivalent convolutional kernel sets to perform feature extraction operations in parallel, obtaining an inference path feature vector set corresponding to each input inference path set. Adaptive parameter optimization is performed in the CPU. When any equivalent convolutional kernel parameter in any neural network unit exceeds a parameter threshold, the parameter adjustment mechanism of that neural network unit is triggered to adjust the parameters. The confidence score of each inference path within each inference path set is calculated based on the path feature vector set. The inference paths within the inference path set are sorted based on the confidence scores, and the N inference paths with the highest confidence scores are selected as candidate main paths. The CPU is used to perform logical verification and supplementary inference on the candidate main paths to generate a complete inference result. By comparing the candidate main paths with the verified inference results, the knowledge graph multi-level caching model and the network parameters are updated, and the task allocation strategy for N neural network units is optimized and adjusted.

[0033] The method in this embodiment can be divided into the following steps: constructing a multi-layer storage structure for the knowledge graph, storing the knowledge graph in layers according to entity relationship types, and calculating the connection density value of entity relationships in each layer of the multi-layer storage structure; constructing a multi-level cache priority function for the knowledge graph, and performing hierarchical caching of frequently accessed entities and entity relationships in the knowledge graph; constructing a lightweight neural network group, which contains N interconnected parallel neural network units; allocating the N interconnected parallel neural network units to the GPU and CPU according to the computing power of the computing device; obtaining knowledge graph reasoning requests, calculating the initial state score, horizontal relationship density, vertical relationship density, and relationship distribution state of the target entity node; allocating reasoning path groups to the N interconnected parallel neural network units, executing high-concurrency path calculation tasks based on the GPU, and executing complex logic reasoning tasks based on the CPU.

[0034] Regarding the multi-layered storage structure, it is used to optimize the storage and access efficiency of knowledge graphs. In specific implementation, the entity relationships in the knowledge graph are first classified according to type, including attribute relationships, inheritance relationships, association relationships, etc. Then, an independent storage layer is allocated for each relationship type. For each storage layer, its connection density value is calculated. In a preferred implementation, when the connection density value is greater than the corresponding preset threshold (e.g., 0.7), the information of that storage layer is stored using an adjacency matrix; otherwise, an adjacency list is used to balance storage space and access efficiency.

[0035] As a further preferred implementation, the connection density value of each storage layer is expressed as:

[0036] In the formula, For the first The connection density value of the layered storage structure; For the first The actual number of entity relationships contained in the knowledge graph stored in the layer; This represents the total number of entity relations in the knowledge graph. For the first The number of entity relationships stored in the layer whose access frequency exceeds a preset threshold; It is a balancing factor, with a value ranging from 0.2 to 0.4.

[0037] The connection density value is calculated using a weighted combination of actual relationship density and the proportion of frequently accessed relationships, reflecting a balance between structural features and dynamic access features. The parameter acquisition method is as follows: Obtained by counting the non-zero elements in the adjacency matrix or adjacency list; Calculated using the cardinality of the entity set; This was obtained by statistically analyzing the number of visits exceeding 10 per unit time (when accessing a node, the unit time is usually defined as 24 hours).

[0038] The derivation of the equation for calculating the connectivity density value: First, consider the definition of basic connectivity density, which is the ratio of the actual number of relations to the maximum possible number of relations. This is the commonly used definition of density in graph theory; then, the influence term of visit frequency is introduced. This represents the proportion of frequently accessed relationships in the total number of relationships, reflecting dynamic access characteristics; weighted by coefficients. Combining the two factors forms the final formula for calculating connectivity density. ;in The value range of 0.2 to 0.4 was obtained through experimental optimization. Within this range, the static structural features and dynamic access features can be well balanced.

[0039] Regarding multi-level caching: In implementation, a multi-level cache priority function is constructed. This function calculates a cache priority score based on entity access frequency and connection density. For each entity in the knowledge graph, the number of times the entity is accessed within a certain time window is first counted. The time window can be set to 24 hours. The access frequency is obtained by dividing the number of accesses by the time window length. Then, the access frequency is weighted and summed with the connection density value of the layer where the entity belongs. The weight ratio can be set to 7:3 (not limited, based on experience) to obtain the entity's cache priority score. Entities are divided into three cache levels according to their scores. The first level cache stores entities with a priority score greater than, for example, 0.8, using memory caching. The second level cache stores entities with a priority score between, for example, 0.5 and 0.8, using solid-state drive caching. The third level cache stores entities with a priority score less than, for example, 0.5, using ordinary hard drive storage.

[0040] As a preferred implementation method, the cache priority score for each entity can be calculated as follows:

[0041] In the formula, Score the cache priority. This represents the cumulative number of visits to a single entity within a unit of time. Set the preset time window length, for example, to a fixed 24 hours; This represents the connection density value of the storage structure of the layer where the entity resides; This is a weight for access frequency, for example, a value of 0.7; This is the time decay coefficient, for example, a value of 0.2; This represents the decay rate, for example, a value of 0.1; This represents the time interval since the last visit to this entity. The second term in the above formula is considered a residual term, also known as an exponentially decaying term.

[0042] The cache priority function introduces an exponential decay term to reflect the temporal locality of data access. The parameter is obtained as follows: Obtained by accumulating the access counter; It is calculated by subtracting the last access timestamp from the current time.

[0043] Derivation of the cache priority function: a basic calculation formula based on access frequency. Considering the need to incorporate structural features, a connection density value is introduced. Both are weighted Combination; to reflect the principle of temporal locality, a time decay term is added. The final formula is formed. ;in This indicates that the access frequency feature has a larger weight. and The value of was determined through cache hit rate optimization experiments.

[0044] Regarding the construction of lightweight neural networks: In specific implementation, a parallel processing unit consisting of N lightweight neural networks is constructed, where N ranges from 4 to 16. Each neural network unit adopts a compressed network structure: containing no more than 3 convolutional layers and 2 fully connected layers. Each convolutional layer uses depthwise separable convolution (not standard convolution), and each fully connected layer uses a linear activation function instead of a complex activation function. The number of parameters in each neural network unit is controlled to within 1 million. Knowledge distillation technology is used to transfer knowledge from large pre-trained models to these lightweight networks, ensuring inference performance while reducing computational complexity.

[0045] In a preferred embodiment, N ranges from 4 to 16, and each neural network unit employs a compressed network structure: containing no more than 3 convolutional layers and 2 fully connected layers. Each convolutional layer uses depthwise separable convolution, as shown below: ,in Indicates the input feature map; Indicates the depthwise convolution kernel; Represents the pointwise convolution kernel; Indicates a depthwise convolution operation; This represents a pointwise convolution operation. To further reduce computational complexity, each fully connected layer uses a linear activation function. Instead of traditional nonlinear activation functions, where To use learnable slope parameters, the number of parameters in each neural network unit is controlled to within 1 million. Knowledge distillation techniques are used to transfer knowledge from large pre-trained models to these lightweight networks. The distillation loss function is defined as: ,in and These represent the output characteristics of the teacher network and the student network, respectively. This represents the temperature coefficient, with a value of 3. This represents the relative entropy between characteristic distributions.

[0046] Regarding the transfer of knowledge from a large pre-trained model to a lightweight network, in one specific embodiment of this invention, the large pre-trained model is based on the Transformer architecture, consisting of stacked multi-layer encoders and decoders. The encoder has 12 layers, each containing a multi-head self-attention mechanism, a feedforward neural network, and a residual connection structure, with a hidden layer dimension of 768 and 12 attention heads. The decoder also uses a 12-layer structure, with the same basic components as the encoder, and additionally includes a cross-attention layer to process the encoder's output information. The total number of model parameters is approximately 340 million, of which attention layer parameters account for approximately 40%, feedforward neural network parameters account for approximately 55%, and the remainder are parameters for components such as position encoding and layer normalization.

[0047] The training dataset primarily originates from three parts: first, entity relation triples extracted from public knowledge graphs, including knowledge from multiple vertical domains such as product, film and television, and technology, totaling approximately 1 billion records; second, structured and semi-structured data crawled from search engines and encyclopedia websites, which, after cleaning and normalization, yielded approximately 500 million entity relation records; and third, high-quality knowledge obtained from professional domain databases, including professional knowledge bases in fields such as medicine, finance, and law, totaling approximately 200 million records. These data underwent standardized format conversion and quality control to form a standard training dataset.

[0048] The pre-training process consists of three stages: The first stage is the entity prediction task with masking. Entities in the input sequence are randomly masked, and the model is trained to predict these masked entities. A dynamic masking strategy is used, with a masking ratio of 15%, where 80% are replaced with special labels, 10% remain unchanged, and 10% are randomly replaced with other entities. The training process uses the Adam optimizer, employing a linear warm-up and cosine decay strategy for the learning rate. The initial learning rate is set to 0.0001, with 10,000 warm-up steps, a total of 1 million training steps, and a batch size of 4096. The second stage is the relation prediction task. Given head and tail entities, the model is trained to predict the type of relationship between them. Negative sampling is used to construct training samples, randomly sampling 5 negative samples for each positive sample. This contrastive learning improves the model's understanding of relationships. The training process uses the AdamW optimizer with weight decay, with a weight decay coefficient set to 0.01. A layered learning rate strategy is adopted, with a learning rate ratio of 1:0.8 between the attention layer and the feedforward layer. The total training steps are 500,000. The third stage is the path reasoning task, which trains the model to understand and reason about multi-hop relationship paths. Reasoning paths of varying lengths (ranging from 2 to 6) are constructed as training samples. Attention and gating mechanisms are used to enhance the model's path reasoning ability. Gradient accumulation is employed during training, with parameters updated every 4 steps. FP16 mixed-precision training is used to improve training efficiency, with a total of 300,000 training steps.

[0049] During training, several techniques were employed to ensure stability and effectiveness: first, gradient clipping was used to prevent gradient explosion, with a clipping threshold of 1.0; second, layer normalization and residual connections were used to improve gradient propagation; third, label smoothing was used to reduce overfitting, with a smoothing coefficient of 0.1; and fourth, EMA was used to update model parameters, with a decay rate of 0.9999. Training was conducted in a distributed manner on eight servers equipped with eight V100 GPUs, employing a data parallel strategy and mixed precision training, with a single-step training time controlled within 0.8 seconds. After pre-training, the model was compressed and transferred to a lightweight neural network using knowledge distillation. The distillation process adopted a progressive strategy, first training a medium-sized teacher model with approximately one-third the number of parameters of the original model, and then transferring the knowledge to the final lightweight model. The distillation loss function comprehensively considered three aspects: soft-label cross-entropy, feature map distance, and attention map similarity, simultaneously optimizing these objectives through multi-task learning. The learning rate for the distillation process employs a loop strategy, with each loop containing 20,000 steps, for a total of 5 loops, ultimately resulting in a lightweight model with only 1 / 10 the number of parameters of the original model.

[0050] To validate the effectiveness of the pre-trained model, it was evaluated on test datasets of different sizes and domains. Evaluation metrics included entity prediction accuracy, relationship classification F1 score, path reasoning recall, and other dimensions. Ablation studies analyzed the contributions of different pre-training tasks, revealing that a multi-stage pre-training strategy significantly improves the model's overall capabilities compared to single-task pre-training. Furthermore, visualization analysis of the model's attention weights and feature representations verified that the model indeed learned meaningful knowledge representations and reasoning patterns.

[0051] Regarding the allocation and deployment of computing devices: In specific implementation, a task allocation function is constructed based on the computing power characteristics of the devices. First, parameters such as the number of GPU cores, clock frequency, and memory size are obtained (directly retrieved). Parameters such as the number of CPU cores, number of threads, and cache size are also obtained. The theoretical computing power ratio of the GPU and CPU is calculated, which is usually between 3 and 8. Then, the allocation strategy for neural network units is determined based on this ratio.

[0052] The ratio of theoretical computing power of computing devices Calculated using the following formula: ,in and These represent the single-operation efficiency coefficients (characterizing floating-point arithmetic capabilities) of the GPU and CPU, respectively. They are primarily obtained by looking up tables based on the microarchitecture features provided by the hardware manufacturers, and can be fine-tuned using runtime test data. Based on the calculated capability ratios, the deployment strategy for neural network units is determined.

[0053] Regarding the initial state score: In the specific implementation, target entity and / or relation information is parsed from the inference request (a missing triple), and a node state evaluation function is constructed. This function considers features such as the degree of the target entity node, the distribution of connection relationship types, and historical access frequency (these features are extracted from a multi-layered storage structure). For the degree feature, the sum of the in-degree and out-degree of the target entity node is calculated. For the relation type distribution feature, the proportion of different types of relations connected to the node is calculated. For the historical access frequency feature, the number of times the node has been accessed in the recent period (within a preset time window) is counted. After normalizing these features, a weighted average is used to obtain the initial state score of the node.

[0054] As a preferred implementation method, the initial state score of the target entity node The calculation method is as follows:

[0055] In the formula, and These represent the in-degree and out-degree of the target entity node, respectively. This represents the maximum degree in the knowledge graph; Represents the first in a knowledge graph The proportion of class relationships; This represents the total number of relation types in the knowledge graph; Indicates the access frequency of the target entity node; This represents the average access frequency of all nodes in the knowledge graph. , , These represent the weight coefficients of each feature, with values ​​ranging from 0 to 1 and a total of 1.

[0056] Regarding relation density: In specific implementation, the relation density of the target entity node is calculated. Horizontal relation density represents the degree of connectivity of the target entity node in its own layer of storage structure, which is obtained by dividing the number of first-order neighbors of the target node by the total number of nodes in that layer. Vertical relation density represents the degree of connectivity of entity nodes across layers. The values ​​of both densities range from 0 to 1, and different weights can be set according to the actual application scenario. The relation distribution state is obtained by weighted summation.

[0057] As a preferred implementation method, the calculation method for the lateral relationship density of the target entity node is as follows:

[0058] In the formula, This refers to the density of horizontal relationships. This represents the number of first-order neighbors of the target entity node in its own storage layer. The total number of nodes in the storage layer containing the target entity node; This refers to the number of strongly connected neighbors whose edge weights exceed a threshold corresponding to the target entity node. This represents the strong connection weight coefficient, for example, a value of 0.3; the parameter is obtained as follows: Obtained by traversing and counting the adjacency list or adjacency matrix; This is obtained by counting the number of first-order neighbor nodes whose edge weights exceed, for example, 0.7. The second term in the above formula is considered an enhancement term.

[0059] The calculation method for vertical relationship density is as follows: In the formula, This refers to the density of vertical relationships; This represents the total number of nodes directly and indirectly connected across layers. The maximum possible number of cross-layer connections; This represents the number of direct cross-layer connections. To directly connect the weight coefficients, for example, a value of 0.4; the parameter acquisition method is as follows: Obtained through statistical analysis of the inter-layer relationship matrix; It is calculated by multiplying the number of nodes in adjacent layers.

[0060] The above relationship distribution is a weighted sum of horizontal relationship density and vertical relationship density, expressed as: ,in and Let these represent the weight coefficients for the density of horizontal and vertical relationships, respectively, and satisfy the following conditions: The calculation of horizontal and vertical relationship density considers two dimensions: the quantity and quality of connections. The weights of strong connections and direct connections reflect the importance of different types of connections.

[0061] Derivation of the formula for calculating the density of horizontal relationships: starting from the basic node connection ratio Initially, considering the quality characteristics of connections, the proportion of strong connections was introduced. Through weighting coefficients Combination ;in The optimal value was obtained by analyzing the impact of different weights on inference performance.

[0062] Derivation of the formula for calculating vertical relationship density: Similar to the derivation process for horizontal density, but the focus shifts to inter-layer connections, with the basic term being the proportion of cross-layer connections. Considering the importance of direct connections, the percentage of direct connections is introduced. ,form ;in This reflects the important role of direct connections in cross-level reasoning.

[0063] Regarding path search: In specific implementation, path search is performed based on the relationship distribution status to obtain multiple inference paths. An inference threshold is set, for example, to 0.6. When the weighted sum of horizontal and vertical relationship density exceeds this threshold, a bidirectional breadth-first search algorithm is used for parallel multi-path search, with the search depth limited to, for example, 6 layers (not limited). When the weighted sum of density is less than the threshold, relationship expansion is used to increase the connection density until it exceeds the threshold (i.e., 0.6). Relationship expansion methods include synonym expansion, hierarchical relationship expansion, and association rule mining. The confidence formula for association rules is: ,in Let A represent the support function, A represent the antecedent, which is the premise of the rule and is a known condition, and B represent the consequent, which is the result of the rule derivation.

[0064] Regarding path grouping: In specific implementation, all obtained inference paths are grouped. First, a common sub-path is identified among the paths using an algorithm such as the longest common subsequence. Inference paths containing the same sub-path are grouped into the same group. That is, inference paths with common sub-paths are grouped into the same inference path group, and multiple path groups are obtained in this way.

[0065] First, the longest common subsequence algorithm is used to identify common sub-paths between paths. The dynamic programming equation of the algorithm is as follows:

[0066] in Indicates the first path Before the first node and the second path The longest common subsequence length of each node. Based on the dp value, inference paths with common sub-paths are grouped into the same path group. Then, a multi-match function is constructed. Calculate the reliability of the path group: ,in Indicates the first The weight of each path; Indicates the length of the longest common subsequence; Indicates the total path length; Indicates the first The strength value of the relationship; This indicates the number of relations in the path. The path groups are sorted based on their MF (Mean Mean Time) values, and the top K path groups are selected, filtering out path groups with excessively low MF values.

[0067] Regarding the allocation of computing power to path groups, there are two allocation strategies in practice. One strategy is to allocate multiple path groups to GPUs when the ratio of the initial state score to the computing power ratio is greater than 1; otherwise, the multiple path groups are allocated to CPUs. The other strategy is to use a dynamic scheduling strategy based on the real-time computing power ratio. Dynamic adjustments are made, including the real-time computing power ratio. In the formula, , , These represent the number of GPU computing cores, clock frequency, and single-operation efficiency coefficient, respectively. , , These represent the number of CPU cores, the number of threads, and the efficiency coefficient for a single operation, respectively; when When the value is greater than 10, GPU acceleration can be triggered when the number of parallel path groups is greater than or equal to 2 or the required batch size is greater than or equal to 16; when When the value is greater than 1 and less than or equal to 10, tasks with a parallel path group size greater than or equal to 4 or a required batch size greater than or equal to 32 are assigned to the GPU; when When the number of parallel path groups is less than or equal to 1, tasks with a number of parallel path groups greater than or equal to 8 or a required batch size greater than or equal to 64 are assigned to the CPU; once a task is detected to contain branching logic or irregular control flow, the task is assigned to the CPU.

[0068] For path groups allocated for GPU processing, batch processing is used to improve parallel efficiency. The function for dynamically adjusting the batch size can be: ,in Indicates the available video memory size. This indicates the memory usage of a single path; This indicates the number of paths. For path groups allocated for CPU processing, a task queue can be used for management. The queue priority calculation formula is: ,in Indicates the logical complexity score; Indicates the estimated execution time; Indicates memory requirements; Indicates the amount of available memory; This represents the memory weight coefficient. Next, the credibility of each inference path group is calculated, and the allocation priority among all inference path groups whose credibility meets the preset requirements is determined, considering factors such as path length, relationship strength, and node importance. Path length is normalized, relationship strength is calculated based on co-occurrence frequency, and node importance is measured by centrality. These factors are then input into the neural network units in the GPU or CPU according to their allocation priority. High-concurrency path calculation tasks are performed on the GPU, while complex logic inference tasks are performed on the CPU.

[0069] Regarding the construction of equivalent convolutional kernel parameter sets: In specific implementations, a convolutional kernel parameter set is constructed for each neural network unit, for example, containing convolutional kernels of three scales: 3×3, 5×5, and 7×7. The number of convolutional kernels at each scale is 16, 8, and 4, respectively. Smaller-scale convolutional kernels are used to extract local features, while larger-scale convolutional kernels are used to capture global features. Multi-scale feature extraction is achieved by stacking convolutional kernels of different scales. Specifically, for example, each neural network unit contains three different-scale convolutional kernels, and the parameters are initialized using the Xavier method: ,in and These represent the input and output feature dimensions, respectively. This indicates a uniform distribution. A 3×3 convolutional kernel has 16 kernels and is used to extract local features; a 5×5 convolutional kernel has 8 kernels and is used to extract medium-scale features; a 7×7 convolutional kernel has 4 kernels and is used to extract global features. The formula for calculating the number of parameters for each convolutional kernel is: ,in Indicates the kernel size; and These represent the number of input and output channels, respectively.

[0070] The equivalent convolution kernel is calculated based on the convolution kernel parameter set. First, a 3×3 convolution kernel is selected as the reference convolution kernel. The parameter ratio of other scale convolution kernels to the reference convolution kernel is calculated. Then, the equivalent convolution kernel is constructed based on the ratio. While maintaining the feature extraction capability, the computational complexity is reduced. The number of parameters of the equivalent convolution kernel can be designed to be about 50% to 70% of the original convolution kernel.

[0071] As a preferred implementation method, the formula for calculating the equivalent convolution kernel parameters is:

[0072] In the formula, Represents the original convolution kernel parameters. , These represent the size of the original convolution kernel and the size of the reference convolution kernel, respectively. This represents the preset error adjustment coefficient, for example, a value of 0.2. This indicates the preset maximum permissible error, for example, a value of 0.1; This represents the historical training error, obtained by recording the mean square error during the training process. As an error correction term, the calculation of the equivalent convolution kernel parameters incorporates a historical error correction term, which improves the adaptability of feature extraction.

[0073] Derivation of the formula for calculating equivalent convolution kernel parameters: from the basic size ratio transformation Initially, to improve parameter adaptability, an error correction term was introduced. ,form ;in This was determined through model convergence experiments. It is set based on the model performance requirements.

[0074] The feature mapping function of the equivalent convolution kernel is defined as: ,in Indicates the input feature map; This represents the equivalent bias term.

[0075] For example, in a GPU, an equivalent set of convolutional kernels (equivalent convolutional layers) is used to process the target inference path to obtain extracted features. The feature extraction process is defined as follows: ,in Indicates the first Input representation of each inference path; Indicates the convolution operation; Indicates the activation function; This indicates a pooling operation. An equivalent convolutional kernel is applied using a sliding window approach, with the window size matching the kernel size and a stride of 1. The extracted feature vector can have a dimension of 64 or 128, with the specific dimension calculated adaptively. ,in This represents the total number of entities in the knowledge graph.

[0076] Regarding the credibility of inference path groups. In a specific implementation, as a preferred embodiment, the credibility of each inference path group... The calculation method is as follows:

[0077] In the formula, Indicates the first path in this path group The weight of each path, where n represents the total number of paths in the path group; Indicates the first path in this path group The length of the longest common subsequence of the paths; Indicates the first path in this path group The total length of the path; Indicates the first path in this path group The first path The strength value of the relationship; Indicates the first path in this path group The number of relationships in the path; Regarding the allocation of inference path groups, in a preferred implementation, the allocation method for inference path groups is as follows: calculate the queue priority of each inference path group, denoted as... ;in, The logical complexity score (i.e., time complexity) of a single reasoning path group. Indicates the estimated execution time of a single inference path group; Indicates the memory requirements of a single inference path group; Indicates the amount of known available memory; This represents the memory weight coefficient; memory is allocated based on the queue priority score, with higher scores receiving priority.

[0078] Regarding the adaptive optimization of parameters for each neural network unit, in a specific implementation, for example, the triggering condition for the parameter adjustment mechanism is: ,in Indicates the current convolution kernel parameters; Indicates the reference parameter; This represents the threshold value, which is 0.5. Parameter updates utilize a gradient pruning method. ,in Represents the original gradient; Denotes the upper bound of the gradient norm; This represents the gradient after clipping. Represents the gradient vector of p Norm. Using exponential moving averages to maintain smooth parameter changes: ,in This represents the smoothing coefficient, with a value of 0.99.

[0079] Regarding the confidence score of the inference path. In a specific implementation, as a preferred embodiment, the confidence score for each inference path is... The calculation method is as follows:

[0080] In the formula, This indicates the first step of the reasoning path. Features Attention weights This represents the preset path length penalty coefficient, for example, a value of 0.1. This indicates the length of the reasoning path. This indicates the preset relationship strength weight, for example, a value of 0.3. This represents the preset relationship strength threshold, for example, a value of 0.6. Attention weights are calculated using a multi-head attention mechanism. ,in , , These represent the query, key, and value matrices, respectively. This represents the dimension of the key vector.

[0081] The confidence score calculation comprehensively considers feature importance, path complexity, and relationship strength, and uses exponential decay to control the penalty effect on path length. The parameters are obtained using attention weights. Eigenvalues ​​were calculated using a multi-head attention mechanism. Obtained by extraction using equivalent convolution kernels; It is obtained by calculating the co-occurrence frequency of entity pairs in the knowledge graph.

[0082] Derivation of the formula for calculating the confidence score of inference path: First, consider the feature weighting. Introduce path length penalty term To control path complexity, a relation strength factor is added. Ultimately formed ;in and This was obtained through path reasoning accuracy optimization experiments.

[0083] As a further preferred implementation, the reasoning paths within the reasoning path group are sorted based on confidence scores as follows: an improved heap sort algorithm is used for efficient sorting, and the heap adjustment function is defined as:

[0084] in This represents the group of reasoning paths to be sorted; This indicates the index of the current node, which is the number of each inference path in the inference path group; This represents the index of the node with the highest confidence score among its left and right child nodes; ultimately, the node with the highest confidence score is selected. Several reasoning paths are selected as candidate main paths, among which... The value ranges from 3 to 5, and the specific value is determined by the following formula: ,in and These represent the maximum and minimum confidence scores, respectively. This represents the threshold for score differences, for example, a value of 0.1; For paths with similar confidence scores, a diversity assessment function is introduced. Perform diverse pruning: and This represents a set of nodes for two paths. When extracting paths sequentially from the top of the heap, if the current path matches the set of already selected paths... DivIf the value is lower than a preset threshold (e.g., 0.4), the path is skipped and the next path is extracted until N inference paths that meet both the high score requirement and have sufficient diversity are selected. If the number of inference paths after screening is less than N, the preset threshold is lowered (e.g., the step size is lowered to 0.1) until N paths are selected or all candidates are traversed, thus achieving a balance between diversity and coverage.

[0085] As a preferred implementation, the above-described logical verification method is as follows: Perform a consistency check on each candidate main path: the check function is defined as follows: ,in Indicates the main path to be verified; Indicates the first Rule functions; This represents the total number of rules; constraint verification uses predicate logic expressions: ,in, Relative predicates; Indicates a binding predicate, Represent two entities; determine the main path that meets the consistency requirements; For each main path that meets the consistency requirements Expand to obtain the expansion path The method is as follows: ,in This represents the minimum confidence threshold, for example, a value of 0.7, which ensures that there is a greater than 70% probability that the consequent will occur when the antecedent occurs; This represents the minimum support threshold, for example, a value of 0.1, ensuring that it is prevalent in at least 10% of the historical data; and These represent the confidence calculation function and the support calculation function, respectively; the extended path As the final result of the reasoning.

[0086] In association rule mining The form is X→Y (X is the antecedent, Y is the consequent). Support and confidence are two core metrics for measuring the strength and reliability of a rule. Confidence calculation function. Conf ( r The conditional probability that a record containing X also contains Y is expressed as: Conf ( r ) = Conf ( X → Y ) = P ( Y | X ) = P (X ∪ Y ) / P ( X ) = count ( X ∪ Y ) / count ( X ) in count ( X ∪ Y () represents the number of records that contain both X and Y. count ( X ) represents the number of records containing X in the dataset. Conf ( r A value ≥ 0.7 means that when the predecessor appears in the path... X At that time, there is a greater than 70% probability that the consequent will also occur. Y This ensures that the extended knowledge has high credibility. Support calculation function, support representation rules. X→Y The frequency of occurrence throughout the entire dataset. It reflects the universality of the rule. Supp ( r ) =supp ( X→Y ) =P (X∪Y)= count ( X ∪ Y ) / | D |, where count( X ∪ Y ) indicates that the dataset contains both X and Y The number of records (i.e.) X and Y (number of simultaneous occurrences), | D | represents the total number of records (total number of paths) in the dataset. Supp ( r A value ≥ 0.1 means that the generated rules r It must have appeared in at least 10% of historical paths or related data. This is used to filter out sparse rules that appear only occasionally and have no statistical significance.

[0087] Finally, update the system model and parameters. The caching strategy uses the Least Recently Used algorithm, and the cache replacement function is defined as: ,in Represents a cache collection; Indicates the last access time; Indicates access frequency; This represents the time weighting coefficient, with a value of 0.6. Network parameter updates use a sliding window averaging method. ,in Indicates window size; Indicates the first in the window Each parameter value; Indicates the learning rate; Let represent the gradient of the loss function. The objective function for optimizing the task allocation strategy is: ,in Indicates the first The execution time of each task (neural network unit); Indicates task weight; Indicates the first The utilization rate of each resource; This represents the resource balance coefficient, with a value of 0.4.

[0088] The overall optimization process of the system is carried out iteratively, and the objective function for each iteration is defined as: ,in This indicates the loss in reasoning accuracy. Indicates execution time loss; This indicates a loss in resource utilization. , , Let represent the weight coefficients of each loss term, and satisfy . The iteration stopping condition is: Or reach the maximum number of iterations, where This represents the convergence threshold, which takes the value of... The maximum number of iterations is set to 100.

[0089] In summary, this invention employs a multi-layered storage structure based on the characteristics of entity relationships. Different types of relationships are allocated to different storage layers, and each layer can select the optimal storage method based on connection density. This design fully considers the heterogeneity of entity relationships in the knowledge graph and achieves targeted optimization through layered storage. Simultaneously, the multi-level caching mechanism analyzes access patterns and performs hierarchical caching of frequently accessed entities and relationships, effectively improving the access efficiency of hot data. Secondly, in terms of computational model design, a lightweight neural network design approach is adopted. Each neural network unit undergoes special structural optimization and parameter compression, significantly reducing computational complexity while maintaining inference capabilities. Through knowledge distillation technology, knowledge from large pre-trained models is transferred to lightweight networks, achieving model lightweighting without sacrificing inference performance. Furthermore, the design of equivalent convolutional kernels further reduces computational overhead. Regarding task scheduling, an intelligent task allocation mechanism based on device characteristics is designed. By analyzing the computational characteristics of GPUs and CPUs, high-concurrency simple tasks are allocated to GPUs, while complex logical reasoning tasks are allocated to CPUs, achieving rational utilization of heterogeneous computing resources. The dynamic task scheduling strategy adjusts the allocation ratio according to real-time load conditions, ensuring system load balancing. During execution, techniques such as path grouping and priority allocation achieve efficient processing of inference paths. Attention mechanisms and adaptive parameter optimization ensure the accuracy of inference results. The entire technical solution forms a complete optimization system, with components working together to achieve coordinated optimization of storage access, computation processing, and resource allocation, collectively improving the performance of knowledge graph inference and effectively solving the technical problem of low computational efficiency in large-scale knowledge graph inference in existing technologies.

[0090] To better illustrate the effectiveness of this invention, a specific application scenario is provided as an example: When developing an intelligent product recommendation system, the technical research team of an e-commerce platform needed to build an efficient product knowledge graph reasoning system to support personalized product recommendations and related product mining. The team adopted the knowledge graph reasoning optimization method of this invention, and the specific implementation process is as follows.

[0091] The research team first constructed an e-commerce knowledge graph containing 5 million product entity nodes and 20 million relationship edges. Entity nodes include types such as products, categories, brands, users, and tags, while relationship edges include types such as attribute relationships (e.g., "product-belongs to-category"), interaction relationships (e.g., "user-purchase-product"), and association relationships (e.g., "product-similar-product"). The knowledge graph is divided into a 6-layer storage structure according to relationship types: Layer 1 is the product attribute layer, Layer 2 is the category layer, Layer 3 is the brand relationship layer, Layer 4 is the user behavior layer, Layer 5 is the product association layer, and Layer 6 is the tag semantic layer.

[0092] The connection density value of the l-th layer storage structure is calculated as follows: .

[0093] The specific calculations yielded the connection density values ​​for each layer, as shown in Table 1 below.

[0094] Table 1 Connection Density Values

[0095] Based on the calculated connection density values, adjacency matrices are used to store the product attribute layer, category layer, and brand relationship layer, while adjacency lists are used to store other layers. For example... Figure 2 As shown, the diagram illustrates the connection density analysis of each layer of the e-commerce knowledge graph's storage structure, including two dimensions: connection density value and the proportion of high-frequency relationships. A dual-axis bar chart is used to compare the features of the six different storage layers.

[0096] Regarding cache optimization, the research team analyzed one month's worth of access data from the platform and calculated cache priority scores: Based on the calculation results, 500,000 popular product entities with a cache priority score greater than 0.8 are stored in 64GB of memory as the first-level cache, 1.5 million entities with a priority score between 0.5 and 0.8 are stored in a 512GB solid-state drive as the second-level cache, and the remaining entities are stored in a mechanical hard drive as the third-level cache. Figure 3 As shown, the distribution of cache priority scores is illustrated using a scatter plot, which demonstrates the relationship between access frequency weight, cache priority score, and time decay factor. The color intensity of the scatter points indicates the magnitude of the time decay factor.

[0097] The system employs 12 lightweight neural networks to construct parallel processing units. Each network uses an improved MobileNetV3 architecture, containing 3 depthwise separable convolutional layers and 2 fully connected layers, with the number of network parameters kept below 800,000. The system is configured with two NVIDIA A100 GPUs (each with 40GB of VRAM) and four AMD EPYC 7763 processors (a total of 256 cores and 512 threads). Based on the device's computing power characteristics, 80% of the computational tasks are allocated to the GPUs, and 20% to the CPUs.

[0098] In a real-world product recommendation scenario, when receiving a reasoning request (with missing triples), the target entity is "user," the relationship is "purchase," and the missing entity is "product." The system then calculates the horizontal and vertical relation density.

[0099] Table 2 below shows the reasoning process data for a certain product recommendation.

[0100] Table 2 Data Table of Product Recommendation Reasoning Process

[0101] The system configures equivalent convolution kernel parameters for each neural network unit: The specific convolution kernel configurations are shown in Table 3 below.

[0102] Table 3 Convolution Kernel Configuration Table

[0103] The final inference path confidence score is calculated using: .

[0104] like Figure 4 As shown, this table compares the number of parameters and analyzes the computational performance of convolutional kernels with different sizes. Grouped bar charts are used to display the original and equivalent parameter counts, while a line graph shows the change in computational speed ratio. Based on the calculations, the system generates the product recommendation results shown in Table 4 below.

[0105] Table 4 Product Recommendation Results

[0106] The entire inference process took an average of 150 milliseconds, with GPU computation taking 120 milliseconds and CPU computation taking 30 milliseconds. After running the system for one month, the cache hit rate reached 88%, the average inference time decreased to 150 milliseconds, and the recommendation accuracy reached 95%. Figure 5 As shown, a multi-dimensional analysis of the inference path is presented. The trend of confidence score and relationship strength is shown through a hyperbola, and the length information of each path is displayed through annotations.

[0107] Traditional e-commerce recommendation systems suffer from the following main problems: They use relational databases to store product relationships, resulting in low query efficiency. Their caching strategies are simple and cannot effectively utilize multi-level storage resources. Recommendation algorithms primarily rely on collaborative filtering, making it difficult to uncover deep product relationships. Computational resources are unevenly utilized, leading to high response latency during peak periods. In contrast, this invention offers the following technical advantages in e-commerce scenarios: A multi-layered storage structure improves product relationship query efficiency by approximately 60%. An intelligent caching mechanism reduces access latency for popular products by approximately 80%. Knowledge graph reasoning methods can discover more valuable product relationships, improving recommendation accuracy by approximately 15%. 4. GPU and CPU collaborative computing improves system reasoning performance by approximately 65% ​​and peak processing capacity by approximately 3 times.

[0108] Example 2 This application also relates to a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described above.

[0109] Specifically, the memory may include high-speed random access memory, as well as non-volatile memory, such as hard disks, RAM, plug-in hard disks, smart media cards (SMC), secure digital (SD) cards, flash cards, at least one disk storage device, flash memory device, or other volatile solid-state storage devices.

[0110] The relevant technical solutions are the same as above, and will not be repeated here.

[0111] In summary, this embodiment provides a method for optimizing large-scale knowledge graph inference. First, it constructs a multi-layered storage structure and a multi-level caching mechanism to optimize data access. Then, it designs a lightweight neural network group for parallel processing. An intelligent task allocation mechanism enables efficient utilization of heterogeneous computing resources. Path grouping and priority allocation techniques are employed to improve inference efficiency. Finally, adaptive parameter optimization and multiple verification mechanisms ensure inference accuracy. This invention utilizes knowledge distillation technology to transfer knowledge from large pre-trained models to lightweight networks, achieving model lightweighting without sacrificing inference performance.

[0112] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for optimizing large-scale knowledge graph reasoning, characterized in that, include: Offline phase: Construct a multi-layer storage structure for the knowledge graph, store the knowledge graph in the multi-layer storage structure according to the entity relationship type, and calculate the connection density value of each layer of the storage structure, which is characterized by the ratio of the number of entity relationships actually stored in that layer to the total number of entity relationships in the knowledge graph; The cache priority score of each entity is determined based on the access frequency of each entity in the knowledge graph and the connection density value of the storage structure where the entity is located. All entity caches are divided into memory cache, solid-state drive cache and hard disk storage according to the score from high to low. N lightweight neural network units are constructed and deployed to GPU and CPU in groups according to the computing power ratio of GPU and CPU. Online reasoning phase: Obtain reasoning requests from the knowledge graph, extract target entity nodes from them, and calculate the initial state score of the target entity nodes based on their degree, connection relationship type distribution, and historical access frequency in the knowledge graph. The horizontal relation density, representing the connectivity of a target entity node within its own storage layer, and the vertical relation density, representing the connectivity of a target entity node across layers, are calculated to determine the relation distribution state of the target entity node. When the relation distribution state meets the inference threshold requirement, a multi-path parallel search is performed to obtain multiple inference paths; otherwise, the relation of the target entity node is expanded until the inference threshold requirement is met. The searched multiple inference paths are grouped to obtain multiple path groups. Based on the computing power ratio or the ratio of the initial state score to the computing power ratio, the multiple path groups are allocated to GPUs or CPUs. The credibility of each inference path group is calculated, and the allocation priority among all inference path groups whose credibility meets the preset requirement is determined. The allocation priority is then sequentially input into the neural network units in the GPU or CPU. For each of the N neural network units, an original convolutional kernel parameter set is constructed, each containing parameters of multiple convolutional kernels at different scales. Within each neural network unit, an equivalent convolutional kernel set is obtained based on the corresponding original convolutional kernel parameter set. The parameters of each equivalent convolutional kernel in the equivalent convolutional kernel set are calculated based on the ratio of the original convolutional kernel parameters to the baseline convolutional kernel parameters. In the GPU, multiple deployed neural network units utilize the equivalent convolutional kernel sets to perform feature extraction operations in parallel, obtaining an inference path feature vector set corresponding to each input inference path set. Adaptive parameter optimization is performed in the CPU. When any equivalent convolutional kernel parameter in any neural network unit exceeds a parameter threshold range, the parameter adjustment mechanism of that neural network unit is triggered to adjust the parameters. The confidence score of each inference path within each inference path set is calculated based on the path feature vector set. Based on the confidence score, the inference paths within the inference path group are sorted, and the N inference paths with the highest confidence scores are selected as candidate main paths from the inference path group; the CPU is used to perform logical verification and supplementary inference on the candidate main paths to generate a complete inference result; By comparing the candidate main paths with the verified inference results, the knowledge graph multi-level caching model and network parameters are updated, and the task allocation strategy for N neural network units is optimized and adjusted.

2. The large-scale knowledge graph reasoning optimization method as described in claim 1, characterized in that, The connection density value of each storage layer is expressed as: In the formula, For the first The connection density value of the layered storage structure; For the first The actual number of entity relationships contained in the knowledge graph stored in the layer; This represents the total number of entity relations in the knowledge graph. For the first The number of entity relationships stored in the layer whose access frequency exceeds a preset threshold; This is a balancing factor, with a value ranging from 0.2 to 0.

4. In the offline phase, the method also includes: when the connection density value is greater than the corresponding preset threshold, the information of the storage structure of this layer is stored using an adjacency matrix; otherwise, it is stored using an adjacency list.

3. The large-scale knowledge graph reasoning optimization method as described in claim 1, characterized in that, The cache priority score for each entity is calculated as follows: In the formula, Score the cache priority. This represents the cumulative number of visits to a single entity within a unit of time. The preset time window length; This represents the connection density value of the storage structure of the layer containing the entity. Weighted by access frequency; This is the time decay coefficient; The decay rate; This represents the time interval since the last access to this entity.

4. The large-scale knowledge graph reasoning optimization method as described in claim 1, characterized in that, Initial state score of the target entity node The calculation method is as follows: In the formula, and These represent the in-degree and out-degree of the target entity node, respectively. This represents the maximum degree in the knowledge graph; Represents the first in a knowledge graph The proportion of class relationships; This represents the total number of relation types in the knowledge graph; Indicates the access frequency of the target entity node; This represents the average access frequency of all nodes in the knowledge graph. , , These represent the weight coefficients of each feature, with values ​​ranging from 0 to 1 and a total of 1; The method for assigning multiple path groups to the GPU or CPU is as follows: A dynamic scheduling strategy is adopted, based on the real-time computing power ratio. Dynamic adjustments are made, including the real-time computing power ratio. In the formula, , , These represent the number of GPU computing cores, clock frequency, and single-operation efficiency coefficient, respectively. , , These represent the number of CPU cores, the number of threads, and the efficiency coefficient for a single operation, respectively. When the ratio of the initial state score to the computing power ratio is greater than 1, multiple path groups are allocated to the GPU; otherwise, multiple path groups are allocated to the CPU; or, when When the value is greater than 10, GPU acceleration can be triggered when the number of parallel path groups is greater than or equal to 2 or the required batch size is greater than or equal to 16; when When the value is greater than 1 and less than or equal to 10, tasks with a parallel path group size greater than or equal to 4 or a required batch size greater than or equal to 32 are assigned to the GPU; when When the number of parallel path groups is less than or equal to 1, tasks with a number of parallel path groups greater than or equal to 8 or a required batch size greater than or equal to 64 are assigned to the CPU; once a task is detected to contain branching logic or irregular control flow, the task is assigned to the CPU.

5. The large-scale knowledge graph reasoning optimization method as described in claim 1, characterized in that, The method for calculating the lateral relationship density of target entity nodes: In the formula, This refers to the density of horizontal relationships. This represents the number of first-order neighbors of the target entity node in its own storage layer structure. The total number of nodes in the storage layer containing the target entity node; This refers to the number of strongly connected neighbors whose edge weights exceed a threshold corresponding to the target entity node. These are the strong connection weight coefficients; The calculation method for vertical relationship density is as follows: In the formula, This refers to the density of vertical relationships; This represents the total number of nodes directly and indirectly connected across layers. The maximum possible number of cross-layer connections; This represents the number of direct cross-layer connections. For direct connection weight coefficients; The relationship distribution state is a weighted sum of the horizontal relationship density and the vertical relationship density.

6. The large-scale knowledge graph reasoning optimization method as described in claim 1, characterized in that, The formula for calculating the equivalent convolution kernel parameters is: In the formula, Represents the original convolution kernel parameters. , These represent the size of the original convolution kernel and the size of the reference convolution kernel, respectively. This represents the preset error adjustment coefficient. This indicates the preset maximum permissible error. Indicates historical training error. This is the error correction term.

7. The large-scale knowledge graph reasoning optimization method as described in claim 1, characterized in that, Credibility of each reasoning path group The calculation method is as follows: In the formula, Indicates the first path in this path group The weight of each path, where n represents the total number of paths in the path group; Indicates the first path in this path group The length of the longest common subsequence of the paths; Indicates the first path in this path group The total length of the path; Indicates the first path in this path group The first path The strength value of the relationship; Indicates the first path in this path group The number of relationships in the path; The allocation method for reasoning path groups is as follows: Calculate the queue priority for each inference path group, denoted as: ;in, The logical complexity score representing a single group of reasoning paths; Indicates the estimated execution time of a single inference path group; Indicates the memory requirements of a single inference path group; Indicates the amount of known available memory; This represents the memory weighting coefficient; Assign priority based on queue priority score.

8. The large-scale knowledge graph reasoning optimization method as described in claim 1, characterized in that, Confidence score for each inference path The calculation method is as follows: In the formula, This indicates the first step of the reasoning path. Features Attention weights This represents the preset path length penalty coefficient. This indicates the length of the reasoning path. Indicates the preset relation strength weight. This indicates a preset threshold for relationship strength. The method for ranking the inference paths within the inference path group based on the confidence scores is as follows: An improved heap sort algorithm is used to achieve efficient sorting. The adjustment function of the heap is defined as: in, This represents the group of reasoning paths to be sorted; Indicates the index of the current node; This represents the index of the node with the highest confidence score among its left and right child nodes; Finally, the one with the highest confidence score was selected. Several reasoning paths were selected as candidate main paths, among which The specific value is determined by the following formula: , and These represent the maximum and minimum confidence scores, respectively. Indicates the threshold for score difference; For paths with similar confidence scores, a diversity assessment function is introduced. Perform diverse pruning: and This represents a set of nodes for two paths. When extracting paths sequentially from the top of the heap, if the current path matches the set of already selected paths... Div If the value is lower than the preset threshold, the path is skipped and the next path is extracted until N inference paths that meet the high score requirements and have sufficient differences are selected. If the number of inference paths after screening is less than N, the preset threshold is lowered until N paths are selected or all candidates are traversed, so as to achieve a balance between diversity and coverage.

9. The large-scale knowledge graph reasoning optimization method as described in claim 1, characterized in that, The method of logical verification is as follows: Perform a consistency check on each candidate main path: the check function is defined as follows: ,in Indicates the main path to be verified; Indicates the first Rule functions; This represents the total number of rules; constraint verification uses predicate logic expressions: ,in, Relative predicates; Indicates a binding predicate, Represent two entities; determine the main path that meets the consistency requirements; For each main path that meets the consistency requirements Expand to obtain the expansion path The method is as follows: ,in Indicates the minimum confidence threshold; This represents the minimum support threshold; and These represent the confidence calculation function and the support calculation function, respectively; the extended path As the final result of the reasoning.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein the computer program, when executed by a processor, controls the device on which the storage medium is located to perform the steps of the method as described in any one of claims 1 to 7.