Model Parameter Count Calculator
Calculate transformer model parameter counts and memory requirements.
Model Architecture
Total Parameters
6.74B
6,73,86,73,664 parameters
Parameter Distribution
Memory by Precision
What the Model Parameter Count Calculator Does
The Model Parameter Count Calculator estimates the total number of trainable weights inside a decoder-only transformer language model and the GPU memory those weights require at several numerical precisions. Instead of digging through a model's configuration file or running a Python script, you enter six architecture values: the hidden size (d_model), the number of layers, the number of attention heads, the vocabulary size, the intermediate (feed-forward) size, and the architecture family. The calculator then returns the parameter count in billions, the raw parameter total, and the storage footprint in FP32, FP16, INT8, and INT4.
This is the fastest way to answer the questions that come up constantly in LLM engineering: How big is this model, really? Will it fit on my GPU? How much smaller does quantization make it? A 4096-hidden, 32-layer LLaMA-style configuration resolves to roughly 6.74 billion parameters and about 12.55 GB in half precision, which is exactly why 7B-class models are popular on 16 GB and 24 GB consumer cards. Because the calculator breaks the total into embedding, attention, and feed-forward (FFN) buckets, you can see at a glance where your parameter budget is being spent and which architectural knob to turn when you need a model of a target size.
Whether you are reverse-engineering a published model card, sizing a custom architecture before a training run, or planning inference hardware, this parameter count calculator gives a transparent, formula-driven estimate that matches the standard transformer parameter accounting used across the deep learning community.
How the Parameter Count Is Computed
The calculator sums parameters from three sources and then adds the embedding table twice, once for the input token embeddings and once for the output (unembedding) projection. Many modern models tie these weights, but the upper-bound accounting here counts them separately, which is how the tool reports its total.
Embedding parameters are simply the vocabulary size multiplied by the hidden size: a lookup table with one d_model-dimensional vector per token. Attention parameters per layer come from four square projection matrices, the query, key, value, and output projections, each of size d × d, giving 4d². Feed-forward (FFN) parameters depend on the architecture: a standard GPT-style block uses an up and a down projection (2 × d × ff), while LLaMA and Mistral use a SwiGLU gate that adds a third matrix (3 × d × ff). Two layer-norm vectors per layer contribute a tiny 2 × 2 × d.
The per-layer subtotal is multiplied by the number of layers and added to both embedding tables to produce the grand total. The tool then converts that count into memory by multiplying by bytes per parameter: 4 for FP32, 2 for FP16, 1 for INT8, and 0.5 for INT4, then dividing by 1024³ to express the result in gibibytes.
Total Transformer Parameter Count
Where:
- V= Vocabulary size (number of tokens)
- d= Hidden size / d_model
- L= Number of transformer layers
- ff= Intermediate (feed-forward) size
- k= FFN matrix count: 3 for LLaMA/Mistral SwiGLU, 2 for GPT-standard
Where the Parameters Live: Embedding, Attention, FFN
One of the most useful outputs of this calculator is the parameter distribution, which separates the total into embedding, attention, and FFN contributions. Understanding this split helps you reason about scaling. As models grow deeper and wider, the embedding table becomes a smaller fraction of the whole, while the feed-forward block dominates because it scales with both d and ff.
| Component | Per-Layer Formula | Scales With |
|---|---|---|
| Embedding (in + out) | 2 × V × d (not per layer) | Vocabulary × width |
| Attention (Q,K,V,O) | 4 × d² | Width squared |
| FFN (SwiGLU) | 3 × d × ff | Width × FFN size |
| FFN (standard) | 2 × d × ff | Width × FFN size |
| Layer norm | 2 × 2 × d | Width (negligible) |
For the default 7B-class configuration, the FFN block carries the heaviest load at roughly 135 million parameters per layer versus 67 million for attention, which is why the common rule of thumb sets the intermediate size to about 2.7 times the hidden size in SwiGLU models. The embedding table, at around 131 million parameters per copy, looks large for a single layer but quickly becomes a minority share once you stack 32 transformer blocks.
Memory by Precision: FP32, FP16, INT8, and INT4
Parameter count alone does not tell you whether a model fits on your hardware; the numerical precision of the stored weights does. The calculator translates the parameter total into a memory footprint by assuming a fixed number of bytes per weight. FP32 (full precision) uses 4 bytes, FP16 and BF16 (half precision) use 2 bytes, INT8 uses 1 byte, and INT4 uses half a byte. Each step down roughly halves the memory you need to hold the weights.
For a 6.74B-parameter model the footprints work out to about 25.10 GB in FP32, 12.55 GB in FP16, 6.28 GB in INT8, and 3.14 GB in INT4. This is why a 7B model that cannot run in full precision on a 24 GB card slots comfortably into 12-16 GB at half precision and runs on modest laptops once quantized to 4-bit. Keep in mind that these figures cover weights only: actual inference also needs memory for activations and the KV cache, and training adds optimizer states and gradients that can multiply the requirement several times over.
Use the precision table to plan deployments: pick the smallest precision that preserves acceptable accuracy for your task, then confirm the resulting GB figure leaves headroom for context length and batch size on your target GPU.
How to Use the Model Parameter Count Calculator
Using the parameter count calculator takes a few seconds once you have a model's configuration values, which usually live in a config.json file on Hugging Face or in a published model card.
- Pick the architecture family. Choose LLaMA/Mistral if the model uses SwiGLU (three FFN matrices) or GPT/Standard if it uses a classic two-matrix MLP. This changes the feed-forward parameter count by 50 percent.
- Enter the hidden size (d_model). This is the model's main width, listed as hidden_size in most configs.
- Enter the number of layers (the depth, often num_hidden_layers) and the number of attention heads (used for context, since the QKVO projections are square).
- Enter the vocabulary size (vocab_size) and the intermediate size (intermediate_size or FFN dimension).
- Read the results. The headline shows total parameters in billions; the cards show FP16 and INT4 memory; and the breakdown panels split parameters by component and show memory across all four precisions.
If your estimate is slightly higher than the published figure, the difference is almost always tied embeddings: real models often share the input and output embedding matrices, so subtract one copy of V × d to get the tied total.
Worked Examples
7B LLaMA-Style Model (Default Configuration)
Problem:
Estimate the parameter count and FP16 memory for a SwiGLU model with d=4096, L=32, V=32000, and ff=11008.
Solution Steps:
- 1Embeddings (both tables): 2 × (32000 × 4096) = 2 × 131,072,000 = 262,144,000.
- 2Per-layer attention: 4 × 4096² = 67,108,864; per-layer FFN (SwiGLU): 3 × 4096 × 11008 = 135,266,304; layer norm: 2 × 2 × 4096 = 16,384; per-layer total = 202,391,552.
- 3All layers: 32 × 202,391,552 = 6,476,529,664. Grand total = 262,144,000 + 6,476,529,664 = 6,738,673,664 ≈ 6.74B.
- 4FP16 memory: 6,738,673,664 × 2 ÷ 1024³ ≈ 12.55 GB; INT4 memory ≈ 3.14 GB.
Result:
About 6.74 billion parameters, ~12.55 GB in FP16 and ~3.14 GB in INT4.
GPT-2 Small (Standard Two-Matrix MLP)
Problem:
Estimate parameters for a GPT-standard model with d=768, L=12, V=50257, and ff=3072.
Solution Steps:
- 1Embeddings (both tables): 2 × (50257 × 768) = 2 × 38,597,376 = 77,194,752.
- 2Per-layer attention: 4 × 768² = 2,359,296; per-layer FFN (standard): 2 × 768 × 3072 = 4,718,592; layer norm: 2 × 2 × 768 = 3,072; per-layer total = 7,080,960.
- 3All layers: 12 × 7,080,960 = 84,971,520. Grand total = 77,194,752 + 84,971,520 = 162,166,272 ≈ 0.16B.
- 4FP32 memory: 162,166,272 × 4 ÷ 1024³ ≈ 0.60 GB.
Result:
About 162 million parameters (~0.16B), roughly 0.60 GB in FP32.
Sizing a 13B Custom Model
Problem:
You want a SwiGLU model near 13B parameters with V=32000. Try d=5120, L=40, ff=13824.
Solution Steps:
- 1Embeddings (both tables): 2 × (32000 × 5120) = 2 × 163,840,000 = 327,680,000.
- 2Per-layer attention: 4 × 5120² = 104,857,600; per-layer FFN: 3 × 5120 × 13824 = 212,336,640; layer norm: 2 × 2 × 5120 = 20,480; per-layer total = 317,214,720.
- 3All layers: 40 × 317,214,720 = 12,688,588,800. Grand total = 327,680,000 + 12,688,588,800 = 13,016,268,800 ≈ 13.02B.
- 4FP16 memory: 13,016,268,800 × 2 ÷ 1024³ ≈ 24.24 GB, so half precision needs a 24 GB+ card with no headroom — quantize to INT8 (~12.12 GB) for comfortable inference.
Result:
About 13.02 billion parameters; ~24.24 GB FP16 and ~12.12 GB INT8.
Tips & Best Practices
- ✓Read d_model, num_layers, vocab_size, and intermediate_size straight from a model's config.json for accurate inputs.
- ✓Pick the LLaMA/Mistral option whenever the model uses SwiGLU — forgetting it undercounts FFN parameters by a third.
- ✓Subtract one V × d embedding copy if the model ties input and output embeddings to match its published size.
- ✓Use the FP16 figure as your baseline GPU budget, then add headroom for the KV cache and activations.
- ✓Reach for INT8 or INT4 memory numbers when planning inference on consumer GPUs with limited VRAM.
- ✓Grow the intermediate size before adding layers when you want more capacity at a fixed depth.
- ✓Remember weights alone are not the whole picture — training adds optimizer and gradient memory on top.
- ✓Cross-check your estimate against a known model like 7B LLaMA (~6.74B) to confirm your inputs are sensible.
Frequently Asked Questions
Sources & References
Last updated: 2026-06-05
Help us improve!
How would you rate the Model Parameter Count Calculator?
Editorial Note
MyCalcBuddy Editorial Team
This page is maintained as an educational calculator reference.
Formula Source: Standard Mathematical References
by Various