Federal learning-based imported food customs clearance risk assessment and sampling inspection method and device

By building a vertical federated learning system between customs supervision and overseas enterprises, and utilizing a trusted execution environment and causal graph model verification, the issues of data privacy and data authenticity in the supervision of imported food have been resolved, enabling efficient risk assessment and sampling decisions, and improving customs clearance efficiency.

CN121961231APending Publication Date: 2026-05-01FOOD INSPECTION CENT OF CIQ SHENZHEN +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
FOOD INSPECTION CENT OF CIQ SHENZHEN
Filing Date
2026-01-14
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

The current supervision of imported food is inaccurate due to the inability to obtain data from overseas sources. Furthermore, in adversarial environments, traditional data collaboration methods are vulnerable to malicious attacks and it is difficult to identify and defend against false characteristic data.

Method used

By employing a federated learning approach, a vertical federated learning system is constructed between the customs supervision end and the overseas enterprise end. Through a trusted execution environment, privacy-preserving cross-domain entity alignment, causal graph model verification, and adversarial regularization training, data privacy and data authenticity are ensured, thereby achieving the accuracy and fraud resistance of the risk assessment model.

Benefits of technology

While ensuring data privacy, the use of overseas source data for accurate risk assessment has improved the accuracy and fraud resistance of risk assessment models, and optimized the allocation of regulatory resources and improved customs clearance efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121961231A_ABST
    Figure CN121961231A_ABST
Patent Text Reader

Abstract

The invention discloses an imported food customs clearance risk assessment and sampling inspection method and device based on federated learning. The method comprises the following steps: constructing a federated supervision network based on trusted hardware and a block chain; performing privacy protection entity alignment; performing causal consistency verification on the source features in the trusted execution environment of the enterprise side to prevent data counterfeiting; implementing longitudinal federation cooperative training based on anti-regularization to improve the anti-attack ability of the model; and carrying out risk attribution based on the federal Sharpley value and generating a dynamic accurate sampling inspection instruction. According to the method, on the premise that data privacy and sovereignty are guaranteed, the problem of data authenticity in a supervision confrontation environment is solved by utilizing overseas source data through trusted hardware, causal verification and a confrontation training mechanism, the accuracy and anti-fraud ability of risk assessment are improved, and an accurate and efficient dynamic sampling inspection decision is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Methods and apparatus for import food customs clearance risk assessment and sampling inspection based on federated learning Technical Field

[0001] This application relates to the fields of federated learning and privacy computing, specifically to a method and apparatus for risk assessment and random inspection of imported food based on federated learning. Background Technology

[0002] The complexity of the imported food trade supply chain poses challenges to food safety supervision. Traditional regulatory models typically rely on on-site sampling and inspection after goods arrive at the port, as well as risk assessment models built based on port-side information. However, a large amount of critical risk information that determines food safety, such as environmental and climatic data of the food's country of origin and key control point parameters during production and processing, is generated and remains overseas.

[0003] In existing technologies, due to laws and regulations on data sovereignty and privacy protection, as well as the need to protect the trade secrets of supply chain participants, regulatory agencies have difficulty obtaining data from overseas sources. This results in risk assessment models being able to analyze data only based on port-side data, failing to perceive potential risks throughout the entire production chain. Furthermore, regulatory scenarios are adversarial; overseas companies may have the incentive to conceal or tamper with risk information to simplify customs clearance procedures. From a data processing perspective, cross-border supply chains primarily involve multi-source heterogeneous data, with inconsistent data distribution characteristics among participating nodes. Existing distributed collaborative training frameworks, when performing global parameter aggregation, typically lack mechanisms to verify the distribution consistency of model update parameters uploaded by nodes, making it difficult to effectively identify and remove abnormal parameters designed to degrade model performance. Simultaneously, existing secure computing protocols mainly focus on encryption protection during data transmission, lacking technical means to verify the validity of the physical logical relationships inherent in the source data, thus failing to fundamentally prevent the injection of false feature data. Traditional federated learning frameworks lack mechanisms for effectively identifying and defending against malicious participating nodes. Therefore, a technical solution is needed that can accurately assess risks using overseas source data while protecting data privacy and effectively defending against malicious attacks. Summary of the Invention

[0004] The technical problem this invention aims to solve is to overcome the inaccurate risk assessment caused by the inability to obtain data from overseas sources in the existing supervision of imported food, and the technical defects of traditional data collaboration methods being vulnerable to malicious attacks in adversarial environments.

[0005] One aspect of the present invention provides a method for assessing and sampling the customs clearance risks of imported food based on federated learning, which is executed in a vertical federated learning system consisting of a customs supervision terminal server and at least one overseas enterprise terminal node, including the following steps: Step S1: Construct a federated supervision network containing digital identity certificates and hash digests recorded by blockchain generated by the customs supervision terminal server for the overseas enterprise terminal node, and verify the local trusted execution environment of the overseas enterprise terminal node through a remote verification protocol.

