A Complete Guide to LLM Dataset Formats: From Pre-Training to DPO in JSONL

CK CK 3788 
Created at  
212 0 0

Large language model datasets utilize specific formats depending on the training stage—including single text fields for pre-training next-token prediction, instruction-input-output structures for single-turn fine-tuning, role and content message arrays for multi-turn chat fine-tuning, and prompt-chosen-rejected triplets for Direct Preference Optimization (DPO)—all of which must adhere to strict JSONL dataset creation rules requiring one single-line JSON object per row, properly escaped newlines within text strings, UTF-8 encoding, and a .jsonl file extension.

 

1. Pre-training / Continual Pre-training

For pre-training, the model simply learns to predict the next token from raw text. The standard format uses a single text field.

{"text": "Large language models are trained on massive amounts of text data to understand and generate human language."}
{"text": "Python is a high-level, interpreted programming language known for its readability and versatile libraries."}

 

2. Instruction Fine-Tuning (SFT - Single Turn)

Used to train models to follow specific user instructions. This format usually contains instruction, input (optional context), and output.

{"instruction": "Translate the following English text to French.", "input": "Hello, how are you today?", "output": "Bonjour, comment allez-vous aujourd'hui ?"}
{"instruction": "Summarize the benefits of drinking water.", "input": "", "output": "Drinking water maintains hydration, improves digestion, supports kidney function, and boosts skin health."}

 

3. Multi-turn Chat Fine-Tuning (OpenAI / Hugging Face Format)

This is the standard format used by OpenAI, Hugging Face trl, and modern open-source fine-tuning frameworks (like LLaMA-Factory). It structures data as a conversation array of messages with role and content.

{"messages": [{"role": "system", "content": "You are a helpful and polite customer service assistant."}, {"role": "user", "content": "Where is my order #12345?"}, {"role": "assistant", "content": "Let me check that for you. Your order #12345 is currently in transit and expected to arrive tomorrow."}]}
{"messages": [{"role": "user", "content": "What is the capital of South Korea?"}, {"role": "assistant", "content": "The capital of South Korea is Seoul."}, {"role": "user", "content": "What is its population?"}, {"role": "assistant", "content": "As of recent estimates, the population of Seoul is approximately 9.5 million people."}]}

 

4. Direct Preference Optimization (DPO / RLHF)

Used to align model outputs with human preferences. Each line contains a prompt, a preferred response (chosen), and a dispreferred response (rejected).

{"prompt": "Explain quantum computing in one sentence.", "chosen": "Quantum computing is a type of computation that uses quantum mechanics principles, such as superposition and entanglement, to solve complex problems much faster than classical computers.", "rejected": "It is a super fast computer that uses quantum physics to do cool stuff."}
{"prompt": "Write a short Haiku about winter.", "chosen": "Cold wind softly blows,\nSilent snow falls from the sky,\nEarth lies fast asleep.", "rejected": "Winter is very cold and white.\nSnow is everywhere outside.\nI like warm cocoa."}

 

Key Rules for Creating JSONL Datasets

  • One JSON per Line: Do not pretty-print (indent) the JSON. The entire object must fit on a single line.
  • Handle Newlines in Text: If your text contains line breaks (e.g., code or paragraphs), escape them as \n inside the string instead of pressing Enter.
  • Encoding: Always save the file using UTF-8 encoding to support multiple languages and special characters.
  • File Extension: Save the file with the .jsonl or .jsonlines extension.
Tags AI Data Preparation DPO Dataset Format Direct Preference Optimization Instruction Fine Tuning JSONL File Format LLM Dataset Formats LLM Training Machine Learning Datasets Multi Turn Chat Pre Training Data SFT Supervised Fine Tuning Facebook X
Comments 0
Similar posts
  1. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    339
  1. Building my own ChatGPT based on SageMaker and Milvus that is specialized to Shopping Mall
    269
  2. Your Blueprint for an LLM & Vector DB Insurance Product Q&A
    263
  3. The Core of Vector Databases: Embeddings and LLM Dependency
    260
  4. Original Purpose of Markdown File - why Engineers love it?
    767
  5. Switch to using Claude Sonnet 4 (Claude-4-sonnet) in the Amazon Q Developer CLI
    642
  6. Amazon Q CLI for Debugging - What You Can Do
    441
  7. Vibe coding with Amazon Q in CLI combined with Claud AI Sonet 4
    471
  8. How do you create AI-based commit message with scope and action in Cursor AI?
    804
  9. Learn SLM if you have interent in the next after LLM
    4861
  10. VLM vs. LLM: How Vision-Language Models Are Revolutionizing Real-Time Media Processing
    39
  11. Why Reranking is Crucial for RAG and Agentic AI Systems?
    269
  12. Technical Hierarchy of AI Agents
    817
  13. MCP vs A2A
    600
  14. Vulnerabilities of MCP
    589
  15. The Revenge of the Junior Developer
    2,294
  16. Comparison of ChatGPT, Gemini, and Grok
    561
  17. MLOps Explained: Spark, Flink, and Reference Architecture Deep Dive
    244
  18. AI-based Image Creation based on Bing Image Creator
    987
  19. ChatGPT App (flowGPT) to create images with text
    1,037
  20. TikTok's Recommendation System - Monolith
    295
  21. Things to Know for AI-driven, Multimodal Content Personalization.
    201
  22. Deep Dive into Vector Databases: Understanding Collections (Not Tables) and Embeddings
    235
  23. Image Embeddings for Vector Databases
    249
  24. Vector Databases: From Embeddings to Application
    317
  25. Scaling Vector Search: How to Architect FAISS on AWS EKS and ECS
    164
  26. Reinforcement Learning–Based Methods for CTR Improvement based on Recommendation System
    266
  27. YouTube's Recommendation System
    264
  28. Wide & Deep / DeepFM for Recommendation Service (aka Ranking Service)
    255
  29. Two-Tower Model for Recommendation Service having a Very Large Catalog
    266
  30. Sequence Models (RNN / Transformer) for Recommendation Service widely used at OTT and e-Commerce
    249
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    42
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    36
  3. How do I create animated background for Google Meet?
    21,007
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    251
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    94
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    157
  7. Array of arguments passed to script in PHP
    90
  8. Invalid Auction Storms in Ad Tech
    98
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    202
  10. The Two Clocks of Ad Server Architecture
    70
  11. Frequency Cap Architecture Overview
    515
  12. Collecting Proof-of-Play from 100,000 Screens
    146
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    288
  14. What is RedisVL?
    109
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    231
  16. TPU & GPU Cluster Management Tools
    245
  17. The Concept of Scaffolding in AI Agents
    234
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    583
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    259
  20. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    202
  21. Machine Learning: Training vs. Ranking
    222
  22. The Continuous Learning Machine: Designing a Loop That Actually Turns
    222
  23. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    195
  24. Designing a Data Curation System Around a Vector Database
    221
  25. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    256
  26. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    656
  27. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    196
  28. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    219
  29. Understanding Data Lineage
    262
  30. System Requirements and Architecture: Intelligent Priority-Based Scheduler
    167