Shipping plays an important role in transporting goods, but it also brings air pollution such as nitrogen and sulfur compounds. Meanwhile, shore power can provide daily work power for ships calling at ports, and it can reduce the pollution of the port. Load forecasting of shore power plays an important role in power decision-making. In this work, we proposed a load forecasting model based on the Transformer and the conditional generation. The Firefly Algorithm (FA) was designed to extract the represented condition features. The proposed shore power transformer (SP-T) method adopts the probability distribution of the target load as the prediction results. The two sub-models, SP-T-1 and SP-T-2, were used to predict the Gaussian distribution parameters μ and σ, respectively. It allowed decision-makers to set the confidence level to obtain the range of predicted values according to the actual situation. To evaluate the proposed model, we used 328 power load data (about 18568.4 hours) of different ships that berth at Zhenjiang Port with shore power. The experimental results showed that SP-T can effectively predict the load data of shore power, with an average P50RMSE was 46.997 and an average P90RMSE was 34.822.