当前位置: 首页 > 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. 最后【一定看!】

官网地址

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

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

http://www.xdnf.cn/news/763417.html

相关文章:

  • 哈希:闭散列的开放定址法
  • #14 【Kaggle】 Drawing with LLMs 金牌方案赏析
  • 简析PointNet++
  • leetcode0404. 左叶子之和-easy
  • 对选择基于模型编程(MBD)的工作对职业发展影响的讨论 (2025)
  • 【Bluedroid】蓝牙启动之 l2c_init 源码解析
  • 字符函数和字符串函数(1)
  • 上位机知识篇---直接无线数据通信
  • 线程与进程
  • 【Dv3Admin】系统视图用户管理API文件解析
  • Redis 架构设计
  • Kali Linux从入门到实战:系统详解与工具指南
  • Fréchet Inception Distance(FID)
  • ubuntu系统更换镜像源
  • [GESP202412 五级] 奇妙数字
  • java 多线程中的volatile关键字作用
  • 【JavaScript-Day 28】告别繁琐循环:`forEach`, `map`, `filter` 数组遍历三剑客详解
  • c++之循环
  • java CountDownLatch‌
  • 题海拾贝:压缩字符串
  • 详解鸿蒙开发如何上传三方库到ohpm仓库
  • 【Dv3Admin】系统视图系统配置API文件解析
  • 017搜索之深度优先DFS——算法备赛
  • java ExecutorService线程池使用(ExecutorService/Completable异步+ExecutorService线程池)
  • Office安装包2024版
  • ck-editor5的研究 (4):初步使用 CKEditor5 的插件功能
  • 72.编辑用户消息功能之前端实现
  • PCB制作入门
  • 开始通信之旅-----话题通信
  • 关于 java:4. 异常处理与调试