|
--- |
|
license: apache-2.0 |
|
tags: |
|
- setfit |
|
- sentence-transformers |
|
- text-classification |
|
pipeline_tag: text-classification |
|
--- |
|
|
|
# krumeto/setfit-recipe-classifer |
|
|
|
This is a [SetFit model](https://github.com/huggingface/setfit) that can be used for classification how difficult is a given recipe. The model has been trained using an efficient few-shot learning technique that involves: |
|
|
|
1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning. |
|
2. Training a classification head with features from the fine-tuned Sentence Transformer. |
|
|
|
## Usage |
|
|
|
To use this model for inference, first install the SetFit library: |
|
|
|
```bash |
|
python -m pip install setfit |
|
``` |
|
|
|
You can then run inference as follows: |
|
|
|
```python |
|
from setfit import SetFitModel |
|
|
|
# Download from Hub and run inference |
|
model = SetFitModel.from_pretrained("krumeto/setfit-recipe-classifer") |
|
complicated_recipe = """Ingredients: |
|
4 ounces pancetta, diced into 1/4 inch cubes |
|
2 1/2 to 3 pounds veal shanks (4 to 6 pieces 2 to 3 inches thick) |
|
1/2 cup diced onion |
|
1/2 cup diced celery |
|
1/2 cup diced carrot |
|
3 garlic cloves , minced |
|
1 1/2 cups canned chopped tomatoes |
|
1 1/2 cups chicken broth |
|
1/2 cup dry white wine |
|
1 bay leaf |
|
1 sprig fresh thyme |
|
salt |
|
freshly ground black pepper |
|
all-purpose flour for dredging |
|
2 tablespoons unsalted butter |
|
2 tablespoons extra-virgin olive oil |
|
4 3-inch strips of lemon zest |
|
|
|
Directions: |
|
|
|
Preheat oven to 375°F. |
|
Heat the olive oil over medium heat in a large Dutch oven. |
|
Cook pancetta until browned and crisp. |
|
Remove pancetta with a slotted spoon and transfer to a paper towel-lined plate. |
|
Season veal shanks with salt and pepper and dredge in flour. |
|
Cook the veal until browned on all sides, working in batches if necessary, then transfer to a plate. |
|
Add the onion, celery, carrot, garlic, and a pinch of salt to the Dutch oven and cook until softened. |
|
Stir in the tomatoes, chicken broth, dry white wine, bay leaf, and thyme sprig. |
|
Return the veal shanks and pancetta to the Dutch oven and bring the liquid to a simmer. |
|
Cover the pot and place it in the oven to braise for 2-2 1/2 hours, until the veal is very tender. |
|
Serve with gremolata and garnish with lemon zest strips. |
|
Note: To make gremolata, finely chop 2 tablespoons fresh parsley, 1 tablespoon grated lemon zest, and 1 garlic clove. Mix together and sprinkle over the osso buco before serving.""" |
|
|
|
# Run inference |
|
preds = model([complicated_recipe]) |
|
``` |
|
|
|
## BibTeX entry and citation info |
|
|
|
```bibtex |
|
@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} |
|
} |
|
``` |
|
|