Backpropagation Explained: Principles and Code for the Core Algorithm Behind Large Models

Backpropagation is the core of AI training, covering two career paths: application development and algorithms.
Based on a tutorial by Bilibili creator Chen Bo, this article explains backpropagation as the core mechanism of neural network training, using the chain rule to propagate gradients and gradient descent to update parameters. It outlines two technical paths in the large model era: engineering-oriented application development (RAG, Agent, Workflow) with a low entry barrier, and the algorithm direction requiring fine-tuning, pre-training, quantization, and distillation. The core hands-on section covers forward propagation, loss computation, gradient backpropagation, and parameter update.
Backpropagation is the core mechanism of neural network training. Whether you're working with NLP, image recognition, or large language models, this algorithm is fundamentally unavoidable. In a tutorial, Bilibili creator Chen Bo provided a complete breakdown of backpropagation from principles to code, and also outlined two clear technical career paths in the era of large AI models.
Why Backpropagation Is a Must-Learn for AI
Whenever artificial intelligence and large models are involved, backpropagation is the core principle you simply cannot skip. It solves a fundamental problem: how exactly should the millions or even billions of parameters in a network be adjusted so that the model's output becomes increasingly accurate?

The answer lies in the chain rule: gradients of the loss function with respect to each parameter are propagated backward layer by layer from the output layer, then combined with gradient descent to update parameters. It sounds simple, but truly understanding its mathematical derivation and engineering implementation is the dividing line between "knowing how to call a library" and "understanding the model." In the course, Chen Bo emphasized that this content covers both theoretical explanation and hands-on coding, with the goal of helping learners fundamentally understand what backpropagation is and how to do it.
The chain rule is a basic rule in calculus for finding the derivative of composite functions: if y = f(u) and u = g(x), then dy/dx = (dy/du)·(du/dx). In neural networks, the loss function can be viewed as the composite result of input data passing through multiple layers of nested functions (each layer being a weighted sum plus activation). Therefore, the gradient of the loss with respect to any parameter equals the product of all local derivatives from the output layer to the layer containing that parameter. Backpropagation is precisely the systematic implementation of this process — it cleverly reuses the gradient computation results of intermediate layers, avoiding repeated differentiation for each parameter individually, reducing computational complexity from exponential to linear in network size. Without the chain rule, training deep networks would be computationally almost infeasible.
Gradient descent is a class of iterative optimization algorithms whose core idea is to update parameters in the direction opposite to the gradient of the loss function, because the gradient points in the direction of steepest ascent, and the opposite direction is the direction of steepest descent. The parameter update formula is typically written as w ← w − η·∂L/∂w, where η is the learning rate, controlling the magnitude of each step. Too large a learning rate causes oscillation or even divergence; too small leads to slow convergence. In practice, variants such as stochastic gradient descent (SGD), momentum, and Adam have been developed, all improving the update strategy on the basic gradient descent framework. Backpropagation efficiently computes gradients; gradient descent uses these gradients to actually change parameters. Together they form the complete training loop.
Two Technical Paths in the Era of Large Models
Before diving into the specifics of backpropagation, Chen Bo first offered a macro perspective: to establish yourself in the large model field, the skills you need to master fall into two major categories.

The first path is large model application development. Typical directions include RAG, Agent systems, and Workflow development. This type of work is closely tied to business needs — essentially secondary development built on top of large models to make specific tasks more intelligent. For those with a backend or Python development background, the entry barrier is relatively low — you don't need deep knowledge of underlying algorithm principles, and you can get up to speed quickly with existing engineering skills. Enterprise demand for this is currently very high.

