[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-RUCAIBox--LLMBox":3,"tool-RUCAIBox--LLMBox":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},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,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},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 真正成长为懂上",140436,2,"2026-04-05T23:32:43",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":75,"owner_avatar_url":76,"owner_bio":77,"owner_company":78,"owner_location":78,"owner_email":78,"owner_twitter":78,"owner_website":79,"owner_url":80,"languages":81,"stars":90,"forks":91,"last_commit_at":92,"license":93,"difficulty_score":10,"env_os":94,"env_gpu":95,"env_ram":94,"env_deps":96,"category_tags":106,"github_topics":78,"view_count":10,"oss_zip_url":78,"oss_zip_packed_at":78,"status":16,"created_at":107,"updated_at":108,"faqs":109,"releases":138},377,"RUCAIBox\u002FLLMBox","LLMBox","A comprehensive library for implementing LLMs, including a unified training pipeline and comprehensive model evaluation.","LLMBox 是一个专为大语言模型（LLM）打造的综合性开源库，旨在为研究人员和开发者提供从模型训练到实际部署的一站式解决方案。面对当前大模型生态中训练流程复杂、评估标准分散的挑战，LLMBox 通过高度统一的架构设计，显著提升了开发效率与灵活性。\n\n在核心功能上，LLMBox 不仅支持监督微调（SFT）、预训练、PPO 及 DPO 等多种训练策略，还集成了 LoRA、QLoRA 等参数高效微调技术，并兼容 Flash Attention 和 DeepSpeed 以优化训练速度。对于模型应用环节，它利用 vLLM 和 KV Cache 管理实现最高 6 倍的推理加速，同时内置了超过 59 种主流数据集和基准测试，覆盖思维链（CoT）、上下文学习（ICL）等多种评估维度。\n\n此外，LLMBox 还支持词表合并与量化技术，帮助用户在控制成本的同时获得更优的性能表现。无论你是希望复现论文结果的研究者，还是需要快速迭代模型的工程师，LLMBox 都能提供详细的文档支持和便捷的调试接口，助力你更高效地探索大模型技术的边界。","**LLMBox** | [Training](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Ftraining) | [Utilization](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Futilization)\n\n# LLMBox\n\nLLMBox is a comprehensive library for implementing LLMs, including **a unified training pipeline** and **comprehensive model evaluation**. LLMBox is designed to be a one-stop solution for training and utilizing LLMs. Through a practical library design, we achieve a high-level of **flexibility** and **efficiency** in both training and utilization stages.\n\n\u003Cimg style=\"display: block; margin: 25 auto;\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FRUCAIBox_LLMBox_readme_a1ea430ad5b1.png\" alt=\"\" \u002F>\n\n\n## Key Features\n\nTraining\n\n- **Diverse training strategies:** We support multiple training strategies, including Supervised Fine-tuning (`SFT`), Pre-training (`PT`), `PPO` and `DPO`.\n- **Comprehensive SFT datasets:** We support 9 SFT datasets as the inputs for training.\n- **Tokenizer Vocabulary Merging:** We support the tokenizer merging function to expand the vocabulary.\n- **Data Construction Strategies:** We currently support merging multiple datasets for training. `Self-Instruct` and `Evol-Instruct` are also available to process the dataset.\n- **Parameter Efficient Fine-Tuning:** `LoRA` and `QLoRA` are supported in SFT or PT.\n- **Efficient Training:** We support [`Flash Attention`](https:\u002F\u002Fgithub.com\u002FDao-AILab\u002Fflash-attention) and `Deepspeed` for efficient training.\n\nUtilization\n\n- **Blazingly Fast:** By managing the KV Cache of prefixes or using [`vLLM`](https:\u002F\u002Fgithub.com\u002Fvllm-project\u002Fvllm), we can speed up local inference by up to 6x 🚀.\n- **Comprehensive Evaluation:** 59+ commonly used [datasets](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Fblob\u002Fmain\u002Fdocs\u002Futilization\u002Fsupported-datasets.md) and benchmarks in evaluating LLMs.\n- **Evaluation Methods:** 📏 Accurately reproduce results from original papers of OpenAI, LLaMA, Mistral, and other models.\n- **In-Context Learning:** We support various ICL strategies, including [`KATE`](https:\u002F\u002Faclanthology.org\u002F2022.deelio-1.10\u002F), [`GlobalE`](https:\u002F\u002Faclanthology.org\u002F2022.acl-long.556\u002F), and [`APE`](https:\u002F\u002Farxiv.org\u002Fabs\u002F2211.01910).\n- **Chain-of-Thought:** For some datasets, we support three types of CoT evaluation: `base`, [`least-to-most`](https:\u002F\u002Farxiv.org\u002Fabs\u002F2205.10625), and [`pal`](https:\u002F\u002Farxiv.org\u002Fabs\u002F2211.10435).\n- **Quantization:** BitsAndBytes and GPTQ quantization are supported.\n- **Easy To Use**: Detailed results are provided for users to debug or integrate new models\u002Fdatasets\u002Fcot.\n\n\n## Documentations\n\nSee [documentations](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Fdocs) for more details.\n\n## Quick Start\n\n### Install\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox.git && cd LLMBox\npip install -r requirements.txt\n```\n\nIf you are only evaluating the OpenAI (or OpenAI compatible like DeepSeek, Perplexity) models, you can install the minimal requirements `requirements-openai.txt`.\n\nFor installation problem, see [trouble shooting](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Fdocs\u002Ftrouble_shooting\u002Fvllm_no_module_name_packaging.md).\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>Update LLMBox\u003C\u002Fb>\u003C\u002Fsummary>\n\nCurrently, you can simply pull the latest repository from GitHub to update LLMBox.\n\n```bash\ngit pull\n```\n\nIf you are facing a merge conflict, please try to drop, stash, or commit your local changes first.\n\n```bash\ngit checkout local_changes && git add -p && git commit -m \"local changes\"\ngit checkout main\ngit pull\n```\n\nThe above commands show how to commit your local changes to a new branch, and then update the LLMBox.\n\n\u003C\u002Fdetails>\n\n### Quick Start with Training\n\nYou can start with training a SFT model based on LLaMA-2 (7B) with deepspeed3:\n\n```bash\ncd training\nbash download.sh\nbash bash\u002Frun_ds3.sh\n```\n\n### Quick Start with Utilization\n\nTo utilize your model, or evaluate an existing model, you can run the following command:\n\n```bash\npython inference.py -m gpt-3.5-turbo -d copa  # --num_shot 0 --model_type chat\n```\n\nThis is default to run the OpenAI GPT 3.5 turbo model on the CoPA dataset in a zero-shot manner.\n\n\n## Training\n\nLLMBox Training supports various training strategies and dataset construction strategies, along with some efficiency-improving modules. You can train your model with the following command:\n\n```bash\npython train.py \\\n    --model_name_or_path meta-llama\u002FLlama-2-7b-hf \\\n    --data_path data\u002F \\\n    --dataset alpaca_data_1k.json \\\n    --output_dir $OUTPUT_DIR \\\n    --num_train_epochs 2 \\\n    --per_device_train_batch_size 8 \\\n    --gradient_accumulation_steps 2 \\\n    --save_strategy \"epoch\" \\\n    --save_steps 2 \\\n    --save_total_limit 2 \\\n    --learning_rate 1e-5 \\\n    --lr_scheduler_type \"constant\"\n```\n\nAlternatively, you can use the following preset bash scripts to train your model:\n\n### Merging Tokenizer\n\nIf you want to pre-train your models on corpora with languages or tokens not well-supported in original language mdoels(e.g., LLaMA), we provide the tokenizer merging function to expand the vocabulary based on the corpora by using [sentencepiece](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fsentencepiece). You can check [merge_tokenizer.py](training\u002Fmerge_tokenizer.py) for detailed information. Please follow the guide in [Pre-train](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Ftraining#2-continual-pre-training-with-your-own-corpora).\n\n```bash\nbash bash\u002Frun_7b_pt.sh\n```\n\n### Merging Datasets\n\nIf you want to train your models with a mix of multiple datasets, you can pass a list of dataset files or names to LLMBox. LLMBox will transfer each file or name into a PTDataset or SFTDataset, and merge them together to construct a combined dataset. You can also set the merging ratio of each dataset by passing a list of floats to LLMBox. Please follow the guide in [Merge Dataset](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Ftraining#3-merging-different-datasets-with-designated-ratios-for-training).\n\n```bash\nbash bash\u002Frun_7b_hybrid.sh\n```\n\n### Self-Instruct and Evol-Instruct\n\nSince manually creating instruction data of high qualities to train the model is very time-consuming and labor-intensive, Self-Instruct and Evol-Instruct are proposed to create large amounts of instruction data with varying levels of complexity using LLM instead of humans. LLMBox support both Self-Instruct and Evol-Instruct to augment or enhance the input data files. Please follow the guide in [Self-Insturct and Evol-Instruct](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Ftraining#8-self-instruct-and-evol-instruct-for-generation-instructions)\n\n```bash\npython self_instruct\u002Fself_instruct.py --seed_tasks_path=seed_tasks.jsonl\n```\n\nFor more details, view the [training](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Ftraining) documentation.\n\n## Utilization\n\nWe provide a broad support on Huggingface models (e.g. `LLaMA-3`, `Mistral`, or the model you are building on), OpenAI, Anthropic, QWen and other OpenAI-compatible models for further utilization. Full list of model backends: [here](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Futilization#supported-models).\n\nCurrently a total of 59+ commonly used datasets are supported, including: `HellaSwag`, `MMLU`, `GSM8K`, `GPQA`, `AGIEval`, `CEval`, and `CMMLU`. Full list of datasets: [here](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Fblob\u002Fmain\u002Fdocs\u002Futilization\u002Fsupported-datasets.md).\n\n```bash\nCUDA_VISIBLE_DEVICES=0 python inference.py \\\n  -m llama-2-7b-hf \\\n  -d mmlu agieval:[English] \\\n  --model_type chat \\\n  --num_shot 5 \\\n  --ranking_type ppl_no_option\n```\n\n- 🔥 Recently supported datasets: `imbue_code`, `imbue_public`, and `imbue_private`.\n\n- 🔥 See [benchmarking LLaMA3](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Fblob\u002Fmain\u002Fdocs\u002Futilization\u002Fbenchmarking_llama3.md) for more examples.\n\n\u003Ctable>\n    \u003Ctr>\n        \u003Ctd colspan=4 align=\"center\">\u003Cb>Performance\u003C\u002Fb>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd rowspan=2>\u003Cb>Model\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Ccode>get_ppl\u003C\u002Fcode>\u003C\u002Ftd>\n        \u003Ctd>\u003Ccode>get_prob\u003C\u002Fcode>\u003C\u002Ftd>\n        \u003Ctd>\u003Ccode>generation\u003C\u002Fcode>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cb>Hellaswag (0-shot)\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Cb>MMLU (5-shot)\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Cb>GSM (8-shot)\u003C\u002Fb>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cb>GPT-3.5 Turbo\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>79.98\u003C\u002Ftd>\n        \u003Ctd>69.25\u003C\u002Ftd>\n        \u003Ctd>75.13\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cb>LLaMA-2 (7B)\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>76\u003C\u002Ftd>\n        \u003Ctd>45.95\u003C\u002Ftd>\n        \u003Ctd>14.63\u003C\u002Ftd>\n    \u003C\u002Ftr>\n\u003C\u002Ftable>\n\n### Efficient Evaluation\n\nWe by default enable prefix caching for efficient evaluation. vLLM is also supported.\n\n\u003Ctable>\n    \u003Ctr>\n        \u003Ctd colspan=6 align=\"center\">\u003Cb>Time\u003C\u002Fb>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd rowspan=2>\u003Cb>Model\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd rowspan=2>\u003Cb>Efficient Method\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Ccode>get_ppl\u003C\u002Fcode>\u003C\u002Ftd>\n        \u003Ctd>\u003Ccode>get_prob\u003C\u002Fcode>\u003C\u002Ftd>\n        \u003Ctd>\u003Ccode>generation\u003C\u002Fcode>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cb>Hellaswag (0-shot)\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Cb>MMLU (5-shot)\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Cb>GSM (8-shot)\u003C\u002Fb>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd rowspan=3>\u003Cb>LLaMA-2 (7B)\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Cb>Vanilla\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>0:05:32\u003C\u002Ftd>\n        \u003Ctd>0:18:30\u003C\u002Ftd>\n        \u003Ctd>2:10:27\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cb>vLLM\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>0:06:37\u003C\u002Ftd>\n        \u003Ctd>0:14:55\u003C\u002Ftd>\n        \u003Ctd>0:03:36\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cb>Prefix Caching\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>0:05:48\u003C\u002Ftd>\n        \u003Ctd>0:05:51\u003C\u002Ftd>\n        \u003Ctd>0:17:13\u003C\u002Ftd>\n    \u003C\u002Ftr>\n\u003C\u002Ftable>\n\nYou can also use the following command to use vllm:\n\n\n```bash\npython inference.py -m ..\u002FLlama-2-7b-hf -d mmlu:abstract_algebra,anatomy --vllm True  # --prefix_caching False --flash_attention False\n```\n\nTo evaluate with quantization, you can use the following command:\n\n```python\npython inference.py -m model -d dataset --load_in_4bits  # --load_in_8_bits or --gptq\n```\n\n### Evaluation Method\n\nVarious types of evaluation methods are supported:\n\n\u003C\u002Fbr>\n\n\u003Ctable>\n    \u003Ctr>\n        \u003Ctd>\u003Cb>Dataset\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Cb>Evaluation Method\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Cb>Instruction\u003C\u002Fb>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cp>\u003Cb>Generation\u003C\u002Fb>\u003C\u002Fp>\n        \u003Cp>\u003Cpre>\u003Ccode>{\n  \"question\":\n    \"when was ...\",\n  \"answer\": [\n    '14 December 1972',\n    'December 1972'\n  ]\n}\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fp>\u003C\u002Ftd>\n    \u003Ctd>\u003Cp>\u003Ccode>generation\u003C\u002Fcode>\u003C\u002Fp>\u003Cp>Generate based on the source text\u003C\u002Fp>\u003Cp>Example: \u003Ca href='https:\u002F\u002Fgithub.com\u002Fmeta-llama\u002Fllama-models\u002Fblob\u002Fmain\u002Fmodels\u002Fllama3_1\u002Feval_details.md#arc-challenge'>ARC-Challenge\u003C\u002Fa> (extract choice characters like A, B, C, D from model generation), \u003Ca href='https:\u002F\u002Fgithub.com\u002Fmeta-llama\u002Fllama3\u002Fblob\u002Fbb55334adcedfa9f5da66d2e1ed64e6f3dbd82ed\u002Feval_details.md#gsm8k'>GSM8K\u003C\u002Fa>, \u003Ca href='https:\u002F\u002Fgithub.com\u002Fmeta-llama\u002Fllama3\u002Fblob\u002Fbb55334adcedfa9f5da66d2e1ed64e6f3dbd82ed\u002Feval_details.md#humaneval'>HumanEval\u003C\u002Fa>\u003C\u002Fp>\u003Cp>Notes: \u003Ccode>vLLM\u003C\u002Fcode> generally generates faster than \u003Ccode>transformers\u003C\u002Fcode> but has different default parameters. Users may need to adjust sampling parameters like \u003Ccode>temperature\u003C\u002Fcode> and \u003Ccode>length_penalty\u003C\u002Fcode> for optimal results.\u003C\u002Fp>\u003C\u002Ftd>\n        \u003Ctd>\u003Cp style=\"text-align: center;\">\u003Ccode>generation\u003C\u002Fcode>\u003C\u002Fp>\u003Cp>\u003Cpre>\u003Ccode>Q: When was ...?\nA: ________\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fp>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd rowspan=3>\u003Cp>\u003Cb>MultipleChoice\u003C\u002Fb>\u003C\u002Fp>\n\u003Cpre>\u003Ccode>{\n  \"question\":\n    \"What is the ...?\",\n  \"choices\": [\n    \"The first\",\n    \"The second\",\n    ...\n  ],\n  \"answer\": 3\n}\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Ftd>\n        \u003Ctd rowspan=2>\u003Cp>\u003Ccode>get_ppl\u003C\u002Fcode>\u003C\u002Fp>\u003Cp>Calculate perplexity of the option text based on the source text (i.e. compute log-likelihood over the suffix)\u003C\u002Fp>\u003Cp>Example: \u003Ca href='https:\u002F\u002Fgithub.com\u002Fmeta-llama\u002Fllama3\u002Fblob\u002Fbb55334adcedfa9f5da66d2e1ed64e6f3dbd82ed\u002Feval_details.md#winogrande'>WinoGrande\u003C\u002Fa>, \u003Ca href='https:\u002F\u002Fgithub.com\u002Fmeta-llama\u002Fllama3\u002Fblob\u002Fbb55334adcedfa9f5da66d2e1ed64e6f3dbd82ed\u002Feval_details.md#boolq'>BoolQ\u003C\u002Fa>\u003C\u002Fp>\u003Cp>Notes: Some datasets, such as ARC, OpenbookQA, and RACE use \u003Ca href='https:\u002F\u002Farxiv.org\u002Fpdf\u002F2005.14165'>normalized accuracy\u003C\u002Fa> when evaluated with the \u003Ccode>get_ppl\u003C\u002Fcode> method.\u003C\u002Fp>\u003C\u002Ftd>\n        \u003Ctd>\u003Cp style=\"text-align: center;\">\u003Ccode>ppl_no_option\u003C\u002Fcode>\u003C\u002Fp>\n\u003Cp>\u003Cpre>\u003Ccode>Q: What is ...?\nA: The first\n   └--ppl--┘\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fp>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cp style=\"text-align: center;\">\u003Ccode>ppl\u003C\u002Fcode>\u003C\u002Fp>\n\u003Cp>\u003Cpre>\u003Ccode style=\"border-style: solid;\">Q: What is ...?\nA. The first\nB. The second\nC. ...\nA: A. The first\n   └----ppl---┘\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fp>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cp>\u003Ccode>get_prob\u003C\u002Fcode>\u003C\u002Fp>\u003Cp>Get the probability of each option label (i.e. over choice characters)\u003C\u002Fp>\u003Cp>Example: \u003Ca href='https:\u002F\u002Fgithub.com\u002Fmeta-llama\u002Fllama3\u002Fblob\u002Fbb55334adcedfa9f5da66d2e1ed64e6f3dbd82ed\u002Feval_details.md#mmlu'>MMLU\u003C\u002Fa>, \u003Ca href='https:\u002F\u002Fgithub.com\u002Fmeta-llama\u002Fllama3\u002Fblob\u002Fbb55334adcedfa9f5da66d2e1ed64e6f3dbd82ed\u002Feval_details.md#arc-challenge'>ARC-Challange\u003C\u002Fa>\u003C\u002Fp>\u003C\u002Ftd>\n        \u003Ctd>\u003Cp style=\"text-align: center;\">\u003Ccode>prob\u003C\u002Fcode>\u003C\u002Fp>\n\u003Cp>\u003Cpre>\u003Ccode>Q: What is ...?\nA. The first\nB. The second\nC. ...\nA: _\n   └→ [A B C D]\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fp>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n\u003C\u002Ftable>\n\nYou can find more evaluation details for each dataset at [supported datasets](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Fblob\u002Fmain\u002Fdocs\u002Futilization\u002Fsupported-datasets.md).\n\nYou can use `--instruction` to pass a jinja template to override the default instruction.\n\nBy default, we use the `get_ppl` method with `ppl_no_option` ranking type for `MultipleChoiceDataset` and the `generation` method for `GenerationDataset`. You can also use the following command to use the `get_prob` method or `ppl` variant of `get_ppl` for MultipleChoiceDataset:\n\n```python\npython inference.py -m model -d dataset --ranking_type prob  # or ppl\n```\n\nWe also support In-Context Learning and Chain-of-Thought evaluation for some datasets:\n\n```python\npython inference.py -m model -d dataset --kate  # --globale or --ape\npython inference.py -m model -d dataset --cot least_to_most  # --base or --pal\n```\n\nFor a more detailed instruction on model utilization, view the [utilization](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Futilization) documentation.\n\nFor a full list of evaluation results, see our paper [LLMBox: A Comprehensive Library for Large Language Models](https:\u002F\u002Faclanthology.org\u002F2024.acl-demos.37.pdf).\n\n## Contributing\n\nPlease let us know if you encounter a bug or have any suggestions by [filing an issue](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Fissues).\n\nWe welcome all contributions from bug fixes to new features and extensions.\n\nWe expect all contributions discussed in the issue tracker and going through PRs.\n\nFor more details, view the [CONTRIBUTING](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Fdocs\u002FCONTRIBUTING.md) documentation.\n\n---\n\nWe thank the following contributors for their contributions to LLMBox:\n\n- [@xansar](https:\u002F\u002Fgithub.com\u002Fxansar) for fixing multiple complex issues like batch sampler and self-consistency.\n\n\n## The Team\n\nLLMBox is developed and maintained by [AI Box](http:\u002F\u002Faibox.ruc.edu.cn\u002F). See more details in [change log](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Futilization#change-log)\n\n## License\n\nLLMBox uses [MIT License](.\u002FLICENSE).\n\n## Reference\n\nIf you find LLMBox useful for your research or development, please cite the following papers:\n\n```\n@inproceedings{tang2024llmbox,\n  title={LLMBox: A Comprehensive Library for Large Language Models},\n  author={Tang, Tianyi and Yiwen, Hu and Li, Bingqian and Luo, Wenyang and Qin, ZiJing and Sun, Haoxiang and Wang, Jiapeng and Xu, Shiyi and Cheng, Xiaoxue and Guo, Geyang and others},\n  booktitle={Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations)},\n  pages={388--399},\n  year={2024}\n}\n```\n","**LLMBox** | [训练](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Ftraining) | [利用](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Futilization)\n\n# LLMBox\n\nLLMBox 是一个全面的库，用于实现大语言模型 (**LLMs**)，包括**统一的训练流程**和**全面的模型评估**。LLMBox 旨在成为训练和利用 LLMs 的一站式解决方案。通过实用的库设计，我们在训练和利用阶段都实现了高水平的**灵活性**和**效率**。\n\n\u003Cimg style=\"display: block; margin: 25 auto;\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FRUCAIBox_LLMBox_readme_a1ea430ad5b1.png\" alt=\"\" \u002F>\n\n\n## 主要特性\n\n训练\n\n- **多样化的训练策略：** 我们支持多种训练策略，包括监督微调 (`SFT`)、预训练 (`PT`)、`PPO` (近端策略优化) 和 `DPO` (直接偏好优化)。\n- **全面的 SFT 数据集：** 我们支持 9 个 SFT 数据集作为训练输入。\n- **分词器词汇表合并：** 我们支持分词器 (Tokenizer) 合并功能以扩展词汇表。\n- **数据构建策略：** 目前我们支持合并多个数据集进行训练。`Self-Instruct` 和 `Evol-Instruct` 也可用于处理数据集。\n- **参数高效微调：** `LoRA` (低秩适应) 和 `QLoRA` (量化低秩适应) 在 SFT 或 PT 中受支持。\n- **高效训练：** 我们支持 [`Flash Attention`](https:\u002F\u002Fgithub.com\u002FDao-AILab\u002Fflash-attention) (高效注意力机制) 和 `Deepspeed` (分布式训练框架) 以实现高效训练。\n\n利用\n\n- **极速运行：** 通过管理前缀的 KV Cache (键值缓存) 或使用 [`vLLM`](https:\u002F\u002Fgithub.com\u002Fvllm-project\u002Fvllm) (高性能推理引擎)，我们可以将本地推理速度提高多达 6 倍 🚀。\n- **全面评估：** 评估 LLMs 时包含 59+ 个常用 [数据集](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Fblob\u002Fmain\u002Fdocs\u002Futilization\u002Fsupported-datasets.md) 和基准测试。\n- **评估方法：** 📏 准确复现 OpenAI、LLaMA、Mistral 及其他模型的原始论文结果。\n- **上下文学习：** 我们支持各种 ICL (上下文学习) 策略，包括 [`KATE`](https:\u002F\u002Faclanthology.org\u002F2022.deelio-1.10\u002F)、[`GlobalE`](https:\u002F\u002Faclanthology.org\u002F2022.acl-long.556\u002F) 和 [`APE`](https:\u002F\u002Farxiv.org\u002Fabs\u002F2211.01910)。\n- **思维链：** 对于某些数据集，我们支持三种类型的 CoT (思维链) 评估：`base`、[`least-to-most`](https:\u002F\u002Farxiv.org\u002Fabs\u002F2205.10625) 和 [`pal`](https:\u002F\u002Farxiv.org\u002Fabs\u002F2211.10435)。\n- **量化：** 支持 BitsAndBytes 和 GPTQ 量化。\n- **易于使用**：提供详细结果供用户调试或集成新模型\u002F数据集\u002Fcot。\n\n\n## 文档\n\n详见 [文档](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Fdocs) 了解更多细节。\n\n## 快速开始\n\n### 安装\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox.git && cd LLMBox\npip install -r requirements.txt\n```\n\n如果您仅评估 OpenAI（或兼容 OpenAI 如 DeepSeek, Perplexity）模型，可以安装最小化需求 `requirements-openai.txt`。\n\n关于安装问题，请查看 [故障排查](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Fdocs\u002Ftrouble_shooting\u002Fvllm_no_module_name_packaging.md)。\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>更新 LLMBox\u003C\u002Fb>\u003C\u002Fsummary>\n\n目前，您可以直接从 GitHub 拉取最新仓库来更新 LLMBox。\n\n```bash\ngit pull\n```\n\n如果您遇到合并冲突，请尝试先丢弃、暂存或提交您的本地更改。\n\n```bash\ngit checkout local_changes && git add -p && git commit -m \"local changes\"\ngit checkout main\ngit pull\n```\n\n上述命令展示了如何将您的本地更改提交到新分支，然后更新 LLMBox。\n\n\u003C\u002Fdetails>\n\n### 训练快速开始\n\n您可以基于 LLaMA-2 (7B) 并使用 deepspeed3 开始训练一个 SFT 模型：\n\n```bash\ncd training\nbash download.sh\nbash bash\u002Frun_ds3.sh\n```\n\n### 利用快速开始\n\n要利用您的模型，或评估现有模型，您可以运行以下命令：\n\n```bash\npython inference.py -m gpt-3.5-turbo -d copa  # --num_shot 0 --model_type chat\n```\n\n这默认以 zero-shot (零样本) 方式在 CoPA 数据集上运行 OpenAI GPT 3.5 turbo 模型。\n\n\n## 训练\n\nLLMBox 训练支持各种训练策略和数据集构建策略，以及一些提高效率的模块。您可以使用以下命令训练您的模型：\n\n```bash\npython train.py \\\n    --model_name_or_path meta-llama\u002FLlama-2-7b-hf \\\n    --data_path data\u002F \\\n    --dataset alpaca_data_1k.json \\\n    --output_dir $OUTPUT_DIR \\\n    --num_train_epochs 2 \\\n    --per_device_train_batch_size 8 \\\n    --gradient_accumulation_steps 2 \\\n    --save_strategy \"epoch\" \\\n    --save_steps 2 \\\n    --save_total_limit 2 \\\n    --learning_rate 1e-5 \\\n    --lr_scheduler_type \"constant\"\n```\n\n或者，您可以使用以下预设 bash 脚本来训练您的模型：\n\n### 合并分词器\n\n如果您想在原始语言模型（例如 LLaMA）支持不佳的语言或 token 语料库上预训练模型，我们提供分词器合并功能，通过使用 [sentencepiece](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fsentencepiece) 基于语料库扩展词汇表。您可以查看 [merge_tokenizer.py](training\u002Fmerge_tokenizer.py) 获取详细信息。请遵循 [Pre-train](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Ftraining#2-continual-pre-training-with-your-own-corpora) 中的指南。\n\n```bash\nbash bash\u002Frun_7b_pt.sh\n```\n\n### 合并数据集\n\n如果您想使用混合多个数据集来训练模型，您可以向 LLMBox 传递一个数据集文件或名称列表。LLMBox 会将每个文件或名称转换为 PTDataset 或 SFTDataset，并将它们合并在一起以构建组合数据集。您也可以通过向 LLMBox 传递一个浮点数列表来设置每个数据集的合并比例。请遵循 [Merge Dataset](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Ftraining#3-merging-different-datasets-with-designated-ratios-for-training) 中的指南。\n\n```bash\nbash bash\u002Frun_7b_hybrid.sh\n```\n\n### Self-Instruct 和 Evol-Instruct\n\n由于手动创建高质量指令数据以训练模型非常耗时且费力，提出了 Self-Instruct 和 Evol-Instruct，以便使用 LLM 而非人类创建大量具有不同复杂程度的指令数据。LLMBox 支持 Self-Instruct 和 Evol-Instruct 来增强或扩充输入数据文件。请遵循 [Self-Insturct and Evol-Instruct](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Ftraining#8-self-instruct-and-evol-instruct-for-generation-instructions) 中的指南。\n\n```bash\npython self_instruct\u002Fself_instruct.py --seed_tasks_path=seed_tasks.jsonl\n```\n\n更多详情，请查看 [训练](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Ftraining) 文档。\n\n## 利用\n\n我们广泛支持 Huggingface 模型（例如 `LLaMA-3`, `Mistral`, 或您构建的模型）、OpenAI、Anthropic、QWen 以及其他 OpenAI 兼容模型，以便进一步利用。完整的模型后端 (model backends) 列表：[此处](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Futilization#supported-models)。\n\n目前共支持 59+ 个常用数据集 (datasets)，包括：`HellaSwag`, `MMLU`, `GSM8K`, `GPQA`, `AGIEval`, `CEval`, 和 `CMMLU`。完整数据集列表：[此处](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Fblob\u002Fmain\u002Fdocs\u002Futilization\u002Fsupported-datasets.md)。\n\n```bash\nCUDA_VISIBLE_DEVICES=0 python inference.py \\\n  -m llama-2-7b-hf \\\n  -d mmlu agieval:[English] \\\n  --model_type chat \\\n  --num_shot 5 \\\n  --ranking_type ppl_no_option\n```\n\n- 🔥 最近支持的数据集：`imbue_code`, `imbue_public`, 和 `imbue_private`。\n\n- 🔥 查看 [LLaMA3 基准测试](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Fblob\u002Fmain\u002Fdocs\u002Futilization\u002Fbenchmarking_llama3.md) 获取更多示例。\n\n\u003Ctable>\n    \u003Ctr>\n        \u003Ctd colspan=4 align=\"center\">\u003Cb>性能\u003C\u002Fb>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd rowspan=2>\u003Cb>模型\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Ccode>get_ppl\u003C\u002Fcode>\u003C\u002Ftd>\n        \u003Ctd>\u003Ccode>get_prob\u003C\u002Fcode>\u003C\u002Ftd>\n        \u003Ctd>\u003Ccode>generation\u003C\u002Fcode>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cb>Hellaswag (0-shot)\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Cb>MMLU (5-shot)\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Cb>GSM (8-shot)\u003C\u002Fb>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cb>GPT-3.5 Turbo\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>79.98\u003C\u002Ftd>\n        \u003Ctd>69.25\u003C\u002Ftd>\n        \u003Ctd>75.13\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cb>LLaMA-2 (7B)\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>76\u003C\u002Ftd>\n        \u003Ctd>45.95\u003C\u002Ftd>\n        \u003Ctd>14.63\u003C\u002Ftd>\n    \u003C\u002Ftr>\n\u003C\u002Ftable>\n\n### 高效评估\n\n我们默认启用前缀缓存 (prefix caching) 以实现高效评估。同时也支持 vLLM。\n\n\u003Ctable>\n    \u003Ctr>\n        \u003Ctd colspan=6 align=\"center\">\u003Cb>时间\u003C\u002Fb>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd rowspan=2>\u003Cb>模型\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd rowspan=2>\u003Cb>高效方法\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Ccode>get_ppl\u003C\u002Fcode>\u003C\u002Ftd>\n        \u003Ctd>\u003Ccode>get_prob\u003C\u002Fcode>\u003C\u002Ftd>\n        \u003Ctd>\u003Ccode>generation\u003C\u002Fcode>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cb>Hellaswag (0-shot)\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Cb>MMLU (5-shot)\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Cb>GSM (8-shot)\u003C\u002Fb>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd rowspan=3>\u003Cb>LLaMA-2 (7B)\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Cb>基础版 (Vanilla)\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>0:05:32\u003C\u002Ftd>\n        \u003Ctd>0:18:30\u003C\u002Ftd>\n        \u003Ctd>2:10:27\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cb>vLLM\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>0:06:37\u003C\u002Ftd>\n        \u003Ctd>0:14:55\u003C\u002Ftd>\n        \u003Ctd>0:03:36\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cb>前缀缓存\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>0:05:48\u003C\u002Ftd>\n        \u003Ctd>0:05:51\u003C\u002Ftd>\n        \u003Ctd>0:17:13\u003C\u002Ftd>\n    \u003C\u002Ftr>\n\u003C\u002Ftable>\n\n您也可以使用以下命令来使用 vllm：\n\n```bash\npython inference.py -m ..\u002FLlama-2-7b-hf -d mmlu:abstract_algebra,anatomy --vllm True  # --prefix_caching False --flash_attention False\n```\n\n若要使用量化 (quantization) 进行评估，您可以使用以下命令：\n\n```python\npython inference.py -m model -d dataset --load_in_4bits  # --load_in_8_bits or --gptq\n```\n\n### 评估方法\n\n支持多种类型的评估方法：\n\n\u003C\u002Fbr>\n\n\u003Ctable>\n    \u003Ctr>\n        \u003Ctd>\u003Cb>数据集\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Cb>评估方法\u003C\u002Fb>\u003C\u002Ftd>\n        \u003Ctd>\u003Cb>指令\u003C\u002Fb>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cp>\u003Cb>生成\u003C\u002Fb>\u003C\u002Fp>\n        \u003Cp>\u003Cpre>\u003Ccode>{\n  \"question\":\n    \"when was ...\",\n  \"answer\": [\n    '14 December 1972',\n    'December 1972'\n  ]\n}\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fp>\u003C\u002Ftd>\n    \u003Ctd>\u003Cp>\u003Ccode>generation\u003C\u002Fcode>\u003C\u002Fp>\u003Cp>基于源文本生成\u003C\u002Fp>\u003Cp>示例：\u003Ca href='https:\u002F\u002Fgithub.com\u002Fmeta-llama\u002Fllama-models\u002Fblob\u002Fmain\u002Fmodels\u002Fllama3_1\u002Feval_details.md#arc-challenge'>ARC-Challenge\u003C\u002Fa>（从模型生成中提取选择字符如 A, B, C, D），\u003Ca href='https:\u002F\u002Fgithub.com\u002Fmeta-llama\u002Fllama3\u002Fblob\u002Fbb55334adcedfa9f5da66d2e1ed64e6f3dbd82ed\u002Feval_details.md#gsm8k'>GSM8K\u003C\u002Fa>，\u003Ca href='https:\u002F\u002Fgithub.com\u002Fmeta-llama\u002Fllama3\u002Fblob\u002Fbb55334adcedfa9f5da66d2e1ed64e6f3dbd82ed\u002Feval_details.md#humaneval'>HumanEval\u003C\u002Fa>\u003C\u002Fp>\u003Cp>注意：\u003Ccode>vLLM\u003C\u002Fcode> 通常比 \u003Ccode>transformers\u003C\u002Fcode> 生成速度更快，但默认参数不同。用户可能需要调整采样参数，如 \u003Ccode>temperature\u003C\u002Fcode> 和 \u003Ccode>length_penalty\u003C\u002Fcode>，以获得最佳结果。\u003C\u002Fp>\u003C\u002Ftd>\n        \u003Ctd>\u003Cp style=\"text-align: center;\">\u003Ccode>generation\u003C\u002Fcode>\u003C\u002Fp>\u003Cp>\u003Cpre>\u003Ccode>Q: When was ...?\nA: ________\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fp>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd rowspan=3>\u003Cp>\u003Cb>多项选择\u003C\u002Fb>\u003C\u002Fp>\n\u003Cpre>\u003Ccode>{\n  \"question\":\n    \"What is the ...?\",\n  \"choices\": [\n    \"The first\",\n    \"The second\",\n    ...\n  ],\n  \"answer\": 3\n}\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Ftd>\n        \u003Ctd rowspan=2>\u003Cp>\u003Ccode>get_ppl\u003C\u002Fcode>\u003C\u002Fp>\u003Cp>计算选项文本的困惑度（即计算后缀的对数似然）\u003C\u002Fp>\u003Cp>示例：\u003Ca href='https:\u002F\u002Fgithub.com\u002Fmeta-llama\u002Fllama3\u002Fblob\u002Fbb55334adcedfa9f5da66d2e1ed64e6f3dbd82ed\u002Feval_details.md#winogrande'>WinoGrande\u003C\u002Fa>，\u003Ca href='https:\u002F\u002Fgithub.com\u002Fmeta-llama\u002Fllama3\u002Fblob\u002Fbb55334adcedfa9f5da66d2e1ed64e6f3dbd82ed\u002Feval_details.md#boolq'>BoolQ\u003C\u002Fa>\u003C\u002Fp>\u003Cp>注意：某些数据集，如 ARC、OpenbookQA 和 RACE，在使用 \u003Ccode>get_ppl\u003C\u002Fcode> 方法评估时使用 \u003Ca href='https:\u002F\u002Farxiv.org\u002Fpdf\u002F2005.14165'>归一化准确率\u003C\u002Fa>。\u003C\u002Fp>\u003C\u002Ftd>\n        \u003Ctd>\u003Cp style=\"text-align: center;\">\u003Ccode>ppl_no_option\u003C\u002Fcode>\u003C\u002Fp>\n\u003Cp>\u003Cpre>\u003Ccode>Q: What is ...?\nA: The first\n   └--ppl--┘\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fp>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cp style=\"text-align: center;\">\u003Ccode>ppl\u003C\u002Fcode>\u003C\u002Fp>\n\u003Cp>\u003Cpre>\u003Ccode style=\"border-style: solid;\">Q: What is ...?\nA. The first\nB. The second\nC. ...\nA: A. The first\n   └----ppl---┘\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fp>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n        \u003Ctd>\u003Cp>\u003Ccode>get_prob\u003C\u002Fcode>\u003C\u002Fp>\u003Cp>获取每个选项标签的概率（即针对选择字符）\u003C\u002Fp>\u003Cp>示例：\u003Ca href='https:\u002F\u002Fgithub.com\u002Fmeta-llama\u002Fllama3\u002Fblob\u002Fbb55334adcedfa9f5da66d2e1ed64e6f3dbd82ed\u002Feval_details.md#mmlu'>MMLU\u003C\u002Fa>，\u003Ca href='https:\u002F\u002Fgithub.com\u002Fmeta-llama\u002Fllama3\u002Fblob\u002Fbb55334adcedfa9f5da66d2e1ed64e6f3dbd82ed\u002Feval_details.md#arc-challenge'>ARC-Challange\u003C\u002Fa>\u003C\u002Fp>\u003C\u002Ftd>\n        \u003Ctd>\u003Cp style=\"text-align: center;\">\u003Ccode>prob\u003C\u002Fcode>\u003C\u002Fp>\n\u003Cp>\u003Cpre>\u003Ccode>Q: What is ...?\nA. The first\nB. The second\nC. ...\nA: _\n   └→ [A B C D]\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fp>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n\u003C\u002Ftable>\n\n您可以在 [支持的数据集](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Fblob\u002Fmain\u002Fdocs\u002Futilization\u002Fsupported-datasets.md) 中找到每个数据集的更多评估详情。\n\n您可以使用 `--instruction` 传递一个 Jinja 模板以覆盖默认指令。\n\n默认情况下，我们对 `MultipleChoiceDataset` 使用带有 `ppl_no_option` 排序类型的 `get_ppl` 方法，对 `GenerationDataset` 使用 `generation` 方法。您也可以使用以下命令为 `MultipleChoiceDataset` 使用 `get_prob` 方法或 `get_ppl` 的 `ppl` 变体：\n\n```python\npython inference.py -m model -d dataset --ranking_type prob  # or ppl\n```\n\n我们还支持部分数据集的上下文学习（In-Context Learning）和思维链（Chain-of-Thought）评估：\n\n```python\npython inference.py -m model -d dataset --kate  # --globale or --ape\npython inference.py -m model -d dataset --cot least_to_most  # --base or --pal\n```\n\n关于模型利用的更详细指令，请查看 [utilization](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Futilization) 文档。\n\n有关评估结果的完整列表，请参阅我们的论文 [LLMBox: A Comprehensive Library for Large Language Models](https:\u002F\u002Faclanthology.org\u002F2024.acl-demos.37.pdf)。\n\n## 贡献\n\n如果您遇到错误 (Bug) 或有任何建议，请通过 [提交问题](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Fissues) 告知我们。\n\n我们欢迎所有贡献，从错误修复到新功能和扩展。\n\n我们期望所有贡献都在问题跟踪器中讨论并通过 Pull Requests (PRs) 进行。\n\n更多详情，请查看 [CONTRIBUTING](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Fdocs\u002FCONTRIBUTING.md) 文档。\n\n---\n\n我们要感谢以下为 LLMBox 做出贡献的贡献者：\n\n- [@xansar](https:\u002F\u002Fgithub.com\u002Fxansar) 修复了多个复杂问题，如 batch sampler 和 self-consistency。\n\n\n## 团队\n\nLLMBox 由 [AI Box](http:\u002F\u002Faibox.ruc.edu.cn\u002F) 开发和维护。更多详情见 [变更日志](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Futilization#change-log)\n\n## 许可证\n\nLLMBox 使用 [MIT 许可证](.\u002FLICENSE)。\n\n## 引用\n\n如果您发现 LLMBox 对您的研究或开发有用，请引用以下论文：\n\n```\n@inproceedings{tang2024llmbox,\n  title={LLMBox: A Comprehensive Library for Large Language Models},\n  author={Tang, Tianyi and Yiwen, Hu and Li, Bingqian and Luo, Wenyang and Qin, ZiJing and Sun, Haoxiang and Wang, Jiapeng and Xu, Shiyi and Cheng, Xiaoxue and Guo, Geyang and others},\n  booktitle={Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations)},\n  pages={388--399},\n  year={2024}\n}\n```","# LLMBox 快速上手指南\n\n**LLMBox** 是一个全面的 LLM 实现库，提供统一的训练流程（Training）和综合的模型评估（Utilization）。它旨在成为训练和利用大语言模型的“一站式”解决方案，支持多种训练策略、高效推理及丰富的评估基准。\n\n## 1. 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**：Linux 或 macOS（推荐 Linux 用于生产环境）。\n*   **编程语言**：Python 3.x。\n*   **硬件**：\n    *   **本地训练\u002F推理**：需要 NVIDIA GPU（支持 CUDA）。\n    *   **仅调用 API**：无需本地 GPU。\n*   **依赖工具**：Git, Pip。\n\n> **注意**：若需使用本地训练或推理功能（如 DeepSpeed, vLLM），请确保已正确安装 CUDA 驱动及对应的 PyTorch 版本。\n\n## 2. 安装步骤\n\n### 完整安装（支持训练与评估）\n\n克隆仓库并安装所有依赖：\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox.git && cd LLMBox\npip install -r requirements.txt\n```\n\n### 最小化安装（仅评估 OpenAI 兼容模型）\n\n如果您仅需评估 OpenAI 或其兼容模型（如 DeepSeek, Perplexity），可安装最小依赖：\n\n```bash\npip install -r requirements-openai.txt\n```\n\n### 更新版本\n\n如需更新到最新版本，可直接拉取代码：\n\n```bash\ngit pull\n```\n\n## 3. 基本使用\n\nLLMBox 主要分为 **训练 (Training)** 和 **利用\u002F评估 (Utilization)** 两个核心场景。\n\n### 场景一：模型训练\n\n支持 SFT、预训练 (PT)、PPO、DPO 等多种策略，以及 LoRA\u002FQLoRA 微调。\n\n**快速启动训练示例**（基于 LLaMA-2 7B + DeepSpeed3）：\n\n```bash\ncd training\nbash download.sh\nbash bash\u002Frun_ds3.sh\n```\n\n**自定义训练命令**：\n\n```bash\npython train.py \\\n    --model_name_or_path meta-llama\u002FLlama-2-7b-hf \\\n    --data_path data\u002F \\\n    --dataset alpaca_data_1k.json \\\n    --output_dir $OUTPUT_DIR \\\n    --num_train_epochs 2 \\\n    --per_device_train_batch_size 8 \\\n    --gradient_accumulation_steps 2 \\\n    --save_strategy \"epoch\" \\\n    --save_steps 2 \\\n    --save_total_limit 2 \\\n    --learning_rate 1e-5 \\\n    --lr_scheduler_type \"constant\"\n```\n\n### 场景二：模型评估与推理\n\n支持 59+ 常用数据集（如 MMLU, GSM8K, C-Eval 等），并提供 vLLM 加速推理。\n\n**快速评估示例**（Zero-shot 评估 OpenAI GPT-3.5 Turbo）：\n\n```bash\npython inference.py -m gpt-3.5-turbo -d copa  # --num_shot 0 --model_type chat\n```\n\n**本地模型评估示例**（使用 HuggingFace 模型 + vLLM 加速）：\n\n```bash\nCUDA_VISIBLE_DEVICES=0 python inference.py \\\n  -m llama-2-7b-hf \\\n  -d mmlu agieval:[English] \\\n  --model_type chat \\\n  --num_shot 5 \\\n  --ranking_type ppl_no_option\n```\n\n**开启 vLLM 加速**：\n\n```bash\npython inference.py -m ..\u002FLlama-2-7b-hf -d mmlu:abstract_algebra,anatomy --vllm True\n```\n\n**量化评估支持**（4-bit\u002F8-bit\u002FGPTQ）：\n\n```python\npython inference.py -m model -d dataset --load_in_4bits  # --load_in_8_bits or --gptq\n```\n\n更多详细文档请参考项目 [Documentation](https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Ftree\u002Fmain\u002Fdocs)。","某电商技术团队计划基于开源模型微调专属客服问答系统，并需在两周内完成验证上线。\n\n### 没有 LLMBox 时\n- 训练与推理环境割裂，需维护多套脚本，依赖冲突导致部署失败率高。\n- 实现 LoRA 微调需从零编写数据加载与优化器逻辑，调试周期长达数周。\n- 本地推理延迟高，无法支撑大促期间的高并发用户咨询请求。\n- 缺乏标准化评测体系，难以客观对比不同版本模型的业务表现。\n\n### 使用 LLMBox 后\n- LLMBox 提供统一训练管线，一键支持 SFT、LoRA 及 QLoRA 等多种策略。\n- 集成 vLLM 与 Flash Attention，本地推理速度提升 6 倍，响应更流畅。\n- 内置 59+ 主流评测数据集，可直接复现 OpenAI 等权威模型的基准结果。\n- 支持 BitsAndBytes 量化方案，显著降低显存占用，加速生产环境迁移。\n\nLLMBox 通过一体化设计，将大模型从训练到评估的复杂工程门槛大幅降低。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FRUCAIBox_LLMBox_155f5d32.png","RUCAIBox","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FRUCAIBox_ca88ccaf.png","The official account of RUC AI Box, which does not engage in any commercial activities. Claims of business associations are fraudulent.",null,"http:\u002F\u002Faibox.ruc.edu.cn","https:\u002F\u002Fgithub.com\u002FRUCAIBox",[82,86],{"name":83,"color":84,"percentage":85},"Python","#3572A5",97.1,{"name":87,"color":88,"percentage":89},"Shell","#89e051",2.9,850,106,"2026-04-02T10:35:22","MIT","未说明","需要 NVIDIA GPU，CUDA 环境，具体型号及显存大小未说明",{"notes":97,"python":94,"dependencies":98},"安装需克隆仓库并执行 pip install -r requirements.txt；训练前需通过 bash 脚本下载数据\u002F模型；支持 OpenAI 兼容接口时可仅安装最小依赖；部分推理加速需配置 vLLM 或量化选项。",[99,100,101,102,103,104,105],"torch","transformers","deepspeed","flash-attention","vllm","sentencepiece","bitsandbytes",[26,13],"2026-03-27T02:49:30.150509","2026-04-06T08:41:36.067640",[110,115,120,124,129,134],{"id":111,"question_zh":112,"answer_zh":113,"source_url":114},1371,"运行推理脚本时遇到 Batch Sampler IndexError 错误如何处理？","这是一个已知问题，可以临时添加 `--prefix_caching True` 参数来解决，等待官方后续修复。","https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Fissues\u002F267",{"id":116,"question_zh":117,"answer_zh":118,"source_url":119},1372,"从 HuggingFace 加载数据集时遇到网络连接问题怎么办？","可以使用 `--hf_mirror` 标志来解决大多数网络问题，具体请参考项目文档中关于如何从 HuggingFace 镜像加载数据集的说明。","https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Fissues\u002F220",{"id":121,"question_zh":122,"answer_zh":123,"source_url":119},1373,"本地加载 C-Eval 数据集报错提示不存在 'ceval' 该如何解决？","这通常是因为目录不是标准的 HuggingFace 格式。有两种解决方案：1. 使用 `save_to_disk` 将数据集转换为 HF 格式后加载；2. 拉取项目最新更新并修改 `ceval-exam.py` 文件中的 `_URL` 路径指向本地文件。",{"id":125,"question_zh":126,"answer_zh":127,"source_url":128},1374,"LLaMA3 模型微调支持吗？tokenizer 导致的问题如何解决？","当前代码对 LLaMA3 的支持尚不完善。如果遇到 eos token 相关问题，可以尝试设置 `tokenizer.add_eos_token = True` 或更新 TemplateProcessor（参考 transformers 社区 issue #30947）。","https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Fissues\u002F264",{"id":130,"question_zh":131,"answer_zh":132,"source_url":133},1375,"使用 vLLM 进行推理评估时，如何保证生成结果的一致性？","为了准确复现 vLLM 的结果，请手动将温度参数设置为 0（`--temperature 0`），因为默认的非零温度设置会导致生成输出不一致。","https:\u002F\u002Fgithub.com\u002FRUCAIBox\u002FLLMBox\u002Fissues\u002F275",{"id":135,"question_zh":136,"answer_zh":137,"source_url":133},1376,"同时测试多个子集的结果与单独测试每个子集的结果不同是什么原因？","这是由于多 GPU 环境导致的已知问题，维护者正在尝试修复。目前建议关注项目更新以获取修复后的版本。",[]]