作者:微信小助手
<p style="text-align: left;margin: 0px 8px 16px;line-height: 2em;"><span style="font-size: 16px;">DeepSeek-R1 通过其强大的推理能力和灵活的训练机制,已经火爆了整个春节。</span></p> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">DeepSeek-R1 是一款高性能 AI 推理模型,旨在通过强化学习技术提升模型在复杂任务场景下的推理能力。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">本地部署 deepseek-r1 硬件需求要求还是挺高的,特别是满血 671b 参数<span style="font-size: 16px;letter-spacing: 0.578px;text-align: left;">版本</span>:</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <img class="rich_pages wxw-img" data-galleryid="" data-imgfileid="588146610" data-ratio="0.6324074074074074" data-s="300,640" src="/upload/fae6889c58cad6bb2e250bde25d6e668.png" data-type="png" data-w="1080" style=""> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">下表说明了各个版本的特点及适用场景:</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <img class="rich_pages wxw-img" data-galleryid="" data-imgfileid="588146612" data-ratio="0.33055555555555555" data-s="300,640" src="/upload/9688a8e3186c6e94e90af9b7d0f5824b.png" data-type="png" data-w="1080" style=""> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <img class="rich_pages wxw-img" data-galleryid="" data-imgfileid="588146615" data-ratio="0.37592592592592594" data-s="300,640" src="/upload/fb9bcf69629d75e33bd08684b9a798a9.png" data-type="png" data-w="1080" style=""> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">其中最强悍的 671B 版本部署需要极高的硬件配置:64 核以上的服务器集群、512GB 以上的内存、300GB 以上的硬盘以及多节点分布式训练(如 8x A100/H100),还需高功率电源(1000W+)和散热系统。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">不同模型版本对应的需求如下:</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="color: rgb(123, 12, 0);font-size: 18px;"><strong>1、小型模型</strong></span><span style="font-size: 16px;"></span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <strong><span style="font-size: 16px;">DeepSeek-R1-1.5B</span></strong><span style="font-size: 16px;"></span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">CPU:最低 4 核</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">内存:8GB+</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">硬盘:256GB+(模型文件约 1.5-2GB)</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">显卡:非必需(纯 CPU 推理)。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">适用场景:本地测试,自己电脑上可以配合 Ollama 轻松跑起来。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">预计费用:2000~5000,这个版本普通人是能够得着的。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="color: rgb(123, 12, 0);font-size: 18px;"><strong>2. 中型模型 </strong></span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <strong><span style="font-size: 16px;">DeepSeek-R1-7B</span></strong><span style="font-size: 16px;"></span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">CPU:8 核+</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">内存:16GB+</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">硬盘:256GB+(模型文件约 4-5GB)</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">显卡:推荐 8GB+ 显存(如 RTX 3070/4060)。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">适用场景:本地开发和测试,可以处理一些中等复杂度的自然语言处理任务,比如文本摘要、翻译、轻量级多轮对话系统等。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">预计费用:5000~10000,这个版本普通人也行。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <strong><span style="font-size: 16px;">DeepSeek-R1-8B</span></strong><span style="font-size: 16px;"></span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">CPU:<span style="font-size: 16px;letter-spacing: 0.578px;text-align: left;">8 核</span><span style="font-size: 16px;letter-spacing: 0.578px;text-align: left;">+</span></span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">内存:16GB+</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">硬盘:256GB+(模型文件约 4-5GB)</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">显卡:推荐 8GB+ 显存(如 RTX 3070/4060)。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">适用场景:适合需要更高精度的轻量级任务,比如代码生成、逻辑推理等。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">预计费用:5000~10000,这个版本咬咬牙也能上。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="color: rgb(123, 12, 0);font-size: 18px;"><strong>3. 大型模型</strong></span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <strong><span style="font-size: 16px;">DeepSeek-R1-14B</span></strong><span style="font-size: 16px;"></span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">CPU:12 核+</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">内存:32GB+</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">硬盘:256GB+</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">显卡:16GB+ 显存(如 RTX 4090 或 A5000)。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">适用场景:适合企业级复杂任务,比如长文本理解与生成。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">预计费用:20000~30000,这个对 3000 工资的小编来说还是算了。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <strong><span style="font-size: 16px;">DeepSeek-R1-32B</span></strong><span style="font-size: 16px;"></span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">CPU:16 核+</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">内存:64GB+</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">硬盘:256GB+</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">显卡:24GB+ 显存(如 A100 40GB 或双卡 RTX 3090)。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">适用场景:适合高精度专业领域任务,比如多模态任务预处理。这些任务对硬件要求非常高,需要高端的 CPU 和显卡,适合预算充足的企业或研究机构使用。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">预计费用:40000~100000,算了。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="color: rgb(123, 12, 0);font-size: 18px;"><strong>4. 超大型模型</strong></span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <strong><span style="font-size: 16px;">DeepSeek-R1-70B</span></strong><span style="font-size: 16px;"></span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">CPU:32 核+</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">内存:128GB+</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">硬盘:256GB+</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">显卡:多卡并行(如 2x A100 80GB 或 4x RTX 4090)。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">适用场景:适合科研机构或大型企业进行高复杂度生成任务。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">预计费用:400000+,这是老板考虑的,不该我去考虑。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <strong><span style="font-size: 16px;">DeepSeek-R1-671B</span></strong><span style="font-size: 16px;"></span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">CPU:64 核+</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">内存:512GB+</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">硬盘:512GB+</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">显卡:多节点分布式训练(如 8x A100/H100)。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">适用场景:适合超大规模 AI 研究或通用人工智能(AGI)探索。</span> </section> <section style="text-align: left;margin: 8px 8px 16px;line-height: 2em;"> <span style="font-size: 16px;">预计费用:20000000+,这是投资人考虑的,不该我去考虑。</span> </section> <p style="display: none;"> <mp-style-type data-value="3"></mp-style-type></p>
作者:微信小助手
<section data-tool="markdown编辑器" data-website="https://markdown.com.cn/editor" style="font-size: 16px;color: black;padding: 25px 30px;line-height: 1.6;word-spacing: 0px;letter-spacing: 0px;word-break: break-word;word-wrap: break-word;text-align: justify;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;margin-top: -10px;"> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">上文评测蚂蚁开源的《<a href="https://mp.weixin.qq.com/s?__biz=MzI0OTAzNTEwMw==&mid=2247485431&idx=1&sn=32827b8c9bc8c601121c44bca9873b35&scene=21#wechat_redirect" textvalue="蚂蚁 DB-GPT 也开源了 GraphRAG,能用吗?好用么?看这篇就够了" data-itemshowtype="0" target="_blank" linktype="text" data-linktype="2">蚂蚁 DB-GPT 也开源了 GraphRAG,能用吗?好用么?看这篇就够了</a>》,本文探一探蚂蚁开源的另外一套知识增强生成框架 KAG(Knowledge Augmented Generation),专门用于构建垂直领域知识库的逻辑推理问答框架,论文中提到在电子政务达到了 91.6 的准确率,电子医疗各个问答也有不俗的准确率。</span></p> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">本文会简单的介绍一下 KAG 的概念和构建流程,然后尝试在本地启动 KAG 简单探索一下。它的问题规划非常有意思,请随我一起探索。</span></p> <h2 data-tool="markdown.com.cn编辑器" style="margin-top: 30px;margin-bottom: 15px;font-weight: bold;color: black;border-bottom: 2px solid rgb(239, 112, 96);font-size: 1.3em;"><span style="display: none;"></span><span style="display: inline-block;font-weight: bold;background: rgb(239, 112, 96);color: #ffffff;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px;"><span leaf="">1. KAG 简介</span></span><span style="display: inline-block;vertical-align: bottom;border-bottom: 36px solid #efebe9;border-right: 20px solid transparent;"><span leaf=""> </span></span></h2> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">KAG 可以有效克服传统 RAG 向量相似度计算的歧义性和 OpenIE 引入的 GraphRAG 的噪声问题,支持逻辑推理、多跳事实问答等。</span></p> <blockquote style="display: block;font-size: 0.9em;overflow: auto;overflow-scrolling: touch;border-left: 3px solid rgba(0, 0, 0, 0.4);color: #6a737d;padding-top: 10px;padding-bottom: 10px;padding-left: 20px;padding-right: 10px;margin-bottom: 20px;margin-top: 20px;border-left-color: rgb(239, 112, 96);background: #fff9f9;"> <p style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0px;color: black;line-height: 26px;"><span leaf="">OpenIE: 神经开放域信息抽取(Open Information Extraction),也被称为开放信息抽取,是</span><strong style="font-weight: bold;color: black;"><span leaf="">一种从非结构化文本中提取信息的强大技术</span></strong><span leaf="">。 不同于传统的信息抽取方法,OpenIE 不依赖于预定义的领域知识或本体模式,使其具有更广泛的适用性和灵活性。</span></p> </blockquote> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">KAG 的核心功能包括:</span></p> <ul style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: black;list-style-type: disc;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1,1,1);font-weight: 500;"> <span leaf="">知识与 Chunk 互索引结构,以整合更丰富的上下文文本信息</span> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1,1,1);font-weight: 500;"> <span leaf="">利用概念语义推理进行知识对齐,缓解 OpenIE 引入的噪音问题</span> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1,1,1);font-weight: 500;"> <span leaf="">支持 Schema-Constraint 知识构建,支持领域专家知识的表示与构建</span> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1,1,1);font-weight: 500;"> <span leaf="">逻辑符号引导的混合推理与检索,实现逻辑推理和多跳推理问答</span> </section></li> </ul> <blockquote style="display: block;font-size: 0.9em;overflow: auto;overflow-scrolling: touch;border-left: 3px solid rgba(0, 0, 0, 0.4);color: #6a737d;padding-top: 10px;padding-bottom: 10px;padding-left: 20px;padding-right: 10px;margin-bottom: 20px;margin-top: 20px;border-left-color: rgb(239, 112, 96);background: #fff9f9;"> <p style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0px;color: black;line-height: 26px;"><span leaf="">我认为 KAG 为何会提到专为垂直领域开发,就在于它采用 Schema 来约束知识图谱的构建。像 GraphRAG 就只能够根据自定义实体进行提取,而 KAG 我粗浅地认为是用户可以自定义知识图谱层次关系,自动进行知识对齐。</span></p> </blockquote> <h2 data-tool="markdown.com.cn编辑器" style="margin-top: 30px;margin-bottom: 15px;font-weight: bold;color: black;border-bottom: 2px solid rgb(239, 112, 96);font-size: 1.3em;"><span style="display: none;"></span><span style="display: inline-block;font-weight: bold;background: rgb(239, 112, 96);color: #ffffff;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px;"><span leaf="">2. 核心功能</span></span><span style="display: inline-block;vertical-align: bottom;border-bottom: 36px solid #efebe9;border-right: 20px solid transparent;"><span leaf=""> </span></span></h2> <h3 data-tool="markdown.com.cn编辑器" style="margin-top: 30px;margin-bottom: 15px;font-weight: bold;color: black;font-size: 20px;"><span style="display: none;"></span><span leaf="">2.1 LLM 友好的语义化知识管理</span><span style="display: none;"></span></h3> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">私域知识库场景,非结构化数据、结构化信息、业务专家经验 往往三者共存,KAG 提出了一种对大型语言模型(LLM)友好的知识表示框架,基于 DIKW(数据、信息、知识和智慧)的层次结构基础进行融合。这使得它能够在同一知识类型(如实体类型、事件类型)上兼容无 schema 约束的信息提取和有 schema 约束的专业知识构建,并支持图结构与原始文本块之间的互索引表示。</span></p> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">这种互索引表示有助于基于图结构的倒排索引的构建,并促进了逻辑形式的统一表示、推理和检索。同时通过知识理解、语义对齐等进一步降低信息抽取的噪声,提升知识的准确率和一致性。</span></p> <figure data-tool="markdown.com.cn编辑器" style="margin: 0;margin-top: 10px;margin-bottom: 10px;"> <span leaf=""><img src="/upload/c7df98c439c92857f10d14686c6a0e55.png" class="rich_pages wxw-img" data-ratio="0.47962962962962963" data-type="png" data-w="1080" style="display: block;margin: 0 auto;width: auto;max-width: 100%;" data-imgfileid="100001827"></span> <figcaption style="margin-top: 5px;text-align: center;color: #888;font-size: 14px;"> <span leaf=""><br></span> </figcaption> </figure> <blockquote style="display: block;font-size: 0.9em;overflow: auto;overflow-scrolling: touch;border-left: 3px solid rgba(0, 0, 0, 0.4);color: #6a737d;padding-top: 10px;padding-bottom: 10px;padding-left: 20px;padding-right: 10px;margin-bottom: 20px;margin-top: 20px;border-left-color: rgb(239, 112, 96);background: #fff9f9;"> <p style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0px;color: black;line-height: 26px;"><span leaf="">可以看到数据被分块后,经过信息提取后,形成了对齐的知识。</span></p> </blockquote> <h3 data-tool="markdown.com.cn编辑器" style="margin-top: 30px;margin-bottom: 15px;font-weight: bold;color: black;font-size: 20px;"><span style="display: none;"></span><span leaf="">2.2 逻辑符号引导的混合推理引擎</span><span style="display: none;"></span></h3> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">KAG 提出了一种逻辑符号引导的混合求解和推理引擎。该引擎包括三种类型的运算符:规划、推理和检索,将自然语言问题转化为结合语言和符号的问题求解过程。在这个过程中,每一步都可以利用不同的运算符,如精确匹配检索、文本检索、数值计算或语义推理,从而实现四种不同问题求解过程的集成:图谱推理、逻辑计算、Chunk 检索和 LLM 推理。如下图右侧所示。</span></p> <figure data-tool="markdown.com.cn编辑器" style="margin: 0;margin-top: 10px;margin-bottom: 10px;"> <span leaf=""><img src="/upload/d6dc0f04ee6b1fd4b23dd09d93f7e04a.png" class="rich_pages wxw-img" data-ratio="0.5435185185185185" data-type="png" data-w="1080" style="display: block;margin: 0 auto;width: auto;max-width: 100%;" data-imgfileid="100001825"></span> <figcaption style="margin-top: 5px;text-align: center;color: #888;font-size: 14px;"> <span leaf=""><br></span> </figcaption> </figure> <blockquote style="display: block;font-size: 0.9em;overflow: auto;overflow-scrolling: touch;border-left: 3px solid rgba(0, 0, 0, 0.4);color: #6a737d;padding-top: 10px;padding-bottom: 10px;padding-left: 20px;padding-right: 10px;margin-bottom: 20px;margin-top: 20px;border-left-color: rgb(239, 112, 96);background: #fff9f9;"> <p style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0px;color: black;line-height: 26px;"><span leaf="">从图上就能看出,问题经过规划生成了逻辑形式的推理步骤,然后检索最终汇总各个子问题的检索结果,最终生成。我们稍后在代码中就能看到问题是如何规划。</span></p> </blockquote> <h2 data-tool="markdown.com.cn编辑器" style="margin-top: 30px;margin-bottom: 15px;font-weight: bold;color: black;border-bottom: 2px solid rgb(239, 112, 96);font-size: 1.3em;"><span style="display: none;"></span><span style="display: inline-block;font-weight: bold;background: rgb(239, 112, 96);color: #ffffff;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px;"><span leaf="">3. 安装</span></span><span style="display: inline-block;vertical-align: bottom;border-bottom: 36px solid #efebe9;border-right: 20px solid transparent;"><span leaf=""> </span></span></h2> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">KAG 开源地址:</span></p> <ul style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: black;list-style-type: disc;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1,1,1);font-weight: 500;"> <strong style="font-weight: bold;color: black;"><span leaf="">https://github.com/OpenSPG/KAG</span></strong> </section></li> </ul> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">其整体代码结构分为 Builder 和 Solver,顾名思义前者表示构建器,后者表示解决器,具体的构建流程或者索引流程就不再赘述了,前文中的图大概已经能够解释。</span></p> <blockquote style="display: block;font-size: 0.9em;overflow: auto;overflow-scrolling: touch;border-left: 3px solid rgba(0, 0, 0, 0.4);color: #6a737d;padding-top: 10px;padding-bottom: 10px;padding-left: 20px;padding-right: 10px;margin-bottom: 20px;margin-top: 20px;border-left-color: rgb(239, 112, 96);background: #fff9f9;"> <p style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0px;color: black;line-height: 26px;"><span leaf="">其实还有一个kag-model,但由于没开源,这里就忽略了。</span></p> </blockquote> <figure data-tool="markdown.com.cn编辑器" style="margin: 0;margin-top: 10px;margin-bottom: 10px;"> <span leaf=""><img src="/upload/07f7483d747f4d874a42e32c5a218d6d.png" class="rich_pages wxw-img" data-ratio="0.44814814814814813" data-type="png" data-w="1080" style="display: block;margin: 0 auto;width: auto;max-width: 100%;" data-imgfileid="100001824"></span> <figcaption style="margin-top: 5px;text-align: center;color: #888;font-size: 14px;"> <span leaf=""><br></span> </figcaption> </figure> <h2 data-tool="markdown.com.cn编辑器" style="margin-top: 30px;margin-bottom: 15px;font-weight: bold;color: black;border-bottom: 2px solid rgb(239, 112, 96);font-size: 1.3em;"><span style="display: none;"></span><span style="display: inline-block;font-weight: bold;background: rgb(239, 112, 96);color: #ffffff;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px;"><span leaf="">3.1 简单安装</span></span><span style="display: inline-block;vertical-align: bottom;border-bottom: 36px solid #efebe9;border-right: 20px solid transparent;"><span leaf=""> </span></span></h2> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">简单安装就是按照如下方式通过 Docker Compose 直接启动所有服务,它安装了以下 3 个服务</span></p> <ul style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: black;list-style-type: disc;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1,1,1);font-weight: 500;"> <span leaf="">openspg-server</span> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1,1,1);font-weight: 500;"> <span leaf="">openspg-neo4j</span> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1,1,1);font-weight: 500;"> <span leaf="">mysql</span> </section></li> </ul> <pre data-tool="markdown.com.cn编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span data-cacheurl="" data-remoteid="" style="display: block;background: none;height: 30px;width: 100%;background-size: 40px;background-repeat: no-repeat;background-color: #f8f8f8;margin-bottom: -7px;border-radius: 5px;background-position: 10px 10px;background-image: url(https://mmbiz.qpic.cn/mmbiz_svg/gWicbXPiajJn9yh86MJZR3XjUIfhYONd3ib7m9PGhnGas513Sou5RbZicfDHWvVYSkRLtiaEzLrjEVxibrdLy1Dj2wj4sVTfsKmx4a/640?wx_fmt=svg&from=appmsg);"></span><code style="overflow-x: auto;padding: 16px;color: #333;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #f8f8f8;border-radius: 5px;"><span leaf="">curl -sSL https://raw.githubusercontent.com/OpenSPG/openspg/refs/heads/master/dev/release/docker-compose.yml -o docker-compose.yml</span><span leaf=""><br></span><span leaf="">docker compose -f docker-compose.yml up -d</span><span leaf=""><br></span></code></pre> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">然后打开网页http://localhost:8887,可以参考</span><span leaf="">官方文档</span><span leaf="">https://openspg.yuque.com/ndx6g9/0.5/nbb1bn3wegwue6yo#R4iWY创建知识库。</span></p> <figure data-tool="markdown.com.cn编辑器" style="margin: 0;margin-top: 10px;margin-bottom: 10px;"> <span leaf=""><img src="/upload/aecc9259e52850ee7eb426a6e778773f.png" class="rich_pages wxw-img" data-ratio="0.28888888888888886" data-type="png" data-w="1080" style="display: block;margin: 0 auto;width: auto;max-width: 100%;" data-imgfileid="100001826"></span> <figcaption style="margin-top: 5px;text-align: center;color: #888;font-size: 14px;"> <span leaf=""><br></span> </figcaption> </figure> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">你大概需要配置以下几项。</span></p> <figure data-tool="markdown.com.cn编辑器" style="margin: 0;margin-top: 10px;margin-bottom: 10px;"> <span leaf=""><img src="/upload/9f92649b5b6bb6c857dc5d3a72d3a960.png" class="rich_pages wxw-img" data-ratio="0.7805555555555556" data-type="png" data-w="1080" style="display: block;margin: 0 auto;width: auto;max-width: 100%;" data-imgfileid="100001823"></span> <figcaption style="margin-top: 5px;text-align: center;color: #888;font-size: 14px;"> <span leaf=""><br></span> </figcaption> </figure> <blockquote style="display: block;font-size: 0.9em;overflow: auto;overflow-scrolling: touch;border-left: 3px solid rgba(0, 0, 0, 0.4);color: #6a737d;padding-top: 10px;padding-bottom: 10px;padding-left: 20px;padding-right: 10px;margin-bottom: 20px;margin-top: 20px;border-left-color: rgb(239, 112, 96);background: #fff9f9;"> <p style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0px;color: black;line-height: 26px;"><span leaf="">但我配置好了之后,在索引的时候会一直会报向量批处理超过默认的 64,用的免费的硅基流动 Embedding,看起来是 Docker 默认配置的 Emebdding Batch 过大了,而配置中无法修改 batch size。只能转向开发者模式。</span></p> </blockquote> <h3 data-tool="markdown.com.cn编辑器" style="margin-top: 30px;margin-bottom: 15px;font-weight: bold;color: black;font-size: 20px;"><span style="display: none;"></span><span leaf="">3.2 开发者模式</span><span style="display: none;"></span></h3> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">即使是开发者模型,也仍然需要安装刚才的 Docker Compose,其中启动了一些依赖服务,KAG 框架并不包含前端或者服务端的代码。</span></p> <ul style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: black;list-style-type: disc;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1,1,1);font-weight: 500;"> <span leaf="">创建虚拟环境</span> </section></li> </ul> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><code style="font-size: 14px;word-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin: 0 2px;background-color: rgba(27,31,35,.05);font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(239, 112, 96);"><span leaf="">conda create -n kag-demo python=3.10 && conda activate kag-demo</span></code></p> <ul style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: black;list-style-type: disc;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1,1,1);font-weight: 500;"> <span leaf="">克隆代码</span> </section></li> </ul> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><code style="font-size: 14px;word-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin: 0 2px;background-color: rgba(27,31,35,.05);font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(239, 112, 96);"><span leaf="">git clone https://github.com/OpenSPG/KAG.git</span></code></p> <ul style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: black;list-style-type: disc;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1,1,1);font-weight: 500;"> <span leaf="">安装依赖</span> </section></li> </ul> <pre data-tool="markdown.com.cn编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span data-cacheurl="" data-remoteid="" style="display: block;background: none;height: 30px;width: 100%;background-size: 40px;background-repeat: no-repeat;background-color: #f8f8f8;margin-bottom: -7px;border-radius: 5px;background-position: 10px 10px;background-image: url(https://mmbiz.qpic.cn/mmbiz_svg/gWicbXPiajJn9yh86MJZR3XjUIfhYONd3ib7m9PGhnGas513Sou5RbZicfDHWvVYSkRLtiaEzLrjEVxibrdLy1Dj2wj4sVTfsKmx4a/640?wx_fmt=svg&from=appmsg);"></span><code style="overflow-x: auto;padding: 16px;color: #333;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #f8f8f8;border-radius: 5px;"><span style="color: #0086b3;line-height: 26px;"><span leaf="">cd</span></span><span leaf=""> ./KAG && pip install -e .</span><span leaf=""><br></span></code></pre> <ul style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: black;list-style-type: disc;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1,1,1);font-weight: 500;"> <span leaf="">验证</span> </section></li> </ul> <pre data-tool="markdown.com.cn编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span data-cacheurl="" data-remoteid="" style="display: block;background: none;height: 30px;width: 100%;background-size: 40px;background-repeat: no-repeat;background-color: #f8f8f8;margin-bottom: -7px;border-radius: 5px;background-position: 10px 10px;background-image: url(https://mmbiz.qpic.cn/mmbiz_svg/gWicbXPiajJn9yh86MJZR3XjUIfhYONd3ib7m9PGhnGas513Sou5RbZicfDHWvVYSkRLtiaEzLrjEVxibrdLy1Dj2wj4sVTfsKmx4a/640?wx_fmt=svg&from=appmsg);"></span><code style="overflow-x: auto;padding: 16px;color: #333;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #f8f8f8;border-radius: 5px;"><span leaf="">knext --version</span><span leaf=""><br></span></code></pre> <ul style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: black;list-style-type: disc;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1,1,1);font-weight: 500;"> <span leaf="">创建 Demo</span> </section></li> </ul> <pre data-tool="markdown.com.cn编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span data-cacheurl="" data-remoteid="" style="display: block;background: none;height: 30px;width: 100%;background-size: 40px;background-repeat: no-repeat;background-color: #f8f8f8;margin-bottom: -7px;border-radius: 5px;background-position: 10px 10px;background-image: url(https://mmbiz.qpic.cn/mmbiz_svg/gWicbXPiajJn9yh86MJZR3XjUIfhYONd3ib7m9PGhnGas513Sou5RbZicfDHWvVYSkRLtiaEzLrjEVxibrdLy1Dj2wj4sVTfsKmx4a/640?wx_fmt=svg&from=appmsg);"></span><code style="overflow-x: auto;padding: 16px;color: #333;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #f8f8f8;border-radius: 5px;"><span style="color: #0086b3;line-height: 26px;"><span leaf="">cd</span></span><span leaf=""> kag/examples</span><span leaf=""><br></span><span leaf="">vim ./example.cfg</span><span leaf=""><br></span></code></pre> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">然后编辑该文件,写入自己的 API KEY。</span></p> <pre data-tool="markdown.com.cn编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span data-cacheurl="" data-remoteid="" style="display: block;background: none;height: 30px;width: 100%;background-size: 40px;background-repeat: no-repeat;background-color: #f8f8f8;margin-bottom: -7px;border-radius: 5px;background-position: 10px 10px;background-image: url(https://mmbiz.qpic.cn/mmbiz_svg/gWicbXPiajJn9yh86MJZR3XjUIfhYONd3ib7m9PGhnGas513Sou5RbZicfDHWvVYSkRLtiaEzLrjEVxibrdLy1Dj2wj4sVTfsKmx4a/640?wx_fmt=svg&from=appmsg);"></span><code style="overflow-x: auto;padding: 16px;color: #333;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #f8f8f8;border-radius: 5px;"><span leaf="">[project]</span><span leaf=""><br></span><span leaf="">namespace = KagDemo</span><span leaf=""><br></span><span leaf="">host_addr = http://localhost:8887</span><span leaf=""><br></span><span leaf="">id = 1</span><span leaf=""><br></span><span leaf=""><br></span><span leaf="">[vectorizer]</span><span leaf=""><br></span><span leaf="">vectorizer = kag.common.vectorizer.OpenAIVectorizer</span><span leaf=""><br></span><span leaf="">model = BAAI/bge-m3</span><span leaf=""><br></span><span leaf="">api_key = xxxx</span><span leaf=""><br></span><span leaf="">base_url = https://api.siliconflow.cn/v1</span><span leaf=""><br></span><span leaf="">vector_dimensions = 1024</span><span leaf=""><br></span><span leaf=""><br></span><span leaf="">[llm]</span><span leaf=""><br></span><span leaf="">client_type = maas</span><span leaf=""><br></span><span leaf="">base_url = https://open.bigmodel.cn/api/paas/v4</span><span leaf=""><br></span><span leaf="">api_key = xxxx</span><span leaf=""><br></span><span leaf="">model = glm-4-flash</span><span leaf=""><br></span><span leaf=""><br></span><span leaf="">[prompt]</span><span leaf=""><br></span><span leaf="">biz_scene = default</span><span leaf=""><br></span><span leaf="">language = en</span><span leaf=""><br></span><span leaf=""><br></span><span leaf="">[log]</span><span leaf=""><br></span><span leaf="">level = INFO</span><span leaf=""><br></span></code></pre> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">使用如下命令创建项目,它会在 kag/examples 下创建 KagDemo 这个项目,并且初始化了一整套代码,但距离使用我们需要给数据,并且改写两个文件。</span></p> <pre data-tool="markdown.com.cn编辑器" style="margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span data-cacheurl="" data-remoteid="" style="display: block;background: none;height: 30px;width: 100%;background-size: 40px;background-repeat: no-repeat;background-color: #f8f8f8;margin-bottom: -7px;border-radius: 5px;background-position: 10px 10px;background-image: url(https://mmbiz.qpic.cn/mmbiz_svg/gWicbXPiajJn9yh86MJZR3XjUIfhYONd3ib7m9PGhnGas513Sou5RbZicfDHWvVYSkRLtiaEzLrjEVxibrdLy1Dj2wj4sVTfsKmx4a/640?wx_fmt=svg&from=appmsg);"></span><code style="overflow-x: auto;padding: 16px;color: #333;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #f8f8f8;border-radius: 5px;"><span leaf="">knext project create --config_path ./example.cfg</span><span leaf=""><br></span></code></pre> <ul style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: black;list-style-type: disc;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1,1,1);font-weight: 500;"> <span leaf="">导入要索引的文件</span> </section></li> </ul> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">我们导入四篇论文 graphrag.pdf、hipporag.pdf、hybridrag.pdf 和 lightrag.pdf 到 kag/examples/KagDemo/builder/data 下。</span></p> <ul style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: black;list-style-type: disc;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1,1,1);font-weight: 500;"> <span leaf="">提交 Schema 到服务端</span> </section></li> </ul> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">这个应该是用来自定义实体类型约束,这里我们暂不定义,走无 Schema 约束。需要回到目录 KagDemo 中执行如下命令。</span></p> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><code style="font-size: 14px;word-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin: 0 2px;background-color: rgba(27,31,35,.05);font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(239, 112, 96);"><span leaf="">knext schema commit</span></code></p> <ul style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: black;list-style-type: disc;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1,1,1);font-weight: 500;"> <span leaf="">编写 Builder 客户端代码</span> </section></li> </ul> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">我们需要参考</span><span style="font-weight: bold;color: #ff3502;"><span leaf="">官方文档索引</span></span><sup style="line-height: 0;font-weight: bold;color: rgb(239, 112, 96);"><span leaf="">[1]</span></sup><span leaf="">如何调用 SDK 编写 builder,写好的文件需要放置在 KagDemo/builder/indexer.py,最后执行</span><code style="font-size: 14px;word-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin: 0 2px;background-color: rgba(27,31,35,.05);font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(239, 112, 96);"><span leaf="">python ./builder/indexer.py</span></code><span leaf="">即可,它会启动构建。</span></p> <ul style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: black;list-style-type: disc;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1,1,1);font-weight: 500;"> <span leaf="">编写 Solver 客户端代码</span> </section></li> </ul> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">我们同样需要参考</span><span style="font-weight: bold;color: #ff3502;"><span leaf="">官方文档 Solver</span></span><sup style="line-height: 0;font-weight: bold;color: rgb(239, 112, 96);"><span leaf="">[2]</span></sup><span leaf="">编写 Solver,然后执行</span><code style="font-size: 14px;word-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin: 0 2px;background-color: rgba(27,31,35,.05);font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(239, 112, 96);"><span leaf="">python ./solver/evalForKagDemo.py</span></code><span leaf="">。</span></p> <h2 data-tool="markdown.com.cn编辑器" style="margin-top: 30px;margin-bottom: 15px;font-weight: bold;color: black;border-bottom: 2px solid rgb(239, 112, 96);font-size: 1.3em;"><span style="display: none;"></span><span style="display: inline-block;font-weight: bold;background: rgb(239, 112, 96);color: #ffffff;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px;"><span leaf="">4. 测试</span></span><span style="display: inline-block;vertical-align: bottom;border-bottom: 36px solid #efebe9;border-right: 20px solid transparent;"><span leaf=""> </span></span></h2> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">我们测试问题如下,是一个需要大模型获取两个知识,然后才能总结出答案。经过了大约 42 秒,一次性输出所有答案。</span></p> <figure data-tool="markdown.com.cn编辑器" style="margin: 0;margin-top: 10px;margin-bottom: 10px;"> <span leaf=""><img src="/upload/3561aedc677923bbf672f05198daca41.png" class="rich_pages wxw-img" data-ratio="0.5120370370370371" data-type="png" data-w="1080" style="display: block;margin: 0 auto;width: auto;max-width: 100%;" data-imgfileid="100001832"></span> <figcaption style="margin-top: 5px;text-align: center;color: #888;font-size: 14px;"> <span leaf=""><br></span> </figcaption> </figure> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">那么为何这么慢呢?按照 1.2 节所述,他需要先规划问题生成逻辑形式推导,之后再推理检索生成。所以他是需要等待第一轮 LLM 规划生成后,才能去检索然后输出。我们看一下它的推理过程,非常的有意思的。</span></p> <figure data-tool="markdown.com.cn编辑器" style="margin: 0;margin-top: 10px;margin-bottom: 10px;"> <span leaf=""><img src="/upload/55f1844b51dc9e3e4dd09efd6604d410.png" class="rich_pages wxw-img" data-ratio="2.680722891566265" data-type="png" data-w="664" style="display: block;margin: 0 auto;width: auto;max-width: 100%;" data-imgfileid="100001831"></span> <figcaption style="margin-top: 5px;text-align: center;color: #888;font-size: 14px;"> <span leaf=""><br></span> </figcaption> </figure> <blockquote style="display: block;font-size: 0.9em;overflow: auto;overflow-scrolling: touch;border-left: 3px solid rgba(0, 0, 0, 0.4);color: #6a737d;padding-top: 10px;padding-bottom: 10px;padding-left: 20px;padding-right: 10px;margin-bottom: 20px;margin-top: 20px;border-left-color: rgb(239, 112, 96);background: #fff9f9;"> <p style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0px;color: black;line-height: 26px;"><span leaf="">这个推理过程似乎并不是每次都能生成,依赖 LLM 本身的能力,可能和我使用的免费 glm-4-flash 测试有关系。</span></p> </blockquote> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">根据源码所示,它采用的是 CoA(Chain of Abstraction)抽象推理链来生成问题推导步骤。CoA 来自于论文</span><span style="font-weight: bold;color: #ff3502;"><span leaf="">Efficient Tool Use with Chain-of-Abstraction Reasoning</span></span><sup style="line-height: 0;font-weight: bold;color: rgb(239, 112, 96);"><span leaf="">[3]</span></sup><span leaf="">。</span></p> <figure data-tool="markdown.com.cn编辑器" style="margin: 0;margin-top: 10px;margin-bottom: 10px;"> <span leaf=""><img src="/upload/8a94d2f04247af2eda1b3c9fb3b94088.png" class="rich_pages wxw-img" data-ratio="0.7718631178707225" data-type="png" data-w="1052" style="display: block;margin: 0 auto;width: auto;max-width: 100%;" data-imgfileid="100001830"></span> <figcaption style="margin-top: 5px;text-align: center;color: #888;font-size: 14px;"> <span leaf=""><br></span> </figcaption> </figure> <h2 data-tool="markdown.com.cn编辑器" style="margin-top: 30px;margin-bottom: 15px;font-weight: bold;color: black;border-bottom: 2px solid rgb(239, 112, 96);font-size: 1.3em;"><span style="display: none;"></span><span style="display: inline-block;font-weight: bold;background: rgb(239, 112, 96);color: #ffffff;padding: 3px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px;"><span leaf="">总结</span></span><span style="display: inline-block;vertical-align: bottom;border-bottom: 36px solid #efebe9;border-right: 20px solid transparent;"><span leaf=""> </span></span></h2> <p data-tool="markdown.com.cn编辑器" style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0;line-height: 26px;color: black;"><span leaf="">本篇分享就到这里了,有需要的同学可以自己参考官方进行复现测试。其他部分需要同学们自己深入研究了,KAG 的概念会相对多一点,相对没那么直观。作者本人只是对这个问题规划过程较为感兴趣,下一篇也会尝试测试 LlamaIndex 中的 CoAAgent,欢迎关注。</span></p> <blockquote style="display: block;font-size: 0.9em;overflow: auto;overflow-scrolling: touch;border-left: 3px solid rgba(0, 0, 0, 0.4);color: #6a737d;padding-top: 10px;padding-bottom: 10px;padding-left: 20px;padding-right: 10px;margin-bottom: 20px;margin-top: 20px;border-left-color: rgb(239, 112, 96);background: #fff9f9;"> <p style="font-size: 16px;padding-top: 8px;padding-bottom: 8px;margin: 0px;color: black;line-height: 26px;"><span leaf="">我们已经建立 LLM 应用交流群,有志于交流想法的同学可以后台回复进群。关注我,与你一起探索 AI 最前沿的技术洞见!您的评论与分享是我创作的动力。</span></p> </blockquote> <h3 data-tool="markdown.com.cn编辑器" style="margin-top: 30px;margin-bottom: 15px;font-weight: bold;color: black;font-size: 20px;"><span style="display: block;"><span leaf="">参考资料</span></span></h3> <section data-tool="markdown.com.cn编辑器"> <span style="display: flex;"><span style="display: inline;width: 10%;background: none;font-size: 80%;opacity: 0.6;line-height: 26px;font-family: ptima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;"><span leaf="">[1] </span></span><p style="padding-top: 8px;padding-bottom: 8px;display: inline;font-size: 14px;width: 90%;padding: 0px;margin: 0;line-height: 26px;color: black;word-break: break-all;width: calc(100%-50);"><span leaf="">官方文档索引: </span><em style="font-style: italic;color: black;"><span leaf="">https://openspg.yuque.com/ndx6g9/0.5/nbb1bn3wegwue6yo#P9GJu</span></em></p></span><span style="display: flex;"><span style="display: inline;width: 10%;background: none;font-size: 80%;opacity: 0.6;line-height: 26px;font-family: ptima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;"><span leaf="">[2] </span></span><p style="padding-top: 8px;padding-bottom: 8px;display: inline;font-size: 14px;width: 90%;padding: 0px;margin: 0;line-height: 26px;color: black;word-break: break-all;width: calc(100%-50);"><span leaf="">官方文档Solver: </span><em style="font-style: italic;color: black;"><span leaf="">https://openspg.yuque.com/ndx6g9/0.5/nbb1bn3wegwue6yo#r95Sg</span></em></p></span><span style="display: flex;"><span style="display: inline;width: 10%;background: none;font-size: 80%;opacity: 0.6;line-height: 26px;font-family: ptima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;"><span leaf="">[3] </span></span><p style="padding-top: 8px;padding-bottom: 8px;display: inline;font-size: 14px;width: 90%;padding: 0px;margin: 0;line-height: 26px;color: black;word-break: break-all;width: calc(100%-50);"><span leaf="">Efficient Tool Use with Chain-of-Abstraction Reasoning: </span><em style="font-style: italic;color: black;"><span leaf="">https://arxiv.org/abs/2401.17464</span></em></p></span> </section> </section> <section> <span leaf=""><br></span> </section> <p style="display: none;"> <mp-style-type data-value="3"></mp-style-type></p>
作者:微信小助手
<section data-role="outer" label="edit by 135editor"> <section data-role="paragraph"> <p><br></p> </section> <section data-role="paragraph"> <section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 10px;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;font-size: 16px;color: #000000;line-height: 1.5em;word-spacing: 0em;letter-spacing: 0em;word-break: break-word;overflow-wrap: break-word;text-align: left;box-sizing:border-box;font-family:Georgia, PingFangSC-light, serif;"> <blockquote data-tool="mdnice编辑器" style="margin-top: 20px;margin-bottom: 20px;margin-left: 0px;margin-right: 0px;padding-top: 10px;padding-bottom: 10px;padding-left: 20px;padding-right: 10px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: #ffc900;border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;background-attachment: scroll;background-clip: border-box;background-color: #fff9e3;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;display: block;overflow-x: auto;overflow-y: auto;box-sizing:border-box;"> <span style="display: none;color: #000000;font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: normal;"></span> <p style="text-align:left;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;color: #9b6e23;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;font-weight: normal;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;">回顾2023年RAG技术的发展,检索增强生成(Retrieval-Augmented Generation,RAG)技术彻底改变了人工智能模型的工作方式,它将生成式人工智能的优势与检索现实世界文档的精确性相结合。通过从外部来源提取相关数据,RAG使得人工智能能够生成更准确且上下文更合适的答案。</p> </blockquote> <blockquote data-tool="mdnice编辑器" style="margin-top: 20px;margin-bottom: 20px;margin-left: 0px;margin-right: 0px;padding-top: 10px;padding-bottom: 10px;padding-left: 20px;padding-right: 10px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: #ffc900;border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;background-attachment: scroll;background-clip: border-box;background-color: #fff9e3;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;display: block;overflow-x: auto;overflow-y: auto;box-sizing:border-box;"> <span style="display: none;color: #000000;font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: normal;"></span> <p style="text-align:left;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;color: #9b6e23;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;font-weight: normal;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;">随着这项技术的不断发展,RAG的多种变体应运而生,每种变体都在解决不同的挑战并提升人工智能的整体性能。在本文中,我们将深入探讨七种关键的RAG技术,重点介绍每种技术如何独特地提升AI生成内容的质量。</p> </blockquote><span style="display: none;"></span><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>1. 简单RAG(Simple RAG)</strong></span> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">在简单RAG中,大型语言模型(LLM)接收用户查询,在向量存储库中进行相似性搜索或在知识图谱中进行关系搜索,然后基于检索到的信息生成答案。</p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-ratio="0.8112324492979719" src="/upload/64aaf19ad087fefb9e400e3f5d2028a5.null" data-w="641" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;vertical-align:baseline;"> </figure> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">工作原理:</strong></p> <section data-role="list"> <ol data-tool="mdnice编辑器" style="list-style-type: decimal;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">用户查询</strong>:用户提供一个查询或输入,该查询被输入到系统的检索部分。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">搜索与检索</strong>:模型在向量存储库或知识图谱中搜索相关文档或文本。检索器根据相关性对文档进行排名,并选择最相关的k个(例如,前5个)段落。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">生成答案</strong>:选定的文档被传递给LLM,LLM使用这些文档作为上下文,生成一个结构良好且相关的答案。 </section></li> </ol> </section><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>2. 校正RAG(Corrective RAG)</strong></span> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">在校正RAG中,系统不仅检索和生成答案,还会验证并校正这些答案。<img class="rich_pages wxw-img" data-ratio="0.4703703703703704" src="/upload/371bed67aa91aa90f5b8147cd49222aa.null" data-w="1080" style="display: block;margin: 0px auto;vertical-align: baseline;width: 100%;box-sizing:border-box;max-width:100% !important;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">工作原理:</strong></p> <section data-role="list"> <ol data-tool="mdnice编辑器" style="list-style-type: decimal;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">搜索与检索</strong>:与简单RAG类似,系统根据查询检索相关文档。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">评分</strong>:将检索到的上下文与可信数据集(如测试集或带有预定义规则的提示)进行比较。此步骤的方法根据项目目标有所不同。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">校正</strong>:如果在评分过程中发现任何不准确或不一致之处,模型将使用从查询中提取的关键词进行网络搜索,以生成新的答案或优化之前的答案。 </section></li> </ol> </section><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>3. 自省RAG(Self RAG)</strong></span> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">自省RAG通过自我反思或自我批评来提高RAG结果的质量。</p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img src="/upload/0cf4e2e4d5e456e0db094ad8e84def03.null" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;vertical-align:baseline;" data-ratio="0.2722222222222222" data-w="1080"> </figure> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">工作原理:</strong></p> <section data-role="list"> <ol data-tool="mdnice编辑器" style="list-style-type: decimal;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">搜索与检索</strong>:模型首先检索相关信息并根据输入查询生成答案。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">评分</strong>:为了对文档进行评分或反思,LLM会对每个答案进行批评,判断其是否与查询相关。如果文档不相关,则使用外部来源;如果相关,则检查是否存在幻觉和准确性。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">幻觉检查</strong>:幻觉节点检查答案是否由文档支持。有时,AI模型会“幻觉”,即生成听起来正确但实际上没有任何真实数据或文档支持的答案。幻觉节点通过确保模型的答案有文档支持来防止这种情况,确保答案的准确性和可靠性。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">回答问题</strong>:回答问题节点检查生成的答案是否回答了问题。它查看生成的答案并检查其是否相关且完整地回答了原始问题。如果没有,模型可以改进或调整答案以确保其准确性。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">输出</strong>:通过每次迭代,模型生成更准确且上下文更相关的答案。迭代次数取决于项目规模和可用处理能力。 </section></li> </ol> </section><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>4. 推测RAG(Speculative RAG)</strong></span> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">推测RAG是一种为给定查询生成多个答案的方法,利用检索模型提供相关信息。然后通过评分系统评估这些答案,选择最准确且上下文最合适的答案。这种方法有助于处理模糊性或查询可能有多种解释的情况。</p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-ratio="0.4888888888888889" src="/upload/f7f4b0f605daaa9d75672a3a0da7b2ab.null" data-w="1080" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;vertical-align:baseline;"> </figure> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">工作原理:</strong></p> <section data-role="list"> <ol data-tool="mdnice编辑器" style="list-style-type: decimal;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">搜索与检索</strong>:与简单RAG类似,系统检索与查询相关的多个文档。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">推测</strong>:LLM从检索到的文档中生成多个推测性答案,探索各种可能的输出,而不仅仅是一个。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">评分</strong>:评分机制根据相关性、连贯性、完整性和事实准确性等标准对每个答案进行评估和打分。这可能涉及将答案与更多检索到的文档进行比较或使用评分模型。与校正RAG类似,此步骤取决于项目目标和领域。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">选择与答案</strong>:模型对答案进行排名,并选择得分最高的答案作为最终输出。 </section></li> </ol> </section><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>5. 融合RAG(Fusion RAG)</strong></span> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">融合RAG结合了来自多个检索来源的信息,以生成一个全面的答案。<img class="rich_pages wxw-img" data-ratio="0.44537037037037036" src="/upload/c1321c251b4a3c50573cbc18fa42ae87.null" data-w="1080" style="display: block;margin: 0px auto;vertical-align: baseline;width: 100%;box-sizing:border-box;max-width:100% !important;"></p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">工作原理:</strong></p> <section data-role="list"> <ol data-tool="mdnice编辑器" style="list-style-type: decimal;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">搜索与检索多样化文档</strong>:系统检索多个相关文档,确保它们代表不同的观点或解决查询的不同方面。每个文档都可以被视为查询的一个答案。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">信息整合</strong>:LLM不仅结合了多个来源一致的文档,还考虑了不同文档中的各种观点或角度,旨在生成一个公平代表这些不同观点的答案。然后,模型通过结合所有检索到的文档中的相关信息,生成一个连贯、统一的答案,基于证据呈现一个平衡的观点。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">冲突解决</strong>:当存在冲突时,模型使用额外的上下文或预定义规则来解决冲突,以确保最终答案的一致性。 </section></li> </ol> </section><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>6. 自主RAG(Agentic RAG)</strong></span> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">自主RAG涉及一个具有特定目标的AI系统,它使用检索过程来自主做出决策并指导其行动。</p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-ratio="0.4425925925925926" src="/upload/278648542be808b6c8df53e4c9bebb18.null" data-w="1080" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;vertical-align:baseline;"> </figure> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">工作原理:</strong></p> <section data-role="list"> <ol data-tool="mdnice编辑器" style="list-style-type: decimal;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">查询输入</strong>:过程从用户的明确目标或查询开始,例如解释一个概念、提供定制建议或解决复杂问题。此查询作为模型行动的基础。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">搜索与检索</strong>:模型访问知识库或数据库,该数据库经过预处理阶段以高效地构建信息以供后续使用。预处理后的数据存储在向量存储库或知识图谱中,以便于检索。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">问答检查</strong>:生成初始答案后,模型检查问题是否已得到充分回答。这是过程中的一个关键决策点。如果是,则继续提供最终答案给用户。如果否,则进入下一阶段。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">代理干预与行动</strong>:如果初始答案未能充分回答查询,模型通过代理采取行动。代理可能会执行额外的任务,例如使用外部工具或调用进一步的操作以收集更多相关信息。LLM自主决定检索哪些信息以及采取哪些行动以实现目标。这可以通过在该步骤中为LLM定义一个思维链提示来完成。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">迭代过程与动态调整</strong>:该过程是动态且迭代的。代理持续评估模型的进展并实时调整行动,优化策略以获得更好的结果。此步骤涉及评估中间结果并采取纠正措施,例如重新查询或更改检索方法。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">目标完成</strong>:一旦模型确认已达到目标或解决了问题,它将生成最终输出或答案,并交付给用户。如果需要进一步调整,该过程可能会再次循环,直到查询完全解决。 </section></li> </ol> </section><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>7. 图RAG(Graph RAG)</strong></span> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">GraphRAG 是微软公司内部广受赞誉的一种结合了检索增强生成(RAG)技术和知识图谱的先进框架。它在传统 RAG 框架的基础上,进一步强化了实体、社区以及文本切块(Chunking)之间的内在联系,并且巧妙地将现有知识图谱(KG)中的知识融入其中。这一系列的改进措施,显著提升了信息检索的召回率与准确性,为用户带来了更为优质的信息检索体验。</p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-ratio="0.6583333333333333" src="/upload/f94ca47ee5a96882e3ea50bf925af289.null" data-w="1080" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;vertical-align:baseline;"> </figure> <blockquote data-tool="mdnice编辑器" style="margin-top: 20px;margin-bottom: 20px;margin-left: 0px;margin-right: 0px;padding-top: 10px;padding-bottom: 10px;padding-left: 20px;padding-right: 10px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: #ffc900;border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;background-attachment: scroll;background-clip: border-box;background-color: #fff9e3;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;display: block;overflow-x: auto;overflow-y: auto;box-sizing:border-box;"> <span style="display: none;color: #000000;font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: normal;"></span> <p style="text-align:left;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;color: #9b6e23;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;font-weight: normal;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">GitHub</strong>: <strong>microsoft/graphrag</strong><br><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">论文</strong>: <strong>From Local to Global: A Graph RAG Approach to Query-Focused Summarization</strong><br><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">项目文档</strong>: <strong>microsoft.github.io/graphrag/</strong></p> </blockquote> <blockquote data-tool="mdnice编辑器" style="margin-top: 20px;margin-bottom: 20px;margin-left: 0px;margin-right: 0px;padding-top: 10px;padding-bottom: 10px;padding-left: 20px;padding-right: 10px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: #ffc900;border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;background-attachment: scroll;background-clip: border-box;background-color: #fff9e3;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;display: block;overflow-x: auto;overflow-y: auto;box-sizing:border-box;"> <span style="display: none;color: #000000;font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: normal;"></span> <p style="text-align:left;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;color: #9b6e23;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;font-weight: normal;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;">GraphRAG 旨在通过利用外部结构化知识图谱来增强大型语言模型(LLMs)的性能,有效解决模型可能出现的“幻觉”问题、领域知识缺失以及信息过时等问题。GraphRAG 的核心目的在于从数据库中检索最相关的知识,以增强下游任务的答案质量,提供更准确和丰富的生成结果。</p> </blockquote> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">工作原理</strong><img class="rich_pages wxw-img" data-ratio="0.5425925925925926" src="/upload/a83d46274cab9df35389d200c2d485d8.null" data-w="1080" style="display: block;margin: 0px auto;vertical-align: baseline;width: 100%;box-sizing:border-box;max-width:100% !important;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">1. 索引建立阶段</strong><br>在 GraphRAG 的索引建立阶段,主要目标是从提供的文档集合中提取出知识图谱,并构建索引以支持后续的快速检索。这一阶段是 GraphRAG 工作流程的基础,其效率和准确性直接影响到后续检索和生成的质量。</p> <section data-role="list"> <ul data-tool="mdnice编辑器" style="list-style-type: disc;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">文本块拆分</strong>:首先,原始文档被拆分成多个文本块,这些文本块是 GraphRAG 处理的基本单元。根据微软的研究,每个文本块的大小和重叠度可以调整,以平衡处理速度和输出质量。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">实体与关系提取</strong>:利用大型语言模型(LLM),对每个文本块进行分析,提取出实体和关系。这一步骤是构建知识图谱的关键,涉及到命名实体识别(NER)和关系抽取(RE)技术。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">生成实体与关系摘要</strong>:为提取的实体与关系生成简单的描述性信息,这些信息将作为图节点的属性存储,有助于后续的检索和生成过程。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">社区检测</strong>:通过社区检测算法,如 Leiden 算法,识别图中的多个社区。这些社区代表了围绕特定主题的一组紧密相关的实体和关系。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">生成社区摘要</strong>:利用 LLM 为每个社区生成摘要信息,这些摘要提供了对数据集全局主题结构和语义的高层次理解,是回答高层次查询问题的关键。 </section></li> </ul> </section> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">2. 查询处理阶段</strong><br>查询处理阶段是 GraphRAG 工作流程的最终环节,它决定了如何利用已建立的索引来回答用户的查询。</p> <section data-role="list"> <ul data-tool="mdnice编辑器" style="list-style-type: disc;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">本地搜索(Local Search)</strong>:针对特定实体的查询,GraphRAG 通过扩展到相关实体的邻居和相关概念来推理,结合结构化数据和非结构化数据,构建用于增强生成的上下文。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">全局搜索(Global Search)</strong>:对于需要跨整个数据集整合信息的复杂查询,GraphRAG 采用 Map-Reduce 架构。首先,利用社区摘要独立并行地回答查询,然后将所有相关的部分答案汇总生成全局性的答案。 </section></li> </ul> </section> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">在查询处理阶段,GraphRAG 展示了其在处理复杂查询任务上的优势,尤其是在需要全局理解和高层语义分析的场景中。通过结合知识图谱的结构化信息和原始文档的非结构化数据,GraphRAG 能够提供更准确、更全面的答案。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">GraphRAG 的成功也催生了一系列轻量级的优化版本,诸如 LightRAG 与 nano-GraphRAG 等。与此同时,还涌现出了一些别具一格的变体,如 KAG 框架。这些框架在传统 RAG 框架的基础上,进一步强化了实体、社区以及文本切块(Chunking)之间的内在联系,并且巧妙地将现有知识图谱(KG)中的知识融入其中。这一系列的改进措施,显著提升了信息检索的召回率与准确性,为用户带来了更为优质的信息检索体验。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">示例</strong>针对新闻文章数据集的示例问题,Graph RAG(C2)和基础 RAG 的表现显示,GraphRAG 在处理复杂查询任务上具有显著优势,尤其是在需要全局理解和高层语义分析的场景中。</p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-ratio="1.2520833333333334" src="/upload/50194495817ad911a8579277a73a29cb.null" data-w="960" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;vertical-align:baseline;"> </figure><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>参考资料</strong></span><span style="display: none;"></span> <section data-role="list"> <section data-role="list"> <ul data-tool="mdnice编辑器" style="list-style-type: disc;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong>GraphRAG、Naive RAG框架总结主流框架推荐(共23个):LightRAG、nano-GraphRAG、Dify等</strong> </section></li> </ul> </section> </section> </section> </section> </section>
作者:微信小助手
<section data-role="outer" label="edit by 135editor"> <section data-role="paragraph"> <section class="mp_profile_iframe_wrp"> <mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-id="MzAxOTU5NTU4MQ==" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/1FD1x61uYVf9D3QcAhQDRtcia3Z56uk8JzHrb6lojGEQ4ddbzCa0XyMB2TpjRFI2zABZ3xOg2ITsdpbpum5BVdw/0?wx_fmt=png" data-nickname="ChallengeHub" data-alias="ChallengeHub" data-signature="由互联网大厂和中科院研究所的算法数分小伙伴们创建,热爱竞赛知识分享,获得过Kaggle、阿里天池等算法竞赛冠亚季成绩。每日给小伙伴带来机器学习、NLP、数据分析知识分享、竞赛干货、职场经验和内推~" data-from="0" data-is_biz_ban="0" data-service_type="1"></mp-common-profile> </section> <p><br></p> </section> <section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 10px;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;font-size: 16px;color: #000000;line-height: 1.5em;word-spacing: 0em;letter-spacing: 0em;word-break: break-word;overflow-wrap: break-word;text-align: left;box-sizing:border-box;font-family:Georgia, PingFangSC-light, serif;"> <blockquote data-tool="mdnice编辑器" style="margin-top: 20px;margin-bottom: 20px;margin-left: 0px;margin-right: 0px;padding-top: 10px;padding-bottom: 10px;padding-left: 20px;padding-right: 10px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: #ffc900;border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;background-attachment: scroll;background-clip: border-box;background-color: #fff9e3;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;display: block;overflow-x: auto;overflow-y: auto;box-sizing:border-box;"> <span style="display: none;color: #000000;font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: normal;"></span> <p style="text-align:left;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;color: #9b6e23;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;font-weight: normal;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;">聪明人往往很“懒”,但这种“懒”其实是高效的体现。他们总能找到解决复杂问题的最佳路径,用最少的力气获得最大的成果。</p> </blockquote> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">在RAG系统中,这种高效的实现往往是通过“分块”来实现的。你可以把它想象成把一本厚书分成几章——这样一来,阅读和理解就轻松多了。同样地,分块技术把大段复杂的文本拆分成更小、更容易处理的片段,让AI能更快、更准确地理解和处理信息。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">不过,在深入探讨分块之前,咱们得先聊聊它背后的“大框架”——检索增强生成,也就是RAG。这个技术可是分块能发挥作用的关键哦!</p> <h2 data-tool="mdnice编辑器" style="margin: 30px 0px 15px;padding: 0px;background: none 50% 50% / 63px no-repeat scroll padding-box border-box transparent;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-align: left;text-shadow: none;-webkit-box-reflect: unset;font-size: 17px;box-sizing: border-box;" data-remoteid="c1736435383380" data-cacheurl="https://files.mdnice.com/test/user/7752/d8da2183-1ef8-4674-abf4-47894263c123.svg"><span style="display: none;"></span><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>什么是RAG</strong></span></h2> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><img class="rich_pages wxw-img" data-imgfileid="100008363" data-ratio="0.5148148148148148" src="/upload/f5f62fc5dca0faf4d3ed3a59e14154fd.png" data-type="png" data-w="1080" style="display: block;margin: 0px auto;vertical-align: baseline;width: 100%;box-sizing:border-box;max-width:100% !important;">长话短说,检索增强生成(RAG)是一种巧妙的方法,它把检索机制和大型语言模型(LLM)结合在了一起。简单来说,就是让AI在生成回答之前,先“翻翻资料”——通过检索相关文档来增强自己的能力。这样一来,AI给出的回答不仅更准确,还能带上更多上下文信息,显得更有深度和针对性。</p> <h2 data-tool="mdnice编辑器" style="margin: 30px 0px 15px;padding: 0px;background: none 50% 50% / 63px no-repeat scroll padding-box border-box transparent;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-align: left;text-shadow: none;-webkit-box-reflect: unset;font-size: 17px;box-sizing: border-box;" data-remoteid="c1736435383381" data-cacheurl="https://files.mdnice.com/test/user/7752/d8da2183-1ef8-4674-abf4-47894263c123.svg"><span style="display: none;"></span><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>引入分块</strong></span></h2> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><img class="rich_pages wxw-img" data-imgfileid="100008364" data-ratio="0.7277777777777777" src="/upload/444f140fa655a439573af1e5956406ea.png" data-type="png" data-w="1080" style="display: block;margin: 0px auto;vertical-align: baseline;width: 100%;box-sizing:border-box;max-width:100% !important;">分块,说白了就是把一大段文字“切”成更小、更容易处理的片段。这个过程主要分两步走:</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">第一步:数据准备</strong><br>首先,我们需要把靠谱的数据源“切”成一个个小文档块,然后存到数据库里。如果这些小文档块还生成了对应的“嵌入”(可以理解成一种数学表示),那这个数据库就可以升级成向量存储,方便后续的快速查找。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">第二步:检索</strong><br>当用户抛出一个问题时,系统就会动起来,通过向量搜索、全文搜索,或者两者结合的方式,去数据库里翻找最相关的小文档块。简单来说,就是快速定位到那些和用户问题最匹配的信息片段。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">这样一来,大模型不仅能更快找到答案,还能确保回答得更精准、更有针对性!</p> <h2 data-tool="mdnice编辑器" style="margin: 30px 0px 15px;padding: 0px;background: none 50% 50% / 63px no-repeat scroll padding-box border-box transparent;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-align: left;text-shadow: none;-webkit-box-reflect: unset;font-size: 17px;box-sizing: border-box;" data-remoteid="c1736435383382" data-cacheurl="https://files.mdnice.com/test/user/7752/d8da2183-1ef8-4674-abf4-47894263c123.svg"><span style="display: none;"></span><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>为什么分块在 RAG 架构中如此重要?</strong></span><span style="display: none;"></span></h2><span style="font-size: 15px;letter-spacing: 0.06em;text-indent: 0em;word-spacing: 0em;">分块在 RAG 架构里可是个“关键角色”,因为它直接决定了生成式 AI 应用的准确性。可以说,它是整个流程的“第一道关卡”。</span> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;text-align: left;text-shadow: none;width: auto;-webkit-box-reflect: unset;font-size:17px;box-sizing:border-box;"><span style="background: none 0% 0% / 15px 15px no-repeat scroll padding-box border-box transparent;width: 15px;height: 15px;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;color: rgb(0, 0, 0);display: inline-block;font-size: 22px;flex-direction: unset;float: unset;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin: 0px 0px -2px;overflow: unset;padding: 0px;text-align: left;text-indent: 0em;text-shadow: none;-webkit-box-reflect: unset;box-sizing: border-box;" data-remoteid="c1736435383383" data-cacheurl="https://files.mdnice.com/test/user/7752/9bbabffd-11a7-40bc-9b0b-42b5679a5d3d.svg"></span><strong style="color: rgb(62, 76, 162);font-size: 18px;letter-spacing: 0em;text-indent: 0em;word-spacing: 0em;">1.</strong><strong style="background-image: none;background-position: 0% 0%;background-size: auto;background-repeat: no-repeat;background-attachment: scroll;background-origin: padding-box;background-clip: border-box;letter-spacing: 0px;text-indent: 0em;word-spacing: 0em;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: inline-block;font-size: 22px;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;width: auto;-webkit-box-reflect: unset;">小块头,大智慧:提高准确性</strong><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">分块让系统能把文本切成更小的片段,方便索引和搜索。这样一来,当用户提问时,系统能快速找到最相关的片段,大大提高了检索的准确性。想象一下,与其在一整本书里翻找答案,不如直接定位到某一页的某一段——效率高多了!</p> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;text-align: left;text-shadow: none;width: auto;-webkit-box-reflect: unset;font-size:17px;box-sizing:border-box;"><span style="background: none 0% 0% / 15px 15px no-repeat scroll padding-box border-box transparent;width: 15px;height: 15px;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;color: rgb(0, 0, 0);display: inline-block;font-size: 22px;flex-direction: unset;float: unset;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin: 0px 0px -2px;overflow: unset;padding: 0px;text-align: left;text-indent: 0em;text-shadow: none;-webkit-box-reflect: unset;box-sizing: border-box;" data-remoteid="c1736435383384" data-cacheurl="https://files.mdnice.com/test/user/7752/9bbabffd-11a7-40bc-9b0b-42b5679a5d3d.svg"></span><strong style="color: rgb(62, 76, 162);font-size: 18px;letter-spacing: 0em;text-indent: 0em;word-spacing: 0em;">2.</strong><strong style="background-image: none;background-position: 0% 0%;background-size: auto;background-repeat: no-repeat;background-attachment: scroll;background-origin: padding-box;background-clip: border-box;letter-spacing: 0px;text-indent: 0em;word-spacing: 0em;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: inline-block;font-size: 22px;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;width: auto;-webkit-box-reflect: unset;">大小适中,上下文更给力</strong><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">不过,分块也不是越小越好。块太小可能会丢失上下文信息,块太大又会让模型难以聚焦。理想的分块大小能让生成模型更好地理解每个片段的上下文,从而生成更连贯、更准确的回答。这样一来,模型就不用在一大堆无关信息里“大海捞针”了。</p> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;text-align: left;text-shadow: none;width: auto;-webkit-box-reflect: unset;font-size:17px;box-sizing:border-box;"><span style="background: none 0% 0% / 15px 15px no-repeat scroll padding-box border-box transparent;width: 15px;height: 15px;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;color: rgb(0, 0, 0);display: inline-block;font-size: 22px;flex-direction: unset;float: unset;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin: 0px 0px -2px;overflow: unset;padding: 0px;text-align: left;text-indent: 0em;text-shadow: none;-webkit-box-reflect: unset;box-sizing: border-box;" data-remoteid="c1736435383385" data-cacheurl="https://files.mdnice.com/test/user/7752/9bbabffd-11a7-40bc-9b0b-42b5679a5d3d.svg"></span><strong style="color: rgb(62, 76, 162);font-size: 18px;letter-spacing: 0em;text-indent: 0em;word-spacing: 0em;">3.</strong><strong style="background-image: none;background-position: 0% 0%;background-size: auto;background-repeat: no-repeat;background-attachment: scroll;background-origin: padding-box;background-clip: border-box;letter-spacing: 0px;text-indent: 0em;word-spacing: 0em;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: inline-block;font-size: 22px;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;width: auto;-webkit-box-reflect: unset;">可扩展性与性能:高效处理大数据</strong><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">分块还能让 RAG 系统更高效地处理海量数据。通过把数据切成可管理的部分,系统可以并行处理这些块,减少计算负担,提升整体性能。这样一来,RAG 系统不仅能处理更多数据,还能跑得更快、更稳。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">总之,分块不仅是 RAG 系统的技术必需品,更是一种战略方法。它提高了检索准确性、处理效率和资源利用率,是 RAG 应用成功的“秘密武器”。</p> <h2 data-tool="mdnice编辑器" style="margin: 30px 0px 15px;padding: 0px;background: none 50% 50% / 63px no-repeat scroll padding-box border-box transparent;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-align: left;text-shadow: none;-webkit-box-reflect: unset;font-size: 17px;box-sizing: border-box;" data-remoteid="c1736435383386" data-cacheurl="https://files.mdnice.com/test/user/7752/d8da2183-1ef8-4674-abf4-47894263c123.svg"><span style="display: none;"></span><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>优化分块的技巧:从基础到高级</strong></span><span style="display: none;"></span></h2><span style="font-size: 15px;letter-spacing: 0.06em;text-indent: 0em;word-spacing: 0em;">分块可不是随便“切一切”就完事了,想要让 RAG 系统表现得更出色,得用上一些技巧。下面这些方法,从简单到复杂,总有一款适合你:</span> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;text-align: left;text-shadow: none;width: auto;-webkit-box-reflect: unset;font-size:17px;box-sizing:border-box;"><span style="background: none 0% 0% / 15px 15px no-repeat scroll padding-box border-box transparent;width: 15px;height: 15px;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;color: rgb(0, 0, 0);display: inline-block;font-size: 22px;flex-direction: unset;float: unset;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin: 0px 0px -2px;overflow: unset;padding: 0px;text-align: left;text-indent: 0em;text-shadow: none;-webkit-box-reflect: unset;box-sizing: border-box;" data-remoteid="c1736435383387" data-cacheurl="https://files.mdnice.com/test/user/7752/9bbabffd-11a7-40bc-9b0b-42b5679a5d3d.svg"></span><strong style="color: rgb(62, 76, 162);font-size: 18px;letter-spacing: 0em;text-indent: 0em;word-spacing: 0em;">1.</strong><strong style="background-image: none;background-position: 0% 0%;background-size: auto;background-repeat: no-repeat;background-attachment: scroll;background-origin: padding-box;background-clip: border-box;letter-spacing: 0px;text-indent: 0em;word-spacing: 0em;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: inline-block;font-size: 22px;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;width: auto;-webkit-box-reflect: unset;">固定字符大小:简单粗暴</strong><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">这是最直接的方法——把文本按固定字符数切成块。比如每 500 个字符切一刀。虽然简单,但有时候效果还不错,尤其是对格式规整的文本。</p> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;text-align: left;text-shadow: none;width: auto;-webkit-box-reflect: unset;font-size:17px;box-sizing:border-box;"><span style="background: none 0% 0% / 15px 15px no-repeat scroll padding-box border-box transparent;width: 15px;height: 15px;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;color: rgb(0, 0, 0);display: inline-block;font-size: 22px;flex-direction: unset;float: unset;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin: 0px 0px -2px;overflow: unset;padding: 0px;text-align: left;text-indent: 0em;text-shadow: none;-webkit-box-reflect: unset;box-sizing: border-box;" data-remoteid="c1736435383388" data-cacheurl="https://files.mdnice.com/test/user/7752/9bbabffd-11a7-40bc-9b0b-42b5679a5d3d.svg"></span><span style="display: none;"></span><span style="font-size: 18px;color: #3e4ca2;line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 8px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>2.</strong><strong style="align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;color: #000000;display: inline-block;font-size: 22px;flex-direction: unset;float: unset;height: auto;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;">递归字符文本分割:按标点“下刀”</strong></span><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">这种方法更聪明一点,它会根据空格、标点符号(比如句号、逗号)来切分文本。这样一来,切出来的块更有上下文意义,不会把一句话硬生生切成两半。</p> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;text-align: left;text-shadow: none;width: auto;-webkit-box-reflect: unset;font-size:17px;box-sizing:border-box;"><span style="background: none 0% 0% / 15px 15px no-repeat scroll padding-box border-box transparent;width: 15px;height: 15px;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;color: rgb(0, 0, 0);display: inline-block;font-size: 22px;flex-direction: unset;float: unset;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin: 0px 0px -2px;overflow: unset;padding: 0px;text-align: left;text-indent: 0em;text-shadow: none;-webkit-box-reflect: unset;box-sizing: border-box;" data-remoteid="c1736435383389" data-cacheurl="https://files.mdnice.com/test/user/7752/9bbabffd-11a7-40bc-9b0b-42b5679a5d3d.svg"></span><strong style="color: rgb(62, 76, 162);font-size: 18px;letter-spacing: 0em;text-indent: 0em;word-spacing: 0em;">3.</strong><strong style="background-image: none;background-position: 0% 0%;background-size: auto;background-repeat: no-repeat;background-attachment: scroll;background-origin: padding-box;background-clip: border-box;letter-spacing: 0px;text-indent: 0em;word-spacing: 0em;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: inline-block;font-size: 22px;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;width: auto;-webkit-box-reflect: unset;">特定文档的拆分:因地制宜</strong><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">不同类型的文档(比如 PDF、Markdown)结构不一样,分块方法也得跟着变。比如,PDF 可以按段落切,Markdown 可以按标题切。这种“量身定制”的方法能让分块更精准。</p> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;text-align: left;text-shadow: none;width: auto;-webkit-box-reflect: unset;font-size:17px;box-sizing:border-box;"><span style="background: none 0% 0% / 15px 15px no-repeat scroll padding-box border-box transparent;width: 15px;height: 15px;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;color: rgb(0, 0, 0);display: inline-block;font-size: 22px;flex-direction: unset;float: unset;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin: 0px 0px -2px;overflow: unset;padding: 0px;text-align: left;text-indent: 0em;text-shadow: none;-webkit-box-reflect: unset;box-sizing: border-box;" data-remoteid="c1736435383390" data-cacheurl="https://files.mdnice.com/test/user/7752/9bbabffd-11a7-40bc-9b0b-42b5679a5d3d.svg"></span><strong style="color: rgb(62, 76, 162);font-size: 18px;letter-spacing: 0em;text-indent: 0em;word-spacing: 0em;">4.</strong><strong style="background-image: none;background-position: 0% 0%;background-size: auto;background-repeat: no-repeat;background-attachment: scroll;background-origin: padding-box;background-clip: border-box;letter-spacing: 0px;text-indent: 0em;word-spacing: 0em;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: inline-block;font-size: 22px;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;width: auto;-webkit-box-reflect: unset;">语义分割:按意思切块</strong><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">这种方法更高级,它会用嵌入技术(embedding)来分析文本的语义,然后根据意思来分块。比如,把讨论同一个话题的句子归到一起。这样一来,切出来的块不仅更连贯,还能更好地保留上下文。</p> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;text-align: left;text-shadow: none;width: auto;-webkit-box-reflect: unset;font-size:17px;box-sizing:border-box;"><span style="background: none 0% 0% / 15px 15px no-repeat scroll padding-box border-box transparent;width: 15px;height: 15px;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;color: rgb(0, 0, 0);display: inline-block;font-size: 22px;flex-direction: unset;float: unset;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin: 0px 0px -2px;overflow: unset;padding: 0px;text-align: left;text-indent: 0em;text-shadow: none;-webkit-box-reflect: unset;box-sizing: border-box;" data-remoteid="c1736435383391" data-cacheurl="https://files.mdnice.com/test/user/7752/9bbabffd-11a7-40bc-9b0b-42b5679a5d3d.svg"></span><strong style="color: rgb(62, 76, 162);font-size: 18px;letter-spacing: 0em;text-indent: 0em;word-spacing: 0em;">5.</strong><strong style="background-image: none;background-position: 0% 0%;background-size: auto;background-repeat: no-repeat;background-attachment: scroll;background-origin: padding-box;background-clip: border-box;letter-spacing: 0px;text-indent: 0em;word-spacing: 0em;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: inline-block;font-size: 22px;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;width: auto;-webkit-box-reflect: unset;">自主分割:让 AI 自己决定</strong><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">这是最“智能”的方法——直接让大型语言模型(LLM)根据内容和上下文来决定怎么分块。AI 会自己判断哪里该切,哪里该留,确保每个块都有完整的意义。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">通过灵活运用这些技巧,RAG 系统的性能和准确性都能大幅提升。分块不仅是技术活儿,更是一门艺术——掌握得好,AI 的表现就能更上一层楼!</p> <h2 data-tool="mdnice编辑器" style="margin: 30px 0px 15px;padding: 0px;background: none 50% 50% / 63px no-repeat scroll padding-box border-box transparent;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-align: left;text-shadow: none;-webkit-box-reflect: unset;font-size: 17px;box-sizing: border-box;" data-remoteid="c1736435383392" data-cacheurl="https://files.mdnice.com/test/user/7752/d8da2183-1ef8-4674-abf4-47894263c123.svg"><span style="display: none;"></span><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>固定字符大小分块:简单但有点“呆”</strong></span><span style="display: none;"></span></h2><span style="font-size: 15px;letter-spacing: 0.06em;text-indent: 0em;word-spacing: 0em;">固定字符大小分块是最基础的分块方法,简单来说,就是不管内容如何,直接按固定的字符数把文本“切”成块。比如,每 300 个字符切一刀,完事儿。</span> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><img data-imgfileid="100008366" data-ratio="0.4444444444444444" src="/upload/7730a9b7564b4a3ea73b9f80a45892a1.png" data-type="png" data-w="1080" style="display: block;margin: 0px auto;vertical-align: baseline;width: 100%;box-sizing:border-box;max-width:100% !important;">固定字符大小分块的优缺点</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">优点</strong>:</p> <section data-role="list"> <ol data-tool="mdnice编辑器" style="list-style-type: decimal;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">简单省事</strong>:这种方法实现起来超级简单,几乎不需要什么计算资源,特别适合快速上手。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">整齐划一</strong>:生成的块大小均匀,方便后续处理,比如存储或检索。 </section></li> </ol> </section> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">缺点</strong>:</p> <section data-role="list"> <ol data-tool="mdnice编辑器" style="list-style-type: decimal;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">忽略上下文</strong>:它完全不管文本的结构和意思,切出来的块可能会把完整的信息拆得支离破碎。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">效率不高</strong>:重要的内容可能会被“拦腰截断”,想要重新拼出有意义的信息,还得额外费功夫。 </section></li> </ol> </section> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">下面是如何使用代码实现固定字符大小分块的示例:</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;text-align: left;margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg sc8ljypicuauar0tctza9lj1d8t86r83y1zetw9yhrj6iaiah8q8iadicaqtufp3xmj16dgufmsggvnnajuzul06qym5nife8mmmc 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;box-sizing: border-box;max-width: 100% !important;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-size: 12px;font-family:Consolas, Monaco, Menlo, monospace;"><span style="color: #5c6370;font-style: italic;line-height: 26px;"># 将示例文本分块</span><br>text = <span style="color: #98c379;line-height: 26px;">"This is the text I would like to ch up. It is the example text for this exercise."</span> <br><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># 设置块大小</span><br>chunk_size = <span style="color: #d19a66;line-height: 26px;">35</span> <br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># 初始化一个列表来保存块 chunks</span><br> = [] <br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># 遍历文本以创建块</span><br><span style="color: #c678dd;line-height: 26px;">for</span> i <span style="color: #c678dd;line-height: 26px;">in</span> range ( <span style="color: #d19a66;line-height: 26px;">0</span> , len (text), chunk_size): <br> chunk = text[i:i + chunk_size] <br> chunks.append(chunk) <br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># 显示块</span><br><span style="color: #c678dd;line-height: 26px;">print</span> (chunks) <br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># 输出:['This is the text I would like to ch', 'unk up. It is the example text for ', 'this exercise']</span><br><br></code></pre> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">使用<code style="color: #9b6e23;font-size: 14px;line-height: 1.8em;letter-spacing: 0.04em;background-attachment: scroll;background-clip: border-box;background-color: #fff9e3;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 2px;margin-right: 2px;padding-top: 2px;padding-bottom: 2px;padding-left: 4px;padding-right: 4px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: #000000;border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;overflow-wrap: break-word;word-break: break-all;box-sizing:border-box;font-family:'Operator Mono', Consolas, Monaco, Menlo, monospace;">LangChainCharacterTextSplitter</code>来实现相同的结果:</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;text-align: left;margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg sc8ljypicuauar0tctza9lj1d8t86r83y1zetw9yhrj6iaiah8q8iadicaqtufp3xmj16dgufmsggvnnajuzul06qym5nife8mmmc 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;box-sizing: border-box;max-width: 100% !important;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-size: 12px;font-family:Consolas, Monaco, Menlo, monospace;"><br>from langchain.text_splitter import CharacterTextSplitter <br><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># 使用指定的块大小初始化文本分割器</span><br>text_splitter = CharacterTextSplitter(chunk_size= 35 , chunk_overlap= 0 , Separator= <span style="color: #98c379;line-height: 26px;">''</span> , strip_whitespace= False ) <br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># 使用文本分割器创建文档</span><br>documents = text_splitter.create_documents([text]) <br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># 显示创建的文档</span><br><span style="color: #c678dd;line-height: 26px;">for</span> doc <span style="color: #c678dd;line-height: 26px;">in</span> documents: <br> <span style="color: #e6c07b;line-height: 26px;">print</span> (doc.page_content) <br></code></pre> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">固定字符大小分块是一种简单但基础的技术,通常在转向更复杂的方法之前用作基准。</p> <h2 data-tool="mdnice编辑器" style="margin: 30px 0px 15px;padding: 0px;background: none 50% 50% / 63px no-repeat scroll padding-box border-box transparent;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-align: left;text-shadow: none;-webkit-box-reflect: unset;font-size: 17px;box-sizing: border-box;" data-remoteid="c1736435383395" data-cacheurl="https://files.mdnice.com/test/user/7752/d8da2183-1ef8-4674-abf4-47894263c123.svg"><span style="display: none;"></span><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>递归字符文本分割:保持上下文关联</strong></span><span style="display: none;"></span></h2><span style="font-size: 15px;letter-spacing: 0.06em;text-indent: 0em;word-spacing: 0em;">递归字符文本分割是一种更高级的技术,它考虑了文本的结构。它使用一系列分隔符以递归方式将文本分成块,确保块更有意义且与上下文更相关。</span> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><img class="rich_pages wxw-img" data-imgfileid="100008365" data-ratio="0.48055555555555557" src="/upload/cb1483f41983b9c6656e549b6da06ca5.png" data-type="png" data-w="1080" style="display: block;margin: 0px auto;vertical-align: baseline;width: 100%;box-sizing:border-box;max-width:100% !important;">在上面的例子中,我们设置了一个块大小为30个字符,重叠部分为20个字符。RecursiveCharacterTextSplitter这个工具会尽量在保持文本逻辑结构的同时进行拆分。不过,这也暴露了一个问题:由于块大小设置得比较小,它还是有可能在单词或句子中间“咔嚓”一刀,这显然不是我们想要的效果。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">优点:</strong></p> <section data-role="list"> <ul data-tool="mdnice编辑器" style="list-style-type: disc;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">上下文更连贯</strong>:这种方法通过使用段落或句子作为分隔符,能够更好地保留文本的自然结构。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">灵活性强</strong>:你可以根据需要调整块的大小和重叠部分,这样就能更精细地控制整个分块过程。 </section></li> </ul> </section> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">缺点:</strong></p> <section data-role="list"> <ul data-tool="mdnice编辑器" style="list-style-type: disc;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">块大小是个关键</strong>:块的大小得适中,既要方便处理,又要确保每个块至少包含一个完整的短语或更多内容。否则,我们在检索这些块时,可能会遇到精度问题。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">性能消耗</strong>:由于采用了递归拆分和处理多个分隔符的方式,这种方法会消耗更多的计算资源。而且,与固定大小的块相比,它生成的块数量也会更多。 </section></li> </ul> </section> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">以下是在 Langchain 中如何实现递归字符文本拆分的示例:</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;text-align: left;margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg sc8ljypicuauar0tctza9lj1d8t86r83y1zetw9yhrj6iaiah8q8iadicaqtufp3xmj16dgufmsggvnnajuzul06qym5nife8mmmc 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;box-sizing: border-box;max-width: 100% !important;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-size: 12px;font-family:Consolas, Monaco, Menlo, monospace;"><span style="color: #c678dd;line-height: 26px;">from</span> langchain_text_splitters <span style="color: #c678dd;line-height: 26px;">import</span> RecursiveCharacterTextSplitter<br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Sample text to chunk</span><br>text = <span style="color: #98c379;line-height: 26px;">"""<br>The Olympic Games, originally held in ancient Greece, were revived in 1896 and<br>have since become the world’s foremost sports competition, bringing together <br>athletes from around the globe.<br>"""</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Initialize the recursive character text splitter with specified chunk size</span><br>text_splitter = RecursiveCharacterTextSplitter(<br> <span style="color: #5c6370;font-style: italic;line-height: 26px;"># Set a really small chunk size, just to show.</span><br> chunk_size=<span style="color: #d19a66;line-height: 26px;">30</span>,<br> chunk_overlap=<span style="color: #d19a66;line-height: 26px;">20</span>,<br> length_function=len,<br> is_separator_regex=<span style="color: #56b6c2;line-height: 26px;">False</span>,<br>)<br><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Create documents using the text splitter</span><br>documents = text_splitter.create_documents([text])<br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Display the created documents</span><br><span style="color: #c678dd;line-height: 26px;">for</span> doc <span style="color: #c678dd;line-height: 26px;">in</span> documents:<br> print(doc.page_content)<br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Output:</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># “The Olympic Games, originally”</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># “held in ancient Greece, were”</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># “revived in 1896 and have”</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># “have since become the world’s”</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># “world’s foremost sports”</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># “competition, bringing together”</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># “together athletes from around”</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># “around the globe.”</span><br></code></pre> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">在这种方法中,文本首先会按照较大的结构(比如段落)进行拆分。如果拆分后的块还是太大,就会继续用更小的结构(比如句子)进一步切分。这样一来,每个块都能保留有意义的上下文,避免了重要信息被“拦腰截断”的情况。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">递归字符文本分割法在简单和复杂之间找到了一个平衡点,既不会过于粗暴地切割文本,也不会让分块过程变得繁琐。它提供了一种既高效又尊重文本结构的分块方式,算得上是一种非常实用的工具。</p> <h2 data-tool="mdnice编辑器" style="margin: 30px 0px 15px;padding: 0px;background: none 50% 50% / 63px no-repeat scroll padding-box border-box transparent;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-align: left;text-shadow: none;-webkit-box-reflect: unset;font-size: 17px;box-sizing: border-box;" data-remoteid="c1736435383397" data-cacheurl="https://files.mdnice.com/test/user/7752/d8da2183-1ef8-4674-abf4-47894263c123.svg"><span style="display: none;"></span><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong style="align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;color: #000000;display: inline-block;font-size: 22px;flex-direction: unset;float: unset;height: auto;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;">特定文档的拆分:因地制宜</strong></span><span style="display: none;"></span></h2><span style="font-size: 15px;letter-spacing: 0.06em;text-indent: 0em;word-spacing: 0em;">这种方法会根据不同的文档类型,量身定制分块策略。比如,Markdown 文件、Python 脚本、JSON 文档或者 HTML 文件,每种文档都会按照最适合其内容和结构的方式进行拆分。</span> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">举个例子,Markdown 文件在 GitHub、Medium 和 Confluence 等平台上非常常见,这也让它成为 RAG 系统中提取数据的首选。毕竟,干净且结构化的数据对于生成准确的响应至关重要。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">不仅如此,针对特定编程语言的分割器也适用于多种语言,比如 C++、Go、Java、Python 等。这样一来,代码可以被高效地分块,方便后续的分析和检索。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">简单来说,这种方法就是“看菜下饭”,根据文档的特点灵活处理,确保分块既高效又精准!</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><img class="rich_pages wxw-img" data-imgfileid="100008367" data-ratio="0.5231481481481481" src="/upload/784050d9e7885479097175fcfb7f07d1.png" data-type="png" data-w="1080" style="display: block;margin: 0px auto;vertical-align: baseline;width: 100%;box-sizing:border-box;max-width:100% !important;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">优点:</strong></p> <section data-role="list"> <ul data-tool="mdnice编辑器" style="list-style-type: disc;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">相关性更强</strong>:针对不同类型的文档,采用最合适的分块方法,同时还能保留文档的逻辑结构。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">精确度更高</strong>:根据每种文档的特点量身定制分块过程,确保分块结果更精准。 </section></li> </ul> </section> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">缺点:</strong></p> <section data-role="list"> <ul data-tool="mdnice编辑器" style="list-style-type: disc;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">实现起来有点复杂</strong>:因为不同类型的文档需要不同的分块策略和工具,所以实现起来会麻烦一些。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> <strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">维护成本较高</strong>:由于方法多样,维护起来也会相对复杂,需要投入更多精力。 </section></li> </ul> </section> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">这种方法虽然效果更好,但也需要更多的“技术含量”和“耐心”来支撑!</p> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;text-align: left;text-shadow: none;width: auto;-webkit-box-reflect: unset;font-size:17px;box-sizing:border-box;"><span style="background: none 0% 0% / 15px 15px no-repeat scroll padding-box border-box transparent;width: 15px;height: 15px;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;color: rgb(0, 0, 0);display: inline-block;font-size: 22px;flex-direction: unset;float: unset;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin: 0px 0px -2px;overflow: unset;padding: 0px;text-align: left;text-indent: 0em;text-shadow: none;-webkit-box-reflect: unset;box-sizing: border-box;" data-remoteid="c1736435383398" data-cacheurl="https://files.mdnice.com/test/user/7752/9bbabffd-11a7-40bc-9b0b-42b5679a5d3d.svg"></span><strong style="color: rgb(62, 76, 162);font-size: 18px;letter-spacing: 0em;text-indent: 0em;word-spacing: 0em;">Markdown 切块</strong><span style="display: none;"></span></h3> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;text-align: left;margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg sc8ljypicuauar0tctza9lj1d8t86r83y1zetw9yhrj6iaiah8q8iadicaqtufp3xmj16dgufmsggvnnajuzul06qym5nife8mmmc 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;box-sizing: border-box;max-width: 100% !important;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-size: 12px;font-family:Consolas, Monaco, Menlo, monospace;"><span style="color: #c678dd;line-height: 26px;">from</span> langchain.text_splitter <span style="color: #c678dd;line-height: 26px;">import</span> MarkdownTextSplitter<br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Sample Markdown text</span><br>markdown_text = <span style="color: #98c379;line-height: 26px;">"""<br># Fun in California<br>## Driving<br>Try driving on the 1 down to San Diego<br>### Food<br>Make sure to eat a burrito while you're there<br>## Hiking<br>Go to Yosemite<br>"""</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Initialize the Markdown text splitter</span><br>splitter = MarkdownTextSplitter(chunk_size=<span style="color: #d19a66;line-height: 26px;">40</span>, chunk_overlap=<span style="color: #d19a66;line-height: 26px;">0</span>)<br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Create documents using the text splitter</span><br>documents = splitter.create_documents([markdown_text])<br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Display the created documents</span><br><span style="color: #c678dd;line-height: 26px;">for</span> doc <span style="color: #c678dd;line-height: 26px;">in</span> documents:<br> print(doc.page_content)<br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Output:</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># # Fun in California\n\n## Driving</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Try driving on the 1 down to San Diego</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># ### Food</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Make sure to eat a burrito while you're</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># there</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># ## Hiking\n\nGo to Yosemite</span><br></code></pre> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: block;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow-x: unset;overflow-y: unset;text-align: left;text-shadow: none;width: auto;-webkit-box-reflect: unset;font-size:17px;box-sizing:border-box;"><span style="background: none 0% 0% / 15px 15px no-repeat scroll padding-box border-box transparent;width: 15px;height: 15px;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;color: rgb(0, 0, 0);display: inline-block;font-size: 22px;flex-direction: unset;float: unset;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin: 0px 0px -2px;overflow: unset;padding: 0px;text-align: left;text-indent: 0em;text-shadow: none;-webkit-box-reflect: unset;box-sizing: border-box;" data-remoteid="c1736435383400" data-cacheurl="https://files.mdnice.com/test/user/7752/9bbabffd-11a7-40bc-9b0b-42b5679a5d3d.svg"></span><strong style="color: rgb(62, 76, 162);font-size: 18px;letter-spacing: 0em;text-indent: 0em;word-spacing: 0em;">Python 代码切块</strong><span style="display: none;"></span></h3> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;text-align: left;margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg sc8ljypicuauar0tctza9lj1d8t86r83y1zetw9yhrj6iaiah8q8iadicaqtufp3xmj16dgufmsggvnnajuzul06qym5nife8mmmc 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;box-sizing: border-box;max-width: 100% !important;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-size: 12px;font-family:Consolas, Monaco, Menlo, monospace;"><span style="color: #c678dd;line-height: 26px;">from</span> langchain.text_splitter <span style="color: #c678dd;line-height: 26px;">import</span> PythonCodeTextSplitter<br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Sample Python code</span><br>python_text = <span style="color: #98c379;line-height: 26px;">"""<br>class Person:<br> def __init__(self, name, age):<br> self.name = name<br> self.age = age<br>p1 = Person("John", 36)<br>for i in range(10):<br> print(i)<br>"""</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Initialize the Python code text splitter</span><br>python_splitter = PythonCodeTextSplitter(chunk_size=<span style="color: #d19a66;line-height: 26px;">100</span>, chunk_overlap=<span style="color: #d19a66;line-height: 26px;">0</span>)<br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Create documents using the text splitter</span><br>documents = python_splitter.create_documents([python_text])<br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Display the created documents</span><br><span style="color: #c678dd;line-height: 26px;">for</span> doc <span style="color: #c678dd;line-height: 26px;">in</span> documents:<br> print(doc.page_content)<br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Output:</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># class Person:\n def __init__(self, name, age):\n self.name = name\n self.age = age</span><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># p1 = Person("John", 36)\n\nfor i in range(10):\n print(i)</span><br></code></pre> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">文档拆分这件事,听起来简单,但其实大有学问。我们采用的是一种“量身定制”的拆分方式,它会根据文档类型的不同,智能地保留原有的逻辑结构。这样做的好处是,每个拆分出来的文本块都自带完整的上下文,不会出现“断章取义”的情况。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">举个例子你就明白了:处理Markdown文档时,系统会聪明地把标题和正文分开处理,就像整理书籍时会区分章节标题和正文内容一样;处理Python代码时,它又能准确识别类和函数的边界,就像程序员阅读代码时会自然地区分不同功能模块。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">这种智能拆分方式,让文档处理系统变得更“懂行”。它不仅保持了文档的完整性,还让系统在检索信息时更精准,生成回答时更靠谱。你可以把它想象成一个特别细心的图书管理员,不仅知道每本书放在哪个书架,还能准确找到书中最相关的段落。</p> <h2 data-tool="mdnice编辑器" style="margin: 30px 0px 15px;padding: 0px;background: none 50% 50% / 63px no-repeat scroll padding-box border-box transparent;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-align: left;text-shadow: none;-webkit-box-reflect: unset;font-size: 17px;box-sizing: border-box;" data-remoteid="c1736435383402" data-cacheurl="https://files.mdnice.com/test/user/7752/d8da2183-1ef8-4674-abf4-47894263c123.svg"><span style="display: none;"></span><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>语义分割:保留语义的完整性</strong></span><span style="display: none;"></span></h2><span style="font-size: 15px;letter-spacing: 0.06em;text-indent: 0em;word-spacing: 0em;">以前的文档拆分方式,说白了就是“简单粗暴”——要么按固定长度切分,要么死板地按照标点符号来划分。但我们现在用的这种语义拆分,那可真是“聪明”多了!它就像个理解能力超强的读者,会根据文本的实际意思来决定怎么拆分,把文档处理带到了一个新高度。</span> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">具体是怎么做到的呢?这要归功于先进的嵌入技术。系统会先理解文本的含义,然后把意思相近的内容自动归类到一起。这样一来,每个拆分出来的文本块都是一个完整的“小故事”,前后文都对得上,不会出现前言不搭后语的情况。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">你可以把它想象成一个特别会整理资料的小助手:它不会把你的文件随便撕成几半,而是会仔细阅读内容,把相关的部分整整齐齐地放在一起。这样不仅看起来舒服,用起来也特别顺手!</p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <img class="rich_pages wxw-img" data-imgfileid="100008369" data-ratio="0.5879629629629629" src="/upload/7fcb46133074341b495b3209aa0cd7db.png" data-type="png" data-w="1080" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;vertical-align:baseline;"> </figure> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">让我们来看看这个语义分块是怎么工作的,就像拆解一个精密的机器一样,它主要分三步走:</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">第一步,先把文档“切”成一句一句的。这可不是简单的断句哦,系统会像语文老师一样,准确地识别出每个完整的句子。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">第二步,给每个句子穿上“智能外套”——也就是生成嵌入向量。这个过程就像是给句子打上独特的身份标签,让系统能理解它们的含义。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">第三步最有趣,系统会像个细心的图书管理员,把意思相近的句子归类到一起。想象一下,它会把讨论同一个话题的句子自动归为一组,就像把同类型的书籍放在同一个书架上。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">这样做的好处显而易见:每个分块都是一个完整的小故事,前后文都对得上号。当你需要查找信息时,系统就能快速找到最相关的内容,准确率杠杠的!</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">下面,我们就通过一个具体的例子,来看看这个方法的神奇之处。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><img class="rich_pages wxw-img" data-imgfileid="100008370" data-ratio="0.5509259259259259" src="/upload/b79fa812718e40bb62f01e6e65531df9.png" data-type="png" data-w="1080" style="display: block;margin: 0px auto;vertical-align: baseline;width: 100%;box-sizing:border-box;max-width:100% !important;">这张图给我们展示了一个生动的例子,展示了如何用余弦相似度来给句子分组。简单来说,就是让聊同一件事的句子待在一起,而话题不同的句子就各走各的路。通过这种可视化的方式,我们能清楚地看到语义分块是怎么保持文本的连贯性的。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">优点:</strong></p> <section data-role="list"> <ol data-tool="mdnice编辑器" style="list-style-type: decimal;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> 上下文拿捏得准:相似的内容总在一起,找信息时特别给力,准确率up up! </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> 灵活度满分:不管什么类型的文本,它都能根据意思来调整,不会死板地按固定规则来。 </section></li> </ol> </section> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">小缺点:</strong>3. 有点费算力:毕竟要生成和比较那些嵌入向量,需要多花点计算资源。4. 实现起来不简单:比起直接按字数或标点拆分,这个方法确实复杂一些。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">以下是如何使用嵌入实现语义分割的示例:</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;text-align: left;margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg sc8ljypicuauar0tctza9lj1d8t86r83y1zetw9yhrj6iaiah8q8iadicaqtufp3xmj16dgufmsggvnnajuzul06qym5nife8mmmc 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;box-sizing: border-box;max-width: 100% !important;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-size: 12px;font-family:Consolas, Monaco, Menlo, monospace;">from sklearn.metrics.pairwise import cosine_similarity<br>from langchain.embeddings import OpenAIEmbeddings<br>import re<br># Sample text<br>text = """<br>One of the most important things I didn't understand about the world when I was a child is the degree to which the returns for performance are superlinear.<br>Teachers and coaches implicitly told us the returns were linear. "You get out," I heard a thousand times, "what you put in." They meant well, but this is rarely true. If your product is only half as good as your competitor's, you don't get half as many customers. You get no customers, and you go out of business.<br>It's obviously true that the returns for performance are superlinear in business. Some think this is a flaw of capitalism, and that if we changed the rules it would stop being true. But superlinear returns for performance are a feature of the world, not an artifact of rules we've invented. We see the same pattern in fame, power, military victories, knowledge, and even benefit to humanity. In all of these, the rich get richer.<br>"""<br># Splitting the text into sentences<br>sentences = re.split(r'(?<=[.?!])\s+', text)<br>sentences = [{'sentence': x, 'index' : i} for i, x in enumerate(sentences)]<br># Combine sentences for context<br>def combine_sentences(sentences, buffer_size=1):<br> for i in range(len(sentences)):<br> combined_sentence = ''<br> for j in range(i - buffer_size, i):<br> if j >= 0:<br> combined_sentence += sentences[j]['sentence'] + ' '<br> combined_sentence += sentences[i]['sentence']<br> for j in range(i + 1, i + 1 + buffer_size):<br> if j < len(sentences):<br> combined_sentence += ' ' + sentences[j]['sentence']<br> sentences[i]['combined_sentence'] = combined_sentence<br> return sentences<br>sentences = combine_sentences(sentences)<br># Generate embeddings<br>oai_embeds = OpenAIEmbeddings()<br>embeddings = oai_embeds.embed_documents([x['combined_sentence'] for x in sentences])<br># Add embeddings to sentences<br>for i, sentence in enumerate(sentences):<br> sentence['combined_sentence_embedding'] = embeddings[i]<br># Calculate cosine distances<br>def calculate_cosine_distances(sentences):<br> distances = []<br> for i in range(len(sentences) - 1):<br> embedding_current = sentences[i]['combined_sentence_embedding']<br> embedding_next = sentences[i + 1]['combined_sentence_embedding']<br> similarity = cosine_similarity([embedding_current], [embedding_next])[0][0]<br> distance = 1 - similarity<br> distances.append(distance)<br> sentences[i]['distance_to_next'] = distance<br> return distances, sentences<br>distances, sentences = calculate_cosine_distances(sentences)<br># Determine breakpoints and create chunks<br>import numpy as np<br>breakpoint_distance_threshold = np.percentile(distances, 95)<br>indices_above_thresh = [i for i, x in enumerate(distances) if x > breakpoint_distance_threshold]<br># Combine sentences into chunks<br>chunks = []<br>start_index = 0<br>for index in indices_above_thresh:<br> end_index = index<br> group = sentences[start_index:end_index + 1]<br> combined_text = ' '.join([d['sentence'] for d in group])<br> chunks.append(combined_text)<br> start_index = index + 1<br>if start_index < len(sentences):<br> combined_text = ' '.join([d['sentence'] for d in sentences[start_index:]])<br> chunks.append(combined_text)<br># Display the created chunks<br>for i, chunk in enumerate(chunks):<br> print(f"Chunk #{i+1}:\n{chunk}\n")</code></pre> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">语义分割这招挺有意思,它用嵌入技术把意思相近的内容打包在一起,做成一个个“语义块”。这样做的好处可不少,特别是在RAG系统里,找东西更准了,生成的回答也更靠谱了。</p> <blockquote data-tool="mdnice编辑器" style="margin-top: 20px;margin-bottom: 20px;margin-left: 0px;margin-right: 0px;padding-top: 10px;padding-bottom: 10px;padding-left: 20px;padding-right: 10px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: #ffc900;border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;background-attachment: scroll;background-clip: border-box;background-color: #fff9e3;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;display: block;overflow-x: auto;overflow-y: auto;box-sizing:border-box;"> <span style="display: none;color: #000000;font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: normal;"></span> <p style="text-align:left;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;color: #9b6e23;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;font-weight: normal;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;">它的秘诀就在于特别注重文本的实际含义。每个分出来的块都像是一个完整的小故事,里面的内容都是相关的、连贯的。这样一来,RAG应用的表现自然就上去了,既好用又可靠。</p> </blockquote> <h2 data-tool="mdnice编辑器" style="margin: 30px 0px 15px;padding: 0px;background: none 50% 50% / 63px no-repeat scroll padding-box border-box transparent;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-align: left;text-shadow: none;-webkit-box-reflect: unset;font-size: 17px;box-sizing: border-box;" data-remoteid="c1736435383404" data-cacheurl="https://files.mdnice.com/test/user/7752/d8da2183-1ef8-4674-abf4-47894263c123.svg"><span style="display: none;"></span><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>代理分割:自主智能切片</strong></span><span style="display: none;"></span></h2><span style="font-size: 15px;letter-spacing: 0.06em;text-indent: 0em;word-spacing: 0em;">代理分割(Agentic Splitter)这招可厉害了!它靠着大语言模型的超强理解力,能像人一样聪明地给文本分块。</span> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">这个方法高级在哪呢?它会像我们读书时那样,先理解内容的意思,再看看上下文,然后找出最合适的地方“下刀”。完全不像以前那些死板的规则或者纯靠统计的方法。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">说白了,它处理文本的方式就跟人一样灵活。想象一下你读文章时会怎么分段——肯定是根据意思和思路来的对吧?这个分裂器也是这么干的!所以分出来的块特别连贯,内容也都很相关,用起来特别顺手。<img class="rich_pages wxw-img" data-imgfileid="100008368" data-ratio="0.5388888888888889" src="/upload/fae51c08eb28ee236a582baa431bf50d.png" data-type="png" data-w="1080" style="display: block;margin: 0px auto;vertical-align: baseline;width: 100%;box-sizing:border-box;max-width:100% !important;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">优点:</strong></p> <section data-role="list"> <ol data-tool="mdnice编辑器" style="list-style-type: decimal;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> 准得很:靠着强大的语言模型,分出来的块不仅内容相关,上下文也特别准。 </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: #010101;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-align: left;font-weight: normal;"> 够灵活:不管什么类型的文本都能搞定,分块策略还能随时调整,特别聪明。 </section></li> </ol> </section> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: #3e4ca3;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;box-sizing:border-box;">缺点:</strong>3. 有点烧资源:毕竟要用大语言模型,计算资源少不了,成本也会高一些。4. 实现起来不简单:得好好设置和微调语言模型,才能让它发挥最佳水平。</p> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">在LangGraph里,节点就像是流水线上的一个个工作站。每个节点都有明确的职责:接活儿、干活儿、交活儿。它会接收输入数据,处理一番,然后把结果传给下一个节点,就像接力赛一样。</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;text-align: left;margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg sc8ljypicuauar0tctza9lj1d8t86r83y1zetw9yhrj6iaiah8q8iadicaqtufp3xmj16dgufmsggvnnajuzul06qym5nife8mmmc 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;box-sizing: border-box;max-width: 100% !important;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-size: 12px;font-family:Consolas, Monaco, Menlo, monospace;"><span style="color: #c678dd;line-height: 26px;">from</span> langgraph.nodes <span style="color: #c678dd;line-height: 26px;">import</span> InputNode, SentenceSplitterNode, LLMDecisionNode, ChunkingNode<br><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Step 1: Input Node</span><br>input_node = InputNode(name=<span style="color: #98c379;line-height: 26px;">"Document Input"</span>)<br><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Step 2: Sentence Splitting Node</span><br>splitter_node = SentenceSplitterNode(input=input_node.output, name=<span style="color: #98c379;line-height: 26px;">"Sentence Splitter"</span>)<br><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Step 3: LLM Decision Node</span><br>decision_node = LLMDecisionNode(<br> input=splitter_node.output, <br> prompt_template=<span style="color: #98c379;line-height: 26px;">"Does the sentence '{next_sentence}' belong to the same chunk as '{current_chunk}'?"</span>, <br> name=<span style="color: #98c379;line-height: 26px;">"LLM Decision"</span><br>)<br><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Step 4: Chunking Node</span><br>chunking_node = ChunkingNode(input=decision_node.output, name=<span style="color: #98c379;line-height: 26px;">"Semantic Chunking"</span>)<br><br><span style="color: #5c6370;font-style: italic;line-height: 26px;"># Run the graph</span><br>document = <span style="color: #98c379;line-height: 26px;">"Your document text here..."</span><br>result = chunking_node.run(document=document)<br>print(result)<br></code></pre> <h2 data-tool="mdnice编辑器" style="margin: 30px 0px 15px;padding: 0px;background: none 50% 50% / 63px no-repeat scroll padding-box border-box transparent;width: auto;height: auto;align-items: unset;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;justify-content: center;line-height: 1.5em;overflow: unset;text-align: left;text-shadow: none;-webkit-box-reflect: unset;font-size: 17px;box-sizing: border-box;" data-remoteid="c1736435383406" data-cacheurl="https://files.mdnice.com/test/user/7752/d8da2183-1ef8-4674-abf4-47894263c123.svg"><span style="display: none;"></span><span style="font-size: 20px;color: #3e4ca3;line-height: 2.4em;letter-spacing: 0em;margin-top: 10px;margin-bottom: 10px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: #000000;border-bottom-color: #000000;border-left-color: #000000;border-right-color: #000000;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;box-shadow: none;display: inline-block;flex-direction: unset;float: unset;height: 38px;justify-content: unset;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: center;text-indent: 0em;text-shadow: none;width: auto;-webkit-box-reflect: unset;box-sizing:border-box;"><strong>总结</strong></span><span style="display: none;"></span></h2><span style="font-size: 15px;letter-spacing: 0.06em;text-indent: 0em;word-spacing: 0em;">总结一下,分块这招对优化RAG系统来说,绝对是个关键策略。它能让系统的回答更准、更贴合上下文,还能轻松应对大规模需求。</span> <p data-tool="mdnice编辑器" style="text-align:left;color: #000000;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;">说白了,把大段文本切成小块,不仅找东西更快更准,还能让AI应用的整体效率蹭蹭往上涨。</p> <blockquote data-tool="mdnice编辑器" style="margin-top: 20px;margin-bottom: 20px;margin-left: 0px;margin-right: 0px;padding-top: 10px;padding-bottom: 10px;padding-left: 20px;padding-right: 10px;border-top-style: none;border-bottom-style: none;border-left-style: solid;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: #ffc900;border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;background-attachment: scroll;background-clip: border-box;background-color: #fff9e3;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;display: block;overflow-x: auto;overflow-y: auto;box-sizing:border-box;"> <span style="display: none;color: #000000;font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: normal;"></span> <p style="text-align:left;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;color: #9b6e23;font-size: 15px;line-height: 1.8em;letter-spacing: 0.06em;font-weight: normal;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;">原文链接🔗:https://towardsdatascience.com/the-art-of-chunking-boosting-ai-performance-in-rag-architectures-acdbdb8bdc2b</p> </blockquote> </section> <section data-role="paragraph"> <section data-role="paragraph"> <p><br></p> </section> <section data-role="paragraph"> <section style="box-sizing: border-box !important;-webkit-tap-highlight-color: transparent;margin: -2px 0px 0px;padding: 0px;outline: 0px;max-width: 100%;overflow-wrap: break-word !important;color: #000000;font-size: 16px;text-align: left;background-color: #ffffff;text-decoration-thickness: initial;display: flex;justify-content: center;align-items: center;flex-shrink: 0;font-family:Georgia, PingFangSC-light, serif;"> <section style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;overflow-wrap: break-word !important;width: 35px;box-sizing:border-box;"> <img class="__bg_gif rich_pages wxw-img" data-imgfileid="100008191" data-ratio="0.9322033898305084" src="/upload/d3099589f9465678fb622b03fa3f13de.null" data-w="354" data-width="100%" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;vertical-align: baseline;border-style: none;display: block;width: 100%;overflow-wrap: break-word !important;height: auto !important;visibility: visible !important;box-sizing:border-box;max-width:100% !important;" width="100%"> </section> <section data-brushtype="code" style="box-sizing: border-box !important;-webkit-tap-highlight-color: transparent;margin: 0px 12px -6px;padding: 0px;outline: 0px;max-width: 100%;overflow-wrap: break-word !important;color: #333333;font-size: 14px;text-align: center;letter-spacing: 1.5px;"> 添加微信,回复”RAG“进入交流群 </section> <section style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;overflow-wrap: break-word !important;width: 35px;box-sizing:border-box;"> <img class="rich_pages wxw-img __bg_gif" data-imgfileid="100008190" data-ratio="0.9322033898305084" src="/upload/d3099589f9465678fb622b03fa3f13de.null" data-w="354" data-width="100%" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;vertical-align: baseline;border-style: none;display: block;overflow-wrap: break-word !important;height: auto !important;width: 35px;visibility: visible !important;box-sizing:border-box;" width="35px"> </section> </section> <p style="text-align:center;box-sizing: border-box !important;-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;overflow-wrap: break-word !important;clear: both;min-height: 1em;color: #000000;font-size: 16px;text-decoration-thickness: initial;font-family:Georgia, PingFangSC-light, serif;"><img class="rich_pages wxw-img" data-backh="138" data-backw="102" data-imgfileid="100008189" data-ratio="1.3519553072625698" src="/upload/7969124f0646aac246cc6a1070c7c761.null" data-w="1074" data-width="102px" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;vertical-align: baseline;border-style: none;overflow-wrap: break-word !important;height: auto !important;text-align: left;background-color: #d7edcc;width: 144px !important;visibility: visible !important;box-sizing:border-box;" title="" width="102"></p> </section> <p><br></p> </section> </section> <p style="display: none;"> <mp-style-type data-value="3"></mp-style-type></p>
作者:微信小助手
<p style="margin-bottom: 0px;"><span style="font-size: 12px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;text-wrap: wrap;background-color: rgb(255, 255, 255);caret-color: var(--weui-brand);letter-spacing: 0.034em;visibility: visible;><span leaf="">* 戳上方蓝字“</span><span style="font-size: 12px;outline: 0px;color: rgb(47, 118, 195);visibility: visible;"><strong style="outline: 0px;visibility: visible;"><span leaf="">牛皮糖不吹牛</span></strong></span><span leaf="">”关注我</span></span></p> <p style="margin-bottom: 0px;"><span leaf=""> </span><span style="color: rgb(53, 53, 53);font-family: Optima-Regular, Optima, PingFangSC-regular, PingFangTC-regular, " pingfang sc, cambria, cochin, georgia, times, times new roman, serif;font-size: 16px;letter-spacing: 0.8px;text-align: left;word-spacing: 0.8px;text-wrap: wrap;background-color: rgb(255, 255, 255);><span leaf="">大家好,我是牛皮糖!大模型时代,动辄百亿参数的AI似乎只是巨头的游戏?</span></span><span leaf=""><br></span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">GitHub上一个开源项目彻底打破门槛:只需3块钱、2小时,普通人也能从零训练自己的语言模型!项目“MiniMind”上线即爆火,狂揽8.9k星标,技术圈直呼:“这才是AI民主化的未来!”</span></strong></p> <p style="margin-bottom: 0px;"><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf=""><br></span></strong></p> <section style="text-align: center;" nodeleaf=""> <img src="/upload/279e4c6b07373627e83d12ef842cdbbd.png" class="rich_pages wxw-img" data-ratio="0.8944444444444445" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100005532"> </section> <p style="margin-bottom: 0px;"><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf=""><br></span></strong></p> <p style="margin-bottom: 0px;"><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf=""><br></span></strong></p> <hr style="color: rgb(0, 0, 0);font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, microsoft yahei, arial, sans-serif;border-style: solid;border-width: 1px 0px 0px;border-color: rgba(0, 0, 0, 0.1);transform-origin: 0px 0px;transform: scale(1, 0.5);> <h3 style="font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;font-size: 15.4px;font-weight: bold;margin: 2em 8px 0.75em 0px;padding-left: 8px;border-left: 3px solid rgb(15, 76, 129);color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">一、逆袭:3块钱+2小时,训练一个AI大模型?</span></strong></h3> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><span leaf="">你以为训练AI需要天价算力、专业团队?</span><span leaf=""><br></span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">MiniMind用实力打脸:</span></strong></p> <ul style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin-left: 0px;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63); class="list-paddingleft-1"> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">成本3元</span></strong><span leaf="">:租用单张3090显卡,训练总成本不到一杯奶茶钱。</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">时间2小时</span></strong><span leaf="">:从数据清洗到模型训练,全流程自动化,普通人也能操作。</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">体积超小</span></strong><span leaf="">:最小模型仅25.8M(0.02B参数),是GPT-3的1/7000,手机都能跑!</span> </section></li> </ul> <section style="text-align: center;" nodeleaf=""> <img src="/upload/b4876dfb2db767cf3398ea991dca260a.png" class="rich_pages wxw-img" data-ratio="0.24457034938621341" data-s="300,640" data-type="png" data-w="1059" type="block" data-imgfileid="100005533"> </section> <hr style="color: rgb(0, 0, 0);font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, microsoft yahei, arial, sans-serif;border-style: solid;border-width: 1px 0px 0px;border-color: rgba(0, 0, 0, 0.1);transform-origin: 0px 0px;transform: scale(1, 0.5);> <h3 style="font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;font-size: 15.4px;font-weight: bold;margin: 2em 8px 0.75em 0px;padding-left: 8px;border-left: 3px solid rgb(15, 76, 129);color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">二、开源即正义:从零到一,代码全公开!</span></strong></h3> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><span leaf="">MiniMind不仅“能用”,更“能学”——</span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">它是一本活的AI教科书!</span></strong></p> <ul style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin-left: 0px;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63); class="list-paddingleft-1"> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">全流程开源</span></strong><span leaf="">:预训练、微调、LoRA、强化学习、模型蒸馏…所有代码从零实现,拒绝“黑箱”。</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">极简设计</span></strong><span leaf="">:核心算法用PyTorch原生重构,无需依赖第三方库,小白也能看懂。</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">保姆级教程</span></strong><span leaf="">:数据清洗、模型配置、训练脚本…每一步都附详细注释,GitHub Issues社区互助解答。</span> </section></li> </ul> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">开发者说:</span></strong><span leaf=""><br></span><span leaf="">“代码即答案——我希望每个人都能亲手‘造’一个AI,而不只是调用API。”</span></p> <hr style="color: rgb(0, 0, 0);font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, microsoft yahei, arial, sans-serif;border-style: solid;border-width: 1px 0px 0px;border-color: rgba(0, 0, 0, 0.1);transform-origin: 0px 0px;transform: scale(1, 0.5);> <h3 style="font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;font-size: 15.4px;font-weight: bold;margin: 2em 8px 0.75em 0px;padding-left: 8px;border-left: 3px solid rgb(15, 76, 129);color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">三、技术党狂喜:MoE、DPO、RLHF…前沿技术全打包!</span></strong></h3> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><span leaf="">你以为小模型=低技术?MiniMind藏着大野心:</span></p> <ul style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin-left: 0px;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63); class="list-paddingleft-1"> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">支持混合专家(MoE)</span></strong><span leaf="">:动态分配计算资源,小模型也能高效学习。</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">直接偏好优化(DPO)</span></strong><span leaf="">:无需复杂奖励模型,用人类偏好直接微调,让AI更“贴心”。</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">多模态扩展</span></strong><span leaf="">:已推出视觉版MiniMind-V,图片对话、图文生成一键搞定。</span> </section></li> </ul> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">技术博主评价:</span></strong><span leaf=""><br></span><span leaf="">“麻雀虽小五脏俱全,MiniMind的技术栈比许多商业项目还先进!”</span></p> <hr style="color: rgb(0, 0, 0);font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, microsoft yahei, arial, sans-serif;border-style: solid;border-width: 1px 0px 0px;border-color: rgba(0, 0, 0, 0.1);transform-origin: 0px 0px;transform: scale(1, 0.5);> <h3 style="font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;font-size: 15.4px;font-weight: bold;margin: 2em 8px 0.75em 0px;padding-left: 8px;border-left: 3px solid rgb(15, 76, 129);color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">四、落地场景:个人开发者的春天来了!</span></strong></h3> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><span leaf="">低成本+轻量化的MiniMind,让AI开发不再“高不可攀”:</span></p> <ul style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin-left: 0px;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63); class="list-paddingleft-1"> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">垂直领域定制</span></strong><span leaf="">:医疗、法律、教育…用LoRA微调专属模型,无需从头训练。</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">嵌入式部署</span></strong><span leaf="">:25.8M的模型可轻松植入App、智能硬件,离线运行无压力。</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">教育神器</span></strong><span leaf="">:学生党用它学习AI原理,论文复现、毕业设计“抄作业”神器。</span> </section></li> </ul> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">用户案例:</span></strong></p> <ul style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin-left: 0px;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63); class="list-paddingleft-1"> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• 某中医团队用MiniMind+医疗数据,训练出“智能问诊助手”。</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• 大学生用个人电脑训练模型,斩获AI竞赛奖项。</span> </section></li> </ul> <hr style="color: rgb(0, 0, 0);font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, microsoft yahei, arial, sans-serif;border-style: solid;border-width: 1px 0px 0px;border-color: rgba(0, 0, 0, 0.1);transform-origin: 0px 0px;transform: scale(1, 0.5);> <h3 style="font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;font-size: 15.4px;font-weight: bold;margin: 2em 8px 0.75em 0px;padding-left: 8px;border-left: 3px solid rgb(15, 76, 129);color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">五、全网热议:AI民主化真的来了?</span></strong></h3> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><span leaf="">MiniMind的爆火,掀起技术圈狂欢与思考:</span></p> <ul style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin-left: 0px;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63); class="list-paddingleft-1"> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">支持派</span></strong><span leaf="">:“技术壁垒被打破,个人开发者也能挑战巨头!”</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">反思派</span></strong><span leaf="">:“小模型虽好,但如何解决数据质量、伦理问题?”</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">• </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">未来派</span></strong><span leaf="">:“如果人人都能训练AI,内容创作、知识服务的边界将被彻底颠覆!”</span> </section></li> </ul> <hr style="color: rgb(0, 0, 0);font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, microsoft yahei, arial, sans-serif;border-style: solid;border-width: 1px 0px 0px;border-color: rgba(0, 0, 0, 0.1);transform-origin: 0px 0px;transform: scale(1, 0.5);> <h3 style="font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;font-size: 15.4px;font-weight: bold;margin: 2em 8px 0.75em 0px;padding-left: 8px;border-left: 3px solid rgb(15, 76, 129);color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">六、立即行动:手把手教你跑通第一个模型</span></strong></h3> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">步骤超简单:</span></strong></p> <ol style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin-left: 0px;padding-left: 1em;color: rgb(63, 63, 63); class="list-paddingleft-1"> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">1. </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">克隆项目</span></strong><span leaf="">:</span> <pre style="color: rgb(171, 178, 191);background: rgb(40, 44, 52);text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;font-size: 14px;overflow-x: auto;border-radius: 8px;margin: 10px 8px;padding: 0px !important;><span data-cacheurl="" data-remoteid="" style="padding: initial;display: block;height: 25px;background-color: transparent;background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;background-image: url(" https: mmbiz.qpic.cn mmbiz_svg 4qtdckraacmbyauvsn6pn2taiaekedl8u8hcspoipvg83iy3jto9zlcz8ufkprmkpnxjcxkklihvdz9qwrvpg8tkiaypwr3ql5 640?wx_fmt="svg&from=appmsg");""></span><code style="display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;font-family: Menlo, " operator mono, consolas, monaco, monospace;font-size: 14px;margin: 0px;white-space: nowrap;><span leaf="">git </span><span style="color: rgb(230, 192, 123);"><span leaf="">clone</span></span><span leaf=""> https://github.com/jingyaogong/minimind </span></code></pre> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">2. </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">安装环境</span></strong><span leaf="">:</span> <pre style="color: rgb(171, 178, 191);background: rgb(40, 44, 52);text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;font-size: 14px;overflow-x: auto;border-radius: 8px;margin: 10px 8px;padding: 0px !important;><span data-cacheurl="" data-remoteid="" style="padding: initial;display: block;height: 25px;background-color: transparent;background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;background-image: url(" https: mmbiz.qpic.cn mmbiz_svg 4qtdckraacmbyauvsn6pn2taiaekedl8u8hcspoipvg83iy3jto9zlcz8ufkprmkpnxjcxkklihvdz9qwrvpg8tkiaypwr3ql5 640?wx_fmt="svg&from=appmsg");""></span><code style="display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;font-family: Menlo, " operator mono, consolas, monaco, monospace;font-size: 14px;margin: 0px;white-space: nowrap;><span leaf="">pip install -r requirements.txt </span></code></pre> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">3. </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">下载数据</span></strong><span leaf="">:Hugging Face上开源1.6GB高质量数据集。</span> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">4. </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">一键训练</span></strong><span leaf="">:</span> <pre style="color: rgb(171, 178, 191);background: rgb(40, 44, 52);text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;font-size: 14px;overflow-x: auto;border-radius: 8px;margin: 10px 8px;padding: 0px !important;><span data-cacheurl="" data-remoteid="" style="padding: initial;display: block;height: 25px;background-color: transparent;background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;background-image: url(" https: mmbiz.qpic.cn mmbiz_svg 4qtdckraacmbyauvsn6pn2taiaekedl8u8hcspoipvg83iy3jto9zlcz8ufkprmkpnxjcxkklihvdz9qwrvpg8tkiaypwr3ql5 640?wx_fmt="svg&from=appmsg");""></span><code style="display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;font-family: Menlo, " operator mono, consolas, monaco, monospace;font-size: 14px;margin: 0px;white-space: nowrap;><span leaf="">python train_pretrain.py </span><span style="color: rgb(92, 99, 112);font-style: italic;"><span leaf=""># 预训练 </span></span><span leaf=""><br></span><span leaf="">python train_full_sft.py </span><span style="color: rgb(92, 99, 112);font-style: italic;"><span leaf=""># 微调 </span></span></code></pre> </section></li> <li style="text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;color: rgb(63, 63, 63);"> <section> <span leaf="">5. </span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">启动对话</span></strong><span leaf="">:</span> <pre style="color: rgb(171, 178, 191);background: rgb(40, 44, 52);text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;font-size: 14px;overflow-x: auto;border-radius: 8px;margin: 10px 8px;padding: 0px !important;><span data-cacheurl="" data-remoteid="" style="padding: initial;display: block;height: 25px;background-color: transparent;background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;background-image: url(" https: mmbiz.qpic.cn mmbiz_svg 4qtdckraacmbyauvsn6pn2taiaekedl8u8hcspoipvg83iy3jto9zlcz8ufkprmkpnxjcxkklihvdz9qwrvpg8tkiaypwr3ql5 640?wx_fmt="svg&from=appmsg");""></span><code style="display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0px;text-align: left;line-height: 1.75;font-family: Menlo, " operator mono, consolas, monaco, monospace;font-size: 14px;margin: 0px;white-space: nowrap;><span leaf="">streamlit run scripts/web_demo.py </span></code></pre> </section></li> </ol> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">网友实测视频教程已在B站疯传,搜索“MiniMind”即可跟练!</span></strong></p> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">https://www.bilibili.com/video/BV12dHPeqE72/</span></strong></p> <hr style="color: rgb(0, 0, 0);font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, microsoft yahei, arial, sans-serif;border-style: solid;border-width: 1px 0px 0px;border-color: rgba(0, 0, 0, 0.1);transform-origin: 0px 0px;transform: scale(1, 0.5);> <h3 style="font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;font-size: 15.4px;font-weight: bold;margin: 2em 8px 0.75em 0px;padding-left: 8px;border-left: 3px solid rgb(15, 76, 129);color: rgb(63, 63, 63);><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">结语</span></strong></h3> <p style="font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: justify;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);><span leaf="">AI不应是少数人的“魔法”,而是每个人手中的“工具”。</span><span leaf=""><br></span><span leaf="">MiniMind的爆火,印证了一个趋势:</span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">技术民主化的浪潮已不可阻挡。</span></strong><span leaf=""><br></span><span leaf="">无论你是学生、开发者,还是纯粹的好奇者——</span><span leaf=""><br></span><strong style="text-align: left;line-height: 1.75;color: rgb(15, 76, 129);font-weight: bold;"><span leaf="">现在,是时候亲手创造一个属于自己的AI了!</span></strong></p> <p style="outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;letter-spacing: 0.544px;text-wrap: wrap;background-color: rgb(255, 255, 255);margin-bottom: 0px;><span data-immersive-translate-walked="825e66ec-cda9-4610-ba28-966a579e7432" style="outline: 0px;color: rgb(53, 53, 53);font-family: Optima-Regular, Optima, PingFangSC-regular, PingFangTC-regular, " pingfang sc, cambria, cochin, georgia, times, times new roman, serif;font-size: 16px;letter-spacing: 0.8px;text-align: left;word-spacing: 0.8px;visibility: visible;><span leaf="">项目地址:</span></span></p> <p style="outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, " helvetica neue, pingfang sc, hiragino sans gb, microsoft yahei ui, yahei, arial, sans-serif;letter-spacing: 0.544px;text-wrap: wrap;background-color: rgb(255, 255, 255);margin-bottom: 0px;><strong style="outline: 0px;color: rgb(53, 53, 53);font-family: Optima-Regular, Optima, PingFangSC-regular, PingFangTC-regular, " pingfang sc, cambria, cochin, georgia, times, times new roman, serif;font-size: 16px;letter-spacing: 0.8px;text-align: left;word-spacing: 0.8px;><span leaf="">https://github.com/jingyaogong/minimind</span></strong></p>
作者:じ☆ve不哭
一、营销推广类 1. 广告文案生成 - 指令:为[产品]写一段30秒的广告文案,突出核心卖点和用户痛点。 - 示例:输入“为智能手表写一段广告文案”。 2. 促销活动策划 - 指令:设计一个[节日]促销活动,包含活动主题、优惠规则和推广渠道。 - 示例:输入“设计一个双十一促销活动”。 3. 品牌故事创作 - 指令:以[品牌]的背景写一篇品牌故事,突出品牌理念和用户共鸣。 - 示例:输入“为一个环保品牌写一篇品牌故事”。 4. 社交媒体海报文案 - 指令:为[活动]设计一张社交媒体海报,包含主标题、副标题和行动号召。 - 示例:输入“为新品发布会设计一张海报文案”。 5. 邮件营销文案 - 指令:写一封针对[目标用户]的营销邮件,包含吸引人的标题和行动号召。 - 示例:输入“写一封针对年轻妈妈的母婴产品营销邮件”。 二、内容创作类 6. 基础爆款标题生成 - 指令:生成6个吸引眼球的[主题]标题,要求包含数字、情绪词和悬念。 - 示例:输入“生成6个关于‘高效学习’的爆款标题”。 7. 情感共鸣标题 - 指令:生成10个[主题]标题,要求包含情感词和用户痛点。 - 示例:输入“生成10个关于‘职场压力’的爆款标题”。 8. 悬念式标题 - 指令:生成10个[主题]标题,要求包含悬念和好奇心引导。 - 示例:输入“生成10个关于‘减肥’的爆款标题”。 9. 数字清单标题 - 指令:生成10个[主题]标题,要求包含数字和实用价值。 - 示例:输入“生成10个关于‘理财’的爆款标题”。 10. 对比式标题 - 指令:生成10个[主题]标题,要求包含对比和反差。 - 示例:输入“生成10个关于‘护肤’的爆款标题”。 11. 问题引导标题 - 指令:生成10个[主题]标题,要求以问题形式引导用户点击。 - 示例:输入“生成10个关于‘学习效率’的爆款标题”。 12. 热点结合标题 - 指令:生成10个[主题]标题,要求结合当前热点话题。 - 示例:输入“生成10个关于‘健康饮食’的爆款标题,结合春节热点”。 13. 行动号召标题 - 指令:生成10个[主题]标题,要求包含行动号召和紧迫感。 - 示例:输入“生成10个关于‘早起’的爆款标题”。 14. 反转式标题 - 指令:生成10个[主题]标题,要求包含反转和意外。 - 示例:输入“生成10个关于‘恋爱技巧’的爆款标题”。 15. 场景化标题 - 指令:生成10个[主题]标题,要求结合具体场景。 - 示例:输入“生成10个关于‘旅行攻略’的爆款标题”。 16. 小红书基础种草文 - 指令:以[身份]的口吻,写一篇[产品]的种草笔记,突出5个使用场景和3个痛点解决方案。 - 示例:输入“以美妆博主的身份,写一篇关于‘素颜霜’的种草笔记”。 17. 小红书多产品对比种草 - 指令:以[身份]的口吻,对比[产品A]和[产品B],突出各自的优缺点和适用人群。 - 示例:输入“以护肤博主的身份,对比‘保湿面霜A’和‘保湿面霜B’”。 18. 小红书节日限定种草 - 指令:以[身份]的口吻,推荐[节日]相关的[产品],突出节日氛围和实用性。 - 示例:输入“以时尚博主的身份,推荐‘圣诞限定彩妆套装’”。 19. 平价替代种草 - 指令:以[身份]的口吻,推荐[平价产品]作为[高价产品]的替代,突出性价比。 - 示例:输入“以美妆博主的身份,推荐‘平价粉底液’作为‘高价粉底液’的替代”。 20. 使用教程种草 - 指令:以[身份]的口吻,写一篇[产品]的使用教程,包含步骤和注意事项。 - 示例:输入“以护肤博主的身份,写一篇‘面膜仪’的使用教程”。 21. 痛点解决种草 - 指令:以[身份]的口吻,推荐[产品],重点解决[用户痛点],并提供使用建议。 - 示例:输入“以健身博主的身份,推荐‘蛋白粉’,重点解决‘蛋白质摄入不足’的问题”。 22. 场景化种草 - 指令:以[身份]的口吻,推荐[产品],并描述3个适合的使用场景。 - 示例:输入“以旅行博主的身份,推荐‘便携烧水壶’,并描述3个适合的使用场景”。 23. 成分党种草 - 指令:以[身份]的口吻,从成分角度分析[产品],并推荐给适合的人群。 - 示例:输入“以成分党博主的身份,分析‘美白精华’的成分,并推荐给适合的人群”。 24. 情感共鸣种草 - 指令:以[身份]的口吻,推荐[产品],并通过情感共鸣打动用户。 - 示例:输入“以宝妈的身份,推荐‘婴儿湿巾’,并通过情感共鸣打动用户”。 25. 测评式种草 - 指令:以[身份]的口吻,对[产品]进行测评,包含优点、缺点和总结。 - 示例:输入“以数码博主的身份,对‘无线耳机’进行测评”。 26. 短视频脚本 - 指令:生成一个[时长]的短视频脚本,包含开场悬念+中间反转+结尾行动号召。 - 示例:输入“生成一个2分钟的短视频脚本,主题是如何快速学会摄影构图”。 27. 长文创作 - 指令:以[风格]写一篇关于[主题]的深度文章,包含5个分论点,每个论点配2个案例。 - 示例:输入“以科普风格写一篇关于‘区块链技术’的深度文章”。 28. SEO优化文章 - 指令:围绕关键词[XX]写一篇1200字文章,关键词密度5%,包含H2/H3标签。 - 示例:输入“围绕关键词‘健康饮食’写一篇SEO优化文章”。 29. 广告文案生成 - 指令:为[产品]写一段30秒的广告文案,突出核心卖点和用户痛点。 - 示例:输入“为智能音箱写一段广告文案”。 三、创意写作类 30. 故事开头生成 - 指令:以[主题]为背景,写一个吸引人的故事开头,包含悬念和冲突。 - 示例:输入“以科幻为主题写一个故事开头”。 31. 对话场景创作 - 指令:写一段[角色A]和[角色B]之间的对话,突出性格特点和情感冲突。 - 示例:输入“写一段情侣之间的争吵对话”。 32. 诗歌创作 - 指令:以[主题]为灵感,写一首现代诗,包含意象和情感表达。 - 示例:输入“以‘秋天’为主题写一首诗”。 33. 短篇小说大纲 - 指令:为[主题]创作一个短篇小说大纲,包含开头、发展和结局。 - 示例:输入“为‘时间旅行’创作一个短篇小说大纲”。 34. 角色设定 - 指令:设计一个[背景]下的角色,包含姓名、性格、目标和冲突。 - 示例:输入“设计一个未来世界的反派角色”。 四、商业策划类 35. 商业计划书 - 指令:为[项目]写一份商业计划书,包含市场分析、产品定位和盈利模式。 - 示例:输入“为一个在线教育平台写一份商业计划书”。 36. 产品定位分析 - 指令:为[产品]做一份市场定位分析,包含目标用户、竞争对手和差异化优势。 - 示例:输入“为智能家居产品做一份市场定位分析”。 37. 用户调研问卷 - 指令:设计一份针对[目标用户]的调研问卷,包含10个问题。 - 示例:输入“设计一份针对Z世代用户的消费习惯问卷”。 38. 竞品分析报告 - 指令:为[产品]做一份竞品分析报告,包含3个竞争对手的优劣势对比。 - 示例:输入“为新能源汽车做一份竞品分析报告”。 39. 品牌口号生成 - 指令:为[品牌]生成5个品牌口号,要求简洁有力、易于记忆。 - 示例:输入“为一个环保品牌生成5个口号”。 五、教育培训类 40. 课程大纲设计 - 指令:为[主题]设计一份课程大纲,包含10个章节和每个章节的核心内容。 - 示例:输入“为‘Python编程入门’设计一份课程大纲”。 41. 教学PPT制作 - 指令:为[主题]制作一份10页的教学PPT,包含图文并茂的内容。 - 示例:输入“为‘人工智能基础’制作一份教学PPT”。 42. 考试复习计划 - 指令:为[考试科目]设计一份30天复习计划,包含每日任务和目标。 - 示例:输入“为‘高考数学’设计一份复习计划”。 43. 学习笔记模板 - 指令:设计一份[主题]的学习笔记模板,包含重点、难点和案例分析。 - 示例:输入“设计一份‘经济学原理’的学习笔记模板”。 44. 培训活动策划 - 指令:为[主题]设计一场培训活动,包含活动流程、互动环节和评估方式。 - 示例:输入“为‘团队协作’设计一场培训活动”。 六、生活实用类 45. 旅行攻略 - 指令:为[目的地]写一份旅行攻略,包含交通、住宿、美食和景点推荐。 - 示例:输入“为‘日本东京’写一份旅行攻略”。 46. 健身计划 - 指令:为[目标]设计一份30天健身计划,包含每日训练内容和饮食建议。 - 示例:输入“为‘减脂’设计一份健身计划”。 47. 菜谱生成 - 指令:为[食材]生成3道菜谱,包含详细步骤和烹饪技巧。 - 示例:输入“为‘鸡胸肉’生成3道菜谱”。 48. 家居整理指南 - 指令:为[房间]设计一份整理指南,包含收纳技巧和空间优化建议。 - 示例:输入“为‘小户型客厅’设计一份整理指南”。 49. 时间管理计划 - 指令:为[目标]设计一份7天时间管理计划,包含每日任务和时间分配。 - 示例:输入“为‘提高工作效率’设计一份时间管理计划”。 七、娱乐休闲类 50. 电影推荐清单 - 指令:为[主题]生成10部电影推荐清单,包含简短推荐理由。 - 示例:输入“为‘科幻电影’生成10部推荐清单”。 51. 书籍推荐 - 指令:为[主题]生成5本书籍推荐,包含简短书评。 - 示例:输入“为‘个人成长’生成5本书籍推荐”。 52. 趣味测试生成 - 指令:设计一个[主题]的趣味测试,包含5个问题和结果分析。 - 示例:输入“设计一个‘你的性格色彩’趣味测试”。 DeepSeek 官网链接: https://www.deepseek.com/ 期待 DeepSeek 未来能够带给我们更多惊喜!
作者:微信小助手
<section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 10px;padding-right: 10px;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;font-family: Optima, 'Microsoft YaHei', PingFangSC-regular, serif;font-size: 16px;color: rgb(0, 0, 0);line-height: 1.5em;word-spacing: 0em;letter-spacing: 0em;word-break: break-word;overflow-wrap: break-word;text-align: left;"> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">群友一直希望我做一个dify的教程,我把去年的dify铲了,重新安装了一遍。 同时基于以前的文章提问,以及群友的问题,我先做一个知识科普,不感兴趣的可以绕过这块。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><a href="https://mp.weixin.qq.com/s?__biz=MjM5NzQxMTAyNw==&mid=2247485191&idx=1&sn=6590bae7fb960a2577c2b77c11479080&scene=21#wechat_redirect" textvalue="国产AI之光!DeepSeek本地部署教程,效果媲美GPT-4" data-itemshowtype="0" target="_blank" linktype="text" data-linktype="2">国产AI之光!DeepSeek本地部署教程,效果媲美GPT-4</a></span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><a href="https://mp.weixin.qq.com/s?__biz=MjM5NzQxMTAyNw==&mid=2247485243&idx=1&sn=c3fcfb5426f82a08903148d004d9cfac&scene=21#wechat_redirect" textvalue="服务器繁忙,电脑配置太低,别急deepseek满血版来了" data-itemshowtype="0" target="_blank" linktype="text" data-linktype="2">服务器繁忙,电脑配置太低,别急deepseek满血版来了</a></span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><a href="https://mp.weixin.qq.com/s?__biz=MjM5NzQxMTAyNw==&mid=2247485376&idx=1&sn=054d7f3521683c3c876ffa8d44096099&scene=21#wechat_redirect" textvalue="DeepSeek+本地知识库:真的太香了(修订版)" data-itemshowtype="0" target="_blank" linktype="text" data-linktype="2">DeepSeek+本地知识库:真的太香了(修订版)</a></span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><a href="https://mp.weixin.qq.com/s?__biz=MjM5NzQxMTAyNw==&mid=2247485287&idx=1&sn=b54291f281cd1fadee229259050d8eab&scene=21#wechat_redirect" textvalue="DeepSeek+本地知识库:真实太香了(企业方案)" data-itemshowtype="0" target="_blank" linktype="text" data-linktype="2">DeepSeek+本地知识库:真</a>是<a href="https://mp.weixin.qq.com/s?__biz=MjM5NzQxMTAyNw==&mid=2247485287&idx=1&sn=b54291f281cd1fadee229259050d8eab&scene=21#wechat_redirect" textvalue="DeepSeek+本地知识库:真实太香了(企业方案)" data-itemshowtype="0" target="_blank" linktype="text" data-linktype="2">太香了(企业方案)</a></span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><a href="https://mp.weixin.qq.com/s?__biz=MjM5NzQxMTAyNw==&mid=2247485351&idx=1&sn=120316a6d46da670af85a14691be9f15&scene=21#wechat_redirect" textvalue="本地DeepSeek下载慢,中断、内网无法安装方案来了" data-itemshowtype="0" target="_blank" linktype="text" data-linktype="2">本地DeepSeek下载慢,中断、内网无法安装方案来了</a></span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><a href="https://mp.weixin.qq.com/s?__biz=MjM5NzQxMTAyNw==&mid=2247485347&idx=1&sn=d6722f5898584d17d8dd1e5afad73c9b&scene=21#wechat_redirect" textvalue="最轻量级的deepseek应用,支持联网或知识库" data-itemshowtype="0" target="_blank" linktype="text" data-linktype="2">最轻量级的deepseek应用,支持联网或知识库</a></span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><a href="https://mp.weixin.qq.com/s?__biz=MjM5NzQxMTAyNw==&mid=2247485305&idx=1&sn=bfa7485fcd8bb26dbe6776a2398db6b4&scene=21#wechat_redirect" textvalue="deepseek一键生成小红书爆款内容,排版下载全自动!睡后收入不是梦" data-itemshowtype="0" target="_blank" linktype="text" data-linktype="2">deepseek一键生成小红书爆款内容,排版下载全自动!睡后收入不是梦</a></span></p> <h2 data-tool="mdnice编辑器" style="border-bottom-color: rgb(239, 112, 96);margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: solid;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 2px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.1em;overflow-x: unset;overflow-y: unset;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 22px;color: rgb(255, 255, 255);background-color: rgb(239, 112, 96);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 3px;border-top-right-radius: 3px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 5px;overflow-x: unset;overflow-y: unset;padding-top: 3px;padding-bottom: 1px;padding-left: 10px;padding-right: 10px;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">知识科普</span></span><span style="display: none;"></span><span style="border-bottom-color: rgb(239, 235, 233);align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: solid;border-left-style: none;border-right-style: solid;border-top-width: 1px;border-bottom-width: 36px;border-left-width: 1px;border-right-width: 20px;border-top-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: transparent;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;color: rgb(0, 0, 0);display: inline-block;font-size: 16px;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;letter-spacing: 0px;line-height: 1.1em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf=""> </span></span></h2> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">关于模型</span></span><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">大语言模型(LLM)是通过深度学习技术,基于海量</span><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">历史</span></strong><span leaf="">文本数据训练出的概率生成系统。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><br></span><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">能力边界</span></strong></p> <ul style="list-style-type: disc;margin-top: 8px;margin-bottom: 8px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 25px;padding-right: 0px;color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">知识时效性</span></strong><span leaf="">:模型知识截止于训练数据时间点</span> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">推理局限性</span></strong><span leaf="">:本质是概率预测而非逻辑运算,复杂数学推理易出错(deepseek的架构有所不同)</span> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">专业领域盲区</span></strong><span leaf="">:缺乏垂直领域知识</span> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">幻觉现象</span></strong><span leaf="">:可能生成看似合理但实际错误的内容</span> </section></li> </ul> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">更新机制</span></strong></p> <ul style="list-style-type: disc;margin-top: 8px;margin-bottom: 8px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 25px;padding-right: 0px;color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">全量重训练</span></strong><span leaf="">:需重新处理TB级数据,消耗数千GPU小时(这个我们直接排除)</span> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <span leaf=""><span textstyle="" style="font-weight: bold;">微调(Fine-tuning)</span>:用领域数据调整模型参数,成本仍较高(这个也需要一定的成本)</span> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">上下文学习</span></strong><span leaf="">:通过提示词临时注入知识,但受限于上下文长度(这个我们通过外挂知识库实现)</span> </section></li> </ul> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">综上,我们能做的更新机制就是给它通过提示词上下文临时注入知识。</span></p> <h4 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">关于知识库</span></span><span style="display: none;"></span></h4> <section data-tool="mdnice编辑器" style="margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;overflow-x: auto;"> <table style="display: table;text-align: left;"> <thead> <tr> <th style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);height: auto;border-style: solid;border-width: 1px;border-color: rgba(204, 204, 204, 0.4);border-radius: 0px;padding: 5px 10px;min-width: 85px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">维度</span></strong></th> <th style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);height: auto;border-style: solid;border-width: 1px;border-color: rgba(204, 204, 204, 0.4);border-radius: 0px;padding: 5px 10px;min-width: 85px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">广义知识库</span></strong></th> <th style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);height: auto;border-style: solid;border-width: 1px;border-color: rgba(204, 204, 204, 0.4);border-radius: 0px;padding: 5px 10px;min-width: 85px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">模型知识库</span></strong></th> </tr> </thead> <tbody> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgba(204, 204, 204, 0.4);border-bottom-color: rgba(204, 204, 204, 0.4);border-left-color: rgba(204, 204, 204, 0.4);border-right-color: rgba(204, 204, 204, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">数据来源</span></strong></td> <td style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgba(204, 204, 204, 0.4);border-bottom-color: rgba(204, 204, 204, 0.4);border-left-color: rgba(204, 204, 204, 0.4);border-right-color: rgba(204, 204, 204, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">外部结构化/非结构化数据(文档、数据库等)</span> </section></td> <td style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgba(204, 204, 204, 0.4);border-bottom-color: rgba(204, 204, 204, 0.4);border-left-color: rgba(204, 204, 204, 0.4);border-right-color: rgba(204, 204, 204, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">预训练模型内嵌的知识(如GPT的训练数据)</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(248, 248, 248);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgba(204, 204, 204, 0.4);border-bottom-color: rgba(204, 204, 204, 0.4);border-left-color: rgba(204, 204, 204, 0.4);border-right-color: rgba(204, 204, 204, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">更新方式</span></strong></td> <td style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgba(204, 204, 204, 0.4);border-bottom-color: rgba(204, 204, 204, 0.4);border-left-color: rgba(204, 204, 204, 0.4);border-right-color: rgba(204, 204, 204, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">手动或API动态更新(如企业知识库)</span> </section></td> <td style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgba(204, 204, 204, 0.4);border-bottom-color: rgba(204, 204, 204, 0.4);border-left-color: rgba(204, 204, 204, 0.4);border-right-color: rgba(204, 204, 204, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">依赖模型重训练或微调</span> </section></td> </tr> <tr style="color: rgb(0, 0, 0);background-attachment: scroll;background-clip: border-box;background-color: rgb(255, 255, 255);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;"> <td style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgba(204, 204, 204, 0.4);border-bottom-color: rgba(204, 204, 204, 0.4);border-left-color: rgba(204, 204, 204, 0.4);border-right-color: rgba(204, 204, 204, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">知识范围</span></strong></td> <td style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgba(204, 204, 204, 0.4);border-bottom-color: rgba(204, 204, 204, 0.4);border-left-color: rgba(204, 204, 204, 0.4);border-right-color: rgba(204, 204, 204, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">垂直领域或特定业务场景(如产品手册)</span> </section></td> <td style="padding-top: 5px;padding-right: 10px;padding-bottom: 5px;padding-left: 10px;min-width: 85px;border-top-style: solid;border-bottom-style: solid;border-left-style: solid;border-right-style: solid;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgba(204, 204, 204, 0.4);border-bottom-color: rgba(204, 204, 204, 0.4);border-left-color: rgba(204, 204, 204, 0.4);border-right-color: rgba(204, 204, 204, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"> <section> <span leaf="">通用知识(训练数据截止时间前的信息)</span> </section></td> </tr> </tbody> </table> </section> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">我们之前说的知识库都是广义知识库。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">在</span><code style="color: rgb(239, 112, 96);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);overflow-wrap: break-word;padding-top: 2px;padding-right: 4px;padding-bottom: 2px;padding-left: 4px;border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;margin-top: 0px;margin-right: 2px;margin-bottom: 0px;margin-left: 2px;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">关于模型</span></code><span leaf="">哪里我们说了,我们可以通过提示词临时注入知识,给大模型,但是大模型的上下文是有长度限制的,我们通过各种技术把最合适的内容挑选出来,然后给大模型。</span></p> <h4 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">关于嵌入模型</span></span><span style="display: none;"></span></h4> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">嵌入模型</span></strong><span leaf="">是一种将高维离散数据(文本、图像等)转换为低维连续向量的技术,这种转换让机器能更好地理解和处理复杂数据。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">举一个例子来理解向量,你正在玩一个叫做"猜词"的游戏。你的目标是描述一个词,而你的朋友们要根据你的描述猜出这个词。你不能直接说出这个词,而是要用其他相关的词来描述它。例如,你可以用"热"、"喝"、"早餐"来描述"咖啡"。嵌入模型就是将一个词转化为其他相关词的专用模型。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">"热"、"喝"、"早餐" 可以理解为向量。不过向量值是在向量空间的特定位置,在这个空间里语义相近的词会自动聚集起来。所以就有了相似度的概念,相似度越高,越匹配。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">我们使用的bge-m3 只能向量化出1024维。</span></p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;text-align: left;margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;"><span data-cacheurl="" data-remoteid="" style="display: block;background: none;height: 30px;width: 100%;background-size: 40px;background-repeat: no-repeat;background-color: #282c34;margin-bottom: -7px;border-radius: 5px;background-position: 10px 10px;background-image: url(" https: mmbiz.qpic.cn mmbiz_svg k0ue4mipavick8hqialiakg2y4ciqoodnaactclbibcgyad7vzlwed4e4twjoq8arkiuadcxiazmb9qb1lw9mihicah73fq7cubgibp 640?wx_fmt="svg&from=appmsg");""></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;"><span leaf=""> ollama show bge-m3:latest</span><span leaf=""><br></span><span leaf=""> architecture bert</span><span leaf=""><br></span><span leaf=""> parameters 566.70M</span><span leaf=""><br></span><span leaf=""> context length 8192</span><span leaf=""><br></span><span leaf=""> embedding length 1024</span><span leaf=""><br></span><span leaf=""> quantization F16</span><span leaf=""><br></span></code></pre> <h4 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">为什么没有匹配到知识</span></span><span style="display: none;"></span></h4> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001819" data-ratio="0.3654661016949153" src="/upload/f5f5263324c269a2947e664f78639dd8.png" data-type="png" data-w="944" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;"></span><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">知识预处理</span></strong></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf=""><br></span></strong><span leaf="">1, 上传文档</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">2,将文档分割成适当大小的文本块</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">3,使用embedding模型将每个文本段转换为向量</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">4,将向量和原文存储到向量数据库中</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">查询处理阶段</span></strong></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">1,将用户输入问题转换为向量</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">2, 在向量库中检索相似内容</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">3, 将检索到的相关内容作为上下文提供给LLM</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">我们用的本地应用工具,<span textstyle="" style="font-weight: bold;">一般都是粗粒度分段,向量化的质量没法保证</span>。</span></p> <h4 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">本地知识库安全吗?</span></span><span style="display: none;"></span></h4> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">根据上一步,我们可以知道本地知识库+本地大模型是安全的。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">本地知识库+远端api的大模型,会把片段上传。</span></p> <h2 data-tool="mdnice编辑器" style="border-bottom-color: rgb(239, 112, 96);margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: solid;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 2px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.1em;overflow-x: unset;overflow-y: unset;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 22px;color: rgb(255, 255, 255);background-color: rgb(239, 112, 96);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 3px;border-top-right-radius: 3px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 5px;overflow-x: unset;overflow-y: unset;padding-top: 3px;padding-bottom: 1px;padding-left: 10px;padding-right: 10px;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">dify安装</span></span><span style="display: none;"></span><span style="border-bottom-color: rgb(239, 235, 233);align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: solid;border-left-style: none;border-right-style: solid;border-top-width: 1px;border-bottom-width: 36px;border-left-width: 1px;border-right-width: 20px;border-top-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: transparent;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;color: rgb(0, 0, 0);display: inline-block;font-size: 16px;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;letter-spacing: 0px;line-height: 1.1em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf=""> </span></span></h2> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">前提条件</span></span><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">假设你已经安装了docker,docker安装不同的架构安装方式不一样,这里就不做教程了。 已经登录了docker</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">安装完docker以后,记得调整docker镜像的存储地址。</span></p> <ul style="list-style-type: disc;margin-top: 8px;margin-bottom: 8px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 25px;padding-right: 0px;color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <span leaf="">已经安装了docker,并且登录了</span> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <span leaf="">已经安装了git win上docker安装地址: https://docs.docker.com/desktop/setup/install/windows-install/#wsl-2-backend</span> </section></li> </ul> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">安装</span></span><span style="display: none;"></span></h3> <h4 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">下载dify</span></span><span style="display: none;"></span></h4> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">通过官网下载,如果你没有魔法,可以从网盘里那对应的</span></p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;text-align: left;margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;"><span data-cacheurl="" data-remoteid="" style="display: block;background: none;height: 30px;width: 100%;background-size: 40px;background-repeat: no-repeat;background-color: #282c34;margin-bottom: -7px;border-radius: 5px;background-position: 10px 10px;background-image: url(" https: mmbiz.qpic.cn mmbiz_svg k0ue4mipavick8hqialiakg2y4ciqoodnaactclbibcgyad7vzlwed4e4twjoq8arkiuadcxiazmb9qb1lw9mihicah73fq7cubgibp 640?wx_fmt="svg&from=appmsg");""></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;"><span style="color: #61aeee;line-height: 26px;"><span leaf="">#</span></span><span style="line-height: 26px;"><span leaf=""> 进入要下载的目录,打卡命令提示行工具,cmd或者powershell</span></span><span leaf=""><br></span><span leaf="">cd E:\ai\code</span><span leaf=""><br></span><span style="color: #61aeee;line-height: 26px;"><span leaf="">#</span></span><span style="line-height: 26px;"><span leaf="">下载</span></span><span leaf=""><br></span><span leaf="">git clone https://github.com/langgenius/dify.git</span><span leaf=""><br></span><span style="color: #61aeee;line-height: 26px;"><span leaf="">#</span></span><span style="line-height: 26px;"><span leaf=""> 国内镜像站</span></span><span leaf=""><br></span><span leaf="">https://gitee.com/dify_ai/dify</span><span leaf=""><br></span><span leaf=""> </span><span leaf=""><br></span></code></pre> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">如果没有git环境,可以直接从网盘下载压缩包。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">我们下载以后,只关注docker文件夹和README_CN.md即可。</span></p> <h4 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">清理(非必须)</span></span><span style="display: none;"></span></h4> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">由于我的dify安装的比较早,是0.7.x版本,为了给大家演示,就把原来的铲了。如果你以前安装过dify,使用以下命令清理历史镜像</span></p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;text-align: left;margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;"><span data-cacheurl="" data-remoteid="" style="display: block;background: none;height: 30px;width: 100%;background-size: 40px;background-repeat: no-repeat;background-color: #282c34;margin-bottom: -7px;border-radius: 5px;background-position: 10px 10px;background-image: url(" https: mmbiz.qpic.cn mmbiz_svg k0ue4mipavick8hqialiakg2y4ciqoodnaactclbibcgyad7vzlwed4e4twjoq8arkiuadcxiazmb9qb1lw9mihicah73fq7cubgibp 640?wx_fmt="svg&from=appmsg");""></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;"><span leaf="">cd docker 进入目录</span><span leaf=""><br></span><span style="color: #61aeee;line-height: 26px;"><span leaf="">#</span></span><span style="line-height: 26px;"><span leaf=""> 清理历史镜像</span></span><span leaf=""><br></span><span leaf="">docker-compose down -v --rmi all</span><span leaf=""><br></span></code></pre> <h4 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">创建配置</span></span><span style="display: none;"></span></h4> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">我们进入dify目录下的docker目录中,比如我的 E:\ai\code\dify\docker</span></p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;text-align: left;margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;"><span data-cacheurl="" data-remoteid="" style="display: block;background: none;height: 30px;width: 100%;background-size: 40px;background-repeat: no-repeat;background-color: #282c34;margin-bottom: -7px;border-radius: 5px;background-position: 10px 10px;background-image: url(" https: mmbiz.qpic.cn mmbiz_svg k0ue4mipavick8hqialiakg2y4ciqoodnaactclbibcgyad7vzlwed4e4twjoq8arkiuadcxiazmb9qb1lw9mihicah73fq7cubgibp 640?wx_fmt="svg&from=appmsg");""></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;"><span style="color: #61aeee;line-height: 26px;"><span leaf="">#</span></span><span style="line-height: 26px;"><span leaf=""> 以示例创建一个.env的文件,执行下面命令</span></span><span leaf=""><br></span><span leaf="">cp .\.env.example .env</span><span leaf=""><br></span></code></pre> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">修改dify绑定ip</span></strong></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">API 服务绑定地址,默认:0.0.0.0,即所有地址均可访问。 刚开始我以为是控制dify对外暴露的服务的,改成了127.0.0.1,然后出现以下的502,折腾了我快3个小时。<img class="rich_pages wxw-img" data-imgfileid="100001821" data-ratio="0.9715698393077874" src="/upload/1a21dd9e91d242802bf50a74f8c6ce20.png" data-type="png" data-w="809" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;"></span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">修改端口(非必须)</span></strong></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">默认占用的是80和443端口,如果你本机已经部署了其他的应用,占了该端口,修改.env文件中的下面两个变量</span></p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;text-align: left;margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;"><span data-cacheurl="" data-remoteid="" style="display: block;background: none;height: 30px;width: 100%;background-size: 40px;background-repeat: no-repeat;background-color: #282c34;margin-bottom: -7px;border-radius: 5px;background-position: 10px 10px;background-image: url(" https: mmbiz.qpic.cn mmbiz_svg k0ue4mipavick8hqialiakg2y4ciqoodnaactclbibcgyad7vzlwed4e4twjoq8arkiuadcxiazmb9qb1lw9mihicah73fq7cubgibp 640?wx_fmt="svg&from=appmsg");""></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;"><span leaf="">EXPOSE_NGINX_PORT=8001</span><span leaf=""><br></span><span leaf="">EXPOSE_NGINX_SSL_PORT=8443</span><span leaf=""><br></span></code></pre> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">上传文件大小</span></strong></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">默认上传图片大小是10MB,上传视频大小是100MB,文件默认是50MB,如果有需要修改下面对应的参数</span></p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;text-align: left;margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;"><span data-cacheurl="" data-remoteid="" style="display: block;background: none;height: 30px;width: 100%;background-size: 40px;background-repeat: no-repeat;background-color: #282c34;margin-bottom: -7px;border-radius: 5px;background-position: 10px 10px;background-image: url(" https: mmbiz.qpic.cn mmbiz_svg k0ue4mipavick8hqialiakg2y4ciqoodnaactclbibcgyad7vzlwed4e4twjoq8arkiuadcxiazmb9qb1lw9mihicah73fq7cubgibp 640?wx_fmt="svg&from=appmsg");""></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;"><span style="color: #5c6370;font-style: italic;line-height: 26px;"><span leaf=""># Upload image file size limit, default 10M.</span></span><span leaf=""><br></span><span leaf="">UPLOAD_IMAGE_FILE_SIZE_LIMIT=10</span><span leaf=""><br></span><span style="color: #5c6370;font-style: italic;line-height: 26px;"><span leaf=""># Upload video file size limit, default 100M.</span></span><span leaf=""><br></span><span leaf="">UPLOAD_VIDEO_FILE_SIZE_LIMIT=100</span><span leaf=""><br></span><span style="color: #5c6370;font-style: italic;line-height: 26px;"><span leaf=""># Upload audio file size limit, default 50M.</span></span><span leaf=""><br></span><span leaf="">UPLOAD_AUDIO_FILE_SIZE_LIMIT=50</span><span leaf=""><br></span></code></pre> <h4 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">启动dify</span></span><span style="display: none;"></span></h4> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;text-align: left;margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;"><span data-cacheurl="" data-remoteid="" style="display: block;background: none;height: 30px;width: 100%;background-size: 40px;background-repeat: no-repeat;background-color: #282c34;margin-bottom: -7px;border-radius: 5px;background-position: 10px 10px;background-image: url(" https: mmbiz.qpic.cn mmbiz_svg k0ue4mipavick8hqialiakg2y4ciqoodnaactclbibcgyad7vzlwed4e4twjoq8arkiuadcxiazmb9qb1lw9mihicah73fq7cubgibp 640?wx_fmt="svg&from=appmsg");""></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;"><span leaf="">docker compose up -d</span><span leaf=""><br></span></code></pre> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">启动以后在docker Desktop中查看,<img class="rich_pages wxw-img" data-imgfileid="100001822" data-ratio="0.7972222222222223" src="/upload/98c1c2f5b7b32a3cf29a7635eb0b220d.png" data-type="png" data-w="1080" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;"><img src="/upload/7eeef0cebd029de9f9019c20636b620e.png" class="rich_pages wxw-img" data-ratio="0.1537037037037037" data-type="png" data-w="1080" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;" data-imgfileid="100001818"></span></p> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">设置管理员与登录</span></span><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">http://127.0.0.1:8001/install</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">填写相关信息,设置管理员账户。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001820" data-ratio="0.9362880886426593" src="/upload/219ec1e665ff7f48dcb2225f7d7b5291.png" data-type="png" data-w="722" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;">设置成功以后,登录</span></p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001823" data-ratio="0.7442307692307693" src="/upload/cd6bdef36fb090c22e244f974fc0e86b.png" data-type="png" data-w="520" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"></span> </figure> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">设置模型</span></span><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001825" data-ratio="0.7923387096774194" src="/upload/329a60e743126d8078663c0b38c8bcb8.png" data-type="png" data-w="496" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;">1,点击右上角的账户 2,点击设置</span></p> <h4 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">本地模型设置</span></span><span style="display: none;"></span></h4> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001827" data-ratio="0.6404382470119522" src="/upload/20e6b36e134ce1c8079e44fc6fab3ada.png" data-type="png" data-w="1004" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;">1, 点击模型供应商 2,下拉找到ollama 3,点击添加模型</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">添加对话模型</span></strong><span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001826" data-ratio="1.3143322475570032" src="/upload/0cba4ac03db78e8106820b6670fb7dd8.png" data-type="png" data-w="614" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;">按照步骤添加模型即可,注意模型上下文长度,可以通过</span><code style="color: rgb(239, 112, 96);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);overflow-wrap: break-word;padding-top: 2px;padding-right: 4px;padding-bottom: 2px;padding-left: 4px;border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;margin-top: 0px;margin-right: 2px;margin-bottom: 0px;margin-left: 2px;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">ollama show 模型名称</span></code><span leaf="">查看,如果你经常用大文本,就直接调到最大值。需要注意的是dify,上传文件是有大小限制的。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">关于ip</span></strong><span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001824" data-ratio="0.23404255319148937" src="/upload/fad92b08ca47d3694aa469a1d79e53ab.png" data-type="png" data-w="564" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;">我使用的是本地docker虚拟网络,如果你ollama设置了</span><code style="color: rgb(239, 112, 96);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);overflow-wrap: break-word;padding-top: 2px;padding-right: 4px;padding-bottom: 2px;padding-left: 4px;border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;margin-top: 0px;margin-right: 2px;margin-bottom: 0px;margin-left: 2px;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">OLLAMA_HOST为0.0.0.0</span></code><span leaf=""> </span><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">需要注意网络安全</span></strong><span leaf="">,防止外网有人能访问。我是将我的ollama绑定到了局域网ip上了。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">添加向量模型</span></strong></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001829" data-ratio="0.921875" src="/upload/0c50f7769f7050c3811827b82b0ee950.png" data-type="png" data-w="640" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;">1,注意选择text embedding</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">系统模型设置</span></strong></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001832" data-ratio="0.6838235294117647" src="/upload/8508e948d74df53c1ddf812d74545727.png" data-type="png" data-w="680" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;">1,点击系统模型设置</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">2,选择已经配置的模型,当然建立知识库的时候,也可以切换</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">3,选择向量模型</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">4,保存</span></p> <h4 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">在线api模型配置</span></span><span style="display: none;"></span></h4> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">腾讯模型配置(免费到2月25日)</span></strong></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001828" data-ratio="0.5582417582417583" src="/upload/88af332db3c1f5ca00470e451b63ff52.png" data-type="png" data-w="455" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;">没找到对应的模型供应商,直接选择openai兼容的模型供应商。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><img src="/upload/89ba93ddeccceeb322cc3d3a8588cb8c.png" class="rich_pages wxw-img" data-ratio="1.2309985096870342" data-type="png" data-w="671" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;" data-imgfileid="100001831">按步骤填写即可。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">2,模型名称选择deepseek-r1</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">3,api key 填写自己的即可</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">4,填写地址:https://api.lkeap.cloud.tencent.com/v1</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">硅基流动添加</span></strong></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001830" data-ratio="0.38310893512851896" src="/upload/042a0f5a2cf432cb8c3a5e492b537c77.png" data-type="png" data-w="817" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;">找到模型供应商,点击设置,配置下密钥就可以了。<img src="/upload/c504a9eb7a6e7342861c16a4a29d7d28.png" class="rich_pages wxw-img" data-ratio="0.48200312989045385" data-type="png" data-w="639" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;" data-imgfileid="100001833"></span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">模型供应商</span></strong></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">配置好以后,我们可以在模型列表那里看到所有的模型<img class="rich_pages wxw-img" data-imgfileid="100001835" data-ratio="0.8158236057068742" src="/upload/4ffcc02e050dd8760a08fcd54aba70d3.png" data-type="png" data-w="771" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;"></span></p> <h4 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">最终系统模型设置</span></span><span style="display: none;"></span></h4> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001834" data-ratio="0.8233333333333334" src="/upload/e6232fb9c35c207bde244f8216db2151.png" data-type="png" data-w="600" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"></span> </figure> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">知识库设置</span></span><span style="display: none;"></span></h3> <h4 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">创建知识库</span></span><span style="display: none;"></span></h4> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001837" data-ratio="0.412962962962963" src="/upload/9feee446a6f4e9cc1fca8d75f8fc81a5.png" data-type="png" data-w="1080" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"></span> </figure> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img src="/upload/7deca8ebfc69acc0f77f0a207e656238.png" class="rich_pages wxw-img" data-ratio="0.562037037037037" data-type="png" data-w="1080" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;" data-imgfileid="100001836"></span> </figure> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img src="/upload/9c58a1ef72334c94665e1406baa0efb5.png" class="rich_pages wxw-img" data-ratio="0.648936170212766" data-type="png" data-w="752" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;" data-imgfileid="100001838"></span> </figure> <h4 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">分段</span></span><span style="display: none;"></span></h4> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">dify的分段有个好处,设置分段以后,可以实时预览,可以根据预览效果,自己实时调整分段策略。</span><code style="color: rgb(239, 112, 96);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);overflow-wrap: break-word;padding-top: 2px;padding-right: 4px;padding-bottom: 2px;padding-left: 4px;border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;margin-top: 0px;margin-right: 2px;margin-bottom: 0px;margin-left: 2px;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">dify建议首次创建知识库使用父子分段模式。</span></code></p> <h4 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">通用分段(原自动分段与清洗)</span></span><span style="display: none;"></span></h4> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">关键点:</span></strong></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">1,默认</span><code style="color: rgb(239, 112, 96);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);overflow-wrap: break-word;padding-top: 2px;padding-right: 4px;padding-bottom: 2px;padding-left: 4px;border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;margin-top: 0px;margin-right: 2px;margin-bottom: 0px;margin-left: 2px;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">\n</span></code><span leaf="">作为分段标识</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">2,最大分段长度为4000tokens,默认为500tokens</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">3,分段重叠长度,默认为50tokens,用于分段时,段与段之间存在一定的重叠部分。建议设置为分段长度 Tokens 数的 10-25%;</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">4,文本预处理规则:用于移除冗余符号、URL等噪声</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">5,这里还有一个点,向量模型会自动按段落或语义进行切分,也就是大家分段以后内容缺失的根因。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><code style="color: rgb(239, 112, 96);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);overflow-wrap: break-word;padding-top: 2px;padding-right: 4px;padding-bottom: 2px;padding-left: 4px;border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;margin-top: 0px;margin-right: 2px;margin-bottom: 0px;margin-left: 2px;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">适用于内容简单、结构清晰的文档(如FAQ列表)</span></code></p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001842" data-ratio="0.4351851851851852" src="/upload/590f73b5f6003dd1970254d9c317e4fa.png" data-type="png" data-w="1080" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"></span> </figure> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img src="/upload/23720c48cb85744c0136674470c856c9.png" class="rich_pages wxw-img" data-ratio="0.5537037037037037" data-type="png" data-w="1080" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;" data-imgfileid="100001839"></span> </figure> <h4 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">父子分段</span></span><span style="display: none;"></span></h4> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">父子模式采用双层分段结构来平衡检索的精确度和上下文信息,让精准匹配与全面的上下文信息二者兼得。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">关键点</span></strong></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">1,父区块(Parent-chunk)保持较大的文本单位(如段落),上下文内容丰富且连贯。默认以</span><code style="color: rgb(239, 112, 96);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);overflow-wrap: break-word;padding-top: 2px;padding-right: 4px;padding-bottom: 2px;padding-left: 4px;border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;margin-top: 0px;margin-right: 2px;margin-bottom: 0px;margin-left: 2px;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">\n\n</span></code><span leaf="">为分段标识,如果知识不长,可以以整个作为父区块(超过1万个分段就直接被截断了)。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">2,子区块(Child-chunk)以较小的文本单位(如句子),用于精确检索。默认以</span><code style="color: rgb(239, 112, 96);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);overflow-wrap: break-word;padding-top: 2px;padding-right: 4px;padding-bottom: 2px;padding-left: 4px;border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;margin-top: 0px;margin-right: 2px;margin-bottom: 0px;margin-left: 2px;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">\n</span></code><span leaf="">为分段标识。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">3,也可以选择噪音清理</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">4,在搜索时通过子区块精确检索后,获取父区块来补充上下文信息,从而给LLM的上下文内容更丰富</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">以句子为最小单位,向量化以后向量匹配的准确度会极大的提升。</span></strong></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">官方示意图如下:</span></p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001840" data-ratio="0.7648148148148148" src="/upload/9dc5f793ddfc256be37931aede3384d2.png" data-type="png" data-w="1080" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"></span> </figure> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><img src="/upload/958b18aed3e972282732149b871b1e90.png" class="rich_pages wxw-img" data-ratio="0.5287037037037037" data-type="png" data-w="1080" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;" data-imgfileid="100001841">1,我们可以不断的调整参数,预览下,看下实际效果,</span></p> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">索引模式</span></span><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">索引模式有两种。分别是高质量索引和经济索引</span></p> <h4 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">高质量索引</span></span><span style="display: none;"></span></h4> <ul style="list-style-type: disc;margin-top: 8px;margin-bottom: 8px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 25px;padding-right: 0px;color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <p style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">适用场景</span></strong><span leaf="">:需要高精度语义检索(如复杂问答、多语言支持)。</span></p> </section></li> <ul style="list-style-type: disc;margin-top: 8px;margin-bottom: 8px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 25px;padding-right: 0px;color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">实现方式</span></strong><span leaf="">:依赖嵌入模型生成向量索引,结合 ReRank 模型优化排序。</span> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">适用文档:</span></strong><span leaf="">格式化文档,如表格、技术手册</span> </section></li> </ul> </ul> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">我们看下官方推荐的配置<img class="rich_pages wxw-img" data-imgfileid="100001847" data-ratio="1.0191326530612246" src="/upload/e636283375aa229a42c6ee53fa2a478e.png" data-type="png" data-w="784" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;">1,选择高质量</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">3,选择向量模型</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">4,选择系统推荐的混合检索</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">5,选择Rerank模型,并选择对应的rerank模型</span></p> <h4 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">经济索引</span></span><span style="display: none;"></span></h4> <ul style="list-style-type: disc;margin-top: 8px;margin-bottom: 8px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 25px;padding-right: 0px;color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <p style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">适用场景</span></strong><span leaf="">:预算有限或内容简单(如关键词匹配为主的FAQ)。</span></p> </section></li> <ul style="list-style-type: disc;margin-top: 8px;margin-bottom: 8px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 25px;padding-right: 0px;color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">实现方式</span></strong><span leaf="">:使用离线向量引擎或关键词索引,无需消耗额外 Token,但语义理解能力较弱。</span> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">优化建议</span></strong><span leaf="">:可通过调整 </span><code style="color: rgb(239, 112, 96);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);overflow-wrap: break-word;padding-top: 2px;padding-right: 4px;padding-bottom: 2px;padding-left: 4px;border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;margin-top: 0px;margin-right: 2px;margin-bottom: 0px;margin-left: 2px;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">TopK</span></code><span leaf="">(返回相似片段数量)和 </span><code style="color: rgb(239, 112, 96);font-size: 14px;line-height: 1.8em;letter-spacing: 0em;background-attachment: scroll;background-clip: border-box;background-color: transparent;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);overflow-wrap: break-word;padding-top: 2px;padding-right: 4px;padding-bottom: 2px;padding-left: 4px;border-top-left-radius: 4px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;border-bottom-left-radius: 4px;margin-top: 0px;margin-right: 2px;margin-bottom: 0px;margin-left: 2px;font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace;word-break: break-all;"><span leaf="">Score 阈值</span></code><span leaf="">(相似度过滤)平衡召回率与准确率。</span> </section></li> <li> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;font-weight: normal;"> <strong style="color: rgb(0, 0, 0);font-weight: bold;background-attachment: scroll;background-clip: border-box;background-color: rgba(0, 0, 0, 0);background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;width: auto;height: auto;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;"><span leaf="">适用文档:</span></strong><span leaf="">非结构化文本**,如会议记录</span> </section></li> </ul> </ul> <h2 data-tool="mdnice编辑器" style="border-bottom-color: rgb(239, 112, 96);margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: solid;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 2px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.1em;overflow-x: unset;overflow-y: unset;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 22px;color: rgb(255, 255, 255);background-color: rgb(239, 112, 96);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 3px;border-top-right-radius: 3px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 5px;overflow-x: unset;overflow-y: unset;padding-top: 3px;padding-bottom: 1px;padding-left: 10px;padding-right: 10px;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">使用</span></span><span style="display: none;"></span><span style="border-bottom-color: rgb(239, 235, 233);align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: solid;border-left-style: none;border-right-style: solid;border-top-width: 1px;border-bottom-width: 36px;border-left-width: 1px;border-right-width: 20px;border-top-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: transparent;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;color: rgb(0, 0, 0);display: inline-block;font-size: 16px;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;letter-spacing: 0px;line-height: 1.1em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf=""> </span></span></h2> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">创建应用</span></span><span style="display: none;"></span></h3> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001844" data-ratio="0.41393034825870645" src="/upload/a56ade78ece00a0570982ddebfac4bf7.png" data-type="png" data-w="1005" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"></span> </figure> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">点击工作室,我们可以看到有很多丰富的应用,包括聊天助手、agent、工作流等 我们选择最简单的应用,聊天助手,点击5,创建空白应用</span></p> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001845" data-ratio="0.9456953642384106" src="/upload/aa13551b252ae8c127ea8a097c862ebf.png" data-type="png" data-w="755" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;"></span> </figure> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">添加知识库</span></span><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><img src="/upload/9b0cae36b75a05120b26f00ef7d6249c.png" class="rich_pages wxw-img" data-ratio="0.6465028355387523" data-type="png" data-w="529" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;" data-imgfileid="100001843">知识库可以一次选多个,我们只选择三国演义。</span></p> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">召回设置</span></span><span style="display: none;"></span></h3> <figure data-tool="mdnice编辑器" style="margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: flex;flex-direction: column;justify-content: center;align-items: center;"> <span leaf=""><img src="/upload/201c1bac7ed1f2ca2d8e580d4daff0ab.png" class="rich_pages wxw-img" data-ratio="0.2969187675070028" data-type="png" data-w="714" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 3px;border-bottom-width: 3px;border-left-width: 3px;border-right-width: 3px;border-top-color: rgba(0, 0, 0, 0.4);border-bottom-color: rgba(0, 0, 0, 0.4);border-left-color: rgba(0, 0, 0, 0.4);border-right-color: rgba(0, 0, 0, 0.4);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;object-fit: fill;box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px;" data-imgfileid="100001846"></span> </figure> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><img src="/upload/661005715b208a30b0574448d55f2afb.png" class="rich_pages wxw-img" data-ratio="0.8333333333333334" data-type="png" data-w="480" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;" data-imgfileid="100001850">1,选择Rerank模型</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">2,选择相关的模型</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">3,设置召回数量(文本片段数量)</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">4,相似度匹配,设置0.7</span></p> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;display: block;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(0, 0, 0);line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;display: block;"><span leaf="">调试与预览</span></span><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001852" data-ratio="0.7064814814814815" src="/upload/aea31a536398c699ffbbb5aa8c1a5985.png" data-type="png" data-w="1080" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;">1,输入聊天内容</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">2,点击发送</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">3,调试成功以后可以点击发布</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001849" data-ratio="1.0185758513931888" src="/upload/6feabe88b9b57908eb6bb5b1b862d605.png" data-type="png" data-w="323" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;">发布以后有多种适用方式。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><img class="rich_pages wxw-img" data-imgfileid="100001851" data-ratio="0.4041013268998794" src="/upload/c2355d3ef2e2f3584dd02b53d3689a8e.png" data-type="png" data-w="829" style="display: block;margin-top: 0px;margin-right: auto;margin-bottom: 0px;margin-left: auto;max-width: 100%;">返回工作室以后,我们可以发现已经有对应的应用了。</span></p> <h2 data-tool="mdnice编辑器" style="border-bottom-color: rgb(239, 112, 96);margin-top: 30px;margin-bottom: 15px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: solid;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 2px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: flex;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.1em;overflow-x: unset;overflow-y: unset;text-align: left;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 22px;color: rgb(255, 255, 255);background-color: rgb(239, 112, 96);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-right-width: 1px;border-top-color: rgb(0, 0, 0);border-bottom-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: rgb(0, 0, 0);border-top-left-radius: 3px;border-top-right-radius: 3px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 5px;overflow-x: unset;overflow-y: unset;padding-top: 3px;padding-bottom: 1px;padding-left: 10px;padding-right: 10px;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf="">后记</span></span><span style="display: none;"></span><span style="border-bottom-color: rgb(239, 235, 233);align-items: unset;background-attachment: scroll;background-clip: border-box;background-color: unset;background-image: none;background-origin: padding-box;background-position-x: 0%;background-position-y: 0%;background-repeat: no-repeat;background-size: auto;border-top-style: none;border-bottom-style: solid;border-left-style: none;border-right-style: solid;border-top-width: 1px;border-bottom-width: 36px;border-left-width: 1px;border-right-width: 20px;border-top-color: rgb(0, 0, 0);border-left-color: rgb(0, 0, 0);border-right-color: transparent;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;box-shadow: none;color: rgb(0, 0, 0);display: inline-block;font-size: 16px;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;letter-spacing: 0px;line-height: 1.1em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;overflow-x: unset;overflow-y: unset;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;text-align: left;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span leaf=""> </span></span></h2> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">后续我会分享dify相关的高级功能。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">同时也会基于dify做整合企业知识的相关功能开发。</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><br></span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">相关资源网盘地址: https://pan.quark.cn/s/7909300e0028</span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf=""><br></span></p> <p data-tool="mdnice编辑器" style="color: rgb(0, 0, 0);font-size: 16px;line-height: 1.8em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;padding-top: 8px;padding-bottom: 8px;padding-left: 0px;padding-right: 0px;"><span leaf="">创作不易,辛苦大家动动发财的小手。</span></p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;text-align: left;margin-top: 10px;margin-bottom: 10px;margin-left: 0px;margin-right: 0px;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;"><span data-cacheurl="" data-remoteid="" style="display: block;background: none;height: 30px;width: 100%;background-size: 40px;background-repeat: no-repeat;background-color: #282c34;margin-bottom: -7px;border-radius: 5px;background-position: 10px 10px;background-image: url(" https: mmbiz.qpic.cn mmbiz_svg k0ue4mipavick8hqialiakg2y4ciqoodnaactclbibcgyad7vzlwed4e4twjoq8arkiuadcxiazmb9qb1lw9mihicah73fq7cubgibp 640?wx_fmt="svg&from=appmsg");""></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;"><span style="color: #c678dd;line-height: 26px;"><span leaf="">if</span></span><span leaf=""> 文章有用: </span><span leaf=""><br></span><span leaf=""> 点赞() </span><span style="color: #5c6370;font-style: italic;line-height: 26px;"><span leaf=""># 👍 小手一抖,bug没有</span></span><span leaf=""><br></span><span leaf=""> 收藏() </span><span style="color: #5c6370;font-style: italic;line-height: 26px;"><span leaf=""># 📂 防止迷路,代码永驻</span></span><span leaf=""><br></span><span leaf=""> 关注() </span><span style="color: #5c6370;font-style: italic;line-height: 26px;"><span leaf=""># 🔔 追更最新内容</span></span><span leaf=""><br></span><span style="color: #c678dd;line-height: 26px;"><span leaf="">else</span></span><span leaf="">:</span><span leaf=""><br></span><span leaf=""> 留言吐槽() </span><span style="color: #5c6370;font-style: italic;line-height: 26px;"><span leaf=""># 💬 评论区等你来战</span></span><span leaf=""><br></span></code></pre> </section> <section> <span leaf=""><br></span> </section> <p style="display: none;"> <mp-style-type data-value="3"></mp-style-type></p>
作者:微信小助手
<section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="margin-bottom: 0px;padding-left: 10px;padding-right: 10px;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;width: auto;font-family: Optima, " microsoft yahei, pingfangsc-regular, serif;font-size: 16px;color: rgb(0, 0, 0);line-height: 1.5em;word-spacing: 0em;letter-spacing: 0em;word-break: break-word;text-align: left;> <h1 data-tool="mdnice编辑器" style="border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(37, 132, 181);margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px;border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(37, 132, 181);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">前言</span><span style="display: none;"></span></h1> <section class="mp_profile_iframe_wrp"> <mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-id="Mzg5MzY5ODMwNA==" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/IHicdx3TSo7U3PCU97Yn2MtLV5giadHZysbQfusgrXtyzT1tAnhOMG3V2ONuibgxTEynMicCnu9Nk425L0TiacVGqhg/0?wx_fmt=png" data-nickname="z先生的备忘录" data-alias="MCXPD0901" data-signature="大模型AIGC/AIGA最新产品、机器学习、可视化等技术实践落地分享" data-from="0" data-is_biz_ban="0" data-service_type="1"></mp-common-profile> </section> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">大家好。今天给大家带来最近2款爆火语音克隆开源TTS模型<span style="color: rgb(172, 57, 255);">阿里的CosyVoice2-0.5B</span>和<span style="color: rgb(172, 57, 255);">fish-audio团队的FishSpeech1.5模型</span>。为了能够较客观的衡量2款模型在特定参考音频下克隆的效果,决定采用seed-tts的<span style="color: rgb(172, 57, 255);">说话人相似度SS指标</span>来<span style="color: rgb(172, 57, 255);">衡量模型语音合成与对应参考音频的相似度;</span><span style="color: rgb(0, 0, 0);">以便给大家带来更理性的判断~</span></p> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">本文带你手把手实操部署2款模型,并提供对应的推理代码进行语音合成效果展示,<span style="letter-spacing: 0em;text-indent: 0em;word-spacing: 0em;">下面进入本文的主题~</span></p> <h1 data-tool="mdnice编辑器" style="border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(37, 132, 181);margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px;border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 20px;color: rgb(37, 132, 181);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">本文目录</span></h1> <ul style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li style="color: rgb(0, 122, 170);"><p><span style="color: rgb(0, 122, 170);">CosyVoice2-0.5B模型介绍</span></p></li> <li style="color: rgb(0, 122, 170);"><p><span style="color: rgb(0, 122, 170);">FishSpeech1.5模型介绍</span></p></li> <li style="color: rgb(0, 122, 170);"><p><span style="color: rgb(0, 122, 170);">实战篇:部署 CosyVoice2-0.5B模型和FishSpeech1.5模型进行语音克隆</span></p></li> <ul style="list-style-type: square;margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li style="color: rgb(0, 122, 170);"><p><span style="color: rgb(0, 122, 170);">配置 CosyVoice2-0.5B模型的运行环境</span></p></li> <li style="color: rgb(0, 122, 170);"><p><span style="color: rgb(0, 122, 170);">配置 FishSpeech1.5模型的运行环境</span></p></li> <li style="color: rgb(0, 122, 170);"><p><span style="color: rgb(0, 122, 170);">搭建CosyVoice2-0.5B模型语音合成推理函数</span></p></li> <li style="color: rgb(0, 122, 170);"><p><span style="color: rgb(0, 122, 170);">搭建 FishSpeech1.5模型语音合成推理函数</span></p></li> <li style="color: rgb(0, 122, 170);"><p><span style="color: rgb(0, 122, 170);">speaker Similarity(ss):字节Seed-TTS客观评估指标函数-衡量语音克隆相似度</span></p></li> </ul> <li style="color: rgb(0, 122, 170);"><p><span style="color: rgb(0, 122, 170);">效果篇: CosyVoice2-0.5B和Fish-Speech1.5语音克隆-性能客观评价</span></p></li> <ul style="list-style-type: square;margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li style="color: rgb(0, 122, 170);"><p><span style="color: rgb(0, 122, 170);">案例1:女音克隆-语音克隆效果展示(客观指标说话人相似度SS指标)</span></p></li> <li style="color: rgb(0, 122, 170);"><p><span style="color: rgb(0, 122, 170);">案例2:男音克隆-语音克隆效果展示(客观指标说话人相似度SS指标)</span></p></li> </ul> <li style="color: rgb(0, 122, 170);"><p><span style="color: rgb(0, 122, 170);">参考链接</span></p></li> </ul> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(37, 132, 181);border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(37, 132, 181);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 4px;border-radius: 0px;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;padding-top: 2px;padding-right: 4px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">CosyVoice2-0.5B模型介绍</span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">CosyVoice系列是阿里开源关于TTS语音合成项目,目前最新已开源CosyVoice2-0.5B版本。更多详情可见之前给大家分享的文章:<a target="_blank" href="https://mp.weixin.qq.com/s?__biz=Mzg5MzY5ODMwNA==&mid=2247492074&idx=1&sn=04e51a86896c9cd3833633f925488cf5&scene=21#wechat_redirect" textvalue="【TTS领域开源霸主模型更新啦】CosyVoice2来啦!超逼真的语音克隆,支持多种地方方言合成,真的好强!" linktype="text" imgurl="" imgdata="null" data-itemshowtype="0" tab="innerlink" data-linktype="2"><span style="color: rgb(0, 122, 170);"><strong>【TTS领域开源霸主模型更新啦】CosyVoice2来啦!超逼真的语音克隆,支持多种地方方言合成,真的好强!</strong></span></a>该文章的目录大纲如下,感兴趣的小伙伴可以访问上面的链接~<img class="rich_pages wxw-img" data-imgfileid="100008902" data-ratio="0.5887096774193549" src="/upload/ff2176d7d8f7fe1ea87e35b75dcd395b.png" data-type="png" data-w="868" style="display: block;margin-right: auto;margin-left: auto;"></p> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(37, 132, 181);border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(37, 132, 181);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 4px;border-radius: 0px;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;padding-top: 2px;padding-right: 4px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">FishSpeech1.5模型介绍</span><span style="display: none;"></span></h2> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">FishSpeech系列是fish-audio开源关于TTS语音合成项目,开源的版本路线: <span style="text-decoration: underline;color: rgb(172, 57, 255);">Fish Speech V1.2 —> Fish Speech V1.4->Fish Speech V1.5</span>;目前最新已开源 V1.5版本。更多详情可见之前给大家分享的文章:<a target="_blank" href="https://mp.weixin.qq.com/s?__biz=Mzg5MzY5ODMwNA==&mid=2247491944&idx=1&sn=818732be3555d515a57a962da94a379d&scene=21#wechat_redirect" textvalue="【TTS领域王炸模型重磅升级】性能超过F5、CosySense,一文带你理论+实操多种语言克隆效果,效果炸裂,请谨慎使用!" linktype="text" imgurl="" imgdata="null" data-itemshowtype="0" tab="innerlink" data-linktype="2"><strong><span style="color: rgb(0, 122, 170);">【TTS领域王炸模型重磅升级】性能超过F5、CosySense,一文带你理论+实操多种语言克隆效果,效果炸裂,请谨慎使用!</span></strong></a>该文章的目录大纲如下,感兴趣的小伙伴可以访问上面的链接~<img class="rich_pages wxw-img" data-imgfileid="100008901" data-ratio="0.6824085005903188" src="/upload/76b785944a4c13644066e544e7b9a249.png" data-type="png" data-w="847" style="display: block;margin-right: auto;margin-left: auto;">截止到目前1月22日, <span style="text-decoration: underline;color: rgb(172, 57, 255);">fish-speech-1.5模型</span><span style="text-decoration: underline;">在huggingface上权重下载量高达6,485次</span>;<span style="text-decoration: underline;color: rgb(172, 57, 255);">CosyVoice2-0.5B</span><span style="text-decoration: underline;">模型在huggingface上权重下载量高达8,589次</span>;从模型权重下载量就能看出,2款TTS模型在开源领域都比较火热。</p> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">今天决定给大家实操部署2款TTS模型并准备一些案例,从客观指标的角度来展示2款模型对语音克隆的效果对比~</p> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(37, 132, 181);border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(37, 132, 181);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 4px;border-radius: 0px;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;padding-top: 2px;padding-right: 4px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">实战篇:部署 CosyVoice2-0.5B模型和FishSpeech1.5模型进行语音克隆</span><span style="display: none;"></span></h2> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="background-image: linear-gradient(45deg, transparent 48%, rgb(37, 132, 181) 48%, rgb(37, 132, 181) 52%, transparent 52%);align-items: unset;background-attachment: scroll;background-clip: border-box;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: inline-block;font-size: 22px;font-weight: bold;flex-direction: unset;float: unset;height: 30px;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin-bottom: -11px;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: 30px;-webkit-box-reflect: unset;"></span><span style="color: rgb(37, 132, 181);border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(37, 132, 181);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 2px;border-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;padding: 2px 10px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">配置 CosyVoice2-0.5B模型的运行环境</span><span style="display: none;"></span></h3> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg dx4y70y9xcshltumvr8v6iccv4hbrrcccibtcgozqck5fjfpnedixdewkciaaqx6iba7yycaxlnnbs2r07tlxikbo5sod9vhqodg 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;"><span style="color: #c678dd;line-height: 26px;">from</span> IPython.display <span style="color: #c678dd;line-height: 26px;">import</span> *<br>!sudo apt-get install sox libsox-dev -y<br>clear_output()<br>%cd /kaggle/working/<br>!git clone --recursive https://github.com/FunAudioLLM/CosyVoice.git<br>%cd CosyVoice<br>!git submodule update --init --recursive<br>!apt-get update &&apt-get install -y imagemagick -o Dpkg::Options::=<span style="color: #98c379;line-height: 26px;">"--force-confold"</span><br>!pip install moviepy==<span style="color: #d19a66;line-height: 26px;">1.0</span><span style="color: #d19a66;line-height: 26px;">.3</span> imageio==<span style="color: #d19a66;line-height: 26px;">2.36</span><span style="color: #d19a66;line-height: 26px;">.0</span><br>!npm install -g localtunnel<br>!pip install gradio==<span style="color: #d19a66;line-height: 26px;">4.44</span><span style="color: #d19a66;line-height: 26px;">.1</span><br>clear_output()<br></code></pre> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="background-image: linear-gradient(45deg, transparent 48%, rgb(37, 132, 181) 48%, rgb(37, 132, 181) 52%, transparent 52%);align-items: unset;background-attachment: scroll;background-clip: border-box;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: inline-block;font-size: 22px;font-weight: bold;flex-direction: unset;float: unset;height: 30px;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin-bottom: -11px;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: 30px;-webkit-box-reflect: unset;"></span><span style="color: rgb(37, 132, 181);border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(37, 132, 181);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 2px;border-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;padding: 2px 10px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">配置 FishSpeech1.5模型的运行环境</span><span style="display: none;"></span></h3> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg dx4y70y9xcshltumvr8v6iccv4hbrrcccibtcgozqck5fjfpnedixdewkciaaqx6iba7yycaxlnnbs2r07tlxikbo5sod9vhqodg 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;">%cd /kaggle/working/<br><span style="color: #c678dd;line-height: 26px;">from</span> IPython.display <span style="color: #c678dd;line-height: 26px;">import</span> *<br>!pip install modelscope<br>!git clone https://github.com/fishaudio/fish-speech<br>%cd fish-speech<br>clear_output()<br>!apt install libsox-dev -y<br>!apt install build-essential \<br> cmake \<br> libasound-dev \<br> portaudio19-dev \<br> libportaudio2 \<br> libportaudiocpp0 -y<br>clear_output()<br><br><span style="color: #c678dd;line-height: 26px;">from</span> modelscope <span style="color: #c678dd;line-height: 26px;">import</span> snapshot_download<br><span style="color: #5c6370;font-style: italic;line-height: 26px;">#下载模型权重</span><br>model_dir = snapshot_download(<span style="color: #98c379;line-height: 26px;">"fishaudio/fish-speech-1.5"</span>, cache_dir=<span style="color: #98c379;line-height: 26px;">"/kaggle/working/"</span>)<br>clear_output()<br></code></pre> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="background-image: linear-gradient(45deg, transparent 48%, rgb(37, 132, 181) 48%, rgb(37, 132, 181) 52%, transparent 52%);align-items: unset;background-attachment: scroll;background-clip: border-box;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: inline-block;font-size: 22px;font-weight: bold;flex-direction: unset;float: unset;height: 30px;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin-bottom: -11px;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: 30px;-webkit-box-reflect: unset;"></span><span style="color: rgb(37, 132, 181);border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(37, 132, 181);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 2px;border-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;padding: 2px 10px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">搭建CosyVoice2-0.5B模型语音合成推理函数</span><span style="display: none;"></span></h3> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg dx4y70y9xcshltumvr8v6iccv4hbrrcccibtcgozqck5fjfpnedixdewkciaaqx6iba7yycaxlnnbs2r07tlxikbo5sod9vhqodg 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;">%cd /kaggle/input/cosyvoice2<span style="color: #d19a66;line-height: 26px;">-0</span><span style="color: #d19a66;line-height: 26px;">-5</span>b/CosyVoice<br>!cp zero_shot_prompt.wav /kaggle/working/<br><span style="color: #c678dd;line-height: 26px;">import</span> warnings<br>warnings.filterwarnings(<span style="color: #98c379;line-height: 26px;">'ignore'</span>, category=FutureWarning)<br>warnings.filterwarnings(<span style="color: #98c379;line-height: 26px;">'ignore'</span>, category=UserWarning)<br><br><span style="color: #c678dd;line-height: 26px;">from</span> rich <span style="color: #c678dd;line-height: 26px;">import</span> <span style="color: #c678dd;line-height: 26px;">print</span><br><span style="color: #c678dd;line-height: 26px;">import</span> torchaudio<br><span style="color: #c678dd;line-height: 26px;">import</span> os<br><span style="color: #c678dd;line-height: 26px;">import</span> sys<br><span style="color: #c678dd;line-height: 26px;">import</span> torch<br><span style="color: #c678dd;line-height: 26px;">import</span> numpy <span style="color: #c678dd;line-height: 26px;">as</span> np<br><span style="color: #c678dd;line-height: 26px;">from</span> IPython.display <span style="color: #c678dd;line-height: 26px;">import</span> *<br>sys.path.append(<span style="color: #98c379;line-height: 26px;">"/kaggle/input/cosyvoice2-0-5b/CosyVoice/third_party/Matcha-TTS"</span>)<br><span style="color: #c678dd;line-height: 26px;">from</span> cosyvoice.cli.cosyvoice <span style="color: #c678dd;line-height: 26px;">import</span> CosyVoice, CosyVoice2<br><span style="color: #c678dd;line-height: 26px;">from</span> cosyvoice.utils.file_utils <span style="color: #c678dd;line-height: 26px;">import</span> load_wav<br>cosyvoice = CosyVoice2(<span style="color: #98c379;line-height: 26px;">'pretrained_models/CosyVoice2-0.5B'</span>, load_jit=<span style="color: #56b6c2;line-height: 26px;">True</span>, load_trt=<span style="color: #56b6c2;line-height: 26px;">False</span>,fp16=<span style="color: #56b6c2;line-height: 26px;">True</span>)<br><br><br><span style="line-height: 26px;"><span style="color: #c678dd;line-height: 26px;">def</span> <span style="color: #61aeee;line-height: 26px;">voice_cloning_Synthesis</span><span style="line-height: 26px;">(target_text,ref_audio,ref_text,output_audio_name )</span>:</span><br> prompt_speech_16k = load_wav(ref_audio, <span style="color: #d19a66;line-height: 26px;">16000</span>)<br> wavs=[]<br> <span style="color: #c678dd;line-height: 26px;">for</span> i, j <span style="color: #c678dd;line-height: 26px;">in</span> enumerate(cosyvoice.inference_zero_shot(target_text,ref_text,<br> prompt_speech_16k, stream=<span style="color: #56b6c2;line-height: 26px;">False</span>,speed=<span style="color: #d19a66;line-height: 26px;">1</span>)):<br> wavs.append(j[<span style="color: #98c379;line-height: 26px;">'tts_speech'</span>])<br> torchaudio.save(output_audio_name, torch.tensor(np.concatenate(wavs,axis=<span style="color: #d19a66;line-height: 26px;">-1</span>)), cosyvoice.sample_rate)<br> print(output_audio_name)<br></code></pre> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="background-image: linear-gradient(45deg, transparent 48%, rgb(37, 132, 181) 48%, rgb(37, 132, 181) 52%, transparent 52%);align-items: unset;background-attachment: scroll;background-clip: border-box;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: inline-block;font-size: 22px;font-weight: bold;flex-direction: unset;float: unset;height: 30px;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin-bottom: -11px;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: 30px;-webkit-box-reflect: unset;"></span><span style="color: rgb(37, 132, 181);border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(37, 132, 181);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 2px;border-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;padding: 2px 10px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">搭建 FishSpeech1.5模型语音合成推理函数</span><span style="display: none;"></span></h3> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg dx4y70y9xcshltumvr8v6iccv4hbrrcccibtcgozqck5fjfpnedixdewkciaaqx6iba7yycaxlnnbs2r07tlxikbo5sod9vhqodg 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;"><span style="color: #c678dd;line-height: 26px;">from</span> IPython.display <span style="color: #c678dd;line-height: 26px;">import</span> *<br><span style="line-height: 26px;"><span style="color: #c678dd;line-height: 26px;">def</span> <span style="color: #61aeee;line-height: 26px;">fish_speech15_infer</span><span style="line-height: 26px;">(content,ref_audio,ref_text,output_path )</span>:</span><br> <span style="color: #5c6370;font-style: italic;line-height: 26px;"># 从语音生成 prompt</span><br> !python tools/vqgan/inference.py \<br> -i <span style="color: #98c379;line-height: 26px;">"$ref_audio"</span> \<br> -o <span style="color: #98c379;line-height: 26px;">"/kaggle/working/outputs/fake.wav"</span> \<br> --checkpoint-path <span style="color: #98c379;line-height: 26px;">"/kaggle/working/fishaudio/fish-speech-1___5/firefly-gan-vq-fsq-8x1024-21hz-generator.pth"</span><br> <br> !rm -rf /kaggle/working/outputs/codes_*.npy<br> <span style="color: #5c6370;font-style: italic;line-height: 26px;"># 从文本生成语义 token</span><br> !python tools/llama/generate.py \<br> --text <span style="color: #98c379;line-height: 26px;">"$content"</span> \<br> --prompt-text <span style="color: #98c379;line-height: 26px;">"$ref_text"</span> \<br> --prompt-tokens <span style="color: #98c379;line-height: 26px;">"/kaggle/working/outputs/fake.npy"</span> \<br> --checkpoint-path <span style="color: #98c379;line-height: 26px;">"/kaggle/working/fishaudio/fish-speech-1___5"</span> \<br> --num-samples <span style="color: #d19a66;line-height: 26px;">1</span> \<br> --temperature <span style="color: #d19a66;line-height: 26px;">0.3</span> \<br> --half <br> <span style="color: #5c6370;font-style: italic;line-height: 26px;"># clear_output()</span><br> <span style="color: #5c6370;font-style: italic;line-height: 26px;"># 从语义 token 生成人声</span><br> !python tools/vqgan/inference.py \<br> -i <span style="color: #98c379;line-height: 26px;">"codes_0.npy"</span> \<br> --checkpoint-path <span style="color: #98c379;line-height: 26px;">"/kaggle/working/fishaudio/fish-speech-1___5/firefly-gan-vq-fsq-8x1024-21hz-generator.pth"</span> \<br> -o <span style="color: #98c379;line-height: 26px;">"$output_path"</span><br></code></pre> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="background-image: linear-gradient(45deg, transparent 48%, rgb(37, 132, 181) 48%, rgb(37, 132, 181) 52%, transparent 52%);align-items: unset;background-attachment: scroll;background-clip: border-box;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: inline-block;font-size: 22px;font-weight: bold;flex-direction: unset;float: unset;height: 30px;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin-bottom: -11px;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: 30px;-webkit-box-reflect: unset;"></span><span style="color: rgb(37, 132, 181);border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(37, 132, 181);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 2px;border-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;padding: 2px 10px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">speaker Similarity(ss):字节Seed-TTS客观评估指标函数-衡量语音克隆相似度</span><span style="display: none;"></span></h3> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">对于speaker Similarity(ss),使用在说话人验证任务上微调的 WavLM-large 来获取说话人embedding,用于计算每个测试话语的语音样本与参考语音的余弦相似度(<span style="text-decoration: underline;color: rgb(172, 57, 255);">0~1之间,越靠近1,说明克隆合成的语音效果接近参考音频的语音效果</span>)</p> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg dx4y70y9xcshltumvr8v6iccv4hbrrcccibtcgozqck5fjfpnedixdewkciaaqx6iba7yycaxlnnbs2r07tlxikbo5sod9vhqodg 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;">wavlm_ckpt_dir = <span style="color: #98c379;line-height: 26px;">"./models/wavlm_large_finetune.pth"</span><br>ss_model = ECAPA_TDNN_SMALL(feat_dim=<span style="color: #d19a66;line-height: 26px;">1024</span>, feat_type=<span style="color: #98c379;line-height: 26px;">"wavlm_large"</span>, config_path=<span style="color: #56b6c2;line-height: 26px;">None</span>)<br>state_dict = torch.load(wavlm_ckpt_dir, weights_only=<span style="color: #56b6c2;line-height: 26px;">True</span>, map_location=<span style="color: #c678dd;line-height: 26px;">lambda</span> storage, loc: storage)<br>ss_model.load_state_dict(state_dict[<span style="color: #98c379;line-height: 26px;">"model"</span>], strict=<span style="color: #56b6c2;line-height: 26px;">False</span>)<br>use_gpu = <span style="color: #56b6c2;line-height: 26px;">True</span> <span style="color: #c678dd;line-height: 26px;">if</span> torch.cuda.is_available() <span style="color: #c678dd;line-height: 26px;">else</span> <span style="color: #56b6c2;line-height: 26px;">False</span><br><span style="color: #c678dd;line-height: 26px;">if</span> use_gpu:<br> ss_model = ss_model.cuda()<br>ss_model.eval()<br><span style="line-height: 26px;"><span style="color: #c678dd;line-height: 26px;">def</span> <span style="color: #61aeee;line-height: 26px;">run_sim</span><span style="line-height: 26px;">(wav1_path,wav2_path )</span>:</span><br> wav1, sr1 = torchaudio.load(wav1_path)<br> wav2, sr2 = torchaudio.load(wav2_path)<br> <br> resample1 = torchaudio.transforms.Resample(orig_freq=sr1, new_freq=<span style="color: #d19a66;line-height: 26px;">16000</span>)<br> resample2 = torchaudio.transforms.Resample(orig_freq=sr2, new_freq=<span style="color: #d19a66;line-height: 26px;">16000</span>)<br> wav1 = resample1(wav1)<br> wav2 = resample2(wav2)<br> <br> <span style="color: #c678dd;line-height: 26px;">if</span> use_gpu:<br> wav1 = wav1.cuda()<br> wav2 = wav2.cuda()<br> <span style="color: #c678dd;line-height: 26px;">with</span> torch.no_grad():<br> emb1 = ss_model(wav1)<br> emb2 = ss_model(wav2)<br> <br> sim = F.cosine_similarity(emb1, emb2)[<span style="color: #d19a66;line-height: 26px;">0</span>].item()<br> <span style="color: #c678dd;line-height: 26px;">return</span> sim<br></code></pre> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(37, 132, 181);border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(37, 132, 181);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 4px;border-radius: 0px;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;padding-top: 2px;padding-right: 4px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">效果篇: CosyVoice2-0.5B和Fish-Speech1.5语音克隆-性能客观评价</span><span style="display: none;"></span></h2> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="background-image: linear-gradient(45deg, transparent 48%, rgb(37, 132, 181) 48%, rgb(37, 132, 181) 52%, transparent 52%);align-items: unset;background-attachment: scroll;background-clip: border-box;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: inline-block;font-size: 22px;font-weight: bold;flex-direction: unset;float: unset;height: 30px;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin-bottom: -11px;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: 30px;-webkit-box-reflect: unset;"></span><span style="color: rgb(37, 132, 181);border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(37, 132, 181);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 2px;border-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;padding: 2px 10px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">案例1:女音克隆-语音克隆效果展示(客观指标说话人相似度SS指标)</span><span style="display: none;"></span></h3> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg dx4y70y9xcshltumvr8v6iccv4hbrrcccibtcgozqck5fjfpnedixdewkciaaqx6iba7yycaxlnnbs2r07tlxikbo5sod9vhqodg 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;">%%time <br>content=<span style="color: #98c379;line-height: 26px;">"""富人优先考虑的都是利益,而穷人优先考虑的永远都是感情和面子。<br>做人不需要太大方,因为你的感情和面子在利益面前一文不值。<br>穷人总是把很好的东西送人,还担心别人瞧不起,看不上。<br>而富人则是把不用的东西送给别人,还认为别人没有吃过,没有见<br>过,也没有用过!穷人是小心翼翼的大方,而富人却是大大方方的小气。<br>所以,请收起你的傻大方,你的感情和面子,在利益面前那是一文不值。<br>做人吝啬一些没有错,不需要太大方。<br>"""</span><br>ref_audio_path = <span style="color: #98c379;line-height: 26px;">"/kaggle/working/woman_2_ref.wav"</span><br>ref_text = <span style="color: #98c379;line-height: 26px;">"呃你这个梦属于超现实主义,狂想派的。"</span><br>fish_output_path = <span style="color: #98c379;line-height: 26px;">"/kaggle/working/fish1.5_output.wav"</span><br>cosyvoice2_output_path = <span style="color: #98c379;line-height: 26px;">"/kaggle/working/cosyvoice2_output.wav"</span><br><br>%cd /kaggle/working/fish-speech<br>fish_speech15_infer(content,ref_audio_path,ref_text,fish_output_path )<br>clear_output()<br>%cd /kaggle/input/cosyvoice2<span style="color: #d19a66;line-height: 26px;">-0</span><span style="color: #d19a66;line-height: 26px;">-5</span>b/CosyVoice<br>voice_cloning_Synthesis(content,ref_audio_path,ref_text,cosyvoice2_output_path )<br>clear_output()<br></code></pre> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">其中SS指标如下:<img class="rich_pages wxw-img" data-imgfileid="100008899" data-ratio="0.14797360980207352" src="/upload/e9b0d8e35dee9a23ea59e5c3357f5966.png" data-type="png" data-w="1061" style="display: block;margin-right: auto;margin-left: auto;">其中参考音频效果如下:</p> <section> <mp-common-mpaudio class="js_editor_audio res_iframe js_uneditable custom_select_card" src="/cgi-bin/readtemplate?t=tmpl/audio_tmpl&name=%E6%A1%88%E4%BE%8B1-%E5%A5%B3%E7%94%9F%E5%8F%82%E8%80%83%E9%9F%B3%E9%A2%91%E6%95%88%E6%9E%9C&play_length=4%E7%A7%92" cover="http://mmbiz.qpic.cn/mmbiz_jpg/IHicdx3TSo7V6wRTBS4uRbicQHkILuICZFRJ2lEc0lyIU8J9pyWNsZkSXsG78DEBoWoUuFdKqGVtBFpkykzEBoTg/0?wx_fmt=jpeg" isaac2="1" low_size="8.05" source_size="8" high_size="33.31" name="案例1-女生参考音频效果" play_length="4000" author="z先生的备忘录" data-topic_id="" data-topic_name="" data-pluginname="insertaudio" data-trans_state="1" data-verify_state="3" voice_encode_fileid="Mzg5MzY5ODMwNF8yMjQ3NDkyNTY4"></mp-common-mpaudio> </section> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">其中Fish-Speech1.5语音合成效果如下:</p> <section> <mp-common-mpaudio class="js_editor_audio res_iframe js_uneditable custom_select_card" src="/cgi-bin/readtemplate?t=tmpl/audio_tmpl&name=%E6%A1%88%E4%BE%8B1_FishSpeech1.5%E8%AF%AD%E9%9F%B3%E5%90%88%E6%88%90%E6%95%88%E6%9E%9C&play_length=35%E7%A7%92" cover="http://mmbiz.qpic.cn/mmbiz_jpg/IHicdx3TSo7V6wRTBS4uRbicQHkILuICZFRJ2lEc0lyIU8J9pyWNsZkSXsG78DEBoWoUuFdKqGVtBFpkykzEBoTg/0?wx_fmt=jpeg" isaac2="1" low_size="68.22" source_size="68.2" high_size="276.78" name="案例1_FishSpeech1.5语音合成效果" play_length="35000" author="z先生的备忘录" data-topic_id="" data-topic_name="" data-pluginname="insertaudio" data-trans_state="1" data-verify_state="3" voice_encode_fileid="Mzg5MzY5ODMwNF8yMjQ3NDkyNTY5"></mp-common-mpaudio> </section> <section> <br> </section> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">其中CosyVoice2-0.5B语音合成效果如下:</p> <section> <mp-common-mpaudio class="js_editor_audio res_iframe js_uneditable custom_select_card" src="/cgi-bin/readtemplate?t=tmpl/audio_tmpl&name=%E6%A1%88%E4%BE%8B1_CosyVoice2_0.5B%E8%AF%AD%E9%9F%B3%E5%90%88%E6%88%90%E6%95%88%E6%9E%9C&play_length=43%E7%A7%92" cover="http://mmbiz.qpic.cn/mmbiz_jpg/IHicdx3TSo7V6wRTBS4uRbicQHkILuICZFRJ2lEc0lyIU8J9pyWNsZkSXsG78DEBoWoUuFdKqGVtBFpkykzEBoTg/0?wx_fmt=jpeg" isaac2="1" low_size="80.11" source_size="80.1" high_size="171.23" name="案例1_CosyVoice2_0.5B语音合成效果" play_length="43000" author="z先生的备忘录" data-topic_id="" data-topic_name="" data-pluginname="insertaudio" data-trans_state="1" data-verify_state="3" voice_encode_fileid="Mzg5MzY5ODMwNF8yMjQ3NDkyNTY3"></mp-common-mpaudio> </section> <section> <br> </section> <h3 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="background-image: linear-gradient(45deg, transparent 48%, rgb(37, 132, 181) 48%, rgb(37, 132, 181) 52%, transparent 52%);align-items: unset;background-attachment: scroll;background-clip: border-box;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;display: inline-block;font-size: 22px;font-weight: bold;flex-direction: unset;float: unset;height: 30px;justify-content: unset;letter-spacing: 0px;line-height: 1.5em;margin-bottom: -11px;overflow: unset;text-indent: 0em;text-shadow: none;transform: none;width: 30px;-webkit-box-reflect: unset;"></span><span style="color: rgb(37, 132, 181);border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(37, 132, 181);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 2px;border-radius: 0px;box-shadow: none;display: inline-block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;padding: 2px 10px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">案例2:男音克隆-语音克隆效果展示(客观指标说话人相似度SS指标)</span><span style="display: none;"></span></h3> <pre data-tool="mdnice编辑器" style="border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;margin-top: 10px;margin-bottom: 10px;"><span style="display: block;background: url(" https: mmbiz.qpic.cn mmbiz_svg dx4y70y9xcshltumvr8v6iccv4hbrrcccibtcgozqck5fjfpnedixdewkciaaqx6iba7yycaxlnnbs2r07tlxikbo5sod9vhqodg 640?wx_fmt="svg&from=appmsg")" 10px 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;></span><code style="overflow-x: auto;padding: 16px;color: #abb2bf;padding-top: 15px;background: #282c34;border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;">%%time <br>content=<span style="color: #98c379;line-height: 26px;">"""人为什么要读书? 读书不一定能前程似锦,功成名就<br>,但至少可以让你出言有尺,嬉闹有度,说话有德,做事有余。<br>读书,世界就在眼前,不读书,眼前就是世界!<br>人生没有白走的路,没有白读的书,你触碰过的那些文字,<br>会在不知不觉中帮你认识这个世界,会悄悄帮你擦去脸上的肤浅和无知。<br>读书不是为了一纸文凭,也不是为了一夜暴富,而是为了成为一个有温度、懂情趣、会思考的人,<br>是为了让你在跌宕起伏的生活中拥有处变不惊的内心,让你在未来能独自度过那些漫长幽暗的岁月而不怨天忧人。<br>"""</span><br>ref_audio_path = <span style="color: #98c379;line-height: 26px;">"/kaggle/working/man_ref.wav"</span><br>ref_text = <span style="color: #98c379;line-height: 26px;">"这个问题,嗯嘶,从另一个角度看,是不是对我们来说也是一件好事?"</span><br>fish_output_path = <span style="color: #98c379;line-height: 26px;">"/kaggle/working/fish1.5_output2.wav"</span><br>cosyvoice2_output_path = <span style="color: #98c379;line-height: 26px;">"/kaggle/working/cosyvoice2_output2.wav"</span><br>%cd /kaggle/working/fish-speech<br>fish_speech15_infer(content,ref_audio_path,ref_text,fish_output_path )<br>clear_output()<br>%cd /kaggle/input/cosyvoice2<span style="color: #d19a66;line-height: 26px;">-0</span><span style="color: #d19a66;line-height: 26px;">-5</span>b/CosyVoice<br>voice_cloning_Synthesis(content,ref_audio_path,ref_text,cosyvoice2_output_path )<br>clear_output()<br><br></code></pre> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">其中SS指标如下:<img class="rich_pages wxw-img" data-imgfileid="100008900" data-ratio="0.1437847866419295" src="/upload/4b097bb652a3d663cb8554c7c702b305.png" data-type="png" data-w="1078" style="display: block;margin-right: auto;margin-left: auto;"></p> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><span style="color: rgb(0, 0, 0);font-family: Optima, " microsoft yahei, pingfangsc-regular, serif;font-size: 16px;letter-spacing: normal;text-align: left;>其中参考音频</span><span style="color: rgb(0, 0, 0);font-family: Optima, " microsoft yahei, pingfangsc-regular, serif;font-size: 16px;letter-spacing: normal;text-align: left;>效果如下:</span></p> <section> <mp-common-mpaudio class="js_editor_audio res_iframe js_uneditable custom_select_card" src="/cgi-bin/readtemplate?t=tmpl/audio_tmpl&name=%E6%A1%88%E4%BE%8B2-%E7%94%B7%E7%94%9F%E5%8F%82%E8%80%83%E9%9F%B3%E9%A2%91%E6%95%88%E6%9E%9C&play_length=6%E7%A7%92" cover="http://mmbiz.qpic.cn/mmbiz_jpg/IHicdx3TSo7V6wRTBS4uRbicQHkILuICZFRJ2lEc0lyIU8J9pyWNsZkSXsG78DEBoWoUuFdKqGVtBFpkykzEBoTg/0?wx_fmt=jpeg" isaac2="1" low_size="11.96" source_size="12" high_size="50.04" name="案例2-男生参考音频效果" play_length="6000" author="z先生的备忘录" data-topic_id="" data-topic_name="" data-pluginname="insertaudio" data-trans_state="1" data-verify_state="3" voice_encode_fileid="Mzg5MzY5ODMwNF8yMjQ3NDkyNTcx"></mp-common-mpaudio> </section> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;"><span style="color: rgb(0, 0, 0);font-family: Optima, " microsoft yahei, pingfangsc-regular, serif;font-size: 16px;letter-spacing: normal;text-align: left;></span></p> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">其中Fish-Speech1.5语音合成效果如下:</p> <section> <mp-common-mpaudio class="js_editor_audio res_iframe js_uneditable custom_select_card" src="/cgi-bin/readtemplate?t=tmpl/audio_tmpl&name=%E6%A1%88%E4%BE%8B2_FishSpeech1.5%E8%AF%AD%E9%9F%B3%E5%90%88%E6%88%90%E6%95%88%E6%9E%9C&play_length=48%E7%A7%92" cover="http://mmbiz.qpic.cn/mmbiz_jpg/IHicdx3TSo7V6wRTBS4uRbicQHkILuICZFRJ2lEc0lyIU8J9pyWNsZkSXsG78DEBoWoUuFdKqGVtBFpkykzEBoTg/0?wx_fmt=jpeg" isaac2="1" low_size="89.31" source_size="89.3" high_size="380.86" name="案例2_FishSpeech1.5语音合成效果" play_length="48000" author="z先生的备忘录" data-topic_id="" data-topic_name="" data-pluginname="insertaudio" data-trans_state="1" data-verify_state="3" voice_encode_fileid="Mzg5MzY5ODMwNF8yMjQ3NDkyNTcw"></mp-common-mpaudio> </section> <p data-tool="mdnice编辑器" style="line-height: 1.8em;letter-spacing: 0em;text-indent: 0em;padding-top: 8px;padding-bottom: 8px;">其中CosyVoice2-0.5B语音合成效果如下:</p> <section> <mp-common-mpaudio class="js_editor_audio res_iframe js_uneditable custom_select_card" src="/cgi-bin/readtemplate?t=tmpl/audio_tmpl&name=%E6%A1%88%E4%BE%8B2_CosyVoice2_0.5B%E8%AF%AD%E9%9F%B3%E5%90%88%E6%88%90%E6%95%88%E6%9E%9C&play_length=48%E7%A7%92" cover="http://mmbiz.qpic.cn/mmbiz_jpg/IHicdx3TSo7V6wRTBS4uRbicQHkILuICZFRJ2lEc0lyIU8J9pyWNsZkSXsG78DEBoWoUuFdKqGVtBFpkykzEBoTg/0?wx_fmt=jpeg" isaac2="1" low_size="89.86" source_size="89.9" high_size="191.01" name="案例2_CosyVoice2_0.5B语音合成效果" play_length="48000" author="z先生的备忘录" data-topic_id="" data-topic_name="" data-pluginname="insertaudio" data-trans_state="1" data-verify_state="3" voice_encode_fileid="Mzg5MzY5ODMwNF8yMjQ3NDkyNTcy"></mp-common-mpaudio> </section> <h2 data-tool="mdnice编辑器" style="margin-top: 30px;margin-bottom: 15px;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none;border-width: 1px;border-color: rgb(0, 0, 0);border-radius: 0px;box-shadow: none;flex-direction: unset;float: unset;height: auto;justify-content: unset;line-height: 1.5em;overflow: unset;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;"><span style="display: none;"></span><span style="font-size: 18px;color: rgb(37, 132, 181);border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(37, 132, 181);line-height: 1.5em;letter-spacing: 0em;align-items: unset;background-attachment: scroll;background-clip: border-box;background-image: none;background-origin: padding-box;background-position: 0% 0%;background-repeat: no-repeat;background-size: auto;border-style: none none solid;border-width: 1px 1px 4px;border-radius: 0px;box-shadow: none;display: block;font-weight: bold;flex-direction: unset;float: unset;height: auto;justify-content: unset;overflow: unset;padding-top: 2px;padding-right: 4px;text-indent: 0em;text-shadow: none;transform: none;width: auto;-webkit-box-reflect: unset;">参考链接</span><span style="display: none;"></span></h2> <ol data-tool="mdnice编辑器" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;" class="list-paddingleft-1"> <li style="color: rgb(0, 122, 170);"> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> <span style="color: rgb(0, 122, 170);">https://github.com/BytedanceSpeech/seed-tts-eval</span> </section></li> <li style="color: rgb(0, 122, 170);"> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> <span style="color: rgb(0, 122, 170);">https://www.modelscope.cn/models/iic/CosyVoice2-0.5B</span> </section></li> <li style="color: rgb(0, 122, 170);"> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> <span style="color: rgb(0, 122, 170);">https://hf-mirror.com/fishaudio/fish-speech-1.5</span> </section></li> <li style="color: rgb(0, 122, 170);"> <section style="margin-top: 5px;margin-bottom: 5px;color: rgb(1, 1, 1);line-height: 1.8em;letter-spacing: 0em;"> <span style="color: rgb(0, 122, 170);">https://github.com/fishaudio/fish-speech</span> </section></li> </ol> </section>
作者:微信小助手
<p style="box-sizing: border-box;margin: 22px 0px;overflow-wrap: break-word;line-height: inherit;color: rgb(51, 51, 51);font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><span leaf="">FireRedASR 是小红书开源的一个高度精确的中文语音转文字项目,在多个对比维度上都优于 whisper/funasr等。</span></p> <p style="box-sizing: border-box;margin: 22px 0px;overflow-wrap: break-word;line-height: inherit;color: rgb(51, 51, 51);font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><span leaf="">为此创建了一个带有 webui界面,并兼容 OpenAI SDK格式的封装,同时提供了一个win下的整合包,以方便使用。</span></p> <p style="box-sizing: border-box;margin: 22px 0px;overflow-wrap: break-word;line-height: inherit;color: rgb(51, 51, 51);font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><span leaf="">开源地址: </span><span leaf=""><span textstyle="" style="color: rgb(255, 76, 65);">https://github.com/jianchang512/fireredasr-ui</span></span></p> <h2 tabindex="-1" style="box-sizing: border-box;margin: 35px 2px 10px 0px;line-height: 1.5;font-size: 24px;font-weight: 700;overflow-wrap: break-word;outline: none;border-top: 1px solid var(--vp-c-divider);padding: 6px 8px 0px 0px;letter-spacing: -0.02em;display: inline-block;background: rgb(239, 112, 96);color: rgb(255, 255, 255);border-top-right-radius: 6px;box-shadow: rgba(239, 112, 96, 0.2) 6px 3px 0px 0px;font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><span leaf=""> WebUI 界面</span></h2> <p style="box-sizing: border-box;margin: 22px 0px;overflow-wrap: break-word;line-height: inherit;color: rgb(51, 51, 51);font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><span leaf="">启动后默认地址: </span><span leaf=""><span textstyle="" style="color: rgb(255, 76, 65);">http://127.0.0.1:5078</span></span></p> <section style="text-align: center;" nodeleaf=""> <img src="/upload/44ef7bbac85057b7530c8dbdbc6185f6.png" class="rich_pages wxw-img" data-ratio="0.4824074074074074" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="300323453"> </section> <p style="box-sizing: border-box;margin: 22px 0px;overflow-wrap: break-word;line-height: inherit;color: rgb(51, 51, 51);font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><span leaf=""><br></span></p> <h2 tabindex="-1" style="box-sizing: border-box;margin: 35px 2px 10px 0px;line-height: 1.5;font-size: 24px;font-weight: 700;overflow-wrap: break-word;outline: none;border-top: 1px solid var(--vp-c-divider);padding: 6px 8px 0px 0px;letter-spacing: -0.02em;display: inline-block;background: rgb(239, 112, 96);color: rgb(255, 255, 255);border-top-right-radius: 6px;box-shadow: rgba(239, 112, 96, 0.2) 6px 3px 0px 0px;font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><span leaf=""> Windows预打包版</span></h2> <p style="box-sizing: border-box;margin: 22px 0px;overflow-wrap: break-word;line-height: inherit;color: rgb(51, 51, 51);font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><span leaf="">win10/11 提供了预打包版。</span><span leaf=""><br></span></p> <p style="box-sizing: border-box;margin: 22px 0px;overflow-wrap: break-word;line-height: inherit;color: rgb(51, 51, 51);font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><span style="white-space:pre-wrap;color: rgba(0, 0, 0, 0.85);font-family: system-ui, -apple-system, " segoe ui, roboto, ubuntu, cantarell, noto sans, sans-serif, blinkmacsystemfont, helvetica neue, arial, pingfang sc, tc, hk, microsoft yahei, jhenghei;font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;display: inline !important;float: none;><span leaf="">123网盘下载地址: <span textstyle="" style="color: rgb(255, 76, 65);font-weight: bold;">https://www.123684.com/s/03Sxjv-xzTJ3</span></span></span></p> <p style="box-sizing: border-box;margin: 22px 0px;overflow-wrap: break-word;line-height: inherit;color: rgb(51, 51, 51);font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><span leaf="">解压后双击 </span><code style="box-sizing: border-box;font-family: " jetbranins mono, monaco, consolas, courier new, monospace;word-break: break-word;border-radius: 4px;overflow-x: auto;background-color: var(--vp-code-bg);color: var(--vp-code-color);font-size: var(--vp-code-font-size);padding: 3px 6px;transition: color 0.25s, background-color 0.5s;><span leaf="">启动.bat</span></code><span leaf=""> 即可</span></p> <h2 tabindex="-1" style="box-sizing: border-box;margin: 35px 2px 10px 0px;line-height: 1.5;font-size: 24px;font-weight: 700;overflow-wrap: break-word;outline: none;border-top: 1px solid var(--vp-c-divider);padding: 6px 8px 0px 0px;letter-spacing: -0.02em;display: inline-block;background: rgb(239, 112, 96);color: rgb(255, 255, 255);border-top-right-radius: 6px;box-shadow: rgba(239, 112, 96, 0.2) 6px 3px 0px 0px;font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><span leaf=""> 源码安装 Linux/MacOS</span></h2> <blockquote style="box-sizing: border-box;margin: 20px 0px 16px;border-left: 3px solid rgb(239, 112, 96);padding: 1px 20px;transition: border-color 0.5s;color: var(--vp-c-text-2);margin-inline: 0px;background: rgb(255, 249, 249);font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;> <p style="box-sizing: border-box;margin: 0px;overflow-wrap: break-word;line-height: inherit;font-size: 16px;transition: color 0.5s;"><span leaf="">确保已安装 python3.10 、ffmpeg</span></p> </blockquote> <p style="box-sizing: border-box;margin: 22px 0px;overflow-wrap: break-word;line-height: inherit;color: rgb(51, 51, 51);font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><span leaf="">进入某个目录下,打开终端</span></p> <ol style="box-sizing: border-box;list-style: decimal;margin: 16px 0px;padding: 0px 0px 0px 28px;color: rgb(51, 51, 51);font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial; class="list-paddingleft-1"> <li style="box-sizing: border-box;overflow-wrap: break-word;margin-bottom: 0px;list-style: inherit;padding-left: 6px;"> <section> <span leaf="">拉取源码,执行命令 </span><code style="box-sizing: border-box;font-family: " jetbranins mono, monaco, consolas, courier new, monospace;word-break: break-word;border-radius: 4px;overflow-x: auto;background-color: var(--vp-code-bg);color: var(--vp-code-color);font-size: var(--vp-code-font-size);padding: 3px 6px;transition: color 0.25s, background-color 0.5s;><span leaf="">git clone https://github.com/jianchang512/fireredasr-ui.git</span></code> </section></li> <li style="box-sizing: border-box;overflow-wrap: break-word;margin-top: 8px;margin-bottom: 0px;list-style: inherit;padding-left: 6px;"> <section> <span leaf="">进入源码目录 </span><code style="box-sizing: border-box;font-family: " jetbranins mono, monaco, consolas, courier new, monospace;word-break: break-word;border-radius: 4px;overflow-x: auto;background-color: var(--vp-code-bg);color: var(--vp-code-color);font-size: var(--vp-code-font-size);padding: 3px 6px;transition: color 0.25s, background-color 0.5s;><span leaf="">cd FireRedASR</span></code> </section></li> <li style="box-sizing: border-box;overflow-wrap: break-word;margin-top: 8px;margin-bottom: 0px;list-style: inherit;padding-left: 6px;"> <section> <span leaf="">创建虚拟环境:</span><code style="box-sizing: border-box;font-family: " jetbranins mono, monaco, consolas, courier new, monospace;word-break: break-word;border-radius: 4px;overflow-x: auto;background-color: var(--vp-code-bg);color: var(--vp-code-color);font-size: var(--vp-code-font-size);padding: 3px 6px;transition: color 0.25s, background-color 0.5s;><span leaf="">python3 -m venv venv</span></code> </section></li> <li style="box-sizing: border-box;overflow-wrap: break-word;margin-top: 8px;margin-bottom: 0px;list-style: inherit;padding-left: 6px;"> <section> <span leaf="">激活该环境:</span><code style="box-sizing: border-box;font-family: " jetbranins mono, monaco, consolas, courier new, monospace;word-break: break-word;border-radius: 4px;overflow-x: auto;background-color: var(--vp-code-bg);color: var(--vp-code-color);font-size: var(--vp-code-font-size);padding: 3px 6px;transition: color 0.25s, background-color 0.5s;><span leaf="">. venv/bin/activate</span></code> </section></li> <li style="box-sizing: border-box;overflow-wrap: break-word;margin-top: 8px;margin-bottom: 0px;list-style: inherit;padding-left: 6px;"> <section> <span leaf="">安装依赖:</span><code style="box-sizing: border-box;font-family: " jetbranins mono, monaco, consolas, courier new, monospace;word-break: break-word;border-radius: 4px;overflow-x: auto;background-color: var(--vp-code-bg);color: var(--vp-code-color);font-size: var(--vp-code-font-size);padding: 3px 6px;transition: color 0.25s, background-color 0.5s;><span leaf="">pip3 install -r requirements.txt</span></code> </section></li> <li style="box-sizing: border-box;overflow-wrap: break-word;margin-top: 8px;margin-bottom: 0px;list-style: inherit;padding-left: 6px;"> <section> <span leaf="">点击从 </span><span leaf="">huggingface</span><span leaf=""> 下载模型,将页面中的几个文件下载后放入 </span><code style="box-sizing: border-box;font-family: " jetbranins mono, monaco, consolas, courier new, monospace;word-break: break-word;border-radius: 4px;overflow-x: auto;background-color: var(--vp-code-bg);color: var(--vp-code-color);font-size: var(--vp-code-font-size);padding: 3px 6px;transition: color 0.25s, background-color 0.5s;><span leaf="">/pretrained_models/FireRedASR-AED-L</span></code><span leaf="">文件夹内</span> </section></li> </ol> <h2 tabindex="-1" style="box-sizing: border-box;margin: 35px 2px 10px 0px;line-height: 1.5;font-size: 24px;font-weight: 700;overflow-wrap: break-word;outline: none;border-top: 1px solid var(--vp-c-divider);padding: 6px 8px 0px 0px;letter-spacing: -0.02em;display: inline-block;background: rgb(239, 112, 96);color: rgb(255, 255, 255);border-top-right-radius: 6px;box-shadow: rgba(239, 112, 96, 0.2) 6px 3px 0px 0px;font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><span leaf=""> API 调用</span></h2> <p style="box-sizing: border-box;margin: 22px 0px;overflow-wrap: break-word;line-height: inherit;color: rgb(51, 51, 51);font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><span leaf="">默认地址: </span><span leaf="">http://127.0.0.1:5078/v1</span></p> <p style="box-sizing: border-box;margin: 22px 0px;overflow-wrap: break-word;line-height: inherit;color: rgb(51, 51, 51);font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><strong style="box-sizing: border-box;font-weight: 600;"><span leaf="">OpenAI SDK中使用</span></strong></p> <p><span style="box-sizing: border-box;top: 2px;right: 8px;z-index: 2;font-size: 12px;font-weight: 500;user-select: none;color: var(--vp-code-lang-color);transition: color 0.4s, opacity 0.4s;"></span></p> <pre tabindex="0" style="white-space:pre-wrap;box-sizing: border-box;font-family: " jetbranins mono, monaco, consolas, courier new, monospace;overflow: auto;line-height: 1.75;box-shadow: rgba(110, 110, 0.45) 0px 8px;border-radius: 4px;margin: 0px;direction: ltr;text-align: left;word-spacing: normal;word-break: normal;overflow-wrap: normal;tab-size: 4;hyphens: none;z-index: 1;padding: 20px 0px;background: rgb(0, 0, 0);color: rgb(255, 255, 255);><code style="white-space:pre-wrap;box-sizing: border-box;font-family: " jetbranins mono, monaco, consolas, courier new, monospace;word-break: normal;border-radius: 2px;overflow-x: auto;background: rgb(0, 0, 0);color: rgb(255, 255, 255);font-size: var(--vp-code-font-size);padding: 0px 24px;margin: 0px;display: block;direction: ltr;text-align: left;word-spacing: normal;overflow-wrap: normal;tab-size: 4;hyphens: none;width: fit-content;min-width: 100%;line-height: var(--vp-code-line-height);transition: color 0.5s;><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span leaf="">from openai import OpenAI</span></span></span><span leaf=""><br></span><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span leaf="">client = OpenAI(api_key='123456',</span></span></span><span leaf=""><br></span><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span leaf=""> base_url='http://127.0.0.1:5078/v1')</span></span></span><span leaf=""><br></span><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"></span></span><span leaf=""><br></span><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span leaf="">audio_file = open("5.wav", "rb")</span></span></span><span leaf=""><br></span><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span leaf="">transcript = client.audio.transcriptions.create(</span></span></span><span leaf=""><br></span><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span leaf=""> model="whisper-1",</span></span></span><span leaf=""><br></span><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span leaf=""> file=audio_file,</span></span></span><span leaf=""><br></span><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span leaf=""> response_format="json",</span></span></span><span leaf=""><br></span><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span leaf=""> timeout=86400</span></span></span><span leaf=""><br></span><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span leaf="">)</span></span></span><span leaf=""><br></span><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"></span></span><span leaf=""><br></span><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span style="box-sizing: border-box;color: var(--shiki-light, inherit);"><span leaf="">print(transcript.text)</span></span></span></code></pre> <p><span style="box-sizing: border-box;"><span leaf=""><br></span></span></p> <h2 tabindex="-1" style="box-sizing: border-box;margin: 35px 2px 10px 0px;line-height: 1.5;font-size: 24px;font-weight: 700;overflow-wrap: break-word;outline: none;border-top: 1px solid var(--vp-c-divider);padding: 6px 8px 0px 0px;letter-spacing: -0.02em;display: inline-block;background: rgb(239, 112, 96);color: rgb(255, 255, 255);border-top-right-radius: 6px;box-shadow: rgba(239, 112, 96, 0.2) 6px 3px 0px 0px;font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><span leaf=""> 在 pyVideoTrans 中使用</span></h2> <p style="box-sizing: border-box;margin: 22px 0px;overflow-wrap: break-word;line-height: inherit;color: rgb(51, 51, 51);font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><span leaf="">如下图在 </span><code style="box-sizing: border-box;font-family: " jetbranins mono, monaco, consolas, courier new, monospace;word-break: break-word;border-radius: 4px;overflow-x: auto;background-color: var(--vp-code-bg);color: var(--vp-code-color);font-size: var(--vp-code-font-size);padding: 3px 6px;transition: color 0.25s, background-color 0.5s;><span leaf="">OpenAI语音识别及兼容API</span></code><span leaf="">中填写,然后在语音识别渠道中选择</span><code style="box-sizing: border-box;font-family: " jetbranins mono, monaco, consolas, courier new, monospace;word-break: break-word;border-radius: 4px;overflow-x: auto;background-color: var(--vp-code-bg);color: var(--vp-code-color);font-size: var(--vp-code-font-size);padding: 3px 6px;transition: color 0.25s, background-color 0.5s;><span leaf="">OpenAI语音识别</span></code></p> <p style="box-sizing: border-box;margin: 22px 0px;overflow-wrap: break-word;line-height: inherit;color: rgb(51, 51, 51);font-family: Inter, ui-sans-serif, system-ui, sans-serif, " apple color emoji, segoe ui symbol, noto emoji;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;><span leaf=""><img src="/upload/2d3aeb128ad4b03a08a3215d3522b4f3.png" alt="ui.png" class="rich_pages wxw-img" data-ratio="0.7241003271537623" data-type="other" data-w="917" style="box-sizing: border-box;display: block;max-width: 100%;height: auto;" data-imgfileid="300323448"></span></p> <section> <span leaf=""><span textstyle="" style="font-weight: bold;"> pyVideoTrans视频翻译软件下载: </span><span textstyle="" style="color: rgb(255, 76, 65);font-weight: bold;">https://pyvideotrans.com</span><span textstyle="" style="font-weight: bold;"> </span></span> </section> <p style="display: none;"> <mp-style-type data-value="3"></mp-style-type></p>
作者:微信小助手
<section style="max-width: 100%;box-sizing: border-box;color: rgb(62, 62, 62);font-size: 16px;white-space: normal;background-color: rgb(255, 255, 255);overflow-wrap: break-word !important;margin-bottom: 0px;"> <section powered-by="xiumi.us" style="max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;"> <section style="max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;"> <section style="padding-right: 10px;padding-left: 10px;max-width: 100%;box-sizing: border-box;line-height: 1.6;word-wrap: break-word !important;"> <section style="max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;"> <section style="max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;"> <section style="padding-right: 30px;padding-left: 30px;max-width: 100%;box-sizing: border-box;line-height: 1.6;word-wrap: break-word !important;"> <section class="mp_profile_iframe_wrp"> <mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-id="Mzg2NzAzMDMwOA==" data-headimg="http://mmbiz.qpic.cn/sz_mmbiz_png/0arf3teEpjCjeKrgtiajadiadeQyY7ia9LBlhQNuGwdHvj5kk4Jm4Cos7ImoCE8lNh4pf2WGuUknxohQicBy7WlmNw/0?wx_fmt=png" data-nickname="烟火的成长" data-alias="" data-signature="记录个人成长,理财,感悟和思考" data-from="0" data-is_biz_ban="0"></mp-common-profile> </section> <p style="max-width: 100%;box-sizing: border-box;min-height: 1em;word-wrap: break-word !important;"><strong style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(136, 136, 136);font-size: 20px;box-sizing: border-box !important;word-wrap: break-word !important;"></span></strong></p> <p style="max-width: 100%;box-sizing: border-box;min-height: 1em;word-wrap: break-word !important;"><strong style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(136, 136, 136);font-size: 20px;box-sizing: border-box !important;word-wrap: break-word !important;">“</span></strong><span style="max-width: 100%;color: rgb(136, 136, 136);box-sizing: border-box !important;word-wrap: break-word !important;"> 向量数据库在召回效率与召回准确率之间,需要做一个业务平衡 <strong style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;font-size: 20px;box-sizing: border-box !important;word-wrap: break-word !important;">”</span></strong></span><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p> </section> </section> </section> <section style="max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;"> <section style="max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;"> <section style="padding-right: 22px;padding-left: 22px;max-width: 100%;box-sizing: border-box;line-height: 1.6;word-wrap: break-word !important;"> <p style="max-width: 100%;box-sizing: border-box;min-height: 1em;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p> <p style="max-width: 100%;box-sizing: border-box;min-height: 1em;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p> </section> </section> </section> <p style="max-width: 100%;box-sizing: border-box;min-height: 1em;word-wrap: break-word !important;">RAG的核心技术点就在于召回数据的准确性,而在相似度搜索过程中,技术载体主要是以向量数据库为主;因此,怎么提升向量数据库的召回准确率就成了一个亟待解决的问题。<span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span></p> <p style="max-width: 100%;box-sizing: border-box;min-height: 1em;word-wrap: break-word !important;"><br></p> <p style="max-width: 100%;box-sizing: border-box;min-height: 1em;word-wrap: break-word !important;">在上一篇关于向量数据库的介绍中说,向量数据库不同于传统关系型数据的一点就是其使用的是向量度量的方式召回数据;而这一点就导致召回的数据在向量层面有关系,但在语义方面可能完全无关。就比如上篇文章中举的例子,在西游记的向量数据库中,搜索林黛玉竟然能搜索到结果。<span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span><span style="display: none;line-height: 0px;"></span></p> <p style="max-width: 100%;box-sizing: border-box;min-height: 1em;word-wrap: break-word !important;"><br></p> <p style="max-width: 100%;box-sizing: border-box;min-height: 1em;word-wrap: break-word !important;">因此,怎么优化向量数据库的召回准确率,这个问题应该怎么解决?<span style="display: none;line-height: 0px;"></span></p> <p style="max-width: 100%;box-sizing: border-box;min-height: 1em;word-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p> </section> </section> </section> </section> <section style="max-width: 100%;box-sizing: border-box;color: rgb(62, 62, 62);font-size: 16px;white-space: normal;background-color: rgb(255, 255, 255);overflow-wrap: break-word !important;margin-bottom: 0px;"> <section powered-by="xiumi.us" style="max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;"> <section style="max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;"> <section style="padding-right: 20px;padding-left: 20px;max-width: 100%;box-sizing: border-box;line-height: 0.8;word-wrap: break-word !important;"> <p style="max-width: 100%;box-sizing: border-box;min-height: 1em;text-align: center;word-wrap: break-word !important;"><br></p> </section> </section> </section> </section> <p style="margin-bottom: 0px;"><br></p> <p style="max-width: 100%;min-height: 1em;color: rgb(62, 62, 62);font-size: 16px;white-space: normal;background-color: rgb(255, 255, 255);box-sizing: border-box !important;overflow-wrap: break-word !important;margin-bottom: 0px;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p> <p style="max-width: 100%;min-height: 1em;color: rgb(62, 62, 62);white-space: normal;background-color: rgb(255, 255, 255);text-align: center;margin-bottom: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="font-size: 20px;">向量数据库的召回准确性问题<span style="display: none;line-height: 0px;"></span></span></p> <p style="max-width: 100%;min-height: 1em;color: rgb(62, 62, 62);font-size: 16px;white-space: normal;background-color: rgb(255, 255, 255);box-sizing: border-box !important;overflow-wrap: break-word !important;margin-bottom: 0px;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p> <p style="max-width: 100%;min-height: 1em;color: rgb(62, 62, 62);font-size: 16px;white-space: normal;background-color: rgb(255, 255, 255);box-sizing: border-box !important;overflow-wrap: break-word !important;margin-bottom: 0px;"><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"></p> <p style="margin-bottom: 0px;"><br></p> <section style="max-width: 100%;box-sizing: border-box;color: rgb(62, 62, 62);font-size: 16px;white-space: normal;background-color: rgb(255, 255, 255);overflow-wrap: break-word !important;margin-bottom: 0px;"> <section powered-by="xiumi.us" style="max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;"> <section style="max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;"> <section style="padding-right: 10px;padding-left: 10px;max-width: 100%;box-sizing: border-box;line-height: 1.6;word-wrap: break-word !important;"> <p style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);">影响向量数据库召回准确率的原因有很多,从单一方面很难甚至可以说根本无法解决这个问题,因此提升向量数据库的准确性就需要从多个方面入手。</p> <p style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);"><br></p> <p style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);">提升向量数据库搜索的准确性可以从以下几个方面进行改进:</p> <p style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);"><br></p> <h3 style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);">1. <strong>提高向量的质量</strong></h3> <ul style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li><p><strong>优化嵌入模型</strong>:使用更高质量的嵌入模型能够生成更准确的向量。例如,可以使用最新的预训练模型(如OpenAI的GPT系列、CLIP、BERT、SimCSE等)来生成语义更准确的向量。</p></li> <li><p><strong>微调模型</strong>:如果可能的话,可以通过在特定领域的数据上对模型进行微调,以使嵌入更符合你的数据特点。</p></li> <li><p><strong>降维和正则化</strong>:在向量数据存储之前,可以考虑对高维向量进行降维(如PCA或t-SNE),同时进行正则化处理,以确保数据分布的均匀性,减少噪声的干扰。</p><p><span style="display: none;line-height: 0px;"></span><mpcpc js_editor_cpcad="" class="js_cpc_area res_iframe cpc_iframe" src="/cgi-bin/readtemplate?t=tmpl/cpc_tmpl#1734878248539" data-category_id_list="1|2|5|6|7|8|16|17|21|24|28|29|31|35|36|37|39|41|42|43|46|47|48|50|51|55|56|57|58|59|60|61|62|63|64|65|66|67|68" data-id="1734878248539"></mpcpc><br></p></li> </ul> <h3 style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);">2. <strong>改进索引结构</strong></h3> <ul style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li><p><strong>选择合适的索引方法</strong>:向量数据库如FAISS、Annoy、HNSW等提供了不同的索引方法。根据数据量、查询的实时性需求以及计算资源,选择合适的索引方法是提升准确性的关键。</p></li> <ul class="list-paddingleft-1" style="list-style-type: square;"> <li><p><strong>FAISS</strong>:适用于大规模的向量搜索,支持多种索引结构,如倒排文件索引(IVF)和量化(PQ)。</p></li> <li><p><strong>HNSW (Hierarchical Navigable Small World)</strong>:适合处理稀疏向量或大规模数据集,通常提供较高的准确性。</p></li> </ul> <li><p><strong>索引的精细化调整</strong>:调整索引的参数(如距离度量方式、候选列表的大小等)有助于提高搜索精度。</p><p><span style="display: none;line-height: 0px;"></span></p></li> <li><p style="text-align: center;"><img class="rich_pages wxw-img" data-galleryid="" data-imgfileid="100002442" data-ratio="0.4703703703703704" data-s="300,640" src="/upload/d66cba9fcadca66a1e11b3532305a0a9.png" data-type="png" data-w="1080" style=""></p></li> </ul> <p><br></p> <h3 style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);">3. <strong>优化距离度量</strong></h3> <ul style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li><p><strong>选择适当的距离度量</strong>:常用的距离度量有欧式距离、余弦相似度、曼哈顿距离等。不同的数据集和应用场景可能需要不同的距离度量。可以通过实验来选择最适合你的应用场景的度量。</p></li> <li><p><strong>距离度量标准化</strong>:确保在计算距离时,输入向量经过适当的标准化(如L2归一化或Z-score标准化),这有助于避免某些特征对距离计算的偏差。</p><p><span style="display: none;line-height: 0px;"></span><br></p></li> </ul> <h3 style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);">4. <strong>改进查询策略</strong></h3> <ul style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li><p><strong>多轮查询优化</strong>:可以通过逐步筛选、分层查询的方式来逐渐精确定位最相关的结果。即在初步检索中返回较多候选项,然后对候选项进行更深入的搜索。</p></li> <li><p><strong>查询重排序</strong>:在初步检索后,使用更精确的排序算法来进一步提高检索结果的相关性。例如,结合传统的排名学习算法(如学习排序,RankNet)或者使用深度学习模型来优化排序。</p><p><span style="display: none;line-height: 0px;"></span></p></li> <li><p style="text-align: center;"><img class="rich_pages wxw-img" data-galleryid="" data-imgfileid="100002443" data-ratio="0.3537037037037037" data-s="300,640" src="/upload/0ce3002d3f8e0c15185460d91b1ac472.png" data-type="png" data-w="1080" style=""></p></li> </ul> <p><br></p> <h3 style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);">5. <strong>数据增强与处理</strong></h3> <ul style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li><p><strong>数据预处理</strong>:确保输入到向量数据库的数据经过有效清洗和规范化。例如,对于文本数据,要去除停用词、进行分词、词干化等处理。</p></li> <li><p><strong>数据增强</strong>:通过引入额外的语义信息或变换来增强数据集,增加训练和嵌入的多样性,减少模型在某些边缘情况上的偏差。</p><p><span style="display: none;line-height: 0px;"></span><br></p></li> </ul> <h3 style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);">6. <strong>通过反馈机制优化</strong></h3> <ul style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li><p><strong>用户反馈学习</strong>:根据用户的点击行为或反馈来不断优化搜索结果。通过机器学习模型调整向量的权重或改进索引结构,使得系统能更准确地反映用户的实际需求。</p></li> <li><p><strong>主动学习</strong>:引入主动学习机制,从少量的标注数据中不断选择最能改进模型的样本进行训练,进一步提高检索的准确性。</p><p><span style="display: none;line-height: 0px;"></span></p></li> </ul> <p style="text-align: center;"><img class="rich_pages wxw-img" data-galleryid="" data-imgfileid="100002444" data-ratio="0.7953703703703704" data-s="300,640" src="/upload/db184e5a6ba4daa6a77d2a3f79ddcb7e.png" data-type="png" data-w="1080" style=""></p> <h3 style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);">7. <strong>多模态融合</strong></h3> <ul style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);" class="list-paddingleft-1"> <li><p>如果你的数据集包括多种类型(如文本、图片、音频等),可以考虑融合不同模态的向量进行检索。比如,使用跨模态的嵌入模型来融合文本和图像的向量,这样可以在查询时实现跨模态检索,提高准确性。</p><p><span style="display: none;line-height: 0px;"></span><br></p></li> </ul> <p style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);">通过上述几种方法的组合应用,你可以逐步提升向量数据库搜索的准确性,满足不同的检索需求。</p> <p style="letter-spacing: normal;text-align: start;white-space: normal;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);"><br></p> </section> </section> </section> </section> <p style="margin-bottom: 0px;"><br></p> <p style="margin-bottom: 0px;"><br></p> <section class="mp_profile_iframe_wrp"> <mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-id="Mzg2NzAzMDMwOA==" data-headimg="http://mmbiz.qpic.cn/sz_mmbiz_png/0arf3teEpjCjeKrgtiajadiadeQyY7ia9LBlhQNuGwdHvj5kk4Jm4Cos7ImoCE8lNh4pf2WGuUknxohQicBy7WlmNw/0?wx_fmt=png" data-nickname="烟火的成长" data-alias="" data-signature="记录个人成长,理财,感悟和思考" data-from="0" data-is_biz_ban="0"></mp-common-profile> </section> <p style="margin-bottom: 0px;"><br></p> <p><br></p> <p style="display: none;"> <mp-style-type data-value="3"></mp-style-type></p>