smallprint-1.5b

smallprint is a question-agnostic document compressor: a LoRA adapter on Qwen2.5-1.5B-Instruct that takes a document plus a target compression ratio and outputs a shorter version that any reader model can still answer questions from. No question is available at compression time β€” the adapter was trained on compressions that a frozen anchor reader (Mistral-Small-24B-Instruct-2501) could still answer grounded questions from, so question-answering utility is preserved by construction.

How it differs from token pruners (e.g. LLMLingua-2)

  • No GPT backbone: inference is a single 1.5B-model forward pass on the document + ratio (no per-sentence perplexity scoring, no prompt re-optimization).
  • Question-agnostic: one compression serves any downstream question.
  • Trained end-to-end on 2,278 book-document chunks with an anchor-validated QA filter (generator: a self-hosted 27B Qwen; gate: the anchor answering grounded questions about the compressed text).

Usage

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel

BASE = "Qwen/Qwen2.5-1.5B-Instruct"
ADAPTER = "__USER__/smallprint-1.5b"          # this repo (run1 at root, run2 in run2/)
SYSTEM = ("You are a faithful document compressor. Compress the document so that a "
          "reader can still answer factual questions about it: preserve names, numbers, "
          "dates, quantities, and causal relations. Never add information. Output only "
          "the compressed text.")

tok = AutoTokenizer.from_pretrained(BASE)
model = AutoModelForCausalLM.from_pretrained(
    BASE, torch_dtype=torch.bfloat16, attn_implementation="sdpa").cuda()
model = PeftModel.from_pretrained(model, ADAPTER)          # add subfolder="run2" for run2

def compress(text: str, target_ratio: float) -> str:
    n = len(tok(text, add_special_tokens=False)["input_ids"])
    target = max(32, int(n / target_ratio))
    user = (f"Target compression ratio: {target_ratio:g}x (output roughly "
            f"{1.0 / target_ratio:.0%} of the original length).\n\nDOCUMENT:\n{text}")
    msgs = [{"role": "system", "content": SYSTEM}, {"role": "user", "content": user}]
    prompt = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
    enc = tok(prompt, truncation=True, max_length=16384, return_tensors="pt").to(model.device)
    out = model.generate(**enc, max_new_tokens=min(8192, int(target * 1.3) + 256),
                         do_sample=False)
    return tok.decode(out[0][enc["input_ids"].shape[1]:], skip_special_tokens=True)

Note: the achieved compression is content-dependent β€” the model reaches a ~2×–7Γ— band rather than the exact requested ratio (see Limitations).

Results (headline)

Accuracy retained (F1) vs the same reader on the full document; 50 docs per benchmark, 256-token answer cap, doc-level bootstrap 95% CIs in the paper. Cell = retained F1 @ measured compression ratio.

Benchmark Reader smallprint LLMLingua-2 Truncation
LongBench (QASPER+HotpotQA mix) Qwen2.5-1.5B 0.605 @ 5.7x 0.554 @ 4.8x 0.334 @ 5.0x
LongBench (QASPER+HotpotQA mix) Gemma-2-2B 0.505 @ 5.7x 0.463 @ 4.8x 0.279 @ 5.0x
NarrativeQA (10x req.) Qwen2.5-1.5B 0.697 @ 7.1x 0.490 @ 10.3x 0.545 @ 10.0x
MuSiQue (2x req.) Qwen2.5-1.5B 0.525 @ 2.1x 1.064 @ 1.9x 0.638 @ 2.0x

Full 3 benchmarks Γ— 2 readers Γ— 4 methods Γ— 4 ratios matrix in the paper and in outputs/main_results.md of the source repository.

Where baselines win (reported in the paper): LLMLingua-2 retains more on MuSiQue at 2–3Γ— on both readers; on NarrativeQA, truncation is competitive at 2Γ— for Gemma-2-2B (0.919 vs 0.923, overlapping CIs).

Overfitting probe

Train-set CE 0.731 vs held-out books (30 books, 88 pairs, generator references not in training) 0.907 β€” gap +0.176 (an overestimate: held-out targets are unfiltered single samples vs anchor-filtered best-of-K train targets). Mild overfitting, no memorization collapse.

Limitations

  • Ratio control is the binding weakness: at requested ratios 2/3/5/10 the achieved compression is ~2.0–7.1Γ— depending on benchmark. A target-tightened re-selection of the training targets (the run2 subfolder) narrows the mean absolute ratio error 5.8 β†’ 5.1 (tighter at 2–3Γ—, worse at 5Γ—, unchanged at 10Γ—) without changing QA retention; the residual is bounded by the candidate pool.
  • Trained and evaluated on English prose (public-domain book chunks for training; QA benchmarks for evaluation). OOD evaluation data (arXiv, EDGAR) was collected but not run.
  • Two reader families evaluated (Qwen2.5-1.5B, Gemma-2-2B); cross-family generalization beyond that is not measured.
  • n = 50 docs per benchmark; CIs are doc-level bootstraps.

Artifacts

  • Repository root β€” the run1 adapter (the model used in all main results; 0.35 A10G-h to train; LoRA r=16, Ξ±=32, lr 2e-4, bf16, 2 epochs, 16k context).
  • run2/ β€” the target-tightened re-selection retrain (0.34 A10G-h, identical hyperparameters).
  • Merged full model β€” trojan0x/smallprint-1.5b-merged: the run1 adapter merged into Qwen2.5-1.5B-Instruct (self-contained, no PEFT needed).

Data & license

Training data: Project Gutenberg public-domain English books (250 documents, 2,278 chunks). Base model license (Apache-2.0) applies; adapter released under Apache-2.0.

Full method, protocol, and analysis: the accompanying paper (ACL format) in the source repository.

Downloads last month
47
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for trojan0x/smallprint-1.5b

Adapter
(1,889)
this model