--- library_name: setfit tags: - setfit - sentence-transformers - text-classification - generated_from_setfit_trainer metrics: - accuracy widget: - text: حصل لاعبو المنتخب السوري لكرة القدم على مكافأة سريعة، بعد تحقيقهم الفوز على نظيرهم السعودي 2/1 في المباراة التي أقيمت، أول من أمس، على استاد الريان ضمن مباريات المجموعة الثانية لبطولة أمم آسيا بكرة القدم، المقامة حالياً في الدوحة وتستمر حتى 27 يناير الجاري. - text: هدد الامين العام لحزب الله حسن نصرالله الثلاثاء بضرب البنى التحتية في اسرائيل وبتدمير ابنية في تل ابيب في حال هاجمت الدولة العبرية لبنان، ملمحا الى اقتناء حزب الله القدرات العسكرية التي تخوله القيام بذلك. - text: برّأت لجنة تحقيق إسرائيلية على نطاق واسع أمس الجيش الإسرائيلي في تحقيق بشأن حصار غزة والعدوان على اسطول الحرية، فيما كشف تقرير إخباري إسرائيلي أن وزير الخارجية أفيغدور ليبرمان، رسم خريطة لدولة فلسطينية بحدود مؤقتة، سارع الفلسطينيون برفضها. - text: دعا الرئيس المنتخب لساحل العاج الحسن وتارا، أمس، الى استخدام القوة لحمل منافسه لوران غباغبو على التنحي. - text: تتجه الأنظار، اليوم، إلى القمة الكلاسيكية الخاصة بين منتخبي اليابان وكوريا الجنوبية، على ملعب نادي الغرافة في نصف نهائي كأس آسيا الخامسة عشرة لكرة القدم في الدوحة. pipeline_tag: text-classification inference: true base_model: sentence-transformers/LaBSE model-index: - name: SetFit with sentence-transformers/LaBSE results: - task: type: text-classification name: Text Classification dataset: name: Unknown type: unknown split: test metrics: - type: accuracy value: 0.9083333333333333 name: Accuracy --- # SetFit with sentence-transformers/LaBSE This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [sentence-transformers/LaBSE](https://huggingface.co/sentence-transformers/LaBSE) 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/LaBSE](https://huggingface.co/sentence-transformers/LaBSE) - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance - **Maximum Sequence Length:** 256 tokens - **Number of Classes:** 4 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 | |:---------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | life | | | politics | | | sports | | | business | | ## Evaluation ### Metrics | Label | Accuracy | |:--------|:---------| | **all** | 0.9083 | ## 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("Ezzaldin-97/LaBSE-based-Arabic-News-Classifier") # Run inference preds = model("نقلت صحيفة واشنطن بوست امس عن مستشار الرئيس الاميركي باراك اوباما للامن القومي قوله ان اوباما يعتزم توسيع عضوية مجلس الامن القومي وزيادة سلطته لوضع استراتيجية سلسلة واسعة من القضايا الداخلية والدولية.") ``` ## Training Details ### Training Set Metrics | Training set | Min | Median | Max | |:-------------|:----|:--------|:----| | Word count | 11 | 32.9082 | 60 | | Label | Training Sample Count | |:---------|:----------------------| | business | 54 | | life | 98 | | politics | 91 | | sports | 73 | ### Training Hyperparameters - batch_size: (16, 16) - num_epochs: (2, 2) - 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.0013 | 1 | 0.2934 | - | | 0.0633 | 50 | 0.2025 | - | | 0.1266 | 100 | 0.104 | - | | 0.1899 | 150 | 0.0906 | - | | 0.2532 | 200 | 0.0012 | - | | 0.3165 | 250 | 0.001 | - | | 0.3797 | 300 | 0.0008 | - | | 0.4430 | 350 | 0.0007 | - | | 0.5063 | 400 | 0.0005 | - | | 0.5696 | 450 | 0.0006 | - | | 0.6329 | 500 | 0.0003 | - | | 0.6962 | 550 | 0.0003 | - | | 0.7595 | 600 | 0.0004 | - | | 0.8228 | 650 | 0.0004 | - | | 0.8861 | 700 | 0.0003 | - | | 0.9494 | 750 | 0.0003 | - | | 1.0127 | 800 | 0.0003 | - | | 1.0759 | 850 | 0.0002 | - | | 1.1392 | 900 | 0.0002 | - | | 1.2025 | 950 | 0.0003 | - | | 1.2658 | 1000 | 0.0003 | - | | 1.3291 | 1050 | 0.0002 | - | | 1.3924 | 1100 | 0.0002 | - | | 1.4557 | 1150 | 0.0004 | - | | 1.5190 | 1200 | 0.0002 | - | | 1.5823 | 1250 | 0.0003 | - | | 1.6456 | 1300 | 0.0002 | - | | 1.7089 | 1350 | 0.0002 | - | | 1.7722 | 1400 | 0.0003 | - | | 1.8354 | 1450 | 0.0002 | - | | 1.8987 | 1500 | 0.0002 | - | | 1.9620 | 1550 | 0.0003 | - | ### Framework Versions - Python: 3.10.12 - SetFit: 1.0.3 - Sentence Transformers: 2.6.1 - Transformers: 4.38.2 - PyTorch: 2.2.1+cu121 - Datasets: 2.18.0 - Tokenizers: 0.15.2 ## 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} } ```