开始使用免费开始使用

创建训练样本

作为团队正在构建的客服聊天机器人的一部分,您需要创建一条预处理数据集的流水线。该数据集将用于微调语言模型,使其能够预测客户问题的意图,并将请求路由到正确的团队处理。

您拿到的数据集中,客户的问题与意图分别位于不同的列。您希望对数据集进行预处理,将每个包含问题与意图的示例合并为一条使用您格式化提示词的单个字符串。

数据集已加载到 dataset 中。该数据集包含 instruction 列(客户问题)和 intent 列(用户意图)。

本练习是课程的一部分

使用 Llama 3 进行微调

查看课程

练习说明

  • "Query: {instruction}\nIntent: {intent}" 的形式,用 instruction 与 intent 创建一条提示词字符串。
  • 在函数调用中填入数据集,将 create_intent_example 应用于每一行。
  • 提取并打印数据集首行中 intent_example 列的值。

交互式实操练习

通过完成这段示例代码来试试这个练习。

def create_intent_example(row):
    # Fill out the columns in the prompt
    row['intent_example'] = ____
    return row

# Call the ds method to apply our preprocessing function to all rows
processed_dataset = dataset.____(____)
# Print the intent_example in the first row of the processed data
print(processed_dataset[____][____])
编辑并运行代码