This paper describes a non-destructive detection method for identifying cable defects using K-mer frequency encoding. The detection methodology combines magnetic leakage detection equipment with artificial intelligence for precise identification. The cable defect identification process includes cable signal acquisition, K-mer frequency encoding, and artificial intelligence-based identification. A magnetic leakage detection device detects signals via sensors and records their corresponding positions to obtain cable signals. The K-mer frequency encoding method consists of several steps, including cable signal normalization, the establishment of K-mer frequency encoding, repeated sampling of cable signals, and conversion for comparison to derive the K-mer frequency. The K-mer frequency coding method has advantages in data processing and repeated sampling. In the identification step of the artificial intelligence identification model, an autoencoder model is used as the algorithm, and the K-mer frequency coding method is used to introduce artificial parameters. Proper adjustments of these parameters are required for optimal cable defect identification performance in various applications and usage scenarios. Experiment results show that the proposed K-mer frequency encoding method is effective, with a cable identification accuracy rate of 91% achieved through repeated sampling.