[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"tool-facebookresearch--blt":3,"similar-facebookresearch--blt":94},{"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":19,"owner_twitter":19,"owner_website":20,"owner_url":21,"languages":22,"stars":31,"forks":32,"last_commit_at":33,"license":34,"difficulty_score":35,"env_os":36,"env_gpu":37,"env_ram":38,"env_deps":39,"category_tags":48,"github_topics":19,"view_count":51,"oss_zip_url":19,"oss_zip_packed_at":19,"status":52,"created_at":53,"updated_at":54,"faqs":55,"releases":93},10106,"facebookresearch\u002Fblt","blt","Code for BLT research paper","blt 是字节潜在变压器（Byte Latent Transformer）架构的开源实现代码，源自 Meta 的研究论文。它旨在解决传统大语言模型依赖分词器（Tokenizer）带来的局限性，首次证明了直接在原始字节（byte）层面训练的大模型，在规模扩展时能达到甚至超越基于分词的模型性能。\n\nblt 的核心创新在于摒弃了固定的分词预处理，转而将字节动态编码为大小可变的“补丁”（patches）作为计算单元。系统会根据下一个字节的熵值动态调整补丁长度：数据越复杂，分配的算力越多。这种机制不仅显著提升了推理效率和鲁棒性，还增强了模型在长尾泛化和逻辑推理方面的表现。该项目包含了从注意力机制优化到字节序列记忆的新型架构设计，并提供了高达 80 亿参数的规模化训练验证。\n\n这款工具主要面向 AI 研究人员和深度学习开发者，特别是那些对底层模型架构、高效推理机制或无分词大模型感兴趣的技术人员。虽然目前代码库仍在积极更新中以提升复现便利性，但它已支持通过 Hugging Face 加载预训练权重（如 1B 和 7B 版本）进行文本生成实验。如果你希望探索下一代大模型的基础构建方式，或研究如何在不损","blt 是字节潜在变压器（Byte Latent Transformer）架构的开源实现代码，源自 Meta 的研究论文。它旨在解决传统大语言模型依赖分词器（Tokenizer）带来的局限性，首次证明了直接在原始字节（byte）层面训练的大模型，在规模扩展时能达到甚至超越基于分词的模型性能。\n\nblt 的核心创新在于摒弃了固定的分词预处理，转而将字节动态编码为大小可变的“补丁”（patches）作为计算单元。系统会根据下一个字节的熵值动态调整补丁长度：数据越复杂，分配的算力越多。这种机制不仅显著提升了推理效率和鲁棒性，还增强了模型在长尾泛化和逻辑推理方面的表现。该项目包含了从注意力机制优化到字节序列记忆的新型架构设计，并提供了高达 80 亿参数的规模化训练验证。\n\n这款工具主要面向 AI 研究人员和深度学习开发者，特别是那些对底层模型架构、高效推理机制或无分词大模型感兴趣的技术人员。虽然目前代码库仍在积极更新中以提升复现便利性，但它已支持通过 Hugging Face 加载预训练权重（如 1B 和 7B 版本）进行文本生成实验。如果你希望探索下一代大模型的基础构建方式，或研究如何在不损失性能的前提下简化数据处理流程，blt 提供了一个极具价值的研究基准和实践框架。","# Byte Latent Transformer\n\nThis repository contains code for our paper: \"Byte Latent Transformer: Patches Scale Better Than Tokens\"\n\n- [Paper Link](https:\u002F\u002Fdl.fbaipublicfiles.com\u002Fblt\u002FBLT__Patches_Scale_Better_Than_Tokens.pdf)\n\n## Abstract\n\nWe introduce the Byte Latent Transformer architecture (BLTs), a new byte-level LLM architecture that\nfor the first time, matches tokenization-based LLM performance at scale, with significant improvements\nin inference efficiency and robustness. BLT encodes bytes into dynamically sized patches, which serve\nas the primary units of computation. Patches are segmented dynamically based on the entropy of the\nnext byte, allocating more compute and model capacity where there is more data complexity. The BLT\narchitecture includes new attention mechanisms to maximize the information flow between byte and\npatch hidden representations and a new type of byte-sequence memory. We present the first scaling\nstudy of byte-level models up to 8B parameters and 8T training bytes, showing for the first time\nthat we can train a model end-to-end at scale from bytes with no tokenization or other preprocessing.\nScaling trends reveal training and inference efficiency benefits from dynamically selecting very long\npatches on average, along with qualitative improvements with reasoning and long tail generalization\nfrom modeling byte-sequences.\n\n![BLT Architecture Diagram](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ffacebookresearch_blt_readme_923a602f1ffa.jpg)\n\n## Development Status\n\nWe are actively updating the blt code to make it easier to reproduce our results.\nPlease file an issue and\u002For be patient while we make more of our code public!\n\n## Quick start\n\nThere are three ways you can create your environment.\n\n### Option 1: conda + pip\n\nRun these commands in your terminal or a script:\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fblt\ncd blt\nconda create -n blt python=3.12\nconda activate blt\npip install --pre torch --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fnightly\u002Fcu121\npip install ninja\npip install -v -U git+https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fxformers.git@de742ec3d64bd83b1184cc043e541f15d270c148\npip install -r requirements.txt\n```\n\n### Option 2: Slurm Job to Build Env\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fblt\ncd blt\n\nbash setup\u002Fcreate_env.sh\n# or if you have access to a SLURM cluster\nsbatch setup\u002Fcreate_env.sh\n```\n\nOnce that is done you can activate the environment\n\n```bash\nconda activate blt_\u003Cdate>\n```\n\n### Options 3 (experimental, reproducible): uv\n\nRun the following to install the env using [uv](https:\u002F\u002Fdocs.astral.sh\u002Fuv\u002F).\nThe main benefit of this method is that the build is reproducible since there is a lock file.\n\n```bash\nuv pip install --group pre_build --no-build-isolation\nuv pip install --group compile_xformers --no-build-isolation\nuv sync\nuv run python download_blt_weights.py\nuv run python demo.py \"A BLT has\"\n```\n\n## Downloading HF Model Weights and Generating Text\n\nWe have released weights on HF for the [BLT 1B Model](https:\u002F\u002Fhuggingface.co\u002Ffacebook\u002Fblt-1b) and [BLT 7B Model](https:\u002F\u002Fhuggingface.co\u002Ffacebook\u002Fblt-7b).\nWe are actively working with HF to make BLT available in [Transformers](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Ftransformers\u002Fen\u002Findex) and will update this when it is.\nIn the meantime, you can follow these instructions to load model weights, initialize a model, and generate text.\nThese instructions have been tested on H100 GPUs, but we can only offer suggestions on running on other hardware.\n\n1. On the model weights HF page, create a HuggingFace account, request access to weights, and wait for approval.\n2. On the huggingface cli, login: `huggingface-cli login`\n\nFrom here there are two options: (1) load weights in our train script and (2) loading weights via HF hub to use for anything else.\n\n## Load Weights via HF Hub\n\nIn your terminal:\n\n```bash\npython -m bytelatent.hf load-transformers --entropy-repo facebook\u002Fblt-entropy --blt-repo facebook\u002Fblt-1b --prompt \"My test prompt\" hub\n```\n\nIn your own code:\n\n```python\nfrom bytelatent.transformer import LMTransformer\nfrom bytelatent.model.blt import ByteLatentTransformer\nfrom bytelatent.hf import BltTokenizerAndPatcher\n\nentropy_repo = \"facebook\u002Fblt-entropy\"\nblt_repo = \"facebook\u002Fblt-1b\"\nentropy_model = LMTransformer.from_pretrained(entropy_repo)\nblt_model = ByteLatentTransformer.from_pretrained(blt_repo)\ntok_and_patcher = BltTokenizerAndPatcher.from_pretrained(blt_repo)\ntokenizer = tok_and_patcher.tokenizer_args.build()\npatcher = tok_and_patcher.patcher_args.build()\n```\n\n## Load Weights for Running BLT Train Script\n\n1. Download the model weights with: `python download_blt_weights.py`, which will load to `hf-weights`\n2. Run the generate demo: `python demo.py \"A BLT has\"`.\n\nThe demo generates text, but is also a good starting point for loading BLT in your own code.\n\n## Downloading Training Data\n\nNote: The following instructions are not well tested in the BLT code as it is based on the lingua code, which we have diverged from.\n\nUse the provided script to download and prepare data from huggingface (among `fineweb_edu`, `fineweb_edu_10bt`, or `dclm_baseline_1.0`).\nThis command will download the `fineweb_edu` and prepare it for training in the `.\u002Fdata` directory, specifying the amount of memory `terashuf` (the tool used to shuffle samples) will be allocated. By default, the number of chunks (`nchunks`) is 32. If you are running on fewer than 32 GPUs, it is recommended to set `nchunks` to 1 or to match `nchunks` with the number of GPUs (`nchunks` = NGPUs). See [here](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Flingua\u002Fissues\u002F55#issuecomment-2483643076) for more details.\n\n```bash\npython setup\u002Fdownload_prepare_hf_data.py fineweb_edu \u003CMEMORY> --data_dir .\u002Fdata --seed 42 --nchunks \u003CNCHUNKS>\n```\n\nto download tokenizer (here llama3), use the following script:\n\n```bash\npython setup\u002Fdownload_tokenizer.py llama3 \u003CSAVE_PATH> --api_key \u003CHUGGINGFACE_TOKEN>\n```\n\nNow launch a debug job to check if everything works. **The provided configurations are templates, you need to adapt them for them to work (change `dump_dir`, `data.root_dir`, `data.tokenizer.path`, etc ...)**\n\n```bash\n# stool stands for SLURM tool !\npython -m bytelatent.stool script=bytelatent.train config=bytelatent\u002Fconfigs\u002Fdebug.yaml nodes=1 partition=\u003Cpartition>\n# if you want to launch locally you can use torchrun\ntorchrun --nproc-per-node 8 -m bytelatent.train config=bytelatent\u002Fconfigs\u002Fdebug.yaml\n# or you can also launch on 1 GPU\npython -m bytelatent.train  config=bytelatent\u002Fconfigs\u002Fdebug.yaml\n```\n\nWhen using `stool`, if a job crashes, it can be relaunched using sbatch:\n\n```bash\nsbatch path\u002Fto\u002Fdump_dir\u002Fsubmit.slurm\n```\n\n## Linting\n\nTo lint, run the following command\n\n```\nbash dev\u002Flint.sh\n```\n\n## Citation\n\nThe BLT is partially based on Meta Lingua, so consider citing it in addition to our BLT paper if you re-use our work.\n\nBLT Paper Citation (will be updated to arXiv soon)\n\n```\n@article{meta_blt,\n  author = {Artidoro Pagnoni, Ram Pasunuru, Pedro Rodriguez, John Nguyen, Benjamin Muller, Margaret Li, Chunting Zhou, Lili Yu, Jason Weston, Luke Zettlemoyer, Gargi Ghosh, Mike Lewis, Ari Holtzman†, Srinivasan Iyer},\n  title = {Byte Latent Transformer: Patches Scale Better Than Tokens},\n  url = {https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fblt},\n  year = {2024}\n}\n```\n\nLingua Code\n\n```\n@misc{meta_lingua,\n  author = {Mathurin Videau, Badr Youbi Idrissi, Daniel Haziza, Luca Wehrstedt, Jade Copet, Olivier Teytaud, David Lopez-Paz},\n  title = {{Meta Lingua}: A minimal {PyTorch LLM} training library},\n  url = {https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Flingua},\n  year = {2024}\n}\n```\n\n## License\n\nThe BLT code is partially based on Meta Lingua.\n\nMeta BLT is licensed under CC-BY-NC-4.0 license. Refer to the LICENSE file in the top level directory.\n","# 字节潜在变换器\n\n本仓库包含我们论文的代码：“字节潜在变换器：补丁的扩展性优于标记”\n\n- [论文链接](https:\u002F\u002Fdl.fbaipublicfiles.com\u002Fblt\u002FBLT__Patches_Scale_Better_Than_Tokens.pdf)\n\n## 摘要\n\n我们提出了字节潜在变换器架构（BLTs），这是一种全新的字节级大语言模型架构。该架构首次在大规模下达到了基于标记的大语言模型性能，并显著提升了推理效率和鲁棒性。BLT将字节编码为动态大小的补丁，这些补丁作为主要的计算单元。补丁会根据下一个字节的熵动态分割，在数据复杂度较高的地方分配更多的计算资源和模型容量。BLT架构还包括新的注意力机制，以最大化字节与补丁隐藏表示之间的信息流动，以及一种新型的字节序列记忆。我们首次对字节级模型进行了规模扩展研究，参数量最高达80亿，训练字节数达8万亿，首次证明了我们可以直接从原始字节端到端地大规模训练模型，而无需任何标记化或其他预处理步骤。规模扩展趋势表明，平均选择非常长的补丁能够带来训练和推理效率上的优势，同时通过建模字节序列，还能在推理能力和长尾泛化方面实现质的提升。\n\n![BLT架构图](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ffacebookresearch_blt_readme_923a602f1ffa.jpg)\n\n## 开发状态\n\n我们正在积极更新BLT代码，以便更轻松地复现我们的实验结果。请提交问题或耐心等待，我们会逐步公开更多代码！\n\n## 快速入门\n\n您可以通过三种方式创建您的环境。\n\n### 选项1：conda + pip\n\n在终端或脚本中运行以下命令：\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fblt\ncd blt\nconda create -n blt python=3.12\nconda activate blt\npip install --pre torch --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fnightly\u002Fcu121\npip install ninja\npip install -v -U git+https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fxformers.git@de742ec3d64bd83b1184cc043e541f15d270c148\npip install -r requirements.txt\n```\n\n### 选项2：Slurm作业构建环境\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fblt\ncd blt\n\nbash setup\u002Fcreate_env.sh\n# 或者如果您有SLURM集群访问权限\nsbatch setup\u002Fcreate_env.sh\n```\n\n完成后，您可以激活环境：\n\n```bash\nconda activate blt_\u003C日期>\n```\n\n### 选项3（实验性、可复现）：uv\n\n运行以下命令以使用[uv](https:\u002F\u002Fdocs.astral.sh\u002Fuv\u002F)安装环境。该方法的主要优势在于其构建过程是可复现的，因为存在锁定文件。\n\n```bash\nuv pip install --group pre_build --no-build-isolation\nuv pip install --group compile_xformers --no-build-isolation\nuv sync\nuv run python download_blt_weights.py\nuv run python demo.py \"A BLT has\"\n```\n\n## 下载HF模型权重并生成文本\n\n我们已在HF上发布了[BLT 1B模型](https:\u002F\u002Fhuggingface.co\u002Ffacebook\u002Fblt-1b)和[BLT 7B模型](https:\u002F\u002Fhuggingface.co\u002Ffacebook\u002Fblt-7b)的权重。我们正与HF合作，计划将BLT集成到[Transformers](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Ftransformers\u002Fen\u002Findex)库中，届时会另行通知。在此期间，您可以按照以下步骤加载模型权重、初始化模型并生成文本。这些步骤已在H100 GPU上测试过，但对于其他硬件平台，我们只能提供一些建议。\n\n1. 在模型权重的HF页面上，创建一个HuggingFace账户，申请访问权限，并等待批准。\n2. 使用HuggingFace CLI登录：`huggingface-cli login`\n\n接下来有两种选择：(1) 在我们的训练脚本中加载权重；(2) 通过HF Hub加载权重以用于其他用途。\n\n## 通过HF Hub加载权重\n\n在您的终端中：\n\n```bash\npython -m bytelatent.hf load-transformers --entropy-repo facebook\u002Fblt-entropy --blt-repo facebook\u002Fblt-1b --prompt \"My test prompt\" hub\n```\n\n在您自己的代码中：\n\n```python\nfrom bytelatent.transformer import LMTransformer\nfrom bytelatent.model.blt import ByteLatentTransformer\nfrom bytelatent.hf import BltTokenizerAndPatcher\n\nentropy_repo = \"facebook\u002Fblt-entropy\"\nblt_repo = \"facebook\u002Fblt-1b\"\nentropy_model = LMTransformer.from_pretrained(entropy_repo)\nblt_model = ByteLatentTransformer.from_pretrained(blt_repo)\ntok_and_patcher = BltTokenizerAndPatcher.from_pretrained(blt_repo)\ntokenizer = tok_and_patcher.tokenizer_args.build()\npatcher = tok_and_patcher.patcher_args.build()\n```\n\n## 加载权重以运行BLT训练脚本\n\n1. 使用`python download_blt_weights.py`下载模型权重，这些权重将被加载到`hf-weights`目录。\n2. 运行生成演示：`python demo.py \"A BLT has\"`。\n\n该演示不仅会生成文本，也是您在自己的代码中加载BLT的一个良好起点。\n\n## 下载训练数据\n\n注意：以下说明尚未在BLT代码中充分测试，因为它们基于lingua代码，而我们已经对该代码进行了分支开发。\n\n使用提供的脚本从HuggingFace下载并准备数据（包括`fineweb_edu`、`fineweb_edu_10bt`或`dclm_baseline_1.0`）。此命令将下载`fineweb_edu`数据，并将其准备为训练数据，存储在`.\u002Fdata`目录中，同时指定`terashuf`工具（用于打乱样本）将分配的内存大小。默认情况下，分块数（`nchunks`）为32。如果您使用的GPU数量少于32张，建议将`nchunks`设置为1，或者使其与GPU数量一致（`nchunks` = NGPUs）。更多详情请参见[这里](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Flingua\u002Fissues\u002F55#issuecomment-2483643076)。\n\n```bash\npython setup\u002Fdownload_prepare_hf_data.py fineweb_edu \u003CMEMORY> --data_dir .\u002Fdata --seed 42 --nchunks \u003CNCHUNKS>\n```\n\n要下载分词器（例如llama3），请使用以下脚本：\n\n```bash\npython setup\u002Fdownload_tokenizer.py llama3 \u003CSAVE_PATH> --api_key \u003CHUGGINGFACE_TOKEN>\n```\n\n现在启动一个调试任务来检查一切是否正常工作。**提供的配置文件只是模板，您需要根据实际情况进行调整才能正常运行（更改`dump_dir`、`data.root_dir`、`data.tokenizer.path`等...）**\n\n```bash\n# stool代表SLURM工具！\npython -m bytelatent.stool script=bytelatent.train config=bytelatent\u002Fconfigs\u002Fdebug.yaml nodes=1 partition=\u003Cpartition>\n# 如果您想在本地运行，可以使用torchrun\ntorchrun --nproc-per-node 8 -m bytelatent.train config=bytelatent\u002Fconfigs\u002Fdebug.yaml\n# 或者您也可以在1张GPU上运行\npython -m bytelatent.train  config=bytelatent\u002Fconfigs\u002Fdebug.yaml\n```\n\n使用`stool`时，如果作业崩溃，可以使用`sbatch`重新启动：\n\n```bash\nsbatch path\u002Fto\u002Fdump_dir\u002Fsubmit.slurm\n```\n\n## 代码检查\n\n要进行代码检查，请运行以下命令：\n\n```bash\nbash dev\u002Flint.sh\n```\n\n## 引用\n\nBLT 部分基于 Meta Lingua，因此如果您复用我们的工作，除了引用我们的 BLT 论文外，也请一并引用 Meta Lingua。\n\nBLT 论文引用（即将更新至 arXiv）\n\n```\n@article{meta_blt,\n  author = {Artidoro Pagnoni, Ram Pasunuru, Pedro Rodriguez, John Nguyen, Benjamin Muller, Margaret Li, Chunting Zhou, Lili Yu, Jason Weston, Luke Zettlemoyer, Gargi Ghosh, Mike Lewis, Ari Holtzman†, Srinivasan Iyer},\n  title = {字节潜伏 Transformer：补丁的扩展性优于标记},\n  url = {https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fblt},\n  year = {2024}\n}\n```\n\nLingua 代码\n\n```\n@misc{meta_lingua,\n  author = {Mathurin Videau, Badr Youbi Idrissi, Daniel Haziza, Luca Wehrstedt, Jade Copet, Olivier Teytaud, David Lopez-Paz},\n  title = {{Meta Lingua}: 一个极简的 {PyTorch LLM} 训练库},\n  url = {https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Flingua},\n  year = {2024}\n}\n```\n\n## 许可证\n\nBLT 代码部分基于 Meta Lingua。\n\nMeta BLT 采用 CC-BY-NC-4.0 许可证。详情请参阅顶级目录下的 LICENSE 文件。","# BLT (Byte Latent Transformer) 快速上手指南\n\nBLT 是一种全新的字节级大语言模型架构，通过动态将字节编码为不同大小的“补丁”（Patches）进行计算，无需传统分词即可实现与基于 Token 的模型相当的性能，并在推理效率和鲁棒性上具有显著优势。\n\n## 环境准备\n\n*   **操作系统**: Linux (推荐 Ubuntu)\n*   **Python 版本**: 3.12\n*   **GPU**: 推荐使用 NVIDIA GPU (测试环境为 H100)，需安装 CUDA 12.1 驱动\n*   **前置依赖**:\n    *   `conda` 或 `uv` (包管理工具)\n    *   `git`\n    *   (可选) SLURM 集群访问权限 (用于大规模训练)\n\n## 安装步骤\n\n你可以选择以下三种方式之一来构建环境。**推荐方式 1** 适合大多数开发者。\n\n### 方式 1：Conda + Pip (推荐)\n\n在终端中依次执行以下命令：\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fblt\ncd blt\nconda create -n blt python=3.12\nconda activate blt\n# 安装 PyTorch nightly 版本 (CUDA 12.1)\npip install --pre torch --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fnightly\u002Fcu121\npip install ninja\n# 安装特定版本的 xformers\npip install -v -U git+https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fxformers.git@de742ec3d64bd83b1184cc043e541f15d270c148\n# 安装其他依赖\npip install -r requirements.txt\n```\n\n> **注意**：国内用户若下载 PyTorch 或 GitHub 资源较慢，可配置相应的国内镜像源或代理加速。\n\n### 方式 2：SLURM 集群脚本\n\n如果你拥有 SLURM 集群访问权限，可以使用提供的脚本自动创建环境：\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fblt\ncd blt\n\n# 直接运行或在集群提交任务\nbash setup\u002Fcreate_env.sh\n# 或者\nsbatch setup\u002Fcreate_env.sh\n\n# 完成后激活环境 (名称包含日期)\nconda activate blt_\u003Cdate>\n```\n\n### 方式 3：UV (实验性，可复现)\n\n使用 `uv` 工具可确保构建的可复现性（包含锁文件）：\n\n```bash\nuv pip install --group pre_build --no-build-isolation\nuv pip install --group compile_xformers --no-build-isolation\nuv sync\n```\n\n## 基本使用\n\n### 1. 下载模型权重并生成文本\n\n目前官方已发布 **BLT 1B** 和 **BLT 7B** 模型权重。使用前需在 Hugging Face 上申请访问权限并通过 CLI 登录。\n\n**第一步：获取权重**\n```bash\n# 登录 Hugging Face (需先申请权限)\nhuggingface-cli login\n\n# 下载权重到本地 hf-weights 目录\npython download_blt_weights.py\n```\n\n**第二步：运行演示生成文本**\n```bash\npython demo.py \"A BLT has\"\n```\n\n### 2. 在代码中加载模型\n\n你也可以直接在 Python 代码中加载模型进行推理或二次开发：\n\n```python\nfrom bytelatent.transformer import LMTransformer\nfrom bytelatent.model.blt import ByteLatentTransformer\nfrom bytelatent.hf import BltTokenizerAndPatcher\n\n# 定义仓库名称\nentropy_repo = \"facebook\u002Fblt-entropy\"\nblt_repo = \"facebook\u002Fblt-1b\"  # 或 facebook\u002Fblt-7b\n\n# 加载模型组件\nentropy_model = LMTransformer.from_pretrained(entropy_repo)\nblt_model = ByteLatentTransformer.from_pretrained(blt_repo)\ntok_and_patcher = BltTokenizerAndPatcher.from_pretrained(blt_repo)\n\n# 构建分词器和补丁生成器\ntokenizer = tok_and_patcher.tokenizer_args.build()\npatcher = tok_and_patcher.patcher_args.build()\n```\n\n### 3. 命令行快速推理 (通过 HF Hub)\n\n如果不希望先下载权重文件，可以直接通过命令行从 Hub 加载并生成：\n\n```bash\npython -m bytelatent.hf load-transformers --entropy-repo facebook\u002Fblt-entropy --blt-repo facebook\u002Fblt-1b --prompt \"My test prompt\" hub\n```\n\n### 4. 训练数据准备 (进阶)\n\n若需从头训练，可下载 FineWeb-Edu 等数据集并进行预处理：\n\n```bash\n# 下载并准备数据 (MEMORY 单位为 MB, NCHUNKS 建议匹配 GPU 数量)\npython setup\u002Fdownload_prepare_hf_data.py fineweb_edu \u003CMEMORY> --data_dir .\u002Fdata --seed 42 --nchunks \u003CNCHUNKS>\n\n# 下载分词器 (例如 llama3)\npython setup\u002Fdownload_tokenizer.py llama3 \u003CSAVE_PATH> --api_key \u003CHUGGINGFACE_TOKEN>\n```\n\n**启动调试训练任务：**\n\n*   **单机单卡**:\n    ```bash\n    python -m bytelatent.train config=bytelatent\u002Fconfigs\u002Fdebug.yaml\n    ```\n*   **单机多卡 (torchrun)**:\n    ```bash\n    torchrun --nproc-per-node 8 -m bytelatent.train config=bytelatent\u002Fconfigs\u002Fdebug.yaml\n    ```\n\n> **提示**：配置文件 (`debug.yaml`) 仅为模板，使用前请根据实际情况修改 `dump_dir`, `data.root_dir`, `data.tokenizer.path` 等路径参数。","某多语言跨境电商平台的技术团队正在构建一个能实时处理全球用户评论、客服对话及商品描述的通用 AI 助手，需应对数十种语言混合输入及生僻字符挑战。\n\n### 没有 blt 时\n- **分词瓶颈严重**：传统模型依赖预定义词表，面对小语种、代码片段或乱码时需频繁回退到未知 token（UNK），导致语义理解断裂。\n- **推理资源浪费**：无论输入内容简单或复杂，模型均按固定 token 长度分配计算力，处理短文本时算力闲置，长文本时响应延迟高。\n- **鲁棒性不足**：遇到拼写错误、特殊符号或非标准格式数据时，分词器容易失效，引发模型输出胡言乱语或拒绝回答。\n- **长尾泛化差**：对于训练数据中未覆盖的新造词或特定领域术语，基于 token 的模型难以通过字节级规律进行有效推理。\n\n### 使用 blt 后\n- **原生字节处理**：blt 直接以字节为单位动态划分补丁，彻底摒弃分词步骤，完美解析任何语言混合、包含代码或特殊符号的原始文本。\n- **动态算力分配**：blt 根据下一字节的熵值动态调整补丁大小，在信息密集处自动增加计算深度，简单内容快速跳过，显著提升推理效率。\n- **抗噪能力增强**：由于不再依赖严格的分词边界，blt 对拼写错误和格式噪声具有天然免疫力，能在脏数据环境下保持稳定的输出质量。\n- **长尾推理提升**：通过建模字节序列的内在规律，blt 能举一反三地理解未见过的专业术语或新造词，大幅改善少样本场景下的泛化表现。\n\nblt 通过“去分词化”和动态计算机制，让大模型在保持高性能的同时，真正具备了像人类一样直接阅读原始字节流的鲁棒性与灵活性。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ffacebookresearch_blt_928dd953.png","facebookresearch","Meta Research","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Ffacebookresearch_449342bd.png","",null,"https:\u002F\u002Fopensource.fb.com","https:\u002F\u002Fgithub.com\u002Ffacebookresearch",[23,27],{"name":24,"color":25,"percentage":26},"Python","#3572A5",99.5,{"name":28,"color":29,"percentage":30},"Shell","#89e051",0.5,2033,191,"2026-04-18T18:14:28","NOASSERTION",4,"Linux","必需 NVIDIA GPU。官方测试环境为 H100；安装指令指定 CUDA 12.1 (cu121)；训练和推理效率依赖于动态补丁机制，显存需求随模型规模（1B-8B+）变化，未给出具体最低显存数值。","未说明（数据预处理脚本需指定 terashuf 工具的内存分配量，具体数值取决于数据集大小）",{"notes":40,"python":41,"dependencies":42},"1. 该工具主要面向 Linux 环境，提供了 Slurm 集群脚本支持。\n2. 必须安装特定版本的 PyTorch nightly (CUDA 12.1) 和特定 commit 的 xformers。\n3. 模型权重托管在 Hugging Face，使用前需申请访问权限并登录。\n4. 训练数据下载和预处理基于 Meta Lingua 代码修改，相关说明标注为‘未经过充分测试’。\n5. 提供三种环境搭建方式：Conda+pip、Slurm 脚本、以及实验性的 uv 工具（推荐用于复现）。\n6. 许可证为 CC-BY-NC-4.0（非商业使用）。","3.12",[43,44,45,46,47],"torch (nightly, cu121)","ninja","xformers (特定 commit)","huggingface_hub","transformers (正在集成中)",[49,50],"语言模型","开发框架",2,"ready","2026-03-27T02:49:30.150509","2026-04-20T19:22:54.901078",[56,61,66,71,76,80,84,88],{"id":57,"question_zh":58,"answer_zh":59,"source_url":60},45365,"如何在 Windows 上运行 BLT？","在 Windows 上运行需要特定的配置和依赖项。建议步骤如下：\n1. 安装特定版本的 Triton：`pip install -U \"triton-windows\u003C3.3\"`\n2. 下载权重文件：`huggingface-cli download facebook\u002Fblt --local-dir blt\u002Fhf-weights\u002F --local-dir-use-symlinks False`\n3. 修改分布式设置以使用 'gloo' 后端，并确保设置以下环境变量：\n   - MASTER_ADDR: localhost\n   - MASTER_PORT: 29500\n   - RANK: 0\n   - WORLD_SIZE: 1\n   - LOCAL_RANK: 0\n注意：官方文档可能已过时，直接运行默认命令可能会失败。","https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fblt\u002Fissues\u002F111",{"id":62,"question_zh":63,"answer_zh":64,"source_url":65},45366,"遇到 'xformers' object has no attribute 'efficient_attention_forward_cutlass' 错误怎么办？","该错误通常与环境配置或代码版本有关。\n1. 确保你使用的是最新的 BLT 代码，维护者已在最近的 Hugging Face 集成更新中修复了此问题。\n2. 参考官方 README 中通过 HF Hub 加载权重的步骤：https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fblt?tab=readme-ov-file#load-weights-via-hf-hub\n3. 如果问题依旧，且发生在 Colab T4 等特定环境中，官方表示暂无带宽支持调试此类特定环境的问题，建议检查本地环境规格是否与最新要求一致。","https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fblt\u002Fissues\u002F101",{"id":67,"question_zh":68,"answer_zh":69,"source_url":70},45367,"train.py 期望 Arrow 文件但数据准备脚本生成的是 JSONL 文件，如何解决？","目前的代码已经更新，Arrow 迭代器现在可以直接接受 JSON 文件，无需手动转换为 Arrow 格式。\n如果你在使用 `train.py` 处理 JSON\u002FArrow 文件时仍遇到问题，请检查是否使用了最新的代码库。此外，关于注意力机制（attention）的相关讨论可参考其他相关 Issue。如果问题持续，建议开启新 Issue 并提供详细报错信息。","https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fblt\u002Fissues\u002F4",{"id":72,"question_zh":73,"answer_zh":74,"source_url":75},45368,"运行 demo.py 时遇到 CUDA device-side assert triggered 或索引越界错误怎么办？","这是一个已知的 Triton\u002FCUDA 错误，通常与块掩码（block mask）创建时的索引计算有关。\n解决方案：\n1. 请参考最新的构建指令（Instructions updated in PR #105），维护者已更新了相关步骤以解决此问题。\n2. 尝试按照 Issue #104 评论中提供的步骤重新构建 conda 环境。\n3. 如果更新后仍然报错，请基于新的指令再次尝试，若无效再提交新的 Issue。","https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fblt\u002Fissues\u002F102",{"id":77,"question_zh":78,"answer_zh":79,"source_url":70},45369,"训练熵模型和生成 Arrow 文件时需要使用相同的数据集吗？","是的，用于训练熵模型的数据集和运行 `preprocess_entropies.py` 脚本生成 Arrow 文件的数据集通常需要保持一致，以确保预处理逻辑与模型训练逻辑匹配。虽然具体实现细节可能随版本更新有所变化（如现在支持直接读取 JSON），但核心原则是数据分布和处理流程需对应。如果遇到具体报错，建议检查配置文件中的数据路径指向是否正确。",{"id":81,"question_zh":82,"answer_zh":83,"source_url":70},45370,"遇到 torch\u002Fdynamo 相关的注意力实现错误该如何调试？","这类错误通常与 torch compile、dynamo 或注意力实现（如 xformers）的组合有关。\n调试建议：\n1. 在配置文件中设置 `debug_dynamo` 标志以启用更多调试信息。\n2. 检查是否使用了 `model.attn_impl: xformers`，因为当前代码依赖它来实现快速高效的注意力机制（支持 block_causal 等变体）。\n3. 如果问题复杂，可能需要暂时禁用某些编译优化或切换注意力后端进行测试。",{"id":85,"question_zh":86,"answer_zh":87,"source_url":65},45371,"目前无法在 Colab T4 实例上运行，官方支持吗？","官方明确表示目前没有带宽（资源）来支持或调试在 Colab T4 实例上运行的问题。\n如果严格按照 README 的步骤操作仍然失败，且错误明显与 Colab T4 环境相关，官方可能无法提供进一步帮助。建议用户尝试在其他符合规格的环境中运行，或者参考社区用户分享的自行修改后的 Colab 笔记（如有）。",{"id":89,"question_zh":90,"answer_zh":91,"source_url":92},45372,"如何正确构建 conda 环境以避免运行时错误？","如果遇到运行时错误（如 CUDA 错误或导入错误），请尝试遵循社区验证过的 conda 环境构建步骤。\n具体参考 Issue #104 中的评论链接（https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fblt\u002Fissues\u002F104#issuecomment-2847442540），其中包含了针对特定错误的環境配置建议。确保严格遵循 `setup.py` 并创建全新的干净环境，避免旧依赖冲突。","https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fblt\u002Fissues\u002F104",[],[95,107,116,124,132,140],{"id":96,"name":97,"github_repo":98,"description_zh":99,"stars":100,"difficulty_score":101,"last_commit_at":102,"category_tags":103,"status":52},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",[104,50,105,106],"Agent","图像","数据工具",{"id":108,"name":109,"github_repo":110,"description_zh":111,"stars":112,"difficulty_score":51,"last_commit_at":113,"category_tags":114,"status":52},9989,"n8n","n8n-io\u002Fn8n","n8n 是一款面向技术团队的公平代码（fair-code）工作流自动化平台，旨在让用户在享受低代码快速构建便利的同时，保留编写自定义代码的灵活性。它主要解决了传统自动化工具要么过于封闭难以扩展、要么完全依赖手写代码效率低下的痛点，帮助用户轻松连接 400 多种应用与服务，实现复杂业务流程的自动化。\n\nn8n 特别适合开发者、工程师以及具备一定技术背景的业务人员使用。其核心亮点在于“按需编码”：既可以通过直观的可视化界面拖拽节点搭建流程，也能随时插入 JavaScript 或 Python 代码、调用 npm 包来处理复杂逻辑。此外，n8n 原生集成了基于 LangChain 的 AI 能力，支持用户利用自有数据和模型构建智能体工作流。在部署方面，n8n 提供极高的自由度，支持完全自托管以保障数据隐私和控制权，也提供云端服务选项。凭借活跃的社区生态和数百个现成模板，n8n 让构建强大且可控的自动化系统变得简单高效。",184740,"2026-04-19T23:22:26",[106,50,104,105,115],"插件",{"id":117,"name":118,"github_repo":119,"description_zh":120,"stars":121,"difficulty_score":101,"last_commit_at":122,"category_tags":123,"status":52},10095,"AutoGPT","Significant-Gravitas\u002FAutoGPT","AutoGPT 是一个旨在让每个人都能轻松使用和构建 AI 的强大平台，核心功能是帮助用户创建、部署和管理能够自动执行复杂任务的连续型 AI 智能体。它解决了传统 AI 应用中需要频繁人工干预、难以自动化长流程工作的痛点，让用户只需设定目标，AI 即可自主规划步骤、调用工具并持续运行直至完成任务。\n\n无论是开发者、研究人员，还是希望提升工作效率的普通用户，都能从 AutoGPT 中受益。开发者可利用其低代码界面快速定制专属智能体；研究人员能基于开源架构探索多智能体协作机制；而非技术背景用户也可直接选用预置的智能体模板，立即投入实际工作场景。\n\nAutoGPT 的技术亮点在于其模块化“积木式”工作流设计——用户通过连接功能块即可构建复杂逻辑，每个块负责单一动作，灵活且易于调试。同时，平台支持本地自托管与云端部署两种模式，兼顾数据隐私与使用便捷性。配合完善的文档和一键安装脚本，即使是初次接触的用户也能在几分钟内启动自己的第一个 AI 智能体。AutoGPT 正致力于降低 AI 应用门槛，让人人都能成为 AI 的创造者与受益者。",183572,"2026-04-20T04:47:55",[104,49,115,50,105],{"id":125,"name":126,"github_repo":127,"description_zh":128,"stars":129,"difficulty_score":101,"last_commit_at":130,"category_tags":131,"status":52},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",[50,105,104],{"id":133,"name":134,"github_repo":135,"description_zh":136,"stars":137,"difficulty_score":51,"last_commit_at":138,"category_tags":139,"status":52},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 真正成长为懂上",161147,"2026-04-19T23:31:47",[50,104,49],{"id":141,"name":142,"github_repo":143,"description_zh":144,"stars":145,"difficulty_score":51,"last_commit_at":146,"category_tags":147,"status":52},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",[50,105,104]]