(background)
(이 논문의 핵심)
(method)
(motivation)
(experiments)
DyT를 적용했을 때, Transformers w/o normalization은 거의 hyperparameter tuning 없이,
the performance of their normalized counterparts에 준하거나 상승했다.
우리는 Transformers with DyT의 effective는 diverse setting에 실험했다.
recognition to generation, supervised to self-supervised learning, and computer vision to language models.
이러한 발견은 normalization layers(NL)가 modern neural networks에서 필수적이라는 conventional understanding에 도전하며,
NL이 deep networks에서 어떤 역할을 하는지에 대한 new insights를 제공한다.
(background: Normalization layer는 현대의 deep neural networks에 필수적이다. 학습을 더 빠르고 안정되게 하여 optimization을 더 잘 시킨다.)
2015년에 fsater and better convergence in visual recognition models을 가능하게 한 batch normalization이 제안되고부터,
many variants of normalization layers이 제안되어 왔다.
오늘날, 모든 modern networks는 normalization layers를 사용한다.
특히 dominant Transformer architectures에서는 LayerNorm, or LN이 one of the most popular한 normalizatoin layer이다.
The widespread adoption of normalization layers는 optimization에 경험적인 benefits을 가져다줬다.
추가로 better results를 달성하기 위해, normLayer는 accelerate and stabilize convergence를 돕는다.
neural network가 wider and deeper해질수록, this necessity는 훨씬 더 중요하다.
따라서 normLayer는 deep network를 효과적으로 학습시키기 위해 매우 중요하며, 없어서는 안 될 요소로까지 여겨지고 있다.
이러한 믿음은 최근 몇 년 동안 novel architecture들이 attention or convolution layers를 대체하려는 시도는 자주 있었지만, normLayer는 거의 항상 유지되고 있다는 사실에서 은연중에 드러난다.
(proposition)
이 연구는 normLayer in Transformers를 대체하는 a simple alternative를 제안함으로써
normLayer가 neural network에 없어서는 안 될 필수요소라는 belief에 도전한다.
우리의 탐구는 LN layers가 그들의 input to output을 tanh, S-shaped curves로 mapping하여,
input activations을 적절히 scaling하면서 extreme values를 눌러주는(squashing) 역할을 한다는 관찰에서 시작된다.
this insight에서 영감을 받아, 우리는 an element-wise operation termed Dynamic Tanh (DyT), defined as: , where is a learnable parameter 를 제안한다.
DyT operation은 (1) an appropriate scaling factor 를 학습하고,
(2) the bounded tanh function를 이용해 extreme values를 눌러줌으로써
the behavior of LN을 모방(emulate)하는 것을 목표로 한다.
특히, normLayers와 달리, DyT는 activation statistics를 계산할 필요 없이 두 효과를 모두 달성한다.
(질문: 기존 normLayers들이 학습을 통해 activation의 statistics를 계산하여 normalization parameter를 학습하는 것이고,
DyT도 똑같이 학습을 통해 normalization parameter 대신 scaling factor 를 학습한다고 이해했는데,
결국 DyT도 마찬가지로 를 학습하기 위해 activation의 statistics를 계산하는 셈 아닌가?)
(AI 답변): 전통적인 LN에서는 입력 텐서가 들어올 때마다 해당 텐서에 대한 mean과 standard deviation을 계산하여 매번 statistics를 계산해야 한다. 이는 런타임에 입력의 statistics를 aggregation해야 하는 overhead가 발생하며, 특히 BN의 경우 batch size에 의존하는 문제가 발생한다.
하지만 DyT는 입력 텐서 가 들어오면, 학습된 scalar 를 사용하여 element-wise로 즉시 계산하기 때문에 aggregation 과정이 전혀 없다.
런타임에 statistics를 계산하는 복잡한 연산이 없어, architecture적으로 훨씬 간결하고 빠르다.
DyT를 적용하는 것은 Figure 1에 보이는 것처럼 간단하다:
vision and language Transformers와 같은 architectures에서 existing normLayers를 DyT로 바로 교체하면 된다.
우리는 경험적으로 models with DyT가 다양한 settings에서 can train stably and achieve high final performance임을 증명했다.
models with DyT는 보통 original architecture의 hyper-parameters tuning을 필요로 하지 않는다.
우리의 연구는 normLayer가 modern neural networks 학습에 필수적이라는 관념(notion)에 도전하며, normLayer의 properties에 대한 empirical insights를 제공한다.

