This paper introduces a method for thermal error modeling that integrates digital twin (DT) technology with transfer learning (TL) techniques. This research seeks to construct a generalizable and resilient thermal error modeling framework for CNC feed systems, ensuring consistent predictive performance across complex operating environments. A DT model is consequently established to emulate the temperature field evolution and corresponding thermal deformation behaviors of the feed system under various operational conditions. This simulated data acts as the source domain ( \({D_S}\) ). The target domain ( \({D_T}\) ) consists of the temperature and thermal error data collected during system operation. Time series samples are generated using sliding window technology, and normalization is applied to both the temperature features and thermal error labels. A bidirectional long short-term memory (BiLSTM) network, enhanced with a domain adversarial mechanism, is developed to tackle the discrepancies in data distribution across domains. This mechanism aligns the feature distributions, while the BiLSTM utilizes temporal modeling to capture the relationships between temperature features and thermal errors over time. Experimental results demonstrate that the proposed approach, a bidirectional long short-term memory network based on domain adversarial mechanism (DANN-BiLSTM), performs well across six representative transfer tasks. When evaluated in the \({D_T}\) , the proposed method achieves a mean absolute error (MAE) of 1.458 μm, a root mean square error (RMSE) of 2.082 μm, and a coefficient of determination (R²) of 0.968, averaged across all six tasks. In the \({D_S}\) , the MAE is 2.752 μm, the RMSE is 3.115 μm, and the R² is 0.927. The findings demonstrate that the proposed method achieves high predictive precision and exhibits robust cross-domain adaptability in modeling thermal errors under multifaceted operational conditions. Furthermore, the results demonstrate that the DT model can be regarded as a reliable source of training data, offering a novel approach for accurate thermal error prediction in feed drive systems.