In the era of big data, traditional data compression methods cannot complete data compression with features of large volume, rapid growth and complex structure, especially in the processing of real-time data compression. The compression algorithm proposed in this paper is improved on the basis of a lossless bit-swap compression coding algorithm. The coding algorithm is based on VAE model and uses classical ANS compression technology to code multiple potential variables, so as to realize the rapid compression and decompression of data. The experimental results show that the algorithm proposed in this paper can compress data with a high compression rate(47.65%), which is higher than LZAM algorithm and Bit-Swap algorithm.