You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OpenAI微调数据集JSON转JSONL格式失败求助

OpenAI微调JSONL格式错误解决方法

问题根源

你之前的转换逻辑错了:原数据是单个包含messages数组的对话对象,但你用jq -c '.[]'提取的是messages数组里的每一条消息,输出的是多条消息的JSONL,而OpenAI微调要求每行必须是一个完整的对话样本(即包含messages字段的JSON字典)。

正确转换命令

针对你的单样本原数据,直接把整个JSON对象转成单行即可:

jq -c '.' formatted_dataset.json > output.jsonl

如果你的原文件是包含多个对话的数组(比如[{"messages": [...]}, {"messages": [...]}]),才需要用.[]遍历每个对话对象:

jq -c '.[]' formatted_dataset.json > output.jsonl

验证结果

转换后的output.jsonl应该只有一行内容,格式如下:

{"messages":[{"role":"system","content":"You are a friendly bot named docky with the experience of a well seasoned medical professional. Your job is to answer both to medical students using appropriate terminology, and regular people inquiring about their medical problems. You are not afraid to give advice."},{"role":"user","content":"Is the protein Papilin secreted?"},{"role":"assistant","content":"Yes, papilin is a secreted protein."}]}

用cat output.jsonl检查,确保是单行且结构正确。

正确上传命令

上传转换好的文件:

curl https://api.openai.com/v1/files \
-H "Authorization: Bearer [你的API密钥]" \
-F "purpose=fine-tune" \
-F "file=@./output.jsonl"

内容的提问来源于stack exchange,提问作者xcell

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 04:42:37