Efficient Few-Shot Learning Without Prompts
Paper • 2209.11055 • Published • 7
How to use oneryalcin/rvl-cdip-setfit-neomme with setfit:
from setfit import SetFitModel
model = SetFitModel.from_pretrained("oneryalcin/rvl-cdip-setfit-neomme")
preds = model.predict(["i loved the spiderman movie!", "pineapple on pizza is the worst"])
print(preds)How to use oneryalcin/rvl-cdip-setfit-neomme with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("oneryalcin/rvl-cdip-setfit-neomme")
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 Hcompany/NeoMME-260M-Retriever-ST-dense as the Sentence Transformer embedding model. A LogisticRegression instance is used for classification.
The model has been trained using an efficient few-shot learning technique that involves:
| Label | Examples |
|---|---|
| questionnaire |
|
| invoice |
|
| advertisement |
|
| scientific publication |
|
| letter |
|
| file folder |
|
| form |
|
|
|
| budget |
|
| specification |
|
| news article |
|
| scientific report |
|
| handwritten |
|
| resume |
|
| presentation |
|
| memo |
|
First install the SetFit library:
pip install setfit
Then you can load this model and run inference.
from PIL import Image
from setfit import SetFitModel
# Download from the 🤗 Hub
model = SetFitModel.from_pretrained("oneryalcin/rvl-cdip-setfit-neomme")
# Run inference on images
preds = model([Image.open("example.png")])
| Epoch | Step | Training Loss | Validation Loss |
|---|---|---|---|
| 0.0031 | 1 | 0.1619 | - |
| 0.1562 | 50 | 0.2096 | - |
| 0.3125 | 100 | 0.1618 | - |
| 0.4688 | 150 | 0.1933 | - |
| 0.625 | 200 | 0.1195 | - |
| 0.7812 | 250 | 0.1068 | - |
| 0.9375 | 300 | 0.0836 | - |
@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}
}
test)
accuracy 0.532, macro F1 0.516 on 400 images; 8 training images per class; body Hcompany/NeoMME-260M-Retriever-ST-dense, task document; trained in 769s on cuda.
precision recall f1-score support
advertisement 0.56 0.76 0.64 25
budget 0.41 0.28 0.33 25
email 0.64 0.56 0.60 25
file folder 0.54 0.76 0.63 25
form 0.41 0.48 0.44 25
handwritten 0.83 0.76 0.79 25
invoice 0.33 0.24 0.28 25
letter 0.58 0.60 0.59 25
memo 0.30 0.32 0.31 25
news article 0.50 0.64 0.56 25
presentation 0.33 0.24 0.28 25
questionnaire 0.38 0.36 0.37 25
resume 1.00 0.92 0.96 25
scientific publication 0.61 0.76 0.68 25
scientific report 0.43 0.12 0.19 25
specification 0.53 0.72 0.61 25
accuracy 0.53 400
macro avg 0.52 0.53 0.52 400
weighted avg 0.52 0.53 0.52 400
Base model
Hcompany/NeoMME-260M