[0006] Furthermore, the remote verification protocol includes: the customs supervision server sending a random number to the local trusted execution environment of the overseas enterprise node; the local trusted execution environment using its built-in private key to sign the random number, the integrity metric, and the hash value of the internally running code, and returning the signature result to the customs supervision server.

[0007] Step S2: Perform privacy-preserving cross-domain entity alignment to match the customs clearance batches held by the customs supervision server with the production batches held by the overseas enterprise node without exposing the original data.

[0008] As one implementation method, the specific steps for performing privacy-preserving cross-domain entity alignment include: Sub-step S2.1: The customs supervision terminal server and the overseas enterprise terminal node each select a private key for blinding processing; Sub-step S2.2: The two parties exchange blinding sets and use their respective private keys to perform secondary encryption again to obtain a set of double-encrypted cargo identification identifiers (IDs); Sub-step S2.3: The double-encrypted ID sets are directly compared to find the intersection.

[0009] Step S3: Within the local trusted execution environment of the overseas enterprise node, perform source feature extraction and multi-dimensional consistency verification based on the causal graph model to determine whether the logical deviation between source features exceeds a preset threshold. If the logical deviation exceeds the preset threshold, the data is deemed questionable and the local trusted execution environment refuses to calculate the gradient for the sample.

[0010] Furthermore, the specific steps of source feature extraction and multidimensional consistency verification also include: extracting multimodal source features; deploying a logical constraint verifier with an embedded business logic causal graph model; using the logical constraint verifier to perform physical logical verification on the multimodal source features; and when the data is determined to be questionable, sending an empty gradient packet with a data question mark to the customs supervision terminal server.

[0011] Step S4: Implement vertical federated collaborative training, whereby the customs supervision terminal server and the overseas enterprise terminal node jointly train a global risk assessment model based on a vertical federated learning framework.

[0012] Furthermore, the customs supervision server uses its inspection result labels to calculate the total loss function for model training. The expression for the total loss function is: L_total = L_cross_entropy + λ · L_adv; where L_cross_entropy is the cross-entropy classification loss, L_adv is the adversarial regularization term, and λ is the weight coefficient. The adversarial regularization term L_adv is calculated by the auxiliary distribution discriminator and is used to distinguish whether the feature embeddings uploaded by the overseas enterprise nodes originate from the real data distribution. In this embodiment, the customs supervision server maintains a node reputation database and dynamically adjusts its weight in the global model aggregation based on the impact of the historical gradient contribution of the overseas enterprise nodes on model performance and the frequency of triggering the logical constraint validator anomalies.

[0013] Step S5: Achieve dynamic and precise sampling inspection. Utilize the global risk assessment model after training and convergence to score the risk of newly declared imported food products and issue differentiated sampling inspection instructions based on the risk scores.

[0014] Furthermore, before issuing the differentiated inspection instructions, the marginal contribution of the customs supervision server features and the overseas enterprise node features to the current high-risk score is calculated using the Federal Shapley algorithm; and the differentiated inspection instructions are generated based on the risk score and the marginal contribution. In this embodiment, the differentiated inspection instructions include: for batches with risk scores below the safety threshold, the instructions are to release them directly; for batches with risk scores above the threshold, a precise control instruction is generated based on the feature dimension with the highest contribution, and the precise control instruction explicitly requires that the batch of goods be subject to key inspection of items associated with the feature dimension with the highest contribution.

[0015] As one implementation scheme, the present invention also includes a data protection strategy: establishing key negotiation based on the national cryptographic SM2 algorithm and encrypted communication based on the national cryptographic SM4 algorithm between the customs supervision terminal server and the overseas enterprise terminal node; and before the overseas enterprise terminal node sends back gradient information to the customs supervision terminal server, adding Laplace noise or Gaussian noise to the gradient vector in the local trusted execution environment to achieve differential privacy protection.

[0016] Another aspect of the present invention provides an imported food customs clearance risk assessment and sampling device based on federated learning, comprising: a network construction module, used to construct a federated regulatory network containing digital identity certificates and hash digests recorded by a blockchain, generated by the customs supervision server for the overseas enterprise node, and to verify the local trusted execution environment of the overseas enterprise node through a remote verification protocol; an entity alignment module, used to perform privacy-preserving cross-domain entity alignment to match the customs clearance batches held by the customs supervision server with the production batches held by the overseas enterprise node without exposing the original data; and a feature verification module, used within the local trusted execution environment of the overseas enterprise node. The system performs source feature extraction and multi-dimensional consistency verification based on a causal graph model to determine whether the logical deviation between source features exceeds a preset threshold. If the logical deviation exceeds the preset threshold, the data is deemed questionable and the local trusted execution environment refuses to calculate the gradient for that sample. A collaborative training module is used to implement vertical federated collaborative training, where the customs supervision server and the overseas enterprise node jointly train a global risk assessment model based on a vertical federated learning framework. A dynamic and precise sampling inspection module is used to achieve dynamic and precise sampling inspection, using the globally risk assessment model after training convergence to score the risk of newly declared imported food and issuing differentiated sampling inspection instructions based on the risk scores.

[0017] This invention constructs a technical system for the supervision of imported food safety through the aforementioned technical solution. This system, while protecting the data sovereignty and commercial privacy of overseas enterprises, enables customs supervisors to utilize key source data for risk assessment modeling. By combining a trusted execution environment, causal consistency verification, and adversarial regularization training—a triple defense mechanism—it effectively solves the problem of data authenticity and credibility in adversarial regulatory environments, improving the accuracy and fraud resistance of the risk assessment model. Finally, interpretable artificial intelligence technology transforms model predictions into precise sampling decisions, optimizing the allocation of regulatory resources and improving customs clearance efficiency. Attached Figure Description

[0018] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0019] Figure 1 is a schematic diagram of the system architecture of an imported food customs clearance risk assessment and sampling method based on federated learning provided by an embodiment of the present invention.

[0020] Figure 2 is a flowchart of a method for assessing and sampling imported food customs clearance based on federated learning, provided by an embodiment of the present invention.

[0021] Figure 3 is a schematic diagram of the internal structure of the source feature causal adversarial extraction and multidimensional consistency verification module in an embodiment of the present invention.

[0022] Figure 4 is a structural block diagram of an imported food customs clearance risk assessment and sampling device based on federated learning provided in an embodiment of the present invention.

[0023] Figure 5 shows the convergence curve of the federated learning model of this invention.

[0024] Figure 6 is a heat map showing the distribution of risk scores for imported food products according to the present invention.

[0025] Figure 7 is a bar chart showing the marginal contribution of the feature dimensions of this invention.

[0026] Figure 8 is a traceability card diagram of the entire chain of characteristics of a single batch of milk powder according to the present invention. Detailed Implementation

[0027] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0028] Example 1 (Referring to Figures 1 and 2) This embodiment of the invention provides a method for import food customs clearance risk assessment and random inspection based on federated learning. This method is executed in a heterogeneous vertical federated learning system consisting of a customs supervision server (hereinafter referred to as Customs 101) acting as the federated learning server and at least one overseas enterprise node (hereinafter referred to as Enterprise 102) acting as the federated learning client. The specific process of this method is as follows: Step S1: Construct a federated supervision network based on trusted hardware and blockchain collaboration and establish secure communication.

[0029] Please refer to Figure 1 to construct the federal regulatory network 100. Specifically, this step begins with the customs supervision server (hereinafter referred to as customs 101) generating a unique digital identity certificate for each overseas enterprise node (hereinafter referred to as enterprise 102) applying to join the federal network. The hash digest information of this certificate is recorded on the consortium blockchain 104 maintained by customs 101. As shown in Figure 8, this invention uses blockchain notarization to record the full-chain traceability information of imported food. The top is the consortium blockchain 104 identifier bar, displaying the batch number NZ-2025-MF-003847 and the comprehensive risk score of 0.78. The central section comprises five chain-linked evidence blocks, each corresponding to a link in the supply chain: Block 1, the raw material ranch, records the ranch ID, location, number of animals (1250), and number of drought days (45 days), with a block hash of 0x7a3f...8c2d; Block 2, the processing plant, records the plant ID, production date, spray drying process, and temperature (185 degrees Celsius); Block 3, the finished product storage, records the warehouse ID, entry date, temperature range, and storage duration (12 days); Block 4, the cross-border transportation, records the vessel number (COSCO-8827), container number (not shown), and voyage duration (14 days); Block 5, the customs port, records the arrival date and disposal instructions for opening and inspection. These blocks are linked together to form an immutable chain of traceability evidence. The bottom shows the causal verification conclusion: Rule 1 is triggered, indicating a logical contradiction between protein content and the production environment.

[0030] In this embodiment, processors supporting Trusted Execution Environment (TEE) 103 technology are deployed on the local servers of each enterprise 102. This TEE 103, as a computing environment completely isolated from the host operating system, is used to securely execute sensitive operations such as reading local raw data, feature extraction, and gradient calculation. This hardware-level isolation ensures that even if the operating system or other software of the overseas enterprise is controlled by a malicious attacker, the computational process and intermediate data performed within the TEE 103 cannot be stolen or tampered with.

