Commit graph

2 commits

Author SHA1 Message Date
chopratejas
39af65a259 Use realistic verbose RAG chunks in demo — triggers Kompress within-item
Previous chunks were too dense (400 chars, no filler). Real blog post
retrieval returns verbose explanatory text (~1000 chars per chunk).
Kompress now compresses 31-47% within each item.

Demo results: 4424 → 2756 tokens (38% savings), all 12 items kept,
6/6 key concepts preserved, zero extra LLM calls.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 00:18:58 -07:00
chopratejas
f121138c8a Fix context-blind compression: pass user query to SmartCrusher relevance scorer
ROOT CAUSE: compress() did not extract the user's question from messages.
The pipeline received empty context, so SmartCrusher selected items by
statistics only (position, anomaly, boundary) — keeping irrelevant chunks
and dropping relevant ones.

FIX: _extract_user_query() in compress.py finds the most recent user
message and passes it as `context` kwarg through the pipeline. SmartCrusher's
RelevanceScorer now receives the actual query and scores items by relevance.

Before: 12 RAG chunks → kept hallucination/video (0/6 key terms)
After:  12 RAG chunks → kept reward hacking content (3/4 key terms)

Also adds:
- examples/context_compression_demo.py — real compression demo for OSS PR
- examples/test_ccr.py — content preservation verification
- OSS_PR_STRATEGY.md — PR target list for LangChain ecosystem

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 23:15:19 -07:00