3.3 Fine-Tuning & Continued Pre-Training Data Pipeline Engineering

Key Takeaways

  • Model customization on Amazon Bedrock consists of Fine-Tuning for supervised task specialization and formatting, and Continued Pre-Training for instilling deep, unlabeled domain knowledge.
  • Fine-tuning requires JSON Lines (JSONL) datasets containing prompt-completion pairs or conversational message arrays, whereas continued pre-training requires raw, unlabeled text chunks formatted in single-key input JSONL records.
  • Data pipeline engineering requires rigorous deduplication (MinHash/LSH), unicode character normalization, and token-length truncation aligned with the target base model's context window limit.
  • Customization jobs are executed via the Bedrock CreateModelCustomizationJob API or AWS Management Console, requiring S3 storage, IAM assume-role policies, and hyperparameter tuning for epochs, batch size, and learning rate multiplier.
  • In-flight training and validation loss curves in Amazon CloudWatch diagnose underfitting, overfitting, and catastrophic forgetting; customized models on Bedrock require Provisioned Throughput for inference hosting.
Last updated: September 2026

3.3 Fine-Tuning & Continued Pre-Training Data Pipeline Engineering

While prompt engineering and Retrieval-Augmented Generation (RAG) address the vast majority of enterprise generative AI use cases, certain production requirements necessitate modifying the underlying neural weights of a foundation model (FM). Amazon Bedrock provides managed model customization capabilities, supporting both Fine-Tuning and Continued Pre-Training. Achieving high-performance model customization depends overwhelmingly on the engineering rigor of the upstream data pipeline: formatting, tokenization boundaries, deduplication, and hyperparameter calibration.


Customization Strategies: Fine-Tuning vs. Continued Pre-Training

Understanding when to apply fine-tuning versus continued pre-training is a fundamental competency for AWS generative AI developers:

┌─────────────────────────────────────────────────────────────────────────────┐
│                      THE MODEL CUSTOMIZATION SPECTRUM                       │
├───────────────────────────────┬─────────────────────────────────────────────┤
│ CONTINUED PRE-TRAINING        │ FINE-TUNING (Instruction / Supervised)      │
├───────────────────────────────┼─────────────────────────────────────────────┤
│ • Unsupervised learning       │ • Supervised learning                       │
│ • Unlabeled proprietary text  │ • Labeled prompt-completion pairs           │
│ • Teaches domain vocabulary & │ • Teaches task behavior, tone, style,       │
│   foundational knowledge      │   and strict output formatting (JSON/XML)   │
│ • Examples: 50,000 internal   │ • Examples: 2,000 prompt-response pairs     │
│   clinical trial reports,     │   extracting medical records into a         │
│   oil exploration logs        │   strict JSON schema without chat filler    │
└───────────────────────────────┴─────────────────────────────────────────────┘
  • Continued Pre-Training: Applied when a base model lacks exposure to a specialized domain vocabulary (such as internal semiconductor physics, obscure legal statutes, or proprietary programming languages). It processes vast volumes of unstructured, raw text using next-token prediction, shifting the base model's probability distribution to encompass the new domain.
  • Fine-Tuning (Instruction Tuning / Task Adaptation): Applied when a model already understands the language of the domain but must consistently follow specialized instructions, match an exact organizational persona, or reliably generate structured syntax (such as valid JSON, YAML, or Cypher graph queries) without conversational preambles.

Dataset Schemas and Formatting Requirements

Amazon Bedrock requires all training and validation datasets to be staged in Amazon S3 as JSON Lines (.jsonl) files. In a JSONL file, each line must represent a complete, valid JSON object terminated by a newline character (\n). Multi-line JSON objects or trailing commas across lines will cause immediate validation failure.

1. Fine-Tuning Format: Prompt-Completion Pairs

For text generation and instruction-following models (e.g., Amazon Titan Text Lite/Express, Cohere Command Light), training data is organized as input-output pairs:

{"prompt": "Extract patient diagnosis and prescribed medication:\n'Patient presents with persistent acute sinusitis. Prescribing amoxicillin-clavulanate 875mg twice daily for 10 days.'", "completion": "{\"diagnosis\": \"acute sinusitis\", \"medication\": \"amoxicillin-clavulanate\", \"dosage\": \"875mg\", \"frequency\": \"BID\", \"duration_days\": 10}"}
{"prompt": "Extract patient diagnosis and prescribed medication:\n'Follow-up visit confirms mild hypertension. Initiating lisinopril 10mg once daily.'", "completion": "{\"diagnosis\": \"hypertension\", \"medication\": \"lisinopril\", \"dosage\": \"10mg\", \"frequency\": \"QD\", \"duration_days\": null}"}

2. Fine-Tuning Format: Conversational Message Turns

For chat-optimized models (such as Meta Llama 3 or fine-tunable conversational variants), Bedrock supports multi-turn message arrays adhering to the role-based conversational structure:

{"messages": [{"role": "system", "content": "You are an enterprise compliance auditor. Output findings strictly in YAML format."}, {"role": "user", "content": "Audit access request: Engineer Bob granted root access to Prod-DB on 2026-09-01 without ticket ID."}, {"role": "assistant", "content": "status: NON_COMPLIANT\nseverity: CRITICAL\nreason: Missing change management ticket for privileged access\nremediation: Revoke root access immediately and file retrospective audit ticket."}]}

3. Continued Pre-Training Format: Raw Text Ingestion

Continued pre-training does not use prompt-completion pairs. Instead, it expects unstructured documents packaged into single-key JSON records with the key "input":

{"input": "The turbofan bypass ratio (BPR) of the GE9X engine is approximately 10:1. The composite fan blades utilize carbon-fiber reinforcement with titanium leading-edge protective sheaths. During transonic cruise conditions, boundary layer ingestion (BLI) dynamics dictate that inlet pressure recovery must remain above 0.985 to avoid compressor stall..."}
{"input": "Subsea umbilical termination assemblies (SUTAs) provide hydraulic and electrical power conduits to subsea trees. High-pressure fluid conduits must withstand hydrostatic pressures exceeding 450 bar at depths greater than 3,000 meters..."}

Feasibility gate before training

Run a small data audit before allocating training compute. Sample records from every source, measure duplicates and missing labels, inspect rights and consent, and compare label agreement among reviewers. Establish a prompt or RAG baseline on the held-out set. If the baseline already meets the acceptance threshold, customization adds cost and lifecycle risk without demonstrated value.

Release evidence and reproducibility

Treat the dataset manifest as part of the model release. Record source snapshot identifiers, consent and license status, transformation code version, schema, accepted and quarantined counts, deduplication rule, split method, model customization configuration, and KMS or role dependencies. Re-running a job against a mutable S3 prefix does not reproduce the original model. Use immutable release prefixes or versioned object manifests and retain hashes for approved files.

Before submitting the full job, validate a small sample through the exact serializer and selected model schema. After training, evaluate an untouched holdout plus safety, privacy, and general-capability regressions. A lower training loss is not a release decision. Promotion requires the predefined task, safety, latency, cost, and operational thresholds, with rollback to the prior complete configuration.

Loading diagram...
Model Customization Data Pipeline and Training Lifecycle on AWS
Test Your Knowledge

A machine learning developer is preparing datasets for two separate model customization tasks on Amazon Bedrock: (Task 1) fine-tuning Amazon Titan Text to generate deterministic JSON outputs from customer support transcripts, and (Task 2) continued pre-training of a base foundation model on 100,000 internal engineering technical specifications. Which file formats and schemas are strictly required for these two jobs?

A
B
C
D