Jev in 25 Lines of Python

Jev in 25 Lines of Python

用 25 行 Python 代码实现 Jev

Everyone and their mom is talking about Jev. Jev this, Jev that. Everyone on Twitter is all over Jev, how it’s the next frontier of large language models and the AI paradigm. We don’t really think so. So here’s Jev in 25 lines of Python. 现在每个人都在谈论 Jev。这个 Jev,那个 Jev。Twitter 上到处都在讨论 Jev,说它是大语言模型和 AI 范式的下一个前沿。我们并不这么认为。所以,这里是用 25 行 Python 代码实现的 Jev。

Load the model.

加载模型。

# /// script
# requires-python = ">=3.12"
# dependencies = ["huggingface-hub", "llama-cpp-python", "numpy"]
# ///

import numpy
from llama_cpp import Llama

# Really, you can use any GGUF model from https://huggingface.co/models?library=gguf
# 实际上,你可以使用来自 https://huggingface.co/models?library=gguf 的任何 GGUF 模型
model = Llama.from_pretrained(
    repo_id="Qwen/Qwen3-0.6B-GGUF",
    filename="Qwen3-0.6B-Q8_0.gguf",
    n_ctx=512,
    logits_all=True,
    verbose=False,
)

Load the prompt and define your choices.

加载提示词并定义选项。

labels = ["A", "B", "C"]
choices = ["Legitimate", "Spam", "Phishing"]
email = "Payroll asks for your password on a non-company sign-in page."

options = "\n".join(
    f"{label}. {choice}" for label, choice in zip(labels, choices, strict=True)
)

prompt = f"""<|im_start|>system
Choose one option.<|im_end|>
<|im_start|>user
Email: {email}\n\n{options}<|im_end|>
<|im_start|>assistant
<think>

</think>

"""

model.eval(tokens=model.tokenize(text=prompt.encode(), add_bos=False, special=True))

Massage the logits into probabilities.

将 Logits 转换为概率。

logits = model.scores[model.n_tokens - 1]
token_ids = [model.tokenize(text=label.encode(), add_bos=False)[0] for label in labels]
choice_logits = numpy.asarray([logits[token_id] for token_id in token_ids])

logprobs = choice_logits - numpy.logaddexp.reduce(choice_logits)
probabilities = numpy.exp(logprobs)

for name, scores in (
    ("Logits", choice_logits),
    ("Log probabilities", logprobs),
    ("Probabilities", probabilities),
):
    values = numpy.round(scores.astype(float), 3).tolist()
    print(f"{name}:", dict(zip(choices, values, strict=True)))

# Logits: {'Legitimate': 26.254, 'Spam': 27.262, 'Phishing': 29.614}
# Log probabilities: {'Legitimate': -3.482, 'Spam': -2.474, 'Phishing': -0.122}
# Probabilities: {'Legitimate': 0.031, 'Spam': 0.084, 'Phishing': 0.885}

There. That’s Jev. But no, you don’t understand Jev! Yeah, we know. We don’t call it a System One decision model. We didn’t call an API. We didn’t create a bunch of synthetic data. We didn’t train a model with Reinforcement Learning for Calibrated Decisions (RLCD) to calibrate the decisions and probabilities (even though they are not always correct). 好了,这就是 Jev。但你可能会说:“不,你不懂 Jev!”是的,我们知道。我们没有把它称为“系统一(System One)”决策模型。我们没有调用 API。我们没有创建大量的合成数据。我们也没有使用“校准决策强化学习(RLCD)”来训练模型以校准决策和概率(尽管它们并不总是正确的)。

But yes. This is Jev. It classifies: it gets a prompt with choices and outputs probabilities. It’s fast. It’s local. You don’t send your data anywhere else. And we like not sending your data anywhere else. Check out NobodyWho. 但没错,这就是 Jev。它进行分类:接收带有选项的提示词并输出概率。它速度快,且在本地运行。你不需要将数据发送到任何其他地方。我们喜欢这种不需要外传数据的方式。请关注 NobodyWho。

(note: this is a parody blog post, see these links for better/more complete open implementations of Jev: OpenJev, openjev-sglang, and OpenJev on DiffusionGemma.) (注:这是一篇讽刺性博文,请查看以下链接以获取更好、更完整的 Jev 开源实现:OpenJev, openjev-sglang, 以及 OpenJev on DiffusionGemma。)

Everything NobodyWho do is open-source, please leave a star on Github to support us ❤️ NobodyWho 的所有项目都是开源的,请在 Github 上点个星支持我们 ❤️

Published Sep 22, 2026 by Duarte O.Carmo Technical 发布于 2026 年 9 月 22 日,作者:Duarte O.Carmo Technical