Turning LLM hard classifiers into tunable soft classifiers with logprobs
JnBrymn · x · 2026-09-24
Inspired by the classification chapter of Hands-On Large Language Models by Jay Alammar and Maarten Grootendorst, the author extends their "hard" LLM sentiment classifier (which just outputs 'positive' or 'negative') into a "soft" one.
Key idea: keep the prompt forcing a single-word answer, then read the logprobs of the candidate tokens from the API response to recover a probability for each class.
Why it matters:
- With real probabilities you can set a classification threshold and tune it against a labeled training set, aligning precision/recall with your needs instead of accepting the model's binary verdict.
- No fine-tuning required — just a prompt plus a logprob lookup.
The post includes a reusable getsentiment code sample and a 10-minute video walkthrough.
More from coding & agent
- Building AI video workflows with Codex driving Dreamina CLI: node-level iteration without regenerating — HeyNayeem · 2026-09-24
- M5 Ultra 96GB local inference: 3,200 tok/s aggregate prefill over 112M tokens with custom MLX server — Every-Fortune-3151 · 2026-09-24
- Alchemy author explains Infrastructure-as-Effects and why it beats SST/Terraform — samgoodwin89 · 2026-09-24
- VS Code Debug Visualizer extension lets you watch linked lists and QuickSort run in real time — adnan_hashmi · 2026-09-24
- Stripe Projects launches, letting AI agents assemble infrastructure via one CLI command — jeff_weinstein · 2026-09-24
- Electric Capital open-sources Quest, a privacy-aware AI harness used company-wide daily — gajesh · 2026-09-24