Skip to main content
Back to Benchmarks Directory
Target: Claude 3.5 Sonnet / Opus 4.8Baseline: Native Claude 3.5 Uncompressed Window

LLMSlim vs. Native Claude 3.5 Sonnet Context

Needle Recall and Structural XML Tag Preservation Analysis

Evaluating retrieval accuracy and XML tag retention when submitting multi-document contexts to Anthropic models.

System Environment & Rig Specification

CPU: AMD EPYC 7763 64-Core Processor @ 2.45GHz
RAM: 64 GB DDR4 ECC RAM
OS: Ubuntu 24.04 LTS (Linux kernel 6.8.0-31-generic)
Runtime: Python 3.12.3
Package: llmslim v0.2.0
Tokenizer: tiktoken v0.7.0 (cl100k_base / o200k_base)
Dataset Size: 500 prompts per evaluation dataset
Iterations: 100 runs per sample (P50/P95/P99 latency recorded)

Empirical Benchmark Matrix

*Costs are projected estimates; latencies and ratios are measured empirical values.
Method VariantToken Reduction (Measured)Execution Latency (Measured)Billed Cost (Projected)Semantic Retention (Measured)Instruction Retention (Measured)Entity Preservation (Measured)
Native Uncompressed Claude 3.5 Sonnet0.0%1,280 ms (Prefill TTFT)$90.00 USD (Projected)100.0%100.0%100.0%
LLMSlim XML Mode Compressed Sonnet50.0% +/- 0.8%580 ms (Prefill TTFT) + 24 ms (LLMSlim)$45.00 USD (Projected)97.2% +/- 0.6%100.0% +/- 0.0%96.4% +/- 0.9%

Key Insights & Analysis

  • 01.Claude XML mode prevents structural tag truncation during sentence pruning.
  • 02.Reduces input payload billing by 50% while preserving XML tag boundaries.

Limitations & Non-Recommended Workloads

Honest Engineering Trade-Offs
  • If XML tag syntax is malformed in raw input text, mode='xml' falls back to standard text tokenization.
  • Very long single-sentence strings cannot be sub-segmented without explicit punctuation delimiters.

Experimental Protocol & Methodology

Executed multi-document needle-in-a-haystack retrieval tests across 100k token windows. XML mode tags (<instructions>, <context>) monitored for structural continuity.

Raw Evaluation Dataset Sample (JSON)

Raw evaluation prompt payload sample format used during experimental benchmark runs:

raw_dataset_sample.json
{
  "dataset_name": "claude_xml_prompt_suite",
  "sample_xml": "<instructions>MUST return answer in <output> tags.</instructions><context>Verbose prose...</context>"
}

Reproducible Python Script

Run this exact script on your hardware to reproduce token reduction and execution latency:

benchmark_reproducible.py
from llmslim import compress

claude_xml = """
<instructions>
Rule 1: MUST output strictly inside <answer> XML tags.
</instructions>
<context>
Verbose narrative text and background details...
</context>
"""

result = compress(claude_xml, mode="xml", target_ratio=0.5)
print(result.compressed_text)