The invention discloses a
cascade speculation
inference method and
system based on hierarchical decline KV
cache compression, and the method comprises the steps: firstly inputting a context prompt text into a target model for coding, generating a KV cache, and calculating an attention
score between tokens; secondly, descending sorting is carried out based on the attention scores of the final input token, KV cache blocks corresponding to the first k attention scores are selected as cascading middle layer cache, a lightweight large
language model is loaded to serve as a draft model, and a hierarchical decline KV
cache compression strategy is adopted to maintain draft model cache. Then, based on all the caches, a double-layer
cascade speculation reasoning framework is constructed, a target reasoning path is obtained, and the caches are updated; and finally, repeating the operation until
target response data corresponding to the context prompt text is output according to the target reasoning path. According to the method, the KV cache proportion is reduced, meanwhile, the draft token
acceptance rate of the target model of the full KV cache is improved, and reduction of precision is reduced.