Using raw digit logits from llama.cpp as a fast classifier without grammar constraints

rhinodevil · reddit · 2026-09-19

A developer shares a lightweight classification trick implemented in mtllm, built on llama.cpp: instead of using the grammar feature, prompt a small LLM (9B or smaller) with a numbered multiple-choice question and stop inference right after the first real token is generated.

The author notes this also lets you force an LLM to answer any multiple-choice question. Full implementation details are in the linked source code.

Original post →

More from coding & agent

coding & agent channel →