内容
<p align="center">
<img src="docs/assets/banner.svg" alt="Distil — 具备质量合同的压缩技术" width="100%"/>
</p>
<p align="center">
<a href="https://github.com/dshakes/distil/actions/workflows/ci.yml"><img src="https://github.com/dshakes/distil/actions/workflows/ci.yml/badge.svg" alt="持续集成"/></a>
<a href="https://pypi.org/project/distil-llm/"><img src="https://img.shields.io/pypi/v/distil-llm?color=5ad1c9&label=pypi" alt="PyPI 版本"/></a>
<a href="https://pypi.org/project/distil-llm/"><img src="https://img.shields.io/pypi/pyversions/distil-llm?color=5ad1c9" alt="Python 版本"/></a>
<a href="LICENSE"><img src="https://img.shields.io/pypi/l/distil-llm?color=8b7bff" alt="许可证"/></a>
<a href="#-what-we-wont-pretend"><img src="https://img.shields.io/badge/runtime%20deps-0-5ad19a" alt="零运行时依赖"/></a>
<a href="https://dshakes.github.io/distil/architecture.html"><img src="https://img.shields.io/badge/typed-py.typed%20%C2%B7%20mypy%20clean-8b7bff" alt="类型安全"/></a>
</p>
<h2 align="center">压缩智能代理的上下文。<br/>证明其决策不会改变。</h2>
<p align="center"><b>唯一具备统计保真度证书的上下文压缩器。</b><br/>在 <b>500 个真实编码任务</b> 中,AI 代理使用 distil 的压缩上下文 (<b>42.0%</b>) 比使用完整、未压缩的上下文 (<b>39.2%</b>) 解决的问题更多 — 压缩帮助而不是阻碍。<sub>(SWE-bench 验证)</sub></p>
```console
$ uvx --from distil-llm distil bench # ~10s,无需 API 密钥
GATE: PASS — 每个轨迹都经过认证为非劣;积极拒绝。
$ distil wrap -- claude # 路由 Claude Code,无需配置
distil · ▼75.0K · 62% 更小 · $0.31 · 总计 ▼27.0M · ✓等于 99.5%
```
<table align="center"><tr>
<td align="center"><b>⚡ 获取节省</b><br/><sub>2 分钟,无需配置</sub><br/><br/><code>pipx install distil-llm</code><br/><code>distil onboard</code></td>
<td align="center"><b>🔬 查看证明</b><br/><sub>真实测试</sub><br/><br/><a href="#-the-proof"><b>基准测试 ↓</b></a> · <a href="docs/PAPER.md">论文</a><br/><a href="https://dshakes.github.io/distil/compare.html">与其他比较</a></td>
</tr></table>
<p align="center"><sub>诚实范围:+2.8pp 是点估计(CI −0.6..+6.2 — <b>认证为非劣,但尚未证明优</b>)。 <a href="#-the-proof">详细信息,包括什么不转移 →</a></sub></p>
<p align="center">
<a href="#-use-it-now">立即使用</a> ·
<a href="#-works-with-every-sdk">集成</a> ·
<a href="#-install-your-way">安装</a> ·
<a href="https://dshakes.github.io/distil/compare.html">与其他比较</a> ·
<a href="https://dshakes.github.io/distil/getting-started.html"><b>完整文档 →</b></a>
</p>
---
<h3 align="center">证明优先 — 不是推销 📊</h3>
<p align="center"><img src="docs/assets/head-to-head.svg" alt="Distil vs LLMLingua-2 vs Headroom — token 节省、决策变更率、延迟" width="100%"/></p>
<table align="center">
<tr><th>在真实的 500 实例长时序代理<br/><sub>(SWE-bench 验证,官方测试)</sub></th><th>任务成功率</th><th>与完整上下文绑定?</th><th>可逆 + 认证?</th></tr>
<tr><td><b>Distil</b> (gated + surprise digest,v1.7)</td><td align="center"><b>42.0%</b></td><td align="center">✅ <b>+2.8pp 超过完整</b> <sub>(CI −0.6..+6.2)</sub></td><td align="center">✅</td></tr>
<tr><td><b>Distil</b> (relevance-gated,E8)</td><td align="center"><b>36.8%</b></td><td align="center">✅</td><td align="center">✅</td></tr>
<tr><td>Headroom <sub>(有损)</sub></td><td align="center">32.6%</td><td align="center">❌ −6.6pp</td><td align="center">❌</td></tr>
<tr><td>LLMLingua-2 <sub>(有损)</sub></td><td align="center">2.4%</td><td align="center">❌ −36.8pp</td><td align="center">❌</td></tr>
<tr><td>无压缩 <sub>(完整)</sub></td><td align="center">39.2%</td><td align="center">—</td><td align="center">—</td></tr>
</table>
<p align="center"><b>Distil 是唯一统计上与完整上下文绑定的压缩器 — 其 v1.7 惊喜保留摘要 <i>高于</i> 完整上下文(42.0% vs 39.2%,配对非劣性认证)</b>,而所有有损工具都失败了。并且在上面的实时对比中(由 <code>claude-opus-4-8</code> 评分),它认证了 <b>83.2% 的节省和 0% 的决策变更率</b>,比最近的工具快约 1,000 倍。 <a href="#-the-proof">完整分解 ↓</a></p>
---
## 🚀 立即使用
**一条命令即可设置并告诉您下一步怎么做:**
```bash
pipx install distil-llm
distil onboard # 检测您的代理 + 计费,连接状态栏,打印引导游览
```
它检测您的环境(Claude Code · Codex · Gemini CLI;计量 vs 订阅)并为您提供确切的命令。或者直接包装您的代理 — **无需配置,无需代码更改:**
```bash
# Claude Code 在计量 API 密钥上 — 节省真实 $$:
distil wrap --expand -- claude
# Claude Code 在 Pro/Max 订阅上 — 固定费率,ToS 安全(修剪上下文,不是 $):
distil wrap --lossless-only -- claude
# Codex,Gemini CLI 或任何代理 — 相同模式:
distil wrap --expand -- codex
```
<details>
<summary><b>设为默认值</b> — 永远不要再次输入 <code>distil wrap</code></summary>
**厌倦每次都输入 `distil wrap`?** 设为默认值 — 一次:
```bash
distil default # 添加一个托管 shell 别名,以便 `claude` 始终通过 distil 路由
distil default --undo # 随时删除它(备份后再进行任何更改)
```
它检测您的 shell(zsh / bash / fish / PowerShell)和计费模式,写入正确的行到您的 shell 实际读取的 rc 文件,并 **告诉您它检测到什么**。想要涵盖每个 SDK(不仅仅是您输入的代理)?`distil default --always-on` 运行一个持久的代理服务 — 功能强大,但它是一个您需要保持活跃的守护进程。
</details>
然后从 **您的** 流量中观察真正的节省 — 衡量,而不是估计:
```bash
distil leaderboard # 累积令牌 + 节省的 $,来自本地账本
distil dashboard # 实时终端 TUI — token-trim + 决策等效条,Ctrl-C 退出
```
**在您的流量上验证它。** `--shadow` 运行一小部分请求两次(压缩 **和** 完整)并比较代理选择的下一个操作:
```bash
distil wrap --shadow 0.1 -- claude # 包装 + 影子 10% 的请求
distil shadow-stats # 实时决策等效率
```
诚实范围:这是下一个动作等价性 — 一个 **代理**,而不是任务成功率([E7](#-the-proof) 表明它在激进的*有损*压缩下不完全转移)。Distil 安全地失败为完整上下文。
> **它会节省钱吗?** 仅在 **计量** 计费(API 密钥)上 — 更少的令牌,更少的美元。在固定费率 **订阅** 上,它修剪上下文 + 延迟,而不是账单。编码代理:短会话 ~7%,在 **长时、多次** 会话中获得大胜利,模型从未重新读取。
---
## 💡 为什么 Distil 不同
您不需要字节等价性 — 您需要 **决策等价性**:您的代理在压缩上下文中采取 *相同的动作*。这是可衡量和可认证的。
- **认证,而不是估计** — 只有当非劣性测试通过时,策略才会发布;无法认证 → 完整上下文。
- **认证端到端** — `distil certify-trajectories` 绑定了压缩可能造成的多少可解任务(没有其他压缩器认证两个级别)。
- **可逆,而不是有损** — 摘要在句柄后面,保持原始,提供给代理一个 `distil_expand` 工具。无忧压缩。
- **在结果上复合** — 扩展和匹配的失败教会策略要保护什么(仅签名,从不内容)— 总是 *更* 保守。
- **像不存在一样流式传输** — SSE 继电器逐块传输;TTFT 保留。
> **保真度层级:** 无损(`--verbatim`)· 可逆(按需字节可恢复 — 默认)· 有损(其他所有工具)。只有 Distil 提供和认证可逆层级。
---
## ⚡ 自己证明数字 — 无需 API 密钥
不要盲目相信上面的表格。`distil bench` 在捆绑的 7 个领域语料库上重新认证节省 **和** 决策等价性,离线,几秒钟内 — 与 CI 中运行的相同门控:
```bash
uvx --from distil-llm distil bench # 在 7 个领域认证节省 + 质量,几秒钟内
```
```
domain trajectory $ saved distil aggr pruned
---------------------------------------------------------------------------
ops/sre sre-disk-incident 33.1% PASS FAIL 615
coding coding-bugfix 28.7% PASS FAIL 736
support support-refund 32.6% PASS FAIL 765
research research-synthesis 25.7% PASS FAIL 809
data-analysis data-analysis-sql 18.1% PASS FAIL 965
devops devops-rollback 25.0% PASS FAIL 857
finance finance-reconcile 29.1% PASS FAIL 1014
---------------------------------------------------------------------------
aggregate: distil cuts $0.14212 -> $0.10402 (26.8% cheaper) reversibly; 5761 tokens causally prunable.
GATE: PASS — 每个轨迹都经过认证为非劣;积极拒绝所有。
```
<p align="center"><img src="docs/assets/domains.svg" alt="在 7 个领域衡量" width="100%"/></p>
> **为什么信任这个数字?** 令牌节省数字很容易造假 — 在 *低* 压缩下衡量质量,在 *高* 压缩下宣传节省。Distil 拒绝这样做:准确性和压缩在 **相同** 轨迹上衡量,并且无法通过非劣性测试的策略不会发布。
> ```
> distil certify --strategy distil # VERDICT: PASS (100% 决策等价性)
> distil certify --strategy aggressive # VERDICT: FAIL (平均差异 −1.0,阻止)
> ```
`distil eval` 绘制 **认证压缩前沿** — 一个节省-vs-质量曲线,其中每个点都带有其认证判决,定位损失压缩下降的悬崖。没有竞争对手发布的工件: [benchmark.html](https://dshakes.github.io/distil/benchmark.html).
---
## 📊 证明
三个结果,所有可复制,所有发布时带有免责声明:
- **实时对比** vs 真实的 `llmlingua` / `headroom-ai`(由 `claude-opus-4-8` 评分): **83.2% 节省和 0% 决策变更率**,比最近的工具快约 1,000 倍。 → [基准测试](https://dshakes.github.io/distil/benchmark.html)
- **E7(SWE-bench 验证):** 激进的*有损*压缩 **使任务成功率下降** (52% → 16%) — 每步认证不能转移到多步骤。 **可逆** 层级存活(56% vs 52%)。我们发布它,因为它是真实的。 → [E7](https://dshakes.github.io/distil/research.html#e7)
- **E8–E14(500 实例代理):** 可逆层级是 **唯一一个与完整上下文非劣的压缩器** ,在 5 个模型 / 3 个供应商之间推广,并且最新的摘要位于 *之上* 完整(42.0% vs 39.2%)。 → [E8–E14](https://dshakes.github.io/distil/research.html#e8)
完整的方法论,McNemar 测试,每个实例的数据:[`docs/PAPER.md`](docs/PAPER.md) · [PDF](docs/paper/main.pdf).
---
## 📡 看它工作
在 **您的** 流量上衡量,从不估计,什么都不离开您的机器:
- **每次请求:** `x-distil-*` 响应头(`tokens-saved`,`mode`,`compressible-tokens`,`expanded`)。
- **每台机器:** `distil leaderboard`( `--html` 用于页面)。
- **影子模式:** `distil proxy --shadow 0.05` 报告实时决策变更率 — 流感知。
- **整个组织:** `distil proxy` 边车 + 设置 `ANTHROPIC_BASE_URL` 一次;每个客户端都通过它路由。
仪表板,状态栏插件,联合排行榜:[部署与可观察性](https://dshakes.github.io/distil/deploy-security.html).
## 🔌 与每个 SDK 配合使用
一个代理。指向任何遵守 `base_url` 的客户端 — **Python、TypeScript、任何语言** — 并获得缓存感知 **可逆** 压缩,无需代码更改。
<p align="center"><img src="docs/assets/cross-sdk.svg" alt="一个代理,适用于每个 SDK" width="100%"/></p>
```bash
distil proxy --upstream https://api.anthropic.com # localhost:8788
```
| SDK / 框架 | 更改 | 示例 |
|---|---|---|
| Anthropic SDK (Py/TS) | `base_url="http://127.0.0.1:8788"` | [`examples/python_anthropic.py`](examples/python_anthropic.py) |
| OpenAI SDK | `base_url="http://127.0.0.1:8788/v1"` | [`examples/python_openai.py`](examples/python_openai.py) |
| Vercel AI SDK | `createAnthropic({ baseURL: '…:8788' })` | [`examples/js_vercel_ai_sdk.ts`](examples/js_vercel_ai_sdk.ts) |
| LangChain (py/js) | `anthropicApiUrl` / 基础 URL | [`examples/js_langchain.ts`](examples/js_langchain.ts) |
| LiteLLM | `api_base="http://127.0.0.1:8788"` | [`examples/python_litellm.py`](examples/python_litellm.py) |
| Google Gemini | `--upstream https://generativelanguage.googleapis.com` | [`examples/python_gemini.py`](examples/python_gemni.py) |
更喜欢进程内?直接包装客户端 — 仍然无需调用站点更改:
```python
from distil.adapters.anthropic import wrap
client = wrap(anthropic.Anthropic()) # 压缩请求,保持缓存热度
```
**框架钩子(无需代理,无网络跳转)** — 适用于拥有消息列表的代理框架,压缩消息列表:
| 框架 | 钩子 | 示例 |
|---|---|---|
| LiteLLM | `distil.integrations.litellm.compress(kwargs)` | [`examples/python_litellm.py`](examples/python_litellm.py) |
| LangChain | `distil.integrations.langchain.compress_messages(msgs)` | — |
| LangGraph | `pre_model_hook=pre_model_hook()`(在模型节点之前压缩图状态) | [`examples/python_langgraph.py`](examples/python_langgraph.py) |
---
## 📦 按需安装
**新用户?** `pipx install distil-llm`,然后 `distil onboard` — 它设置并引导您(参见 [立即使用](#-use-it-now))。想先查看它证明自己?`distil bench` 在 ~10 秒内运行认证门控,无需 API 密钥。下面的矩阵用于选择 *安装格式* — 其中每个都是替代方案,而不是需求。
<details>
<summary><b>安装注意事项和故障排除</b> (包名,旧 Python 错误,过期镜像)</summary>
> ⚠️ **唯一需要注意的是包名。** PyPI 包是 **`distil-llm`** 但命令是 **`distil`** (包名被占用)。所以 `pipx install distil-llm` → 运行 `distil …`。`pip install distil` 安装的是其他东西。
> 🔧 **看到 `Could not find a version that satisfies the requirement distil-llm (from versions: none)`?** 包 **存在** 在 PyPI 上 — 这个错误意味着您的 `pip` / `pipx` 位于比包的最低 Python 版本更老的 Python 上,因此 pip 过滤掉了所有版本。**Distil 现在支持 Python 3.9+** (macOS 默认自带),因此当前安装直接有效;如果您仍然遇到这个问题,在非常老的 Python 上, **uv 为您提供一个**:`uvx --python 3.12 --from distil-llm distil bench` (或 `uv tool install --python 3.12 distil-llm`)。用 `python3 --version` 检查您的版本。
> 🔧 **得到一个 *旧* 版本(例如 `0.25.1`)而不是最新版本?** 公共 PyPI 始终提供最新版本(`pip index versions distil-llm` 列出它们)。如果您得到一个旧版本,您的 `pip` / `pipx` **没有解析公共 PyPI** — 通常是 **过时的内部镜像** (Artifactory / CodeArtifact / Nexus 在最近发布后尚未同步)或约束文件 / `pip.conf` 中的 `<1.0` 版本固定。诊断并修复:
> ```bash
> pip index versions distil-llm # 停在旧版本? → 您的索引/镜像已过时
> pip config list ; env | grep -i pip # 查找索引网址或 PIP_CONSTRAINT 固定
> # 现在使用公共 PyPI 取消固定:
> pipx install --pip-args="--index-url https://pypi.org/simple/" distil-llm
> # (或者,如果必须使用镜像,请让您的平台团队同步 distil-llm;它在上游存在)
> ```
</details>
<p align="center"><img src="docs/assets/install.svg" alt="安装选项" width="100%"/></p>
| 格式 | 命令 | 前提 |
|---|---|---|
| **零安装** | `uvx --from distil-llm distil bench` | [uv](https://docs.astral.sh/uv/) — **自动提供 Python 3.9+** |
| **隔离 CLI** | `pipx install distil-llm` → `distil bench` | Python **3.9+** (否则 `pipx install --python python3.12 distil-llm`) |
| **Homebrew** | `brew install dshakes/tap/distil` | Homebrew |
| **Docker** | `docker run ghcr.io/dshakes/distil:latest bench` (或 `docker build -t distil .`)| Docker |
| **单个文件** | `make pyz` → `python dist/distil.pyz bench` | Python 3.9+ |
| **在虚拟环境中** | `pip install distil-llm` (在活动虚拟环境中) | Python 3.9+ |
> 导入包和 CLI 是 `distil`;PyPI 发行版是 `distil-llm` (包名被占用 — 所以 `uvx` / `pip` 必须引用 `distil-llm`,而不是 `distil`)。Distil 是一个 CLI:**隔离安装** (pipx/uv/brew/Docker),因为现代 macOS/Linux 阻止系统范围的 `pip install` ([PEP 668](https://peps.python.org/pep-0668/))。**节点 / 任何语言:** 将 SDK 的 `base_url` 指向 `distil proxy`,或使用 `distil wrap -- <agent>` — 无需 Distil 特定包。
## 🧰 快速参考
基础知识请参见 [立即使用](#-use-it-now) 和 [与所有 SDK 兼容](#-works-with-every-sdk)。除此之外:
| 目标 | 命令 |
|---|---|
| **设置 + 导览(从这里开始)** | `distil onboard` |
| 将 distil 设置为默认(无需每次会话都执行 `wrap`) | `distil default` · 撤销:`distil default --undo` |
| 删除 distil 的 footprint(在卸载前) | `distil offboard` · 同时清除数据:`distil offboard --purge` |
| 诊断您的设置(ledger、shadow、proxy 自我测试、线路) | `distil doctor` |
| 将节省状态行连接到 Claude Code | `distil setup`(紧凑段:`DISTIL_STATUSLINE=minimal`) |
| 查看实际节省 | `distil leaderboard` · 实时 TUI:`distil dashboard` |
| 在真实流量上进行实时决策等价性测试 | `distil wrap --shadow 0.1 -- claude` → `distil shadow-stats` |
| 在您的域名上认证 | `distil ingest --input prod.jsonl --out ./mycorpus` → `distil conformal --corpus ./mycorpus` |
| 从任何代理(MCP)恢复消化细节 | `distil mcp` |
| 自我改进的保留策略 | `distil learn` / `distil online` |
> **状态行** — 每个状态下的一个模式:`distil · <live> · total ▼<lifetime>`。
>
> | 状态 | 您看到的 | 含义 |
> |---|---|---|
> | **节省中** | `distil · ▼12.0K · 40% smaller · $0.31 · total ▼27.0M · ✓eq 99%` | 压缩您的最近流量(最近 15 分钟,所有终端) |
> | **观察中** | `distil · ✓ on · waiting for a large read · total ▼27.0M` | 已启用,但尚未有大量内容 — 节省来自大文件/命令输出 |
> | **空闲** | `distil · ✓ on · total ▼27.0M` | 已设置并启用,无最近流量 |
>
> `▼` = 已节省的 tokens · `total` = 生命周期 · `✓eq` = 决策等价性(显示过去 25 个 shadow 样例)。与 git/cwd/model 共享该行? `DISTIL_STATUSLINE=minimal` → `distil ▼7.8K · 27M total`。在**订阅**上,美元是名义上的且自动隐藏(`DISTIL_SUBSCRIPTION=0/1`)。
经验法则:**订阅/交互 → `--lossless-only` (+`--verbatim`)** · **PAYG/自主 → 默认摘要 (+`--expand`)** · **代码重读 → 添加 `--session-delta`**。
---
## 🧠 工作原理
<p align="center"><img src="docs/assets/architecture.svg" alt="architecture — pipeline and the quality-contract loop" width="100%"/></p>
两种技术带来了大部分的收益 — 它们针对的是智能体循环中真正花费钱的地方,而不是看起来花费钱的地方。
### ① 缓存感知压缩 — 主要杠杆
您每次都重新发送增长的上下文。使用提示缓存,缓存 **读取的成本比新鲜输入便宜约 10 倍**,因此真正的成本是缓存 **未命中**,而不是上下文 **大小**。Distil 保持前缀字节稳定(模式规范化 + 将类似时间戳/UUID 的易变字段提升出前缀)并仅压缩易变尾部。
<p align="center"><img src="docs/assets/cache-aware.svg" alt="cache-aware savings" width="100%"/></p>
> 天真的重新压缩发送的 **token 较少,但比根本不压缩更昂贵**,因为它每次都重写缓存前缀。Distil 不会这样做 — 这是大多数工具忽略的重点。
### ② 因果/反事实剪枝 — 发现引擎
评估不是一个固定在侧面的尺子;它是一个**发现引擎**。移除一个上下文块,重新播放,决策是否改变?**不会改变决策的块可以证明是免费的,可以丢弃**。
```bash
distil prune
# doc-0 PRUNE (causally inert) # 推测性检索,从未被引用
# obs-0 keep (changed a decision) # 携带决策驱动信号
```
---
## 🎓 证书(DERC)
网关回答 **“该策略在我的语料库中是否非劣?”**。**决策等价风险证书** 回答操作问题:**“对于我选择的某个风险预算(例如 ≤5% 决策变化),我可以压缩多少并保证在我的真实流量上仍然有效?”**
```bash
distil conformal --corpus ./mycorpus --alpha 0.05 --delta 0.05
# ✔ CERTIFIED 'lossless' → 57.4% savings; decision-change ≤ 5.0% at 95% confidence (Learn-Then-Test)
```
这是 **一致性风险控制**(Learn-Then-Test / CRC — 无分布,限样本),而不是启发式阈值。唯一的承载关键点:保证需要 **可交换性**(校准流量 ≈ 实时流量)并且在该分布上 **边缘** — 需要重新校准以适应漂移。完整的理论 + 引用:[概念](https://dshakes.github.io/distil/concepts.html) · [`docs/PAPER.md`](docs/PAPER.md)。
### 🏔 轨迹级证书
DERC 认证 **步骤**;本证书认证 **任务**。我们的 E7 实验 — 以及 2024-26 年的智能体压缩文献 — 显示每步保真度可以传递,而端到端成功率却会崩溃,因此 distil 还会认证用户实际感受到的级别:运行您的评估套件两次(完整上下文 vs 压缩),输入匹配的结果,并获得一个无分布的边界,说明 **压缩可能会使多少可解任务失败**:
```bash
distil certify-trajectories outcomes.jsonl --alpha 0.05 --delta 0.05
# each line: {"task_id": "...", "full_success": true, "compressed_success": true}
# → With confidence 95%, compression degrades at most 5.0% of tasks the full
# context would have solved (observed 0.5% over 200 matched trajectories).
```
它拒绝在小样本上认证,在证书本身中声明其可交换性假设,并附带一个 **漂移监测器** (`trajectory_risk.drift_monitor`),当实时流量发生足够大的偏移时,该监测器会告知您证书已过期。匹配的失败结果也会馈送到 **结果引导的策略** (`distil.compress.guideline`):被破坏的字节精确内容类别在消化后会自动受到保护。
## 🧩 内部结构
已发布的 40+ 功能,全部为真实功能(无存根):缓存感知成本引擎、因果剪枝、TOST 网关 + 一致性证书、代理 + Anthropic/OpenAI/Gemini 适配器、MCP 服务器、LiteLLM/LangChain/LangGraph 钩子、学习保留模型、输出压缩和 Rust 热点核心 — 核心中 **无运行时依赖**。
完整的模块映射:[架构](https://dshakes.github.io/distil/architecture.html) · [技术](https://dshakes.github.io/distil/techniques.html) · [CLI 参考](https://dshakes.github.io/distil/cli.html)。
## 🔒 安全性和部署
- **默认仅限本地主机** — 代理绑定到 `127.0.0.1` 并仅转发到单个配置的上游(无 SSRF)。
- **无秘密/主体日志记录** — 请求正文和凭证永远不会被记录。
- **身份验证模式门控** — `--lossless-only` 保留订阅/OAuth 会话以实现无损策略,并且永远不会注入工具(提供者-ToS 安全);可逆的认证摘要仍然运行。添加 `--verbatim` 以完全跳过摘要(仅限 Tier-0)以实现交互式会话。
- **无状态** — 无需持久化;兼容 ZDR。
参见 [部署和安全](https://dshakes.github.io/distil/deploy-security.html),了解拓扑结构(本地 sidecar、容器 sidecar、共享网关)和威胁模型。
---
## ✅ 不做虚假宣传
- **默认分词器是离线启发式** — 比例稳健,美元近似。 `--tokenizer anthropic` 用于计费级计数。
- **默认运行器是确定性占位符**(离线网关与真值)。非循环评估 **使用真实模型和真实智能体轨迹进行评级** — [证明框架](#-reproducible-evaluation--the-paper)。
- **可信赖的评级,强制执行:** 多数投票(单个样本允许评级噪声看起来像决策变化),同一家族的评级器,并使用其 `distil_expand` 恢复循环对可逆层进行评级。
- **无制造的权重** — 保留模型是真正的逻辑分类器(96.4%);Transformer 随演示检查点一起提供,您可以在您的轨迹上重新训练。
### 刻意 *不* 作为平台
Distil 是一个 **带有正确性网关的压缩引擎**,而不是上下文套件。我们拒绝那些无法在证书下通过的功能:
| 相邻功能 | 我们的立场 |
|---|---|
| 持久内存 / 知识图谱 | **超出范围** — 有损存储与字节可逆性相反。 |
| 主机语义缓存 | **超出范围** — 我们让 **提供者的** 提示缓存受益,而不是第二个有损缓存。 |
| 编辑器/副驾驶身份验证 | **超出范围** — Distil 位于线路或进程中;从不代理凭证。 |
我们采用了(它在网关下幸存):可插拔的显著性评分器来 **保护** 实体,缓存前缀可观察性和框架钩子。
---
## 🎯 账单的两边
Distil 压缩 **输入/上下文**(全面)**和输出** — 生成端 verbosity 整形(PAYG,用 `distil output-savings` 衡量)加上可逆输出再入摘要,因此冗长的过去答案不再花费全价的历史记录。详情:[输出和 I/O](https://dshakes.github.io/distil/output.html)。
## 🔬 可复制评估和论文
每个数字都从捆绑的语料库中复制(`distil bench`,无密钥)。非循环证明框架对 **真实智能体轨迹和真实模型进行评级**(τ-bench / SWE-bench):[`benchmarks/PROVE.md`](benchmarks/PROVE.md)。编译论文、LaTeX 源代码和所有提交的结果:[`docs/PAPER.md`](docs/PAPER.md) · [`docs/paper/`](docs/paper/) · [论文 PDF](docs/paper/main.pdf)。
<h3 align="center">停止支付重新发送智能体从未读取的上下文。</h3>
<p align="center">
<code>pipx install distil-llm && distil bench</code><br/>
<sub>在 ~10 秒内认证 7 个领域的节省 — 零 API 密钥,零运行时依赖</sub>
</p>
<p align="center">
<a href="https://dshakes.github.io/distil/getting-started.html"><b>开始使用 →</b></a> ·
<a href="#-works-with-every-sdk">将其连接到您的 SDK</a> ·
<a href="docs/PAPER.md">阅读证明</a> ·
<a href="https://pypi.org/project/distil-llm/">PyPI</a>
</p>
---
## ⭐ 如果 distil 为您节省了 token
一颗星是下一个工程师找到可证明的节省而不是有损猜测的方式 — 而
`distil stats --badge` 为您提供一个 **您自己的测量数字** 的可分享徽章来展示它。 该徽章 + 此仓库是整个营销部门。
## 🤝 贡献
欢迎 PR — 请参见 [CONTRIBUTING.md](CONTRIBUTING.md)。最重要的规则:**新的压缩策略必须通过 `make gate`**(在每个领域都非劣,无损字节可逆)。没有绿色网关,无合并。那是哲学的全部。
## License
[Apache-2.0](LICENSE) · *“相同的效力,更少的体积。”*
连接信息
猜你喜欢
暂无推荐服务器