[0031] Furthermore, during the federated network initialization phase, the system executes a remote verification protocol. Customs terminal 101 sends a random number to TEE 103 of enterprise terminal 102. TEE 103 of enterprise terminal 102 uses its private key to sign the random number, the integrity metric of the TEE 103 environment, and the hash value of the client code running inside, and returns the signature result to Customs terminal 101. Customs terminal 101 verifies the signature, thereby ensuring that TEE 103 of enterprise terminal 102 is authentic and trustworthy, and that the client program running within it is an untampered official version.

[0032] Simultaneously, secure communication is established between the customs terminal 101 and each enterprise terminal 102. Specifically, both parties use the national cryptographic algorithm SM2 for key negotiation to generate a session key, and then use the national cryptographic algorithm SM4 to encrypt the communication data, including model parameters, gradient information, etc.

[0033] Both parties also agreed on unified feature engineering specifications and privacy protection protocols. A differential privacy mechanism was introduced in this step. Specifically, before transmitting gradient information back to the customs terminal 101, enterprise terminal 102 adds Laplacian noise or Gaussian noise to the calculated gradient vector within its TEE 103 environment. The noise intensity is controlled by a privacy budget parameter, which can be adjusted by the customs terminal 101 as required. This effectively prevents the customs terminal 101 from inferring the original production data of enterprise terminal 102 through attacks such as gradient inversion.

[0034] Step S2: Perform privacy-preserving cross-domain entity alignment.

[0035] Because the data from Customs 101 and Enterprise 102 are physically isolated and may use different identifiers, a privacy set intersection operation is required to match samples that correspond to both sides. Specifically, Customs 101 combines the bill of lading number and container number of the batch to be evaluated, and then processes it using a hash function to obtain a primary key ID. Enterprise 102 pre-establishes an association mapping table between its internal production batch numbers and logistics bill of lading numbers. For the many-to-one situation where a container contains multiple production batches, a data aggregation strategy can be adopted, such as taking the weighted average or maximum value of the risk characteristics of each batch as the comprehensive source feature of the container. For the one-to-many situation where a production batch is split into multiple container shipments, the source data of the same batch is copied to match different container primary key IDs.

[0036] Subsequently, both parties execute a blind matching protocol based on the elliptic curve Diffie-Hellman principle, where H(·) represents a cryptographic hash function, ID represents the identification identifier of the goods, and a and b represent the private keys selected by both parties. Specifically, the protocol includes the following sub-steps: Sub-step S2.1: Customs end 101 and enterprise end 102 each select a private key, denoted as a and b. Customs end 101 performs blinding processing on the hash value H(ID) of each ID in its own ID set, calculating H(ID)^a (ID belongs to Set_customs); Enterprise end 102 performs blinding processing on the hash value H(ID) of each ID in its own ID set, calculating H(ID)^b (ID belongs to Set_enterprise).

[0037] Sub-step S2.2: Both parties exchange blinding sets and perform secondary encryption again using their respective private keys. Customs side 101 calculates (H(ID)^b)^a, and enterprise side 102 calculates (H(ID)^a)^b. Based on the elliptic curve Diffie-Hellman (ECDH) commutative encryption property, the commutative law is satisfied: (H(ID)^a)^b = (H(ID)^b)^a = H(ID)^(ab). This means that for the same ID, regardless of the encryption order, the final double encryption result is the same.

[0038] Sub-step S2.3: Since both parties ultimately obtain a set of IDs with double encryption and the same power, i.e., set H(ID)^ab, this set can be directly compared to find the intersection and identify the matching sample. During this process, neither party reveals their original ID information or private key. After successful alignment, both parties only load the relevant feature data of the matching sample into the subsequent computing environment, ensuring the principle of minimizing data exposure.

[0039] Step S3: Extract causal adversarial features from the source and perform multidimensional consistency verification.

[0040] Please refer to Figure 3. This step is performed within the TEE 103 environment of enterprise side 102 and is a key step in ensuring the authenticity of overseas source data.

[0041] First, multimodal end-to-end feature extraction is performed. The feature extraction module 301 on the enterprise side 102 reads various source data related to the aligned samples from the local database 302. For structured data, such as the physicochemical indicators of production batches, the geographical coordinates of raw material origins, and temperature and duration during processing, normalization or one-hot encoding is performed. For unstructured data, such as screenshots from monitoring videos of key processes in the production workshop and scanned PDF quality inspection reports issued by third-party laboratories, high-dimensional feature vectors are extracted using a pre-trained deep learning model. As a preferred embodiment, for image data such as scanned PDF quality inspection reports, the pre-trained deep learning model uses a ResNet-50 network structure for feature extraction; for video data such as monitoring videos, a C3D (Convolutional 3D) network structure is used to extract spatiotemporal features.

