CIFLEX: Contextual Instruction Flow for Sub-task Execution in Multi-Turn Interactions with a Single On-Device LLM

Juntae Lee, Jihwan Bang, Seunghan Yang, Simyung Chang

TL;DR

Running multi-task dialogues on edge devices with a single LLM typically forces a brutal trade-off: either reload the entire conversation history every time an auxiliary sub-task runs (causing massive prefill latency), or risk context pollution in a single prompt. CIFLEX solves this by branching the main conversation's key-value (KV) cache into temporary "side paths" for sub-task routing and execution, then rolling back once finished. This drastically cuts on-device prefill overhead while outperforming traditional single-stream and multi-choice routing approaches.

What Problem Does This Paper Address?

In real-world conversational assistants, a single user session frequently triggers auxiliary sub-tasks: resolving ambiguous references via query rewriting, executing API calls, performing intermediate math reasoning, or summarizing conversational state.

On resource-constrained edge devices (such as smartphones), deploying multiple specialized models for each sub-task is impractical due to strict memory budgets. However, managing all sub-tasks with a single LLM introduces severe bottlenecks:

  1. Prefill Explosion: In long conversations (e.g., 20+ turns), reloading the full dialogue history with a new sub-task prompt can require over 300 times more prefill tokens than the tokens generated.
  2. Context Contamination: Running everything in one single context ("seamless" execution) pollutes the conversation history with intermediate tool calls and instructions, degrading the model's core conversational abilities.
  3. Classification Failures: Small models (7B–8B parameters) struggle to perform multi-choice classification over complex sub-task descriptions in one shot, frequently misrouting user queries.

Methods

CIFLEX introduces a task-level cache orchestration strategy combined with hierarchical classification:

  • KV Cache Checkpointing and Rollback: When a user query arrives, the system checkpoints the KV cache of the main conversation thread. Instead of recomputing history, CIFLEX branches into an isolated side path by prefilling only the specific sub-task instruction on top of the cached state. Once the sub-task completes, the model discards intermediate instructions and reasoning tokens, appends only the relevant result (e.g., an API response or final math answer), and rolls back to the main thread without re-prefilling the conversation context.

  • Hierarchical Sub-Task Classification: Because 7B/8B models fail at picking from five simultaneous options, CIFLEX converts routing into an ordered cascade of binary decisions (API call $\rightarrow$ Math solving $\rightarrow$ Query rewriting $\rightarrow$ Summarization $\rightarrow$ None). Because each binary classification shares the same cached conversational prefix, running this chain adds minimal prefill overhead and can even be batched.

Datasets

Because existing multi-turn benchmarks rarely integrate diverse sub-tasks, the authors created two composite benchmarks:

  • TopiOCQA-Task+ and QReCC-Task+: Built on top of conversational search datasets (TopiOCQA and QReCC), augmented with:
  • Multi-step math problems sampled from GSM8K.
  • Multi-modal API calls based on Gorilla, with synthetic conversational queries generated via LLaMA-3.1-70B.
  • Open-domain casual conversation turns (openers, ongoing banter, and closing turns requiring memory summarization).

Key Insights and Ideas

  • Task-level vs. Token-level Reuse: Standard inference uses KV caching to avoid recomputing previous tokens within a single sequence. CIFLEX shows that KV caches can act as an operating system-like checkpointing mechanism across task switches.
  • Instruction Primacy Over Hidden State: Despite the main task prompt remaining frozen inside the inherited KV cache, injecting a new sub-task instruction at the sequence boundary reliably directs 7B/8B models without task collision.
  • Binary Routing Beats Multi-Choice for Small LLMs: Multi-choice classification degrades drastically on small models when task descriptions are nuanced. Decomposing routing into prioritized binary gates brings 8B models within striking distance of server-class models like GPT-4.

Key Results

  • Routing Accuracy: On TopiOCQA-Task+, hierarchical binary classification improved sub-task routing accuracy for LLaMA-3.1-8B from 33.93% (multi-choice) to 88.01%, approaching GPT-4's 98.55%.
  • Prefill Token Savings: Across a 22-turn session, sub-task classification token cost plummeted from 193.6K tokens (without cache reuse) to just 11.4K tokens with CIFLEX.
  • Real Hardware Latency: Benchmarked on a commercial mobile device with a Snapdragon® 8 Elite chipset:
  • By turn 20+, baseline full re-loading prefill latency surged to 331.76 seconds.
  • CIFLEX slashed this to 23.51 seconds (and 16.79 seconds when batching binary classifications), keeping prefill latency well below total generation time.
  • Downstream Quality: CIFLEX matched or slightly exceeded full context re-loading on retrieval (nDCG@3: 31.34 vs. 31.07 on TopiOCQA-Task+) and response coherence, while outperforming seamless single-stream execution by a wide margin.

Limitations and Future Work

  • Simulated Modalities: API responses for vision and audio are currently represented via textual descriptions rather than native multi-modal model processing.
  • External Tool Dependencies: The retrieval pipeline still depends on an external retriever (BGE-Large).
  • Generation Dominance: While CIFLEX successfully resolves the prefill bottleneck, autoregressive generation latency remains the dominant runtime cost, pointing to a need for speculative decoding or hardware-level LRU KV-eviction schemes.

Summary updated

BibTeX
@inproceedings{lee2025ciflex,
  author = {Juntae Lee and Jihwan Bang and Seunghan Yang and Simyung Chang},
  title = {{CIFLEX: Contextual Instruction Flow for Sub-task Execution in Multi-Turn Interactions with a Single On-Device LLM}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
}
Figure