It’s crucial for both producers and consumers to accurately trace the origin of millet, given the significant differences in price and taste that exist between millets from various origins. The traditional method of identifying the origin of millet is time-consuming, laborious, complex, and destructive. In this study, a new method for fast and non-destructive differentiation of millet origins is developed by combining terahertz time domain spectroscopy with ensemble learning. Firstly, three machine learning algorithms, namely support vector machine (SVM), random forest (RF), and kernel extreme learning machine (KELM), were used to build different discriminative models, and then the impact of six different preprocessing methods on the models’ classification performance was compared. It was observed that models employing Savitzky-Golay preprocessing exhibited pronounced superiority in accurately determining the millet’s geographical origins. Building upon these findings, the research introduces an innovative ensemble learning strategy, leveraging both topsis and stacking techniques, to harness the collective strengths of the three algorithms. The outcomes of this approach reveal its remarkable capacity to distinguish millets originating from five distinct locations without the necessity for any parameter fine-tuning. The accuracy, F1 score, and Kappa on the prediction set are all 100 %, which significantly outperforms the single model, traditional voting method, and stacking method. The culmination of this study suggests that the integration of terahertz time-domain spectroscopy and TOPSIS-Stacking ensemble learning emerges as a promising method for the swift and non-intrusive discrimination of millet geographical origins with remarkable precision.