Decision Models in Hugging Face
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.
Related posts
- Introducing Decision Transformers on Hugging Face 🤗
Hugging Face mediumAdeptDecision Transformer, an offline reinforcement learning method that recasts RL as return-conditioned sequence modeling, is now part of the 🤗 transformers library, with nine pretrained checkpoints for Gym continuous-control tasks (Hopper, Walker2D, HalfCheetah). Instead of fitting a value function, a GPT-2 model takes the last K timesteps of return-to-go, state and action tokens and autoregressively predicts actions that reach a desired return. Code covers loading the model, padding and masking a 20-step context window, normalizing states with the mean and standard deviation from each model card, and running an evaluation loop. Setting the target return directly controls how well the resulting policy performs.
- Train your first Decision Transformer
Hugging Face hardMasterDecision Transformers recast reinforcement learning as conditional sequence modeling: a GPT-2 model takes the last K timesteps of return-to-go, state and action tokens and autoregressively predicts actions that achieve a desired return. This walkthrough trains an offline Decision Transformer from scratch on the HalfCheetah expert dataset from the Hugging Face hub. A custom data collator normalizes states, computes returns-to-go, scales rewards by 1000, pads sequences and samples trajectories by length. A subclassed model adds an MSE action loss so the standard transformers Trainer can be used, and training takes about 40 minutes in Colab versus roughly 3 hours in the original paper.
- Introducing AnySpeechRecognizer and AnyDecisionModel: Open Models for Speech and Decisions on Apple Platforms
Hugging Face mediumAdeptAnySpeechRecognizer mirrors Apple's SpeechAnalyzer API but lets apps swap in other engines (NVIDIA Parakeet v3/Ultra/Unified and Alibaba Qwen3-ASR on Core ML) and adds Sortformer-based speaker diarization for up to four speakers. On an M4 Max, Parakeet variants reached 1.4–2.8% WER on LibriSpeech files versus 2.1–4.0% for Apple's transcriber, transcribing an hour of audio in 20–40 seconds with about 100 MB of memory. AnyDecisionModel answers yes/no, multiple-choice and rating questions as typed Swift results with probabilities, read from one-token label probabilities or trained decision heads like Cloudflare's Clef. It supports MLX, Core AI, llama.cpp, Jev and Ollama backends, with calibration, rotation debiasing and entropy-based confidence.
- Few-shot learning in practice: GPT-Neo and the 🤗 Accelerated Inference API
Hugging Face mediumAdeptFew-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.
- SetFitABSA: Few-Shot Aspect Based Sentiment Analysis using SetFit
Hugging Face mediumAdeptSetFitABSA 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.