[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"tool-arcee-ai--DistillKit":3,"similar-arcee-ai--DistillKit":86},{"id":4,"github_repo":5,"name":6,"description_en":7,"description_zh":8,"ai_summary_zh":9,"readme_en":10,"readme_zh":11,"quickstart_zh":12,"use_case_zh":13,"hero_image_url":14,"owner_login":15,"owner_name":16,"owner_avatar_url":17,"owner_bio":18,"owner_company":19,"owner_location":19,"owner_email":20,"owner_twitter":19,"owner_website":19,"owner_url":21,"languages":22,"stars":27,"forks":28,"last_commit_at":29,"license":30,"difficulty_score":31,"env_os":32,"env_gpu":33,"env_ram":32,"env_deps":34,"category_tags":42,"github_topics":19,"view_count":45,"oss_zip_url":19,"oss_zip_packed_at":19,"status":46,"created_at":47,"updated_at":48,"faqs":49,"releases":85},6857,"arcee-ai\u002FDistillKit","DistillKit","An Open Source Toolkit For LLM Distillation","DistillKit 是一款专为大语言模型（LLM）知识蒸馏设计的开源工具包，旨在帮助开发者高效地将大型“教师”模型的能力迁移到更小、更快的“学生”模型中。它同时支持在线蒸馏（训练时实时调用教师模型）和离线蒸馏（基于预存数据训练）两种工作流。\n\n在大规模场景下，离线蒸馏面临巨大的存储挑战：直接保存数十亿 token 的概率分布数据成本极高。DistillKit 通过独特的先进对数概率压缩技术解决了这一难题。该技术结合多项式近似、误差扩散量化及位级打包策略，在大幅降低存储空间和内存占用的同时，完美保留了蒸馏质量，使得原本难以落地的超大规模离线蒸馏变得切实可行。\n\n此外，DistillKit 提供了灵活的损失函数组合（如 KL 散度、排名损失等），并深度集成 HuggingFace 生态（Transformers、TRL、Accelerate），开箱即用。该工具已历经实战检验，支撑了 Arcee 多个知名开源模型的训练。\n\nDistillKit 非常适合 AI 研究人员、算法工程师及希望优化模型推理成本的开发者使用。无论是想要复现前沿蒸馏成果，还是需要在有限资源下定制轻量级模型，它都能提供","DistillKit 是一款专为大语言模型（LLM）知识蒸馏设计的开源工具包，旨在帮助开发者高效地将大型“教师”模型的能力迁移到更小、更快的“学生”模型中。它同时支持在线蒸馏（训练时实时调用教师模型）和离线蒸馏（基于预存数据训练）两种工作流。\n\n在大规模场景下，离线蒸馏面临巨大的存储挑战：直接保存数十亿 token 的概率分布数据成本极高。DistillKit 通过独特的先进对数概率压缩技术解决了这一难题。该技术结合多项式近似、误差扩散量化及位级打包策略，在大幅降低存储空间和内存占用的同时，完美保留了蒸馏质量，使得原本难以落地的超大规模离线蒸馏变得切实可行。\n\n此外，DistillKit 提供了灵活的损失函数组合（如 KL 散度、排名损失等），并深度集成 HuggingFace 生态（Transformers、TRL、Accelerate），开箱即用。该工具已历经实战检验，支撑了 Arcee 多个知名开源模型的训练。\n\nDistillKit 非常适合 AI 研究人员、算法工程师及希望优化模型推理成本的开发者使用。无论是想要复现前沿蒸馏成果，还是需要在有限资源下定制轻量级模型，它都能提供生产级的稳定支持。","# DistillKit\n\nA flexible and production-ready toolkit for knowledge distillation of large language models, supporting both online and offline distillation workflows with advanced logit compression.\n\nDistillKit powers the training of many of Arcee's popular open-source models, including [Virtuoso](https:\u002F\u002Fhuggingface.co\u002Farcee-ai\u002FVirtuoso-Large), [SuperNova Medius](https:\u002F\u002Fhuggingface.co\u002Farcee-ai\u002FSuperNova-Medius), and [Blitz](https:\u002F\u002Fhuggingface.co\u002Farcee-ai\u002FArcee-Blitz).\n\n## Features\n\n- **Online Distillation**: Real-time teacher inference during student training\n- **Offline Distillation**: Train from pre-captured teacher outputs with advanced compression\n- **Advanced Logit Compression**: Novel polynomial approximation + quantization + bit-packing achieving vigorous compression ratios while preserving distillation quality\n- **Flexible Loss Functions**: Composable losses including KL divergence, JSD, TVD, ranking losses, and hidden state alignment\n- **Sparse & Dense Support**: Efficient sparse distributions (top-k) or exact dense distributions\n- **Battle-tested**: The infrastructure powering Arcee's distilled model releases\n- **HuggingFace Integration**: Built on Transformers, TRL, and Accelerate\n\n## Why DistillKit?\n\nWhile online distillation is straightforward, **offline distillation at scale** requires careful engineering. Simply storing top-k token-logit pairs becomes prohibitively expensive when distilling on billions of tokens.\n\nDistillKit's compression system is the result of months of experimentation to strike the delicate balance between storage costs, memory throughput, and distillation quality. Our approach:\n\n1. **Polynomial approximation** of the logit distribution curve\n2. **Error-diffusion quantization** of residuals to preserve quality\n3. **Bit-level packing** with arbitrary bit widths (1-64 bits)\n\nThis enables practical offline distillation workflows that would otherwise be infeasible.\n\n## Installation\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Farcee-ai\u002Fdistillkit.git\ncd distillkit\npip install -e .\n```\n\n### Optional: Logit Capture\n\nTo capture your own teacher outputs, install the capture dependencies:\n\n```bash\npip install -e \".[capture]\"\n```\n\nFor most users, we recommend starting with the pre-captured teacher datasets we provide (see [Datasets](#datasets) below).\n\n## Quick Start\n\n### Offline Distillation\n\nTrain a student model using pre-captured teacher outputs:\n\n```yaml\n# config.yaml\nproject_name: my-distillation\nmodel: Qwen\u002FQwen3-8B\noutput_path: .\u002Foutput\nsequence_length: 8192\n\ndataset:\n  train_dataset:\n    repo_id: arcee-ai\u002FQwen3-235B-Logits-Packed-8192  # Pre-captured teacher outputs\n    split: train\n  prepacked: true\n\nteacher:\n  kind: dataset\n  logprob_compressor:\n    d: 151936  # Vocabulary size\n    delta_encoding: true\n    error_diffusion: false\n    exact_dtype: float32\n    exact_k: 32\n    k: 128\n    polynomial_terms: [0, 1, 2]\n    residual_bins: []\n    term_dtype: float32\n\nloss_functions:\n  - function: cross_entropy\n    weight: 0.5\n  - function: kl\n    weight: 0.5\n    temperature: 1.0\n    missing_probability_handling: zero\n    sparse_chunk_length: 1024\n\ntraining_args:\n  num_train_epochs: 1\n  per_device_train_batch_size: 1\n  gradient_accumulation_steps: 8\n  learning_rate: 2.0e-6\n  bf16: true\n  optim: adamw_torch\n  gradient_checkpointing: true\n```\n\nRun training:\n\n```bash\ndistillkit config.yaml\n```\n\n### Online Distillation\n\nFor online distillation where the teacher runs alongside student training, see [`examples\u002Fafm_test.yml`](examples\u002Fafm_test.yml) for a complete configuration example.\n\n## Core Concepts\n\n### Knowledge Distillation for LLMs\n\nKnowledge distillation transfers knowledge from a (potentially larger) \"teacher\" model to a \"student\" model. Instead of training only on hard labels (the correct token), the student learns from the teacher's probability distribution over tokens, which is a much richer learning signal.\n\n**Key benefits:**\n- Smaller, faster models with competitive performance\n- Lower inference costs\n- Easier deployment in resource-constrained environments\n\n### Online vs Offline Distillation\n\n**Online Distillation:**\n- Teacher runs in real-time during student training\n- No storage overhead\n- Best when: You have sufficient VRAM for both models and dense distributions\n\n**Offline Distillation:**\n- Teacher outputs pre-captured and compressed\n- Enables training multiple students from the same teacher\n- Best when: VRAM-limited, reusing teacher signals, or training at large scale\n\n**Rule of thumb:** If you can fit both teacher and student with dense distributions into VRAM, use online distillation. Otherwise, offline distillation with our compression system is the way to go.\n\n### Sparse vs Dense Distributions\n\n**Dense distributions** include probabilities for the full vocabulary. This is more accurate but memory-intensive.\n\n**Sparse distributions** store only the top-k tokens and serve as a lossy, but useful and efficient, approximation of the full dense distribution. With sufficient training data, sparse distillation can achieve equivalent performance to dense.\n\nDistillKit supports both, with automatic chunking for memory-efficient processing of long sequences.\n\n### Logit Compression\n\nOur compression system balances storage efficiency with distillation quality:\n\n1. Select top-k logits from teacher output\n2. Sort by log-probability, optionally apply delta encoding\n3. Fit polynomial to the distribution curve\n4. Quantize residuals, with optional error diffusion\n5. Bitpack everything into byte vectors\n\nThere are lots of knobs you can twiddle here to reach a storage\u002Ffidelity tradeoff that works for your particular needs.\n\n**Recommended configuration** (used at Arcee for new captures):\n```yaml\nlogprob_compressor:\n  d: \u003Cyour_vocab_size_here>\n  k: 128\n  exact_k: 16\n  exact_dtype: bfloat16\n  polynomial_terms: [0, 1, 2, 3, 4, \"sqrt\"]\n  term_dtype: float32\n  residual_bins: []\n  delta_encoding: false\n  error_diffusion: false\n```\n\nThis takes ~300 bytes\u002Ftoken (0.15% of uncompressed distribution size) with minimal quality loss.\n\nIf you're a little tight on storage, try the **budget pick**:\n```yaml\nlogprob_compressor:\n  d: \u003Cyour_vocab_size_here>\n  k: 50\n  exact_k: 1\n  exact_dtype: bfloat16\n  polynomial_terms: [0, 1, \"sqrt\"]\n  term_dtype: float32\n  residual_bins: []\n  delta_encoding: false\n  error_diffusion: false\n```\n\nThis weighs in at around 114 bytes per token, smaller and with better reconstruction quality than storing the top 32 logprobs in bf16.\n\nNote that the configuration that was used to capture the logits must be reflected in the distillation configuration. Mixing and matching isn't gonna work out so hot.\n\n## Configuration Guide\n\n### Loss Functions\n\nDistillKit supports composable loss functions with independent weights:\n\n#### Distribution-Based Losses\n- `kl`: Kullback-Leibler divergence (standard distillation loss)\n- `jsd`: Jensen-Shannon divergence (symmetric alternative to KL)\n- `tvd`: Total Variation Distance\n\n#### Ranking Losses\n- `hinge`: Hinge ranking loss\n- `logistic_ranking`: Logistic ranking loss\n\n#### Hidden State Alignment\n- `hs_mse`: Mean squared error between teacher and student hidden states\n- `hs_cosine`: Cosine similarity between hidden states\n\n#### Standard\n- `cross_entropy`: Standard language modeling loss\n\nAll distribution losses support both sparse and dense modes. Combine multiple losses:\n\n```yaml\nloss_functions:\n  - function: cross_entropy\n    weight: 0.25\n  - function: kl\n    weight: 0.5\n    temperature: 2.0\n  - function: hs_cosine\n    weight: 0.25\n```\n\n### Teacher Configuration\n\n**Offline (from dataset):**\n```yaml\nteacher:\n  kind: dataset\n  logprob_compressor:\n    d: 128256\n    k: 128\n    exact_k: 16\n    delta_encoding: true\n    ...\n  # or:\n  legacy_logit_compression:\n    vocab_size: 128256\n    k: 128\n    exact_k: 32\n    polynomial_degree: 8\n    ...\n```\n\n**Online (HuggingFace model):**\n```yaml\nteacher:\n  kind: hf\n  path: Qwen\u002FQwen3-8B\n  kwargs: # keyword arguments passed when loading teacher model\n    attn_implementation: flash_attention_2\n    torch_dtype: bfloat16\n```\n\n## Advanced Topics\n\n\n### Compression Deep-Dive\n\nThe compression system supports two modes:\n\n**Legacy compression** (fully polynomial-based):\n```yaml\nlegacy_logit_compression:\n  vocab_size: 128256       # Size of teacher vocabulary\n  k: 128                   # Total number of logprobs per token, exact plus approximated\n  exact_k: 32              # Number of logprobs stored as floating point values\n  polynomial_degree: 8     # Degree of approximating polynomial\n  with_sqrt_term: false    # Include sqrt term in polynomial\n  term_dtype: float32      # Precision for polynomial coefficients\n  invert_polynomial: true  # Invert for better numerical properties\n```\n\n**Distribution quantization** (newer, more flexible):\n```yaml\nlogprob_compressor:\n  d: 128256                # Size of teacher vocabulary\n  k: 128                   # Total number of logprobs per token, exact plus approximated\n  exact_k: 16              # Number of logprobs stored as floating point values\n  exact_dtype: bfloat16    # dtype for \"exact\" logprobs\n  delta_encoding: false    # Store logprobs as deltas (not recommended)\n  error_diffusion: false   # Perform error diffusion to spread quantization error across values (not recommended)\n  polynomial_terms:        # List of polynomial terms used for approximating tail\n    - 0\n    - 1\n    - 2\n    - \"sqrt\"\n  term_dtype: float32      # dtype for storage of polynomial coefficients\n  residual_bins:           # Optional list of bins storing quantized residuals vs. the approximated tail\n    - scale_dtype: float16 # dtype for scale factor for this bin\n      element_bits: 8      # Bits\u002Felement\n      num_elements: 16     # Total number of elements in this bin\n    - scale_dtype: float32 # bfloat16 also works\n      element_bits: 2      # Can use any number of bits \u003C= 64\n      num_elements: 64\n    ...\n```\n\n### Hidden State Distillation\n\nAlign student hidden states with teacher hidden states:\n\n```yaml\nlayer_mapping: all  # Or specify layer pairs\nloss_functions:\n  - function: hs_mse\n    weight: 0.5\n```\n\nFor cross-architecture distillation, hidden states are projected using learned linear mappings. You can also enable this for same-architecture distillations by setting `force_hidden_state_projection: true`.\n\n### Capturing Teacher Outputs\n\nTo create your own offline distillation dataset:\n\n```bash\npython -m distillkit.sample_logits_vllm \\\n  --model meta-llama\u002FLlama-3.1-70B \\\n  --dataset allenai\u002Ftulu-3-sft-mixture \\\n  --output .\u002Fllama3_70b_tulu_logits\u002F \\\n  --compression-config .\u002Fcompression_config.yaml\n```\n\nRequires vLLM (see [Installation](#optional-logit-capture)).\n\n### Memory Management Tips\n\n**For long sequences:**\n- Use `sparse_chunk_length` to process sequences in chunks (e.g., `1024`)\n- Use DeepSpeed ZeRO Stage 1 or 2 to cram more tokens in there\n\n**For general savings:**\n- Use `optim: paged_adamw_8bit` or `optim: adamw_bnb_8bit`\n- Enable Flash Attention 2: `use_flash_attention: true`\n- Use bfloat16 instead of float32\n- Enable `gradient_checkpointing`\n- Reduce batch size, increase gradient accumulation\n\n## Examples\n\n- **Offline Distillation (70B → 8B)**: [`examples\u002Fllama_70b_base.yml`](examples\u002Fllama_70b_base.yml)\n- **Online Distillation with Hidden States**: [`examples\u002Fafm_test.yml`](examples\u002Fafm_test.yml)\n- **Multimodal Model Distillation**: [`examples\u002Fmistral3.yaml`](examples\u002Fmistral3.yaml)\n\n## Datasets\n\nWe're releasing several pre-captured teacher datasets:\n\n* [Qwen3-235B instruction-following](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Farcee-ai\u002FQwen3-235B-Logits-Packed-8192): ~1.5 billion tokens of general instruct data at 8192 context length\n* [DeepSeek V3\u002FR1 synthetic mixed-mode reasoning](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Farcee-ai\u002FDeepSeek-MixedModeReasoning-Logits-Packed-16384): ~5 billion tokens captured from DeepSeek V3 and R1, with prefixes to distinguish reasoning from non-reasoning traces - 16k context length\n* [DeepSeek V3 base](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Farcee-ai\u002FDeepSeek-DCLM-Logits-Packed-8192): ~1.2 billion tokens of raw completion data from DCLM captured from the DeepSeek V3 base model\n\n## Cross-Architecture Distillation\n\nDistillKit can be used together with [mergekit-tokensurgeon](https:\u002F\u002Fgithub.com\u002Farcee-ai\u002Fmergekit\u002Fblob\u002Fmain\u002Fdocs\u002Ftokensurgeon.md) for cross-tokenizer, cross-architecture distillation. Many Arcee models combine both tools:\n\n1. Use tokensurgeon to adapt student embeddings to teacher's tokenizer\n2. Use DistillKit to distill teacher knowledge to student\n3. Optionally convert back to student's original tokenizer, maybe do some other weird merges, follow your dreams\n\n## Training Tips\n\n- **Start with ~0.5 cross-entropy weight**, then tune up or down depending on how high quality your dataset is\n- **Distillation temperature**: `temperature: 2.0` is a good first choice\n- **Missing probability handling**: Use `zero` to focus only on the teacher's most confident predictions; use `uniform` to match the teacher's uncertainty as well\n\n## Citation\n\nIf you use DistillKit in your research, please cite:\n\n```bibtex\n@software{distillkit2024,\n  title = {DistillKit: Flexible Knowledge Distillation for Large Language Models},\n  author = {Goddard, Charles and Atkins, Lucas},\n  year = {2024},\n  publisher = {Arcee AI},\n  url = {https:\u002F\u002Fgithub.com\u002Farcee-ai\u002Fdistillkit}\n}\n```\n\n## Community & Support\n\n- **Issues**: [GitHub Issues](https:\u002F\u002Fgithub.com\u002Farcee-ai\u002Fdistillkit\u002Fissues)\n- **Discussions**: [Arcee Discord](https:\u002F\u002Fdiscord.gg\u002Farceeai)\n\nNote: DistillKit is an open-source research release. While it powers several of our production models and we'll happily address issues as bandwidth allows, community support is best-effort.\n\n## License\n\nDistillKit is released under the Apache License 2.0.\n\n### Acknowledgments\n\n- Flash Attention packing implementation adapted from [Functionary](https:\u002F\u002Fgithub.com\u002FMeetKai\u002Ffunctionary) (MIT License)\n- Built on [HuggingFace Transformers](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftransformers), [TRL](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftrl), and [Accelerate](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Faccelerate)\n\n---\n\n**Built with ♥ by [Arcee AI](https:\u002F\u002Fwww.arcee.ai)**\n","# DistillKit\n\n一个灵活且生产就绪的大语言模型知识蒸馏工具包，支持在线和离线蒸馏工作流，并配备先进的 logits 压缩技术。\n\nDistillKit 为 Arcee 的多款热门开源模型的训练提供了强大支持，包括 [Virtuoso](https:\u002F\u002Fhuggingface.co\u002Farcee-ai\u002FVirtuoso-Large)、[SuperNova Medius](https:\u002F\u002Fhuggingface.co\u002Farcee-ai\u002FSuperNova-Medius) 和 [Blitz](https:\u002F\u002Fhuggingface.co\u002Farcee-ai\u002FArcee-Blitz)。\n\n## 特性\n\n- **在线蒸馏**：学生模型训练过程中实时进行教师推理\n- **离线蒸馏**：基于预先捕获的教师输出进行训练，并采用高级压缩技术\n- **先进的 Logits 压缩**：创新的多项式近似 + 量化 + 位打包技术，在保持蒸馏质量的同时实现极高的压缩比\n- **灵活的损失函数**：可组合的损失函数，包括 KL 散度、JSD、TVD、排序损失以及隐藏状态对齐等\n- **稀疏与稠密支持**：高效处理 top-k 稀疏分布或精确的稠密分布\n- **经过实战检验**：支撑 Arcee 蒸馏模型发布的基础设施\n- **HuggingFace 集成**：基于 Transformers、TRL 和 Accelerate 构建\n\n## 为什么选择 DistillKit？\n\n虽然在线蒸馏相对简单，但**大规模的离线蒸馏**需要精心设计。当在数十亿个 token 上进行蒸馏时，仅存储 top-k 的 token-logits 对就会变得极其昂贵。\n\nDistillKit 的压缩系统是数月实验的结果，旨在平衡存储成本、内存吞吐量和蒸馏质量之间的微妙关系。我们的方法如下：\n\n1. 对 logits 分布曲线进行**多项式近似**\n2. 对残差进行**误差扩散量化**以保持质量\n3. 使用任意位宽（1-64 位）进行**位级打包**\n\n这使得原本不可行的离线蒸馏工作流程得以实际运行。\n\n## 安装\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Farcee-ai\u002Fdistillkit.git\ncd distillkit\npip install -e .\n```\n\n### 可选：Logits 捕获\n\n要捕获您自己的教师输出，请安装捕获依赖项：\n\n```bash\npip install -e \".[capture]\"\n```\n\n对于大多数用户，我们建议从我们提供的预捕获教师数据集开始（见下文的 [数据集](#datasets)）。\n\n## 快速入门\n\n### 离线蒸馏\n\n使用预捕获的教师输出训练学生模型：\n\n```yaml\n# config.yaml\nproject_name: my-distillation\nmodel: Qwen\u002FQwen3-8B\noutput_path: .\u002Foutput\nsequence_length: 8192\n\ndataset:\n  train_dataset:\n    repo_id: arcee-ai\u002FQwen3-235B-Logits-Packed-8192  # 预捕获的教师输出\n    split: train\n  prepacked: true\n\nteacher:\n  kind: dataset\n  logprob_compressor:\n    d: 151936  # 词汇表大小\n    delta_encoding: true\n    error_diffusion: false\n    exact_dtype: float32\n    exact_k: 32\n    k: 128\n    polynomial_terms: [0, 1, 2]\n    residual_bins: []\n    term_dtype: float32\n\nloss_functions:\n  - function: cross_entropy\n    weight: 0.5\n  - function: kl\n    weight: 0.5\n    temperature: 1.0\n    missing_probability_handling: zero\n    sparse_chunk_length: 1024\n\ntraining_args:\n  num_train_epochs: 1\n  per_device_train_batch_size: 1\n  gradient_accumulation_steps: 8\n  learning_rate: 2.0e-6\n  bf16: true\n  optim: adamw_torch\n  gradient_checkpointing: true\n```\n\n运行训练：\n\n```bash\ndistillkit config.yaml\n```\n\n### 在线蒸馏\n\n对于教师在学生训练过程中实时运行的在线蒸馏，完整的配置示例请参阅 [`examples\u002Fafm_test.yml`](examples\u002Fafm_test.yml)。\n\n## 核心概念\n\n### 大语言模型的知识蒸馏\n\n知识蒸馏是将知识从一个（可能更大的）“教师”模型转移到“学生”模型的过程。与仅基于硬标签（正确 token）进行训练不同，学生模型会学习教师对各个 token 的概率分布，这是一种更为丰富的学习信号。\n\n**主要优势：**\n- 更小、更快的模型，同时保持竞争力能\n- 更低的推理成本\n- 更易于在资源受限的环境中部署\n\n### 在线与离线蒸馏的区别\n\n**在线蒸馏：**\n- 教师在学生训练过程中实时运行\n- 无存储开销\n- 适用场景：当您的显存足以同时容纳教师和学生模型，并且可以处理稠密分布时\n\n**离线蒸馏：**\n- 教师输出被预先捕获并压缩\n- 可以用同一个教师模型训练多个学生模型\n- 适用场景：显存有限、需要重复利用教师信号，或者进行大规模训练时\n\n**经验法则：** 如果您能够在显存中同时容纳教师和学生的稠密分布，则使用在线蒸馏；否则，使用我们的压缩系统进行离线蒸馏是更好的选择。\n\n### 稀疏与稠密分布\n\n**稠密分布**包含整个词汇表的概率。这种方式更准确，但占用大量内存。\n\n**稀疏分布**只存储 top-k 的 token，是对完整稠密分布的一种有损但实用且高效的近似。在充足的训练数据下，稀疏蒸馏可以达到与稠密蒸馏相当的效果。\n\nDistillKit 同时支持这两种方式，并通过自动分块实现长序列的高效处理。\n\n### Logits 压缩\n\n我们的压缩系统在存储效率和蒸馏质量之间取得了平衡：\n\n1. 从教师输出中选择 top-k logits\n2. 按对数概率排序，可选应用差分编码\n3. 对分布曲线进行多项式拟合\n4. 对残差进行量化，可选误差扩散\n5. 将所有内容打包成字节向量\n\n您可以调整许多参数，以找到适合您特定需求的存储与保真度之间的权衡。\n\n**推荐配置**（Arcee 新捕获时使用的配置）：\n```yaml\nlogprob_compressor:\n  d: \u003Cyour_vocab_size_here>\n  k: 128\n  exact_k: 16\n  exact_dtype: bfloat16\n  polynomial_terms: [0, 1, 2, 3, 4, \"sqrt\"]\n  term_dtype: float32\n  residual_bins: []\n  delta_encoding: false\n  error_diffusion: false\n```\n\n这种配置每 token 占用约 300 字节（未压缩分布大小的 0.15%），且质量损失极小。\n\n如果您对存储空间较为紧张，可以尝试以下**经济型配置**：\n```yaml\nlogprob_compressor:\n  d: \u003Cyour_vocab_size_here>\n  k: 50\n  exact_k: 1\n  exact_dtype: bfloat16\n  polynomial_terms: [0, 1, \"sqrt\"]\n  term_dtype: float32\n  residual_bins: []\n  delta_encoding: false\n  error_diffusion: false\n```\n\n该配置每 token 仅需约 114 字节，体积更小，且重建质量优于直接以 bfloat16 存储 top-32 logits。\n\n请注意，用于捕获 logits 的配置必须与蒸馏配置保持一致。混合使用可能会导致效果不佳。\n\n## 配置指南\n\n### 损失函数\n\nDistillKit 支持可组合的损失函数，并为每个损失函数分配独立的权重：\n\n#### 基于分布的损失\n- `kl`：Kullback-Leibler 散度（标准蒸馏损失）\n- `jsd`：Jensen-Shannon 散度（KL 的对称替代方案）\n- `tvd`：总变差距离\n\n#### 排序损失\n- `hinge`：Hinge 排序损失\n- `logistic_ranking`：Logistic 排序损失\n\n#### 隐藏状态对齐\n- `hs_mse`：教师模型与学生模型隐藏状态之间的均方误差\n- `hs_cosine`：隐藏状态之间的余弦相似度\n\n#### 标准损失\n- `cross_entropy`：标准语言建模损失\n\n所有基于分布的损失都支持稀疏和密集两种模式。可以组合使用多种损失函数：\n\n```yaml\nloss_functions:\n  - function: cross_entropy\n    weight: 0.25\n  - function: kl\n    weight: 0.5\n    temperature: 2.0\n  - function: hs_cosine\n    weight: 0.25\n```\n\n### 教师模型配置\n\n**离线（从数据集获取）：**\n```yaml\nteacher:\n  kind: dataset\n  logprob_compressor:\n    d: 128256\n    k: 128\n    exact_k: 16\n    delta_encoding: true\n    ...\n  # 或：\n  legacy_logit_compression:\n    vocab_size: 128256\n    k: 128\n    exact_k: 32\n    polynomial_degree: 8\n    ...\n```\n\n**在线（HuggingFace 模型）：**\n```yaml\nteacher:\n  kind: hf\n  path: Qwen\u002FQwen3-8B\n  kwargs: # 加载教师模型时传递的关键字参数\n    attn_implementation: flash_attention_2\n    torch_dtype: bfloat16\n```\n\n## 高级主题\n\n\n### 压缩深度解析\n\n压缩系统支持两种模式：\n\n**传统压缩**（完全基于多项式）：\n```yaml\nlegacy_logit_compression:\n  vocab_size: 128256       # 教师词汇表大小\n  k: 128                   # 每个 token 的总对数概率数，精确值加近似值\n  exact_k: 32              # 以浮点数存储的对数概率数量\n  polynomial_degree: 8     # 近似多项式的次数\n  with_sqrt_term: false    # 在多项式中包含平方根项\n  term_dtype: float32      # 多项式系数的精度\n  invert_polynomial: true  # 为改善数值特性而反转多项式\n```\n\n**分布量化**（较新、更灵活）：\n```yaml\nlogprob_compressor:\n  d: 128256                # 教师词汇表大小\n  k: 128                   # 每个 token 的总对数概率数，精确值加近似值\n  exact_k: 16              # 以浮点数存储的对数概率数量\n  exact_dtype: bfloat16    # “精确”对数概率的数据类型\n  delta_encoding: false    # 以差值形式存储对数概率（不推荐）\n  error_diffusion: false   # 执行误差扩散以将量化误差分散到各个值上（不推荐）\n  polynomial_terms:        # 用于近似尾部的多项式项列表\n    - 0\n    - 1\n    - 2\n    - “sqrt”\n  term_dtype: float32      # 存储多项式系数的数据类型\n  residual_bins:           # 可选的存储量化残差与近似尾部之差的桶列表\n    - scale_dtype: float16 # 此桶的比例因子数据类型\n      element_bits: 8      # 每个元素的位数\n      num_elements: 16     # 此桶中的元素总数\n    - scale_dtype: float32 # bfloat16 也可用\n      element_bits: 2      # 可以使用最多 64 位\n      num_elements: 64\n    ...\n```\n\n### 隐藏状态蒸馏\n\n将学生模型的隐藏状态与教师模型的隐藏状态对齐：\n\n```yaml\nlayer_mapping: all  # 或指定层对\nloss_functions:\n  - function: hs_mse\n    weight: 0.5\n```\n\n对于跨架构蒸馏，隐藏状态会通过学习得到的线性映射进行投影。你也可以通过设置 `force_hidden_state_projection: true` 来为同架构蒸馏启用此功能。\n\n### 捕获教师输出\n\n要创建自己的离线蒸馏数据集：\n\n```bash\npython -m distillkit.sample_logits_vllm \\\n  --model meta-llama\u002FLlama-3.1-70B \\\n  --dataset allenai\u002Ftulu-3-sft-mixture \\\n  --output .\u002Fllama3_70b_tulu_logits\u002F \\\n  --compression-config .\u002Fcompression_config.yaml\n```\n\n需要 vLLM（参见【可选对数概率捕获】）。\n\n### 内存管理技巧\n\n**对于长序列：**\n- 使用 `sparse_chunk_length` 将序列分块处理（例如 `1024`）\n- 使用 DeepSpeed ZeRO 第 1 或第 2 阶段来容纳更多 token\n\n**一般节省内存的方法：**\n- 使用 `optim: paged_adamw_8bit` 或 `optim: adamw_bnb_8bit`\n- 启用 Flash Attention 2：`use_flash_attention: true`\n- 使用 bfloat16 而不是 float32\n- 启用 `gradient_checkpointing`\n- 减小批量大小，增加梯度累积步数\n\n## 示例\n\n- **离线蒸馏（70B → 8B）**：[`examples\u002Fllama_70b_base.yml`](examples\u002Fllama_70b_base.yml)\n- **带隐藏状态的在线蒸馏**：[`examples\u002Fafm_test.yml`](examples\u002Fafm_test.yml)\n- **多模态模型蒸馏**：[`examples\u002Fmistral3.yaml`](examples\u002Fmistral3.yaml)\n\n## 数据集\n\n我们发布了多个预先捕获的教师数据集：\n\n* [Qwen3-235B 指令遵循数据集](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Farcee-ai\u002FQwen3-235B-Logits-Packed-8192)：约 15 亿 tokens 的通用指令数据，上下文长度为 8192\n* [DeepSeek V3\u002FR1 合成混合模式推理数据集](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Farcee-ai\u002FDeepSeek-MixedModeReasoning-Logits-Packed-16384)：约 50 亿 tokens，来自 DeepSeek V3 和 R1，带有前缀以区分推理与非推理轨迹，上下文长度为 16k\n* [DeepSeek V3 基础模型数据集](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Farcee-ai\u002FDeepSeek-DCLM-Logits-Packed-8192)：约 12 亿 tokens 的原始完成数据，来自 DCLM，由 DeepSeek V3 基础模型捕获\n\n## 跨架构蒸馏\n\nDistillKit 可以与 [mergekit-tokensurgeon](https:\u002F\u002Fgithub.com\u002Farcee-ai\u002Fmergekit\u002Fblob\u002Fmain\u002Fdocs\u002Ftokensurgeon.md) 结合使用，实现跨分词器、跨架构的蒸馏。许多 Arcee 模型同时结合了这两种工具：\n\n1. 使用 tokensurgeon 将学生模型的嵌入适配到教师模型的分词器\n2. 使用 DistillKit 将教师的知识蒸馏到学生模型\n3. 可选地再转换回学生模型原有的分词器，甚至进行其他奇特的合并操作，随心所欲\n\n## 训练提示\n\n- **从 ~0.5 的交叉熵权重开始**，然后根据数据集的质量调整权重\n- **蒸馏温度**：`temperature: 2.0` 是一个不错的初始选择\n- **缺失概率处理**：使用 `zero` 只关注教师最自信的预测；使用 `uniform` 则同时匹配教师的不确定性\n\n## 引用\n\n如果你在研究中使用了 DistillKit，请引用以下内容：\n\n```bibtex\n@software{distillkit2024,\n  title = {DistillKit：大型语言模型的灵活知识蒸馏},\n  author = {Goddard, Charles 和 Atkins, Lucas},\n  year = {2024},\n  publisher = {Arcee AI},\n  url = {https:\u002F\u002Fgithub.com\u002Farcee-ai\u002Fdistillkit}\n}\n```\n\n## 社区与支持\n\n- **问题反馈**: [GitHub Issues](https:\u002F\u002Fgithub.com\u002Farcee-ai\u002Fdistillkit\u002Fissues)\n- **讨论交流**: [Arcee Discord](https:\u002F\u002Fdiscord.gg\u002Farceeai)\n\n注意：DistillKit 是一个开源研究项目。虽然它为我们的多款生产级模型提供了支持，并且在资源允许的情况下我们会尽力解决遇到的问题，但社区支持属于尽力而为的范畴。\n\n## 许可证\n\nDistillKit 采用 Apache License 2.0 许可证发布。\n\n### 致谢\n\n- Flash Attention 的打包实现改编自 [Functionary](https:\u002F\u002Fgithub.com\u002FMeetKai\u002Ffunctionary)（MIT 许可证）\n- 基于 [HuggingFace Transformers](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftransformers)、[TRL](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftrl) 和 [Accelerate](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Faccelerate) 构建\n\n---\n\n**由 [Arcee AI](https:\u002F\u002Fwww.arcee.ai) 竭诚打造**","# DistillKit 快速上手指南\n\nDistillKit 是一个灵活且生产就绪的大语言模型（LLM）知识蒸馏工具包，支持在线和离线蒸馏工作流，并具备先进的 Logit 压缩技术。它已被用于训练 Arcee 的多个开源模型（如 Virtuoso、SuperNova Medius 等）。\n\n## 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**: Linux (推荐 Ubuntu 20.04+)\n*   **Python**: 3.9 或更高版本\n*   **GPU**: 支持 CUDA 的 NVIDIA GPU（建议显存充足以运行教师\u002F学生模型）\n*   **前置依赖**:\n    *   PyTorch (与 CUDA 版本匹配)\n    *   Hugging Face Transformers\n    *   TRL (Transformer Reinforcement Learning)\n    *   Accelerate\n    *   (可选) vLLM：如果您需要自行捕获教师模型的输出数据\n\n> **提示**：国内用户建议在 `pip` 命令中添加国内镜像源（如清华源 `-i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple`）以加速依赖下载。\n\n## 安装步骤\n\n### 1. 克隆仓库并安装核心包\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Farcee-ai\u002Fdistillkit.git\ncd distillkit\npip install -e .\n```\n\n### 2. (可选) 安装日志捕获依赖\n\n如果您计划自行运行教师模型来生成蒸馏数据（而非使用预生成的数据集），需要安装额外的捕获依赖：\n\n```bash\npip install -e \".[capture]\"\n```\n\n> **注意**：对于大多数初学者，建议直接使用官方提供的预捕获教师数据集（见下文“基本使用”），无需执行此步。\n\n## 基本使用\n\nDistillKit 的核心优势在于**离线蒸馏**，即利用预先生成并压缩的教师模型输出数据进行训练，从而节省显存和计算资源。\n\n### 场景：使用预捕获数据进行离线蒸馏\n\n以下示例展示如何配置并启动一个从大型教师模型（如 Qwen3-235B）到小型学生模型（如 Qwen3-8B）的蒸馏任务。\n\n#### 1. 创建配置文件\n\n新建一个名为 `config.yaml` 的文件，填入以下内容：\n\n```yaml\n# config.yaml\nproject_name: my-distillation\nmodel: Qwen\u002FQwen3-8B  # 学生模型\noutput_path: .\u002Foutput\nsequence_length: 8192\n\ndataset:\n  train_dataset:\n    repo_id: arcee-ai\u002FQwen3-235B-Logits-Packed-8192  # 使用官方预捕获的教师 Logits 数据集\n    split: train\n  prepacked: true\n\nteacher:\n  kind: dataset  # 指定为离线数据集模式\n  logprob_compressor:\n    d: 151936  # 词表大小 (需与教师模型一致)\n    delta_encoding: true\n    error_diffusion: false\n    exact_dtype: float32\n    exact_k: 32\n    k: 128\n    polynomial_terms: [0, 1, 2]\n    residual_bins: []\n    term_dtype: float32\n\nloss_functions:\n  - function: cross_entropy\n    weight: 0.5\n  - function: kl\n    weight: 0.5\n    temperature: 1.0\n    missing_probability_handling: zero\n    sparse_chunk_length: 1024\n\ntraining_args:\n  num_train_epochs: 1\n  per_device_train_batch_size: 1\n  gradient_accumulation_steps: 8\n  learning_rate: 2.0e-6\n  bf16: true\n  optim: adamw_torch\n  gradient_checkpointing: true\n```\n\n#### 2. 启动训练\n\n在终端中运行以下命令开始蒸馏：\n\n```bash\ndistillkit config.yaml\n```\n\n### 关键配置说明\n\n*   **dataset.repo_id**: 指向 Hugging Face 上的预压缩 Logits 数据集。使用这些数据可以避免在训练时加载巨大的教师模型。\n*   **teacher.kind**: 设置为 `dataset` 表示启用离线模式；若需在线蒸馏（实时推理教师模型），则设为 `hf` 并指定模型路径。\n*   **loss_functions**: 支持组合多种损失函数（如交叉熵 `cross_entropy` 和 KL 散度 `kl`），通过 `weight` 调整权重。\n*   **logprob_compressor**: 必须与生成数据集时使用的压缩配置保持一致，否则无法正确解码 Logits。\n\n### 进阶提示\n\n*   **在线蒸馏**: 如果显存足够同时容纳教师和学生模型，可参考 `examples\u002Fafm_test.yml` 配置在线蒸馏，无需预先存储 Logits。\n*   **显存优化**: 对于长序列训练，建议在配置中启用 `gradient_checkpointing: true` 并使用 `sparse_chunk_length` 分块处理，或结合 DeepSpeed ZeRO 技术。\n*   **自定义数据捕获**: 若需针对特定数据集生成教师 Logits，可使用 `python -m distillkit.sample_logits_vllm` 命令（需先安装 vLLM）。","某 AI 初创团队试图将自研的千亿参数大模型能力迁移至端侧设备，计划通过知识蒸馏训练一个轻量级学生模型。\n\n### 没有 DistillKit 时\n- **存储成本爆炸**：直接保存教师模型在数十亿 token 上的完整 logits 分布需要 PB 级存储空间，硬件预算严重超支。\n- **工程实现复杂**：团队需自行研发压缩算法来平衡精度与体积，耗时数月仍难以解决内存吞吐量瓶颈。\n- **训练流程低效**：若采用在线蒸馏，巨大的教师模型需实时参与训练，导致显存占用过高且推理延迟拖慢整体进度。\n- **灵活性受限**：缺乏现成的模块化损失函数组合，难以针对特定任务调整 KL 散度、排序损失等策略以优化效果。\n\n### 使用 DistillKit 后\n- **存储大幅缩减**：利用其多项式近似与位打包技术，将日志数据压缩数个数量级，使离线蒸馏数据集可轻松存入普通硬盘。\n- **开箱即用高效**：直接调用内置的先进压缩工作流，无需重复造轮子，几天内即可搭建起生产级的离线蒸馏管线。\n- **资源解耦灵活**：支持从预捕获的高压缩数据中训练，完全移除训练时对巨型教师模型的依赖，显著降低显存门槛。\n- **策略组合自由**：通过配置文件即可灵活编排多种损失函数与稀疏分布策略，快速验证不同蒸馏方案对模型性能的影响。\n\nDistillKit 通过突破性的日志压缩技术与成熟的工作流，让大规模离线知识蒸馏从“理论可行”变为“工程落地”，极大降低了小模型获取大模型能力的门槛。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Farcee-ai_DistillKit_23b2891b.png","arcee-ai","Arcee AI","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Farcee-ai_73073be0.png","",null,"info@arcee.ai","https:\u002F\u002Fgithub.com\u002Farcee-ai",[23],{"name":24,"color":25,"percentage":26},"Python","#3572A5",100,922,122,"2026-04-11T11:31:49","Apache-2.0",3,"未说明","必需 NVIDIA GPU。在线蒸馏需足够显存同时容纳教师和学生模型及稠密分布；离线蒸馏适合显存受限场景。建议使用支持 Flash Attention 2 的显卡，并配合 bf16 精度训练。",{"notes":35,"python":32,"dependencies":36},"该工具支持在线和离线两种知识蒸馏模式。离线模式依赖预捕获并压缩的教师模型输出（Logits），可大幅降低显存需求但需要存储空间。配置压缩参数时，蒸馏配置必须与捕获时使用的配置完全一致。建议开启梯度检查点（gradient_checkpointing）和使用 bf16 精度以优化显存使用。若需自行捕获教师输出，需额外安装 vLLM 依赖。",[37,38,39,40,41],"torch","transformers","trl","accelerate","vLLM (可选，用于捕获教师输出)",[43,44],"语言模型","开发框架",2,"ready","2026-03-27T02:49:30.150509","2026-04-12T20:18:42.607158",[50,55,60,65,70,75,80],{"id":51,"question_zh":52,"answer_zh":53,"source_url":54},30937,"运行 accelerate launch 时出现关于 SFTTrainer 位置参数弃用的警告或错误怎么办？","这是由于依赖库版本不匹配导致的。维护者表示将在短期内通过锁定依赖项版本来修复此问题。临时解决方案可以参考相关 StackOverflow 链接调整参数传递方式，或等待项目方更新 requirements.txt 以固定兼容的版本。","https:\u002F\u002Fgithub.com\u002Farcee-ai\u002FDistillKit\u002Fissues\u002F10",{"id":56,"question_zh":57,"answer_zh":58,"source_url":59},30932,"使用 DeepSpeed Zero3 进行分布式训练时出现 'weight' must be 2-D 错误怎么办？","这是一个已知的初始化问题。解决方案是在初始化 trainer 时，对 teacher_model 调用 deepspeed.initialize。另外，有用户反馈使用 DeepSpeed stage2 或 FSDP 也可以避免此问题。","https:\u002F\u002Fgithub.com\u002Farcee-ai\u002FDistillKit\u002Fissues\u002F3",{"id":61,"question_zh":62,"answer_zh":63,"source_url":64},30933,"运行脚本时遇到 CUDA 显存不足（OOM）错误如何解决？","可以尝试以下几种方法：1. 调整 max_length 参数以适配显存大小；2. 如果仍然 OOM，建议使用 DDP 或 FSDP 进行分布式训练；3. 另一个有效的建议是离线保存教师模型的 logits，这样可以大幅节省显存占用。","https:\u002F\u002Fgithub.com\u002Farcee-ai\u002FDistillKit\u002Fissues\u002F4",{"id":66,"question_zh":67,"answer_zh":68,"source_url":69},30934,"遇到 SFTTrainer 初始化错误：TypeError: got an unexpected keyword argument 'max_seq_length' 或 'num_items_in_batch' 怎么办？","这通常是由于 TRL 或 Transformers 库的版本更新导致的破坏性变更。解决方案包括：1. 降级库版本，例如使用 trl==0.9.6 或 trl==0.11.3（避免使用 0.18.2）；2. 修改源码，在 compute_loss 函数定义中添加默认参数 num_items_in_batch=None，即改为 def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None)。","https:\u002F\u002Fgithub.com\u002Farcee-ai\u002FDistillKit\u002Fissues\u002F23",{"id":71,"question_zh":72,"answer_zh":73,"source_url":74},30935,"使用 PyTorch 2.4 进行多 GPU 蒸馏时报错 '_get_socket_with_port' import error 怎么办？","该问题与 PyTorch 2.4 和 DeepSpeed 的兼容性有关。维护者确认已在后续版本中修复。如果遇到此问题，建议检查是否有可用的代码更新，或者暂时尝试调整 DeepSpeed 配置。维护者曾提到计划在通过 Accelerate 直接传递配置而不是配置文件来解决此类问题。","https:\u002F\u002Fgithub.com\u002Farcee-ai\u002FDistillKit\u002Fissues\u002F2",{"id":76,"question_zh":77,"answer_zh":78,"source_url":79},30936,"训练后的模型输出无法停止（无限生成文本）是什么原因？","这通常与停止令牌（stop token）设置不当或训练过度有关。建议检查训练代码和保存模型中的 tokenizer_config.json 配置。此外，观察损失曲线，如果模型在 0.5 个 epoch 后损失已收敛，则无需训练 3 个 epoch，过度训练可能导致模型行为异常。","https:\u002F\u002Fgithub.com\u002Farcee-ai\u002FDistillKit\u002Fissues\u002F9",{"id":81,"question_zh":82,"answer_zh":83,"source_url":84},30938,"由于 Hugging Face 库更新导致脚本不兼容，如何保证环境复现性？","建议固定 requirements.txt 中的库版本。由于主要\u002F次要版本更新常导致不兼容，用户应等待维护者更新具体的版本号，或在本地手动指定经过测试的稳定版本（如特定的 trl 和 accelerate 版本）以确保脚本可复现运行。","https:\u002F\u002Fgithub.com\u002Farcee-ai\u002FDistillKit\u002Fissues\u002F25",[],[87,98,106,114,122,131],{"id":88,"name":89,"github_repo":90,"description_zh":91,"stars":92,"difficulty_score":31,"last_commit_at":93,"category_tags":94,"status":46},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,"2026-04-06T06:32:30",[95,44,96,97],"Agent","图像","数据工具",{"id":99,"name":100,"github_repo":101,"description_zh":102,"stars":103,"difficulty_score":31,"last_commit_at":104,"category_tags":105,"status":46},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",[44,96,95],{"id":107,"name":108,"github_repo":109,"description_zh":110,"stars":111,"difficulty_score":45,"last_commit_at":112,"category_tags":113,"status":46},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 真正成长为懂上",151918,"2026-04-12T11:33:05",[44,95,43],{"id":115,"name":116,"github_repo":117,"description_zh":118,"stars":119,"difficulty_score":45,"last_commit_at":120,"category_tags":121,"status":46},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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,"2026-04-10T11:39:34",[44,96,95],{"id":123,"name":124,"github_repo":125,"description_zh":126,"stars":127,"difficulty_score":45,"last_commit_at":128,"category_tags":129,"status":46},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",[130,95,96,44],"插件",{"id":132,"name":133,"github_repo":134,"description_zh":135,"stars":136,"difficulty_score":45,"last_commit_at":137,"category_tags":138,"status":46},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",[130,44]]