A double matching dynamic knowledge planning method and device for content security detection
Patent Information
- Application Number
- CN202511567787.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-30
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2045-10-30
AI Technical Summary
大语言模型在内容安全多跳推理中存在固有缺陷,其因果关系建模能力薄弱,难以基于 “特征提取 - 规则匹配 - 处置决策” 的深层因果链条进行准确推理,且长距离推理稳定性不足,易出现逻辑断层,同时其源于非结构化文本的内容安全知识存在信息过时、标注错误等可靠性风险
[0007]上述一种用于内容安全检测的双匹配动态知识规划方法及装置,首先获取包含主题实体集的数据集,并将自然语言问题解析为初始思维链,构建包含节点和有向边的图结构,通过知识图谱本体兼容的节点集合与图结构有向边,为推理提供了结构化基础,确保思维链的实体与图谱实体类型一致,避免了语义歧义。其次,利用预训练语言模型对齐思维链与知识图谱,通过筛选实体类型一致的节点映射形成子图,构建语义匹配二部图并借助匈牙利算法求解最大权匹配,既校验了推理步骤在图谱中的结构支撑,又通过语义相似度匹配解决了自然语言表述多样性与图谱预定义关系的鸿沟,修正了跨域实体歧义与隐含关系缺失。最后,基于精炼子图和问题构建提示修正思维链,补充缺失关系边并纠正实体关系错误,有效避免了大模型生成思维链时与图谱结构脱节的子目标幻觉问题,使推理路径既符合安全逻辑又具备图谱结构化支撑,从而提升了复杂多跳推理的连贯性与可靠性,最终提内容安全检测的准确率。
Smart Images

