CoolFace
Modelpublic

najwaa/absa-combined-p2-polarity

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes3downloads
Model Card

SetFit Polarity Model with sentence-transformers/all-mpnet-base-v2

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

The model has been trained using an efficient few-shot learning technique that involves:

  1. 1.Fine-tuning a Sentence Transformer with contrastive learning.
  2. 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. 1.Use a spaCy model to select possible aspect span candidates.
  2. 2.Use a SetFit model to filter these possible aspect span candidates.
  3. 3.Use this SetFit model to classify the filtered aspect span candidates.

Model Details

Model Description

Model Sources

Model Labels

LabelExamples
positive<ul><li>'computer is so light weight and easy to:this computer is so light weight and easy to carry.'</li><li>'and easy to carry.:this computer is so light weight and easy to carry.'</li><li>'very lightweight.:very lightweight.'</li></ul>
negative<ul><li>"it's surprisingly heavy for daily commuting:The build quality feels premium but it's surprisingly heavy for daily commuting."</li><li>', though the keyboard feels cramped during:Fantastic display clarity and vibrant colors make this perfect for photo editing, though the keyboard feels cramped during long typing sessions.'</li><li>', but the screen brightness is disappointing in:The laptop boots up incredibly fast thanks to the SSD, but the screen brightness is disappointing in outdoor conditions.'</li></ul>
negative<ul><li>'Screen could be better:Screen could be better'</li><li>'not worth the price value.:definitely not worth the price value.'</li></ul>

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 AbsaModel

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

<!--

Downstream Use

List how someone could finetune this model on their own dataset. -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Set Metrics

Training setMinMedianMax
Word count321.183357
LabelTraining Sample Count
negative215
negative2
positive263

Training Hyperparameters

  • —batch_size: (32, 32)
  • —num_epochs: (5, 5)
  • —max_steps: -1
  • —sampling_strategy: oversampling
  • —bodylearningrate: (2e-05, 1e-05)
  • —headlearningrate: 0.01
  • —loss: CosineSimilarityLoss
  • —distancemetric: cosinedistance
  • —margin: 0.25
  • —endtoend: False
  • —use_amp: True
  • —warmup_proportion: 0.1
  • —l2_weight: 0.01
  • —seed: 42
  • —evalmaxsteps: -1
  • —loadbestmodelatend: True

Training Results

EpochStepTraining LossValidation Loss
0.000310.3951-
0.002810-0.3058
0.005520-0.3027
0.008330-0.2976
0.011040-0.2907
0.0138500.31250.2827
0.016660-0.2732
0.019370-0.2622
0.022180-0.2505
0.024890-0.2405
0.02761000.27670.2297
0.0304110-0.2195
0.0331120-0.2085
0.0359130-0.1961
0.0387140-0.1811
0.04141500.22170.1629
0.0442160-0.1405
0.0469170-0.1143
0.0497180-0.0882
0.0525190-0.0641
0.05522000.14680.0483
0.0580210-0.0385
0.0607220-0.0352
0.0635230-0.0328
0.0663240-0.0283
0.06902500.06160.0248
0.0718260-0.0237
0.0745270-0.0208
0.0773280-0.0209
0.0801290-0.0174
0.08283000.02980.0195
0.0856310-0.0196
0.0883320-0.0166
0.0911330-0.0199
0.0939340-0.0200
0.09663500.0170.0184
0.0994360-0.0146
0.1022370-0.0220
0.1049380-0.0212
0.1077390-0.0174
0.11044000.01130.0237
0.1132410-0.0220

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

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

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->