A domestic large language model retrieval enhancement generation method for customs

By optimizing the knowledge graph for customs business scenarios using GraphRAG and Leiden algorithms, the problems of multi-hop dependency and information conflict in customs business by traditional RAG technology are solved, and efficient and reliable decision support for the customs intelligent supervision system is achieved.

CN121350080BActive Publication Date: 2026-06-19HUANGPU CUSTOMS DISTRICT OF PEOPLES REPUBLIC OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HUANGPU CUSTOMS DISTRICT OF PEOPLES REPUBLIC OF CHINA
Filing Date
2025-10-28
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Traditional search augmented generation (RAG) technology struggles to capture multi-hop dependencies between entities in customs business scenarios. It is also susceptible to redundancy and conflicting clauses, leading to semantic gaps in search results. This makes it difficult to support a global analysis of policy evolution trends and trade network topology characteristics, thus affecting the reliability of intelligent regulatory systems.

Method used

A multimodal knowledge graph is constructed using GraphRAG technology, and the regulatory system is optimized by combining it with the Leiden algorithm. Semantic alignment and dynamic evolution of the multidimensional feature space are achieved through graph neural networks. A hierarchical retrieval framework is used for community screening, node localization, and timeliness verification. A full-stack system architecture for knowledge graphs based on multi-source heterogeneous data is established to support intelligent decision-making in complex knowledge scenarios of customs.

Benefits of technology

It enables dynamic penetration of multi-hop relationship reasoning, automatically traces related elements, reduces information conflicts, improves the decision-making accuracy and timeliness of the customs intelligent supervision system, and can achieve millisecond-level response on the global trade knowledge graph, ensuring data security and service stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121350080B_ABST
    Figure CN121350080B_ABST
Patent Text Reader

Abstract

This invention discloses a domestically developed large language model retrieval enhancement generation method for customs use, comprising the following steps: S1, constructing GraphRAG, leveraging the deep semantic understanding capabilities of the large language model to dynamically deconstruct multimodal data such as customs announcements, enterprise customs declarations, and international treaties; S2, based on the Leiden algorithm for regulatory sub-community partitioning, combining the Leiden community discovery algorithm with regulatory validity analysis, constructing a time-sensitivity graph of regulatory clauses-revision events-effective regions; S3, a hierarchical retrieval framework, decomposing the retrieval process into three levels of probabilistic decision-making; S4, establishing a full-stack system architecture for a knowledge graph of multi-source heterogeneous data. This invention uses GraphRAG technology as its core carrier, achieving breakthroughs in complex customs knowledge scenarios through a dual innovation path: firstly, constructing a graph-structured retrieval enhancement model adapted to customs business characteristics; secondly, introducing the Leiden community discovery algorithm to optimize the dynamic governance mechanism of the regulatory system, thereby improving the decision-making reliability of the customs intelligent supervision system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a retrieval enhancement generation method, specifically a retrieval enhancement generation method using a domestically developed large language model for customs purposes. Background Technology

[0002] The customs sector faces the dual challenges of integrating multi-source heterogeneous data and managing complex evolving regulations. Traditional Retrieval Augmentation (RAG) techniques, relying on similarity retrieval, struggle to capture multi-hop dependencies between entities and are susceptible to redundancy and conflicting clauses. This research proposes a GraphRAG framework based on graph structure optimization. By constructing a multimodal knowledge graph (KG), it integrates semantic relationships between trade entities, commodity categories, and regulatory clauses. It also innovatively introduces the Leiden algorithm to dynamically partition and hierarchically map regulatory sub-communities, effectively mitigating the problem of conflicting legal provisions. Furthermore, the incremental indexing mechanism of the Neo4j graph database supports dynamic updates of customs policies and global feature extraction from the trade network. The research findings provide a scalable technical path for customs compliance risk analysis and intelligent supervision.

[0003] In customs operations, multi-source heterogeneous data, including trade records, regulations, and compliance requirements, exhibit high dimensionality and strong correlation. Traditional Retrieval Augmentation (RAG) technology, due to its flat retrieval model, suffers from three limitations: First, it ignores multi-hop dependencies between entities, such as the chain relationship between trade entities, commodity categories, and tariff terms, leading to semantic gaps in search results; second, frequent revisions of regulations result in partial overlap between old and new provisions, making it easy for traditional similarity searches to return redundant or conflicting information; and third, fragmented text snippets make it difficult to support a global analysis of policy evolution trends or trade network topology. These problems severely restrict the reliability of decisions made by customs intelligent supervision systems. To address this issue, the inventors have proposed a domestically developed large language model-based retrieval augmentation method for customs applications. Summary of the Invention

[0004] The purpose of this invention is to provide a domestically developed large language model retrieval enhancement generation method for customs. This retrieval enhancement generation method takes GraphRAG technology as its core carrier and achieves breakthroughs in complex knowledge scenarios of customs through a dual innovation path: first, it constructs a graph structure retrieval enhancement model adapted to the characteristics of customs business; second, it introduces the Leiden community discovery algorithm to optimize the dynamic governance mechanism of the regulatory system, thereby improving the decision reliability of the customs intelligent supervision system and solving the problems raised in the above technical background.

