setfit safetensors mpnet sentence-transformers text-classification generated_from_setfit_trainer arxiv:2209.11055 base_model:sentence-transformers/paraphrase-mpnet-base-v2 base_model:finetune:sentence-transformers/paraphrase-mpnet-base-v2 model-index region:us
---
base_model: sentence-transformers/paraphrase-mpnet-base-v2
library_name: setfit
metrics:
- accuracy
pipeline_tag: text-classification
tags:
- setfit
- sentence-transformers
- text-classification
- generated_from_setfit_trainer
widget:
- text: Blockbuster Cuts Online Price, Challenges Netflix (Reuters) Reuters - Video
    chain Blockbuster Inc on\Friday said it would lower the price of its online DVD
    rentals\to undercut a similar move by Netflix Inc. that sparked a stock\a sell-off
    of both companies' shares.
- text: Goss Gets Senate Panel's OK for CIA Post (AP) AP - A Senate panel on Tuesday
    approved the nomination of Rep. Porter Goss, R-Fla., to head the CIA, overcoming
    Democrats' objections that Goss was too political for the job.
- text: 'Crazy Like a Firefox Today, the Mozilla Foundation #39;s Firefox browser
    officially launched -- welcome, version 1.0. In a way, it #39;s much ado about
    nothing, seeing how it wasn #39;t that long ago that we reported on how Mozilla
    had set '
- text: North Korea eases tough stance against US in nuclear talks North Korea on
    Friday eased its tough stance against the United States, saying it is willing
    to resume stalled six-way talks on its nuclear weapons if Washington is ready
    to consider its demands.
- text: Mauresmo confident of LA victory Amelie Mauresmo insists she can win the Tour
    Championships this week and finish the year as world number one. The Frenchwoman
    could overtake Lindsay Davenport with a win in Los Angeles.
inference: true
model-index:
- name: SetFit with sentence-transformers/paraphrase-mpnet-base-v2
  results:
  - task:
      type: text-classification
      name: Text Classification
    dataset:
      name: Unknown
      type: unknown
      split: test
    metrics:
    - type: accuracy
      value: 0.8567105263157895
      name: Accuracy
---

# SetFit with sentence-transformers/paraphrase-mpnet-base-v2

This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [sentence-transformers/paraphrase-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-mpnet-base-v2) as the Sentence Transformer embedding model. A [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance is used for classification.

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.

## Model Details

### Model Description
- **Model Type:** SetFit
- **Sentence Transformer body:** [sentence-transformers/paraphrase-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-mpnet-base-v2)
- **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
- **Maximum Sequence Length:** 512 tokens
- **Number of Classes:** 4 classes
<!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
<!-- - **Language:** Unknown -->
<!-- - **License:** Unknown -->

### Model Sources

- **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
- **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
- **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)

### Model Labels
| Label | Examples                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|:------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1     | <ul><li>'Injuries prevent Fox from continuing career Rick Fox made it official yesterday: He will not be coming through any door to have a second go-round with the Celtics. As shockers go, this one is slightly behind  quot;Dewey Defeats Truman. quot;'</li><li>'Sack-happy  #39;D #39; bags Bills defenders got a piece of Bledsoe, and the Raiders offense did just enough -- as in a 43-yard touchdown pass from Rich Gannon to Ronald Curry and two Sebastian Janikowski field '</li><li>'Aussies ready for Sachin On Wednesday morning Sachin Tendulkar was at the Brabourne stadium, to egg on his Mumbai teammates. Not only did he have a chat with the Mumbai captain and coach and see the practice session through, but also '</li></ul>                                                                                                                                                                                                       |
| 2     | <ul><li>'Costello to steer Group of 20 TREASURER Peter Costello will chair the 2006 meeting of the Group of 20, which brings together the finance ministers and central bankers from the leading industrial and developing nations.'</li><li>'Bye-bye, floppy. It #39;s been good to know you If you #39;re a computer user, you may have several of them stacked on your desk. We #39;re talking about floppy disks - and they are pretty much becoming extinct.'</li><li>'Eisner #39;s Exit Plan Good for Disney -Analysts While fans of Michael Eisner argue that his 20-year legacy of continued financial and stock growth at the Walt Disney Co. is a strong achievement, Wall Street observers say his record is more mixed.'</li></ul>                                                                                                                                                                                                                |
| 0     | <ul><li>"Militants beat man thought to be from US HENDALA, Sri Lanka -- Day after day, locked in a cement room somewhere in Iraq, the hooded men beat him. They told him he would be beheaded. ''Ameriqi! quot; they shouted, even though he comes from this poor Sri Lankan fishing village."</li><li>'World News  gt; Indians unfazed by Kathmandu blockade - but panic in India: Kanaiyalal Jiwanlal, a businessman from Valsad in Gujarat, has seen sectarian violence and a killer earthquake devastate parts of the western Indian state. Compared to such upheavals, the blockade of Kathmandu, called by Maoists, holds no terror for him. '</li><li>'Mosque on Fire After U.S. Air Strikes in West Iraq  BAGHDAD (Reuters) - U.S. marines engaged in heavy clashes  with scores of insurgents near a mosque in western Iraq on  Monday, leading to U.S. air strikes which damaged the shrine  and left it ablaze, the U.S. military said.'</li></ul> |
| 3     | <ul><li>'Philips Electronics resumes marketing PCs After an absence of a decade, Philips Electronics is making personal computers again, the company said yesterday. The Netherlands-based electronics conglomerate, which abandoned the PC business in the early '</li><li>'Microsoft is ready to remove media player for EU Microsoft will be ready to comply with European Commission demands for changes to its Windows operating systems if a European court does not suspend the antitrust remedy, a company spokesman said today.'</li><li>'NASA #39;s chief quitting post Sean O #39;Keefe on Monday officially resigned as the head of NASA to interview as the chancellor at Louisiana State University in Baton Rouge.'</li></ul>                                                                                                                                                                                                                  |

## Evaluation

### Metrics
| Label   | Accuracy |
|:--------|:---------|
| **all** | 0.8567   |

## Uses

### Direct Use for Inference

First install the SetFit library:

```bash
pip install setfit
```

Then you can load this model and run inference.

```python
from setfit import SetFitModel

# Download from the 🤗 Hub
model = SetFitModel.from_pretrained("vidhi0206/setfit-paraphrase-mpnet-ag_news")
# Run inference
preds = model("Mauresmo confident of LA victory Amelie Mauresmo insists she can win the Tour Championships this week and finish the year as world number one. The Frenchwoman could overtake Lindsay Davenport with a win in Los Angeles.")
```

<!--
### Downstream Use

*List how someone could finetune this model on their own dataset.*
-->

<!--
### Out-of-Scope Use

*List how the model may foreseeably be misused and address what users ought not to do with the model.*
-->

<!--
## Bias, Risks and Limitations

*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
-->

<!--
### Recommendations

*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
-->

## Training Details

### Training Set Metrics
| Training set | Min | Median  | Max |
|:-------------|:----|:--------|:----|
| Word count   | 25  | 40.0938 | 56  |

| Label | Training Sample Count |
|:------|:----------------------|
| 0     | 8                     |
| 1     | 8                     |
| 2     | 8                     |
| 3     | 8                     |

### Training Hyperparameters
- batch_size: (8, 8)
- num_epochs: (1, 1)
- max_steps: -1
- sampling_strategy: oversampling
- num_iterations: 20
- body_learning_rate: (2e-05, 2e-05)
- head_learning_rate: 2e-05
- loss: CosineSimilarityLoss
- distance_metric: cosine_distance
- margin: 0.25
- end_to_end: False
- use_amp: False
- warmup_proportion: 0.1
- seed: 42
- eval_max_steps: -1
- load_best_model_at_end: False

### Training Results
| Epoch  | Step | Training Loss | Validation Loss |
|:------:|:----:|:-------------:|:---------------:|
| 0.0063 | 1    | 0.1756        | -               |
| 0.3125 | 50   | 0.0433        | -               |
| 0.625  | 100  | 0.0022        | -               |
| 0.9375 | 150  | 0.0011        | -               |

### Framework Versions
- Python: 3.8.10
- SetFit: 1.0.3
- Sentence Transformers: 2.3.1
- Transformers: 4.37.2
- PyTorch: 2.2.0+cu121
- Datasets: 2.17.0
- Tokenizers: 0.15.1

## Citation

### BibTeX
```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}
}
```

<!--
## Glossary

*Clearly define terms in order to be accessible across audiences.*
-->

<!--
## Model Card Authors

*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
-->

<!--
## Model Card Contact

*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
-->