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 Code style: black


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

or clone the repository and install the package using the -e flag to make changes to the source code:

pip install -e lm-pub-quiz  # Modify the path to the repository if necessary

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

Example Usage

from lm_pub_quiz import Dataset, Evaluator

dataset_path = "<BEAR data path, e.g. ./transformer-knowledge-probe/data/BEAR>"
result_save_path = "<BEAR results save path>"
model_name = "gpt2"

# Load the BEAR dataset from its specific location
dataset = Dataset.from_path(dataset_path)

# Run the BEAR evaluator and save the results
evaluator = Evaluator.from_model(model_name, model_type="CLM", device="cuda")
results = evaluator.evaluate_dataset(dataset, save_path=result_save_path, batch_size=32)

Contributing

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

We use hatch to manage this project. To run the test cases, run hatch run test or hatch run all:test (to test on multiple python versions). In order to check the formatting and correct typing, run hatch run lint:all.

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.2.1.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

lm_pub_quiz-0.2.1-py3-none-any.whl (38.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lm_pub_quiz-0.2.1.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.25.1

File hashes

Hashes for lm_pub_quiz-0.2.1.tar.gz
Algorithm Hash digest
SHA256 222081706da44fbe5596b67a3370f0843d8600c066c7d39149d3fe9119834eeb
MD5 85bc6ce7a86129417d5bd573cd077f11
BLAKE2b-256 c0408edf653a3ec29665398b731bb57126b1163656885d841925432638ffea00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lm_pub_quiz-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b56f7403d7a10149859e4e94dc4ea551ea85ab8ccf17347b74e43cf15f771ab4
MD5 ccbf0925b948910edb790f41ea3917fc
BLAKE2b-256 a80a562dc09a4864a4ab2a46dcf6441d44fe4cde73d58f40ee5dab87bb1bbf04

See more details on using hashes here.

Supported by

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