[0042] E = |Y - f(X)| where Y is the actual observed value of the node feature, f(X) is the theoretical value inferred based on the parent node feature and through the causal relationship function, and |.| represents the absolute value operation. When E>T_h (where T_h is the deviation threshold set based on the statistical distribution of historical normal data, and in this embodiment, its value range is preferably set to a normalized value [0.05, 0.15]), the system determines that there is a logical contradiction. At this time, TEE 103 will refuse to calculate the gradient for the sample and instead send a special empty gradient packet 305 with a data doubt flag to the customs terminal 101. This mechanism can prevent illogical false data from entering the model training process from the source and directly trigger the highest level of inspection warning of the customs terminal 101.

[0043] Step S4: Implement longitudinal federated collaborative training based on adversarial regularization and dynamic weights.

[0044] Customs terminal 101 and enterprise terminal 102 jointly trained a global risk assessment model based on a vertical federated learning framework. As shown in Figure 5, this invention demonstrates the convergence performance of the global risk assessment model during vertical federated collaborative training. The experimental data is based on a simulated dataset containing 10,000 historical customs clearance batches. The experimental environment uses a server equipped with a high-performance GPU, and the network bandwidth between nodes is limited to 100Mbps to simulate a cross-border network environment. In the figure, the horizontal axis represents the training epochs, ranging from 1 to 50 epochs; the left vertical axis represents the value of the total loss function L_total, and the right vertical axis represents the validation set AUC metric. From the curve trend, it can be observed that the total loss function shows a rapid decreasing trend in the early stage of training, and begins to flatten out around the 20th epoch, eventually converging to around 0.15; the validation set AUC shows the opposite upward trend, gradually increasing from the initial 0.5 to above 0.92. This convergence curve shows that the federated collaborative training strategy based on adversarial regularization can effectively optimize the global risk assessment model, enabling it to achieve high prediction accuracy while protecting data privacy. First, the enterprise end 102 calculates the intermediate embedding representation of its local features after passing through a partial layer of the neural network within its TEE 103, and sends it to the customs end 101. Specifically, in one embodiment, the partial layer of the neural network is constructed as a three-layer multilayer perceptron (MLP), with the number of neurons in each layer set to 128, 64, and 32 respectively, and the ReLU function is selected as the activation function. After receiving the embedded features from the enterprise end, the customs end 101 concatenates and fuses them with the port clearance features locally held by the customs end (such as the reasonableness of the declared price, commodity classification code, historical risk rating of the exporting country, etc.). The fused complete feature vector is input into the top layer network of the model to calculate the risk prediction probability of this batch of goods.

[0045] When calculating the loss, Customs Unit 101 uses its actual inspection result labels to design and calculate an adversarial regularization loss function. In this embodiment, the expression for the total loss function L_total is: L_total = L_cross_entropy + λ · L_adv.

[0046] Where L_cross_entropy is the standard cross-entropy classification loss, used to measure the difference between the model's predicted probability and the true label. L_adv is the adversarial regularization term, and λ is its weight coefficient. In this embodiment, the weight coefficient λ is preferably set to [0.1, 0.5] to achieve a balance between model classification accuracy and privacy protection strength.

[0047] L_adv aims to enhance the model's resistance to attacks. Specifically, it introduces an auxiliary distribution discriminator D at the customs end (101). This discriminator engages in a mini-max game with the main risk assessment model (generator G). The discriminator D's task is to distinguish whether the feature embedding h_i uploaded by the enterprise end (102) originates from the real data distribution p_data or the potentially forged data distribution p_fake. The discriminator's loss function L_D is defined as: L_D = - ( E[ log(D(h_real)) ] + E[ log(1 - D(h_fake)) ]), where h_real comes from known compliant historical samples, h_fake is the feature embedding of the current sample to be verified, and E[.] represents the expectation. By adding the adversarial loss term L_adv (i.e., attempting to maximize the discriminator's misclassification rate) to the main model's optimization objective, the main model is forced to learn to generate feature embeddings that conform to the statistical laws of real data, thereby increasing the difficulty of feature forgery. During the training process, the customs and enterprise sides alternately update parameters to achieve the Nash equilibrium of the game.

[0048] During the gradient calculation and model update phases, Customs terminal 101 calculates the gradient of the loss function with respect to each parameter and encrypts the gradient related to the embedding of overseas features before sending it back to Enterprise terminal 102. In scenarios involving multiple overseas enterprises, Customs terminal 101 also maintains a node reputation database. Based on the impact of each node's historical gradient contribution on model performance and the frequency with which it triggers consistency verification anomalies, Customs terminal 101 dynamically adjusts its weight in the global model aggregation, downweighting poorly performing or suspicious nodes, and even temporarily excluding them from federated training.

