Building a 15M-Parameter AI Model from Scratch: Runs on CPU

A developer built a 15M-parameter AI model from scratch that runs entirely on CPU, exploring the feasibility and significance of the small-model path.
A developer shared on Reddit a from-scratch AI model with only 15 million parameters that runs entirely on a CPU. The article analyzes why this scale was chosen: weights of about 60MB can sit close to the CPU cache, reducing memory access bottlenecks; CPU inference eliminates GPU drivers and VRAM management, lowering the deployment barrier. Building from scratch covers the data pipeline, training loop, tokenizer, and inference engine, offering engineering education value. The original post did not disclose dataset, training duration, or performance evaluation, so information is limited. The small-model path suits edge devices and privacy-sensitive scenarios, complements the large-model path, and reminds the community that parameter scale is not the only dimension—operating cost matters too.
In an era of large models with hundreds of billions of parameters, a developer shared an opposite approach on Reddit: he built a 15-million-parameter AI model from scratch and ran it entirely on a CPU. It sounds like a silent rebuttal to the current scale race, but behind it lies a more pragmatic question—when a model is small enough, how low can the barrier to AI become?

Why 15 Million Parameters?
According to the Reddit post, the developer's choice of the 15M parameter scale was not arbitrary. This scale is roughly one-tenth of the early GPT-2 Small, enough for the model to exhibit basic language patterns without imposing harsh hardware requirements during training and inference. The key is that he treated "can run on CPU" as a hard constraint rather than a compromise made afterward.
From an engineering perspective, this means the model architecture, operator selection, and memory layout all had to be designed around the CPU's cache hierarchy and instruction set. Frankly, the original author did not elaborate on specific architectural details in the post, but the result shows that the model did complete an end-to-end inference loop.
Core trade-off: fewer parameters mean lower floating-point operations per forward pass, allowing CPU SIMD instructions to work more efficiently.
GPT-2 Small is an early generative language model released by OpenAI in 2019, with approximately 124 million parameters, trained on about 40GB of WebText corpus. It demonstrated zero-shot task transfer at the time and is an important reference point for understanding "what small models can do." At 15M parameters, roughly one-tenth of that size, model capacity is greatly reduced, but it may still capture lexical and syntactic local patterns. When evaluating such small models, perplexity is typically the focus rather than downstream task accuracy, because capacity limits make it difficult to perform reasoning that requires long-range dependencies.
The Engineering Reality of CPU Inference
Most AI developers are used to treating GPUs as the default option, but CPU inference has underappreciated advantages. It requires no VRAM allocation, involves no CUDA driver compatibility issues, and deployment environments are nearly ubiquitous. For a small-parameter model, CPU inference latency is often within an acceptable range, especially with a batch size of 1.
However, there is a key prerequisite: the model must be small enough. The weights of a 15M-parameter model take up about 60MB in FP32, which can fit near the L3 cache of consumer-grade CPUs, greatly reducing the memory access bottleneck. This also explains why the original author insisted on this parameter scale—any larger, and CPU inference would slide from "feasible" to "barely workable."
FP32 (single-precision floating point) is the most commonly used numerical format in deep learning, with each parameter occupying 4 bytes. 15M parameters in FP32 are about 60MB, while modern consumer CPUs typically have 8MB to 32MB of L3 cache, so the weights cannot fully "fit" into L3, but they can partially reside there and leverage the high-bandwidth L2/L3 hierarchy to reduce main memory access. With FP16 or INT8 quantization, the weight size can be further halved or reduced to a quarter, significantly improving cache hit rates. SIMD (Single Instruction, Multiple Data) instructions such as AVX2/AVX-512 can process multiple floating-point operations at once and are the key hardware foundation for efficient inference of small models on CPUs.
What Building from Scratch Means
"From scratch" is a keyword in the post title. It implies not just training a model, but also building the data pipeline, training loop, tokenizer, and even the inference engine yourself. This approach has clear value in engineering education: the inputs and outputs of every step are transparent and controllable, with no framework magic black box.
Of course, the post provides quite limited information, disclosing neither dataset size, training duration, nor final performance evaluation. We cannot judge how this model performs on specific tasks; we can only confirm that it indeed runs. For readers who want to reproduce it, this is a starting point rather than a complete tutorial.
In machine learning, "from scratch" usually means not relying on the automatic differentiation and built-in layers of high-level frameworks (such as PyTorch or TensorFlow), but manually implementing forward propagation, backpropagation, and the optimizer. The tokenizer is responsible for splitting text into subword units (such as BPE or WordPiece), and its design directly affects the vocabulary and sequence length the model can handle. The inference engine is responsible for loading weights, managing memory, and executing the computation graph. Implementing these components from scratch is time-consuming, but it allows a thorough understanding of the data flow at each stage and avoids the "black box" dependency brought by framework abstractions.
The Practical Significance of the Small-Model Path
In edge devices and privacy-sensitive scenarios, a model that can run locally on a CPU means data does not have to leave the device. Although 15M parameters cannot handle complex reasoning, it is sufficient for simple pattern recognition, text classification, or rule-based generation. The value of such models is not in competing with large models, but in squeezing AI capabilities into corners that previously had no computing power.
It is worth noting that the small-model path and the large-model path are not opposed. The former handles scenarios where "good enough" suffices, while the latter explores the upper limits of capability. This Reddit developer's attempt is essentially a reminder to the community: parameter scale is not the only dimension, and operating cost also deserves serious attention.
A Signal Worth Noticing
Part of the reason this post sparked discussion is that it highlights how much the default path of AI development depends on GPUs. When someone runs a model written from scratch on a CPU, it is more like a signal: the maturity of the toolchain makes small-scale experimentation readily accessible. As for what this 15M model can specifically do, the original post does not give an answer—perhaps that is exactly the blank left for the community to fill.
One-line Summary
A developer built a 15-million-parameter AI model from scratch and ran it entirely on a CPU, exploring the feasibility and practical significance of the small-model path.
Paragraph Summary
A developer shared on Reddit a from-scratch AI model with only 15 million parameters that runs entirely on a CPU. The article analyzes why this scale was chosen: weights of about 60MB can sit close to the CPU cache, reducing memory access bottlenecks; CPU inference eliminates GPU drivers and VRAM management, lowering the deployment barrier. Building from scratch covers the data pipeline, training loop, tokenizer, and inference engine, offering engineering education value. The original post did not disclose dataset, training duration, or performance evaluation, so information is limited. The small-model path suits edge devices and privacy-sensitive scenarios, complements the large-model path, and reminds the community that parameter scale is not the only dimension—operating cost matters too.
Related articles

Hermes Agent Beginner's Guide: Hands-On with a Self-Evolving AI Agent
A beginner's guide to Hermes Agent, the open-source self-evolving AI agent that gained 41.7K GitHub stars in two months—covering Harness Engineering, the learning loop, three-layer memory, WSL installation, and hands-on configuration.

AI Agent in Action: Building a Smart Office Assistant with WorkBuddy
A practical case study shows how Tencent WorkBuddy batch-converts and archives files, compares chat LLMs with AI Agents, and analyzes WorkBuddy's credit system, use cases, and positioning for office automation selection.

From Single-GPU Bottlenecks to Hundreds of Billions of Parameters: 6 Key Questions in Large Model Distributed Parallelism
Based on a Bilibili tutorial, this article organizes core knowledge of large model distributed parallelism: starting from decoder-only architecture's token-by-token generation and the essence of X times W computation, it analyzes six key questions including data parallelism, tensor parallelism, and pipeline parallelism under single-GPU bottlenecks. Suitable for learners in private deployment and model training scenarios to build systematic understanding.