A personalized exercise recommendation method that combines cognitive diagnosis and deep factorization machine was proposed to address the problems of single modeling angle and unreasonable exercise recommendation results of the existing exercise recommendation based on cognitive diagnosis. Firstly, a new method for calculating the relationship between knowledge points was designed to construct a course knowledge tree, and the concept of enhanced Q matrix to accurately represent the relationship between knowledge points contained in exercises was proposed. Secondly, the Neural Cognitive Diagnosis with Knowledge-based Discernment (NeuralCD-KD) model was proposed to calculate the enhanced Q matrix. In the model, the feature second-order cross and attention mechanism were used to fuse internal and external factors of exercise difficulty, and the students’ cognitive states were simulated. The effectiveness of the proposed cognitive diagnosis model was verified on private and public datasets, and this method was able to give reasonable explanations for students’ cognitive states. To personalize exercise recommendation, a Neural Knowledge-based Cognitive Diagnosis with Deep Bilinear Factorization Machine (NKD-DBFM) method was proposed by combining the diagnostic model with deep bilinear factorization machine, and the effectiveness of this proposed exercise recommendation method was verified on the private dataset. Compared with the optimal baseline model Neural Cognitive Diagnosis Model (NeuralCDM), the proposed method improves the Area Under Curve (AUC) by 3.7 percentage points.