[0005] To achieve the above objectives, the present invention provides the following technical solution: a domestically developed large language model retrieval enhancement generation method for customs use, comprising the following steps:

[0006] S1. Construct GraphRAG, which leverages the deep semantic understanding capabilities of large language models to dynamically deconstruct multimodal data such as customs announcements, enterprise customs declarations, and international treaties. Then, it uses graph neural networks to achieve semantic alignment of multidimensional feature spaces, and finally constructs a domain knowledge graph with dynamic evolution capabilities. This domain knowledge graph adopts a dual-engine architecture of semantic-driven and graph-fusion, and realizes the structured reconstruction of customs knowledge through a three-order progressive workflow.

[0007] S2. Legal sub-community partitioning based on Leiden algorithm: This method combines the Leiden community discovery algorithm with legal effectiveness analysis. By constructing a triplet timeliness graph of legal clauses, revision events, and effective areas, the Leiden algorithm achieves community partitioning by recursively optimizing the modularity function.

[0008] S3, the hierarchical retrieval framework, decomposes the retrieval process into three levels of probabilistic decision-making: community screening, node positioning, and timeliness verification. Among them, community screening calculates the relevance between the query and the community through semantic matching and prioritizes the activation of relevant fields. Node positioning determines candidate clauses within the selected community by combining the similarity of clause texts and graph topology features. Timeliness verification filters out invalid or outdated legal provisions based on the clause revision history and effective time.

[0009] S4. Establish a full-stack knowledge graph system architecture for multi-source heterogeneous data. This architecture includes a system layer, a data layer, a retrieval layer, an image layer, a generation layer, and end users. The system layer, through distributed access control, real-time monitoring, and performance analysis modules, runs through the entire chain to ensure data security and service stability, forming a closed-loop system from raw data access, knowledge modeling, intelligent retrieval to interactive generation. This supports end users' decision-making and analysis needs in complex business scenarios. The data layer integrates multimodal data such as trade records, customs regulations, and corporate archives. After being cleaned and preprocessed into a unified structure, the data is input into a knowledge extraction engine for triple parsing of entities, relationships, and attributes. A dynamic knowledge graph based on Neo4j is constructed, and the topological relationships are continuously updated through community discovery algorithms. Subsequently, the image layer generates a structural index, a pre-trained language model vector embedding index, and an inverted text index simultaneously in the retrieval layer. A hybrid query engine integrates multimodal features to achieve cross-dimensional semantic retrieval. After relevance ranking, a domain-enhanced large model in the generation layer is triggered. The results are optimized by combining dynamic summary generation and prompting engineering techniques, and finally, multi-format knowledge services adapted to business scenarios are output.

[0010] Preferably, the construction of GraphRAG in S1 specifically includes the following steps:

[0011] S1.1, a multi-stage semantic parsing framework, utilizes the context-aware mechanism of LLM to design a prompting engineering template based on customs business logic, and performs paragraph-level joint extraction of entity relationships from unstructured text. Through a progressive parsing strategy of concept anchoring-relational reasoning-attribution, the professional semantics of HS coding mapping, rules of origin, and regulatory regulations are transformed into a subject-predicate-object triple topological structure, significantly improving the accuracy of capturing complex relationships in cross-border trade;

[0012] S1.2 Node semantic vector extraction: A multi-layer semantic network containing the core elements of customs is constructed in the Neo4j graph database. Differentiated node types are set, and node attributes are mapped to a 768-dimensional feature space through a vectorization engine.

[0013] S1.3 Dynamic Adaptive Enhancement Architecture: In response to the frequent iterations of customs policies, a version-controlled knowledge graph update protocol is developed. Through timestamp-driven subgraph isolation technology, the semantic relationships of new regulations are dynamically injected while ensuring the consistency of historical queries, forming an elastic storage structure of basic graph + incremental graph.

[0014] Preferably, the multi-stage semantic parsing framework in S1.1 includes a concept anchoring layer, a relational reasoning layer, and an attribute attribution layer, wherein the concept anchoring layer uses a BiLSTM-CRF model for entity boundary detection. The parameters are defined as follows:

[0015] – Total number of training samples;

[0016] – : No. One input sequence;

[0017] – : No. A sequence of entity labels;

[0018] – : BiLSTM-CRF model parameter set;

[0019] This loss function maximizes the likelihood probability of the label sequence. The BiLSTM encoder learns contextual features and uses the CRF layer to model the transition constraints between labels. The negative log-likelihood form transforms the sequence labeling task into a loss minimization problem, effectively optimizing the accuracy of entity boundary detection. The bidirectional mechanism of BiLSTM can capture semantic features of the preceding and following contexts at the same time, and the transition matrix of CRF explicitly constrains the legal jumps between labels.

[0020] The relational reasoning layer is based on the LLM interaction protocol of prompting engineering: the knowledge extraction process is defined as a three-stage mapping. ,

