LM-Similarity
lm-sim is a Python module for computing similarity between Language Models and is distributed under the MIT license.
Installation
Dependencies
lm-sim requries:
- Python (>=3.9)
- Numpy (>= 1.19.5)
User installation
If you already have a working installation of NumPy, the easiest way to install lm-sim is using pip:
pip install lm-sim
Example Usage
Currently we support the calcualtion of 3 similarity metrics in the context of MCQ datasets:
- CAPA (Chance Adjusted Probabilistic Agreement), $\kappa_p$ (default)
- CAPA (Chance Adjusted Probabilistic Agreement), $\kappa_p$ discrete
- Error Consistency
Compute similarity based on CAPA, $\kappa_p$
Below is a simple example on how to compute similarity between 2 models based on $k_p$. The input has be to formatted as follows:
output_a: list[np.array], containing the softmax output probabilties of model aoutput_b: list[np.array], containing the softmax output probabilties of model bgt: list[int], containing the index of the ground truth
from lmsim.metrics import CAPA
capa= CAPA()
capa.compute_k(output_a, output_b, gt)
For a discrete computation (when output probabilities are not availble) set the flag prob=False and the input must be formatted as one-hot vectors:
output_a: list[np.array], one-hot vector of model aoutput_b: list[np.array], one-hot vector of model b
from lmsim.metrics import CAPA
capa = CAPA(prob=False)
capa.compute_k(output_a, output_b, gt)
Compute similarity based on Error Consistency
from lmsim.metrics import EC
ec = EC()
ec.compute_k(output_a, output_b, gt)
Implementation supports both softmax output probabilties or one-hot vector as input.
Release files for lm-sim 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lm_sim-0.1.1.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lm_sim-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.0 kB
Release files / lm_sim-0.1.1.tar.gz
| Download URL | lm_sim-0.1.1.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f35f94af7c8790fa0d60fa802d316cf06eebb6869b41d98e66f0d4460b7121c
|
|
BLAKE2b-256 checksum How to use checksums |
9ef8f5aacb33a2744b2c372a36793e7719b1c1ed3211dbdbd5e4d03fa0072180
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|
Release files / lm_sim-0.1.1-py3-none-any.whl
| Download URL | lm_sim-0.1.1-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d60727545058579d31d2ae472cde51085efd0de09e98c93b3f359d912a096b4c
|
|
BLAKE2b-256 checksum How to use checksums |
a2843193693b95233c6355c35ac75b9470760224858cc57361f37a9509579238
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|