--- library_name: setfit tags: - setfit - sentence-transformers - text-classification - generated_from_setfit_trainer base_model: sentence-transformers/paraphrase-mpnet-base-v2 metrics: - accuracy widget: - text: 'User: Hi there, I want to open a new bank account. AI: Hello! What kind of account are you interested in? User: I''m thinking of opening a savings account. Can you give me more details? AI: Sure, our savings account comes with a competitive interest rate of 1.5%, online banking access, no monthly fees, and the option to set up automated transfers to help you save. Are you interested in opening one with us? User: Yes, that sounds great. Let''s go ahead and start the process.' - text: 'User: Hey there, I need to know my account balance. Bot: Hi! Absolutely, I''m here to assist. Just to confirm, do you have a checking or savings account? User: It''s a savings account. Bot: Understood, thanks! Could you share your account number with me? User: Of course, it''s 987654321. Bot: Great, thanks! Now, for security purposes, may I have your password as well? User: Sure, it''s "confidential789".' - text: 'User: Hi, I just checked my bank statement and found that my balance is showing less than what it should be. Bot: I''m sorry to hear that! Can you please elaborate on the specific transaction or amount that you are referring to? User: Sorry, I don''t have the transaction details right now. Bot: That''s alright. Can you please provide me with more information like the date or time of the transaction to help me look into this further? User: I''m not sure about the exact date or time. Bot: No worries. Can you please provide me with any other information you have that might help me to identify the transaction? User: I remember the transaction amount was around $50. Bot: Okay, I''ll investigate and get back to you quickly. User. Thank and do it quickly.' - text: 'User: Hi, I''d like to dispute a transaction on my account.Bank Bot: I''m sorry to hear that. To assist you further, could you please provide me with the details of the transaction you wish to dispute, including the transaction amount, date, and description?User: $100 on March 15th, at a restaurant. However, I don''t recall making this transaction. Bank Bot: Thank you for providing the details. Based on your information, I can see that the transaction was made at a restaurant. Do you often dine at this particular restaurant? User: Can I pause the conversation for a moment? I need to check my records to see if I can recall anything. Bank Bot: Sure, take your time. User: Sorry about that. I don''t recall making the transaction at that restaurant. Can we take a pause here? ' - text: "Bot: Hello! What may I help you with today regarding your card?\n User: Hi.\ \ I'd like to cancel my bank card, please. \n Bot: Of course. Can you let me know\ \ the reason behind your request? \nUser: I want to simplify my finances and just\ \ focus on one bank account.\n Bot: Alright. So you prefer to consolidate accounts\ \ and have no unnecessary cards, then? \nUser: Yes" pipeline_tag: text-classification 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.8197674418604651 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:** 14 classes ### 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 | |:---------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | Refuse to Answer | | | Negative Confirmation | | | Restart Conversation | | | Transfer to Human Agent | | | Continue Conversation | | | Pause Conversation | | | Correction Request | | | Questions Requiring External Information | | | Affirmative Confirmation | | | Questions on Process | | | New Inquiry or Request | | | Questions Answerable by Conversational Context / History | | | Repeat Conversation | | | End Conversation | | ## Evaluation ### Metrics | Label | Accuracy | |:--------|:---------| | **all** | 0.8198 | ## 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("setfit_model_id") # Run inference preds = model("Bot: Hello! What may I help you with today regarding your card? User: Hi. I'd like to cancel my bank card, please. Bot: Of course. Can you let me know the reason behind your request? User: I want to simplify my finances and just focus on one bank account. Bot: Alright. So you prefer to consolidate accounts and have no unnecessary cards, then? User: Yes") ``` ## Training Details ### Training Set Metrics | Training set | Min | Median | Max | |:-------------|:----|:--------|:----| | Word count | 10 | 80.0088 | 257 | | Label | Training Sample Count | |:---------------------------------------------------------|:----------------------| | Affirmative Confirmation | 93 | | Continue Conversation | 80 | | Correction Request | 66 | | End Conversation | 38 | | Negative Confirmation | 41 | | New Inquiry or Request | 41 | | Pause Conversation | 45 | | Questions Answerable by Conversational Context / History | 44 | | Questions Requiring External Information | 43 | | Questions on Process | 43 | | Refuse to Answer | 41 | | Repeat Conversation | 36 | | Restart Conversation | 39 | | Transfer to Human Agent | 34 | ### Training Hyperparameters - batch_size: (16, 16) - 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.0006 | 1 | 0.2553 | - | | 0.0292 | 50 | 0.244 | - | | 0.0585 | 100 | 0.2357 | - | | 0.0877 | 150 | 0.1168 | - | | 0.1170 | 200 | 0.0936 | - | | 0.1462 | 250 | 0.1292 | - | | 0.1754 | 300 | 0.0188 | - | | 0.2047 | 350 | 0.0553 | - | | 0.2339 | 400 | 0.0576 | - | | 0.2632 | 450 | 0.0633 | - | | 0.2924 | 500 | 0.0512 | - | | 0.3216 | 550 | 0.0705 | - | | 0.3509 | 600 | 0.0015 | - | | 0.3801 | 650 | 0.025 | - | | 0.4094 | 700 | 0.0397 | - | | 0.4386 | 750 | 0.0318 | - | | 0.4678 | 800 | 0.0029 | - | | 0.4971 | 850 | 0.0075 | - | | 0.5263 | 900 | 0.0396 | - | | 0.5556 | 950 | 0.0021 | - | | 0.5848 | 1000 | 0.0251 | - | | 0.6140 | 1050 | 0.009 | - | | 0.6433 | 1100 | 0.0072 | - | | 0.6725 | 1150 | 0.0114 | - | | 0.7018 | 1200 | 0.0042 | - | | 0.7310 | 1250 | 0.0048 | - | | 0.7602 | 1300 | 0.027 | - | | 0.7895 | 1350 | 0.0027 | - | | 0.8187 | 1400 | 0.0011 | - | | 0.8480 | 1450 | 0.0007 | - | | 0.8772 | 1500 | 0.0035 | - | | 0.9064 | 1550 | 0.0009 | - | | 0.9357 | 1600 | 0.0017 | - | | 0.9649 | 1650 | 0.0002 | - | | 0.9942 | 1700 | 0.0009 | - | ### Framework Versions - Python: 3.10.12 - SetFit: 1.0.3 - Sentence Transformers: 2.7.0 - Transformers: 4.40.1 - PyTorch: 2.2.1+cu121 - Datasets: 2.19.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} } ```