Skip to main content

Promptzl - LLMs as Classifiers

Project description

GitHub - License Docs - GitHub.io Tests Passing

Pr🥨mptzl (Under Development)

Promptzl is a simple library for turning LLMs into traditional PyTorch-based classifiers using the 🤗 Transformers library.

Classify large datasets quickly and easily while maintaining full control!

Installation

Download this repository, navigate to the folder and run: pip install .

Getting Started

In just a few lines of code, you can transform a LLM of choice into an old-school classifier with all it's desirable properties:

    from promptzl import *
    from datasets import load_dataset

    dataset = load_dataset("SetFit/ag_news")

    verbalizer = Vbz({0: ["World"], 1: ["Sports"], 2: ["Business"], 3: ["Tech"]})
    prompt = Txt("[Category:") + verbalizer + Txt("] ") + Key()

    model = MaskedLM4Classification("roberta-large", prompt)
    output = model.classify(dataset['test'], show_progress_bar=True).predictions
    sum([int(prd == lbl) for prd, lbl in zip(output, dataset['test']['label'])]) / len(output)

Installation (Dev)

pip install -e .

pip install -r test-requirements.txt

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

promptzl-0.9.1.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

promptzl-0.9.1-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file promptzl-0.9.1.tar.gz.

File metadata

  • Download URL: promptzl-0.9.1.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.0 CPython/3.12.7

File hashes

Hashes for promptzl-0.9.1.tar.gz
Algorithm Hash digest
SHA256 75ac727807e833a1e1acc4abd322efc13db72e477e1374f248237aa4dc4387dc
MD5 d7a0a02694918bdbe48b9af22cc72704
BLAKE2b-256 c6b8107ef1277920ba6affeee9ee483de5cd8ba6ee3f8964c29fe8812b4040d5

See more details on using hashes here.

File details

Details for the file promptzl-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: promptzl-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.0 CPython/3.12.7

File hashes

Hashes for promptzl-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 34a925c5015c6ca8e32aa3ad8183af10319c3dba7858a04485cfb0be0c82301c
MD5 3ce7bf53ef949d61ce97ce96ad1bc40d
BLAKE2b-256 2988aa41fc0cd8b65266d8049f99f02277034fa981eaa8091ff6a6d2b8fbec8a

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