Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 9 min read Deep dive mediumAdept

SetFitABSA: Few-Shot Aspect Based Sentiment Analysis using SetFit

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.

Assumes: sentence embeddingstext classification basicsHugging Face datasets

Related posts

  • SetFit: Efficient Few-Shot Learning Without Prompts

    Hugging Face mediumAdept

    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. With 8 examples per class it matches RoBERTa Large fine-tuned on 3k examples on Customer Reviews, beats GPT-3 and PET on the RAFT benchmark with a 355M-parameter model, and rivals T-Few 3B while being 27x smaller. Training takes about 30 seconds on a V100 ($0.025) versus 11 minutes on an A100 for T-Few, and the setfit library trains a model in a few lines of Python; swapping in a multilingual checkpoint extends it to other languages.

  • Few-shot learning in practice: GPT-Neo and the 🤗 Accelerated Inference API

    Hugging Face mediumAdept

    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. GPT-Neo 2.7B, about 60x smaller than GPT-3, generalizes poorly zero-shot but works well with 3-4 examples. Generation parameters such as end sequence, max new tokens and temperature strongly affect whether a task succeeds, and a Python snippet shows how to call the model through the Hugging Face Accelerated Inference API. Few-shot predictions also inherit pretraining biases, as when a sentiment prompt labels "I'm a disabled happy person" negative. The recommended safeguards are transparency, opt-out, user feedback and override, and human review of automated decisions.

  • Decision Models in Hugging Face

    Hugging Face mediumAdept

    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. Three primitives cover most cases: choice (softmax over options), score (expected value over an ordered scale), and noul (a Bernoulli probability for yes/no). Choice and score also report a confidence value that normalizes the top probability against a uniform distribution. The post compares the approach with fixed-label and zero-shot NLI classification and shows usage through a new transformers "decision" pipeline intended to give these models a common interface.

  • How Hugging Face Accelerated Development of Witty Works Writing Assistant

    Hugging Face easyNovice

    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. Labeled data needs dropped from 100-200 to 15-20 sentences per word, and the model reached 0.92 accuracy. It was deployed on Azure without further optimization because latency was already acceptable.

  • Investing in Performance: Fine-tune small models with LLM insights - a CFM case study

    Hugging Face mediumAdept

    Capital Fund Management built a financial named-entity recognition pipeline that extracts company names from Benzinga news headlines in the FNSPID dataset. Llama 3.1-70B, served on Hugging Face Inference Endpoints, pre-labels the headlines using a structured few-shot prompt and JSON-schema guided output, and humans then review those labels in Argilla. Fine-tuning compact models such as GLiNER and SpanMarker on the curated labels raises F1 to 93.4% and 90.1%. That approaches the 95% zero-shot F1 of Llama 3.1-70B at up to 80x lower inference cost. The walkthrough includes endpoint setup, prompt design, async batched requests with AsyncInferenceClient, and a comparison against weak supervision.

The quest for software engineering knowledge.

Look:
Layout: