Community boundary awareness path segmentation and large language model comparative training method and system
Patent Information
- Application Number
- CN202611090202.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-22
- Publication Date
- 2026-10-09
AI Technical Summary
该方法通过社区感知正负样本构造,提高对比学习样本质量,减少训练噪声,能够识别图路径中的跨社区语义转移,解决整条路径直接建模导致的语义不连续,以及弥补图路径线性化过程中边语义丢失等问题,大大提升图数据分析系统在分类、聚类、检索、推荐和关系挖掘任务中的效果
[0065]本发明与现有技术相比具有以下有益的技术效果和显著的技术进步:
Smart Images

Figure CN122886707A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of graph machine learning and natural language processing, specifically to a method and system for comparing community boundary-aware path segmentation with large language models for text attribute graphs. Background Technology
[0002] Text attribute graphs are widely found in real-world production environments, such as paper citation networks, product recommendation networks, user social networks, web link networks, enterprise knowledge graphs, and transaction relationship networks. In this type of graph data, nodes typically contain text attributes, and edges represent citations, links, interactions, transactions, or associations between nodes. How to simultaneously utilize the semantic meaning of node text and the structural relationships within the graph is a crucial issue in graph intelligent analysis systems.
[0003] Existing methods typically employ graph neural networks, random walks, path sampling, or graph contrastive learning for graph representation learning. With the development of large language models, some methods also convert node text and path structures in the graph into natural language sequences before using language models for modeling. However, existing methods often treat the entire path as a continuous semantic sequence, ignoring semantic mutations that occur when the path crosses different communities. Furthermore, during path textification, edge relationships are often simplified to connection symbols, resulting in a loss of specific semantic relationships between nodes. In addition, traditional contrastive learning methods for constructing positive and negative samples are relatively coarse, easily introducing spurious positive or negative samples, affecting model training performance and downstream task performance.
[0004] In summary, existing graph language models struggle to identify semantic abrupt changes in cross-community paths, semantic loss of edge relationships after path linearization, inaccurate construction of positive and negative samples, and insufficient model awareness of graph structure. Therefore, a graph language model training method is needed that can identify community boundaries in graph paths, enhance edge relationship semantics, and construct high-quality training samples to improve the classification, clustering, retrieval, and recommendation performance of text attribute graphs in real-world business scenarios. Summary of the Invention
[0005] The purpose of this invention is to address the shortcomings of existing technologies by providing a community boundary-aware path segmentation and large language model comparative training method and system. This method employs a graph language model training approach that constructs high-quality training samples. By combining the semantic understanding capabilities of the large language model with the graph structure modeling capabilities, it identifies community boundaries in graph paths and enhances edge relation semantics, thereby improving the classification, clustering, retrieval, and recommendation performance of text attribute graphs in real-world business scenarios. This method improves the quality of comparative learning samples and reduces training noise through the construction of community-aware positive and negative samples. It can identify cross-community semantic transfers in graph paths, solve the semantic discontinuity caused by directly modeling the entire path, and compensate for edge semantic loss during graph path linearization. This significantly improves the performance of graph data analysis systems in classification, clustering, retrieval, recommendation, and relation mining tasks.
[0006] This invention can serve as a core algorithm module in graph intelligence analysis platforms, knowledge graph platforms, recommendation systems, intelligent risk control systems, academic retrieval systems, and enterprise relationship analysis systems. Large language model calls can employ offline inference, result caching, and lightweight model deployment methods, reducing online service costs and making it suitable for integration into enterprise internal data platforms or industry solutions. It is particularly applicable to tasks such as node classification, node clustering, community discovery, graph retrieval, recommendation systems, and text attribute graph analysis. It is adaptable to various types of text attribute graphs, including academic networks, web networks, product networks, user networks, and enterprise knowledge graphs, and possesses strong commercial promotion value.
[0007] The specific technical solution to achieve the purpose of this invention is: a method for comparing and training community boundary-aware path segmentation with a large language model, characterized by the following steps:
[0008] (I) Semantic and structural encoding
[0009] Step 1-1: Generation of Node Semantic Representations
[0010] Obtain the node text and edge connection relationships in the text attribute graph, and generate node semantic representations using the text encoding model or large language model embedding module.
[0011] Steps 1-2: Community Construction and Anchor Point Selection
[0012] Let the text attribute graph be ,in For a set of nodes, Let be the set of edges. For any node, it is a collection of node text attributes. The node semantic representation shown in the following formula is obtained through the text encoding model. :
[0013] .
[0014] in, Represents a node semantic embedding, For the embedding dimension. The text encoding model can be a large language model embedding module, a pre-trained text representation model, or other semantic encoding models.
[0015] semantic representation of nodes Clustering is performed to obtain multiple semantic communities. For any community... The community center is calculated using the following formula:
[0016] .
[0017] Select the node closest to the community center as the anchor node for that community:
[0018] .
[0019] The anchor nodes selected using the above method can represent the main semantic regions of the corresponding community, thereby improving the coverage and stability of subsequent path sampling. (Based on node semantic representation) Clustering is performed to obtain multiple candidate semantic communities. In each semantic community, the node closest to the community center is selected as the anchor node for subsequent path construction.
[0020] (II) Path Construction and Enhancement
[0021] Step 2-1: Construction of Path Candidate Set
[0022] From each community anchor node Starting from the given point, calculate the shortest path to other reachable nodes in the graph, forming a path candidate set:
[0023] .
[0024] in, This is a set of anchor nodes; in actual deployment, the maximum path length can be set. Only retain lengths not exceeding The path is determined to control computational costs.
[0025] Step 2-2: Path diversity calculation and screening
[0026] The discreteness of the semantic representation of each node in the calculation path is used to obtain the path diversity score. Low diversity paths and high diversity paths are selected based on the path diversity score. The low diversity paths are used to represent semantic continuity relationships within a community, and the high diversity paths are used to represent semantic transfer relationships that may cross communities.
[0027] The path diversity score Calculated by the following formula:
[0028] .
[0029] in, For path The Middle The semantic representation vector of each node. As the center of the semantic representation of nodes within the path, for the path The center of the semantic representation of a node within a path is calculated using the following formula:
[0030] .
[0031] in, For path The number of nodes contained in the path, i.e., the path length.
[0032] When the path diversity score is low, it indicates that the semantics of the nodes within the path are relatively concentrated, and it can be used as a candidate path within the community; when the path diversity score is high, it indicates that the path may cross multiple semantic communities, and it can be used as a candidate path across communities.
[0033] Steps 2-3: Path semantic verification and semantic boundary segmentation
[0034] For low-diversity paths, the text of each node in the path is input into the large language model in sequence. The large language model outputs a judgment result on whether the path belongs to the same topic. If the output result is consistent with the topic, the path is retained; otherwise, the path is filtered. For high-diversity paths, the text of each node in the path is input into the large language model in the original path order. The large language model identifies the semantic transition positions and outputs several continuous sub-paths representing semantic boundary segments, as shown in the following formula. :
[0035] .
[0036] Each sub-path The internal semantics remain consistent, and the order of nodes in each sub-path remains unchanged from the original path.
[0037] Steps 2-4: Edge Relation Interpretation and Generation
[0038] Based on the low diversity of paths and semantic boundary segmentation of path semantic verification, for adjacent nodes in the path, generate edge relationship explanation text to describe the reasons for reference, link, association or semantic connection between the nodes based on the text content of the two nodes.
[0039] Steps 2-5: Enhance path text construction
[0040] For subpaths and adjacent nodes Generate edge relation explanations based on node text and edge relation explanation text. The node text and edge interpretations are then concatenated alternately to obtain the enhanced path text represented by the following formula:
[0041] .
[0042] in," The "" symbol is used as a separator, and this representation allows the model to simultaneously obtain node semantics and edge relation semantics.
[0043] (III) Comparative Learning and Training
[0044] Step 3-1: Construction of positive and negative community-aware samples
[0045] Sub-paths with semantically consistent characteristics in low-diversity paths are constructed as positive samples within the community, while sub-paths that cross semantic boundaries in high-diversity paths are constructed as negative samples between communities. Simultaneously, difficult positive samples sharing start, end, or boundary nodes, as well as intra-batch negative samples, are introduced to enhance the training signal. Specifically, this includes:
[0046] 1) For a training sample The first sub-path of the semantically validated low-diversity path is selected as the query sample. Select another sub-path within the same path as the main positive sample. At the same time, it will be with Low-diversity sub-paths sharing a start point, end point, or boundary node are considered as difficult positive samples. .
[0047] 2) For negative samples, select those that are similar to... Sub-paths with the same starting point but originating from the ends of highly diverse paths are considered cross-community negative samples. ;
[0048] 3) Select low-diversity sub-paths connected to the endpoints of cross-community paths as difficult negative samples. ;
[0049] 4) Other sub-paths in the same batch can be used as negative samples within the batch.
[0050] Step 3-2: Contrastive Learning Training with Confidence Mask Based on the similarity relationship between query sub-paths and candidate samples, a confidence mask mechanism is introduced to suppress possible pseudo-positive and pseudo-negative samples. An objective function is applied to ensure that semantically continuous sub-paths within a community are represented as close to each other, while semantically dissimilar sub-paths across communities are represented as far apart. Specifically, this includes:
[0051] 1) Let The cosine similarity between two sub-path representations is denoted as . Indicates the temperature coefficient. This represents the confidence threshold for negative samples. The confidence mask is defined by the following formula. :
[0052] .
[0053] 2) For hard positive samples, the positive sample mask is defined by the following formula. :
[0054] .
[0055] 3) Positive sample items It can be expressed as follows:
[0056] .
[0057] 4) Negative sample items The weighted sum of cross-community negative samples, hard negative samples, and intra-batch negative samples is expressed by the following formula:
[0058] .
[0059] 5) The constructed positive, negative, and difficult samples are used to perform comparative learning training on the large language model to obtain a graph structure-aware representation model. The objective of the comparative learning training is the objective function shown in the following formula. :
[0060] .
[0061] Step 3-3: Output of graph structure-aware representation
[0062] The node text, edge relationships, and path text sequence constructed by the above steps in the attribute graph of the text to be processed are input into the graph structure-aware representation model to obtain a node representation vector that integrates text semantic information and graph structure information. The node representation vector can be used for downstream tasks such as node classification, node clustering, community detection, graph retrieval, recommendation ranking, or relationship mining.
[0063] A community boundary-aware path segmentation and large language model comparison training system is characterized by its architecture, which comprises a data input layer, a graph structure and semantic processing layer, a path and edge semantic refinement layer, a comparison training layer, and a business application layer. Each functional layer collaboratively completes text attribute graph input, path construction, semantic segmentation, edge relationship enhancement, model training, and downstream business applications. The data input layer accepts text attribute graph data including node text and edge connection relationships. The graph structure and semantic processing layer is configured with a node representation generation module, a community construction module, and a path construction module. The path and edge semantic refinement layer is configured with a path filtering and segmentation module and an edge semantic enhancement module. The comparison training layer is configured with a sample construction module and a model training module. The business application layer includes business application modules for classification, clustering, recommendation, retrieval, risk control, and knowledge discovery.
[0064] The node representation generation module receives text attribute graph data and generates node semantic embedding representations. The community construction module performs clustering based on node embeddings to form candidate semantic communities and selects community anchor nodes. The path construction module generates a candidate set of paths starting from the anchor nodes, covering intra-community paths and cross-community paths. The path filtering and segmentation module calculates path diversity scores and calls a large language model to complete path semantic consistency verification and semantic boundary segmentation. The edge semantic enhancement module generates edge relationship interpretations based on adjacent node texts and forms structure-enhanced path texts. The sample construction module generates positive samples within communities, negative samples between communities, difficult positive samples, difficult negative samples, and intra-batch negative samples. The model training module fine-tunes the language model based on a contrastive learning objective with a confidence mask to obtain a graph structure-aware representation. The business application module inputs the trained representations into business systems such as node classification, clustering, recommendation, retrieval, risk control, or knowledge discovery.
[0065] Compared with the prior art, the present invention has the following beneficial technical effects and significant technical progress:
[0066] 1) It can identify cross-community semantic transfers in graph paths, solving the semantic discontinuity problem caused by directly modeling the entire path;
[0067] 2) Enhance path text through edge relation interpretation to compensate for the loss of edge semantics during graph path linearization;
[0068] 3) By constructing positive and negative samples based on community perception, the quality of contrastive learning samples is improved and training noise is reduced;
[0069] 4) Reduce the impact of false positive and false negative samples through a confidence mask mechanism to improve model training stability;
[0070] 5) Offline preprocessing and caching mechanisms can be adopted to reduce the cost of calling large language models and facilitate deployment in production systems;
[0071] 6) It can be adapted to various types of text attribute graphs such as academic networks, web networks, product networks, user networks, and enterprise knowledge graphs, and has strong commercial promotion value. Attached Figure Description
[0072] Figure 1 This is a flowchart of Example 1;
[0073] Figure 2 This is a schematic diagram of the layered architecture and system of Example 2; Detailed Implementation
[0074] In one embodiment of this invention, the input data is a paper citation network, where each node represents a paper, the node text includes the title and abstract, and edges represent citation relationships between papers. The system first uses a text encoding model to generate semantic embeddings for each paper, and then performs clustering based on the embedding results to obtain multiple candidate communities related to research topics. In a specific implementation, the node text can be generated using a pre-trained text embedding model to generate node semantic representations; path semantic verification, path segmentation, and edge relationship interpretation can be performed offline by a locally deployed large language model. The inference results of the aforementioned large language model can be cached and reused during model training and downstream task inference, thereby reducing online call costs and meeting the needs of batch graph data processing in production environments.
[0075] Subsequently, the system selects representative papers as anchor nodes in each community and generates a shortest path candidate set from these anchor nodes. For each path, the system calculates the discreteness of node embeddings within the path to obtain a path diversity score. Low-diversity paths typically represent paper paths within the same research direction, while high-diversity paths typically represent paper citation paths across research directions. For low-diversity paths, the system uses a large language model to determine whether the papers in the path belong to the same topic; if there are significantly inconsistent papers in the path, the path is filtered out. For high-diversity paths, the system uses a large language model to analyze topic changes in paper titles and abstracts, identify locations where semantic shifts occur in the path, and segment the path into multiple semantically consistent continuous sub-paths. In the path text construction stage, the system generates citation relationship explanations based on the titles and abstracts of adjacent papers, such as the reasons for the connection between two papers in terms of research questions, methods, or application scenarios. Subsequently, the paper texts and citation relationship explanations are concatenated in the path order to form enhanced path text, enabling the language model to simultaneously understand node content and edge relationship semantics. During the training phase, the system treats semantically consistent sub-paths within a community as positive samples and semantically transferred sub-paths across communities as negative samples, introducing difficult positive samples, difficult negative samples, and intra-batch negative samples. The system further sets a confidence mask based on sample similarity relationships to reduce the impact of noisy samples on training. Finally, through contrastive learning, the language model is fine-tuned to achieve a representation capability more suitable for graph structure tasks.
[0076] In another implementation, the input data can be an e-commerce recommendation network, where nodes represent users, products, stores, or content, and edges represent clicks, purchases, favorites, browsing, or similarity relationships. This invention can be used to generate more accurate user and product representations, improving recommendation recall, ranking, and similar product retrieval performance.
[0077] In another implementation, the input data can be a corporate relationship graph, where nodes represent companies, individuals, products, or events, and edges represent investments, transactions, collaborations, control, or affiliations. This invention can be used to identify community structures and cross-community risk propagation paths within corporate relationship networks, thereby serving intelligent risk control, business intelligence analysis, and knowledge discovery systems.
[0078] This invention is applicable to production systems that require processing large-scale text attribute graphs. By combining the semantic understanding capabilities of a large language model with graph structure modeling capabilities, this invention improves the performance of graph data analysis systems in tasks such as classification, clustering, retrieval, recommendation, and relationship mining. In terms of commercial application, this invention can serve as a core algorithm module in graph intelligent analysis platforms, knowledge graph platforms, recommendation systems, intelligent risk control systems, academic retrieval systems, and enterprise relationship analysis systems. Its large language model can be invoked using offline inference, result caching, and lightweight model deployment methods, reducing online service costs and making it suitable for integration into enterprise internal data platforms or industry solutions.
[0079] The specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
[0080] Example 1
[0081] See Figure 1 This includes the following steps:
[0082] Step 1: Generation of Node Semantic Representations
[0083] Obtain the node text and edge connection relationships in the text attribute graph, and generate node semantic representations using the text encoding model or large language model embedding module.
[0084] Step 2: Community Construction and Anchor Point Selection 1) Cluster based on node semantic representation to obtain multiple candidate semantic communities. In each semantic community, select the node that is closer to the community center as the anchor node for subsequent path construction.
[0085] Let the text attribute graph be , in For a set of nodes, Let be the set of edges. This is the collection of text attributes for a node. The semantic representation of a node is obtained through a text encoding model, as shown in the following formula:
[0086] .
[0087] in, Represents a node semantic embedding, For the embedded dimension.
[0088] The text encoding model can be a large language model embedding module, a pre-trained text representation model, or other semantic encoding models.
[0089] 2) Cluster the semantic representations of the nodes to obtain multiple semantic communities. For any community... Calculate its community center:
[0090] .
[0091] 3) Select the node closest to the community center as the anchor node for that community, expressed by the following formula:
[0092] .
[0093] The anchor nodes selected in the above manner can represent the main semantic regions of the corresponding community, which can be used to improve the coverage and stability of subsequent path sampling.
[0094] Step 3: Path candidate set generation from each community anchor node Starting from the given point, calculate the shortest path to other reachable nodes in the graph, forming a path candidate set:
[0095]
[0096] in, This is a set of anchor nodes. In actual deployment, the maximum path length can be set. Only retain lengths not exceeding The path is determined to control computational costs.
[0097] Step 4: Path diversity calculation and screening
[0098] The discreteness of the semantic representation of each node in the path is calculated to obtain the path diversity score. Low diversity paths and high diversity paths are selected based on the path diversity score. Low diversity paths are used to represent semantic continuity within the community, while high diversity paths are used to represent semantic transfer relationships that may cross communities.
[0099] For path First, the center of the semantic representation of the nodes within the path is calculated using the following formula:
[0100] .
[0101] The path diversity score is then calculated using the following formula:
[0102] .
[0103] When the path diversity score is low, it indicates that the semantics of the nodes within the path are relatively concentrated, and it can be used as a candidate path within the community; when the path diversity score is high, it indicates that the path may cross multiple semantic communities, and it can be used as a candidate path across communities.
[0104] Step 5: Path semantic verification and semantic boundary segmentation.
[0105] For low-diversity paths, the text of each node in the path is input into the large language model in sequence. The large language model outputs a judgment result on whether the path belongs to the same topic. If the output result indicates a consistent topic, the path is retained; otherwise, the path is filtered. For high-diversity paths, the text of each node in the path is input into the large language model in the original path order. The large language model identifies semantic transition positions and outputs several continuous sub-paths represented by the following formula:
[0106] .
[0107] Each sub-path The internal semantics remain consistent, and the order of nodes in each sub-path remains unchanged from the original path.
[0108] Step 6: Edge Relation Semantic Enhancement
[0109] For adjacent nodes in the path, edge relationship explanation text is generated based on the text content of the two nodes to describe the reasons for the reference, link, association or semantic connection between the nodes; the node text and edge relationship explanation are alternately spliced in the path order to form a structurally enhanced path text.
[0110] For subpaths For adjacent nodes Generate an explanation of the edge relationship based on the text content of the two. Then, the node text and edge interpretations are concatenated alternately to obtain the enhanced path text:
[0111]
[0112] in," The separator is ".". This representation allows the model to simultaneously obtain node semantics and edge relation semantics.
[0113] Step 7: Community-aware positive and negative sample construction. Sub-paths with semantic consistency in low-diversity paths are constructed as positive samples within the community, and sub-paths that cross semantic boundaries in high-diversity paths are constructed as negative samples between communities. At the same time, difficult positive samples with shared start, end or boundary nodes, as well as negative samples within the batch, are introduced to enhance the training signal.
[0114] For a training sample The first sub-path of the semantically validated low-diversity path is selected as the query sample. Select another sub-path within the same path as the main positive sample. At the same time, it will be with Low-diversity sub-paths sharing a start point, end point, or boundary node are considered as difficult positive samples. .
[0115] For negative samples, select and Sub-paths with the same starting point but originating from the ends of highly diverse paths are considered cross-community negative samples. Low-diversity sub-paths connected to endpoints of cross-community paths are selected as difficult negative samples. In addition, other sub-paths within the same batch can be used as negative samples within the batch.
[0116] Step 8: Comparative learning training with confidence mask
[0117] Based on the similarity relationship between query sub-paths and candidate samples, a confidence mask mechanism is introduced to suppress possible pseudo-positive and pseudo-negative samples. By comparing the learning objectives, the language model is fine-tuned to make path representations within a community closer to each other and path representations across communities further apart.
[0118] set up The cosine similarity between two sub-path representations is denoted as . Indicates the temperature coefficient. This represents the confidence threshold for negative samples. The confidence mask is defined by the following formula:
[0119] .
[0120] For difficult positive samples, the positive sample mask is defined by the following formula:
[0121] .
[0122] The positive sample term is expressed by the following formula:
[0123] .
[0124] The negative sample term can be expressed as a weighted sum of cross-community negative samples, hard negative samples, and intra-batch negative samples:
[0125] .
[0126] The final training objective is the objective function shown in the following formula:
[0127] .
[0128] The objective function aims to make semantically continuous sub-paths within a community closer to each other, while making semantically dissimilar sub-paths across communities further apart.
[0129] Step 9: Graph Structure Aware Representation Output. Input the node text, edge relationships, and path text sequence constructed in the above steps from the attribute graph of the text to be processed into the graph structure awareness representation model to obtain a node representation vector that integrates text semantic information and graph structure information. The node representation vector can be used for downstream tasks such as node classification, node clustering, community detection, graph retrieval, recommendation ranking, or relationship mining.
[0130] The performance verification results of the above embodiments in node classification and node clustering tasks are detailed in Table 1 below:
[0131] Table 1. Results of performance verification in node classification and node clustering tasks.
[0132]
[0133] The experimental results above demonstrate that this invention exhibits superior technical performance in both node classification and node clustering tasks. In node classification, the invention achieves an overall average ranking of 1.33 across nine real-world text attribute graph datasets, with optimal results on six datasets and top-two rankings on all datasets. Compared to schemes using only language model node embedding, this invention improves average accuracy by approximately 2.96 percentage points. In node clustering, across nine datasets, three evaluation metrics, and a total of 27 evaluation results, this invention achieves optimal results on 23 out of 27 metrics, and second-best results on the remaining four out of 27 metrics, indicating that this invention effectively enhances the model's ability to characterize community structure and semantic boundaries.
[0134] The ablation experiment results of the key modules of this invention are detailed in Table 2 below:
[0135] Table 2 Ablation Experiment Results of the Module
[0136]
[0137] Table 2 above shows the changes in node classification accuracy compared to the complete method. CiteSeer is a paper citation network dataset, where nodes represent academic papers and edges represent citation relationships between papers; Texas is a university webpage link network dataset, where nodes represent webpages and edges represent hyperlink relationships between webpages. The results show that path segmentation, anchor point selection, and confidence masks all improve model representation quality, with path segmentation having the most significant impact on performance, indicating that this invention has practical effectiveness in modeling cross-community semantic boundaries.
[0138] The above results demonstrate that path segmentation, anchor point selection, and confidence masking can all improve the model representation quality, with path segmentation having the most significant impact on performance, indicating that the present invention has practical effects on modeling cross-community semantic boundaries.
[0139] Example 2
[0140] See Figure 2 The system of this invention includes: a data input layer, a graph structure and semantic processing layer, a path and edge semantic refinement layer, a contrastive training layer, and a business application layer. Each layer collaborates to complete text attribute graph input, path construction, semantic segmentation, edge relationship enhancement, model training, and downstream business applications. The data input layer accepts text attribute graph data including node text and edge connection relationships. The graph structure and semantic processing layer is configured with a node representation generation module, a community construction module, and a path construction module. The path and edge semantic refinement layer is configured with a path filtering and segmentation module and an edge semantic enhancement module. The contrastive training layer is configured with a sample construction module and a model training module. The business application layer is configured with business application modules including: classification, clustering, recommendation, retrieval, risk control, and knowledge discovery.
[0141] The node representation generation module receives text attribute graph data and generates node semantic embedding representations. The community construction module performs clustering based on node embeddings to form candidate semantic communities and selects community anchor nodes. The path construction module generates a candidate set of paths starting from the anchor nodes, covering intra-community paths and cross-community paths. The path filtering and segmentation module calculates path diversity scores and calls a large language model to complete path semantic consistency verification and semantic boundary segmentation. The edge semantic enhancement module generates edge relationship interpretations based on adjacent node texts and forms structure-enhanced path texts. The sample construction module generates positive samples within communities, negative samples between communities, difficult positive samples, difficult negative samples, and intra-batch negative samples. The model training module fine-tunes the language model based on a contrastive learning objective with a confidence mask to obtain a graph structure-aware representation. The business application module inputs the trained representations into business systems such as node classification, clustering, recommendation, retrieval, risk control, or knowledge discovery.
[0142] The above detailed description further illustrates the purpose, technical solution, and beneficial effects of the invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for comparing and training community boundary-aware path segmentation with large language models, characterized in that, The method includes the following steps: (I) Semantic and structural encoding Step 1-1: Generation of Node Semantic Representations Let's define a text attribute graph. ,in For a set of nodes, Let be the set of edges. For any node, it is a collection of node text attributes. Get the text attribute graph The node text and edge connections in the model are used to generate the node semantic representation shown in the following formula using a text encoding model or a large language model embedding module. : ; in, For nodes semantic embedding; For the embedded dimension; Steps 1-2: Community Construction and Anchor Point Selection 1) Semantic representation of nodes Clustering is performed to obtain multiple semantic communities. For any community... Its community center is calculated by the following formula: ; 2) Select the node closest to the community center as the anchor node of the community, as shown in the following formula. : ; (II) Path Construction and Enhancement Step 2-1: Construction of Path Candidate Set From each community anchor node Starting from a given point, calculate the shortest path from it to other reachable nodes in the graph using the following formula, forming a path candidate set: ; in, For the set of anchor nodes; Step 2-2: Path diversity calculation and screening Based on the degree of dispersion of the semantic representation of each node in the path, a path diversity score is obtained. Low-diversity paths and high-diversity paths are then selected based on these scores. Calculated by the following formula: ; in, For path Middle The semantic representation vector of each node; As the center of the semantic representation of nodes within the path, for the path The center of the semantic representation of a node within a path is calculated using the following formula: ; in, For path The number of nodes contained in the path, i.e., the path length; Steps 2-3: Path semantic verification and semantic boundary segmentation 1) Input the text of each node in the low diversity path into the large language model in sequence, and let the large language model output the judgment result of whether the path belongs to the same topic; if the output result is consistent topic, the path is retained; otherwise, the path is filtered out. 2) Input the text of each node in the highly diverse path into the large language model in the original path order, and let the large language model identify the semantic transition positions and output the following formula to represent several continuous sub-paths of semantic boundary segmentation. : ; Each sub-path Internally, semantic consistency is maintained, and the order of nodes in each sub-path is preserved in the original path; Steps 2-4: Edge Relation Interpretation and Generation Based on the path and semantic boundary segmentation of the path semantic verification, edge relationship explanation text is generated for the text content of two adjacent nodes in the path. This includes: a description of the reasons for the reference, link, association, or semantic connection between the two nodes; Steps 2-5: Enhance path text construction For subpaths and adjacent nodes Generate edge relation explanations based on node text and edge relation explanation text. The node text and edge interpretations are then concatenated alternately to obtain the enhanced path text represented by the following formula: ; in," The separator indicates that the model simultaneously acquires node semantics and edge relation semantics; (III) Comparative Learning and Training Step 3-1: Community-Aware Positive and Negative Sample Construction. Semantically consistent sub-paths in low-diversity paths are constructed as intra-community positive samples, and sub-paths in high-diversity paths that cross semantic boundaries are constructed as inter-community negative samples. Simultaneously, difficult positive samples sharing start, end, or boundary nodes, as well as intra-batch negative samples, are introduced to enhance the training signal. Specifically, this includes: 1) For a training sample The first sub-path of the semantically validated low-diversity path is selected as the query sample. Select another sub-path within the same path as the main positive sample. At the same time, it will be with Low-diversity sub-paths sharing a start point, end point, or boundary node are considered as difficult positive samples. ; 2) For negative samples, select those that are similar to... Sub-paths at the ends of highly diverse paths with the same starting point are considered as cross-community negative samples. ; 3) Select low-diversity sub-paths connected to the endpoints of cross-community paths as difficult negative samples. ; 4) Other sub-paths within the same batch can be used as negative samples within the batch; Step 3-2: Contrastive Learning Training with Confidence Mask Based on the similarity relationship between query sub-paths and candidate samples, a confidence mask mechanism is introduced to suppress possible pseudo-positive and pseudo-negative samples. An objective function is applied to ensure that semantically continuous sub-paths within a community are represented as close to each other, while semantically dissimilar sub-paths across communities are represented as far apart. Specifically, this includes: 1) Let This represents the cosine similarity between two sub-path representations. Indicates the temperature coefficient. This represents the confidence threshold for negative samples. The confidence mask is defined by the following formula. : ; 2) For hard positive samples, the positive sample mask is defined by the following formula. : ; 3) Define the positive sample term by the following formula. : ; 4) Negative sample items The weighted sum of cross-community negative samples, hard negative samples, and intra-batch negative samples is shown in the following formula: ; 5) The constructed positive, negative, and difficult samples are used to perform comparative learning training on the large language model to obtain a graph structure-aware representation model. The objective of the comparative learning training is the objective function shown in the following formula. : ; Step 3-3: Output of graph structure-aware representation The node text, edge relationships, and path text sequences constructed in the above steps are input into the graph structure-aware representation model to obtain node representation vectors that integrate text semantic information and graph structure information. These node representation vectors are used for downstream tasks such as node classification, node clustering, community detection, graph retrieval, recommendation ranking, or relationship mining.
2. The community boundary-aware path segmentation and large language model comparison training method according to claim 1, characterized in that, The text encoding model can be a large language model embedding module, a pre-trained text representation model, or other semantic encoding models.
3. The community boundary-aware path segmentation and large language model comparison training method according to claim 1, characterized in that, The low-diversity path is used to represent semantic continuity relationships within a community; the high-diversity path is used to represent semantic transfer relationships that may cross communities.
4. The community boundary-aware path segmentation and large language model comparison training method according to claim 1, characterized in that... When the path diversity score is low, it is a candidate path within the community, indicating that the semantics of the nodes within the path are relatively concentrated; when the path diversity score is high, it is a candidate path across communities, indicating that the path may cross multiple semantic community paths.
5. A system constructed using the community boundary-aware path segmentation and large language model comparative training method as described in claim 1, characterized in that, The system adopts an architecture comprising a data input layer, a graph structure and semantic processing layer, a path and edge semantic refinement layer, a contrastive training layer, and a business application layer. Each functional layer collaborates to complete text attribute graph input, path construction, semantic segmentation, edge relationship enhancement, model training, and downstream business applications. The data input layer accepts text attribute graph data including node text and edge connection relationships. The graph structure and semantic processing layer is configured with a node representation generation module, a community construction module, and a path construction module. The path and edge semantic refinement layer is configured with a path filtering and segmentation module and an edge semantic enhancement module. The contrastive training layer is configured with a sample construction module and a model training module. The business application layer includes business application modules for classification, clustering, recommendation, retrieval, risk control, and knowledge discovery.
6. The system constructed by the community boundary-aware path segmentation and large language model comparative training method according to claim 5 is characterized in that, The node representation generation module receives text attribute graph data and generates node semantic embedding representations; The community construction module performs clustering based on node embedding to form candidate semantic communities and selects community anchor nodes; the path construction module generates a path candidate set starting from the anchor nodes, covering intra-community paths and cross-community paths; the path filtering and segmentation module calculates path diversity scores and calls a large language model to complete path semantic consistency verification and semantic boundary segmentation; the edge semantic enhancement module generates edge relationship interpretations based on adjacent node texts and forms structure-enhanced path text; the sample construction module generates positive samples within communities, negative samples between communities, difficult positive samples, difficult negative samples, and intra-batch negative samples; the model training module fine-tunes the language model based on a contrastive learning objective with confidence masks to obtain a graph structure-aware representation model.