normLayer를 review하면서 시작한다.
Most normalization layers는 a common formulation을 공유한다.
Give an input with shape , where is the batch size, is the number of tokens, and is the embedding dimension per token,
the output is generally computed as:
.
여기서 은 a small constant, and ("scaling") and ("shifting")는 learnable vector parameters of shape 이다.
와 는 input의 mean and variance를 나타낸다.
다른 methods들은 주로 이 두 개의 statistics를 계산하는가에 따라 달라진다.
most modern neural networks에서는 LN의 simplicity and universality 덕분에 LN을 사용하고 있다.
최근에는 특히 language model에서 RMSNorm의 인기도 많아지고 있다. (T5, LLaMA, Mistral, Qwen, InternLM, DeepSeek)
이 논문에서 우리가 평가한 Transformers들은 LLaMA가 RMSNorm을 사용한 것을 제외하고, 모두 LN을 사용한다.
요약)
input activation에 대해서 two statistics(mean=와 variance=)를 구하는 방법에 따라
BatchNormalization, LayerNormalization, RMSNorm으로 구분된다.
이 논문에서는 LLaMa 빼고, 모두 LN에 대해서 실험을 적용했다.
(질문) : Transformer에서 특히 RMSNorm이 많이 사용되고 있다고 했는데, 왜 Transformer에서만 특히 많이 사용될까?
(AI 답): Transformer는 residual connection이 많아서, mean-centering이 크게 중요하지 않다. 그래서 mean-centering을 빼도 충분히 안정적으로 학습될 뿐더러 더 단순하고 빠르다.
우리는 먼저 이미 trained된 networks에서 normalization layers의 behaviors를 경험적으로 연구했다.
이 분석을 위해,
(1) ViT-B trained on ImageNet-1K,
(2) a wav2vec 2.0 Large Transformer model trained on LibriSpeech,
(3) Diffusion Transformer (DiT-XL) trained on ImageNet-1K
를 가지고 실험했다.
모든 경우에서, LN은 모든 Transformer block에의 the final linear projection 이전에 적용되었다.
위 세 가지 networks에 대해서, 우리는 mini-batch of samples을 샘플링하여 network에 forward pass를 진행했다.
그 다음 normalization layers의 input과 output을 측정했는데, 이는 normalization operation 직전과 직후 (learnable affine transformation = scaling()과 shifting())의 tensor를 의미한다.
LN은 input tensor의 dimension을 그대로 유지하므로, input과 output elements 사이에 one-to-one 대응 관계를 만들 수 있으며,
이를 통해 두 값의 relationship을 Figure 2에 나타냈다.

세가지 model 전부에 대해,
earlier LN layers (1st column of Figure 2)에서 input-output relationship이 linear하며, x-y plot에서 straight line에 가까운 모습을 보임을 발견했다.
하지만 deepr LN layers에서 관찰한 놀라운 점은, tanh function으로 표현되는 완전하거나 부분적인 S-shaped curves를 띤다는 것이다.
LN은 per-token 단위로 mean을 subtracting하고 standard deviation으로 dividing하기 때문에 input tensor를 linearly transform한다고 생각할 수 있지만...
token마다 mean and stddev 값이 다르기 때문에 모든 activation들을 하나로 모아서 보면 전체적으로는 linearity가 유지되지 않는다.
(정리: 즉, 개별 token 단위에서는 linear하지만 모든 activation값들을 모아서 그려보면 linearity가 깨진다. nonlinear하다.)
(AI의 쉬운 설명: 각 token은 직선 경로를 가지만, 모두 다른 속도(분산)과 방향(평균)으로 움직여서, 전체 무리를 보면 곡선을처럼 보이는 것과 같다.)
(아래 그림은 내가 이해한 내용)

