Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lasercut

Given the context units that went into a prompt and the answer they produced, lasercut estimates how much each unit contributed. When the estimates support it, the library returns a smaller prompt that keeps the units that carried the answer.

Install

uv add lasercut
pip install lasercut

Example

from lasercut import ContextUnit, EstimateConfig, attribute, apply_prune

units = (
    ContextUnit("city", "Paris is the capital of France."),
    ContextUnit("noise", "A shopping list: milk, bread, eggs."),
)
result = attribute(units, "What is the capital of France?", "Paris.", EstimateConfig())
kept = apply_prune(units, result)

Verdicts

  • PRUNE. The estimates are tight enough, and a smaller set of units carries enough of the mass, so the prompt can be cut.
  • INSUFFICIENT_BUDGET. The call budget ran out before every unit could be placed clearly above or below the keep line.
  • NOT_PRUNABLE. The estimates are tight, and no smaller set of units carries enough of the mass to justify a cut.

Limitations

Black-box estimates need many scorer calls because each coalition is a separate request. Units are treated as interchangeable players in a cooperative game, so the estimate does not encode order or overlap between units. EMBEDDING mode measures agreement between the original answer and a sampled completion, which is a weaker signal than token likelihood. tracllmkit is a GPU research toolkit with a different contract: it wraps several attribution methods behind a permutation count and does not expose a call-budget prune path.

Citations

  • Castro, Gómez, and Tejada, 2009. Polynomial calculation of the Shapley value based on sampling. Truncated Monte Carlo Shapley.
  • TracLLM, USENIX Security 2025. arXiv:2506.04202.
  • TokenShapley. arXiv:2507.05261.
  • Shapley Context Pruning. arXiv:2607.16209.

About

Estimate which context units produced an answer, then prune the rest.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages