-
Notifications
You must be signed in to change notification settings - Fork 390
Integrate SetFit library #1150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Integrate SetFit library #1150
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Using SetFit with Hugging Face | ||
|
|
||
| SetFit is an efficient and prompt-free framework for few-shot fine-tuning of [Sentence Transformers](https://sbert.net/). It achieves high accuracy with little labeled data - for instance, with only 8 labeled examples per class on the Customer Reviews sentiment dataset, SetFit is competitive with fine-tuning RoBERTa Large on the full training set of 3k examples 🤯! | ||
|
|
||
| Compared to other few-shot learning methods, SetFit has several unique features: | ||
|
|
||
| * 🗣 **No prompts or verbalizers:** Current techniques for few-shot fine-tuning require handcrafted prompts or verbalizers to convert examples into a format suitable for the underlying language model. SetFit dispenses with prompts altogether by generating rich embeddings directly from text examples. | ||
| * 🏎 **Fast to train:** SetFit doesn't require large-scale models like [T0](https://huggingface.co/bigscience/T0) or GPT-3 to achieve high accuracy. As a result, it is typically an order of magnitude (or more) faster to train and run inference with. | ||
| * 🌎 **Multilingual support**: SetFit can be used with any [Sentence Transformer](https://huggingface.co/models?library=sentence-transformers&sort=downloads) on the Hub, which means you can classify text in multiple languages by simply fine-tuning a multilingual checkpoint. | ||
|
|
||
| ## Exploring SetFit on the Hub | ||
|
|
||
| You can find SetFit models by filtering at the left of the [models page](https://huggingface.co/models?library=setfit). | ||
|
|
||
| All models on the Hub come with these useful features: | ||
| 1. An automatically generated model card with a brief description. | ||
| 2. An interactive widget you can use to play with the model directly in the browser. | ||
| 3. An Inference API that allows you to make inference requests. | ||
|
|
||
| ## Installation | ||
|
|
||
| To get started, you can follow the [SetFit installation guide](https://huggingface.co/docs/setfit/installation). You can also use the following one-line install through pip: | ||
|
|
||
| ``` | ||
| pip install -U setfit | ||
| ``` | ||
|
|
||
| ## Using existing models | ||
|
|
||
| All `setfit` models can easily be loaded from the Hub. | ||
|
|
||
| ```py | ||
| from setfit import SetFitModel | ||
|
|
||
| model = SetFitModel.from_pretrained("tomaarsen/setfit-paraphrase-mpnet-base-v2-sst2-8-shot") | ||
| ``` | ||
|
|
||
| Once loaded, you can use [`SetFitModel.predict`](https://huggingface.co/docs/setfit/reference/main#setfit.SetFitModel.predict) to perform inference. | ||
|
|
||
| ```py | ||
| model.predict("Amelia Earhart flew her single engine Lockheed Vega 5B across the Atlantic to Paris.") | ||
| ``` | ||
| ```bash | ||
| ['positive', 'negative'] | ||
| ``` | ||
|
|
||
| If you want to load a specific SpanMarker model, you can click `Use in SetFit` and you will be given a working snippet! | ||
|
|
||
| ## Additional resources | ||
| * [All SetFit models available on Hub](https://huggingface.co/models?library=setfit) | ||
tomaarsen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * SetFit [repository](https://github.com/huggingface/setfit) | ||
| * SetFit [docs](https://huggingface.co/docs/setfit) | ||
| * SetFit [paper](https://arxiv.org/abs/2209.11055) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.