모든 activation들을 하나로 모아서 그렸을 때, linearity가 깨지는 것은 알겠는데...
이러한 non-linear transformation이 scaled tanh function과 매우 유사하다는 것이 놀라운 것이다.
S-shaped curve를 보면, 값이 0에 가까운 central part에서는 대부분 linear shape 구간에 놓여있다.
대부분의 points (약 99%)가 이 linear range에 존재한다.
하지만 이 range를 명확히 벗어나는 point들이 상당히 존재하는데, 이들은 "extreme" values로 간주된다.
예를 들어, ViT model에서는 값이 50보다 크거나 -50보다 작은 값들인 이에 해당한다.
normalization layer들이 이러한 extreme values에 주는 효과는 그 값을 less extreme values로 squash(밀어 넣다)한다는 것이다.
그렇기 때문에, normalization layer는 a simple affine transformation layer로는 approximation될 수 없다는 것이다.
우리는 extreme values에 대해 이렇게 non-linear하고 disprotional(불균형)한 squahsing effect가
normalization layers가 중요한 이유이자 필수적인 요소라는 가설을 세운다.
추가로, 최근에 Ni et al. [62]에서도 유사하게 LN layers의 strong non-linearities를 강조하며, non-linearity가 얼마나 a model's representational capacity를 강화하는지 보였다.
게다가 이러한 squashing behavior는 100년 전 쯤 관찰된 현상인, the saturation properties of biological neurons for large inputs을 모방한다.
(정리: LayerNormalization은 non-linearity의 특성을 가지고 있고, extreme value를 squash해주는 역할도 있기 때문에, a simple linear transformation으로 approximation할 수 없다.
즉, LayerNorm을 approximation하려면 non-linear transformation을 사용해야 한다.
저자들이 제안하는 non-linear 함수인 tanh()를 사용한 이유에 대해서 정당성을 부여하는 중요한 주장이었다고 생각함.)
LN layer는 각 token에 대해서 a linear transformation을 수행하면서, 동시에 extreme values를 어떻게 그렇게 non-linear 방식으로 squash할 수 있을까?
이를 이해하기 위해, 우리는 points들을 token별, channel별로 각각 묶어서 시각화했다.
Figure 3에서는 Figure 2의 ViT 관련 두 번째, 세 번째 subplot을 가져와, 더 명확하게 보기 위해 sampling된 일부 점들만을 사용해 plot했다.
plotting할 channel을 선택할 때는 extreme values를 가지는 channel들을 반드시 포함하도록 했다.
Figure 3 왼쪽 두 개의 panels에서, 우리는 각 token's activation을 동일한 색으로 표시했다.
관찰해보면, any single token에 속한 모든 points들은 straigh line(직선)을 이룬다.
( 하나의 token 내에서 mean, stddev를 구해 normalization하기 때문에 linear한 것이 당연)
하지만, token마다 variance가 다르기 때문에 각 직선의 기울기(slope)는 서로 다르다.
input 값의 범위가 작은 token일수록 variance가 작으며, normalization layer는 이 token의 activation을 더 작은 stddev로 나누게 된다.
그 결과, 기울기가 더 큰 직선이 형성된다.
이러한 직선들이 모두 합쳐지면, 전체적으로는 tanh()와 유사한 S-shaped curve를 이루게 된다.
(앞서 내가 그려놨던 그림과 동일한 내용이 Figure 3 left panel에서 말해주고 있었다...)
Figure 3 오른쪽 두 panels에서는, 각 channel의 activation을 동일한 색으로 표시했다.
여기서, 는 입력의 range에 따라 서로 다른 방식으로 scaling할 수 있도록 해주는 a learnable scalar parameter로,
and 는 모든 normalization layers에서 사용되는 것과 동일한 방식 learnable, per-channel vector parameters이며,
이를 통해 output값을 다양한 scale로 되돌릴(back) 수 있다.
이는 종종 별도의 affine layer로 취급되지만, normalization layers가 affine transformation을 포함하듯이, 본 논문에서는 이들을 DyT layer의 일부로 간주한다.
PyTorch-like pseudocode of DyT는 Algorithm 1에 제시되어 있다.


scaling parameters에 대해서는, normalization layers에 따라
는 an all-one vector로 initialize하고
는 an all-zero vector로 initialize했다.
scaler parameter 에 대해서는, LLM training을 제외하고, a default initialization of 0.5를 사용하는 것으로 충분했다.
별도로 명시되지 않는 한, 이후 experiments에서 는 0.5로 initialization되었다.
주목할 점: DyT는 새로운 종류의 정규화 레이어는 아닙니다. DyT는 순전파(forward pass) 동안 텐서의 각 입력 요소에 대해 독립적으로 동작하며 통계나 기타 집계 연산을 계산하지 않습니다. 그러나 DyT는 입력의 중심 부분을 거의 선형으로 변환하면서, 극단적인 값들은 비선형 방식으로 압축(squash)하는 정규화 레이어의 효과를 그대로 유지합니다.

우리는 two popular visual self-supervised learning methods: masked autoencoders (MAE) and DINO를 benchmarking했다.
두 방법 모두 기본적으로 ViT를 backbone으로 사용하지만, training objectives가 다르다:
MAE는 reconstruction loss로 trained되고,
DINO는 joint-embedding loss로 trained 된다.
the standard self-supervised learning protocol에 따라,
우리는 ImageNet-1K dataset에서 label 없이 pretrain하고,
그 후 pretrained model에 classification layer를 붙여 label을 사용해 fine-tuning 했다.
finetuning results는 Table 2에 나와있다.
결과적으로, DyT는 self-supervised learning tasks에서 LN과 동등한 성능을 지속적으로 보여준다.

