πŸ€– AI/ML

Parameter

Parameter

The weights and biases a model learns. GPT-4 has trillions of parameters.

πŸ“– Detailed Explanation

A parameter is the set of weight and bias values that a machine learning model learns from data during training. The model's predictive ability is determined by these parameter values, and training is the process of finding the optimal parameter values.

With the advancement of deep learning, the number of parameters in models has increased dramatically. AlexNet in 2012 had 60 million parameters, BERT in 2018 had 340 million, GPT-3 in 2020 had 175 billion, and GPT-4 in 2023 has an estimated 1.8 trillion.

Parameters are determined by the model architecture. In a Transformer-based LLM, the number of parameters is determined mainly by the embedding dimension (d_model), the number of layers (n_layers), the number of heads (n_heads), and the vocabulary size (vocab_size). It has roughly 12 * n_layers * d_model^2 parameters.

In practice, the number of parameters is a key indicator that determines a model's capacity, training time, inference cost, and required GPU memory. In general, more parameters mean better performance, but they also require more data and computing resources.

πŸ’» Code Example

# λͺ¨λΈ νŒŒλΌλ―Έν„° 확인 및 뢄석
import torch
import torch.nn as nn
from transformers import AutoModel

# 1. κ°„λ‹¨ν•œ 신경망 νŒŒλΌλ―Έν„° 예제
class SimpleNN(nn.Module):
    def __init__(self, input_dim=784, hidden_dim=256, output_dim=10):
        super().__init__()
        self.fc1 = nn.Linear(input_dim, hidden_dim)  # κ°€μ€‘μΉ˜ + 편ν–₯
        self.fc2 = nn.Linear(hidden_dim, output_dim)

    def forward(self, x):
        return self.fc2(torch.relu(self.fc1(x)))

model = SimpleNN()

# νŒŒλΌλ―Έν„° 수 계산
def count_parameters(model):
    total = sum(p.numel() for p in model.parameters())
    trainable = sum(p.numel() for p in model.parameters() if p.requires_grad)
    return total, trainable

total, trainable = count_parameters(model)
print(f"Total: {total:,}, Trainable: {trainable:,}")
# 좜λ ₯: Total: 203,530, Trainable: 203,530
# fc1: 784*256 + 256 = 200,960
# fc2: 256*10 + 10 = 2,570

# 2. LLM νŒŒλΌλ―Έν„° 확인
llm = AutoModel.from_pretrained("bert-base-uncased")
total_llm, _ = count_parameters(llm)
print(f"BERT-base parameters: {total_llm / 1e6:.1f}M")
# 좜λ ₯: BERT-base parameters: 109.5M

# 3. λ ˆμ΄μ–΄λ³„ νŒŒλΌλ―Έν„° 뢄포
print("\nλ ˆμ΄μ–΄λ³„ νŒŒλΌλ―Έν„°:")
for name, param in model.named_parameters():
    print(f"  {name}: {param.shape} = {param.numel():,}")

# 4. ν•™μŠ΅ κ°€λŠ₯ μ—¬λΆ€ μ œμ–΄ (νŒŒμΈνŠœλ‹ μ‹œ)
for param in llm.encoder.layer[:10].parameters():
    param.requires_grad = False  # ν•˜μœ„ 10개 λ ˆμ΄μ–΄ 동결

_, trainable_after = count_parameters(llm)
print(f"동결 ν›„ ν•™μŠ΅ κ°€λŠ₯: {trainable_after/1e6:.1f}M")

πŸ“Š Comparison of Parameters in Major Models

As of January 2025, the number of parameters in major AI models

ModelParameterNotes
GPT-21.5B2019, open source
BERT-large340MEncoder model
GPT-3175B2020, API only
Llama 27B / 13B / 70B2023, open source
Llama 3.18B / 70B / 405B2024, open source
GPT-4~1.8T (estimated)MoE architecture
Claude 3 OpusUndisclosedAnthropic
Phi-3-mini3.8BMicrosoft SLM

πŸ—£οΈ Say It Like This in Practice

πŸ’¬ In a Meeting
"A 7B model needs about 2 bytes per parameter (FP16), so it requires at least 14GB of VRAM. With 4-bit quantization, it can be reduced to 3.5GB."
πŸ’¬ In an Interview
"A parameter is a value learned from training data, while a hyperparameter is a value set by a person before training. Learning rate and batch size are hyperparameters."
πŸ’¬ In a Technical Discussion
"According to the Scaling Law, the number of parameters, the amount of training data, and the compute budget determine model performance. Simply increasing the parameters alone can lead to overfitting due to insufficient data."

Take a mock interview on this topic β†’ WIA SOOM AI Interview Β· Start for free

⚠️ Common Mistakes & Cautions

❌
Confusing Parameters with Hyperparameters

A parameter is a weight determined through training, while a hyperparameter (such as the learning rate) is a value set by a person. It is a concept frequently asked about in interviews.

❌
Judging Performance by Parameter Count Alone

Phi-3 (3.8B) outperforms Llama 2 (7B) on some benchmarks. Data quality and training techniques also matter.

βœ…
The right way

Choose a model size suited to the task. Fine-tuning a small model is often more efficient than prompting a large model.

πŸ”— Related Terms

πŸ“š Learn More