使用 LLM 辅助理解业务知识

要使用 LLM 辅助理解业务知识并生成相应的模型和任务,可以通过以下详细步骤和示例进行操作。这里的步骤包括如何编写有效的 prompt 模板,如何处理领域模型、用户故事和验收场景,并生成样例数据。

1. 领域模型(Domain Model)

领域模型是对业务实体及其关系的结构化描述。它帮助我们理解系统的基本组成部分及其交互方式。

示例领域模型模板
1
*
*
*
1
*
Customer
+customerId: string
+name: string
Order
+orderId: string
+orderDate: date
Product
+productId: string
+price: float
Category
+categoryId: string
+categoryName: string

在这个示例中:

  • Customer 类包含客户信息。
  • Order 类记录订单详情。
  • Product 类描述产品。
  • Category 类表示产品的类别。
  • 关系线表示不同类之间的联系。

2. 用户故事(User Story)

用户故事是对用户需求的简短描述,帮助我们理解用户希望系统做什么。

示例用户故事模板
作为一个 [用户角色],我想要 [功能],以便 [目的]。
示例用户故事
作为一个电商平台的顾客,我想要查看我的订单历史记录,以便我可以跟踪我的购物情况。

3. 验收场景(Acceptance Criteria)

验收场景定义了系统应满足的具体条件或功能,以确保用户故事的实现符合预期。

示例验收场景模板
场景:用户查看订单历史记录

给定 [初始条件]
当 [事件发生]
那么 [期望结果]
示例验收场景
场景:用户查看订单历史记录

给定 用户已经登录到系统,并且有一个订单记录
当 用户访问“我的订单”页面
那么 系统应显示用户所有的订单记录,包括订单号、日期和总金额

4. 任务(Tasks)

任务是将验收场景中的条件转化为具体的操作步骤。

示例任务模板
tasks:
  - task: Understand the user story based on the domain model
  - task: Generate sample data for the given acceptance criteria
示例 YAML 数据
tasks:
  - task: Understand the user story based on the domain model
    description: Using the provided domain model, interpret the user story and determine what data needs to be generated to satisfy the acceptance criteria.
  - task: Generate sample data for the given acceptance criteria
    description: Create sample data in YAML format that fulfills the conditions described in the acceptance criteria.

5. 生成 Prompt

在实际使用 LLM 时,您可以将上述模板整合到一个 prompt 中,以帮助模型理解业务上下文并生成所需的输出。以下是一个完整的 prompt 示例:

示例 Prompt
领域模型
======
classDiagram
    class Customer {
        +customerId: string
        +name: string
    }
    class Order {
        +orderId: string
        +orderDate: date
    }
    class Product {
        +productId: string
        +price: float
    }
    class Category {
        +categoryId: string
        +categoryName: string
    }
    
    Customer "1" -- "*" Order
    Order "*" -- "*" Product
    Product "1" -- "*" Category

用户故事
======
作为一个电商平台的顾客,我想要查看我的订单历史记录,以便我可以跟踪我的购物情况。

验收场景
======
场景:用户查看订单历史记录

给定 用户已经登录到系统,并且有一个订单记录
当 用户访问“我的订单”页面
那么 系统应显示用户所有的订单记录,包括订单号、日期和总金额

任务
===
数据都以yaml格式给出。
首先,请根据领域模型理解用户故事中的场景,并针对验收场景中Given的部分,给出样例数据。

6. 分解 Prompt

步骤 1: 理解领域模型

LLM 应根据领域模型中的实体和关系理解用户故事中的场景。例如,在上面的领域模型中,LLM 需要了解 CustomerOrder 之间的关系。

步骤 2: 理解用户故事

LLM 应解析用户故事,以确定用户需求。例如,用户希望查看订单历史记录,LLM 需要知道如何从系统中提取相关的订单信息。

步骤 3: 生成样例数据

LLM 应根据验收场景中的 Given 部分生成样例数据。这些数据应模拟实际使用场景,以验证系统功能是否符合要求。

示例输出
sample_data:
  customers:
    - customerId: "C001"
      name: "Alice"
  orders:
    - orderId: "O001"
      orderDate: "2024-08-31"
      totalAmount: 100.00
      customerId: "C001"
  products:
    - productId: "P001"
      price: 50.00
      categoryId: "Cat01"
  categories:
    - categoryId: "Cat01"
      categoryName: "Electronics"

总结

通过上述步骤和模板,您可以有效地利用 LLM 辅助理解业务知识。使用领域模型描述业务实体,利用用户故事定义需求,并通过验收场景和任务生成样例数据。结合 Mermaid 图表和自然语言描述,能够为 LLM 提供清晰的上下文,从而帮助它生成符合业务需求的结果。

  • 15
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值