Graph structure poisoning-oriented darning type non-intrusive large language model repairing method and system

By dividing the graph into subgraphs and training sub-models independently, the efficiency and security issues of graph structure poisoning and privacy information processing in the graph-RAG system are solved. This achieves comprehensive modeling of local updatable and full-graph semantics, improving the robustness and maintenance efficiency of the question answering system.

CN120974491APending Publication Date: 2025-11-18THE THIRD RES INST OF MIN OF PUBLIC SECURITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511085664.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-04
Publication Date
2025-11-18

AI Technical Summary

Technical Problem

Existing graph-RAG systems face challenges such as data poisoning, difficulty in deleting private information, time-consuming and resource-intensive full-graph retraining, and difficulty in local updates when dealing with graph poisoning, which affect the system's security and efficiency.

Method used

The original graph is divided into multiple subgraphs. Subgraphs are generated using a constrained K-Means embedding clustering algorithm. Graph neural network models are trained independently, and summary and compensation information are introduced for local updates, generating autonomously updatable submodels that are retrained only when local subgraphs change.

Benefits of technology

Modular management of graphs is achieved, reducing computational costs and maintenance complexity, improving the local updability and response efficiency of the system, enhancing system security and the robustness of the question-answering system, avoiding repeated fine-tuning of large models, and improving overall maintenance efficiency and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120974491A_ABST
    Figure CN120974491A_ABST
Patent Text Reader

Abstract

The invention provides a textured non-intrusive large language model repairing method and system oriented to graph structure poisoning, and belongs to the technical field of artificial intelligence. The textured non-intrusive large language model repairing method comprises the steps that an original graph is divided into a plurality of sub-graphs, the sub-graphs contain boundary and non-boundary nodes, and the boundary nodes have abstract and compensation information; independently training a graph neural network model for each sub-graph, using the abstract and the compensation information for training, and generating a sub-model capable of being autonomously updated; and finally, when a local change request is received, changing the corresponding sub-model. The method has the beneficial effects that modular management of graphs is realized, and the calculation and maintenance cost is reduced; the local updatability and response efficiency of the system are improved, and local repair is supported; the graph reasoning capability is reserved, the safety is enhanced, and the robustness and accuracy of a question-answering system are improved; repeated fine tuning of a large model is avoided, the language model burden is relieved, and the overall maintenance efficiency and reliability of the system are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a non-intrusive, graph-structure-oriented method and system for repairing large language models through patching. Background Technology

[0002] Large Language Models (LLMs), such as LLaMa, ChatGLM, and ChatGPT, have demonstrated powerful generative and comprehension capabilities in tasks such as intelligent question answering, academic search, and medical knowledge retrieval. However, the knowledge scope of pre-trained large language models is typically limited to static corpora. To enhance their reliability and expertise, introducing external knowledge sources is essential.

[0003] Currently, common methods include fine-tuning large models or employing Retrieval-Augmented Generation (RAG) techniques. Retrieval-Augmented Generation, as an effective fusion approach, allows large language models to access specialized or internal knowledge bases during the generation process. Graph-structured data, such as academic graphs, enterprise knowledge graphs, and drug interaction graphs, are increasingly being integrated into RAG systems due to their strong structural expressiveness, low noise interference, and suitability for causal reasoning and prediction, forming graph-RAG systems.

[0004] In the practical implementation of graph-RAG systems, several security challenges have been exposed. First, there is the risk of data poisoning. Due to the diverse sources of graph data, attackers can inject malicious nodes or edges, forge or distort relationships, or manipulate node features to bias the model towards incorrect conclusions. Second, graphs may contain private or outdated information, which is difficult to remove. Furthermore, existing graph-RAG systems are typically based on joint training of the entire graph; deleting a node often means retraining the entire graph model, which is not only time-consuming and resource-intensive but also lacks local updability.

[0005] Currently, the industry has proposed several solutions:

[0006] The full-graph retraining method reloads and retrains the entire graph neural network when abnormal edge relationships are detected or privacy deletion requests are made. However, this method cannot support modular maintenance, makes it difficult to isolate, update, or reinforce local regions as needed, and is costly and has a long training cycle, which greatly affects the system's online responsiveness and maintenance efficiency.

[0007] The knowledge distillation-based modification method transforms structural knowledge in the graph into text, such as graph path or neighbor sequence descriptions. Upon discovering poisoned data or data to be modified, modifications can be made directly within the text. While this method reduces reliance on the graph structure itself and eliminates the need to retrain the entire graph, representing graph structure information through text weakens its inherent causal reasoning and contextual modeling capabilities. This can easily lead to a decline in the understanding of structural relationships within large language models, resulting in lower quality responses and ultimately impacting question-answering performance.

[0008] The method of fine-tuning the large language model using negative samples does not directly modify the graph structure or retrain the graph neural network model. Instead, it starts from the downstream question-answering task, generating or collecting queries (prompts) related to harmful nodes / edges and their incorrect answers (i.e., the model's original responses). These are then used as negative samples to feed into the large language model for comparative training or rejection training, allowing the large model to learn to avoid, ignore, or refute content related to this knowledge. For example, a common approach is to construct "positive-negative pairs" problems, where one question is based on a poisoning node, and the other is the equivalent question after deleting that node. By training the large language model, it outputs a negative / warning response to the former and a normal result to the latter, thus forming a response distinction. This method does not require retraining the graph neural network or embedding unit, making it more suitable for rapid patching of deployed systems while preserving the original reasoning ability of the graph structure. It achieves "soft deletion" without affecting the performance of the backbone graph data. However, directly fine-tuning the large language model using negative samples relies on high-quality task-based sample construction, which involves a lot of manual intervention and is difficult to automate. The large number of parameters in the large model results in a still high training cost, and its effectiveness is difficult to cover all potential malicious paths, leading to problems such as incomplete patching or excessive rejection. Summary of the Invention

[0009] To address the above technical problems, this invention provides a non-intrusive, graph-structure-oriented method for repairing large language models using patching techniques; furthermore, it also provides a non-intrusive, graph-structure-oriented system for repairing large language models using patching techniques.

[0010] The technical problem solved by this invention can be achieved by the following technical solutions:

[0011] A non-intrusive, graph-structure-oriented method for repairing large language models through patching techniques includes:

[0012] Step S1: Divide the original graph into multiple subgraphs. Each subgraph contains multiple nodes, including boundary nodes and non-boundary nodes. Boundary nodes have summary information and compensation information. The summary information is the structural features of the connecting nodes in the subgraphs adjacent to the boundary nodes, and the compensation information is the statistical features of key association edges.

[0013] Step S2: Train a graph neural network model independently for each subgraph. During the training process, use the summary information of the boundary nodes as contextual cues and the compensation information as auxiliary semantic features to generate multiple autonomously updatable submodels.

[0014] Step S3: Upon receiving a local change request, modify the sub-model corresponding to the subgraph according to the nodes / edges included in the local change request to obtain a new sub-model.

[0015] Preferably, step S1 includes the following steps before dividing the original map:

[0016] Step S10: Embedding modeling is performed on each node in the original graph, and a node embedding vector space is generated based on node attribute features and local adjacency structure features.

[0017] Preferably, in step S1, the original graph is divided according to the node embedding vectors in the node embedding vector space to form the multiple sub-graphs.

[0018] Preferably, the node attribute features are static information of the node, and the static information includes at least one of text content, tag category, and type identifier;

[0019] The local adjacency structure feature is the local topological structure information of the node in the original graph, and the local topological structure information includes at least one of adjacency distribution, path information, and subgraph structure.

[0020] Preferably, the partitioning is implemented using a constrained K-Means embedding clustering algorithm, and step S1 includes:

[0021] Step S11: Randomly initialize K cluster centers of the original map, where K is a positive integer greater than 1;

[0022] Step S12: Based on the subgraph size balance constraint, the cross-subgraph edge minimization constraint, and the subgraph connectivity and semantic integrity constraint, construct the cost function:

[0023]

[0024] in, Indicates node embedding Z i With its cluster center The squared Euclidean distance between them, where i represents a node and v represents the total number of nodes;

[0025] Indicates the current number of cluster nodes The square of the difference between the proportion of the total number of nodes v in the original graph and the reciprocal of the number of clusters, 1 / K.

[0026] ∑ j∈N(i) 1[c i ≠c j [] represents the number of nodes in different clusters for two adjacent nodes, j represents the node, and c i c represents the cluster to which node i belongs. j Let N(i) represent the cluster to which node j belongs, and let N(i) represent the set of neighboring nodes of node i.

[0027] φ(i,c i ) represents semantic connectivity constraints.

[0028]

[0029] This indicates the number of a node's neighbors that are assigned to the same cluster. Entropy representing the label information of a cluster;

[0030] λ1, λ2, and λ3 represent the weights, respectively;

[0031] Step S13: Perform node iteration, calculate the total loss cost of each node, assign the node to the cluster with the minimum total loss cost, and update the centroid of each cluster iteratively to the average embedding vector of the cluster member nodes.

[0032] Step S14: Repeat step S13 until the node partitioning no longer changes or the set number of iterations is reached, then stop the iteration.

[0033] Preferably, the step of generating the summary information includes:

[0034] Step A1: For each subgraph, identify the boundary nodes of the subgraph;

[0035] Step A2: For each boundary node in the subgraph, identify the connecting nodes that are connected to the boundary node and belong to the adjacent subgraph, and obtain the cross-subgraph neighbor set;

[0036] Step A3: Extract summary information based on all connected nodes in the cross-subgraph neighbor set. The summary information includes one or more combinations of the following: the embedding mean of connected nodes, the distribution statistics of connected edges, the mean of connected edges, and the standard deviation of connected edges.

[0037] Preferably, the step of generating the compensation information includes:

[0038] Step B1: Filter key edges;

[0039] Step B2: For each key edge, calculate the statistical feature vector of the key edge, and use the statistical feature vector of the high-confidence connection pair as the compensation information.

[0040] Preferably, when the local change request includes a boundary node, step S3 further includes:

[0041] Regenerate summary and compensation information, and retrain the sub-model corresponding to the boundary node adjacency subgraph to obtain a new sub-model.

[0042] Preferably, it further includes:

[0043] Based on the input query request, retrieve several subgraphs related to the query request and obtain the prediction results of the sub-models corresponding to the several subgraphs;

[0044] The obtained prediction results are integrated to obtain an integrated result;

[0045] The integrated result is transmitted to a large language model, which uses the integrated result as a pre-prompt word to output a natural language answer to the query request.

[0046] On the other hand, a non-intrusive, graph-structure-oriented poisoning repair system for large language models is also provided, for implementing the aforementioned graph-structure-oriented poisoning repair method for non-intrusive, graph-structure-oriented large language models. The system includes:

[0047] The graph partitioning module is used to partition the original graph into multiple subgraphs. Each subgraph contains multiple nodes, including boundary nodes and non-boundary nodes. The boundary nodes have summary information and compensation information. The summary information is the structural features of the connecting nodes in the subgraphs adjacent to the boundary nodes, and the compensation information is the statistical features of key association edges.

[0048] The subgraph model training module, connected to the graph partitioning module, is used to independently train a graph neural network model for each subgraph. During the training process, the summary information of the boundary nodes is used as contextual cues, and the compensation information is used as auxiliary semantic features to generate multiple autonomously updatable submodels.

[0049] The update module, connected to the subgraph model training module, is used to modify the subgraph corresponding to the subgraph based on the nodes / edges contained in the local change request when a local change request is received, so as to obtain a new subgraph.

[0050] The advantages or beneficial effects of the technical solution of this invention are as follows:

[0051] This invention achieves modular graph management by dividing the entire graph into multiple subgraphs or submodules, enabling graph neural networks to be trained and updated independently at the local subgraph level, significantly reducing computational costs and maintenance complexity. Simultaneously, it greatly improves the system's local updability and response efficiency. When a node in a subgraph is determined to be involved in poisoning or contains private information, only the model corresponding to that subgraph needs to be retrained, without requiring full graph retraining, thus supporting flexible, secure, and efficient local repair. While preserving the graph structure's reasoning capabilities, it enhances system security by fusing and aggregating multiple subgraph models, achieving comprehensive semantic modeling and result enhancement for the entire graph, improving the robustness and accuracy of the question-answering system when facing harmful information. Furthermore, it avoids repetitive fine-tuning of large models, reducing the burden on language models. This invention completes isolation and repair operations at the graph structure level, eliminating the need for frequent modifications to large language model parameters, thereby improving the overall maintenance efficiency and reliability of the system. Attached Figure Description

[0052] Figure 1 This is a flowchart illustrating a preferred embodiment of the present invention, showing a patch-based non-intrusive large language model repair method for graph-structure poisoning.

[0053] Figure 2 A flowchart illustrating the constrained K-Means embedding clustering algorithm is shown in a preferred embodiment of the present invention.

[0054] Figure 3 This is a flowchart illustrating the steps for generating summary information in a preferred embodiment of the present invention.

[0055] Figure 4 This is a flowchart illustrating the steps for generating compensation information in a preferred embodiment of the present invention.

[0056] Figure 5 This is a schematic diagram of the subgraph model prediction process in a preferred embodiment of the present invention.

[0057] Figure 6 A structural block diagram of a graph-oriented, non-intrusive, large language model repair system for poisoning graph structures, as shown in a preferred embodiment of the present invention. Detailed Implementation

[0058] 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. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0059] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other.

[0060] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, but this is not intended to limit the scope of the invention.

[0061] In a preferred embodiment of the present invention, based on the aforementioned problems existing in the prior art, a non-intrusive, graph-structure-oriented method for repairing large language models using patching techniques is provided, such as... Figure 1 As shown, the method includes the following steps:

[0062] Step S10: Embedding modeling is performed on each node in the original graph. Based on the node attribute features and local adjacency structure features, a node embedding vector space is generated.

[0063] In this step, first, input the original graph G = (V, E); where V represents a node and E represents an edge with an association relationship.

[0064] Next, graph neural networks, including but not limited to Graph Convolutional Network (GCN), Graph Attention Network (GAT), and Graph Sample and Aggregate (GraphSAGE), are used to embed each node in the original graph, combining node attribute features with local adjacency structure features to generate a unified embedding vector space for subsequent partitioning.

[0065] Graph neural network models jointly model graph structure and node features, extracting high-dimensional node embeddings (Z-representations) with structure awareness. During embedding generation, the following two types of key features are integrated:

[0066] Node attribute characteristics: These are the static information carried by the node itself, including text content, tag category, type identifier, etc.

[0067] Local adjacency structure features: These are the local topological structure information of a node in the graph, including adjacency distribution, path information, subgraph structure, etc.

[0068] The final output node embedding in the vector space can be represented as:

[0069] H∈R |V|×d ;

[0070] Where |V| represents the total number of nodes in the original graph G, i.e. the number of rows in the matrix; d represents the dimension of the embedding vector, i.e. the number of columns in the matrix; and H represents the node embedding vector space.

[0071] In the matrix of the node embedding vector space, each row corresponds to a node v. i Embedding vector h i This is used to drive subsequent graph partitioning and subgraph modeling; where v i ∈V.

[0072] This embedding represents the fusion of structural features and attribute semantics, providing a unified and structurally and semantically consistent input foundation for subsequent robust partitioning and sub-model training.

[0073] It should be noted that node embedding modeling can be implemented using conventional methods in this field, and will not be described in detail here.

[0074] Step S1: Divide the original graph into multiple subgraphs based on the node embedding vectors in the node embedding vector space H. Each subgraph contains multiple nodes, including boundary nodes and non-boundary nodes. Boundary nodes have summary information and compensation information. The summary information is the structural features of the connecting nodes in the subgraphs adjacent to the boundary nodes, and the compensation information is the statistical features of the key association edges.

[0075] In this step, graph partitioning and model balance control techniques are used, namely, based on node embedding vectors, constrained K-Means or other embedding-driven graph partitioning algorithms are used to perform balanced partitioning of the entire graph, dividing the graph into multiple subgraphs.

[0076] The following factors need to be considered during the partitioning process: First, the size of the subgraph should be as balanced as possible with the complexity of the model; second, the number of edges across the subgraph should be reduced to minimize structural loss; and third, the local connectivity and semantic integrity of the subgraph should be guaranteed.

[0077] Within the node embedding space, constrained K-Means or equivalent embedding clustering algorithms are executed. To control the partitioning quality and enhance overall robustness, the algorithm sets the following three types of key constraint metrics:

[0078] Subgraph size balance constraint: This constraint aims to control the number of nodes in each subgraph to be close, avoiding problems such as insufficient training or overfitting caused by excessive differences in the number of nodes in the subgraphs. At the same time, it avoids problems such as excessive consumption of computing resources and time during retraining if the poisoned data appears in a large subgraph.

[0079] Minimize cross-subgraph edges: This constraint aims to reduce the number of structural cut edges, limit the propagation of poisoned edges between subgraphs, and reduce cross-subgraph edges to reduce interference between subgraphs, thereby improving the safety and stability of the model.

[0080] Subgraph connectivity and semantic integrity constraints: This constraint aims to maintain connectivity within each subgraph and ensure that semantics are relatively independent, avoiding information fragmentation or isolated node regions caused by partitioning; at the same time, ensuring the semantic integrity of the subgraph helps to improve the model's reasoning ability and ability to process complex information.

[0081] Specifically, such as Figure 2 As shown, the constrained K-Means embedding clustering algorithm includes the following steps:

[0082] Step S11: Randomly initialize K cluster centers of the original graph, where K is a positive integer greater than 1; preferably, the number of clusters K is less than half the total number of nodes, i.e., 1. <K<V / 2。

[0083] Step S12: Based on the subgraph size balance constraint, the cross-subgraph edge minimization constraint, and the subgraph connectivity and semantic integrity constraint, construct the cost function:

[0084]

[0085] in, The clustering loss is calculated using node embedding Z. i With its cluster center The squared Euclidean distance between them is represented by i, where i represents a node and v represents the total number of nodes.

[0086] To balance the scale constraints, based on the current number of cluster nodes The square of the difference between the proportion of the total number of nodes v in the original graph and the reciprocal of the number of clusters 1 / K is used to constrain the balance of subgraph size and avoid some subgraphs being too large or too small.

[0087] ∑ j∈N(i) 1[c i ≠c j The penalty for cross-subgraph edges is represented by the number of nodes in different clusters between two adjacent nodes, where j represents a node and c represents a node. i c represents the cluster to which node i belongs. j Let N(i) represent the cluster to which node j belongs, and let N(i) represent the set of neighboring nodes of node i; this penalty is used to minimize the existence of cross-cluster edges; where,

[0088] It is a Boolean function used to indicate whether a certain condition is met. In our formula, it is used to measure whether two adjacent nodes are assigned to different clusters.

[0089] φ(i,c i ) represents semantic connectivity constraints.

[0090]

[0091] This constraint formula is a penalty term designed to ensure semantic coherence. Wherein, This represents the number of nodes in the same cluster that a node's neighbors belong to, and is used to measure how many of a node's neighbors are assigned to the same cluster. Cluster The entropy of label information, which is the degree of semantic confusion.

[0092] λ1, λ2, and λ3 represent the weights, respectively;

[0093] Step S13: Perform node iteration, calculate the total cost of loss for each node, assign the node to the cluster with the minimum total cost of loss, and update the centroid of each cluster iteratively to the average embedding vector of the cluster member nodes.

[0094] The centroid can be calculated using a simple statistical average, where the k-th cluster is denoted as C. k If the node embedding vectors contained in the k-th cluster are z1, z2, ..., then the centroid μ of the k-th cluster is... k That is:

[0095]

[0096] Among them, C k Indicates cluster C k The set of nodes; |C k | represents cluster C k The number of nodes.

[0097] Step S14: Repeat step S13 until the node partitioning no longer changes or the set maximum number of iterations (e.g., V / 2 times) is reached, then stop the iteration.

[0098] The embodiments of the present invention, through the constrained K-Means embedding clustering algorithm, can limit graph structure attacks or spoofing interference to local areas, preventing the damage from spreading to the entire graph, thereby constructing a graph model system that is naturally attack-tolerant.

[0099] During graph partitioning, edges between nodes inevitably get "cut off," leading to information loss. To compensate for the structural fragmentation caused by graph partitioning and maintain semantic coherence and reasoning accessibility between subgraphs, a non-intrusive structural repair scheme is proposed.

[0100] Specifically, to address semantic integrity, a darning-based cross-graph repair mechanism is introduced. This mechanism draws inspiration from the textile field's darning technique, compensating through two methods:

[0101] Cross-graph summary fusion (semantic edge locking): During the subgraph training phase, instead of directly introducing complete adjacency information, structural feature representations of adjacent subgraphs are introduced in the form of summaries, such as aggregated representations of boundary node embeddings and adjacency distribution patterns, as non-intrusive contextual cue signals. This process is like edge locking on the fabric, ensuring semantic continuity between subgraphs without disrupting the original training process of each subgraph, enhancing collaborative perception capabilities, and avoiding the introduction of strong dependencies.

[0102] Compensatory Feature Injection (Key Information Transition): For important structural edges or potential dependencies that are truncated during graph partitioning, this invention introduces the concept of high-confidence weaving edges. Key edges that should be retained are selected using a confidence index, and then injected as features during the training phase to provide additional input signals to the subgraph model, guiding the model to reconstruct potential inference paths. This method does not rely on real structural reconnection, but rather completes semantic stitching in an auxiliary manner, balancing structural integrity and module independence.

[0103] Through the low-coupling patching mechanism of edge locking and transition stitching, this invention achieves the maximum restoration of the original graph reasoning ability while maintaining independent training and deployment among subgraph models, and significantly reduces the cost of system reconstruction and full graph maintenance.

[0104] Step S2: Train a graph neural network model independently for each subgraph. During the training process, the summary information of the boundary nodes is used as contextual cues, and the compensation information is used as auxiliary semantic features to generate multiple autonomously updatable submodels.

[0105] Each subgraph is deployed and trained independently with its own graph neural network model, generating multiple autonomously updatable submodels.

[0106] In the question-answering reasoning stage of the large language model, the prediction results of multiple sub-models are aggregated and passed to the large language model as external knowledge support, thereby outputting a credible and structure-aware natural language answer.

[0107] Step S3: Upon receiving a local change request, modify the sub-model corresponding to the subgraph based on the nodes / edges included in the local change request to obtain a new sub-model.

[0108] When faced with requests to delete data due to data poisoning or privacy deletion, it is only necessary to locate the subgraph to which the data belongs and locally retrain or prune the corresponding submodel to obtain new submodel prediction results.

[0109] In the question-answering reasoning stage of the large language model, the prediction results of the new sub-model are used, while other aggregation algorithms and steps passed to the large language model remain unchanged.

[0110] In a preferred embodiment, such as Figure 3 As shown, the steps for generating summary information include:

[0111] Step A1: For each subgraph, identify the boundary nodes of the subgraph;

[0112] Step A2: For each boundary node in the subgraph, identify the connected nodes that belong to the adjacent subgraph and are connected to the boundary node to obtain the cross-subgraph neighbor set;

[0113] Step A3: Extract summary information based on all connected nodes in the cross-subgraph neighbor set. The summary information includes one or more combinations of the following: the embedding mean of connected nodes, the distribution statistics of connected edges, the mean of connected edges, and the standard deviation of connected edges.

[0114] Specifically, in the summary semantic edge locking mechanism of this embodiment, the boundary nodes connecting other subgraphs in each subgraph are identified, and summary information is extracted from the adjacent subgraphs they are connected to, including the embedding mean of the connected nodes, the distribution statistics of the connected edges, etc. The summary information is used as contextual prompts to input the subgraph model for training, rather than the actual edge connections.

[0115] This is similar to the "locking" treatment in fabric, which allows boundary nodes to gain semantic awareness of neighboring graphs while maintaining structural closure, thus enhancing defense against boundary perturbations and cross-graph attacks.

[0116] Specifically, the mending method is a solution for locally repairing the frayed edges of clothing after it has been torn. It uses fine, non-invasive threads to fill in the torn pattern information along the original fabric structure, thus restoring structural strength while maintaining the overall small-piece feel in terms of appearance and function.

[0117] In graph partitioning, the nodes at the boundary are like broken edges, and the semantics of the adjacent subgraphs are like the missing threads that have been cut away. Edge locking is about filling in the original semantics at these break points.

[0118] Specifically, the edge-locking process includes the following steps:

[0119] First, identify the boundary nodes;

[0120] Boundary nodes are nodes in each subgraph that are connected to other subgraphs.

[0121] For example,

[0122] Among them, v k This represents a node in the k-th cluster; Indicates the concept of existence; v l E represents the node of the l-th cluster; E represents the node v. i and node v j Belonging to the same side; This represents the set of boundary nodes in the k-th cluster (the subgraph after graph partitioning).

[0123] For sets Each boundary node v in i Extract the following summary semantic features from its original connected cross-graph neighbors:

[0124] Mean concatenation of node embeddings: For each boundary node, define the set of its connected cross-subgraph neighbors as the set of boundary nodes in other subgraphs connected to that boundary node. Then, embed the node embedding vector h from this set. v The average value is used as the summary embedding vector to represent the semantic summary of its adjacent subgraphs.

[0125] That is, for a boundary node V, let its neighbor set across the subgraph be N. CROSS (v) is:

[0126] N CROSS (v) = {u∈V|(v,u)∈E}

[0127] Its summary embedding vector is then defined as the average of the embedding vectors of all cross-graph neighbors.

[0128]

[0129] Among them, h u Represents the set of neighbors across the subgraph N CROSS The node embedding vector of the u-th node in (v).

[0130] Furthermore, the summary embedding vector can be fused with the node's own node embedding vector to enhance its contextual semantic awareness. Specifically, the fusion method utilizes a multilayer perceptron (MLP) feedforward neural network structure. The concatenated vector is input into the MLP network for nonlinear mapping, resulting in a fused embedding vector. It can be represented as:

[0131]

[0132] Statistical characteristics of edge distribution: Extracting structural summary from a structural perspective.

[0133]

[0134] in, This represents the number of connected edges, also known as the cross-graph degree, which is the number of edges that the node connects to other subgraphs.

[0135] μw This represents the mean;

[0136] σ w Indicates standard deviation;

[0137] P v To represent the distribution vector of the connected target subgraphs, we need to categorize all connecting edges according to the target subgraph number, count the frequency of connecting edges in each target subgraph, and obtain a vector P of length K. v , where the j-th vector p v (j) is:

[0138]

[0139] Edge weight statistics: The mean and standard deviation of the connected edges can be further calculated to reflect the stability of the connection strength;

[0140] mean μ w It can be represented as:

[0141]

[0142] Among them, w vu This represents the initial weight of the edge. If the edge has no weight, it is uniformly recorded as 1.

[0143] Standard deviation σ w It can be represented as:

[0144]

[0145] Furthermore, for the above four structural summaries, a feedforward neural network structure can also be used for nonlinear combination and compression.

[0146] In a preferred embodiment, such as Figure 4 As shown, the steps for generating compensation information include:

[0147] Step B1: Filter key edges;

[0148] Step B2: For each key edge, calculate the statistical feature vector of the key edge, and use the statistical feature vector of the high-confidence connection pair as compensation information.

[0149] Specifically, in the compensation feature injection mechanism of this embodiment, key edges are first screened. Key edges can be screened by four selectable methods: path importance score (such as PageRank (PR) value, shortest path influence), neighbor node co-occurrence frequency, or structural coupling degree.

[0150] These key edges are not explicitly defined in the graph structure, but are embedded into the model as compensating inputs using the statistical features of high-confidence connection pairs. This process is similar to the "stitching" reinforcement structure in fabric, restoring the key semantic chains without breaking the structural closure, and significantly enhancing the model's robustness to dummy edges and miscut edges.

[0151] Specifically, the PageRank algorithm is a common path evaluation method used to assess the probability of a node being visited in a graph. In this embodiment of the invention, the algorithm can be executed directly by calling libraries such as NetworkX to obtain the PageRank value.

[0152] The shortest path impact is also a common method. Edge importance can be determined by verifying whether deleting an edge leads to the breakage of multiple shortest paths. For example, if deleting an edge causes multiple shortest path breaks, it indicates that the edge is important for connecting critical paths. For instance, one could enumerate edges (u, v), temporarily delete an edge, and count the changes in the shortest path between any pair of nodes in the original graph and after the deletion (whether it becomes longer or unreachable). The "number of broken shortest paths" can then be used as a measure of importance. In this embodiment of the invention, the shortest path impact can be obtained by calling the `nx.edge_betweenness_centrality(G)` function.

[0153] The co-occurrence frequency of neighboring nodes refers to the frequency at which two nodes frequently appear together in higher-order structures (such as triangles, four-membered rings, etc.), indicating a possible semantic correlation. This embodiment of the invention directly calls relevant libraries for implementation, for example:

[0154] from networkx.algorithms import triangles

[0155] co_occurrence_score[(u,v)]=len(set(G.neighbors(u))&set(G.neighbors(v))).

[0156] Structural coupling is the structural similarity between nodes u and v, commonly measured by Jaccard similarity or Adamic-Adar Index.

[0157] from networkx.algorithms.link_prediction import jaccard_coefficient

[0158] pred = list(jaccard_coefficient(G)) # Returns (u, v, score)

[0159] The statistical features of high-confidence connection pairs are used as compensation inputs to the model. That is, these compensation edges are not directly added to the graph structure, but rather injected into the model training as auxiliary semantic features, serving as an enhancement and supplement to semantic edge locking. For each key edge (u,v), its statistical feature vector f is calculated. uv Then, it is merged into the representation of the endpoint node:

[0160] f uv =[PR u PR v [Co-occurrence frequency, coupling degree, whether it is a critical edge of the path];

[0161] Among them, PR u Represents the PR value of the u-th key edge; PR v This represents the PR value of the v-th key edge.

[0162] Finally, the final feature representation can be obtained.

[0163]

[0164] Where, x u The initial feature vector of node u is represented; KeyEdges represents the set of key edges associated with node u; avg (u,v)∈KeyEdges f uv The feature f represents all key edges (u,v) of node u. uv Take the average.

[0165] When encountering data structure poisoning attacks requiring the deletion of related data, or receiving privacy / outdated deletions or mislabeling corrections, the system can quickly locate the subgraph to which these elements belong based on the received set of nodes, edges, or entities to be deleted, using either initial graph partitioning or real-time embedding and remapping. It can then locally retrain or prune the model corresponding to that subgraph to obtain new submodel prediction results. Other aggregation algorithms and steps passed to the large language model remain unchanged, avoiding the high computational cost and time consumption of full graph retraining.

[0166] Users only need to provide the specific entity identifier to be deleted, such as node ID or entity name. Then, based on the partitioning result storage table, the subgraph number to which the node or edge belongs can be obtained through a basic lookup table method such as node_id --> partition_id.

[0167] In a preferred embodiment, where the node included in the local change request is a boundary node, step S3 further includes:

[0168] Regenerate summary and compensation information, and retrain the sub-model corresponding to the boundary node adjacency subgraph to obtain a new sub-model.

[0169] Specifically, when performing local updates on a sub-model, it is necessary to remove the relevant nodes or edges, reconstruct the local structure, and then retrain the model corresponding to that subgraph. If summarization or compensation features are involved, only difference updates need to be performed, without global propagation, reducing unnecessary computation and time costs.

[0170] Reconstructing the local structure and retraining essentially involves updating all relevant computational processes of the modified subgraph. The specific steps are as follows:

[0171] First, perform the deletion operation on the node or edge. If the deleted node is a boundary node, the summary vector needs to be recalculated. Since changes to boundary nodes alter their connection structure and semantic information with their adjacent subgraphs, the summary vector needs to be updated to reflect these changes.

[0172] More specifically, considering that the existence of isolated nodes may affect the local connectivity and semantic integrity of the subgraph, thereby adversely affecting the training and prediction of the model, in this embodiment, if the deletion of edges included in the local change request results in isolated nodes, the isolated nodes are directly removed, and a new submodel is retrained to ensure the local connectivity and semantic integrity of the subgraph and improve the performance of the model.

[0173] If a boundary node changes, such as when a cross-graph edge it connects to is deleted, its summary embedding and structural distribution statistics need to be regenerated. After updating through an MLP feedforward network, the context vector is regenerated.

[0174] If the deletion operation affects the critical path or highly coupled edges, it is necessary to recalculate the path importance score (such as PageRank value, shortest path influence), neighbor node co-occurrence frequency, or structural coupling degree, and update the corresponding statistical feature vector f. uv And merge it into the endpoint representation.

[0175] It's important to note that all local changes only affect the model within the corresponding subgraph; other aggregation mechanisms and language generation processes remain unchanged. Instead of retraining the entire graph, the sub-model is reinitialized and trained within that subgraph, which reduces computational cost and time consumption while maintaining model performance.

[0176] In a preferred embodiment, such as Figure 5 As shown, it also includes:

[0177] S201, Based on the input query request, retrieve several subgraphs related to the query request and obtain the prediction results of the sub-models corresponding to the several subgraphs;

[0178] S202, integrate the obtained prediction results to obtain the integrated result;

[0179] S203, the integrated results are transmitted to the large language model, which uses the integrated results as pre-prompt words and outputs a natural language answer to the query request.

[0180] Specifically, in the question-answering reasoning stage of the large language model, after receiving the user's query request, subgraph localization techniques, including but not limited to keyword matching, entity embedding retrieval, and topic semantic similarity analysis, are used to select the most relevant subgraphs from among many subgraphs.

[0181] Then, the sub-model corresponding to each retrieved subgraph is invoked. These sub-models will perform diverse inference tasks for the query, such as entity classification, relationship identification, and path prediction. During the inference process, each sub-model is ensured to independently output its local inference results to guarantee the objectivity and accuracy of the results.

[0182] Next, an aggregation algorithm is used to summarize the prediction results of all sub-models to obtain the integrated result. Common aggregation algorithms include weighted average, voting mechanism, and optimal aggregator. The weighted average algorithm can assign different weights to sub-models based on their importance or reliability, thus integrating the results more reasonably; the voting mechanism determines the final result by majority vote based on the frequency of occurrence of each sub-model's prediction results; the optimal aggregator can select the most appropriate aggregation method according to specific circumstances.

[0183] Finally, the integrated results are passed as a prompt to the large language model, which uses the integrated results as external knowledge support to output a credible and structure-aware natural language response.

[0184] The embodiments of this invention realize modular management of graphs, dividing large graphs into multiple subgraphs or submodules, enabling graph neural networks to be trained and updated independently at the local subgraph level, significantly reducing computational costs and maintenance complexity; it also improves the local updability and response efficiency of the system. When a node in a subgraph is determined to be poisoned or contains privacy information, only the model corresponding to that subgraph needs to be retrained, without the need for full graph retraining, supporting flexible, safe and efficient local repair.

[0185] Compared to traditional knowledge distillation methods, this invention enhances system security while preserving the reasoning capabilities of graph structures. By fusing and aggregating multiple subgraph models, it achieves comprehensive modeling and result enhancement of the semantics of the entire graph, thereby improving the robustness and accuracy of the question-answering system when faced with harmful information.

[0186] The embodiments of the present invention can avoid repeated fine-tuning of large models, reduce the burden on language models, complete isolation and repair operations at the graph structure level, eliminate the need for frequent modification of large language model parameters, and improve the overall maintenance efficiency and reliability of the system.

[0187] In a preferred embodiment of the present invention, a non-invasive, graph-structure-oriented poisoning patching system for repairing large language models is also provided, for implementing the graph-structure-oriented poisoning patching system for repairing large language models as described above. Figure 6 As shown, the system includes:

[0188] Graph partitioning module 1 is used to partition the original graph into multiple subgraphs. Each subgraph contains multiple nodes, including boundary nodes and non-boundary nodes. Boundary nodes have summary information and compensation information. The summary information is the structural features of the connecting nodes in the subgraphs adjacent to the boundary nodes, and the compensation information is the statistical features of the key association edges.

[0189] Subgraph model training module 2, connected to graph partitioning module 1, is used to independently train graph neural network models for each subgraph. During the training process, the summary information of boundary nodes is used as contextual cues, and the compensation information is used as auxiliary semantic features to generate multiple autonomously updatable submodels.

[0190] Update module 3 connects to subgraph model training module 2. When a local change request is received, it modifies the subgraph corresponding to the subgraph based on the nodes / edges contained in the local change request to obtain a new subgraph.

[0191] Specifically, traditional data poisoning prevention methods often rely on full-graph retraining or fine-tuning of large language models, resulting in huge computational resource consumption, low update efficiency, and difficulty in quickly responding to privacy deletion and mislabeling correction needs, thus limiting the promotion of large-scale graph applications. Furthermore, existing subgraph partitioning methods often only focus on subgraph partitioning, neglecting the semantic fragmentation caused by cross-subgraph structural breaks. The severing of connections between subgraphs leads to the loss of semantic information, affecting the accuracy and robustness of the model's overall inference, making the model prone to errors when processing complex graph data.

[0192] To address the aforementioned problems, the present invention proposes a non-intrusive, graph-structure-based large language model repair method and system, which can efficiently and reliably handle graph structure poisoning and privacy deletion issues. The key innovations of this method and system are mainly reflected in the following aspects:

[0193] A constrained balanced graph partitioning method based on node embedding: This method uses node embedding technology to introduce constraints, achieving balanced partitioning of graph data according to structure and semantics. Since retraining is only required on the affected subgraphs, without reprocessing the entire graph, and the size of each subgraph is balanced with the model complexity, the scale of a single retraining iteration is significantly reduced. Simultaneously, the reduced retraining scale also improves update efficiency, enabling the system to adapt to changes in graph data more quickly.

[0194] A non-intrusive cross-graph repair mechanism based on woven edges: This mechanism employs a woven approach, effectively mitigating the structural fragmentation caused by graph partitioning through semantic edge locking (using summary edges) and compensatory feature injection. Semantic edge locking extracts summary information from adjacent subgraphs, providing contextual cues and ensuring semantic continuity between subgraphs. Compensatory feature injection selects key edges and embeds their statistical features as compensation input into the model, enhancing its defense against dummy edges and incorrectly cut edges. This non-intrusive repair mechanism does not disrupt the original structure of the subgraphs while maintaining semantic continuity across subgraphs, thus improving the overall performance of the model.

[0195] Subgraph Model Autonomous Training and Local Incremental Update Mechanism: This mechanism enables retraining of the model only in the affected subgraphs, without requiring full graph reconstruction. When graph data changes, the system can quickly locate the affected subgraphs and retrain the models for those subgraphs. This local incremental update approach significantly improves the system's response speed and resource utilization, as only a portion of the subgraphs needs to be processed, rather than retraining the entire graph. Simultaneously, this mechanism better meets the needs for privacy deletion and mislabeling correction, enabling the system to respond quickly to data changes.

[0196] A multi-sub-model structured aggregation and large language model-assisted reasoning framework: This framework integrates the reasoning results of multiple sub-graphs and utilizes a large language model to generate high-quality, semantically consistent natural language answers. Multi-sub-model structured aggregation summarizes and integrates the reasoning results of multiple sub-models to obtain more accurate and comprehensive reasoning results. The large language model serves as an auxiliary reasoning tool, leveraging its powerful language generation capabilities to transform the reasoning results into natural language answers. This framework balances the interpretability and reasoning ability of the models, enabling the system to not only provide accurate reasoning results but also offer easily understandable explanations in natural language.

[0197] The above are merely preferred embodiments of the present invention and are not intended to limit the implementation methods and protection scope of the present invention. Those skilled in the art should recognize that any equivalent substitutions and obvious changes made using the content of this specification and illustrations should be included within the protection scope of the present invention.

Claims

1. A non-intrusive, graph-structure-oriented method for repairing large language models through patching, characterized in that... include: Step S1: Divide the original graph into multiple subgraphs. Each subgraph contains multiple nodes, including boundary nodes and non-boundary nodes. Boundary nodes have summary information and compensation information. The summary information is the structural features of the connecting nodes in the subgraphs adjacent to the boundary nodes, and the compensation information is the statistical features of key association edges. Step S2: Train a graph neural network model independently for each subgraph. During the training process, use the summary information of the boundary nodes as contextual cues and the compensation information as auxiliary semantic features to generate multiple autonomously updatable submodels. Step S3: Upon receiving a local change request, modify the sub-model corresponding to the subgraph according to the nodes / edges included in the local change request to obtain a new sub-model.

2. The non-intrusive, graph-structure-oriented large language model repair method based on patching, as described in claim 1, is characterized in that... Step S1, before dividing the original map, includes: Step S10: Embedding modeling is performed on each node in the original graph, and a node embedding vector space is generated based on node attribute features and local adjacency structure features.

3. The non-intrusive, graph-structure-oriented large language model repair method based on patching, as described in claim 2, is characterized in that... In step S1, the original graph is divided according to the node embedding vectors in the node embedding vector space to form the multiple subgraphs.

4. The non-intrusive, graph-structure-oriented large language model repair method based on patching, as described in claim 2, is characterized in that... The node attribute features are the static information of the node, and the static information includes at least one of text content, tag category and type identifier; The local adjacency structure feature is the local topological structure information of the node in the original graph, and the local topological structure information includes at least one of adjacency distribution, path information, and subgraph structure.

5. The non-intrusive, graph-structure-oriented large language model repair method based on patching, as described in claim 1, is characterized in that... The partitioning is implemented using a constrained K-Means embedding clustering algorithm, and step S1 includes: Step S11: Randomly initialize K cluster centers of the original map, where K is a positive integer greater than 1; Step S12: Based on the subgraph size balance constraint, the cross-subgraph edge minimization constraint, and the subgraph connectivity and semantic integrity constraint, construct the cost function: in, Indicates node embedding Z i With its cluster center The squared Euclidean distance between them, where i represents a node and v represents the total number of nodes; Indicates the current number of cluster nodes The square of the difference between the proportion of the total number of nodes v in the original graph and the reciprocal of the number of clusters, 1 / K. ∑ j∈N(i) 1[c i ≠c j [] represents the number of nodes in different clusters for two adjacent nodes, j represents the node, and c i c represents the cluster to which node i belongs. j Let N(i) represent the cluster to which node j belongs, and let N(i) represent the set of neighboring nodes of node i. φ(i,c i ) represents semantic connectivity constraints. This indicates the number of a node's neighbors that are assigned to the same cluster. Entropy representing the label information of a cluster; λ1, λ2, and λ3 represent the weights, respectively; Step S13: Perform node iteration, calculate the total loss cost of each node, assign the node to the cluster with the minimum total loss cost, and update the centroid of each cluster iteratively to the average embedding vector of the cluster member nodes. Step S14: Repeat step S13 until the node partitioning no longer changes or the set number of iterations is reached, then stop the iteration.

6. The non-intrusive, graph-structure-oriented, non-invasive large language model repair method according to claim 1, characterized in that, The steps for generating the summary information include: Step A1: For each subgraph, identify the boundary nodes of the subgraph; Step A2: For each boundary node in the subgraph, identify the connecting nodes that are connected to the boundary node and belong to the adjacent subgraph, and obtain the cross-subgraph neighbor set; Step A3: Extract summary information based on all connected nodes in the cross-subgraph neighbor set. The summary information includes one or more combinations of the following: the embedding mean of connected nodes, the distribution statistics of connected edges, the mean of connected edges, and the standard deviation of connected edges.

7. The non-intrusive, graph-structure-oriented, non-invasive large language model repair method according to claim 1, characterized in that, The steps for generating the compensation information include: Step B1: Filter key edges; Step B2: For each key edge, calculate the statistical feature vector of the key edge, and use the statistical feature vector of the high-confidence connection pair as the compensation information.

8. The non-intrusive, graph-structure-oriented large language model repair method based on patching, as described in claim 1, is characterized in that... When the local change request includes a boundary node, step S3 further includes: Regenerate summary and compensation information, and retrain the sub-model corresponding to the boundary node adjacency subgraph to obtain a new sub-model.

9. The non-intrusive, graph-structure-oriented, non-invasive large language model repair method according to claim 1, characterized in that, Also includes: Based on the input query request, retrieve several subgraphs related to the query request and obtain the prediction results of the sub-models corresponding to the several subgraphs; The obtained prediction results are integrated to obtain an integrated result; The integrated result is transmitted to a large language model, which uses the integrated result as a pre-prompt word to output a natural language answer to the query request.

10. A non-invasive, graph-structure-oriented, patch-based large language model repair system, characterized in that, The system is used to implement the non-intrusive, graph-structure-oriented poisoning method for repairing large language models as described in any one of claims 1-9, and comprises: The graph partitioning module is used to partition the original graph into multiple subgraphs. Each subgraph contains multiple nodes, including boundary nodes and non-boundary nodes. The boundary nodes have summary information and compensation information. The summary information is the structural features of the connecting nodes in the subgraphs adjacent to the boundary nodes, and the compensation information is the statistical features of key association edges. The subgraph model training module, connected to the graph partitioning module, is used to independently train a graph neural network model for each subgraph. During the training process, the summary information of the boundary nodes is used as contextual cues, and the compensation information is used as auxiliary semantic features to generate multiple autonomously updatable submodels. The update module, connected to the subgraph model training module, is used to modify the subgraph corresponding to the subgraph based on the nodes / edges contained in the local change request when a local change request is received, so as to obtain a new subgraph.