DOCS: Quantifying Weight Similarity for Deeper Insights into Large Language Models
Authors: Zeping Min
Xinshang Wang
Venue: ICLR 2025 Poster (2025)
Keywords: Weight Similarity
Large Language Models
Distribution of Cosine Similarity
Cluster Analysis
Primary area: foundation or frontier models, including LLMs

Abstract: We introduce a novel index, the Distribution of Cosine Similarity (DOCS), for quantitatively assessing the similarity between weight matrices in Large Language Models (LLMs),  aiming to facilitate the analysis of their complex architectures. Leveraging DOCS, our analysis uncovers intriguing patterns in the latest open-source LLMs: adjacent layers frequently exhibit high weight similarity and tend to form clusters, suggesting depth-wise functional specialization. Additionally, we prove that DOCS is theoretically effective in quantifying similarity for orthogonal matrices, a crucial aspect given the prevalence of orthogonal initializations in LLMs. This research contributes to a deeper understanding of LLM architecture and behavior, offering tools with potential implications for developing more efficient and interpretable models.

Published as a conference paper at ICLR 2025
DOCS: QUANTIFYING WEIGHT SIMILARITY FOR DEEPER INSIGHTS INTO LARGE LANGUAGE MODELS
Zeping Min
Xinshang Wang
Alibaba Group
Alibaha Group xi xinshang- wéa baaaabiancce com
Hupan Laboratory
AMSS, Chinese Academy of Sciences
mirzeping.mapeeal.eee wwt.pmmmpppaaaaaae.. inc. com
ABSTRACT
We introduce novel index, the Distribution of Cosine Similarity (DOCS), for quantitatively assessing the similarity between weight matrices in Large Language Models (LLMs), aiming to facilitate the analysis of their complex architectures. Leveraging DOCS, our analysis uncovers intriguing patterns in the latest open- source LLMs: adjacent layers frequently exhibit high weight similarity and tend to form clusters, suggesting depth-wise functional specialization. Additionally, we prove that DOCS is theoretically effective in quantifying similarity for orthog- onal matrices, a crucial aspect given the prevalence of orthogonal initializations in LLMs. This research contributes to deeper understanding of LLM architec- ture and behavior, offering tools with potential implications for developing more efficient and interpretable models.
INTRODUCTION
Large Language Models (LLMs), built on transformer architectures Vaswwani et al. 2017). have ushered in new in natural language processing (Brown al., 2020)). These complex models have demonstrated remarkable capabilities, but understanding their underlying mechanisms remains challenge. Similarity analysis techniques (Raghu al., 2017; Morcos et al., 2018: Kornblith iet al., 2019) offer promising approach for gaining insights into the learned representations and computational processes within these models.
In this work, we extend the application of similarity analysis by directly examining the weight matri- ces of various LLMS instead of focusing on representations. By analyzing the weights themselves, we aim to uncover deeper insights into the model's 's structure and functionality that are not apparent from representations alone.
While prior research has explored many methods for characterizing the similarity of neural networks
(Wu et al. 2020 Khosla & Williams 2024 Kriegeskorte al., 2008 Klabunde et al., 2023b
Wang
et al.
2020
Barannikov et al. 2021| Hamilton et al. 2016 Rahamim & Belinkov] 2024
Tang
ct al. 2020 Camastta & Staiano [0166] Wang et al. 2018 Raghu et al. 2017 Morcos et al. 2018
Kornblith et al. 2019), these methods are often not applicable to measuring similarity between weight matrices due to the following two key factors. For further discussion, see Appendix
1. Focus on Representation, Not Weights: Similar representations across layers do not nec- essarily imply similar weight matrices. This discrepancy arises from the use of residual connections transformer architectures (He et al.) 2016), which create shortcuts that al- low information to bypass layer transformations. Mathematically, residual connection is represented as
y Fxx
where x is the layer's input, W represents the weight matrices, F is the transformation function (including the feedforward network and attention). and y is the layer's 's output. As
While different transformer-bseed architectures exist, in this paper primarily focus decoder-only architectures, which include the W., WE. Wa, W.. MI.P-UP, and MI.--DoN weight matrices.

---

