C.W.K.
Stream
Lesson 02 of 05 · published

데이터 포맷: JSONL, OpenAI, Alpaca, ShareGPT

~22 min · jsonl, openai-format, alpaca, sharegpt

Level 0관찰자
0 XP0/43 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

JSONL이 이긴 이유

거의 모든 파인튜닝 파이프라인은 JSONL(JSON Lines) 써: 한 줄에 JSON 객체 하나. 이긴 이유 — (1) 스트리밍 가능, (2) 나머지 안 파싱하고 한 줄만 검증 가능, (3) 나쁜 줄이 파일 전체 망치지 않음, (4) 현대 데이터셋 도구 다 네이티브 지원.

OpenAI chat 포맷 (사실상 표준)

OpenAI managed 파인튜닝이 요구하는 거고, TRL의 SFTTrainer가 자동 감지하는 거고, 현대 오픈소스 도구 대부분이 기본값으로 쓰는 거. 한 줄당 messages 배열을 갖는 예제 하나.

Alpaca 포맷

오래됐지만 많은 오픈 데이터셋에 여전히 보여. 한 줄: {instruction, input, output}. 인테이크 시 chat 포맷으로 변환 쉬워.

ShareGPT 포맷

멀티턴 대화용. 한 줄에 {from, value} 항목 가진 conversations 배열. Axolotl 시대 데이터셋에 흔해.

포맷 섞는 건 함정

인테이크 시점에 포맷 하나 정하고 나머지 다 변환해. 한 학습 런 안에서 포맷 섞는 게 1주차 파인튜닝 프로젝트에서 "모델이 헛소리 출력함"의 1번 원인.

Code

OpenAI chat format (one example per JSONL line)·json
{"messages": [
  {"role": "system", "content": "You are a medical assistant. Be concise."},
  {"role": "user", "content": "What are common symptoms of type 2 diabetes?"},
  {"role": "assistant", "content": "Increased thirst, frequent urination, increased hunger, fatigue, blurred vision, slow-healing sores, frequent infections."}
]}
Alpaca format·json
{"instruction": "Summarize the key findings.", "input": "Patient presents with elevated BP (160/95)...", "output": "Stage 2 hypertension; recommend ambulatory BP monitoring."}
ShareGPT format·json
{"conversations": [
  {"from": "system", "value": "You are a coding assistant."},
  {"from": "human", "value": "How do I read a CSV in Python?"},
  {"from": "gpt", "value": "Use pandas:\n\nimport pandas as pd\ndf = pd.read_csv('data.csv')"}
]}

External links

Exercise

ShareGPT 포맷 데이터셋 가져와(Hub에서 'sharegpt' 검색 — 5분이면 찾아). 20줄짜리 Python 스크립트로 OpenAI chat 포맷으로 변환. 변환된 파일이 모든 줄에서 'last message is assistant' 체크 통과하는지 검증.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.