Skip to content
AI/ML

The AI Training Pipeline Behind ChatGPT and Claude

The AI training pipeline separates knowledge from assistant behavior; I explain the stages and how I would use that distinction in production decisions.

Topic
AI/ML
Reading time
6 min
Length
1,378 words
Published
Nov 4, 2026
01:08 pm IST
In this article
  1. How I read the five training stages
  2. Data cleaning determines what gets learned
  3. Tokenization is part of the product budget
  4. Pre-training produces a predictor, not an assistant
  5. Supervised fine-tuning teaches the expected response
  6. Preference tuning selects between plausible answers
  7. Applying the AI training pipeline to a production feature
  8. A small corpus split I would start with
  9. What the AI training pipeline does not solve

The AI training pipeline behind ChatGPT and Claude separates learning language from learning how to behave as an assistant: data cleaning, tokenization, pre-training, supervised fine-tuning, and preference tuning. That is the useful distinction in ByteMuni’s walkthrough. This is an explanation of how assistants are built, not a new model release. I would read it to understand why a model can follow instructions beautifully and still answer the wrong question.

For production work, I care about that distinction more than a diagram of training stages. If an assistant produces a polished but incorrect article summary, I need to decide what to investigate: missing knowledge, weak examples, unsuitable preferences, or an evaluation that rewards presentation instead of correctness.

How I read the five training stages

Data cleaning determines what gets learned

The source describes training material drawn from public internet content, partnerships or licensed datasets, and information supplied or generated by users, trainers, and researchers. The precise mixture differs between providers. I would not treat their shared pipeline as evidence that their datasets are interchangeable.

Cleaning includes extracting useful text, filtering unwanted material, removing personal information where possible, deduplicating, and balancing the material. My takeaway is that collecting more documents is not automatically progress. I would rather inspect what survives the filters than celebrate the size of the initial download.

ByteMuni’s small experiment makes that concrete. Its authors cleaned their own articles and held back text for validation. I would preserve that separation in any experiment of my own: training performance alone would not tell me whether the model can handle unseen material.

Tokenization is part of the product budget

I think of tokenization as the translation between readable text and the numbered chunks a model processes. The source explains byte-pair encoding through repeated merges of common neighboring symbols. A token may represent a word, part of a word, or punctuation.

The article’s tokenizer kept “LangChain” together but split “Bengaluru” into several pieces. That is an observation from its tiny corpus, not a comparison of commercial tokenizers. For my plain-English and Hinglish search work on PlanToday.in, I would test representative queries rather than estimate token usage from English word counts. The source notes that context limits and API pricing are measured in tokens.

Pre-training produces a predictor, not an assistant

The pre-training objective described in the source is next-token prediction. The model compares its prediction with the actual next token and updates its parameters. Across training text, that process develops the patterns that support language and knowledge.

I would keep the distinction between a base model and an assistant explicit. The source gives the example of a base model continuing a list of questions instead of answering one. From a text-continuation perspective, that can be a plausible output. From my application’s perspective, it is the wrong behavior.

The source also cautions against treating model parameters as a database of original sentences, while acknowledging that memorization can occur. I would therefore avoid either extreme: assuming the model stores nothing, or assuming I can reliably retrieve training documents from it.

Supervised fine-tuning teaches the expected response

Supervised fine-tuning, or SFT, uses curated prompt-and-response examples. The source describes it as next-token training again, usually with loss calculated only on response tokens. I read this as teaching the model what an acceptable answer should look like.

The most useful result in ByteMuni’s experiment is also its least impressive-looking one. After fine-tuning, its tiny model produced grammatical definitions, but selected definitions that did not answer the questions. I would not interpret that experiment as a limit on all fine-tuning. I would interpret it as a warning against using fluency as evidence of knowledge.

Preference tuning selects between plausible answers

The source describes reinforcement learning from human feedback, or RLHF, as a reward model trained on ranked answers, followed by optimization of the assistant against that reward. It also describes a penalty intended to keep the assistant from drifting too far from the supervised model.

For Claude, the supplied explanation introduces Constitutional AI: critique and revision against written principles, with AI-generated feedback used to train the preference model. I would distinguish that from saying humans disappear from the process. The source describes a different feedback mechanism, not an absence of human choices.

