Joule Studio 文档接地(Document Grounding)实操:让 Agent 只按你的企业文档回答问题
发布时间:2026/9/18 20:33:38 作者:尧图编辑部 阅读量:1,286
实操:让 Agent 只按你的企业文档回答问题)
素材来源SAP Developers 官方教程《Use Joule Studio, Classic Edition with Document Grounding》原文链接https://developers.sap.com/tutorials/joulestudio-document-grounding贡献者Martin PlummerSAP预计耗时 30 分钟大模型最让人不放心的地方不是它不会说话而是它太会说话——你问它我们公司维修工单能不能部分确认后释放它能给你编出一套听起来极其专业的答案而这套答案跟你们公司制度一毛钱关系都没有。这篇 SAP 官方教程解决的正是这个问题用 Document Grounding 把 Agent 的回答锚定在你自己的文档上。本文按原教程 6 个步骤完整拆解并补充落地时的注意事项。一、这个方案在架构上是怎么搭的先理清组件关系不然后面配 Destination 会配懵Joule Studio (Classic) ├── Destination ──→ SAP AI Core 负责 embedding / 检索 / 编排 └── Destination ──→ S3 Object Store 存你的原始文档 ↓ Control Tower → Document Grounding → resource group ↓ Joule Agent → Tools → Documents引用该 resource group需要两个 Destination一个指向 AI Core一个指向对象存储。原文特别说明这两个 Destination 要在Joule Studio classic subaccount和Joule subaccount里各配一遍所以步骤标题是复数Destinations。前置条件原文列得很清楚Joule Studio, classic editionSAP Build 中已完成前序教程《Use Joule Studio, Classic Edition to Create an Agent》SAP AI Core 一个 S3 Object Store文档已上传到对象存储教程提供了guidelines1.docx、guidelines2.docx两个示例文件关于资源组原文有一句很容易被误读的提醒The entity called resource group here is not the same as a resource group in SAP AI Core, though one will be created there among other things.划重点Document Grounding 里说的 resource group跟 AI Core 里的 resource group 不是同一个东西。配置 grounding 时会在 AI Core 侧自动创建一个所以教程明确说你不需要手动创建任何 resource group 或 pipelineYou do not need to create any resource groups or pipelines. This will be done for you when you configure document grounding.这对没怎么摸过 AI Core 的人来说是个减负——不用去啃 AI Core 的 resource group / pipeline 概念就能把 grounding 跑起来。二、步骤 1-2配两个 DestinationAI Core Destination下载spba-aicore-destination.json教程 GitHub 仓库sap-tutorials/sap-build-process-automation的tutorials/joulestudio-document-grounding/路径下用你自己的 AI Core 实例 key替换文件里的占位符BTP Cockpit → 你的 Joule Studio classic subaccount →Connectivity Destinations→ Create → 导入点Check Connection确认连通在 Joule subaccount 里重复一遍S3 Object Store Destination同样流程下载spba-s3-object-store-destination.json用Object Store 实例的 key替换占位符导入后 Check Connection。原文提示The json file contains placeholders that you will need to replace.Workshop 场景下讲师会预先配好个人实操必须自己改。实操提醒Check Connection 通过不代表 grounding 一定能成功——它只验证网络与凭据。真正的问题比如对象存储桶权限不足、AI Core 配额不够要到步骤 3 才会暴露。三、步骤 3配置 Document Grounding路径Joule Studio classic Lobby → Control Tower → Document Grounding点Add输入名称 →Next选择你的AI Core destination→Next选择你的S3 Object Store destination→Add等 Status 从Pending变成Completed这段原文给了一句非常体贴的话值得单独摘出来You might see the status starting withErrorand perhaps later beforeCompletedis reached. Don’t panic - give it time.状态先报 Error、过一会儿才变 Completed是正常现象。后台要拉起 AI Core 的 resource group、建 pipeline、做文档切片和向量化这一串动作是异步的。遇到 Error 先刷新等几分钟别急着删了重建——重建反而可能产生孤儿资源。这个名称要记牢步骤 4 里选 Documents 工具时要选它。四、步骤 4创建 Agent原文配置照录先说明前提这一步是在前序教程的项目上扩展——You will extend the project that you completed in the previous tutorial.操作Lobby → Versions of your project → Save as New Project→ 命名 → 打开新项目 →Create → Joule Agent。原文刻意不让读者直接改已有 agentYou could enhance your existing validation agent with document grounding later, but here we intentionally keep them distinct — to show how grounding works for learning purposes.Agent 基本信息字段值NameMaintenance Compliance AgentDescriptionHelps users understand, assess, and troubleshoot maintenance policies to ensure correct executionExpertise原文照录Help users understand, assess, and troubleshoot the executability of maintenance orders.Instructions原文照录This agent is trained to support, validate, and guide users through maintenance orders based on the following two internal documents: Component Management Guidelines in Maintenance Orders Business Guidelines for Validating Maintenance Order Executability It behaves like a skilled maintenance planner, applying domain logic and SAP system rules (PM module) to assess: Order status, Operation structure, Component availability, Common data issues, Edge cases requiring human review这段 Instructions 是教科书级的写法值得拆开看明确列出两篇内部文档的名称——让模型知道去哪份资料里找给出角色设定“behaves like a skilled maintenance planner”指明适用的 SAP 模块PM工厂维护枚举评估维度订单状态、工序结构、组件可用性、常见数据问题、需人工复核的边缘情况。这是写 Agent Instructions 的最佳实践不要写你是一个 helpful assistant这种废话要写清楚依据什么文档、扮演什么角色、覆盖哪些场景、什么情况该交给人。挂载 Documents 工具Tools 区域右上角 → Add Tool 下拉 → 选 Documents字段值原文照录NameOrder Validation DocumentsDescriptionInternal guidelines required by the agent to validate and guide users through maintenance orders. It covers component assignment rules, stock validation logic, operational status checks, and exception handling — based on SAP PM best practices.然后选步骤 3 里你创建的 resource group 名称→ Add →Save。五、步骤 5在 Private Environment 里测试Agent 编辑器 → Test→ 选你的 private environment 和前序教程的 destination → Continue。教程给了两个测试问题原文照录Can you give me a short summary of our Maintenance Order Compliance policy, highlighting the main dos and donts?Is it a policy violation to execute or release a maintenance order that is only partially confirmed? Please explain the conditions when this is allowed or not, referencing the policy.第二个问题设计得很刁钻它问的是一个有条件的合规判断部分确认能否释放而不是简单的事实检索。这类问题最能验证 grounding 是否真的生效——如果 Agent 只是泛泛而谈通常不建议说明它没吃到你的文档如果能说出在什么条件下允许、依据哪份指南哪一条才说明 grounding 起作用了。原文对结果波动有明确预期The results can vary from run to run. You might need additional prompts if the LLM does not understand or requires further clarification.最后别忘了一个很有用的调试手段UnderTimeline, expand the nodes and see how Joule processed your request.Timeline 是排查 grounding 问题的第一现场——能看到它到底检索了哪些片段、走了哪些节点。回答不对时先看 Timeline比反复改 prompt 高效得多。六、落地补充我的四点建议文档质量决定上限。Grounding 不是魔法它只是把相关片段塞进上下文。如果源文档本身写得含糊、前后矛盾比如两份指南对同一场景说法不一致Agent 照样会答错。先治理文档再谈 grounding。文档要切片友好。长篇 PDF 直接丢进去效果通常不好。按主题拆成独立小文档、保留清晰的标题层级和小标题检索命中率会明显提升。Instructions 里写明检索不到就承认。教程的示例没写这条但生产环境必须加当文档里没有答案时让 Agent 明确回复内部文档中未找到相关规定而不是自由发挥。区分接地与接系统。Document Grounding 解决的是静态知识制度、规范、手册如果要查实时的工单状态、库存数量那是 Action / MCP 的活儿。很多项目把两者混为一谈结果拿 grounding 去查实时数据必然失败。七、一句话总结这篇教程演示的是 SAP 官方给出的企业知识落地标准路径AI Core算力与编排 S3文档存储 Document Grounding切片向量化 Joule Agent角色与指令 一个只按你公司制度回答问题的助手。三个最容易卡住的地方两个 Destination 要在两个 subaccount 各配一遍、Status 报 Error 别慌先等、resource group 名称要留给 Documents 工具用。参考链接本教程原文https://developers.sap.com/tutorials/joulestudio-document-grounding前序教程Create an Agenthttps://developers.sap.com/tutorials/joulestudio-agent-create.htmlAI Core Orchestration with Groundinghttps://developers.sap.com/tutorials/ai-core-orchestration-grounding.html原理深挖社区博客https://community.sap.com/t5/tooling-sap-build-blog-posts/joule-studio-how-to-create-document-grounding/ba-p/14306631示例文档仓库https://github.com/sap-tutorials/sap-build-process-automation