Skip to content
HomeNewsDigestsConceptsGuidesToolbox
AboutSubscribeUA
Subscribe

AI Today Brief

The daily AI-engineering brief. Built in public. EN · UA.

XTelegramLinkedInYouTubeRSS

Follow AI Today Brief on LinkedIn for daily AI-engineering updates and the weekly “5 shifts that changed how developers work” PDF.

Explore

NewsDigestsConceptsGuides

Company

SubscribeAdvertiseAbout

Legal

Editorial policyAI disclosurePrivacyTerms

© 2026 AI Today Brief. All rights reserved.

  1. Home/
  2. News/
  3. Token & cost optimization/
  4. Extract LLM Logprobs to Run Single-Token Vision and Text Classification
Token & cost optimization

Extract LLM Logprobs to Run Single-Token Vision and Text Classification

Constraining multimodal language models to return a single token while capturing alternative log probabilities enables fast, non-hallucinating classification. Benchmarks show this technique achieves 1.0 FPS across three visual questions using Gemma 4 12B locally on an RTX 3090.

September 26, 2026· 7 min read
OKCurated by Oleksandr Kuzmenko, AI Product Engineer·Updated September 26, 2026·Sources cited on every story
AI-assisted · editor-reviewed·How we use AI
Extract LLM Logprobs to Run Single-Token Vision and Text Classification

Impact: Medium

Why it matters

You can eliminate output generation latency and avoid JSON extraction failures by turning any vision or text LLM into a calibrated multi-choice classifier.

TL;DR

  • 01Force vision and text LLMs to answer multiple-choice questions with a single character to eliminate output token decoding delay.
  • 02Extract raw log probabilities from Chat Completions or Responses APIs to obtain true probability distributions.
  • 03Reuse KV cache prefixes across multiple single-token questions evaluating the same image or document state.

Key facts

~0.2 FPSOpenAI gpt-6-luna throughput
1 tokenOutput tokens per answer
Local throughput (RTX 3090)
~1.0 FPS (3 questions/frame)
OpenAI gpt-6-luna throughput
~0.2 FPS
Model weights size
~7 GB (Gemma 4 12B QAT) + 175 MB mmproj
Output tokens per answer
1 token

Bypassing Text Generation Overhead

Traditional LLM classification pipelines force models to produce complete sentences or structured JSON schemas, exposing pipelines to formatting drift, syntax errors, and generation latency. By prompting the model to answer multiple-choice questions strictly with a single option letter (A, B, C, etc.) and inspecting token probabilities, developers can compute normalized confidence scores across all options in a single step.

# Requesting top logprobs for single-token selection
prompt = f"State:\n{state}\n\nQuestion: {question}\nOptions:\n{options_block}\nAnswer with the letter of the best option only."

Local Gemma 4 12B Benchmarks

The pattern was tested on live webcam frames using a local setup with llama.cpp and Gemma 4 12B QAT (~7 GB model weights plus ~175 MB multimodal projector) on an Nvidia RTX 3090:

  • Local Throughput: Achieved ~1.0 frames per second while evaluating three distinct queries per frame (detecting visible persons, scene setting, and relative brightness).
  • Cloud Comparison: The same pipeline querying OpenAI gpt-6-luna ran at ~0.2 FPS, largely bottlenecked by HTTP request round-trips per question.
  • Prefix Caching: Repeating queries over the same image benefits from KV-cache re-use, ensuring that processing input tokens dominates rather than output token generation.

API Differences and Normalization

Implementing this across providers requires handling subtle API differences. Local llama.cpp endpoints expose logprobs via the Chat Completions endpoint (top_logprobs), whereas OpenAI's API requires the Responses endpoint with include: ["message.output_text.logprobs"]. The returned log probabilities are normalized through a softmax-style exponentiation to calculate calibrated probabilities.

Try it in 2 minutes

# Fetch Gemma 4 12B QAT model and multimodal projector
curl -fL -o gemma-4-12b-it-qat-q4_0.gguf https://huggingface.co/google/gemma-4-12B-it-qat-q4_0-gguf/resolve/main/gemma-4-12b-it-qat-q4_0.gguf
curl -fL -o mmproj-gemma-4-12b-it-qat-q4_0.gguf https://huggingface.co/google/gemma-4-12B-it-qat-q4_0-gguf/resolve/main/mmproj-gemma-4-12b-it-qat-q4_0.gguf
llama-server -m gemma-4-12b-it-qat-q4_0.gguf --mmproj mmproj-gemma-4-12b-it-qat-q4_0.gguf --port 8060

bash

✓ When to use

  • Zero-shot image and document classification where categories change frequently in production.
  • Edge or local deployments needing strict latency caps and zero hallucination risk on categorical flags.

✕ When NOT to use

  • Open-ended conversational responses or complex multi-step reasoning generation.
  • High-framerate video pipelines requiring >30 FPS, where lightweight dedicated CNNs/YOLO models are mandatory.

What to do today

  • →Download Gemma 4 12B QAT GGUF and run llama-server with logprobs enabled.
  • →Replace multi-line JSON classification prompts with single-letter multiple-choice questions.
  • →Implement a logprob normalization function using softmax exponentiation to calculate true confidence percentages.

What the community says

  • “providers could subsidize the cost of cached input tokens to virtually zero if they would allow for a more flexible API... Most of the cost is the infrastructure around keeping KV caches”

    — bicsi on Hacker News

  • “I've created a Jev wrapper so that it can work via any OpenAI-compatible endpoints”

    — czl_my on Hacker News

#llama.cpp#Gemma 4#OpenAI#OpenJev#SemIf

Sources

  • A Jev-like wrapper for LLMs, including vision models
  • Jevper: Jev wrapper for OpenAI-compatible endpoints
ShareShare on XShare on LinkedIn
← Previous storyEnforce Spend Controls for Paid Model Context Protocol Tools via HTTP x402Next story →Inverting the AI Coding Loop to Prevent Burnout and Skill Loss

Related stories

  • Token & cost optimizationNVIDIA Cuts Confidential Computing Overhead in TensorRT-LLM Below Five Percent
  • Token & cost optimizationFast Jev Compaction Replaces Lossy Summaries in Claude Code
  • Token & cost optimizationAnthropic Open-Sources Claude-Generated Custom GPU Kernels for 4x Faster Inference

Email digest

Get the morning AI brief

One email a day — the stories that matter for engineers, founders and tech leads. Human-edited, with links to primary sources.

  • ✓120+ sources scanned daily
  • ✓Edited by a human
  • ✓1 email per day
  • ✓EN + UA

By subscribing you agree to the privacy policy.