Expand description
Extractive prose compression: keep the most informative sentences within a char budget instead of truncating to the prefix.
This is the premium replacement for crate::core::web::distill::squeeze_prose’s
FIFO prefix truncation. It reuses the embedding model lean-ctx already ships
(all-MiniLM-L6-v2, 384d, the embeddings feature) — no new model, no new
heavy dependency.
§Determinism (#498)
For a fixed (text, budget, mode, anchor, model_version) the output is
byte-identical. Guaranteed by:
- pure, allocation-only segmentation (the
segmentmodule); - embeddings that are run-to-run stable on a given build/host;
- fixed-precision score quantization with an original-index tiebreak
(the
rankermodule); and - re-emitting kept segments in their ORIGINAL order.
A regression test asserts the byte-stability empirically.
§Graceful fallback
When the embedding engine is unavailable — embeddings feature off, model
not yet loaded, or memory_profile=low — rank_and_squeeze returns
None, and callers fall back to the deterministic truncating squeeze. No
build or OS regresses.
Enums§
- Rank
Mode - Which signal drives segment scoring.
Functions§
- rank_
and_ squeeze - Rank the sentences of
textand keep the highest-value ones withinbudget_chars, emitted in original order.