Datawhale AI冬令营 法律小顾问微调

使用数据集:GitHub - AndrewZhe/lawyer-llama: 中文法律LLaMA (LLaMA for Chinese legel domain)

将数据集上传到讯飞星辰MaaS平台搭建自己的大模型。

如何搭建私有数据集?

首先了解Alpaca格式

再通过code将自己的数据转化为该格式,代码如下:

def extract_dialogues(file_path):
    result = []
    current_act_dialogues = []
    with open(file_path, 'r', encoding='utf-8') as file:
        lines = file.readlines()
        for line in lines:
            line = line.strip()
            if line.startswith("("): # 过滤旁白行
                continue
            if line.startswith("第") and line.endswith("幕"): # 解析新的一幕
                if current_act_dialogues:
                    result.append(current_act_dialogues)
                    current_act_dialogues = []
            elif ":" in line: # 按:切分角色和对话内容
                role, content = line.split(":", 1)
                role = role.strip()
                content = content.strip()
                current_act_dialogues.append({"role": role, "content": content})
        if current_act_dialogues: # 保存最后一幕
            result.append(current_act_dialogues)
    return result

file_path = '甄嬛传剧本11-20.txt'
dialogues = extract_dialogues(file_path)
print(dialogues)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值