Text Classification
setfit
Safetensors
sentence-transformers
mpnet
generated_from_setfit_trainer
Eval Results (legacy)
text-embeddings-inference
Instructions to use EphronM/setfit-demoModel with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- setfit
How to use EphronM/setfit-demoModel with setfit:
from setfit import SetFitModel model = SetFitModel.from_pretrained("EphronM/setfit-demoModel") preds = model.predict(["i loved the spiderman movie!", "pineapple on pizza is the worst"]) print(preds) - sentence-transformers
How to use EphronM/setfit-demoModel with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("EphronM/setfit-demoModel") 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] - Notebooks
- Google Colab
- Kaggle
Add SetFit model
Browse filesFiles changed (13)
- 1_Pooling/config.jsonAdded+10
- README.mdAdded+206
- config.jsonAdded+24
- config_sentence_transformers.jsonAdded+10
- config_setfit.jsonAdded+7
- model.safetensorsAdded+3
- model_head.pklAdded+3
- modules.jsonAdded+14
- sentence_bert_config.jsonAdded+4
- special_tokens_map.jsonAdded+51
- tokenizer.jsonAdded
- tokenizer_config.jsonAdded+66
- vocab.txtAdded
12345678910{ "word_embedding_dimension": 768, "pooling_mode_cls_token": false, "pooling_mode_mean_tokens": true, "pooling_mode_max_tokens": false, "pooling_mode_mean_sqrt_len_tokens": false, "pooling_mode_weightedmean_tokens": false, "pooling_mode_lasttoken": false, "include_prompt": true}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206---base_model: sentence-transformers/paraphrase-mpnet-base-v2library_name: setfitmetrics:- accuracypipeline_tag: text-classificationtags:- setfit- sentence-transformers- text-classification- generated_from_setfit_trainerwidget:- text: 'the band ''s courage in the face of official repression is inspiring , especially for aging hippies ( this one included ) . '- text: 'a fast , funny , highly enjoyable movie . '- text: 'the movie achieves as great an impact by keeping these thoughts hidden as ... ( quills ) did by showing them . '- text: 'the title not only describes its main characters , but the lazy people behind the camera as well . '- text: '... the movie is just a plain old monster . 'inference: truemodel-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.8886010362694301 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:** 2 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 ||:------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|| yes | <ul><li>'a compelling story of musical passion '</li><li>'able to forgive its mean-spirited second half '</li><li>'has the chops of a smart-aleck film school brat and the imagination of a big kid ... '</li></ul> || no | <ul><li>'will have completely forgotten the movie by the time you get back to your car in the parking lot '</li><li>'indignation '</li><li>'down the reality drain '</li></ul> |
## Evaluation
### Metrics| Label | Accuracy ||:--------|:---------|| **all** | 0.8886 |
## Uses
### Direct Use for Inference
First install the SetFit library:
```bashpip install setfit```
Then you can load this model and run inference.
```pythonfrom setfit import SetFitModel
# Download from the 🤗 Hubmodel = SetFitModel.from_pretrained("EphronM/setfit-demoModel")# Run inferencepreds = model("a fast , funny , highly enjoyable movie . ")```
<!--### 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 | 2 | 10.58 | 37 |
| Label | Training Sample Count ||:------|:----------------------|| no | 50 || yes | 50 |
### Training Hyperparameters- batch_size: (16, 16)- num_epochs: (1, 1)- max_steps: -1- sampling_strategy: oversampling- body_learning_rate: (2e-05, 1e-05)- head_learning_rate: 0.01- 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: True
### Training Results| Epoch | Step | Training Loss | Validation Loss ||:-------:|:-------:|:-------------:|:---------------:|| 0.0031 | 1 | 0.3648 | - || 0.1567 | 50 | 0.0215 | - || 0.3135 | 100 | 0.0029 | - || 0.4702 | 150 | 0.001 | - || 0.6270 | 200 | 0.0005 | - || 0.7837 | 250 | 0.0012 | - || 0.9404 | 300 | 0.0011 | - || **1.0** | **319** | **-** | **0.1299** |
* The bold row denotes the saved checkpoint.### Framework Versions- Python: 3.10.14- SetFit: 1.1.0.dev0- Sentence Transformers: 3.0.1- Transformers: 4.44.2- PyTorch: 2.4.0+cu121- Datasets: 2.21.0- Tokenizers: 0.19.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.*-->123456789101112131415161718192021222324{ "_name_or_path": "checkpoints/step_319", "architectures": [ "MPNetModel" ], "attention_probs_dropout_prob": 0.1, "bos_token_id": 0, "eos_token_id": 2, "hidden_act": "gelu", "hidden_dropout_prob": 0.1, "hidden_size": 768, "initializer_range": 0.02, "intermediate_size": 3072, "layer_norm_eps": 1e-05, "max_position_embeddings": 514, "model_type": "mpnet", "num_attention_heads": 12, "num_hidden_layers": 12, "pad_token_id": 1, "relative_attention_num_buckets": 32, "torch_dtype": "float32", "transformers_version": "4.44.2", "vocab_size": 30527}12345678910{ "__version__": { "sentence_transformers": "3.0.1", "transformers": "4.44.2", "pytorch": "2.4.0+cu121" }, "prompts": {}, "default_prompt_name": null, "similarity_fn_name": null}1234567{ "labels": [ "no", "yes" ], "normalize_embeddings": false}123version https://git-lfs.github.com/spec/v1oid sha256:57f8fd03d8843e6dd751368607ef921eed1320cf437563e99d00e565bfff496asize 437967672123version https://git-lfs.github.com/spec/v1oid sha256:0c2232d48aa05ee08ccc0292f7e366251c1ef212e416985401b730d553f9e475size 70071234567891011121314[ { "idx": 0, "name": "0", "path": "", "type": "sentence_transformers.models.Transformer" }, { "idx": 1, "name": "1", "path": "1_Pooling", "type": "sentence_transformers.models.Pooling" }]1234{ "max_seq_length": 512, "do_lower_case": false}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051{ "bos_token": { "content": "<s>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "cls_token": { "content": "<s>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "eos_token": { "content": "</s>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "mask_token": { "content": "<mask>", "lstrip": true, "normalized": false, "rstrip": false, "single_word": false }, "pad_token": { "content": "<pad>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "sep_token": { "content": "</s>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "unk_token": { "content": "[UNK]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566{ "added_tokens_decoder": { "0": { "content": "<s>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "1": { "content": "<pad>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "2": { "content": "</s>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "104": { "content": "[UNK]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "30526": { "content": "<mask>", "lstrip": true, "normalized": false, "rstrip": false, "single_word": false, "special": true } }, "bos_token": "<s>", "clean_up_tokenization_spaces": true, "cls_token": "<s>", "do_basic_tokenize": true, "do_lower_case": true, "eos_token": "</s>", "mask_token": "<mask>", "max_length": 512, "model_max_length": 512, "never_split": null, "pad_to_multiple_of": null, "pad_token": "<pad>", "pad_token_type_id": 0, "padding_side": "right", "sep_token": "</s>", "stride": 0, "strip_accents": null, "tokenize_chinese_chars": true, "tokenizer_class": "MPNetTokenizer", "truncation_side": "right", "truncation_strategy": "longest_first", "unk_token": "[UNK]"}1_Pooling/config.jsonAdded+10
README.mdAdded+206
config.jsonAdded+24
config_sentence_transformers.jsonAdded+10
config_setfit.jsonAdded+7
model.safetensorsAdded+3
model_head.pklAdded+3
modules.jsonAdded+14
sentence_bert_config.jsonAdded+4
special_tokens_map.jsonAdded+51
tokenizer.jsonAdded
tokenizer_config.jsonAdded+66
vocab.txtAdded