Skip to content

docs(tokenless): document compression-rate scenarios and standard test load - #2601

Open
Forrest-ly wants to merge 5 commits into
alibaba:mainfrom
Forrest-ly:chore/tokenless-doc-compress-rate-scenarios
Open

docs(tokenless): document compression-rate scenarios and standard test load#2601
Forrest-ly wants to merge 5 commits into
alibaba:mainfrom
Forrest-ly:chore/tokenless-doc-compress-rate-scenarios

Conversation

@Forrest-ly

Copy link
Copy Markdown
Collaborator

改动说明

应客户反馈,在 tokenless 用户文档中补充「压缩率适用场景」说明,并指引使用仓库内置的标准测试负载,使用户能够:1) 了解不同场景下的预期压缩率区间与影响因素;2) 用标准负载复现参考压缩率,自行验证所用版本的效果。

变更内容

  • docs/user-guide/{zh,en}/token-saving/tokenless/measuring-savings.md
    • 新增小节「压缩率的适用场景 / Where the compression rate applies」:
      • 参考节省率表(6 个场景:单路响应压缩、单路 Schema 压缩、混合负载仅响应、Schema+响应叠加、全栈叠加、仅 TOON),全部数字为使用标准测试负载对当前代码实测所得;
      • 按场景归纳:收益高(统一结构记录 / 冗余字段 / 冗长描述)、收益中等(Shell 输出超 Layer 2 阈值部分)、收益接近零(短于最小触发长度 / 已紧凑无冗余 / 尺寸保护)、不参与压缩(内容读取类工具 / 非 JSON / Skill 文本);
      • 提示实际会话收益还需乘以工具 Payload 占比,交叉引用现有小节「正确解释节省率」。
    • 新增小节「标准测试负载 / Standard test load」:
      • 说明仓库内置负载(src/tokenless/benchmark/l1-compressor/fixtures/ 下 3 个 canonical fixtures,由 python/gen_fixtures.py 生成、无随机数、字节级可复现、已提交);
      • 给出运行方式:cargo run --release --bin compression_rate(快速报告)与 ./run-benchmarks.sh --quick(完整质量/对抗测试 + 报告),均已在本地实际执行验证;
      • 注意事项:Token 为 bytes/4 启发式估算、适合版本间相对比较;引用数字需注明 commit/版本;评估业务收益应使用 dry-run 双跑对比。
    • 触发条件交叉引用 PR docs(tokenless): document compression trigger conditions and thresholds #2600 在用户手册新增的小节(锚点按 docs(tokenless): document compression trigger conditions and thresholds #2600 的实际标题对齐)。

测试情况

测试范围与实际执行的命令(本次为纯文档变更,共 2 个 Markdown 文件;为保证文档中的数字与操作步骤真实有效,实际运行了标准测试负载全流程):

  1. 标准测试负载实测(验证文档引用数字与运行步骤):
    • cargo build --release --bin compression_rate(l1-compressor 独立 workspace)— 成功
    • cargo run --release --bin compression_rate — 输出与文档参考节省率一致:canonical response 65.8%、canonical schema 47.3%、混合负载 response_only 61.7%、schema_response 64.7%、full_stack 62.9%、toon_only 15.8%
    • ./run-benchmarks.sh --quick(完整质量/对抗测试 + 压缩率报告)— 全部通过,退出码 0
    • cargo test --release — 96 passed、0 failed(13 个测试套件,含质量保留、对抗、worst-case、压缩率回归守护)
  2. bash scripts/docs-lint.sh(CI 文档门禁:命名规范 + en/zh 目录树镜像)— 通过
  3. python3 scripts/docs-link-check.py(相对链接检查)— 通过
  4. 文档引用的阈值与负载说明逐项对照源码核实:common/hooks/compress_response_hook.pycompress_toon_hook.py(最小 200 字符)、codex/scripts/compress-response(500/4,000 字符)、tool_categories.json(Layer 2/3 阈值)、benchmark fixtures 与 gen_fixtures.py

环境概要:Linux x86_64;Rust 1.94.1(cargo 1.94.1);Python 3.8.17;rtk 0.43.0(报告中 RTK 采样正常输出)。

结果汇总:96 个测试全部通过,0 失败;文档门禁脚本全部通过;文档参考节省率与实测值完全一致。

未运行项及原因

  • criterion 性能基准(cargo bench):未运行 — 本次不涉及性能结论,--quick 模式按设计跳过该部分。
  • 真实业务工作负载的端到端测量:未运行 — 文档已明确标准负载用于版本间横向对比,业务收益需按双跑对比另行测量。

