Midterms 2026See who we think should earn your vote, based on our standardsThe guide →
WRITTEN IN PLAIN AMERICAN ENGLISH.
CLAY TRIBUNE.
Advertisement

Single-Function Wrapper Turns Webcam Frames Into Human-Readable Scene Judgments Using LLM Logprobs

A Python wrapper forces an LLM to pick a single letter from a list of options, judging webcam scenes into readable judgments.

By mitch·5 min read
A laptop displays a Python script output with human-readable judgments about a webcam scene.

A single Python script is turning webcam frames into a stream of human-readable judgments about what the scene contains, using a clever trick of forcing an LLM to pick a single letter from a list of options. The trick comes from a project called Jev and its spinoffs, and it works for both text and images.

The technique involves writing a prompt that asks an LLM to choose the best answer from a fixed set of options, then adding a few JSON request parameters to a compatible Chat Completions call. The LLM API returns the letter of the chosen answer along with the model’s log probabilities for other possible tokens. Repeat for each question, and you get a fast, repeatable way to score visual content without building a custom vision pipeline.

The Prompt Trick

The core idea is simple. You write a prompt like this:

Advertisement

State: My order arrived broken and I want a refund. Question: Which team should handle this? [A] billing [B] shipping [C] returns Answer with the letter of the best option only.

Then you add a few request parameters:

json
{
"max_completion_tokens": 1,
"logprobs": true,
"top_logprobs": 20
}

Forcing the model to generate only one token avoids a lengthy answer and is super quick. Processing the input still costs time, though. A shared state prefix can be KV-cached if the backend supports it.

Vision Models Too

The trick extends to vision models. Jev’s documented request format currently describes only text/JSON state, but the author added an attachments field for images in their local experiments. The example captures webcam frames, sends base64 JPEGs, and prints a table showing whether a person is visible, whether the scene is indoors or outdoors, and how bright it is.

On a Gemma 4 12B running on an RTX 3090, the setup gets around 1 frame per second, with three questions per frame. Against OpenAI’s gpt-6-luna, the rate drops to around 0.2 FPS. That slower speed is likely because the setup makes no effort to avoid the cost of a separate connection through the OpenAI system per question per frame.

Specialized computer vision models are surely more efficient, but the author likes the flexibility of changing a condition by describing it in plain text.

The Standalone Script

The full script is a standalone Python example. It uses OpenCV just for convenient access to the webcam, not for any actual computer vision. The dependencies are simple: opencv-python, plus standard libraries like argparse, base64, and urllib.

The data structure is a JSON blob with a state, attachments, and questions section. The attachments field holds image file paths or base64 data URLs. The script loads them once for all questions, guessing MIME types and raising a ValueError on unsupported formats.

“Provide 2 to 20 criteria per question.”

The questions section maps each query to a type: choice, noul, or score. Choices are lettered options like [A] billing [B] shipping [C] returns. Booleans and ordinal levels are represented as lettered options too, with a range of 2 to 20 criteria allowed per question.

Sending the Requests

The script sends requests to two endpoints depending on the provider. For OpenAI, the endpoint is /responses and the content includes both text and image inputs. The request body sets top_p=1 to avoid pruning alternatives.

For llama.cpp, the endpoint is /chat/completions, and the content is text only. The body asks for a single completion token with temperature=0 and logprobs=true.

How It Works

The script handles image attachments by encoding them as base64 strings and attaching them to the request payload. The JSON structure includes the attachments field, which the author added to extend Jev’s documented request format. The MIME guessing happens in the script itself, where the author raises a ValueError on unsupported image file types.

The prompt construction is consistent across both text and image questions. Each question is framed as a lettered list of options, and the model is forced to respond with a single letter representing its choice. The log probabilities returned with that letter show the confidence of the model’s selection.

Performance Numbers

The author reports around 1 frame per second on a Gemma 4 12B with an RTX 3090, with three questions per frame. Against OpenAI’s gpt-6-luna, the rate drops to around 0.2 FPS. The difference likely comes from the separate connection required for each question per frame through the OpenAI system.

Specialized computer vision models are surely more efficient, but the author’s focus remains on flexibility: changing a condition by describing it in plain text.

What It Shows

The script is a proof of concept, not a production-ready tool. It works across providers, and the author extended Jev’s request format with a custom field, loaded images from paths or URLs, and wrapped the whole thing in a script that anyone can run.

The performance numbers matter. One frame per second on a powerful setup is reasonable for preview work, while the OpenAI rate of 0.2 FPS shows the cost of round-tripping through a public API. The comparison to specialized models suggests room for improvement, but the author’s focus on flexibility over efficiency is clear.

The trick is not new to everyone. OpenAI’s logprobs cookbook documents the approach, and similar self-hostable projects like OpenJev and SemIf have been building on it. But the author found it new.

The core idea is sound, and the code is open for anyone who wants to try it. The author’s enthusiasm is contagious. They found a trick they had not seen before, built a script around it, and published it for others to use. That is the hacker spirit in action.

Source material: “A single function Jev-like wrapper for LLMs, including vision models,” allanrbo.blogspot.com.

The Notebook

Get the Notebook.

The day's best stories and every fresh verdict, in plain English, in your inbox by seven. One email a day, no more.

We send one note to confirm. Every issue has a one-click way out.

Advertisement

Leave a Reply

Your email address will not be published. Required fields are marked *

As an Amazon Associate, Clay Tribune earns from qualifying purchases.