Saved in:
Bibliographic Details
Main Authors: Guo, Tianyu, Dong, Hande, Leng, Yichong, Liu, Feng, Lin, Cheater, Xiao, Nong, Zhang, Xianwei
Format: Preprint
Published: 2025
Subjects:
Online Access:https://arxiv.org/abs/2505.21889
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866913865810313216
author Guo, Tianyu
Dong, Hande
Leng, Yichong
Liu, Feng
Lin, Cheater
Xiao, Nong
Zhang, Xianwei
author_facet Guo, Tianyu
Dong, Hande
Leng, Yichong
Liu, Feng
Lin, Cheater
Xiao, Nong
Zhang, Xianwei
contents Large language models (LLMs) are often used for infilling tasks, which involve predicting or generating missing information in a given text. These tasks typically require multiple interactions with similar context. To reduce the computation of repeated historical tokens, cross-request key-value (KV) cache reuse, a technique that stores and reuses intermediate computations, has become a crucial method in multi-round interactive services. However, in infilling tasks, the KV cache reuse is often hindered by the structure of the prompt format, which typically consists of a prefix and suffix relative to the insertion point. Specifically, the KV cache of the prefix or suffix part is frequently invalidated as the other part (suffix or prefix) is incrementally generated. To address the issue, we propose EFIM, a transformed prompt format of FIM to unleash the performance potential of KV cache reuse. Although the transformed prompt can solve the inefficiency, it exposes subtoken generation problems in current LLMs, where they have difficulty generating partial words accurately. Therefore, we introduce a fragment tokenization training method which splits text into multiple fragments before tokenization during data processing. Experiments on two representative LLMs show that LLM serving with EFIM can lower the latency by 52% and improve the throughput by 98% while maintaining the original infilling capability. EFIM's source code is publicly available at https://github.com/gty111/EFIM.
format Preprint
id arxiv_https___arxiv_org_abs_2505_21889
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle EFIM: Efficient Serving of LLMs for Infilling Tasks with Improved KV Cache Reuse
Guo, Tianyu
Dong, Hande
Leng, Yichong
Liu, Feng
Lin, Cheater
Xiao, Nong
Zhang, Xianwei
Computation and Language
Large language models (LLMs) are often used for infilling tasks, which involve predicting or generating missing information in a given text. These tasks typically require multiple interactions with similar context. To reduce the computation of repeated historical tokens, cross-request key-value (KV) cache reuse, a technique that stores and reuses intermediate computations, has become a crucial method in multi-round interactive services. However, in infilling tasks, the KV cache reuse is often hindered by the structure of the prompt format, which typically consists of a prefix and suffix relative to the insertion point. Specifically, the KV cache of the prefix or suffix part is frequently invalidated as the other part (suffix or prefix) is incrementally generated. To address the issue, we propose EFIM, a transformed prompt format of FIM to unleash the performance potential of KV cache reuse. Although the transformed prompt can solve the inefficiency, it exposes subtoken generation problems in current LLMs, where they have difficulty generating partial words accurately. Therefore, we introduce a fragment tokenization training method which splits text into multiple fragments before tokenization during data processing. Experiments on two representative LLMs show that LLM serving with EFIM can lower the latency by 52% and improve the throughput by 98% while maintaining the original infilling capability. EFIM's source code is publicly available at https://github.com/gty111/EFIM.
title EFIM: Efficient Serving of LLMs for Infilling Tasks with Improved KV Cache Reuse
topic Computation and Language
url https://arxiv.org/abs/2505.21889