Efficient Few-Shot Learning Without Prompts
Paper • 2209.11055 • Published • 6
How to use HelgeKn/Swag-multi-class-4 with setfit:
from setfit import SetFitModel
model = SetFitModel.from_pretrained("HelgeKn/Swag-multi-class-4")How to use HelgeKn/Swag-multi-class-4 with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("HelgeKn/Swag-multi-class-4")
sentences = [
"The weather is lovely today.",
"It's so sunny outside!",
"He drove to the stadium."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]This is a SetFit model that can be used for Text Classification. This SetFit model uses sentence-transformers/paraphrase-mpnet-base-v2 as the Sentence Transformer embedding model. A SetFitHead instance is used for classification.
The model has been trained using an efficient few-shot learning technique that involves:
| Label | Examples |
|---|---|
| 6 |
|
| 4 |
|
| 1 |
|
| 5 |
|
| 8 |
|
| 2 |
|
| 7 |
|
| 0 |
|
| 3 |
|
| Label | Accuracy |
|---|---|
| all | 0.1148 |
First install the SetFit library:
pip install setfit
Then you can load this model and run inference.
from setfit import SetFitModel
# Download from the 🤗 Hub
model = SetFitModel.from_pretrained("HelgeKn/Swag-multi-class-4")
# Run inference
preds = model("He approaches the object and reads a plaque on its side. Someone")
| Training set | Min | Median | Max |
|---|---|---|---|
| Word count | 6 | 13.25 | 31 |
| Label | Training Sample Count |
|---|---|
| 0 | 4 |
| 1 | 4 |
| 2 | 4 |
| 3 | 4 |
| 4 | 4 |
| 5 | 4 |
| 6 | 4 |
| 7 | 4 |
| 8 | 4 |
| Epoch | Step | Training Loss | Validation Loss |
|---|---|---|---|
| 0.0111 | 1 | 0.2285 | - |
| 0.5556 | 50 | 0.0567 | - |
| 1.1111 | 100 | 0.0083 | - |
| 1.6667 | 150 | 0.0084 | - |
@article{https://doi.org/10.48550/arxiv.2209.11055,
doi = {10.48550/ARXIV.2209.11055},
url = {https://arxiv.org/abs/2209.11055},
author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {Efficient Few-Shot Learning Without Prompts},
publisher = {arXiv},
year = {2022},
copyright = {Creative Commons Attribution 4.0 International}
}