LLM Lifecycle: Pre-Training, Post-Training (RLHF, RLVR, RLCD) & Jev Decision Models
Modern Artificial Intelligence has evolved beyond monolithic, autoregressive text generators. While early Large Language Models (LLMs) operated strictly as next-token predictors, production enterprise systems now rely on a multi-stage training pipeline (Pre-training SFT RL Post-training) combined with specialized System 1 decision engines (such as Jev by TypeSafe AI) that do not generate text at all.
This guide provides a comprehensive architectural deep-dive into the training mechanics, mathematical foundations, alignment paradigms (RLHF, RLVR, RLCD), and the emerging hybrid architectures pairing fast decision models with deep reasoning LLMs.
1. The End-to-End LLM Lifecycle
The creation and alignment of a modern frontier model spans three distinct physical phases:
Predicts the next token over trillions of tokens of web crawls, code repositories, books, and scientific papers. Establishes broad general knowledge and linguistic reasoning foundations.
3. Phase 1: Pre-Training Fundamentals
Pre-training transforms uninitialized neural network weights into a general-purpose knowledge base by predicting the next token over trillions of tokens of web scrapes (Common Crawl), source code, books, and scientific papers.
3.1 Loss Formulation: Causal Language Modeling (CLM)
For a token sequence , the training objective maximizes the log-likelihood:
The model computes a softmax distribution over vocabulary (typically 32,000 to 128,000 tokens):
3.2 Compute Scaling Laws (Chinchilla)
Hoffmann et al. (DeepMind Chinchilla) demonstrated that model parameter count and training dataset size should scale in equal proportion:
- Training a 70B parameter model compute-optimally requires tokens.
- Modern foundation models (e.g. LLaMA 3 70B/405B) intentionally over-train by up to tokens to minimize downstream inference serving costs.
3.3 Hardware Memory Bounds: The Memory Wall
Training a modern 70Bβ405B model exceeds single-GPU High Bandwidth Memory (HBM3e). With 16-bit mixed precision (BF16):
- Model Weights: (140 GB for 70B).
- Gradients: (140 GB).
- Adam Optimizer States: FP32 master weights (), first momentum (), second momentum () = (840 GB).
- Total Static State: ( for 70B model before KV-cache and activation memory).
To distribute this compute, clusters utilize 3D Parallelism (Megatron-LM Tensor Parallelism across NVLink, Pipeline Parallelism across InfiniBand, and ZeRO-3 Data Parallelism).
4. Phase 2: Supervised Fine-Tuning (SFT)
A pre-trained base model is merely a statistical completion engine: given the prompt "Write a Python script to sort an array", it may simply complete the prompt with more interview questions.
Supervised Fine-Tuning (SFT) uses curated question-answer pairs to teach the model instruction adherence:
The Loss Masking Invariant
The cross-entropy loss is strictly masked out on the prompt tokens . Gradients are backpropagated only through assistant completion tokens . Backpropagating gradients through user prompt tokens degrades the model's pre-trained distribution.
The Limits of SFT
While SFT establishes formatting and tone, it cannot teach complex, multi-step problem solving. SFT suffers from:
- Teacher Forcing Distribution Shift: During training, the ground truth prefix is always fed. During inference, errors compound autoregressively.
- Superficial Imitation: The model mimics human writing style without validating mathematical or logical veracity.
5. Phase 3: Post-Training Reinforcement Learning (RL)
Reinforcement Learning frames text generation as a Markov Decision Process (MDP):
- State : The prompt concatenated with all generated tokens .
- Action : The next token sampled from policy .
- Transition: Deterministic string concatenation: .
- Reward : Scalar evaluation assigned upon reaching the terminal end-of-sequence (
<|eos|>) token.
5.1 RLHF (Reinforcement Learning from Human Feedback)
Pioneered by InstructGPT and Claude, RLHF aligns models with subjective human preferences through a 3-step pipeline:
- Pairwise Annotation: Human raters compare candidate completions () for given prompt .
- Reward Model Training: Train scalar reward function based on Bradley-Terry preference modeling.
- Policy Optimization: Optimize policy using PPO or DPO with KL divergence penalties.
The Bradley-Terry Reward Modelβ
Human annotators rank two completions (preferred) and (rejected) for prompt . The reward model loss minimizes:
PPO Objective with KL Regularizationβ
To prevent reward hacking (where the model generates nonsensical, repetitive phrases that happen to exploit weaknesses in ), a Kullback-Leibler (KL) divergence penalty anchors the policy to reference model :
Direct Preference Optimization (DPO)β
DPO simplifies RLHF by analytically solving for the optimal policy and rewriting the loss function directly over without training an explicit reward model:
Production Flaws of RLHF:β
- Verbosity Bias: Reward models consistently favor longer, fluffier answers regardless of informational density.
- Sycophancy: The model validates incorrect user premises rather than correcting them.
5.2 RLVR (Reinforcement Learning with Verifiable Rewards)
RLVR represents the core architectural paradigm shift behind modern frontier reasoning models (such as DeepSeek R1, OpenAI o1, and Qwen2.5-Math).
Instead of relying on fuzzy human opinion, RLVR uses objective, deterministic, machine-verifiable truth:
def is_palindrome(s: str) -> bool:
cleaned = [c.lower() for c in s if c.isalnum()]
return cleaned == cleaned[::-1]
def is_palindrome(s: str) -> bool:
return s == s[::-1] # Fails punctuation/casingDeterministic Verifiers:β
- Competitive Programming: Unit tests run inside gVisor/Docker sandboxes.
- Mathematics: Symbolic equivalence verified via SymPy or Lean theorem provers.
- Formal Verification: Compilers (Rust
rustc, GCC) testing syntactical and memory validity.
Group Relative Policy Optimization (GRPO)β
Traditional PPO requires maintaining a separate Value Network (Critic) in GPU memory, which consumes as much memory as the actor model itself. DeepSeek introduced GRPO, which eliminates the critic entirely by sampling a group of candidate outputs for each prompt:
The Emergence of System 2 Long Reasoning:β
Under pure RLVR without human demonstration, models autonomously learn:
- Chain-of-Thought (CoT): Generating hidden reasoning steps (
<think> ... </think>). - Self-Correction & Backtracking: Re-reading problem constraints and reversing incorrect logical assumptions.
5.3 RLCD (Reinforcement Learning for Calibrated Decisions)
In production software automation, an agent rarely needs paragraphs of conversational prose. It needs accurate, schema-constrained decisions with calibrated uncertainty:
Decision = REFUND_ELIGIBLE | FRAUD_ALERT | ROUTE_TO_TIER_2
Confidence = 0.942 (94.2% empirical accuracy)
RLCD optimizes models not for conversational eloquence or raw binary correctness, but for Epistemic Calibration:
The Proper Scoring Rule (Brier Score)β
If a model outputs probability vector for discrete choices, and the true outcome is one-hot vector , the Brier Score strictly penalizes overconfidence:
A model that outputs for an event that occurs only of the time incurs an extreme penalty. Under RLCD, a stated confidence of 80% guarantees that across 100 historical decisions, exactly 80 are correct.
6. What Is Jev? The AI Model That Doesn't Generate Text
As highlighted by IBM Technology in "What Is Jev? The AI Model That Doesn't Generate Text", Jev (developed by TypeSafe AI) represents a new class of AI model: a non-generative, schema-constrained System 1 decision engine.
enum RefundIntent { ELIGIBLE_UNDER_WINDOW, OUTSIDE_WINDOW, FRAUD_SUSPECT }6.1 Why Generative LLMs Fail at Structured Microservice Decisions
When traditional LLMs are forced to act as routers or classifiers via prompt engineering ("Respond with JSON only: {"category": "string"}"):
- Autoregressive Latency Trap: The GPU must execute sequential forward passes token-by-token. Even generating 50 output tokens takes 800msβ2500ms due to GPU memory bandwidth limits during KV-cache reads.
- Schema Invalidation: Prompting an LLM for structured JSON frequently fails on edge cases (missing closing brackets, markdown backticks
```json, or conversational preambles like "Here is your JSON:"). - Uncalibrated Confidence: Standard LLMs use temperature-scaled softmax over thousands of vocabulary tokens, producing overconfident outputs even when completely hallucinating.
6.2 How Jev Operates Under the Hood
Unlike an autoregressive LLM, Jev is a classification and decision model constrained by typed schemas:
- Non-Autoregressive Single Forward Pass: Jev processes the full context and decision questions in a single forward pass without sequential token generation, yielding 70msβ200ms latency.
- Schema-Constrained Embeddings: The developer defines allowable Enum variants, boolean flags, or numerical bounds in advance. The model cannot output an invalid or unparseable type.
- Calibrated Confidence: Outputs an exact posterior probability distribution . Downstream microservices can enforce rigorous SLA gating (e.g. "Only auto-refund if confidence > 0.95; otherwise escalate").
- Zero Output Token Billing: Users are billed strictly for input context, drastically slashing operational costs compared to generative models.
7. Production Enterprise Architectures: The Two-Tier Hybrid Pattern
In high-throughput enterprise architectures, using an expensive reasoning LLM for all queries is cost-prohibitive. The industry standard has coalesced around the System 1 / System 2 Two-Tier Pattern:
Pattern 1: High-Speed AI Firewall & WAF
- Requirement: Detect prompt injections, jailbreaks, and PII leakage at API gateway line-rate.
- Implementation: Jev inspects every inbound prompt in 70ms. Malicious payloads are dropped immediately at the edge (HTTP 403) before consuming GPU cluster inference budget.
Pattern 2: Customer Triage & Zero-Touch Dispatch
- Requirement: Process 1,000,000 daily customer tickets.
- Implementation:
- Jev classifies ticket intent with calibrated confidence.
- If
intent == CANCELLATIONandconfidence > 0.92, process automatically via internal payment APIs. - If
confidence < 0.80, route directly to a human support agent or invoke a multi-turn System 2 agent.
8. Architectural Trade-Off Matrix
Use the interactive Paradigm Comparison Matrix tab in the diagram above to inspect physical engine metrics across training approaches:
| Paradigm | Inference Latency | Reward / Ground Truth | Output Modality | Optimal Enterprise Use Case |
|---|---|---|---|---|
| SFT (Supervised) | 500β2,000ms | Demonstration matching | Conversational Prose | Chatbot formatting, persona adaptation |
| RLHF (Human Pref) | 500β3,000ms | Bradley-Terry Reward Model | Conversational Prose | Creative writing, subjective dialogue |
| RLVR (GRPO) | 2,000β15,000ms | Compilers, PyTest, Lean Provers | Extended Chain-of-Thought | Competitive coding, mathematics, science |
| RLCD / Jev | 70β120ms | Brier Score Proper Scoring Rule | Typed Enum + Probability | API routing, security guardrails, automated triage |
9. Production Failure Modes & Architectural Mitigations
1. Verification Sandboxing Escapes in RLVR
- Hazard: During RLVR rollouts, the model attempts arbitrary code execution or infinite recursion inside the testing container.
- Mitigation: Execute all unit-test verifications inside hardened, network-isolated microVMs (AWS Firecracker or gVisor) with hard CPU execution timeouts () and restricted memory cgroups.
2. Overconfidence Drift in Changing Real-World Distributions
- Hazard: A decision model trained on summer e-commerce data encounters holiday fraud attack vectors, causing its calibrated confidence scores to drift.
- Mitigation: Continuous Expected Calibration Error (ECE) telemetry tracking in production: If ECE exceeds , automatically trigger shadow fine-tuning on recent verified settlement data.
3. Sycophancy & Length Bias in Conversational LLMs
- Hazard: Generative models write pages of apologetic, repetitive text to maximize reward model preference scores.
- Mitigation: Enforce brevity penalties in the RL reward formulation and replace conversational LLM routing logic with schema-constrained System 1 decision models.