I would also resist reducing either provider to one algorithm. The supplied material names other approaches, including DPO and reinforcement learning with verifiable rewards, but does not provide enough detail here for a useful implementation comparison.

Applying the AI training pipeline to a production feature

I would use these stages as a diagnostic checklist before deciding to train anything. In a newsroom CMS, I would test factual fidelity separately from editorial style. A summary that sounds publishable is not necessarily one I would let through without checking it against the article.

  1. Define the failure. I would collect representative prompts, source material, expected behavior, and unacceptable answers. “Make the assistant better” is not a testable requirement; preserving the facts in an article is a requirement I can review.
  2. Separate content from behavior. I would label whether an answer lacks relevant information, ignores instructions, or uses an unsuitable tone. These are investigation categories, not proof of which training stage caused the problem.
  3. Inspect examples before expanding them. I would review ambiguous answers, duplicated material, and cases where the expected response contains unsupported detail. I would not want my training examples to reward the behavior I am trying to remove.
  4. Hold back evaluation material. I would keep an untouched set for judging changes. I would also review related documents together rather than assume that removing exact duplicates eliminates overlap.
  5. Measure token usage on actual inputs. I would include local names, Hinglish queries, punctuation, and the response formats my application expects. The tokenizer example is enough reason not to extrapolate from a convenient English sample.
  6. Compare correctness and presentation independently. I would record whether the response answers the question before judging whether I like its wording. That is the practical lesson I take from the source’s fluent-but-wrong fine-tuned model.

A small corpus split I would start with

For a local experiment, I would make document assignment repeatable. This Python example removes exact duplicates after whitespace normalization and assigns documents by a content hash. It is my preparation example, not the training code or cleaning method used in the source.

from hashlib import sha256
from pathlib import Path
import json

splits = {"train": [], "validation": []}
seen = set()

for path in sorted(Path("corpus").glob("*.txt")):
    text = " ".join(path.read_text(encoding="utf-8").split())
    if not text:
        continue

    digest = sha256(text.encode("utf-8")).hexdigest()
    if digest in seen:
        continue
    seen.add(digest)

    bucket = int(digest, 16) % 10
    split = "validation" if bucket == 0 else "train"
    splits[split].append({"id": digest, "text": text})

for split, records in splits.items():
    with Path(f"{split}.jsonl").open("w", encoding="utf-8") as output:
        for record in records:
            output.write(json.dumps(record, ensure_ascii=False) + "\n")
    print(split, len(records))

I would inspect the resulting counts, especially with a small corpus; this assignment does not guarantee a particular split size. I would also avoid this whitespace normalization for code-heavy material where formatting matters. Before real training, I would add checks for near-duplicates, related document families, personal information, and data permissions. This snippet is deliberately not a complete cleaning pipeline.

What the AI training pipeline does not solve

I would not read these stages as a guarantee of truthfulness. The source’s experiment shows why: teaching an answer format can produce convincing sentences without the knowledge needed to answer correctly. For my own evaluations, I would keep correctness failures visible even when a reviewer prefers the writing.

I would also separate preference from fact. The source describes preference tuning around qualities such as clarity, honesty, safety, and structure. My concern is how I translate those goals into review instructions. If I ask reviewers only which response they like, I have not explicitly asked them to verify its claims.

The CPU experiment is useful for learning, but I would not use its training time or model behavior to estimate a production assistant’s requirements. The source itself contrasts its tiny model with much larger pre-training runs. I would want measurements from my intended workload before making any infrastructure decision.

If I were shipping a feature through a hosted model API, I would ignore the temptation to reproduce every training stage. I would first build a small, reviewed evaluation set and identify the failure I actually need to fix. I would consider fine-tuning only after I could state the desired behavior clearly and show why my existing approach was insufficient. My next step would be an evaluation file, not a training cluster.

Deepak Kumar

Written by

Deepak Kumar

Sr Software Engineer at India Today Group | Aaj Tak · MERN Stack · Generative AI

I build LLM systems in production — retrieval, evaluation harnesses and guardrails, plus the unattended agent pipelines that write this blog and my books. I write here about what those systems actually do once real traffic hits them. Hiring an LLM engineer in India? Here is how I work.

More on ByteMuni

ByteMuni is a developer publication: tutorials and source-checked tech news, published daily.

Read more on ByteMuni →
Message me