Submitted by KD_A t3_127pbst in MachineLearning
GitHub: https://github.com/kddubey/cappr
Docs: https://cappr.readthedocs.io/en/latest/index.html
PyPI: https://pypi.org/project/cappr/
What is CAPPr?
CAPPr is a Python package which performs zero-shot text classification by estimating the probability that an inputted completion comes after an inputted prompt. CAPPr = "Completion After Prompt Probability".
Why?
The standard zero-shot classification method using LLMs is to sample a completion given a prompt. For example, if you're classifying animals, you'd have the LLM generate text after
The biological class of a blue whale is
and then hope the LLM outputs Mammalia
.
Sampling usually works well. The problem is that the string you get could be any plausible completion, not necessarily one in your list of classes. So you'll have to write custom post-processing code for every new classification task you solve.
CAPPr addresses this problem by reframing the task as a series of simple computations:
Pr(Mammalia | The biological class of a blue whale is)
Read the (lengthy) motivation page of CAPPr's documentation if you're more curious.
Is it good?
I'm still trying to find out lol. I've evaluated CAPPr on a grand total of 2 datasets and a handful of examples. So if you're interested in using the cappr
package, make sure to carefully evaluate it :-)
One interesting result is that on the Choice of Plausible Alternatives task, zero-shot text-curie-001
(a smaller GPT-3 model) is < 50% accurate when using sampling, but 80% accurate when using CAPPr. (Here's a link to the experiment notebook.) It would be cool to demonstrate that CAPPr squeezes more out of smaller or less-heavily trained LLMs, as CAPPr's performance may be based more on next-token prediction performance than instruction-based performance.
Feel free to install it and mess around, I'd be happy to hear what you think!
nbviewerbot t1_jef48jq wrote
I see you've posted a GitHub link to a Jupyter Notebook! GitHub doesn't render large Jupyter Notebooks, so just in case, here is an nbviewer link to the notebook:
https://nbviewer.jupyter.org/url/github.com/kddubey/cappr/blob/main/demos/copa.ipynb
Want to run the code yourself? Here is a binder link to start your own Jupyter server and try it out!
https://mybinder.org/v2/gh/kddubey/cappr/main?filepath=demos%2Fcopa.ipynb
^(I am a bot.) ^(Feedback) ^(|) ^(GitHub) ^(|) ^(Author)