This prompt is for AI engineers and operators who need to find the optimal balance between token cost and downstream task quality when compressing evidence. The job is not just to compress text, but to produce a tunable set of compressed outputs at different aggressiveness levels, each paired with a quality score measured against a task-specific rubric. You use this when you are building a production pipeline that must operate within a token budget, and you need data to decide where the knee in the quality curve sits before you hardcode a compression ratio.
Prompt
Compression Ratio vs Quality Trade-Off Prompt

When to Use This Prompt
Define the job-to-be-done, the ideal user, required context, and when this prompt is the wrong tool.
The ideal user has a specific downstream task with measurable quality criteria—such as answer accuracy, recall of key facts, or citation precision—and a compression function that can accept a ratio parameter. You should bring your own quality metric definition, a representative sample of source documents, and a clear understanding of what 'good enough' looks like for your product. This prompt is not for one-off summarization or for cases where you lack a repeatable quality evaluation loop. If you cannot define what quality means for your task, you cannot tune the trade-off.
Do not use this prompt when the compression ratio is already fixed by infrastructure constraints, when the downstream task is too subjective for reliable scoring, or when the cost of running multiple compression passes exceeds the savings from optimization. It is also the wrong tool if your compression method is extractive-only and cannot vary its output length along a continuous spectrum. For those cases, use a simpler single-ratio compression prompt with a pass/factuality check. If the task involves regulated content where any compression carries compliance risk, pair this prompt with the Risk-Based Context Retention Prompt and require human review of the final operating point before deployment.
Use Case Fit
Where the Compression Ratio vs Quality Trade-Off Prompt delivers value and where it introduces unacceptable risk. Use these cards to decide if this prompt fits your operational context before integrating it into a production pipeline.
Strong Fit: Cost-Sensitive RAG Pipelines
Use when: you run high-volume RAG with tight per-request token budgets and need to find the cheapest compression ratio that preserves acceptable answer quality. Guardrail: always define a task-specific quality metric before tuning; never optimize cost without a quality floor.
Strong Fit: Pre-Production Tuning
Use when: you are benchmarking a new compression strategy before shipping it to users. Guardrail: run the prompt across a golden dataset of diverse queries and document types; do not tune on a single representative sample.
Poor Fit: High-Stakes Compliance Workflows
Avoid when: dropping evidence could violate regulatory obligations, audit requirements, or legal discovery duties. Guardrail: use risk-based retention prompts instead; never apply aggressive compression where missing a clause or fact has legal or financial consequences.
Poor Fit: Single-Request Ad-Hoc Use
Avoid when: you are compressing a one-off document and have no downstream quality measurement loop. Guardrail: this prompt is designed for systematic tuning across many requests; for one-off compression, use a simpler extractive or abstractive prompt with manual review.
Required Inputs: Quality Metric Definition
Risk: without a clear, measurable quality metric, the prompt cannot produce meaningful trade-off scores. Guardrail: define the metric in the prompt template—factuality, recall, citation integrity, or task-specific accuracy—and ensure it can be evaluated automatically or by a judge model.
Operational Risk: Latency Spikes at Multiple Ratios
Risk: generating multiple compression outputs in a single request can increase latency beyond acceptable limits for real-time applications. Guardrail: run this prompt asynchronously or offline; do not place it in the critical path of a synchronous user-facing request without timeout and fallback logic.
Copy-Ready Prompt Template
A reusable prompt that generates multiple compressed versions of source context at different ratios, each with a quality score, so you can select the optimal operating point.
This prompt template is the core instruction set for the compression ratio vs. quality trade-off analysis. It instructs the model to take a source document, apply multiple compression ratios, and produce a structured report that includes the compressed text, a quality score, and a justification for each ratio. The output is designed to be machine-readable so you can programmatically select the best ratio for your cost, latency, and accuracy requirements.
textYou are a context compression analyst. Your task is to compress the provided [SOURCE_TEXT] at multiple compression ratios and evaluate the quality of each compressed output against a task-specific quality rubric. ## INPUTS - Source Text: [SOURCE_TEXT] - Target Task Description: [TASK_DESCRIPTION] - Quality Metric Definitions: [QUALITY_METRICS] - Compression Ratios to Test: [COMPRESSION_RATIOS] - Output Schema: [OUTPUT_SCHEMA] ## INSTRUCTIONS 1. For each ratio in [COMPRESSION_RATIOS], compress [SOURCE_TEXT] to achieve approximately that ratio (compressed_length / original_length). 2. For each compressed output, evaluate its quality against [QUALITY_METRICS] in the context of [TASK_DESCRIPTION]. 3. Produce a structured report following [OUTPUT_SCHEMA] exactly. 4. If a compression ratio causes critical information loss that would make the output unusable for [TASK_DESCRIPTION], flag it with a quality score of 0 and explain why. 5. Do not introduce facts, claims, or entities not present in [SOURCE_TEXT]. ## CONSTRAINTS - Preserve all domain-specific terminology, named entities, numbers, and dates exactly as they appear in the source. - If [SOURCE_TEXT] contains conflicting information, preserve the conflict rather than resolving it. - Do not hallucinate citations or source references. - If the source is too short to meaningfully compress at a given ratio, note this and return the full text.
To adapt this template, replace the square-bracket placeholders with your specific inputs. [SOURCE_TEXT] is the document or context you need to compress. [TASK_DESCRIPTION] should describe the downstream task that will consume the compressed output, such as 'question answering over financial filings' or 'summarization for a legal brief.' [QUALITY_METRICS] must define the scoring dimensions, such as factuality, completeness, and readability, with clear scoring criteria for each. [COMPRESSION_RATIOS] should be a list of target ratios like [0.1, 0.25, 0.5, 0.75]. [OUTPUT_SCHEMA] must specify the exact JSON structure you expect, including fields for the ratio, compressed text, quality scores per metric, an overall score, and a justification. After copying the template, validate that your quality metrics are measurable and that your output schema is strict enough to parse programmatically without manual cleanup.
Prompt Variables
Required inputs for the Compression Ratio vs Quality Trade-Off Prompt. Each placeholder must be populated before the prompt is assembled and sent. Validation notes describe checks to apply before inference.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[SOURCE_TEXT] | The original document or passage to compress | The quarterly financial report for Q3 2024, totaling 4,200 tokens | Required. Must be non-empty string. Check token count before assembly; if under 500 tokens, compression may be unnecessary. Null not allowed. |
[TASK_DESCRIPTION] | What downstream task will consume the compressed output | Extract revenue by segment and compare to prior quarter | Required. Must be a complete sentence describing the consumer task. Vague descriptions like 'analysis' produce unreliable quality scores. Null not allowed. |
[COMPRESSION_RATIOS] | Ordered list of target compression ratios to evaluate | [0.1, 0.25, 0.5, 0.75] | Required. Must be a list of floats between 0.0 and 1.0. Values below 0.05 risk unusable output. Sort ascending. At least 3 ratios required for meaningful trade-off curve. Null not allowed. |
[QUALITY_METRICS] | Named quality dimensions with scoring rules for each | {"factual_accuracy": "Count of claims in compressed text verifiable in source", "key_entity_retention": "Fraction of named entities preserved", "task_relevance": "1-5 scale: how well compressed text supports [TASK_DESCRIPTION]"} | Required. Must be a JSON object with at least 2 metric names mapped to scoring rules. Each rule must reference [SOURCE_TEXT] or [TASK_DESCRIPTION]. Vague metrics like 'quality' are invalid. Null not allowed. |
[OUTPUT_FORMAT] | Schema for the structured output the prompt must return | JSON with fields: ratio, compressed_text, quality_scores (map of metric_name to score), word_count, compression_notes | Required. Must specify JSON schema with at least ratio, compressed_text, and quality_scores fields. Schema check: confirm quality_scores keys match [QUALITY_METRICS] keys exactly. Null not allowed. |
[MAX_OUTPUT_TOKENS] | Token ceiling for the entire model response | 4096 | Required. Must be integer. Calculate: (max compressed text length across all ratios) + (overhead per ratio entry) * (number of ratios). If ceiling too low, later ratios may be truncated. Null not allowed. |
[GROUND_TRUTH_SAMPLE] | Optional reference compression at one ratio for calibration | null | Optional. If provided, must be a valid compressed version of [SOURCE_TEXT] at a known ratio. Used to calibrate quality scoring. If null, prompt uses self-assessment only. Validate that sample ratio matches one value in [COMPRESSION_RATIOS]. |
Implementation Harness Notes
How to wire the compression ratio vs quality trade-off prompt into a production pipeline with validation, retries, and decision logic.
This prompt is designed to be called in a sweep loop, not a single inference. The application layer iterates over a list of target compression ratios (e.g., 0.1, 0.3, 0.5, 0.7, 0.9) and calls the prompt once per ratio. Each call receives the same [ORIGINAL_CONTEXT] and [TASK_DESCRIPTION] but a different [TARGET_RATIO]. The model returns a compressed output and a quality score for that ratio. The harness collects all results into a sweep report, then either selects the best operating point automatically or presents the trade-off curve to a human operator for a decision. Do not try to compress to multiple ratios in a single call—the quality scoring becomes unreliable when the model must self-compare across compression levels.
Validation and retry logic must be strict because downstream tasks depend on the compressed context. After each call, validate that: (1) the output contains valid JSON with the required fields (compressed_context, quality_score, compression_ratio_achieved, information_loss_notes); (2) compression_ratio_achieved is within ±0.05 of the target ratio (if not, the model may have ignored the instruction—retry once with stronger constraint language); (3) quality_score is between 0.0 and 1.0; (4) compressed_context is not empty and is measurably shorter than the original (if it is longer, the model failed—retry or flag for review). For high-stakes domains, add a factuality preservation check by running a separate verification prompt that compares the compressed output against the original and flags additions, omissions, or semantic drift. Log every sweep result with the original context hash, target ratio, achieved ratio, quality score, token counts, and model version for later analysis.
Model choice matters. This prompt benefits from models with strong instruction-following and structured output capabilities. GPT-4o, Claude 3.5 Sonnet, and Gemini 1.5 Pro all handle the dual task of compression plus quality estimation reliably. Avoid smaller or older models that may conflate compression with summarization or produce hallucinated quality scores. If cost is a concern, run the sweep on a capable model to establish the trade-off curve, then use a cheaper model for production compression at the selected ratio—but validate the cheaper model's outputs against the original sweep baseline. Human review gating is required when the sweep shows a sharp quality cliff (score drops >0.3 between adjacent ratios) or when the selected ratio falls below 0.3 for regulated content. In those cases, surface the sweep report and the compressed output to a reviewer before the compressed context enters any downstream workflow.
Wiring into a RAG or agent pipeline is straightforward: the compressed output replaces the original context in the next stage's prompt. Store the compression_ratio_achieved and quality_score as metadata on the request so downstream evaluators can correlate compression decisions with end-to-end task quality. If you are running this sweep periodically to recalibrate compression settings (e.g., after a knowledge base update or model change), compare the new trade-off curve against the previous one and alert if the quality-at-ratio degrades by more than 0.1. This turns the prompt from a one-off tuning exercise into an ongoing quality control signal for your compression pipeline.
Expected Output Contract
Defines the structure, types, and validation rules for the compression ratio vs quality trade-off output. Use this contract to parse, validate, and store results before routing to downstream evaluation or selection logic.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
compression_results | Array of objects | Must contain at least 2 entries. Each entry represents a distinct compression ratio tier. | |
compression_results[].ratio | Float (0.0-1.0) | Must be a number between 0 and 1 representing the target compression ratio. Lower values indicate more aggressive compression. Values must be strictly increasing across the array. | |
compression_results[].compressed_context | String | Must be a non-empty string. Length in tokens must be less than or equal to original_context_tokens * (1 - ratio) with a 10% tolerance. Must not introduce claims absent from [ORIGINAL_CONTEXT]. | |
compression_results[].quality_score | Float (0.0-1.0) | Must be a number between 0 and 1. Score must be calculated against [QUALITY_METRIC_DEFINITION]. Higher scores indicate better preservation of task-relevant information. | |
compression_results[].quality_justification | String | Must be 1-3 sentences explaining the score with reference to specific elements from [QUALITY_METRIC_DEFINITION]. Must cite at least one concrete example of preserved or lost information. | |
compression_results[].factuality_flags | Array of strings | If present, each string must match one of: 'addition', 'omission', 'distortion', 'no_issues'. Empty array or null is equivalent to ['no_issues']. Presence of 'addition', 'omission', or 'distortion' must trigger a factuality review before downstream use. | |
recommended_ratio | Float (0.0-1.0) | Must match one of the ratio values in compression_results. Selection must be justified by the highest quality_score that meets [MIN_QUALITY_THRESHOLD]. If no ratio meets the threshold, this field must be null and a warning must be logged. | |
tradeoff_summary | String | Must be 2-4 sentences describing the observed quality degradation curve across ratios. Must explicitly state the point where quality drops below [MIN_QUALITY_THRESHOLD] or confirm all ratios exceed the threshold. |
Common Failure Modes
When tuning compression aggressiveness, these failures surface first. Each card identifies a specific breakage pattern and the operational guardrail that catches it before it impacts downstream task quality.
Critical Evidence Omission
What to watch: The compression prompt drops a fact, figure, or constraint that is essential for the downstream task, producing a fluent but incorrect output. This is most common when the compression ratio is pushed too high and the model must choose what to discard. Guardrail: Run a factuality preservation check prompt that compares the compressed output against the original source, flagging any claim present in the original but absent from the compressed version before it feeds downstream tasks.
Semantic Drift Under Aggressive Ratios
What to watch: At high compression ratios, the model introduces subtle meaning shifts—changing 'may increase risk' to 'increases risk,' or softening a hard constraint into a suggestion. The output reads plausibly but misrepresents the source. Guardrail: Deploy a context drift detection prompt that compares the compressed output against the original for tone shifts, emphasis changes, and missing nuance. Gate compression ratios above 5:1 with this check.
Citation Chain Breakage
What to watch: When compressing evidence for RAG systems, the mapping between generated claims and source citations breaks. Compressed text may merge facts from multiple sources, creating orphaned citations or citations that no longer point to the correct passage. Guardrail: Run a citation integrity verification prompt after compression that confirms every citation marker maps to a retrievable source passage. Reject compressed outputs with broken citation chains before they reach the answer generator.
Domain Terminology Corruption
What to watch: In specialized domains like medicine, law, or engineering, compression may paraphrase or replace precise terms with approximate synonyms, destroying the technical accuracy required downstream. 'Myocardial infarction' becomes 'heart problem,' invalidating clinical reasoning. Guardrail: Use a domain-specific terminology preservation prompt that explicitly requires all domain terms, definitions, and entity references to survive compression verbatim. Validate with a terminology fidelity check against a controlled vocabulary list.
PII Leakage Through Compression
What to watch: Compression prompts that summarize or abstract text may inadvertently surface personally identifiable information that was buried in the original but becomes explicit in the compressed version. Names, identifiers, or contact details can leak through abstraction. Guardrail: Run a PII-safe context compression prompt that redacts or abstracts PII during compression, and validate the output with a PII leak detection check before the compressed context is used in any downstream system.
Quality Cliff at High Ratios
What to watch: Compression quality degrades non-linearly. A 3:1 ratio may preserve 98% of task-critical information, while 5:1 drops to 85% and 10:1 collapses to 60%. Operators often discover this cliff only after downstream task failures accumulate. Guardrail: Produce multiple compression outputs at different ratios (e.g., 2:1, 5:1, 10:1) and score each with a task-specific quality metric before selecting the operating point. Never deploy a new ratio without measuring the quality drop first.
Evaluation Rubric
Use this rubric to test the quality of compressed outputs at different ratios before selecting an operating point for production. Each criterion targets a specific failure mode in the compression vs. quality trade-off.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Task-Specific Quality Score | Score meets or exceeds the minimum threshold defined in [QUALITY_METRIC] for the target [COMPRESSION_RATIO] | Score drops below threshold while token count is within budget | Run [EVAL_PROMPT] against compressed output; compare score to threshold in [QUALITY_THRESHOLD_CONFIG] |
Factuality Preservation | Zero introduced claims absent from [ORIGINAL_CONTEXT]; all retained facts are verifiable against source | Compressed output contains a statement not present in or directly inferable from [ORIGINAL_CONTEXT] | Run factuality check prompt comparing compressed output to [ORIGINAL_CONTEXT] sentence by sentence; flag additions |
Critical Evidence Retention | All items marked as critical in [EVIDENCE_PRIORITY_MAP] appear in compressed output | A critical evidence item from [EVIDENCE_PRIORITY_MAP] is missing from compressed output | Parse [EVIDENCE_PRIORITY_MAP]; verify each critical item ID appears in compressed output via string match or embedding similarity above [SIMILARITY_THRESHOLD] |
Citation Integrity | Every citation marker in compressed output resolves to a retrievable passage in [SOURCE_INDEX] | Orphaned citation marker present that cannot be traced to a source passage | Extract all citation markers from compressed output; cross-reference against [SOURCE_INDEX]; flag any marker with no matching entry |
Domain Terminology Preservation | All terms listed in [DOMAIN_TERM_LIST] appear in compressed output with correct usage | A term from [DOMAIN_TERM_LIST] is missing or used in a semantically incorrect context | Tokenize compressed output; check presence of each term in [DOMAIN_TERM_LIST]; for flagged terms, run domain usage check prompt against [ORIGINAL_CONTEXT] |
Token Budget Compliance | Compressed output token count is at or below [TARGET_TOKEN_BUDGET] for the given [COMPRESSION_RATIO] | Output exceeds [TARGET_TOKEN_BUDGET] by more than [BUDGET_TOLERANCE_PERCENT] | Count tokens in compressed output using [TOKENIZER]; compare to [TARGET_TOKEN_BUDGET]; fail if over tolerance |
Semantic Drift Detection | No change in sentiment, emphasis, or conclusion compared to [ORIGINAL_CONTEXT] beyond acceptable compression loss | Compressed output shifts the implied conclusion, polarity, or relative importance of claims | Run semantic drift check prompt comparing compressed output to [ORIGINAL_CONTEXT]; flag drift score above [DRIFT_THRESHOLD] |
Redundancy Elimination | No duplicate information within compressed output; each unique fact appears once | Same fact or claim appears in multiple locations within compressed output | Run redundancy detection prompt on compressed output; flag any cluster of sentences with similarity above [REDUNDANCY_THRESHOLD] |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Start with the base prompt and a single compression ratio target. Use a simple quality rubric with 1–3 Likert-scale questions instead of a full metric suite. Run on 5–10 representative samples and manually spot-check outputs.
Simplify the output schema to:
json{ "compressed_text": "[COMPRESSED]", "compression_ratio": [RATIO], "quality_score": [SCORE], "issues": ["[ISSUE]"] }
Watch for
- Quality scores that don't correlate with human judgment
- Over-compression that drops critical entities or numbers
- No baseline comparison against uncompressed performance

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us