Integrating Blockchain Traceability and Deep Learning for Risk Prediction in Grain and Oil Food Safety
Abstract
1. Introduction
2. Materials and Methods
2.1. Blockchain
2.2. SM2 Algorithm
2.3. Smart Contract
2.4. GRA-TabNet-BO Risk Prediction Model
2.4.1. Architectural Framework of the GRA-TabNet-BO Model
2.4.2. The Grey Relational Analysis
2.4.3. TabNet Model Based on Bayesian Optimization
TabNet Model
Bayesian Optimization for Hyperparameter Tuning
2.5. Risk Prediction Framework Based on Blockchain and Deep Learning
- (1)
- Data Collection Layer: The data collection layer is the foundational layer of the framework, responsible for collecting raw data from various stages of grain and oil food production and testing. By establishing diversified data collection mechanisms, it ensures the comprehensiveness and completeness of the data. This data includes quality testing values (such as pesticide residues, mycotoxins, heavy metal contamination, etc.) and key information such as production batches, enabling comprehensive monitoring and traceability of grain and oil food quality. The key task of the data collection layer is to ensure the reliability and integrity of data sources, build a stable data collection network, prevent data omission or tampering, and provide robust data support for subsequent quality assessment, risk prediction, and regulatory oversight.
- (2)
- Business Layer: The business layer is the core component of the framework, responsible for screening data exceeding quality and safety standards for grain and oil food products and for predicting risks. This layer integrates deep learning models with smart contracts to ensure data credibility and traceability. First, smart contracts automatically screen uploaded data based on predefined quality standards. Because smart contracts execute without human intervention, they automatically identify data exceeding standards. This automated screening process reduces the time and error rates associated with manual review, ensuring efficient and consistent data processing. Next, a pre-trained deep learning model interface is invoked for risk prediction. This model combines gray relational analysis (GRA) with Bayesian optimization of tabular neural networks (TabNet-BO) to provide accurate, granular predictions, effectively identifying potential quality risks. Finally, exceeding data (such as product information and test values) and prediction results (such as predicted values and risk levels) are uploaded to the blockchain. The blockchain not only ensures immutability and decentralization but also enhances data transparency and traceability—no party can alter the uploaded data, significantly boosting security and credibility.
- (3)
- Data Storage Layer: The data storage layer is responsible for data storage and management. To address the storage limitations of blockchain, this layer employs a two-tier storage strategy. Exceeding data (such as quality inspection values or prediction results) filtered by the smart contract will be uploaded to the blockchain. Due to the high cost and limitations of blockchain storage, only data critical to quality and safety will be uploaded. Non-exceeding data is stored in a local database, where it is protected using the SM2 encryption storage mechanism. The SM2 algorithm, as a public-key cryptography scheme, ensures that data remains unaltered and secure during storage. By uploading only exceeding data to the blockchain, unnecessary data waste is avoided, optimizing storage efficiency. Additionally, the combination of a local database and blockchain enables the system to balance data security while effectively distributing storage pressure, thereby enhancing overall performance.
3. Results
3.1. System Efficiency Evaluation Under Tiered Storage Strategy
3.2. Performance Evaluation of the Risk Prediction Model
3.2.1. Risk Dataset Analysis and Model Configuration
3.2.2. Model Performance Evaluation
3.2.3. Model Interpretability and Efficiency Analysis
4. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Shewry, P.R. Can We Increase the Use of Wheat and Other Cereals as Sources of Protein? J. Cereal Sci. 2024, 117, 103899. [Google Scholar] [CrossRef]
- Almeida, N.A.; Freire, L.; Carnielli-Queiroz, L.; Bragotto, A.P.; Silva, N.C.; Rocha, L.O. Essential Oils: An Eco-Friendly Alternative for Controlling Toxigenic Fungi in Cereal Grains. Compr. Rev. Food Sci. Food Saf. 2024, 23, e13251. [Google Scholar] [CrossRef] [PubMed]
- Madhukar, P.; Pandey, L.M.; Dixit, U.S. Post-Harvest Grain Storage: Methods, Factors, and Eco-Friendly Solutions. Food Control 2025, 174, 111236. [Google Scholar] [CrossRef]
- Bai, E.; Guo, W.; Zhang, H.; Tan, Y.; Li, X.; Wei, Z. Degradation Mechanism of Cultivated Land and Its Protection Technology in the Central Coal-Grain Overlapped Area of China. J. Clean. Prod. 2024, 468, 143075. [Google Scholar] [CrossRef]
- Li, M.; Chen, L.; Yang, Y.; Wu, S.; Zhang, Q.; Deng, X.; Zeng, Q. Analysis of the Phytoremediation Potential, Rice Safety, and Economic Benefits of Light to Moderate Cd-Contaminated Farmland in Oilseed Rape-Rice Rotation with Straw Removal: A Three-Year Field Trial. Environ. Res. 2024, 263, 120280. [Google Scholar] [CrossRef]
- Fu, J.; Yue, X.; Zhang, Q.; Li, P. Early Warning Technologies for Mycotoxins in Grains and Oilseeds: A Review. Trends Food Sci. Technol. 2024, 148, 104479. [Google Scholar] [CrossRef]
- Cui, H.; Wang, S.; Yang, X.; Zhang, W.; Chen, M.; Wu, Y.; Wang, S. Predictive Models for Assessing the Risk of Fusarium pseudograminearum Mycotoxin Contamination in Post-Harvest Wheat with Multi-Parameter Integrated Sensors. Food Chem. X 2022, 16, 100472. [Google Scholar] [CrossRef]
- Hudu, A.R.; Addy, F.; Mahunu, G.K.; Abubakari, A.H.; Opoku, N. Zearalenone Contamination in Maize, Its Associated Producing Fungi, Control Strategies, and Legislation in Sub-Saharan Africa. Food Sci. Nutr. 2024, 12, 4489–4512. [Google Scholar] [CrossRef]
- Balczewski, E.A.; Cao, J.; Singh, K. Risk Prediction and Machine Learning: A Case-Based Overview. Clin. J. Am. Soc. Nephrol. 2023, 18, 524–526. [Google Scholar] [CrossRef]
- Freire, P.; Freire, D.; Licon, C.C. A Comprehensive Review of Machine Learning and Its Application to Dairy Products. Crit. Rev. Food Sci. Nutr. 2025, 65, 1878–1893. [Google Scholar] [CrossRef]
- Rodrigues, M.; Migueis, V.; Freitas, S.; Machado, T. Machine Learning Models for Short-Term Demand Forecasting in Food Catering Services: A Solution to Reduce Food Waste. J. Clean. Prod. 2024, 435, 140265. [Google Scholar] [CrossRef]
- Geng, Z.; Duan, X.; Li, J.; Chu, C.; Han, Y. Risk Prediction Model for Food Safety Based on Improved Random Forest Integrating Virtual Sample. Eng. Appl. Artif. Intell. 2022, 116, 105352. [Google Scholar] [CrossRef]
- Lü, Q.X.; Tang, Z.X.; Tang, Z.; Dong, G.; Xu, Z.R.; Zhao, F.J.; Wang, P. Interpretable Machine Learning Models to Predict Cadmium in Wheat for Safe Production and Soil Management. Fundam. Res. 2025; in press. [Google Scholar]
- Zhang, Y. Food Safety Risk Intelligence Early Warning Based on Support Vector Machine. J. Intell. Fuzzy Syst. 2020, 38, 6957–6969. [Google Scholar] [CrossRef]
- Sheng, W.; Jiang, H.; Yang, Z.; Zhao, L.; Jin, J. A Safety Risk Assessment Method Based on Conditionally Constrained Game Theory and Adaptive Ensemble Learning: Application to Wheat Flour and Rice. Food Res. Int. 2025, 203, 115835. [Google Scholar] [CrossRef] [PubMed]
- Foukalas, F. A Survey of Artificial Neural Network Computing Systems. Cogn. Comput. 2025, 17, 4. [Google Scholar] [CrossRef]
- Geng, Z.; Liu, F.; Shang, D.; Han, Y.; Shang, Y.; Chu, C. Early Warning and Control of Food Safety Risk Using an Improved AHC-RBF Neural Network Integrating AHP-EW. J. Food Eng. 2021, 292, 110239. [Google Scholar] [CrossRef]
- Niu, B.; Zhang, H.; Zhou, G.; Zhang, S.; Yang, Y.; Deng, X.; Chen, Q. Safety Risk Assessment and Early Warning of Chemical Contamination in Vegetable Oil. Food Control 2021, 125, 107970. [Google Scholar] [CrossRef]
- Geng, Z.; Shang, D.; Han, Y.; Zhong, Y. Early Warning Modeling and Analysis Based on a Deep Radial Basis Function Neural Network Integrating an Analytic Hierarchy Process: A Case Study for Food Safety. Food Control 2019, 96, 329–342. [Google Scholar] [CrossRef]
- Zhong, J.; Sun, L.; Zuo, E.; Chen, C.; Chen, C.; Jiang, H.; Lv, X. An Ensemble of AHP-EW and AE-RNN for Food Safety Risk Early Warning. PLoS ONE 2023, 18, e0284144. [Google Scholar] [CrossRef]
- Han, Y.; Cui, S.; Geng, Z.; Chu, C.; Chen, K.; Wang, Y. Food Quality and Safety Risk Assessment Using a Novel HMM Method Based on GRA. Food Control 2019, 105, 180–189. [Google Scholar] [CrossRef]
- Lüth, S.; Boone, I.; Kleta, S.; Al Dahouk, S. Analysis of RASFF Notifications on Food Products Contaminated with Listeria Monocytogenes Reveals Options for Improvement in the Rapid Alert System for Food and Feed. Food Control 2019, 96, 479–487. [Google Scholar] [CrossRef]
- Nogales, A.; Díaz-Morón, R.; García-Tejedor, Á.J. A Comparison of Neural and Non-Neural Machine Learning Models for Food Safety Risk Prediction with European Union RASFF Data. Food Control 2022, 134, 108697. [Google Scholar] [CrossRef]
- Arik, S.Ö.; Pfister, T. TabNet: Attentive Interpretable Tabular Learning. Proc. AAAI Conf. Artif. Intell. 2021, 35, 6679–6687. [Google Scholar] [CrossRef]
- Asencios, R.; Asencios, C.; Ramos, E. Profit Scoring for Credit Unions Using the Multilayer Perceptron, XGBoost and TabNet Algorithms: Evidence from Peru. Expert Syst. Appl. 2023, 213, 119201. [Google Scholar] [CrossRef]
- Hong, Z.; Tao, M.; Liu, L.; Zhao, M.; Wu, C. An Intelligent Approach for Predicting Overbreak in Underground Blasting Operation Based on an Optimized XGBoost Model. Eng. Appl. Artif. Intell. 2023, 126, 107097. [Google Scholar] [CrossRef]
- Hu, S.; Huang, S.; Huang, J.; Su, J. Blockchain and Edge Computing Technology Enabling Organic Agricultural Supply Chain: A Framework Solution to Trust Crisis. Comput. Ind. Eng. 2021, 153, 107079. [Google Scholar] [CrossRef]
- Peng, T.; Wang, L. Blockchain-Enabled Traceability for Rice Blending Fraud: A Practical Framework to Strengthen Supply Chain Integrity in Smart Agricultural IoT. Internet Things 2025, 31, 101824. [Google Scholar] [CrossRef]
- Biswas, D.; Jalali, H.; Ansaripoor, A.H.; De Giovanni, P. Traceability vs. Sustainability in Supply Chains: The Implications of Blockchain. Eur. J. Oper. Res. 2023, 305, 128–147. [Google Scholar] [CrossRef]
- Jiang, L.; Yao, A.; Li, W.; Wei, Q. Blockchain Technology Empowers the Cross-Border Dual-Channel Supply Chain: Introduction Strategy, Tax Differences, Optimal Decisions. Comput. Ind. Eng. 2024, 195, 110431. [Google Scholar] [CrossRef]
- Liu, Z.; Yu, X.; Liu, N.; Liu, C.; Jiang, A.; Chen, L. Integrating AI with Detection Methods, IoT, and Blockchain to Achieve Food Authenticity and Traceability from Farm-to-Table. Trends Food Sci. Technol. 2025, 158, 104925. [Google Scholar] [CrossRef]
- Verna, E.; Genta, G.; Galetto, M. Enhanced Food Quality by Digital Traceability in Food Processing Industry. Food Eng. Rev. 2025, 17, 359–383. [Google Scholar] [CrossRef]
- Ruan, Y.; Unachukwu, P.; Benjakul, S.; Zhang, Y.; Fu, Y. The Emerging Role of Blockchain Technology in Ensuring Food Safety: A Review. Trends Food Sci. Technol. 2026, 168, 105489. [Google Scholar] [CrossRef]
- Khanna, A.; Jain, S.; Burgio, A.; Bolshev, V.; Panchenko, V. Blockchain-Enabled Supply Chain Platform for Indian Dairy Industry: Safety and Traceability. Foods 2022, 11, 2716. [Google Scholar] [CrossRef] [PubMed]
- Malik, M.; Mor, R.S.; Gahlawat, V.K.; Kumar, V. Unlocking the Potential: Hybrid Blockchain and AI-Enabled Traceability Model Development and Implementation in the Dairy Industry—Proof-of-Concept. Transp. Res. Part E Logist. Transp. Rev. 2026, 205, 104552. [Google Scholar] [CrossRef]
- Rehman, K.U.; Andleeb, S.; Ashfaq, M.; Akram, N.; Akram, M.W. Blockchain-Enabled Smart Agriculture: Enhancing Data-Driven Decision Making and Ensuring Food Security. J. Clean. Prod. 2023, 427, 138900. [Google Scholar] [CrossRef]
- Kaliji, S.A.; Pakseresht, A.; Hocquette, J.F. Can Blockchain Revolutionize Meat Production? Addressing Transparency, Trust, and Compliance in Conventional and Cultured Meat. Trends Food Sci. Technol. 2025, 163, 105197. [Google Scholar] [CrossRef]
- Ni, W.; Asheralieva, A.; Kang, J.; Xiong, Z.; Maple, C.; Wei, X. An Enhanced Block Validation Framework with Efficient Consensus for Secure Consortium Blockchains. IEEE Trans. Serv. Comput. 2023, 17, 420–436. [Google Scholar] [CrossRef]
- Kim, S.K.; Vong, H.C. Secured Network Architectures Based on Blockchain Technologies: A Systematic Review. ACM Comput. Surv. 2025, 57, 1–24. [Google Scholar] [CrossRef]
- Liu, Y.; He, J.; Li, X.; Chen, J.; Liu, X.; Peng, S.; Cao, H.; Wang, Y. An Overview of Blockchain Smart Contract Execution Mechanism. J. Ind. Inf. Integr. 2024, 41, 100674. [Google Scholar] [CrossRef]
- Guan, S.; Wang, Z.; Cao, Y. A Novel Blockchain-Based Model for Agricultural Product Traceability System. IEEE Commun. Mag. 2023, 61, 124–129. [Google Scholar] [CrossRef]
- Kuznetsov, O.; Rusnak, A.; Yezhov, A.; Kuznetsova, K.; Kanonik, D.; Domin, O. Merkle Trees in Blockchain: A Study of Collision Probability and Security Implications. Internet Things 2024, 26, 101193. [Google Scholar] [CrossRef]
- El Hajji, M.; Es-saady, Y.; Ait Addi, M.; Antari, J. Optimization of Agrifood Supply Chains Using Hyperledger Fabric Blockchain Technology. Comput. Electron. Agric. 2024, 227, 109503. [Google Scholar] [CrossRef]
- Wang, Y.X.; Hsueh, Y.L. A Low-Storage Synchronization Framework for Blockchain Systems. J. Netw. Comput. Appl. 2024, 231, 103977. [Google Scholar] [CrossRef]
- Bellaj, B.; Ouaddah, A.; Bertin, E.; Crespi, N.; Mezrioui, A. Drawing the Boundaries Between Blockchain and Blockchain-Like Systems: A Comprehensive Survey on Distributed Ledger Technologies. Proc. IEEE 2024, 112, 247–299. [Google Scholar] [CrossRef]
- Shao, W.; Wang, J.; Wang, L.; Jia, C.; Xu, S.; Zhang, S. Auditable Blockchain Rewriting in Permissioned Setting with Mandatory Revocability for IoT. IEEE Internet Things J. 2023, 10, 21322–21336. [Google Scholar] [CrossRef]
- Puthenveettil, N.R.; Sappati, P.K. A Review of Smart Contract Adoption in Agriculture and Food Industry. Comput. Electron. Agric. 2024, 223, 109061. [Google Scholar] [CrossRef]
- Hasan, H.R.; Musamih, A.; Salah, K.; Jayaraman, R.; Omar, M.; Arshad, J.; Boscovic, D. Smart Agriculture Assurance: IoT and Blockchain for Trusted Sustainable Produce. Comput. Electron. Agric. 2024, 224, 109184. [Google Scholar] [CrossRef]
- Liu, P.; Fu, Y.; Wang, P.; Wu, X. Grey Relational Analysis- and Clustering-Based Opinion Dynamics Model in Social Network Group Decision Making. Inf. Sci. 2023, 647, 119545. [Google Scholar] [CrossRef]
- Lu, N.; Liu, S.; Du, J.; Fang, Z.; Dong, W.; Tao, L.; Yang, Y. Grey Relational Analysis Model with Cross-Sequences and Its Application in Evaluating Air Quality Index. Expert Syst. Appl. 2023, 233, 120910. [Google Scholar] [CrossRef]
- Xiao, Y.; Zhang, L.; Yang, Y.; Wu, W.; Ning, J.; Huang, X. Provably Secure Multi-Signature Scheme Based on the Standard SM2 Signature Scheme. Comput. Stand. Interfaces 2024, 89, 103819. [Google Scholar] [CrossRef]