[0049] Step S5: Implement dynamic and accurate sampling based on the federal Shapley value.

[0050] Once the global risk assessment model training converges, the system enters the online inference and application phase. For each newly declared batch of imported food, the system performs real-time inference through a federated network, outputting a comprehensive risk score. To achieve interpretable regulation, the system utilizes the federated Shapley Value algorithm to calculate the marginal contribution of customs-side features and enterprise-side features to the current high-risk score without disclosing the original data from all parties.

[0051] For the i-th feature in the feature set N, its Shapley value phi_i is calculated using the following formula:

[0052] Where S is all possible feature subsets that do not contain feature i, N is the set of all features, |S| represents the number of elements in subset S, |N| represents the total number of features, and v(S) represents the contribution of feature subset S to the model prediction result (i.e., the prediction probability).

[0053] Preferably, to meet the real-time requirements of customs clearance, and considering the excessive computational cost of traversing all subsets S, this invention employs an approximate algorithm based on Monte Carlo sampling to efficiently calculate the Shapley value. Specifically, by randomly sampling multiple feature permutations, the average of the marginal contribution [v(SU i) - v(S)] before and after adding feature i is calculated to estimate phi_i. As shown in Figure 7, the bar chart of this invention illustrates the marginal contribution of each feature dimension calculated by the federal Shapley value algorithm to the high-risk score. The features are divided into two groups: customs supervision features and overseas enterprise features. Customs supervision features include declared price deviation, historical violation records, commodity classification codes, and export country risk ratings; overseas enterprise features include origin pesticide records, production process parameters, abnormal quality inspection reports, warehouse temperature control records, and raw material traceability completeness. It can be observed from the figure that origin pesticide records and declared price deviation have the highest marginal contributions, reaching 0.22 and 0.18 respectively, indicating that these two feature dimensions have the most significant impact on the risk score. The attribution analysis results provide a basis for decision-making in generating precise deployment instructions.

[0054] Finally, the system issues dynamically differentiated sampling instructions based on the risk score and Shapley value attribution results. As shown in Figure 6, the heat map of this invention displays the risk score distribution of different product categories and exporting country combinations. The horizontal axis represents eight major imported food categories, including dairy products, meat, aquatic products, fruits, grains, condiments, beverages, and confectionery; the vertical axis represents ten major food exporting countries. The color intensity represents the average risk score of the combination, ranging from 0 to 1. It can be observed from the figure that traditional advantageous production areas such as New Zealand dairy products and Australian meat exhibit lower risk scores, while combinations of some emerging production areas with specific product categories exhibit higher risk scores. This heat map provides customs supervisors with an intuitive view of risk distribution, which helps in formulating differentiated sampling strategies. For example, batches with risk scores below the safety threshold can be directly ordered to be released quickly. For batches with risk scores above the threshold, the system will generate precise control instructions based on the feature dimension with the highest contribution. For example, if the attribution results show that the "pesticide use records at the place of origin" provided by the enterprise contributes the most to the high-risk score, the sampling inspection order will explicitly require "focusing on testing for specific types of pesticide residues" for that batch of goods, thus replacing the traditional, inefficient random sampling inspection model. The actual results of on-site inspections are recorded and fed back to the system as new high-quality labels, used to trigger incremental learning or periodic retraining of the model, thereby forming a continuous optimization closed loop of data-model-inspection-data.

[0055] Example 2 (Referring to Figure 4) also provides an imported food customs clearance risk assessment and sampling device 200 based on federated learning. This device can be a server at the customs end 101 or the enterprise end 102, or a system deployed on it. The device 200 may include: a network construction module 201, used to execute step S1 described in Example 1, that is, to construct a federated regulatory network based on trusted hardware and blockchain collaboration, including functions such as node identity authentication and remote verification of trusted execution environment.

[0056] The entity alignment module 202 is used to perform step S2 as described in embodiment 1, that is, based on privacy computing technologies such as homomorphic encryption, to perform privacy-preserving cross-domain entity alignment without disclosing their respective data, and to match the samples that correspond to both the customs end and the enterprise end.

[0057] The feature verification module 203 is typically deployed on the enterprise side to perform step S3 as described in Example 1, that is, to perform multimodal extraction of source features in a trusted execution environment, and to verify the logical consistency between features through the logical constraint verifier 303 of the embedded causal graph model 304 in order to defend against data forgery attacks.

[0058] The collaborative training module 204 is used to perform step S4 as described in Example 1, that is, to implement collaborative training based on adversarial regularization and dynamic weights based on the longitudinal federated learning framework to generate an accurate and robust global risk assessment model.

