当前位置: 首页 > news >正文

【火山引擎 大模型批量推理数据教程---详细讲解一篇过!】

0. 相关的文档

!!先注册火山引擎账号第一步!!

  • 批量推理文档网页
  • 对象存储网页
  • 提交批量处理网页
  • 费用接口网页

1. 准备jsonl数据集

  • 官网地址
  • 样例,需要根据你自己的数据进行需改
import json## 你的数据,自行处理成
data = []## 必须是list[dict]结构,
huoshan_data_jsonl = [{"custom_id": f"uuid-xxxx", # 必须唯一"body": {"messages": [{"role": "system", "content": "你的系统提示词"},{"role": "user","content": "你的文本内容",},],"temperature": 0.0,# 其他参数},}for d in data
]
huoshan_data_jsonl = sum(huoshan_data_jsonl, [])with open("hs_data.jsonl", "w", encoding="utf-8") as f:for d in huoshan_data_jsonl:f.write(json.dumps(d, ensure_ascii=False) + "\n")len(huoshan_data_jsonl), huoshan_data_jsonl[0]
  • 检查数据是否符合规定
import jsondef check_jsonl_file(file_path):with open(file_path, "r", encoding="utf-8") as file:total = 0custom_id_set = set()for line in file:if line.strip() == "":continuetry:line_dict = json.loads(line)except json.decoder.JSONDecodeError:raise Exception(f"批量推理输入文件格式错误,第{total + 1}行非json数据")if not line_dict.get("custom_id"):raise Exception(f"批量推理输入文件格式错误,第{total + 1}行custom_id不存在")if not isinstance(line_dict.get("custom_id"), str):raise Exception(f"批量推理输入文件格式错误, 第{total + 1}行custom_id不是string")if line_dict.get("custom_id") in custom_id_set:raise Exception(f"批量推理输入文件格式错误,custom_id={line_dict.get('custom_id', '')}存在重复")else:custom_id_set.add(line_dict.get("custom_id"))if not isinstance(line_dict.get("body", ""), dict):raise Exception(f"批量推理输入文件格式错误,custom_id={line_dict.get('custom_id', '')}的body非json字符串")total += 1return totalfile_path = "hs_data.jsonl"
total_lines = check_jsonl_file(file_path)
print(f"文件中有效JSON数据的行数为: {total_lines}")

2. 创建桶 【必须,存储数据】

  • 官网地址
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

3. 开始批量处理

  • 官网地址
    在这里插入图片描述
    在这里插入图片描述

4. 最后【一定看!】

官网地址

  • 处理完后,及时下载结果,然后删除创建的桶,是收费的!!
  • 处理完后,及时下载结果,然后删除创建的桶,是收费的!!
  • 处理完后,及时下载结果,然后删除创建的桶,是收费的!!

之所以用火山,处理速度还是很快的!

相关文章:

  • 文言文停词库 | 古文停词库 | 624个简体停词 |文言文python分词库-thulac
  • OS10.【Linux】yum命令
  • PCB制作入门
  • 财管-0-战略和战略管理
  • 最大子数组和问题详解
  • nc 命令示例
  • Python训练第四十一天
  • LeRobot ACT——LeRobot对ALOHA ACT策略的封装:含源码解析与真机部署(效果比肩ACT原论文)
  • 上位机知识篇---直接无线数据通信
  • Broker、Proxy、Agent的区别
  • 哈尔滨工业大学提出ADSUNet—红外暗弱小目标邻帧检测新框架
  • Parametric Retrieval Augmented Generation
  • 每日八股文6.1
  • 6v6-导航收录:2025年网站自动引流终极方案 - 提升SEO排名新策略
  • win11回收站中出现:查看回收站中是否有以下项: WPS云盘回收站
  • springboot-响应接收与ioc容器控制反转、Di依赖注入
  • Cursor 中三个选项 Agent 、 Ask 和 Manual 含义
  • 2025年家用电梯品牌推荐榜单:聚焦品质与创新,探寻理想垂直出行方案
  • 【js逆向】信息公示平台搜索滑块逆向
  • C++: STL简介与string类核心技术解析及其模拟实现
  • 苏州建站模板搭建/seo是什么及作用
  • 鹤壁哪有做网站的/免费网站制作
  • 做百度网站需不需要备案吗/长春网站建设平台
  • wordpress做淘客网站/友情链接交换方式有哪些
  • 网站架构设计师简历/知识营销
  • 做网站css/东莞seo优化团队