| Environment | Description |
|---|---|
| Development Platform | IntelliJ IDEA 2019.3.3 × 64; MySQL8.0 |
| Operating System | Windows 10; Ubuntu 16.04 |
| Blockchain Module | Hyperledger Fabric v1.2.0; nodejs v8.10.0; go v1.12 |
| Languages | Python 3.8; Go; Node.js |
| Model | Type | Epochs/Estimators | Learning Rate (Init) | Scheduler | Training Time (s) |
|---|---|---|---|---|---|
| TabNet-BO (Proposed) | DL | 500 | 0.0031 | ReduceLROnPlateau | 1046 |
| TabNet (Default) | DL | 500 | 0.005 | ReduceLROnPlateau | 415 |
| BP | DL | 400 | 0.001 | StepLR | 163 |
| XGBoost | ML | 800 | N/A | N/A | 25 |
| GBDT | ML | 800 | N/A | N/A | 19 |
| Random Forest (RF) | ML | 300 | N/A | N/A | 7 |
| RBF(SVR) | ML | N/A | N/A | N/A | 4 |
| Hyperparameter | Symbol | Search Range | Optimal Value |
|---|---|---|---|
| Decision prediction width | Nd | [8, 128] | 56 |
| Attention prediction width | Na | [8, 128] | 8 |
| Number of steps | Nsteps | [3, 10] | 7 |
| Relaxation parameter | Γ | [1.0, 2.0] | 1.43 |
| Sparsity regularization | Λ | [1 × 10−6, 0.01] | 1.0 × 10−6 |
| Learning rate | H | [1 × 10−4, 0.01] | 0.0031 |
| Batch size | B | - | 32 |
| Virtual batch size | Bv | - | 32 |
| Models | MAE | RMSE | R2 |
|---|---|---|---|
| RF | 0.0421 | 0.0535 | 0.7583 |
| RBF | 0.0443 | 0.0490 | 0.8020 |
| BP | 0.0329 | 0.0440 | 0.8410 |
| GBDT | 0.0336 | 0.0432 | 0.8460 |
| XGBoost | 0.0338 | 0.0427 | 0.8535 |
| TabNet | 0.0216 | 0.0316 | 0.9246 |
| TabNet-BO | 0.0146 | 0.0168 | 0.9681 |
| Comparison Pair | T-Statistic | p-Value |
|---|---|---|
| TabNet-BO vs. TabNet | 6.027 | 2.88 × 10−8 |
| TabNet-BO vs. BP | 7.703 | 1.04 × 10−11 |
| TabNet-BO vs. XGBoost | 8.438 | 2.75 × 10−13 |
| TabNet-BO vs. RBF | 8.926 | 2.40 × 10−14 |
| TabNet-BO vs. RF | 9.602 | 8.07 × 10−16 |
| TabNet-BO vs. GBDT | 9.641 | 6.65 × 10−16 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.
Share and Cite
Ge, H.; Fan, K.; Zhang, Y.; Jiang, Y.; Wang, S.; Chen, Z. Integrating Blockchain Traceability and Deep Learning for Risk Prediction in Grain and Oil Food Safety. Foods 2026, 15, 407. https://doi.org/10.3390/foods15020407
Ge H, Fan K, Zhang Y, Jiang Y, Wang S, Chen Z. Integrating Blockchain Traceability and Deep Learning for Risk Prediction in Grain and Oil Food Safety. Foods. 2026; 15(2):407. https://doi.org/10.3390/foods15020407
Chicago/Turabian StyleGe, Hongyi, Kairui Fan, Yuan Zhang, Yuying Jiang, Shun Wang, and Zhikun Chen. 2026. "Integrating Blockchain Traceability and Deep Learning for Risk Prediction in Grain and Oil Food Safety" Foods 15, no. 2: 407. https://doi.org/10.3390/foods15020407
APA StyleGe, H., Fan, K., Zhang, Y., Jiang, Y., Wang, S., & Chen, Z. (2026). Integrating Blockchain Traceability and Deep Learning for Risk Prediction in Grain and Oil Food Safety. Foods, 15(2), 407. https://doi.org/10.3390/foods15020407

