ZHZisZZ/dllm

GitHub: ZHZisZZ/dllm

一个统一的扩散语言模型训练与评估框架,支持多种扩散架构和从 AR 模型转换的完整配方。

Stars: 2062 | Forks: 200

dLLM

简单扩散语言建模

**[2026/02] ⚡[`Fast-dLLM`](https://github.com/NVlabs/Fast-dLLM)**: 我们支持通过 [Fast-dLLM](https://arxiv.org/abs/2505.22618)(缓存、置信度阈值解码)加速 [LLaDA](https://arxiv.org/abs/2502.09992) 和 [Dream](https://arxiv.org/abs/2508.15487) 的推理和评估。有关推理/评估说明,请参阅 [`examples/fastdllm`](/examples/fastdllm)。 **[2025/12] 🤗[`Tiny-A2D`](https://huggingface.co/collections/dllm-hub/tiny-a2d)**: 我们发布了一系列改编自 AR 模型的 **SOTA** 小型(0.5B/0.6B)扩散模型,并提供了完全开放的配方,用于将 **任意** AR 模型(例如 Qwen、LLaMA 和 GPT-2)转换为扩散模型。有关训练/推理/评估说明,请参阅 [`examples/a2d`](/examples/a2d)。 **[2025/11] 🤗[`BERT-Chat`](https://huggingface.co/collections/dllm-hub/bert-chat)**: 我们发布了一系列经过微调以使用扩散进行聊天的 BERT 模型,并提供了将 **任意** BERT 编码器(例如 BERT、RoBERTa、ModernBERT)转换为扩散模型的开放配方。有关训练/推理/评估说明,请参阅 [`examples/bert`](/examples/bert)。 ## 目录 - [功能](#features) - [安装](#setup) - [文件](#files) - [训练](#training) - [推理](#inference) - [评估](#evaluation) - [引用](#citation) ## 功能 - [`examples/llada`](/examples/llada): [LLaDA](https://arxiv.org/abs/2502.09992) / [LLaDA-MoE](https://arxiv.org/abs/2509.24389) 的预训练、微调和评估。 - [`examples/dream`](/examples/dream): [Dream](https://arxiv.org/abs/2508.15487) 的预训练、微调和评估。 - [`examples/a2d`](/examples/a2d): 微调任意自回归模型以使用 [掩码扩散](https://arxiv.org/abs/2406.07524) / [块扩散](https://arxiv.org/abs/2503.09573) 生成文本。 - [`examples/bert`](/examples/bert): 微调任意 [BERT](https://arxiv.org/abs/1810.04805) 以成为轻量级聊天机器人。 #### 训练技巧: - 使用数据子集: `--dataset_args "allenai/tulu-3-sft-mixture[train:10000,test:1000]"` - 拼接数据集: `--dataset_args "allenai/tulu-3-sft-mixture+HuggingFaceTB/smoltalk"` - 使用 LoRA 和 4bit 量化进行训练: `--load_in_4bit True --lora True` - 使用不同的分布式训练方法: `--accelerate_config "ddp,zero-{1,2,3},fsdp"` - 以流式模式加载预训练数据集: `--streaming True` - 在训练前预处理 SFT 数据集(例如 LLaDA): ## 评估 例如,要在 4 个 GPU 上评估 [`MMLU_Pro`](https://huggingface.co/datasets/TIGER-Lab/MMLU-Pro) 上的 [`LLaDA-8B-Instruct`](https://huggingface.co/GSAI-ML/LLaDA-8B-Instruct),请运行: ``` accelerate launch --num_processes 4 \ dllm/pipelines/llada/eval.py \ --tasks "mmlu_pro" \ --model "llada" \ --apply_chat_template \ --num_fewshot 0 \ --model_args "pretrained=GSAI-ML/LLaDA-8B-Instruct,is_check_greedy=False,mc_num=1,max_new_tokens=256,steps=256,block_size=256,cfg_scale=0.0" ``` 我们还提供了在所有基准测试上自动评估 [LLaDA](https://arxiv.org/abs/2502.09992)、[Dream](https://arxiv.org/abs/2508.15487) 和 [BERT-Chat](https://huggingface.co/collections/dllm-hub/bert-chat) 的脚本。 例如,您可以使用以下命令直接运行 [`examples/llada/eval.sh`](/examples/llada/eval.sh): ``` bash examples/llada/eval.sh --model_name_or_path "GSAI-ML/LLaDA-8B-Instruct" --instruct True bash examples/llada/eval.sh --model_name_or_path "GSAI-ML/LLaDA-8B-Base" --instruct False ``` 我们提供了使用 [Fast-dLLM](https://arxiv.org/abs/2505.22618) 评估 [LLaDA](https://arxiv.org/abs/2502.09992) 和 [Dream](https://arxiv.org/abs/2508.15487) 的脚本: ``` bash examples/fastdllm/llada/eval.sh --model_name_or_path "GSAI-ML/LLaDA-8B-Instruct" --instruct True --num_gpu 1 bash examples/fastdllm/dream/eval.sh --model_name_or_path "Dream-org/Dream-v0-Base-7B" --instruct False --num_gpu 1 ``` ## 引用 ``` @misc{zhou2026dllm, title={dLLM: Simple Diffusion Language Modeling}, author={Zhanhui Zhou and Lingjie Chen and Hanghang Tong and Dawn Song}, year={2026}, eprint={2602.22661}, archivePrefix={arXiv}, primaryClass={cs.CL}, url={https://arxiv.org/abs/2602.22661}, } ```
标签:Apex, BD3LM, DeepSpeed, dLLM, DLL 劫持, Dream, Edit Flows, FSDP, Hugging Face Transformers, LLaDA, LoRA, MDLM, PyTorch, Vectored Exception Handling, 人工智能, 凭据扫描, 可扩展训练, 块扩散, 复现性, 大语言模型, 开源库, 扩散语言模型, 推理优化, 掩码扩散, 搜索引擎爬虫, 机器学习, 模型评估, 深度学习, 生成式AI, 用户模式Hook绕过, 科研工具, 算法实现, 索引, 训练框架, 语言建模, 逆向工具