Skip to main content

Evaluate language models using multiple choice items

Project description

LM Pub Quiz

Evaluate language models using multiple choice items

Build status PyPI - Version PyPI - Python Version License


This library implements a knoweledge probing approach which uses LM's inherent ability to estimate the log-likelihood of any given textual statement. For more information visit the LM Pub Quiz website.

See also

Getting started

This short guide should get you started. For more detailed information visit the documentation.

Installing the Package

You can install the package via pip:

pip install lm-pub-quiz

For alternatives methods of installing the package, visit the documentation.

Example Usage

from lm_pub_quiz import Dataset, Evaluator

# Load the dataset
dataset = Dataset.from_name("BEAR")

# Load the model
evaluator = Evaluator.from_model(
    "gpt2",
    model_type="CLM",
)

# Run the evaluation and save the
results = evaluator.evaluate_dataset(
    dataset,
    template_index=0,
    save_path="gpt2_results",
    batch_size=32,
)

# If the results are analyzed in a different session, they can be loaded from the file system
# results = DatasetResults.from_path("gpt2_results")

print("=== Overall score ===")
print(results.get_metrics("accuracy"))

Contributing

We welcome any questions, comments, or even PRs to this project to improve the package.

We use hatch to manage this project. For the most comfortable development experience, please first install hatch using pip or pipx.

Then, to propose a change to the library,

  • test your code locally using hatch run all:test
  • format the code according to our formatting guidelines using hatch run lint:fmt,
  • check type- and style-consistency using hatch run lint:all, and
  • finally create a pull request describing the changes you propose.

For work on the documentation, use hatch run serve-docs to run a local documentation server.

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_pub_quiz-0.3.1.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

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

lm_pub_quiz-0.3.1-py3-none-any.whl (40.3 kB view details)

Uploaded Python 3

File details

Details for the file lm_pub_quiz-0.3.1.tar.gz.

File metadata

  • Download URL: lm_pub_quiz-0.3.1.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for lm_pub_quiz-0.3.1.tar.gz
Algorithm Hash digest
SHA256 ff8c2eff596674ac2cff9e8d0113803df6d2a78f2a1a0f8333828040e7d1c979
MD5 a8883d422cefe44e439128384ebe2572
BLAKE2b-256 052375b214cd08c575869ba77fb74a6d040d5e0a6f149f20984f1adbed4b24e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for lm_pub_quiz-0.3.1.tar.gz:

Publisher: publish.yml on lm-pub-quiz/lm-pub-quiz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lm_pub_quiz-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: lm_pub_quiz-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 40.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for lm_pub_quiz-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 48ab109194089fb9f2ec8c660c2529f84f8ac68b941eea6fe2de168edc18629e
MD5 f3081f3dd8a43208650816f8f3d3810d
BLAKE2b-256 19f52d686eb38f7ff0bde93e779a9014fa03ea63c37a10cfd98fe792a1fe714b

See more details on using hashes here.

Provenance

The following attestation bundles were made for lm_pub_quiz-0.3.1-py3-none-any.whl:

Publisher: publish.yml on lm-pub-quiz/lm-pub-quiz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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