[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-openai--gpt-oss":3,"tool-openai--gpt-oss":62},[4,18,26,36,46,54],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",160784,2,"2026-04-19T11:32:54",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":42,"last_commit_at":43,"category_tags":44,"status":17},8272,"opencode","anomalyco\u002Fopencode","OpenCode 是一款开源的 AI 编程助手（Coding Agent），旨在像一位智能搭档一样融入您的开发流程。它不仅仅是一个代码补全插件，而是一个能够理解项目上下文、自主规划任务并执行复杂编码操作的智能体。无论是生成全新功能、重构现有代码，还是排查难以定位的 Bug，OpenCode 都能通过自然语言交互高效完成，显著减少开发者在重复性劳动和上下文切换上的时间消耗。\n\n这款工具专为软件开发者、工程师及技术研究人员设计，特别适合希望利用大模型能力来提升编码效率、加速原型开发或处理遗留代码维护的专业人群。其核心亮点在于完全开源的架构，这意味着用户可以审查代码逻辑、自定义行为策略，甚至私有化部署以保障数据安全，彻底打破了传统闭源 AI 助手的“黑盒”限制。\n\n在技术体验上，OpenCode 提供了灵活的终端界面（Terminal UI）和正在测试中的桌面应用程序，支持 macOS、Windows 及 Linux 全平台。它兼容多种包管理工具，安装便捷，并能无缝集成到现有的开发环境中。无论您是追求极致控制权的资深极客，还是渴望提升产出的独立开发者，OpenCode 都提供了一个透明、可信",144296,1,"2026-04-16T14:50:03",[13,45],"插件",{"id":47,"name":48,"github_repo":49,"description_zh":50,"stars":51,"difficulty_score":32,"last_commit_at":52,"category_tags":53,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",109154,"2026-04-18T11:18:24",[14,15,13],{"id":55,"name":56,"github_repo":57,"description_zh":58,"stars":59,"difficulty_score":32,"last_commit_at":60,"category_tags":61,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[45,13,15,14],{"id":63,"github_repo":64,"name":65,"description_en":66,"description_zh":67,"ai_summary_zh":68,"readme_en":69,"readme_zh":70,"quickstart_zh":71,"use_case_zh":72,"hero_image_url":73,"owner_login":74,"owner_name":75,"owner_avatar_url":76,"owner_bio":77,"owner_company":78,"owner_location":78,"owner_email":78,"owner_twitter":78,"owner_website":79,"owner_url":80,"languages":81,"stars":110,"forks":111,"last_commit_at":112,"license":113,"difficulty_score":114,"env_os":115,"env_gpu":116,"env_ram":117,"env_deps":118,"category_tags":128,"github_topics":78,"view_count":32,"oss_zip_url":78,"oss_zip_packed_at":78,"status":17,"created_at":129,"updated_at":130,"faqs":131,"releases":132},9668,"openai\u002Fgpt-oss","gpt-oss","gpt-oss-120b and gpt-oss-20b are two open-weight language models by OpenAI","gpt-oss 是 OpenAI 推出的开源权重语言模型系列，包含 gpt-oss-120b 和 gpt-oss-20b 两个版本，旨在为开发者提供强大的推理能力和智能体（Agentic）任务支持。它主要解决了高性能大模型难以在本地或单卡环境下高效部署的痛点，让复杂的逻辑推理、代码执行及网页浏览等功能不再依赖昂贵的云端集群。\n\n这款工具特别适合开发者、研究人员以及需要构建定制化 AI 应用的企业团队。其技术亮点显著：采用宽松的 Apache 2.0 许可，允许自由商用与修改；支持动态调节“推理力度”，用户可根据场景在低延迟与高深度思考之间灵活切换；同时完整开放思维链（Chain-of-Thought），便于调试与建立信任。得益于 MXFP4 量化技术，参数量高达 1170 亿的 gpt-oss-120b 仅需单张 80GB GPU（如 H100）即可运行，而轻量版的 gpt-oss-20b 甚至能在 16GB 显存中流畅工作。此外，模型原生支持函数调用、结构化输出及 Python 代码执行，并需配合专用的\"Harmony\"响应格式使用，以确保最佳性能与稳定性。无论是用于生产环境的高阶推","gpt-oss 是 OpenAI 推出的开源权重语言模型系列，包含 gpt-oss-120b 和 gpt-oss-20b 两个版本，旨在为开发者提供强大的推理能力和智能体（Agentic）任务支持。它主要解决了高性能大模型难以在本地或单卡环境下高效部署的痛点，让复杂的逻辑推理、代码执行及网页浏览等功能不再依赖昂贵的云端集群。\n\n这款工具特别适合开发者、研究人员以及需要构建定制化 AI 应用的企业团队。其技术亮点显著：采用宽松的 Apache 2.0 许可，允许自由商用与修改；支持动态调节“推理力度”，用户可根据场景在低延迟与高深度思考之间灵活切换；同时完整开放思维链（Chain-of-Thought），便于调试与建立信任。得益于 MXFP4 量化技术，参数量高达 1170 亿的 gpt-oss-120b 仅需单张 80GB GPU（如 H100）即可运行，而轻量版的 gpt-oss-20b 甚至能在 16GB 显存中流畅工作。此外，模型原生支持函数调用、结构化输出及 Python 代码执行，并需配合专用的\"Harmony\"响应格式使用，以确保最佳性能与稳定性。无论是用于生产环境的高阶推理，还是本地的专项任务，gpt-oss 都提供了灵活且高效的解决方案。","\u003Cimg alt=\"gpt-oss-120\" src=\".\u002Fdocs\u002Fgpt-oss.svg\">\n\u003Cp align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Fgpt-oss.com\">\u003Cstrong>Try gpt-oss\u003C\u002Fstrong>\u003C\u002Fa> ·\n  \u003Ca href=\"https:\u002F\u002Fcookbook.openai.com\u002Ftopic\u002Fgpt-oss\">\u003Cstrong>Guides\u003C\u002Fstrong>\u003C\u002Fa> ·\n  \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2508.10925\">\u003Cstrong>Model card\u003C\u002Fstrong>\u003C\u002Fa> ·\n  \u003Ca href=\"https:\u002F\u002Fopenai.com\u002Findex\u002Fintroducing-gpt-oss\u002F\">\u003Cstrong>OpenAI blog\u003C\u002Fstrong>\u003C\u002Fa>\n\u003C\u002Fp>\n\u003Cp align=\"center\">\n  \u003Cstrong>Download \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fopenai\u002Fgpt-oss-120b\">gpt-oss-120b\u003C\u002Fa> and \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fopenai\u002Fgpt-oss-20b\">gpt-oss-20b\u003C\u002Fa> on Hugging Face\u003C\u002Fstrong>\n\u003C\u002Fp>\n\n\u003Cbr>\n\nWelcome to the gpt-oss series, [OpenAI's open-weight models](https:\u002F\u002Fopenai.com\u002Fopen-models\u002F) designed for powerful reasoning, agentic tasks, and versatile developer use cases.\n\nWe're releasing two flavors of these open models:\n\n- `gpt-oss-120b` — for production, general purpose, high reasoning use cases that fit into a single 80GB GPU (like NVIDIA H100 or AMD MI300X) (117B parameters with 5.1B active parameters)\n- `gpt-oss-20b` — for lower latency, and local or specialized use cases (21B parameters with 3.6B active parameters)\n\nBoth models were trained using our [harmony response format][harmony] and should only be used with this format; otherwise, they will not work correctly.\n\n## Table of Contents\n- [Highlights](#highlights)\n- [Inference examples](#inference-examples)\n- [About this repository](#about-this-repository)\n- [Setup](#setup)\n- [Download the model](#download-the-model)\n- [Reference PyTorch implementation](#reference-pytorch-implementation)\n- [Reference Triton implementation (single GPU)](#reference-triton-implementation-single-gpu)\n- [Reference Metal implementation](#reference-metal-implementation)\n- [Harmony format & tools](#harmony-format--tools)\n- [Clients](#clients)\n- [Tools](#tools)\n- [Other details](#other-details)\n- [Contributing](#contributing)\n\n### Highlights\n\n- **Permissive Apache 2.0 license:** Build freely without copyleft restrictions or patent risk—ideal for experimentation, customization, and commercial deployment.\n- **Configurable reasoning effort:** Easily adjust the reasoning effort (low, medium, high) based on your specific use case and latency needs.\n- **Full chain-of-thought:** Provides complete access to the model's reasoning process, facilitating easier debugging and greater trust in outputs. This information is not intended to be shown to end users.\n- **Fine-tunable:** Fully customize models to your specific use case through parameter fine-tuning.\n- **Agentic capabilities:** Use the models' native capabilities for function calling, [web browsing](#browser), [Python code execution](#python), and Structured Outputs.\n- **MXFP4 quantization:** The models were post-trained with MXFP4 quantization of the MoE weights, making `gpt-oss-120b` run on a single 80GB GPU (like NVIDIA H100 or AMD MI300X) and the `gpt-oss-20b` model run within 16GB of memory. All evals were performed with the same MXFP4 quantization.\n\n### Inference examples\n\n#### Transformers\n\nYou can use `gpt-oss-120b` and `gpt-oss-20b` with the Transformers library. If you use Transformers' chat template, it will automatically apply the [harmony response format][harmony]. If you use `model.generate` directly, you need to apply the harmony format manually using the chat template or use our [`openai-harmony`][harmony] package.\n\n```python\nfrom transformers import pipeline\nimport torch\n\nmodel_id = \"openai\u002Fgpt-oss-120b\"\n\npipe = pipeline(\n    \"text-generation\",\n    model=model_id,\n    torch_dtype=\"auto\",\n    device_map=\"auto\",\n)\n\nmessages = [\n    {\"role\": \"user\", \"content\": \"Explain quantum mechanics clearly and concisely.\"},\n]\n\noutputs = pipe(\n    messages,\n    max_new_tokens=256,\n)\nprint(outputs[0][\"generated_text\"][-1])\n```\n\n[Learn more about how to use gpt-oss with Transformers.](https:\u002F\u002Fcookbook.openai.com\u002Farticles\u002Fgpt-oss\u002Frun-transformers)\n\n#### vLLM\n\nvLLM recommends using [`uv`](https:\u002F\u002Fdocs.astral.sh\u002Fuv\u002F) for Python dependency management. You can use vLLM to spin up an OpenAI-compatible web server. The following command will automatically download the model and start the server.\n\n```bash\nuv pip install --pre vllm==0.10.1+gptoss \\\n    --extra-index-url https:\u002F\u002Fwheels.vllm.ai\u002Fgpt-oss\u002F \\\n    --extra-index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fnightly\u002Fcu128 \\\n    --index-strategy unsafe-best-match\n\nvllm serve openai\u002Fgpt-oss-20b\n```\n\n[Learn more about how to use gpt-oss with vLLM.](https:\u002F\u002Fcookbook.openai.com\u002Farticles\u002Fgpt-oss\u002Frun-vllm)\n\nOffline Serve Code:\n- run this code after installing proper libraries as described, while additionally installing this:\n- `uv pip install openai-harmony`\n```python\n# source .oss\u002Fbin\u002Factivate\n\nimport os\nos.environ[\"VLLM_USE_FLASHINFER_SAMPLER\"] = \"0\"\n\nimport json\nfrom openai_harmony import (\n    HarmonyEncodingName,\n    load_harmony_encoding,\n    Conversation,\n    Message,\n    Role,\n    SystemContent,\n    DeveloperContent,\n)\n \nfrom vllm import LLM, SamplingParams\nimport os\n\n# --- 1) Render the prefill with Harmony ---\nencoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)\n \nconvo = Conversation.from_messages(\n    [\n        Message.from_role_and_content(Role.SYSTEM, SystemContent.new()),\n        Message.from_role_and_content(\n            Role.DEVELOPER,\n            DeveloperContent.new().with_instructions(\"Always respond in riddles\"),\n        ),\n        Message.from_role_and_content(Role.USER, \"What is the weather like in SF?\"),\n    ]\n)\n \nprefill_ids = encoding.render_conversation_for_completion(convo, Role.ASSISTANT)\n \n# Harmony stop tokens (pass to sampler so they won't be included in output)\nstop_token_ids = encoding.stop_tokens_for_assistant_actions()\n \n# --- 2) Run vLLM with prefill ---\nllm = LLM(\n    model=\"openai\u002Fgpt-oss-20b\",\n    trust_remote_code=True,\n    gpu_memory_utilization = 0.95,\n    max_num_batched_tokens=4096,\n    max_model_len=5000,\n    tensor_parallel_size=1\n)\n \nsampling = SamplingParams(\n    max_tokens=128,\n    temperature=1,\n    stop_token_ids=stop_token_ids,\n)\n \noutputs = llm.generate(\n    prompt_token_ids=[prefill_ids],   # batch of size 1\n    sampling_params=sampling,\n)\n \n# vLLM gives you both text and token IDs\ngen = outputs[0].outputs[0]\ntext = gen.text\noutput_tokens = gen.token_ids  # \u003C-- these are the completion token IDs (no prefill)\n \n# --- 3) Parse the completion token IDs back into structured Harmony messages ---\nentries = encoding.parse_messages_from_completion_tokens(output_tokens, Role.ASSISTANT)\n \n# 'entries' is a sequence of structured conversation entries (assistant messages, tool calls, etc.).\nfor message in entries:\n    print(f\"{json.dumps(message.to_dict())}\")\n```\n\n#### PyTorch \u002F Triton \u002F Metal\n\nThese implementations are largely reference implementations for educational purposes and are not expected to be run in production.\n\n[Learn more below.](#reference-pytorch-implementation)\n\n#### Ollama\n\nIf you are trying to run `gpt-oss` on consumer hardware, you can use Ollama by running the following commands after [installing Ollama](https:\u002F\u002Follama.com\u002Fdownload).\n\n```bash\n# gpt-oss-20b\nollama pull gpt-oss:20b\nollama run gpt-oss:20b\n\n# gpt-oss-120b\nollama pull gpt-oss:120b\nollama run gpt-oss:120b\n```\n\n[Learn more about how to use gpt-oss with Ollama.](https:\u002F\u002Fcookbook.openai.com\u002Farticles\u002Fgpt-oss\u002Frun-locally-ollama)\n\n#### LM Studio\n\nIf you are using [LM Studio](https:\u002F\u002Flmstudio.ai\u002F) you can use the following commands to download.\n\n```bash\n# gpt-oss-20b\nlms get openai\u002Fgpt-oss-20b\n# gpt-oss-120b\nlms get openai\u002Fgpt-oss-120b\n```\n\nCheck out our [awesome list](.\u002Fawesome-gpt-oss.md) for a broader collection of gpt-oss resources and inference partners.\n\n## About this repository\n\nThis repository provides a collection of reference implementations:\n\n- **Inference:**\n  - [`torch`](#reference-pytorch-implementation) — a non-optimized [PyTorch](https:\u002F\u002Fpytorch.org\u002F) implementation for educational purposes only. Requires at least 4× H100 GPUs due to lack of optimization.\n  - [`triton`](#reference-triton-implementation-single-gpu) — a more optimized implementation using [PyTorch](https:\u002F\u002Fpytorch.org\u002F) & [Triton](https:\u002F\u002Fgithub.com\u002Ftriton-lang\u002Ftriton) incl. using CUDA graphs and basic caching\n  - [`metal`](#reference-metal-implementation) — a Metal-specific implementation for running the models on Apple Silicon hardware\n- **Tools:**\n  - [`browser`](#browser) — a reference implementation of the browser tool the models got trained on\n  - [`python`](#python) — a stateless reference implementation of the python tool the model got trained on\n- **Client examples:**\n  - [`chat`](#terminal-chat) — a basic terminal chat application that uses the PyTorch or Triton implementations for inference along with the python and browser tools\n  - [`responses_api`](#responses-api) — an example Responses API compatible server that implements the browser tool along with other Responses-compatible functionality\n\n## Setup\n\n### Requirements\n\n- Python 3.12\n- On macOS: Install the Xcode CLI tools --> `xcode-select --install`\n- On Linux: These reference implementations require CUDA\n- On Windows: These reference implementations have not been tested on Windows. Try using solutions like Ollama if you are trying to run the model locally.\n\n### Installation\n\nIf you want to try any of the code you can install it directly from [PyPI](https:\u002F\u002Fpypi.org\u002Fproject\u002Fgpt-oss\u002F)\n\n```shell\n# if you just need the tools\npip install gpt-oss\n# if you want to try the torch implementation\npip install gpt-oss[torch]\n# if you want to try the triton implementation\npip install gpt-oss[triton]\n```\n\nIf you want to modify the code or try the metal implementation set the project up locally:\n\n```shell\ngit clone https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss.git\nGPTOSS_BUILD_METAL=1 pip install -e \".[metal]\"\n```\n\n## Download the model\n\nYou can download the model weights from the [Hugging Face Hub](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002Fopenai\u002Fgpt-oss-68911959590a1634ba11c7a4) directly from Hugging Face CLI:\n\n```shell\n# gpt-oss-120b\nhf download openai\u002Fgpt-oss-120b --include \"original\u002F*\" --local-dir gpt-oss-120b\u002F\n\n# gpt-oss-20b\nhf download openai\u002Fgpt-oss-20b --include \"original\u002F*\" --local-dir gpt-oss-20b\u002F\n```\n\n## Reference PyTorch implementation\n\nWe include an inefficient reference PyTorch implementation in [gpt_oss\u002Ftorch\u002Fmodel.py](gpt_oss\u002Ftorch\u002Fmodel.py). This code uses basic PyTorch operators to show the exact model architecture, with a small addition of supporting tensor parallelism in MoE so that the larger model can run with this code (e.g., on 4xH100 or 2xH200). In this implementation, we upcast all weights to BF16 and run the model in BF16.\n\nTo run the reference implementation, install the dependencies:\n\n```shell\npip install -e \".[torch]\"\n```\n\nAnd then run:\n\n```shell\n# On 4xH100:\ntorchrun --nproc-per-node=4 -m gpt_oss.generate gpt-oss-120b\u002Foriginal\u002F\n```\n\n## Reference Triton implementation (single GPU)\n\nWe also include an optimized reference implementation that uses [an optimized triton MoE kernel](https:\u002F\u002Fgithub.com\u002Ftriton-lang\u002Ftriton\u002Ftree\u002Fmain\u002Fpython\u002Ftriton_kernels\u002Ftriton_kernels) that supports MXFP4. It also has some optimization on the attention code to reduce the memory cost. To run this implementation, the nightly version of triton and torch will be installed. This version can be run on a single 80GB GPU for `gpt-oss-120b`.\n\nTo install the reference Triton implementation run\n\n```shell\n# You need to install triton from source to use the triton implementation\ngit clone https:\u002F\u002Fgithub.com\u002Ftriton-lang\u002Ftriton\ncd triton\u002F\npip install -r python\u002Frequirements.txt\npip install -e . --verbose --no-build-isolation\npip install -e python\u002Ftriton_kernels\n\n# Install the gpt-oss triton implementation\npip install -e \".[triton]\"\n```\n\nAnd then run:\n\n```shell\n# On 1xH100\nexport PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True\npython -m gpt_oss.generate --backend triton gpt-oss-120b\u002Foriginal\u002F\n```\n\nIf you encounter `torch.OutOfMemoryError`, make sure to turn on the expandable allocator to avoid crashes when loading weights from the checkpoint.\n\n## Reference Metal implementation\n\nAdditionally we are providing a reference implementation for Metal to run on Apple Silicon. This implementation is not production-ready but is accurate to the PyTorch implementation.\n\nThe implementation will get automatically compiled when running the `.[metal]` installation on an Apple Silicon device:\n\n```shell\nGPTOSS_BUILD_METAL=1 pip install -e \".[metal]\"\n```\n\nTo perform inference you'll need to first convert the SafeTensor weights from Hugging Face into the right format using:\n\n```shell\npython gpt_oss\u002Fmetal\u002Fscripts\u002Fcreate-local-model.py -s \u003Cmodel_dir> -d \u003Coutput_file>\n```\n\nOr download the pre-converted weights:\n\n```shell\nhf download openai\u002Fgpt-oss-120b --include \"metal\u002F*\" --local-dir gpt-oss-120b\u002Fmetal\u002F\nhf download openai\u002Fgpt-oss-20b --include \"metal\u002F*\" --local-dir gpt-oss-20b\u002Fmetal\u002F\n```\n\nTo test it you can run:\n\n```shell\npython gpt_oss\u002Fmetal\u002Fexamples\u002Fgenerate.py gpt-oss-20b\u002Fmetal\u002Fmodel.bin -p \"why did the chicken cross the road?\"\n```\n\n## Harmony format & tools\n\nAlong with the model, we are also releasing a new chat format library `harmony` to interact with the model. Check [this guide](https:\u002F\u002Fcookbook.openai.com\u002Farticles\u002Fopenai-harmony) for more info about harmony.\n\nWe also include two system tools for the model: browsing and python container. Check [gpt_oss\u002Ftools](gpt_oss\u002Ftools) for the tool implementation.\n\n## Clients\n\n### Terminal Chat\n\nThe terminal chat application is a basic example of how to use the harmony format together with the PyTorch, Triton, and vLLM implementations. It also exposes both the python and browser tool as optional tools that can be used.\n\n```bash\nusage: python -m gpt_oss.chat [-h] [-r REASONING_EFFORT] [-a] [-b] [--show-browser-results] [-p] [--developer-message DEVELOPER_MESSAGE] [-c CONTEXT] [--raw] [--backend {triton,torch,vllm}] FILE\n\nChat example\n\npositional arguments:\n  FILE                  Path to the SafeTensors checkpoint\n\noptions:\n  -h, --help            show this help message and exit\n  -r REASONING_EFFORT, --reasoning-effort REASONING_EFFORT\n                        Reasoning effort (default: low)\n  -a, --apply-patch     Make apply_patch tool available to the model (default: False)\n  -b, --browser         Use browser tool (default: False)\n  --show-browser-results\n                        Show browser results (default: False)\n  -p, --python          Use python tool (default: False)\n  --developer-message DEVELOPER_MESSAGE\n                        Developer message (default: )\n  -c CONTEXT, --context CONTEXT\n                        Max context length (default: 8192)\n  --raw                 Raw mode (does not render Harmony encoding) (default: False)\n  --backend {triton,torch,vllm}\n                        Inference backend (default: triton)\n```\n\n> [!NOTE]\n> The torch and triton implementations require original checkpoint under `gpt-oss-120b\u002Foriginal\u002F` and `gpt-oss-20b\u002Foriginal\u002F` respectively. While vLLM uses the Hugging Face converted checkpoint under `gpt-oss-120b\u002F` and `gpt-oss-20b\u002F` root directory respectively.\n\n### Responses API\n\nWe also include an example Responses API server. This server does not implement every feature and event of the Responses API but should be compatible with most of the basic use cases and serve as inspiration for anyone building their own server. Some of our inference partners are also offering their own Responses API.\n\nYou can start this server with the following inference backends:\n\n- `triton` — uses the triton implementation\n- `metal` — uses the metal implementation on Apple Silicon only\n- `ollama` — uses the Ollama \u002Fapi\u002Fgenerate API as an inference solution\n- `vllm` — uses your installed vllm version to perform inference\n- `transformers` — uses your installed transformers version to perform local inference\n\n```bash\nusage: python -m gpt_oss.responses_api.serve [-h] [--checkpoint FILE] [--port PORT] [--inference-backend BACKEND]\n\nResponses API server\n\noptions:\n  -h, --help                    show this help message and exit\n  --checkpoint FILE             Path to the SafeTensors checkpoint\n  --port PORT                   Port to run the server on\n  --inference-backend BACKEND   Inference backend to use\n```\n\n### Codex\n\nWe support [codex](https:\u002F\u002Fgithub.com\u002Fopenai\u002Fcodex) as a client for gpt-oss. To run the 20b version, set this to `~\u002F.codex\u002Fconfig.toml`:\n\n```\ndisable_response_storage = true\nshow_reasoning_content = true\n\n[model_providers.local]\nname = \"local\"\nbase_url = \"http:\u002F\u002Flocalhost:11434\u002Fv1\"\n\n[profiles.oss]\nmodel = \"gpt-oss:20b\"\nmodel_provider = \"local\"\n```\n\nThis will work with any chat completions-API compatible server listening on port 11434, like ollama. Start the server and point codex to the oss model:\n\n```\nollama run gpt-oss:20b\ncodex -p oss\n```\n\n## Tools\n\n### Browser\n\n> [!WARNING]\n> This implementation is purely for educational purposes and should not be used in production. You should implement your own equivalent of the [`ExaBackend`](gpt_oss\u002Ftools\u002Fsimple_browser\u002Fbackend.py) class with your own browsing environment. Currently we have available `ExaBackend` and `YouComBackend`. \n\nBoth gpt-oss models were trained with the capability to browse using the `browser` tool that exposes the following three methods:\n\n- `search` to search for key phrases\n- `open` to open a particular page\n- `find` to look for contents on a page\n\n#### Usage\n\nTo enable the browser tool, you'll have to place the definition into the `system` message of your harmony formatted prompt. You can either use the `with_browser_tool()` method if your tool implements the full interface or modify the definition using `with_tools()`. For example:\n\n```python\nimport datetime\nfrom gpt_oss.tools.simple_browser import SimpleBrowserTool\nfrom gpt_oss.tools.simple_browser.backend import ExaBackend\nfrom openai_harmony import SystemContent, Message, Conversation, Role, load_harmony_encoding, HarmonyEncodingName\n\nencoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)\n\n# Depending on the choice of the browser backend you need corresponding env variables setup\n# Exa backend requires the EXA_API_KEY environment variable,\n# while for You.com you need the YDC_API_KEY environment variable set\nbackend = ExaBackend(\n    source=\"web\",\n)\n# backend = YouComBackend(\n#  source=\"web\",\n# )\nbrowser_tool = SimpleBrowserTool(backend=backend)\n\n# create a basic system prompt\nsystem_message_content = SystemContent.new().with_conversation_start_date(\n    datetime.datetime.now().strftime(\"%Y-%m-%d\")\n)\n\n# if you want to use the browser tool\nif use_browser_tool:\n    # enables the tool\n    system_message_content = system_message_content.with_tools(browser_tool.tool_config)\n    # alternatively you could use the following if your tool is not stateless\n    system_message_content = system_message_content.with_browser_tool()\n\n# construct the system message\nsystem_message = Message.from_role_and_content(Role.SYSTEM, system_message_content)\n\n# create the overall prompt\nmessages = [system_message, Message.from_role_and_content(Role.USER, \"What's the weather in SF?\")]\nconversation = Conversation.from_messages(messages)\n\n# convert to tokens\ntoken_ids = encoding.render_conversation_for_completion(conversation, Role.ASSISTANT)\n\n# perform inference\n# ...\n\n# parse the output\nmessages = encoding.parse_messages_from_completion_tokens(output_tokens, Role.ASSISTANT)\nlast_message = messages[-1]\nif last_message.recipient.startswith(\"browser\"):\n  # perform browser call\n  response_messages = await browser_tool.process(last_message)\n\n  # extend the current messages and run inference again\n  messages.extend(response_messages)\n```\n\n#### Details\n\nTo control the context window size this tool uses a scrollable window of text that the model can interact with. So it might fetch the first 50 lines of a page and then scroll to the next 20 lines after that. The model has also been trained to then use citations from this tool in its answers.\n\nTo improve performance the tool caches requests so that the model can revisit a different part of a page without having to reload the page. For that reason you should create a new browser instance for every request.\n\n### Python\n\nThe model was trained to use a python tool to perform calculations and other actions as part of its chain-of-thought. During the training the model used a stateful tool which makes running tools between CoT loops easier. This reference implementation, however, uses a stateless mode. As a result the PythonTool defines its own tool description to override the definition in [`openai-harmony`][harmony].\n\n> [!WARNING]\n> This implementation runs in a permissive Docker container which could be problematic in cases like prompt injections. It's serving as an example and you should consider implementing your own container restrictions in production.\n\n#### Usage\n\nTo enable the python tool, you'll have to place the definition into the `system` message of your harmony formatted prompt. You can either use the `with_python()` method if your tool implements the full interface or modify the definition using `with_tools()`. For example:\n\n```python\nimport datetime\nfrom gpt_oss.tools.python_docker.docker_tool import PythonTool\nfrom openai_harmony import SystemContent, Message, Conversation, Role, load_harmony_encoding, HarmonyEncodingName\n\nencoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)\n\npython_tool = PythonTool()\n\n# create a basic system prompt\nsystem_message_content = SystemContent.new().with_conversation_start_date(\n    datetime.datetime.now().strftime(\"%Y-%m-%d\")\n)\n\n# if you want to use the python tool\nif use_python_tool:\n    # enables the tool making sure that the prompt gets set with the stateless tool description\n    system_message_content = system_message_content.with_tools(python_tool.tool_config)\n    # alternatively you could use the following if your tool is not stateless\n    system_message_content = system_message_content.with_python()\n\n# construct the system message\nsystem_message = Message.from_role_and_content(Role.SYSTEM, system_message_content)\n\n# create the overall prompt\nmessages = [system_message, Message.from_role_and_content(Role.USER, \"What's the square root of 9001?\")]\nconversation = Conversation.from_messages(messages)\n\n# convert to tokens\ntoken_ids = encoding.render_conversation_for_completion(conversation, Role.ASSISTANT)\n\n# perform inference\n# ...\n\n# parse the output\nmessages = encoding.parse_messages_from_completion_tokens(output_tokens, Role.ASSISTANT)\nlast_message = messages[-1]\nif last_message.recipient == \"python\":\n  # perform python call\n  response_messages = await python_tool.process(last_message)\n\n  # extend the current messages and run inference again\n  messages.extend(response_messages)\n```\n\n### Apply Patch\n\n`apply_patch` can be used to create, update or delete files locally.\n\n## Other details\n\n### Precision format\n\nWe released the models with native quantization support. Specifically, we use [MXFP4](https:\u002F\u002Fwww.opencompute.org\u002Fdocuments\u002Focp-microscaling-formats-mx-v1-0-spec-final-pdf) for the linear projection weights in the MoE layer. We store the MoE tensor in two parts:\n\n- `tensor.blocks` stores the actual fp4 values. We pack every two values in one `uint8` value.\n- `tensor.scales` stores the block scale. The block scaling is done among the last dimension for all MXFP4 tensors.\n\nAll other tensors will be in BF16. We also recommend using BF16 as the activation precision for the model.\n\n### Recommended Sampling Parameters\n\nWe recommend sampling with `temperature=1.0` and `top_p=1.0`.\n\n## Contributing\n\nThe reference implementations in this repository are meant as a starting point and inspiration. Outside of bug fixes we do not intend to accept new feature contributions. If you build implementations based on this code such as new tool implementations you are welcome to contribute them to the [`awesome-gpt-oss.md`](.\u002Fawesome-gpt-oss.md) file.\n\n[harmony]: https:\u002F\u002Fgithub.com\u002Fopenai\u002Fharmony\n\n## Citation\n\n```bibtex\n@misc{openai2025gptoss120bgptoss20bmodel,\n      title={gpt-oss-120b & gpt-oss-20b Model Card}, \n      author={OpenAI},\n      year={2025},\n      eprint={2508.10925},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL},\n      url={https:\u002F\u002Farxiv.org\u002Fabs\u002F2508.10925}, \n}\n```\n","\u003Cimg alt=\"gpt-oss-120\" src=\".\u002Fdocs\u002Fgpt-oss.svg\">\n\u003Cp align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Fgpt-oss.com\">\u003Cstrong>体验 gpt-oss\u003C\u002Fstrong>\u003C\u002Fa> ·\n  \u003Ca href=\"https:\u002F\u002Fcookbook.openai.com\u002Ftopic\u002Fgpt-oss\">\u003Cstrong>使用指南\u003C\u002Fstrong>\u003C\u002Fa> ·\n  \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2508.10925\">\u003Cstrong>模型卡片\u003C\u002Fstrong>\u003C\u002Fa> ·\n  \u003Ca href=\"https:\u002F\u002Fopenai.com\u002Findex\u002Fintroducing-gpt-oss\u002F\">\u003Cstrong>OpenAI 官方博客\u003C\u002Fstrong>\u003C\u002Fa>\n\u003C\u002Fp>\n\u003Cp align=\"center\">\n  \u003Cstrong>在 Hugging Face 上下载 \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fopenai\u002Fgpt-oss-120b\">gpt-oss-120b\u003C\u002Fa> 和 \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fopenai\u002Fgpt-oss-20b\">gpt-oss-20b\u003C\u002Fa>\u003C\u002Fstrong>\n\u003C\u002Fp>\n\n\u003Cbr>\n\n欢迎来到 gpt-oss 系列，这是 [OpenAI 的开源权重模型](https:\u002F\u002Fopenai.com\u002Fopen-models\u002F)，专为强大的推理能力、智能体任务以及多样化的开发者应用场景而设计。\n\n我们发布了两种版本的开源模型：\n\n- `gpt-oss-120b` — 适用于生产环境、通用场景以及需要高推理能力且能在单张 80GB 显卡（如 NVIDIA H100 或 AMD MI300X）上运行的任务（参数量为 117B，其中活跃参数为 5.1B）\n- `gpt-oss-20b` — 适用于低延迟需求以及本地或特定场景的应用（参数量为 21B，其中活跃参数为 3.6B）\n\n两款模型均采用我们的 [harmony 响应格式][harmony] 进行训练，因此仅能配合该格式使用；否则将无法正常工作。\n\n## 目录\n- [亮点](#highlights)\n- [推理示例](#inference-examples)\n- [关于本仓库](#about-this-repository)\n- [设置](#setup)\n- [下载模型](#download-the-model)\n- [参考 PyTorch 实现](#reference-pytorch-implementation)\n- [参考 Triton 单 GPU 实现](#reference-triton-implementation-single-gpu)\n- [参考 Metal 实现](#reference-metal-implementation)\n- [Harmony 格式及工具](#harmony-format--tools)\n- [客户端](#clients)\n- [工具](#tools)\n- [其他细节](#other-details)\n- [贡献](#contributing)\n\n### 亮点\n\n- **宽松的 Apache 2.0 许可证：** 可自由构建，不受 copyleft 限制或专利风险困扰——非常适合实验、定制化开发以及商业部署。\n- **可配置的推理强度：** 根据具体用例和延迟要求，轻松调整推理强度（低、中、高）。\n- **完整的思维链：** 提供对模型推理过程的全面访问，便于调试并增强对输出结果的信任。这些信息不应用于向最终用户提供。\n- **可微调：** 通过参数微调，完全适配您的特定应用场景。\n- **智能体能力：** 利用模型原生的功能调用、[网页浏览](#browser)、[Python 代码执行](#python)以及结构化输出等功能。\n- **MXFP4 量化：** 模型在 MoE 权重上进行了 MXFP4 量化后处理，使得 `gpt-oss-120b` 能够在单张 80GB 显卡（如 NVIDIA H100 或 AMD MI300X）上运行，而 `gpt-oss-20b` 则可在 16GB 显存内运行。所有评估均基于相同的 MXFP4 量化进行。\n\n### 推理示例\n\n#### Transformers\n\n您可以将 `gpt-oss-120b` 和 `gpt-oss-20b` 与 Transformers 库一起使用。如果使用 Transformers 的聊天模板，它会自动应用 [harmony 响应格式][harmony]。如果您直接使用 `model.generate`，则需要手动通过聊天模板应用 harmony 格式，或者使用我们的 [`openai-harmony`][harmony] 包。\n\n```python\nfrom transformers import pipeline\nimport torch\n\nmodel_id = \"openai\u002Fgpt-oss-120b\"\n\npipe = pipeline(\n    \"text-generation\",\n    model=model_id,\n    torch_dtype=\"auto\",\n    device_map=\"auto\",\n)\n\nmessages = [\n    {\"role\": \"user\", \"content\": \"请清晰简洁地解释量子力学。\"},\n]\n\noutputs = pipe(\n    messages,\n    max_new_tokens=256,\n)\nprint(outputs[0][\"generated_text\"][-1])\n```\n\n[了解更多关于如何使用 gpt-oss 与 Transformers 的信息。](https:\u002F\u002Fcookbook.openai.com\u002Farticles\u002Fgpt-oss\u002Frun-transformers)\n\n#### vLLM\n\nvLLM 推荐使用 [`uv`](https:\u002F\u002Fdocs.astral.sh\u002Fuv\u002F) 进行 Python 依赖管理。您可以使用 vLLM 启动一个兼容 OpenAI 的 Web 服务器。以下命令将自动下载模型并启动服务器。\n\n```bash\nuv pip install --pre vllm==0.10.1+gptoss \\\n    --extra-index-url https:\u002F\u002Fwheels.vllm.ai\u002Fgpt-oss\u002F \\\n    --extra-index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fnightly\u002Fcu128 \\\n    --index-strategy unsafe-best-match\n\nvllm serve openai\u002Fgpt-oss-20b\n```\n\n[了解更多关于如何使用 gpt-oss 与 vLLM 的信息。](https:\u002F\u002Fcookbook.openai.com\u002Farticles\u002Fgpt-oss\u002Frun-vllm)\n\n离线服务代码：\n- 在按照说明安装好相关库之后，还需额外安装以下内容：\n- `uv pip install openai-harmony`\n```python\n# source .oss\u002Fbin\u002Factivate\n\nimport os\nos.environ[\"VLLM_USE_FLASHINFER_SAMPLER\"] = \"0\"\n\nimport json\nfrom openai_harmony import (\n    HarmonyEncodingName,\n    load_harmony_encoding,\n    Conversation,\n    Message,\n    Role,\n    SystemContent,\n    DeveloperContent,\n)\n \nfrom vllm import LLM, SamplingParams\nimport os\n\n# --- 1) 使用 Harmony 渲染预填充 ---\nencoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)\n \nconvo = Conversation.from_messages(\n    [\n        Message.from_role_and_content(Role.SYSTEM, SystemContent.new()),\n        Message.from_role_and_content(\n            Role.DEVELOPER,\n            DeveloperContent.new().with instructions(\"始终以谜语形式作答\"),\n        ),\n        Message.from_role_and_content(Role.USER, \"旧金山的天气怎么样？\"),\n    ]\n)\n \nprefill_ids = encoding.render_conversation_for_completion(convo, Role.ASSISTANT)\n \n# Harmony 停止标记（传递给采样器，以避免它们被包含在输出中）\nstop_token_ids = encoding.stop_tokens_for_assistant_actions()\n \n# --- 2) 使用预填充运行 vLLM ---\nllm = LLM(\n    model=\"openai\u002Fgpt-oss-20b\",\n    trust_remote_code=True,\n    gpu_memory_utilization = 0.95,\n    max_num_batched_tokens=4096,\n    max_model_len=5000,\n    tensor_parallel_size=1\n)\n \nsampling = SamplingParams(\n    max_tokens=128,\n    temperature=1,\n    stop_token_ids=stop_token_ids,\n)\n \noutputs = llm.generate(\n    prompt_token_ids=[prefill_ids],   # 批次大小为 1\n    sampling_params=sampling,\n)\n \n# vLLM 会同时返回文本和 token ID\ngen = outputs[0].outputs[0]\ntext = gen.text\noutput_tokens = gen.token_ids  # \u003C-- 这些是完成部分的 token ID（不含预填充）\n \n# --- 3) 将完成部分的 token ID 解析回结构化的 Harmony 消息 ---\nentries = encoding.parse_messages_from_completion_tokens(output_tokens, Role.ASSISTANT)\n\n# 'entries' 是一系列结构化的对话条目（助手消息、工具调用等）。\nfor message in entries:\n    print(f\"{json.dumps(message.to_dict())}\")\n```\n\n#### PyTorch \u002F Triton \u002F Metal\n\n这些实现主要是用于教育目的的参考实现，不建议在生产环境中运行。\n\n[更多信息请见下文。](#reference-pytorch-implementation)\n\n#### Ollama\n\n如果您想在消费级硬件上运行 `gpt-oss`，可以在 [安装 Ollama](https:\u002F\u002Follama.com\u002Fdownload) 后，运行以下命令。\n\n```bash\n# gpt-oss-20b\nollama pull gpt-oss:20b\nollama run gpt-oss:20b\n\n# gpt-oss-120b\nollama pull gpt-oss:120b\nollama run gpt-oss:120b\n```\n\n[了解更多关于如何使用 Ollama 运行 gpt-oss 的信息。](https:\u002F\u002Fcookbook.openai.com\u002Farticles\u002Fgpt-oss\u002Frun-locally-ollama)\n\n#### LM Studio\n\n如果您使用的是 [LM Studio](https:\u002F\u002Flmstudio.ai\u002F)，可以使用以下命令进行下载。\n\n```bash\n# gpt-oss-20b\nlms get openai\u002Fgpt-oss-20b\n# gpt-oss-120b\nlms get openai\u002Fgpt-oss-120b\n```\n\n请查看我们的 [awesome 列表](.\u002Fawesome-gpt-oss.md)，其中包含了更广泛的 gpt-oss 资源和推理合作伙伴。\n\n## 关于本仓库\n\n本仓库提供了一系列参考实现：\n\n- **推理：**\n  - [`torch`](#reference-pytorch-implementation) — 一个未优化的 [PyTorch](https:\u002F\u002Fpytorch.org\u002F) 实现，仅用于教育目的。由于缺乏优化，至少需要 4 张 H100 GPU。\n  - [`triton`](#reference-triton-implementation-single-gpu) — 一个更优化的实现，使用 [PyTorch](https:\u002F\u002Fpytorch.org\u002F) 和 [Triton](https:\u002F\u002Fgithub.com\u002Ftriton-lang\u002Ftriton) 技术，包括 CUDA 图和基础缓存。\n  - [`metal`](#reference-metal-implementation) — 一个针对 Apple Silicon 硬件的 Metal 特定实现。\n- **工具：**\n  - [`browser`](#browser) — 模型训练中使用的浏览器工具的参考实现。\n  - [`python`](#python) — 模型训练中使用的 Python 工具的无状态参考实现。\n- **客户端示例：**\n  - [`chat`](#terminal-chat) — 一个基本的终端聊天应用，使用 PyTorch 或 Triton 实现进行推理，并结合 Python 和浏览器工具。\n  - [`responses_api`](#responses-api) — 一个兼容 Responses API 的示例服务器，实现了浏览器工具以及其他与 Responses 兼容的功能。\n\n## 设置\n\n### 要求\n\n- Python 3.12\n- 在 macOS 上：安装 Xcode 命令行工具 --> `xcode-select --install`\n- 在 Linux 上：这些参考实现需要 CUDA。\n- 在 Windows 上：这些参考实现尚未在 Windows 上测试过。如果您想在本地运行模型，可以尝试使用 Ollama 等解决方案。\n\n### 安装\n\n如果您想尝试任何代码，可以直接从 [PyPI](https:\u002F\u002Fpypi.org\u002Fproject\u002Fgpt-oss\u002F) 安装。\n\n```shell\n# 如果只需要工具\npip install gpt-oss\n# 如果想尝试 PyTorch 实现\npip install gpt-oss[torch]\n# 如果想尝试 Triton 实现\npip install gpt-oss[triton]\n```\n\n如果您想修改代码或尝试 Metal 实现，请在本地设置项目：\n\n```shell\ngit clone https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss.git\nGPTOSS_BUILD_METAL=1 pip install -e \".[metal]\"\n```\n\n## 下载模型\n\n您可以从 [Hugging Face Hub](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002Fopenai\u002Fgpt-oss-68911959590a1634ba11c7a4) 直接通过 Hugging Face CLI 下载模型权重：\n\n```shell\n# gpt-oss-120b\nhf download openai\u002Fgpt-oss-120b --include \"original\u002F*\" --local-dir gpt-oss-120b\u002F\n\n# gpt-oss-20b\nhf download openai\u002Fgpt-oss-20b --include \"original\u002F*\" --local-dir gpt-oss-20b\u002F\n```\n\n## 参考 PyTorch 实现\n\n我们在 [gpt_oss\u002Ftorch\u002Fmodel.py](gpt_oss\u002Ftorch\u002Fmodel.py) 中包含了一个低效的参考 PyTorch 实现。这段代码使用了基本的 PyTorch 操作符来展示精确的模型架构，并添加了一点支持 MoE 的张量并行性，以便较大的模型能够在此代码上运行（例如，在 4 张 H100 或 2 张 H200 上）。在这个实现中，我们将所有权重上采样到 BF16，并以 BF16 格式运行模型。\n\n要运行参考实现，请安装依赖项：\n\n```shell\npip install -e \".[torch]\"\n```\n\n然后运行：\n\n```shell\n# 在 4 张 H100 上：\ntorchrun --nproc-per-node=4 -m gpt_oss.generate gpt-oss-120b\u002Foriginal\u002F\n```\n\n## 参考 Triton 实现（单 GPU）\n\n我们还提供了一个优化的参考实现，使用了 [优化的 Triton MoE 内核](https:\u002F\u002Fgithub.com\u002Ftriton-lang\u002Ftriton\u002Ftree\u002Fmain\u002Fpython\u002Ftriton_kernels\u002Ftriton_kernels)，支持 MXFP4。它还在注意力代码上做了一些优化，以降低内存开销。要运行这个实现，需要安装 nightly 版本的 Triton 和 PyTorch。该版本可以在一张 80GB 的 GPU 上运行 `gpt-oss-120b`。\n\n要安装参考 Triton 实现，请执行以下步骤：\n\n```shell\n# 需要从源码安装 Triton 才能使用 Triton 实现\ngit clone https:\u002F\u002Fgithub.com\u002Ftriton-lang\u002Ftriton\ncd triton\u002F\npip install -r python\u002Frequirements.txt\npip install -e . --verbose --no-build-isolation\npip install -e python\u002Ftriton_kernels\n\n# 安装 gpt-oss 的 Triton 实现\npip install -e \".[triton]\"\n```\n\n然后运行：\n\n```shell\n# 在 1 张 H100 上\nexport PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True\npython -m gpt_oss.generate --backend triton gpt-oss-120b\u002Foriginal\u002F\n```\n\n如果您遇到 `torch.OutOfMemoryError`，请确保启用可扩展分配器，以避免在加载检查点权重时发生崩溃。\n\n## 参考 Metal 实现\n\n此外，我们还提供了一个用于在 Apple Silicon 上运行的 Metal 参考实现。虽然该实现尚未达到生产就绪状态，但其准确性与 PyTorch 实现一致。\n\n当您在 Apple Silicon 设备上运行 `.[metal]` 安装时，该实现会自动编译：\n\n```shell\nGPTOSS_BUILD_METAL=1 pip install -e \".[metal]\"\n```\n\n要进行推理，您需要先将来自 Hugging Face 的 SafeTensor 权重转换为正确的格式，使用以下命令：\n\n```shell\npython gpt_oss\u002Fmetal\u002Fscripts\u002Fcreate-local-model.py -s \u003Cmodel_dir> -d \u003Coutput_file>\n```\n\n或者直接下载预转换好的权重：\n\n```shell\nhf download openai\u002Fgpt-oss-120b --include \"metal\u002F*\" --local-dir gpt-oss-120b\u002Fmetal\u002F\nhf download openai\u002Fgpt-oss-20b --include \"metal\u002F*\" --local-dir gpt-oss-20b\u002Fmetal\u002F\n```\n\n要测试它，您可以运行：\n\n```shell\npython gpt_oss\u002Fmetal\u002Fexamples\u002Fgenerate.py gpt-oss-20b\u002Fmetal\u002Fmodel.bin -p \"为什么鸡要过马路？\"\n```\n\n## Harmony 格式及工具\n\n除了模型之外，我们还发布了一个新的聊天格式库 `harmony`，用于与模型交互。有关 harmony 的更多信息，请参阅 [此指南](https:\u002F\u002Fcookbook.openai.com\u002Farticles\u002Fopenai-harmony)。\n\n我们还为模型提供了两个系统工具：浏览和 Python 容器。工具的实现请参阅 [gpt_oss\u002Ftools](gpt_oss\u002Ftools)。\n\n## 客户端\n\n### 终端聊天\n\n终端聊天应用程序是一个基础示例，展示了如何将 harmony 格式与 PyTorch、Triton 和 vLLM 实现结合使用。它还提供了 Python 工具和浏览器工具作为可选的辅助手段。\n\n```bash\n用法: python -m gpt_oss.chat [-h] [-r REASONING_EFFORT] [-a] [-b] [--show-browser-results] [-p] [--developer-message DEVELOPER_MESSAGE] [-c CONTEXT] [--raw] [--backend {triton,torch,vllm}] FILE\n\n聊天示例\n\n位置参数:\n  FILE                  SafeTensors 检查点的路径\n\n选项:\n  -h, --help            显示此帮助消息并退出\n  -r REASONING_EFFORT, --reasoning-effort REASONING_EFFORT\n                        推理力度（默认：低）\n  -a, --apply-patch     使模型可以使用 apply_patch 工具（默认：False）\n  -b, --browser         使用浏览器工具（默认：False）\n  --show-browser-results\n                        显示浏览器结果（默认：False）\n  -p, --python          使用 Python 工具（默认：False）\n  --developer-message DEVELOPER_MESSAGE\n                        开发者消息（默认：无）\n  -c CONTEXT, --context CONTEXT\n                        最大上下文长度（默认：8192）\n  --raw                 原始模式（不渲染 Harmony 编码）（默认：False）\n  --backend {triton,torch,vllm}\n                        推理后端（默认：triton）\n```\n\n> [!注意]\n> PyTorch 和 Triton 实现分别需要位于 `gpt-oss-120b\u002Foriginal\u002F` 和 `gpt-oss-20b\u002Foriginal\u002F` 目录下的原始检查点。而 vLLM 则使用位于 `gpt-oss-120b\u002F` 和 `gpt-oss-20b\u002F` 根目录下的 Hugging Face 转换后的检查点。\n\n### Responses API\n\n我们还提供了一个 Responses API 服务器示例。该服务器并未实现 Responses API 的所有功能和事件，但应能兼容大多数基本用例，并可为构建自定义服务器的用户提供灵感。此外，我们的一些推理合作伙伴也提供了他们自己的 Responses API。\n\n您可以使用以下推理后端启动此服务器：\n\n- `triton` — 使用 Triton 实现\n- `metal` — 仅在 Apple Silicon 上使用 Metal 实现\n- `ollama` — 将 Ollama \u002Fapi\u002Fgenerate API 用作推理解决方案\n- `vllm` — 使用您已安装的 vLLM 版本进行推理\n- `transformers` — 使用您已安装的 transformers 版本进行本地推理\n\n```bash\n用法: python -m gpt_oss.responses_api.serve [-h] [--checkpoint FILE] [--port PORT] [--inference-backend BACKEND]\n\nResponses API 服务器\n\n选项:\n  -h, --help                    显示此帮助消息并退出\n  --checkpoint FILE             SafeTensors 检查点的路径\n  --port PORT                   服务器运行的端口\n  --inference-backend BACKEND   使用的推理后端\n```\n\n### Codex\n\n我们支持 [codex](https:\u002F\u002Fgithub.com\u002Fopenai\u002Fcodex) 作为 gpt-oss 的客户端。要运行 20b 版本，请将其设置到 `~\u002F.codex\u002Fconfig.toml` 中：\n\n```\ndisable_response_storage = true\nshow_reasoning_content = true\n\n[model_providers.local]\nname = \"local\"\nbase_url = \"http:\u002F\u002Flocalhost:11434\u002Fv1\"\n\n[profiles.oss]\nmodel = \"gpt-oss:20b\"\nmodel_provider = \"local\"\n```\n\n这将与任何兼容聊天完成 API 的服务器配合使用，例如 ollama，只要该服务器在 11434 端口上监听即可。启动服务器并将 codex 指向 oss 模型：\n\n```\nollama run gpt-oss:20b\ncodex -p oss\n```\n\n## 工具\n\n### 浏览器\n\n> [!警告]\n> 此实现纯粹用于教育目的，不应在生产环境中使用。您应当根据自己的浏览环境实现一个等效的 [`ExaBackend`](gpt_oss\u002Ftools\u002Fsimple_browser\u002Fbackend.py) 类。目前我们提供了 `ExaBackend` 和 `YouComBackend`。\n\ngpt-oss 的两个模型均经过训练，能够使用“浏览器”工具进行浏览，该工具暴露了以下三种方法：\n\n- `search` 用于搜索关键词\n- `open` 用于打开特定页面\n- `find` 用于在页面上查找内容\n\n#### 使用方法\n\n要启用浏览器工具，您需要将其定义放入 harmony 格式的系统提示中。如果您的工具实现了完整的接口，可以直接使用 `with_browser_tool()` 方法；否则，可以使用 `with_tools()` 方法修改定义。例如：\n\n```python\nimport datetime\nfrom gpt_oss.tools.simple_browser import SimpleBrowserTool\nfrom gpt_oss.tools.simple_browser.backend import ExaBackend\nfrom openai_harmony import SystemContent, Message, Conversation, Role, load_harmony_encoding, HarmonyEncodingName\n\nencoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)\n\n# 根据所选的浏览器后端，需要设置相应的环境变量\n# Exa 后端需要 EXA_API_KEY 环境变量，\n# 而 You.com 则需要 YDC_API_KEY 环境变量\nbackend = ExaBackend(\n    source=\"web\",\n)\n# backend = YouComBackend(\n#  source=\"web\",\n# )\nbrowser_tool = SimpleBrowserTool(backend=backend)\n\n# 创建一个基本的系统提示\nsystem_message_content = SystemContent.new().with_conversation_start_date(\n    datetime.datetime.now().strftime(\"%Y-%m-%d\")\n)\n\n# 如果要使用浏览器工具\nif use_browser_tool:\n    # 启用工具\n    system_message_content = system_message_content.with_tools(browser_tool.tool_config)\n    # 或者，如果您的工具不是无状态的，也可以使用以下方法\n    system_message_content = system_message_content.with_browser_tool()\n\n# 构建系统消息\nsystem_message = Message.from_role_and_content(Role.SYSTEM, system_message_content)\n\n# 创建整体提示\nmessages = [system_message, Message.from_role_and_content(Role.USER, \"旧金山的天气怎么样？\")]\nconversation = Conversation.from_messages(messages)\n\n# 转换为 token\ntoken_ids = encoding.render_conversation_for_completion(conversation, Role.ASSISTANT)\n\n# 进行推理\n# ...\n\n# 解析输出\nmessages = encoding.parse_messages_from_completion_tokens(output_tokens, Role.ASSISTANT)\nlast_message = messages[-1]\nif last_message.recipient.startswith(\"browser\"):\n  # 执行浏览器调用\n  response_messages = await browser_tool.process(last_message)\n\n  # 扩展当前消息并再次进行推理\n  messages.extend(response_messages)\n```\n\n#### 详情\n\n为了控制上下文窗口的大小，该工具使用一个可滚动的文本窗口，模型可以与其交互。例如，它可能会先获取页面的前 50 行，然后滚动到接下来的 20 行。模型也被训练成在其回答中引用该工具提供的信息。\n\n为提高性能，该工具会缓存请求，以便模型可以在不重新加载页面的情况下访问页面的不同部分。因此，您应该为每次请求创建一个新的浏览器实例。\n\n### Python\n\n该模型经过训练，能够在思维链过程中使用 Python 工具执行计算和其他操作。在训练期间，模型使用了一个有状态的工具，这使得在思维链循环之间运行工具更加便捷。然而，此参考实现采用的是无状态模式。因此，PythonTool 定义了自己的工具描述，以覆盖 [`openai-harmony`][harmony] 中的定义。\n\n> [!WARNING]\n> 此实现运行在一个宽松的 Docker 容器中，在提示注入等情况下可能会存在问题。它仅作为示例，生产环境中应考虑实施自己的容器限制。\n\n#### 使用方法\n\n要启用 Python 工具，您需要将其定义放入 Harmony 格式提示的 `system` 消息中。如果您的工具实现了完整接口，可以使用 `with_python()` 方法；否则，可以使用 `with_tools()` 修改定义。例如：\n\n```python\nimport datetime\nfrom gpt_oss.tools.python_docker.docker_tool import PythonTool\nfrom openai_harmony import SystemContent, Message, Conversation, Role, load_harmony_encoding, HarmonyEncodingName\n\nencoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)\n\npython_tool = PythonTool()\n\n# 创建一个基础系统提示\nsystem_message_content = SystemContent.new().with_conversation_start_date(\n    datetime.datetime.now().strftime(\"%Y-%m-%d\")\n)\n\n# 如果要使用 Python 工具\nif use_python_tool:\n    # 启用工具，并确保提示中设置为无状态工具描述\n    system_message_content = system_message_content.with_tools(python_tool.tool_config)\n    # 或者，如果您的工具不是无状态的，也可以使用以下方式：\n    system_message_content = system_message_content.with_python()\n\n# 构建系统消息\nsystem_message = Message.from_role_and_content(Role.SYSTEM, system_message_content)\n\n# 创建整体提示\nmessages = [system_message, Message.from_role_and_content(Role.USER, \"9001 的平方根是多少？\")]\nconversation = Conversation.from_messages(messages)\n\n# 转换为 token\ntoken_ids = encoding.render_conversation_for_completion(conversation, Role.ASSISTANT)\n\n# 进行推理\n# ...\n\n# 解析输出\nmessages = encoding.parse_messages_from_completion_tokens(output_tokens, Role.ASSISTANT)\nlast_message = messages[-1]\nif last_message.recipient == \"python\":\n  # 执行 Python 调用\n  response_messages = await python_tool.process(last_message)\n\n  # 扩展当前消息并再次进行推理\n  messages.extend(response_messages)\n```\n\n### 应用补丁\n\n`apply_patch` 可用于在本地创建、更新或删除文件。\n\n## 其他细节\n\n### 精度格式\n\n我们发布的模型支持原生量化。具体而言，我们在 MoE 层的线性投影权重中使用 [MXFP4](https:\u002F\u002Fwww.opencompute.org\u002Fdocuments\u002Focp-microscaling-formats-mx-v1-0-spec-final-pdf) 格式。MoE 张量被分为两部分存储：\n\n- `tensor.blocks` 存储实际的 fp4 值。我们将每两个值打包成一个 `uint8` 值。\n- `tensor.scales` 存储块尺度。块尺度缩放是在所有 MXFP4 张量的最后一维上进行的。\n\n其余张量均采用 BF16 格式。我们也建议将模型的激活精度设置为 BF16。\n\n### 推荐的采样参数\n\n我们推荐使用 `temperature=1.0` 和 `top_p=1.0` 进行采样。\n\n## 贡献\n\n本仓库中的参考实现旨在作为起点和灵感。除修复 bug 外，我们不打算接受新的功能贡献。如果您基于此代码构建实现，例如新的工具实现，欢迎将其贡献到 [`awesome-gpt-oss.md`](.\u002Fawesome-gpt-oss.md) 文件中。\n\n[harmony]: https:\u002F\u002Fgithub.com\u002Fopenai\u002Fharmony\n\n## 引用\n\n```bibtex\n@misc{openai2025gptoss120bgptoss20bmodel,\n      title={gpt-oss-120b & gpt-oss-20b 模型卡片}, \n      author={OpenAI},\n      year={2025},\n      eprint={2508.10925},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL},\n      url={https:\u002F\u002Farxiv.org\u002Fabs\u002F2508.10925}, \n}\n```","# gpt-oss 快速上手指南\n\ngpt-oss 是 OpenAI 推出的开源权重模型系列，专为强大的推理能力、智能体任务及多样化开发场景设计。本指南将帮助您快速在本地部署并运行 `gpt-oss-120b`（高性能）或 `gpt-oss-20b`（低延迟\u002F本地运行）模型。\n\n## 环境准备\n\n### 系统要求\n- **操作系统**：Linux (推荐) 或 macOS。\n  - *注：参考实现未在 Windows 上测试，Windows 用户建议使用 Ollama 等第三方工具。*\n- **Python 版本**：Python 3.12\n- **硬件要求**：\n  - **gpt-oss-120b**：需单张 80GB GPU (如 NVIDIA H100 或 AMD MI300X) 运行量化版本；若使用未优化的 PyTorch 参考实现，则需至少 4 张 H100。\n  - **gpt-oss-20b**：可在 16GB 显存内运行，适合消费级显卡或本地开发。\n- **依赖工具**：\n  - **Linux**: 需安装 CUDA。\n  - **macOS**: 需安装 Xcode 命令行工具 (`xcode-select --install`)。\n\n### 前置依赖\n确保已安装 `pip` 和 `git`。若使用 Hugging Face 下载模型，建议安装 `huggingface_hub` 客户端。\n\n## 安装步骤\n\n### 1. 安装 Python 包\n根据您的需求选择安装方式。推荐使用 `pip` 直接从 PyPI 安装：\n\n```shell\n# 仅安装工具库 (browser, python tools 等)\npip install gpt-oss\n\n# 安装 PyTorch 参考实现 (教育\u002F调试用途，需多卡)\npip install gpt-oss[torch]\n\n# 安装 Triton 优化实现 (单卡运行 120b 模型推荐)\npip install gpt-oss[triton]\n```\n\n> **注意**：若需使用 Triton 后端运行大模型，可能需要从源码安装最新版的 Triton：\n> ```shell\n> git clone https:\u002F\u002Fgithub.com\u002Ftriton-lang\u002Ftriton\n> cd triton\u002F\n> pip install -r python\u002Frequirements.txt\n> pip install -e . --verbose --no-build-isolation\n> pip install -e python\u002Ftriton_kernels\n> ```\n\n### 2. 下载模型权重\n使用 Hugging Face CLI 下载模型权重（请确保网络通畅，国内用户可配置镜像源）：\n\n```shell\n# 下载 gpt-oss-120b\nhf download openai\u002Fgpt-oss-120b --include \"original\u002F*\" --local-dir gpt-oss-120b\u002F\n\n# 下载 gpt-oss-20b\nhf download openai\u002Fgpt-oss-20b --include \"original\u002F*\" --local-dir gpt-oss-20b\u002F\n```\n\n## 基本使用\n\ngpt-oss 模型必须配合 **Harmony 响应格式** 才能正常工作。以下提供两种最常用的快速启动方式。\n\n### 方式一：使用 Transformers 库（最简单）\n此方法自动处理 Harmony 格式，适合快速测试。\n\n```python\nfrom transformers import pipeline\nimport torch\n\nmodel_id = \"openai\u002Fgpt-oss-120b\"  # 或 \"openai\u002Fgpt-oss-20b\"\n\npipe = pipeline(\n    \"text-generation\",\n    model=model_id,\n    torch_dtype=\"auto\",\n    device_map=\"auto\",\n)\n\nmessages = [\n    {\"role\": \"user\", \"content\": \"Explain quantum mechanics clearly and concisely.\"},\n]\n\noutputs = pipe(\n    messages,\n    max_new_tokens=256,\n)\nprint(outputs[0][\"generated_text\"][-1])\n```\n\n### 方式二：使用 vLLM 部署服务（生产\u002F高性能推荐）\nvLLM 可提供兼容 OpenAI API 的服务。首先安装特定版本的 vLLM：\n\n```bash\nuv pip install --pre vllm==0.10.1+gptoss \\\n    --extra-index-url https:\u002F\u002Fwheels.vllm.ai\u002Fgpt-oss\u002F \\\n    --extra-index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fnightly\u002Fcu128 \\\n    --index-strategy unsafe-best-match\n```\n\n启动服务：\n```bash\nvllm serve openai\u002Fgpt-oss-20b\n```\n\n若需在代码中离线调用并解析 Harmony 格式，请参考以下示例：\n\n```python\nimport os\nos.environ[\"VLLM_USE_FLASHINFER_SAMPLER\"] = \"0\"\n\nimport json\nfrom openai_harmony import (\n    HarmonyEncodingName,\n    load_harmony_encoding,\n    Conversation,\n    Message,\n    Role,\n    SystemContent,\n    DeveloperContent,\n)\n \nfrom vllm import LLM, SamplingParams\n\n# 1. 渲染 Harmony 预填充内容\nencoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)\n \nconvo = Conversation.from_messages(\n    [\n        Message.from_role_and_content(Role.SYSTEM, SystemContent.new()),\n        Message.from_role_and_content(\n            Role.DEVELOPER,\n            DeveloperContent.new().with_instructions(\"Always respond in riddles\"),\n        ),\n        Message.from_role_and_content(Role.USER, \"What is the weather like in SF?\"),\n    ]\n)\n \nprefill_ids = encoding.render_conversation_for_completion(convo, Role.ASSISTANT)\nstop_token_ids = encoding.stop_tokens_for_assistant_actions()\n \n# 2. 初始化 vLLM\nllm = LLM(\n    model=\"openai\u002Fgpt-oss-20b\",\n    trust_remote_code=True,\n    gpu_memory_utilization=0.95,\n    max_num_batched_tokens=4096,\n    max_model_len=5000,\n    tensor_parallel_size=1\n)\n \nsampling = SamplingParams(\n    max_tokens=128,\n    temperature=1,\n    stop_token_ids=stop_token_ids,\n)\n \n# 3. 生成并解析结果\noutputs = llm.generate(\n    prompt_token_ids=[prefill_ids],\n    sampling_params=sampling,\n)\n \ngen = outputs[0].outputs[0]\noutput_tokens = gen.token_ids\n \n# 将 token 解析回结构化消息\nentries = encoding.parse_messages_from_completion_tokens(output_tokens, Role.ASSISTANT)\n \nfor message in entries:\n    print(f\"{json.dumps(message.to_dict())}\")\n```\n\n### 其他方式：Ollama (适合本地\u002F消费级硬件)\n如果您希望在个人电脑上轻松运行，可使用 Ollama：\n\n```bash\n# 拉取并运行 20b 版本\nollama pull gpt-oss:20b\nollama run gpt-oss:20b\n\n# 拉取并运行 120b 版本 (需高端硬件)\nollama pull gpt-oss:120b\nollama run gpt-oss:120b\n```","某金融科技公司的算法团队需要在本地服务器部署一套高频交易策略分析系统，要求模型具备极强的逻辑推理能力且数据绝不能出域。\n\n### 没有 gpt-oss 时\n- **数据安全风险高**：只能调用云端闭源 API 进行复杂策略回测，敏感的交易数据和核心算法逻辑存在泄露隐患。\n- **硬件门槛难以跨越**：同等量级的高性能推理模型通常需要多卡并行或超大显存，公司现有的单张 80GB H100 显卡无法运行。\n- **推理过程不透明**：面对模型给出的错误投资建议，无法查看其内部的思维链（Chain-of-Thought），导致调试困难且难以建立信任。\n- **响应延迟不可控**：云端服务受网络波动影响大，且无法根据业务高峰期灵活调整模型的“推理努力程度”以平衡速度与精度。\n\n### 使用 gpt-oss 后\n- **实现完全本地化部署**：利用 gpt-oss-120b 的 MXFP4 量化技术，成功在单张 80GB GPU 上运行百亿参数模型，确保核心数据不出内网。\n- **低成本高性能推理**：无需昂贵的多卡集群，仅凭现有硬件即可承载生产级的高强度逻辑推理任务，大幅降低基础设施成本。\n- **全链路思维可追溯**：通过 gpt-oss 输出的完整思维链，开发人员能清晰看到策略生成的每一步逻辑，快速定位并修正推理偏差。\n- **灵活调控推理强度**：针对实时盘口分析调低“推理努力程度”以降低延迟，针对深度研报生成则调高该参数，完美适配不同场景需求。\n\ngpt-oss 让企业在单一消费级显卡上即可拥有安全、透明且可定制的企业级推理能力，彻底打破了高性能 AI 落地的硬件与隐私壁垒。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fopenai_gpt-oss_bf1e8ef7.png","openai","OpenAI","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fopenai_1960bbf4.png","",null,"https:\u002F\u002Fopenai.com\u002F","https:\u002F\u002Fgithub.com\u002Fopenai",[82,86,90,94,98,102,106],{"name":83,"color":84,"percentage":85},"Python","#3572A5",40.2,{"name":87,"color":88,"percentage":89},"C","#555555",28,{"name":91,"color":92,"percentage":93},"C++","#f34b7d",13.4,{"name":95,"color":96,"percentage":97},"Metal","#8f14e9",12.2,{"name":99,"color":100,"percentage":101},"TypeScript","#3178c6",2.9,{"name":103,"color":104,"percentage":105},"Objective-C","#438eff",2.1,{"name":107,"color":108,"percentage":109},"CMake","#DA3434",1.3,20017,2065,"2026-04-19T08:27:34","Apache-2.0",4,"Linux, macOS","gpt-oss-120b: 单张 80GB GPU (如 NVIDIA H100 或 AMD MI300X)；gpt-oss-20b: 16GB 显存即可。参考 PyTorch 实现需 4x H100。Linux 参考实现需要 CUDA，vLLM 示例指定 cu128。Apple Silicon 可使用 Metal 实现。","未说明",{"notes":119,"python":120,"dependencies":121},"模型必须使用 Harmony 响应格式才能正常工作。gpt-oss-120b 和 gpt-oss-20b 均经过 MXFP4 量化以优化显存占用。Windows 系统未测试参考实现，建议使用 Ollama 等工具在本地运行。vLLM 运行时若遇到显存错误，需设置环境变量 'PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True'。","3.12",[122,123,124,125,126,127],"torch","triton","transformers","vllm (特定版本 0.10.1+gptoss)","openai-harmony","flashinfer (可选)",[35,13],"2026-03-27T02:49:30.150509","2026-04-20T04:06:02.450141",[],[133,138,143,148,153,158],{"id":134,"version":135,"summary_zh":136,"released_at":137},343056,"v0.0.9","## 变更内容\n* 添加 AWS 官方发布博客文章，并由 @neoremind 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F197 中将 AWS 相关部分重新格式化为 awesome-gpt-oss.md\n* Metal：简化 Python 封装中的模型类型检查，由 @Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F202 中完成\n* Metal：将 max_batch_tokens 从 Model 移至 Context，由 @Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F201 中完成\n* GPT-OSS 强化学习微调示例，由 @danielhanchen 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F208 中添加\n* 添加有状态的 Jupyter Notebook 选项，并提升浏览器的可靠性，由 @dkundel-openai 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F199 中实现\n* 在预填充阶段移除 MoE MLP 中的 GPU-CPU 同步，由 @ibahmed-oai 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F218 中完成\n* 在预填充阶段省略将 RoPE 处理后的 KV 复制到 KV 缓存的操作，由 @ibahmed-oai 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F221 中完成\n* 修复：移除导致 Metal 构建失败的重复变量，由 @hukurou0 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F220 中完成\n* 为追踪目的在请求头中添加 User-Agent，由 @smboy 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F235 中完成\n\n## 新贡献者\n* @neoremind 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F197 中完成了首次贡献\n* @danielhanchen 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F208 中完成了首次贡献\n* @hukurou0 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F220 中完成了首次贡献\n* @smboy 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F235 中完成了首次贡献\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fcompare\u002Fv0.0.8...v0.0.9","2026-01-13T19:03:30",{"id":139,"version":140,"summary_zh":141,"released_at":142},343057,"v0.0.8","## 变更内容\n* 由 @ibahmed-oai 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F191 中添加了用于预填充的 Metal MOE 内核。\n* 由 @ibahmed-oai 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F192 中通过新的 MOE 内核加速预填充。\n* Metal：由 @Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F194 中修复了预填充中的资源泄漏问题。\n* Metal：由 @Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F195 中在转换器中支持分片检查点。\n* 由 @dkundel-openai 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F198 中优化了 Python 代码和浏览器体验。\n\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fcompare\u002Fv0.0.7...v0.0.8","2025-09-29T02:58:19",{"id":144,"version":145,"summary_zh":146,"released_at":147},343058,"v0.0.7","## 变更内容\n* 评估：在使用 Responses API 时正确传递 temperature\u002Fmax_tokens 参数，由 @Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F174 中完成\n* Metal：将采样操作移至 GPU 上执行，由 @Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F175 中完成\n* Metal：将基准测试的生成长度从 1 个标记调整为 100 个标记，由 @Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F178 中完成\n* Metal：支持一次性生成多个标记，由 @Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F179 中完成\n* 为 Metal 后端添加预填充基准测试，由 @ibahmed-oai 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F181 中完成\n* Metal：优化线程组大小，由 @Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F180 中完成\n* Metal：添加优化的密集矩阵乘法内核以提升预填充性能，由 @ibahmed-oai 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F183 中完成\n* Metal：融合 QKV 投影（矩阵乘法 + RoPE）内核，由 @Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F184 中完成\n* [修复] 使用 uv 作为后端时捕获 Python 工具的 stderr 输出，由 @wuhang2014 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F182 中完成\n\n## 新贡献者\n* @ibahmed-oai 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F181 中完成了首次贡献\n* @wuhang2014 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F182 中完成了首次贡献\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fcompare\u002Fv0.0.6...v0.0.7","2025-09-15T19:30:44",{"id":149,"version":150,"summary_zh":151,"released_at":152},343059,"v0.0.6","## 变更内容\n* Metal：@Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F161 中添加了端到端基准测试。\n* Metal：@Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F162 中简化并优化了 Responses API 适配器。\n* Metal：@Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F163 中修复了重置+追加后 KV 缓存失效的问题。\n* 将 Responses API 的最大输出标记数增加至 131K，由 @Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F165 中完成。\n* 移除对 Python 最高版本的限制，由 @Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F167 中实现。\n* 将 Lemonade 移至 `awesome-gpt-oss` 的 AMD 部分，由 @danielholanda 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F164 中完成。\n* 添加了 VLLM 离线推理的工作代码，由 @hrithiksagar-tih 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F150 中实现。\n* Metal：指示线程组是 SIMD 组的倍数，由 @Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F168 中完成。\n* Metal：将模型权重在内存中进行 mlock 操作，由 @Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F170 中实现。\n* 添加 You.com 作为浏览器工具，由 @bojanbabic 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F171 中完成。\n\n## 新贡献者\n* @hrithiksagar-tih 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F150 中完成了首次贡献。\n* @bojanbabic 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F171 中完成了首次贡献。\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fcompare\u002Fv0.0.5...v0.0.6","2025-09-03T22:37:52",{"id":154,"version":155,"summary_zh":156,"released_at":157},343060,"v0.0.5","## 变更内容\n* @dkundel-openai 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F148 中更新了 awesome-gpt-oss.md，加入了 llama.cpp\n* @dkundel-openai 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F154 中更新了 README.md\n* @samagra14 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F118 中添加了 Tensorfuse（AWS）指南\n* @danielholanda 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F117 中将 Lemonade 添加到 `awesome-gpt-oss`\n* @heheda12345 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F156 中添加了 uv Python 后端\n\n## 新贡献者\n* @samagra14 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F118 中完成了首次贡献\n* @danielholanda 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F117 中完成了首次贡献\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fcompare\u002Fv0.0.4...v0.0.5","2025-08-28T19:04:43",{"id":159,"version":160,"summary_zh":161,"released_at":162},343061,"v0.0.4","## 变更内容\n* 修复 Streamlit 和 Ollama 演示。由 @dkundel-openai 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F131 中添加了 Python 工具。\n* 由 @hiyouga 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F28 中向 awesome-gpt-oss.md 添加了一些链接。\n* 修复：由 @liuzhiqi71 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F31 中修复了 streamlit_chat.py 中 f-string 匹配不上的 '(' 错误。\n* 由 @peterbell10 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F136 中修复了 upper bound 计算中 start_q 的使用问题。\n* 由 @Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F138 中实现了上下文中的 token 延迟处理。\n* 由 @simonw 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F142 中修复了模型名称中包含 \u002F 导致评估失败的 bug。\n* [README] 由 @xiaohk 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F140 中将 README 中的 `with_browser()` 重命名为 `with_browser_tool()`。\n* 由 @peterbell10 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F137 中更新了注意力核函数以使用 TensorDescriptor。\n* 由 @Maratyszcza 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F144 中实现了 SDPA 在多个 simdgroup 上的并行化。\n* 杂项：由 @dkundel-openai 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F145 中发布了 v0.0.4 版本。\n\n## 新贡献者\n* @hiyouga 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F28 中完成了首次贡献。\n* @liuzhiqi71 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F31 中完成了首次贡献。\n* @peterbell10 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F136 中完成了首次贡献。\n* @simonw 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F142 中完成了首次贡献。\n* @xiaohk 在 https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fpull\u002F140 中完成了首次贡献。\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgpt-oss\u002Fcompare\u002Fv0.0.3...v0.0.4","2025-08-18T01:03:14"]