Compress prompts by turning text into relation graphs, keeping readability and model utility

March 30, 20247 min

Overview

Decision SnapshotReady For Pilot

Method is practical: use Open‑IE and embeddings to extract triplets, select a subgraph by similarity or task relevance, and rebuild readable prompts; evidence from GSM8K-aug, NaturalQuestions and ShareGPT shows consistent gains on tested LLMs.

Citations0

Evidence Strength0.75

Confidence0.80

Risk Signals9

Trust Signals

Findings with numeric evidence: 4/4

Findings with evidence refs: 4/4

Results with explicit delta: 5/5

Reproducibility

Status: No open assets linked

Open source: Partial

At A Glance

Cost impact: 70%

Production readiness: 70%

Novelty: 70%

Authors

Muhammad Asif Ali, Zhengping Li, Shu Yang, Keyuan Cheng, Yang Cao, Tianhao Huang, Guimin Hu, Weimin Lyu, Lijie Hu, Lu Yu, Di Wang

Links

Abstract / PDF

Why It Matters For Business

Compress prompts into readable information units to cut LLM API cost and latency while often improving downstream accuracy on evaluated tasks.

Who Should Care

Summary TLDR

Prompt-SAW converts a prompt's text into a small knowledge graph (entities + relations), selects key graph triplets, and reassembles them into a compressed prompt. Compared to token-level compressors, it preserves grammar and human readability while often improving downstream task accuracy. In experiments on GSM8K-aug (math reasoning), NaturalQuestions (QA) and ShareGPT (dialog), Prompt-SAW reduces prompt length by 33–94% and improves task metrics versus prior compressors on evaluated benchmarks.

Problem Statement

Long prompts hurt latency, cost, and clarity. Existing compressors remove tokens without preserving syntax or meaning, producing unreadable prompts and harming downstream answers. The paper asks: can we compress prompts by extracting and selecting relation-aware information units so compressed prompts stay readable and keep utility?

Main Contribution

Prompt-SAW: a graph-based prompt compressor that extracts (subject, relation, object) triplets and selects a subgraph to build a compressed, readable prompt.

GSM8K-aug: an i-shot extension of GSM8K (i∈{1,2,4,8}) to test compression across shot counts.

Key Findings

On GSM8K-aug (task-agnostic, 2-shot) Prompt-SAW improved Exact Match (EM) versus best baseline by 10.1% while cutting prompt tokens by 34.9%.

NumbersEM ↑ 10.1%; tokens 612399 (−34.9%)

Practical UseUse Prompt-SAW to shrink chain-of-thought style prompts and often get better math QA accuracy with a smaller context.

Evidence RefTable 1 (GSM8K-aug 2-shot)

On NaturalQuestions (task-aware) with GPT3.5-turbo, Prompt-SAW raised Span Accuracy by 39.0% at a target compression rate η*=0.5 while cutting prompt tokens from 524 to 227 (~56.7% reduction).

NumbersSpanAcc ↑ 39.0%; tokens 524227 (−56.7%)

Practical UseWhen prompts contain task-relevant documents, selecting graph triplets preserves answer accuracy and shrinks context cost.

Evidence RefTable 2 (NaturalQuestions, GPT3.5-turbo, η*=0.5)

Results

MetricValueBaselineDeltaSplit / DatasetEvidenceEvidence Ref
GSM8K-aug EM (task-agnostic)73.17 EM (Prompt-SAW, 2-shot)LLMLingua / GPT4-generation (best baseline ~66.44 EM)+10.1% vs best baselineGSM8K-aug (2-shot)Table 1 reports 73.17 EM for Prompt-SAW vs 66.44 for best baselineTable 1
NaturalQuestions SpanAcc (task-aware)82.93 Acc (Prompt-SAW, GPT3.5-turbo, η*=0.5)LongLLMlingua 59.65 Acc+39.0% vs LongLLMlinguaNaturalQuestions, η*=0.5Table 2 shows 82.93 vs 59.65Table 2

What To Try In 7 Days

Run Prompt-SAW on a few long prompt templates and compare accuracy and token billing versus your current compressor.

Use Open-IE + an embedding encoder to build triplets from your documentation or demos and compress to 30–60% of original tokens.

Measure fluency and a downstream metric; prefer subgraph selection for task-aware prompts and similarity-threshold pruning for demo-style prompts.

Optimization Features

Token Efficiency
Prompt Compression
Inference Optimization
Context CompressionToken Budgeting

Reproducibility

Code AvailableNo
Data AvailableNo
Open Source StatusPartial
LicenseUnknown

Risks & Boundaries

Limitations

Works best when prompt content can be expressed as subject–relation–object triplets.

Quality depends on OpenIE/graph extraction; extraction errors propagate to compressed prompt.

When Not To Use

Prompts that are narrative or resist decomposition into clean triplets.

Cases where OpenIE fails due to noisy or informal text.

Failure Modes

OpenIE fails to extract key facts → missing information in compressed prompt.

Similarity threshold removes subtly important but long triplets → lower task accuracy.

Core Entities

Models

GPT3.5-turboLLaMA2-7B-chatGPT-4Phi-3-mini

Metrics

Exact Match (EM)AccuracyROUGE-1ROUGE-2ROUGE-LFluency (FL)

Datasets

GSM8K-augGSM8KNaturalQuestionsShareGPT

Context Entities

Models

LLMLinguaLongLLMlinguaSelective-Context