SetFit Aspect Model with sentence-transformers/all-MiniLM-L6-v2

This is a SetFit model that can be used for Aspect Based Sentiment Analysis (ABSA). This SetFit model uses sentence-transformers/all-MiniLM-L6-v2 as the Sentence Transformer embedding model. A LogisticRegression instance is used for classification. In particular, this model is in charge of filtering aspect span candidates.

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.

This model was trained within the context of a larger system for ABSA, which looks like so:

  1. Use a spaCy model to select possible aspect span candidates.
  2. Use this SetFit model to filter these possible aspect span candidates.
  3. Use a SetFit model to classify the filtered aspect span candidates.

Model Details

Model Description

Model Sources

Model Labels

Label Examples
aspect
  • 'light weight:this computer is so light weight and easy to carry.'
  • 'carry:this computer is so light weight and easy to carry.'
  • 'lightweight:very lightweight.'
no aspect
  • 'computer:this computer is so light weight and easy to carry.'
  • "premium:The build quality feels premium but it's surprisingly heavy for daily commuting."
  • "commuting:The build quality feels premium but it's surprisingly heavy for daily commuting."

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 AbsaModel

# Download from the ๐Ÿค— Hub
model = AbsaModel.from_pretrained(
    "najwaa/absa-laptops-aspect-p2",
    "setfit-absa-polarity",
)
# Run inference
preds = model("The food was great, but the venue is just way too busy.")

Training Details

Training Set Metrics

Training set Min Median Max
Word count 2 18.3046 52
Label Training Sample Count
no aspect 341
aspect 263

Training Hyperparameters

  • batch_size: (32, 32)
  • num_epochs: (5, 5)
  • 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: True
  • warmup_proportion: 0.1
  • l2_weight: 0.01
  • seed: 42
  • eval_max_steps: -1
  • load_best_model_at_end: True

Training Results

Epoch Step Training Loss Validation Loss
0.0002 1 0.2288 -
0.0017 10 - 0.3073
0.0034 20 - 0.3065
0.0052 30 - 0.3052
0.0069 40 - 0.3034
0.0086 50 0.3393 0.3011
0.0103 60 - 0.2984
0.0120 70 - 0.2954
0.0138 80 - 0.2923
0.0155 90 - 0.2888
0.0172 100 0.3016 0.2855
0.0189 110 - 0.2821
0.0206 120 - 0.2786
0.0224 130 - 0.2754
0.0241 140 - 0.2722
0.0258 150 0.2875 0.2684
0.0275 160 - 0.2653
0.0292 170 - 0.2629
0.0310 180 - 0.2611
0.0327 190 - 0.2597
0.0344 200 0.272 0.2588
0.0361 210 - 0.2585
0.0378 220 - 0.2584
0.0396 230 - 0.2584
0.0413 240 - 0.2584
0.0430 250 0.2652 0.2585
0.0447 260 - 0.2581
0.0464 270 - 0.2580
0.0482 280 - 0.2580
0.0499 290 - 0.2580
0.0516 300 0.2635 0.2578
0.0533 310 - 0.2578
0.0550 320 - 0.2575
0.0567 330 - 0.2572
0.0585 340 - 0.2573
0.0602 350 0.2608 0.2572
0.0619 360 - 0.2576
0.0636 370 - 0.2576
0.0653 380 - 0.2579

Framework Versions

  • Python: 3.11.12
  • SetFit: 1.1.2
  • Sentence Transformers: 4.1.0
  • spaCy: 3.7.5
  • Transformers: 4.51.3
  • PyTorch: 2.6.0+cu124
  • Datasets: 3.6.0
  • Tokenizers: 0.21.1

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}
}
Downloads last month
21
Safetensors
Model size
22.7M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for najwaa/absa-laptops-aspect-p2

Finetuned
(439)
this model