Abstract:Code summarization can automatically extract the core functionality and logic of code, providing developers with support for rapid understanding and documentation. Aiming at the problems of low efficiency and limited semantic understanding capability in traditional template-based and rule-based code summarization methods, a code summarization generation and optimization method based on deep learning is proposed. The method first serializes code into an Syntax Tree (AST) representation, then employs an improved Transformer model for encoding and generation, and combines reinforcement learning to optimize the accuracy and readability of generated summaries.