---
title: "SetFitABSA: Few-Shot Aspect Based Sentiment Analysis using SetFit"
description: "SetFitABSA performs few-shot aspect-based sentiment analysis in three stages: spaCy extracts noun and noun-compound aspect candidates, one SetFit model classifies each candidate as aspect or non-aspect, and a second SetFit model assigns a sentiment polarity to each aspect."
url: "https://swe.quest/articles/setfitabsa-few-shot-aspect-based-sentiment-analysis-using-setfit-1531f1fb3bd2dc96"
canonical: "https://huggingface.co/blog/setfit-absa"
source: "Hugging Face"
published: "2023-12-06"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 9
tags: ["machine-learning","model-training","python"]
---

# SetFitABSA: Few-Shot Aspect Based Sentiment Analysis using SetFit

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2023-12-06, 9 min read, Deep dive. Original: [https://huggingface.co/blog/setfit-absa](https://huggingface.co/blog/setfit-absa)

## Summary

SetFitABSA performs few-shot aspect-based sentiment analysis in three stages: spaCy extracts noun and noun-compound aspect candidates, one SetFit model classifies each candidate as aspect or non-aspect, and a second SetFit model assigns a sentiment polarity to each aspect. Both classifiers turn token-level labeling into sentence classification by prefixing the candidate to the full sentence ("aspect\_candidate:sentence"), so no prompts are needed. On SemEval-2014 Laptop and Restaurant data, the two 110M-parameter MPNet models beat fine-tuned T5 and GPT2 when training data is scarce and match or beat 7B Llama-2-chat with in-context learning. A full model trains in about 10 minutes on a free Colab T4 through the setfit library's AbsaTrainer and AbsaModel APIs.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Machine learning](https://swe.quest/tags/machine-learning.md) (AI & ML)
- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- sentence embeddings ([easy posts on RAG & retrieval](https://swe.quest/tags/rag.md?difficulty=easy))
- text classification basics
- Hugging Face datasets

## Keywords

SetFit, SetFitABSA, spaCy, SemEval-2014, Llama 2, Sentence Transformers, MPNet

## Related posts

- [SetFit: Efficient Few-Shot Learning Without Prompts](https://swe.quest/articles/setfit-efficient-few-shot-learning-without-prompts-aff1dcaa7c0b808d.md): Hugging Face · 2022-09-26 · Medium · 6 min read · Model training, Machine learning, Python
  SetFit is a prompt-free few-shot text classification framework that first fine-tunes a Sentence Transformer contrastively on in-class/out-of-class sentence pairs built from a handful of labeled examples, then trains a classifier head on the resulting embeddings.
- [Few-shot learning in practice: GPT-Neo and the 🤗 Accelerated Inference API](https://swe.quest/articles/few-shot-learning-in-practice-gpt-neo-and-the-accelerated-inference-api-08cde6019b028379.md): Hugging Face · 2021-06-03 · Medium · 6 min read · LLMs, Inference & serving, AI safety, Python
  Few-shot learning lets a large language model perform a new NLP task from a handful of examples supplied in the prompt (task description, examples, and a prompt to complete), avoiding the labeled data needed for fine-tuning.
- [Decision Models in Hugging Face](https://swe.quest/articles/decision-models-in-hugging-face-8e72d537e83c9634.md): Hugging Face · 2026-11-10 · Medium · 16 min read · LLMs, Machine learning, Inference & serving, Python
  Decision models take a state plus a set of typed questions with predefined answers and return structured decisions with probabilities instead of generating text, avoiding schema violations and autoregressive decoding overhead.
- [How Hugging Face Accelerated Development of Witty Works Writing Assistant](https://swe.quest/articles/how-hugging-face-accelerated-development-of-witty-works-writing-assistant-c724e5be1af64d53.md): Hugging Face · 2023-03-01 · Easy · 6 min read · Machine learning, Model training, LLMs
  Witty Works' inclusive-language writing assistant began with spaCy-based linguistic feature matching, which handled about 85% of its ~2,300-word vocabulary but failed on context-dependent words like "fossil" or "flexible." On Hugging Face experts' advice, the team switched from contextualized word embeddings to Sentence Transformers sentence embeddings and used SetFit few-shot fine-tuning, feeding mpnet-base-v2 embeddings into logistic regression and KNN classifiers.
- [Investing in Performance: Fine-tune small models with LLM insights - a CFM case study](https://swe.quest/articles/investing-in-performance-fine-tune-small-models-with-llm-insights-a-cfm-case-116aeecc59f2bbd4.md): Hugging Face · 2024-12-03 · Medium · 23 min read · Model training, LLMs, Inference & serving, Cost optimization, Python
  Capital Fund Management built a financial named-entity recognition pipeline that extracts company names from Benzinga news headlines in the FNSPID dataset.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