[0021] in, For template-based and relational constraints Hints for constructing operators

[0022] Represents the knowledge reasoning process of a language model;

[0023] The overall structured data parsing function can be represented as a composite function:

[0024] ;

[0025] Attribute attribution layer: Multi-head attention weight calculation: The parameters are defined as follows: , Word position index in the sequence:

[0026] Query matrix (Query, current word representation);

[0027] : Key matrix (Key, context word representation);

[0028] : The scaling factor of the attention head;

[0029] This formula calculates words using a scaled dot product attention mechanism. Word pair Association weight denominator To prevent the gradient from vanishing due to excessively large dot products, the softmax function ensures weight normalization. The multi-head design allows the model to focus on the dependencies of different semantic subspaces in parallel. The sparse weight distribution can filter key attribute features and support subsequent relational reasoning tasks.

[0030] Preferably, in S1.2, the text attributes of each node... Perform context-aware encoding:

[0031]

[0032] The parameters are defined as follows:

[0033] Knowledge graph node identifier;

[0034] The original text description associated with the node;

[0035] Category marker;

[0036] 768: Hidden layer dimension of the pre-trained model;

[0037] By extracting the aggregated representation of the [CLS] tag, a 768-dimensional vector that integrates global semantics is obtained. Based on a deep bidirectional architecture of multi-layer Transformer, cross-word dependencies are modeled, enabling the representation to capture both local language patterns and document-level semantic coherence.

[0038] Preferably, the core formula for community division in S2 is the weighted modularity: The parameters are defined as follows: Clause association weight matrix;

[0039] • Node strength;

[0040] • : Region resolution parameters;

[0041] • Community indicator function;

[0042] Modularity The saliency of quantifying network community structure is based on the core idea of ​​comparing actual edge weights. With zero model expectation The difference, a positive value indicates that the connection strength of the node within the community is higher than expected under random distribution, denominator The total network weights are used for normalization. > 1 indicates that the algorithm prefers to detect more fine-grained community structure, and this metric is achieved by maximizing Value-driven network partitioning algorithm.

[0043] Preferably, the probabilistic model for the hierarchical retrieval framework in S3 is as follows:

[0044]

[0045] in, Consultation / Inquiry;

[0046] Community segmentation in knowledge graphs;

[0047] Target clause node;

[0048] : Time-sensitive context;

[0049] The model decomposes the retrieval process into three levels of probabilistic decision-making: 1) Community screening Query calculation based on semantic matching With the community 1) Prioritize activation of relevant fields based on their relevance; 2) Node positioning Within the selected community, candidate clauses are determined by combining clause text similarity with graph topological features; 3) Timeliness verification Based on the revision history and effective date of the terms, legal provisions that are invalid or outdated are filtered out.

[0050] Preferably, the knowledge graph full-stack system architecture in S4 includes the following steps:

[0051] S4.1 Multimodal data processing architecture: The data layer processes heterogeneous data streams through a fusion of rules and deep learning. First, it performs regular rule matching on unstructured fields in the original data to extract key information, and completes entity recognition and knowledge base mapping based on the domain dictionary. At the same time, it performs dependency parsing on all data blocks to construct syntactic and logical relationships. Then, it generates deep semantic vectors through a deep bidirectional semantic encoder to capture contextual associations. Finally, it dynamically aggregates entity linking results and semantic enhancement features into a buffer pool to form a multi-dimensional data representation that combines structured fields and semantic embedding features. Finally, it outputs a standardized structured dataset through serialization, realizing a unified expression of cross-modal data at the syntactic, semantic, and entity levels, providing a high-quality and interpretable data foundation for subsequent analysis tasks.

[0052] S4.2 Dynamic knowledge graph construction: The graph layer adopts a three-level architecture of "extraction-fusion-evolution". The knowledge extraction engine integrates a deep semantic encoder-BiLSTM-CRF joint model, solves the entity ambiguity problem across data sources through attribute alignment algorithm, and innovatively introduces a time-series community discovery algorithm, which can dynamically identify abnormal patterns of cargo flow and support real-time evolution and update of the graph structure. The subgraph isolation technology ensures query stability when data is updated.

[0053] S4.3, Hybrid Retrieval and Reasoning Mechanism: The retrieval layer constructs a multi-dimensional index joint service, innovatively integrating graph path query, semantic vector matching, and keyword retrieval. The graph index adopts a bidirectional breadth-first traversal strategy, supporting complex relationship reasoning within 6 hops. The 768-dimensional vector embedding model has been fine-tuned with 200,000 sets of customs inquiry data; the inverted index achieves millisecond-level positioning for regulatory provisions. The hybrid query engine, through an adaptive weight allocation algorithm, controls the average response time to within 1.2 seconds while ensuring high recall.

[0054] The S4.4 domain-enhanced generation system constructs a three-level optimized pipeline in the generation layer: the dynamic summary module extracts query-related subgraph features, the prompting engineering component injects customs terminology constraints, and the domain knowledge enhancer ensures that the output meets regulatory requirements through rule templates.

