Skip to content

openDreamStudioResearch/context-window-prober

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

context-window-prober

一个用于测试 OpenAI 兼容接口模型上下文窗口大小的 Python 脚本。

脚本文件:probe_context_window.py

功能

  • 先按常见上下文档位探测(2K / 4K / 8K / 16K / ...)
  • 自动做二分逼近,估算可用上下文上限
  • 输出建议的安全 prompt budget(方便你做会话压缩)
  • 支持交互式输入:Base URL -> API Key -> Model

运行要求

  • Python 3.9+
  • 可访问目标 OpenAI 兼容 API

快速开始(交互式)

python3 probe_context_window.py

按提示输入:

  1. Base URL(例如 https://your-host:port
  2. API Key
  3. Model 名称

非交互模式

python3 probe_context_window.py \
  --no-interactive \
  --base-url https://your-host:port \
  --api-key 'sk-xxx' \
  --model your-model-name \
  --json

常用参数

  • --max-output-tokens 1:降低探测成本
  • --safe-margin 256:给生产请求留安全余量
  • --binary-steps 20:二分最多迭代次数
  • --checkpoints 2048,4096,8192,16384:自定义预探测档位

建议仓库名

推荐:context-window-prober

备选:

  • llm-context-prober
  • model-context-tester

About

一个用于测试 OpenAI 兼容接口模型上下文窗口大小的 Python 脚本。

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages