Community Hacker News (LLM)

LLM Classification Is Feature Engineering

LLM classifierscalibrationfeature engineeringlogistic regression

The post starts from a familiar frustration: LLMs used as classifiers — prompts applied to a context that return a label — are painful to work with, precisely because they often perform fairly well. The author argues these shortcomings aren't the LLM's fault, since it isn't designed as a classifier and has no mechanism for plausibly doing some of what's asked; the real issue is thinking about the problem incorrectly.

The desiderata for a classifier expose the gaps. On calibration and threshold control, LLM verdicts are typically hard labels; token log probabilities exist but there's no reason to believe they are well-calibrated, and asking the LLM for its confidence is no better, which makes it hard to trade off precision and recall in a principled way. On incorporating all available information, LLMs handle unstructured data well but we often also have structured data: it can be pasted into the prompt, yet the LLM doesn't really need to use it, and even for prose parts of the prompt it's unclear whether the LLM actually used them — likely losing signal. The LLM also carries baked-in priors that may poorly fit the target distribution, e.g. it won't know whether the population has a rare positive class or an enriched one, and supplying that context means modifying the prompt per population with no guarantee it will be incorporated into the judgment. On interpretability, a prose prompt is superficially transparent, but it isn't clear what is happening inside the LLM or which parts of the prompt are being followed correctly, or at all.

The proposed fix is a proper framework that harnesses the LLM's power while keeping the convenience of stock ML algorithms. A taste of it: wrap the LLM verdict in a simple logistic regression, p(y = 1 | x) = σ(α + β · LLM(x)). In the special case where β → ∞ this essentially recovers the plain LLM classifier, but that is a dumb parameter-selection policy; instead, estimate the parameters from training data, which collapses into two cases and yields the empirical estimates p(y = k | LLM(x) = 1) = (Σᵢ I(yᵢ = k and LLM(xᵢ) = 1)) / (Σᵢ I(LLM(xᵢ) = 1)).

Revisiting the desiderata under this framing: because the LLM prediction is just a feature, the two resulting predictions land at the empirical proportions and are therefore calibrated in expectation. As more features are added (which the post says it will cover next), the approach will naturally produce more unique outputs — the excerpt ends mid-sentence at this point.

Read original →

← Back to home