[0055] Preferably, the graph layer in S4.2 innovatively integrates the Leiden community discovery algorithm with legal provisions constraints, employing a two-stage dynamic adjustment strategy: first, it automatically identifies the aggregation pattern of regulatory provisions based on network modularity; then, it ensures regulatory compliance through community reorganization guided by a whitelist. Subgraph segmentation technology enables rapid isolation of provision clusters, and a modularity optimization function ensures the topological rationality of the segmentation results, supporting the elastic expansion of the legal provisions system.

[0056] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0057] 1. This invention provides a domestically developed large language model retrieval enhancement generation method for customs use. The retrieval enhancement generation method includes the following steps: S1, constructing GraphRAG; S2, dividing the regulatory sub-community based on the Leiden algorithm; S3, hierarchical retrieval framework; S4, establishing a full-stack system architecture of knowledge graph for multi-source heterogeneous data. GraphRAG, through the deep integration of knowledge graph and graph neural network, demonstrates a systematic advantage over traditional RAG technology in complex customs scenarios. Its core breakthrough lies in transforming fragmented text semantics into a reasonable three-dimensional knowledge network. Through three-dimensional modeling of "entity-relationship-attribute", it constructs an intelligent decision-making framework covering trade entity relationships, policy dynamic evolution, and risk transmission paths. Compared to the linear matching mechanism of traditional retrieval models, GraphRAG achieves dynamic penetration of multi-hop relational reasoning: based on the HS code node of the commodity, the system can automatically trace back to related elements such as rules of origin, tariff preference terms, and enterprise qualification verification, forming a compliance review link; facing the high-frequency iteration of the customs regulatory system, its unique temporal knowledge graph architecture supports dual timestamp version management. Through the neighborhood message passing mechanism of graph neural networks, it can complete the incremental hot update of new regulations within 30 seconds, while automatically blocking the logical contradiction path of "repealed clauses - current policies", reducing the conflict rate of multi-source information. At the global semantic integration level, GraphRAG innovatively integrates spatiotemporal attribute embedding and hypergraph modeling technology to jointly represent heterogeneous data such as commodity circulation trajectory, enterprise supply chain network, and policy evolution curve, enabling the system to capture implicit correlations. In engineering practice, this technology leverages a distributed graph storage architecture to achieve millisecond-level response times. On a global trade knowledge graph with over 1 billion nodes, the end-to-end decision-making latency for "commodity classification - risk assessment" remains consistently below 800ms. Furthermore, through fine-grained access control using an attribute graph model, it ensures that sensitive supply chain data is only visible within authorized subgraphs. These characteristics enable GraphRAG to systematically overcome the inherent shortcomings of traditional RAGs, such as the lack of structured relationships, dynamic knowledge conflicts, and limitations in global perception, providing a new generation of solutions for intelligent customs supervision that combine accuracy, timeliness, and interpretability.

[0058] 2. The hierarchical retrieval framework in this invention achieves a breakthrough in complex knowledge scenarios in customs through a dual innovative approach: first, it constructs a graph-structured retrieval enhancement model adapted to the characteristics of customs business; second, it introduces the Leiden community discovery algorithm to optimize the dynamic governance mechanism of the regulatory system. The innovation is reflected in two aspects: first, it breaks through the traditional RAG text fragment retrieval paradigm and establishes a heterogeneous knowledge graph covering all elements of customs entities; second, through hierarchical topological analysis of regulatory sub-communities, it constructs a legal validity tracing framework with spatiotemporal adaptability, effectively solving the industry pain point of conflicts between old and new regulations. Attached Figure Description

[0059] Figure 1 This is a flowchart of the retrieval enhancement generation method of the present invention;

[0060] Figure 2 This is a flowchart of the customs GraphRAG system architecture of the present invention;

[0061] Figure 3 This is a schematic diagram of the structure of the neo4j spectrum of the present invention. Detailed Implementation

[0062] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0063] In the description of the embodiments of the present invention, it should be understood that the terms "length," "width," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientation or positional relationships, are based on the orientation or positional relationships shown in the accompanying drawings and are only for the convenience of describing the embodiments of the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the present invention. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined with "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the embodiments of the present invention, "a plurality of" means two or more, unless otherwise explicitly specified.

[0064] In the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in the embodiments of the present invention according to the specific circumstances.

[0065] Please see Figure 1 The present invention provides an embodiment of a domestically developed large language model retrieval enhancement generation method for customs use, comprising the following steps:

[0066] S1. Construct GraphRAG, which leverages the deep semantic understanding capabilities of large language models to dynamically deconstruct multimodal data such as customs announcements, enterprise customs declarations, and international treaties. Then, it uses graph neural networks to achieve semantic alignment of multidimensional feature spaces, and finally constructs a domain knowledge graph with dynamic evolution capabilities. This domain knowledge graph adopts a dual-engine architecture of semantic-driven and graph-fusion, and realizes the structured reconstruction of customs knowledge through a three-order progressive workflow.

