--- tags: - setfit - sentence-transformers - text-classification - generated_from_setfit_trainer widget: - text: A fantastical portal opening into another dimension, swirling energy. - text: Analyze the concept of political trust and its importance for governance. - text: What makes a particular escape room experience engaging and successful? - text: What is the function of the lymphatic system? - text: Desenvolva um conto fictício sobre um mapa antigo que guia para um tesouro cultural perdido. metrics: - accuracy pipeline_tag: text-classification library_name: setfit inference: true base_model: ibm-granite/granite-embedding-107m-multilingual model-index: - name: SetFit with ibm-granite/granite-embedding-107m-multilingual results: - task: type: text-classification name: Text Classification dataset: name: Unknown type: unknown split: test metrics: - type: accuracy value: 0.8924137931034483 name: Accuracy --- As of 28/07/2025, I instead of using this model, a simpler approach would be to just use one of these [Gliclass Models](https://huggingface.co/cnmoro/gliclass-base-v3.0-onnx), matching the user's prompt against the prompts classes. But this model will remain here nonetheless. ------------------------ # SetFit with ibm-granite/granite-embedding-107m-multilingual This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [ibm-granite/granite-embedding-107m-multilingual](https://huggingface.co/ibm-granite/granite-embedding-107m-multilingual) 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:** [ibm-granite/granite-embedding-107m-multilingual](https://huggingface.co/ibm-granite/granite-embedding-107m-multilingual) - **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:** 30 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 | |:-------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | sentiment_analysis | | | marketing | | | entertainment | | | image_generation | | | complex_reasoning | | | education | | | mathematics | | | biology | | | extraction | | | engineering | | | ethics | | | law | | | general_knowledge | | | geopolitics | | | summarization | | | healthcare | | | spiritual | | | coding | | | tool | | | politics | | | business | | | creativity | | | physics | | | psychological | | | history | | | translation | | | basic_reasoning | | | finance | | | chemistry | | | roleplay | | ## Evaluation ### Metrics | Label | Accuracy | |:--------|:---------| | **all** | 0.8924 | ## 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("cnmoro/prompt-router") # Run inference preds = model("What is the function of the lymphatic system?") ``` ## Training Details ### Training Set Metrics | Training set | Min | Median | Max | |:-------------|:----|:--------|:----| | Word count | 3 | 11.6859 | 38 | | Label | Training Sample Count | |:-------------------|:----------------------| | creativity | 176 | | extraction | 283 | | image_generation | 173 | | education | 181 | | summarization | 174 | | chemistry | 174 | | sentiment_analysis | 179 | | geopolitics | 181 | | translation | 179 | | history | 177 | | coding | 158 | | politics | 181 | | healthcare | 178 | | business | 170 | | complex_reasoning | 152 | | psychological | 174 | | biology | 172 | | mathematics | 178 | | marketing | 177 | | physics | 177 | | engineering | 176 | | roleplay | 171 | | finance | 175 | | basic_reasoning | 154 | | ethics | 180 | | entertainment | 180 | | tool | 166 | | law | 173 | | spiritual | 175 | | general_knowledge | 170 | ### Training Hyperparameters - batch_size: (8, 8) - num_epochs: (1, 16) - max_steps: 2400 - 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 - l2_weight: 0.01 - seed: 42 - evaluation_strategy: steps - eval_max_steps: -1 - load_best_model_at_end: True ### Training Results | Epoch | Step | Training Loss | Validation Loss | |:------:|:----:|:-------------:|:---------------:| | 0.0004 | 1 | 0.2374 | - | | 0.0208 | 50 | 0.2111 | - | | 0.0417 | 100 | 0.2087 | - | | 0.0625 | 150 | 0.1995 | - | | 0.0833 | 200 | 0.1984 | 0.1876 | | 0.1042 | 250 | 0.1894 | - | | 0.125 | 300 | 0.1872 | - | | 0.1458 | 350 | 0.1818 | - | | 0.1667 | 400 | 0.1758 | 0.1587 | | 0.1875 | 450 | 0.1647 | - | | 0.2083 | 500 | 0.1547 | - | | 0.2292 | 550 | 0.1404 | - | | 0.25 | 600 | 0.1342 | 0.1252 | | 0.2708 | 650 | 0.1309 | - | | 0.2917 | 700 | 0.1209 | - | | 0.3125 | 750 | 0.1329 | - | | 0.3333 | 800 | 0.1068 | 0.1055 | | 0.3542 | 850 | 0.1131 | - | | 0.375 | 900 | 0.1006 | - | | 0.3958 | 950 | 0.1033 | - | | 0.4167 | 1000 | 0.1005 | 0.0922 | | 0.4375 | 1050 | 0.1133 | - | | 0.4583 | 1100 | 0.0898 | - | | 0.4792 | 1150 | 0.0918 | - | | 0.5 | 1200 | 0.0983 | 0.0855 | | 0.5208 | 1250 | 0.0947 | - | | 0.5417 | 1300 | 0.0921 | - | | 0.5625 | 1350 | 0.1045 | - | | 0.5833 | 1400 | 0.09 | 0.0763 | | 0.6042 | 1450 | 0.0893 | - | | 0.625 | 1500 | 0.0823 | - | | 0.6458 | 1550 | 0.0853 | - | | 0.6667 | 1600 | 0.0881 | 0.0713 | | 0.6875 | 1650 | 0.0837 | - | | 0.7083 | 1700 | 0.0886 | - | | 0.7292 | 1750 | 0.0784 | - | | 0.75 | 1800 | 0.0838 | 0.0680 | | 0.7708 | 1850 | 0.0743 | - | | 0.7917 | 1900 | 0.0788 | - | | 0.8125 | 1950 | 0.084 | - | | 0.8333 | 2000 | 0.0772 | 0.0659 | | 0.8542 | 2050 | 0.0872 | - | | 0.875 | 2100 | 0.0808 | - | | 0.8958 | 2150 | 0.0649 | - | | 0.9167 | 2200 | 0.0795 | 0.0651 | | 0.9375 | 2250 | 0.0774 | - | | 0.9583 | 2300 | 0.0687 | - | | 0.9792 | 2350 | 0.0787 | - | | 1.0 | 2400 | 0.0786 | 0.0647 | ### Framework Versions - Python: 3.11.11 - SetFit: 1.2.0.dev0 - Sentence Transformers: 5.0.0 - Transformers: 4.53.2 - PyTorch: 2.7.1+cu126 - Datasets: 3.2.0 - Tokenizers: 0.21.0 ## 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} } ```