[0059] The dynamic and precise sampling inspection module 205 is typically deployed at the customs end to execute step S5 described in Example 1, which involves using a trained model to perform online risk scoring and attribution analysis using the Federal Shapley value algorithm, ultimately generating and issuing dynamic and precise sampling inspection instructions.

[0060] Example 3: This example uses the customs clearance supervision of a batch of high-value imported infant formula milk powder as an application scenario. The safety and quality of milk powder depends on multiple key process parameters throughout the entire overseas production chain, such as the environmental conditions of the pasture, the physicochemical indicators of raw milk, and the key process parameters of the spray drying tower. These data are all provided by overseas manufacturers, making verification difficult using traditional regulatory methods.

[0061] First, step S1 is executed to construct and verify the federated regulatory network. In this embodiment, the customs terminal 101 acts as the server, and the enterprise terminal 102 acts as the client, jointly deploying the federated learning system described in this invention. To ensure the trustworthiness of the source environment, the customs terminal periodically sends random number challenges (Nonces) to the enterprise terminal. The enterprise terminal uses the TEE's hardware private key to sign the random number and code hash value and returns it to complete remote verification. When the enterprise declares a batch of imported milk powder, the system enters step S2, the privacy-preserving cross-domain entity alignment stage. The system uses a privacy set intersection operation based on the elliptic curve Diffie-Hellman key exchange protocol to accurately match the customs declaration batch to be inspected on the customs supervision terminal server with the internal production batch of the overseas enterprise terminal node without disclosing the original information of each batch or customs declaration number.

[0062] In step S3, source feature extraction and verification, within the Trusted Execution Environment (TEE) 103 deployed on the enterprise side 102, the system automatically extracts multi-dimensional source feature data corresponding to the production batch. This data includes: historical meteorological remote sensing data of the raw milk source farm, the farm's current feed procurement records, the energy consumption records of the spray drying tower on the production line, and finished product quality inspection reports issued by the enterprise or a third-party laboratory. At this point, the logic constraint validator deployed within TEE 103 comes into play. Its built-in causal graph model contains a series of expert rules. For example, rule one states that the protein content of raw milk is positively correlated with the quality of pasture growth (which can be reflected through historical meteorological data) and the nutritional composition of feed; rule two states that the energy consumption of the spray drying process and the declared milk powder finished product output should be within a preset reasonable range.

[0063] During the verification process, the verifier discovered that while the finished product test report uploaded by the company showed that the protein content met the standards, the historical weather data of the corresponding raw milk source farm during the relevant production cycle showed continuous drought, and the proportion of high-protein feed in the feed purchase records for that cycle did not increase. This situation violates Rule 1 of the causal graph model, indicating a logical contradiction between the feature data. Therefore, TEE 103 determined that the sample data was questionable, refused to calculate the model gradient for it, and sent a special empty gradient packet containing a data doubt flag to the customs supervision server. Upon receiving this flag, the customs supervision system generated an instruction for the port inspection personnel, requiring them to conduct an unpacking inspection and laboratory testing of the batch of goods. Under normal circumstances where the data verification passes, step S4 is executed to implement vertical federated collaborative training. Based on the vertical federated learning framework, the customs and the company interact with encrypted intermediate results (Embedding) and gradients to jointly optimize the global risk assessment model. Finally, step S5 is executed to achieve dynamic and accurate sampling inspection. For another batch that passed the verification but had a high model score, the system used the Federal Shapley value algorithm to perform risk attribution and found that the "finished product storage temperature and humidity record" feature contributed the most to the high-risk score. Therefore, it generated a precise control instruction to "focus on checking the temperature control record of the goods in transit and randomly test the total number of colonies" to optimize the allocation of regulatory resources.

[0064] The above description is merely a preferred 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 customs clearance risk assessment and random inspection of imported food based on federated learning, characterized in that, The process is executed in a vertical federated learning system consisting of a customs supervision server and at least one overseas enterprise node, including the following steps: Step S1: Construct a federated supervision network containing digital identity certificates and hash digests recorded by the blockchain, generated by the customs supervision server for the overseas enterprise node, and verify the local trusted execution environment of the overseas enterprise node through a remote verification protocol; Step S2: Perform privacy-preserving cross-domain entity alignment to match the customs clearance batches held by the customs supervision server with the production batches held by the overseas enterprise node without exposing the original data; Step S3: In the local trusted execution environment of the overseas enterprise node... Domestically, source feature extraction and multi-dimensional consistency verification based on a causal graph model are performed to determine whether the logical deviation between source features exceeds a preset threshold. If the logical deviation exceeds the preset threshold, the data is deemed questionable and the gradient is refused to be calculated for the sample through the local trusted execution environment. Step S4: Vertical federated collaborative training is implemented, where the customs supervision terminal server and the overseas enterprise terminal node jointly train a global risk assessment model based on a vertical federated learning framework. Step S5: Dynamic and accurate sampling inspection is achieved by using the global risk assessment model after training convergence to score the risk of newly declared imported food and issuing differentiated sampling inspection instructions based on the risk scores.