[0067] S2. Legal sub-community partitioning based on Leiden algorithm: This method combines the Leiden community discovery algorithm with legal effectiveness analysis. By constructing a triplet timeliness graph of legal clauses, revision events, and effective areas, the Leiden algorithm achieves community partitioning by recursively optimizing the modularity function.

[0068] S3, the hierarchical retrieval framework, decomposes the retrieval process into three levels of probabilistic decision-making: community screening, node positioning, and timeliness verification. Among them, community screening calculates the relevance between the query and the community through semantic matching and prioritizes the activation of relevant fields. Node positioning determines candidate clauses within the selected community by combining the similarity of clause texts and graph topology features. Timeliness verification filters out invalid or outdated legal provisions based on the clause revision history and effective time.

[0069] S4. Establish a full-stack knowledge graph system architecture for multi-source heterogeneous data. This architecture includes a system layer, a data layer, a retrieval layer, an image layer, a generation layer, and end users. The system layer, through distributed access control, real-time monitoring, and performance analysis modules, runs through the entire chain to ensure data security and service stability, forming a closed-loop system from raw data access, knowledge modeling, intelligent retrieval to interactive generation. This supports end users' decision-making and analysis needs in complex business scenarios. The data layer integrates multimodal data such as trade records, customs regulations, and corporate archives. After being cleaned and preprocessed into a unified structure, the data is input into a knowledge extraction engine for triple parsing of entities, relationships, and attributes. A dynamic knowledge graph based on Neo4j is constructed, and the topological relationships are continuously updated through community discovery algorithms. Subsequently, the image layer generates a structural index, a pre-trained language model vector embedding index, and an inverted text index simultaneously in the retrieval layer. A hybrid query engine integrates multimodal features to achieve cross-dimensional semantic retrieval. After relevance ranking, a domain-enhanced large model in the generation layer is triggered. The results are optimized by combining dynamic summary generation and prompting engineering techniques, and finally, multi-format knowledge services adapted to business scenarios are output.

[0070] Specifically, the construction of GraphRAG in S1 includes the following steps:

[0071] S1.1, a multi-stage semantic parsing framework, utilizes the context-aware mechanism of LLM to design a prompt engineering template based on customs business logic, and performs paragraph-level joint extraction of entity relationships from unstructured text. Through a progressive parsing strategy of concept anchoring-relational reasoning-attribution, the professional semantics of HS coding mapping, rules of origin, and regulatory regulations are transformed into a subject-predicate-object triple topology, significantly improving the accuracy of capturing complex relationships in cross-border trade.

[0072] S1.2 Node semantic vector extraction: A multi-layer semantic network containing the core elements of customs is constructed in the Neo4j graph database. Differentiated node types are set, and node attributes are mapped to a 768-dimensional feature space through a vectorization engine.

[0073] S1.3 Dynamic Adaptive Enhancement Architecture: In response to the frequent iterations of customs policies, a version-controlled knowledge graph update protocol is developed. Through timestamp-driven subgraph isolation technology, the semantic relationships of new regulations are dynamically injected while ensuring the consistency of historical queries, forming an elastic storage structure of basic graph + incremental graph.

[0074] Specifically, the multi-stage semantic parsing framework in S1.1 includes a concept anchoring layer, a relational reasoning layer, and an attribute attribution layer, wherein the concept anchoring layer uses a BiLSTM-CRF model for entity boundary detection. The parameters are defined as follows:

[0075] – Total number of training samples;

[0076] – : No. One input sequence;

[0077] – : No. A sequence of entity labels;

[0078] – : BiLSTM-CRF model parameter set;

[0079] This loss function maximizes the likelihood probability of the label sequence. The BiLSTM encoder learns contextual features and uses the CRF layer to model the transition constraints between labels. The negative log-likelihood form transforms the sequence labeling task into a loss minimization problem, effectively optimizing the accuracy of entity boundary detection. The bidirectional mechanism of BiLSTM can capture semantic features of the preceding and following contexts at the same time, and the transition matrix of CRF explicitly constrains the legal jumps between labels.

[0080] The relational reasoning layer is based on the LLM interaction protocol of prompting engineering: the knowledge extraction process is defined as a three-stage mapping. ,

[0081] in, For template-based and relational constraints Hints for constructing operators

[0082] Represents the knowledge reasoning process of a language model;

[0083] The overall structured data parsing function can be represented as a composite function:

[0084]

[0085] Attribute attribution layer: Multi-head attention weight calculation: The parameters are defined as follows: , Word position index in the sequence:

[0086] Query matrix (Query, current word representation);

[0087] : Key matrix (Key, context word representation);

[0088] : The scaling factor of the attention head;

[0089] This formula calculates words using a scaled dot product attention mechanism. Word pair Association weight denominator To prevent the gradient from vanishing due to excessively large dot products, the softmax function ensures weight normalization. The multi-head design allows the model to focus on the dependencies of different semantic subspaces in parallel. The sparse weight distribution can filter key attribute features and support subsequent relational reasoning tasks.

[0090] Specifically, in S1.2, the text attributes of each node Perform context-aware encoding:

