BACKGROUND: Long non-coding RNA (LncRNA) play pivotal roles in various cellular processes, and elucidating their subcellular localization can offer crucial insights into their functional significance. Accurate prediction of lncRNA subcellular localization is of paramount importance. Despite numerous computational methods developed for this purpose, existing approaches still encounter challenges stemming from the complexity of data representation and the difficulty in capturing nucleotide distribution information within sequences. RESULTS: In this study, we propose a novel deep learning-based model, termed MGBLncLoc, which incorporates a unique multi-class encoding technique known as generalized encoding based on the Distribution Density of Multi-Class Nucleotide Groups (MCD-ND). This encoding approach enables more precise reflection of nucleotide distributions, distinguishing between constant and discriminative regions within sequences, thereby enhancing prediction performance. Additionally, our deep learning model integrates advanced neural network modules, including Multi-Dconv Head Transposed Attention, Gated-Dconv Feed-forward Network, Convolutional Neural Network, and Bidirectional Gated Recurrent Unit, to comprehensively exploit sequence features of lncRNA. CONCLUSIONS: Comparative analysis against commonly used sequence feature encoding methods and existing prediction models validates the effectiveness of MGBLncLoc, demonstrating superior performance. This research offers novel insights and effective solutions for predicting lncRNA subcellular localization, thereby providing valuable support for related biological investigations.