Masked Autoencoders ViT는 label이 없는 대규모 data를 사용하여 image의 강력한 feature representation을 효율적으로 학습하는 self-supervised learning 모델.
이 pretrained된 encoder는 이후 object detection, segmentation 등 다양한 downstream 작업의 backbone으로 사용.
(2021 CVPR, https://arxiv.org/pdf/2111.06377)
작동 방식:
input image의 약 75%에 달하는 Patch를 random masking.
나머지 25%의 visible patch만 처리.
encoder는 극도로 작은 input만으로도 Image의 전체 context를 유추하도록 학습되어, 강력한 일반화 능력을 학습.
decoder는 encoder의 output(visible patch의 feature vector)와, masked된 위치를 채우는 Mask Tokens을 입력으로 받음.
decoder는 이 정보를 바탕으로 masked patch의 실제 pixel 값을 reconstruct하는 것.

DINO ViT:
DINO는 DIstillation with NO labels의 약자로, 레이블 없이 지식 증류(knowledge distillation)를 사용하는 방식
(2021 ICCV, https://arxiv.org/pdf/2104.14294)








During training.After training.
Non-LLM models은 에 상대적으로 insensitive하다.
Figure 8은 다양한 task에서 값을 변화시켰을 때 validation performance에 미치는 영향을 보여준다.
모든 실험은 각 model의 original setup and hyperparameters를 따른다.
우리는 값이 넓은 범위에 걸쳐도 성능이 안정적으로 유지되며, 일반적으로 0.5에서 1.2 사이의 값이 좋은 결과를 낸다는 것을 관찰했다.
를 조정하는 것은 일반적으로 the early stage of the training curves에만 영향을 미친다.
주요 예외는 supervised ViT-L experiment로, 가 0.6을 초과하면 tranining이 unstable해지고 diverge한다.
이런 경우, learning rate를 낮추면 stability가 회복된다.

Smaller results in more stable training.
이전 observations을 바탕으로 training instability에 기여하는 요인을 추가 분석했다.
그 결과, model size or the learning rate를 증가하면 학습을 안정시키기 위해 를 낮춰야 한다는 것을 알 수 있다.
반대로 가 높으면 training instability를 줄이기 위해 lower learning rate가 필요하다.
Figure 9는 ImageNet-1K dataset에서 supervised learning ViT의 training stability에 대한 ablation을 보여준다.
learning rates, model sizes, and values를 변화시키며 실험했다.
큰 model을 학습할수록 failure 가능성이 높아지며, 안정적인 학습을 위해 smaller values or learning rates가 필요하다.
유사한 instability pattern이 LN-based models에서도 관찰되며, 로 설정하면 LN과 유사한 stability pattern을 보인다.

our findings를 기반으로, 우리는 all non-LLM models에 대해 default value를 로 설정했다.

많은 연구들은 deep models을 normalization layers 없이 학습시키는 방법을 탐구하고 있다.
몇몇 연구들은 training을 stabilizing하기 위해 alternative weight initialization 방식을 제안했다.
Self-normalizing networks는 scaled exponential linear units (SELUs)와
신중히 선태된 initialization 방식을 도입하여, 명시적인 normalization layer 없이도 stable activations and gradient flow를 유지했다.
[11, 12]의 연구에서는, ResNet을 높은 성능으로 학습할 수 있음을 보여줬는데, 이는 initialization techniques, weight normalization 그리고 adaptive gradient glipping이 포함된다.
위 연구들은 주로 다양한 ConvNet models을 기반으로 한다.
Transformer architectures에는, [32]에서 normalization layer와 skip connections에 대한 reliance를 줄이는 Transformer block 의 modification을 탐구했다.
[42]는 AERO, 즉 Softmax만 사용하는 LLM을 소개하며, 성능 저하를 최소화하면서 inference efficiency and privacy를 개선했다.
[35]는 pretrained network에서에서 LN을 점진적으로 제거하고 각 normLayer를 제거한 후 model을 fine-tuning하는 방법을 제안했다.
이전 접근법과 달리, DyT는 architecture와 training recipe에 대한 수정이 최소화되어 있다.
DyT의 simplicity에도 불구하고, DyT는 stable training and comparable performance를 달성한다.
https://github.com/HyungseopLee/Paper_Review/blob/main/Paper-Review/251202_DyTanh.pptx