[0091]

[0092] The parameters are defined as follows:

[0093] Knowledge graph node identifier;

[0094] The original text description associated with the node;

[0095] Category marker;

[0096] 768: Hidden layer dimension of the pre-trained model;

[0097] By extracting the aggregated representation of the [CLS] tag, a 768-dimensional vector that integrates global semantics is obtained. Based on a deep bidirectional architecture of multi-layer Transformer, cross-word dependencies are modeled, enabling the representation to capture both local language patterns and document-level semantic coherence.

[0098] Specifically, the core formula for community division in S2 is the weighted modularity: The parameters are defined as follows: Clause association weight matrix;

[0099] • Node strength;

[0100] • : Region resolution parameters;

[0101] • Community indicator function;

[0102] Modularity The saliency of quantifying network community structure is based on the core idea of ​​comparing actual edge weights. With zero model expectation The difference, a positive value indicates that the connection strength of the node within the community is higher than expected under random distribution, denominator The total network weights are used for normalization. > 1 indicates that the algorithm prefers to detect more fine-grained community structure, and this metric is achieved by maximizing Value-driven network partitioning algorithm.

[0103] Specifically, the probabilistic model for the hierarchical retrieval framework in S3 is as follows:

[0104]

[0105] in, Consultation / Inquiry;

[0106] Community segmentation in knowledge graphs;

[0107] Target clause node;

[0108] : Time-sensitive context;

[0109] The model decomposes the retrieval process into three levels of probabilistic decision-making: 1) Community screening Query calculation based on semantic matching With the community 1) Prioritize activation of relevant fields based on their relevance; 2) Node positioning Within the selected community, candidate clauses are determined by combining clause text similarity with graph topological features; 3) Timeliness verification Based on the revision history and effective date of the terms, legal provisions that are invalid or outdated are filtered out.

[0110] Specifically, the knowledge graph full-stack system architecture in S4 includes the following steps:

[0111] S4.1 Multimodal data processing architecture: The data layer processes heterogeneous data streams through a fusion of rules and deep learning. First, it performs regular rule matching on unstructured fields in the original data to extract key information, and completes entity recognition and knowledge base mapping based on the domain dictionary. At the same time, it performs dependency parsing on all data blocks to construct syntactic and logical relationships. Then, it generates deep semantic vectors through a deep bidirectional semantic encoder to capture contextual associations. Finally, it dynamically aggregates entity linking results and semantic enhancement features into a buffer pool to form a multi-dimensional data representation that combines structured fields and semantic embedding features. Finally, it outputs a standardized structured dataset through serialization, realizing a unified expression of cross-modal data at the syntactic, semantic, and entity levels, providing a high-quality and interpretable data foundation for subsequent analysis tasks.

[0112] S4.2 Dynamic knowledge graph construction: The graph layer adopts a three-level architecture of "extraction-fusion-evolution". The knowledge extraction engine integrates a deep semantic encoder-BiLSTM-CRF joint model, solves the entity ambiguity problem across data sources through attribute alignment algorithm, and innovatively introduces a time-series community discovery algorithm, which can dynamically identify abnormal patterns of cargo flow and support real-time evolution and update of the graph structure. The subgraph isolation technology ensures query stability when data is updated.

[0113] S4.3, Hybrid Retrieval and Reasoning Mechanism: The retrieval layer constructs a multi-dimensional index joint service, innovatively integrating graph path query, semantic vector matching, and keyword retrieval. The graph index adopts a bidirectional breadth-first traversal strategy, supporting complex relationship reasoning within 6 hops. The 768-dimensional vector embedding model has been fine-tuned with 200,000 sets of customs inquiry data; the inverted index achieves millisecond-level positioning for regulatory provisions. The hybrid query engine, through an adaptive weight allocation algorithm, controls the average response time to within 1.2 seconds while ensuring high recall.

[0114] The S4.4 domain-enhanced generation system constructs a three-level optimized pipeline in the generation layer: the dynamic summary module extracts query-related subgraph features, the prompting engineering component injects customs terminology constraints, and the domain knowledge enhancer ensures that the output meets regulatory requirements through rule templates.

[0115] Specifically, the graph layer in S4.2 innovatively integrates the Leiden community discovery algorithm with legal constraints, employing a two-stage dynamic adjustment strategy: first, it automatically identifies the aggregation pattern of regulatory clauses based on network modularity; then, it ensures regulatory compliance through community reorganization guided by a whitelist. Subgraph segmentation technology enables rapid isolation of clause clusters, and a modularity optimization function ensures the topological rationality of the partitioning results, supporting the elastic expansion of the legal provision system.

[0116] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.

Claims

