[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-deepseek-ai--DeepSeek-V2":3,"tool-deepseek-ai--DeepSeek-V2":65},[4,17,27,35,48,57],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"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 真正成长为懂上",158594,2,"2026-04-16T23:34:05",[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},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,3,"2026-04-06T11:19:32",[15,26,14,13],"图像",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":10,"last_commit_at":33,"category_tags":34,"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,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":10,"last_commit_at":41,"category_tags":42,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",85092,"2026-04-10T11:13:16",[26,43,44,45,14,46,15,13,47],"数据工具","视频","插件","其他","音频",{"id":49,"name":50,"github_repo":51,"description_zh":52,"stars":53,"difficulty_score":54,"last_commit_at":55,"category_tags":56,"status":16},5784,"funNLP","fighting41love\u002FfunNLP","funNLP 是一个专为中文自然语言处理（NLP）打造的超级资源库，被誉为\"NLP 民工的乐园”。它并非单一的软件工具，而是一个汇集了海量开源项目、数据集、预训练模型和实用代码的综合性平台。\n\n面对中文 NLP 领域资源分散、入门门槛高以及特定场景数据匮乏的痛点，funNLP 提供了“一站式”解决方案。这里不仅涵盖了分词、命名实体识别、情感分析、文本摘要等基础任务的标准工具，还独特地收录了丰富的垂直领域资源，如法律、医疗、金融行业的专用词库与数据集，甚至包含古诗词生成、歌词创作等趣味应用。其核心亮点在于极高的全面性与实用性，从基础的字典词典到前沿的 BERT、GPT-2 模型代码，再到高质量的标注数据和竞赛方案，应有尽有。\n\n无论是刚刚踏入 NLP 领域的学生、需要快速验证想法的算法工程师，还是从事人工智能研究的学者，都能在这里找到急需的“武器弹药”。对于开发者而言，它能大幅减少寻找数据和复现模型的时间；对于研究者，它提供了丰富的基准测试资源和前沿技术参考。funNLP 以开放共享的精神，极大地降低了中文自然语言处理的开发与研究成本，是中文 AI 社区不可或缺的宝藏仓库。",79857,1,"2026-04-08T20:11:31",[15,43,46],{"id":58,"name":59,"github_repo":60,"description_zh":61,"stars":62,"difficulty_score":54,"last_commit_at":63,"category_tags":64,"status":16},6590,"gpt4all","nomic-ai\u002Fgpt4all","GPT4All 是一款让普通电脑也能轻松运行大型语言模型（LLM）的开源工具。它的核心目标是打破算力壁垒，让用户无需依赖昂贵的显卡（GPU）或云端 API，即可在普通的笔记本电脑和台式机上私密、离线地部署和使用大模型。\n\n对于担心数据隐私、希望完全掌控本地数据的企业用户、研究人员以及技术爱好者来说，GPT4All 提供了理想的解决方案。它解决了传统大模型必须联网调用或需要高端硬件才能运行的痛点，让日常设备也能成为强大的 AI 助手。无论是希望构建本地知识库的开发者，还是单纯想体验私有化 AI 聊天的普通用户，都能从中受益。\n\n技术上，GPT4All 基于高效的 `llama.cpp` 后端，支持多种主流模型架构（包括最新的 DeepSeek R1 蒸馏模型），并采用 GGUF 格式优化推理速度。它不仅提供界面友好的桌面客户端，支持 Windows、macOS 和 Linux 等多平台一键安装，还为开发者提供了便捷的 Python 库，可轻松集成到 LangChain 等生态中。通过简单的下载和配置，用户即可立即开始探索本地大模型的无限可能。",77307,"2026-04-11T06:52:37",[15,13],{"id":66,"github_repo":67,"name":68,"description_en":69,"description_zh":70,"ai_summary_zh":70,"readme_en":71,"readme_zh":72,"quickstart_zh":73,"use_case_zh":74,"hero_image_url":75,"owner_login":76,"owner_name":77,"owner_avatar_url":78,"owner_bio":79,"owner_company":80,"owner_location":80,"owner_email":81,"owner_twitter":80,"owner_website":82,"owner_url":83,"languages":80,"stars":84,"forks":85,"last_commit_at":86,"license":87,"difficulty_score":88,"env_os":79,"env_gpu":89,"env_ram":90,"env_deps":91,"category_tags":95,"github_topics":80,"view_count":10,"oss_zip_url":80,"oss_zip_packed_at":80,"status":16,"created_at":96,"updated_at":97,"faqs":98,"releases":134},8223,"deepseek-ai\u002FDeepSeek-V2","DeepSeek-V2","DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model","DeepSeek-V2 是一款由深度求索推出的强大且高效的混合专家（MoE）语言模型。它旨在解决大型人工智能模型在训练成本高昂、推理速度慢以及显存占用过高等核心痛点，让高性能 AI 变得更加经济实惠。\n\n该模型拥有 2360 亿总参数，但在处理每个词元时仅激活 210 亿参数。这种独特的架构设计带来了显著优势：与前代 DeepSeek 67B 相比，DeepSeek-V2 不仅性能更强，还将训练成本降低了 42.5%，推理时的键值缓存（KV Cache）减少了 93.3%，最大生成吞吐量更是提升了 5.76 倍。这意味着它能在保持顶尖智能水平的同时，大幅降低硬件门槛并提升响应速度。\n\nDeepSeek-V2 非常适合各类用户群体。对于开发者和研究人员，它是构建高效应用和探索大模型架构的理想基座，其开源协议友好，便于二次开发与部署；对于企业用户，它能有效降低算力投入；而对于普通用户，通过集成该模型的聊天机器人或应用，也能享受到更快速、更聪明的智能服务。凭借“强性能、低成本、高效率”的特点，DeepSeek-V2 正成为推动大模型落地普及的重要力量。","\u003C!-- markdownlint-disable first-line-h1 -->\n\u003C!-- markdownlint-disable html -->\n\u003C!-- markdownlint-disable no-duplicate-header -->\n\n\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V2\u002Fblob\u002Fmain\u002Ffigures\u002Flogo.svg?raw=true\" width=\"60%\" alt=\"DeepSeek-V2\" \u002F>\n\u003C\u002Fdiv>\n\u003Chr>\n\u003Cdiv align=\"center\" style=\"line-height: 1;\">\n  \u003Ca href=\"https:\u002F\u002Fwww.deepseek.com\u002F\" target=\"_blank\" style=\"margin: 2px;\">\n    \u003Cimg alt=\"Homepage\" src=\"https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V2\u002Fblob\u002Fmain\u002Ffigures\u002Fbadge.svg?raw=true\" style=\"display: inline-block; vertical-align: middle;\"\u002F>\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fchat.deepseek.com\u002F\" target=\"_blank\" style=\"margin: 2px;\">\n    \u003Cimg alt=\"Chat\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F🤖%20Chat-DeepSeek%20V2-536af5?color=536af5&logoColor=white\" style=\"display: inline-block; vertical-align: middle;\"\u002F>\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fdeepseek-ai\" target=\"_blank\" style=\"margin: 2px;\">\n    \u003Cimg alt=\"Hugging Face\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%F0%9F%A4%97%20Hugging%20Face-DeepSeek%20AI-ffc107?color=ffc107&logoColor=white\" style=\"display: inline-block; vertical-align: middle;\"\u002F>\n  \u003C\u002Fa>\n\u003C\u002Fdiv>\n\n\u003Cdiv align=\"center\" style=\"line-height: 1;\">\n  \u003Ca href=\"https:\u002F\u002Fdiscord.gg\u002FTc7c45Zzu5\" target=\"_blank\" style=\"margin: 2px;\">\n    \u003Cimg alt=\"Discord\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDiscord-DeepSeek%20AI-7289da?logo=discord&logoColor=white&color=7289da\" style=\"display: inline-block; vertical-align: middle;\"\u002F>\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V2\u002Fblob\u002Fmain\u002Ffigures\u002Fqr.jpeg?raw=true\" target=\"_blank\" style=\"margin: 2px;\">\n    \u003Cimg alt=\"Wechat\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FWeChat-DeepSeek%20AI-brightgreen?logo=wechat&logoColor=white\" style=\"display: inline-block; vertical-align: middle;\"\u002F>\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Ftwitter.com\u002Fdeepseek_ai\" target=\"_blank\" style=\"margin: 2px;\">\n    \u003Cimg alt=\"Twitter Follow\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTwitter-deepseek_ai-white?logo=x&logoColor=white\" style=\"display: inline-block; vertical-align: middle;\"\u002F>\n  \u003C\u002Fa>\n\u003C\u002Fdiv>\n\n\u003Cdiv align=\"center\" style=\"line-height: 1;\">\n  \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V2\u002Fblob\u002Fmain\u002FLICENSE-CODE\" style=\"margin: 2px;\">\n    \u003Cimg alt=\"Code License\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FCode_License-MIT-f5de53?&color=f5de53\" style=\"display: inline-block; vertical-align: middle;\"\u002F>\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V2\u002Fblob\u002Fmain\u002FLICENSE-MODEL\" style=\"margin: 2px;\">\n    \u003Cimg alt=\"Model License\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FModel_License-Model_Agreement-f5de53?&color=f5de53\" style=\"display: inline-block; vertical-align: middle;\"\u002F>\n  \u003C\u002Fa>\n\u003C\u002Fdiv>\n\n\u003Cp align=\"center\">\n  \u003Ca href=\"#2-model-downloads\">Model Download\u003C\u002Fa> |\n  \u003Ca href=\"#3-evaluation-results\">Evaluation Results\u003C\u002Fa> |\n  \u003Ca href=\"#4-model-architecture\">Model Architecture\u003C\u002Fa> |\n  \u003Ca href=\"#6-api-platform\">API Platform\u003C\u002Fa> |\n  \u003Ca href=\"#8-license\">License\u003C\u002Fa> |\n  \u003Ca href=\"#9-citation\">Citation\u003C\u002Fa>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.04434\">\u003Cb>Paper Link\u003C\u002Fb>👁️\u003C\u002Fa>\n\u003C\u002Fp>\n\n# DeepSeek-V2:  A Strong, Economical, and Efficient Mixture-of-Experts Language Model\n\n## 1. Introduction\nToday, we’re introducing DeepSeek-V2, a strong Mixture-of-Experts (MoE) language model characterized by economical training and efficient inference. It comprises 236B total parameters, of which 21B are activated for each token. Compared with DeepSeek 67B, DeepSeek-V2 achieves stronger performance, and meanwhile saves 42.5% of training costs, reduces the KV cache by 93.3%, and boosts the maximum generation throughput to 5.76 times. \n\n\u003Cp align=\"center\">\n\u003Cdiv style=\"display: flex; justify-content: center;\">\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeepseek-ai_DeepSeek-V2_readme_1a2150718592.png\" style=\"height:300px; width:auto; margin-right:10px\">\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeepseek-ai_DeepSeek-V2_readme_aada4fe91620.png\" style=\"height:300px; width:auto; margin-left:10px\">\n\u003C\u002Fdiv>\n\u003C\u002Fp>\n\nWe pretrained DeepSeek-V2 on a diverse and high-quality corpus comprising 8.1 trillion tokens. This comprehensive pretraining was followed by a process of Supervised Fine-Tuning (SFT) and Reinforcement Learning (RL) to fully unleash the model's capabilities. The evaluation results validate the effectiveness of our approach as DeepSeek-V2 achieves remarkable performance on both standard benchmarks and open-ended generation evaluation.\n\n## 2. News\n\n- 2024.05.16: We released the DeepSeek-V2-Lite.\n- 2024.05.06: We released the DeepSeek-V2.\n\n## 3. Model Downloads\n\n\u003Cdiv align=\"center\">\n\n| **Model** | **#Total Params** | **#Activated Params** | **Context Length** | **Download** |\n| :------------: | :------------: | :------------: | :------------: | :------------: |\n| DeepSeek-V2-Lite | 16B | 2.4B | 32k   | [🤗 HuggingFace](https:\u002F\u002Fhuggingface.co\u002Fdeepseek-ai\u002FDeepSeek-V2-Lite)   |\n| DeepSeek-V2-Lite-Chat (SFT)   | 16B | 2.4B | 32k   | [🤗 HuggingFace](https:\u002F\u002Fhuggingface.co\u002Fdeepseek-ai\u002FDeepSeek-V2-Lite-Chat)   |\n| DeepSeek-V2   | 236B | 21B |  128k   | [🤗 HuggingFace](https:\u002F\u002Fhuggingface.co\u002Fdeepseek-ai\u002FDeepSeek-V2)   |\n| DeepSeek-V2-Chat (RL)   | 236B | 21B |  128k   | [🤗 HuggingFace](https:\u002F\u002Fhuggingface.co\u002Fdeepseek-ai\u002FDeepSeek-V2-Chat)   |\n\n\u003C\u002Fdiv>\n\nDue to the constraints of HuggingFace, the open-source code currently experiences slower performance than our internal codebase when running on GPUs with Huggingface. To facilitate the efficient execution of our model, we offer a dedicated vllm solution that optimizes performance for running our model effectively.\n\n## 4. Evaluation Results\n### Base Model\n#### Standard Benchmark (Models larger than 67B)\n\n\u003Cdiv align=\"center\">\n\n| **Benchmark** | **Domain** | **LLaMA3 70B** | **Mixtral 8x22B** | **DeepSeek-V1 (Dense-67B)** | **DeepSeek-V2 (MoE-236B)** |\n|:-----------:|:--------:|:------------:|:---------------:|:-------------------------:|:------------------------:|\n| **MMLU** | English | 78.9 | 77.6 | 71.3 | 78.5 |\n| **BBH** | English | 81.0 | 78.9 | 68.7 | 78.9 |\n| **C-Eval** | Chinese | 67.5 | 58.6 | 66.1 | 81.7 |\n| **CMMLU** | Chinese | 69.3 | 60.0 | 70.8 | 84.0 |\n| **HumanEval** | Code | 48.2\t| 53.1 | 45.1 | 48.8 |\n| **MBPP** | Code | 68.6 | 64.2 | 57.4 | 66.6 |\n| **GSM8K** | Math | 83.0 | 80.3 | 63.4 | 79.2 |\n| **Math** | Math | 42.2 | 42.5 | 18.7 | 43.6 |\n\n\u003C\u002Fdiv>\n\n#### Standard Benchmark (Models smaller than 16B)\n\u003Cdiv align=\"center\">\n\n| **Benchmark** | **Domain** | **DeepSeek 7B (Dense)** | **DeepSeekMoE 16B** | **DeepSeek-V2-Lite (MoE-16B)** |\n|:-------------:|:----------:|:--------------:|:-----------------:|:--------------------------:|\n| **Architecture**      | -    | MHA+Dense           | MHA+MoE              | MLA+MoE                       |\n| **MMLU**      | English    | 48.2           | 45.0              | 58.3                       |\n| **BBH**       | English    | 39.5           | 38.9              | 44.1                       |\n| **C-Eval**    | Chinese    | 45.0           | 40.6              | 60.3                       |\n| **CMMLU**     | Chinese    | 47.2           | 42.5              | 64.3                       |\n| **HumanEval** | Code       | 26.2           | 26.8              | 29.9                       |\n| **MBPP**      | Code       | 39.0           | 39.2              | 43.2                       |\n| **GSM8K**     | Math       | 17.4           | 18.8              | 41.1                       |\n| **Math**      | Math       | 3.3            | 4.3               | 17.1                       |\n\n\u003C\u002Fdiv>\nFor more evaluation details, such as few-shot settings and prompts, please check our paper. \n\n#### Context Window\n\u003Cp align=\"center\">\n  \u003Cimg width=\"80%\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeepseek-ai_DeepSeek-V2_readme_04acd8a52241.png\">\n\u003C\u002Fp>\n\nEvaluation results on the ``Needle In A Haystack`` (NIAH) tests.  DeepSeek-V2 performs well across all context window lengths up to **128K**. \n\n### Chat Model\n#### Standard Benchmark (Models larger than 67B)\n\u003Cdiv align=\"center\">\n\n| Benchmark | Domain         | QWen1.5 72B Chat | Mixtral 8x22B | LLaMA3 70B Instruct | DeepSeek-V1 Chat (SFT) | DeepSeek-V2 Chat (SFT) | DeepSeek-V2 Chat (RL) |\n|:-----------:|:----------------:|:------------------:|:---------------:|:---------------------:|:-------------:|:-----------------------:|:----------------------:|\n| **MMLU**      | English        | 76.2             | 77.8          | 80.3                | 71.1        | 78.4                 | 77.8                 |\n| **BBH**       | English        | 65.9             | 78.4          | 80.1                | 71.7        | 81.3                 | 79.7                 |\n| **C-Eval**    | Chinese        | 82.2             | 60.0          | 67.9                | 65.2        | 80.9                 | 78.0                 |\n| **CMMLU**     | Chinese        | 82.9             | 61.0          | 70.7                | 67.8        | 82.4                 | 81.6                 |\n| **HumanEval** | Code           | 68.9             | 75.0          | 76.2                | 73.8        | 76.8                 | 81.1                 |\n| **MBPP**      | Code           | 52.2             | 64.4          | 69.8                | 61.4        | 70.4                 | 72.0                 |\n|   **LiveCodeBench  (0901-0401)**     | Code       | 18.8          | 25.0                | 30.5        | 18.3                 | 28.7                 | 32.5                 |\n| **GSM8K**     | Math           | 81.9             | 87.9          | 93.2                | 84.1        | 90.8                 | 92.2                 |\n| **Math**      | Math           | 40.6             | 49.8          | 48.5                | 32.6        | 52.7                 | 53.9                 |\n\n\u003C\u002Fdiv>\n\n#### Standard Benchmark (Models smaller than 16B)\n\n\u003Cdiv align=\"center\">\n\n| Benchmark | Domain         | DeepSeek 7B Chat (SFT) | DeepSeekMoE 16B Chat (SFT) | DeepSeek-V2-Lite 16B Chat (SFT) |\n|:-----------:|:----------------:|:------------------:|:---------------:|:---------------------:|\n| **MMLU**      | English        | 49.7             | 47.2          | 55.7                |\n| **BBH**       | English        | 43.1             | 42.2          | 48.1                |\n| **C-Eval**    | Chinese        | 44.7             | 40.0          | 60.1                |\n| **CMMLU**     | Chinese        | 51.2             | 49.3          | 62.5                |\n| **HumanEval** | Code           | 45.1             | 45.7          | 57.3                |\n| **MBPP**      | Code           | 39.0             | 46.2          | 45.8                |\n| **GSM8K**     | Math           | 62.6             | 62.2          | 72.0                |\n| **Math**      | Math           | 14.7             | 15.2          | 27.9                |\n\n\u003C\u002Fdiv>\n\n#### English Open Ended Generation Evaluation\nWe evaluate our model on AlpacaEval 2.0 and MTBench, showing the competitive performance of DeepSeek-V2-Chat-RL on English conversation generation. \n\u003Cp align=\"center\">\n  \u003Cimg width=\"50%\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeepseek-ai_DeepSeek-V2_readme_a78c318cdc2b.png\" \u002F>\n\u003C\u002Fp>\n\n#### Chinese Open Ended Generation Evaluation\n**Alignbench** (https:\u002F\u002Farxiv.org\u002Fabs\u002F2311.18743)\n\u003Cdiv align=\"center\">\n\n| **模型** | **开源\u002F闭源** | **总分** | **中文推理** | **中文语言** |\n| :---: | :---: | :---: | :---: | :---: |\n| gpt-4-1106-preview | 闭源 | 8.01 | 7.73 | 8.29 |\n| DeepSeek-V2 Chat (RL) | 开源 | 7.91 | 7.45 | 8.36 |\n| erniebot-4.0-202404 (文心一言) | 闭源 | 7.89 | 7.61 | 8.17 |\n| DeepSeek-V2 Chat (SFT) | 开源 | 7.74 | 7.30 | 8.17 |\n| gpt-4-0613 | 闭源 | 7.53 | 7.47 | 7.59 |\n| erniebot-4.0-202312 (文心一言) | 闭源 | 7.36 | 6.84 | 7.88 |\n| moonshot-v1-32k-202404 (月之暗面) | 闭源 | 7.22 | 6.42 | 8.02 |\n| Qwen1.5-72B-Chat (通义千问) | 开源 | 7.19 | 6.45 | 7.93 |\n| DeepSeek-67B-Chat | 开源 | 6.43 | 5.75 | 7.11 |\n| Yi-34B-Chat (零一万物) | 开源 | 6.12 | 4.86 | 7.38 |\n| gpt-3.5-turbo-0613 | 闭源 | 6.08 | 5.35 | 6.71 |\n| DeepSeek-V2-Lite 16B Chat | 开源 | 6.01 | 4.71 | 7.32 |\n\n\u003C\u002Fdiv>\n\n#### Coding Benchmarks\nWe evaluate our model on LiveCodeBench (0901-0401), a benchmark designed for live coding challenges. As illustrated, DeepSeek-V2 demonstrates considerable proficiency in LiveCodeBench, achieving a Pass@1 score that surpasses several other sophisticated models. This performance highlights the model's effectiveness in tackling live coding tasks.\n\n\u003Cp align=\"center\">\n  \u003Cimg width=\"50%\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeepseek-ai_DeepSeek-V2_readme_4a02365c20bb.png\">\n\u003C\u002Fp>\n\n## 5. Model Architecture\nDeepSeek-V2 adopts innovative architectures to guarantee economical training and efficient inference： \n- For attention, we design MLA (Multi-head Latent Attention), which utilizes low-rank key-value union compression to eliminate the bottleneck of inference-time key-value cache, thus supporting efficient inference. \n- For Feed-Forward Networks (FFNs), we adopt DeepSeekMoE architecture, a high-performance MoE architecture that enables training stronger models at lower costs. \n\n\u003Cp align=\"center\">\n  \u003Cimg width=\"90%\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeepseek-ai_DeepSeek-V2_readme_87784b5f5212.png\" \u002F>\n\u003C\u002Fp>\n\n## 6. Chat Website\nYou can chat with the DeepSeek-V2 on DeepSeek's official website: [chat.deepseek.com](https:\u002F\u002Fchat.deepseek.com\u002Fsign_in)\n\n## 7. API Platform\nWe also provide OpenAI-Compatible API at DeepSeek Platform: [platform.deepseek.com](https:\u002F\u002Fplatform.deepseek.com\u002F). Sign up for over millions of free tokens. And you can also pay-as-you-go at an unbeatable price.\n\n\n\u003Cp align=\"center\">\n  \u003Cimg width=\"40%\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeepseek-ai_DeepSeek-V2_readme_6235390167c5.png\">\n\u003C\u002Fp>\n\n## 8. How to run locally\n**To utilize DeepSeek-V2 in BF16 format for inference, 80GB*8 GPUs are required.**\n### Inference with Huggingface's Transformers\nYou can directly employ [Huggingface's Transformers](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftransformers) for model inference.\n\n#### Text Completion\n```python\nimport torch\nfrom transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig\n\nmodel_name = \"deepseek-ai\u002FDeepSeek-V2\"\ntokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)\n# `max_memory` should be set based on your devices\nmax_memory = {i: \"75GB\" for i in range(8)}\n# `device_map` cannot be set to `auto`\nmodel = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True, device_map=\"sequential\", torch_dtype=torch.bfloat16, max_memory=max_memory, attn_implementation=\"eager\")\nmodel.generation_config = GenerationConfig.from_pretrained(model_name)\nmodel.generation_config.pad_token_id = model.generation_config.eos_token_id\n\ntext = \"An attention function can be described as mapping a query and a set of key-value pairs to an output, where the query, keys, values, and output are all vectors. The output is\"\ninputs = tokenizer(text, return_tensors=\"pt\")\noutputs = model.generate(**inputs.to(model.device), max_new_tokens=100)\n\nresult = tokenizer.decode(outputs[0], skip_special_tokens=True)\nprint(result)\n```\n\n#### Chat Completion\n```python\nimport torch\nfrom transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig\n\nmodel_name = \"deepseek-ai\u002FDeepSeek-V2-Chat\"\ntokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)\n# `max_memory` should be set based on your devices\nmax_memory = {i: \"75GB\" for i in range(8)}\n# `device_map` cannot be set to `auto`\nmodel = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True, device_map=\"sequential\", torch_dtype=torch.bfloat16, max_memory=max_memory, attn_implementation=\"eager\")\nmodel.generation_config = GenerationConfig.from_pretrained(model_name)\nmodel.generation_config.pad_token_id = model.generation_config.eos_token_id\n\nmessages = [\n    {\"role\": \"user\", \"content\": \"Write a piece of quicksort code in C++\"}\n]\ninput_tensor = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors=\"pt\")\noutputs = model.generate(input_tensor.to(model.device), max_new_tokens=100)\n\nresult = tokenizer.decode(outputs[0][input_tensor.shape[1]:], skip_special_tokens=True)\nprint(result)\n```\n\nThe complete chat template can be found within `tokenizer_config.json` located in the huggingface model repository.\n\nAn example of chat template is as belows:\n\n```bash\n\u003C｜begin▁of▁sentence｜>User: {user_message_1}\n\nAssistant: {assistant_message_1}\u003C｜end▁of▁sentence｜>User: {user_message_2}\n\nAssistant:\n```\n\nYou can also add an optional system message:\n\n```bash\n\u003C｜begin▁of▁sentence｜>{system_message}\n\nUser: {user_message_1}\n\nAssistant: {assistant_message_1}\u003C｜end▁of▁sentence｜>User: {user_message_2}\n\nAssistant:\n```\n### Inference with SGLang (recommended)\n\n[SGLang](https:\u002F\u002Fgithub.com\u002Fsgl-project\u002Fsglang) currently supports MLA optimizations, FP8 (W8A8), FP8 KV Cache, and Torch Compile, offering the best latency and throughput among open-source frameworks. Here are some example commands to launch an OpenAI API-compatible server:\n\n```bash\n# BF16, tensor parallelism = 8\npython3 -m sglang.launch_server --model deepseek-ai\u002FDeepSeek-V2-Chat --tp 8 --trust-remote-code\n\n# BF16, w\u002F torch.compile (The compilation can take several minutes)\npython3 -m sglang.launch_server --model deepseek-ai\u002FDeepSeek-V2-Lite-Chat --trust-remote-code --enable-torch-compile\n\n# FP8, tensor parallelism = 8, FP8 KV cache\npython3 -m sglang.launch_server --model deepseek-ai\u002FDeepSeek-V2-Chat --tp 8 --trust-remote-code --quant fp8 --kv-cache-dtype fp8_e5m2\n```\n\nAfter launching the server, you can query it with OpenAI API\n\n```\nimport openai\nclient = openai.Client(\n    base_url=\"http:\u002F\u002F127.0.0.1:30000\u002Fv1\", api_key=\"EMPTY\")\n\n# Chat completion\nresponse = client.chat.completions.create(\n    model=\"default\",\n    messages=[\n        {\"role\": \"system\", \"content\": \"You are a helpful AI assistant\"},\n        {\"role\": \"user\", \"content\": \"List 3 countries and their capitals.\"},\n    ],\n    temperature=0,\n    max_tokens=64,\n)\nprint(response)\n```\n\n### Inference with vLLM (recommended)\nTo utilize [vLLM](https:\u002F\u002Fgithub.com\u002Fvllm-project\u002Fvllm) for model inference, please merge this Pull Request into your vLLM codebase: https:\u002F\u002Fgithub.com\u002Fvllm-project\u002Fvllm\u002Fpull\u002F4650.\n\n```python\nfrom transformers import AutoTokenizer\nfrom vllm import LLM, SamplingParams\n\nmax_model_len, tp_size = 8192, 8\nmodel_name = \"deepseek-ai\u002FDeepSeek-V2-Chat\"\ntokenizer = AutoTokenizer.from_pretrained(model_name)\nllm = LLM(model=model_name, tensor_parallel_size=tp_size, max_model_len=max_model_len, trust_remote_code=True, enforce_eager=True)\nsampling_params = SamplingParams(temperature=0.3, max_tokens=256, stop_token_ids=[tokenizer.eos_token_id])\n\nmessages_list = [\n    [{\"role\": \"user\", \"content\": \"Who are you?\"}],\n    [{\"role\": \"user\", \"content\": \"Translate the following content into Chinese directly: DeepSeek-V2 adopts innovative architectures to guarantee economical training and efficient inference.\"}],\n    [{\"role\": \"user\", \"content\": \"Write a piece of quicksort code in C++.\"}],\n]\n\nprompt_token_ids = [tokenizer.apply_chat_template(messages, add_generation_prompt=True) for messages in messages_list]\n\noutputs = llm.generate(prompt_token_ids=prompt_token_ids, sampling_params=sampling_params)\n\ngenerated_text = [output.outputs[0].text for output in outputs]\nprint(generated_text)\n```\n\n### LangChain Support\nSince our API is compatible with OpenAI, you can easily use it in [langchain](https:\u002F\u002Fwww.langchain.com\u002F).\nHere is an example:\n\n```\nfrom langchain_openai import ChatOpenAI\nllm = ChatOpenAI(\n    model='deepseek-chat',\n    openai_api_key=\u003Cyour-deepseek-api-key>,\n    openai_api_base='https:\u002F\u002Fapi.deepseek.com\u002Fv1',\n    temperature=0.85,\n    max_tokens=8000)\n``` \n## 9. License\nThis code repository is licensed under [the MIT License](LICENSE-CODE). The use of DeepSeek-V2 Base\u002FChat models is subject to [the Model License](LICENSE-MODEL). DeepSeek-V2 series (including Base and Chat) supports commercial use.\n\n## 10. Citation\n```\n@misc{deepseekv2,\n      title={DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model}, \n      author={DeepSeek-AI},\n      year={2024},\n      eprint={2405.04434},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL}\n}\n```\n\n## 11. Contact\nIf you have any questions, please raise an issue or contact us at [service@deepseek.com](service@deepseek.com).\n","\u003C!-- markdownlint-disable first-line-h1 -->\n\u003C!-- markdownlint-disable html -->\n\u003C!-- markdownlint-disable no-duplicate-header -->\n\n\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V2\u002Fblob\u002Fmain\u002Ffigures\u002Flogo.svg?raw=true\" width=\"60%\" alt=\"DeepSeek-V2\" \u002F>\n\u003C\u002Fdiv>\n\u003Chr>\n\u003Cdiv align=\"center\" style=\"line-height: 1;\">\n  \u003Ca href=\"https:\u002F\u002Fwww.deepseek.com\u002F\" target=\"_blank\" style=\"margin: 2px;\">\n    \u003Cimg alt=\"首页\" src=\"https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V2\u002Fblob\u002Fmain\u002Ffigures\u002Fbadge.svg?raw=true\" style=\"display: inline-block; vertical-align: middle;\"\u002F>\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fchat.deepseek.com\u002F\" target=\"_blank\" style=\"margin: 2px;\">\n    \u003Cimg alt=\"聊天\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F🤖%20Chat-DeepSeek%20V2-536af5?color=536af5&logoColor=white\" style=\"display: inline-block; vertical-align: middle;\"\u002F>\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fdeepseek-ai\" target=\"_blank\" style=\"margin: 2px;\">\n    \u003Cimg alt=\"Hugging Face\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%F0%9F%A4%97%20Hugging%20Face-DeepSeek%20AI-ffc107?color=ffc107&logoColor=white\" style=\"display: inline-block; vertical-align: middle;\"\u002F>\n  \u003C\u002Fa>\n\u003C\u002Fdiv>\n\n\u003Cdiv align=\"center\" style=\"line-height: 1;\">\n  \u003Ca href=\"https:\u002F\u002Fdiscord.gg\u002FTc7c45Zzu5\" target=\"_blank\" style=\"margin: 2px;\">\n    \u003Cimg alt=\"Discord\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDiscord-DeepSeek%20AI-7289da?logo=discord&logoColor=white&color=7289da\" style=\"display: inline-block; vertical-align: middle;\"\u002F>\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V2\u002Fblob\u002Fmain\u002Ffigures\u002Fqr.jpeg?raw=true\" target=\"_blank\" style=\"margin: 2px;\">\n    \u003Cimg alt=\"微信\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FWeChat-DeepSeek%20AI-brightgreen?logo=wechat&logoColor=white\" style=\"display: inline-block; vertical-align: middle;\"\u002F>\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Ftwitter.com\u002Fdeepseek_ai\" target=\"_blank\" style=\"margin: 2px;\">\n    \u003Cimg alt=\"Twitter关注\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTwitter-deepseek_ai-white?logo=x&logoColor=white\" style=\"display: inline-block; vertical-align: middle;\"\u002F>\n  \u003C\u002Fa>\n\u003C\u002Fdiv>\n\n\u003Cdiv align=\"center\" style=\"line-height: 1;\">\n  \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V2\u002Fblob\u002Fmain\u002FLICENSE-CODE\" style=\"margin: 2px;\">\n    \u003Cimg alt=\"代码许可证\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FCode_License-MIT-f5de53?&color=f5de53\" style=\"display: inline-block; vertical-align: middle;\"\u002F>\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V2\u002Fblob\u002Fmain\u002FLICENSE-MODEL\" style=\"margin: 2px;\">\n    \u003Cimg alt=\"模型许可证\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FModel_License-Model_Agreement-f5de53?&color=f5de53\" style=\"display: inline-block; vertical-align: middle;\"\u002F>\n  \u003C\u002Fa>\n\u003C\u002Fdiv>\n\n\u003Cp align=\"center\">\n  \u003Ca href=\"#2-model-downloads\">模型下载\u003C\u002Fa> |\n  \u003Ca href=\"#3-evaluation-results\">评估结果\u003C\u002Fa> |\n  \u003Ca href=\"#4-model-architecture\">模型架构\u003C\u002Fa> |\n  \u003Ca href=\"#6-api-platform\">API平台\u003C\u002Fa> |\n  \u003Ca href=\"#8-license\">许可证\u003C\u002Fa> |\n  \u003Ca href=\"#9-citation\">引用\u003C\u002Fa>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.04434\">\u003Cb>论文链接\u003C\u002Fb>👁️\u003C\u002Fa>\n\u003C\u002Fp>\n\n# DeepSeek-V2：一款强大、经济高效且高效的专家混合语言模型\n\n## 1. 引言\n今天，我们隆重推出DeepSeek-V2，这是一款强大的专家混合（MoE）语言模型，以其经济高效的训练和高效的推理能力而著称。该模型总参数量为2360亿，其中每次处理一个token时仅激活210亿个参数。与DeepSeek 67B相比，DeepSeek-V2不仅性能更优，还节省了42.5%的训练成本，将KV缓存减少了93.3%，并将最大生成吞吐量提升了5.76倍。\n\n\u003Cp align=\"center\">\n\u003Cdiv style=\"display: flex; justify-content: center;\">\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeepseek-ai_DeepSeek-V2_readme_1a2150718592.png\" style=\"height:300px; width:auto; margin-right:10px\">\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeepseek-ai_DeepSeek-V2_readme_aada4fe91620.png\" style=\"height:300px; width:auto; margin-left:10px\">\n\u003C\u002Fdiv>\n\u003C\u002Fp>\n\n我们在包含8.1万亿个token的多样化高质量语料库上预训练了DeepSeek-V2。全面的预训练之后，我们又进行了监督微调（SFT）和强化学习（RL），以充分释放模型的能力。评估结果证明了我们方法的有效性：DeepSeek-V2在标准基准测试以及开放式生成评估中均表现出色。\n\n## 2. 新闻\n\n- 2024年5月16日：我们发布了DeepSeek-V2-Lite。\n- 2024年5月6日：我们发布了DeepSeek-V2。\n\n## 3. 模型下载\n\n\u003Cdiv align=\"center\">\n\n| **模型** | **总参数量** | **激活参数量** | **上下文长度** | **下载** |\n| :------------: | :------------: | :------------: | :------------: | :------------: |\n| DeepSeek-V2-Lite | 160亿 | 24亿 | 32k   | [🤗 HuggingFace](https:\u002F\u002Fhuggingface.co\u002Fdeepseek-ai\u002FDeepSeek-V2-Lite)   |\n| DeepSeek-V2-Lite-Chat (SFT)   | 160亿 | 24亿 | 32k   | [🤗 HuggingFace](https:\u002F\u002Fhuggingface.co\u002Fdeepseek-ai\u002FDeepSeek-V2-Lite-Chat)   |\n| DeepSeek-V2   | 2360亿 | 210亿 |  128k   | [🤗 HuggingFace](https:\u002F\u002Fhuggingface.co\u002Fdeepseek-ai\u002FDeepSeek-V2)   |\n| DeepSeek-V2-Chat (RL)   | 2360亿 | 210亿 |  128k   | [🤗 HuggingFace](https:\u002F\u002Fhuggingface.co\u002Fdeepseek-ai\u002FDeepSeek-V2-Chat)   |\n\n\u003C\u002Fdiv>\n\n由于HuggingFace平台的限制，在使用HuggingFace运行于GPU上的代码时，开源代码的性能目前仍不及我们的内部代码库。为了便于高效运行我们的模型，我们提供了一个专门的vllm解决方案，可优化性能，从而更有效地运行我们的模型。\n\n## 4. 評估結果\n\n### 基础模型\n#### 标准基准测试（模型参数量大于67B）\n\n\u003Cdiv align=\"center\">\n\n| **基准测试** | **领域** | **LLaMA3 70B** | **Mixtral 8x22B** | **DeepSeek-V1（密集型-67B）** | **DeepSeek-V2（MoE-236B）** |\n|:-----------:|:--------:|:------------:|:---------------:|:-------------------------:|:------------------------:|\n| **MMLU** | 英语 | 78.9 | 77.6 | 71.3 | 78.5 |\n| **BBH** | 英语 | 81.0 | 78.9 | 68.7 | 78.9 |\n| **C-Eval** | 中文 | 67.5 | 58.6 | 66.1 | 81.7 |\n| **CMMLU** | 中文 | 69.3 | 60.0 | 70.8 | 84.0 |\n| **HumanEval** | 代码 | 48.2\t| 53.1 | 45.1 | 48.8 |\n| **MBPP** | 代码 | 68.6 | 64.2 | 57.4 | 66.6 |\n| **GSM8K** | 数学 | 83.0 | 80.3 | 63.4 | 79.2 |\n| **Math** | 数学 | 42.2 | 42.5 | 18.7 | 43.6 |\n\n\u003C\u002Fdiv>\n\n#### 标准基准测试（模型参数量小于16B）\n\u003Cdiv align=\"center\">\n\n| **基准测试** | **领域** | **DeepSeek 7B（密集型）** | **DeepSeekMoE 16B** | **DeepSeek-V2-Lite（MoE-16B）** |\n|:-------------:|:----------:|:--------------:|:-----------------:|:--------------------------:|\n| **架构**      | -    | MHA+密集 | MHA+MoE | MLA+MoE |\n| **MMLU**      | 英语    | 48.2           | 45.0              | 58.3                       |\n| **BBH**       | 英语    | 39.5           | 38.9              | 44.1                       |\n| **C-Eval**    | 中文    | 45.0           | 40.6              | 60.3                       |\n| **CMMLU**     | 中文    | 47.2           | 42.5              | 64.3                       |\n| **HumanEval** | 代码       | 26.2           | 26.8              | 29.9                       |\n| **MBPP**      | 代码       | 39.0           | 39.2              | 43.2                       |\n| **GSM8K**     | 数学       | 17.4           | 18.8              | 41.1                       |\n| **Math**      | 数学       | 3.3            | 4.3               | 17.1                       |\n\n\u003C\u002Fdiv>\n更多评估细节，如少样本设置和提示词，请参阅我们的论文。\n\n#### 上下文窗口\n\u003Cp align=\"center\">\n  \u003Cimg width=\"80%\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeepseek-ai_DeepSeek-V2_readme_04acd8a52241.png\">\n\u003C\u002Fp>\n\n在“针中找针”（NIAH）测试中的评估结果。DeepSeek-V2 在所有上下文窗口长度上均表现出色，最长可达 **128K**。\n\n### 对话模型\n#### 标准基准测试（模型参数量大于67B）\n\u003Cdiv align=\"center\">\n\n| 基准测试 | 领域         | QWen1.5 72B Chat | Mixtral 8x22B | LLaMA3 70B Instruct | DeepSeek-V1 Chat（SFT） | DeepSeek-V2 Chat（SFT） | DeepSeek-V2 Chat（RL） |\n|:-----------:|:----------------:|:------------------:|:---------------:|:---------------------:|:-------------:|:-----------------------:|:----------------------:|\n| **MMLU**      | 英语        | 76.2             | 77.8          | 80.3                | 71.1        | 78.4                 | 77.8                 |\n| **BBH**       | 英语        | 65.9             | 78.4          | 80.1                | 71.7        | 81.3                 | 79.7                 |\n| **C-Eval**    | 中文        | 82.2             | 60.0          | 67.9                | 65.2        | 80.9                 | 78.0                 |\n| **CMMLU**     | 中文        | 82.9             | 61.0          | 70.7                | 67.8        | 82.4                 | 81.6                 |\n| **HumanEval** | 代码           | 68.9             | 75.0          | 76.2                | 73.8        | 76.8                 | 81.1                 |\n| **MBPP**      | 代码           | 52.2             | 64.4          | 69.8                | 61.4        | 70.4                 | 72.0                 |\n|   **LiveCodeBench  (0901-0401)**     | 代码       | 18.8          | 25.0                | 30.5        | 18.3                 | 28.7                 | 32.5                 |\n| **GSM8K**     | 数学           | 81.9             | 87.9          | 93.2                | 84.1        | 90.8                 | 92.2                 |\n| **Math**      | 数学           | 40.6             | 49.8          | 48.5                | 32.6        | 52.7                 | 53.9                 |\n\n\u003C\u002Fdiv>\n\n#### 标准基准测试（模型参数量小于16B）\n\n\u003Cdiv align=\"center\">\n\n| 基准测试 | 领域         | DeepSeek 7B Chat（SFT） | DeepSeekMoE 16B Chat（SFT） | DeepSeek-V2-Lite 16B Chat（SFT） |\n|:-----------:|:----------------:|:------------------:|:---------------:|:---------------------:|\n| **MMLU**      | 英语        | 49.7             | 47.2          | 55.7                |\n| **BBH**       | 英语        | 43.1             | 42.2          | 48.1                |\n| **C-Eval**    | 中文        | 44.7             | 40.0          | 60.1                |\n| **CMMLU**     | 中文        | 51.2             | 49.3          | 62.5                |\n| **HumanEval** | 代码           | 45.1             | 45.7          | 57.3                |\n| **MBPP**      | 代码           | 39.0             | 46.2          | 45.8                |\n| **GSM8K**     | 数学           | 62.6             | 62.2          | 72.0                |\n| **Math**      | 数学           | 14.7             | 15.2          | 27.9                |\n\n\u003C\u002Fdiv>\n\n#### 英语开放式生成评估\n我们在 AlpacaEval 2.0 和 MTBench 上对我们的模型进行了评估，结果显示 DeepSeek-V2-Chat-RL 在英语对话生成方面具有竞争力。\n\u003Cp align=\"center\">\n  \u003Cimg width=\"50%\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeepseek-ai_DeepSeek-V2_readme_a78c318cdc2b.png\" \u002F>\n\u003C\u002Fp>\n\n#### 中文开放式生成评估\n**Alignbench**（https:\u002F\u002Farxiv.org\u002Fabs\u002F2311.18743）\n\u003Cdiv align=\"center\">\n\n| **模型** | **开源\u002F闭源** | **总分** | **中文推理** | **中文语言** |\n| :---: | :---: | :---: | :---: | :---: |\n| gpt-4-1106-preview | 闭源 | 8.01 | 7.73 | 8.29 |\n| DeepSeek-V2 Chat（RL） | 开源 | 7.91 | 7.45 | 8.36 |\n| erniebot-4.0-202404（文心一言） | 闭源 | 7.89 | 7.61 | 8.17 |\n| DeepSeek-V2 Chat（SFT） | 开源 | 7.74 | 7.30 | 8.17 |\n| gpt-4-0613 | 闭源 | 7.53 | 7.47 | 7.59 |\n| erniebot-4.0-202312（文心一言） | 闭源 | 7.36 | 6.84 | 7.88 |\n| moonshot-v1-32k-202404（月之暗面） | 闭源 | 7.22 | 6.42 | 8.02 |\n| Qwen1.5-72B-Chat（通义千问） | 开源 | 7.19 | 6.45 | 7.93 |\n| DeepSeek-67B-Chat | 开源 | 6.43 | 5.75 | 7.11 |\n| Yi-34B-Chat（零一万物） | 开源 | 6.12 | 4.86 | 7.38 |\n| gpt-3.5-turbo-0613 | 闭源 | 6.08 | 5.35 | 6.71 |\n| DeepSeek-V2-Lite 16B Chat | 开源 | 6.01 | 4.71 | 7.32 |\n\n\u003C\u002Fdiv>\n\n#### 编码基准测试\n我们在 LiveCodeBench（0901-0401）上对我们的模型进行了评估，该基准测试专为实时编码挑战而设计。正如所示，DeepSeek-V2 在 LiveCodeBench 中表现出相当高的水平，其 Pass@1 分数超越了其他一些复杂模型。这一表现凸显了该模型在处理实时编码任务方面的有效性。\n\n\u003Cp align=\"center\">\n  \u003Cimg width=\"50%\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeepseek-ai_DeepSeek-V2_readme_4a02365c20bb.png\">\n\u003C\u002Fp>\n\n## 5. 模型架构\nDeepSeek-V2 采用了创新的架构，以确保经济高效的训练和高效的推理：\n\n- 在注意力机制方面，我们设计了 MLA（多头潜在注意力），它利用低秩键值联合压缩来消除推理时键值缓存的瓶颈，从而支持高效的推理。\n- 对于前馈网络（FFN），我们采用了 DeepSeekMoE 架构，这是一种高性能的 MoE 架构，能够在更低的成本下训练出更强大的模型。\n\n\u003Cp align=\"center\">\n  \u003Cimg width=\"90%\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeepseek-ai_DeepSeek-V2_readme_87784b5f5212.png\" \u002F>\n\u003C\u002Fp>\n\n## 6. 聊天网站\n您可以在 DeepSeek 的官方网站上与 DeepSeek-V2 进行对话：[chat.deepseek.com](https:\u002F\u002Fchat.deepseek.com\u002Fsign_in)\n\n## 7. API 平台\n我们还在 DeepSeek 平台上提供了与 OpenAI 兼容的 API：[platform.deepseek.com](https:\u002F\u002Fplatform.deepseek.com\u002F)。注册即可获得数百万个免费 Token，并且还可以按需付费，价格极具竞争力。\n\n\u003Cp align=\"center\">\n  \u003Cimg width=\"40%\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeepseek-ai_DeepSeek-V2_readme_6235390167c5.png\">\n\u003C\u002Fp>\n\n## 8. 如何在本地运行\n**要在 BF16 格式下使用 DeepSeek-V2 进行推理，需要 80GB 显存的 8 张 GPU。**\n### 使用 Hugging Face 的 Transformers 进行推理\n您可以直接使用 [Hugging Face 的 Transformers](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftransformers) 进行模型推理。\n\n#### 文本补全\n```python\nimport torch\nfrom transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig\n\nmodel_name = \"deepseek-ai\u002FDeepSeek-V2\"\ntokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)\n# `max_memory` 应根据您的设备设置\nmax_memory = {i: \"75GB\" for i in range(8)}\n# `device_map` 不能设置为 `auto`\nmodel = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True, device_map=\"sequential\", torch_dtype=torch.bfloat16, max_memory=max_memory, attn_implementation=\"eager\")\nmodel.generation_config = GenerationConfig.from_pretrained(model_name)\nmodel.generation_config.pad_token_id = model.generation_config.eos_token_id\n\ntext = \"An attention function can be described as mapping a query and a set of key-value pairs to an output, where the query, keys, values, and output are all vectors. The output is\"\ninputs = tokenizer(text, return_tensors=\"pt\")\noutputs = model.generate(**inputs.to(model.device), max_new_tokens=100)\n\nresult = tokenizer.decode(outputs[0], skip_special_tokens=True)\nprint(result)\n```\n\n#### 聊天补全\n```python\nimport torch\nfrom transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig\n\nmodel_name = \"deepseek-ai\u002FDeepSeek-V2-Chat\"\ntokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)\n# `max_memory` 应根据您的设备设置\nmax_memory = {i: \"75GB\" for i in range(8)}\n# `device_map` 不能设置为 `auto`\nmodel = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True, device_map=\"sequential\", torch_dtype=torch.bfloat16, max_memory=max_memory, attn_implementation=\"eager\")\nmodel.generation_config = GenerationConfig.from_pretrained(model_name)\nmodel.generation_config.pad_token_id = model.generation_config.eos_token_id\n\nmessages = [\n    {\"role\": \"user\", \"content\": \"Write a piece of quicksort code in C++\"}\n]\ninput_tensor = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors=\"pt\")\noutputs = model.generate(input_tensor.to(model.device), max_new_tokens=100)\n\nresult = tokenizer.decode(outputs[0][input_tensor.shape[1]:], skip_special_tokens=True)\nprint(result)\n```\n\n完整的聊天模板可以在 Hugging Face 模型仓库中的 `tokenizer_config.json` 文件中找到。\n\n聊天模板示例如下：\n\n```bash\n\u003C｜begin▁of▁sentence｜>User: {user_message_1}\n\nAssistant: {assistant_message_1}\u003C｜end▁of▁sentence｜>User: {user_message_2}\n\nAssistant:\n```\n\n您也可以添加一个可选的系统消息：\n\n```bash\n\u003C｜begin▁of▁sentence｜>{system_message}\n\nUser: {user_message_1}\n\nAssistant: {assistant_message_1}\u003C｜end▁of▁sentence｜>User: {user_message_2}\n\nAssistant:\n```\n### 使用 SGLang 进行推理（推荐）\n[SGLang](https:\u002F\u002Fgithub.com\u002Fsgl-project\u002Fsglang) 目前支持 MLA 优化、FP8（W8A8）、FP8 键值缓存以及 Torch Compile，在开源框架中提供了最佳的延迟和吞吐量。以下是一些启动兼容 OpenAI API 服务器的示例命令：\n\n```bash\n# BF16，张量并行度 = 8\npython3 -m sglang.launch_server --model deepseek-ai\u002FDeepSeek-V2-Chat --tp 8 --trust-remote-code\n\n# BF16，带 Torch Compile（编译可能需要几分钟）\npython3 -m sglang.launch_server --model deepseek-ai\u002FDeepSeek-V2-Lite-Chat --trust-remote-code --enable-torch-compile\n\n# FP8，张量并行度 = 8，FP8 键值缓存\npython3 -m sglang.launch_server --model deepseek-ai\u002FDeepSeek-V2-Chat --tp 8 --trust-remote-code --quant fp8 --kv-cache-dtype fp8_e5m2\n```\n\n启动服务器后，您可以使用 OpenAI API 进行查询：\n\n```python\nimport openai\nclient = openai.Client(\n    base_url=\"http:\u002F\u002F127.0.0.1:30000\u002Fv1\", api_key=\"EMPTY\")\n\n# 聊天补全\nresponse = client.chat.completions.create(\n    model=\"default\",\n    messages=[\n        {\"role\": \"system\", \"content\": \"You are a helpful AI assistant\"},\n        {\"role\": \"user\", \"content\": \"List 3 countries and their capitals.\"},\n    ],\n    temperature=0,\n    max_tokens=64,\n)\nprint(response)\n```\n\n### 使用 vLLM 进行推理（推荐）\n要使用 [vLLM](https:\u002F\u002Fgithub.com\u002Fvllm-project\u002Fvllm) 进行模型推理，请将此 Pull Request 合并到您的 vLLM 代码库中：https:\u002F\u002Fgithub.com\u002Fvllm-project\u002Fvllm\u002Fpull\u002F4650。\n\n```python\nfrom transformers import AutoTokenizer\nfrom vllm import LLM, SamplingParams\n\nmax_model_len, tp_size = 8192, 8\nmodel_name = \"deepseek-ai\u002FDeepSeek-V2-Chat\"\ntokenizer = AutoTokenizer.from_pretrained(model_name)\nllm = LLM(model=model_name, tensor_parallel_size=tp_size, max_model_len=max_model_len, trust_remote_code=True, enforce_eager=True)\nsampling_params = SamplingParams(temperature=0.3, max_tokens=256, stop_token_ids=[tokenizer.eos_token_id])\n\nmessages_list = [\n    [{\"role\": \"user\", \"content\": \"Who are you?\"}],\n    [{\"role\": \"user\", \"content\": \"Translate the following content into Chinese directly: DeepSeek-V2 adopts innovative architectures to guarantee economical training and efficient inference.\"}],\n    [{\"role\": \"user\", \"content\": \"Write a piece of quicksort code in C++.\"}],\n]\n\nprompt_token_ids = [tokenizer.apply_chat_template(messages, add_generation_prompt=True) for messages in messages_list]\n\noutputs = llm.generate(prompt_token_ids=prompt_token_ids, sampling_params=sampling_params)\n\ngenerated_text = [output.outputs[0].text for output in outputs]\nprint(generated_text)\n```\n\n### LangChain 支持\n由于我们的 API 与 OpenAI 兼容，因此您可以轻松地在 [langchain](https:\u002F\u002Fwww.langchain.com\u002F) 中使用它。\n以下是一个示例：\n\n```\nfrom langchain_openai import ChatOpenAI\nllm = ChatOpenAI(\n    model='deepseek-chat',\n    openai_api_key=\u003C您的 DeepSeek API 密钥>,\n    openai_api_base='https:\u002F\u002Fapi.deepseek.com\u002Fv1',\n    temperature=0.85,\n    max_tokens=8000)\n``` \n## 9. 许可证\n本代码仓库采用 [MIT 许可证](LICENSE-CODE) 许可。DeepSeek-V2 Base\u002FChat 模型的使用受 [模型许可证](LICENSE-MODEL) 约束。DeepSeek-V2 系列（包括 Base 和 Chat）支持商业用途。\n\n## 10. 引用\n```\n@misc{deepseekv2,\n      title={DeepSeek-V2: 一款强大、经济高效且高效的专家混合语言模型}, \n      author={DeepSeek-AI},\n      year={2024},\n      eprint={2405.04434},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL}\n}\n```\n\n## 11. 联系方式\n如果您有任何问题，请提交一个问题或通过 [service@deepseek.com](service@deepseek.com) 联系我们。","# DeepSeek-V2 快速上手指南\n\nDeepSeek-V2 是一款强大的混合专家（MoE）语言模型，拥有 2360 亿总参数（每次激活 210 亿），在保持卓越性能的同时，显著降低了训练成本和推理显存占用。它支持长达 128k 的上下文窗口，并在中英文理解、代码生成及数学推理方面表现优异。\n\n## 1. 环境准备\n\n### 系统要求\n- **操作系统**: Linux (推荐 Ubuntu 20.04+)\n- **GPU**: NVIDIA GPU (建议显存 24GB 以上，多卡环境更佳)\n- **CUDA**: 11.8 或 12.1+\n- **Python**: 3.8 - 3.11\n\n### 前置依赖\n确保已安装以下基础库：\n- PyTorch (2.0+)\n- Transformers\n- Accelerate\n\n> **注意**：由于 Hugging Face 原生代码在运行 MoE 架构时效率较低，官方强烈推荐使用优化的 `vllm` 后端以获得最佳推理速度。\n\n## 2. 安装步骤\n\n### 方案 A：使用 vllm 加速推理（推荐）\n这是运行 DeepSeek-V2 最高效的方式，能显著提升吞吐量并降低延迟。\n\n```bash\n# 安装 vllm (确保 CUDA 版本匹配)\npip install vllm\n\n# 或者从源码安装以获取最新优化\ngit clone https:\u002F\u002Fgithub.com\u002Fvllm-project\u002Fvllm.git\ncd vllm\npip install -e .\n```\n\n### 方案 B：使用 Hugging Face Transformers\n适用于调试或非高性能需求场景。\n\n```bash\n# 安装必要依赖\npip install torch torchvision torchaudio --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118\npip install transformers accelerate sentencepiece protobuf\n```\n\n## 3. 基本使用\n\n### 方法一：通过 vllm 启动 API 服务（推荐）\n此方法启动一个兼容 OpenAI 格式的本地 API 服务，适合集成到现有应用或进行高并发测试。\n\n```bash\n# 启动 DeepSeek-V2-Chat 模型服务\n# --tensor-parallel-size 根据显卡数量调整，例如 2 张卡设为 2\npython -m vllm.entrypoints.api_server \\\n    --model deepseek-ai\u002FDeepSeek-V2-Chat \\\n    --trust-remote-code \\\n    --tensor-parallel-size 2 \\\n    --port 8000\n```\n\n**调用示例 (Python):**\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n    base_url=\"http:\u002F\u002Flocalhost:8000\u002Fv1\",\n    api_key=\"EMPTY\" # vllm 默认不需要 key\n)\n\nresponse = client.chat.completions.create(\n    model=\"deepseek-ai\u002FDeepSeek-V2-Chat\",\n    messages=[\n        {\"role\": \"user\", \"content\": \"请用 Python 写一个快速排序算法。\"}\n    ]\n)\n\nprint(response.choices[0].message.content)\n```\n\n### 方法二：使用 Hugging Face Transformers 直接加载\n适合本地脚本快速测试或研究模型结构。\n\n```python\nfrom transformers import AutoModelForCausalLM, AutoTokenizer\nimport torch\n\nmodel_name = \"deepseek-ai\u002FDeepSeek-V2-Chat\"\n\n# 加载分词器\ntokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)\n\n# 加载模型 (建议使用 float16 或 bfloat16 节省显存)\nmodel = AutoModelForCausalLM.from_pretrained(\n    model_name,\n    torch_dtype=torch.bfloat16,\n    device_map=\"auto\",\n    trust_remote_code=True\n)\n\n# 准备输入\nprompt = \"解释一下量子纠缠的基本概念。\"\nmessages = [{\"role\": \"user\", \"content\": prompt}]\n\n# 生成回复\ninput_ids = tokenizer.apply_chat_template(messages, return_tensors=\"pt\").to(model.device)\noutput_ids = model.generate(input_ids, max_new_tokens=512)\n\nresponse = tokenizer.decode(output_ids[0], skip_special_tokens=True)\nprint(response)\n```\n\n### 模型版本选择\n根据需求选择合适的模型版本下载：\n\n| 模型名称 | 参数量 | 激活参数 | 上下文长度 | 适用场景 |\n| :--- | :--- | :--- | :--- | :--- |\n| **DeepSeek-V2-Lite** | 16B | 2.4B | 32k | 资源受限环境，轻量级任务 |\n| **DeepSeek-V2-Lite-Chat** | 16B | 2.4B | 32k | 轻量级对话交互 |\n| **DeepSeek-V2** | 236B | 21B | 128k | 复杂推理、长文档分析 (基座) |\n| **DeepSeek-V2-Chat** | 236B | 21B | 128k | 高级对话、代码生成、逻辑推理 |\n\n> **提示**: 国内用户若访问 Hugging Face 较慢，可配置镜像源：\n> ```bash\n> export HF_ENDPOINT=https:\u002F\u002Fhf-mirror.com\n> ```","某中型电商公司的后端团队需要在高并发促销期间，实时处理海量用户评论以生成智能摘要并识别潜在风险内容。\n\n### 没有 DeepSeek-V2 时\n- **推理成本高昂**：部署参数量巨大的传统大模型导致 GPU 资源消耗剧增，单次调用成本难以承受，限制了服务覆盖范围。\n- **响应延迟严重**：在高流量峰值下，模型推理速度慢，用户等待摘要生成的时间过长，严重影响购物体验。\n- **显存占用过大**：庞大的 KV Cache 占用了大量显存，导致单卡能支持的并发请求数极低，不得不频繁扩容硬件。\n- **训练迭代缓慢**：团队试图针对电商垂直领域微调模型，但全参数训练耗时极长且算力开销巨大，难以快速响应业务变化。\n\n### 使用 DeepSeek-V2 后\n- **显著降低运营成本**：利用其混合专家（MoE）架构，每次仅激活 210 亿参数，在保持高性能的同时将训练成本降低了 42.5%，大幅节省预算。\n- **吞吐量提升近 6 倍**：高效的推理机制使最大生成吞吐量提升至原来的 5.76 倍，用户几乎无感知地获取实时评论摘要。\n- **显存效率极大优化**：KV Cache 体积减少了 93.3%，单张显卡可承载的并发请求数成倍增加，无需额外购买昂贵硬件即可应对流量洪峰。\n- **快速落地垂直场景**：经济的训练特性让团队能在短时间内完成针对电商术语的微调，迅速上线更精准的风险识别功能。\n\nDeepSeek-V2 凭借“强性能、低消耗、高效率”的特性，帮助企业在不牺牲智能体验的前提下，实现了大模型规模化落地的成本与速度双重突破。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeepseek-ai_DeepSeek-V2_aada4fe9.png","deepseek-ai","DeepSeek","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fdeepseek-ai_04503588.png","",null,"service@deepseek.com","https:\u002F\u002Fwww.deepseek.com\u002F","https:\u002F\u002Fgithub.com\u002Fdeepseek-ai",5004,534,"2026-04-16T07:43:15","MIT",4,"需要 NVIDIA GPU（文中提及在 GPU 上运行 HuggingFace 代码性能较慢，建议使用专用的 vllm 解决方案以获得高效执行），具体显存大小和 CUDA 版本未说明","未说明",{"notes":92,"python":90,"dependencies":93},"由于 HuggingFace 的限制，当前开源代码在 GPU 上运行时性能低于内部代码库。为了实现模型的高效执行，官方提供了专用的 vllm 解决方案以优化性能。模型总参数量高达 236B（激活 21B），上下文长度支持 128k，对硬件资源要求极高。",[94],"vllm",[15],"2026-03-27T02:49:30.150509","2026-04-17T08:32:53.757928",[99,104,109,114,119,124,129],{"id":100,"question_zh":101,"answer_zh":102,"source_url":103},36799,"如何在 LangChain 中调用 DeepSeek-V2？","可以通过安装专用包 `langchain-deepseek` 来使用。代码示例如下：\n1. 安装：`pip install langchain-deepseek`\n2. 导入并初始化：\n```python\nfrom langchain_deepseek import ChatDeepSeekAI\nfrom langchain_core.output_parsers import StrOutputParser\n\nllm = ChatDeepSeekAI(\n    model=\"deepseek-chat\",\n    api_key=\"sk-...\",\n)\noutput_parser = StrOutputParser()\nchain = llm | output_parser\nresponse = chain.invoke(\"太阳系有几大行星？\")\nprint(response)\n```\n注意：直接使用 `langchain_openai.ChatOpenAI` 可能因参数不兼容而失败，建议使用官方提供的专用类。","https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V2\u002Fissues\u002F18",{"id":105,"question_zh":106,"answer_zh":107,"source_url":108},36800,"API 返回错误 \"Invalid top_logprobs and logprobs value\" 如何解决？","该错误是因为当设置 `top_logprobs` 参数时，必须同时将 `logprobs` 设置为 `True`。API 文档中的默认值描述曾有误导，现已修复。\n解决方案：\n1. 确保请求中同时包含 `\"logprobs\": true` 和 `\"top_logprobs\": \u003Cvalue>`。\n2. 如果不需要控制这些参数，可以直接从请求中完全移除 `top_logprobs` 和 `logprobs` 字段。","https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V2\u002Fissues\u002F9",{"id":110,"question_zh":111,"answer_zh":112,"source_url":113},36801,"在 8 卡 A100 上加载模型启动非常慢，有什么优化方法？","HuggingFace 的 `accelerate` 库在显存分配计算上存在问题，导致加载缓慢。可以通过修改加载代码来解决：\n1. 使用 `device_map=\"sequential\"` 并指定 `max_memory`。\n2. 设置 `attn_implementation=\"eager\"`。\n修改后的代码示例：\n```python\nmodel = AutoModelForCausalLM.from_pretrained(\n    model_name, \n    trust_remote_code=True, \n    device_map=\"sequential\", \n    torch_dtype=torch.bfloat16, \n    max_memory=max_memory, \n    attn_implementation=\"eager\"\n)\n```\n此外，也推荐使用 vLLM 进行启动以获得更好的性能。","https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V2\u002Fissues\u002F11",{"id":115,"question_zh":116,"answer_zh":117,"source_url":118},36802,"如何实现 128k 上下文长度的推理？需要多少显存？","默认情况下最大模型长度（max_model_len）通常设置为 32k。要扩展到 100k 或 128k，需要进行 int4 量化和 KV Cache 优化。\n在 8 卡 A100 (80G) 环境下，直接设置 `max_model_len=100000` 可能会遇到 NCCL 通信错误或显存不足问题。建议先尝试量化方案，并确保分布式环境配置正确。目前社区反馈在未经特殊优化下，8 卡 A100 推理超长上下文存在挑战。","https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V2\u002Fissues\u002F56",{"id":120,"question_zh":121,"answer_zh":122,"source_url":123},36803,"MLA 模块复现效果不如 MHA，关于缩放因子（scaling factor）和 RMSNorm 的位置有何建议？","根据论文，低秩压缩和细粒度专家分割会影响输出尺度，因此需要在压缩后的潜在向量后添加额外的 RMSNorm 层，并在宽度瓶颈处乘以额外的缩放因子以确保训练稳定。\n虽然在没有内部 RMSNorm 的情况下稳定性尚可，但为了最佳实践：\n1. 建议在压缩后的潜在向量之后应用 RMSNorm。\n2. 缩放因子通常应用于瓶颈处（即压缩后的向量和路由专家的中间隐藏状态）。\n具体缩放因子的数值未在公开讨论中明确给出，通常需要根据实验调整或通过权重吸收推导，但在混合模型不使用 RoPE 时，检查是否正确实现了这些归一化和缩放步骤至关重要。","https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V2\u002Fissues\u002F23",{"id":125,"question_zh":126,"answer_zh":127,"source_url":128},36804,"DeepSeek-V2 的 Token 丢弃（Drop Token）策略是基于专家维度还是设备维度计算的？","Token 丢弃策略的具体实现细节较为复杂。根据论文提到的设备级（device-level）Token 丢弃：\n1. 如果是基于专家维度，容量计算公式为：`capacity = ceil(num_tokens * topk) \u002F num_experts * capacity_factor`，每个专家处理自己的 token，超出容量则丢弃得分最低的，不足则填充。\n2. 如果是基于设备维度，容量计算涉及设备组（num_groups）。\n关于论文中提到的“确保约 10% 的训练序列 token 永远不会被丢弃”，这通常意味着在丢弃逻辑中加入了对特定序列的保护机制或动态调整容量因子，具体实现需参考官方代码或更详细的技术报告。建议查阅相关 Issue #5 获取更深层讨论。","https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V2\u002Fissues\u002F48",{"id":130,"question_zh":131,"answer_zh":132,"source_url":133},36805,"DeepSeek-V2 是否支持函数调用（Function Calling）？","截至当前讨论，官方尚未在开源版本或 API 中明确全面支持标准的函数调用（Function Calling）功能。多个用户询问此功能，维护者指向了相关的功能请求 Issue。如果需要该功能，建议关注官方后续的更新公告或在 API 文档中查找最新的工具调用（Tool Use）支持情况。","https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-V2\u002Fissues\u002F47",[]]