[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-huggingface--huggingface-llama-recipes":3,"tool-huggingface--huggingface-llama-recipes":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 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[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":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":68,"owner_location":68,"owner_email":68,"owner_twitter":75,"owner_website":79,"owner_url":80,"languages":81,"stars":90,"forks":91,"last_commit_at":92,"license":68,"difficulty_score":10,"env_os":93,"env_gpu":94,"env_ram":95,"env_deps":96,"category_tags":110,"github_topics":68,"view_count":10,"oss_zip_url":68,"oss_zip_packed_at":68,"status":16,"created_at":111,"updated_at":112,"faqs":113,"releases":143},250,"huggingface\u002Fhuggingface-llama-recipes","huggingface-llama-recipes",null,"huggingface-llama-recipes 是 Hugging Face 官方推出的 Llama 3.x 模型入门教程仓库，提供了简洁的代码示例，帮助开发者快速上手 Llama 3.1、3.2 和 3.3 系列模型。\n\n这个仓库解决了什么问题？很多开发者想使用 Llama 大语言模型，但不知道如何开始。这个仓库提供了“开箱即用”的最小示例，从环境安装到运行推理，一步步引导用户完成整个流程。同时，针对不同的硬件配置，仓库还提供了多种量化方案（如 INT4、FP8 等），帮助用户在有限显存下运行更大的模型。\n\n适合谁使用？主要面向开发者、研究人员和机器学习工程师。如果你想要在本地机器上运行 Llama 模型，或者想对模型进行微调，这个仓库都提供了相应的脚本和教程。\n\n技术亮点包括：支持 4-bit\u002F8-bit 量化推理，大幅降低显存需求；提供针对 405B 超大模型的推理方案；包含完整的微调脚本，支持用户使用自己的数据集定制模型。\n\n需要注意的是，使用 Llama 模型需要先在 Hugging Face 申请访问权限。","# Hugging Face Llama Recipes\n\n![thumbnail for repository](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhuggingface_huggingface-llama-recipes_readme_8787f163ce2d.png)\n\n🤗🦙Welcome! This repository contains *minimal* recipes to get started quickly\nwith **Llama 3.x** models, including **Llama 3.1**, **Llama 3.2**, and **Llama 3.3**.\n\n* To get an overview of Llama 3.1, please visit the [Hugging Face announcement blog post (3.1)](https:\u002F\u002Fhuggingface.co\u002Fblog\u002Fllama31).\n* To get an overview of Llama 3.2, please visit the [Hugging Face announcement blog post (3.2)](https:\u002F\u002Fhuggingface.co\u002Fblog\u002Fllama32).\n* For more advanced end-to-end use cases with open ML, please visit the [Open Source AI Cookbook](https:\u002F\u002Fhuggingface.co\u002Flearn\u002Fcookbook\u002Findex).\n\nThis repository is WIP so that you might see considerable changes in the coming days.\n\n> [!NOTE]\n> To use Llama 3.x, you need to accept the license and request permission\nto access the models. Please visit [the Hugging Face repos](https:\u002F\u002Fhuggingface.co\u002Fmeta-llama)\nand submit your request. You only need to do this once per collection; you'll get access to\nall the repos in the collection if your request is approved.\n\n## Getting Started\n\nThe easiest way to quickly run a Llama 🦙 on your machine would be with the\n🤗 `transformers` repository. Make sure you have the latest release installed.\n\n```shell\n$ pip install -U transformers\n```\n\nLet us conversate with an instruction tuned model.\n\n```python\nimport torch\nfrom transformers import pipeline\n\ndevice = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n\nllama_31 = \"meta-llama\u002FLlama-3.1-8B-Instruct\" # \u003C-- llama 3.1\nllama_32 = \"meta-llama\u002FLlama-3.2-3B-Instruct\" # \u003C-- llama 3.2\n\nprompt = [\n    {\"role\": \"system\", \"content\": \"You are a helpful assistant, that responds as a pirate.\"},\n    {\"role\": \"user\", \"content\": \"What's Deep Learning?\"},\n]\n\ngenerator = pipeline(model=llama_32, device=device, torch_dtype=torch.bfloat16)\ngeneration = generator(\n    prompt,\n    do_sample=False,\n    temperature=1.0,\n    top_p=1,\n    max_new_tokens=50\n)\n\nprint(f\"Generation: {generation[0]['generated_text']}\")\n\n# Generation:\n# [\n#   {'role': 'system', 'content': 'You are a helpful assistant, that responds as a pirate.'},\n#   {'role': 'user', 'content': \"What's Deep Learning?\"},\n#   {'role': 'assistant', 'content': \"Yer lookin' fer a treasure trove o'\n#             knowledge on Deep Learnin', eh? Alright then, listen close and\n#             I'll tell ye about it.\\n\\nDeep Learnin' be a type o' machine\n#             learnin' that uses neural networks\"}\n# ]\n```\n\n## Local Inference\n\nWould you like to run inference of the Llama models locally?\nSo do we! The memory requirements depend on the model size and the\nprecision of the weights. Here's a table showing the approximate\nmemory needed for different configurations:\n\n| Model Size | Llama Variant | BF16\u002FFP16 | FP8 | INT4(AWQ\u002FGPTQ\u002Fbnb) |\n| :--: | :--: | :--: | :--: | :--: |\n| 1B | 3.2 | 2.5 GB | 1.25GB | 0.75GB |\n| 3B | 3.2 |6.5 GB | 3.2GB | 1.75GB |\n| 8B | 3.1 |16 GB | 8GB | 4GB |\n| 70B | 3.1 and 3.3 | 140 GB | 70GB | 35GB |\n|405B | 3.1 |810 GB | 405GB | 204GB |\n\n\n> [!NOTE]\n> These are estimated values and may vary based on specific\nimplementation details and optimizations.\n\nWorking with the capable Llama 3.1 8B models:\n\n* [Run Llama 3.1 8B in 4-bits with bitsandbytes](..\u002Flocal_inference\u002F4bit_bnb.ipynb)\n* [Run Llama 3.1 8B in 8-bits with bitsandbytes](..\u002Flocal_inference\u002F8bit_bnb.ipynb)\n* [Run Llama 3.1 8B with AWQ & fused ops](..\u002Flocal_inference\u002Fawq.ipynb)\n\nWorking on the 🐘 big Llama 3.1 405B model:\n\n* [Run Llama 3.1 405B FP8](..\u002Flocal_inference\u002Ffp8-405B.ipynb)\n* [Run Llama 3.1 405B quantized to INT4 with AWQ](..\u002Flocal_inference\u002Fawq_generation.py)\n* [Run Llama 3.1 405B quantized to INT4 with GPTQ](..\u002Flocal_inference\u002Fgptq_generation.py)\n\n## Model Fine Tuning:\n\nIt is often not enough to run inference on the model.\nMany times, you need to fine-tune the model on some \ncustom dataset. Here are some scripts showing \nhow to fine-tune the models.\n\nFine tune models on your custom dataset:\n* [Fine tune Llama 3.2 Vision on a custom dataset](..\u002Ffine_tune\u002FLlama-Vision%20FT.ipynb)\n* [Supervised Fine Tuning on Llama 3.2 Vision with TRL](..\u002Ffine_tune\u002Fsft_vlm.py)\n* [How to fine-tune Llama 3.1 8B on consumer GPU with PEFT and QLoRA with bitsandbytes](..\u002Ffine_tune\u002Fpeft_finetuning.py)\n* [Execute a distributed fine tuning job for the Llama 3.1 405B model on a SLURM-managed computing cluster](..\u002Ffine_tune\u002Fqlora_405B.slurm)\n\n## Assisted Decoding Techniques\n\nDo you want to use the smaller Llama 3.2 models to speed up text generation\nfor bigger models? These notebooks showcase assisted decoding (speculative decoding), which gives you upto 2x speedups for text generation on Llama 3.1 70B (with greedy decoding).\n\n* [Run assisted decoding with 🐘 Llama 3.1 70B and 🤏 Llama 3.2 3B](..\u002Fassisted_decoding\u002Fassisted_decoding_70B_3B.ipynb)\n* [Run assisted decoding with Llama 3.1 8B and Llama 3.2 1B](..\u002Fassisted_decoding\u002Fassisted_decoding_8B_1B.ipynb)\n* [Assisted Decoding with 405B model](..\u002Fassisted_decoding\u002Fassisted_decoding.py)\n\n## Performance Optimization\n\nLet us optimize performace shall we?\n\n* [Accelerate your inference using torch.compile](..\u002Fperformance_optimization\u002Ftorch_compile.py)\n* [Accelerate your inference using torch.compile and 4-bit quantization with torchao](..\u002Fperformance_optimization\u002Ftorch_compile_with_torchao.ipynb)\n* [Quantize KV Cache to lower memory requirements](..\u002Fperformance_optimization\u002Fquantized_cache.py)\n* [How to reuse prompts with dynamic caching](..\u002Fperformance_optimization\u002Fprompt_reuse.py)\n* [How to setup distributed training utilizing DeepSpeed with mixed-precision and Zero-3 optimization](..\u002Fperformance_optimization\u002Fdeepspeed_zero3.yaml)\n\n## API inference\n\nAre these models too large for you to run at home? Would you like to experiment with Llama 70B? Try out the following examples!\n\n* [Use the Inference API for PRO users](..\u002Fapi_inference\u002Finference-api.ipynb)\n\n## Llama Guard and Prompt Guard\n\nIn addition to the generative models, Meta released two new models: Llama Guard 3 and Prompt Guard. Prompt Guard is a small classifier that detects jailbreaks and prompt injections. Llama Guard 3 is a safeguard model that can classify LLM inputs and generations. Learn how to use them as done in the following notebooks:\n\n* [Detecting jailbreaks and prompt injection with Prompt Guard](..\u002Fllama_guard\u002Fprompt_guard.ipynb)\n* [Integrating Llama Guard in LLM Workflows for detecting prompt safety](..\u002Fllama_guard\u002Fllama_guard_3_1B.ipynb)\n\n## Synthetic Data Generation\nWith the ever hungry models, the need for synthetic data generation is\non the rise. Here we show you how to build your very own synthetic dataset.\n\n* [Generate synthetic data with `distilabel`](..\u002Fsynthetic_data_gen\u002Fsynthetic-data-with-llama.ipynb)\n\n\n## Llama RAG \nSeeking an entry-level RAG pipeline? This notebook guides you through building a very simple streamlined RAG experiment using Llama and Hugging Face.\n\n* [Simple RAG Pipeline](..\u002Fllama_rag\u002Fllama_rag_pipeline.ipynb)\n\n\n## Text Generation Inference (TGI) & API Inference with Llama Models\nText Generation Inference (TGI) framework enables efficient and  scalable deployment of Llama models. In this notebook we'll learn how to integrate TGI for fast text generation and to consume already deployed Llama models via  the Inference API:\n\n* [Text Generation Inference (TGI) with Llama Models](..\u002Fllama_tgi_api_inference\u002Ftgi_api_inference_recipe.ipynb) \n\n## Chatbot Demo with Llama Models \nWould you like to build a chatbot with Llama models? Here's a simple example to get you started.\n\n* [Chatbot with Llama Models](..\u002Fgradio_demos\u002Fchatbot_demo.ipynb)\n\n## Tool Calling\n\nIn this notebook, we explore how to leverage the **tool-calling capabilities** of Llama models, also using and integrating the `chat_template` functionality for tool interactions.\n\n* [Tool calling with Llama Models](..\u002Ftool_calling\u002Ftool_calling.ipynb)\n","# Hugging Face Llama 食谱\n\n![thumbnail for repository](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhuggingface_huggingface-llama-recipes_readme_8787f163ce2d.png)\n\n🤗🦙欢迎！本仓库包含帮助您快速入门 **Llama 3.x** 模型的*最小化*示例，包括 **Llama 3.1**、**Llama 3.2** 和 **Llama 3.3**。\n\n* 想要了解 Llama 3.1 的概述，请访问 [Hugging Face 公告博客 (3.1)](https:\u002F\u002Fhuggingface.co\u002Fblog\u002Fllama31)。\n* 想要了解 Llama 3.2 的概述，请访问 [Hugging Face 公告博客 (3.2)](https:\u002F\u002Fhuggingface.co\u002Fblog\u002Fllama32)。\n* 想要获取更多使用开源机器学习的端到端高级用例，请访问 [开源 AI  Cookbook](https:\u002F\u002Fhuggingface.co\u002Flearn\u002Fcookbook\u002Findex)。\n\n本仓库正在积极开发中，未来几天可能会有重大变化。\n\n> [!NOTE]\n> 要使用 Llama 3.x，您需要接受许可协议并请求访问模型的权限。请访问 [Hugging Face 仓库](https:\u002F\u002Fhuggingface.co\u002Fmeta-llama) 提交您的请求。每个模型系列只需完成一次请求；如果您的请求获批，您将获得该系列所有仓库的访问权限。\n\n## 快速开始\n\n在本地快速运行 Llama 🦙 的最简单方式是使用 🤗 `transformers` 库。请确保已安装最新版本。\n\n```shell\n$ pip install -U transformers\n```\n\n让我们与一个指令微调模型进行对话。\n\n```python\nimport torch\nfrom transformers import pipeline\n\ndevice = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n\nllama_31 = \"meta-llama\u002FLlama-3.1-8B-Instruct\" # \u003C-- llama 3.1\nllama_32 = \"meta-llama\u002FLlama-3.2-3B-Instruct\" # \u003C-- llama 3.2\n\nprompt = [\n    {\"role\": \"system\", \"content\": \"You are a helpful assistant, that responds as a pirate.\"},\n    {\"role\": \"user\", \"content\": \"What's Deep Learning?\"},\n]\n\ngenerator = pipeline(model=llama_32, device=device, torch_dtype=torch.bfloat16)\ngeneration = generator(\n    prompt,\n    do_sample=False,\n    temperature=1.0,\n    top_p=1,\n    max_new_tokens=50\n)\n\nprint(f\"Generation: {generation[0]['generated_text']}\")\n\n# Generation:\n# [\n#   {'role': 'system', 'content': 'You are a helpful assistant, that responds as a pirate.'},\n#   {'role': 'user', 'content': \"What's Deep Learning?\"},\n#   {'role': 'assistant', 'content': \"Yer lookin' fer a treasure trove o'\n#             knowledge on Deep Learnin', eh? Alright then, listen close and\n#             I'll tell ye about it.\\n\\nDeep Learnin' be a type o' machine\n#             learnin' that uses neural networks\"}\n# ]\n```\n\n## 本地推理\n\n您想本地运行 Llama 模型的推理吗？我们也是！内存需求取决于模型大小和权重精度。以下是不同配置所需的大致内存：\n\n| 模型规模 | Llama 变体 | BF16\u002FFP16 | FP8 | INT4(AWQ\u002FGPTQ\u002Fbnb) |\n| :--: | :--: | :--: | :--: | :--: |\n| 1B | 3.2 | 2.5 GB | 1.25GB | 0.75GB |\n| 3B | 3.2 |6.5 GB | 3.2GB | 1.75GB |\n| 8B | 3.1 |16 GB | 8GB | 4GB |\n| 70B | 3.1 和 3.3 | 140 GB | 70GB | 35GB |\n|405B | 3.1 |810 GB | 405GB | 204GB |\n\n\n> [!NOTE]\n> 这些是估计值，具体数值可能因具体实现细节和优化方式而有所不同。\n\n使用强大的 Llama 3.1 8B 模型：\n\n* [使用 bitsandbytes 以 4 位量化运行 Llama 3.1 8B](..\u002Flocal_inference\u002F4bit_bnb.ipynb)\n* [使用 bitsandbytes 以 8 位量化运行 Llama 3.1 8B](..\u002Flocal_inference\u002F8bit_bnb.ipynb)\n* [使用 AWQ 和融合算子运行 Llama 3.1 8B](..\u002Flocal_inference\u002Fawq.ipynb)\n\n使用 🐘 大型 Llama 3.1 405B 模型：\n\n* [运行 Llama 3.1 405B FP8](..\u002Flocal_inference\u002Ffp8-405B.ipynb)\n* [使用 AWQ 将 Llama 3.1 405B 量化至 INT4](..\u002Flocal_inference\u002Fawq_generation.py)\n* [使用 GPTQ 将 Llama 3.1 405B 量化至 INT4](..\u002Flocal_inference\u002Fgptq_generation.py)\n\n## 模型微调：\n\n仅运行模型推理往往是不够的。很多时候，您需要根据自定义数据集对模型进行微调。以下是展示如何微调模型的一些脚本。\n\n根据自定义数据集微调模型：\n* [在自定义数据集上微调 Llama 3.2 Vision](..\u002Ffine_tune\u002FLlama-Vision%20FT.ipynb)\n* [使用 TRL 对 Llama 3.2 Vision 进行监督微调](..\u002Ffine_tune\u002Fsft_vlm.py)\n* [如何使用 bitsandbytes 在消费级 GPU 上使用 PEFT 和 QLoRA 微调 Llama 3.1 8B](..\u002Ffine_tune\u002Fpeft_finetuning.py)\n* [在 SLURM 管理的计算集群上执行 Llama 3.1 405B 模型的分布式微调任务](..\u002Ffine_tune\u002Fqlora_405B.slurm)\n\n## 辅助解码技术\n\n您想使用较小的 Llama 3.2 模型来加速较大模型的文本生成吗？这些笔记本展示了辅助解码（投机解码），使用 Llama 3.1 70B（贪婪解码）可实现高达 2 倍的文本生成加速。\n\n* [使用 🐘 Llama 3.1 70B 和 🤏 Llama 3.2 3B 运行辅助解码](..\u002Fassisted_decoding\u002Fassisted_decoding_70B_3B.ipynb)\n* [使用 Llama 3.1 8B 和 Llama 3.2 1B 运行辅助解码](..\u002Fassisted_decoding\u002Fassisted_decoding_8B_1B.ipynb)\n* [使用 405B 模型进行辅助解码](..\u002Fassisted_decoding\u002Fassisted_decoding.py)\n\n## 性能优化\n\n让我们优化性能吧！\n\n* [使用 torch.compile 加速推理](..\u002Fperformance_optimization\u002Ftorch_compile.py)\n* [使用 torch.compile 和 4 位量化（torchao）加速推理](..\u002Fperformance_optimization\u002Ftorch_compile_with_torchao.ipynb)\n* [量化 KV Cache 以降低内存需求](..\u002Fperformance_optimization\u002Fquantized_cache.py)\n* [如何使用动态缓存重用提示词](..\u002Fperformance_optimization\u002Fprompt_reuse.py)\n* [如何设置使用 DeepSpeed 和混合精度以及 Zero-3 优化的分布式训练](..\u002Fperformance_optimization\u002Fdeepspeed_zero3.yaml)\n\n## API 推理\n\n这些模型对您来说太大而无法在本地运行吗？您想尝试 Llama 70B 吗？请尝试以下示例！\n\n* [为 PRO 用户使用推理 API](..\u002Fapi_inference\u002Finference-api.ipynb)\n\n## Llama Guard 和 Prompt Guard\n\n除了生成模型外，Meta 还发布了两个新模型：Llama Guard 3 和 Prompt Guard。Prompt Guard 是一个小型分类器，用于检测越狱攻击和提示词注入。Llama Guard 3 是一个安全防护模型，可以对 LLM 的输入和生成内容进行分类。以下笔记本展示了如何使用它们：\n\n* [使用 Prompt Guard 检测越狱攻击和提示词注入](..\u002Fllama_guard\u002Fprompt_guard.ipynb)\n* [在 LLM 工作流中集成 Llama Guard 以检测提示词安全性](..\u002Fllama_guard\u002Fllama_guard_3_1B.ipynb)\n\n## 合成数据生成\n\n随着模型对数据的需求不断增长，合成数据生成的需求也在增加。在这里我们将向您展示如何构建自己的合成数据集。\n\n* [使用 `distilabel` 生成合成数据](..\u002Fsynthetic_data_gen\u002Fsynthetic-data-with-llama.ipynb)\n\n## Llama RAG\n\n正在寻找入门级的 RAG 管道吗？本笔记本将引导您使用 Llama 和 Hugging Face 构建一个简单流畅的 RAG 实验。\n\n* [简单 RAG 管道](..\u002Fllama_rag\u002Fllama_rag_pipeline.ipynb)\n\n## 使用 Llama 模型的文本生成推理 (TGI) 与 API 推理\n\n文本生成推理 (TGI，Text Generation Inference) 框架支持 Llama 模型的高效可扩展部署。在本 notebook 中，我们将学习如何集成 TGI 以实现快速文本生成，以及如何通过推理 API (Inference API) 调用已部署的 Llama 模型：\n\n* [使用 Llama 模型的文本生成推理 (TGI)](..\u002Fllama_tgi_api_inference\u002Ftgi_api_inference_recipe.ipynb)\n\n## 使用 Llama 模型的聊天机器人演示\n\n您想使用 Llama 模型构建聊天机器人吗？这里有一个简单的示例，帮助您快速入门。\n\n* [使用 Llama 模型的聊天机器人](..\u002Fgradio_demos\u002Fchatbot_demo.ipynb)\n\n## 工具调用\n\n在本 notebook 中，我们将探索 Llama 模型的**工具调用能力**，同时使用并集成 `chat_template` 功能来实现工具交互。\n\n* [使用 Llama 模型的工具调用](..\u002Ftool_calling\u002Ftool_calling.ipynb)","# Hugging Face Llama Recipes 快速上手指南\n\n## 环境准备\n\n- **Python**: 3.8+\n- **GPU**: 推荐使用 NVIDIA GPU（CUDA 11.8+）\n- **内存**: 根据模型大小需求不同，详见下方\"本地推理\"部分\n\n### 前置依赖\n\n```shell\n# 确保 pip 已是最新版本\npip install -U pip\n```\n\n## 安装步骤\n\n### 1. 安装 transformers（推荐使用国内镜像源）\n\n```shell\n# 方式一：使用清华镜像源\npip install -U transformers -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n\n# 方式二：使用阿里云镜像源\npip install -U transformers -i https:\u002F\u002Fmirrors.aliyun.com\u002Fpypi\u002Fsimple\u002Fsimple\u002F\n```\n\n### 2. 安装其他必要依赖\n\n```shell\n# 安装 torch（根据 CUDA 版本选择）\npip install torch torchvision torchaudio -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n\n# 安装 bitsandbytes（用于量化推理）\npip install bitsandbytes -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n### 3. 申请模型访问权限\n\n> [!IMPORTANT]\n> 使用 Llama 3.x 模型前，需要：\n> 1. 访问 [Hugging Face Llama 仓库](https:\u002F\u002Fhuggingface.co\u002Fmeta-llama) 并接受许可证\n> 2. 提交访问权限申请（通常一次申请可获得整个模型集合的访问权限）\n\n## 基本使用\n\n### 最简单的推理示例\n\n```python\nimport torch\nfrom transformers import pipeline\n\ndevice = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n\n# 可选模型：Llama 3.1 或 Llama 3.2\nllama_31 = \"meta-llama\u002FLlama-3.1-8B-Instruct\"\nllama_32 = \"meta-llama\u002FLlama-3.2-3B-Instruct\"\n\n# 构建提示词\nprompt = [\n    {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n    {\"role\": \"user\", \"content\": \"What's Deep Learning?\"},\n]\n\n# 创建推理管道\ngenerator = pipeline(model=llama_32, device=device, torch_dtype=torch.bfloat16)\n\n# 生成回复\ngeneration = generator(\n    prompt,\n    do_sample=False,\n    temperature=1.0,\n    top_p=1,\n    max_new_tokens=50\n)\n\nprint(generation[0]['generated_text'])\n```\n\n### 本地推理内存需求参考\n\n| 模型大小 | Llama 版本 | BF16\u002FFP16 | FP8 | INT4 量化 |\n|:---:|:---:|:---:|:---:|:---:|\n| 1B | 3.2 | 2.5 GB | 1.25 GB | 0.75 GB |\n| 3B | 3.2 | 6.5 GB | 3.2 GB | 1.75 GB |\n| 8B | 3.1 | 16 GB | 8 GB | 4 GB |\n| 70B | 3.1\u002F3.3 | 140 GB | 70 GB | 35 GB |\n\n### 进阶：4-bit 量化推理\n\n如需在消费级 GPU 上运行大模型，可使用量化技术：\n\n```python\nfrom transformers import AutoModelForCausalLM, AutoTokenizer\nimport bitsandbytes as bnb\n\nmodel = AutoModelForCausalLM.from_pretrained(\n    \"meta-llama\u002FLlama-3.1-8B-Instruct\",\n    load_in_4bit=True,\n    quantization_config=bnb.QuantizationConfig(\n        load_in_4bit=True,\n        bnb_4bit_compute_dtype=torch.bfloat16,\n        bnb_4bit_use_double_quant=True,\n        bnb_4bit_quant_type=\"nf4\"\n    ),\n    device_map=\"auto\"\n)\n```\n\n## 快速链接\n\n仓库还包含更多高级示例：\n\n- **微调**: `fine_tune\u002F` 目录下的 QLoRA、PEFT 示例\n- **性能优化**: `performance_optimization\u002F` 目录下的 torch.compile、DeepSpeed 配置\n- **RAG**: `llama_rag\u002F` 目录下的 RAG 流水线示例\n- **工具调用**: `tool_calling\u002F` 目录下的工具调用示例","# 场景背景\n\n张明是一家中小型科技公司的后端工程师，公司计划在内部部署一个基于 Llama 模型的智能问答系统，为员工提供技术文档查询服务。由于数据安全要求，系统必须运行在本地服务器上，不能调用外部 API。张明需要在有限的时间内完成模型选型、部署和微调。\n\n---\n\n### 没有 huggingface-llama-recipes 时\n\n- 面对 Hugging Face 上众多的 Llama 模型版本（3.1、3.2、3.3），张明不知道该选择哪个版本，也不清楚各个版本的适用场景和性能差异\n- 不了解模型量化的概念和实现方式，8B 模型需要 16GB 内存才能运行，尝试直接加载后服务器直接 OOM 崩溃\n- 网上搜索的示例代码零散且版本过时，很多 API 已经废弃，调试过程踩坑无数\n- 微调模型需要自定义数据集，但网上缺乏完整的微调流程文档，不知道如何处理数据格式和训练参数\n- 每次尝试都像在黑暗中摸索，一个简单的本地运行任务花费了整整一周时间\n\n---\n\n### 使用 huggingface-llama-recipes 后\n\n- 仓库提供了清晰的版本说明和快速开始指南，张明只用了半小时就确定了使用 Llama 3.2-3B-Instruct 模型\n- 内存需求表格帮助他快速了解不同量化方式的资源消耗，选择了 INT4 量化（仅需 1.75GB），在 8GB 内存的服务器上流畅运行\n- 仓库中的 4-bit 和 8-bit 量化示例代码直接可用，只需修改模型名称即可运行\n- 微调脚本提供了完整的数据处理和训练流程，张明只需准备 JSON 格式的问答对数据集，就能启动微调\n- 整个部署和微调流程在两天内完成，系统顺利上线\n\n---\n\nhuggingface-llama-recipes 大幅降低了 Llama 模型的本地部署门槛，让中小团队也能快速拥有自己的本地大模型服务。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhuggingface_huggingface-llama-recipes_67151b07.png","huggingface","Hugging Face","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fhuggingface_90da21a4.png","The AI community building the future.","https:\u002F\u002Fhuggingface.co\u002F","https:\u002F\u002Fgithub.com\u002Fhuggingface",[82,86],{"name":83,"color":84,"percentage":85},"Jupyter Notebook","#DA5B0B",99.8,{"name":87,"color":88,"percentage":89},"Python","#3572A5",0.2,699,84,"2026-04-05T22:45:40","Linux, macOS, Windows","需要 NVIDIA GPU，显存根据模型大小：1B 约 2.5GB，3B 约 6.5GB，8B 约 16GB，70B 约 140GB，405B 约 810GB；支持量化降低显存需求（INT4 模式下 8B 约 4GB）","建议 16GB 以上（根据模型大小调整）",{"notes":97,"python":98,"dependencies":99},"需接受 Meta Llama 许可证并申请访问权限；首次运行需下载模型文件（根据模型大小从几百 MB 到几百 GB 不等）；支持多种量化方式（FP8、INT4\u002FAWQ\u002FGPTQ）降低显存需求；部分高级功能需要 SLURM 集群或分布式训练环境","未说明",[100,101,102,103,104,105,106,107,108,109],"torch","transformers","bitsandbytes","accelerate","deepspeed","peft","trl","torchao","gradio","distilabel",[26,13],"2026-03-27T02:49:30.150509","2026-04-06T07:15:04.328223",[114,119,124,129,134,138],{"id":115,"question_zh":116,"answer_zh":117,"source_url":118},780,"如何解决 deep copy past_key_values 时出现的 RuntimeError？","在第一次调用模型时需要使用 `with torch.no_grad()` 上下文管理器。这是导致 deep copy 失败的根本原因。具体代码示例：在第一次生成时使用 `with torch.no_grad(): outputs = model.generate(...)`，然后再进行 deep copy 操作。","https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fhuggingface-llama-recipes\u002Fissues\u002F33",{"id":120,"question_zh":121,"answer_zh":122,"source_url":123},781,"如何将微调后的 Llama 模型量化并使用 llama.cpp 部署？","可以使用 ggml-org\u002Fgguf-my-repo (https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fggml-org\u002Fgguf-my-repo) 对微调后的 Llama 模型进行量化，然后使用 llama.cpp (https:\u002F\u002Fgithub.com\u002Fggerganov\u002Fllama.cpp) 来服务模型。","https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fhuggingface-llama-recipes\u002Fissues\u002F46",{"id":125,"question_zh":126,"answer_zh":127,"source_url":128},782,"如何集成 Llama Guard 来检测有害的多模态提示和文本响应？","可以参考 PurpleLlama 项目中的 Llama Guard 3-11B-vision Model Card 来集成有害内容检测功能。也可以考虑使用 Llama Guard 3 1B 或 8B 版本。相关参考：https:\u002F\u002Fgithub.com\u002Fmeta-llama\u002FPurpleLlama\u002Fblob\u002Fmain\u002FLlama-Guard3\u002F11B-vision\u002FMODEL_CARD.md","https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fhuggingface-llama-recipes\u002Fissues\u002F53",{"id":130,"question_zh":131,"answer_zh":132,"source_url":133},783,"SRF-RAG 相比传统 RAG 方法有哪些优势？","SRF-RAG 提供以下关键优势：1) 检索（Retrieval）：从外部来源检索相关上下文；2) 生成（Generation）：基于检索到的上下文生成连贯响应；3) 指令调优（Instruction Tuning）：提高对复杂查询的理解；4) 减少幻觉（Hallucination Reduction）：最大程度减少错误或误导性信息；5) 多跳推理（Multi-Hop Reasoning）：通过综合多个来源的信息处理复杂问题。","https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fhuggingface-llama-recipes\u002Fissues\u002F47",{"id":135,"question_zh":136,"answer_zh":137,"source_url":133},784,"如何判断输入是需要 RAG 方法还是可以直接由 LLM 处理？","可以使用 Langchain 设置一个管道（pipeline），根据输入内容自动判断是使用 RAG 方法还是直接由 LLM 处理。这需要分析输入的复杂度、是否需要最新信息或外部知识等因素来决定使用哪种方式。",{"id":139,"question_zh":140,"answer_zh":141,"source_url":142},785,"如何为这个项目贡献新的 notebook 示例？","建议先查看现有仓库中的 notebook，避免重复创建相同功能的示例。如果有新的想法，可以先在 Google Colab 上开发和测试，完成后可以创建 Hugging Face Space 并发布供所有人使用。提交前建议先与维护者沟通，确保想法与项目方向一致。","https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fhuggingface-llama-recipes\u002Fissues\u002F66",[]]