Accurate and reliable state of health (SOH) estimation is essential to ensure the stable and safe operation of lithium-ion batteries. The SOH estimation for batteries with different formulations remains challenging. To solve this problem, this paper proposed a novel transfer learning (TL) framework with attention mechanisms and random forest (RF) regression for battery health estimation. First, only partial charging voltage and current are used in this method, significantly enhancing adaptability to real-world working conditions. Furthermore, multiple attention mechanisms are integrated with the convolution neural network (CNN) to improve feature acuity and expedite convergence. Pre-training tests conducted on three different datasets affirm that the multi attention mechanisms lead to a substantial reduction in estimation errors by 80.9%, 41.3% and 25.6% for LCO, LFP and NCA respectively. Moreover, to ensure precise SOH estimation for batteries with diverse formulations while mitigating the risk of overfitting on limited data, a novel transfer learning (TL) strategy is employed. This involves the freezing of CNN parameters and the transformation of dense layers using RF regression. The optimization of three critical hyper-parameters in the RF process is accomplished through the Tree-structure Parzen Estimator (TPE) method instead of inefficient brute-force search. In the TL process, despite the training data for fine-tuning only occupies 20%, the root mean square error (RMSE) of SOH estimation is impressively low, standing at only 0.46% and 1.61% for LFP and NCA, respectively.