1. A domestic large language model retrieval enhancement generation method for customs, characterized by: Includes the following steps: S1. Construct GraphRAG, which leverages the deep semantic understanding capabilities of large language models to dynamically deconstruct multimodal data such as customs announcements, enterprise customs declarations, and international treaties. Then, it uses graph neural networks to achieve semantic alignment of multidimensional feature spaces, and finally constructs a domain knowledge graph with dynamic evolution capabilities. This domain knowledge graph adopts a dual-engine architecture of semantic-driven and graph-fusion, and realizes the structured reconstruction of customs knowledge through a three-order progressive workflow. S2. Legal sub-community partitioning based on Leiden algorithm: This method combines the Leiden community discovery algorithm with legal effectiveness analysis. By constructing a triplet timeliness graph of legal clauses, revision events, and effective areas, the Leiden algorithm achieves community partitioning by recursively optimizing the modularity function. S3, the hierarchical retrieval framework, decomposes the retrieval process into three levels of probabilistic decision-making: community screening, node positioning, and timeliness verification. Among them, community screening calculates the relevance between the query and the community through semantic matching and prioritizes the activation of relevant fields. Node positioning determines candidate clauses within the selected community by combining the similarity of clause texts and graph topology features. Timeliness verification filters out invalid or outdated legal provisions based on the clause revision history and effective time. S4. Establish a full-stack knowledge graph system architecture for multi-source heterogeneous data. This architecture includes a system layer, a data layer, a retrieval layer, an image layer, a generation layer, and end users. The system layer, through distributed access control, real-time monitoring, and performance analysis modules, runs through the entire chain to ensure data security and service stability, forming a closed-loop system from raw data access, knowledge modeling, intelligent retrieval to interactive generation. This supports end users' decision-making and analysis needs in complex business scenarios. The data layer integrates multimodal data such as trade records, customs regulations, and corporate archives. After being cleaned and preprocessed into a unified structure, the data is input into a knowledge extraction engine for triple parsing of entities, relationships, and attributes. A dynamic knowledge graph based on Neo4j is constructed, and the topological relationships are continuously updated through community discovery algorithms. Subsequently, the image layer generates a structural index, a pre-trained language model vector embedding index, and an inverted text index simultaneously in the retrieval layer. A hybrid query engine integrates multimodal features to achieve cross-dimensional semantic retrieval. After relevance ranking, a domain-enhanced large model in the generation layer is triggered. The results are optimized by combining dynamic summary generation and prompting engineering techniques, and finally, multi-format knowledge services adapted to business scenarios are output.

2. The method for generating a domestic large language model retrieval enhancement for customs according to claim 1, characterized in that: The construction of GraphRAG in S1 specifically includes the following steps: S1.1, a multi-stage semantic parsing framework, utilizes the context-aware mechanism of LLM to design a prompt engineering template based on customs business logic, and performs paragraph-level joint extraction of entity relationships from unstructured text; through a progressive parsing strategy of concept anchoring-relational reasoning-attribution, the professional semantics of HS coding mapping, rules of origin, and regulatory regulations are transformed into a subject-predicate-object triple topology structure, which significantly improves the accuracy of capturing complex relationships in cross-border trade; S1.2 Node semantic vector extraction: A multi-layer semantic network containing the core elements of customs is constructed in the Neo4j graph database. Differentiated node types are set, and node attributes are mapped to a 768-dimensional feature space through a vectorization engine. S1.3 Dynamic Adaptive Enhancement Architecture: In response to the frequent iterations of customs policies, a version-controlled knowledge graph update protocol is developed. Through timestamp-driven subgraph isolation technology, the semantic relationships of new regulations are dynamically injected while ensuring the consistency of historical queries, forming an elastic storage structure of basic graph + incremental graph.

3. The method for enhancing the retrieval of a domestically developed large language model used by customs, as described in claim 2, is characterized in that: The multi-stage semantic parsing framework in S1.1 includes a concept anchoring layer, a relationship reasoning layer, and an attribute attribution layer, wherein the concept anchoring layer adopts a BiLSTM-CRF model for entity boundary detection: Wherein the parameters are defined as follows: – Total number of training samples; – : No. One input sequence; – : No. A sequence of entity labels; – : BiLSTM-CRF model parameter set; This loss function maximizes the likelihood probability of the label sequence. The BiLSTM encoder learns contextual features and uses the CRF layer to model the transition constraints between labels. The negative log-likelihood form transforms the sequence labeling task into a loss minimization problem, effectively optimizing the accuracy of entity boundary detection. The bidirectional mechanism of BiLSTM can capture semantic features of the preceding and following contexts at the same time, and the transition matrix of CRF explicitly constrains the legal jumps between labels. The relational reasoning layer is based on the LLM interaction protocol of prompting engineering: the knowledge extraction process is defined as a three-stage mapping. , in, For template-based and relational constraints Hints for constructing operators Represents the knowledge reasoning process of a language model; The overall structured data parsing function can be represented as a composite function: ; Attribute attribution layer: Multi-head attention weight calculation: The parameters are defined as follows: , Word position index in the sequence: Query matrix (Query, current word representation); : Key matrix (Key, context word representation); : The scaling factor of the attention head; This formula calculates words using a scaled dot product attention mechanism. Word pair Association weight denominator To prevent the gradient from vanishing due to excessively large dot products, the softmax function ensures weight normalization. The multi-head design allows the model to focus on the dependencies of different semantic subspaces in parallel. The sparse weight distribution can filter key attribute features and support subsequent relational reasoning tasks.