2. The method according to claim 1, characterized in that, In step S1, the remote verification protocol includes: the customs supervision server sending a random number to the local trusted execution environment of the overseas enterprise node; the local trusted execution environment using its built-in private key to sign the random number, the integrity metric of the local trusted execution environment, and the hash value of the internally running code, and returning the signing result to the customs supervision server.

3. The method according to claim 1, characterized in that, In step S3, the specific steps of source feature extraction and multidimensional consistency verification include: extracting multimodal source features; deploying a logic constraint verifier with an embedded business logic causal graph model; using the logic constraint verifier to perform physical logic verification on the multimodal source features; and when the data is determined to be questionable, sending an empty gradient packet with a data question mark to the customs supervision terminal server.

4. The method according to claim 3, characterized in that, In step S4, the customs supervision server uses its unique inspection result label to calculate the total loss function for model training. The expression of the total loss function is: L_total = L_cross_entropy + λ · L_adv; where L_cross_entropy is the cross-entropy classification loss, L_adv is the adversarial regularization term, and λ is the weight coefficient; the adversarial regularization term L_adv is calculated by the auxiliary distribution discriminator and is used to distinguish whether the feature embedding uploaded by the overseas enterprise terminal node originates from the real data distribution.

5. The method according to claim 3 or 4, characterized in that, Step S4 further includes: the customs supervision terminal server maintains a node reputation database, and dynamically adjusts its weight in the global model aggregation based on the impact of the historical gradient contribution of the overseas enterprise terminal node on the model performance and the frequency of triggering the logical constraint validator anomaly.

6. The method according to claim 1, characterized in that, Step S5 further includes: before issuing the differentiated inspection instruction, using the Federal Shapley algorithm to calculate the marginal contribution of the characteristics of the customs supervision terminal server and the characteristic dimensions of the overseas enterprise terminal to the current risk score; and generating the differentiated inspection instruction based on the risk score and the marginal contribution.

7. The method according to claim 6, characterized in that, The differentiated sampling instructions include: for batches with risk scores below the safety threshold, the instructions are to release them directly; for batches with risk scores above the safety threshold, a precise control instruction is generated based on the feature dimension with the highest contribution, and the precise control instruction explicitly requires the inspection of items related to the feature dimension with the highest contribution for that batch of goods.

8. The method according to claim 1, characterized in that, In step S2, the specific steps for performing privacy-preserving cross-domain entity alignment include: Sub-step S2.1: The customs supervision server and the overseas enterprise node each select a private key for blinding processing; Sub-step S2.2: The two parties exchange blinding sets and use their respective private keys to perform secondary encryption again to obtain a set of double-encrypted cargo identifiers; Sub-step S2.3: The double-encrypted identifier sets are directly compared to find the intersection.

9. The method according to claim 1, characterized in that, It also includes data protection strategies: establishing key negotiation based on the national cryptographic SM2 algorithm and encrypted communication based on the national cryptographic SM4 algorithm between the customs supervision terminal server and the overseas enterprise terminal node; and before the overseas enterprise terminal node sends gradient information back to the customs supervision terminal server, adding Laplace noise or Gaussian noise to the gradient vector in the local trusted execution environment to achieve differential privacy protection.

10. A device for import food customs clearance risk assessment and sampling inspection based on federated learning, characterized in that, include: The network construction module is used to construct a federal regulatory network that includes digital identity certificates and hash digests recorded by the blockchain, generated by the customs supervision terminal server for the overseas enterprise terminal nodes, and to verify the local trusted execution environment of the overseas enterprise terminal nodes through a remote verification protocol. The entity alignment module is used to perform privacy-preserving cross-domain entity alignment, so as to match the customs clearance batches held by the customs supervision server with the production batches held by the overseas enterprise node without exposing the original data. The feature verification module is used to perform source feature extraction and multi-dimensional consistency verification based on the causal graph model in the local trusted execution environment of the overseas enterprise end node, so as to determine whether the logical deviation between source features exceeds a preset threshold, and when the logical deviation exceeds the preset threshold, the data is deemed suspicious and the local trusted execution environment refuses to calculate the gradient for the sample. The collaborative training module is used to implement vertical federated collaborative training, in which the customs supervision terminal server and the overseas enterprise terminal node jointly train a global risk assessment model based on the vertical federated learning framework; the dynamic and precise sampling inspection module is used to realize dynamic and precise sampling inspection, using the global risk assessment model after training convergence to score the risk of newly declared imported food, and issuing differentiated sampling inspection instructions based on the risk score.