{"id":24559162,"url":"https://github.com/lazerlambda/promptzl","last_synced_at":"2025-04-19T12:08:45.681Z","repository":{"id":259540572,"uuid":"819094387","full_name":"LazerLambda/Promptzl","owner":"LazerLambda","description":"Turn LLMs into zero-shot PyTorch classifiers!","archived":false,"fork":false,"pushed_at":"2025-01-17T18:24:58.000Z","size":540,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-17T19:34:08.616Z","etag":null,"topics":["classification","few-shot","huggingface","large-language-model","large-language-models","llama","llm","machine-learning","ml","prompt","prompt-engineering","prompt-toolkit","pytorch","qwen","transformer-models","transformers","transformers-library","zero-shot"],"latest_commit_sha":null,"homepage":"https://promptzl.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LazerLambda.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-23T19:00:17.000Z","updated_at":"2025-01-17T18:25:00.000Z","dependencies_parsed_at":"2024-10-26T10:44:03.300Z","dependency_job_id":"c520bf0c-648b-4a7f-98f6-f36de8273213","html_url":"https://github.com/LazerLambda/Promptzl","commit_stats":null,"previous_names":["lazerlambda/promptzl"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LazerLambda%2FPromptzl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LazerLambda%2FPromptzl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LazerLambda%2FPromptzl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LazerLambda%2FPromptzl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LazerLambda","download_url":"https://codeload.github.com/LazerLambda/Promptzl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235233259,"owners_count":18957066,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["classification","few-shot","huggingface","large-language-model","large-language-models","llama","llm","machine-learning","ml","prompt","prompt-engineering","prompt-toolkit","pytorch","qwen","transformer-models","transformers","transformers-library","zero-shot"],"created_at":"2025-01-23T06:15:04.640Z","updated_at":"2025-01-23T06:15:07.786Z","avatar_url":"https://github.com/LazerLambda.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--- BADGES: START ---\u003e\n[![GitHub - License](https://img.shields.io/badge/License-Apache-yellow.svg)][#github-license]\n[![Docs - GitHub.io](https://img.shields.io/static/v1?logo=github\u0026style=flat\u0026color=pink\u0026label=docs\u0026message=promptzl)][#docs-package]\n![Tests Passing](https://github.com/lazerlambda/promptzl/actions/workflows/python-package.yml/badge.svg)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/promptzl?logo=pypi\u0026style=flat)][#pypi-package]\n[![PyPI - Package Version](https://img.shields.io/pypi/v/promptzl?logo=pypi\u0026style=flat)][#pypi-package]\n\n[#github-license]: https://github.com/LazerLambda/Promptzl/blob/main/LICENSE.md\n[#docs-package]: https://promptzl.readthedocs.io/en/latest/\n[#pypi-package]: https://pypi.org/project/promptzl/\n\u003c!--- BADGES: END ---\u003e\n\n\n\u003c!-- TODO --\u003e\n\u003ch1 align=\"center\"\u003ePr🥨mptzl\u003c/h1\u003e\n\nTurn state-of-the-art LLMs into zero\u003csup\u003e+\u003c/sup\u003e-shot PyTorch classifiers in just a few lines of code.\n\nPromptzl offers:\n   - 🤖 Zero\u003csup\u003e+\u003c/sup\u003e-shot classification with LLMs\n   - 🤗 Turning [causal](https://huggingface.co/models?pipeline_tag=text-generation\u003e) and [masked](https://huggingface.co/models?pipeline_tag=fill-mask\u003e) LMs into classifiers without any training\n   - 📦 Batch processing on your device for efficiency\n   - 🚀 Speed-up over calling an online API\n   - 🔎 Transparency and accessibility by using the model locally\n   - 📈 Distribution over labels\n   - ✂️ No need to extract the predictions from the answer.\n\nFor more information, check out the [**official documentation**.](https://promptzl.readthedocs.io/en/latest/)\n\n## Installation\n\n\n`pip install -U promptzl`\n\n## Getting Started\n\nIn just a few lines of code, you can transform a LLM of choice into an old-school classifier with all it's desirable properties:\n\nSet up the dataset:\n```python\nfrom datasets import Dataset\n\ndataset = Dataset.from_dict(\n    {\n        'text': [\n            \"The food was absolutely wonderful, from preparation to presentation, very pleasing.\",\n            \"The service was a bit slow, but the food made up for it. Highly recommend the pasta!\",\n            \"The restaurant was too noisy and the food was mediocre at best. Not worth the price.\",\n        ],\n        'label': [1, 1, 0]\n    }\n)\n```\n\nDefine a prompt for guiding the language model to the correct predictions:\n```python\nfrom promptzl import FnVbzPair, Vbz\nprompt = FnVbzPair(\n    lambda e: f\"\"\"Restaurant review classification into categories 'positive' or 'negative'.\n\n    'Best pretzls in town!'='positive'\n    'Rude staff, horrible food.'='negative'\n\n    '{e['text']}'=\"\"\",\n    Vbz({0: [\"negative\"], 1: [\"positive\"]}))\n```\n\nInitialize a model:\n```python\nfrom promptzl import CausalLM4Classification\nmodel = CausalLM4Classification(\n    'HuggingFaceTB/SmolLM2-1.7B',\n    prompt=prompt)\n```\n\nClassify the data:\n```python\nfrom sklearn.metrics import accuracy_score\noutput = model.classify(dataset, show_progress_bar=True, batch_size=1)\naccuracy_score(dataset['label'], output.predictions)\n1.0\n```\n\nFor more detailed tutorials, check out the [documentation](https://promptzl.readthedocs.io/en/latest/)!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flazerlambda%2Fpromptzl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flazerlambda%2Fpromptzl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flazerlambda%2Fpromptzl/lists"}