Skip to content

Commit 3e26364

Browse files
committed
Clarify the nature of the calculated cosine similarity
1 parent 5aca256 commit 3e26364

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/imatrix/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ For current versions of `llama-imatrix`, the `--show-statistics` option has two
9292
* **H Norm**: Shannon Entropy normalized over log₂(N). Defined as $H Norm=\frac{-\sum_{i=1}^N p_i \log_2 p_i}{log_2 N}$. Used to determine how well a prompt "exercises" the model's capabilities.
9393
* **H** *(legacy mode)* / **ECS** *(preferred)*: If legacy, Shannon Entropy defined as $H = -\sum_{i=1}^N p_i \log_2 p_i$. If preferred, *Euclidean-Cosine Score* defined as $ECS = K \cdot e^{-\alpha a} \cdot |b|^{\gamma}$ where `a = L₂ Norm`, `b = Cosine Similarity`, `α = 0.01`, `γ = 10` between this tensor’s elements and those of the previous layer. Higher score means more similarity and lower change.
9494
* **ZD**: % of elements whose Z-score is > 1.0 in magnitude (an indicator of outliers), as described in _3.1 Layer Importance Scores_ of [Layer-Wise Quantization](https://arxiv.org/abs/2406.17415)
95-
* **CosSim**: Cosine Similarity between this tensor’s elements and those of the previous layer.
95+
* **CosSim**: Cosine Similarity of the mean activations between this tensor’s elements and those of the previous layer.
9696

9797
#### Per layer
9898

9999
Aggregated metrics per block/layer:
100100

101101
* **Σ(Act²)** *(legacy mode)* / **L₂ Norm** *(preferred)*: If in legacy mode, the sum of squared activations (sum of Act²) for the layer's concatenated tensors. In preferred mode, the Euclidean Distance (L₂ Norm) between this layer's average concatenated tensor activations the previous layer.
102102
* **ZD**: % of this layer's concatenated tensors' elements with |Z| > 1.
103-
* **CosSim**: Cosine Similarity between this layer's concatenated tensors' elements compared and the previous layer’s.
103+
* **CosSim**: Cosine Similarity of the mean activations between this layer's concatenated tensors' elements compared and the previous layer’s.
104104
* **ECS** *(preferred only)*: Euclidean-Cosine Score applied to the layer.
105105

106106
More information is available in https://github.com/ggml-org/llama.cpp/pull/14891

0 commit comments

Comments
 (0)