glm53f wrote the following response and simplified the actual implementation into a cleaner/shorter answer. The way it’s built supports endpoints /system-one/ask and /system-one/batch for one v multiple requests in the payload. The morn started with me pulling in a few YT videos about Jev because I had no idea what it was. By the afternoon my API supported this approach. Still have yet to use it for anything outside of testing. Wanted to be clear about that.
Yes — it’s genuinely small. The whole readout is one prompt render plus one chat-completions call with the assistant turn stopped at the right token. Here’s the core, cleaned out of my stack’s plumbing:
import math
import requests
BASE_URL = "http://localhost:8000/v1" # stock vLLM OpenAI server
PREFILL = "Answer: (" # the readout slot — see note below
def decide(state: str, question: str, options: list[str], model: str):
tokens = [chr(ord("A") + i) for i in range(len(options))] # A, B, C, ...
rendered = " ".join(f"({t}) {o}" for t, o in zip(tokens, options))
user = f"State: {state}\nQuestion: {question}\nOptions: {rendered}"
resp = requests.post(f"{BASE_URL}/chat/completions", json={
"model": model,
"messages": [
{"role": "user", "content": user},
{"role": "assistant", "content": PREFILL},
],
"continue_final_message": True, # vLLM extras: extend the assistant turn...
"add_generation_prompt": False, # ...instead of opening a new one
"max_tokens": 1, "temperature": 0,
"logprobs": True, "top_logprobs": 15,
}).json()
top = resp["choices"][0]["logprobs"]["content"][0]["top_logprobs"]
probs = {e["token"]: math.exp(e["logprob"]) for e in top}
mass = {t: probs.get(t, 0.0) for t in tokens}
total = sum(mass.values()) # option_mass: did the model accept the frame?
if not total:
return None, {}, 0.0
dist = {o: mass[t] / total for t, o in zip(tokens, options)}
return max(dist, key=dist.get), dist, total
Two flags that are the difference between working and not:
- The two vLLM extras are what make the prefill trick possible. With the default
add_generation_prompt=True the model ignores your assistant message and regenerates the turn.
- Option tokens must be single tokens: letters A–O for choices, digits 0–9 for scores (that’s what caps a rubric at ten levels).
top_logprobs=15 is what bounds cardinality — raise it if your server allows.
Example against one state — three question types, live output:
state = "Customer says they were charged twice for one order and wants the duplicate refunded."
decide(state, "Which team should handle this?",
["billing", "technical", "sales", "other"], model)
# ('billing', {'billing': 0.9982, 'technical': 0.0013, 'sales': 0.0002, 'other': 0.0003}, 0.9999)
decide(state, "How time-sensitive is this request?",
["not urgent", "low", "elevated", "urgent"], model)
# ('elevated', {'not urgent': 0.0048, 'low': 0.0585, 'elevated': 0.5551, 'urgent': 0.3815}, 0.9999)
decide(state, "Is a refund being requested?", ["yes", "no"], model)
# ('yes', {'yes': 0.9991, 'no': 0.0009}, 1.0)
Return tuple is (answer, distribution, option_mass). Note the urgency call: “elevated 0.56 / urgent 0.38” is graded information the argmax flattens — that’s why the distribution is the thing to consume, not the argmax. Nothing is sampled anywhere; everything above is read straight off the first token.
The prefill is model-dependent, and it’s worth deriving rather than guessing: chat models want to open sentences (The at 95% with no prefill) or decorate answers (** at 72% after a plain "Answer: "). Three probes: no prefill → look at the top tokens; "Answer: " → the dominant format token is the model’s preferred next step; append that token and re-probe until the option tokens hold ≥ 0.9 of the mass. Takes about two minutes per model.
On the confidence metric from your post above: I don’t emit a scalar confidence at all, so I never had to pick between max-prob and the (n·max−1)/(n−1) rescale — for a fixed option set that formula is an affine remap of max, so it can’t change any ordering or threshold decision. What I report instead:
- the distribution, normalized over the option tokens, and
option_mass — the share of the raw first-token distribution sitting on option tokens. That’s the number that actually matters here: low mass means the model is fighting the slot, and the readout is unreliable no matter which option is argmax. Below a threshold I fall back to a normal generation call.
Also worth being explicit: untrained, the distributions rank correctly but the absolute values are the model’s raw opinion. If a workload ever needs calibrated thresholds, one fitted temperature is the lightest fix — a training run is overkill for a scalar.
On speed vs decoding JSON: the readout costs one prefill pass, so the speedup is roughly “the number of tokens you didn’t decode” — every decoded token is another full forward pass. Concretely, a 127-token state prefills in ~55 ms on my box; end-to-end through my API proxy it averages ~390 ms, most of that being per-call overhead rather than model time; and fanning out N questions against one state costs about one prefill total because the state prefix rides vLLM’s prefix cache. I haven’t run a clean same-engine A/B against JSON decoding, but the arithmetic is the token count of the JSON answer.
On your fine-tuning idea: plausible, but my JevBench numbers (73.9% on the hard tier, untrained, vs 74.1% for the RLCD-trained reference) suggest the headroom is in calibration rather than knowledge. And if you want a maintained starting point, fidecastro’s jevify already packages this exact pattern.