Published as a conference paper at ICLR 2025
shown in equation I the output y directly depends the imput While residual con- nections mitigate issues such as vanishing gradients during training, this direct dependence inherently creates correlations between the inputs of different layers, the output of one layer serves as the input for the next. Since the transformation function F. depends on the input x, these input correlations across layers, even if the underlying weight matrices W are distinct. This is further ev- idenced by Figures la and [b] which show that the input and output of the feedforward network have similar patterns of representation similarity.
lead correlated representations of transformations
Consequently, observing similar representations across layers does not guarantee that the corresponding weight matrices are also similar. Since representation and weight are two fundamental facets of the model, each offers unique insights. Therefore, while represen- tation analysis can provide profound understanding of large language models, examining the weight matrices can further deepen our comprehension of their structure and behav- ior, offering additional perspectives for potential applications. For further discussion, see Appendix E.1
2. Non- Non-Discriminative for Orthogonal Matrices: Many existing similarity indices, such as |984|Morcos
Canonical Correlation Analysis (CCA) (Ramsay et al. 1984 Morcos et al. (2018). Singular Vector Canonical Correlation Analysis (SVCCA) (Raghu Kernel Alignment (linear CKA) (Kornblith et al. (201)). are ron-discriminative. for orthog- onal matrices.
2017), and linear Centered
orthogonal matrix Q is defined by the property Q QT = QQ I, where is the identity matrix. This non-diseriminative nature means that these indices can yield the same score when assessing the similarity between any two orthogonal matrices, regardless of their actual differences. This limitation hinders accurate similarity assess- ment, as fails to capture genuine differences between weight matrices. This issue is particularly relevant in the context of LLMs, where orthogonal matrices commonly occur throughout the training process
(Tian et al. 2023).
To address these challenges, we introduce a novel matrix-similante index called the Distribution of Cosine Similarity (DOCS). DOCS directly measures the similarity of weight matrices by computing the cosine similarity between corresponding vectors and analyzing their distribution. Importantly, DOCS retains the desirable properties of existing similarity indices while overcoming their non- discriminative nature for orthogonal matrices, a critical factor in LLM analysis. Through extensive experiments on various LLMs, we demonstrate that DOCS provides more reliable and accurate measure of similarity between LLM weight matrices.
9.14
Lpveng
6599
Locong
Lavverg
Lovera
33
6589
072
037
23
(a) Representation similarity before the feedforward network, measured using linear CKA.
(b) Representation similarity of the feed- forward network's output, measured using linear CKA.
(c) Weight similarity of the MLP-UP ma- trix, measured using linear CKA.
(d) Weight similarity of the MLP-UP ma- trix, measured using DOCS method.
Figure 1: Comparison of similarity indices applied to representation similarities ((a) and (b)) and weight similarities ((c) and (d)) across different layers of Llama 3.1-8B-Instruce (Dubey et al. 2024).
To demonstrate the effectiveness of our DOCS method, Figures Taaeessschae an compare weight similarity heatmaps generated using linear CKA (Kornblih al. 2019) and DOCS. The lincar CKA heatmap shows light off-diagonal areas and dark stripes, indicating an inability to distinguish between distant layers- possibly due the orthogonality of weight matrices (see Section () In contrast, the DOCS heatmap displays clear light areas near the diagonal, highlighting similarities between adjacent lay- ers in the LLM.
Our results reveal many intriguing similarity patterns within open-source LLMs, leading us to ex- plore several key observations in the following discussions.
2

---

Published as a conference paper at ICLR 2025
Neighboring Transformer Layers Exhibit Similar Weights.
Our analysis reveals a consistent pattern of weight similarity between adjacent layers in open-source LLMs. This suggests that after optimization, similar neurons tend stay in layers that best suit their function. This observation supports recent studies (Lad et al., 2024 Song et al. 2024; Mu ett al.; 2024) indicating functional redundaney in adjacent layers. These studies have demonstrated
high prediction accuracy even after layer manipulations (Lad et al.] (024), identified block-level redundancy (Song al., 2024), and observed analogous attention patterns nearby layers (Mul et al. 2024). Furthermore, we find that weight similarity decreases with increasing layer distance, aligning with the hypothesized universal stages of inference across models (Lad et al. 2024h.
Clusters of Similar Transformer Layers Exist.
Beyond merely adjacent layers, we find that clusters of multiple similar, nearby layers exist within LLMs. As depicted in Figure [d layers 7-12 form such cluster, exhibiting relatively high mutual similarity (approximately twice the DOCS index values of other elements) in their MLP-UP module weights according to our DOCS index. This challenges the common practice of uniform layer configurations, as such designs fail to leverage the cluster structure revealed by DOCS, potentially limiting optimization during the SFT stage.
Many open-source LLM implementations, including GPT-2 (Radford et al. 2019). Llama (Tourron et al. 2023). Mistral (Jiang et al. (023)). Llama 3 (Dubey et 20024). Gpt-neox- 20b (Black et al. 2022). Opt (Zhagg et al., 2022). Codegeex (Zheng et al. 2023). Glm- 130b (Zeng et al. 2022), ), and
Flm (Li et al. 20033) adopt architectures where all layers have the same size. Furthermore, existing
literature on scaling laws for neural language models (Kaplan et al. 2020 Hofimann et al. 2022)
and purameter-efficien fine-tuning (PEFT) methods (Hu et al. 2021 Houlsby et al. 2019 often
assumes uniform layer sizes, treating the model as a homogeneously scaled entity.
Our observations suggest revisiting these assumptions. The presence of mutual similarity within the layers of a cluster indicates the potential to apply a distinct configuration to those layers, such as adjusting neuron sizes or training strategies. DOCS similarity can guide such designs, aligning with prior efforts to leverage layer clusters for reduced computation (Liao & Vargas 2024).
Comparing Weight Similarities Between Base and Instruction-Tunen Models.
We investigate whether base models and their instruction-tune counterparts exhibit similar weight patterns. We address questions such as: How different are the base and instruction fine-tuned mod- els? Which parts of the LLMs are most affected by instruction fine-tuning? Are there any patterns in the changes of weight matrices due to fine-tuning? This examination sheds light on how instruction tuning affects the internal weights of models (Ouyang et al. 2022).
Comparing Similarities Between Experts
We examine the similarity between experts in pre-trained Mixture of Experts (MoE) models. Do the experts have similar weights? Is there any expert that significantly different from the others? Our analysis provides insights into the diversity among experts (Shazeer et al.) 2017 Lepikhin et al., 2020
2 MATHEMATICAL PROPERTIES OF SIMILARITY INDICES
When evaluating similarity indices for neural network weights, especially in the context of large language models, a critical property to consider is their ability to discriminate between orthogonal matrices. Orthogonal matrices play significant role in neural network initialization and training- They are often used to improve training stability and preserve gradient flow. Even after optimization, weight matrices may retain orthogonality properties (Tian et al. (023). Therefore, a similarity index that can distinguish between different orthogonal matrices is essential for capturing meaningful variations in weight matrices.
We categorize the behavior of similarity indices concerning orthogonal matrices into three classes:
Definition 1 (Constant Orthogonal Matrices). An index S is constant orthogonal matrices if there exists a constant E RR such that for all n E N and all orthogonal matrices X, Y e guxn have S ( Y)= C.
3

---

Published as a conference paper at ICLR 2025
Definition 2 (Dimension Denoonn--eDennntneeeee on Orthogonal Matrices). An index S is dimension-dependen on orthogonal matrices if for each n E N, there exists a constant ((n) E R such that for all orthogonal matrices X, E R=x=, we have Y) C(n).
Definition 3 (Discriminative Orthogonal Matrices). An index S is discriminative orthogonal matrices if there exist orthogonal matrices X, X', Y' E R2xx such that S( + S(X', ,Y)'
Apart from the behavior concerning orthogonal matrices, there are other desirable mathematical properties that ensure similarity indices provide meaningful and consistent comparisons across dif- ferent models and layers. These properties include:
1. Permutation Transformation (PT) Invariance (Williams al. 2021
S Y) = S(XPx,YPy)
where Px and Py are permutation matrices. This property characterizes the ability of an index to be unaffected by permutations in the neuron ordering.
2. Symmetry. S(X,Y) order of the inputs, ensuring fair comparison between matrices.
5(Y,X) The similarity measure should be independent of the
3. Isotropic Scaling (IS) Invariance. (Klabunde et al. 2023a S(aX, bY) = S(X, Y) for any non-zero scalars a, b. This allows for meaningful comparisons of models trained under different conditions, such as varying learning rates or initialization schemes that scale the weights differently.
4. Reflexivity, S(X, X) = 1. matrix should be most similar to itself, providing a normal- ization baseline for similarity measures.
Table 1: Comparison of Mathematical Properties Across Different Similarity Indices.
Method
PT Invariance
Symmetry
IS Invariance
Reflexivity
Behuvior on Orthogunul Mutrices
Lincar Regression
Constant
CCA (R(cx) Morens et al.
2018
Constant
CCA (ACCA)
Constant
SVCCA (oavo T Kagaa Kapga al.
2017
Constant (assuming Ty Ty
SVOCA (psvoca) Kaginn
V
Constant (assuming T' Ty
Linear HSIC Gretton et al 2005
X
Dimension Dependent
Lincar
Constant
DOCS (Ouns)
Discriminative
[able[cooppree the behavior of various similarity indices with respect to these mathematical prop- erties. Our proposed DOCS index introduces a discriminative behavior on orthogonal matrices (see Section 3.I for theoretical results) and satisfies all the other mathematical properties outlined above. This discriminative capability allows DOCS to capture meaningful differences between weight ma- trices that other similarity indices-which are constant or dimension-depeendent on orthogonal ma- trices (see proofs in Appendix B might overlook. Consequently, DOCS provides a more reliable and accurate measure of similarity between LLM weight matrices, enhancing the analysis and un- derstanding of neural network behaviors.
In Appendix D. discuss additional mathematical properties, some of which DOCS may not sat- isfy. These properties, while valuable in other contexts, are not critical for evaluating weight simi- larity measures in neural networks.
3 DISTRIBUTION OF COSINE SIMILARITY
Our DOCS method operates by comparing the weight matrices of two components (e.g., feed- forward networks, attention heads) within a neural network. Each component is represented by matrix where columns correspond to individual parameter vectors (e.g., neuron weights, attention patterns). The key idea is to quantify how well the parameters from one component align with those from another, based their vector representations.
4

---

Published as a conference paper at ICLR 2025
Algorithm 1 Computation of the DOCS Similarity Index Spocs
1: Input: Matrices X [X1, X2,..., Xm] Rexm and Y [Y1, Y2...., Yml Ruxm
2: Output: Similarity index Spocs
3: function MAXCOSSIM(A, B)
A] BR
4: Compute the cosine similarity matrix C' E Rm where Cyk
||A, (ll BB
5: For each column Aj. find 8A, max; [Cjk]
6: return S
: 8A2 ... SAm.
7:
end function
8: Compute sx = MAXCOSSIM(X,
9: Compute Sy MAXCOSSIM(Y,A)
10: Fit a Gumbel distribution to Sx to estimate the location parameter using maximum likeli- hood estimation
11: Fit a Gumbel distribution to sy to estimate the location parameter uy using maximum likelihood
estimation
12: Compute the similarity index:
+ uy
Spocs
The DOCS algorithm consists of the following steps:
Compute Cosine Similarities: Calculate the cosine similarity between all pairs of param- eter vectors from the two weight matrices. This results in cosine similarity matrix C, where each element Cjs quantifies similarity between the j-th vector from and k-th vector from Y.
2. Extract Maximum Similarities: For each vector in X, identify the vector in Y with which it has the highest absolute cosine similarity. This captures the strongest alignment for each vector.
3. Fit Gumbel Distribution: Fit separate Gumbel distributions to sx and Sy by treating the elements in each vector as data points. Using maximum likelihood estimation, compute the location parameters ux and wy. respectively. This allows summarize each distribution with single parameter.
4. Compute DOCS Index: The location parameters ux and uy of the fitted Gumbel distri- butions represent the central tendency of the maximum similarities. Averaging uxx and uy yields the DOCS similarity index Spocs-
The DOCS index Spocs provides scalar value between 0 and that reflects the degree of similarity between the two weight matrices. higher value indicates that the matrices have parameters (e.g., neuron weights or attention patterns) that are highly aligned, suggesting similar functional roles. Conversely, a lower value implies less similarity, indicating that the components may be specialized for different functions.
By focusing on maximum cosine similarities and modeling their distribution, DOCS captures signif- icant parameter alignments instead of averaging over all pairwise similarities. In contrast, similarity indices such as Canonical Correlation Analysis (CCA) (Morcos et al., 2018). Singular Vector CCA (SVCCA) (Raghu et al. 2017), and linear Centered Kernel Alignment (linear CKA) (Kornblith et al. 2019) rely on matrix multiplication to aggregate pair-wise information across entire matrices. This aggregation dilute strong correspondences between specific parameter vectors, potentially over- looking meaningful alignments. Consequently, DOCS effectively detects strong correspondences between components, enhancing the analysis of deep neural network structures.
3.1 THEORETICAL JUSTIFICATION
We establish that DOCS can distinguish between orthogonal matrices, a capability that existing similarity indices lack (see Section 2). The following theorem demonstrates that DOCS not only

---

Published as a conference paper at ICLR 2025
meets the Definition B of being discriminative orthogonal matrices but also achieves a stronger level of distinction through a constructive proof.
Theorem 1. For 2 2, there exist m Q(n)) and column-orthogonl matrices X,Y Y. R such that their Frobenius norm difference and DOCS similarity satisfy:
| - Y = = and Spocs(X,Y)
Vm
The proof of the theorem is deferred to Appendix The intuition behind the proof is to construct the matrices X and Y with orthonormal columns but differing structures highlight their dissimilarity. The matrix X is built from standard basis vectors, while Y leverages a normalized Hadamard matrix ensure orthonormality. By calculating the Frobenius norm of the difference X -Y, show that it scales as vm. Meanwhile, the DOCS value between X and Y is controlled by the normalized entries of the Hadamard matrix, demonstrating that their cosine similarity is small, the order of 1/ym. This gap between the large Frobenius norm and small DOCS establishes the desired properties.
This theorem proves the existence of column-orthogon matrices with significant differences ||X Y| $2( m)). Unlike existing methods, DOCS similarity effectively captures these differences SDOCS (X, Y)= m demonstrating its superior discriminative power for orthogonal matrices (see
Table T. An illustrative example is provided in Appendix A.5
EXPERIMENTS
conduct experiments to demonstrate the capabilities of DOCS and to gain insights into the inter- nal structure of LLMs. In LLM implementationss] the rows of weight matrix correspond to output dimensions, and the columns correspond to input dimensions. To align the column vectors with meaningful entities (e.g., neuron weights), transpose W., Wg. Wg. and MLP-UP PP before com- puting DOCS scores. In the MoE experiment, W, and W3 (Jiang et al. 2024) are also transposed for consistency.
4.1 COMPARISON OF SIMILARITY INDICES
Figure provides visual comparison of eight different similarity indices applied to the MIP-UP layers of the Meta-Llama-3, 1atamma-3111880 1-8---18-IIntt model.
Lavers
0.8
20
06
28
Layers
Layers
Layers
Layers
(a) Linear Regression
(b) CCA
CCA (Nuclear)
(d) SVCCA
0.50
0055
078
Layers
Loyor
Lavers
0.6
0000
0015
26
33
20
20
26
(e) SVCCA (Nuclear)
(1) Linear HSIC
(g) Linear CKA
(h) DOCS
Figure 2: Comparison similarity indices on the MLP-UP layers Meta-Llama 3.1-8B-Instrre

---

Published as a conference paper at ICLR 2025
In these visualizations, we observe that Linear Regression, Canonical Correlation Analysis (CCA), and CCA (Nuclear) indices fail to exhibit clear structural patterns, with their heatmaps appearing noisy. This suggests that they may have limitations in accurately capturing meaningful relationships between the parameters different transformer layers. The observed noise could be indicative of their reduced sensitivity the underlying layer similarities.
On the other hand, the similarity indices Singular Vector CCA (SVCCA), SVCCA (Nuclear), and Linear Centered Kernel Alignment (Linear CKA) display more discernible patterns. Specifically, they exhibit block-diagonal structures, which suggests that the layers in close proximity share higher similarity. This behavior aligns with our expectations, as neighboring layers within transformer models often exhibit greater parameter correlation due to their sequential processing of information. However, we also observe the presence of minor blocks and stripes the off-diagonal regions, which could be attributed to biases or noise in the similarity indices. These artifacts may result from the indices' reduced ability differentiate orthogonal matrices, as elaborated in Section 2
In contrast, the heatmap for DOCS exhibits clear structure along the diagonal, demonstrating its effectiveness in identifying similar layers with minimal interference from noisy or unrelated signals. Furthermore, we calculated the Gini coefficients of the similarity heatmaps obtained through each method (calculation details are provided in Appendix HD. A higher Gini coefficient indicates uneven distribution of similarity scores, signifying greater concentration of significant similarities in fewer layer pairs. This concentration potentially highlights structural characteristics of the model parameters. As shown in Table 2 DOCS achieves the highest Gini coefficient among all the evaluated similarity indices. This result suggests that DOCS excels in revealing structural characteristics of the model parameters.
Table 2: Gini Coefficients for Different Similarity Indices on MLP-UP of Meta-Llama-3. 1-BB- Instruct
Similarity Index
Gini Value
CCA Nuclear Similarity
0.0098
CCA Similarity
0.0098
Linear CKA Similarity
0.0488
Linear HSIC Similarity
0.0617
Linear Regression Similarity
0.0098
SVCCA Nuclear Similarity
0,0186
SVCCA Similarity
0.0225
DOCS (Ours)
0.0745
Appendix E.3 provides more experimental results.
4.2 NEIGHIBRIING LAYERS EXHIBIT SIMILAR WEIGHTS
We investigated the similarity patterns between neighboring transformer layers by analyzing various weight matrices (W., Wx. W W.. MLP-UP, MLP-DoWN) in various LLMs. We employed DOCS to compute and visualize these similarities. Figure illustrates the results for Wa. W,, and MLP-DOWN on gemma-2-27b-in
The heatmaps clearly show that adjacent layers exhibit higher similarity scores. Scatter plots in Figures (d), (e), and (f) further support this, displaying decreasing trend in similarity as the absolute layer index difference increases. The shaded areas, representing one standard deviation around the mean similarity, reinforce this observation.
Interestingly, the first and last layers- the most distant ones also display higher similarity, as in- dicated by upward trends at the ends of the scatter plots. We hypothesize that this is because both layers are closely connected to the token embeddings. Similar patterns were observed for other weight matrices and across different L.MSs.
7

---

Published as a conference paper at ICLR 2025
0.14
0.12
0.12
0.11
16
Layers
Layers
0.10
23
78
0.09
0.08
0.08
8
0.06
0.06
0.07
Layers
Layers
Layers
(a) W
(h) Wa
(c) MLP-UP
0.14
Similarity Points
Similerity Points
0.14
Smilerity Points
Mean Similarty
Similanty
Similartyy
Siillarit
0.12
Standard Deviation
Similarity
#1 Standard Devistion
Similarity
0.12
#1 Standard Deviation
0.10
0.10
0.10
3.00
0.08
0.00
0.06
0.06
20
40
10
30
10
20
30
40
Layer index Absolute Difference
Layer Index Absolute Difference
Layer Index Absolute Difference
(d) W
(e) W
(f) MLP-UP
Figure 3: The top row displays heatmaps of DOCS scores between layers for different weight ma- trices in gemma-22 gemma-2-277-it 2-27bbit. The bottom row illustrates the relationship between DOCS scores and the distance between layers.
Due to space limitations, other results are presented in Appendix These findings suggest that neighboring layers tend to share more functional similarities compared layers that are farther apart.
4.3 CLUSTERS OF SIMILAR LAYERS
We examined clusters of similar consecutive layers within LLMs. Figure 4 shows heatmaps of DOCS scores for the W, matrices. They reveal clusters represented by light regions- contain- ing multiple layers with high mutual DOCS scores. The bottom row displays the average DOCS scores for diagonal blocks ranging from x x 7, providing a clearer view of cluster locations and their similarity levels.
interesting pattern emerges: each figure shows two clusters of layers. The first cluster, located in the middle depths (centered around layer 19 in gemma-2-9h and gemma-2-27b, and around layer 10 in Llama-3.1-80 3-BBBBBBBBBBBBBBBB and Mixtral-&x7B), is the most distinct. The second cluster appears in the last layers (after layer 27 in gemma-2-9b, after 33 in gemma-2-27b after 21 in Llama-3. 23 in Mixtr, though it is less pronounced in some models. This phenomenon, observed across different model sizes and even vendors, suggests universal structural pattern resulting from LLM training. The consistent appearance of these clusters indicates that the training process leads the formation of distinct functional groups of layers within the model.
and after
Different models, however, may exhibit a varying number of clusters. For example, Figure 5 shows that Llama-3.1 3-0B contains multiple clusters.
4.4 BASE vs. INSTRUCT MODELS
We used the DOCS index to measure changes in weight matrices between base and instruction-tumm tuned models, examining LLM families including yi-1.5, Llama-3.1, and gemma-2. Figure [ illustrates the results. Our analysis reveals that all DOCS scores notably high, with values exceeding 0.7 for every matrix evaluated. This indicates that the base and instruction-tuum models largely retain the same foundational knowledge after the fine-tuning process.
On the other hand, a notable observation from our results is the tendency the weight matrices to cluster into three distinct groups based the trends observed in their DOCS scores. Specifically,
8

---

Published as a conference paper at ICLR 2025
0.56
0.0
Layas
Layess
0.37
202
0.7
0.66
0.06
0.06
76
Layers
Layers
Layers
Layers
gemma-2-9b
(b) gemma-2-276
(c) Llama-3.1-8B
(d) Mixtral-8x7B
0.055
0.055
Elec--be
0,090
Blcck
0.095
0000
3,000
nocs Sinlless
0.08s
Eleck Sen
0.000
c.ces
Elock
0.085
6.090
$0.075
0.05
0.070
0.000
0.070
6600
0.065
0.005
0.066
6,090
0.000
10 35 40
20 Position
40
10
Block Most.on
Postaon
(e) gemma-2-9b
(1) gemma-2-27b
(g) Llama-3.1--
(h) Mixtral-8x7B
Figure 4: Analysis of W matrices across various LLMs. Top row: Heatmaps visualize DOCS similarity scores between transformer layers. Bottom row: Average DOCS scores computed for diagonal blocks (sizes 3x3 to 7x7) within each heatmap.
Zo.12
0.13
Mick Bin
Mick
Bowrage Doce Cemilety
0.30
Book Sin
Average DoCS Simttrity
0.07
0.
o:c0
0.09
5000
3007
5.06
0.04
0.06
0.06
Ster
Rlack Poutine
Block Posttio
Block Paschio
Rlock Posttion
(a) MLP-DOWN
(b) MLP-UP
W
(d) W.
Figure 5: Average DOCS scores for diagonal blocks of varying sizes (3x3 to 7x7) within heatmaps representing different weight matrices Llama-3.1-70BB.
these groups consist of MLP-UP and MLP-DOWN, W, and W.. well as W, and W.. This grouping may be due to the functional similarities between these matrices in the model architecture.
4.5 MOE EXPERIMENT
We analyzed the weights of different experts Mixtral-8x7B using DOCS to generate similarity heatmaps for the expert weight matrices (Wi, W2, W₂) in the MoE network. The outcomes visualized in Figure 7
In many model layers, typically just expert stands out, indicated by dark grids that show clear separation from the others. Figures 7a 7c this with the third expert's prominent dark intersecting lines, highlighting its uniqueness. This suggests some experts may have specialized roles, differing in function or behavior within the architecture. We hypothesize that this may be related data load imbalance during the MoE training process, where a large portion of the data
concentrates on single expert (Dai al. 2022 Zuo al. 2021
CONCLUSION AND FUTURE WORK
This work introduces DOCS, novel index for quantifying weight similarity in large language mod- els. Unlike existing similarity indices, DOCS effectively differentiates orthogonal matrices, ad- dressing a key limitation and enabling deeper insights into the internal structures of L.Mss. Our

---

Published as a conference paper at ICLR 2025
N.P Ligums Doar pens
090
0005 Smitand
UDCS Simlerty
1333
0.0
2.245
000
0.00
000
0435
25
(a) yi-1.5-9b
(b) yi-1.5-9b
(c) yi-1.5-9b
HUF Doin pat
DOCS Smiarts
Gmilety
0.330
0.0035
2080
03973
0.9970
25
Layers
Layers
Layers
(d) 1lama-3.1-88
(c) Llama-3.1-8P
(f) Llama-3.1-80
MJ7 N.7.Dowm.ne
0.993
0205 Srstang
3.87
0.903
0.00
0.73
0333
0.4
0.93
Layerss
Layyrrs
Layerrs
(g) gemma- 2-9b
(h) gemma-2-90
gemma-2-444
Figure 6: DOCS similarity scores between the base and instruction fine-tuned weight matrices for various models.
034
014
0L00
Experts
Experts
Experts
Operts
(a) Wi in layer one
(b) W2 in layer one
(c) Wa in layer one
(d) Wa in layer 25
Figure 7: DOCS similarity scores between the MoE experts.
experiments uncovered meaningful patterns, including high similarity between neighboring layers and the presence of similar layer clusters. These findings underscore the potential DOCS to guide applications in several ways. First, the identified cluster structures could be leveraged to in- troduce inductive biases during the supervised fine-tuning stage of parameter-efficien techniques. Second, the clustering results offer valuable information for designing sparsity patterns aimed at model compression. By targeting redundant connections within clustered layers, we may be able to significantly reduce model size and computational costs without compromising performance. Third, these findings can inform more efficient knowledge distillation strategies by identifying critical lay- that deserve prioritization in the distillation process. A student model could focus replicating the most representative layers within each cluster, thereby alleviating the computational overhead associated with emulating the teacher model's entire architecture.
10

---

Published as a conference paper at ICLR 2025
REFERENCES
Serguei Barannikov, Ilya Trofiov,, Nikita Balabin, and Evgeny Burnaev. Representation topol- ogy divergence: A method for comparing neural network representations. arXiv preprint arXiv:2201.00055 2021.
Sid Black, Stella Biderman, Eric Hallahan, Quentin Anthony, Leo Gao, Laurence Golding, Horace He, Connor Leahy, Kyle McDonell, Jason Phang, al. Gpt-neox-20b: An open-source autore- gressive language model. arXiv preprint arXiv:220.006745. 2022.
Tom B Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, and others. Language models few-shot learners. In Advances in Neural Information Processing Systems, volume 33, pp- 1877-1901, 2020.
Francesco Camastra and Antonino Staiano. Intrinsic dimension estimation: Advances and open problems. Information Sciences, 328:26-41, 2016.
Damai Dai, Li Dong, Shuming Ma, Bo Zheng, Zhifang Sui, Baobao Chang, and Furu Wei. Stable- moe: Stable routing strategy for mixture of experts. arXiv preprint arXiv:2204.08396, 2022.
Abhimanyu Dubey, Abhinav Jauhri, Abhinav Pandey, Abhishek Kadian, Ahmad Al-Dahle, Aiesha Letman, Akhil Mathur, Alan Schelten, Amy Yang. Angela Fan, et al. The llama 3 herd of models. arXiv preprint arXiv:2407.21720 2024.
Arthur Gretton, Olivier Bousquet, Alex Smola, and Bernhard Schölkopf. Measuring statistical de- pendence with hilbert-schmidt norms. In International conference on algorithmic learning theory, pp. 63-77. Springer, 2005.
William I. Hamilton, Jure Leskovec, and Dan Jurafsky. Diachronic word embeddings reveal statis- tical laws of semantic change. arXiv preprint 1eX.::1605.00096 2016.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recog- nition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 770-778. IEEE, 2016.
Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch, Trevor Cai, Eliza Rutherford, Diego de Las Casas, Aurelia Guy, Jacob Menick, Raphaël Milliere, Scott Reed, et al. Training compute- optimal large language models. arXiv preprint arXiv: /5556, 2022.
Neil Houlsby, Andrei Giurgiu, Stanislaw Jastrzebski, Bruna Morrone, Quentin De Laroussilhe, An- drea Gesmundo, Mona Attariyan, and Sylvain Gelly. Parameter-efficient transfer learning for nlp. In International conference on machine learning, pp. 2790-2799, PMLR, 2019.
Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.0940 09685, 2021.
Albert Jiang, Alexandre Sablayrolles. Antoine Roux, Arthur Mensch, Blanche Savary, Chris Bam- ford, Devendra Singh Chaplot, Diego de las Casas, Emma Bou Hanna, Florian Bressand, et al. Mixtral of experts. arXiv preprint arXiv:2401.0408: 2024.
Xinyu Jiang, John Smith, Jane Doe, et al. Mistral 7b: compact and effective transformer model. arXiv preprint arXiv:2309.0553 2023.
Jared Kaplan, Sam McCandlish, Tom Henighan, Tom Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, and Dario Amodei. Scaling laws for neural language models. arXiv preprint arXiv:2001.08366 2020.
Meenakshi Khosla and Alex H Williams. Soft matching distance: A metric neural representations that captures single-neum neuron tuning. In Proceedings of UniReps: the First Workshop on Unifying Representations in Neural Models, pp. 341. PMLR, 2024.

---

Published as a conference paper at ICLR 2025
Max Klabunde, Mehdi Ben Amor, Michael Granitzer, and Florian Lemmerich. Towards measuring representational similarity of large language models. In UniReps: the First Workshop on Unifying Representations in Neural Models, 2023a.
Max Klabunde, Tobias Schumacher, Markus Strohmaier, and Florian Lemmerich. Similarity of neural network models: A survey of functional and representational measures. arXiv preprint arXiv:2305.006329 2023b.
Simon Kornblith, Mohammad Norouzi, Honglak Lee, and Geoffrey Hinton. Similarity of neural network representations revisited. In International conference on machine learning, pp. 3519- 3529. PMLR, 2019.
Nikolaus Kriegeskorte, Marieke Mur, and Peter A Bandettini. Representational similarity analysis- connecting the branches of systems neuroscience. Frontiers in systems neuroscience, 2:249, 2008.
Vedang Lad, Wes Gurnee, and Max Tegmark. The remarkable robustness of Ilms: Stages of infer- ence? arXiv preprint arXiv:2406. 19384, 2024.
Dmitry Lepikhin, HyoukJoong Lee, Yuanzhong Xu, Dehao Chen, Orhan Firat, Yanping Huang, Maxim Krikun, Noam Shazeer, Zhifeng Chen, Tamara Duke, et al. Gshard: Scaling giant models with conditional computation and automatic sharding. arXiv preprint arXiv:2006. 16668, 2020.
Xiang Li, Yiqun Yao, Xin Jiang, Xuezhi Fang, Xuying Meng, Siqi Fan, Peng Han, Jing Li, Li Du, Bowen Qin, et al. Flm-101b: An open Ilm and how to train with 100 budget. arXiv preprint wrX.0:2309.03852, 2023.
Bingli Liao and Danilo Vasconcellos Vargas, Beyond kv caching: Shared attention for efficient Ilms. arXiv preprint arXiv:2407. 12866 2024.
Ari Morcos, Maithra Raghu, and Samy Bengio. Insights on representational similarity in neural networks with canonical correlation. Advances in neural information processing systems, 31, 2018.
Yongyu Mu, Yuzhang Wu, Yuchun Fan, Chenglong Wang. Hengyu Li. Qiaozhi He, Murun Yang, Tong Xiao, and Jingbo Zhu. Cross-layer attention sharing for large language models. arXiv preprint #xXv:2240.001890 2024.
Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll I. Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, al. Training language models to follow instructions with human feedback. arXiv preprint arXiv:2203.02/555 2022.
Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. OpenAl Blog. 1(8):9, 2019.
Maithra Raghu, Justin Gilmer, Jason Yosinski, and Jascha Sohl-Dickstein. Sveca: Singular vector canonical correlation analysis for deep learning dynamics and interpretability. Advances in neural information processing systems, 30, 2017.
Adir Rahamim and Yonatan Belinkov. Contrasim Contrasim-anallzing analyzing neural representations based on trastive learning. In Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguisties: Human Language Technologies (Volume I: Long Papers), pp. 6325-6339) 2024.
James O Ramsay, Jos ten Berge, and George PH Styan. Matrix correlation. Psychometrika, 49(3): 403-423, 1984.
Noam Shazeer, Azalia Mirhoseini, Kelsey Maziarz, Andy Davis, Quoe V Le, Geoffrey E Hinton, and Jeffrey Dean. Outrageously large neural networks: The sparsely gated mixture-of-experts layer. arXiv preprint arXiv: 0et.:::170.065550 2017.
Jiwon Song, Kyungseok Oh, Taesu Kim, Hyungjun Kim, Yulhwa Kim, and Jae-Joon Kim. Sleb: Streamlining Ilms through redundancy verification and elimination transformer blocks. arXiv preprint arXiv:2402.0900 2024.
12

---

Published as a conference paper at ICLR 2025
Shuai Tang, Wesley J Maddox, Charlie Dickens, Tom Diethe, and Andreas Damianou. Similarity of neural networks with gradients. arXiv preprint arXiv:2003. 2020.
Yuandong Tian, Yiping Wang, Zhenyu Zhang, Beidi Chen, and Simon Du. Joma: Demystifying mul- tilayer transformers via joint dynamics of mip and attention. arXiv preprint arXiv:2310.00535, 2023.
Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Roziere, Naman Goyal, Eric Hambro, Faisal Azhar, et Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302. 13971, 2023.
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention all you need. In Advances Neural Infor- mation Processing Systems, volume 30, pp. 5998 6008, 2017.
Chenxu Wang, Wei Rao, Wenna Guo, Pinghui Wang, Jun Liu, and Xiaohong Guan. Towards un- derstanding the instability of network embedding. IEEE Transactions on Knowledge and Data Engineering, 54(2):927-941) 2020.
Liwei Wang. Lunjia Hu, Jiayuan Gu, Zhiqiang Hu, Yue Wu, Kun He, and John Hoperoft. Towards understanding learning representations: To what extent do different neural networks learn the same representation. Advances in neural information processing systems, 31, 2018.
Alex H Williams, Erin Kunz, Simon Kornblith, and Scott Linderman. Generalized shape metrics neural representations. Advances in Neural Information Processing Systems, 34:4738-4750, 2021.
John M Wu, Yonatan Belinkov, Hassan Sajjad, Nadir Durrani, Fahim Dalvi, and James Glass. Simi- larity analysis of contextual word representation models. arXiv preprint arXiv:2005.00 172, 2020.
Aohan Zeng, Xiao Liu, Zhengxiao Du, Zihan Wang, Hanyu Lai, Ming Ding, Zhuoyi Yang, Yifan Xu, Wendi Zheng, Xiao Xia, et al. Glm-130b An open bilingual tre-trained model. arXiv preprint arXiv:2210.02414. 2022.
Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christo- pher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, al. Opt: Open pre-trained transformer language models. arXiv preprint arXiv:2205.001 200022000..00,,,. 2022.
Qinkai Zheng, Xiao Xia, Xu Zou, Yuxiao Dong, Shan Wang, Yufei Xue, Zihan Wang, Lei Shen, Andi Wang, Yang Li, et al. Codegeex: A pre-trained model for code generation with multilingual evaluations humaneval-x. arXiv preprint arXiv:2303. 17568, 2023.
Simiao Zuo, Xiaodong Liu, Jian Jiao, Young Jin Kim, Hany Hassan, Ruofei Zhang, Tuo Zhao, and Jianfeng Gao. Taming sparsely activated transformer with stochastic experts. arXiv preprint 10.04221 2021.
13

---

Published as a conference paper at ICLR 2025
A PROOFS OF MATHEMATICAL PROPERTIES OF DOCS SIMILARITY INDICES
A.1 PROOF OF PERMUTATION TRANSFORMATION INVARIANCE
Lemma (Permutation Transformation Invariance). Let X,Y <I and let Px, Py mmxm be permutation matrices. Then the DOCS similarity index is invariant under permutation transfor- mations:
S(X,Y) S(XPx,
Proof. We aim show that the DOCS similarity index invariant under permutation transforma- tions:
Spocs X, Y) Spocs(XPs YPy),
where Px and Py are permutation matrices of size x m.
First, recall that multiplying a matrix by permutation matrix permutes its columns. Specifically, if ox the permutation associated with Px, then:
XPx (I)) (ox()) .... (ox(m))
where Xox (J) denotes the xx (j)-th column of X. Similarly, Y YPy permutes the columns of Y according to the permutation σy:
YPy = (1), Yoy(2), ... (oy(m))
Next, compute the cosine similarity matrix C mmmx between X and Y:
Y
Cjs- = ||X, ||
where Xj and Y are the j-th and k-th columns of X and Y, respectively.
When we compute the cosine similarity matrix C' between the permuted matrices XPx and Y YPy, we get:
C₁ = (XPx)](YPP))
XT X xxx Yor [|x (1
[(XXx) [[
This shows that C²2x oy (k) In other words, C' is reordering of the entries of C based on the permutations dx and dy.
In the MAXCOSSIM function of the DOCS algorithm |
for each j. we compute:
sx, max [Cykl=
Similarly, for the permuted matrices, we have:
8(XPx), max [C2xl = max (Cox)) &
Since σy is a permutation of (1,2....,m)) as & ranges over 1 to m, so does (k). Therefore:
s(xxx); = max (Cxx (1)) = max (). Sx,x
(1))
This means that 8(XPx), is equal 8 ()) indicating that the sequence {s(XPx)) permuta- tion of {sx,} based on ox. Similarly, for Y and its permutation YPy, we find:
max 1Cyy1 max C (y) = max (y) = SYover)
s(yPy), y
Thus, StyPy), is equal to sy,ya), so the sequence {s(yBy) permutation of {sy, based on ay.
14

---

Published as a conference paper at ICLR 2025
When we fit Gumbel distributions to the sequences {sx, and (x(xPx), J. or (sy, and (s }. the estimated location parameters ux and u'x (or uy and udy) remain the same because the sets of values are identical up to permutation.
Therefore, the DOCS similarity index remains unchanged:
Spocs Sxxcs(XXxx YPy)
" + tly
ux uy
Spocs (X,Y).
2
This concludes the proof that the DOCS similarity index is invariant under permutation transforma- tions.
A.2 PROOF OF SYMMETRY
Lemma 2 (Symmetry). For any matrices X,Y Y E R=x" the DOCS similarity index satisfies:
Spocs (o, Y) Spocs(Y,
Proof. Compute the cosine similarity matrix C' E Rmxm where:
Y Cjk- || ||&2|
Note that Cjk- Cuj because:
Y |X &
Y,T.
Cjs
Ckj.
Therefore, the cosine similarity matrix C is symmetric. The MaxCosSim function computes for each j:
8x, = max |Cyal=
&
Similarly, for Y and X:
8Y. = max [Ckyl max Cjaal- Thus, the { and { } are identical.
Fitting Gumbel distributions to (*x,) and {sy, yields identical location parameters:
ux ny.
Therefore, the DOCS similarity index is:
Spocs(X,Y) +
ux uY Spocs (Y, X).
A.3 PROOF OF ISOTROPIC SCALING INVARIANCE INVARIANCE
Lemma 3 (Isotropic Scaling Invariance). For any matrices X,Y paxm and nonzero scalars a, E R. the DOCS similarity index satisfies:
Spocs(aX, Spocs(X, ().Y).
Proof. Consider the scaled matrices:
= - bY.
The cosine similarity between columns X, and Ye is:
X7
((b2)
abx, Yv
XTYr
CSK ||xx ||
=Cjk-
laX,l bbai
al|X;|| bl Yıll
XX,|| Y&ll
15

---

Published as a conference paper at ICLR 2025
Therefore, the cosine similarity matrix Č is identical to C. For each column Xj, the maximum absolute cosine similarity is:
max [Cyal SX, $ max [Cykl
k:
Similarly, Sy, SYL-
Thus, the vectors x and sx are the same, are sy and sy. Fitting a Gumbel distribution yields the same location parameters:
"x ux: up uy.
Therefore,
ux + uy U + uy
Spocs Sbocs(aX,bb))
Spocs (X,
2
2
A.4 PROOF OF REFLEXIVITY
Lemma 4 (Reflexivity). For any matrix X E Raxm the DOCS similarity index satisfies:
Xpo XX
Proof. Compute the cosine similarity matrix C Rm where:
XTXA Xx
Cjk
||
When j = k, we have:
XJX, =1 O₁ ||X
Since the absolute value of the cosine similarity is bounded by 1, for each j:
8x, = max |Cjul = 1.
&
Therefore, the vector sx [1,
Fitting Gumbel distribution to x consisting of all ones yields a location parameter:
ux 1.
Similarly, since Y X, have sy 8x and my ux 1. Therefore, the DOCS similarity index is:
1+1 = Sx,cs(X, ux + uy
2
A.5 PROOF OF DISCRIMINATIVE ON ORTHOGONAL MATRICES
Lemma 5 (Discriminative on Orthogonal Matrices). There exist orthogonal matrices X, X,Y X',Y"
such that:
Spocs(X, Y) * Spocs(X', YY).
Proof. Consider the following orthogonal matrices:
First pair:
0.6676
0.5171
-0.3557
0.1837
0.5950
0.78257
X
0.7310
-0.5917
0.3399
Y
0.0457
-0.7900
0.6114
0.1412
0.6185
0.7730
0.9819
0.1481
0.1179
16

---

Published as a conference paper at ICLR 2025
Second pair:
0.8499
0.0164
0.5267
0.7028
-0.6446
-0.3009
X'
0.0816
-0.9915
-0.1009
Y"
0.3734
-0.6943
0.6153
0.5206
-0.1287
0.8440
0.6056
0.3200
0.7286
Compute the DOCS similarity index for each pair:
For X and Y:
Spocs (x Y) = 0.88.
For X' and Y
SDocs (X),") 0.76.
Since SDOCS (X, Y) SDocS Y the DOCS similarity index distinguishes between different pairs of orthogonal matrices. Therefore, discriminative on orthogonal matrices.
B PROOFS OF NON-DISCRIMINATIVE NATURE OF OTHER SIMILARITY INDICES FOR ORTHOGONAL MATRICES
In this section, we present the proof's demonstrating that other common similarity indices are either constant depend only the dimensions of the matrices when applied orthogonal matrices.
B. LINEAR REGRESSION
The Linear Regression Similarity defined as:
|
SLR Y)
||
where Qx and Qy orthonormal bases for the columns of X and Y, respectively.
Lemma 6. For any orthogonal matrices X, X,Y Raxn.
Q x
is a constant that is independent of n.
Proof. Since and Y are orthogonal matrices, their columns form orthonormal bases. Simply let Qx X and Qy Y.
We begin by evaluating the Frobenius norm squared of QT
x ||yTX|| XIE trace (X""X) x)) trace (X"ry'X)).
Since Y is orthogonal, YYT = I. Thus, the expression simplifies to:
trace xx trace (/)
Next, we compute the Frobenius norm squared of X:
|X trace (x xx) trace (1)
Therefore, the ratio is:
1 xI
1.
X IXI
T2
17

---

Published as a conference paper at ICLR 2025
B.2 CANONICAL CORRELATION ANALYSIS (CCA) WITH ROCA
CCA (Reca) is defined as:
SCCA(REOX) () |1 Qx
"
where Qx and Qy represent orthonormal bases corresponding to the columns of X and Y, respec- tively.
Lemma 7. For any orthogonal matrices X,Y Raxn, the quantity
ccaA (OCA) (X,Y) 11
a constant that independent of n.
Proof. Since X and Y are orthogonal matrices, their columns form orthonormal bases. Therefore, Qx = X and Qy = =Y.
Consider the matrix Qx YTX. Since both Y and X orthogonal, their product YTX X is also an orthogonal matrix.
The Frobenius of orthogonal matrix Y is given by
P trace ((YT))" (0"T(TT)))))) = trace(In) = n,
where Ia is the x identity matrix.
Therefore,
1Q
11
n
B.3 CANONICAL CORRELATION ANALYSIS (CCA) WITH PCCA CCA (POCA) defined as:
|
SCCAlpoca) Y)
where Qx and Qy represent orthonormal bases corresponding the columns of X and Y, respec- tively. Lemma 8. For any orthogonal matrices X, Y E gaxn
SOCA(Foca)(X) (X,Y) |x
a constant that independent of n.
Proof. Since X and Y are orthogonal matrices, their columns form orthonormal bases. Therefore, Qx and Qy are also orthogonal matrices.
The product Q is an orthogonal matrix because the product of orthogonal matrices is orthogo- nal. For any orthogonal matrix A, the nuclear norm ||A| | is equal to the sum of its singular values. Since all singular values of orthogonal matrix equal I, we have:
| Σ (x(FF(x)
1==
1=1
Therefore,
1QFQxI1
72
72
18

---

Published as a conference paper at ICLR 2025
B.4 SINGULAR VECTOR CCA (SVCCA) WITH RSvOCA
SVCCA (R5vccx) is defined as:
(U>Ty UxxTx Ux F
min
[ pp 11.l1 11
where Ux and Uy represent the left singular vectors of X and Y. respectively, arranged in de- scending order based on their associated singular values. Meanwhile, Tx and Ty denote truncated identity matrices that retain the left singular vectors, ensuring that the accumulated variance meets a predefined limit. Here, we consider Tx Ty I.
Lemma 9, Assume that Tx = Ty For any orthogonal matrices X,Y Y E Rnxx.
[ Ux 2
S S
Syso
min
|Tx I
|
a constant independent of n.
Proof. Given that Tx = Ty = I, the expression simplifies to "xx=))xUX]]] ||
[UV) Ux min (1111 11/11)))
| |
Since Ux and Uy are orthogonal matrices, their product UpUU is also an orthogonal matrix, de- noted by Q. The Frobenius norm of an orthogonal matrix satisfies
Q
o (Qa trace(!) = n.
=1j=1
Additionally, the Frobenius norm the identity matrix / is
||
trace(I) = n.
Substituting these results back into the original expression, we obtain
|UşUx l|
n
=1
| |
B.5 SINGULAR VECTOR CCA (SVCCA) WITH ĀSvCCA SVCCA (ĀsvOcA) is defined as:
( U
S Specea
min [1xx|] | 11?
where Ux and Uy represent the left singular vectors of X and Y. respectively, arranged in de- scending order based their associated singular values. Meanwhile, Tx and Ty denote truncated identity matrices that retain the left singular vectors, ensuring that the accumulated variance meets predefined limit. Here, consider Tx Ty =
19

---

Published as a conference paper at ICLR 2025
Lemma 10. Assume Tx Ty I. For any orthogonal matrices X, Y E R
(U>TTy) Ux
pioccc
min
[|
|
is constant independent of
Proof. Since X and Y are orthogonal matrices in RR their singular value decompositions (SVDs) given by
X=UxExVX y-
where Σx and Ey diagonal matrices of singular values. Because X and Y are orthogonal, their singular values are all equal to I; thus, Σx = Ey J. Therefore, the SVDs simplify to
X UX Y U.
Given that Tx Tv I, the expression reduces to
|ITTU||.
|
min [|2 11111
n
Since Ux and Uy are orthonormal matrices, UFUx also an orthogonal matrix. The singular values of UFUx are thus equal to I, and the nuclear norm
1UFUXI1- i=1
2o,=n
Substituting back, we obtain
|1UFUX]]
n =
Therefore, the quantity is constant equal to 1, independent of n.
B.6 LINEAR HILBERT-SCHMIDY INDEPENDENCE CRITERION (HSIC)
Linear HSIC is defined as:
YTX
Sinnear (XI
(n - 1)2
Lemma 11. For any orthogonal matrices X, Y E BRxx
Siinar HSIC (X,Y) Y x p
(n 1)
is constant that depends solely
Proof. Let and be any orthogonal matrices in guxn, Since both X and Y are orthogonal, their transpose inverses satisfy X = YTY In, where I, is the identity matrix.
Consider the product YTx. X. Since the product of two orthogonal matrices also orthogonal, Y is orthogonal. The Frobenius norm of an orthogonal matrix A satisfies
|| trace( AA AA.)
Applying this to YT X, we have
y x 2 trace
trace (X"YY"X).
Since YYT = In. this simplifies to
trace (x"x) (trace(n))
Therefore,
Y x 2 (n 1)2 (n 1)2²
F
n
which depends only This concludes the proof.
20

---

Published as a conference paper at ICLR 2025
B.7 LINEAR CENTERED KERNEL ALIGNMENT (CKA)
Linear CKA is defined as:
YI
SeKA(X,Y) XX X Y Y
Lemma 12. For any orthogonal matrices X, E R the ratio
x 1
XXT |Y F
constant independent n.
Proof. Since X and Y are orthogonal matrices, we have:
x = In and y = Las
where La is the n x identity matrix.
The Frobenius norm of the identity matrix is:
82 Vn.
1=1 j=1
where dig is the Kronecker delta.
Thus, have:
| x|| = 1 Vn,
||yTy|| = =1/ = Vn.
Next, consider the matrix Y Since both X and Y are orthogonal, Y is also orthogonal:
xx" xTyyTxxv xTX= I,
Therefore, the Frobenius norm of y X is:
Y | |T 1pp Vn.
Substituting these results into the original ratio, we obtain:
| J
(VT)
=1
X |YTI|F
Vn- Vn
Therefore, the ratio is equal to which is a constant independent of n.
C PROOF OF THEOREM 1
We construct specific matrices X and Y to verify the stated properties.
Construction of and Y:
Let 2 2. Let 2 200g nl, so m ((1). Define:
E Raxm as X [ei, .., em), where e; is the i-th standard basis vector in RR.
Baxm as:
== vm ( Hm
(m)mm))m)))
where Hm the m x m Hadamard matrix, and is zero matrix.
Orthogonality of X and Y:
21

---

Published as a conference paper at ICLR 2025
The columns of X are orthonormal since they are standard basis vectors.
For Y:
(J1n m
(() Hm
1
y
Hm
H H
I I
m
m
since Hm Hm = mmm. Thus, the columns of Y are orthonormal.
Computing |X F|
Compute the Frobenius norm:
12 922 XX - YI
(Xig Yu))
==
For Si m:
hej
X1 Yss-
v m
where 6ig is the Kronecker delta and hij +1
For m +1 +isis n:
Xij Yij = 0 0.
Diagonal terms (i= j):
(1-
his vm
2
1
2
1
1
F
vm
/m
m
Off-diagonal terms (i j.1 1 i,j S m):
0
haj
1
/m
m
Summing all terms:
Number of diagonal terms: m. Number of off-diagonal terms: m(m 1).
Diagonal sum:
Since the 2
terms cancel out when summed over all
Vm
S Sing m (1+ 11 m
m
Off-diagonal sum:
1 m 1. Saft.dig = =m(m 1)
Total Frobenius norm:
|| VII Saiag Sat (m + + (m 1) 2m.
X Y 22 12 vn)
Computing Spocs(X,Y) Y): For columns X, and Yr. the cosine similarity is:
cos(0,x) = X Yk
|X
|
22

---

Published as a conference paper at ICLR 2025
hykk
Since ||x||| 1 and ||xi| 1, and Ys
we have:
mm
coo (00s(0))))
m
Thus, the maximum absolute cosine similarity for each column is
S0:
V
Spocs Poocs(X.V,) (XY)=
m
This demonstrates that the DOCS similarity inversely proportional the square root of the number of columns, m..
D EXCLUDED MATHEMATICAL PROPERTIES
In this section, we discuss the additional mathematical properties that could be considered when evaluating similarity indices:
Invertible Linear Transformation (ILT) Invariance (Raghu et al., 2017):
S(X S(XA,Y))
where A and B are arbitrary invertible matrices. This property describes the ability of an index to remain invariant under invertible linear transformations. is not applicable for evaluating weight similarity measures, weight matrices not expected to undergo arbitrary invertible transformations. Similarly, it does not apply to representation similarity measures (Kornblith et al., 2019).
Translation (TR) Invariance (Raghu et al. 2017
Klabunde et al. 2023a):
Y) S (X 1c Y 1d
where and d are arbitrary constant vectors. This property describes the ability of an index to be unaffeccted by additive shifts in the data. is not applicable for evaluating weight similarity measures because translating the parameters would result in fundamentally different set parameters, which is inconsistent for evaluation purposes.
Affine Transformations (AT) Invariance:
S(X,Y) S (XA+ 1c YB+ 1d")
where A and B are arbitrary invertible matrices and d are arbitrary constant vectors. This property is a combination of linear transformations and translations and is not applicable for evaluating weight similarity measures for the same reasons ILT and TR Invariance.
23

---

Published as a conference paper at ICLR 2025
E FURTHER DISCUSSIONS ON THE MOTIVATIONS OF DOCS
In this section, we provide additional justifications regarding (i) why we focus on weight similarity rather than representational similarity, (ii) the orthogonality of weight matrices in large language models, and (iii the advantages of DOCS compared to other existing similarity indices.
E. WEIGHT SIMILARITY VS. REPRESENTATIONAL SIMILARITY
As introduced in Section 1 while prior research has explored many methods for characterizing the similarity of neural networks (Wu et al. 2020; Khosla & Williams/ 2024; Kriegeskorte al. [0088]
Klabunde et al. 2023bb Wang al. [2020] Barannikov et al., 2021 Hamilton et al. 2016 Rahamim
Belinkov] 2024; Tang al., (0220 Camastra Staiano 2016 Wang et al.) 201 Raghu et al,
2017 Morcos et al. 2018 Kornblith et al. (2019), these methods often focus representational
similarity rather than weight similarity.
Similar representations across layers do not necessarily imply similar weight matrices. This discrep- ancy arises from the use of residual connections transformer architectures (He et al. 2016). This evidenced by Figures| la and lb] which show that the input and output of the feedforward network have similar patterns of representational similarity
Here, present another example where weight similarity reveals intriguing finding that would otherwise be overlooked. We plot both the representational and weight similarity indices for the 01-ai/Yi-1.5-9B-CH model. On one hand, we use the Linear CKA method calculate the simi- larity between the outputs of MLP-Up layers. On the other hand, we employ the DOCS method to calculate the weight similarity of the MLP-UP layers. The experimental results are shown in Figure g
The results underscore the strengths of DOCS in revealing the weight structure. Specifically, DOCS reveals an intricate pattern in Figure 8a indicating that layer 9 is highly similar to layer 25, layer 10 is highly similar to layer 26, layer 11 is highly similar layer 27, and so on. This suggests repetition of a section of layers within 1l-ai/Yi-1559BB-Cha possibly due to specific training strategy employed to save training costs.
In contrast, Figures 8b Sc and 8d present the representational similarity computed by Linear CKA using different input sequences. Despite using multiple input sentences for the analysis, the results provide limited understanding of the weight structure. They exhibit relatively homogeneous pat- terns, lacking the fine-ge aue-grained layer correspondence seen with DOCS. Therefore, in this example, focusing weight similarity deepens understanding of the model.
9.9
Layers
Layers
Layers
0.8
0.05
0.8
0.8
077
0.06
0.6
0.04
18
42
18
30
42
0.6
30
30
42
18
35
03
Layers
Layers
Layers
Layers
(a)
(b)
(c)
(d)
Figure 8: Comparison between DOCS and Linear CKA on the MLP-UP layers of the 01-ai/Yi- 1.5-9B-Chat model. (a) shows the DOCS weight similarity of MIP-UP parameters across layers, while (b), (c), and (d) illustrate the Linear CKA representational similarity of the corresponding layer outputs with different input sentences.
E.2 FURTHER EXPERIMENTS ON THE NON-DISCRIMINATIVE NATURE OF OTHER SIMILARITY INDICES
In Section [ emphasized that many existing similarity indices, such Canonical Correlation Analysis (CCA) (Ramsay et al.) 1984; Morcos et al. 2018). Singular Vector Canonical Correlation Analysis (SVCCA) (Raghu et al. 2017), and Linear Centered Kernel Alignment (Linear CKA)
24

---

Published as a conference paper at ICLR 2025
(Kornblihh et al. 2019), non-discriminatiive for orthogonal matrices. An orthogonal matrix Q is defined by the property Q Q = QQ = where is the identity matrix. This non-discriminative nature means that these indices yield the same
when assessing the similarity between any two orthogonal matrices, regardless of their actual differences. These conclusions are presented in Section 2 with proofs provided in Appendix
[ This issue is partieularly relevant in the context of LLMs, where orthogonal matrices commonly occur throughout the training process (Tian et al., 2023). In fact, in F we observe that when CKA is directly used measure weight similarity, a large number of values concentrate in the high range of discriminative property for orthogonal matrices.
This is likely due to the non-
Here, we present additional results demonstrating a substantial degree of orthogonality among the weight matrices LLMss we introduce an index named the Off-Diagonal Average Cosine Similarity metric. This metric provides systematic way to measure the extent of orthogonality between the columns of given weight matrix. The metric defined as:
1
X; X
Off-Diagonal Average Cosine Similarity(X) n(nn
||
|
im
j=l J
where X a matrix with n columns, and x; represents the i-th column X. This formulation indicates that a larger Off- Off-Diagonal Average Cosine Similarity value corresponds to a lower degree of orthogonality in the matrix.
To further understand the orthogonality of weight matrices in LLMs, constructed family of approximately orthogonal matrices, denoted as Mg. defined by:
Mg = I, +0U1
where:
In is the identity matrix of size n x n.
0 E R is scalar controlling the deviation from orthogonality; smaller values of 0 corre- spond to matrices closer to orthogonal.
U E R a random vector sampled from the normal distribution e ~ (O,, 1).
1 E R is a vector of ones.
In our study, we utilized the Q matrices and matrices from each layer of the Meta-Llamat 1- 8B-Instruct model. Additionally, we generated four sets of approximately orthogonal matrices by sampling Mg with 0 values of 0.005, 0.003, 0.002, and 0.001, ensuring that their shapes matched those of the Q and O matrices. We then computed the Off-diagonal Average Cosine Similarity for these matrices.
The experimental results, presented in Figures reveal that the majority of the Q and O matrices from each layer of the Meta-Llama-3, 1..mma-..1-88 --B--BB--BBBB-- Instruct model exhibit stronger orthogonality compared to Mo.eos. According to the definition of Ma. Ma. only has very small perturbation added to the identity matrix. This observation suggests that the Q and O matrices in the Llama- 1-B Instruct model are highly orthogonal.
25

---

Published as a conference paper at ICLR 2025
Ort-Diggonal Average Cosine Similrtty
Off Dreggond Average Casine Similantt
00.00
0.100
Masia
Marto
To nod Woghts
Tandd Wajht
0.010
15
20
10
15
25
30
Layer
Layer
Figure 9: Average cosine similarity for Meta-I.lama-3.111 ---0----3---------ttutt---- with the Q matrix on the left and the O matrix on the right.
E.3 ADVANTAGES OF DOCS OVER OTHER SIMILARITY INDICES
In Section Figure showeases the evaluation outcomes of eight different similarity indices on the MLP-UP layers from the Meta-Llama-3, 1--ma--,,--B-Inne 1-8B-Instruct model. The resulting heatmaps highlight that indices like Linear Regression, Canonical Correlation Analysis (CCA), and CCA (Nuclear) fail to display discernible structural patterns. On the other hand, methods such as Singular Vector CCA (SVCCA), SVCCA (Nuclear), and Linear Centered Kernel Alignment (Linear CKA) exhibit faint block-like striped formations in the off-diagonal regions, which might be attributed to either noise or inherent limitations in the indices themselves. These anomalies could arise due to the reduced sensitivity of these indices in differentiating between orthogonal matrices, elaborated in Section
To further compare the effectiveness of the DOCS method with other approaches, we conducted additional experiments using three models:
(A) meta - Baee--laaaMMMaaatla ama 3.. 1-8B (the base model)
(an instruction-tuned version of
the base model)
(C) A version
1-BB with randomly initialized weights
Intuitively, the weight matrices of corresponding layers in models (A) and (B) should exhibit signif- icantly higher similarity compared those between models (A) and (C), since model (C) contains random weights and lacks the learned structure present in models (A) and (B).
To quantify this, define the similarity ratio as the ratio of the similarity scores between models (A) and (B) to those between models (A) and (C). Specifically, for each similarity index, we compute the similarity the corresponding MLP- UP and MLP-DDW'S weight matrices between models (A) and (B), and between models (A) and (C). A higher ratio indicates that the similarity index is better distinguishing between meaningful relationships
model weights (as seen models (A) and (B)) and unrelated weights (as in models (A) and (C)). Thus, higher ratio reflects the ability of the index to highlight structural patterns specific to related models while minimizing noise from uncorrelated data.
As shown in Figure 10 the experimental results reveal that the similarity ratio computed using the DOCS method is much higher approximately 10 times greater- than those obtained with the other indices. This demonstrates the effectiveness of DOCS capturing meaningful similarity patterns in model weights.
26

---

Published as a conference paper at ICLR 2025
Mir du Auile
-110
16.32
100
(a) Similarity ratio com- (b) Similarity ratio com- (c) Similarity ratio com- (d) Similarity ratio com- puted using the DOCS puted using the Linear puted using the SVCCA puted using the SVCCA method.
CKA method.
method.
(nuclcar) method.
Figure 10: Comparison of similarity ratios between models (A) and (B) relative to models (A) and (C) across four methods: DOCS, Linear CKA, SVCCA, and SVCCA (nuclear). The DOCS method demonstrates a significantly higher ratio, indicating more effective performance.
COMPARISON OF SIMILARITY INDICES ON A RANDOMLY INITIALIZED MODEL
Figure [ provides visual comparison of eight different similarity indices applied to the MLP-UP UP layers of the reinitialized relatively random patterns.
1.mma-3.11800 1..1-8B-Imm In-trutttt model. We observed that all of them exhibit
09994
65
64992
Laver
0,090
25
00935
0.9955
Layers
Layers
Layers
Layers
(a) Lincar Regression
(b) CCA
(c) CCA (Nuclear)
(d) SVCCA
0U0G07T
0.762
GUN6000
67750
03379
0.02003
03778
0.02000
67008
2011
67706
20005003
83376
20000202
03775
0001555
Layos
Layers
(c) SVCCA (Nuclear)
(f) Linear HSIC
(g) Linear CKA
(h) DOCS
Figure II: Comparison of similarity indices on the MLP-UP layers of reinitialized Meta-Llama- 3.1 Instruc..
G JUSTIFICATIONS FOR SPECIFIC STEPS IN THE DOCS ALGORITHM
In this section, we provide justifications for specific design choices made in the DOCS algorithm, focusing the use of the Gumbel distribution and the maximization function in computing the similarity index.
Justification for the Choice of Gumbel Distribution
To illustrate why the Gumbel distribution is suitable for modeling the data in the DOCS algorithm, analyze the distribution of maximum cosine similarities between columns of weight matrices from different layers.
Let X be the MLP-UP weight matrix from the 4th layer, and let Y be the MLP-UP weight matrix from the 8th layer of the a-etall /Me -- L-8B model. We compute the vectors Sx MAXCOSSIM(X, Y) and sy MAXCosSIM X), where MAXCOSSIM refers to the
27

---

Published as a conference paper at ICLR 2025
function that computes, for each column in matrix, the maximum absolute cosine similarity with any column in the other matrix.
The histograms of sx and sy plotted in Figure 12 As observed, the distributions of the max- imum cosine similarities closely resemble the Gumbel distribution, which is commonly used to model the distribution of extreme values (maxima minima) of samples of random variables. This empirical observation supports our choice of fitting a Gumbel distribution to the maximum cosine similarities in the DOCS algorithm.
By fitting a Gumbel distribution to these maximum similarity values and using the location parame- ter the similarity index, we capture the central tendency of the extreme similarities in way that is robust to outliers and sensitive to the most significant alignments between the weight matrices.
Similarity Layer
Similarity (Layer
20
Fitted Gumbel (u1=0.0805)
20
Fitted Gumbel (u2=0.0829)
Density
Density
15
10
5
0
0.1
0.2
0.3
0.4
0.5
0.6
0.1
0.2
0.3
0.4
0.5
0.6
Maximum Absolute Cosine Similarity
Maximum Absolute Cosine Similarity
(a) Histogram of sx (Layer to Layer 8).
(b) Histogram of sy (Layer 8 Layer 4).
Figure 12: Histograms of the maximum cosine similarity vectors s and Sy for the MLP-UP weight matrices from layers and 8. The overlaid curves represent the fitted Gumbel distributions.
Importance of the Maximization Function
The maximization operation the MAXCOSSIM function plays crucial role in the DOCS algo- rithm. To demonstrate this, compare the results of the standard DOCS algorithm with variant where the maximum operation is replaced by averaging.
In the standard DOCS algorithm, for each column in matrix X, we compute the maximum absolute cosine similarity with any column in matrix Y. This approach emphasizes the strongest alignments between the weight matrices, which essential for detecting structural similarities.
Alternatively, using the average of the absolute cosine similarities incorporates all pairwise sim- ilarities, including weaker alignments. This averaging process dilute the impact of the most significant similarities by combining them with less relevant ones.
Figure 13 compares the similarity heatmaps generated by the average-based DOCS and the standard DOCS algorithm for the MLP-UP parameter matrices of the meta- 1-l1aam MMtta-Llaa- ama-3 1-88 model.
28

---

Published as a conference paper at ICLR 2025
0.016
0.12
0.015
0.11
12
12
Layers
0.014
Layers
0.10
0.09
20
0.013
20
0.08
0.012
28
28
0.07
0.011
20 Layers
20
28
Layers
(a) Similarity heatmap
using average-based
(b) Similarity heatmap using standard DOCS gorithm.
DOCS.
Figure 13: Comparison similarity heatmaps for the MLP-UP parameter matrices of the
meta preta-llama, weellaaaaaaaaaaaa aate//MtttaLaaa L-ama-amaa---- -ama.-.. 1.1.111 1-8B model: (a) average-based DOCS and (b) standard DOCS algorithm.
As shown in Figure 13 the similarity heatmap generated by the average-based DOCS lacks clear structural patterns and appears more uniform. contrast, the heatmap produced by the standard DOCS algorithm reveals distinct structural similarities between specific layers, evident through pro- nounced diagonal and off-diagonal patterns.
This comparison highlights the importance of using the maximum operation in the MAXCOSSIM function. By focusing on the strongest relationships between columns of the weight matrices, the DOCS algorithm effectively captures meaningful structural patterns that might be obscured when using an averaging approach. The maximum operation ensures that significant alignments are em- phasized, enhancing the sensitivity of the similarity measure to relevant features in the model's architecture.
H COMPUTATION DETAILS OF GINI COEFFICIENT
The computation of the Gini coefficient involves several steps. First, we exclude the diagonal el- ements from the similarity matrix they always equal to one, focusing solely inter-layer relationships. For each row, the remaining elements are normalized by dividing them by the sum of all row values, ensuring that the resulting coefficients reflect the relative distribution of similarity scores within the row. The Gini coefficient for each row is then calculated to quantify the inequality in the distribution of these scores, with higher values indicating greater concentration of simi- larity among fewer layer pairs. Finally, the mean Gini coefficient across all rows is computed to summarize the overall inequality in the similarity matrix.
A higher Gini coefficient suggests more uneven distribution of similarity scores, implying a greater concentration of significant similarities in fewer layer pairs, which potentially reveals structural characteristics of the model parameters. As demonstrated in Table our proposed method (DOCS) achieves higher Gini coefficients compared to other methods, indicating ability to isolate signifi- cant layer similarities.
I HEATMAPS OF DOCS SCORES ON VARIOUS LLMS
29

---

Published as a conference paper at ICLR 2025
0.14
0.16
15
0.12
15
0.14
15
0.12
Layers
Layer
0.10
0.10
26
26
26
36
36
36
0.06
18
Layers
Layers
Layers
(a) MLP-UP
(h) MLP-DOwN
(c) Wa
0.09
0.12
15
Layers
0.08
Layen
26
25
0.06
0.05
R
Layers
Layers
Layers
(d) W.
(e) Wg
(f) W.
Figure 14: DOCS scores between transformer layers in gemma-2-9b.
0.12
0.14
0.11
Layers 28
16
0.10
Layers
0.12
Layer
0.09
29
0.08
30
0.07
39
Layers
Layers
Layers
MLP-UP
(b) MLP-DOWN
(c) W
0.14
0.09
0.09
16
0.08
Layers
Layers
0.10
28
0.07
28
0.07
59
0.06
0.06
16
28
0.05
16
28
39
16
28
39
Layers
Layers
Layers
(d) W.
(c) W
(f) W
Figure 15: DOCS scores between transformer layers in gemma-2-22 -2-27b.
30

---

Published as a conference paper at ICLR 2025
0.16
0.13
0.16
0.12
Layers 17
10
0.11
Layers
10
0.12
Layyo
0.14
0.10
24
24
0.00
22
0.08
0.07
0.06
Layers
Layers
Layers
(a) MLP-UP
(b) MLP-DoWN
(c) We
0.10
0.10
10
0.14
Layers
Layers
0.09
0.08
0.12
17
17
0.08
0.07
24
0.08
24
0.07
17
17
10
24
Layers
Layers
Layers
(d) W.
(e) W
(f) W.
Figure 16: DOCS scores between transformer layers Llama-3.1-3B.
0.16
0.12
0.14
0.11
Layers 20
12
0.10
Layers
0.12
0.09
0.10
0.08
0.08
28
0.07
0.06
Layers
Layers
Layers
(a) MLP- UP
(b) MLP-DoWn
(c) W4.
0.09
0.10
0.08
0.14
Layers
12
Layers
12
Layers
20
0.10
0.07
28
20
28
0.05
0.06
0.06
12
20
28
12
20
28
4
20
28
Layers
Layers
Layers
(d) W.
(e) Wg
(f) W,
Figure 17: DOCS scores between transformer layers Llama-3.1-8 3.1-BB.
31


Reviews:
[{"review_id": "Jz6q2k5i9k", "reviewer": "Reviewer_6MYG", "summary": "The paper introduces Distribution of Cosine Similarity (DOCS), a new method for measuring similarity between LLM weights.  Unlike previous methods that focused on analyzing representations, DOCS directly examines weight matrices, providing a more precise tool for understanding the internal structure of these complex models. DOCS reveales two important insights, (i) adjacent layers in LLMs often share similar weights and (ii) tend to form functional clusters suggesting depth-wise functional specialization. The findings show that the conventional use of uniform layer configurations in large language models may not be optimal, suggesting hints for more efficient architectures design.", "questions": "- Please follow weakness", "limitations": "", "rating": 8, "confidence": 5, "soundness": 3, "presentation": 4, "contribution": 4, "strengths": "- The method provides a quantitatively similarity score for LLM weights (not representation) which may be helpful for model merging and pruning research.\n- The method is proposed with a good level of interpretability and visualization with impressive analysis.", "weaknesses": "While the paper showed an impressive set of analysis (with page limitations), I would very much like to see an analysis on what makes DOCS work. Especially in Algorithm 1, which step is the most crucial one. A small set of experiments may help.", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}, {"review_id": "BI2ehrqbfr", "reviewer": "Reviewer_RK55", "summary": "The paper introduces the Distribution of Cosine Similarity (DOCS), a novel index designed to quantitatively assess the similarity between weight matrices in large language models (LLMs). This tool aims to enhance the analysis of LLM architectures by revealing significant patterns within them. Using DOCS, the authors identify that adjacent layers in contemporary open-source LLMs often show high weight similarity and tend to cluster, indicating a trend toward depth-wise functional specialization. Furthermore, the paper demonstrates that DOCS effectively quantifies similarity for orthogonal matrices, an important consideration given the common use of orthogonal initializations in LLMs.", "questions": "1.\tWhy did you choose to use Gumbel distribution to summarize each distribution to a parameter? Is there any specific reason or proof for that?\n\n2.\tCould you suggest some other potential applications besides what people have already done (e.g., leveraging layer clusters to reduce computational requirements) that could benefit from the findings in this paper?", "limitations": "", "rating": 6, "confidence": 3, "soundness": 3, "presentation": 3, "contribution": 3, "strengths": "1.\tThis paper is overall well-written.\n\n2.\tThis paper proposes to better calculate the parameter similarity between different layers by computing the cosine similarity between corresponding vectors and analyzing their distribution.\n\n3.\tUsing the technique they propose, the authors observed that: 1) neighboring transformer layers exhibit similar weights, 2) clusters of similar transformer layers exist, 3) the difference of parameters among different models.", "weaknesses": "1.\tSome experimental designs could be more detailed and justified, such as the use of the gumbel distribution.\n\n2.\tNo direct application could be derived from this analysis paper, which could be a weakness of the paper. The authors could add a discussion section to further point out the practical value of the findings in this paper.", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}, {"review_id": "ENyKDqvdmt", "reviewer": "Reviewer_UcWi", "summary": "This paper introduces DOCS, a novel matrix-similarity index that measures weight similarity of LLMs. It provides a more reliable and accurate measure of similarity between LLM weight matrices.", "questions": "1.Could you provide a detailed explanation on the relation between clusters of similar phases and multiple reasoning phases?\n\n2.Proofs of DOCS satisfying all desired mathematical properties could be added to improve the rigorousness of the claim.\n\n3.I am curious about other similarity indices could achieve similar findings on LLMs. I believe this is important to further demonstrate the superiority of DOCS over other methods.", "limitations": "", "rating": 6, "confidence": 2, "soundness": 3, "presentation": 2, "contribution": 3, "strengths": "1.The approach is novel. It is a discriminative index which captures meaningful differences between weight matrices than other methods.\n\n2.This paper encompasses detailed theoretical derivation on discriminative property and comprehensive experiments, which demonstrate discriminative nature of DOCS and provides some insights into the structure of LLMs.", "weaknesses": "1.Some of findings are not straightforward in this paper. For example, the authors associate multiple reasoning phases with clusters and attribute different numbers of clusters across LLMs to different training strategies. However, they do not clarify the rationale behind these conclusions.\n\n2.Although the authors claim that DOCS satisfies all desired mathematical properties, they do not provide corresponding proofs in the paper.", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}, {"review_id": "qZMxzLkWV0", "reviewer": "Reviewer_Fe2j", "summary": "This paper presents a new metric for measuring the similarity between the weights of transformer models with the goal of gaining insights into LM learning. It is pointed out that existing methods like Canonical Correlation Analysis (CCA) and Centered Kernel Alignment (CKA) do not discriminate between orthogonal matrices well enough, which is a requirement for handling transformer weights. Moreover many existing metrics do not have certain desirable mathematical properties such as transformation and scaling invariance, symmetry, and reflexivity. The proposed metric, DOCS has all these properties.\n\nEmpirical justification for the suitability of DOCS for measuring similarity among transformer weights is provided by visualizing the similarity between pairs of MLP layers in a pretrained model.\n\nThe main findings using DOCS are that\n1. neighboring layers in pretrained LMs are very similar to each other, and there exist clusters of similar layers, both indicating that the transformer architecture can be made more efficient by minimizing such redundancy.\n2. the weights of base and instruction tuned models are generally highly similar to each other, and no clear trends exist at which layers weights are most dissimilar (i.e., impacted by instruction tuning).\n3. some experts in MoE models are different from others.", "questions": "- It makes sense that the mathematical properties listed in Section 2 are desirable in a similarity measure of transformer weights. But are these properties *sufficient* for such a metric?", "limitations": "", "rating": 5, "confidence": 4, "soundness": 2, "presentation": 3, "contribution": 2, "strengths": "The approach, mathematical notation, and the visualizations presented in the paper are easy to follow. The comparison of mathematical properties of similarity functions is informative.", "weaknesses": "**Motivation**: The main motivation behind studying the similarity between weights instead of representations is unclear. The arguments about discriminating between orthogonal matrices, and the mathematical properties of scaling invariance etc. are built on top of the assumption that studying similarity between the weight space is more insightful than in the representation space, but it is not clear to me why that is the case. After all, is it not the representations that directly affect the outputs and the behavior of a model? Moreover, representational similarity is arguably agnostic to the depth of a network, which is not the case with weight-space similarity. It would be great if the authors could clarify their motivation in the response.\n\n**Empirical justification**: The empirical justification provided for DOCS being superior to other similarity measures is a) that the visualization of the similarity between layers lack a clear structure and appear noisy for CCA and Linear Regression in contrast to DOCS (Section 4.1), and b) the Gini coefficient of DOCS is higher than that of other metrics.\n- (a) is not a convincing justification. A metric showing clearer patterns is not necessarily better.This could also mean that DOCS is missing out on useful information other metrics are capturing. It would be more meaningful to compare metrics against a ground truth, e.g., are models that have similar output distributions, like different training checkpoints of the same model, more similar according to one measure than the other?\n- (b) requires elaboration. How is the Gini coefficient computed? Why is t relevant? How should one interpret these results?\n\n**Impact of the findings**:\n- That there is potential redundancy of knowledge in the weights of neural networks is an interesting finding, but it is not new. This has been empirically studied in many works that are well cited in this paper.\n- The experiments comparing base and finetuned models and MoE do not show clear trends, and it is unclear what can be inferred from them.", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}, {"review_id": "KzmSoJWNjw", "reviewer": "Reviewer_37uY", "summary": "This paper proposes a novel similarity index, DOCS, designed to measure the similarity between two matrices, with a focus on its application to neural network matrices. A key feature of DOCS is its ability to distinguish between orthogonal matrices, which the authors claim is crucial for training neural networks. In addition, DOCS possesses desirable properties such as symmetry and reflexivity.\n\nThe computation of DOCS is both simple and elegant, making it easy to understand and computationally efficient. It calculates the maximum cosine similarity between the rows and columns of two matrices, then fits a Gumbel distribution to each of these values. Finally, it averages the two scores to produce the final similarity measure.\n\nThe authors present a series of experiments demonstrating the results of applying DOCS to several large language models, comparing the results to other similarity indices such as CCA and SVCCA.\n\nOverall, the paper introduces a promising new similarity index, DOCS, with several interesting properties for comparing neural network weight matrices, particularly in the context of language models. The authors provide an extensive set of experiments with recent open-weight models, comparing DOCS with other indices. However, while the contributions are valid, there are several issues that need to be addressed in the current version of the paper:\n\nEvaluation\n------\n\nIt is unclear how to evaluate DOCS or whether it captures a truly desirable property. The experiments in the paper show results, but it is not clear why DOCS should be considered superior to other similarity indices. How should we interpret these results? Are the similarities computed by DOCS more meaningful than those computed by other indices? The paper does not provide sufficient justification for why the \"elegant\" similarity matrices obtained by DOCS are more informative or useful than those obtained by other methods. The authors also suggest that DOCS could help in developing more efficient models (L.124) or provide deeper insights into model behavior (L.134), but there is no empirical evidence to support these claims.\nProviding some empirical evidence that using DOCS can lead to better empirical results, or new insights about models are crucial as part of the evaluation of this method.\n\nThe authors attempt to justify DOCS by presenting heatmaps of weight matrices, suggesting that these show clearer patterns with less noise. However, this is a highly subjective measure and not convincing. They also compute the Gini coefficient (which should be explained more thoroughly) and claim that its higher value supports DOCS’s superiority. I find this reasoning unconvincing.\n\n\nOverclaiming\n--------\nSeveral claims made in the paper are either overstated or lack sufficient evidence.\n\n- The assertion that neural network matrices require a similarity index that discriminates between orthogonal matrices is one such claim. The authors should (1) empirically demonstrate that the matrices are orthogonal, which should be straightforward, and (2) show that this property is important in practice. Currently, these claims are made without adequate justification.\n- L93-98: The authors claim that the heatmaps demonstrate the effectiveness of DOCS. Why do these heatmaps prove effectiveness? Why should we expect the DOCS index to be more informative than other similarity indices?\n- L.113: The paper claims that DOCS shows high similarity, but the values are around 0.12, which seems quite low to me.\n- L.124: The statement that DOCS \"could lead to more efficient models\" feels like an overreach.\n- L.420-421: The claim that large language models (LLMs) might consist of multiple reasoning phases based on the similarity clusters is speculative and not well-substantiated.\n- L.424: The argument that multiple clusters imply multiple training strategies is unconvincing. This could easily be tested by comparing models at different training stages (e.g., base model, fine-tuned model, RLHF model) and examining whether the number of clusters changes.\n- L.477: The trends in similarity scores across different layers are minimal (e.g., differences of <0.001 in Llama-3.1-8B), so I question how meaningful these differences really are.\n\n\nMissing Details\n---------\n(Note: these are smaller issues, but still important to address in the paper.)\n\n- When computing DOCS, part 3 of the algorithm involves fitting a Gumbel distribution to the obtained values. However, it is unclear how the final single numeric value is derived. Is it the mean, median, or another statistic from the distribution?\n- The claim that DOCS can distinguish between orthogonal matrices (L.267) is not explicitly demonstrated in the paper. More details should be provided.\n- There is no information on how the baselines for comparison were computed. These details should be included for transparency.\n\n\nNeed for Elaboration\n-------------\nThe paper discusses at length DOCS’s ability to discriminate between orthogonal matrices, but it is unclear why this is a valuable property. Expanding on why this distinction matters in practice would strengthen the paper.\n\nThe theoretical proof in Section 3.1 is also not entirely clear. It would be helpful if the authors could expand on the practical implications of this proof.\n\n\n-------\nRebuttal summary:\n\nAfter the authors' response I decided to increase my scores due to the satisfying responses that satisfied most of my concerns.\nI still believe it's not completely clear how the metric can be used, but I believe some may find it useful, and I do not object of having another similarity metric, especially since it operates on matrices, unlike most previous work that operates on hidden representations.", "questions": "- It could be valuable to experiment with an initialized model and compute similarity indices, including DOCS. Given the presence of residual connections, the results may exhibit non-random patterns.\n- L.115: This sentence is unclear. Are you suggesting that the layer configurations remain uniform during the initialization of the model?\n- Suggestion: The font sizes in Figure 3 panels (1-3) and (d-f) are inconsistent. Ensure uniform font sizes across the figures for clarity and visual consistency.", "limitations": "", "rating": 8, "confidence": 4, "soundness": 3, "presentation": 3, "contribution": 3, "strengths": "- Introduction of a new similarity index, DOCS, which possesses intriguing properties that make it well-suited for comparing neural network similarities.\n- Extensive experimentation on recent language models, with comparisons to established similarity indices.", "weaknesses": "- The evaluation of DOCS is insufficient and unconvincing, as discussed in detail in the review.\n- Several claims made in the paper are overstated or lack adequate justification (see the summary section for further elaboration).\n- Certain important details are missing or insufficiently explained (further discussed in the summary section).", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}]

Author rebuttal:

Decision: Accept (Poster)