[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-ironjr--grokfast":3,"tool-ironjr--grokfast":61},[4,18,26,36,44,53],{"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 真正成长为懂上",143909,2,"2026-04-07T11:33:18",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107888,"2026-04-06T11:32:50",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":10,"last_commit_at":59,"category_tags":60,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[35,15,13,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":76,"owner_location":77,"owner_email":78,"owner_twitter":79,"owner_website":80,"owner_url":81,"languages":82,"stars":87,"forks":88,"last_commit_at":89,"license":90,"difficulty_score":91,"env_os":92,"env_gpu":93,"env_ram":92,"env_deps":94,"category_tags":99,"github_topics":100,"view_count":32,"oss_zip_url":106,"oss_zip_packed_at":106,"status":17,"created_at":107,"updated_at":108,"faqs":109,"releases":138},5202,"ironjr\u002Fgrokfast","grokfast","Official repository for the paper \"Grokfast: Accelerated Grokking by Amplifying Slow Gradients\"","Grokfast 是一款旨在加速机器学习模型“顿悟”（Grokking）现象的开源优化辅助工具。在深度学习中，模型有时会在长时间完美过拟合训练数据后，突然实现泛化能力的飞跃，这一过程往往耗时极长。Grokfast 正是为了解决这一漫长的等待延迟而生，它能显著缩短模型从过拟合到真正掌握规律的时间。\n\n该工具的核心技术亮点在于将训练过程中的参数梯度视为时间信号，并通过频谱分析将其分解为“快速变化导致过拟合”和“缓慢变化诱导泛化”两个分量。Grokfast 通过简单的几行代码，放大梯度中的低频（慢变）分量，从而在不改变模型架构的前提下，将顿悟过程加速高达 50 倍以上。实验证明，该方法广泛适用于图像、自然语言处理及图神经网络等多种任务场景。\n\nGrokfast 特别适合 AI 研究人员和深度学习开发者使用，尤其是那些正在探索模型泛化机制、希望减少训练成本或复现顿悟现象的专业人士。其集成极为简便，仅需下载单个 Python 文件并在优化器调用前插入一行滤波代码即可生效，无需安装额外的复杂依赖库，让前沿的优化理论能迅速落地于实际实验中。","\u003Cdiv align=\"center\">\n\n\u003Ch1>Grokfast: Accelerated Grokking by\u003C\u002Fbr>Amplifying Slow Gradients\u003C\u002Fh1>\n\n[**Jaerin Lee**](http:\u002F\u002Fjaerinlee.com\u002F)\\* · [**Bong Gyun Kang**](https:\u002F\u002Fscholar.google.com\u002Fcitations?hl=en&user=iuMRdnIAAAAJ)\\* · [**Kihoon Kim**](https:\u002F\u002Fgithub.com\u002Fkihoon96\u002F) · [**Kyoung Mu Lee**](https:\u002F\u002Fcv.snu.ac.kr\u002Findex.php\u002F~kmlee\u002F)\n\n\u003Ch5 align=\"center\">Seoul National University\u003C\u002Fh5>\n\n\u003Cp align=\"left\">\n*Denotes equal contribution.\n\u003C\u002Fp>\n\n\n[![Project](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FProject-Page-green)](https:\u002F\u002Fjaerinlee.com\u002Fresearch\u002Fgrokfast)\n[![ArXiv](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FArxiv-2405.20233-red)](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.20233)\n[![Github](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002Fironjr\u002Fgrokfast)](https:\u002F\u002Fgithub.com\u002Fironjr\u002Fgrokfast)\n[![X](https:\u002F\u002Fimg.shields.io\u002Ftwitter\u002Furl?label=_ironjr_&url=https%3A%2F%2Ftwitter.com%2F_ironjr_)](https:\u002F\u002Ftwitter.com\u002F_ironjr_)\n[![HFPaper](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%F0%9F%A4%97%20Hugging%20Face-Paper-yellow)](https:\u002F\u002Fhuggingface.co\u002Fpapers\u002F2405.20233)\n[![LICENSE](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-lightgrey)](https:\u002F\u002Fgithub.com\u002Fironjr\u002Fgrokfast\u002Fblob\u002Fmain\u002FLICENSE)\n\n\u003C\u002Fdiv>\n\n**tl;dr:** We accelerate the [grokking phenomenon](https:\u002F\u002Farxiv.org\u002Fabs\u002F2201.02177) by amplifying low-frequencies of the parameter gradients with an augmented optimizer.\n\n![fig2](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fironjr_grokfast_readme_a806399f8ed1.png) |  ![fig3](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fironjr_grokfast_readme_47757e3db433.gif)  |\n:----------------------------: | :----------------------------: |\n\n**Abstract:** \nOne puzzling artifact in machine learning dubbed *grokking* is where delayed generalization is achieved tenfolds of iterations after near perfect overfitting to the training data.\nFocusing on the long delay itself on behalf of machine learning practitioners, our goal is to accelerate generalization of a model under grokking phenomenon.\nBy regarding a series of gradients of a parameter over training iterations as a random signal over time, we can spectrally decompose the parameter trajectories under gradient descent into two components: the fast-varying, overfitting-yielding component and the slow-varying, generalization-inducing component.\nThis analysis allows us to accelerate the grokking phenomenon more than $\\times$ 50 with only a few lines of code that amplifies the slow-varying components of gradients.\nThe experiments show that our algorithm applies to diverse tasks involving images, languages, and graphs, enabling practical availability of this peculiar artifact of sudden generalization.\n\n![fig2](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fironjr_grokfast_readme_f558e4134878.png) |  ![fig3](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fironjr_grokfast_readme_32edee01eec3.png)  |\n:----------------------------: | :----------------------------: |\n\n---\n\n## Usage\n\n### Installation\n\nGrokfast doesn't require additional packages except for [PyTorch](https:\u002F\u002Fpytorch.org\u002Fget-started\u002Flocally\u002F). The file `requirements.txt` is only for reproduction of the experiments in the article, as described in the [Reproduction](#reproduction) section below.\n\n### Instructions\n\nGrokfast can be applied by inserting a single line before the optimizer call.\n\n1. Download a single file `grokfast.py` from our repository.\n```bash\nwget https:\u002F\u002Fraw.githubusercontent.com\u002Fironjr\u002Fgrokfast\u002Fmain\u002Fgrokfast.py\n```\n2. Import the helper function.\n```python\nfrom grokfast import gradfilter_ma, gradfilter_ema\n```\n3. Insert the following line **before** the training loop.\n```python\ngrads = None\n```\n4. Between `loss.backward()` and `optimizer.step()`, insert one of the following line. Make sure `model` is of type `nn.Module` and `grads` are initialized properly before the training loop:\n```python\n# ... in the optimization loop.\nloss.backwards() # Calculate the gradients.\n\n### Option 1: Grokfast (has argument alpha, lamb)\ngrads = gradfilter_ema(model, grads=grads, alpha=alpha, lamb=lamb)\n### Option 2: Grokfast-MA (has argument window_size, lamb)\n# grads = gradfilter_ma(model, grads=grads, window_size=window_size, lamb=lamb)\n\noptimizer.step() # Call the optimizer.\n# ... logging & other codes.\n```\n\nDone!\n\n\u003Cdetails>\n  \n\u003Csummary>(2-1) ...or, copy and paste the method directly into your code!\u003C\u002Fsummary>\n\n```python\n### Imports\nfrom collections import deque\nfrom typing import Dict, Optional, Literal\nimport torch\nimport torch.nn as nn\n\n\n### Grokfast\ndef gradfilter_ema(\n    m: nn.Module,\n    grads: Optional[Dict[str, torch.Tensor]] = None,\n    alpha: float = 0.99,\n    lamb: float = 5.0,\n) -> Dict[str, torch.Tensor]:\n    if grads is None:\n        grads = {n: p.grad.data.detach() for n, p in m.named_parameters() if p.requires_grad}\n\n    for n, p in m.named_parameters():\n        if p.requires_grad:\n            grads[n] = grads[n] * alpha + p.grad.data.detach() * (1 - alpha)\n            p.grad.data = p.grad.data + grads[n] * lamb\n\n    return grads\n\n\n### Grokfast-MA\ndef gradfilter_ma(\n    m: nn.Module,\n    grads: Optional[Dict[str, deque]] = None,\n    window_size: int = 128,\n    lamb: float = 5.0,\n    filter_type: Literal['mean', 'sum'] = 'mean',\n    warmup: bool = True,\n    trigger: bool = False,\n) -> Dict[str, deque]:\n    if grads is None:\n        grads = {n: deque(maxlen=window_size) for n, p in m.named_parameters() if p.requires_grad}\n\n    for n, p in m.named_parameters():\n        if p.requires_grad:\n            grads[n].append(p.grad.data.detach())\n\n            if not warmup or len(grads[n]) == window_size and not trigger:\n                if filter_type == \"mean\":\n                    avg = sum(grads[n]) \u002F len(grads[n])\n                elif filter_type == \"sum\":\n                    avg = sum(grads[n])\n                else:\n                    raise ValueError(f\"Unrecognized filter_type {filter_type}\")\n                p.grad.data = p.grad.data + avg * lamb\n\n    return grads\n```\n\n\u003C\u002Fdetails>\n\n### Arguments\n\n1. Grokfast (`gradfilter_ema`)\n\n    - `m: nn.Module`: Model that contains every trainable parameters.\n    - `grads: Optional[Dict[str, torch.Tensor]] = None`: Running memory (EMA). Initialize by setting it to `None`. Feed the output of the method recursively after on.\n    - `alpha: float = 0.98`: Momentum hyperparmeter of the EMA.\n    - `lamb: float = 2.0`: Amplifying factor hyperparameter of the filter.\n\n2. Grokfast-MA (`gradfilter_ma`)\n\n    - `m: nn.Module`: Model that contains every trainable parameters.\n    - `grads: Optional[Dict[str, deque]] = None`: Running memory (Queue for windowed moving average). Initialize by setting it to `None`. Feed the output of the method recursively after on.\n    - `window_size: int = 100`: The width of the filter window. Additional memory requirements increases linearly with respect to the windows size.\n    - `lamb: float = 5.0`: Amplifying factor hyperparameter of the filter.\n    - `filter_type: Literal['mean', 'sum'] = 'mean'`: Aggregation method for the running queue.\n    - `warmup: bool = True`: If true, filter is not applied until the queue is filled.\n    - `trigger: bool = False`:  For ablation study only. If true, the filter is simply not applied.\n\n---\n\n## Reproduction\n\nWe also note the additional computational resources required for each run. Time & memory costs are measured with a single GTX 1080 Ti GPU.\n\n### Installation\n\nThis will install the additional packages to preprocess each data and to summarize the results. \n\n```bash\nconda create -n grok python=3.10 && conda activate grok\ngit clone https:\u002F\u002Fgithub.com\u002Fironjr\u002Fgrokfast\npip install -r requirements.txt\n```\n\n### Algorithmic Data (Transformer decoder, *Grokfast-MA*)\n\n| Run | Iterations to Reach 95% Val. Acc. | Wall Clock Time to Reach 95% Val. Acc. (s) | VRAM Requirements (MB) | Latency Per Iteration (s) |\n| :-: | :-------------------------------: | :------------------------------------: | :--------------------: | :-----------------------: |\n| Baseline | 39890 | 5984 | 290 | 0.15 |\n| Grokfast-MA | 790 ($\\times$ 50.49 $\\downarrow$) | 292 ($\\times$ 20.49 $\\downarrow$) | 458 | 0.37 |\n\n```bash\n# python main.py --label test # Baseline.\npython main.py --label test --filter ma --window_size 100 --lamb 5.0 --weight_decay 0.01\n```\n\n### Algorithmic Data (Transformer decoder, *Grokfast*)\n\n| Run | Iterations to Reach 95% Val. Acc. | Wall Clock Time to Reach 95% Val. Acc. (s) | VRAM Requirements (MB) | Latency Per Iteration (s) |\n| :-: | :-------------------------------: | :------------------------------------: | :--------------------: | :-----------------------: |\n| Baseline | 39890 | 5984 | $290 | 0.15 |\n| Grokfast | 910 ($\\times$ 43.84 $\\downarrow$) | 137 ($\\times$ 43.79 $\\downarrow$) | 294 | 0.15 |\n\n```bash\n# python main.py --label test # Baseline.\npython main.py --label test --filter ema --alpha 0.98 --lamb 2.0 --weight_decay 0.005\n```\n\n### MNIST (MLP)\n\n| Run | Iterations to Reach 95% Val. Acc. | Wall Clock Time to Reach 95% Val. Acc. (s) | VRAM Requirements (MB) | Latency Per Iteration (ms) |\n| :-: | :-------------------------------: | :------------------------------------: | :--------------------: | :------------------------: |\n| Baseline | 44022 | 1928 | 196 | 43.8 |\n| Grokfast | 2001 ($\\times$ 22.00 $\\downarrow$) | 87.8 ($\\times$ 21.96 $\\downarrow$) | 198 | 43.9 |\n\n```bash\n# python main_mnist.py --label test # Baseline.\npython main_mnist.py --label test --alpha 0.8 --lamb 0.1 --weight_decay 2.0\n```\n\n### IMDb (LSTM)\n\n| Run | Best Validation Acc. | Minimum Validation Loss | VRAM Requirements (MB) | Latency Per Iteration (ms) |\n| :-: | :------------------: | :---------------------: | :--------------------: | :------------------------: |\n| Baseline | 0.84 | 0.517 | 754 | 20.4 |\n| Grokfast | 0.90 | 0.412 | 762 | 21.2 |\n\n- Before training, download the IMDb dataset from [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F11dNiqE5Y5tigaeyYP6JPV3xxa1MOu1L-\u002Fview?usp=sharing) or [Baidu Webdisk](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1kNDXlqPHxuDLtQWbdItwhw) (pw: vdp7).\n\n```bash\n# python main_imdb.py --label test # Baseline.\npython main_imdb.py --label test --alpha 0.98 --lamb 2.0 --weight_decay 10.0\n```\n\n### QM9 (G-CNN)\n\n| Run | Minimum Validation Loss | VRAM Requirements (MB) | Latency Per Iteration (ms) |\n| :-: | :---------------------: | :--------------------: | :------------------------: |\n| Baseline | 0.00659 | 216 | 40.2 |\n| Grokfast | 0.00348 | 216 | 41.4 |\n\n```bash\n# python main_qm9.py --label test # Baseline.\npython main_qm9.py --label test --alpha 0.9 --lamb 1.0 --weight_decay 0.01\n```\n\n---\n\n## FAQ\n\n### Choosing the right hyperparameters\n\nThese recommendations are based on my experiences during the experiments shown in the main manuscript. This may not work perfectly to every other problems, and maybe more intelligent techniques can do better jobs than this procedure. So, please take these as one possible starting guidelines for designing your own filters.\n\n\n1. **Cutoff parameters**: The work uses MA\u002FEMA filters to implement the filtering techniques. The cutoff frequency is determined by the _window size_ for the MA filter, and the _momentum parameter_ for the EMA filter.\n    1. **Roughly figure out the amount of acceleration you want to achieve.** For example, in the main manuscript, the cutoff parameters are determined based on the original grokking report, where experiments shows generalization happening X100 slower than overfitting. Therefore, we want *N=100* times faster acceleration.\n    2. **Set the pivotal values for the cutoff parameter search.** For MA, I started to set the window size of \"w=N=100\" and for EMA, I began with the momentum parameter alpha that satisfies \"alpha^{N} = alpha^{100} = 0.1\" (which is roughly alpha ~ 0.98).\n    3. **Perform hyperparameter search near the pivot values.** I swept across hyperparameter values near the values set in (1.b).\n3. **Weight decay**: The weight decay is set in the optimizer constructor as usual (e.g., `optimizer = optim.Adam(m.parameters(), weight_decay=wd)`).\n    1. **Start from the default weight decay of that task.** For example, the value chosen by the most widely used Github repository of that task.\n    2. **Fix the weight decay and try to find the optimal setting for the Grokfast filter parameters (momentum, window size, and amplitude) first.** Although weight decay do affect the values of the optimal filter parameters, its effect seems to be insignificant in my experiences.\n    3. **Start _increasing_ the weight decay value.** Start from X1 then try (X2, X5, X10). I couldn't get better results with X100 scale of the default value.\n\n\n## Acknowledgement\n\nOur code is heavily based on the following projects:\n- Ziming Liu et al., \"Omnigrok: Grokking Beyond Algorithmic Data,\" ICLR 2023. [\\[arXiv\\]](https:\u002F\u002Farxiv.org\u002Fabs\u002F2210.01117) [\\[code\\]](https:\u002F\u002Fgithub.com\u002FKindXiaoming\u002FOmnigrok)\n- Alethea Power et al., \"Grokking: Generalization Beyond Overfitting on Small Algorithmic Datasets,\" arXiv preprint arXiv:2201.02177. [\\[arXiv\\]](https:\u002F\u002Farxiv.org\u002Fabs\u002F2201.02177) [\\[code\\]](https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgrok)\n- [@danielmamay](https:\u002F\u002Fgithub.com\u002Fdanielmamay)'s Re-implementation of Grokking. [\\[code\\]](https:\u002F\u002Fgithub.com\u002Fdanielmamay\u002Fgrokking)\n\nThank you all for providing useful references!\n\n\n## Citation\n\nPlease cite us if you find our project useful!\n\n```latex\n@article{lee2024grokfast,\n    title={{Grokfast}: Accelerated Grokking by Amplifying Slow Gradients},\n    author={Lee, Jaerin and Kang, Bong Gyun and Kim, Kihoon and Lee, Kyoung Mu},\n    journal={arXiv preprint arXiv:2405.20233},\n    year={2024}\n}\n```\n\n## Star History\n\n[![Star History Chart](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fironjr_grokfast_readme_fc423342fc29.png)](https:\u002F\u002Fstar-history.com\u002F#ironjr\u002Fgrokfast&Date)\n\n## Contact\n\nIf you have any questions, please email `jarin.lee@gmail.com`.\n","\u003Cdiv align=\"center\">\n\n\u003Ch1>Grokfast：通过放大慢梯度加速 Grokking\u003C\u002Fh1>\n\n[**Jaerin Lee**](http:\u002F\u002Fjaerinlee.com\u002F)\\* · [**Bong Gyun Kang**](https:\u002F\u002Fscholar.google.com\u002Fcitations?hl=en&user=iuMRdnIAAAAJ)\\* · [**Kihoon Kim**](https:\u002F\u002Fgithub.com\u002Fkihoon96\u002F) · [**Kyoung Mu Lee**](https:\u002F\u002Fcv.snu.ac.kr\u002Findex.php\u002F~kmlee\u002F)\n\n\u003Ch5 align=\"center\">首尔国立大学\u003C\u002Fh5>\n\n\u003Cp align=\"left\">\n*表示共同贡献。\n\u003C\u002Fp>\n\n\n[![项目](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FProject-Page-green)](https:\u002F\u002Fjaerinlee.com\u002Fresearch\u002Fgrokfast)\n[![ArXiv](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FArxiv-2405.20233-red)](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.20233)\n[![Github](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002Fironjr\u002Fgrokfast)](https:\u002F\u002Fgithub.com\u002Fironjr\u002Fgrokfast)\n[![X](https:\u002F\u002Fimg.shields.io\u002Ftwitter\u002Furl?label=_ironjr_&url=https%3A%2F%2Ftwitter.com%2F_ironjr_)](https:\u002F\u002Ftwitter.com\u002F_ironjr_)\n[![HFPaper](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%F0%9F%A4%97%20Hugging%20Face-Paper-yellow)](https:\u002F\u002Fhuggingface.co\u002Fpapers\u002F2405.20233)\n[![LICENSE](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-lightgrey)](https:\u002F\u002Fgithub.com\u002Fironjr\u002Fgrokfast\u002Fblob\u002Fmain\u002FLICENSE)\n\n\u003C\u002Fdiv>\n\n**简而言之：** 我们通过使用增强型优化器放大参数梯度的低频成分，从而加速了 [Grokking 现象](https:\u002F\u002Farxiv.org\u002Fabs\u002F2201.02177)。\n\n![fig2](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fironjr_grokfast_readme_a806399f8ed1.png) |  ![fig3](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fironjr_grokfast_readme_47757e3db433.gif)  |\n:----------------------------: | :----------------------------: |\n\n**摘要：** 机器学习中一个令人困惑的现象被称为 *Grokking*，即在对训练数据几乎完美过拟合之后，经过数十倍的迭代才实现泛化。针对机器学习从业者关注的这种长时间延迟问题，我们的目标是加速处于 Grokking 现象下的模型的泛化过程。我们将训练过程中参数梯度随时间变化的一系列信号视为随机信号，并将其分解为两个成分：快速变化、导致过拟合的成分，以及缓慢变化、促进泛化的成分。基于这一分析，我们仅需几行代码即可放大梯度中的慢速变化成分，从而将 Grokking 现象加速超过 50 倍。实验表明，我们的算法适用于图像、语言和图等多种任务，使得这种突然泛化的奇特现象具有实际应用价值。\n\n![fig2](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fironjr_grokfast_readme_f558e4134878.png) |  ![fig3](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fironjr_grokfast_readme_32edee01eec3.png)  |\n:----------------------------: | :----------------------------: |\n\n---\n\n## 使用方法\n\n### 安装\n\nGrokfast 除了 [PyTorch](https:\u002F\u002Fpytorch.org\u002Fget-started\u002Flocally\u002F) 外，无需其他额外依赖包。文件 `requirements.txt` 仅用于复现文章中的实验，具体说明见下文的 [复现部分](#reproduction)。\n\n### 指导说明\n\n只需在调用优化器之前插入一行代码，即可应用 Grokfast。\n\n1. 从我们的仓库下载单个文件 `grokfast.py`。\n```bash\nwget https:\u002F\u002Fraw.githubusercontent.com\u002Fironjr\u002Fgrokfast\u002Fmain\u002Fgrokfast.py\n```\n2. 导入辅助函数。\n```python\nfrom grokfast import gradfilter_ma, gradfilter_ema\n```\n3. 在训练循环 **之前** 插入以下一行。\n```python\ngrads = None\n```\n4. 在 `loss.backward()` 和 `optimizer.step()` 之间，插入以下其中一行。请确保 `model` 是 `nn.Module` 类型，并且在训练循环开始前已正确初始化 `grads`：\n```python\n# ... 在优化循环中。\nloss.backwards() # 计算梯度。\n\n### 选项 1：Grokfast（有参数 alpha 和 lamb）\ngrads = gradfilter_ema(model, grads=grads, alpha=alpha, lamb=lamb)\n### 选项 2：Grokfast-MA（有参数 window_size 和 lamb）\n# grads = gradfilter_ma(model, grads=grads, window_size=window_size, lamb=lamb)\n\noptimizer.step() # 调用优化器。\n# ... 日志记录及其他代码。\n```\n\n完成！\n\n\u003Cdetails>\n  \n\u003Csummary>(2-1) 或者，直接将方法复制粘贴到你的代码中！\u003C\u002Fsummary>\n\n```python\n### 导入\nfrom collections import deque\nfrom typing import Dict, Optional, Literal\nimport torch\nimport torch.nn as nn\n\n\n### Grokfast\ndef gradfilter_ema(\n    m: nn.Module,\n    grads: Optional[Dict[str, torch.Tensor]] = None,\n    alpha: float = 0.99,\n    lamb: float = 5.0,\n) -> Dict[str, torch.Tensor]:\n    if grads is None:\n        grads = {n: p.grad.data.detach() for n, p in m.named_parameters() if p.requires_grad}\n\n    for n, p in m.named_parameters():\n        if p.requires_grad:\n            grads[n] = grads[n] * alpha + p.grad.data.detach() * (1 - alpha)\n            p.grad.data = p.grad.data + grads[n] * lamb\n\n    return grads\n\n\n### Grokfast-MA\ndef gradfilter_ma(\n    m: nn.Module,\n    grads: Optional[Dict[str, deque]] = None,\n    window_size: int = 128,\n    lamb: float = 5.0,\n    filter_type: Literal['mean', 'sum'] = 'mean',\n    warmup: bool = True,\n    trigger: bool = False,\n) -> Dict[str, deque]:\n    if grads is None:\n        grads = {n: deque(maxlen=window_size) for n, p in m named parameters() if p requires grad}\n\n    for n, p in m named parameters():\n        if p requires grad:\n            grads[n].append(p.grad.data.detach())\n\n            if not warmup or len(grads[n]) == window_size and not trigger:\n                if filter_type == \"mean\":\n                    avg = sum(grads[n]) \u002F len(grads[n])\n                elif filter_type == \"sum\":\n                    avg = sum(grads[n])\n                else:\n                    raise ValueError(f\"Unrecognized filter_type {filter_type}\")\n                p.grad.data = p.grad.data + avg * lamb\n\n    return grads\n```\n\n\u003C\u002Fdetails>\n\n### 参数说明\n\n1. Grokfast (`gradfilter_ema`)\n\n    - `m: nn.Module`: 包含所有可训练参数的模型。\n    - `grads: Optional[Dict[str, torch.Tensor]] = None`: 运行时内存（EMA）。初始值设为 `None`。后续递归地传入该方法的输出。\n    - `alpha: float = 0.98`: EMA 的动量超参数。\n    - `lamb: float = 2.0`: 滤波器的放大因子超参数。\n\n2. Grokfast-MA (`gradfilter_ma`)\n\n    - `m: nn.Module`: 包含所有可训练参数的模型。\n    - `grads: Optional[Dict[str, deque]] = None`: 运行时内存（窗口移动平均队列）。初始值设为 `None`。后续递归地传入该方法的输出。\n    - `window_size: int = 100`: 滤波器窗口的宽度。额外的内存需求会随着窗口大小线性增加。\n    - `lamb: float = 5.0`: 滤波器的放大因子超参数。\n    - `filter_type: Literal['mean', 'sum'] = 'mean'`: 对运行队列的聚合方式。\n    - `warmup: bool = True`: 如果为真，则在队列填满之前不应用滤波器。\n    - `trigger: bool = False`: 仅用于消融实验。如果为真，则完全不应用滤波器。\n\n---\n\n## 复现\n\n我们还注意到每次运行所需的额外计算资源。时间和内存开销均使用单块 GTX 1080 Ti GPU 进行测量。\n\n### 安装\n\n这将安装用于预处理数据和汇总结果的附加包。\n\n```bash\nconda create -n grok python=3.10 && conda activate grok\ngit clone https:\u002F\u002Fgithub.com\u002Fironjr\u002Fgrokfast\npip install -r requirements.txt\n```\n\n### 算法性数据（Transformer 解码器，*Grokfast-MA*）\n\n| 运行 | 达到 95% 验证准确率的迭代次数 | 达到 95% 验证准确率的壁时（秒） | 显存需求（MB） | 每次迭代延迟（秒） |\n| :-: | :-------------------------------: | :------------------------------------: | :--------------------: | :-----------------------: |\n| 基线 | 39890 | 5984 | 290 | 0.15 |\n| Grokfast-MA | 790（$\\times$ 50.49 $\\downarrow$） | 292（$\\times$ 20.49 $\\downarrow$） | 458 | 0.37 |\n\n```bash\n# python main.py --label test # 基线。\npython main.py --label test --filter ma --window_size 100 --lamb 5.0 --weight_decay 0.01\n```\n\n### 算法性数据（Transformer 解码器，*Grokfast*）\n\n| 运行 | 达到 95% 验证准确率的迭代次数 | 达到 95% 验证准确率的壁时（秒） | 显存需求（MB） | 每次迭代延迟（秒） |\n| :-: | :-------------------------------: | :------------------------------------: | :--------------------: | :-----------------------: |\n| 基线 | 39890 | 5984 | $290 | 0.15 |\n| Grokfast | 910（$\\times$ 43.84 $\\downarrow$） | 137（$\\times$ 43.79 $\\downarrow$） | 294 | 0.15 |\n\n```bash\n# python main.py --label test # 基线。\npython main.py --label test --filter ema --alpha 0.98 --lamb 2.0 --weight_decay 0.005\n```\n\n### MNIST（MLP）\n\n| 运行 | 达到 95% 验证准确率的迭代次数 | 达到 95% 验证准确率的壁时（秒） | 显存需求（MB） | 每次迭代延迟（毫秒） |\n| :-: | :-------------------------------: | :------------------------------------: | :--------------------: | :------------------------: |\n| 基线 | 44022 | 1928 | 196 | 43.8 |\n| Grokfast | 2001（$\\times$ 22.00 $\\downarrow$） | 87.8（$\\times$ 21.96 $\\downarrow$） | 198 | 43.9 |\n\n```bash\n# python main_mnist.py --label test # 基线。\npython main_mnist.py --label test --alpha 0.8 --lamb 0.1 --weight_decay 2.0\n```\n\n### IMDb（LSTM）\n\n| 运行 | 最佳验证准确率 | 最小验证损失 | 显存需求（MB） | 每次迭代延迟（毫秒） |\n| :-: | :------------------: | :---------------------: | :--------------------: | :------------------------: |\n| 基线 | 0.84 | 0.517 | 754 | 20.4 |\n| Grokfast | 0.90 | 0.412 | 762 | 21.2 |\n\n- 在训练之前，请从 [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F11dNiqE5Y5tigaeyYP6JPV3xxa1MOu1L-\u002Fview?usp=sharing) 或 [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1kNDXlqPHxuDLtQWbdItwhw)（提取码：vdp7）下载 IMDb 数据集。\n\n```bash\n# python main_imdb.py --label test # 基线。\npython main_imdb.py --label test --alpha 0.98 --lamb 2.0 --weight_decay 10.0\n```\n\n### QM9（G-CNN）\n\n| 运行 | 最小验证损失 | 显存需求（MB） | 每次迭代延迟（毫秒） |\n| :-: | :---------------------: | :--------------------: | :------------------------: |\n| 基线 | 0.00659 | 216 | 40.2 |\n| Grokfast | 0.00348 | 216 | 41.4 |\n\n```bash\n# python main_qm9.py --label test # 基线。\npython main_qm9.py --label test --alpha 0.9 --lamb 1.0 --weight_decay 0.01\n```\n\n---\n\n## 常见问题解答\n\n### 如何选择合适的超参数\n\n这些建议基于我在主论文中展示的实验中的经验。它们可能并不适用于所有问题，也可能有更智能的方法能够取得更好的效果。因此，请将这些建议视为设计您自己的滤波器时的一种可能的起点指南。\n\n1. **截止参数**：本研究使用 MA\u002FEMA 滤波器来实现滤波技术。对于 MA 滤波器，截止频率由窗口大小决定；对于 EMA 滤波器，截止频率由动量参数决定。\n    1. **大致确定您希望达到的加速倍数。** 例如，在主论文中，截止参数是根据原始的 grokking 报告确定的，该报告表明泛化发生的速度比过拟合慢约 100 倍。因此，我们希望实现 N=100 倍的加速。\n    2. **设定截止参数搜索的基准值。** 对于 MA，我从窗口大小 w=N=100 开始；对于 EMA，我从满足 alpha^{N} = alpha^{100} = 0.1 的动量参数 alpha 开始（大约为 0.98）。\n    3. **在基准值附近进行超参数搜索。** 我围绕 (1.b) 中设定的值进行了超参数扫描。\n3. **权重衰减**：权重衰减通常在优化器构造函数中设置（例如，`optimizer = optim.Adam(m.parameters(), weight_decay=wd)`）。\n    1. **从该任务的默认权重衰减开始。** 例如，该任务中最常用的 GitHub 仓库所选择的值。\n    2. **固定权重衰减，首先尝试找到 Grokfast 滤波器参数（动量、窗口大小和幅度）的最佳设置。** 尽管权重衰减确实会影响最佳滤波器参数的取值，但根据我的经验，其影响似乎并不显著。\n    3. **逐步增加权重衰减的值。** 从 X1 开始，然后尝试 (X2, X5, X10)。我未能通过将权重衰减提高到默认值的 100 倍而获得更好的结果。\n\n\n## 致谢\n\n我们的代码大量借鉴了以下项目：\n- Ziming Liu 等人，“Omnigrok：超越算法性数据的 grokking”，ICLR 2023。[\\[arXiv\\]](https:\u002F\u002Farxiv.org\u002Fabs\u002F2210.01117) [\\[代码\\]](https:\u002F\u002Fgithub.com\u002FKindXiaoming\u002FOmnigrok)\n- Alethea Power 等人，“Grokking：在小型算法性数据集上超越过拟合的泛化”，arXiv 预印本 arXiv:2201.02177。[\\[arXiv\\]](https:\u002F\u002Farxiv.org\u002Fabs\u002F2201.02177) [\\[代码\\]](https:\u002F\u002Fgithub.com\u002Fopenai\u002Fgrok)\n- [@danielmamay](https:\u002F\u002Fgithub.com\u002Fdanielmamay) 对 Grokking 的重新实现。[\\[代码\\]](https:\u002F\u002Fgithub.com\u002Fdanielmamay\u002Fgrokking)\n\n感谢大家提供的有用参考！\n\n\n## 引用\n\n如果您觉得我们的项目有用，请引用我们！\n\n```latex\n@article{lee2024grokfast,\n    title={{Grokfast}: 加速 grokking 通过放大缓慢梯度},\n    author={Lee, Jaerin and Kang, Bong Gyun and Kim, Kihoon and Lee, Kyoung Mu},\n    journal={arXiv preprint arXiv:2405.20233},\n    year={2024}\n}\n```\n\n## 星标历史\n\n[![星标历史图](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fironjr_grokfast_readme_fc423342fc29.png)](https:\u002F\u002Fstar-history.com\u002F#ironjr\u002Fgrokfast&Date)\n\n## 联系方式\n\n如有任何问题，请发送邮件至 `jarin.lee@gmail.com`。","# Grokfast 快速上手指南\n\nGrokfast 是一个旨在加速机器学习中“顿悟”（Grokking）现象的优化器增强工具。它通过放大参数梯度中的低频分量（即缓慢变化但能诱导泛化的成分），显著缩短模型从过拟合到泛化的等待时间，适用于图像、语言和图结构等多种任务。\n\n## 环境准备\n\n*   **操作系统**: Linux, macOS, Windows\n*   **Python 版本**: 推荐 Python 3.8+ (实验复现环境为 Python 3.10)\n*   **核心依赖**:\n    *   [PyTorch](https:\u002F\u002Fpytorch.org\u002Fget-started\u002Flocally\u002F) (必须)\n    *   无需其他额外第三方库即可运行核心功能。\n\n> **国内加速建议**：\n> 安装 PyTorch 时，推荐使用清华或中科大镜像源以加快下载速度：\n> ```bash\n> pip install torch torchvision torchaudio --index-url https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n> ```\n\n## 安装步骤\n\nGrokfast 的核心功能仅需一个 Python 文件，无需通过 `pip` 安装包。\n\n1.  **下载核心脚本**\n    直接从 GitHub 仓库下载 `grokfast.py` 文件到你的项目目录：\n    ```bash\n    wget https:\u002F\u002Fraw.githubusercontent.com\u002Fironjr\u002Fgrokfast\u002Fmain\u002Fgrokfast.py\n    ```\n    *(如果无法访问 GitHub，可手动下载该文件并保存为 `grokfast.py`)*\n\n2.  **(可选) 安装复现实验依赖**\n    如果你需要运行官方提供的复现代码（包含数据预处理和结果汇总），请执行：\n    ```bash\n    git clone https:\u002F\u002Fgithub.com\u002Fironjr\u002Fgrokfast\n    cd grokfast\n    pip install -r requirements.txt\n    ```\n\n## 基本使用\n\n只需在现有的训练循环中插入几行代码，即可启用 Grokfast。\n\n### 1. 导入辅助函数\n在你的训练脚本中导入以下函数：\n```python\nfrom grokfast import gradfilter_ma, gradfilter_ema\n```\n\n### 2. 初始化状态变量\n在训练循环开始前，初始化梯度记忆变量：\n```python\ngrads = None\n```\n\n### 3. 修改训练循环\n在 `loss.backward()` 之后、`optimizer.step()` 之前，插入过滤函数。\n\n**方案 A：使用 Grokfast-EMA (指数移动平均，推荐用于大多数场景)**\n```python\n# ... 在优化循环中\nloss.backward()  # 计算梯度\n\n# 应用 Grokfast-EMA 过滤器\n# alpha: 动量超参数 (默认 0.98), lamb: 放大系数 (默认 2.0)\ngrads = gradfilter_ema(model, grads=grads, alpha=0.98, lamb=2.0)\n\noptimizer.step()  # 更新参数\n```\n\n**方案 B：使用 Grokfast-MA (滑动窗口平均)**\n```python\n# ... 在优化循环中\nloss.backward()  # 计算梯度\n\n# 应用 Grokfast-MA 过滤器\n# window_size: 窗口大小 (默认 100), lamb: 放大系数 (默认 5.0)\ngrads = gradfilter_ma(model, grads=grads, window_size=100, lamb=5.0)\n\noptimizer.step()  # 更新参数\n```\n\n### 参数调优建议\n*   **alpha (EMA)**: 控制截止频率。若希望加速倍数约为 $N$，可尝试设定 $\\alpha$ 使得 $\\alpha^N \\approx 0.1$（例如加速 100 倍，$\\alpha \\approx 0.98$）。\n*   **window_size (MA)**: 对应加速倍数的粗略估计值。\n*   **lamb**: 梯度放大系数，通常设置在 1.0 到 5.0 之间，需配合具体任务调整。\n*   **weight_decay**: 建议保留优化器中原有的权重衰减设置，先固定它再调整 Grokfast 参数。","某算法团队正在训练一个小型 Transformer 模型，试图让其在有限的算术运算数据集中掌握泛化规律，但模型陷入了典型的“顿悟（Grokking）”延迟困境。\n\n### 没有 grokfast 时\n- **训练周期极长**：模型在完美过拟合训练数据后，仍需额外运行数万次迭代才能突然实现泛化，严重消耗 GPU 算力资源。\n- **收敛时机难测**：由于泛化发生的时间点具有高度随机性和滞后性，工程师难以判断何时停止训练，容易过早放弃或无效空转。\n- **调试成本高昂**：漫长的等待过程拉长了实验反馈循环，导致超参数调整和架构验证的效率极低，阻碍研发进度。\n- **资源利用率低**：大部分计算时间浪费在梯度更新缓慢的“ plateau\"阶段，慢变分量（即指向泛化的信号）被噪声淹没，无法有效引导优化方向。\n\n### 使用 grokfast 后\n- **加速泛化出现**：通过放大梯度中的慢变分量，grokfast 将原本需要数万步的顿悟过程压缩了 50 倍以上，显著缩短训练时间。\n- **训练过程可控**：泛化现象在可预测的早期阶段稳定出现，团队能更精准地设定训练终止条件，避免资源浪费。\n- **研发效率飞跃**：实验迭代周期从“天”级缩短至“小时”级，研究人员能快速验证不同架构在复杂任务上的泛化潜力。\n- **信号提取增强**：即使在小批量或高噪声场景下，grokfast 也能有效分离并增强指向通用规律的梯度信号，让模型更快“开窍”。\n\ngrokfast 的核心价值在于将原本不可控的漫长“顿悟”等待，转化为高效、可预期的快速泛化过程，极大提升了模型训练的经济性与可行性。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fironjr_grokfast_47757e3d.gif","ironjr","Jaerin Lee","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fironjr_d4cef99b.jpg","Yet another AI toolmaker.","Seoul National University","Seoul, Korea","jarin.lee@gmail.com","_ironjr_","jaerinlee.com","https:\u002F\u002Fgithub.com\u002Fironjr",[83],{"name":84,"color":85,"percentage":86},"Python","#3572A5",100,579,50,"2026-04-02T16:32:21","MIT",1,"未说明","非必需（核心库仅依赖 PyTorch，可运行于 CPU）；复现实验测试环境为单张 GTX 1080 Ti，显存需求视任务而定：算法数据任务约 290-458MB，MNIST 约 196-198MB，IMDb 约 754-762MB，QM9 约 216MB。",{"notes":95,"python":96,"dependencies":97},"核心功能仅需安装 PyTorch，无需其他额外包。若要复现论文中的实验（包括数据预处理和结果汇总），需通过 conda 创建 Python 3.10 环境并安装 requirements.txt 中的依赖。部分实验（如 IMDb）需手动下载数据集。该工具通过在优化器调用前插入几行代码即可加速模型的'grokking'现象。","3.10 (复现实验环境指定版本)",[98],"torch",[14],[101,102,103,104,105],"deep-learning","grokking","machine-learning","optimization","signal-processing",null,"2026-03-27T02:49:30.150509","2026-04-08T02:01:16.389771",[110,115,120,125,130,134],{"id":111,"question_zh":112,"answer_zh":113,"source_url":114},23578,"为新模型和数据集选择 AdamW 权重衰减（weight decay）值的最佳策略是什么？","建议遵循以下经验法则：\n1. 从该任务的默认权重衰减值开始（例如该任务最广泛使用的 GitHub 仓库中选择的值）。\n2. 固定权重衰减，先寻找 Grokfast 滤波器参数（动量、窗口大小和幅度）的最佳设置。虽然权重衰减会影响最佳滤波器参数的值，但其影响通常不显著。\n3. 开始增加权重衰减值。从默认值的 1 倍开始，然后尝试 2 倍、5 倍、10 倍。根据经验，增加到默认值的 100 倍通常不会带来更好的结果。\n此外，Grokfast 添加了平滑梯度，倾向于稍微稳定训练，因此您可以将学习率提高到基线模型的 1.5 到 2.0 倍。","https:\u002F\u002Fgithub.com\u002Fironjr\u002Fgrokfast\u002Fissues\u002F1",{"id":116,"question_zh":117,"answer_zh":118,"source_url":119},23579,"Grokfast 是否仅适用于 Transformer 模型？","不，Grokfast 不仅限于 Transformer。论文中提到，处于 Grokking 现象下的 Transformers、MLPs 和 LSTMs 都可以受益于使用设计良好的低通滤波器的 Grokfast。\n但在 MLPs 和 LSTMs 上应用时，通常需要较高的权重范数正则化（weight norm regularization）才能获得收益。权重范数和低通滤波梯度的结合似乎能产生协同效应。如果未观察到效果，可能是因为滤波器设计在其他场景下并非最优，需要进一步调整。","https:\u002F\u002Fgithub.com\u002Fironjr\u002Fgrokfast\u002Fissues\u002F11",{"id":121,"question_zh":122,"answer_zh":123,"source_url":124},23580,"为什么在某些实验中 AdamW 的表现优于 Grokfast + Adam？","目前的代码和论文主要是概念验证（proof-of-concept），旨在证明如果在已知的 Grokking 场景中应用特定调制的梯度滤波器，可以加速 Grokking 现象。\n如果您发现 AdamW 表现更好，这通常意味着当前的滤波器参数（如移动平均的窗口大小、EMA 的 alpha 值和权重衰减等）对您所使用的特定任务过于敏感，尚未达到最优设计。实际应用中，需要针对具体任务进行更细致的滤波器参数调整或研究更好的滤波器设计，以获得比标准优化器更好的效果。","https:\u002F\u002Fgithub.com\u002Fironjr\u002Fgrokfast\u002Fissues\u002F12",{"id":126,"question_zh":127,"answer_zh":128,"source_url":129},23581,"使用 Grokfast 时遇到梯度爆炸（grad norm 变为 inf）该怎么办？","梯度爆炸通常是因为在特定的损失曲面下，添加高幅度的低频梯度导致了不稳定的大梯度更新。\n解决方案是降低学习率以补偿这种梯度爆炸。您可以将代码中的更新逻辑理解为：用（1）原始的、快速变化的较小批量梯度与（2）低频的、较慢变化的较大批量梯度之和来替换原始梯度。如果总和过大，通过按比例减小学习率可以有效缓解这一问题。","https:\u002F\u002Fgithub.com\u002Fironjr\u002Fgrokfast\u002Fissues\u002F9",{"id":131,"question_zh":132,"answer_zh":133,"source_url":114},23582,"Grokfast 对学习率的选择有什么建议？","通常情况下，可以坚持使用论文中每个任务默认的學習率（通常在 1e-3 到 1e-4 之间）。经验表明，Grokfast 增强型优化器和非 Grokfast 基线优化器的最大稳定学习率是相似的。\n不过，由于 Grokfast 添加了平滑梯度，往往能使训练更加稳定，因此您可以尝试将学习率提高到基线模型的 1.5 倍到 2.0 倍，这可能带来更好的性能。",{"id":135,"question_zh":136,"answer_zh":137,"source_url":114},23583,"Grokfast 滤波器参数（如窗口大小、alpha）应该如何调整？","调整策略应分步进行：首先固定权重衰减（weight decay），专注于寻找 Grokfast 滤波器参数（如动量 momentum、窗口大小 window size、幅度 amplitude 或 EMA 的 alpha）的最佳设置。\n这是因为虽然权重衰减会影响最佳滤波器参数的具体数值，但其影响程度通常不如滤波器参数本身对结果的直接影响大。在确定好滤波器参数后，再微调权重衰减值（例如尝试默认值的 1x, 2x, 5x, 10x）。",[]]