Figure CN122734091B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a dual-matching dynamic knowledge planning method and apparatus for content security detection. Background Technology
[0002] In the field of content security detection, the application of complex multi-hop inference technology faces numerous technical challenges. Large language models have inherent limitations in multi-hop inference for content security. Their causal relationship modeling capabilities are weak, making accurate inference based on deep causal chains of "feature extraction - rule matching - decision-making" difficult. Furthermore, their long-distance inference stability is insufficient, prone to logical breaks. Additionally, content security knowledge derived from unstructured text carries reliability risks such as outdated information and incorrect labeling. A semantic mapping gap exists between knowledge graphs and natural language. The diversity of security concept expressions leads to discrepancies between natural language and graph-specific entities, such as the difference between "phishing link" and "malicious URL." Difficulties in cross-modal knowledge integration make inference paths prone to breakage, and lagging dynamic security rule updates also affect detection accuracy. When multi-hop inference frameworks are implemented in corresponding scenarios, sub-objective planning is often disconnected from security logic, failing to verify path feasibility using rule knowledge bases. The lack of cross-step evidence chain verification affects diagnostic transparency, and the explosion of inference chains for complex content leads to low decision-making efficiency.
[0003] However, existing content security detection methods have significant flaws in the planning stage: over-reliance on large language models to generate thought chains leads to a disconnect between reasoning steps and the graph structure, resulting in the illusion of sub-targets that cannot be implemented. Specifically, this manifests as a semantic mapping gap between the diversity of conceptual expressions in natural language and the predefined entity types and relational paths in the graph; thought chains generated by large language models may contain unexecutable steps. Furthermore, the cross-step connection of multi-hop reasoning chains relies on explicit or implicit path support in the graph. If the large language model only derives sub-target sequences based on linguistic logic without verifying the structural feasibility of the graph, it may lead to breaks in the reasoning chain. This disconnect between semantics and structure is amplified layer by layer in complex reasoning with more than three hops, ultimately causing the illusion of sub-targets. Essentially, this is an inherent contradiction between the flexibility of natural language reasoning and the rigidity of graph structural constraints. Therefore, bridging the gap between natural language semantics and knowledge graph structure, and achieving dynamic synergy between semantic understanding and graph structural constraints, becomes crucial for improving the coherence and reliability of content security detection reasoning. Summary of the Invention
[0004] Therefore, it is necessary to provide a dual-matching dynamic knowledge planning method and apparatus for content security detection that can improve the accuracy of content security detection, in order to address the above-mentioned technical problems.
[0005] A dual-matching dynamic knowledge programming method for content security detection, the method comprising: Acquire content security detection natural language questions and datasets; the dataset includes a set of topic entities for content security detection natural language questions; the topic entity set includes entities for inappropriate content types, detection features, processing rules, and handling measures. The content security detection natural language problem is parsed into an initial thought chain containing entity relationships; key entities are extracted from the initial thought chain to form a node set compatible with the knowledge graph ontology; the semantic associations and reasoning logic in the initial thought chain are transformed into directed edges in the graph structure, and the thought chain is constructed based on the node set and directed edges. The thought chain and knowledge graph are aligned using a pre-trained language model to obtain an alignment table; node mappings that satisfy entity type consistency are selected from the alignment table to obtain a subgraph. Construct a bipartite graph for semantic matching of the graph and the thought chain based on the alignment table and subgraph; use the Hungarian algorithm to solve the maximum weight matching of the bipartite graph for semantic matching of the graph and the thought chain; traverse the relation edges in the thought chain one by one based on the maximum weight matching to determine the missing relation edges; The subgraph is refined using maximum weight matching to obtain a refined subgraph. Based on content security detection of natural language issues, the current thought chain, and the refined subgraph, the thought chain is modified with the goal of supplementing missing edges and correcting entity relationship errors to obtain a modified thought chain. The content security detection result is output based on the modified thought chain.
[0006] A dual-matching dynamic knowledge planning device for content security detection, the device comprising: The data acquisition module is used to acquire natural language questions and datasets for content security detection. The dataset includes a set of topic entities for natural language questions for content security detection. The set of topic entities includes entities for inappropriate content types, detection features, processing rules, and handling measures. The Mind Chain Construction Module is used to parse natural language questions for content security detection into an initial mind chain containing entity relationships; extract key entities from the initial mind chain to form a node set compatible with the knowledge graph ontology; transform the semantic associations and reasoning logic in the initial mind chain into directed edges in the graph structure, and construct the mind chain based on the node set and directed edges. The subgraph construction module is used to align the thought chain and knowledge graph using a pre-trained language model to obtain an alignment table; from the alignment table, node mappings that satisfy entity type consistency are selected to obtain the subgraph. The module for determining missing edges is used to construct a bipartite graph for semantic matching of the graph and the thought chain based on the alignment table and the subgraph; it uses the Hungarian algorithm to solve the maximum weight matching of the bipartite graph for semantic matching of the graph and the thought chain; and it traverses the relation edges in the thought chain one by one based on the maximum weight matching to determine the missing edges. The content security detection module is used to refine the subgraph using maximum weight matching to obtain a refined subgraph; based on the content security detection natural language problem, the current thought chain, and the refined subgraph, it constructs prompts to correct the thought chain with the goal of supplementing missing edges and correcting entity relationship errors, resulting in a corrected thought chain; and outputs the content security detection result based on the corrected thought chain.
[0007] The aforementioned dual-matching dynamic knowledge planning method and apparatus for content security detection first acquires a dataset containing a set of topic entities and parses the natural language problem into an initial thought chain, constructing a graph structure containing nodes and directed edges. Through a knowledge graph ontology-compatible node set and directed edges in the graph structure, a structured foundation for reasoning is provided, ensuring that the entities in the thought chain are consistent with the entity types in the graph, thus avoiding semantic ambiguity. Secondly, a pre-trained language model is used to align the thought chain with the knowledge graph. By selecting nodes with consistent entity types, a subgraph is formed, constructing a semantic matching bipartite graph and using the Hungarian algorithm to solve for maximum weight matching. This verifies the structural support of the reasoning steps in the graph and, through semantic similarity matching, bridges the gap between the diversity of natural language expressions and the predefined relationships in the graph, correcting cross-domain entity ambiguity and the lack of implicit relationships. Finally, based on the refined subgraph and the question-based construct prompts, the thought chain is corrected, missing relation edges are supplemented, and entity relation errors are corrected. This effectively avoids the sub-target illusion problem that occurs when the large model generates a thought chain that is disconnected from the graph structure. This ensures that the reasoning path conforms to security logic and has graph structure support, thereby improving the coherence and reliability of complex multi-hop reasoning and ultimately improving the accuracy of content security detection. Attached Figure Description
[0008] Figure 1 This is a flowchart illustrating a dual-matching dynamic knowledge planning method for content security detection in one embodiment. Figure 2 This is a structural block diagram of a dual-matching dynamic knowledge planning device for content security detection in one embodiment; Figure 3 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0009] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0010] In one embodiment, such as Figure 1 As shown, a dual-matching dynamic knowledge programming method for content security detection is provided, including the following steps: Step 102: Obtain the content security detection natural language questions and dataset; the dataset includes a set of subject entities for the content security detection natural language questions; the set of subject entities includes entities for inappropriate content types, detection features, processing rules, and handling measures.
[0011] The subject entity set includes entities such as malicious content types, detection features, processing rules, and handling measures. This ensures that key information extracted from natural language questions, such as "spam," "contains fraudulent links," and "blocking," accurately corresponds to core elements in the content security domain. This avoids inference biases caused by entity omissions, such as ignoring the impact of "file format spoofing" on "virus detection." By labeling entity types in the dataset and using a link security knowledge base, ambiguous expressions in natural language—such as "black links"—are mapped to standardized terms like "malicious redirect links." This reduces entity linking errors caused by conceptual ambiguity and provides standardized input for subsequent inference.
[0012] Step 104: Parse the natural language problem of content security detection into an initial thought chain containing entity relationships; extract key entities from the initial thought chain to form a node set compatible with the knowledge graph ontology; transform the semantic associations and reasoning logic in the initial thought chain into directed edges in the graph structure, and construct the thought chain based on the node set and directed edges.
[0013] The initial thought chain generation is a fundamental step in the dual-matching dynamic knowledge planning mechanism. Natural language problems are parsed into an initial thought chain of entity-relationship: political remarks → containing sensitive topics → need to be intercepted. By clarifying the reasoning logic through directed edges, the model is forced to explicitly express the causal chain, thus solving the problem of long-distance dependency breakage when large models implicitly reason.
[0014] The core objective of node extraction is to identify and extract key entities from the natural language thought chain, forming a node set compatible with the knowledge graph ontology. Specifically, node extraction requires extracting all relevant entities from the textual description of the initial thought chain, including source entities explicitly mentioned in the question and intermediate entities implicit in the reasoning process. Source entities directly correspond to the core semantic objects of the question, while intermediate entities serve as logical bridges connecting multi-hop reasoning; together, they constitute the nodes of a complete reasoning path. The extracted entities are then organized into node sets. This approach transforms the semantic connections and reasoning logic within the natural language thought chain into directed edges in a graph structure, explicitly modeling the relationships between entities and the dependencies between reasoning steps. Specifically, edge construction requires identifying two types of edges from the initial textual description of the thought chain: explicit dependency edges, which directly correspond to clear statements of relationships between entities within the thought chain steps; and logical step edges, representing sequential dependencies between reasoning steps. The result of edge construction is the formation of an edge set. Each edge carries a relational semantic description in natural language.
[0015] The node design is compatible with the knowledge graph ontology, ensuring structural feasibility. Extracted key entities must conform to the knowledge graph ontology. For example, malicious URLs must be mapped to the category of inappropriate content in the graph to avoid generating non-executable steps that do not conform to the graph structure constraints, such as skipping feature comparison and directly intercepting. This prevents the illusion of sub-targets from the source.
[0016] The results of node extraction and edge construction are integrated into a complete structured graph model to explicitly represent the semantic connections and reasoning logic of natural language thought chains. Specifically, the graph structure definition combines node sets. and edge set Form a mind map The output of the graph structure definition serves as a structured mapping for natural language reasoning, providing query templates for entity-relation alignment with knowledge graph subgraphs in the subsequent "long-chain structure matching" stage. It also lays the foundation for calibrating the differences between natural language representations and graph structures in the "semantic-structural bidirectional iterative correction" stage. Through this process of semantic explicitation to structural template-based processing, a crucial transformation from fuzzy language logic to a computable graph model is achieved. During graph modeling, the system ensures the compatibility of nodes with the knowledge graph ontology through entity type verification and matches natural language relations in the thought chain to standard relations in the graph through relation mapping rules. Furthermore, for implicit relations, the system generates a candidate relation list through a multi-model approach and matches the closest predefined relation in the graph based on semantic similarity, ensuring that each step of the thought chain can be mapped to structured operations in the graph.
[0017] Step 106: Align the thought chain and knowledge graph using a pre-trained language model to obtain an alignment table; select node mappings that satisfy entity type consistency from the alignment table to obtain a subgraph.
[0018] The system aligns entities in the thought chain with entities in the knowledge graph based on semantic similarity, and simultaneously matches relations in the thought chain with relations in the knowledge graph, generating an alignment table to record candidate graph entities and relations for each thought chain entity and relation. This process is achieved by using a pre-trained language model to calculate the semantic similarity between the thought chain and the knowledge graph, ensuring that each entity and relation in the thought chain can find its semantically closest corresponding entity and relation in the knowledge graph. With map entities Alignment is performed, and the relationships in the thought chain are matched with the relationships in the graph to generate an alignment table. To record candidate graph entities / relationships for each thought chain entity / relationship, where, Represents entities in the thought chain. This represents entities stored in an external knowledge graph. This represents the relationship between linked entities in a thought chain. This represents the relationships between connected entities stored in the external knowledge graph. Based on the generated alignment table, node mappings that satisfy entity type consistency are selected one by one. This step ensures that the entity types in the thought chain match the corresponding entity types in the graph, avoiding reasoning errors caused by type inconsistencies. For each node in the thought chain, the system searches the graph for a corresponding relationship path, verifying whether the reasoning steps have structural support in the graph to ensure the feasibility and coherence of the reasoning path. This step is implemented using a subgraph isomorphism algorithm, detecting whether there is a matching subgraph structure for the nodes and relationships in the thought chain in the graph, identifying the specific location and connection method of the entities and relationships at each step of the reasoning chain in the graph. Specifically, for nodes in the thought chain... Search the graph for the existence of relationship paths. Finally, output the subgraph obtained from the matching. And the parts that exist in the thought chain but are missing in the graph .
[0019] Specifically, the pre-trained language model calculates natural language entities in the thought chain through semantic similarity. For example, it establishes a mapping between vulgar text and the standard entity "vulgar content" in the graph, resolving cross-modal semantic conflicts between different spellings of synonyms, such as the cross-modal semantic conflict between phishing websites and fraudulent URLs, ensuring semantic consistency of inference nodes. It selects node mappings with consistent entity types from the alignment table; for example, entities of the "detection feature" class can only match feature nodes in the graph, avoiding incorrectly associating malicious code with response measure nodes, reducing noise interference during graph retrieval, and improving the accuracy of subsequent subgraph construction.
[0020] Step 108: Construct a bipartite graph for semantic matching of the graph and the thought chain based on the alignment table and the subgraph; use the Hungarian algorithm to solve for the maximum weight matching of the bipartite graph for semantic matching of the graph and the thought chain; and traverse the relation edges in the thought chain one by one based on the maximum weight matching to determine the missing relation edges.
[0021] Based on the resulting alignment table and subgraph Constructing a bipartite graph for semantic matching of the graph and thought chain The left side represents the thought chain entity, and the right side represents the graph candidate entity, with edge weights. The cosine similarity is calculated by embedding pre-trained language models of entities. Specifically, each entity in the thought chain and each candidate entity in the graph are first encoded as vector representations. A pre-trained language model (such as DistilBERT) is then used to semantically embed the entities, generating representations in a high-dimensional vector space. These vectors capture the semantic features of the entities, making semantically similar entities closer in the vector space. Then, the cosine similarity between the thought chain entities and the graph candidate entities is calculated as the edge weight. Cosine similarity measures the directional consistency of two vectors in the semantic space by calculating the cosine of the angle between them, with a value ranging from -1 to 1; a higher value indicates a stronger semantic match. This method quantifies the semantic similarity between thought chain entities and graph entities, providing a basis for subsequent matching. The maximum weight matching of the bipartite graph is then solved using the Hungarian algorithm. This ensures that each entity in the thought chain corresponds to the most semantically relevant unique entity in the graph, effectively correcting cross-domain entity ambiguity. This maximum-weight matching strategy not only improves the accuracy of entity alignment but also ensures the coherence and reliability of the inference chain. Furthermore, to further optimize the matching results, the system introduces a dynamic adjustment mechanism. During the matching process, the strictness and flexibility of the matching are dynamically adjusted based on the structural characteristics of the thought chain and the graph, as well as the specific needs of the inference task. Specifically, a semantic matching bipartite graph of the graph and the thought chain is constructed, and the maximum-weight matching is solved using the Hungarian algorithm, such as assigning higher weights to "feature-rule" relationships, and quantitatively evaluating the feasibility of each inference edge in the graph.
[0022] Based on the already confirmed entity pairs The system iterates through the relationship edges in the thought chain one by one. Check in the graph and Does a semantic compatibility relationship exist between them? If a direct correspondence exists, then... Mark as a valid relation; if it does not exist but a semantically similar relation exists, record as a potential substitutable relation; if it is completely missing, mark as a missing relation edge. This process is incorporated into subsequent correction procedures. Through explicit verification of relationship paths, this ensures that each step in the reasoning chain has semantic equivalence or deducible evidence in the graph, avoiding logical gaps. Specifically, when traversing the thought chain relationship edges, the maximum weight matching result identifies relationship edges that do not exist in the graph. For example, if "Content A → Distribution Channel" has no direct path in the graph, the model is forced to supplement intermediate reasoning steps, such as "Content A → Encrypted Transmission → Onion Routing → Distribution Channel." This solves the problem of reasoning chain gaps in traditional methods, making multi-hop reasoning more consistent with security logic.
[0023] Step 110: Refine the subgraph using maximum weight matching to obtain a refined subgraph; Based on content security detection of natural language issues, the current thought chain, and the refined subgraph construction prompts, modify the thought chain with the goal of supplementing missing relationship edges and correcting entity relationship errors to obtain a modified thought chain; Output the detection results based on the modified thought chain.
[0024] First, retain the maximum weight matching. All entities involved are semantically most relevant to the entities in the thought chain, providing the most reliable foundation for subsequent reasoning. Next, the k-hop neighbors of these entities in the knowledge graph and their associated relationships are extracted, forming a preliminary refined subgraph. Here, k-hop neighbors refer to entities in the knowledge graph that are directly connected (1 hop) to the core entity or indirectly connected through k-step relationships. In this way, the system can construct a preliminary refined subgraph containing information about the core entity and its surrounding relationships, ensuring the coherence and completeness of the reasoning chain. Subsequently, based on the relationships contained in the thought chain... Further pruning involves removing edges and connected entities from the initially refined subgraph that do not match the thought chain relationships. The core of this process is ensuring that every edge in the subgraph has a corresponding semantic basis in the thought chain, thereby improving the subgraph's relevance and effectiveness. To avoid information loss due to overly strict relationship matching, the system constructs relationship aliases and a thesaurus to broaden the matching scope. This means the system integrates relationships with the same or similar semantics but different expressions from the knowledge graph, ultimately retaining the final set of entities. Relation set and the corresponding set of triples Forming a refined subgraph The refined subgraph not only includes entities and relationships closely related to the current reasoning task, but also clarifies the specific connections between these entities through triples. This structured representation clearly demonstrates the hierarchical relationships and logical connections between entities in the knowledge graph, providing a concise and complete knowledge framework for subsequent reasoning. Through this series of operations, the dual-matching dynamic knowledge planning mechanism can effectively extract the most relevant parts to complex multi-hop question-answering tasks from a large-scale knowledge graph, providing a solid foundation for accurate and efficient reasoning while reducing computational complexity and improving system efficiency. Specifically, by refining the subgraph using the maximum weight matching result, redundant nodes in the graph that do not match the semantics of the thought chain are removed, such as the "video decoding" node unrelated to "text security," reducing the reasoning chain explosion problem in complex content and improving decision-making efficiency.
[0025] Finally, the thought chain is iteratively revised using a large model, based on the original question Q, and the current thought chain... and the coded refined subgraph The system constructs prompts to correct the thought chain by filling in missing relationship steps and correcting entity relationship errors. For example, prompts are constructed based on refined subgraphs and questions, such as "Please fill in the relationship edge of 'malware → file signature → feature library'". This guides the model to correct entity relationship errors, such as correcting the incorrect relationship "intercept → review" to "review → intercept". Through bidirectional calibration of "structural constraints + semantic feedback", the system ensures that the final thought chain conforms to both the graph structure and the security detection logic, thereby improving the accuracy and interpretability of the detection.
[0026] The aforementioned dual-matching dynamic knowledge planning method for content security detection first acquires a dataset containing a set of topic entities and parses the natural language problem into an initial thought chain, constructing a graph structure containing nodes and directed edges. By using a knowledge graph ontology-compatible node set and directed edges in the graph structure, a structured foundation for reasoning is provided, ensuring that the entities in the thought chain are consistent with the entity types in the graph, thus avoiding semantic ambiguity. Secondly, a pre-trained language model is used to align the thought chain with the knowledge graph. By selecting nodes with consistent entity types and mapping them to form a subgraph, a semantic matching bipartite graph is constructed, and the Hungarian algorithm is used to solve for the maximum weight matching. This not only verifies the structural support of the reasoning steps in the graph but also bridges the gap between the diversity of natural language expressions and the predefined relationships in the graph through semantic similarity matching, correcting cross-domain entity ambiguity and the lack of implicit relationships. Finally, based on the refined subgraph and the question-based construct prompts, the thought chain is corrected, missing relation edges are supplemented, and entity relation errors are corrected. This effectively avoids the problem of sub-target illusion that is disconnected from the graph structure when the large model generates the thought chain. This ensures that the reasoning path is both in line with security logic and has graph structure support, thereby improving the coherence and reliability of complex multi-hop reasoning and ultimately improving the accuracy of content security detection.
[0027] In one embodiment, the content security detection problem is resolved into an initial thought chain containing entity relationships, including: The content security detection natural language question and the corresponding topic entity set in the dataset are input into the large language model. The model is then guided by prompting engineering to generate an initial thought chain in natural language format. Each step Includes explicit or implicit relationships between entity pairs.
[0028] In one embodiment, key entities are extracted from the initial thought chain to form a node set compatible with the knowledge graph ontology, including: Extract all relevant entities from the textual description of the initial thought chain, including source entities explicitly mentioned in the question and intermediate entities implicit in the reasoning process. Source entities directly correspond to the core semantic objects of the question, while intermediate entities serve as logical bridges connecting multi-hop reasoning; together, they constitute the nodes of a complete reasoning path. The extracted entities are then organized into node sets. .
[0029] In one embodiment, the semantic associations and reasoning logic in the initial thought chain are transformed into directed edges in a graph structure, including: Two types of edges are identified from the textual description of the initial thought chain: first, explicit dependency edges, which directly correspond to the explicit relationship between entities within the thought chain steps; and second, logical step edges (such as "detection feature extraction → rule matching → disposal decision"), which represent the sequential dependency relationship between reasoning steps. Construct an edge set based on explicit dependency edges and logical step edges. Each edge in the edge set carries a relational semantic description in natural language.
[0030] In one embodiment, a pre-trained language model is used to align the thought chain and the knowledge graph to obtain an alignment table, including: The semantic similarity between the thought chain and the knowledge graph is calculated using a pre-trained language model, and the entities in the thought chain are then grouped based on this semantic similarity. With map entities Alignment is performed, and the relationships in the thought chain are matched with the relationships in the graph to generate an alignment table. To record candidate graph entities or relations for each thought chain entity or relation, where, Represents entities in the thought chain. This represents entities stored in an external knowledge graph. This represents the relationship between linked entities in a thought chain. This represents the relationships between connected entities stored in an external knowledge graph. (Through "...)" (Entity alignment) (Relationship Alignment), generate alignment table. This addresses the disconnect between the thought chain and the graph structure.
[0031] In one embodiment, node mappings that satisfy entity type consistency are filtered from the alignment table to obtain a subgraph, including: The subgraph isomorphism algorithm is used to detect whether there is a matching subgraph structure in the graph for the nodes and relationships in the thought chain. Search the graph for the existence of relationship paths. Output the subgraph obtained from the matching. And the parts that exist in the thought chain but are missing in the graph .
[0032] In one embodiment, determining missing edges in the thought chain by traversing each relation edge according to the maximum weight matching includes: Based on maximum weight matching Traverse the relation edges in the thought chain one by one Check in the graph and Does a semantic compatibility relationship exist between them? If a direct correspondence exists, then... Mark as a valid relation; if it does not exist but a semantically similar relation exists, record as a potential substitutable relation; if it is completely missing, mark as a missing relation edge. It will be included in the subsequent revision process.
[0033] In one embodiment, the subgraph is refined using maximum weight matching to obtain a refined subgraph, including: Preserve the maximum weight matching For all entities involved, extract the k-hop neighbors of each entity in the knowledge graph and their related relationships to form a preliminary refined subgraph; Based on the relationships contained in the mind chain Further pruning is performed on the preliminary refined subgraph to remove edges and their connected entities that do not match the thought chain relationship, resulting in a refined subgraph. The refined subgraph includes a set of entities, a set of relationships, and a set of corresponding triples.
[0034] In one embodiment, the thought chain is modified based on content security detection issues, the current thought chain, and refined subgraph construction hints, with the goal of supplementing missing relationship edges and correcting entity relationship errors, resulting in a modified thought chain, including: The thought chain is iteratively revised using a large model, based on the natural language question Q for content security detection, to determine the current thought chain. and refined sub-graphs The system constructs prompts to correct missing edges and entity relationship errors in the thought chain. The iterative process continues until all entity-relation pairs are matched with the knowledge graph or the prescribed number of iterations is reached, resulting in the corrected thought chain.
[0035] It should be understood that, although Figure 1 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise explicitly stated in this document, there is no strict order in which these steps are executed, and they can be performed in other orders. Furthermore, Figure 1At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.
[0036] In one embodiment, such as Figure 2 As shown, a dual-matching dynamic knowledge planning device for content security detection is provided, comprising: a data acquisition module 202, a thought chain construction module 204, a subgraph construction module 206, a relationship missing edge determination module 208, and a content security detection module 210, wherein: Data acquisition module 202 is used to acquire content security natural language issues and datasets; the dataset includes a set of topic entities for content security natural language issues; the set of topic entities includes entities for inappropriate content types, detection features, processing rules, and handling measures. The Mind Chain Construction Module 204 is used to parse the natural language problem of content security detection into an initial mind chain containing entity relationships; extract key entities from the initial mind chain to form a node set compatible with the knowledge graph ontology; transform the semantic associations and reasoning logic in the initial mind chain into directed edges in the graph structure, and construct the mind chain based on the node set and directed edges. The subgraph construction module 206 is used to align the thought chain and knowledge graph using a pre-trained language model to obtain an alignment table; and to select node mappings that satisfy entity type consistency from the alignment table to obtain a subgraph. The module 208 for determining missing edges is used to construct a bipartite graph for semantic matching of the graph and the thought chain based on the alignment table and the subgraph; to solve the maximum weight matching of the bipartite graph for semantic matching of the graph and the thought chain using the Hungarian algorithm; and to determine missing edges by traversing the edges in the thought chain one by one based on the maximum weight matching. The content security detection module 210 is used to refine the subgraph using maximum weight matching to obtain a refined subgraph; based on the content security detection natural language problem, the current thought chain and the refined subgraph, it constructs prompts to correct the thought chain with the goal of supplementing missing edges of relations and correcting errors in entity relations, to obtain a corrected thought chain; and outputs the detection results based on the corrected thought chain.
[0037] Specific limitations regarding the dual-matching dynamic knowledge planning device for content security detection can be found in the limitations of the dual-matching dynamic knowledge planning method for content security detection described above, and will not be repeated here. Each module in the aforementioned dual-matching dynamic knowledge planning device for content security detection can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0038] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 3 As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external terminals via a network connection. When executed by the processor, the computer program implements a dual-matching dynamic knowledge planning method for content security detection. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.
[0039] Those skilled in the art will understand that Figure 3 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0040] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0041] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0042] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these modifications and improvements all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A dual-matching dynamic knowledge programming method for content security detection, characterized in that, The method includes: Acquire content security detection natural language questions and datasets; the dataset includes a set of topic entities for content security detection natural language questions; the set of topic entities includes entities for inappropriate content types, detection features, processing rules, and handling measures. The content security detection natural language problem is parsed into an initial thought chain containing entity relationships; key entities are extracted from the initial thought chain to form a node set compatible with the knowledge graph ontology; the semantic associations and reasoning logic in the initial thought chain are transformed into directed edges in the graph structure, and the thought chain is constructed based on the node set and the directed edges. The thought chain and knowledge graph are aligned using a pre-trained language model to obtain an alignment table; node mappings that satisfy entity type consistency are selected from the alignment table to obtain a subgraph. Construct a bipartite graph for semantic matching of the graph and the thought chain based on the alignment table and the subgraph; use the Hungarian algorithm to solve for the maximum weight matching of the bipartite graph for semantic matching of the graph and the thought chain; traverse the relation edges in the thought chain one by one according to the maximum weight matching to determine the missing relation edges; The subgraph is refined using the maximum weight matching method to obtain a refined subgraph. Based on content security detection of natural language issues, the current thought chain, and the refined subgraph construction prompts, the thought chain is corrected with the goal of supplementing missing relationship edges and correcting entity relationship errors to obtain a corrected thought chain. The content security detection result is output based on the corrected thought chain.
2. The method according to claim 1, characterized in that, The content security natural language problem is analyzed as an initial thought chain containing entity relationships, including: The content security natural language problem is input into a large language model along with the corresponding topic entity set in the dataset. Then, prompting engineering guides the model to generate an initial thought chain in natural language format. Each step Includes explicit or implicit relationships between entity pairs.
3. The method according to claim 1, characterized in that, Key entities are extracted from the initial thought chain to form a node set compatible with the knowledge graph ontology, including: Extract all relevant entities from the textual description of the initial thought chain, including source entities explicitly mentioned in the question and intermediate entities implicit in the reasoning process. Source entities directly correspond to the core semantic objects of the question, while intermediate entities serve as logical bridges connecting multi-hop reasoning; together, they constitute the nodes of a complete reasoning path. The extracted entities are then organized into node sets. .
4. The method according to claim 1, characterized in that, The semantic connections and reasoning logic in the initial thought chain are transformed into directed edges in a graph structure, including: Two types of edges are identified from the textual description of the initial thought chain: first, explicit dependency edges, which directly correspond to the explicit relationship between entities within the thought chain steps; and second, logical step edges, which represent the sequential dependency relationship between reasoning steps. Construct an edge set based on the explicit dependency edges and logical step edges. Each edge in the edge set carries a relational semantic description in natural language.
5. The method according to claim 1, characterized in that, The thought chain and knowledge graph are aligned using a pre-trained language model to obtain an alignment table, including: The semantic similarity between the thought chain and the knowledge graph is calculated using a pre-trained language model, and the entities in the thought chain are then grouped based on this semantic similarity. With map entities Alignment is performed, and the relationships in the thought chain are matched with the relationships in the graph to generate an alignment table. To record candidate graph entities / relationships for each thought chain entity / relationship, where, Represents entities in the thought chain. This represents entities stored in an external knowledge graph. This represents the relationship between linked entities in a thought chain. It represents the relationships between connected entities stored in an external knowledge graph.
6. The method according to claim 1, characterized in that, Node mappings that satisfy entity type consistency are selected from the alignment table to obtain a subgraph, including: The subgraph isomorphism algorithm is used to detect whether there is a matching subgraph structure in the graph for the nodes and relationships in the thought chain. Search the graph for the existence of relationship paths. Output the subgraph obtained from the matching. And the parts that exist in the thought chain but are missing in the graph .
7. The method according to claim 1, characterized in that, Based on the maximum weight matching, the missing edges in the thought chain are determined one by one, including: Based on maximum weight matching Traverse the relation edges in the thought chain one by one Check in the graph and Does a semantic compatibility relationship exist between them? If a direct correspondence exists, then... Mark as a valid relation; if it does not exist but a semantically similar relation exists, record as a potential substitutable relation; if it is completely missing, mark as a missing relation edge. It will be included in the subsequent revision process.
8. The method according to claim 1, characterized in that, The subgraph is refined using the maximum weight matching method to obtain a refined subgraph, including: Preserve the maximum weight matching For all entities involved, extract the k-hop neighbors of each entity in the knowledge graph and their related relationships to form a preliminary refined subgraph; Based on the relationships contained in the mind chain Further pruning is performed on the preliminary refined subgraph to remove edges and their connected entities that do not match the thought chain relationship in the preliminary refined subgraph, resulting in a refined subgraph; the refined subgraph includes a set of entities, a set of relationships, and a set of corresponding triples.
9. The method according to claim 1, characterized in that, Based on content security detection of natural language issues, the current thought chain, and refined subgraph construction hints, the thought chain is revised with the goal of supplementing missing edges and correcting entity relationship errors, resulting in a revised thought chain, including: The thought chain is iteratively revised using a large model, based on the natural language question Q for content security detection, to determine the current thought chain. and refined sub-graphs The system constructs prompts to correct missing edges and entity relationship errors in the thought chain. The iterative process continues until all entity-relation pairs are matched with the knowledge graph or the prescribed number of iterations is reached, resulting in the corrected thought chain.
10. A dual-matching dynamic knowledge planning device for content security detection, characterized in that, The device includes: The data acquisition module is used to acquire natural language questions and datasets for content security detection; the dataset includes a set of topic entities for natural language questions for content security detection; the set of topic entities includes entities for inappropriate content types, detection features, processing rules, and handling measures. The thought chain construction module is used to parse the natural language problem of content security detection into an initial thought chain containing entity relationships; extract key entities from the initial thought chain to form a node set compatible with the knowledge graph ontology; transform the semantic associations and reasoning logic in the initial thought chain into directed edges in the graph structure, and construct the thought chain based on the node set and the directed edges. The subgraph construction module is used to align the thought chain and knowledge graph using a pre-trained language model to obtain an alignment table; and to select node mappings that satisfy entity type consistency from the alignment table to obtain a subgraph. The module for determining missing edges is used to construct a bipartite graph for semantic matching of the graph and the thought chain based on the alignment table and the subgraph; use the Hungarian algorithm to solve the maximum weight matching of the bipartite graph for semantic matching of the graph and the thought chain; and traverse the edges in the thought chain one by one based on the maximum weight matching to determine the missing edges. The content security detection module is used to refine the subgraph using the maximum weight matching to obtain a refined subgraph; based on the content security detection natural language problem, the current thought chain, and the refined subgraph, it constructs prompts to correct the thought chain with the goal of supplementing missing relationship edges and correcting entity relationship errors, to obtain a corrected thought chain; and outputs the content security detection result based on the corrected thought chain.
Citation Information
Patent Citations
Multi-round dialogue processing method and system based on RAG and knowledge graph
CN118885627A
Security information retrieval reasoning method, device and equipment and storage medium
CN120278284A