The second path is the algorithm direction. This path requires understanding algorithm principles and mastering fine-tuning and training of large models. Specifically, it involves using business data to train open-source large models so they perform better in specialized domains; going further, you also need to know how to build models from scratch, do pre-training, and apply deployment optimization techniques like quantization and distillation. Chen Bo's assessment is that if you can master both areas, you'll be much more secure in competing for large model-related positions.
RAG (Retrieval-Augmented Generation) is a technical paradigm that combines external knowledge bases with large models: when a user asks a question, the system first retrieves relevant passages from a document store, then inserts these passages into the prompt for the large model to generate an answer. It can mitigate hallucinations and supplement private domain knowledge without retraining the model, making it one of the most common solutions for enterprise deployment. Agent gives large models the ability to plan autonomously and call tools, enabling them to break down tasks, invoke external interfaces like search or code execution, and complete complex goals in multiple steps. Workflow is an orchestration method that chains multiple model calls or tool nodes together according to predetermined logic, emphasizing process controllability and observability. The three are often used in combination, forming the main engineering content of large model application development.
Key Code Implementation Points of Backpropagation
The core part of the course focuses on the code implementation of backpropagation. Although the original material didn't expand into line-by-line code, from the teaching structure, the hands-on section revolves around the following key steps:
- Forward propagation: Input data passes through each layer's weighted sum and activation function to produce predicted output
- Loss computation: Use a loss function to measure the gap between predicted and actual values
- Gradient backpropagation: Starting from the output layer, use the chain rule to compute partial derivatives for each parameter layer by layer

- Parameter update: Adjust weights and biases using gradient descent based on gradients and learning rate
The value of understanding this process is that it's not only the foundation of neural networks but also a prerequisite for understanding modern architectures like Transformer, GPT, LLaMA, and MoE. Chen Bo mentioned that mastering underlying technologies like machine learning, deep learning, reinforcement learning, and model quantization before approaching large model architectures makes the learning path much smoother.
What You Can Achieve After Learning
Chen Bo set clear expectations for the course: after fully working through backpropagation principles plus hands-on coding, you'll have substantial support for positions as a large model application engineer or algorithm engineer. This "principles + code" training approach makes a big difference compared to only watching videos without hands-on practice, or only running code without delving into principles.
For engineers transitioning from traditional development to AI, backpropagation is an extremely cost-effective entry point. It's fundamental enough that learning it once benefits you long-term; and it's specific enough that there's clear code to verify whether your understanding is correct.
One-line Summary
Backpropagation is the core of AI training, and this covers two career paths in the large model era: application development and algorithms.
Paragraph Summary
Based on a tutorial by Bilibili creator Chen Bo, the article points out that backpropagation is the unavoidable core mechanism of neural network training, propagating gradients layer by layer via the chain rule and updating parameters with gradient descent — the dividing line between "knowing how to call a library" and "understanding the model." It also outlines two technical paths in the large model era: one is engineering-oriented application development covering RAG, Agent, and Workflow, with a low entry barrier for backend or Python backgrounds and high demand; the other is the algorithm direction, requiring understanding of principles and mastery of fine-tuning, pre-training, quantization, and distillation. The core hands-on section includes four steps: forward propagation, loss computation, gradient backpropagation, and parameter update. Mastering these provides substantial support for large model application or algorithm positions.
Related articles

Behind TinyFish's Free Search: The Real Cost of AI Agents Reading the Web
TinyFish opens search retrieval for free, but the real cost of AI Agents reading the web hasn't disappeared: with retrieval fees at zero, token processing and inference generation become the main expenses. This article breaks down both cost structures and analyzes the impact of free search on Agent infrastructure competition and developer cost strategy.

ScopeGuard: A Local-First Open Source AI Tool That Takes Aim at Freelancer Scope Creep
ScopeGuard is a local-first open source AI tool that helps freelancers detect client scope creep, cite contract clauses, and generate boundary-setting replies and change order quotations—all running locally to protect NDA privacy.

Philadelphia Woman Arrested for Blocking Delivery Robot: A Flashpoint in Human-Machine Conflict
A Philadelphia woman, Carolyn Marvin, was arrested for blocking an Uber delivery robot to protest job displacement, highlighting human-machine conflict and legal-ethical dilemmas.