@Forrest-ly
Forrest-ly requested a review from casparant as a code owner August 17, 2026 05:24
@github-actions github-actions Bot added the scope:documentation ./docs/|./*.md|./NOTICE label Aug 17, 2026

@qoderai qoderai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 英文文档的“Standard test load” 小节仅在括号中写明 “Linux only”,未明确说明该 workspace 不支持 macOS/Windows,易让跨平台用户误以为可以直接运行,建议补充平台约束说明。
  2. 中文文档对应小节虽提到“仅支持 Linux”,但同样未显式声明在 macOS/Windows 上不支持运行,建议与英文版对齐,追加明确的平台限制句。

🤖 Generated by QoderView workflow run


Real session savings must additionally be multiplied by the share of tool payloads in total session tokens; see [Interpret the saving rate correctly](#interpret-the-saving-rate-correctly) above.

## Standard test load

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 标准测试负载路径缺少平台约束说明

“Standard test load” 小节仅在括号中标注 “Linux only”,但没有明确说明该 workspace 无法在 macOS/Windows 上运行。对只读文档的用户来说,可能误以为任何平台都可直接进入目录运行 cargo run/./run-benchmarks.sh,在不支持平台上必然失败。建议在括号中或紧随其后增加一句明确平台限制,例如 “Linux only; unsupported on macOS and Windows”。


🤖 Generated by QoderFix in Qoder

@Forrest-ly Forrest-ly Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已采纳。已将该小节的平台约束显式写为 "(a standalone Cargo workspace; Linux only — unsupported on macOS and Windows)",避免读者误以为任意平台都可直接运行 cargo run / ./run-benchmarks.sh。见 commit ffdd307


实际会话收益还要乘以工具 Payload 在会话总 Token 中的占比,见上文[正确解释节省率](#正确解释节省率)。

## 标准测试负载

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 标准测试负载中文描述缺少平台约束说明

“标准测试负载” 小节中仅在括号中写明 “仅支持 Linux”,但未指出该 workspace 在 macOS/Windows 上不支持运行。用户可能误以为任意平台都可进入目录执行 cargo run/./run-benchmarks.sh,在不支持平台上必然失败。建议与英文版保持一致,显式补充“不支持 macOS/Windows”的平台约束语句。


🤖 Generated by QoderFix in Qoder

@Forrest-ly Forrest-ly Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已采纳。中文版已同步修改为 "(独立 Cargo workspace;仅支持 Linux,不支持 macOS/Windows)",与英文版保持一致。见 commit ffdd307

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d5f09b8e97

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

| Function-calling schema (long descriptions), schema compression alone | ~47% | description truncation; `title`/`examples` and code blocks removed |
| Mixed workload (response + schema): response compression only | ~62% | responses dominate the savings |
| Mixed workload: schema + response stacked | ~65% | both payload types reduced |
| Mixed workload: full stack (schema + response + TOON) | ~63% | little room left for TOON after response compression |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Report the deployed full-stack rate

This ~63% value comes from the benchmark’s ungated full_stack, which always TOON-encodes both compressed payloads (src/metrics.rs:355-358,387). The deployed compress-toon path instead keeps the original input whenever TOON does not reduce the estimated token count (tokenless-cli/src/main.rs:888-910), and the benchmark itself notes that this fixture therefore remains at the compressed-only rate of about 65%. Presenting the ungated value as the full-stack Tokenless result contradicts the size-guard behavior described below; either report the gated rate or label this as a synthetic ungated measurement.

AGENTS.md reference: AGENTS.md:L337-L343

Useful? React with 👍 / 👎.

@Forrest-ly Forrest-ly Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted. Verified against the code and the benchmark output: full_stack in src/metrics.rs is ungated (measures 62.9% on the standard fixture), while the deployed compress-toon path applies a size guard (tokenless-cli/src/main.rs) that keeps the original input whenever TOON does not reduce the estimated token count. For the standard fixture TOON inflates after response/schema compression, so the deployed rate equals the compressed-only rate (schema_response, 64.7% ≈ ~65%). The table now reports the gated ~65% as the full-stack result and keeps the ungated ~63% benchmark value as an explicit note for traceability. The Chinese doc was updated the same way. See commit ffdd307.


```bash
cd src/tokenless/benchmark/l1-compressor
cargo run --release --bin compression_rate # add --json for machine-readable output

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Put --json after Cargo's separator

Appending --json as instructed produces error: unexpected argument '--json' found because Cargo consumes options before the binary argument separator. Checked cargo run --help, which explicitly says binary flags must be passed after --; show cargo run --release --bin compression_rate -- --json so the documented machine-readable invocation works.

AGENTS.md reference: AGENTS.md:L337-L343

Useful? React with 👍 / 👎.

@Forrest-ly Forrest-ly Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted. Reproduced: cargo run --release --bin compression_rate --json fails with error: unexpected argument '--json' found (cargo consumes options before the binary argument separator). The doc now shows cargo run --release --bin compression_rate -- --json, which was verified to build and emit valid JSON. The Chinese doc was updated as well. See commit ffdd307.

@Forrest-ly

Copy link
Copy Markdown
Collaborator Author

来自同一任务的另一个并行执行:我提交的重复 PR #2602 已关闭,以本 PR 为准跟进。

一个合并顺序提示供参考:本 PR 中新增的 user-manual.md#compression-trigger-conditions-and-thresholds(中文对应锚点)交叉引用指向 PR #2600 在用户手册中新增的小节。scripts/docs-link-check.py 只校验文件存在、不校验锚点,但 Pages 构建(Docusaurus onBrokenMarkdownLinks: throw 与构建后片段校验)会校验锚点。若 #2600 先于本 PR 合并则无影响;若本 PR 先合并,Pages 检查可能因锚点尚不存在而失败,建议关注两个 PR 的合并顺序或在合并前 rebase 对齐。

…ore/tokenless-doc-compress-rate-scenarios

Bring in the user-manual anchor (#compression-trigger-conditions-and-thresholds)
that measuring-savings references, so PR alibaba#2601 passes the website link check
before PR alibaba#2600 is merged. Cross-PR dependency fix for CI.
… --json usage

- Make the Linux-only constraint of the standard test load explicit
  (unsupported on macOS/Windows) in EN and ZH docs.
- Report the deployed (gated) full-stack rate ~65% instead of the
  benchmark's ungated full_stack ~63%: the compress-toon size guard
  keeps the original input when TOON does not reduce estimated tokens,
  which is what happens for the standard fixture. The ungated
  benchmark value is kept as a note for traceability.
- Show -- --json in the compression_rate invocation; cargo consumes
  options before the binary argument separator, so the previously
  documented form errored with 'unexpected argument'.
…ompress-rate-scenarios

# Conflicts:
#	docs/user-guide/en/token-saving/tokenless/framework-integration.md
#	docs/user-guide/zh/token-saving/tokenless/framework-integration.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:documentation ./docs/|./*.md|./NOTICE

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant