Skip to main content

Python package to compute similarity between LMs

Project description

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

A simple example to compute Goels $k$ in the context of MCQs (default computation is probabilistic Goels $k_p$). Input has be to formatted as follows:

  • output_a: list[np.array], containing the softmax output probabilties of model a
  • output_b: list[np.array], containing the softmax output probabilties of model b
  • gt: list[int], containing the index of the ground truth
from lmsim.metrics import Goels_k

calculator = Goels_k()
calculator.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 a
  • output_b: list[np.array], one-hot vector of model b
from lmsim.metrics import Goels_k

calculator = Goels_k(prob=False)
calculator.compute_k(output_a, output_b, gt)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lm_sim-0.0.3.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lm_sim-0.0.3-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file lm_sim-0.0.3.tar.gz.

File metadata

  • Download URL: lm_sim-0.0.3.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for lm_sim-0.0.3.tar.gz
Algorithm Hash digest
SHA256 79985c78d78d68dbf9d512b20a0dfadc315122ed8dae70c23ec8f99b5a1e65e5
MD5 4dff9821d8184e6917ed8e9d36647279
BLAKE2b-256 8243ea516850466a380d5d319bfea0641016701f7fbc8f5cece154d25793685e

See more details on using hashes here.

File details

Details for the file lm_sim-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: lm_sim-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for lm_sim-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f3699226f6caadac39e7aa5e22d2615da2402d3bf02803c8fe26e9a30aa8e4d2
MD5 34939c31c945ffaed71231930e22bfc3
BLAKE2b-256 df1696383a69987b3759205d390c08f1778f45189f0409e791cdc4d3faa2f871

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page