Skip to main content

Module extractive

Module extractive 

Source
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:

  1. pure, allocation-only segmentation (the segment module);
  2. embeddings that are run-to-run stable on a given build/host;
  3. fixed-precision score quantization with an original-index tiebreak (the ranker module); and
  4. 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=lowrank_and_squeeze returns None, and callers fall back to the deterministic truncating squeeze. No build or OS regresses.

Enums§

RankMode
Which signal drives segment scoring.

Functions§

rank_and_squeeze
Rank the sentences of text and keep the highest-value ones within budget_chars, emitted in original order.