Heavy metal contamination in wheat not only endangers human health, but also causes crop quality degradation, leads to economic losses and affects social stability. Therefore, this paper proposes a Pyraformer-based model to predict the safety risk level of Chinese wheat contaminated with heavy metals. First, based on the heavy metal sampling data of wheat and the dietary consumption data of residents, a wheat risk level dataset was constructed using the risk evaluation method; a data-driven approach was used to classify the dataset into risk levels using the K-Means++ clustering algorithm; and, finally, on the constructed dataset, Pyraformer was used to predict the risk assessment indicator and, thus, the risk level. In this paper, the proposed model was compared to the constructed dataset, and for the dataset with the lowest risk level, the precision and recall of this model still reached more than 90%, which was 25.38–4.15% and 18.42–5.26% higher, respectively. The model proposed in this paper provides a technical means for hierarchical management and early warning of heavy metal contamination of wheat in China, and also provides a scientific basis for dynamic monitoring and integrated prevention of heavy metal contamination of wheat in farmland.