twright8's picture
Update README.md
8117533 verified
|
raw
history blame
6.6 kB
metadata
library_name: setfit
metrics:
  - f1
  - accuracy
pipeline_tag: text-classification
tags:
  - setfit
  - sentence-transformers
  - text-classification
  - generated_from_setfit_trainer
widget:
  - text: >-
      To make introductions between Camelot's Chairman and the Cabinet
      Secretary. We discussed the operation of the UK National Lottery and how
      to maximise returns to National Lottery Good Causes as well as our plans
      to celebrate the 25th birthday of The National Lottery.
  - text: Discussion on crime
  - text: To discuss Northern Powerhouse Rail and HS2
  - text: To discuss food security
  - text: Electricity market
inference: true
model-index:
  - name: SetFit
    results:
      - task:
          type: text-classification
          name: Text Classification
        dataset:
          name: Unknown
          type: unknown
          split: test
        metrics:
          - type: f1
            value: 0.92
            name: F1
          - type: accuracy
            value: 0.9658119658119658
            name: Accuracy

SetFit

This is a SetFit model that can be used for Text Classification. A SetFitHead 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 with contrastive learning.
  2. Training a classification head with features from the fine-tuned Sentence Transformer.

Model Details

Model Description

  • Model Type: SetFit
  • Classification head: a SetFitHead instance
  • Maximum Sequence Length: 512 tokens
  • Number of Classes: 4 classes

Model Sources

Evaluation

Metrics

Label F1 Accuracy
all 0.92 0.9658

Uses

Direct Use for Inference

First install the SetFit library:

pip install setfit

Then you can load this model and run inference.

from setfit import SetFitModel

# Download from the 🤗 Hub
model = SetFitModel.from_pretrained("twright8/setfit-oversample-labels-lobbying")
# Run inference
preds = model("Electricity market")

Training Details

Training Set Metrics

Training set Min Median Max
Word count 2 26.1406 153

Training Hyperparameters

  • batch_size: (16, 2)
  • num_epochs: (4, 9)
  • max_steps: -1
  • sampling_strategy: oversampling
  • body_learning_rate: (1.0797496673911536e-05, 3.457046714445997e-05)
  • head_learning_rate: 0.0004470582121407239
  • loss: CoSENTLoss
  • distance_metric: cosine_distance
  • margin: 0.25
  • end_to_end: True
  • 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.0040 1 19.1843 -
0.2024 50 11.3434 -
0.4049 100 9.3116 -
0.6073 150 2.7233 -
0.8097 200 1.5662 -
1.0 247 - 14.3603
1.0121 250 0.0159 -
1.2146 300 0.0135 -
1.4170 350 0.0003 -
1.6194 400 0.0002 -
1.8219 450 0.0007 -
2.0 494 - 16.8205
2.0243 500 0.0023 -
2.2267 550 0.0004 -
2.4291 600 0.0001 -
2.6316 650 0.0 -
2.8340 700 0.0003 -
3.0 741 - 15.2312
3.0364 750 0.0 -
3.2389 800 3.1257 -
3.4413 850 0.0001 -
3.6437 900 0.0002 -
3.8462 950 0.0139 -
4.0 988 - 14.4995
  • The bold row denotes the saved checkpoint.

Framework Versions

  • Python: 3.10.12
  • SetFit: 1.0.3
  • Sentence Transformers: 3.0.1
  • Transformers: 4.39.0
  • PyTorch: 2.3.1+cu118
  • Datasets: 2.20.0
  • Tokenizers: 0.15.2

Citation

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}
}