4. The method for enhancing the retrieval of a domestically developed large language model used by customs, as described in claim 2, is characterized in that: The text attributes of each node in S1.2 Perform context-aware encoding: ; The parameters are defined as follows: Knowledge graph node identifier; : The original text description associated with the node; Category marker; 768: Hidden layer dimension of the pre-trained model; By extracting the aggregated representation of the [CLS] tag, a 768-dimensional vector that integrates global semantics is obtained. Based on a deep bidirectional architecture of multi-layer Transformer, cross-word dependencies are modeled, enabling the representation to capture both local language patterns and document-level semantic coherence.

5. The method for enhancing the retrieval of a domestically developed large language model used by customs, as described in claim 1, is characterized in that: The core formula for community division in S2 is the weighted modularity: The parameters are defined as follows: Clause association weight matrix; • Node strength; • : Region resolution parameters; • Community indicator function; Modularity The saliency of quantifying network community structure is based on the core idea of ​​comparing actual edge weights. With zero model expectation The difference, a positive value indicates that the connection strength of the node within the community is higher than expected under random distribution, denominator The total network weights are used for normalization. > 1 indicates that the algorithm prefers to detect more fine-grained community structure, and this metric is achieved by maximizing Value-driven network partitioning algorithm.

6. The enhanced generation method for domestically produced large language model retrieval used by customs according to claim 1, characterized in that: The probabilistic model for the retrieval process in the hierarchical retrieval framework of S3 is as follows: ; in, Consultation / Inquiry; Community segmentation in knowledge graphs; Target clause node; : Time-sensitive context; The model decomposes the retrieval process into three levels of probabilistic decision-making: 1) Community screening Query calculation based on semantic matching With the community 1) Prioritize activation of relevant fields based on their relevance; 2) Node positioning Within the selected community, candidate clauses are determined by combining clause text similarity with graph topological features; 3) Timeliness verification Based on the revision history and effective date of the terms, legal provisions that are invalid or outdated are filtered out.

7. The method for enhancing the retrieval of a domestically developed large language model used by customs, as described in claim 1, is characterized in that: The full-stack knowledge graph system architecture in S4 includes the following steps: S4.1 Multimodal data processing architecture: The data layer processes heterogeneous data streams through a fusion of rules and deep learning. First, it performs regular rule matching on unstructured fields in the original data to extract key information, and completes entity recognition and knowledge base mapping based on the domain dictionary. At the same time, it performs dependency parsing on all data blocks to construct syntactic and logical relationships. Then, it generates deep semantic vectors through a deep bidirectional semantic encoder to capture contextual associations. Finally, it dynamically aggregates entity linking results and semantic enhancement features into a buffer pool to form a multi-dimensional data representation that combines structured fields and semantic embedding features. Finally, it outputs a standardized structured dataset through serialization, realizing a unified expression of cross-modal data at the syntactic, semantic, and entity levels, providing a high-quality and interpretable data foundation for subsequent analysis tasks. S4.2 Dynamic knowledge graph construction: The graph layer adopts a three-level architecture of "extraction-fusion-evolution". The knowledge extraction engine integrates a deep semantic encoder-BiLSTM-CRF joint model, solves the entity ambiguity problem across data sources through attribute alignment algorithm, and innovatively introduces a time-series community discovery algorithm, which can dynamically identify abnormal patterns of cargo flow and support real-time evolution and update of the graph structure. The subgraph isolation technology ensures query stability when data is updated. S4.3, Hybrid retrieval and reasoning mechanism: The retrieval layer constructs a multi-dimensional index joint service, innovatively integrating graph path query, semantic vector matching, and keyword retrieval; the graph index adopts a bidirectional breadth-first traversal strategy, supporting complex relationship reasoning within 6 hops; the 768-dimensional vector embedding model has been fine-tuned with 200,000 sets of customs inquiry data; the inverted index achieves millisecond-level positioning for legal provisions; the hybrid query engine, through an adaptive weight allocation algorithm, controls the average response time to within 1.2 seconds while ensuring recall. The S4.4 domain-enhanced generation system constructs a three-level optimized pipeline in the generation layer: the dynamic summary module extracts query-related subgraph features, the prompting engineering component injects customs terminology constraints, and the domain knowledge enhancer ensures that the output meets regulatory requirements through rule templates.

8. The method for enhancing the retrieval of a domestically developed large language model for customs use according to claim 1, characterized in that: The graph layer in S4.2 innovatively integrates the Leiden community discovery algorithm with legal provisions constraints, and adopts a two-stage dynamic adjustment strategy: first, it automatically identifies the aggregation pattern of legal provisions based on network modularity, and then ensures regulatory compliance through community reorganization guided by a whitelist; it achieves rapid isolation of provision clusters through subgraph segmentation technology, and uses a modularity optimization function to ensure the topological rationality of the partitioning results, supporting the elastic expansion of the legal provisions system.