In this study, we introduce CNSMolGen -a novel molecular generation model designed to design central nervous system (CNS) drugs from scratch. The model combines pre-training and transfer learning to generate new compounds with CNS activity by learning the SMILES strings of the molecules and shows superior performance on small datasets, opening up new avenues for drug design. Further, we investigated the effect of using different pre-training datasets on the model performance and found that pre-training on large datasets helps to improve the performance of the generated molecules, while pre-training on CNS-specific datasets is more favorable for generating molecules with CNS properties. The application of CNSMolGen in the actual generation of CNS drug molecules was validated using SSRI as an example. The model generated a total of 215 molecules, 129 of which showed good binding affinity in molecular docking. In conclusion, the CNSMolGen model demonstrated significant effectiveness in generating CNS drugs, especially in handling small datasets, and also demonstrated its potential to provide valuable support for future drug design and discovery. With the increasing role of AI tools in drug design and optimization, experimental validation of their results remains indispensable.