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

【火山引擎 大模型批量处理数据教程-详细】

相关的文档

!!先注册账号第一步!!

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

1. 准备jsonl数据集

  • 官网网页地址
  • 样例,需要根据你自己的数据进行需改
import jsonsystem_prompt = """
你的任务是根据用户提供的药品名称,规格参数以及治疗的疾病名称,返回该药品的使用方式、使用频次、使用量!认真、仔细阅读以下任务信息,保质保量完成任务!## 返回示例
1. 必须按此药品的规格配置做计量的基本单位
2. 如果可能用片、粒等基本单位,则必须使用
3. 如果只有ul、ml等液体类型的剂量,则用对应的剂量- 例子1
口服,1日1次,1次3粒- 例子2
皮下注射,1日1次,1次30IU## 返回格式
<使用方式>,<使用频次>,<使用量>!必须是返回上述格式,否则会解析出错
""".strip()huoshan_data_jsonl = [[{"custom_id": f"{cid}-{idx}", # 必须唯一"body": {"messages": [{"role": "system", "content": system_prompt},{"role": "user","content": f"药品名称:{d[0]}\n规格:{d[1]}/{d[2]}\n疾病名称:{di}",},],"temperature": 0.0,},}for idx, di in enumerate(d[3:])]for d, cid in zip(data, ruuid_gen())
]
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/10366.html

相关文章:

  • 基于千帆大模型的AI体检报告解读系统实战:使用OSS与PDFBox实现PDF内容识别
  • WEBSTORM前端 —— 第3章:移动 Web —— 第3节:移动适配
  • Rust 学习笔记:发布一个 crate 到 crates.io
  • Python 序列的修改、散列和切 片(Vector类第5版:格式化)
  • qwen3解读
  • Java BigInteger类详解与应用
  • C语言之编译器集合
  • 蓝桥杯java2021年十二届国赛大学A组真题答案整理
  • 基于Sqoop的MySQL-Hive全量/增量同步解决方案(支持多表批量处理
  • 设计模式——单例设计模式(创建型)
  • 131. 分割回文串-两种回溯思路
  • C++手撕 shared_ptr
  • Paimon 建表常用属性分析
  • simulink mask的使用技巧
  • Windows下编译zlib
  • LangGraph 快速入门
  • Ubuntu设置之初始化
  • 利用Dify创建一个公司产品知识问答
  • DeepSeek部署实战:常见问题与高效解决方案全解析
  • 【Java基础05】面向对象01
  • leetcode动态规划—买卖股票系列
  • Python案例解析 : 函数模块化编程的实践应用
  • CTFHub-RCE 命令注入-过滤目录分隔符
  • 解决8080端口被占问题
  • python学习day34
  • 学习海康VisionMaster之表面缺陷滤波
  • Cesium快速入门到精通系列教程
  • 【KWDB 创作者计划】_探秘浪潮KWDB数据库:从时间索引到前沿技术
  • 用户认证的魔法配方:从模型设计到密码安全的奇幻之旅
  • ApiHug 1.3.9 支持 Spring 3.5.0 + Plugin 0.7.4 内置小插件升级!儿童节快乐!!!