Latent Space just unpacked how ChatGPT actually works—beyond the hype. If you build with LLMs, understanding this stack will help you ship safer, faster features. Source: Latent Space.
The modern ChatGPT stack (in brief)
- Base model (pretraining): A transformer trained on internet-scale text/code to predict the next token. This yields broad world knowledge.
- Supervised fine-tuning (SFT): Curated instruction data teaches the model to follow directions and format responses.
- RLHF / RLAIF: Human (or AI) preference data trains a reward model; the policy is optimized to align outputs with preferences and safety norms. See InstructGPT (Ouyang et al., 2022).
- System prompts & guardrails: Policies, style guides, and safety filters steer behavior and catch risky content before/after generation.
- Tools & function calling: The model calls functions for retrieval, web search, code execution, or data lookups, then composes an answer. Reference: OpenAI function calling.
- Retrieval augmentation (RAG): A vector database injects fresh, grounded context so answers reflect your data, not just training.
- Memory: Short-term chat history + optional long-term user or org memory for continuity and personalization.
- Orchestration & routing: A controller selects models, tools, or multi-step plans based on the task and latency/cost targets.
- Evals & telemetry: Automated tests, red-teaming, and online metrics catch regressions; human review closes the loop.
- Shipping & operations: Canary releases, rate limits, caching, cost/latency budgets, and incident playbooks keep things reliable.
Why this works
Pretraining gives broad competence. SFT and RLHF align behavior to what users actually want. Tools + RAG add superpowers and up-to-date facts.
The secret sauce is feedback. Preference data, evals, and production telemetry create a virtuous cycle that steadily reduces errors and increases trust.
What product teams should do now
- Start simple: Ship a focused use case with RAG and one or two tools. Add complexity only when it pays off.
- Design for guardrails: Use clear system prompts, content filters, and allowlist/denylist patterns from day one.
- Instrument everything: Log prompts, tool calls, tokens, latency, and user feedback with privacy in mind.
- Invest in evals: Combine automated checks (groundedness, harmful content) with targeted human review.
- Scale with caching and routing: Cache results, batch long contexts, and route heavy tasks to specialist models.
- Close the loop: Turn thumbs-up/down and issue reports into new SFT/RLHF data.
Practical checklist
- Define a north-star metric (e.g., task success, groundedness, or resolution time).
- Write a tight system prompt and 10-20 golden test cases.
- Add retrieval over your docs with chunking, embeddings, and freshness policy.
- Expose one critical tool (search, DB query, calculator, or code executor) via function calling.
- Add pre- and post-generation safety filters and run a red-team pass.
- Ship to a small cohort with canary + real-time logging and issue capture.
- Stand up weekly eval runs and a data pipeline for SFT/RLHF refresh.
Sources and deeper dives
- Latent Space: Unpacking how ChatGPT works
- InstructGPT (RLHF): Ouyang et al., 2022
- Constitutional AI (alternatives to pure RLHF): Bai et al., 2023
Takeaway
ChatGPT isn’t just a model—it’s a product and ops stack. If you pair RAG + tools with strong evals and feedback loops, you’ll get durable quality gains.
Enjoyed this nugget? Get more practical AI insights in your inbox: theainuggets.com/newsletter.

