Parse Trees Guided LLM Prompt Compression

Wenhao Mao, Chengbin Hou, Tianyu Zhang, Xinyu Lin, Ke Tang, Hairong Lv · DOI

Abstract

Prompt compression is essential for managing the computational costs and context limits of Large Language Models (LLMs). However, existing selective methods often treat prompts as unstructured token sequences, leading to a loss of linguistic coherence and "human logic." This paper introduces PartPrompt, a novel selective compression framework that leverages linguistic parse trees and global document structure. By modeling prompts as hierarchical trees and employing root-ward and leaf-ward value propagation, PartPrompt preserves semantic integrity and structural context. Experimental results demonstrate that PartPrompt achieves state-of-the-art performance across diverse benchmarks, particularly in long-context reasoning tasks where traditional methods struggle.

Introduction

Large Language Models (LLMs) rely heavily on extensive context to perform complex tasks. However, the Transformer architecture's quadratic computational cost relative to input length and fixed context windows impose significant constraints. Prompt compression has emerged as a vital technique to mitigate these issues. Current approaches generally fall into two categories: generative methods, which use an LLM to rewrite prompts (often introducing hallucinations), and selective methods, which use smaller models to identify and remove low-entropy tokens.

The authors identify a critical flaw in existing selective methods: they treat prompts as a "bag of tokens," ignoring the underlying linguistic syntax and global document structure (e.g., paragraphs and sections). This neglect often results in fragmented, incoherent compressed text that disrupts the "human writing logic" necessary for effective LLM reasoning.

Methodology: The PartPrompt Framework

PartPrompt addresses these limitations by treating a prompt as a hierarchical tree rather than a linear sequence. The framework operates through a four-stage pipeline:

  1. Local Entropy and Parse Tree Generation: The prompt is segmented into sentences. For each sentence, a linguistic parse tree is generated using the Stanford CoreNLP toolkit. Simultaneously, a small LLM (e.g., Llama2-7B) calculates the information entropy for each token. To maintain efficiency, entropy is calculated locally within each sentence.
  2. Global Tree Construction: These local sentence trees are integrated into a "Global Tree" that reflects the document's inherent hierarchy: Tokens $\rightarrow$ Sentences $\rightarrow$ Paragraphs $\rightarrow$ Sections $\rightarrow$ Document.
  3. Value Propagation: To preserve structural context, the framework utilizes two propagation techniques:
  4. Root-ward propagation: Aggregates importance values from leaf nodes (tokens) up to virtual nodes (structural elements).
  5. Leaf-ward propagation: Distributes importance back down the tree, prioritizing "anchor" content such as the introductory sentences of paragraphs.
  6. Recursive Pruning: A recursive algorithm prunes the tree to achieve the target compression ratio. By following the tree structure, the algorithm ensures that if a child token is retained, its parent structural context is also preserved.
Overview of the PartPrompt pipeline: (1) Local tree generation, (2) Global tree construction, (3) Value propagation, and (4) Recursive pruning.

Experimental Evaluation

PartPrompt was evaluated across a wide range of benchmarks, including BBCnews (contextual understanding), PeopleDaily (multilingual), HotpotQA (reasoning), and RULER (long-context "Needle-in-a-Haystack").

Key Results

  • State-of-the-Art Performance: PartPrompt consistently outperformed established baselines like LLMLingua and Selective-Context. On the BBCnews dataset with an 80% compression rate (20% tokens remaining), PartPrompt achieved a BLEU score of 13.69, nearly doubling the performance of several competitors.
  • Superior Coherence: Qualitative analysis indicates that PartPrompt maintains semantic integrity. Unlike token-dropping methods that produce fragmented words, PartPrompt’s alignment with linguistic structures ensures readable and logical output.
  • Long-Context Robustness: On the RULER benchmark, PartPrompt achieved a score of 69.0, significantly higher than LLMLingua2 (24.0) and even the original uncompressed prompt (21.0). This suggests that by filtering noise while preserving structure, PartPrompt enhances the LLM's ability to retrieve specific information.

Discussion and Insights

The success of PartPrompt stems from several key design choices. Using syntax as a safety rail ensures that the "skeleton" of the language is preserved, preventing the deletion of critical verbs or connectors. Furthermore, the model accounts for the "first-part" bias—the human tendency to place critical information at the beginning of structural units—which significantly boosts reasoning performance. Finally, by approximating global context through local entropy calculations and tree-based propagation, PartPrompt remains computationally efficient and scalable to extremely long prompts (exceeding 6,000 tokens).

Limitations and Future Work

Despite its advantages, PartPrompt's performance is contingent on the accuracy of the underlying linguistic parser, which may vary across different languages. Additionally, the generation of parse trees introduces a pre-processing overhead not found in simpler methods. Future research will explore adapting PartPrompt to diverse prompt patterns and investigating its compatibility with non-Transformer architectures like Mamba or RWKV.

Summary updated

BibTeX
@article{mao2026parse,
  author = {Wenhao Mao and Chengbin Hou and Tianyu Zhang and Xinyu Lin and Ke Tang and Hairong Lv},
  title = {{Parse Trees Guided LLM Prompt Compression}},
  journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
  year = {2026},
  url = {https://openreview.net/forum?id=O3id1Ym685},
}
Figure