In this study, a quantitative model was developed using near-infrared spectroscopy to analyze protein content in dried purple alfalfa, employing preprocessing methods (SG, SNV, MSC, FD) and variable selection algorithms (CARS, IRIV) to optimize spectra. Models using ELM, PLSR, SVM, and LSTM were tested; the MSC-CARS-PLSR-SVM model achieved the highest accuracy, with a calibration determination coefficient (R-2) of 0.9982 and root mean square error (RMSE) of 0.1088, and a prediction R 2 of 0.9645 with RMSE of 0.5230, offering a precise and reliable method for protein content prediction.